@feedmepos/mf-report 5.21.1-beta.0 → 5.21.2-beta.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.
@@ -0,0 +1,2431 @@
1
+ import { computed as _, defineComponent as Re, mergeModels as Pe, useModel as We, ref as f, onMounted as Xe, nextTick as Se, watch as he, resolveComponent as B, createElementBlock as te, openBlock as $, Fragment as xe, renderSlot as Be, createVNode as P, normalizeStyle as Ne, unref as s, createElementVNode as H, toDisplayString as Le, withCtx as se, createBlock as re, createCommentVNode as De, normalizeClass as Ye, h as ot, renderList as rt, toRaw as fl, markRaw as vl, createTextVNode as ft, onUnmounted as gl, resolveDynamicComponent as yl, withDirectives as bl, vShow as wl, withModifiers as dt } from "vue";
2
+ import { W as A, e as tt, f as xl, S as qe, v as nt, g as Sl, h as mt, i as Ht, q as Ot, R as Je, j as Cl, D as Ee, c as pe, C as _e, a as kl, b as _l, _ as Tl } from "./BaseDialog.vue_vue_type_script_setup_true_lang-Ccrz29qZ.js";
3
+ import { u as lt, b as et, a as Ct, d as Ke, i as Fl } from "./vue-i18n-BJW_sJot.js";
4
+ import { d as It, _ as Ll, a as Dl, b as Rl, c as Vl } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-BeBr4VIF.js";
5
+ import { storeToRefs as Me, defineStore as qt } from "pinia";
6
+ import { useBreakpoints as Ut, useSnackbar as kt, components as zl } from "@feedmepos/ui-library";
7
+ import { a as $l } from "./SelectComponent.vue_vue_type_script_setup_true_lang-BcQEW5MO.js";
8
+ import { r as Ue } from "./i18n-DQxDgiLO.js";
9
+ import { _ as vt } from "./NoData.vue_vue_type_script_setup_true_lang-CtN7oqXx.js";
10
+ var gt = /* @__PURE__ */ ((e) => (e.line = "LINE", e.bar = "BAR", e))(gt || {}), Oe = /* @__PURE__ */ ((e) => (e.top = "TOP", e.bottom = "BOTTOM", e))(Oe || {}), yt = /* @__PURE__ */ ((e) => (e.start = "start", e.center = "center", e.end = "end", e))(yt || {}), bt = /* @__PURE__ */ ((e) => (e.start = "start", e.center = "center", e.end = "end", e.left = "left", e.right = "right", e.top = "top", e.bottom = "bottom", e))(bt || {}), wt = /* @__PURE__ */ ((e) => (e.top = "top", e.bottom = "bottom", e))(wt || {}), xt = /* @__PURE__ */ ((e) => (e.right = "right", e.left = "left", e))(xt || {}), St = /* @__PURE__ */ ((e) => (e.top = "top", e.bottom = "bottom", e.right = "right", e.left = "left", e.chartArea = "chartArea", e))(St || {});
11
+ A.Circular, A.Table, A.BarChart, A.LineChart, A.StackBarChart, A.StackLineChart, A.Scorecard, A.Spacer;
12
+ const Al = [
13
+ {
14
+ type: A.Circular,
15
+ showLabel: !1,
16
+ // TODO: temporarily removed show label as it has no function
17
+ showDrillDimension: !0,
18
+ showRollup: !1,
19
+ showSearchBar: !1
20
+ },
21
+ {
22
+ type: A.Table,
23
+ showLabel: !1,
24
+ showDrillDimension: !0,
25
+ showRollup: !0,
26
+ showSearchBar: !0
27
+ },
28
+ {
29
+ type: A.BarChart,
30
+ showLabel: !1,
31
+ // TODO: temporarily removed show label as it has no function
32
+ showDrillDimension: !0,
33
+ showRollup: !1,
34
+ showSearchBar: !1
35
+ },
36
+ {
37
+ type: A.LineChart,
38
+ showLabel: !1,
39
+ // TODO: temporarily removed show label as it has no function
40
+ showDrillDimension: !0,
41
+ showRollup: !0,
42
+ showSearchBar: !1
43
+ },
44
+ {
45
+ type: A.StackBarChart,
46
+ showLabel: !1,
47
+ // TODO: temporarily removed show label as it has no function
48
+ showDrillDimension: !0,
49
+ showRollup: !0,
50
+ showSearchBar: !1
51
+ },
52
+ {
53
+ type: A.StackLineChart,
54
+ showLabel: !1,
55
+ // TODO: temporarily removed show label as it has no function
56
+ showDrillDimension: !0,
57
+ showRollup: !0,
58
+ showSearchBar: !1
59
+ },
60
+ {
61
+ type: A.Scorecard,
62
+ showLabel: !1,
63
+ showDrillDimension: !1,
64
+ showRollup: !1,
65
+ showSearchBar: !1
66
+ },
67
+ {
68
+ type: A.Spacer,
69
+ showLabel: !1,
70
+ showDrillDimension: !1,
71
+ showRollup: !1,
72
+ showSearchBar: !1
73
+ }
74
+ ];
75
+ function pt(e) {
76
+ const a = [e.schemaName, e.name];
77
+ return "option" in e && e.option && a.push(e.option), "aggregation" in e && e.aggregation && a.push(e.aggregation), a.push(e.label.replace(/[^a-zA-Z0-9]/g, "")), a.join("_").toLowerCase();
78
+ }
79
+ function El(e, a) {
80
+ switch (e) {
81
+ case A.BarChart:
82
+ case A.LineChart:
83
+ case A.StackBarChart:
84
+ case A.StackLineChart:
85
+ return Array.isArray(a == null ? void 0 : a.datasets) && Array.isArray(a == null ? void 0 : a.xAxis) && a.datasets.length > 0 && a.xAxis.length > 0;
86
+ case A.Table:
87
+ return Array.isArray(a == null ? void 0 : a.rows) && Array.isArray(a == null ? void 0 : a.columns) && a.rows.length > 0 && a.columns.length > 0;
88
+ case A.Circular:
89
+ return Array.isArray(a == null ? void 0 : a.datasets) && a.datasets.length > 0;
90
+ case A.Scorecard:
91
+ return !0;
92
+ case A.Spacer:
93
+ return !0;
94
+ }
95
+ }
96
+ const Nt = [
97
+ "54, 162, 235",
98
+ //8CE6D7
99
+ "0, 123, 167",
100
+ //007BA7
101
+ "255, 93, 83",
102
+ //FF5D53
103
+ "115, 200, 230",
104
+ //73C8E6
105
+ "252, 162, 62",
106
+ //FCA23E
107
+ "240, 155, 190",
108
+ //F09BBE
109
+ "255, 210, 50",
110
+ //FFD232
111
+ "80, 190, 155",
112
+ //50BE9B
113
+ "131, 88, 212",
114
+ //8358D4
115
+ "155, 80, 70"
116
+ //9B5046
117
+ ];
118
+ function Ie({
119
+ index: e,
120
+ isCompare: a,
121
+ opacity: r
122
+ }) {
123
+ let l = typeof r == "number" ? r : 1;
124
+ return a && (l = l * 0.6), `rgba(${Nt[e % Nt.length]}, ${l})`;
125
+ }
126
+ function Gt(e, a, r) {
127
+ if (e === "" || a === "")
128
+ return null;
129
+ let l = (F) => F == null ? void 0 : F.replace(/,/g, "");
130
+ r === "ID" && (l = (F) => F == null ? void 0 : F.replace(/\./g, "").replace(/,/g, "."));
131
+ const b = Number(l(e)), S = Number(l(a));
132
+ if (isNaN(b) || isNaN(S))
133
+ return null;
134
+ let R = 0;
135
+ S === 0 ? b === 0 ? R = 0 : R = 1 : R = (b - S) / S;
136
+ const D = Ml(R);
137
+ return {
138
+ value: isNaN(R) ? "" : `${(R * 100).toFixed(0)}%`,
139
+ icon: D
140
+ };
141
+ }
142
+ function Ml(e) {
143
+ return e > 0 ? {
144
+ name: "moving",
145
+ color: "#1F7735",
146
+ tailwind: "fm-color-system-success-100"
147
+ } : e < 0 ? {
148
+ name: "trending_down",
149
+ color: "#99231D",
150
+ tailwind: "fm-color-system-error-100"
151
+ } : {
152
+ name: "equal",
153
+ color: "#C7C7CC",
154
+ tailwind: "fm-color-neutral-gray-100"
155
+ };
156
+ }
157
+ function at(e) {
158
+ function a(u, c, m) {
159
+ if (u.measureText(c).width <= m) return c;
160
+ const p = "…";
161
+ let L = 0, x = c.length;
162
+ for (; L < x; ) {
163
+ const T = Math.floor((L + x) / 2), g = c.slice(0, T) + p;
164
+ u.measureText(g).width <= m ? L = T + 1 : x = T;
165
+ }
166
+ return c.slice(0, L - 1) + p;
167
+ }
168
+ const r = _(() => ({
169
+ display: e.showLabel,
170
+ align: e.labelAlign,
171
+ anchor: e.labelAnchor,
172
+ rotation: e.labelRotation,
173
+ offset: e.labelOffset,
174
+ font: {
175
+ size: e.labelFontSize
176
+ },
177
+ color: (u) => {
178
+ const c = u.chart.data.datasets[u.datasetIndex];
179
+ return c.borderColor ? Array.isArray(c.borderColor) ? c.borderColor[u.dataIndex] : c.borderColor : c.backgroundColor ? Array.isArray(c.backgroundColor) ? c.backgroundColor[u.dataIndex] : c.backgroundColor : "#000";
180
+ },
181
+ formatter: (u) => u === 0 ? "" : u.toLocaleString("en-US")
182
+ })), l = _(() => ({
183
+ display: e.showX,
184
+ position: e.xPosition,
185
+ grid: {
186
+ display: e.showXGrid
187
+ },
188
+ ticks: {
189
+ display: e.showXTick,
190
+ callback: function(u) {
191
+ if ((e == null ? void 0 : e.isTransposed) === !0) return String(u);
192
+ let m = String(u);
193
+ const p = this;
194
+ p && typeof p.getLabelForValue == "function" && (m = p.getLabelForValue(u));
195
+ const L = p == null ? void 0 : p.chart, x = p == null ? void 0 : p.ctx, T = L.height * 0.25;
196
+ if (x && T > 0) {
197
+ x.save();
198
+ const E = x.measureText(m).width > T ? a(x, m, T) : m;
199
+ return x.restore(), E;
200
+ }
201
+ return m;
202
+ },
203
+ font: {
204
+ size: e.xTickFontSize
205
+ }
206
+ },
207
+ title: {
208
+ display: e.showXTitle,
209
+ text: e.xTitle,
210
+ font: {
211
+ size: e.xTitleFontSize
212
+ }
213
+ },
214
+ afterBuildTicks: (u) => {
215
+ const c = Array.isArray(u == null ? void 0 : u.ticks) ? u.ticks : [];
216
+ if (c.length === 0) return;
217
+ const m = u.getLabelForValue(c[0].value), p = !isNaN(Number(m));
218
+ u.options.ticks.minRotation = p || c.length < 10 ? 0 : 90;
219
+ },
220
+ afterFit: (u) => {
221
+ if (!(e != null && e.isTransposed)) {
222
+ const c = u.chart.height * 0.4;
223
+ u.height > c && (u.height = c);
224
+ }
225
+ }
226
+ })), b = _(() => ({
227
+ display: e.showY,
228
+ position: e.yPosition,
229
+ grid: {
230
+ display: e.showYGrid
231
+ },
232
+ ticks: {
233
+ display: e.showYTick,
234
+ font: {
235
+ size: e.yTickFontSize
236
+ },
237
+ callback: function(u) {
238
+ if (!((e == null ? void 0 : e.isTransposed) === !0)) return String(u);
239
+ let m = String(u);
240
+ const p = this;
241
+ p && typeof p.getLabelForValue == "function" && (m = p.getLabelForValue(u));
242
+ const L = p == null ? void 0 : p.chart, x = p == null ? void 0 : p.ctx, T = L.width * 0.4;
243
+ if (x && T > 0) {
244
+ x.save();
245
+ const E = x.measureText(m).width > T ? a(x, m, T) : m;
246
+ return x.restore(), E;
247
+ }
248
+ return m;
249
+ }
250
+ },
251
+ title: {
252
+ display: e.showYTitle,
253
+ text: e.yTitle,
254
+ font: {
255
+ size: e.yTitleFontSize
256
+ }
257
+ }
258
+ })), S = _(() => ({
259
+ display: e.showLegend,
260
+ position: e.legendPosition,
261
+ usePointStyle: e.usePointStyle,
262
+ maxHeight: e.legendMaxHeight,
263
+ maxWidth: e.legendMaxWidth,
264
+ labels: {
265
+ usePointStyle: e.usePointStyle ?? !0,
266
+ generateLabels: (u) => {
267
+ var m;
268
+ const c = ((m = u == null ? void 0 : u.data) == null ? void 0 : m.datasets) || [];
269
+ if (c.length === 0) return [];
270
+ if (c.length === 1 && Array.isArray(c[0].backgroundColor) && c[0].backgroundColor.length > 1 && Array.isArray(c[0].data)) {
271
+ const p = c[0];
272
+ return u.data.labels.map((x, T) => {
273
+ const g = p.backgroundColor[T];
274
+ return {
275
+ text: x,
276
+ fontColor: "#6b6b6b",
277
+ fillStyle: g,
278
+ strokeStyle: g,
279
+ datasetIndex: 0,
280
+ index: T,
281
+ hidden: u.getDataVisibility ? !u.getDataVisibility(T) : !1
282
+ };
283
+ });
284
+ }
285
+ return u.data.datasets.map((p, L) => {
286
+ const x = p.borderColor || p.backgroundColor;
287
+ return {
288
+ text: p.label,
289
+ fontColor: "#6b6b6b",
290
+ fillStyle: x,
291
+ strokeStyle: x,
292
+ datasetIndex: L,
293
+ hidden: !u.isDatasetVisible(L)
294
+ };
295
+ });
296
+ }
297
+ }
298
+ })), R = _(() => e.isTransposed), D = _(() => e.chartWidth), F = _(() => e.chartHeight);
299
+ return { datalabels: r, xCfg: l, yCfg: b, isTransposed: R, legend: S, chartWidth: D, chartHeight: F };
300
+ }
301
+ const Il = /* @__PURE__ */ Re({
302
+ __name: "WidgetBarchart",
303
+ props: /* @__PURE__ */ Pe({
304
+ tileIndex: {}
305
+ }, {
306
+ modelValue: { required: !0 },
307
+ modelModifiers: {}
308
+ }),
309
+ emits: ["update:modelValue"],
310
+ setup(e) {
311
+ const a = e, r = We(e, "modelValue"), l = f(null), b = _(() => {
312
+ var g;
313
+ return ((g = r.value.data) == null ? void 0 : g.xAxis) ?? [];
314
+ }), S = _(() => {
315
+ var g;
316
+ return ((g = r.value.data) == null ? void 0 : g.datasets) ?? [];
317
+ }), { datalabels: R, xCfg: D, yCfg: F, isTransposed: u, legend: c, chartWidth: m, chartHeight: p } = at(
318
+ r.value
319
+ ), L = _(() => S.value.length > 0 ? [
320
+ ...S.value.map((g, E) => ({
321
+ label: g.name,
322
+ data: g.values,
323
+ dash: !!g.isCompare,
324
+ backgroundColor: Ie({ index: E, isCompare: g.isCompare })
325
+ }))
326
+ ] : []), x = tt();
327
+ function T() {
328
+ return x.extractChartSize(l.value, a.tileIndex) || { width: 0, height: 0 };
329
+ }
330
+ return Xe(() => {
331
+ Se(() => {
332
+ T();
333
+ });
334
+ }), he([L], () => {
335
+ Se(() => T());
336
+ }), (g, E) => {
337
+ const v = B("FmBarChart");
338
+ return $(), te(xe, null, [
339
+ Be(g.$slots, "menu"),
340
+ P(v, {
341
+ ref_key: "chartRef",
342
+ ref: l,
343
+ class: "bar-chart",
344
+ datasets: L.value,
345
+ "x-axis": { categories: b.value },
346
+ "x-cfg": s(D),
347
+ "y-cfg": s(F),
348
+ transpose: s(u),
349
+ legend: {
350
+ display: s(c).display ?? !1,
351
+ position: s(c).position,
352
+ maxHeight: s(c).maxHeight,
353
+ maxWidth: s(c).maxWidth,
354
+ labels: s(c).labels
355
+ },
356
+ datalabels: s(R),
357
+ "maintain-aspect-ratio": !1,
358
+ style: Ne({
359
+ "--chart-width": s(m) !== void 0 ? s(m) + "px" : "100%",
360
+ "--chart-height": s(p) !== void 0 ? s(p) + "px" : "calc(100% - 36px)"
361
+ })
362
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
363
+ ], 64);
364
+ };
365
+ }
366
+ }), Nl = /* @__PURE__ */ Re({
367
+ __name: "WidgetCircular",
368
+ props: /* @__PURE__ */ Pe({
369
+ tileIndex: {}
370
+ }, {
371
+ modelValue: { required: !0 },
372
+ modelModifiers: {}
373
+ }),
374
+ emits: ["update:modelValue"],
375
+ setup(e) {
376
+ const a = e, r = We(e, "modelValue"), { breakpoints: l } = Ut(), b = f(null), { datalabels: S, legend: R, chartWidth: D, chartHeight: F } = at(r.value), u = _(() => {
377
+ let L = [];
378
+ return r.value.data.datasets && r.value.data.metrics && r.value.data.datasets.length > 0 && r.value.data.metrics.length > 0 && (L = [
379
+ {
380
+ label: r.value.data.metrics[0],
381
+ data: r.value.data.datasets.map((x) => x.value),
382
+ backgroundColor: r.value.data.datasets.map((x, T) => Ie({ index: T }))
383
+ }
384
+ ]), L;
385
+ }), c = tt();
386
+ function m() {
387
+ return c.extractChartSize(b.value, a.tileIndex) || { width: 0, height: 0 };
388
+ }
389
+ Xe(() => {
390
+ Se(() => {
391
+ m();
392
+ });
393
+ }), he([u], () => {
394
+ Se(() => m());
395
+ });
396
+ const p = _(() => l.value.lg ? 12 : 8);
397
+ return (L, x) => {
398
+ const T = B("FmPieChart");
399
+ return $(), te(xe, null, [
400
+ Be(L.$slots, "menu"),
401
+ P(T, {
402
+ ref_key: "chartRef",
403
+ ref: b,
404
+ class: "circular",
405
+ percentage: "70%",
406
+ datasets: u.value,
407
+ metrics: r.value.data.datasets.map((g) => g.name),
408
+ variant: "doughnut",
409
+ legend: {
410
+ display: s(R).display ?? !0,
411
+ position: s(R).position ?? "top",
412
+ maxHeight: s(R).maxHeight,
413
+ maxWidth: s(R).maxWidth,
414
+ labels: {
415
+ ...s(R).labels,
416
+ font: {
417
+ size: p.value
418
+ }
419
+ }
420
+ },
421
+ datalabels: s(S),
422
+ "maintain-aspect-ratio": !1,
423
+ style: Ne({
424
+ "--chart-width": s(D) !== void 0 ? s(D) + "px" : "100%",
425
+ "--chart-height": s(F) !== void 0 ? s(F) + "px" : "calc(100% - 36px)"
426
+ })
427
+ }, null, 8, ["datasets", "metrics", "legend", "datalabels", "style"])
428
+ ], 64);
429
+ };
430
+ }
431
+ }), Wl = { class: "flex flex-col gap-1" }, Pl = { class: "fm-typo-en-title-sm-600" }, Bl = { class: "flex gap-2" }, Hl = { key: 0 }, Ol = { key: 1 }, ql = /* @__PURE__ */ Re({
432
+ __name: "WidgetScorecard",
433
+ props: {
434
+ modelValue: { required: !0 },
435
+ modelModifiers: {}
436
+ },
437
+ emits: ["update:modelValue"],
438
+ setup(e) {
439
+ const a = We(e, "modelValue"), { t: r } = lt(), { compareDateRange: l, defaultDateSetting: b } = Me(et()), { country: S } = Ct(), R = _(() => {
440
+ var m;
441
+ return ((m = a.value.data) == null ? void 0 : m.value) || "";
442
+ }), D = _(() => {
443
+ const { data: m } = a.value;
444
+ return m != null && m.comparison ? Gt(R.value, m.comparison, S) : null;
445
+ });
446
+ function F(m) {
447
+ switch (m) {
448
+ case gt.bar:
449
+ return "bar";
450
+ case gt.line:
451
+ return "line";
452
+ default:
453
+ return "line";
454
+ }
455
+ }
456
+ const u = _(() => {
457
+ var m;
458
+ return (m = a.value.data) == null ? void 0 : m.sparkline;
459
+ }), c = _(() => u.value.datasets.map((m) => ({
460
+ label: m.name,
461
+ data: m.values,
462
+ fill: !0,
463
+ color: "#36a2eb"
464
+ })));
465
+ return (m, p) => {
466
+ var E;
467
+ const L = B("FmIcon"), x = B("FmChip"), T = B("FmTooltip"), g = B("FmLineChart");
468
+ return $(), te("div", Wl, [
469
+ Be(m.$slots, "menu"),
470
+ H("p", Pl, Le(R.value), 1),
471
+ H("div", Bl, [
472
+ P(T, {
473
+ content: `vs. ${(E = s(b).defaultCompareType) == null ? void 0 : E.split("_").join(" ")}`,
474
+ placement: "right",
475
+ "hide-arrow": "",
476
+ variant: "plain"
477
+ }, {
478
+ default: se(() => [
479
+ D.value ? ($(), re(x, {
480
+ key: 0,
481
+ icon: D.value.icon.name,
482
+ class: Ye(`bg-${D.value.icon.tailwind}`),
483
+ compact: ""
484
+ }, {
485
+ default: se(() => [
486
+ P(L, {
487
+ name: D.value.icon.name,
488
+ color: D.value.icon.color
489
+ }, null, 8, ["name", "color"]),
490
+ H("p", {
491
+ class: "fm-typo-en-body-md-600",
492
+ style: Ne({ color: D.value.icon.color })
493
+ }, Le(D.value.value), 5)
494
+ ]),
495
+ _: 1
496
+ }, 8, ["icon", "class"])) : De("", !0),
497
+ s(l).endDate !== null && s(l).startDate !== null && D.value === null ? ($(), re(x, {
498
+ key: 1,
499
+ compact: ""
500
+ }, {
501
+ default: se(() => [
502
+ P(L, {
503
+ name: "arrow_upward",
504
+ color: "#C7C7CC"
505
+ }),
506
+ p[0] || (p[0] = H("p", { class: "fm-typo-en-body-md-600 text-fm-color-typo-disabled" }, "N/A", -1))
507
+ ]),
508
+ _: 1
509
+ })) : De("", !0)
510
+ ]),
511
+ _: 1
512
+ }, 8, ["content"])
513
+ ]),
514
+ u.value ? ($(), te("div", Hl, [
515
+ F(u.value.type) === "line" ? ($(), re(g, {
516
+ key: 0,
517
+ class: "sparkline",
518
+ datasets: c.value,
519
+ legend: {
520
+ display: !1
521
+ },
522
+ datalabels: { display: !1 },
523
+ "x-axis": { categories: u.value.dimensions },
524
+ "y-cfg": { display: !1 },
525
+ "x-cfg": { display: !1 },
526
+ "maintain-aspect-ratio": !1
527
+ }, null, 8, ["datasets", "x-axis"])) : De("", !0)
528
+ ])) : ($(), te("div", Ol, p[1] || (p[1] = [
529
+ H("div", { class: "sparkline" }, [
530
+ H("div", { class: "flex flex-col gap-8" }, [
531
+ H("div"),
532
+ H("div")
533
+ ]),
534
+ H("div", { class: "grow" })
535
+ ], -1)
536
+ ])))
537
+ ]);
538
+ };
539
+ }
540
+ }), Ul = {};
541
+ function Gl(e, a) {
542
+ const r = B("FmMenuDivider");
543
+ return $(), re(r);
544
+ }
545
+ const Yl = /* @__PURE__ */ $l(Ul, [["render", Gl]]), Xl = "mf-reporttable-dimension", Wt = qt(Xl, () => {
546
+ const e = f(0), a = f([]), r = f(!1), l = (v, n) => {
547
+ e.value = v, S(v, n);
548
+ }, b = (v, n, h, w) => {
549
+ a[v] = n, a.value = [...a.value], R(v, n, h, w);
550
+ }, S = (v, n) => {
551
+ const h = (n == null ? void 0 : n.querySelectorAll("thead tr")) ?? [], w = (n == null ? void 0 : n.querySelectorAll("tbody tr")) ?? [];
552
+ [...h, ...w].forEach((U) => {
553
+ const X = U;
554
+ X && (X.style.height = `${v}px`);
555
+ });
556
+ }, R = (v, n, h, w = !1) => {
557
+ const z = (h == null ? void 0 : h.querySelectorAll("th")) ?? [];
558
+ if (v === void 0) return;
559
+ const U = z[v], X = w ? a[v] : n;
560
+ if (!U || X === void 0) return;
561
+ const ee = () => {
562
+ U.style.width = `${X}px`;
563
+ };
564
+ w ? requestAnimationFrame(ee) : ee();
565
+ }, D = () => {
566
+ const v = document.querySelectorAll("th"), n = document.querySelectorAll("td"), h = document.querySelector("table");
567
+ h == null || h.classList.add("table-fixed"), v.forEach((w) => w.classList.add("toggleEditResize")), n.forEach((w) => w.classList.add("toggleEditResize")), r.value = !0;
568
+ }, F = () => {
569
+ const v = document.querySelectorAll("th"), n = document.querySelectorAll("td"), h = document.querySelectorAll(".col-resize-handle"), w = document.querySelectorAll(".row-resize-handle");
570
+ v.forEach((z) => z.classList.remove("toggleEditResize")), n.forEach((z) => z.classList.remove("toggleEditResize")), h.forEach((z) => z.remove()), w.forEach((z) => z.remove()), r.value = !1;
571
+ }, u = () => {
572
+ e.value = 0, a.value = [];
573
+ }, c = (v, n) => {
574
+ if (n) {
575
+ const h = document.querySelectorAll(`thead th:nth-child(${v + 1})`), w = document.querySelectorAll(`tbody td:nth-child(${v + 1})`);
576
+ [...h, ...w].forEach((z) => {
577
+ z.classList.add("highlight-hover-col");
578
+ });
579
+ } else
580
+ document.querySelectorAll(
581
+ `thead th:nth-child(${v + 1}), tbody td:nth-child(${v + 1})`
582
+ ).forEach((h) => h.classList.add("highlight-col"));
583
+ }, m = (v) => {
584
+ const n = document.querySelectorAll("thead tr"), h = document.querySelectorAll("tbody tr"), w = [...n, ...h];
585
+ for (const z of w)
586
+ v ? z.classList.add("highlight-hover-row") : z.classList.add("highlight-row");
587
+ }, p = (v) => {
588
+ const n = v ? ".highlight-hover-row" : ".highlight-row", h = document.querySelectorAll(n);
589
+ for (const w of h)
590
+ w.classList.remove(n.slice(1));
591
+ }, L = (v) => {
592
+ v ? document.querySelectorAll(".highlight-hover-col").forEach((n) => {
593
+ n.classList.remove("highlight-hover-col");
594
+ }) : document.querySelectorAll(".highlight-col").forEach((n) => n.classList.remove("highlight-col"));
595
+ }, x = (v, n) => {
596
+ const h = /* @__PURE__ */ new Map(), w = v.clientX, z = v.target.closest("table"), U = z == null ? void 0 : z.querySelectorAll("th")[n], X = U == null ? void 0 : U.getBoundingClientRect().width, ee = h.get(n) ? a[n.toString()] || 60 : (h.set(n, !0), X || a[n.toString()] || 60), le = U == null ? void 0 : U.querySelector("p");
597
+ if (!le) return;
598
+ const Te = le.textContent || "", ve = window.getComputedStyle(le), Fe = `${ve.fontWeight} ${ve.fontSize} ${ve.fontFamily}`, fe = document.createElement("canvas").getContext("2d");
599
+ if (!fe) return;
600
+ fe.font = Fe;
601
+ const y = fe.measureText(Te), V = window.getComputedStyle(U), G = parseFloat(V.paddingLeft || "0"), W = parseFloat(V.paddingRight || "0"), N = y.width + G + W;
602
+ c(n, !1);
603
+ const M = (Ce) => {
604
+ const be = Ce.clientX - w, we = Math.max(N, ee + be);
605
+ if (z) {
606
+ b(n, we, z, !0);
607
+ let ge = 0;
608
+ z.querySelectorAll("th").forEach((d, C) => {
609
+ ge += C === n ? we : a[C] || d.getBoundingClientRect().width;
610
+ }), z.classList.remove("w-full"), z.style.width = `${ge}px`;
611
+ const t = z == null ? void 0 : z.parentElement;
612
+ if (t) {
613
+ const d = t.scrollWidth, C = t.scrollLeft;
614
+ t.offsetWidth + C >= d - 100 && (t.scrollLeft = d);
615
+ }
616
+ }
617
+ }, ie = () => {
618
+ const Ce = (z == null ? void 0 : z.querySelectorAll("th")) ?? [], be = [...a.value];
619
+ Ce.forEach((we, ge) => {
620
+ const ze = we.getBoundingClientRect().width;
621
+ a[ge] = ze, be[ge] = ze;
622
+ }), a.value = be, L(!1), document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", ie);
623
+ };
624
+ document.addEventListener("mousemove", M), document.addEventListener("mouseup", ie);
625
+ }, T = (v) => {
626
+ const n = v.clientY, h = v.target.closest("table"), w = e.value || 48;
627
+ m(!1);
628
+ const z = (X) => {
629
+ const ee = Math.max(30, w + (X.clientY - n));
630
+ h && l(ee, h);
631
+ }, U = () => {
632
+ p(!1), document.removeEventListener("mousemove", z), document.removeEventListener("mouseup", U);
633
+ };
634
+ document.addEventListener("mousemove", z), document.addEventListener("mouseup", U);
635
+ };
636
+ return {
637
+ rowHeight: e,
638
+ colWidths: a,
639
+ isEditing: r,
640
+ updateRowHeight: l,
641
+ updateColWidth: b,
642
+ setRowHeights: S,
643
+ setColWidths: R,
644
+ enableEditMode: D,
645
+ disableEditMode: F,
646
+ resetStore: u,
647
+ highlightCol: c,
648
+ highlightRows: m,
649
+ removeRowHighlight: p,
650
+ removeColHighlight: L,
651
+ resizeCol: x,
652
+ resizeRow: T,
653
+ enableCellResizing: () => {
654
+ const v = document.querySelector("thead"), n = document.querySelectorAll("thead tr"), h = document.querySelectorAll("tbody tr"), w = [...n, ...h];
655
+ v && v.classList.remove("sticky");
656
+ const z = (U, X) => {
657
+ const ee = document.createElement("div");
658
+ return ee.className = `${U}-resize-handle`, U === "col" ? (ee.addEventListener("mouseenter", () => c(X, !0)), ee.addEventListener("mouseleave", () => L(!0)), ee.addEventListener("mousedown", (le) => {
659
+ le.stopPropagation(), x(le, X);
660
+ })) : (ee.addEventListener("mouseenter", () => m(!0)), ee.addEventListener("mouseleave", () => p(!0)), ee.addEventListener("mousedown", (le) => {
661
+ le.stopPropagation(), T(le);
662
+ })), ee;
663
+ };
664
+ w.forEach((U) => {
665
+ const X = U.closest("thead") !== null;
666
+ U.querySelectorAll(X ? "th" : "td").forEach((le, Te) => {
667
+ const ve = z("col", Te), Fe = z("row", Te);
668
+ le.appendChild(ve), le.appendChild(Fe);
669
+ });
670
+ }), D();
671
+ },
672
+ cancelResizingChanges: () => {
673
+ F();
674
+ }
675
+ };
676
+ });
677
+ function ht(e) {
678
+ if (e == null || e === "")
679
+ return "";
680
+ const a = String(e), r = Number(a);
681
+ if (isNaN(r)) return a;
682
+ const [l, b] = a.split("."), S = new Intl.NumberFormat("en-US").format(Number(l));
683
+ return b !== void 0 ? `${S}.${b}` : S;
684
+ }
685
+ const jl = "/assets/processTableData.worker-B_-FBESg.js", Jl = { class: "my-4" }, Kl = {
686
+ class: "border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm",
687
+ style: { backgroundColor: "#f9f9f9" }
688
+ }, Zl = { class: "font-bold" }, Ql = { class: "text-fm-color-neutral-gray-300" }, ea = /* @__PURE__ */ Re({
689
+ __name: "WidgetTable",
690
+ props: /* @__PURE__ */ Pe({
691
+ tileIndex: {}
692
+ }, {
693
+ modelValue: { required: !0 },
694
+ modelModifiers: {}
695
+ }),
696
+ emits: ["update:modelValue"],
697
+ setup(e) {
698
+ const { t: a, te: r } = lt(), l = We(e, "modelValue"), { country: b } = Ct(), { clearTileSorts: S, setTileSorts: R } = xl(), D = kt(), F = e, u = f([]), { isEditing: c, colWidths: m, rowHeight: p } = Me(Wt()), { setColWidths: L, setRowHeights: x, enableCellResizing: T } = Wt(), g = f(null), E = _(() => {
699
+ var y;
700
+ return ((y = l.value.data) == null ? void 0 : y.columns) || [{ label: "", key: "" }];
701
+ }), v = _(() => {
702
+ var y;
703
+ return ((y = l.value.data) == null ? void 0 : y.rows) || [];
704
+ }), n = _(() => l.value.filterText), h = _(() => {
705
+ var y, V;
706
+ if (!(n.value && n.value.trim().length > 0 || !((y = v.value[0]) != null && y.isRollup) && !((V = v.value[v.value.length - 1]) != null && V.isRollup))) {
707
+ if (l.value.rollupPosition === Oe.top || l.value.rollupPosition === void 0)
708
+ return Oe.top;
709
+ if (l.value.rollupPosition === Oe.bottom)
710
+ return Oe.bottom;
711
+ }
712
+ }), w = _(() => {
713
+ const W = h.value !== void 0 ? 1 : 0, N = (g.value ? g.value.$el.offsetHeight : 0) - 48;
714
+ return Math.floor((N - 34.5 - 32) / 48) - W;
715
+ }), z = _(() => {
716
+ var V, G;
717
+ let y = [];
718
+ switch (h.value) {
719
+ case Oe.top:
720
+ y = [...((V = v.value[0]) == null ? void 0 : V.cells) || []].map((W, N) => {
721
+ var M;
722
+ return {
723
+ main: W,
724
+ comparison: (M = v.value[0]) == null ? void 0 : M.comparisonCells[N],
725
+ rowType: E.value[N].type
726
+ };
727
+ });
728
+ break;
729
+ case Oe.bottom:
730
+ y = [...((G = v.value[v.value.length - 1]) == null ? void 0 : G.cells) || []].map((W, N) => {
731
+ var M;
732
+ return {
733
+ main: W,
734
+ comparison: (M = v.value[0]) == null ? void 0 : M.comparisonCells[N],
735
+ rowType: E.value[N].type
736
+ };
737
+ });
738
+ break;
739
+ }
740
+ return y.length > 0 && y[0].main === "" && (y[0].main = Ue(a, r, "Grand Total", "other")), y;
741
+ });
742
+ function U(y) {
743
+ let V = (y == null ? void 0 : y.main) || "";
744
+ return V.includes("#") && !V.startsWith("#") && (V = V.split("#")[0]), !y || y.main === "" || y.comparison === "" ? {
745
+ main: V
746
+ } : {
747
+ main: V,
748
+ comparison: y == null ? void 0 : y.comparison,
749
+ difference: Gt(y.main, y.comparison, b)
750
+ };
751
+ }
752
+ Xe(() => {
753
+ S();
754
+ });
755
+ const X = f([]);
756
+ let ee = 0, le;
757
+ function Te() {
758
+ var N;
759
+ if (!((N = l.value) != null && N.data)) {
760
+ X.value = [];
761
+ return;
762
+ }
763
+ const y = ++ee, V = (l.value.data.rows || []).map((M) => ({
764
+ isRollup: M.isRollup,
765
+ cells: Array.isArray(M.cells) ? [...M.cells] : [],
766
+ comparisonCells: Array.isArray(M.comparisonCells) ? [...M.comparisonCells] : []
767
+ })), G = (l.value.data.columns || []).map((M) => ({
768
+ key: M.key,
769
+ type: M.type,
770
+ label: M.label
771
+ })), W = {
772
+ rows: V,
773
+ columns: G,
774
+ filter: n.value ?? "",
775
+ globalSorts: fl(u.value).map((M) => ({
776
+ key: M.key,
777
+ type: M.type
778
+ })),
779
+ grandTotalPosition: h.value,
780
+ pageSize: w.value
781
+ };
782
+ Sl(jl, W).then((M) => {
783
+ y === ee && (M != null && M.error ? (D.open({ message: "Failed to process table data. Please retry.", type: "error" }), console.log(M.error), X.value = []) : X.value = vl(M.data || []));
784
+ });
785
+ }
786
+ he(
787
+ () => u.value,
788
+ (y) => {
789
+ F.tileIndex === void 0 || F.tileIndex === null || R(F.tileIndex, y);
790
+ },
791
+ { immediate: !0, deep: !0 }
792
+ );
793
+ const ve = _(() => {
794
+ var G, W;
795
+ const y = ((G = l.value.data) == null ? void 0 : G.rows) || [], V = ((W = l.value.data) == null ? void 0 : W.columns) || [];
796
+ return JSON.stringify({
797
+ rowsLength: y.length,
798
+ columns: V.map((N) => ({ key: N.key, type: N.type, label: N.label })),
799
+ filter: n.value ?? "",
800
+ globalSorts: u.value.map((N) => ({ key: N.key, type: N.type })),
801
+ grandTotalPosition: h.value,
802
+ pageSize: w.value
803
+ });
804
+ });
805
+ he(
806
+ () => ve.value,
807
+ () => {
808
+ clearTimeout(le), le = setTimeout(Te, 200);
809
+ },
810
+ { immediate: !0 }
811
+ );
812
+ function Fe(y) {
813
+ const V = u.value.find((G) => G.key === y);
814
+ if (!V) {
815
+ u.value.push({ key: y, type: qe.Asc });
816
+ return;
817
+ }
818
+ V.type === qe.Asc ? V.type = qe.Desc : V.type === qe.Desc && (u.value = u.value.filter((G) => G.key !== y));
819
+ }
820
+ const Ve = _(
821
+ () => {
822
+ var y;
823
+ return (((y = l.value.colWidths) == null ? void 0 : y.length) ?? 0) > 0 || m.value.length > 0;
824
+ }
825
+ ), fe = _(() => {
826
+ var y;
827
+ return (y = l.value.data) != null && y.columns ? l.value.data.columns.map((V) => {
828
+ const G = Ue(a, r, V.label, "other"), W = u.value.find((ie) => ie.key === V.key), N = !!W, M = N ? W.type === qe.Asc ? "arrow_upward" : "arrow_downward" : "unfold_more";
829
+ return {
830
+ accessorKey: V.key,
831
+ header: () => {
832
+ const ie = B("FmIcon");
833
+ return ot(
834
+ "button",
835
+ {
836
+ type: "button",
837
+ class: `w-full flex items-center gap-1 group/select-header select-none ${V.type === "NUMERIC" ? "justify-end" : "justify-start"} ${N ? "text-fm-color-typo-primary" : "text-fm-color-neutral-gray-400"}`,
838
+ onClick: () => Fe(V.key)
839
+ },
840
+ [
841
+ ot(
842
+ "span",
843
+ { class: `${V.type === "NUMERIC" ? "text-right" : ""} whitespace-nowrap` },
844
+ G
845
+ ),
846
+ ot(ie, {
847
+ name: M,
848
+ color: N ? "primary" : "neutral-gray-400",
849
+ size: "sm",
850
+ class: "transition-transform",
851
+ style: M === "arrow_upward" ? "transform: translateY(-1px);" : ""
852
+ })
853
+ ]
854
+ );
855
+ },
856
+ cell: (ie) => {
857
+ var we, ge;
858
+ const Ce = U(ie.getValue()), be = (ge = (we = ie == null ? void 0 : ie.row) == null ? void 0 : we.original) == null ? void 0 : ge.isRollup;
859
+ return ot(
860
+ "div",
861
+ {
862
+ class: [
863
+ be ? "fm-typo-en-body-md-600 text-fm-color-typo-secondary" : "fm-typo-en-body-md-400",
864
+ V.type === "NUMERIC" ? "text-right" : "",
865
+ Ve.value ? "whitespace-normal break-words line-clamp-6" : "whitespace-nowrap"
866
+ ].join(" ")
867
+ },
868
+ [V.type === "NUMERIC" ? ht(Ce.main) : Ce.main]
869
+ );
870
+ },
871
+ enableSorting: !1
872
+ };
873
+ }) : [];
874
+ });
875
+ return he(
876
+ () => m.value.length > 0,
877
+ async (y) => {
878
+ y && c.value && (await Se(), T());
879
+ }
880
+ ), he(
881
+ [() => fe.value],
882
+ async () => {
883
+ var N;
884
+ await Se();
885
+ const y = (N = g.value) == null ? void 0 : N.$el;
886
+ if (!y) return;
887
+ const V = y.querySelector("table");
888
+ if (!V) return;
889
+ V.classList.add(Ve.value ? "table-fixed" : "table-auto");
890
+ let G, W;
891
+ c.value ? (T(), G = m.value, W = p.value) : (W = l.value.rowHeight, G = l.value.colWidths), typeof W == "number" && x(W, y), G == null || G.forEach((M, ie) => {
892
+ L(ie, M, y);
893
+ });
894
+ },
895
+ { immediate: !0 }
896
+ ), (y, V) => {
897
+ const G = B("FmTable");
898
+ return $(), te(xe, null, [
899
+ H("div", Jl, [
900
+ Be(y.$slots, "menu")
901
+ ]),
902
+ P(G, {
903
+ ref_key: "table",
904
+ ref: g,
905
+ "column-defs": fe.value,
906
+ "row-data": X.value,
907
+ "search-value": n.value,
908
+ "page-size": w.value,
909
+ "shrink-at": !1,
910
+ "force-mobile-footer": !0,
911
+ class: "scrollbar-hide-table"
912
+ }, {
913
+ "pin-top": se(() => [
914
+ H("tbody", null, [
915
+ H("tr", Kl, [
916
+ ($(!0), te(xe, null, rt(z.value, (W, N) => ($(), te("td", {
917
+ key: `${s(nt)()}_${N}`,
918
+ class: "h-[48px] text-fm-color-typo-primary px-16"
919
+ }, [
920
+ H("span", {
921
+ class: Ye([
922
+ "items-center text-fm-color-typo-secondary gap-2",
923
+ W.rowType === "NUMERIC" ? "text-right" : "",
924
+ Ve.value ? "whitespace-normal break-words line-clamp-6" : "whitespace-nowrap"
925
+ ])
926
+ }, [
927
+ H("p", Zl, Le(W.rowType === "NUMERIC" ? s(ht)(W.main) : W.main), 1),
928
+ H("p", Ql, Le(W.comparison ? W.rowType === "NUMERIC" ? `(${s(ht)(W.comparison)})` : `(${W.comparison})` : ""), 1)
929
+ ], 2)
930
+ ]))), 128))
931
+ ])
932
+ ])
933
+ ]),
934
+ _: 1
935
+ }, 8, ["column-defs", "row-data", "search-value", "page-size"])
936
+ ], 64);
937
+ };
938
+ }
939
+ }), ta = /* @__PURE__ */ Re({
940
+ __name: "WidgetStackBarChart",
941
+ props: /* @__PURE__ */ Pe({
942
+ tileIndex: {}
943
+ }, {
944
+ modelValue: { required: !0 },
945
+ modelModifiers: {}
946
+ }),
947
+ emits: ["update:modelValue"],
948
+ setup(e) {
949
+ const a = e, r = We(e, "modelValue"), l = f(null), b = _(() => {
950
+ var E;
951
+ return ((E = r.value.data) == null ? void 0 : E.xAxis) || [];
952
+ }), S = _(() => {
953
+ var g;
954
+ return ((g = r.value.data) == null ? void 0 : g.datasets) ?? [];
955
+ }), { datalabels: R, xCfg: D, yCfg: F, isTransposed: u, legend: c, chartWidth: m, chartHeight: p } = at(
956
+ r.value
957
+ ), L = _(() => S.value.length > 0 ? [
958
+ ...S.value.map((g, E) => {
959
+ let v = g.values;
960
+ return {
961
+ label: g.name,
962
+ data: v,
963
+ dash: !!g.isCompare,
964
+ backgroundColor: Ie({ index: E, isCompare: g.isCompare })
965
+ };
966
+ })
967
+ ] : []), x = tt();
968
+ function T() {
969
+ return x.extractChartSize(l.value, a.tileIndex) || { width: 0, height: 0 };
970
+ }
971
+ return Xe(() => {
972
+ Se(() => {
973
+ T();
974
+ });
975
+ }), he([L], () => {
976
+ Se(() => T());
977
+ }), (g, E) => {
978
+ const v = B("FmBarChart");
979
+ return $(), te(xe, null, [
980
+ Be(g.$slots, "menu"),
981
+ P(v, {
982
+ ref_key: "chartRef",
983
+ ref: l,
984
+ class: "bar-chart",
985
+ datasets: L.value,
986
+ "x-axis": { categories: b.value },
987
+ "x-cfg": s(D),
988
+ "y-cfg": s(F),
989
+ transpose: s(u),
990
+ stacked: !0,
991
+ legend: {
992
+ display: s(c).display ?? !1,
993
+ position: s(c).position,
994
+ maxHeight: s(c).maxHeight,
995
+ maxWidth: s(c).maxWidth,
996
+ labels: s(c).labels
997
+ },
998
+ datalabels: s(R),
999
+ "maintain-aspect-ratio": !1,
1000
+ style: Ne({
1001
+ "--chart-width": s(m) !== void 0 ? s(m) + "px" : "100%",
1002
+ "--chart-height": s(p) !== void 0 ? s(p) + "px" : "calc(100% - 36px)"
1003
+ })
1004
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
1005
+ ], 64);
1006
+ };
1007
+ }
1008
+ }), la = /* @__PURE__ */ Re({
1009
+ __name: "WidgetStackLineChart",
1010
+ props: /* @__PURE__ */ Pe({
1011
+ tileIndex: {}
1012
+ }, {
1013
+ modelValue: { required: !0 },
1014
+ modelModifiers: {}
1015
+ }),
1016
+ emits: ["update:modelValue"],
1017
+ setup(e) {
1018
+ var v;
1019
+ const a = e, r = We(e, "modelValue"), l = ((v = r.value.data) == null ? void 0 : v.xAxis) ?? [], b = _(
1020
+ () => l.length === 1 && D.value.length > 0 && D.value.every((n) => n.values.length === 1)
1021
+ ), S = _(() => b.value ? ["", l[0], ""] : l), R = f(null), D = _(() => {
1022
+ var n;
1023
+ return ((n = r.value.data) == null ? void 0 : n.datasets) ?? [];
1024
+ }), { datalabels: F, xCfg: u, yCfg: c, isTransposed: m, legend: p, chartWidth: L, chartHeight: x } = at(
1025
+ r.value
1026
+ ), T = _(() => D.value.length > 0 ? [
1027
+ ...D.value.map((n, h) => {
1028
+ let w = n.values;
1029
+ return b.value && (w = [NaN, w[0], NaN]), {
1030
+ label: n.name,
1031
+ data: w,
1032
+ dash: n.isCompare,
1033
+ fill: !1,
1034
+ color: Ie({ index: h, isCompare: n.isCompare }),
1035
+ pointRadius: b.value ? 4 : void 0,
1036
+ pointHoverRadius: b.value ? 6 : void 0,
1037
+ pointBackgroundColor: b.value ? Ie({ index: h, isCompare: n.isCompare }) : void 0,
1038
+ pointBorderColor: b.value ? Ie({ index: h, isCompare: n.isCompare }) : void 0,
1039
+ pointBorderWidth: b.value ? 2 : void 0
1040
+ };
1041
+ })
1042
+ ] : []), g = tt();
1043
+ function E() {
1044
+ return g.extractChartSize(R.value, a.tileIndex) || { width: 0, height: 0 };
1045
+ }
1046
+ return Xe(() => {
1047
+ Se(() => {
1048
+ E();
1049
+ });
1050
+ }), he([T], () => {
1051
+ Se(() => E());
1052
+ }), (n, h) => {
1053
+ const w = B("FmLineChart");
1054
+ return $(), te(xe, null, [
1055
+ Be(n.$slots, "menu"),
1056
+ P(w, {
1057
+ ref_key: "chartRef",
1058
+ ref: R,
1059
+ class: "line-chart",
1060
+ datasets: T.value,
1061
+ "x-axis": { categories: S.value },
1062
+ "x-cfg": s(u),
1063
+ "y-cfg": s(c),
1064
+ transpose: s(m),
1065
+ legend: {
1066
+ display: s(p).display ?? !1,
1067
+ position: s(p).position,
1068
+ maxHeight: s(p).maxHeight,
1069
+ maxWidth: s(p).maxWidth,
1070
+ labels: s(p).labels
1071
+ },
1072
+ stacked: !0,
1073
+ datalabels: s(F),
1074
+ "maintain-aspect-ratio": !1,
1075
+ style: Ne({
1076
+ "--chart-width": s(L) !== void 0 ? s(L) + "px" : "100%",
1077
+ "--chart-height": s(x) !== void 0 ? s(x) + "px" : "calc(100% - 36px)"
1078
+ })
1079
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
1080
+ ], 64);
1081
+ };
1082
+ }
1083
+ }), Ze = [
1084
+ "col-span-1",
1085
+ "col-span-2",
1086
+ "col-span-3",
1087
+ "col-span-4",
1088
+ "col-span-5",
1089
+ "col-span-6",
1090
+ "col-span-7",
1091
+ "col-span-8",
1092
+ "col-span-9",
1093
+ "col-span-10",
1094
+ "col-span-11",
1095
+ "col-span-12"
1096
+ ];
1097
+ function aa(e) {
1098
+ return e < 12 ? Ze[e - 1] : Ze[11];
1099
+ }
1100
+ function sa(e) {
1101
+ return e < 12 ? Ze[Math.min(11, e * 2 - 1)] : Ze[11];
1102
+ }
1103
+ function oa(e) {
1104
+ return e < 12 ? Ze[Math.min(11, e * 3 - 1)] : Ze[11];
1105
+ }
1106
+ const na = /* @__PURE__ */ Re({
1107
+ __name: "WidgetLinechart",
1108
+ props: /* @__PURE__ */ Pe({
1109
+ tileIndex: {}
1110
+ }, {
1111
+ modelValue: { required: !0 },
1112
+ modelModifiers: {}
1113
+ }),
1114
+ emits: ["update:modelValue"],
1115
+ setup(e) {
1116
+ var v;
1117
+ const a = e, r = We(e, "modelValue"), l = ((v = r.value.data) == null ? void 0 : v.xAxis) ?? [], b = _(
1118
+ () => l.length === 1 && D.value.length > 0 && D.value.every((n) => n.values.length === 1)
1119
+ ), S = _(() => b.value ? ["", l[0], ""] : l), R = f(null), D = _(() => {
1120
+ var n;
1121
+ return ((n = r.value.data) == null ? void 0 : n.datasets) ?? [];
1122
+ }), { datalabels: F, xCfg: u, yCfg: c, isTransposed: m, legend: p, chartWidth: L, chartHeight: x } = at(
1123
+ r.value
1124
+ ), T = _(() => D.value.length > 0 ? [
1125
+ ...D.value.map((n, h) => {
1126
+ let w = n.values;
1127
+ return b.value && (w = [NaN, w[0], NaN]), {
1128
+ label: n.name,
1129
+ data: w,
1130
+ dash: !!n.isCompare,
1131
+ fill: !1,
1132
+ color: Ie({ index: h, isCompare: n.isCompare }),
1133
+ pointRadius: b.value ? 4 : void 0,
1134
+ pointHoverRadius: b.value ? 6 : void 0,
1135
+ pointBackgroundColor: b.value ? Ie({ index: h, isCompare: n.isCompare }) : void 0,
1136
+ pointBorderColor: b.value ? Ie({ index: h, isCompare: n.isCompare }) : void 0,
1137
+ pointBorderWidth: b.value ? 2 : void 0
1138
+ };
1139
+ })
1140
+ ] : []), g = tt();
1141
+ function E() {
1142
+ return g.extractChartSize(R.value, a.tileIndex) || { width: 0, height: 0 };
1143
+ }
1144
+ return Xe(() => {
1145
+ Se(() => {
1146
+ E();
1147
+ });
1148
+ }), he([T], () => {
1149
+ Se(() => E());
1150
+ }), (n, h) => {
1151
+ const w = B("FmLineChart");
1152
+ return $(), te(xe, null, [
1153
+ Be(n.$slots, "menu"),
1154
+ P(w, {
1155
+ ref_key: "chartRef",
1156
+ ref: R,
1157
+ class: "line-chart",
1158
+ datasets: T.value,
1159
+ "x-axis": { categories: S.value },
1160
+ "x-cfg": s(u),
1161
+ "y-cfg": s(c),
1162
+ transpose: s(m),
1163
+ legend: {
1164
+ display: s(p).display ?? !1,
1165
+ position: s(p).position,
1166
+ maxHeight: s(p).maxHeight,
1167
+ maxWidth: s(p).maxWidth,
1168
+ labels: s(p).labels
1169
+ },
1170
+ datalabels: s(F),
1171
+ "maintain-aspect-ratio": !1,
1172
+ style: Ne({
1173
+ "--chart-width": s(L) !== void 0 ? s(L) + "px" : "100%",
1174
+ "--chart-height": s(x) !== void 0 ? s(x) + "px" : "calc(100% - 36px)"
1175
+ })
1176
+ }, null, 8, ["datasets", "x-axis", "x-cfg", "y-cfg", "transpose", "legend", "datalabels", "style"])
1177
+ ], 64);
1178
+ };
1179
+ }
1180
+ }), ra = { class: "flex flex-col gap-16" }, ia = { class: "flex flex-row" }, ua = /* @__PURE__ */ Re({
1181
+ __name: "PdfOrientationDialog",
1182
+ props: /* @__PURE__ */ Pe({
1183
+ reportType: {},
1184
+ index: {}
1185
+ }, {
1186
+ modelValue: { type: Boolean, required: !0 },
1187
+ modelModifiers: {}
1188
+ }),
1189
+ emits: ["update:modelValue"],
1190
+ setup(e) {
1191
+ const { t: a } = lt(), { FmForm: r } = zl, l = e, b = f(), S = We(e, "modelValue"), R = f(!0), D = f(!1), F = kt(), { selectedLocationIds: u, dateRange: c, timeRange: m } = Me(et()), p = f(mt.PORTRAIT);
1192
+ function L() {
1193
+ var T;
1194
+ (T = b.value) == null || T.validateInputs();
1195
+ }
1196
+ async function x() {
1197
+ D.value = !0;
1198
+ try {
1199
+ l.index != null && await Ht({
1200
+ reportType: l.reportType,
1201
+ index: l.index,
1202
+ orientationTypes: [p.value],
1203
+ isCombinedLocationLayout: R.value,
1204
+ timeRange: m.value,
1205
+ dateRange: c.value,
1206
+ locationIds: u.value
1207
+ });
1208
+ } catch (T) {
1209
+ F.open({ message: T.message, type: "error" });
1210
+ } finally {
1211
+ D.value = !1;
1212
+ }
1213
+ }
1214
+ return (T, g) => {
1215
+ const E = B("FmRadio"), v = B("FmRadioGroup"), n = B("FmButton"), h = B("FmDialog");
1216
+ return $(), re(h, {
1217
+ modelValue: S.value,
1218
+ "onUpdate:modelValue": g[2] || (g[2] = (w) => S.value = w),
1219
+ overlay: !0,
1220
+ "z-index": 10
1221
+ }, {
1222
+ "dialog-header": se(() => g[3] || (g[3] = [
1223
+ ft("Select Orientation")
1224
+ ])),
1225
+ default: se(() => [
1226
+ P(s(r), {
1227
+ ref_key: "form",
1228
+ ref: b,
1229
+ onValidationSuccess: x
1230
+ }, {
1231
+ default: se(() => [
1232
+ H("div", ra, [
1233
+ P(v, {
1234
+ modelValue: p.value,
1235
+ "onUpdate:modelValue": g[0] || (g[0] = (w) => p.value = w)
1236
+ }, {
1237
+ default: se(() => [
1238
+ P(E, {
1239
+ value: s(mt).PORTRAIT,
1240
+ label: s(a)("report.common.portrait")
1241
+ }, null, 8, ["value", "label"]),
1242
+ P(E, {
1243
+ value: s(mt).LANDSCAPE,
1244
+ label: s(a)("report.common.landscape")
1245
+ }, null, 8, ["value", "label"])
1246
+ ]),
1247
+ _: 1
1248
+ }, 8, ["modelValue"])
1249
+ ]),
1250
+ H("div", ia, [
1251
+ g[4] || (g[4] = H("div", { class: "grow" }, null, -1)),
1252
+ P(n, {
1253
+ label: s(a)("report.common.cancel"),
1254
+ variant: "tertiary",
1255
+ onClick: g[1] || (g[1] = (w) => S.value = !1)
1256
+ }, null, 8, ["label"]),
1257
+ H("div", null, [
1258
+ P(n, {
1259
+ label: s(a)("report.common.download"),
1260
+ loading: D.value,
1261
+ onClick: L
1262
+ }, null, 8, ["label", "loading"])
1263
+ ])
1264
+ ])
1265
+ ]),
1266
+ _: 1
1267
+ }, 512)
1268
+ ]),
1269
+ _: 1
1270
+ }, 8, ["modelValue"]);
1271
+ };
1272
+ }
1273
+ }), ca = {
1274
+ key: 1,
1275
+ class: "grow"
1276
+ }, da = {
1277
+ key: 2,
1278
+ class: "flex"
1279
+ }, Pa = /* @__PURE__ */ Re({
1280
+ __name: "DynamicWidget",
1281
+ props: /* @__PURE__ */ Pe({
1282
+ index: {
1283
+ type: Number,
1284
+ default: 0
1285
+ },
1286
+ hideExport: {
1287
+ type: Boolean,
1288
+ default: !1
1289
+ },
1290
+ customScreenWidth: {
1291
+ type: Number,
1292
+ required: !1,
1293
+ default: void 0
1294
+ }
1295
+ }, {
1296
+ modelValue: { required: !0, default: () => {
1297
+ } },
1298
+ modelModifiers: {}
1299
+ }),
1300
+ emits: ["update:modelValue"],
1301
+ setup(e) {
1302
+ const a = f(!0), r = We(e, "modelValue"), l = r.value.widget.config, { t: b, te: S } = lt(), R = e, D = f(null), F = f(l.rollup), u = f(nt()), c = f(l.drillDimension), m = _(() => {
1303
+ if (He.value.length > 0) {
1304
+ const i = He.value.findIndex(
1305
+ (Q) => Q.value === c.value
1306
+ );
1307
+ return i >= 0 ? i : 0;
1308
+ } else
1309
+ return -1;
1310
+ }), p = _(() => m.value !== 0), L = _(
1311
+ () => m.value != He.value.length - 1
1312
+ ), x = f(l.showTitle ?? !0), T = f(l.titleFontSize ?? 14), g = f(l.titleBold ?? !1), E = f(l.titleItalic ?? !1), v = f(l.titleUnderline ?? !1), n = f(l.chartWidth ?? void 0), h = f(l.chartHeight ?? void 0), w = f(l.showLabel ?? !1), z = f(l.labelAlign ?? bt.center), U = f(l.labelAnchor ?? yt.center), X = f(l.labelRotation ?? 0), ee = f(l.labelOffset ?? 0), le = f(l.labelFontSize ?? 12), Te = _(() => l.showSearchBar), ve = f(l.showX ?? !0), Fe = f(l.xPosition ?? wt.bottom), Ve = f(l.showXGrid ?? !1), fe = f(l.showXTick ?? !0), y = f(l.xTickFontSize ?? 12), V = f(l.showXTitle ?? !1), G = f(l.xTitle ?? ""), W = f(l.xTitleFontSize ?? 12), N = f(l.showY ?? !0), M = f(l.yPosition ?? xt.left), ie = f(l.showYGrid ?? !1), Ce = f(l.showYTick ?? !0), be = f(l.yTickFontSize ?? 12), we = f(l.showYTitle ?? !1), ge = f(l.yTitle ?? ""), ze = f(l.yTitleFontSize ?? 12), t = f(l.showLegend ?? void 0), d = f(l.legendPosition ?? St.top), C = f(l.usePointStyle ?? !0), k = f(l.legendMaxHeight), O = f(l.legendMaxWidth), ae = f(l.rowHeight ?? 0), de = f(l.colWidths ?? []), ue = f(!1), me = f(""), { breakpoints: q, getBreakpointsBoundary: o } = Ut(), j = f(), I = _(
1313
+ () => R.customScreenWidth === void 0 ? window.innerWidth : R.customScreenWidth
1314
+ ), oe = _(
1315
+ () => (I == null ? void 0 : I.value) > o("xs")[1] && (I == null ? void 0 : I.value) <= o("sm")[1]
1316
+ ), J = _(
1317
+ () => (I == null ? void 0 : I.value) > o("sm")[1] && (I == null ? void 0 : I.value) <= o("md")[1]
1318
+ ), ne = _(() => (I == null ? void 0 : I.value) > o("md")[1]), K = _(() => {
1319
+ const i = r.value.size.width;
1320
+ return ne.value || J.value ? aa(i) : oe.value ? sa(i) : oa(i);
1321
+ }), ye = _(
1322
+ () => Al.find((i) => i.type === r.value.widget.type)
1323
+ ), Z = It(() => {
1324
+ var i;
1325
+ j.value = ll((i = D.value) == null ? void 0 : i.$el.offsetWidth), u.value = nt();
1326
+ }), ke = _(() => {
1327
+ if (El(ce.value.type, Y.value))
1328
+ switch (r.value.widget.type) {
1329
+ case A.BarChart:
1330
+ return Il;
1331
+ case A.StackBarChart:
1332
+ return ta;
1333
+ case A.LineChart:
1334
+ return na;
1335
+ case A.StackLineChart:
1336
+ return la;
1337
+ case A.Circular:
1338
+ return Nl;
1339
+ case A.Scorecard:
1340
+ return ql;
1341
+ case A.Spacer:
1342
+ return Yl;
1343
+ case A.Table:
1344
+ return ea;
1345
+ default:
1346
+ return vt;
1347
+ }
1348
+ else
1349
+ return vt;
1350
+ }), Y = f(null), {
1351
+ selectedLocationIds: it,
1352
+ dateRange: _t,
1353
+ compareDateRange: Xt,
1354
+ timeRange: Tt,
1355
+ globalFilters: jt,
1356
+ isGlobalFiltersLoading: Ft
1357
+ } = Me(et()), { businessId: Jt } = Me(Ct()), { businessLoadedId: Kt, businessDataVersion: ut } = Me(et());
1358
+ _(() => Kt.value === Jt.value && it.value.length > 0 && !Ft.value);
1359
+ const Zt = f(!0), ce = _(() => {
1360
+ const i = JSON.parse(JSON.stringify(r.value.widget));
1361
+ return {
1362
+ ...i,
1363
+ config: {
1364
+ ...i.config,
1365
+ rollup: F.value,
1366
+ drillDimension: c.value,
1367
+ showGrandTotal: !1
1368
+ }
1369
+ };
1370
+ });
1371
+ function Qt() {
1372
+ return {
1373
+ data: Y.value,
1374
+ showTitle: x.value,
1375
+ titleFontSize: T.value,
1376
+ titleBold: g.value,
1377
+ titleItalic: E.value,
1378
+ titleUnderline: v.value,
1379
+ chartHeight: h.value,
1380
+ chartWidth: n.value,
1381
+ showLabel: w.value,
1382
+ labelAnchor: U.value,
1383
+ labelAlign: z.value,
1384
+ labelRotation: X.value,
1385
+ labelOffset: ee.value,
1386
+ labelFontSize: le.value,
1387
+ showX: ve.value,
1388
+ xPosition: Fe.value,
1389
+ showXGrid: Ve.value,
1390
+ showXTick: fe.value,
1391
+ xTickFontSize: y.value,
1392
+ showXTitle: V.value,
1393
+ xTitle: G.value,
1394
+ xTitleFontSize: W.value,
1395
+ showY: N.value,
1396
+ yPosition: M.value,
1397
+ showYGrid: ie.value,
1398
+ showYTick: Ce.value,
1399
+ yTitle: ge.value,
1400
+ showYTitle: we.value,
1401
+ yTitleFontSize: ze.value,
1402
+ yTickFontSize: be.value,
1403
+ isTransposed: ce.value.config.isTransposed,
1404
+ showLegend: t.value,
1405
+ legendPosition: d.value,
1406
+ usePointStyle: C.value,
1407
+ legendMaxHeight: k.value,
1408
+ legendMaxWidth: O.value
1409
+ };
1410
+ }
1411
+ function el() {
1412
+ return {
1413
+ data: Y.value,
1414
+ filterText: me.value,
1415
+ rollupPosition: ce.value.config.rollupPosition,
1416
+ rowHeight: ae.value,
1417
+ colWidths: de.value
1418
+ };
1419
+ }
1420
+ const Lt = _(() => {
1421
+ switch (ce.value.type) {
1422
+ case A.Table:
1423
+ return el();
1424
+ case A.BarChart:
1425
+ case A.LineChart:
1426
+ case A.StackBarChart:
1427
+ case A.StackLineChart:
1428
+ case A.Circular:
1429
+ return Qt();
1430
+ default:
1431
+ return { data: Y.value };
1432
+ }
1433
+ }), Dt = _(() => {
1434
+ const { config: i } = r.value.widget;
1435
+ if (i.rollup != null) {
1436
+ const Q = [...i.dimensions].filter(($e) => !$e.hide);
1437
+ return Q.sort(
1438
+ ($e, Qe) => (i.rowIds || []).indexOf(pt($e)) - (i.rowIds || []).indexOf(pt(Qe))
1439
+ ), [
1440
+ { label: Ue(b, S, "None", "other"), value: "none" },
1441
+ { label: Ue(b, S, "Grand Total", "other"), value: 0 },
1442
+ ...[...Q].slice(0, Q.length - 1).map(($e, Qe) => ({
1443
+ label: Ue(b, S, $e.label, "other"),
1444
+ value: Qe + 1
1445
+ }))
1446
+ ];
1447
+ }
1448
+ return [];
1449
+ }), He = _(() => {
1450
+ const { config: i } = ce.value;
1451
+ return i.isDrillable ? i.dimensions.map((Q) => ({
1452
+ label: Ue(b, S, Q.label, "other"),
1453
+ value: pt(Q)
1454
+ })) : [];
1455
+ }), tl = _(() => {
1456
+ const i = r.value.id;
1457
+ return (jt.value || []).filter(
1458
+ (Q) => Array.isArray(Q.tileIds) && Q.tileIds.includes(i)
1459
+ );
1460
+ });
1461
+ he(
1462
+ () => r.value.widget.config,
1463
+ (i) => {
1464
+ F.value = i.rollup, x.value = i.showTitle ?? !0, T.value = i.titleFontSize ?? 14, g.value = i.titleBold ?? !1, E.value = i.titleItalic ?? !1, v.value = i.titleUnderline ?? !1, h.value = i.chartHeight ?? void 0, n.value = i.chartWidth ?? void 0, w.value = i.showLabel ?? !1, z.value = i.labelAlign ?? bt.center, U.value = i.labelAnchor ?? yt.center, X.value = i.labelRotation ?? 0, ee.value = i.labelOffset ?? 0, le.value = i.labelFontSize ?? 12, ve.value = i.showX ?? !0, Fe.value = i.xPosition ?? wt.bottom, Ve.value = i.showXGrid ?? !1, fe.value = i.showXTick ?? !0, y.value = i.xTickFontSize ?? 12, V.value = i.showXTitle ?? !1, G.value = i.xTitle ?? "", W.value = i.xTitleFontSize ?? 12, N.value = i.showY ?? !0, M.value = i.yPosition ?? xt.left, ie.value = i.showYGrid ?? !1, Ce.value = i.showYTick ?? !0, be.value = i.yTickFontSize ?? 12, we.value = i.showYTitle ?? !1, ge.value = i.yTitle ?? "", ze.value = i.yTitleFontSize ?? 12, t.value = i.showLegend ?? void 0, d.value = i.legendPosition ?? St.top, C.value = i.usePointStyle ?? !0, k.value = i.legendMaxHeight, O.value = i.legendMaxWidth, ae.value = i.rowHeight ?? 0, de.value = i.colWidths ?? [];
1465
+ },
1466
+ { deep: !0 }
1467
+ ), he([() => F.value], () => {
1468
+ F.value !== null && (r.value.widget.config.rollup = F.value);
1469
+ }), he(
1470
+ [
1471
+ () => ce.value,
1472
+ () => _t.value,
1473
+ () => Tt.value,
1474
+ () => Xt.value,
1475
+ () => it.value,
1476
+ () => tl.value,
1477
+ () => ut.value
1478
+ ],
1479
+ () => {
1480
+ Vt();
1481
+ },
1482
+ { deep: !0 }
1483
+ ), he(
1484
+ [() => r.value.size],
1485
+ () => {
1486
+ Z();
1487
+ },
1488
+ { deep: !0 }
1489
+ ), Xe(() => {
1490
+ Z(), q.value.sm || q.value.md || q.value.xs ? (console.log("Ignoring resize event due to keyboard"), addEventListener("change", Z)) : addEventListener("resize", Z), Vt();
1491
+ }), gl(() => {
1492
+ q.value.sm || q.value.md || q.value.xs ? (console.log("Ignoring resize event due to keyboard"), removeEventListener("change", Z)) : removeEventListener("resize", Z);
1493
+ });
1494
+ const Rt = kt();
1495
+ let st;
1496
+ async function Vt() {
1497
+ if (ce.value.config.schemaNames.length <= 0 && !(ce.value.config.dimensions.length <= 0 || ce.value.config.metrics.length <= 0)) {
1498
+ Rt.open({
1499
+ message: "schema must not be empty and dimension or metrics must have at least 1 column",
1500
+ type: "info"
1501
+ }), a.value = !1;
1502
+ return;
1503
+ }
1504
+ try {
1505
+ a.value = !0, st && st.abort(), st = new AbortController();
1506
+ const i = st.signal, Q = ut.value, $e = await It(Ot, 500)(ce.value, i, r.value.id);
1507
+ ut.value === Q && (Y.value = $e, u.value = nt()), a.value = !1;
1508
+ } catch (i) {
1509
+ i.code !== "ERR_CANCELED" && (Y.value = null, Rt.open({ message: `Invalid chart ${ce.value.type}`, type: "error" }), console.log(i), a.value = !1);
1510
+ }
1511
+ }
1512
+ function ll(i) {
1513
+ switch (r.value.widget.type) {
1514
+ case "SPACER":
1515
+ return;
1516
+ case "SCORECARD":
1517
+ return;
1518
+ case "TABLE":
1519
+ return `${r.value.size.height * 100 + (Te.value ? 72 : 0) + 96.5}px`;
1520
+ }
1521
+ return `${Math.max(i / r.value.size.width, 90) * r.value.size.height}px`;
1522
+ }
1523
+ function al() {
1524
+ const i = m.value - 1;
1525
+ i >= 0 && (c.value = He.value[i].value);
1526
+ }
1527
+ function sl() {
1528
+ const i = m.value + 1;
1529
+ i >= 0 && i < He.value.length && (c.value = He.value[i].value);
1530
+ }
1531
+ const zt = f(Je.EXCEL), $t = f(), ol = Object.values(Je).map((i) => ({
1532
+ label: Cl(i),
1533
+ value: i,
1534
+ onClick: async () => {
1535
+ i === Je.EXCEL || i === Je.PDFFULLSIZE || i === Je.PDFRECEIPT ? await Ht({
1536
+ reportType: i,
1537
+ index: R.index,
1538
+ isCombinedLocationLayout: Zt.value,
1539
+ timeRange: Tt.value,
1540
+ dateRange: _t.value,
1541
+ locationIds: it.value
1542
+ }) : i === Je.PDF && (zt.value = i, $t.value = R.index, ue.value = !0);
1543
+ }
1544
+ })), nl = ce.value.type === A.Spacer ? "flat" : "outlined", rl = ce.value.type === A.Spacer ? "p-0" : "p-16";
1545
+ return (i, Q) => {
1546
+ const $e = B("FmTooltip"), Qe = B("FmSearch"), il = B("FmCheckbox"), ct = B("FmButton"), ul = B("FmSelect"), cl = B("FmMenuItem"), dl = B("FmMenu"), ml = B("FmForm"), pl = B("FmCircularProgress"), hl = B("FmCard");
1547
+ return $(), re(hl, {
1548
+ ref_key: "tileCard",
1549
+ ref: D,
1550
+ class: Ye(`${K.value} ${s(rl)}`),
1551
+ variant: s(nl)
1552
+ }, {
1553
+ default: se(() => [
1554
+ P(ua, {
1555
+ modelValue: ue.value,
1556
+ "onUpdate:modelValue": Q[0] || (Q[0] = (je) => ue.value = je),
1557
+ "report-type": zt.value,
1558
+ index: $t.value
1559
+ }, null, 8, ["modelValue", "report-type", "index"]),
1560
+ !a.value && !s(Ft) ? ($(), te("div", {
1561
+ key: 0,
1562
+ style: Ne({ height: j.value })
1563
+ }, [
1564
+ ($(), re(yl(ke.value), {
1565
+ key: u.value,
1566
+ modelValue: Lt.value,
1567
+ "onUpdate:modelValue": Q[4] || (Q[4] = (je) => Lt.value = je),
1568
+ "tile-index": R.index
1569
+ }, {
1570
+ menu: se(() => [
1571
+ P(ml, { class: "flex items-center gap-2" }, {
1572
+ default: se(() => {
1573
+ var je, At, Et, Mt;
1574
+ return [
1575
+ P($e, {
1576
+ variant: "plain",
1577
+ placement: "right",
1578
+ content: ce.value.description,
1579
+ "hide-arrow": !0,
1580
+ disabled: !ce.value.description
1581
+ }, {
1582
+ default: se(() => [
1583
+ x.value !== !1 ? ($(), te("p", {
1584
+ key: 0,
1585
+ style: Ne({
1586
+ fontSize: T.value + "px",
1587
+ fontWeight: g.value ? "bold" : "normal",
1588
+ fontStyle: E.value ? "italic" : "normal",
1589
+ textDecoration: v.value ? "underline" : "none"
1590
+ }),
1591
+ class: Ye(["text-fm-color-typo-secondary line-clamp-1", [
1592
+ T.value <= 18 ? "fm-typo-en-body-md-400" : "",
1593
+ ce.value.description ? "border-b-2 border-dashed border-gray-300" : ""
1594
+ ]])
1595
+ }, Le(s(Ue)(s(b), s(S), ce.value.title, "other")), 7)) : De("", !0)
1596
+ ]),
1597
+ _: 1
1598
+ }, 8, ["content", "disabled"]),
1599
+ (je = ye.value) != null && je.showSearchBar ? ($(), re(Qe, {
1600
+ key: 0,
1601
+ modelValue: me.value,
1602
+ "onUpdate:modelValue": Q[1] || (Q[1] = (Ae) => me.value = Ae),
1603
+ class: "grow"
1604
+ }, null, 8, ["modelValue"])) : ($(), te("div", ca)),
1605
+ bl(P(il, {
1606
+ modelValue: w.value,
1607
+ "onUpdate:modelValue": Q[2] || (Q[2] = (Ae) => w.value = Ae),
1608
+ label: "Label",
1609
+ value: !1
1610
+ }, null, 8, ["modelValue"]), [
1611
+ [wl, (At = ye.value) == null ? void 0 : At.showLabel]
1612
+ ]),
1613
+ (Et = ye.value) != null && Et.showDrillDimension && He.value.length > 0 ? ($(), te("div", da, [
1614
+ P(ct, {
1615
+ icon: "arrow_upward",
1616
+ variant: "tertiary",
1617
+ disabled: !p.value,
1618
+ onClick: al
1619
+ }, null, 8, ["disabled"]),
1620
+ P(ct, {
1621
+ icon: "arrow_downward",
1622
+ variant: "tertiary",
1623
+ disabled: !L.value,
1624
+ onClick: sl
1625
+ }, null, 8, ["disabled"])
1626
+ ])) : De("", !0),
1627
+ (Mt = ye.value) != null && Mt.showRollup && Dt.value.length > 0 ? ($(), re(ul, {
1628
+ key: 3,
1629
+ modelValue: F.value,
1630
+ "onUpdate:modelValue": Q[3] || (Q[3] = (Ae) => F.value = Ae),
1631
+ class: "w-[150px]",
1632
+ items: Dt.value
1633
+ }, null, 8, ["modelValue", "items"])) : De("", !0),
1634
+ R.hideExport ? De("", !0) : ($(), re(dl, {
1635
+ key: 4,
1636
+ shift: !0
1637
+ }, {
1638
+ "menu-button": se(() => [
1639
+ P(ct, {
1640
+ icon: "more_vert",
1641
+ variant: "tertiary"
1642
+ })
1643
+ ]),
1644
+ default: se(() => [
1645
+ ($(!0), te(xe, null, rt(s(ol), (Ae) => ($(), re(cl, {
1646
+ key: Ae.value,
1647
+ label: Ae.label,
1648
+ onClick: Ae.onClick
1649
+ }, null, 8, ["label", "onClick"]))), 128))
1650
+ ]),
1651
+ _: 1
1652
+ }))
1653
+ ];
1654
+ }),
1655
+ _: 1
1656
+ })
1657
+ ]),
1658
+ _: 1
1659
+ }, 8, ["modelValue", "tile-index"]))
1660
+ ], 4)) : ($(), re(pl, { key: 1 }))
1661
+ ]),
1662
+ _: 1
1663
+ }, 8, ["class", "variant"]);
1664
+ };
1665
+ }
1666
+ });
1667
+ var Ge = /* @__PURE__ */ ((e) => (e.Select = "Select", e.TextField = "TextField", e.Timestamp = "Timestamp", e))(Ge || {});
1668
+ function ma(e) {
1669
+ let a = !1, r = 1;
1670
+ switch (e) {
1671
+ case _e.Equal:
1672
+ case _e.NotEqual:
1673
+ case _e.Like:
1674
+ case _e.NotLike:
1675
+ a = !1, r = 1;
1676
+ break;
1677
+ case _e.GreaterThan:
1678
+ case _e.GreaterThanOrEqual:
1679
+ case _e.LessThan:
1680
+ case _e.LessThanOrEqual:
1681
+ a = !0, r = 1;
1682
+ break;
1683
+ case _e.Between:
1684
+ a = !0, r = 2;
1685
+ break;
1686
+ }
1687
+ return {
1688
+ fixed: a,
1689
+ count: r
1690
+ };
1691
+ }
1692
+ function Ba({
1693
+ operator: e,
1694
+ dimensionOption: a,
1695
+ dataType: r,
1696
+ t: l
1697
+ }) {
1698
+ const { fixed: b, count: S } = ma(e);
1699
+ switch (r) {
1700
+ case Ee.String:
1701
+ return {
1702
+ type: "TextField",
1703
+ fixed: b,
1704
+ count: S,
1705
+ dataType: void 0,
1706
+ default: ""
1707
+ };
1708
+ case Ee.Numeric:
1709
+ return {
1710
+ type: "TextField",
1711
+ fixed: b,
1712
+ count: S,
1713
+ dataType: "number",
1714
+ default: 0
1715
+ };
1716
+ case Ee.Bool:
1717
+ return {
1718
+ type: "Select",
1719
+ fixed: b,
1720
+ count: S,
1721
+ options: [
1722
+ { label: l("report.common.yes"), value: !0 },
1723
+ { label: l("report.common.no"), value: !1 }
1724
+ ],
1725
+ default: !0
1726
+ };
1727
+ case Ee.Timestamp:
1728
+ return Yt({
1729
+ dimensionOption: a,
1730
+ fixed: b,
1731
+ count: S,
1732
+ t: l
1733
+ });
1734
+ }
1735
+ return {
1736
+ type: "TextField",
1737
+ fixed: b,
1738
+ count: S,
1739
+ dataType: void 0,
1740
+ default: ""
1741
+ };
1742
+ }
1743
+ function Ha(e) {
1744
+ switch (e) {
1745
+ case pe.HourOfDay:
1746
+ return 0;
1747
+ case pe.DayOfMonth:
1748
+ return 1;
1749
+ default:
1750
+ return;
1751
+ }
1752
+ }
1753
+ function Oa(e) {
1754
+ switch (e) {
1755
+ case pe.HourOfDay:
1756
+ return 23;
1757
+ case pe.DayOfMonth:
1758
+ return 31;
1759
+ default:
1760
+ return;
1761
+ }
1762
+ }
1763
+ function Yt({
1764
+ dimensionOption: e,
1765
+ fixed: a,
1766
+ count: r,
1767
+ t: l
1768
+ }) {
1769
+ switch (e) {
1770
+ case pe.HourOfDay:
1771
+ return {
1772
+ type: Ge.Select,
1773
+ fixed: a,
1774
+ count: r,
1775
+ options: Array.from({ length: 24 }, (b, S) => ({
1776
+ label: S.toString().padStart(2, "0"),
1777
+ value: S.toString()
1778
+ })),
1779
+ default: "0"
1780
+ };
1781
+ case pe.DayOfWeek:
1782
+ return {
1783
+ type: Ge.Select,
1784
+ fixed: a,
1785
+ count: r,
1786
+ options: [
1787
+ { label: l("report.days.sunday"), value: "1" },
1788
+ { label: l("report.days.monday"), value: "2" },
1789
+ { label: l("report.days.tuesday"), value: "3" },
1790
+ { label: l("report.days.wednesday"), value: "4" },
1791
+ { label: l("report.days.thursday"), value: "5" },
1792
+ { label: l("report.days.friday"), value: "6" },
1793
+ { label: l("report.days.saturday"), value: "7" }
1794
+ ],
1795
+ default: "1"
1796
+ };
1797
+ case pe.DayOfMonth:
1798
+ return {
1799
+ type: Ge.Select,
1800
+ fixed: a,
1801
+ count: r,
1802
+ options: Array.from({ length: 31 }, (b, S) => ({
1803
+ label: (S + 1).toString(),
1804
+ value: (S + 1).toString()
1805
+ })),
1806
+ default: "1"
1807
+ };
1808
+ case pe.MonthOfYear:
1809
+ return {
1810
+ type: Ge.Select,
1811
+ fixed: a,
1812
+ count: r,
1813
+ options: [
1814
+ { label: l("report.months.january"), value: "1" },
1815
+ { label: l("report.months.february"), value: "2" },
1816
+ { label: l("report.months.march"), value: "3" },
1817
+ { label: l("report.months.april"), value: "4" },
1818
+ { label: l("report.months.may"), value: "5" },
1819
+ { label: l("report.months.june"), value: "6" },
1820
+ { label: l("report.months.july"), value: "7" },
1821
+ { label: l("report.months.august"), value: "8" },
1822
+ { label: l("report.months.september"), value: "9" },
1823
+ { label: l("report.months.october"), value: "10" },
1824
+ { label: l("report.months.november"), value: "11" },
1825
+ { label: l("report.months.december"), value: "12" }
1826
+ ],
1827
+ default: "1"
1828
+ };
1829
+ default:
1830
+ return {
1831
+ type: Ge.Timestamp,
1832
+ fixed: a,
1833
+ count: r,
1834
+ default: (/* @__PURE__ */ new Date()).toISOString()
1835
+ };
1836
+ }
1837
+ }
1838
+ function Pt({
1839
+ dimensionOption: e,
1840
+ t: a
1841
+ }) {
1842
+ const r = Yt({
1843
+ dimensionOption: e,
1844
+ fixed: !1,
1845
+ count: 1,
1846
+ t: a
1847
+ });
1848
+ return r.type === Ge.Select ? r.options : [];
1849
+ }
1850
+ const pa = "mf-reportglobalFilter";
1851
+ function Bt(e, a) {
1852
+ var r;
1853
+ return [
1854
+ a,
1855
+ e.schemaName,
1856
+ e.name,
1857
+ e.operator ?? "",
1858
+ e.option ?? "",
1859
+ e.dataFormula ?? "",
1860
+ ((r = e.tileIds) == null ? void 0 : r.join(",")) ?? ""
1861
+ ].join("|");
1862
+ }
1863
+ const ha = qt(pa, () => {
1864
+ const e = f({}), a = f(!1), r = () => ({
1865
+ search: "",
1866
+ selectedValues: [],
1867
+ keepSelection: !1,
1868
+ showAdvanced: !1,
1869
+ visibleCount: 50
1870
+ });
1871
+ function l(F, u) {
1872
+ const c = Bt(F, u);
1873
+ return e.value[c] || (e.value[c] = r()), e.value[c];
1874
+ }
1875
+ function b(F, u, c, m) {
1876
+ l(F, u)[c] = m;
1877
+ }
1878
+ function S(F, u, c = 50) {
1879
+ l(F, u).visibleCount += c;
1880
+ }
1881
+ function R(F) {
1882
+ a.value = F;
1883
+ }
1884
+ return {
1885
+ allStates: _(() => e.value),
1886
+ getGlobalFilter: l,
1887
+ setGlobalFilter: b,
1888
+ showMore: S,
1889
+ includeUnavailable: a,
1890
+ setIncludeUnavailable: R,
1891
+ getKey: Bt
1892
+ };
1893
+ }), fa = { class: "flex flex-row flex-wrap gap-2" }, va = { class: "inline-flex max-w-[460px]" }, ga = {
1894
+ key: 0,
1895
+ class: "flex justify-center my-2"
1896
+ }, ya = { class: "px-2 pb-8" }, ba = { class: "flex-1 overflow-y-auto overflow-x-hidden" }, wa = { class: "px-2 pb-8" }, xa = { class: "flex items-start w-full" }, Sa = ["onClick"], Ca = { class: "fm-typo-en-body-md-400" }, ka = { key: 0 }, _a = { class: "px-12 py-3" }, Ta = { class: "flex items-center justify-between" }, Fa = ["onClick"], La = { class: "fm-typo-en-body-md-400" }, Da = { class: "text-xs max-w-[200px]" }, Ra = { class: "px-4 py-3 flex flex-row justify-end gap-2 bg-white" }, qa = /* @__PURE__ */ Re({
1897
+ __name: "FilterSelector",
1898
+ setup(e) {
1899
+ const { t: a, locale: r } = lt(), { currentReport: l, editingReport: b, editingTile: S } = Me(kl());
1900
+ let { globalFilters: R, isGlobalFiltersLoading: D, timeRange: F, dateRange: u, selectedLocationIds: c } = Me(et()), { schemas: m } = Me(_l()), { showMore: p, getGlobalFilter: L, setGlobalFilter: x, setIncludeUnavailable: T, getKey: g } = ha(), E = null;
1901
+ const v = f(!1), n = {}, h = _(() => {
1902
+ var t;
1903
+ return ((t = l.value) == null ? void 0 : t.id) ?? "";
1904
+ }), w = f([]);
1905
+ function z(t, d) {
1906
+ const C = t.id;
1907
+ if (d)
1908
+ n.value = { ...n.value, [C]: d };
1909
+ else {
1910
+ const k = { ...n.value };
1911
+ delete k[C], n.value = k;
1912
+ }
1913
+ }
1914
+ function U(t) {
1915
+ const C = L(t.filter, h.value).selectedValues;
1916
+ t.selectedValues = t.keepSelection ? C : t.options.map((k) => k.value), t.filter.values = [...t.selectedValues], x(t.filter, h.value, "selectedValues", t.selectedValues);
1917
+ }
1918
+ he(
1919
+ () => ({
1920
+ reportId: h.value,
1921
+ globalFilters: R.value
1922
+ }),
1923
+ () => {
1924
+ w.value = (R.value || []).map((t) => {
1925
+ const d = L(t, h.value), C = d.selectedValues.length ? [...d.selectedValues] : [...t.values ?? []];
1926
+ return {
1927
+ id: g(t, h.value),
1928
+ filter: t,
1929
+ search: d.search,
1930
+ options: [],
1931
+ type: X(t),
1932
+ selectedValues: C,
1933
+ visibleCount: d.visibleCount,
1934
+ keepSelection: d.keepSelection,
1935
+ showAdvanced: d.showAdvanced
1936
+ };
1937
+ }), fe();
1938
+ },
1939
+ { immediate: !0 }
1940
+ ), he(
1941
+ [F, u, c],
1942
+ async () => {
1943
+ await fe();
1944
+ },
1945
+ { deep: !0, immediate: !0 }
1946
+ ), he(
1947
+ [() => S.value],
1948
+ async () => {
1949
+ w.value.forEach((t) => {
1950
+ t.options = [];
1951
+ }), await fe();
1952
+ },
1953
+ { deep: !0 }
1954
+ );
1955
+ function X(t) {
1956
+ var C;
1957
+ const d = (C = m.value.find((k) => k.name === t.schemaName)) == null ? void 0 : C.fields.find((k) => k.name === t.name);
1958
+ return d == null ? void 0 : d.type;
1959
+ }
1960
+ function ee(t) {
1961
+ var ue, me;
1962
+ if (!b.value && !l.value && !S.value) return [];
1963
+ const d = S.value ? [S.value] : [...((ue = b.value) == null ? void 0 : ue.tiles) ?? ((me = l.value) == null ? void 0 : me.tiles) ?? []], { name: C = "", schemaName: k = "" } = t, O = d.filter((q) => {
1964
+ var J, ne;
1965
+ const o = (J = q == null ? void 0 : q.widget) == null ? void 0 : J.config;
1966
+ if (!o || (ne = t.tileIds) != null && ne.length && !t.tileIds.includes(q.id)) return !1;
1967
+ const j = (o.dimensions ?? []).some(
1968
+ (K) => K.schemaName === k && K.name === C
1969
+ ), I = (o.joinDatasources ?? []).some(
1970
+ (K) => (K.dimensions ?? []).some((ye) => ye.schemaName === k && ye.name === C)
1971
+ ), oe = (o.schemaNames ?? []).includes(k);
1972
+ return j || I || oe;
1973
+ });
1974
+ if (!O.length) return [];
1975
+ const ae = (q, o) => {
1976
+ const j = /* @__PURE__ */ new Map(), I = (oe) => {
1977
+ const J = `${oe.schemaName}:${oe.name}:${oe.operator}`, ne = j.get(J);
1978
+ ne ? [_e.Like, _e.NotLike].includes(oe.operator) ? ne.values = Array.from(/* @__PURE__ */ new Set([...ne.values ?? [], ...oe.values ?? []])) : j.set(J, { ...oe }) : j.set(J, { ...oe });
1979
+ };
1980
+ return q.forEach(I), o.forEach(I), Array.from(j.values());
1981
+ }, de = (q) => {
1982
+ var j;
1983
+ const o = (j = q.dimensions) == null ? void 0 : j.find(
1984
+ (I) => I.schemaName === k && I.name === C
1985
+ );
1986
+ return {
1987
+ name: C,
1988
+ schemaName: k,
1989
+ label: (o == null ? void 0 : o.label) ?? C,
1990
+ hide: !1,
1991
+ option: t.option ?? null,
1992
+ dataFormula: o == null ? void 0 : o.dataFormula
1993
+ };
1994
+ };
1995
+ return O.map((q) => {
1996
+ var K, ye;
1997
+ const o = (K = q == null ? void 0 : q.widget) == null ? void 0 : K.config;
1998
+ if (!o) return null;
1999
+ const j = de(o), I = (o.dimensions ?? []).some((Z) => Z.schemaName === k) || (o.schemaNames ?? []).includes(k), oe = ae(
2000
+ o.filters ?? [],
2001
+ (t.filters ?? []).filter((Z) => {
2002
+ var ke;
2003
+ return (ke = o.schemaNames) == null ? void 0 : ke.includes(Z.schemaName);
2004
+ })
2005
+ ), J = (ye = o.joinDatasources) == null ? void 0 : ye.find(
2006
+ (Z) => (Z.schemaNames ?? []).includes(k) || (Z.dimensions ?? []).some((ke) => ke.schemaName === k)
2007
+ ), ne = ae(
2008
+ (J == null ? void 0 : J.filters) ?? [],
2009
+ (t.filters ?? []).filter((Z) => {
2010
+ var ke;
2011
+ return (ke = J == null ? void 0 : J.schemaNames) == null ? void 0 : ke.includes(Z.schemaName);
2012
+ })
2013
+ );
2014
+ return {
2015
+ type: A.Table,
2016
+ title: "Global Filter",
2017
+ config: {
2018
+ schemaNames: o.schemaNames,
2019
+ schemas: o.schemas,
2020
+ dimensions: I ? [j] : [],
2021
+ filters: oe,
2022
+ sorts: I ? [{ name: C, schemaName: k, type: qe.Asc, aggregation: null, dimensionOption: null }] : [],
2023
+ joinDatasources: !I && J ? [
2024
+ {
2025
+ ...J,
2026
+ dimensions: [j],
2027
+ sorts: [
2028
+ {
2029
+ name: C,
2030
+ schemaName: k,
2031
+ type: qe.Asc,
2032
+ aggregation: null,
2033
+ dimensionOption: null
2034
+ }
2035
+ ],
2036
+ filters: ne
2037
+ }
2038
+ ] : [],
2039
+ rowIds: [],
2040
+ metrics: [],
2041
+ limit: null,
2042
+ rollup: void 0,
2043
+ drillDimension: void 0,
2044
+ showGrandTotal: !1,
2045
+ breakdownDimension: void 0,
2046
+ sparklineDimension: void 0,
2047
+ isTransposed: !1,
2048
+ isDrillable: !1,
2049
+ isBlend: !1
2050
+ }
2051
+ };
2052
+ }).filter(Boolean);
2053
+ }
2054
+ function le(t) {
2055
+ return t.options.every((d) => {
2056
+ var C;
2057
+ return (C = t.selectedValues) == null ? void 0 : C.includes(d.value);
2058
+ });
2059
+ }
2060
+ function Te(t) {
2061
+ le(t) ? t.selectedValues = ["(EMPTY)"] : t.selectedValues = t.options.map((d) => d.value);
2062
+ }
2063
+ const ve = _(
2064
+ () => w.value.map((t) => {
2065
+ const d = t.options, C = t.search.toLowerCase() ?? "";
2066
+ return d.filter(
2067
+ (O) => O.label.toLowerCase().includes(C.toLowerCase())
2068
+ ).slice(0, t.visibleCount);
2069
+ })
2070
+ );
2071
+ function Fe(t) {
2072
+ t.visibleCount += 50, p(t.filter, h.value, 50);
2073
+ }
2074
+ async function Ve(t, d) {
2075
+ var C;
2076
+ if (!(!t.type && (t.type = X(t.filter), !t.type)))
2077
+ switch (t.type) {
2078
+ case Ee.String:
2079
+ try {
2080
+ const k = ee(t.filter);
2081
+ if (!k.length) {
2082
+ t.options = [];
2083
+ return;
2084
+ }
2085
+ const O = [];
2086
+ for (const q of k) {
2087
+ const o = await Ot(q, d);
2088
+ (o == null ? void 0 : o.type) === A.Table && O.push(...o.rows.map((j) => {
2089
+ var I;
2090
+ return ((I = j.cells) == null ? void 0 : I[0]) ?? " ";
2091
+ }));
2092
+ }
2093
+ const ae = Array.from(new Set(O)), de = (C = L(t.filter, h.value).selectedValues) != null && C.length ? L(t.filter, h.value).selectedValues : t.selectedValues || [], ue = t.keepSelection ? Array.from(/* @__PURE__ */ new Set([...ae, ...de])) : ae, me = new Set(O);
2094
+ t.options = ue.map((q) => ({
2095
+ label: String(q),
2096
+ value: q,
2097
+ available: t.keepSelection ? me.has(q) : new Set(ae).has(q)
2098
+ })), U(t);
2099
+ } catch (k) {
2100
+ if ((k == null ? void 0 : k.code) === "ERR_CANCELED" || (k == null ? void 0 : k.name) === "CanceledError")
2101
+ return;
2102
+ throw k;
2103
+ }
2104
+ break;
2105
+ case Ee.Bool: {
2106
+ t.options = [
2107
+ { label: "Yes", value: !0 },
2108
+ { label: "No", value: !1 }
2109
+ ], U(t);
2110
+ break;
2111
+ }
2112
+ case Ee.Timestamp:
2113
+ if (t.filter.option !== pe.DateTime && t.filter.option !== pe.TimeOfDay) {
2114
+ const k = t.filter.option;
2115
+ t.options = Pt({ dimensionOption: k, t: a }), t.filter.values = t.options.length ? t.options.map((O) => O.value) : ["NULL"];
2116
+ }
2117
+ U(t);
2118
+ break;
2119
+ case Ee.Numeric:
2120
+ break;
2121
+ }
2122
+ }
2123
+ async function fe(t = !1) {
2124
+ if (!h.value || !w.value.length) return;
2125
+ E == null || E.abort();
2126
+ const d = new AbortController();
2127
+ E = d;
2128
+ try {
2129
+ t || (D.value = !0), v.value = !0, await Promise.all(
2130
+ w.value.map((C) => Ve(C, d.signal))
2131
+ );
2132
+ } finally {
2133
+ E === d && (t || (D.value = !1), v.value = !1);
2134
+ }
2135
+ }
2136
+ function y(t, d) {
2137
+ var k;
2138
+ if ((k = t.selectedValues) == null ? void 0 : k.includes(d)) {
2139
+ let O = (t.selectedValues || []).filter((ae) => ae !== d && ae !== "(EMPTY)");
2140
+ t.selectedValues = O.length > 0 ? O : ["(EMPTY)"];
2141
+ } else
2142
+ t.selectedValues = [...(t.selectedValues || []).filter((O) => O !== "(EMPTY)"), d];
2143
+ x(t.filter, h.value, "selectedValues", t.selectedValues);
2144
+ }
2145
+ function V(t, d) {
2146
+ if (d === null)
2147
+ t.values = [];
2148
+ else {
2149
+ const k = Ke(d.startDate).startOf("day").utc().toISOString(), O = Ke(d.endDate).endOf("day").utc().toISOString();
2150
+ t.values = [k, O];
2151
+ }
2152
+ const C = w.value.find((k) => k.id === g(t, h.value));
2153
+ C && (C.keepSelection = d !== null, x(C.filter, h.value, "keepSelection", C.keepSelection));
2154
+ }
2155
+ function G(t) {
2156
+ const d = (t.selectedValues || []).filter((C) => C !== "(EMPTY)");
2157
+ return `${a("report.section.filter.selectAll")} (${d.length}/${t.options.length})`;
2158
+ }
2159
+ function W(t) {
2160
+ const d = t.options.length, C = a("report.section.filter.search"), k = a("report.common.results", { count: d });
2161
+ return `${C} (${k})`;
2162
+ }
2163
+ function N(t) {
2164
+ var ae, de, ue, me, q;
2165
+ const d = Fl(t.filter);
2166
+ if (t.type === Ee.Timestamp) {
2167
+ const o = ((ae = t.filter.values) == null ? void 0 : ae.length) === 2;
2168
+ if (t.filter.option === pe.DateTime)
2169
+ return { preview: o ? `${d} is between ${Rl({
2170
+ startDate: ((de = t.filter.values) == null ? void 0 : de[0]) || null,
2171
+ endDate: ((ue = t.filter.values) == null ? void 0 : ue[1]) || null,
2172
+ locale: r.value
2173
+ })}` : d, suffix: "" };
2174
+ if (t.filter.option === pe.TimeOfDay) {
2175
+ const j = (me = t.filter.values) != null && me[0] ? Ke(t.filter.values[0]) : null, I = (q = t.filter.values) != null && q[1] ? Ke(t.filter.values[1]) : null, oe = (ne) => ne && ne.isValid() ? { hour: ne.hour(), minute: ne.minute() } : null;
2176
+ return { preview: o ? `${d} is between ${Vl({
2177
+ startTime: oe(j),
2178
+ endTime: oe(I),
2179
+ locale: r.value
2180
+ })}` : d, suffix: "" };
2181
+ }
2182
+ if (t.filter.option !== pe.DateTime && t.filter.option !== pe.TimeOfDay) {
2183
+ const j = Pt({
2184
+ dimensionOption: t.filter.option,
2185
+ t: a
2186
+ }), I = new Map(j.map((K) => [String(K.value), K.label])), J = (t.selectedValues || []).filter((K) => K !== "(EMPTY)").map((K) => I.get(String(K)) ?? String(K)), ne = J.map((K) => K.length > 20 ? `${K.slice(0, 20)}…` : K).join(", ");
2187
+ return J.length ? {
2188
+ preview: `${d}: ${ne}`,
2189
+ suffix: `(${J.length} selected)`
2190
+ } : { preview: d, suffix: "" };
2191
+ }
2192
+ }
2193
+ const k = (t.selectedValues || []).filter((o) => o !== "(EMPTY)").map((o) => o === !0 ? a("report.common.yes") || "Yes" : o === !1 ? a("report.common.no") || "No" : String(o)), O = k.map((o) => o.length > 20 ? `${o.slice(0, 20)}…` : o).join(", ");
2194
+ return k.length ? {
2195
+ preview: `${d}: ${O}`,
2196
+ suffix: `(${k.length} selected)`
2197
+ } : { preview: O, suffix: `${d}` };
2198
+ }
2199
+ function M(t) {
2200
+ t.filter.values = [...t.selectedValues || []], x(t.filter, h.value, "selectedValues", t.selectedValues), be(t);
2201
+ }
2202
+ function ie(t) {
2203
+ t.showAdvanced = !t.showAdvanced, x(t.filter, h.value, "showAdvanced", t.showAdvanced);
2204
+ }
2205
+ function Ce(t) {
2206
+ t.keepSelection = !t.keepSelection, T(t.keepSelection), x(t.filter, h.value, "keepSelection", t.keepSelection), t.options = [], fe(!0);
2207
+ }
2208
+ function be(t) {
2209
+ const d = t.id, C = n.value[d];
2210
+ C == null || C.toggleMenu(!1);
2211
+ }
2212
+ function we(t, d) {
2213
+ d || (t.selectedValues = [...t.filter.values ?? []], x(t.filter, h.value, "selectedValues", t.selectedValues));
2214
+ }
2215
+ function ge(t, d) {
2216
+ return t ? t.length > d ? `${t.slice(0, d)}…` : t : "";
2217
+ }
2218
+ function ze(t, d) {
2219
+ var k, O, ae, de;
2220
+ if (d === null)
2221
+ t.values = [];
2222
+ else {
2223
+ const ue = Ke().set("hour", Number((k = d.start) == null ? void 0 : k.hour)).set("minute", Number((O = d.start) == null ? void 0 : O.minute)).toISOString(), me = Ke().set("hour", Number((ae = d.end) == null ? void 0 : ae.hour)).set("minute", Number((de = d.end) == null ? void 0 : de.minute)).toISOString();
2224
+ t.values = [ue, me];
2225
+ }
2226
+ const C = w.value.find((ue) => ue.id === g(t, h.value));
2227
+ C && (C.keepSelection = d !== null, x(C.filter, h.value, "keepSelection", C.keepSelection));
2228
+ }
2229
+ return (t, d) => {
2230
+ const C = B("FmCircularProgress"), k = B("FmTextField"), O = B("FmMenuItem"), ae = B("FmTooltip"), de = B("FmIcon"), ue = B("FmMenuDivider"), me = B("FmButton"), q = B("FmMenu");
2231
+ return $(), te("div", fa, [
2232
+ ($(!0), te(xe, null, rt(w.value, (o, j) => {
2233
+ var I, oe, J, ne, K, ye;
2234
+ return $(), te("div", {
2235
+ key: `${o.id}`
2236
+ }, [
2237
+ o.filter.option === s(pe).DateTime ? ($(), re(Ll, {
2238
+ key: 0,
2239
+ "model-value": { startDate: (I = o.filter.values) == null ? void 0 : I[0], endDate: (oe = o.filter.values) == null ? void 0 : oe[1] },
2240
+ class: "w-full",
2241
+ label: N(o).preview,
2242
+ removable: ((J = o.filter.values) == null ? void 0 : J.length) === 2,
2243
+ onUpdate: (Z) => V(o.filter, Z),
2244
+ onChipClosed: () => V(o.filter, null)
2245
+ }, null, 8, ["model-value", "label", "removable", "onUpdate", "onChipClosed"])) : o.filter.option === s(pe).TimeOfDay ? ($(), re(Tl, {
2246
+ key: 1,
2247
+ "model-value": { start: (ne = o.filter.values) == null ? void 0 : ne[0], end: (K = o.filter.values) == null ? void 0 : K[1] },
2248
+ class: "w-full",
2249
+ label: N(o).preview,
2250
+ removable: ((ye = o.filter.values) == null ? void 0 : ye.length) === 2,
2251
+ onUpdate: (Z) => ze(o.filter, Z),
2252
+ onChipClosed: () => ze(o.filter, null)
2253
+ }, null, 8, ["model-value", "label", "removable", "onUpdate", "onChipClosed"])) : ($(), re(q, {
2254
+ key: 2,
2255
+ "close-on-click": !1,
2256
+ shift: !0,
2257
+ ref_for: !0,
2258
+ ref: (Z) => z(o, Z),
2259
+ onMenuChanged: (Z) => we(o, Z)
2260
+ }, {
2261
+ "menu-button": se(() => [
2262
+ H("div", va, [
2263
+ P(Dl, {
2264
+ "left-icon": "filter_alt",
2265
+ "trailing-icon": "expand_more",
2266
+ label: N(o).preview,
2267
+ class: "w-full"
2268
+ }, {
2269
+ default: se(() => [
2270
+ ft(Le(N(o).suffix), 1)
2271
+ ]),
2272
+ _: 2
2273
+ }, 1032, ["label"])
2274
+ ])
2275
+ ]),
2276
+ "menu-wrapper": se(({ maxHeight: Z, width: ke }) => [
2277
+ H("div", {
2278
+ class: "flex flex-col bg-fm-color-neutral-white p-2 rounded-lg shadow-light-300",
2279
+ style: Ne({ maxHeight: `${Z}px`, width: ke })
2280
+ }, [
2281
+ v.value ? ($(), te("div", ga, [
2282
+ P(C)
2283
+ ])) : o.options.length > 0 && !s(D) ? ($(), te(xe, { key: 1 }, [
2284
+ H("div", ya, [
2285
+ P(k, {
2286
+ modelValue: o.search,
2287
+ "onUpdate:modelValue": [(Y) => o.search = Y, (Y) => s(x)(o.filter, h.value, "search", Y)],
2288
+ type: "text",
2289
+ "prepend-icon": "search",
2290
+ placeholder: W(o),
2291
+ class: "border px-2 pb-8 text-sm mb-1 rounded"
2292
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])
2293
+ ]),
2294
+ H("div", ba, [
2295
+ H("div", wa, [
2296
+ P(O, {
2297
+ label: G(o),
2298
+ "has-checkbox": !0,
2299
+ "model-value": le(o),
2300
+ indeterminate: !0,
2301
+ onClick: (Y) => Te(o)
2302
+ }, null, 8, ["label", "model-value", "onClick"]),
2303
+ ($(!0), te(xe, null, rt(ve.value[j], (Y) => ($(), te(xe, {
2304
+ key: Y.value
2305
+ }, [
2306
+ Y.label && Y.label.length > 110 ? ($(), re(ae, {
2307
+ key: 0,
2308
+ placement: "right",
2309
+ "hide-arrow": !0,
2310
+ "z-index": 2e3
2311
+ }, {
2312
+ content: se(() => [
2313
+ ft(Le(Y.label), 1)
2314
+ ]),
2315
+ default: se(() => [
2316
+ H("div", xa, [
2317
+ P(O, {
2318
+ label: ge(Y.label, 110),
2319
+ "has-checkbox": !0,
2320
+ "model-value": o.selectedValues.includes(Y.value),
2321
+ class: Ye([
2322
+ "flex-1 text-left",
2323
+ { "bg-gray-200": Y.available === !1 }
2324
+ ]),
2325
+ onClick: () => y(o, Y.value)
2326
+ }, null, 8, ["label", "model-value", "class", "onClick"])
2327
+ ])
2328
+ ]),
2329
+ _: 2
2330
+ }, 1024)) : ($(), re(O, {
2331
+ key: 1,
2332
+ label: Y.label,
2333
+ "has-checkbox": !0,
2334
+ "model-value": o.selectedValues.includes(Y.value),
2335
+ class: Ye(["flex-1 text-left", { "bg-gray-100": Y.available === !1 }]),
2336
+ onClick: () => y(o, Y.value)
2337
+ }, null, 8, ["label", "model-value", "class", "onClick"]))
2338
+ ], 64))), 128)),
2339
+ ve.value[j].length < o.options.length && !o.search ? ($(), re(O, {
2340
+ key: 0,
2341
+ class: "fm-typo-en-body-md-400 -ml-2",
2342
+ label: s(a)("report.section.filter.loadMore"),
2343
+ onClick: dt((Y) => Fe(o), ["stop"]),
2344
+ icon: "autorenew"
2345
+ }, null, 8, ["label", "onClick"])) : De("", !0)
2346
+ ])
2347
+ ]),
2348
+ H("div", {
2349
+ class: "px-12 py-2 flex items-center gap-2 cursor-pointer hover:bg-fm-color-neutral-50 transition-colors",
2350
+ onClick: (Y) => ie(o)
2351
+ }, [
2352
+ P(de, {
2353
+ name: o.showAdvanced ? "keyboard_arrow_up" : "keyboard_arrow_down",
2354
+ size: "md",
2355
+ class: ""
2356
+ }, null, 8, ["name"]),
2357
+ H("span", Ca, Le(s(a)("report.section.filter.advanced")), 1)
2358
+ ], 8, Sa),
2359
+ P(ue),
2360
+ o.showAdvanced ? ($(), te("div", ka, [
2361
+ H("div", _a, [
2362
+ H("div", Ta, [
2363
+ H("div", {
2364
+ class: "flex items-center gap-2 cursor-pointer",
2365
+ onClick: (Y) => Ce(o)
2366
+ }, [
2367
+ P(de, {
2368
+ name: o.keepSelection ? "check_box" : "check_box_outline_blank",
2369
+ size: "md",
2370
+ class: Ye(
2371
+ o.keepSelection ? "text-fm-color-primary" : "text-fm-color-neutral-gray-400"
2372
+ )
2373
+ }, null, 8, ["name", "class"]),
2374
+ H("span", La, Le(s(a)("report.section.filter.keepSelection")), 1)
2375
+ ], 8, Fa),
2376
+ P(ae, {
2377
+ placement: "top",
2378
+ "z-index": 2e3
2379
+ }, {
2380
+ content: se(() => [
2381
+ H("div", Da, Le(s(a)("report.section.filter.keepSelectionTooltip")), 1)
2382
+ ]),
2383
+ default: se(() => [
2384
+ P(de, {
2385
+ name: "info",
2386
+ size: "md",
2387
+ class: "text-fm-color-primary"
2388
+ })
2389
+ ]),
2390
+ _: 1
2391
+ })
2392
+ ])
2393
+ ])
2394
+ ])) : De("", !0),
2395
+ H("div", Ra, [
2396
+ P(me, {
2397
+ variant: "tertiary",
2398
+ label: s(a)("report.common.cancel"),
2399
+ onClick: dt((Y) => be(o), ["stop"])
2400
+ }, null, 8, ["label", "onClick"]),
2401
+ P(me, {
2402
+ color: "primary",
2403
+ onClick: dt((Y) => M(o), ["stop"]),
2404
+ label: s(a)("report.common.apply")
2405
+ }, null, 8, ["onClick", "label"])
2406
+ ])
2407
+ ], 64)) : s(D) ? De("", !0) : ($(), re(vt, { key: 2 }))
2408
+ ], 4)
2409
+ ]),
2410
+ _: 2
2411
+ }, 1032, ["onMenuChanged"]))
2412
+ ]);
2413
+ }), 128)),
2414
+ Be(t.$slots, "default")
2415
+ ]);
2416
+ };
2417
+ }
2418
+ });
2419
+ export {
2420
+ Ge as I,
2421
+ bt as L,
2422
+ Oe as R,
2423
+ Pa as _,
2424
+ qa as a,
2425
+ yt as b,
2426
+ Ha as c,
2427
+ Oa as d,
2428
+ Ba as e,
2429
+ pt as g,
2430
+ Wt as u
2431
+ };