@actionexec/dashboards 0.15.0 → 0.16.1

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.
@@ -0,0 +1,853 @@
1
+ import { jsx as u, jsxs as T } from "react/jsx-runtime";
2
+ import oe from "react-datepicker";
3
+ import { useState as I, useRef as H, useMemo as j, useLayoutEffect as ce, useEffect as ie } from "react";
4
+ import { createPortal as le } from "react-dom";
5
+ const ue = "https://action-data-api-7mbrztperq-rj.a.run.app", V = "/external/dashboards", C = "/external/statements";
6
+ let J = ue;
7
+ function ve(e) {
8
+ J = e.replace(/\/$/, "");
9
+ }
10
+ class fe extends Error {
11
+ constructor(t, n, a) {
12
+ super(t), this.status = n, this.payload = a, this.name = "ApiError";
13
+ }
14
+ }
15
+ async function X(e, t, n, a) {
16
+ const r = new URL(`${J}${e}${t}`);
17
+ if (a)
18
+ for (const [c, i] of Object.entries(a)) r.searchParams.set(c, i);
19
+ const s = await fetch(r.toString(), {
20
+ headers: { Authorization: `Bearer ${n}` }
21
+ });
22
+ if (!s.ok) {
23
+ let c;
24
+ try {
25
+ c = await s.json();
26
+ } catch {
27
+ }
28
+ throw new fe(
29
+ `Requisicao falhou (${s.status}) em ${t}`,
30
+ s.status,
31
+ c
32
+ );
33
+ }
34
+ return s;
35
+ }
36
+ async function R(e, t, n, a) {
37
+ return await (await X(e, t, n, a)).json();
38
+ }
39
+ const Ue = (e) => R(V, "/layout", e), Ye = (e, t) => R(V, "/render", e, t), Ge = (e) => R(C, "/layout", e), We = (e, t) => R(C, "/render", e, t), He = async (e, t) => (await X(C, "/pdf", e, t)).blob(), d = {
40
+ series0: 0,
41
+ series1: 1,
42
+ series2: 2,
43
+ series3: 3,
44
+ series4: 4,
45
+ bgDark: 5,
46
+ bgPaper: 6,
47
+ bgElevated: 7,
48
+ textPrimary: 8,
49
+ textMuted: 9,
50
+ accent: 10,
51
+ success: 11,
52
+ error: 12,
53
+ // Alerta e informacao tem slot proprio: derivá-los de cores de serie fazia
54
+ // trocar a cor de uma serie mudar o significado semantico de "atencao".
55
+ warning: 13,
56
+ info: 14
57
+ }, de = 5, M = 15, me = {
58
+ series0: "Série 1",
59
+ series1: "Série 2",
60
+ series2: "Série 3",
61
+ series3: "Série 4",
62
+ series4: "Série 5",
63
+ bgDark: "Fundo Escuro",
64
+ bgPaper: "Fundo Cartão",
65
+ bgElevated: "Fundo Elevado",
66
+ textPrimary: "Texto Primário",
67
+ textMuted: "Texto Secundário",
68
+ accent: "Destaque",
69
+ success: "Sucesso",
70
+ error: "Erro",
71
+ warning: "Alerta",
72
+ info: "Informação"
73
+ }, O = {
74
+ action: {
75
+ label: "Action",
76
+ colors: [
77
+ "#ff6b00",
78
+ "#a3e635",
79
+ "#e3f544",
80
+ "#65ffd1",
81
+ "#ff0404",
82
+ "#1a1a1a",
83
+ "#262626",
84
+ "#333333",
85
+ "#f5f5f5",
86
+ "#999999",
87
+ "#ff6b00",
88
+ "#a3e635",
89
+ "#ef4444",
90
+ "#f59e0b",
91
+ "#38bdf8"
92
+ ]
93
+ },
94
+ westCoast: {
95
+ label: "West Coast",
96
+ colors: [
97
+ "#a3b86c",
98
+ "#c89b3c",
99
+ "#8b6f47",
100
+ "#6b8e23",
101
+ "#d2691e",
102
+ "#1f1a14",
103
+ "#2a241b",
104
+ "#3a3225",
105
+ "#e8dcc4",
106
+ "#a89878",
107
+ "#c89b3c",
108
+ "#a3b86c",
109
+ "#c44536",
110
+ "#d99a2b",
111
+ "#7c9bb5"
112
+ ]
113
+ },
114
+ mono: {
115
+ label: "Monocromático",
116
+ colors: [
117
+ "#f8fafc",
118
+ "#cbd5e1",
119
+ "#94a3b8",
120
+ "#64748b",
121
+ "#475569",
122
+ "#0a0a0a",
123
+ "#171717",
124
+ "#262626",
125
+ "#fafafa",
126
+ "#a3a3a3",
127
+ "#e5e5e5",
128
+ "#cbd5e1",
129
+ "#ef4444",
130
+ "#facc15",
131
+ "#7dd3fc"
132
+ ]
133
+ },
134
+ ocean: {
135
+ label: "Ocean",
136
+ colors: [
137
+ "#0ea5e9",
138
+ "#06b6d4",
139
+ "#0891b2",
140
+ "#3b82f6",
141
+ "#22d3ee",
142
+ "#0a1929",
143
+ "#0f2740",
144
+ "#173554",
145
+ "#e0f2fe",
146
+ "#7dd3fc",
147
+ "#22d3ee",
148
+ "#10b981",
149
+ "#f43f5e",
150
+ "#fbbf24",
151
+ "#60a5fa"
152
+ ]
153
+ },
154
+ princess: {
155
+ label: "Cute Pink",
156
+ colors: [
157
+ "#ff79bc",
158
+ "#a855f7",
159
+ "#f472b6",
160
+ "#d946ef",
161
+ "#fb7185",
162
+ "#fff0f6",
163
+ "#ffe4ec",
164
+ "#ffffff",
165
+ "#ff4099",
166
+ "#ffadd5",
167
+ "#ec4899",
168
+ "#10b981",
169
+ "#e11d48",
170
+ "#f59e0b",
171
+ "#8b5cf6"
172
+ ]
173
+ }
174
+ }, B = O.action.colors;
175
+ function A(e) {
176
+ const t = B;
177
+ if (!e || e.length === 0) return [...t];
178
+ if (e.length >= M) return e.slice(0, M);
179
+ const n = [...e];
180
+ for (let a = e.length; a < M; a++) n.push(t[a]);
181
+ return n;
182
+ }
183
+ function ge(e) {
184
+ return A(e).slice(0, de);
185
+ }
186
+ function je(e) {
187
+ const t = A(e);
188
+ return {
189
+ "--bg-dark": t[d.bgDark],
190
+ "--bg-paper": t[d.bgPaper],
191
+ "--bg-elevated": t[d.bgElevated],
192
+ "--text-primary": t[d.textPrimary],
193
+ "--text-secondary": t[d.textMuted],
194
+ "--text-muted": t[d.textMuted],
195
+ "--color-accent": t[d.accent],
196
+ "--color-success": t[d.success],
197
+ "--color-error": t[d.error],
198
+ "--color-warning": t[d.warning],
199
+ "--color-info": t[d.info],
200
+ // Aliases historicos, mantidos para nao quebrar CSS de consumidores.
201
+ "--action-orange": t[d.accent],
202
+ "--action-green": t[d.success]
203
+ };
204
+ }
205
+ const pe = B, be = 30, _e = 10, ze = {
206
+ gridColumns: be,
207
+ gridRows: _e,
208
+ widgets: []
209
+ }, qe = {
210
+ kpi_card: "Card",
211
+ gauge: "Gauge",
212
+ chart: "Gráfico",
213
+ composition: "Composição",
214
+ table: "Tabela",
215
+ filter: "Filtro",
216
+ variable: "Variável",
217
+ color_palette: "Paleta de Cores"
218
+ }, Ve = ["kpi_card", "gauge", "chart", "composition", "table"], Je = ["filter", "variable", "color_palette"], Xe = /* @__PURE__ */ new Set(["filter", "variable", "color_palette"]), Be = {
219
+ day: ["dia", "dias"],
220
+ week: ["semana", "semanas"],
221
+ month: ["mês", "meses"],
222
+ quarter: ["trimestre", "trimestres"],
223
+ year: ["ano", "anos"]
224
+ }, Ke = ["período", "períodos"], Qe = {
225
+ sum: "Soma",
226
+ avg: "Média",
227
+ count: "Contagem",
228
+ min: "Mínimo",
229
+ max: "Máximo",
230
+ count_distinct: "Contagem Distinta"
231
+ }, he = {
232
+ currency: "Moeda (R$)",
233
+ number: "Número",
234
+ integer: "Inteiro",
235
+ percentage: "Porcentagem",
236
+ date: "Data",
237
+ text: "Texto"
238
+ }, Ze = Object.entries(he).filter(([e]) => e !== "date" && e !== "text"), et = {
239
+ variance: "Variação %",
240
+ difference: "Diferença",
241
+ ratio: "Proporção",
242
+ value: "Base"
243
+ }, tt = {
244
+ scroll: "Rolar",
245
+ clip: "Cortar"
246
+ }, nt = {
247
+ higher: "Positivo",
248
+ lower: "Negativo",
249
+ neutral: "Neutro"
250
+ }, at = {
251
+ eq: "Igual a",
252
+ neq: "Diferente de",
253
+ in: "Está entre os valores",
254
+ not_in: "Não está entre os valores",
255
+ gt: "Maior que",
256
+ gte: "Maior ou igual a",
257
+ lt: "Menor que",
258
+ lte: "Menor ou igual a",
259
+ between: "Entre (faixa numérica)",
260
+ contains: "Contém",
261
+ not_contains: "Não contém",
262
+ is_empty: "Está vazio",
263
+ not_empty: "Não está vazio"
264
+ }, rt = ["is_empty", "not_empty"], st = ["in", "not_in"], ot = {
265
+ bar: "Barras",
266
+ line: "Linhas",
267
+ area: "Área"
268
+ }, ct = {
269
+ pie: "Pizza",
270
+ bridge: "Ponte"
271
+ }, it = {
272
+ descending: "Descendente",
273
+ ascending: "Ascendente"
274
+ }, lt = {
275
+ date_range: "Periodo",
276
+ select: "Seleção Única",
277
+ multi_select: "Seleção Múltipla"
278
+ }, z = "", ut = {
279
+ kpi_card: { x: 0, y: 0, w: 6, h: 3 },
280
+ gauge: { x: 0, y: 0, w: 6, h: 5 },
281
+ chart: { x: 0, y: 0, w: 6, h: 6 },
282
+ composition: { x: 0, y: 0, w: 6, h: 6 },
283
+ table: { x: 0, y: 0, w: 12, h: 7 },
284
+ filter: { x: 0, y: 0, w: 4, h: 2 },
285
+ variable: { x: 0, y: 0, w: 4, h: 2 },
286
+ color_palette: { x: 0, y: 0, w: 4, h: 2 }
287
+ }, ft = {
288
+ kpi_card: { label: "Novo card", aggregation: "sum", format: "number" },
289
+ gauge: { label: "Novo Gauge", aggregation: "sum" },
290
+ chart: { label: "Novo gráfico", chartType: "bar", xAxis: { column: "", granularity: "day" }, series: [] },
291
+ composition: {
292
+ label: "Nova composição",
293
+ display: "pie",
294
+ categories: [],
295
+ direction: "descending"
296
+ },
297
+ table: { label: "Nova Tabela", columns: [] },
298
+ filter: { label: "Novo Filtro", filterType: "select" },
299
+ variable: { label: "Nova Variavel", variableValue: 0, variableFormat: "number", locked: !1 },
300
+ color_palette: { label: "Paleta de Cores", paletteColors: pe, locked: !1 }
301
+ }, k = 6, v = 16, U = 1, x = 24, Ee = 80, Te = (e, t, n) => Math.min(Math.max(e, t), n), S = (e) => Number.isFinite(e) && e > 0;
302
+ function dt(e, t, n = k, a = v) {
303
+ if (!S(t) || !Number.isFinite(e)) return 0;
304
+ const r = e - a * 2 - n * (t - 1);
305
+ return Math.max(0, r / t);
306
+ }
307
+ function mt(e, t = U) {
308
+ return !S(e) || !S(t) ? x : Te(e / t, x, Ee);
309
+ }
310
+ function gt(e, t, n = k, a = v) {
311
+ return e <= 0 ? a * 2 : e * t + (e - 1) * n + a * 2;
312
+ }
313
+ function pt(e, t, n = U) {
314
+ return !S(e) || !S(t) || !S(n) ? 1 : e * n / t;
315
+ }
316
+ function bt(e, t = U, n = k, a = v) {
317
+ return !S(e) || !S(t) ? 0 : x * t * e + n * (e - 1) + a * 2;
318
+ }
319
+ const $ = "pt-BR", Se = 100, we = /* @__PURE__ */ new Set(["currency", "number", "integer", "percentage"]), ye = new Intl.NumberFormat($, { style: "currency", currency: "BRL" }), De = new Intl.NumberFormat($), Le = new Intl.NumberFormat($, { maximumFractionDigits: 1 }), K = new Intl.NumberFormat($, { maximumFractionDigits: 2 });
320
+ function _t(e) {
321
+ return !!e && we.has(e);
322
+ }
323
+ function Q(e) {
324
+ if (e == null || e === "") return null;
325
+ const t = typeof e == "number" ? e : Number(e);
326
+ return Number.isFinite(t) ? t : null;
327
+ }
328
+ function Ne(e, t, n = "-") {
329
+ if (e == null || e === "") return n;
330
+ const a = Q(e);
331
+ if (a === null) return String(e);
332
+ switch (t) {
333
+ case "currency":
334
+ return ye.format(a);
335
+ case "integer":
336
+ return De.format(Math.round(a));
337
+ case "percentage":
338
+ return `${Le.format(a * Se)}%`;
339
+ case "number":
340
+ return K.format(a);
341
+ default:
342
+ return String(e);
343
+ }
344
+ }
345
+ function ht(e, t) {
346
+ const n = Q(e);
347
+ if (n === null) return "-";
348
+ if (t === "percentage") return Ne(n, "percentage");
349
+ const a = t === "currency" ? "R$ " : "", r = Math.abs(n);
350
+ return r >= 1e9 ? `${a}${(n / 1e9).toFixed(1)}B` : r >= 1e6 ? `${a}${(n / 1e6).toFixed(1)}M` : r >= 1e3 ? `${a}${(n / 1e3).toFixed(1)}K` : `${a}${K.format(n)}`;
351
+ }
352
+ const Ae = [
353
+ "Jan",
354
+ "Fev",
355
+ "Mar",
356
+ "Abr",
357
+ "Mai",
358
+ "Jun",
359
+ "Jul",
360
+ "Ago",
361
+ "Set",
362
+ "Out",
363
+ "Nov",
364
+ "Dez"
365
+ ], Et = [
366
+ "Janeiro",
367
+ "Fevereiro",
368
+ "Marco",
369
+ "Abril",
370
+ "Maio",
371
+ "Junho",
372
+ "Julho",
373
+ "Agosto",
374
+ "Setembro",
375
+ "Outubro",
376
+ "Novembro",
377
+ "Dezembro"
378
+ ];
379
+ function Tt(e) {
380
+ return { start: `${e}-01-01`, end: `${e}-12-31` };
381
+ }
382
+ function St(e) {
383
+ if (!e) return null;
384
+ const t = e.match(/^(\d{4})/);
385
+ return t ? { year: parseInt(t[1]) } : null;
386
+ }
387
+ function Me(e, t) {
388
+ const n = new Date(e, t, 0).getDate(), a = (r) => String(r).padStart(2, "0");
389
+ return {
390
+ start: `${e}-${a(t)}-01`,
391
+ end: `${e}-${a(t)}-${a(n)}`
392
+ };
393
+ }
394
+ function Y(e) {
395
+ const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
396
+ t.setUTCDate(t.getUTCDate() + 4 - (t.getUTCDay() || 7));
397
+ const n = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
398
+ return Math.ceil(((t.getTime() - n.getTime()) / 864e5 + 1) / 7);
399
+ }
400
+ function wt(e, t) {
401
+ const n = new Date(e, 0, 4), a = (n.getDay() + 6) % 7, r = new Date(n.getTime() - a * 864e5), s = new Date(r.getTime() + (t - 1) * 7 * 864e5), c = new Date(s.getTime() + 6 * 864e5), i = (b) => String(b).padStart(2, "0"), m = (b) => `${b.getFullYear()}-${i(b.getMonth() + 1)}-${i(b.getDate())}`;
402
+ return { start: m(s), end: m(c) };
403
+ }
404
+ function yt(e, t) {
405
+ const n = /* @__PURE__ */ new Set(), a = new Date(e, t, 0).getDate();
406
+ for (let r = 1; r <= a; r++)
407
+ n.add(Y(new Date(e, t - 1, r)));
408
+ return Array.from(n).sort((r, s) => r - s);
409
+ }
410
+ function Dt(e, t) {
411
+ const n = new Date(e, t, 0).getDate(), a = (i) => String(i).padStart(2, "0"), r = [];
412
+ let s = 1, c = 1;
413
+ for (; s <= n; ) {
414
+ const i = s, m = Math.min(s + 6, n), b = `${e}-${a(t)}-${a(i)}`, l = `${e}-${a(t)}-${a(m)}`, f = `${c}° Semana (${a(i)}/${a(t)} - ${a(m)}/${a(t)})`;
415
+ r.push({ index: c, startDay: i, endDay: m, start: b, end: l, label: f }), s = m + 1, c++;
416
+ }
417
+ return r;
418
+ }
419
+ function Lt(e, t, n) {
420
+ if (!e) return 1;
421
+ const a = (c) => String(c).padStart(2, "0"), r = e.match(new RegExp(`^${t}-${a(n)}-(\\d{2})`));
422
+ if (!r) return 1;
423
+ const s = parseInt(r[1]);
424
+ return Math.ceil(s / 7);
425
+ }
426
+ function Nt(e) {
427
+ if (!e) return null;
428
+ const t = e.match(/^(\d{4})-(\d{2})/);
429
+ return t ? { year: parseInt(t[1]), month: parseInt(t[2]) } : null;
430
+ }
431
+ function At(e) {
432
+ if (!e) return null;
433
+ const t = /* @__PURE__ */ new Date(e + "T00:00:00");
434
+ return isNaN(t.getTime()) ? null : { year: t.getFullYear(), week: Y(t) };
435
+ }
436
+ function Mt(e) {
437
+ const t = /* @__PURE__ */ new Date(), n = e != null && e.min ? parseInt(e.min.slice(0, 4)) : t.getFullYear() - 2, a = e != null && e.max ? parseInt(e.max.slice(0, 4)) : t.getFullYear(), r = [];
438
+ for (let s = a; s >= n; s--) r.push(s);
439
+ return r;
440
+ }
441
+ const h = (e) => String(e).padStart(2, "0");
442
+ function L(e) {
443
+ return `${e.getFullYear()}-${h(e.getMonth() + 1)}-${h(e.getDate())}`;
444
+ }
445
+ function P(e) {
446
+ const [t, n, a] = e.split("-").map(Number);
447
+ return new Date(t, (n || 1) - 1, a || 1);
448
+ }
449
+ function q(e, t) {
450
+ const n = e.getFullYear();
451
+ if (t === "year")
452
+ return { key: `${n}`, label: `${n}`, start: `${n}-01-01`, end: `${n}-12-31` };
453
+ if (t === "month") {
454
+ const a = e.getMonth() + 1, r = Me(n, a);
455
+ return {
456
+ key: `${n}-${h(a)}`,
457
+ label: `${Ae[a - 1].toLowerCase()}/${h(n % 100)}`,
458
+ ...r
459
+ };
460
+ }
461
+ if (t === "week") {
462
+ const a = new Date(e.getTime() - (e.getDay() + 6) % 7 * 864e5), r = new Date(a.getTime() + 6 * 864e5), s = Y(a);
463
+ return {
464
+ key: `${a.getFullYear()}-W${h(s)}`,
465
+ label: `S${h(s)}/${h(a.getFullYear() % 100)}`,
466
+ start: L(a),
467
+ end: L(r)
468
+ };
469
+ }
470
+ return {
471
+ key: L(e),
472
+ label: `${h(e.getDate())}/${h(e.getMonth() + 1)}/${h(n % 100)}`,
473
+ start: L(e),
474
+ end: L(e)
475
+ };
476
+ }
477
+ const Oe = 400;
478
+ function Ot(e, t) {
479
+ const n = /* @__PURE__ */ new Date(), a = t != null && t.min ? P(t.min) : new Date(n.getFullYear() - 1, 0, 1), r = t != null && t.max ? P(t.max) : n;
480
+ if (a > r) return [];
481
+ const s = [];
482
+ let c = q(r, e);
483
+ for (; s.length < Oe; ) {
484
+ s.push(c);
485
+ const i = P(c.start);
486
+ if (i.setDate(i.getDate() - 1), i < a) break;
487
+ c = q(i, e);
488
+ }
489
+ return s;
490
+ }
491
+ function N(e) {
492
+ if (!e) return null;
493
+ const [t, n, a] = e.split("-").map(Number);
494
+ return !t || !n || !a ? null : new Date(t, n - 1, a);
495
+ }
496
+ function Re(e) {
497
+ if (!e) return "";
498
+ const t = e.getFullYear(), n = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
499
+ return `${t}-${n}-${a}`;
500
+ }
501
+ function Rt({
502
+ value: e,
503
+ onChange: t,
504
+ minIso: n,
505
+ maxIso: a,
506
+ placeholder: r,
507
+ selectsStart: s,
508
+ selectsEnd: c,
509
+ startIso: i,
510
+ endIso: m,
511
+ className: b,
512
+ disabled: l
513
+ }) {
514
+ return /* @__PURE__ */ u("div", { className: `ddp-field ${b ?? ""}`, children: /* @__PURE__ */ u(
515
+ oe,
516
+ {
517
+ selected: N(e),
518
+ onChange: (f) => t(Re(f)),
519
+ selectsStart: s,
520
+ selectsEnd: c,
521
+ startDate: N(i) ?? void 0,
522
+ endDate: N(m) ?? void 0,
523
+ minDate: N(n) ?? void 0,
524
+ maxDate: N(a) ?? void 0,
525
+ dateFormat: "dd/MM/yyyy",
526
+ placeholderText: r ?? "Selecione...",
527
+ disabled: l,
528
+ portalId: "ddp-portal",
529
+ popperPlacement: "bottom-start",
530
+ popperModifiers: [
531
+ {
532
+ name: "flip",
533
+ options: { fallbackPlacements: ["bottom-end", "top-start", "top-end"] },
534
+ fn: (f) => f
535
+ }
536
+ ]
537
+ }
538
+ ) });
539
+ }
540
+ function $t({ options: e, value: t, multi: n, onChange: a }) {
541
+ const [r, s] = I(!1), [c, i] = I(""), [m, b] = I(null), l = H(null), f = H(null), g = j(
542
+ () => t ? t.split(z).filter(Boolean) : [],
543
+ [t]
544
+ ), _ = j(() => {
545
+ const o = c.trim().toLowerCase();
546
+ return o ? e.filter((p) => p.toLowerCase().includes(o)) : e;
547
+ }, [e, c]), w = () => {
548
+ const o = l.current;
549
+ if (!o) return;
550
+ const p = o.getBoundingClientRect(), E = 4, y = window.innerHeight - p.bottom - E, D = p.top - E, W = y < 200 && D > y, se = Math.max(150, Math.min(360, W ? D : y));
551
+ b({
552
+ left: p.left,
553
+ width: p.width,
554
+ maxHeight: se,
555
+ ...W ? { bottom: window.innerHeight - p.top + E } : { top: p.bottom + E }
556
+ });
557
+ };
558
+ ce(() => {
559
+ if (!r) return;
560
+ w();
561
+ const o = () => w();
562
+ return window.addEventListener("scroll", o, !0), window.addEventListener("resize", o), () => {
563
+ window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", o);
564
+ };
565
+ }, [r]), ie(() => {
566
+ if (!r) return;
567
+ const o = (p) => {
568
+ var y, D;
569
+ const E = p.target;
570
+ (y = l.current) != null && y.contains(E) || (D = f.current) != null && D.contains(E) || s(!1);
571
+ };
572
+ return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
573
+ }, [r]);
574
+ const Z = () => {
575
+ s(!1), i("");
576
+ }, F = (o) => {
577
+ var p;
578
+ a(o), i(""), s(!1), (p = l.current) == null || p.blur();
579
+ }, G = (o) => {
580
+ const p = g.includes(o) ? g.filter((E) => E !== o) : [...g, o];
581
+ a(p.join(z));
582
+ }, ee = () => {
583
+ s(!0), n || i("");
584
+ }, te = (o) => {
585
+ var p;
586
+ o.key === "Escape" ? (Z(), (p = l.current) == null || p.blur()) : o.key === "Enter" && _.length > 0 && (o.preventDefault(), n ? (G(_[0]), i("")) : F(_[0]));
587
+ }, ne = n || r ? c : t || "", ae = n && g.length > 0 ? `${g.length} selecionado(s)` : r ? "Buscar..." : "Todos", re = r && m ? le(
588
+ /* @__PURE__ */ u(
589
+ "div",
590
+ {
591
+ ref: f,
592
+ className: "widget-filter__search-panel",
593
+ style: {
594
+ position: "fixed",
595
+ left: m.left,
596
+ width: m.width,
597
+ top: m.top,
598
+ bottom: m.bottom,
599
+ maxHeight: m.maxHeight
600
+ },
601
+ children: /* @__PURE__ */ T("div", { className: "widget-filter__search-list", children: [
602
+ n && g.length > 0 && /* @__PURE__ */ u(
603
+ "button",
604
+ {
605
+ type: "button",
606
+ className: "widget-filter__search-clear",
607
+ onClick: () => a(""),
608
+ children: "Limpar seleção"
609
+ }
610
+ ),
611
+ !n && /* @__PURE__ */ T(
612
+ "button",
613
+ {
614
+ type: "button",
615
+ className: `widget-filter__search-option${t ? "" : " is-selected"}`,
616
+ onClick: () => F(""),
617
+ children: [
618
+ /* @__PURE__ */ u("span", { className: "widget-filter__search-check", "aria-hidden": !0, children: t ? "" : "✓" }),
619
+ "Todos"
620
+ ]
621
+ }
622
+ ),
623
+ _.length === 0 ? /* @__PURE__ */ u("span", { className: "widget-filter__search-empty", children: "Nenhuma opção" }) : _.map(
624
+ (o) => n ? /* @__PURE__ */ T(
625
+ "label",
626
+ {
627
+ className: `widget-filter__search-option${g.includes(o) ? " is-selected" : ""}`,
628
+ children: [
629
+ /* @__PURE__ */ u(
630
+ "input",
631
+ {
632
+ type: "checkbox",
633
+ checked: g.includes(o),
634
+ onChange: () => G(o)
635
+ }
636
+ ),
637
+ o
638
+ ]
639
+ },
640
+ o
641
+ ) : /* @__PURE__ */ T(
642
+ "button",
643
+ {
644
+ type: "button",
645
+ className: `widget-filter__search-option${t === o ? " is-selected" : ""}`,
646
+ onClick: () => F(o),
647
+ children: [
648
+ /* @__PURE__ */ u("span", { className: "widget-filter__search-check", "aria-hidden": !0, children: t === o ? "✓" : "" }),
649
+ o
650
+ ]
651
+ },
652
+ o
653
+ )
654
+ )
655
+ ] })
656
+ }
657
+ ),
658
+ document.body
659
+ ) : null;
660
+ return /* @__PURE__ */ T("div", { className: "widget-filter__search", children: [
661
+ /* @__PURE__ */ u(
662
+ "input",
663
+ {
664
+ ref: l,
665
+ type: "text",
666
+ className: "widget-filter__search-field",
667
+ value: ne,
668
+ placeholder: ae,
669
+ onFocus: ee,
670
+ onClick: () => s(!0),
671
+ onChange: (o) => {
672
+ i(o.target.value), s(!0);
673
+ },
674
+ onKeyDown: te
675
+ }
676
+ ),
677
+ re
678
+ ] });
679
+ }
680
+ const $e = [
681
+ d.bgDark,
682
+ d.bgPaper,
683
+ d.bgElevated,
684
+ d.accent,
685
+ d.success
686
+ ];
687
+ function Fe(e) {
688
+ if (!e) return !0;
689
+ const t = A(e);
690
+ return Object.values(O).some(
691
+ (n) => JSON.stringify(n.colors) === JSON.stringify(t)
692
+ );
693
+ }
694
+ const Ie = [
695
+ { label: "Series", slots: ["series0", "series1", "series2", "series3", "series4"] },
696
+ { label: "Tema", slots: ["bgDark", "bgPaper", "bgElevated", "textPrimary", "textMuted"] },
697
+ { label: "Estados", slots: ["accent", "success", "error"] }
698
+ ];
699
+ function Ft({
700
+ selected: e,
701
+ onSelect: t,
702
+ customMode: n,
703
+ onCustomModeChange: a,
704
+ disabled: r
705
+ }) {
706
+ var b;
707
+ const s = n ?? !Fe(e), c = A(e), i = s || (b = Object.entries(O).find(
708
+ ([, l]) => JSON.stringify(l.colors) === JSON.stringify(c)
709
+ )) == null ? void 0 : b[0], m = (l, f) => {
710
+ const g = [...c];
711
+ for (; g.length < M; ) g.push("#000000");
712
+ g[l] = f, t(g);
713
+ };
714
+ return /* @__PURE__ */ T("div", { className: `palette-selector ${r ? "palette-selector--disabled" : ""}`, children: [
715
+ a && /* @__PURE__ */ T("label", { className: "config-panel__checkbox", children: [
716
+ /* @__PURE__ */ u(
717
+ "input",
718
+ {
719
+ type: "checkbox",
720
+ checked: s,
721
+ onChange: (l) => a(l.target.checked),
722
+ disabled: r
723
+ }
724
+ ),
725
+ "Customizar"
726
+ ] }),
727
+ s ? /* @__PURE__ */ u("div", { className: "palette-selector__custom", children: Ie.map((l) => /* @__PURE__ */ T("div", { className: "palette-selector__row", children: [
728
+ /* @__PURE__ */ u("span", { className: "palette-selector__row-label", children: l.label }),
729
+ /* @__PURE__ */ u("div", { className: "palette-selector__row-slots", children: l.slots.map((f) => {
730
+ const g = d[f];
731
+ return /* @__PURE__ */ u(
732
+ "input",
733
+ {
734
+ type: "color",
735
+ className: "palette-selector__color-input",
736
+ value: c[g] || "#000000",
737
+ onChange: (_) => m(g, _.target.value),
738
+ disabled: r,
739
+ title: me[f]
740
+ },
741
+ f
742
+ );
743
+ }) })
744
+ ] }, l.label)) }) : /* @__PURE__ */ u("div", { className: "palette-selector__options", children: Object.entries(O).map(([l, f]) => {
745
+ const g = A(f.colors);
746
+ return /* @__PURE__ */ T(
747
+ "button",
748
+ {
749
+ className: `palette-selector__option ${i === l ? "palette-selector__option--active" : ""}`,
750
+ onClick: () => t(f.colors),
751
+ disabled: r,
752
+ children: [
753
+ /* @__PURE__ */ u("div", { className: "palette-selector__bar", children: ge(f.colors).map((_, w) => /* @__PURE__ */ u(
754
+ "span",
755
+ {
756
+ className: "palette-selector__swatch",
757
+ style: { backgroundColor: _ }
758
+ },
759
+ w
760
+ )) }),
761
+ /* @__PURE__ */ u("div", { className: "palette-selector__bar palette-selector__bar--theme", children: $e.map((_, w) => /* @__PURE__ */ u(
762
+ "span",
763
+ {
764
+ className: "palette-selector__swatch",
765
+ style: { backgroundColor: g[_] }
766
+ },
767
+ w
768
+ )) }),
769
+ /* @__PURE__ */ u("span", { className: "palette-selector__label", children: f.label })
770
+ ]
771
+ },
772
+ l
773
+ );
774
+ }) })
775
+ ] });
776
+ }
777
+ export {
778
+ nt as $,
779
+ We as A,
780
+ He as B,
781
+ Ft as C,
782
+ Rt as D,
783
+ fe as E,
784
+ Be as F,
785
+ v as G,
786
+ Qe as H,
787
+ it as I,
788
+ ot as J,
789
+ et as K,
790
+ ct as L,
791
+ z as M,
792
+ Je as N,
793
+ Ve as O,
794
+ ft as P,
795
+ ut as Q,
796
+ be as R,
797
+ $t as S,
798
+ Ke as T,
799
+ _e as U,
800
+ pe as V,
801
+ B as W,
802
+ ze as X,
803
+ at as Y,
804
+ lt as Z,
805
+ he as _,
806
+ Ye as a,
807
+ st as a0,
808
+ Ee as a1,
809
+ Et as a2,
810
+ Ze as a3,
811
+ O as a4,
812
+ de as a5,
813
+ d as a6,
814
+ me as a7,
815
+ tt as a8,
816
+ M as a9,
817
+ rt as aa,
818
+ qe as ab,
819
+ Re as ac,
820
+ A as ad,
821
+ Y as ae,
822
+ wt as af,
823
+ yt as ag,
824
+ N as ah,
825
+ At as ai,
826
+ ve as aj,
827
+ dt as b,
828
+ mt as c,
829
+ bt as d,
830
+ ht as e,
831
+ Ue as f,
832
+ Ne as g,
833
+ Mt as h,
834
+ _t as i,
835
+ Nt as j,
836
+ Ae as k,
837
+ Dt as l,
838
+ Lt as m,
839
+ Me as n,
840
+ Tt as o,
841
+ St as p,
842
+ ge as q,
843
+ Ot as r,
844
+ je as s,
845
+ Xe as t,
846
+ gt as u,
847
+ pt as v,
848
+ k as w,
849
+ U as x,
850
+ x as y,
851
+ Ge as z
852
+ };
853
+ //# sourceMappingURL=ColorPaletteSelector-nBO_fbbj.js.map