@actionexec/dashboards 0.16.2 → 0.18.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,960 +1,1103 @@
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
- const n = {};
8
- for (const [a, l] of Object.entries(e))
9
- if (l.includes("|")) {
10
- const [s, c] = l.split("|");
11
- s && (n.f_date_start = s), c && (n.f_date_end = c);
1
+ import { jsxs as _, jsx as a, Fragment as V } from "react/jsx-runtime";
2
+ import { useState as T, useRef as R, useEffect as F, useCallback as x, useMemo as I, memo as Fe } from "react";
3
+ import { M as q, f as Oe, a as We, c as se, b as le, d as ze, e as ve, i as oe, g as D, p as De, h as ee, j as ye, k as we, l as U, m as He, r as Ve, D as ie, n as je, o as Ge, S as Ne, C as Ke, q as Ye, s as Se, t as Ue, u as Be, v as qe, G as Xe, w as ce, x as Qe, y as Ze, z as Je, A as et, B as tt } from "./ColorPaletteSelector-nBO_fbbj.js";
4
+ import { E as Hr } from "./ColorPaletteSelector-nBO_fbbj.js";
5
+ import { LineChart as rt, Line as nt, AreaChart as at, Area as st, BarChart as ke, Bar as X, CartesianGrid as Ce, XAxis as Re, YAxis as $e, Tooltip as Q, Legend as lt, Cell as de, PieChart as ot, Pie as it } from "recharts";
6
+ function H(e, t = {}) {
7
+ const r = {};
8
+ for (const [n, s] of Object.entries(e))
9
+ if (s.includes("|")) {
10
+ const [l, o] = s.split("|");
11
+ l && (r.f_date_start = l), o && (r.f_date_end = o);
12
12
  } else
13
- n[`f_${a}`] = l;
14
- for (const [a, l] of Object.entries(t))
15
- n[`v_${a}`] = String(l);
16
- return n;
13
+ r[`f_${n}`] = s;
14
+ for (const [n, s] of Object.entries(t))
15
+ r[`v_${n}`] = String(s);
16
+ return r;
17
17
  }
18
- function H(e) {
18
+ function j(e) {
19
19
  return Object.keys(e).sort().map((t) => `${t}=${e[t]}`).join("&");
20
20
  }
21
- function Se(e, t) {
22
- const n = Object.keys(e);
23
- return n.length !== Object.keys(t).length ? !1 : n.every((a) => e[a] === t[a]);
21
+ function xe(e, t) {
22
+ const r = Object.keys(e);
23
+ return r.length !== Object.keys(t).length ? !1 : r.every((n) => e[n] === t[n]);
24
24
  }
25
- function ke(e) {
25
+ function Te(e) {
26
26
  const t = {};
27
- for (const [n, a] of Object.entries(e))
28
- if (a && typeof a == "object" && "start" in a) {
29
- const l = a;
30
- t[n] = `${l.start || ""}|${l.end || ""}`;
31
- } else Array.isArray(a) ? t[n] = a.join(V) : typeof a == "string" && (t[n] = a);
27
+ for (const [r, n] of Object.entries(e))
28
+ if (n && typeof n == "object" && "start" in n) {
29
+ const s = n;
30
+ t[r] = `${s.start || ""}|${s.end || ""}`;
31
+ } else Array.isArray(n) ? t[r] = n.join(q) : typeof n == "string" && (t[r] = n);
32
32
  return t;
33
33
  }
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);
34
+ const ct = 300;
35
+ function dt(e) {
36
+ const [t, r] = T(null), [n, s] = T(null), [l, o] = T({}), [i, d] = T({}), [c, u] = T(null), [m, p] = T(!0), [f, h] = T(null), v = R(), k = R(!1), y = R(null), w = R(!1);
37
+ F(() => {
38
+ let b = !1;
39
+ return k.current = !1, y.current = null, w.current = !1, Oe(e).then((g) => {
40
+ b || r(g);
41
+ }).catch((g) => {
42
+ b || h(g.message);
43
43
  }), () => {
44
- _ = !0;
44
+ b = !0;
45
45
  };
46
- }, [e]), W(() => {
46
+ }, [e]), F(() => {
47
47
  if (!t) return;
48
48
  if (t.widgets.length === 0) {
49
- f(!1);
49
+ p(!1);
50
50
  return;
51
51
  }
52
- const _ = D(s, i), u = H(_);
53
- if (u === A.current) return;
54
- S.current && clearTimeout(S.current);
55
- const R = y.current ? tt : 0;
56
- return S.current = setTimeout(() => {
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
- })), v(null);
62
- }).catch((C) => v(C.message)).finally(() => f(!1));
63
- }, R), () => {
64
- S.current && clearTimeout(S.current);
52
+ const b = H(l, i), g = j(b);
53
+ if (g === y.current) return;
54
+ v.current && clearTimeout(v.current);
55
+ const N = w.current ? ct : 0;
56
+ return v.current = setTimeout(() => {
57
+ p(!0), We(e, b).then((A) => {
58
+ y.current = g, w.current = !0, s(A), !k.current && A.applied && (k.current = !0, o((M) => {
59
+ const S = { ...Te(A.applied), ...M };
60
+ return xe(S, M) ? M : (y.current = j(H(S, i)), S);
61
+ })), h(null);
62
+ }).catch((A) => h(A.message)).finally(() => p(!1));
63
+ }, N), () => {
64
+ v.current && clearTimeout(v.current);
65
65
  };
66
- }, [e, t, s, i]);
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
- () => o ?? (t == null ? void 0 : t.palette) ?? [],
75
- [o, t]
66
+ }, [e, t, l, i]);
67
+ const C = x((b, g) => {
68
+ o((N) => ({ ...N, [b]: g }));
69
+ }, []), $ = x((b, g) => {
70
+ d((N) => ({ ...N, [b]: g }));
71
+ }, []), P = x((b) => {
72
+ u(b);
73
+ }, []), E = I(
74
+ () => c ?? (t == null ? void 0 : t.palette) ?? [],
75
+ [c, t]
76
76
  );
77
77
  return {
78
78
  layout: t,
79
- renderData: a,
80
- loading: d,
81
- error: p,
82
- filters: s,
79
+ renderData: n,
80
+ loading: m,
81
+ error: f,
82
+ filters: l,
83
83
  variables: i,
84
- palette: x,
85
- setFilter: w,
86
- setVariable: N,
87
- setPalette: T
84
+ palette: E,
85
+ setFilter: C,
86
+ setVariable: $,
87
+ setPalette: P
88
88
  };
89
89
  }
90
- const nt = (e) => {
91
- var t, n;
92
- return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.inlineSize) ?? e.target.offsetWidth;
93
- }, at = (e) => {
94
- var t, n;
95
- return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.blockSize) ?? e.target.offsetHeight;
90
+ const ut = (e) => {
91
+ var t, r;
92
+ return ((r = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : r.inlineSize) ?? e.target.offsetWidth;
93
+ }, mt = (e) => {
94
+ var t, r;
95
+ return ((r = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : r.blockSize) ?? e.target.offsetHeight;
96
96
  };
97
- function lt(e, t, n) {
98
- return e === void 0 ? 0 : e === "auto" ? Me(t, n) : Math.max(0, e);
97
+ function ht(e, t, r) {
98
+ return e === void 0 ? 0 : e === "auto" ? ze(t, r) : Math.max(0, e);
99
99
  }
100
- function st(e) {
100
+ function ft(e) {
101
101
  let t = e.parentElement;
102
102
  for (; t && t !== document.body && t !== document.documentElement; ) {
103
- const { overflowY: n } = getComputedStyle(t);
104
- if (n !== "visible")
105
- return n === "hidden" || n === "clip" ? t : null;
103
+ const { overflowY: r } = getComputedStyle(t);
104
+ if (r !== "visible")
105
+ return r === "hidden" || r === "clip" ? t : null;
106
106
  t = t.parentElement;
107
107
  }
108
108
  return null;
109
109
  }
110
- function it(e) {
111
- const t = $(e);
110
+ function pt(e) {
111
+ const t = R(e);
112
112
  t.current = e;
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.`
113
+ const r = R(null), n = R(null), s = R(null), l = R(null), o = R(null), i = R(0), d = R(0), c = R(!1), u = R(!1), m = R(-1), [p, f] = T(!1), h = x((b) => {
114
+ const g = n.current;
115
+ if (u.current || t.current.silenceWarnings || !g) return;
116
+ const N = ft(g);
117
+ !N || N.clientHeight >= b.gridHeight || (u.current = !0, console.warn(
118
+ `[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(b.gridHeight)}px de altura, mas o ancestral com overflow oculto tem ${N.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
- }, []), S = E(() => {
120
+ }, []), v = x(() => {
121
121
  var L, O;
122
- if (!n.current) return;
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
- stacked: o.current
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
- }, []), A = E(() => {
142
- s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
143
- }, []), y = E(() => {
144
- s.current === null && (s.current = requestAnimationFrame(() => {
145
- s.current = null, k(), S();
122
+ if (!r.current) return;
123
+ const { columns: b, cellAspect: g } = t.current, N = i.current, A = le(N, b), M = {
124
+ containerWidth: N,
125
+ cellWidth: A,
126
+ cellHeight: se(A, g),
127
+ gridHeight: d.current,
128
+ stacked: c.current
129
+ }, S = o.current;
130
+ S && S.containerWidth === M.containerWidth && S.cellWidth === M.cellWidth && S.cellHeight === M.cellHeight && S.gridHeight === M.gridHeight && S.stacked === M.stacked || (o.current = M, (O = (L = t.current).onGeometryChange) == null || O.call(L, M), h(M));
131
+ }, [h]), k = x((b = !1) => {
132
+ const g = r.current;
133
+ if (!g) return;
134
+ const N = i.current;
135
+ if (!b && N === m.current) return;
136
+ m.current = N;
137
+ const { columns: A, cellAspect: M, stackBelow: S } = t.current, z = le(N, A);
138
+ g.style.setProperty("--dash-cell-h", `${se(z, M)}px`);
139
+ const L = ht(S, A, M), O = L > 0 && N > 0 && N < L;
140
+ O !== c.current && (c.current = O, f(O));
141
+ }, []), y = x(() => {
142
+ l.current !== null && (cancelAnimationFrame(l.current), l.current = null);
143
+ }, []), w = x(() => {
144
+ l.current === null && (l.current = requestAnimationFrame(() => {
145
+ l.current = null, k(), v();
146
146
  }));
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;
147
+ }, [k, v]), C = x((b) => {
148
+ for (const g of b)
149
+ g.target === r.current ? i.current = Math.round(ut(g)) : g.target === n.current && (d.current = mt(g));
150
+ w();
151
+ }, [w]), $ = x(() => s.current ? s.current : typeof ResizeObserver > "u" ? null : (s.current = new ResizeObserver(C), s.current), [C]), P = x((b) => {
152
+ const g = $();
153
+ r.current && (g == null || g.unobserve(r.current)), r.current = b, b && (g == null || g.observe(b), i.current = Math.round(b.getBoundingClientRect().width), k(!0), w());
154
+ }, [k, $, w]), E = x((b) => {
155
+ const g = $();
156
+ if (n.current && (g == null || g.unobserve(n.current)), n.current = b, !b) {
157
+ d.current = 0;
158
158
  return;
159
159
  }
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();
160
+ g == null || g.observe(b), d.current = b.getBoundingClientRect().height, w();
161
+ }, [$, w]);
162
+ return F(() => {
163
+ const b = $();
164
+ return r.current && (b == null || b.observe(r.current)), n.current && (b == null || b.observe(n.current)), () => {
165
+ var g;
166
+ (g = s.current) == null || g.disconnect(), s.current = null, y();
167
167
  };
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 };
168
+ }, [$, y]), F(() => {
169
+ r.current && (k(!0), w());
170
+ }, [e.columns, e.cellAspect, e.stackBelow, k, w]), { rootRef: P, gridRef: E, stacked: p };
171
171
  }
172
- const ot = {
172
+ const _t = {
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 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
- }
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
- t && /* @__PURE__ */ r("span", { className: "widget__title", children: t }),
184
- l,
185
- n ? /* @__PURE__ */ r(B, { kind: n, message: a }) : s
178
+ function te({ kind: e, message: t }) {
179
+ return /* @__PURE__ */ a("div", { className: `widget__state widget__state--${e}`, role: e === "error" ? "alert" : void 0, children: t || _t[e] });
180
+ }
181
+ function W({ name: e, title: t, state: r, stateMessage: n, toolbar: s, children: l }) {
182
+ return /* @__PURE__ */ _("div", { className: `widget widget-${e}`, children: [
183
+ t && /* @__PURE__ */ a("span", { className: "widget__title", children: t }),
184
+ s,
185
+ r ? /* @__PURE__ */ a(te, { kind: r, message: n }) : l
186
186
  ] });
187
187
  }
188
- const ct = { up: "↑", down: "↓" };
189
- function Re(e) {
188
+ const gt = { up: "↑", down: "↓" };
189
+ function Pe(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 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
- a,
194
+ function bt({ comparison: e, primary: t }) {
195
+ const r = e.sentiment ?? "neutral", n = gt[e.trend ?? ""] ?? "";
196
+ return /* @__PURE__ */ _("div", { className: `widget-kpi__trend widget-kpi__trend--${r}${t ? "" : " widget-kpi__trend--muted"}`, children: [
197
+ /* @__PURE__ */ _("span", { className: "widget-kpi__variance", children: [
198
+ n,
199
199
  " ",
200
200
  e.formatted
201
201
  ] }),
202
- e.label && /* @__PURE__ */ r("span", { className: "widget-kpi__trend-label", children: e.label })
202
+ e.label && /* @__PURE__ */ a("span", { className: "widget-kpi__trend-label", children: e.label })
203
203
  ] });
204
204
  }
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
- /* @__PURE__ */ r("span", { className: "widget-kpi__value", children: a }),
209
- l.map((s, c) => /* @__PURE__ */ r(dt, { comparison: s, primary: c === 0 }, s.id || c))
205
+ function vt({ data: e, label: t }) {
206
+ const r = t || String(e.label || ""), n = String(e.formatted || "-"), s = Pe(e.comparisons);
207
+ return /* @__PURE__ */ _(W, { name: "kpi", title: r, children: [
208
+ /* @__PURE__ */ a("span", { className: "widget-kpi__value", children: n }),
209
+ s.map((l, o) => /* @__PURE__ */ a(bt, { comparison: l, primary: o === 0 }, l.id || o))
210
210
  ] });
211
211
  }
212
- const mt = "var(--bg-elevated)", ht = [
212
+ const yt = "var(--bg-elevated)", wt = [
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 le(e, t, n, a) {
220
- if (a <= 0) return "";
221
- if (a >= 1)
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
- const l = a * Math.PI;
224
- return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e - n * Math.cos(l)} ${t - n * Math.sin(l)}`;
225
- }
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" })
219
+ function ue(e, t, r, n) {
220
+ if (n <= 0) return "";
221
+ if (n >= 1)
222
+ return `M ${e - r} ${t} A ${r} ${r} 0 0 1 ${e} ${t - r} A ${r} ${r} 0 0 1 ${e + r} ${t}`;
223
+ const s = n * Math.PI;
224
+ return `M ${e - r} ${t} A ${r} ${r} 0 0 1 ${e - r * Math.cos(s)} ${t - r * Math.sin(s)}`;
225
+ }
226
+ function Nt({ data: e, palette: t, label: r }) {
227
+ const n = r || String(e.label || ""), s = typeof e.ratio == "number" ? e.ratio : 0, l = typeof e.format == "string" ? e.format : void 0, o = String(e.value_formatted || ve(e.value, l)), i = String(e.formatted || "-"), d = Pe(e.comparisons), [c, ...u] = d, m = String((c == null ? void 0 : c.baseline_formatted) || "-"), p = (c == null ? void 0 : c.label) ?? null, f = s >= 1, h = Math.min(Math.max(s, 0), 1), v = wt.find(([P]) => s >= P), k = (v == null ? void 0 : v[1]) || t[0] || "var(--color-info)", y = 50, w = 50, C = 44, $ = 10;
228
+ return /* @__PURE__ */ a(W, { name: "gauge", title: n, children: /* @__PURE__ */ _("div", { className: "widget-gauge__chart", children: [
229
+ /* @__PURE__ */ _("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", role: "img", "aria-label": `${i} da meta`, children: [
230
+ /* @__PURE__ */ a("path", { d: ue(y, w, C, 1), fill: "none", stroke: yt, strokeWidth: $, strokeLinecap: "butt" }),
231
+ h > 0 && /* @__PURE__ */ a("path", { d: ue(y, w, C, h), fill: "none", stroke: k, strokeWidth: $, strokeLinecap: "butt" })
232
232
  ] }),
233
- /* @__PURE__ */ b("div", { className: "widget-gauge__center", children: [
234
- /* @__PURE__ */ r("span", { className: "widget-gauge__percent", children: i }),
235
- /* @__PURE__ */ b("span", { className: "widget-gauge__comparison", children: [
236
- c,
233
+ /* @__PURE__ */ _("div", { className: "widget-gauge__center", children: [
234
+ /* @__PURE__ */ a("span", { className: "widget-gauge__percent", children: i }),
235
+ /* @__PURE__ */ _("span", { className: "widget-gauge__comparison", children: [
236
+ o,
237
237
  " / ",
238
- d
238
+ m
239
239
  ] }),
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,
240
+ f && /* @__PURE__ */ a("span", { className: "widget-gauge__badge", children: p || "Meta batida" }),
241
+ !f && p && /* @__PURE__ */ a("span", { className: "widget-gauge__comparison", children: p }),
242
+ u.map((P, E) => /* @__PURE__ */ _("span", { className: "widget-gauge__comparison", children: [
243
+ P.formatted,
244
244
  " ",
245
- T.label
246
- ] }, T.id || x))
245
+ P.label
246
+ ] }, P.id || E))
247
247
  ] })
248
248
  ] }) });
249
249
  }
250
- function X(e) {
251
- const [t, n] = M({ width: 0, height: 0 });
252
- return W(() => {
253
- const a = e.current;
254
- if (!a) return;
255
- const l = new ResizeObserver(([s]) => {
256
- const { width: c, height: i } = s.contentRect;
257
- n(
258
- (m) => m.width !== Math.floor(c) || m.height !== Math.floor(i) ? { width: Math.floor(c), height: Math.floor(i) } : m
250
+ function re(e) {
251
+ const [t, r] = T({ width: 0, height: 0 });
252
+ return F(() => {
253
+ const n = e.current;
254
+ if (!n) return;
255
+ const s = new ResizeObserver(([l]) => {
256
+ const { width: o, height: i } = l.contentRect;
257
+ r(
258
+ (d) => d.width !== Math.floor(o) || d.height !== Math.floor(i) ? { width: Math.floor(o), height: Math.floor(i) } : d
259
259
  );
260
260
  });
261
- return l.observe(a), () => l.disconnect();
261
+ return s.observe(n), () => s.disconnect();
262
262
  }, [e]), t;
263
263
  }
264
- const se = { fontSize: 10, fill: "var(--text-muted)" }, gt = "var(--bg-elevated)", _t = {
264
+ const me = { fontSize: 10, fill: "var(--text-muted)" }, St = "var(--bg-elevated)", kt = {
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
- }, pt = {
269
+ }, Ct = {
270
270
  color: "var(--text-primary)",
271
271
  fontWeight: 600
272
272
  };
273
- function bt(e, t) {
274
- var l;
275
- const n = Array.isArray(t) ? t[0] : void 0, a = (l = n == null ? void 0 : n.payload) == null ? void 0 : l.tooltipLabel;
276
- return typeof a == "string" && a ? a : String(e ?? "");
277
- }
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
- /* @__PURE__ */ r(
284
- U,
273
+ function Rt(e, t) {
274
+ var s;
275
+ const r = Array.isArray(t) ? t[0] : void 0, n = (s = r == null ? void 0 : r.payload) == null ? void 0 : s.tooltipLabel;
276
+ return typeof n == "string" && n ? n : String(e ?? "");
277
+ }
278
+ function B({ Chart: e, chartData: t, xKey: r, series: n, palette: s, renderSeries: l, width: o, height: i }) {
279
+ return /* @__PURE__ */ _(e, { data: t, width: o, height: i, children: [
280
+ /* @__PURE__ */ a(Ce, { strokeDasharray: "3 3", stroke: St }),
281
+ /* @__PURE__ */ a(Re, { dataKey: r, tick: me }),
282
+ /* @__PURE__ */ a($e, { tick: me }),
283
+ /* @__PURE__ */ a(
284
+ Q,
285
285
  {
286
- contentStyle: _t,
287
- labelStyle: pt,
288
- labelFormatter: bt,
286
+ contentStyle: kt,
287
+ labelStyle: Ct,
288
+ labelFormatter: Rt,
289
289
  cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
290
290
  }
291
291
  ),
292
- a.length > 1 && /* @__PURE__ */ r(Ze, {}),
293
- a.map((m, o) => s(m, l[o % l.length], o))
292
+ n.length > 1 && /* @__PURE__ */ a(lt, {}),
293
+ n.map((d, c) => l(d, s[c % s.length], c))
294
294
  ] });
295
295
  }
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,
296
+ function $t({ data: e, palette: t, label: r }) {
297
+ const n = String(e.chartType || "bar"), s = r || String(e.label || ""), l = String(e.xKey || "label"), o = e.series || [], i = e.data || [], d = R(null), { width: c, height: u } = re(d), m = () => {
298
+ if (c <= 0 || u <= 0) return null;
299
+ const p = { chartData: i, xKey: l, series: o, palette: t, width: c, height: u };
300
+ return n === "line" ? /* @__PURE__ */ a(B, { ...p, Chart: rt, renderSeries: (f, h) => /* @__PURE__ */ a(
301
+ nt,
302
302
  {
303
303
  type: "monotone",
304
- dataKey: p.key,
305
- name: p.label,
306
- stroke: v,
304
+ dataKey: f.key,
305
+ name: f.label,
306
+ stroke: h,
307
307
  strokeWidth: 2,
308
308
  dot: i.length <= 31
309
309
  },
310
- p.key
311
- ) }) : a === "area" ? /* @__PURE__ */ r(G, { ...f, Chart: Xe, renderSeries: (p, v) => /* @__PURE__ */ r(
312
- Qe,
310
+ f.key
311
+ ) }) : n === "area" ? /* @__PURE__ */ a(B, { ...p, Chart: at, renderSeries: (f, h) => /* @__PURE__ */ a(
312
+ st,
313
313
  {
314
314
  type: "monotone",
315
- dataKey: p.key,
316
- name: p.label,
317
- fill: v,
318
- stroke: v,
315
+ dataKey: f.key,
316
+ name: f.label,
317
+ fill: h,
318
+ stroke: h,
319
319
  fillOpacity: 0.3
320
320
  },
321
- p.key
322
- ) }) : /* @__PURE__ */ r(G, { ...f, Chart: ve, renderSeries: (p, v) => /* @__PURE__ */ r(
323
- K,
321
+ f.key
322
+ ) }) : /* @__PURE__ */ a(B, { ...p, Chart: ke, renderSeries: (f, h) => /* @__PURE__ */ a(
323
+ X,
324
324
  {
325
- dataKey: p.key,
326
- name: p.label,
327
- fill: v,
325
+ dataKey: f.key,
326
+ name: f.label,
327
+ fill: h,
328
328
  radius: [3, 3, 0, 0]
329
329
  },
330
- p.key
330
+ f.key
331
331
  ) });
332
332
  };
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() }) });
333
+ return /* @__PURE__ */ a(W, { name: "chart", title: s, children: /* @__PURE__ */ a("div", { ref: d, className: "widget-chart__container", children: i.length === 0 ? /* @__PURE__ */ a(te, { kind: "empty" }) : m() }) });
334
334
  }
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) {
335
+ const he = { fontSize: 10, fill: "var(--text-muted)" }, xt = "var(--bg-elevated)", Tt = { fill: "var(--bg-paper)", opacity: 0.3 };
336
+ function Pt(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 oe({ active: e, payload: t }) {
340
- var a;
341
- const n = e ? (a = t == null ? void 0 : t[0]) == null ? void 0 : a.payload : void 0;
342
- return n ? /* @__PURE__ */ b("div", { className: "widget-composition__tooltip", children: [
343
- /* @__PURE__ */ r("span", { className: "widget-composition__tooltip-label", children: n.label }),
344
- /* @__PURE__ */ r("span", { className: "widget-composition__tooltip-value", children: n.formatted })
339
+ function fe({ active: e, payload: t }) {
340
+ var n;
341
+ const r = e ? (n = t == null ? void 0 : t[0]) == null ? void 0 : n.payload : void 0;
342
+ return r ? /* @__PURE__ */ _("div", { className: "widget-composition__tooltip", children: [
343
+ /* @__PURE__ */ a("span", { className: "widget-composition__tooltip-label", children: r.label }),
344
+ /* @__PURE__ */ a("span", { className: "widget-composition__tooltip-value", children: r.formatted })
345
345
  ] }) : null;
346
346
  }
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
- /* @__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((f, p) => /* @__PURE__ */ r(ae, { fill: Nt(f) }, p)) })
355
- ] }), d = () => /* @__PURE__ */ b(Je, { width: m, height: o, children: [
356
- /* @__PURE__ */ r(
357
- et,
347
+ function At({ data: e, palette: t, label: r }) {
348
+ const n = r || String(e.label || ""), s = String(e.display || "pie"), l = e.data || [], o = typeof e.format == "string" ? e.format : void 0, i = R(null), { width: d, height: c } = re(i), u = () => /* @__PURE__ */ _(ke, { data: l, width: d, height: c, children: [
349
+ /* @__PURE__ */ a(Ce, { strokeDasharray: "3 3", stroke: xt }),
350
+ /* @__PURE__ */ a(Re, { dataKey: "label", tick: he, interval: 0 }),
351
+ /* @__PURE__ */ a($e, { tick: he, tickFormatter: (p) => ve(p, o) }),
352
+ /* @__PURE__ */ a(Q, { content: /* @__PURE__ */ a(fe, {}), cursor: Tt }),
353
+ /* @__PURE__ */ a(X, { dataKey: "base", stackId: "bridge", fill: "none", fillOpacity: 0, isAnimationActive: !1 }),
354
+ /* @__PURE__ */ a(X, { dataKey: "span", stackId: "bridge", radius: [3, 3, 0, 0], children: l.map((p, f) => /* @__PURE__ */ a(de, { fill: Pt(p) }, f)) })
355
+ ] }), m = () => /* @__PURE__ */ _(ot, { width: d, height: c, children: [
356
+ /* @__PURE__ */ a(
357
+ it,
358
358
  {
359
- data: s,
359
+ data: l,
360
360
  dataKey: "value",
361
361
  nameKey: "label",
362
362
  cx: "50%",
363
363
  cy: "50%",
364
364
  outerRadius: "75%",
365
- label: ({ name: f, percent: p }) => `${f}: ${(p * 100).toFixed(0)}%`,
365
+ label: ({ name: p, percent: f }) => `${p}: ${(f * 100).toFixed(0)}%`,
366
366
  labelLine: !1,
367
- children: s.map((f, p) => /* @__PURE__ */ r(ae, { fill: t[p % t.length] }, p))
367
+ children: l.map((p, f) => /* @__PURE__ */ a(de, { fill: t[f % t.length] }, f))
368
368
  }
369
369
  ),
370
- /* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(oe, {}) })
370
+ /* @__PURE__ */ a(Q, { content: /* @__PURE__ */ a(fe, {}) })
371
371
  ] });
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() }) });
372
+ return /* @__PURE__ */ a(W, { name: "composition", title: n, children: /* @__PURE__ */ a("div", { ref: i, className: "widget-composition__container", children: l.length === 0 || d <= 0 || c <= 0 ? /* @__PURE__ */ a(te, { kind: "empty" }) : s === "bridge" ? u() : m() }) });
373
373
  }
374
- function kt(e, t) {
374
+ function Mt(e, t) {
375
375
  if (t !== "percentage") return "";
376
- const n = Number(e);
377
- return Number.isNaN(n) || n === 0 ? "" : n > 0 ? " widget-table__td--up" : " widget-table__td--down";
378
- }
379
- function Rt(e, t, n, a) {
380
- const l = (a == null ? void 0 : a.offsetHeight) ?? 0;
381
- if (e === 0 || t <= 0 || l <= 0) return e;
382
- const s = Math.floor((t - ((n == null ? void 0 : n.offsetHeight) ?? 0)) / l);
383
- return Math.max(0, Math.min(e, s));
384
- }
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
- a.length,
389
- h,
390
- m.current,
391
- ((f = o.current) == null ? void 0 : f.firstElementChild) ?? null
392
- )) : a;
393
- return n.length === 0 ? /* @__PURE__ */ r(
394
- P,
376
+ const r = Number(e);
377
+ return Number.isNaN(r) || r === 0 ? "" : r > 0 ? " widget-table__td--up" : " widget-table__td--down";
378
+ }
379
+ function Et(e, t, r, n) {
380
+ const s = (n == null ? void 0 : n.offsetHeight) ?? 0;
381
+ if (e === 0 || t <= 0 || s <= 0) return e;
382
+ const l = Math.floor((t - ((r == null ? void 0 : r.offsetHeight) ?? 0)) / s);
383
+ return Math.max(0, Math.min(e, l));
384
+ }
385
+ function It({ data: e, label: t }) {
386
+ var p;
387
+ const r = e.columns || [], n = e.rows || [], s = e.overflow === "clip", l = e.indexColumn === !0, o = t || String(e.label || ""), i = R(null), d = R(null), c = R(null), { height: u } = re(i), m = s ? n.slice(0, Et(
388
+ n.length,
389
+ u,
390
+ d.current,
391
+ ((p = c.current) == null ? void 0 : p.firstElementChild) ?? null
392
+ )) : n;
393
+ return r.length === 0 ? /* @__PURE__ */ a(
394
+ W,
395
395
  {
396
396
  name: "table",
397
- title: c,
397
+ title: o,
398
398
  state: "unconfigured",
399
399
  stateMessage: "Configure as colunas da tabela."
400
400
  }
401
- ) : /* @__PURE__ */ r(P, { name: "table", title: c, children: /* @__PURE__ */ r(
401
+ ) : /* @__PURE__ */ a(W, { name: "table", title: o, children: /* @__PURE__ */ a(
402
402
  "div",
403
403
  {
404
404
  ref: i,
405
- className: `widget-table__scroll${l ? " widget-table__scroll--clip" : ""}`,
406
- children: /* @__PURE__ */ b(
405
+ className: `widget-table__scroll${s ? " widget-table__scroll--clip" : ""}`,
406
+ children: /* @__PURE__ */ _(
407
407
  "table",
408
408
  {
409
- className: `widget-table__table${l && d.length < a.length ? "" : " widget-table__table--fill"}`,
409
+ className: `widget-table__table${s && m.length < n.length ? "" : " widget-table__table--fill"}`,
410
410
  children: [
411
- /* @__PURE__ */ r("thead", { ref: m, children: /* @__PURE__ */ b("tr", { children: [
412
- s && /* @__PURE__ */ r("th", { className: "widget-table__th widget-table__th--index", children: "#" }),
413
- n.map((p) => /* @__PURE__ */ r(
411
+ /* @__PURE__ */ a("thead", { ref: d, children: /* @__PURE__ */ _("tr", { children: [
412
+ l && /* @__PURE__ */ a("th", { className: "widget-table__th widget-table__th--index", children: "#" }),
413
+ r.map((f) => /* @__PURE__ */ a(
414
414
  "th",
415
415
  {
416
- className: `widget-table__th${te(p.format) ? " widget-table__th--num" : ""}`,
417
- children: p.label || p.key
416
+ className: `widget-table__th${oe(f.format) ? " widget-table__th--num" : ""}`,
417
+ children: f.label || f.key
418
418
  },
419
- p.key
419
+ f.key
420
420
  ))
421
421
  ] }) }),
422
- /* @__PURE__ */ r("tbody", { ref: o, children: d.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r(
422
+ /* @__PURE__ */ a("tbody", { ref: c, children: m.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
423
423
  "td",
424
424
  {
425
425
  className: "widget-table__td widget-table__td--placeholder",
426
- colSpan: n.length + (s ? 1 : 0),
426
+ colSpan: r.length + (l ? 1 : 0),
427
427
  children: "Sem dados"
428
428
  }
429
- ) }) : d.map((p, v) => /* @__PURE__ */ b("tr", { children: [
430
- s && /* @__PURE__ */ r("td", { className: "widget-table__td widget-table__td--index", children: v + 1 }),
431
- n.map((S) => {
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);
429
+ ) }) : m.map((f, h) => /* @__PURE__ */ _("tr", { children: [
430
+ l && /* @__PURE__ */ a("td", { className: "widget-table__td widget-table__td--index", children: h + 1 }),
431
+ r.map((v) => {
432
+ const k = f[v.key], y = oe(v.format) ? " widget-table__td--num" : "";
433
+ return /* @__PURE__ */ a("td", { className: `widget-table__td${y}${Mt(k, v.format)}`, children: D(k, v.format) }, v.key);
434
434
  })
435
- ] }, v)) })
435
+ ] }, h)) })
436
436
  ]
437
437
  }
438
438
  )
439
439
  }
440
440
  ) });
441
441
  }
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,
442
+ function Ae({ mode: e, value: t, dateBounds: r, rangeUnit: n, onChange: s }) {
443
+ return e === "yearly" ? /* @__PURE__ */ a(Ot, { value: t, dateBounds: r, onChange: s }) : e === "monthly" ? /* @__PURE__ */ a(Wt, { value: t, dateBounds: r, onChange: s }) : e === "weekly" ? /* @__PURE__ */ a(zt, { value: t, dateBounds: r, onChange: s }) : n && n !== "day" ? /* @__PURE__ */ a(
444
+ Lt,
445
445
  {
446
446
  value: t,
447
- dateBounds: n,
448
- unit: a,
449
- onChange: l
447
+ dateBounds: r,
448
+ unit: n,
449
+ onChange: s
450
450
  }
451
- ) : /* @__PURE__ */ r(At, { value: t, dateBounds: n, onChange: l });
452
- }
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
- d && a(o === "start" ? `${d.start}|${!s || s < d.end ? d.end : s}` : `${!l || l > d.start ? d.start : l}|${d.end}`);
451
+ ) : /* @__PURE__ */ a(Ft, { value: t, dateBounds: r, onChange: s });
452
+ }
453
+ function Lt({ value: e, dateBounds: t, unit: r, onChange: n }) {
454
+ const [s, l] = e ? e.split("|") : ["", ""], o = Ve(r, t), i = (c) => {
455
+ var u;
456
+ return ((u = o.find((m) => c >= m.start && c <= m.end)) == null ? void 0 : u.key) ?? "";
457
+ }, d = (c, u) => {
458
+ const m = o.find((p) => p.key === u);
459
+ m && n(c === "start" ? `${m.start}|${!l || l < m.end ? m.end : l}` : `${!s || s > m.start ? m.start : s}|${m.end}`);
460
460
  };
461
- return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--period", children: [
462
- /* @__PURE__ */ b(
461
+ return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--period", children: [
462
+ /* @__PURE__ */ _(
463
463
  "select",
464
464
  {
465
465
  className: "widget-filter__select",
466
466
  "aria-label": "Período inicial",
467
- value: i(l),
468
- onChange: (o) => m("start", o.target.value),
467
+ value: i(s),
468
+ onChange: (c) => d("start", c.target.value),
469
469
  children: [
470
- !i(l) && /* @__PURE__ */ r("option", { value: "", children: "De..." }),
471
- c.map((o) => /* @__PURE__ */ r("option", { value: o.key, children: o.label }, o.key))
470
+ !i(s) && /* @__PURE__ */ a("option", { value: "", children: "De..." }),
471
+ o.map((c) => /* @__PURE__ */ a("option", { value: c.key, children: c.label }, c.key))
472
472
  ]
473
473
  }
474
474
  ),
475
- /* @__PURE__ */ b(
475
+ /* @__PURE__ */ _(
476
476
  "select",
477
477
  {
478
478
  className: "widget-filter__select",
479
479
  "aria-label": "Período final",
480
- value: i(s),
481
- onChange: (o) => m("end", o.target.value),
480
+ value: i(l),
481
+ onChange: (c) => d("end", c.target.value),
482
482
  children: [
483
- !i(s) && /* @__PURE__ */ r("option", { value: "", children: "Até..." }),
484
- c.map((o) => /* @__PURE__ */ r("option", { value: o.key, children: o.label }, o.key))
483
+ !i(l) && /* @__PURE__ */ a("option", { value: "", children: "Até..." }),
484
+ o.map((c) => /* @__PURE__ */ a("option", { value: c.key, children: c.label }, c.key))
485
485
  ]
486
486
  }
487
487
  )
488
488
  ] });
489
489
  }
490
- function At({ value: e, dateBounds: t, onChange: n }) {
491
- const [a, l] = e ? e.split("|") : ["", ""];
492
- return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
493
- /* @__PURE__ */ r(
494
- re,
490
+ function Ft({ value: e, dateBounds: t, onChange: r }) {
491
+ const [n, s] = e ? e.split("|") : ["", ""];
492
+ return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
493
+ /* @__PURE__ */ a(
494
+ ie,
495
495
  {
496
- value: a,
496
+ value: n,
497
497
  minIso: t == null ? void 0 : t.min,
498
- maxIso: l || (t == null ? void 0 : t.max),
498
+ maxIso: s || (t == null ? void 0 : t.max),
499
499
  selectsStart: !0,
500
- startIso: a,
501
- endIso: l,
500
+ startIso: n,
501
+ endIso: s,
502
502
  placeholder: "Data inicial",
503
- onChange: (s) => n(`${s}|${l}`)
503
+ onChange: (l) => r(`${l}|${s}`)
504
504
  }
505
505
  ),
506
- /* @__PURE__ */ r(
507
- re,
506
+ /* @__PURE__ */ a(
507
+ ie,
508
508
  {
509
- value: l,
510
- minIso: a || (t == null ? void 0 : t.min),
509
+ value: s,
510
+ minIso: n || (t == null ? void 0 : t.min),
511
511
  maxIso: t == null ? void 0 : t.max,
512
512
  selectsEnd: !0,
513
- startIso: a,
514
- endIso: l,
513
+ startIso: n,
514
+ endIso: s,
515
515
  placeholder: "Data final",
516
- onChange: (s) => n(`${a}|${s}`)
516
+ onChange: (l) => r(`${n}|${l}`)
517
517
  }
518
518
  )
519
519
  ] });
520
520
  }
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}`);
521
+ function Ot({ value: e, dateBounds: t, onChange: r }) {
522
+ const [n] = e ? e.split("|") : [""], s = De(n), l = /* @__PURE__ */ new Date(), o = (s == null ? void 0 : s.year) ?? l.getFullYear(), i = ee(t), d = (c) => {
523
+ const u = Ge(c);
524
+ r(`${u.start}|${u.end}`);
525
525
  };
526
- return /* @__PURE__ */ r("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ r(
526
+ return /* @__PURE__ */ a("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ a(
527
527
  "select",
528
528
  {
529
529
  className: "widget-filter__select",
530
- value: c,
531
- onChange: (o) => m(parseInt(o.target.value)),
532
- children: i.map((o) => /* @__PURE__ */ r("option", { value: o, children: o }, o))
530
+ value: o,
531
+ onChange: (c) => d(parseInt(c.target.value)),
532
+ children: i.map((c) => /* @__PURE__ */ a("option", { value: c, children: c }, c))
533
533
  }
534
534
  ) });
535
535
  }
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}`);
536
+ function Wt({ value: e, dateBounds: t, onChange: r }) {
537
+ const [n] = e ? e.split("|") : [""], s = ye(n), l = /* @__PURE__ */ new Date(), o = (s == null ? void 0 : s.year) ?? l.getFullYear(), i = (s == null ? void 0 : s.month) ?? l.getMonth() + 1, d = ee(t), c = (u, m) => {
538
+ const p = je(u, m);
539
+ r(`${p.start}|${p.end}`);
540
540
  };
541
- return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
542
- /* @__PURE__ */ r(
541
+ return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
542
+ /* @__PURE__ */ a(
543
543
  "select",
544
544
  {
545
545
  className: "widget-filter__select",
546
546
  value: i,
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))
547
+ onChange: (u) => c(o, parseInt(u.target.value)),
548
+ children: we.map((u, m) => /* @__PURE__ */ a("option", { value: m + 1, children: u }, m + 1))
549
549
  }
550
550
  ),
551
- /* @__PURE__ */ r(
551
+ /* @__PURE__ */ a(
552
552
  "select",
553
553
  {
554
554
  className: "widget-filter__select",
555
- value: c,
556
- onChange: (h) => o(parseInt(h.target.value), i),
557
- children: m.map((h) => /* @__PURE__ */ r("option", { value: h, children: h }, h))
555
+ value: o,
556
+ onChange: (u) => c(parseInt(u.target.value), i),
557
+ children: d.map((u) => /* @__PURE__ */ a("option", { value: u, children: u }, u))
558
558
  }
559
559
  )
560
560
  ] });
561
561
  }
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
- /* @__PURE__ */ r(
562
+ function zt({ value: e, dateBounds: t, onChange: r }) {
563
+ const [n] = e ? e.split("|") : [""], s = ye(n), l = /* @__PURE__ */ new Date(), o = (s == null ? void 0 : s.year) ?? l.getFullYear(), i = (s == null ? void 0 : s.month) ?? l.getMonth() + 1, d = ee(t), c = U(o, i), u = He(n, o, i) || 1;
564
+ return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
565
+ /* @__PURE__ */ a(
566
566
  "select",
567
567
  {
568
568
  className: "widget-filter__select",
569
- value: c,
570
- onChange: (d) => {
571
- const f = parseInt(d.target.value), v = j(f, i)[0];
572
- v && n(`${v.start}|${v.end}`);
569
+ value: o,
570
+ onChange: (m) => {
571
+ const p = parseInt(m.target.value), h = U(p, i)[0];
572
+ h && r(`${h.start}|${h.end}`);
573
573
  },
574
- children: m.map((d) => /* @__PURE__ */ r("option", { value: d, children: d }, d))
574
+ children: d.map((m) => /* @__PURE__ */ a("option", { value: m, children: m }, m))
575
575
  }
576
576
  ),
577
- /* @__PURE__ */ r(
577
+ /* @__PURE__ */ a(
578
578
  "select",
579
579
  {
580
580
  className: "widget-filter__select",
581
581
  value: i,
582
- onChange: (d) => {
583
- const f = parseInt(d.target.value), v = j(c, f)[0];
584
- v && n(`${v.start}|${v.end}`);
582
+ onChange: (m) => {
583
+ const p = parseInt(m.target.value), h = U(o, p)[0];
584
+ h && r(`${h.start}|${h.end}`);
585
585
  },
586
- children: _e.map((d, f) => /* @__PURE__ */ r("option", { value: f + 1, children: d }, f + 1))
586
+ children: we.map((m, p) => /* @__PURE__ */ a("option", { value: p + 1, children: m }, p + 1))
587
587
  }
588
588
  ),
589
- /* @__PURE__ */ r(
589
+ /* @__PURE__ */ a(
590
590
  "select",
591
591
  {
592
592
  className: "widget-filter__select",
593
- value: h,
594
- onChange: (d) => {
595
- const f = o[parseInt(d.target.value) - 1];
596
- f && n(`${f.start}|${f.end}`);
593
+ value: u,
594
+ onChange: (m) => {
595
+ const p = c[parseInt(m.target.value) - 1];
596
+ p && r(`${p.start}|${p.end}`);
597
597
  },
598
- children: o.map((d) => /* @__PURE__ */ r("option", { value: d.index, children: d.label }, d.index))
598
+ children: c.map((m) => /* @__PURE__ */ a("option", { value: m.index, children: m.label }, m.index))
599
599
  }
600
600
  )
601
601
  ] });
602
602
  }
603
- function xt({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }) {
604
- const s = e.filterType || "select", c = e.label || "Filtro", i = e.dateFilterMode || "range";
605
- return /* @__PURE__ */ b("div", { className: "widget-filter", children: [
606
- /* @__PURE__ */ r("label", { className: "widget-filter__label", children: c }),
607
- s === "date_range" ? /* @__PURE__ */ r(
608
- $e,
603
+ function Dt({ config: e, value: t, options: r = [], dateBounds: n, onChange: s }) {
604
+ const l = e.filterType || "select", o = e.label || "Filtro", i = e.dateFilterMode || "range";
605
+ return /* @__PURE__ */ _("div", { className: "widget-filter", children: [
606
+ /* @__PURE__ */ a("label", { className: "widget-filter__label", children: o }),
607
+ l === "date_range" ? /* @__PURE__ */ a(
608
+ Ae,
609
609
  {
610
610
  mode: i,
611
611
  value: t,
612
- dateBounds: a,
613
- onChange: l
612
+ dateBounds: n,
613
+ onChange: s
614
614
  }
615
- ) : /* @__PURE__ */ r(
616
- Et,
615
+ ) : /* @__PURE__ */ a(
616
+ Ht,
617
617
  {
618
618
  value: t,
619
- options: n,
620
- multi: s === "multi_select",
619
+ options: r,
620
+ multi: l === "multi_select",
621
621
  searchable: e.searchable || !1,
622
- onChange: l
622
+ onChange: s
623
623
  }
624
624
  )
625
625
  ] });
626
626
  }
627
- function Et({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
628
- if (a)
629
- return /* @__PURE__ */ r(
630
- pe,
627
+ function Ht({ value: e, options: t, multi: r, searchable: n, onChange: s }) {
628
+ if (n)
629
+ return /* @__PURE__ */ a(
630
+ Ne,
631
631
  {
632
632
  value: e,
633
633
  options: t,
634
- multi: n,
635
- onChange: l
634
+ multi: r,
635
+ onChange: s
636
636
  }
637
637
  );
638
- if (n) {
639
- const s = e ? e.split(V) : [], c = (i) => {
640
- const m = s.includes(i) ? s.filter((o) => o !== i) : [...s, i];
641
- l(m.join(V));
638
+ if (r) {
639
+ const l = e ? e.split(q) : [], o = (i) => {
640
+ const d = l.includes(i) ? l.filter((c) => c !== i) : [...l, i];
641
+ s(d.join(q));
642
642
  };
643
- return /* @__PURE__ */ b("div", { className: "widget-filter__multi", children: [
644
- s.length > 0 && /* @__PURE__ */ r(
643
+ return /* @__PURE__ */ _("div", { className: "widget-filter__multi", children: [
644
+ l.length > 0 && /* @__PURE__ */ a(
645
645
  "button",
646
646
  {
647
647
  type: "button",
648
648
  className: "widget-filter__multi-clear",
649
- onClick: () => l(""),
649
+ onClick: () => s(""),
650
650
  children: "Limpar filtro"
651
651
  }
652
652
  ),
653
- t.map((i) => /* @__PURE__ */ b("label", { className: "widget-filter__multi-option", children: [
654
- /* @__PURE__ */ r(
653
+ t.map((i) => /* @__PURE__ */ _("label", { className: "widget-filter__multi-option", children: [
654
+ /* @__PURE__ */ a(
655
655
  "input",
656
656
  {
657
657
  type: "checkbox",
658
- checked: s.includes(i),
659
- onChange: () => c(i)
658
+ checked: l.includes(i),
659
+ onChange: () => o(i)
660
660
  }
661
661
  ),
662
662
  i
663
663
  ] }, i))
664
664
  ] });
665
665
  }
666
- return /* @__PURE__ */ b(
666
+ return /* @__PURE__ */ _(
667
667
  "select",
668
668
  {
669
669
  className: "widget-filter__select",
670
670
  value: e,
671
- onChange: (s) => l(s.target.value),
671
+ onChange: (l) => s(l.target.value),
672
672
  children: [
673
- /* @__PURE__ */ r("option", { value: "", children: "Todos" }),
674
- t.map((s) => /* @__PURE__ */ r("option", { value: s, children: s }, s))
673
+ /* @__PURE__ */ a("option", { value: "", children: "Todos" }),
674
+ t.map((l) => /* @__PURE__ */ a("option", { value: l, children: l }, l))
675
675
  ]
676
676
  }
677
677
  );
678
678
  }
679
- const Lt = {
679
+ const Vt = {
680
680
  currency: "R$",
681
681
  percentage: "%"
682
682
  };
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
- /* @__PURE__ */ r("label", { className: "widget-variable__label", children: a }),
687
- /* @__PURE__ */ b("div", { className: "widget-variable__input-wrapper", children: [
688
- /* @__PURE__ */ r(
683
+ function jt({ config: e, value: t, onChange: r }) {
684
+ const n = e.label || "Variavel", s = e.locked || !1, l = e.variableFormat || "number", o = Vt[l] || "";
685
+ return /* @__PURE__ */ _("div", { className: `widget-variable ${s ? "widget-variable--locked" : ""}`, children: [
686
+ /* @__PURE__ */ a("label", { className: "widget-variable__label", children: n }),
687
+ /* @__PURE__ */ _("div", { className: "widget-variable__input-wrapper", children: [
688
+ /* @__PURE__ */ a(
689
689
  "input",
690
690
  {
691
691
  className: "widget-variable__input",
692
692
  type: "number",
693
693
  value: t,
694
- onChange: (i) => n(parseFloat(i.target.value) || 0),
695
- disabled: l,
696
- step: s === "integer" ? 1 : 0.01
694
+ onChange: (i) => r(parseFloat(i.target.value) || 0),
695
+ disabled: s,
696
+ step: l === "integer" ? 1 : 0.01
697
697
  }
698
698
  ),
699
- c && /* @__PURE__ */ r("span", { className: "widget-variable__suffix", children: c })
699
+ o && /* @__PURE__ */ a("span", { className: "widget-variable__suffix", children: o })
700
700
  ] }),
701
- l && /* @__PURE__ */ r("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
701
+ s && /* @__PURE__ */ a("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
702
702
  ] });
703
703
  }
704
- function Pt({ config: e, palette: t, onChange: n }) {
705
- const a = e.label || "Cores", l = e.locked || !1;
706
- return /* @__PURE__ */ b("div", { className: `widget-palette ${l ? "widget-palette--locked" : ""}`, children: [
707
- /* @__PURE__ */ r("label", { className: "widget-palette__label", children: a }),
708
- /* @__PURE__ */ r(Ie, { selected: t, onSelect: n, customMode: !0, disabled: l }),
709
- l && /* @__PURE__ */ r("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
704
+ function Gt({ config: e, palette: t, onChange: r }) {
705
+ const n = e.label || "Cores", s = e.locked || !1;
706
+ return /* @__PURE__ */ _("div", { className: `widget-palette ${s ? "widget-palette--locked" : ""}`, children: [
707
+ /* @__PURE__ */ a("label", { className: "widget-palette__label", children: n }),
708
+ /* @__PURE__ */ a(Ke, { selected: t, onSelect: r, customMode: !0, disabled: s }),
709
+ s && /* @__PURE__ */ a("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
710
710
  ] });
711
711
  }
712
- const It = {
712
+ const Kt = {
713
713
  failed_to_compute: "Não foi possível calcular este widget"
714
714
  };
715
- function Wt({
715
+ function Yt({
716
716
  type: e,
717
717
  computed: t,
718
- palette: n,
719
- config: a,
720
- filterValue: l,
721
- filterOptions: s,
722
- dateBounds: c,
718
+ palette: r,
719
+ config: n,
720
+ filterValue: s,
721
+ filterOptions: l,
722
+ dateBounds: o,
723
723
  onFilterChange: i,
724
- variableValue: m,
725
- onVariableChange: o,
726
- onPaletteChange: h
724
+ variableValue: d,
725
+ onVariableChange: c,
726
+ onPaletteChange: u
727
727
  }) {
728
728
  if (t.error)
729
- return /* @__PURE__ */ r(
730
- P,
729
+ return /* @__PURE__ */ a(
730
+ W,
731
731
  {
732
732
  name: e.replace("_", "-"),
733
- title: a == null ? void 0 : a.label,
733
+ title: n == null ? void 0 : n.label,
734
734
  state: "error",
735
- stateMessage: It[String(t.error)]
735
+ stateMessage: Kt[String(t.error)]
736
736
  }
737
737
  );
738
- const d = We(n);
738
+ const m = Ye(r);
739
739
  switch (e) {
740
740
  case "kpi_card":
741
- return /* @__PURE__ */ r(ut, { data: t, label: a == null ? void 0 : a.label });
741
+ return /* @__PURE__ */ a(vt, { data: t, label: n == null ? void 0 : n.label });
742
742
  case "gauge":
743
- return /* @__PURE__ */ r(ft, { data: t, palette: d, label: a == null ? void 0 : a.label });
743
+ return /* @__PURE__ */ a(Nt, { data: t, palette: m, label: n == null ? void 0 : n.label });
744
744
  case "chart":
745
- return /* @__PURE__ */ r(vt, { data: t, palette: d, label: a == null ? void 0 : a.label });
745
+ return /* @__PURE__ */ a($t, { data: t, palette: m, label: n == null ? void 0 : n.label });
746
746
  case "composition":
747
- return /* @__PURE__ */ r(St, { data: t, palette: d, label: a == null ? void 0 : a.label });
747
+ return /* @__PURE__ */ a(At, { data: t, palette: m, label: n == null ? void 0 : n.label });
748
748
  case "table":
749
- return /* @__PURE__ */ r($t, { data: t, label: a == null ? void 0 : a.label });
749
+ return /* @__PURE__ */ a(It, { data: t, label: n == null ? void 0 : n.label });
750
750
  case "filter":
751
- return a && i ? /* @__PURE__ */ r(
752
- xt,
751
+ return n && i ? /* @__PURE__ */ a(
752
+ Dt,
753
753
  {
754
- config: a,
755
- value: l || "",
756
- options: s,
757
- dateBounds: c,
754
+ config: n,
755
+ value: s || "",
756
+ options: l,
757
+ dateBounds: o,
758
758
  onChange: i
759
759
  }
760
760
  ) : null;
761
761
  case "variable": {
762
- const f = a;
763
- return f && o ? /* @__PURE__ */ r(
764
- Ot,
762
+ const p = n;
763
+ return p && c ? /* @__PURE__ */ a(
764
+ jt,
765
765
  {
766
- config: f,
767
- value: m ?? f.variableValue ?? 0,
768
- onChange: o
766
+ config: p,
767
+ value: d ?? p.variableValue ?? 0,
768
+ onChange: c
769
769
  }
770
770
  ) : null;
771
771
  }
772
772
  case "color_palette":
773
- return a && h ? /* @__PURE__ */ r(
774
- Pt,
773
+ return n && u ? /* @__PURE__ */ a(
774
+ Gt,
775
775
  {
776
- config: a,
777
- palette: n,
778
- onChange: h
776
+ config: n,
777
+ palette: r,
778
+ onChange: u
779
779
  }
780
780
  ) : null;
781
781
  default:
782
- return /* @__PURE__ */ r(P, { name: "unknown", state: "unconfigured" });
782
+ return /* @__PURE__ */ a(W, { name: "unknown", state: "unconfigured" });
783
783
  }
784
784
  }
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({
785
+ const Ut = Fe(Yt), Bt = (e, t) => e.grid.y - t.grid.y || e.grid.x - t.grid.x, qt = {}, pe = [];
786
+ function Or({
787
787
  token: e,
788
- cellAspect: t = Ge,
789
- stackBelow: n,
790
- onGeometryChange: a,
791
- silenceWarnings: l,
792
- className: s
788
+ cellAspect: t = Qe,
789
+ stackBelow: r,
790
+ onGeometryChange: n,
791
+ silenceWarnings: s,
792
+ className: l
793
793
  }) {
794
794
  const {
795
- layout: c,
795
+ layout: o,
796
796
  renderData: i,
797
- loading: m,
798
- error: o,
799
- filters: h,
800
- variables: d,
801
- palette: f,
802
- setFilter: p,
803
- setVariable: v,
804
- setPalette: S
805
- } = rt(e), { rootRef: k, gridRef: A, stacked: y } = it({
806
- columns: (c == null ? void 0 : c.gridColumns) ?? 0,
797
+ loading: d,
798
+ error: c,
799
+ filters: u,
800
+ variables: m,
801
+ palette: p,
802
+ setFilter: f,
803
+ setVariable: h,
804
+ setPalette: v
805
+ } = dt(e), { rootRef: k, gridRef: y, stacked: w } = pt({
806
+ columns: (o == null ? void 0 : o.gridColumns) ?? 0,
807
807
  cellAspect: t,
808
- stackBelow: n,
809
- onGeometryChange: a,
810
- silenceWarnings: l
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)
808
+ stackBelow: r,
809
+ onGeometryChange: n,
810
+ silenceWarnings: s
811
+ }), C = I(() => {
812
+ const g = (o == null ? void 0 : o.widgets) ?? [];
813
+ return w ? [...g].sort(Bt) : g;
814
+ }, [o == null ? void 0 : o.widgets, w]), $ = I(() => {
815
+ const g = {};
816
+ for (const N of C)
817
+ g[N.id] = {
818
+ onFilter: (A) => f(N.id, A),
819
+ onVariable: (A) => h(N.id, A)
820
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 _;
827
- if (o && !c)
828
- _ = /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o });
829
- else if (!c)
830
- _ = /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
831
- else if (c.widgets.length === 0)
832
- _ = /* @__PURE__ */ r("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
821
+ return g;
822
+ }, [C, f, h]), P = {
823
+ "--dash-gap": `${ce}px`,
824
+ "--dash-pad": `${Xe}px`
825
+ }, E = ["preview-tab", l].filter(Boolean).join(" ");
826
+ let b;
827
+ if (c && !o)
828
+ b = /* @__PURE__ */ a("div", { className: "preview-tab__error", children: c });
829
+ else if (!o)
830
+ b = /* @__PURE__ */ a("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
831
+ else if (o.widgets.length === 0)
832
+ b = /* @__PURE__ */ a("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
833
833
  else {
834
- const u = (i == null ? void 0 : i.widgets) ?? {}, R = (i == null ? void 0 : i.date_bounds) ?? null, C = {
835
- "--dash-cols": c.gridColumns,
836
- "--dash-rows": c.gridRows,
837
- ...be(f)
838
- }, F = ["preview-tab__grid", y && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
839
- _ = /* @__PURE__ */ b(he, { children: [
840
- o && !i && /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o }),
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 ? {
834
+ const g = (i == null ? void 0 : i.widgets) ?? {}, N = (i == null ? void 0 : i.date_bounds) ?? null, A = {
835
+ "--dash-cols": o.gridColumns,
836
+ "--dash-rows": o.gridRows,
837
+ ...Se(p)
838
+ }, M = ["preview-tab__grid", w && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
839
+ b = /* @__PURE__ */ _(V, { children: [
840
+ c && !i && /* @__PURE__ */ a("div", { className: "preview-tab__error", children: c }),
841
+ i && /* @__PURE__ */ a("div", { className: M, style: A, ref: y, children: C.map((S) => {
842
+ var ne, ae;
843
+ const z = Ue.has(S.type), L = g[S.id], O = w ? {
844
844
  gridColumn: 1,
845
- aspectRatio: `${He(g.grid.w, g.grid.h, t)}`,
846
- minHeight: `${ze(g.grid.h, Ye, ne, 0)}px`
845
+ aspectRatio: `${qe(S.grid.w, S.grid.h, t)}`,
846
+ minHeight: `${Be(S.grid.h, Ze, ce, 0)}px`
847
847
  } : {
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;
851
- return /* @__PURE__ */ r(
848
+ gridColumn: `${S.grid.x + 1} / span ${S.grid.w}`,
849
+ gridRow: `${S.grid.y + 1} / span ${S.grid.h}`
850
+ }, Le = S.type === "variable" ? m[S.id] ?? (L == null ? void 0 : L.value) ?? S.config.variableValue ?? 0 : void 0;
851
+ return /* @__PURE__ */ a(
852
852
  "div",
853
853
  {
854
- className: `preview-tab__widget ${I ? "preview-tab__widget--control" : ""}`,
854
+ className: `preview-tab__widget ${z ? "preview-tab__widget--control" : ""}`,
855
855
  style: O,
856
- children: I || L ? /* @__PURE__ */ r(
857
- Dt,
856
+ children: z || L ? /* @__PURE__ */ a(
857
+ Ut,
858
858
  {
859
- type: g.type,
860
- computed: L || Ht,
861
- palette: f,
862
- config: g.config,
863
- filterValue: h[g.id] || "",
859
+ type: S.type,
860
+ computed: L || qt,
861
+ palette: p,
862
+ config: S.config,
863
+ filterValue: u[S.id] || "",
864
864
  filterOptions: (
865
865
  // Estruturais: vem do /layout (cacheavel), nao do /render —
866
866
  // recalcula-los a cada render custaria um DISTINCT por filtro.
867
- g.type === "filter" ? g.config.availableValues ?? ce : ce
867
+ S.type === "filter" ? S.config.availableValues ?? pe : pe
868
868
  ),
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,
873
- onPaletteChange: S
869
+ dateBounds: N,
870
+ onFilterChange: (ne = $[S.id]) == null ? void 0 : ne.onFilter,
871
+ variableValue: Le,
872
+ onVariableChange: (ae = $[S.id]) == null ? void 0 : ae.onVariable,
873
+ onPaletteChange: v
874
874
  }
875
- ) : /* @__PURE__ */ r("div", { className: "preview-tab__widget-loading", children: m ? "Carregando..." : "Sem dados" })
875
+ ) : /* @__PURE__ */ a("div", { className: "preview-tab__widget-loading", children: d ? "Carregando..." : "Sem dados" })
876
876
  },
877
- g.id
877
+ S.id
878
878
  );
879
879
  }) }),
880
- m && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
880
+ d && i && /* @__PURE__ */ a("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
881
881
  ] });
882
882
  }
883
- return /* @__PURE__ */ r("div", { className: x, style: T, ref: k, children: _ });
883
+ return /* @__PURE__ */ a("div", { className: E, style: P, ref: k, children: b });
884
884
  }
885
- function jt(e, t) {
886
- const n = URL.createObjectURL(e), a = document.createElement("a");
887
- a.href = n, a.download = t, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
885
+ function Xt(e, t) {
886
+ const r = URL.createObjectURL(e), n = document.createElement("a");
887
+ n.href = r, n.download = t, document.body.appendChild(n), n.click(), n.remove(), setTimeout(() => URL.revokeObjectURL(r), 0);
888
888
  }
889
- const Gt = 768, Yt = 879;
890
- function Vt(e) {
889
+ const Qt = 768, Zt = 879;
890
+ function Jt(e) {
891
891
  return Array.from(e.normalize("NFD")).filter((t) => {
892
- const n = t.codePointAt(0) ?? 0;
893
- return n < Gt || n > Yt;
892
+ const r = t.codePointAt(0) ?? 0;
893
+ return r < Qt || r > Zt;
894
894
  }).join("");
895
895
  }
896
- function Kt(e, t) {
897
- return `${Vt(e).replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "documento"}.${t}`;
898
- }
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);
896
+ function er(e, t) {
897
+ return `${Jt(e).replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "documento"}.${t}`;
898
+ }
899
+ const tr = 300;
900
+ function rr(e) {
901
+ const [t, r] = T(null), [n, s] = T(null), [l, o] = T({}), [i, d] = T(!0), [c, u] = T(null), [m, p] = T(!1), f = R(), h = R(!1), v = R(null), k = R(!1);
902
+ F(() => {
903
+ let C = !1;
904
+ return h.current = !1, v.current = null, k.current = !1, Je(e).then(($) => {
905
+ C || r($);
906
+ }).catch(($) => {
907
+ C || u($.message);
908
908
  }), () => {
909
- w = !0;
909
+ C = !0;
910
910
  };
911
- }, [e]), W(() => {
911
+ }, [e]), F(() => {
912
912
  if (!t) return;
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);
913
+ const C = H(l), $ = j(C);
914
+ if ($ === v.current) return;
915
+ f.current && clearTimeout(f.current);
916
+ const P = k.current ? tr : 0;
917
+ return f.current = setTimeout(() => {
918
+ d(!0), et(e, C).then((E) => {
919
+ v.current = $, k.current = !0, s(E), !h.current && E.applied && (h.current = !0, o((b) => {
920
+ const g = { ...Te(E.applied), ...b };
921
+ return xe(g, b) ? b : (v.current = j(H(g)), g);
922
+ })), u(null);
923
+ }).catch((E) => u(E.message)).finally(() => d(!1));
924
+ }, P), () => {
925
+ f.current && clearTimeout(f.current);
926
926
  };
927
- }, [e, t, s]);
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));
934
- }, [e, s, t == null ? void 0 : t.name]);
927
+ }, [e, t, l]);
928
+ const y = x((C, $) => {
929
+ o((P) => ({ ...P, [C]: $ }));
930
+ }, []), w = x(() => {
931
+ p(!0), tt(e, H(l)).then((C) => {
932
+ Xt(C, er((t == null ? void 0 : t.name) ?? "demonstrativo", "pdf")), u(null);
933
+ }).catch((C) => u(C.message)).finally(() => p(!1));
934
+ }, [e, l, t == null ? void 0 : t.name]);
935
935
  return {
936
936
  layout: t,
937
- renderData: a,
937
+ renderData: n,
938
938
  loading: i,
939
- error: o,
940
- filters: s,
941
- setFilter: A,
942
- downloadPdf: y,
943
- downloading: d
939
+ error: c,
940
+ filters: l,
941
+ setFilter: y,
942
+ downloadPdf: w,
943
+ downloading: m
944
944
  };
945
945
  }
946
- const Bt = 8, Xt = 14;
947
- function de(e) {
948
- return { paddingLeft: `${Bt + e * Xt}px` };
946
+ const nr = [0, 0.25, 0.5, 0.75, 1];
947
+ function ar(e, t, r) {
948
+ let n = null, s = 0;
949
+ for (const [l, o] of e) {
950
+ if (o <= 0) continue;
951
+ if (n === null || o > s) {
952
+ n = l, s = o;
953
+ continue;
954
+ }
955
+ if (o < s) continue;
956
+ const i = l === r, d = n !== r && (t.get(l) ?? 1 / 0) < (t.get(n) ?? 1 / 0);
957
+ (i || d) && (n = l);
958
+ }
959
+ return n;
960
+ }
961
+ function sr(e, t) {
962
+ const [r, n] = T(null);
963
+ return F(() => {
964
+ const s = e.current;
965
+ if (!s || t.length === 0 || typeof IntersectionObserver > "u") {
966
+ n(null);
967
+ return;
968
+ }
969
+ const l = Array.from(s.querySelectorAll("th[data-period]"));
970
+ if (l.length === 0) {
971
+ n(null);
972
+ return;
973
+ }
974
+ const o = /* @__PURE__ */ new Map(), i = new Map(t.map((c, u) => [c, u])), d = new IntersectionObserver((c) => {
975
+ for (const u of c) {
976
+ const m = u.target.dataset.period;
977
+ m != null && o.set(m, u.isIntersecting ? u.intersectionRatio : 0);
978
+ }
979
+ n((u) => ar(o, i, u));
980
+ }, { root: s, threshold: nr });
981
+ return l.forEach((c) => d.observe(c)), () => d.disconnect();
982
+ }, [e, t]), r;
983
+ }
984
+ function lr(e, t) {
985
+ return e.type === "separator" || e.indent > t.indent ? !1 : !(t.type === "header" && e.type === "data" && e.indent === t.indent);
986
+ }
987
+ function Y(e, t) {
988
+ const r = e[t];
989
+ if (!r || r.type === "separator") return null;
990
+ let n = t + 1;
991
+ for (; n < e.length && !lr(e[n], r); )
992
+ n += 1;
993
+ return n === t + 1 || !e.slice(t + 1, n).some((l) => l.type !== "separator") ? null : { from: t + 1, to: n };
994
+ }
995
+ function or(e) {
996
+ const t = [];
997
+ for (let r = 0; r < e.length; r += 1)
998
+ Y(e, r) && t.push(e[r].id);
999
+ return t;
1000
+ }
1001
+ function ir(e) {
1002
+ const t = /* @__PURE__ */ new Map();
1003
+ e.forEach((n, s) => {
1004
+ const l = Y(e, s);
1005
+ l && t.set(s, l);
1006
+ });
1007
+ const r = [];
1008
+ for (const [n, s] of t) {
1009
+ let l = !0;
1010
+ for (const o of t.keys())
1011
+ if (o >= s.from && o < s.to) {
1012
+ l = !1;
1013
+ break;
1014
+ }
1015
+ l && r.push(e[n].id);
1016
+ }
1017
+ return r;
949
1018
  }
950
- function Qt(e) {
1019
+ function cr(e, t) {
1020
+ const r = Y(e, t);
1021
+ if (!r) return 0;
1022
+ let n = 0;
1023
+ for (let s = r.from; s < r.to; s += 1)
1024
+ e[s].type === "data" && (n += 1);
1025
+ return n;
1026
+ }
1027
+ function dr(e, t) {
1028
+ const r = /* @__PURE__ */ new Set();
1029
+ for (const n of t) {
1030
+ const s = e.findIndex((o) => o.id === n);
1031
+ if (s < 0) continue;
1032
+ const l = Y(e, s);
1033
+ if (l)
1034
+ for (let o = l.from; o < l.to; o += 1)
1035
+ r.add(e[o].id);
1036
+ }
1037
+ return r;
1038
+ }
1039
+ function ur(e) {
1040
+ const t = I(
1041
+ () => e.map((f) => ({ id: f.id, type: f.type, indent: f.style.indent })),
1042
+ [e]
1043
+ ), r = I(() => or(t), [t]), n = I(() => new Set(r), [r]), s = I(
1044
+ () => new Set(ir(t)),
1045
+ [t]
1046
+ ), l = I(
1047
+ () => new Map(t.map((f, h) => [f.id, cr(t, h)])),
1048
+ [t]
1049
+ ), [o, i] = T(null), d = o ?? s, c = I(() => dr(t, d), [t, d]), u = x((f) => {
1050
+ i((h) => {
1051
+ const v = new Set(h ?? s);
1052
+ return v.has(f) ? v.delete(f) : v.add(f), v;
1053
+ });
1054
+ }, [s]), m = x(() => i(s), [s]), p = x(() => i(/* @__PURE__ */ new Set()), []);
1055
+ return I(() => ({
1056
+ collapsible: n,
1057
+ collapsed: d,
1058
+ hidden: c,
1059
+ accountCounts: l,
1060
+ hasSections: r.length > 0,
1061
+ toggle: u,
1062
+ collapseToSummary: m,
1063
+ expandAll: p
1064
+ }), [n, d, c, l, r, u, m, p]);
1065
+ }
1066
+ const mr = 600, hr = (e) => {
1067
+ var t, r;
1068
+ return ((r = (t = e.contentBoxSize) == null ? void 0 : t[0]) == null ? void 0 : r.inlineSize) ?? e.contentRect.width;
1069
+ };
1070
+ function fr(e, t = mr) {
1071
+ const [r, n] = T(!1), s = R(null), l = x((i) => {
1072
+ n(i > 0 && i < t);
1073
+ }, [t]), o = x((i) => {
1074
+ s.current = i, i && e && l(i.getBoundingClientRect().width);
1075
+ }, [e, l]);
1076
+ return F(() => {
1077
+ const i = s.current;
1078
+ if (!e || !i || typeof ResizeObserver > "u") return;
1079
+ const d = new ResizeObserver((c) => {
1080
+ for (const u of c)
1081
+ u.target === i && l(hr(u));
1082
+ });
1083
+ return d.observe(i), () => d.disconnect();
1084
+ }, [e, l]), { ref: o, narrow: e && r };
1085
+ }
1086
+ const pr = 8, _r = 14, _e = 10;
1087
+ function gr(e, t = _r) {
1088
+ return { paddingLeft: `${pr + e * t}px` };
1089
+ }
1090
+ function br(e) {
951
1091
  const t = {};
952
1092
  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;
953
1093
  }
954
- function ue(e) {
1094
+ function Z(e) {
955
1095
  return e == null || e === 0 ? "stmt__number" : `stmt__number stmt__number--${e > 0 ? "pos" : "neg"}`;
956
1096
  }
957
- const Zt = {
1097
+ function ge(e) {
1098
+ return e == null || e === 0 ? "stmt__aux" : `stmt__aux stmt__aux--${e > 0 ? "up" : "down"}`;
1099
+ }
1100
+ const vr = {
958
1101
  day: "day",
959
1102
  week: "week",
960
1103
  month: "month",
@@ -962,37 +1105,37 @@ const Zt = {
962
1105
  year: "year",
963
1106
  total: "month"
964
1107
  };
965
- function Jt({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onChange: s }) {
1108
+ function yr({ definition: e, value: t, options: r, bounds: n, rangeUnit: s, onChange: l }) {
966
1109
  if (e.type === "date_range") {
967
- const c = e.dateFilterMode ?? "range";
968
- return /* @__PURE__ */ b("div", { className: `stmt__filter stmt__filter--date stmt__filter--${c}`, children: [
969
- /* @__PURE__ */ r("span", { className: "stmt__filter-label", children: e.label }),
970
- /* @__PURE__ */ r(
971
- $e,
1110
+ const o = e.dateFilterMode ?? "range";
1111
+ return /* @__PURE__ */ _("div", { className: `stmt__filter stmt__filter--date stmt__filter--${o}`, children: [
1112
+ /* @__PURE__ */ a("span", { className: "stmt__filter-label", children: e.label }),
1113
+ /* @__PURE__ */ a(
1114
+ Ae,
972
1115
  {
973
- mode: c,
1116
+ mode: o,
974
1117
  value: t,
975
- dateBounds: a,
976
- rangeUnit: l,
977
- onChange: s
1118
+ dateBounds: n,
1119
+ rangeUnit: s,
1120
+ onChange: l
978
1121
  }
979
1122
  )
980
1123
  ] });
981
1124
  }
982
- return /* @__PURE__ */ b("div", { className: "stmt__filter", children: [
983
- /* @__PURE__ */ r("span", { className: "stmt__filter-label", children: e.label }),
984
- /* @__PURE__ */ r(
985
- pe,
1125
+ return /* @__PURE__ */ _("div", { className: "stmt__filter", children: [
1126
+ /* @__PURE__ */ a("span", { className: "stmt__filter-label", children: e.label }),
1127
+ /* @__PURE__ */ a(
1128
+ Ne,
986
1129
  {
987
1130
  value: t,
988
- options: n,
1131
+ options: r,
989
1132
  multi: e.type === "multi_select",
990
- onChange: s
1133
+ onChange: l
991
1134
  }
992
1135
  )
993
1136
  ] });
994
1137
  }
995
- const er = 13, me = {
1138
+ const wr = 13, Nr = [], Sr = [], be = {
996
1139
  day: ["dia", "dias"],
997
1140
  week: ["semana", "semanas"],
998
1141
  month: ["mês", "meses"],
@@ -1000,167 +1143,459 @@ const er = 13, me = {
1000
1143
  year: ["ano", "anos"],
1001
1144
  total: ["período", "períodos"]
1002
1145
  };
1003
- function tr(e, t) {
1004
- const [n, a] = me[t] ?? me.total;
1005
- return `Variação sobre ${e} ${e === 1 ? n : a} atrás`;
1146
+ function kr(e, t) {
1147
+ const [r, n] = be[t] ?? be.total;
1148
+ return `Variação sobre ${e} ${e === 1 ? r : n} atrás`;
1006
1149
  }
1007
- function rr({
1008
- line: e,
1009
- columnCount: t,
1010
- showTotal: n,
1011
- showVertical: a,
1012
- showHorizontal: l,
1013
- comparisonLabel: s
1150
+ function Cr({
1151
+ label: e,
1152
+ collapsed: t,
1153
+ onToggle: r
1014
1154
  }) {
1015
- if (e.type === "separator")
1016
- return /* @__PURE__ */ r("tr", { className: "stmt__row stmt__row--separator", children: /* @__PURE__ */ r("td", { colSpan: t }) });
1017
- if (e.type === "header" && e.formatted.length === 0)
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 }),
1020
- /* @__PURE__ */ r("td", { colSpan: t - 1 })
1021
- ] });
1022
- const c = [
1155
+ return /* @__PURE__ */ a(
1156
+ "button",
1157
+ {
1158
+ type: "button",
1159
+ className: "stmt__toggle",
1160
+ "aria-expanded": !t,
1161
+ "aria-label": t ? `Expandir ${e}` : `Recolher ${e}`,
1162
+ onClick: (n) => {
1163
+ n.stopPropagation(), r();
1164
+ },
1165
+ children: /* @__PURE__ */ a("span", { className: "stmt__caret", "aria-hidden": "true" })
1166
+ }
1167
+ );
1168
+ }
1169
+ function Me(e, t) {
1170
+ return {
1171
+ collapsible: t.collapsible.has(e.id),
1172
+ collapsed: t.collapsed.has(e.id),
1173
+ hiddenCount: t.accountCounts.get(e.id) ?? 0,
1174
+ onToggle: () => t.toggle(e.id)
1175
+ };
1176
+ }
1177
+ function G({ line: e, section: t, indentStep: r }) {
1178
+ const { collapsible: n, collapsed: s, hiddenCount: l, onToggle: o } = t;
1179
+ return /* @__PURE__ */ _(
1180
+ "th",
1181
+ {
1182
+ scope: "row",
1183
+ style: gr(e.style.indent, r),
1184
+ onClick: n ? o : void 0,
1185
+ children: [
1186
+ n && /* @__PURE__ */ a(Cr, { label: e.label, collapsed: s, onToggle: o }),
1187
+ e.label,
1188
+ n && s && l > 0 && /* @__PURE__ */ _("span", { className: "stmt__count", children: [
1189
+ l,
1190
+ " ",
1191
+ l === 1 ? "conta" : "contas"
1192
+ ] })
1193
+ ]
1194
+ }
1195
+ );
1196
+ }
1197
+ function K(e, t, r = { bold: !0 }) {
1198
+ return [
1023
1199
  "stmt__row",
1024
1200
  `stmt__row--${e.type}`,
1025
- e.style.bold && "stmt__row--bold"
1201
+ r.bold && e.style.bold && "stmt__row--bold",
1202
+ t.collapsible && "stmt__row--section",
1203
+ t.collapsed && "stmt__row--collapsed"
1026
1204
  ].filter(Boolean).join(" ");
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) => {
1030
- var d;
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") }),
1035
- l && o != null && /* @__PURE__ */ r(
1205
+ }
1206
+ function Ee(e) {
1207
+ return e.type === "header" && e.formatted.length === 0;
1208
+ }
1209
+ function Rr({
1210
+ line: e,
1211
+ columnCount: t,
1212
+ showTotal: r,
1213
+ showVertical: n,
1214
+ showHorizontal: s,
1215
+ comparisonLabel: l,
1216
+ section: o
1217
+ }) {
1218
+ return e.type === "separator" ? /* @__PURE__ */ a("tr", { className: "stmt__row stmt__row--separator", children: /* @__PURE__ */ a("td", { colSpan: t }) }) : Ee(e) ? /* @__PURE__ */ _("tr", { className: K(e, o, { bold: !1 }), children: [
1219
+ /* @__PURE__ */ a(G, { line: e, section: o }),
1220
+ /* @__PURE__ */ a("td", { colSpan: t - 1 })
1221
+ ] }) : /* @__PURE__ */ _("tr", { className: K(e, o), children: [
1222
+ /* @__PURE__ */ a(G, { line: e, section: o }),
1223
+ e.formatted.map((i, d) => {
1224
+ var m;
1225
+ const c = e.horizontalAnalysis[d], u = (m = e.comparison) == null ? void 0 : m[d];
1226
+ return /* @__PURE__ */ _("td", { className: "stmt__value", children: [
1227
+ /* @__PURE__ */ a("span", { className: Z(e.values[d]), children: i }),
1228
+ n && e.verticalAnalysis[d] != null && /* @__PURE__ */ a("span", { className: "stmt__aux", title: "Análise vertical", children: D(e.verticalAnalysis[d], "percentage") }),
1229
+ s && c != null && /* @__PURE__ */ a(
1036
1230
  "span",
1037
1231
  {
1038
- className: `stmt__aux stmt__aux--${o < 0 ? "down" : "up"}`,
1232
+ className: `stmt__aux stmt__aux--${c < 0 ? "down" : "up"}`,
1039
1233
  title: "Variação sobre o período anterior",
1040
- children: z(o, "percentage")
1234
+ children: D(c, "percentage")
1041
1235
  }
1042
1236
  ),
1043
- s && h != null && /* @__PURE__ */ b(
1237
+ l && u != null && /* @__PURE__ */ _(
1044
1238
  "span",
1045
1239
  {
1046
- className: `stmt__aux stmt__aux--${h < 0 ? "down" : "up"}`,
1047
- title: s,
1240
+ className: `stmt__aux stmt__aux--${u < 0 ? "down" : "up"}`,
1241
+ title: l,
1048
1242
  children: [
1049
1243
  "vs ",
1050
- z(h, "percentage")
1244
+ D(u, "percentage")
1051
1245
  ]
1052
1246
  }
1053
1247
  )
1054
- ] }, m);
1248
+ ] }, d);
1055
1249
  }),
1056
- n && /* @__PURE__ */ r("td", { className: "stmt__value stmt__value--total", children: /* @__PURE__ */ r("span", { className: ue(e.total), children: e.totalFormatted ?? "-" }) })
1250
+ r && /* @__PURE__ */ a("td", { className: "stmt__value stmt__value--total", children: /* @__PURE__ */ a("span", { className: Z(e.total), children: e.totalFormatted ?? "-" }) })
1057
1251
  ] });
1058
1252
  }
1059
- function or({ token: e, palette: t, showDownload: n = !0, className: a }) {
1060
- const {
1061
- layout: l,
1062
- renderData: s,
1063
- loading: c,
1064
- error: i,
1065
- filters: m,
1066
- setFilter: o,
1067
- downloadPdf: h,
1068
- downloading: d
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)
1072
- };
1073
- let k;
1074
- if (i && !l)
1075
- k = /* @__PURE__ */ r("div", { className: "stmt__error", children: i });
1076
- else if (!l)
1077
- k = /* @__PURE__ */ r("div", { className: "stmt__state", children: "Carregando demonstrativo..." });
1078
- else {
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,
1253
+ function $r({
1254
+ name: e,
1255
+ columns: t,
1256
+ lines: r,
1257
+ showTotal: n,
1258
+ totalLabel: s,
1259
+ showVertical: l,
1260
+ showHorizontal: o,
1261
+ comparisonLabel: i,
1262
+ collapse: d
1263
+ }) {
1264
+ const c = R(null), u = I(() => t.map((h) => h.key), [t]), m = sr(c, u), p = x((h) => {
1265
+ const v = c.current;
1266
+ if (!v) return;
1267
+ const k = v.querySelector(`[data-period="${CSS.escape(h)}"]`);
1268
+ k == null || k.scrollIntoView({ inline: "center", block: "nearest", behavior: "smooth" });
1269
+ }, []), f = 1 + t.length + (n ? 1 : 0);
1270
+ return /* @__PURE__ */ _(V, { children: [
1271
+ t.length > 1 && /* @__PURE__ */ a("nav", { className: "stmt__periods", "aria-label": "Períodos", children: t.map((h) => {
1272
+ const v = h.key === m;
1273
+ return /* @__PURE__ */ a(
1274
+ "button",
1275
+ {
1276
+ type: "button",
1277
+ className: v ? "stmt__period stmt__period--current" : "stmt__period",
1278
+ "aria-current": v ? "true" : void 0,
1279
+ title: `${h.start} a ${h.end}`,
1280
+ onClick: () => p(h.key),
1281
+ children: h.label
1282
+ },
1283
+ h.key
1284
+ );
1285
+ }) }),
1286
+ /* @__PURE__ */ a("div", { className: "stmt__scroll", ref: c, children: /* @__PURE__ */ _("table", { className: "stmt__table", children: [
1287
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ _("tr", { children: [
1288
+ /* @__PURE__ */ a("th", { className: "stmt__corner", scope: "col", children: e }),
1289
+ t.map((h) => /* @__PURE__ */ a(
1290
+ "th",
1084
1291
  {
1085
- definition: g,
1086
- value: m[g.id] ?? "",
1087
- options: l.filterOptions[g.id] ?? [],
1088
- bounds: A,
1089
- rangeUnit: Zt[l.periods.granularity] ?? "day",
1090
- onChange: (I) => o(g.id, I)
1292
+ scope: "col",
1293
+ "data-period": h.key,
1294
+ title: `${h.start} a ${h.end}`,
1295
+ children: h.label
1091
1296
  },
1092
- g.id
1297
+ h.key
1093
1298
  )),
1094
- /* @__PURE__ */ b("div", { className: "stmt__toolbar-end", children: [
1095
- /* @__PURE__ */ b("span", { className: "stmt__bounds", children: [
1096
- "Base: ",
1097
- A.min,
1098
- " a ",
1099
- A.max
1100
- ] }),
1101
- n && /* @__PURE__ */ r(
1299
+ n && /* @__PURE__ */ a("th", { scope: "col", className: "stmt__total-head", children: s })
1300
+ ] }) }),
1301
+ /* @__PURE__ */ a("tbody", { children: r.map((h) => d.hidden.has(h.id) ? null : /* @__PURE__ */ a(
1302
+ Rr,
1303
+ {
1304
+ line: h,
1305
+ columnCount: f,
1306
+ showTotal: n,
1307
+ showVertical: l,
1308
+ showHorizontal: o,
1309
+ comparisonLabel: i,
1310
+ section: Me(h, d)
1311
+ },
1312
+ h.id
1313
+ )) })
1314
+ ] }) })
1315
+ ] });
1316
+ }
1317
+ function J(e) {
1318
+ return e.kind === "total" ? "total" : `period:${e.column.key}`;
1319
+ }
1320
+ function Ie(e) {
1321
+ return e.kind === "total" ? e.label : e.column.label;
1322
+ }
1323
+ function xr({ slots: e, selected: t, onSelect: r }) {
1324
+ const n = () => r(Math.max(0, t - 1)), s = () => r(Math.min(e.length - 1, t + 1));
1325
+ return /* @__PURE__ */ _("div", { className: "stmt__picker", role: "group", "aria-label": "Seleção de período", onKeyDown: (o) => {
1326
+ o.key === "ArrowLeft" ? (o.preventDefault(), n()) : o.key === "ArrowRight" && (o.preventDefault(), s());
1327
+ }, children: [
1328
+ /* @__PURE__ */ a(
1329
+ "button",
1330
+ {
1331
+ type: "button",
1332
+ className: "stmt__picker-arrow",
1333
+ "aria-label": "Período anterior",
1334
+ onClick: n,
1335
+ disabled: t <= 0,
1336
+ children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "‹" })
1337
+ }
1338
+ ),
1339
+ /* @__PURE__ */ a(
1340
+ "select",
1341
+ {
1342
+ className: "stmt__picker-select",
1343
+ "aria-label": "Período",
1344
+ value: String(t),
1345
+ onChange: (o) => r(Number(o.target.value)),
1346
+ children: e.map((o, i) => /* @__PURE__ */ a("option", { value: String(i), children: Ie(o) }, J(o)))
1347
+ }
1348
+ ),
1349
+ /* @__PURE__ */ a(
1350
+ "button",
1351
+ {
1352
+ type: "button",
1353
+ className: "stmt__picker-arrow",
1354
+ "aria-label": "Próximo período",
1355
+ onClick: s,
1356
+ disabled: t >= e.length - 1,
1357
+ children: /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" })
1358
+ }
1359
+ )
1360
+ ] });
1361
+ }
1362
+ function Tr({ line: e, index: t, previous: r }) {
1363
+ const n = e.horizontalAnalysis[t];
1364
+ if (n != null)
1365
+ return /* @__PURE__ */ _("span", { className: ge(n), title: `Variação sobre ${r.label}`, children: [
1366
+ /* @__PURE__ */ a("span", { className: "stmt__aux-number", children: D(n, "percentage") }),
1367
+ " ",
1368
+ /* @__PURE__ */ _("span", { className: "stmt__aux-label", children: [
1369
+ "vs ",
1370
+ r.label
1371
+ ] })
1372
+ ] });
1373
+ const s = e.formatted[t - 1];
1374
+ return s == null ? null : /* @__PURE__ */ _("span", { className: ge(e.values[t - 1]), title: `Valor em ${r.label}`, children: [
1375
+ /* @__PURE__ */ _("span", { className: "stmt__aux-label", children: [
1376
+ r.label,
1377
+ ":"
1378
+ ] }),
1379
+ " ",
1380
+ /* @__PURE__ */ a("span", { className: "stmt__aux-number", children: s })
1381
+ ] });
1382
+ }
1383
+ function Pr({ line: e, slot: t, previous: r, compare: n, section: s }) {
1384
+ if (e.type === "separator")
1385
+ return /* @__PURE__ */ a("tr", { className: "stmt__row stmt__row--separator", children: /* @__PURE__ */ a("td", { colSpan: 2 }) });
1386
+ if (Ee(e))
1387
+ return /* @__PURE__ */ _("tr", { className: K(e, s, { bold: !1 }), children: [
1388
+ /* @__PURE__ */ a(G, { line: e, section: s, indentStep: _e }),
1389
+ /* @__PURE__ */ a("td", {})
1390
+ ] });
1391
+ const l = t.kind === "total", o = l ? e.total : e.values[t.index], i = l ? e.totalFormatted ?? "-" : e.formatted[t.index];
1392
+ return /* @__PURE__ */ _("tr", { className: K(e, s), children: [
1393
+ /* @__PURE__ */ a(G, { line: e, section: s, indentStep: _e }),
1394
+ /* @__PURE__ */ _("td", { className: l ? "stmt__value stmt__value--total" : "stmt__value", children: [
1395
+ /* @__PURE__ */ a("span", { className: Z(o), children: i }),
1396
+ n && t.kind === "period" && r && /* @__PURE__ */ a(Tr, { line: e, index: t.index, previous: r })
1397
+ ] })
1398
+ ] });
1399
+ }
1400
+ function Ar({ name: e, columns: t, lines: r, showTotal: n, totalLabel: s, collapse: l }) {
1401
+ const o = I(() => {
1402
+ const y = t.map((w, C) => ({ kind: "period", index: C, column: w }));
1403
+ return n && y.push({ kind: "total", label: s }), y;
1404
+ }, [t, n, s]), [i, d] = T(null), [c, u] = T(!0), m = t.length - 1, p = i == null ? -1 : o.findIndex((y) => J(y) === i), f = p >= 0 ? p : m, h = o[f], v = h.kind === "period" && h.index > 0 ? t[h.index - 1] : null, k = x((y) => {
1405
+ const w = o[y];
1406
+ w && d(J(w));
1407
+ }, [o]);
1408
+ return /* @__PURE__ */ _(V, { children: [
1409
+ /* @__PURE__ */ a(xr, { slots: o, selected: f, onSelect: k }),
1410
+ /* @__PURE__ */ _("label", { className: "stmt__compare", children: [
1411
+ /* @__PURE__ */ a(
1412
+ "input",
1413
+ {
1414
+ type: "checkbox",
1415
+ checked: c,
1416
+ onChange: (y) => u(y.target.checked)
1417
+ }
1418
+ ),
1419
+ "Comparar com o anterior"
1420
+ ] }),
1421
+ /* @__PURE__ */ a("div", { className: "stmt__scroll", children: /* @__PURE__ */ _("table", { className: "stmt__list", children: [
1422
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ _("tr", { children: [
1423
+ /* @__PURE__ */ a("th", { scope: "col", className: "stmt__list-name", children: e }),
1424
+ /* @__PURE__ */ a("th", { scope: "col", className: "stmt__list-period", "aria-live": "polite", "aria-atomic": "true", children: Ie(h) })
1425
+ ] }) }),
1426
+ /* @__PURE__ */ a("tbody", { children: r.map((y) => l.hidden.has(y.id) ? null : /* @__PURE__ */ a(
1427
+ Pr,
1428
+ {
1429
+ line: y,
1430
+ slot: h,
1431
+ previous: v,
1432
+ compare: c,
1433
+ section: Me(y, l)
1434
+ },
1435
+ y.id
1436
+ )) })
1437
+ ] }) })
1438
+ ] });
1439
+ }
1440
+ function Mr({
1441
+ layout: e,
1442
+ renderData: t,
1443
+ loading: r,
1444
+ error: n,
1445
+ filters: s,
1446
+ setFilter: l,
1447
+ downloadPdf: o,
1448
+ downloading: i,
1449
+ showDownload: d,
1450
+ mode: c
1451
+ }) {
1452
+ const u = (t == null ? void 0 : t.dateBounds) ?? e.dateBounds, m = e.periods.showTotal, p = (t == null ? void 0 : t.columns) ?? Nr, f = (t == null ? void 0 : t.lines) ?? Sr, h = ur(f), [v, k] = T(!1), y = f.some((N) => N.verticalAnalysis.length > 0), w = f.some((N) => N.horizontalAnalysis.length > 0), C = e.periods.comparisonOffset, $ = C ? kr(C, e.periods.granularity) : void 0, P = wr - (m ? 1 : 0), E = Math.max(0, p.length - P), b = /* @__PURE__ */ _("span", { className: "stmt__meta stmt__bounds", children: [
1453
+ "Base: ",
1454
+ u.min,
1455
+ " a ",
1456
+ u.max
1457
+ ] });
1458
+ let g;
1459
+ return t ? p.length === 0 ? g = /* @__PURE__ */ a("div", { className: "stmt__state", children: "Nenhum período na janela selecionada." }) : f.length === 0 ? g = /* @__PURE__ */ a("div", { className: "stmt__state", children: "Este demonstrativo não possui linhas." }) : c === "periods" ? g = /* @__PURE__ */ a(
1460
+ Ar,
1461
+ {
1462
+ name: t.name,
1463
+ columns: p,
1464
+ lines: f,
1465
+ showTotal: m,
1466
+ totalLabel: e.periods.totalLabel,
1467
+ collapse: h
1468
+ }
1469
+ ) : g = /* @__PURE__ */ a(
1470
+ $r,
1471
+ {
1472
+ name: t.name,
1473
+ columns: p,
1474
+ lines: f,
1475
+ showTotal: m,
1476
+ totalLabel: e.periods.totalLabel,
1477
+ showVertical: y,
1478
+ showHorizontal: w,
1479
+ comparisonLabel: $,
1480
+ collapse: h
1481
+ }
1482
+ ) : g = /* @__PURE__ */ a("div", { className: "stmt__state", children: "Calculando..." }), /* @__PURE__ */ _(V, { children: [
1483
+ /* @__PURE__ */ _("div", { className: "stmt__toolbar", children: [
1484
+ e.filters.map((N) => /* @__PURE__ */ a(
1485
+ yr,
1486
+ {
1487
+ definition: N,
1488
+ value: s[N.id] ?? "",
1489
+ options: e.filterOptions[N.id] ?? [],
1490
+ bounds: u,
1491
+ rangeUnit: vr[e.periods.granularity] ?? "day",
1492
+ onChange: (A) => l(N.id, A)
1493
+ },
1494
+ N.id
1495
+ )),
1496
+ /* @__PURE__ */ _("div", { className: "stmt__toolbar-end", children: [
1497
+ c === "table" && b,
1498
+ h.hasSections && /* @__PURE__ */ _(V, { children: [
1499
+ /* @__PURE__ */ a(
1102
1500
  "button",
1103
1501
  {
1104
1502
  type: "button",
1105
- className: "stmt__download",
1106
- onClick: () => {
1107
- if (F > 0 && !f) {
1108
- p(!0);
1109
- return;
1110
- }
1111
- p(!1), h();
1112
- },
1113
- disabled: d || !s,
1114
- title: "Baixar o documento em PDF",
1115
- children: d ? "Gerando..." : "Baixar PDF"
1503
+ className: "stmt__outline",
1504
+ onClick: h.collapseToSummary,
1505
+ children: "Recolher seções"
1506
+ }
1507
+ ),
1508
+ /* @__PURE__ */ a(
1509
+ "button",
1510
+ {
1511
+ type: "button",
1512
+ className: "stmt__outline",
1513
+ onClick: h.expandAll,
1514
+ children: "Expandir tudo"
1116
1515
  }
1117
1516
  )
1118
- ] })
1119
- ] }),
1120
- i && /* @__PURE__ */ r("div", { className: "stmt__error", children: i }),
1121
- f && F > 0 && /* @__PURE__ */ b("div", { className: "stmt__warning", children: [
1122
- "O PDF cabe ",
1123
- C,
1124
- " períodos e este documento tem ",
1125
- w.length,
1126
- ": o arquivo sairá com os ",
1127
- C,
1128
- " mais recentes",
1129
- y && ", e a coluna de total seguirá cobrindo a janela inteira",
1130
- '. Clique em "Baixar PDF" de novo para gerar assim, ou reduza o período.'
1131
- ] }),
1132
- (s == null ? void 0 : s.truncated) && /* @__PURE__ */ b("div", { className: "stmt__warning", children: [
1133
- "A janela pedida excede o limite de colunas: o documento mostra as primeiras ",
1134
- w.length,
1135
- ". Escolha um período menor ou uma coluna mais larga."
1136
- ] }),
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: [
1139
- /* @__PURE__ */ r("th", { className: "stmt__corner", scope: "col", children: s.name }),
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 })
1142
- ] }) }),
1143
- /* @__PURE__ */ r("tbody", { children: N.map((g) => /* @__PURE__ */ r(
1144
- rr,
1517
+ ] }),
1518
+ d && /* @__PURE__ */ a(
1519
+ "button",
1145
1520
  {
1146
- line: g,
1147
- columnCount: T,
1148
- showTotal: y,
1149
- showVertical: x,
1150
- showHorizontal: _,
1151
- comparisonLabel: R
1152
- },
1153
- g.id
1154
- )) })
1155
- ] }) }) : /* @__PURE__ */ r("div", { className: "stmt__state", children: "Calculando..." }),
1156
- c && s && /* @__PURE__ */ r("div", { className: "stmt__recalculating", children: "Atualizando..." })
1157
- ] });
1158
- }
1159
- return /* @__PURE__ */ r("div", { className: v, style: S, children: k });
1521
+ type: "button",
1522
+ className: "stmt__download",
1523
+ onClick: () => {
1524
+ if (E > 0 && !v) {
1525
+ k(!0);
1526
+ return;
1527
+ }
1528
+ k(!1), o();
1529
+ },
1530
+ disabled: i || !t,
1531
+ title: "Baixar o documento em PDF",
1532
+ children: i ? "Gerando..." : "Baixar PDF"
1533
+ }
1534
+ )
1535
+ ] })
1536
+ ] }),
1537
+ n && /* @__PURE__ */ a("div", { className: "stmt__error", children: n }),
1538
+ v && E > 0 && /* @__PURE__ */ _("div", { className: "stmt__warning", children: [
1539
+ "O PDF cabe ",
1540
+ P,
1541
+ " períodos e este documento tem ",
1542
+ p.length,
1543
+ ": o arquivo sairá com os ",
1544
+ P,
1545
+ " mais recentes",
1546
+ m && ", e a coluna de total seguirá cobrindo a janela inteira",
1547
+ '. Clique em "Baixar PDF" de novo para gerar assim, ou reduza o período.'
1548
+ ] }),
1549
+ (t == null ? void 0 : t.truncated) && /* @__PURE__ */ _("div", { className: "stmt__warning", children: [
1550
+ "A janela pedida excede o limite de colunas: o documento mostra as primeiras ",
1551
+ p.length,
1552
+ ". Escolha um período menor ou uma coluna mais larga."
1553
+ ] }),
1554
+ g,
1555
+ c === "periods" && b,
1556
+ r && t && /* @__PURE__ */ a("div", { className: "stmt__recalculating", children: "Atualizando..." })
1557
+ ] });
1558
+ }
1559
+ function Wr({
1560
+ token: e,
1561
+ palette: t,
1562
+ showDownload: r = !0,
1563
+ layout: n = "auto",
1564
+ className: s
1565
+ }) {
1566
+ const {
1567
+ layout: l,
1568
+ renderData: o,
1569
+ loading: i,
1570
+ error: d,
1571
+ filters: c,
1572
+ setFilter: u,
1573
+ downloadPdf: m,
1574
+ downloading: p
1575
+ } = rr(e), { ref: f, narrow: h } = fr(n === "auto"), v = n === "auto" ? h ? "periods" : "table" : n, k = ["stmt", `stmt--${v}`, s].filter(Boolean).join(" "), y = {
1576
+ ...t ? Se(t) : {},
1577
+ ...br(l == null ? void 0 : l.colors)
1578
+ };
1579
+ let w;
1580
+ return d && !l ? w = /* @__PURE__ */ a("div", { className: "stmt__error", children: d }) : l ? w = /* @__PURE__ */ a(
1581
+ Mr,
1582
+ {
1583
+ layout: l,
1584
+ renderData: o,
1585
+ loading: i,
1586
+ error: d,
1587
+ filters: c,
1588
+ setFilter: u,
1589
+ downloadPdf: m,
1590
+ downloading: p,
1591
+ showDownload: r,
1592
+ mode: v
1593
+ }
1594
+ ) : w = /* @__PURE__ */ a("div", { className: "stmt__state", children: "Carregando demonstrativo..." }), /* @__PURE__ */ a("div", { ref: f, className: k, style: y, children: w });
1160
1595
  }
1161
1596
  export {
1162
- ur as ApiError,
1163
- ir as Dashboard,
1164
- or as Statement
1597
+ Hr as ApiError,
1598
+ Or as Dashboard,
1599
+ Wr as Statement
1165
1600
  };
1166
1601
  //# sourceMappingURL=index.js.map