@feedmepos/mf-report 5.29.2 → 5.30.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.
Files changed (33) hide show
  1. package/dist/{App-BZSznIVk.js → App-DLfT0eCF.js} +4 -4
  2. package/dist/{DateRangeSelect-DkvUo0cb.js → DateRangeSelect-B7WdpXF2.js} +1 -1
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-CpcW6e8f.js → Default.vue_vue_type_script_setup_true_lang-CL-aDO0k.js} +1 -1
  4. package/dist/DynamicWidget.vue_vue_type_script_setup_true_lang-CBQqry-z.js +5554 -0
  5. package/dist/GlobalFilterSelect.vue_vue_type_script_setup_true_lang-Dw7f7Ezy.js +2127 -0
  6. package/dist/{InsightView-BlBTxYPI.js → InsightView-C6C7JOZ6.js} +5 -5
  7. package/dist/{Integration-Cn0dO3bp.js → Integration-C-jTirOn.js} +3 -3
  8. package/dist/{Integrations-BbIEat5a.js → Integrations-GGOG7SoK.js} +2 -2
  9. package/dist/{Layout-CLOxLFnG.js → Layout-Bh9XKigp.js} +1 -1
  10. package/dist/{LocationSelect.vue_vue_type_script_setup_true_lang-BPBUsbFi.js → LocationSelect.vue_vue_type_script_setup_true_lang-rIw_bBJj.js} +2 -2
  11. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-BUbVlzC2.js → MenuTab.vue_vue_type_script_setup_true_lang-Cd0znwmF.js} +5 -5
  12. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang--ZqfguuE.js → NavigationTab.vue_vue_type_script_setup_true_lang-DfyDACQ_.js} +5 -5
  13. package/dist/{OverviewView-BnUQ_3U7.js → OverviewView-lMOe2TOC.js} +5 -5
  14. package/dist/{Report-BgvWo3nT.js → Report-D2Xn49J6.js} +3 -3
  15. package/dist/{ReportCanvasView-CPArvQyC.js → ReportCanvasView-CFD234l5.js} +419 -436
  16. package/dist/{ReportEditor-DMn20A0v.js → ReportEditor-CSCoj3H6.js} +7 -7
  17. package/dist/{ReportView-4ZwIkVpM.js → ReportView-CkWRa86t.js} +6 -6
  18. package/dist/{ReportViewRoute-CUXYY7p8.js → ReportViewRoute-BhtvTT7S.js} +2 -2
  19. package/dist/{Setting-rT9gqbLW.js → Setting-CoeUOLBq.js} +3 -3
  20. package/dist/{Template-BPWPq033.js → Template-CC5lUzPa.js} +3 -3
  21. package/dist/{TileEditor-D_Mdi1L7.js → TileEditor-DrbNsCcm.js} +6 -6
  22. package/dist/{TilePageStack.vue_vue_type_script_setup_true_lang-DPMdTPX0.js → TilePageStack.vue_vue_type_script_setup_true_lang-H9-q9z6X.js} +2 -2
  23. package/dist/{TransitionFade-BXD3t2SP.js → TransitionFade-BdCRphCd.js} +5 -5
  24. package/dist/{app-CECOMH9a.js → app-DQmVmRnR.js} +218 -206
  25. package/dist/app.js +1 -1
  26. package/dist/assets/{processTableData.worker-CUHdogDS.js → formatChartData.worker-t4_wCRf0.js} +62 -60
  27. package/dist/assets/{formatChartData.worker-M6h6qnIf.js → processTableData.worker-JSjN8c44.js} +62 -60
  28. package/dist/currency-D5C8SOmH.js +12 -0
  29. package/dist/{GlobalFilterSelect.vue_vue_type_script_setup_true_lang-DstuZr3i.js → index-DXT80H-V.js} +6897 -8853
  30. package/dist/{report-DSqxkGWu.js → report-Fll6MFsc.js} +1 -1
  31. package/dist/{useRestaurantPermission-Bj6HF5-f.js → useRestaurantPermission-D0zsFIys.js} +1 -1
  32. package/package.json +1 -1
  33. package/dist/DynamicWidget.vue_vue_type_script_setup_true_lang-D-v8cfNo.js +0 -5529
@@ -0,0 +1,2127 @@
1
+ import { ref as ye, computed as ve, defineComponent as yt, mergeModels as lt, useModel as ft, watch as Ie, resolveComponent as ee, createElementBlock as me, openBlock as H, createVNode as L, withCtx as re, createElementVNode as q, createCommentVNode as bt, Fragment as Le, renderList as ht, createBlock as Fe, unref as T, createTextVNode as nt, withDirectives as xl, toDisplayString as fe, vShow as Al, renderSlot as Ut, normalizeStyle as $l, normalizeClass as Gt, withModifiers as dt } from "vue";
2
+ import { c as jt, _ as qt, D as Gl, e as El } from "./DateRangeSelect-B7WdpXF2.js";
3
+ import { e as gt } from "./index-DXT80H-V.js";
4
+ import { d as I, u as Oe, c as je, a as Me, F as ke, Z as St, r as $e, g as Ll, h as Ml } from "./app-DQmVmRnR.js";
5
+ import { b as M, C as W, Q as tt, u as Pe, o as Ge, p as Ue, D as pe, a as Pl, x as Et, W as Lt, A as Bl, S as Mt } from "./report-Fll6MFsc.js";
6
+ import { defineStore as Qt, storeToRefs as se } from "pinia";
7
+ import { detectLocale as Ae } from "@feedmepos/mf-common";
8
+ import { u as Kt } from "./_plugin-vue_export-helper-C6QDExPN.js";
9
+ import { _ as zl } from "./SelectComponent.vue_vue_type_script_setup_true_lang-DW7Dk7iQ.js";
10
+ var Jt = /* @__PURE__ */ ((l) => (l.generating = "GENERATING", l.completed = "COMPLETED", l.failed = "FAILED", l.canceled = "CANCELLED", l))(Jt || {});
11
+ const Wl = "/assets/formatChartData.worker-t4_wCRf0.js", mt = /* @__PURE__ */ new Map();
12
+ function Pt(l) {
13
+ return new Worker(l, { type: "module" });
14
+ }
15
+ async function Ul(l) {
16
+ if (mt.has(l))
17
+ return Pt(mt.get(l));
18
+ let n = l;
19
+ if (location.hostname !== new URL(import.meta.url).hostname) {
20
+ const d = new URL(l.replace(/^\//, ""), import.meta.url).href, p = await fetch(d).then((g) => g.text()), f = new Blob([p], { type: "application/javascript" });
21
+ n = URL.createObjectURL(f);
22
+ }
23
+ const r = Pt(n);
24
+ return mt.set(l, n), r;
25
+ }
26
+ async function jl(l, n) {
27
+ const s = await Ul(l);
28
+ return s.postMessage(n), await new Promise((r) => {
29
+ s.onmessage = async (d) => {
30
+ const p = d.data;
31
+ s.terminate(), r(p);
32
+ };
33
+ });
34
+ }
35
+ const ql = "mf-reportreport-sort-store", Yt = Qt(ql, () => {
36
+ const l = ye([]);
37
+ function n(d, p) {
38
+ if (d == null) return;
39
+ const f = Array.isArray(p) ? p.filter((i) => i && i.key) : [], g = l.value.findIndex((i) => i.tileIndex === d), h = { tileIndex: d, sorts: f };
40
+ g !== -1 ? l.value.splice(g, 1, h) : l.value.push(h);
41
+ }
42
+ function s(d) {
43
+ var p;
44
+ return d == null ? [] : ((p = l.value.find((f) => f.tileIndex === d)) == null ? void 0 : p.sorts) ?? [];
45
+ }
46
+ function r(d) {
47
+ typeof d == "number" ? l.value = l.value.filter((p) => p.tileIndex !== d) : l.value = [];
48
+ }
49
+ return { tileSort: l, setTileSorts: n, getTileSorts: s, clearTileSorts: r };
50
+ }), Ht = "__EMPTY__";
51
+ function We(l = []) {
52
+ return Array.from(new Set(l));
53
+ }
54
+ function Ql(l) {
55
+ return [
56
+ l.schemaName,
57
+ l.name,
58
+ l.option ?? "",
59
+ l.dataFormula ?? "",
60
+ l.operator
61
+ ].join(":");
62
+ }
63
+ function Kl(l) {
64
+ const n = (s, r) => I().set("hour", s).set("minute", r).set("second", 0).set("millisecond", 0).toISOString();
65
+ return !l.startTime || !l.endTime ? [] : [
66
+ n(l.startTime.hour, l.startTime.minute),
67
+ n(l.endTime.hour, l.endTime.minute)
68
+ ];
69
+ }
70
+ function Jl(l, n) {
71
+ return {
72
+ schemaName: l.schemaName,
73
+ name: l.name,
74
+ operator: n.operator,
75
+ option: l.option ?? null,
76
+ values: We(n.values),
77
+ dataFormula: l.dataFormula,
78
+ isGlobalFilter: !0
79
+ };
80
+ }
81
+ function Yl(l, n) {
82
+ const s = Kl(n);
83
+ return s.length !== 2 ? null : {
84
+ schemaName: l.schemaName,
85
+ name: l.name,
86
+ operator: W.Between,
87
+ option: l.option ?? M.TimeOfDay,
88
+ values: s,
89
+ dataFormula: l.dataFormula,
90
+ isGlobalFilter: !0
91
+ };
92
+ }
93
+ function Hl(l) {
94
+ var d, p, f, g;
95
+ const n = (l.filters ?? []).map((h) => ({
96
+ ...h,
97
+ isGlobalFilter: !0
98
+ })), s = Array.from(new Set(l.values ?? []));
99
+ if (s.length === 1 && String(s[0]) === "EMPTY_GLOBAL_FILTER_VALUE") {
100
+ const h = Object.values(M).includes(
101
+ String(l.option ?? "")
102
+ ), i = l.option === M.TimeOfDay ? ["1000-01-01T23:59:59.999Z", "1000-01-01T00:00:00.000Z"] : [h ? "-1" : Ht];
103
+ return [
104
+ ...n,
105
+ {
106
+ schemaName: l.schemaName,
107
+ name: l.name,
108
+ operator: W.Equal,
109
+ option: l.option ?? null,
110
+ values: i,
111
+ dataFormula: l.dataFormula,
112
+ isGlobalFilter: !0
113
+ }
114
+ ];
115
+ }
116
+ if ((((d = l.customTimeRanges) == null ? void 0 : d.length) ?? 0) > 0) {
117
+ const h = new Set(s.map((i) => String(i)));
118
+ return [
119
+ ...n,
120
+ ...((p = l.customTimeRanges) == null ? void 0 : p.filter((i) => {
121
+ const F = String(i.name ?? "");
122
+ return h.has(F);
123
+ }).map((i) => Yl(l, i)).filter((i) => !!i)) ?? []
124
+ ];
125
+ }
126
+ if ((((f = l.customOptions) == null ? void 0 : f.length) ?? 0) > 0) {
127
+ const h = new Set(s.map((i) => String(i)));
128
+ return [
129
+ ...n,
130
+ ...((g = l.customOptions) == null ? void 0 : g.filter((i) => {
131
+ const F = String(i.label ?? "");
132
+ return h.has(F);
133
+ }).map((i) => Jl(l, i)).filter((i) => Array.isArray(i.values) && i.values.length > 0)) ?? []
134
+ ];
135
+ }
136
+ return s.length === 0 ? n : [
137
+ ...n,
138
+ {
139
+ schemaName: l.schemaName,
140
+ name: l.name,
141
+ operator: W.Equal,
142
+ option: l.option ?? null,
143
+ values: s,
144
+ dataFormula: l.dataFormula,
145
+ isGlobalFilter: !0
146
+ }
147
+ ];
148
+ }
149
+ function Bt({
150
+ originalFilters: l,
151
+ globalFilters: n,
152
+ schemaNames: s
153
+ }) {
154
+ const r = /* @__PURE__ */ new Map(), d = [], p = new Set((s ?? []).map((u) => String(u))), f = (u) => p.has(u.schemaName ?? ""), g = n.filter(f);
155
+ function h(u) {
156
+ const m = Object.values(M).includes(
157
+ String(u.option ?? "")
158
+ );
159
+ return u.option === M.TimeOfDay ? ["1000-01-01T23:59:59.999Z", "1000-01-01T00:00:00.000Z"] : [m ? "-1" : Ht];
160
+ }
161
+ function i(u, m) {
162
+ const v = typeof u == "number" ? u : Number(u), N = typeof m == "number" ? m : Number(m);
163
+ return Number.isFinite(v) && Number.isFinite(N) ? v - N : typeof u == "string" && typeof m == "string" ? u.localeCompare(m) : null;
164
+ }
165
+ function F(u, m) {
166
+ if (u.length === 0 || m.length === 0) return null;
167
+ const v = i(u[0], m[0]);
168
+ return v == null ? null : [v >= 0 ? u[0] : m[0]];
169
+ }
170
+ function P(u, m) {
171
+ if (u.length === 0 || m.length === 0) return null;
172
+ const v = i(u[0], m[0]);
173
+ return v == null ? null : [v <= 0 ? u[0] : m[0]];
174
+ }
175
+ function ne(u, m) {
176
+ if (u.length < 2 || m.length < 2) return null;
177
+ const v = i(u[0], m[0]), N = i(u[1], m[1]);
178
+ if (v == null || N == null) return null;
179
+ const k = v >= 0 ? u[0] : m[0], O = N <= 0 ? u[1] : m[1];
180
+ return i(k, O) == null ? null : [k, O];
181
+ }
182
+ function _(u, m) {
183
+ const v = We(u.values), N = We(m.values);
184
+ switch (m.operator) {
185
+ case W.Equal: {
186
+ const k = new Set(N), O = v.filter((B) => k.has(B));
187
+ return O.length ? O : h(u);
188
+ }
189
+ case W.NotEqual:
190
+ case W.NotLike:
191
+ return We([
192
+ ...v,
193
+ ...N
194
+ ]);
195
+ case W.GreaterThan:
196
+ case W.GreaterThanOrEqual:
197
+ return F(v, N);
198
+ case W.LessThan:
199
+ case W.LessThanOrEqual:
200
+ return P(v, N);
201
+ case W.Between:
202
+ return ne(v, N);
203
+ default:
204
+ return null;
205
+ }
206
+ }
207
+ const D = (u) => {
208
+ if (!u || !f(u) || !Array.isArray(u.values) || u.values.length === 0)
209
+ return;
210
+ const m = {
211
+ ...u,
212
+ values: We(u.values)
213
+ };
214
+ if (m.option === M.TimeOfDay && m.operator === W.Between) {
215
+ d.push(m);
216
+ return;
217
+ }
218
+ const N = Ql(m), k = r.get(N);
219
+ if (!k) {
220
+ r.set(N, m);
221
+ return;
222
+ }
223
+ const O = _(k, m);
224
+ if (O == null) {
225
+ d.push(m);
226
+ return;
227
+ }
228
+ k.values = O, r.set(N, k);
229
+ };
230
+ return l.forEach(D), g.forEach(D), [...Array.from(r.values()), ...d];
231
+ }
232
+ function qe(l, n, s) {
233
+ var p;
234
+ const r = JSON.parse(JSON.stringify(l)), d = n.filter((f) => {
235
+ var g;
236
+ return (g = f.tileIds) == null ? void 0 : g.includes(s);
237
+ }).flatMap((f) => Hl(f));
238
+ return {
239
+ ...r,
240
+ config: {
241
+ ...r.config,
242
+ filters: Bt({
243
+ originalFilters: r.config.filters ?? [],
244
+ globalFilters: d ?? [],
245
+ schemaNames: r.config.schemaNames
246
+ }),
247
+ joinDatasources: ((p = r.config.joinDatasources) == null ? void 0 : p.map((f, g) => {
248
+ var h;
249
+ return {
250
+ ...f,
251
+ filters: Bt({
252
+ originalFilters: f.filters ?? [],
253
+ globalFilters: d ?? [],
254
+ schemaNames: (h = r.config.joinDatasources) == null ? void 0 : h[g].schemaNames
255
+ })
256
+ };
257
+ })) ?? []
258
+ }
259
+ };
260
+ }
261
+ function Zl(l) {
262
+ return (l == null ? void 0 : l.queryDatasource) === tt.BigQuery ? tt.BigQuery : tt.Postgres;
263
+ }
264
+ const Xl = [
265
+ "schemaNames",
266
+ "schemas",
267
+ "dimensions",
268
+ "breakdownDimension",
269
+ "sparklineDimension",
270
+ "sparklineType",
271
+ "sparklinePercentOfTotal",
272
+ "drillDimension",
273
+ "metrics",
274
+ "filters",
275
+ "sorts",
276
+ "limit",
277
+ "showGrandTotal",
278
+ "rollupPosition",
279
+ "grandTotalLabel",
280
+ "showSearchBar",
281
+ "isTransposed",
282
+ "isDrillable",
283
+ "rollup",
284
+ "columnIds",
285
+ "rowIds",
286
+ "joinDatasources",
287
+ "isComparable",
288
+ "isCumulative",
289
+ "isBlend",
290
+ "periodType"
291
+ ];
292
+ function Zt(l) {
293
+ const n = { ...l.config };
294
+ for (const s of Xl)
295
+ delete n[s];
296
+ return n;
297
+ }
298
+ function vt(l) {
299
+ return (l == null ? void 0 : l.queryVersion) === "v2";
300
+ }
301
+ function Qe({
302
+ report: l,
303
+ pageSubject: n,
304
+ dateRange: s,
305
+ compareDateRange: r,
306
+ timezone: d
307
+ }) {
308
+ const { canReadReportDateRange: p, canReadPageDateRange: f } = Ml(), g = (i) => n ? f(n, i, d) : l ? p(l, i, d) : !0, h = !!(r != null && r.startDate && (r != null && r.endDate));
309
+ return g(s) && (!h || g(r));
310
+ }
311
+ function Ke(l) {
312
+ if (l === "overview")
313
+ return Ll.report_accessOverview;
314
+ }
315
+ function Ft({
316
+ selectedNavigationTab: l,
317
+ isEditorRoute: n,
318
+ overviewReport: s,
319
+ editingReport: r,
320
+ currentReport: d
321
+ }) {
322
+ return l === "overview" && s ? s : n ? r ?? d : d;
323
+ }
324
+ async function Xt(l, n) {
325
+ for (let s = 0; s < l.length; s++)
326
+ try {
327
+ return await l[s]();
328
+ } catch (r) {
329
+ if (r.message === "Unauthorized" || s === l.length - 1) throw r;
330
+ await new Promise((d) => setTimeout(d, n));
331
+ }
332
+ throw new Error("No callback");
333
+ }
334
+ const en = async ({
335
+ widget: l,
336
+ signal: n,
337
+ tileId: s,
338
+ scopedLocationIds: r,
339
+ scopedTimeRange: d,
340
+ scopedDateRange: p,
341
+ scopedGlobalFilters: f,
342
+ page: g,
343
+ pageRead: h,
344
+ search: i
345
+ }) => {
346
+ var ie, he, ue, ge;
347
+ const { businessId: F } = se(Oe()), { currentReport: P, editingReport: ne, overviewReport: _ } = Pe(), { selectedNavigationTab: D, isEditorRoute: u } = je(), m = Ft({
348
+ selectedNavigationTab: D,
349
+ isEditorRoute: u,
350
+ overviewReport: _,
351
+ editingReport: ne,
352
+ currentReport: P
353
+ }), v = Ke(D), {
354
+ selectedRestaurantIds: N,
355
+ selectedWarehouseIds: k,
356
+ selectedLocationIds: O,
357
+ dateRange: B,
358
+ compareDateRange: Q,
359
+ timeRange: U,
360
+ timezone: te,
361
+ restaurants: X,
362
+ warehouses: le
363
+ } = Me(), { globalFilters: w } = Ge();
364
+ if (O.length === 0)
365
+ return null;
366
+ const x = p ?? B, J = d ?? U, z = f ?? w;
367
+ if (!Qe({
368
+ report: m,
369
+ pageSubject: v,
370
+ dateRange: x,
371
+ compareDateRange: Q,
372
+ timezone: te
373
+ }))
374
+ return null;
375
+ const Y = (r == null ? void 0 : r.filter((we) => X.some((ce) => ce.id === we))) ?? N, ae = (r == null ? void 0 : r.filter((we) => le.some((ce) => ce.id === we))) ?? k, K = qe(l, z, s ?? ""), R = {
376
+ fetchType: ke.Post,
377
+ url: h ? `/${F.value}/v2/query/page` : `/${F.value}/v2/query`,
378
+ data: {
379
+ ...g ? { page: g } : {},
380
+ ...h ?? {},
381
+ ...i ? { search: i } : {},
382
+ widget: K,
383
+ dateRange: [x.startDate, x.endDate],
384
+ compareDateRange: Q.startDate && Q.endDate ? [Q.startDate, Q.endDate] : void 0,
385
+ timeRange: [
386
+ I().tz(te).hour(Number((ie = J.start) == null ? void 0 : ie.hour)).minute(Number((he = J.start) == null ? void 0 : he.minute)).toISOString(),
387
+ I().tz(te).hour(Number((ue = J.end) == null ? void 0 : ue.hour)).minute(Number((ge = J.end) == null ? void 0 : ge.minute)).endOf("minutes").toISOString()
388
+ ],
389
+ businessIds: F.value ? [F.value] : [],
390
+ restaurantIds: Y,
391
+ warehouseIds: ae,
392
+ timezone: te,
393
+ skipStringSpaceGrouping: !!(m != null && m.batch) || vt(m),
394
+ reportId: m == null ? void 0 : m.id,
395
+ queryDatasource: Zl(m)
396
+ },
397
+ requestConfig: {
398
+ timeout: 1e3 * 60 * 5,
399
+ signal: n
400
+ },
401
+ // A query is a read: a 502/503/504 from the gateway is safe to re-send.
402
+ retry: 2
403
+ };
404
+ return await Xt([() => $e.fetch(R)], 2e3);
405
+ }, Mn = async ({
406
+ widget: l,
407
+ signal: n,
408
+ tileId: s,
409
+ scopedDateRange: r,
410
+ scopedCompareDateRange: d
411
+ }) => {
412
+ var le, w, x, J;
413
+ const { businessId: p } = se(Oe()), { currentReport: f, editingReport: g, overviewReport: h } = Pe(), { selectedNavigationTab: i, isEditorRoute: F } = je(), P = Ft({
414
+ selectedNavigationTab: i,
415
+ isEditorRoute: F,
416
+ overviewReport: h,
417
+ editingReport: g,
418
+ currentReport: f
419
+ }), ne = Ke(i), { restaurants: _, warehouses: D, dateRange: u, compareDateRange: m, timeRange: v, timezone: N } = Me(), { globalFilters: k } = Ge();
420
+ if (_.length === 0 && D.length === 0)
421
+ return { totalBytesProcessed: 0 };
422
+ const O = r ?? u, B = d ?? m;
423
+ if (!Qe({
424
+ report: P,
425
+ pageSubject: ne,
426
+ dateRange: O,
427
+ compareDateRange: B,
428
+ timezone: N
429
+ }))
430
+ return { totalBytesProcessed: 0 };
431
+ const Q = _.map((z) => z.id), U = D.map((z) => z.id), te = qe(l, k, s ?? ""), X = {
432
+ fetchType: ke.Post,
433
+ url: `/${p.value}/v2/query/dry-run`,
434
+ data: {
435
+ widget: te,
436
+ dateRange: [O.startDate, O.endDate],
437
+ compareDateRange: B.startDate && B.endDate ? [B.startDate, B.endDate] : void 0,
438
+ timeRange: [
439
+ I().tz(N).hour(Number((le = v.start) == null ? void 0 : le.hour)).minute(Number((w = v.start) == null ? void 0 : w.minute)).toISOString(),
440
+ I().tz(N).hour(Number((x = v.end) == null ? void 0 : x.hour)).minute(Number((J = v.end) == null ? void 0 : J.minute)).endOf("minutes").toISOString()
441
+ ],
442
+ businessIds: p.value ? [p.value] : [],
443
+ restaurantIds: Q,
444
+ warehouseIds: U,
445
+ timezone: N,
446
+ skipStringSpaceGrouping: !1,
447
+ reportId: P == null ? void 0 : P.id,
448
+ queryDatasource: tt.BigQuery
449
+ },
450
+ requestConfig: {
451
+ timeout: 1e3 * 60,
452
+ signal: n
453
+ }
454
+ };
455
+ return $e.fetch(X);
456
+ }, tn = async ({
457
+ widget: l,
458
+ signal: n,
459
+ tileId: s,
460
+ scopedLocationIds: r,
461
+ scopedTimeRange: d,
462
+ scopedDateRange: p,
463
+ scopedGlobalFilters: f,
464
+ page: g,
465
+ pageRead: h,
466
+ search: i
467
+ }) => {
468
+ var ue, ge, we, ce;
469
+ const { businessId: F, country: P } = se(Oe()), { currentReport: ne, editingReport: _, overviewReport: D } = Pe(), { selectedNavigationTab: u, isEditorRoute: m } = je(), v = Ft({
470
+ selectedNavigationTab: u,
471
+ isEditorRoute: m,
472
+ overviewReport: D,
473
+ editingReport: _,
474
+ currentReport: ne
475
+ }), N = Ke(u);
476
+ if (vt(v))
477
+ return en({
478
+ widget: l,
479
+ signal: n,
480
+ tileId: s,
481
+ scopedLocationIds: r,
482
+ scopedTimeRange: d,
483
+ scopedDateRange: p,
484
+ scopedGlobalFilters: f,
485
+ page: g,
486
+ pageRead: h,
487
+ search: i
488
+ });
489
+ const {
490
+ selectedRestaurantIds: k,
491
+ selectedWarehouseIds: O,
492
+ selectedLocationIds: B,
493
+ dateRange: Q,
494
+ compareDateRange: U,
495
+ timeRange: te,
496
+ timezone: X,
497
+ restaurants: le,
498
+ warehouses: w
499
+ } = Me(), { globalFilters: x } = Ge();
500
+ if (B.length === 0)
501
+ return null;
502
+ const J = p ?? Q, z = d ?? te, Y = f ?? x;
503
+ if (!Qe({
504
+ report: v,
505
+ pageSubject: N,
506
+ dateRange: J,
507
+ compareDateRange: U,
508
+ timezone: X
509
+ }))
510
+ return null;
511
+ const ae = (r == null ? void 0 : r.filter((Z) => le.some((De) => De.id === Z))) ?? k, K = (r == null ? void 0 : r.filter((Z) => w.some((De) => De.id === Z))) ?? O, R = qe(l, Y, s ?? ""), be = {
512
+ fetchType: ke.Post,
513
+ url: `/${F.value}/postgres-query`,
514
+ data: gt.getQueryRequests({
515
+ widget: R,
516
+ dateRange: [J.startDate, J.endDate],
517
+ compareDateRange: U.startDate && U.endDate ? [U.startDate, U.endDate] : void 0,
518
+ timeRange: [
519
+ I().tz(X).hour(Number((ue = z.start) == null ? void 0 : ue.hour)).minute(Number((ge = z.start) == null ? void 0 : ge.minute)).toISOString(),
520
+ I().tz(X).hour(Number((we = z.end) == null ? void 0 : we.hour)).minute(Number((ce = z.end) == null ? void 0 : ce.minute)).endOf("minutes").toISOString()
521
+ ],
522
+ businessIds: F.value ? [F.value] : [],
523
+ restaurantIds: ae,
524
+ warehouseIds: K,
525
+ timezone: X
526
+ }).map((Z, De) => {
527
+ const Te = De === 0 ? 3e3 : 12e3;
528
+ return {
529
+ ...Z,
530
+ limit: ae.length > 50 ? l.config.limit || Te : l.config.limit,
531
+ skipStringSpaceGrouping: !!(v != null && v.batch) || vt(v),
532
+ reportId: v == null ? void 0 : v.id
533
+ };
534
+ }),
535
+ requestConfig: {
536
+ timeout: 1e3 * 60 * 5,
537
+ signal: n
538
+ }
539
+ }, ie = [() => $e.fetch(be)];
540
+ k.length < 50 && ie.push(() => $e.fetch(be)), ie.push(() => $e.fetch(be));
541
+ const he = await Xt(ie, 2e3);
542
+ return (await jl(Wl, {
543
+ responses: he,
544
+ widget: JSON.parse(JSON.stringify(l)),
545
+ country: P.value,
546
+ timezone: X
547
+ })).data;
548
+ }, Pn = async ({
549
+ fileType: l,
550
+ index: n,
551
+ orientationTypes: s,
552
+ isCombinedLocationLayout: r,
553
+ locationIds: d,
554
+ timeRange: p,
555
+ dateRange: f,
556
+ globalFilters: g
557
+ }) => {
558
+ const { businessId: h } = se(Oe()), i = Me(), { compareDateRange: F } = se(i), { restaurants: P, warehouses: ne, timezone: _ } = i, { globalFilters: D } = Ge(), { currentReport: u, overviewReport: m } = Pe(), { selectedNavigationTab: v } = je(), { getTileSorts: N } = Yt();
559
+ let k = u == null ? void 0 : u.id, O = Ue(u == null ? void 0 : u.tiles);
560
+ v === "overview" && m && (k = m == null ? void 0 : m.id, O = Ue(m == null ? void 0 : m.tiles));
561
+ const B = v === "overview" && m ? m : u, Q = Ke(v);
562
+ if (!Qe({
563
+ report: B,
564
+ pageSubject: Q,
565
+ dateRange: f,
566
+ compareDateRange: F.value,
567
+ timezone: _
568
+ }))
569
+ return;
570
+ const U = g ?? D, te = O.filter((Y, ae) => typeof n == "number" ? ae === n : !0).map((Y) => qe(Y.widget, U, Y.id)), X = {
571
+ fetchType: ke.Post,
572
+ url: `/${h.value}/file?lang=${Ae()}`,
573
+ data: {
574
+ configs: [
575
+ ...te.map((Y, ae) => {
576
+ var K, R, be, ie;
577
+ return {
578
+ requests: gt.getQueryRequests({
579
+ widget: Y,
580
+ dateRange: [f.startDate, f.endDate],
581
+ compareDateRange: F.value.startDate && F.value.endDate ? [F.value.startDate, F.value.endDate] : void 0,
582
+ timeRange: [
583
+ I().tz(_).set("hour", Number((K = p.start) == null ? void 0 : K.hour)).set("minute", Number((R = p.start) == null ? void 0 : R.minute)).toISOString(),
584
+ I().tz(_).set("hour", Number((be = p.end) == null ? void 0 : be.hour)).set("minute", Number((ie = p.end) == null ? void 0 : ie.minute)).toISOString()
585
+ ],
586
+ businessIds: h ? [h.value] : [],
587
+ restaurantIds: d.filter(
588
+ (he) => P.find((ue) => ue.id === he)
589
+ ),
590
+ warehouseIds: d.filter(
591
+ (he) => ne.find((ue) => ue.id === he)
592
+ ),
593
+ timezone: _
594
+ }),
595
+ index: n || ae,
596
+ drillDimension: null,
597
+ ...Zt(Y),
598
+ globalSorts: N(n ?? ae)
599
+ };
600
+ })
601
+ ],
602
+ reportId: k,
603
+ type: l,
604
+ orientationTypes: s,
605
+ isCombinedLocationLayout: r
606
+ },
607
+ requestConfig: {
608
+ responseType: "arraybuffer",
609
+ timeout: 1e3 * 60 * 60 * 24
610
+ }
611
+ }, { headers: le, data: w } = await St.rawFetch(X), x = le["content-disposition"].split("filename=")[1].replaceAll('"', ""), J = window.URL.createObjectURL(new Blob([new Uint8Array(w).buffer])), z = document.createElement("a");
612
+ z.href = J, z.setAttribute("download", decodeURIComponent(x)), document.body.appendChild(z), z.click(), z.remove();
613
+ }, Bn = async ({
614
+ emails: l,
615
+ types: n,
616
+ dateRange: s,
617
+ timeRange: r,
618
+ locationIds: d,
619
+ orientationTypes: p,
620
+ isCombinedLocationLayout: f,
621
+ globalFilters: g
622
+ }) => {
623
+ const { businessId: h } = se(Oe()), { currentReport: i, overviewReport: F } = Pe(), { selectedNavigationTab: P } = je(), ne = Me(), { compareDateRange: _ } = se(ne), { restaurants: D, warehouses: u, timezone: m } = ne, { globalFilters: v } = Ge(), { getTileSorts: N } = Yt();
624
+ if (l.length === 0) {
625
+ console.error("No email addresses provided.");
626
+ return;
627
+ }
628
+ let k = (i == null ? void 0 : i.id) || "", O = (i == null ? void 0 : i.name) || "", B = Ue(i == null ? void 0 : i.tiles);
629
+ P === "overview" && F && (k = F == null ? void 0 : F.id, O = F.name, B = Ue(F == null ? void 0 : F.tiles));
630
+ const Q = P === "overview" && F ? F : i, U = Ke(P);
631
+ if (!Qe({
632
+ report: Q,
633
+ pageSubject: U,
634
+ dateRange: s,
635
+ compareDateRange: _.value,
636
+ timezone: m
637
+ }))
638
+ return;
639
+ const te = g ?? v, X = B.map((w) => qe(w.widget, te, w.id)), le = {
640
+ businessId: h.value,
641
+ status: Jt.generating,
642
+ dateRange: {
643
+ start: s.startDate,
644
+ end: s.endDate
645
+ },
646
+ reportName: O,
647
+ emails: l,
648
+ configs: X.map((w, x) => {
649
+ var J, z, Y, ae;
650
+ return {
651
+ requests: gt.getQueryRequests({
652
+ widget: w,
653
+ dateRange: [s.startDate, s.endDate],
654
+ compareDateRange: _.value.startDate && _.value.endDate ? [_.value.startDate, _.value.endDate] : void 0,
655
+ timeRange: [
656
+ I().tz(m).hour(Number((J = r.start) == null ? void 0 : J.hour)).minute(Number((z = r.start) == null ? void 0 : z.minute)).toISOString(),
657
+ I().tz(m).hour(Number((Y = r.end) == null ? void 0 : Y.hour)).minute(Number((ae = r.end) == null ? void 0 : ae.minute)).endOf("minutes").toISOString()
658
+ ],
659
+ businessIds: h ? [h.value] : [],
660
+ restaurantIds: d.filter(
661
+ (K) => D.find((R) => R.id === K)
662
+ ),
663
+ warehouseIds: d.filter(
664
+ (K) => u.find((R) => R.id === K)
665
+ ),
666
+ timezone: m
667
+ }),
668
+ index: x,
669
+ drillDimension: null,
670
+ ...Zt(w),
671
+ globalSorts: N(x)
672
+ };
673
+ }),
674
+ reportId: k,
675
+ type: n,
676
+ orientationTypes: p,
677
+ isCombinedLocationLayout: f
678
+ };
679
+ await St.fetch({
680
+ fetchType: ke.Post,
681
+ url: `/${h.value}/reports/email?lang=${Ae()}`,
682
+ data: le,
683
+ requestConfig: { timeout: 1e3 * 60 * 3 }
684
+ });
685
+ }, zn = async (l) => {
686
+ const { businessId: n } = se(Oe());
687
+ await St.fetch({
688
+ fetchType: ke.Post,
689
+ url: `/${n.value}/reports/resend-email?lang=${Ae()}`,
690
+ data: { jobId: l },
691
+ requestConfig: { timeout: 1e3 * 60 * 3 }
692
+ });
693
+ }, Wn = async () => {
694
+ const { businessId: l } = se(Oe());
695
+ return await $e.fetch({
696
+ fetchType: ke.Get,
697
+ url: `/${l.value}/reports/email-recipients`
698
+ });
699
+ }, Un = async (l) => {
700
+ const { businessId: n } = se(Oe());
701
+ await $e.fetch({
702
+ fetchType: ke.Post,
703
+ url: `/${n.value}/reports/email-recipient/delete`,
704
+ data: { email: l }
705
+ });
706
+ }, ln = "mf-reportwidget-result-store", nn = Qt(ln, () => {
707
+ const l = ye({}), n = ye(0), s = ve(() => n.value === 0);
708
+ function r() {
709
+ n.value += 1;
710
+ }
711
+ function d() {
712
+ n.value = Math.max(0, n.value - 1);
713
+ }
714
+ function p(h, i) {
715
+ if (h)
716
+ if (i === null)
717
+ l.value[h] = [];
718
+ else {
719
+ const F = l.value[h] ?? [];
720
+ l.value[h] = Array.from(/* @__PURE__ */ new Set([...F, ...i]));
721
+ }
722
+ }
723
+ function f(h) {
724
+ return h ? l.value[h] ?? [] : [];
725
+ }
726
+ function g() {
727
+ l.value = {};
728
+ }
729
+ return {
730
+ widgetResults: l,
731
+ widgetResultLoadingCount: n,
732
+ isAllWidgetResultLoaded: s,
733
+ startWidgetResultLoading: r,
734
+ finishWidgetResultLoading: d,
735
+ setWidgetResult: p,
736
+ getWidgetResult: f,
737
+ clearAllWidgetResults: g
738
+ };
739
+ }), zt = (l, n = "en") => I().set("hour", l.hour).set("minute", l.minute).locale(n).format("h:mm A"), an = (l, n) => {
740
+ const s = I().set("hour", l.hour).set("minute", l.minute);
741
+ return I().set("hour", n.hour).set("minute", n.minute) < s ? "+1" : "";
742
+ };
743
+ function Wt(l, n) {
744
+ return l.isSystem ? n("reportV5.reportHour.fullDay") : l.name;
745
+ }
746
+ const sn = { class: "px-24 py-16 rounded-lg shadow-light-300" }, rn = { class: "text-fm-color-typo-primary" }, on = { class: "text-fm-color-typo-secondary" }, un = { class: "fm-typo-en-body-lg-600 mb-8" }, cn = { class: "flex items-center justify-center w-full" }, dn = { class: "fm-typo-en-body-lg-600 mb-8" }, mn = { class: "flex items-center justify-center" }, pn = { class: "flex flex-row mb-4 px-4 gap-2" }, fn = /* @__PURE__ */ yt({
747
+ __name: "TimeRangeSelect",
748
+ props: /* @__PURE__ */ lt({
749
+ defaultDateRange: {
750
+ type: Array,
751
+ default: () => [
752
+ {
753
+ name: "Full day",
754
+ isDefault: !0,
755
+ isSystem: !0,
756
+ startTime: { hour: 0, minute: 0 },
757
+ endTime: { hour: 23, minute: 59 }
758
+ }
759
+ ]
760
+ },
761
+ label: {
762
+ type: String,
763
+ required: !1,
764
+ default: null
765
+ },
766
+ removable: {
767
+ type: Boolean,
768
+ required: !1,
769
+ default: !1
770
+ }
771
+ }, {
772
+ timeRange: {
773
+ type: Object,
774
+ default: () => ({
775
+ start: { hour: 0, minute: 0 },
776
+ end: { hour: 23, minute: 59 }
777
+ })
778
+ },
779
+ timeRangeModifiers: {},
780
+ selectTimeDefault: {
781
+ type: Number,
782
+ default: 1
783
+ },
784
+ selectTimeDefaultModifiers: {}
785
+ }),
786
+ emits: /* @__PURE__ */ lt(["update", "chip-closed"], ["update:timeRange", "update:selectTimeDefault"]),
787
+ setup(l, { emit: n }) {
788
+ const { t: s, locale: r } = Kt(), d = ft(l, "timeRange"), p = n, f = ft(l, "selectTimeDefault");
789
+ function g(D) {
790
+ D && (d.value = D, p("update", d.value)), P.value = !1;
791
+ }
792
+ function h(D) {
793
+ const u = D.split(":"), m = I().set("hour", Number(u[0])).set("minute", Number(u[1]));
794
+ return {
795
+ hours: Number(m.format("h")),
796
+ minutes: Number(m.format("m")),
797
+ period: m.format("A")
798
+ };
799
+ }
800
+ const i = ye(JSON.parse(JSON.stringify(d.value)));
801
+ function F(D, u) {
802
+ i.value.start = JSON.parse(JSON.stringify(D)), i.value.end = JSON.parse(JSON.stringify(u));
803
+ }
804
+ Ie(
805
+ () => [d.value, l.defaultDateRange],
806
+ () => {
807
+ if (d.value) {
808
+ const D = l.defaultDateRange.findIndex(
809
+ (u) => {
810
+ var m, v, N, k;
811
+ return u.startTime.hour === ((m = d.value.start) == null ? void 0 : m.hour) && u.startTime.minute === ((v = d.value.start) == null ? void 0 : v.minute) && u.endTime.hour === ((N = d.value.end) == null ? void 0 : N.hour) && u.endTime.minute === ((k = d.value.end) == null ? void 0 : k.minute);
812
+ }
813
+ ) + 1;
814
+ D !== 0 ? f.value = D : f.value = l.defaultDateRange.length + 1;
815
+ }
816
+ },
817
+ { deep: !0, immediate: !0 }
818
+ );
819
+ const P = ye(!1);
820
+ function ne(D) {
821
+ p("chip-closed", D);
822
+ }
823
+ const _ = ve(() => l.label ? l.label : jt({
824
+ startTime: d.value.start,
825
+ endTime: d.value.end,
826
+ locale: r.value
827
+ }));
828
+ return (D, u) => {
829
+ const m = ee("FmChip"), v = ee("FmRadio"), N = ee("FmMenuDivider"), k = ee("FmRadioGroup"), O = ee("FmTimeInput"), B = ee("FmButton"), Q = ee("FmPopover");
830
+ return H(), me("div", null, [
831
+ L(Q, {
832
+ "show-popover": P.value,
833
+ placement: "bottom",
834
+ onPopoverChanged: u[6] || (u[6] = (U) => P.value = U)
835
+ }, {
836
+ "popover-button": re(() => [
837
+ L(qt, {
838
+ "left-icon": l.label ? "filter_alt" : "schedule",
839
+ label: _.value,
840
+ removable: l.removable,
841
+ onChipClosed: u[0] || (u[0] = (U) => ne(!0))
842
+ }, null, 8, ["left-icon", "label", "removable"])
843
+ ]),
844
+ default: re(() => {
845
+ var U, te, X, le;
846
+ return [
847
+ q("div", sn, [
848
+ L(k, {
849
+ modelValue: f.value,
850
+ "onUpdate:modelValue": u[1] || (u[1] = (w) => f.value = w)
851
+ }, {
852
+ default: re(() => [
853
+ (H(!0), me(Le, null, ht(l.defaultDateRange, (w, x) => (H(), Fe(v, {
854
+ key: `range_${x}`,
855
+ value: x + 1,
856
+ label: T(Wt)(w, T(s)),
857
+ onClick: (J) => F(w.startTime, w.endTime)
858
+ }, {
859
+ label: re(() => [
860
+ q("p", rn, [
861
+ nt(fe(T(Wt)(w, T(s))) + " ", 1),
862
+ xl(L(m, {
863
+ label: T(s)("report.common.default"),
864
+ class: "bg-fm-color-system-info-100 border-fm-color-typo-info text-fm-color-typo-info",
865
+ compact: ""
866
+ }, null, 8, ["label"]), [
867
+ [Al, w.isDefault]
868
+ ])
869
+ ]),
870
+ q("p", on, fe(T(zt)(w.startTime, T(Ae)())) + " - " + fe(T(zt)(w.endTime, T(Ae)())) + " " + fe(T(an)(w.startTime, w.endTime)), 1)
871
+ ]),
872
+ _: 2
873
+ }, 1032, ["value", "label", "onClick"]))), 128)),
874
+ L(N),
875
+ L(v, {
876
+ key: "range_custom",
877
+ label: T(s)("report.common.custom"),
878
+ value: l.defaultDateRange.length + 1
879
+ }, null, 8, ["label", "value"])
880
+ ]),
881
+ _: 1
882
+ }, 8, ["modelValue"]),
883
+ f.value === l.defaultDateRange.length + 1 ? (H(), me(Le, { key: 0 }, [
884
+ q("p", un, fe(T(s)("report.date.startingTime")), 1),
885
+ q("div", cn, [
886
+ L(O, {
887
+ "model-value": h(`${(U = i.value.start) == null ? void 0 : U.hour}:${(te = i.value.start) == null ? void 0 : te.minute}`),
888
+ "onUpdate:modelValue": u[2] || (u[2] = (w) => {
889
+ if (i.value.start) {
890
+ const x = T(I)(`${w.hours}:${w.minutes} ${w.period}`, "h:m A").locale(
891
+ T(Ae)()
892
+ );
893
+ i.value.start.hour = x.get("hour"), i.value.start.minute = x.get("minute");
894
+ }
895
+ })
896
+ }, null, 8, ["model-value"])
897
+ ]),
898
+ q("p", dn, fe(T(s)("report.date.endingTime")), 1),
899
+ q("div", mn, [
900
+ L(O, {
901
+ "model-value": h(`${(X = i.value.end) == null ? void 0 : X.hour}:${(le = i.value.end) == null ? void 0 : le.minute}`),
902
+ "onUpdate:modelValue": u[3] || (u[3] = (w) => {
903
+ if (i.value.end) {
904
+ const x = T(I)(`${w.hours}:${w.minutes} ${w.period}`, "h:m A").locale(
905
+ T(Ae)()
906
+ );
907
+ i.value.end.hour = x.get("hour"), i.value.end.minute = x.get("minute");
908
+ }
909
+ })
910
+ }, null, 8, ["model-value"])
911
+ ])
912
+ ], 64)) : bt("", !0),
913
+ q("div", pn, [
914
+ u[7] || (u[7] = q("div", { class: "grow" }, null, -1)),
915
+ L(B, {
916
+ label: T(s)("report.common.cancel"),
917
+ variant: "tertiary",
918
+ onClick: u[4] || (u[4] = (w) => P.value = !1)
919
+ }, null, 8, ["label"]),
920
+ L(B, {
921
+ label: T(s)("report.common.apply"),
922
+ onClick: u[5] || (u[5] = () => g(JSON.parse(JSON.stringify(i.value))))
923
+ }, null, 8, ["label"])
924
+ ])
925
+ ])
926
+ ];
927
+ }),
928
+ _: 1
929
+ }, 8, ["show-popover"])
930
+ ]);
931
+ };
932
+ }
933
+ }), jn = /* @__PURE__ */ yt({
934
+ __name: "BaseDialog",
935
+ props: /* @__PURE__ */ lt({
936
+ title: {
937
+ type: String,
938
+ default: "Title"
939
+ },
940
+ primaryButtonLabel: {
941
+ type: String,
942
+ default: "Confirm"
943
+ },
944
+ secondaryButtonLabel: {
945
+ type: String,
946
+ default: "Cancel"
947
+ }
948
+ }, {
949
+ modelValue: { type: Boolean, required: !0 },
950
+ modelModifiers: {}
951
+ }),
952
+ emits: /* @__PURE__ */ lt(["confirm"], ["update:modelValue"]),
953
+ setup(l, { emit: n }) {
954
+ const s = ft(l, "modelValue"), r = l, d = n;
955
+ return Ie(s, () => {
956
+ s.value ? document.body.style.overflow = "hidden" : document.body.style.overflow = "scroll";
957
+ }), (p, f) => {
958
+ const g = ee("FmButton"), h = ee("FmDialog");
959
+ return H(), Fe(h, {
960
+ modelValue: s.value,
961
+ "onUpdate:modelValue": f[2] || (f[2] = (i) => s.value = i),
962
+ overlay: ""
963
+ }, {
964
+ "dialog-header": re(() => [
965
+ nt(fe(r.title), 1)
966
+ ]),
967
+ default: re(() => [
968
+ Ut(p.$slots, "content")
969
+ ]),
970
+ "dialog-footer": re(() => [
971
+ f[3] || (f[3] = q("div", { class: "grow" }, null, -1)),
972
+ L(g, {
973
+ label: r.secondaryButtonLabel,
974
+ variant: "tertiary",
975
+ onClick: f[0] || (f[0] = (i) => s.value = !1)
976
+ }, null, 8, ["label"]),
977
+ L(g, {
978
+ label: r.primaryButtonLabel,
979
+ variant: "primary",
980
+ onClick: f[1] || (f[1] = (i) => d("confirm"))
981
+ }, null, 8, ["label"])
982
+ ]),
983
+ _: 3
984
+ }, 8, ["modelValue"]);
985
+ };
986
+ }
987
+ });
988
+ var xe = /* @__PURE__ */ ((l) => (l.Select = "Select", l.TextField = "TextField", l.Timestamp = "Timestamp", l))(xe || {});
989
+ function bn(l) {
990
+ let n = !1, s = 1;
991
+ switch (l) {
992
+ case W.Equal:
993
+ case W.NotEqual:
994
+ case W.Like:
995
+ case W.NotLike:
996
+ n = !1, s = 1;
997
+ break;
998
+ case W.GreaterThan:
999
+ case W.GreaterThanOrEqual:
1000
+ case W.LessThan:
1001
+ case W.LessThanOrEqual:
1002
+ n = !0, s = 1;
1003
+ break;
1004
+ case W.Between:
1005
+ n = !0, s = 2;
1006
+ break;
1007
+ }
1008
+ return {
1009
+ fixed: n,
1010
+ count: s
1011
+ };
1012
+ }
1013
+ function qn({
1014
+ operator: l,
1015
+ dimensionOption: n,
1016
+ dataType: s,
1017
+ t: r
1018
+ }) {
1019
+ const { fixed: d, count: p } = bn(l);
1020
+ switch (s) {
1021
+ case pe.String:
1022
+ return {
1023
+ type: "TextField",
1024
+ fixed: d,
1025
+ count: p,
1026
+ dataType: void 0,
1027
+ default: ""
1028
+ };
1029
+ case pe.Numeric:
1030
+ return {
1031
+ type: "TextField",
1032
+ fixed: d,
1033
+ count: p,
1034
+ dataType: "number",
1035
+ default: 0
1036
+ };
1037
+ case pe.Bool:
1038
+ return {
1039
+ type: "Select",
1040
+ fixed: d,
1041
+ count: p,
1042
+ options: [
1043
+ { label: r("report.common.yes"), value: !0 },
1044
+ { label: r("report.common.no"), value: !1 }
1045
+ ],
1046
+ default: !0
1047
+ };
1048
+ case pe.Timestamp:
1049
+ return el({
1050
+ dimensionOption: n,
1051
+ fixed: d,
1052
+ count: p,
1053
+ t: r
1054
+ });
1055
+ }
1056
+ return {
1057
+ type: "TextField",
1058
+ fixed: d,
1059
+ count: p,
1060
+ dataType: void 0,
1061
+ default: ""
1062
+ };
1063
+ }
1064
+ function Qn(l) {
1065
+ switch (l) {
1066
+ case M.HourOfDay:
1067
+ return 0;
1068
+ case M.DayOfMonth:
1069
+ return 1;
1070
+ default:
1071
+ return;
1072
+ }
1073
+ }
1074
+ function Kn(l) {
1075
+ switch (l) {
1076
+ case M.HourOfDay:
1077
+ return 23;
1078
+ case M.DayOfMonth:
1079
+ return 31;
1080
+ default:
1081
+ return;
1082
+ }
1083
+ }
1084
+ function el({
1085
+ dimensionOption: l,
1086
+ fixed: n,
1087
+ count: s,
1088
+ t: r
1089
+ }) {
1090
+ switch (l) {
1091
+ case M.HourOfDay:
1092
+ return {
1093
+ type: xe.Select,
1094
+ fixed: n,
1095
+ count: s,
1096
+ options: Array.from({ length: 24 }, (d, p) => ({
1097
+ label: p.toString().padStart(2, "0"),
1098
+ value: p.toString()
1099
+ })),
1100
+ default: "0"
1101
+ };
1102
+ case M.DayOfWeek:
1103
+ return {
1104
+ type: xe.Select,
1105
+ fixed: n,
1106
+ count: s,
1107
+ options: [
1108
+ { label: r("report.days.sunday"), value: "1" },
1109
+ { label: r("report.days.monday"), value: "2" },
1110
+ { label: r("report.days.tuesday"), value: "3" },
1111
+ { label: r("report.days.wednesday"), value: "4" },
1112
+ { label: r("report.days.thursday"), value: "5" },
1113
+ { label: r("report.days.friday"), value: "6" },
1114
+ { label: r("report.days.saturday"), value: "7" }
1115
+ ],
1116
+ default: "1"
1117
+ };
1118
+ case M.DayOfMonth:
1119
+ return {
1120
+ type: xe.Select,
1121
+ fixed: n,
1122
+ count: s,
1123
+ options: Array.from({ length: 31 }, (d, p) => ({
1124
+ label: (p + 1).toString(),
1125
+ value: (p + 1).toString()
1126
+ })),
1127
+ default: "1"
1128
+ };
1129
+ case M.MonthOfYear:
1130
+ return {
1131
+ type: xe.Select,
1132
+ fixed: n,
1133
+ count: s,
1134
+ options: [
1135
+ { label: r("report.months.january"), value: "1" },
1136
+ { label: r("report.months.february"), value: "2" },
1137
+ { label: r("report.months.march"), value: "3" },
1138
+ { label: r("report.months.april"), value: "4" },
1139
+ { label: r("report.months.may"), value: "5" },
1140
+ { label: r("report.months.june"), value: "6" },
1141
+ { label: r("report.months.july"), value: "7" },
1142
+ { label: r("report.months.august"), value: "8" },
1143
+ { label: r("report.months.september"), value: "9" },
1144
+ { label: r("report.months.october"), value: "10" },
1145
+ { label: r("report.months.november"), value: "11" },
1146
+ { label: r("report.months.december"), value: "12" }
1147
+ ],
1148
+ default: "1"
1149
+ };
1150
+ default:
1151
+ return {
1152
+ type: xe.Timestamp,
1153
+ fixed: n,
1154
+ count: s,
1155
+ default: (/* @__PURE__ */ new Date()).toISOString()
1156
+ };
1157
+ }
1158
+ }
1159
+ function pt({
1160
+ dimensionOption: l,
1161
+ t: n
1162
+ }) {
1163
+ const s = el({
1164
+ dimensionOption: l,
1165
+ fixed: !1,
1166
+ count: 1,
1167
+ t: n
1168
+ });
1169
+ return s.type !== xe.Select ? [] : [{ label: n("report.input.unknown"), value: "" }, ...s.options];
1170
+ }
1171
+ const hn = { class: "flex flex-row flex-wrap gap-2" }, vn = { class: "inline-flex max-w-[460px]" }, yn = {
1172
+ key: 0,
1173
+ class: "flex justify-center my-2"
1174
+ }, gn = { class: "px-2 pb-8" }, Sn = { class: "flex-1 overflow-y-auto overflow-x-hidden" }, Fn = { class: "px-2 pb-8" }, wn = { class: "flex items-start w-full" }, Dn = ["onClick"], Tn = { class: "fm-typo-en-body-md-400" }, Vn = { key: 0 }, Cn = { class: "px-12 py-3" }, Nn = { class: "flex items-center justify-between" }, On = { class: "text-xs max-w-[200px]" }, kn = { class: "px-4 py-3 flex flex-row justify-end gap-2 bg-white" }, Ne = "__EMPTY__", Se = "__NO_SELECTION__", Jn = /* @__PURE__ */ yt({
1175
+ __name: "GlobalFilterSelect",
1176
+ props: {
1177
+ globalFilterId: {},
1178
+ globalFilters: {},
1179
+ report: {},
1180
+ dateRange: {},
1181
+ timeRange: {},
1182
+ locationIds: {},
1183
+ isDialogGlobalFilter: { type: Boolean }
1184
+ },
1185
+ setup(l) {
1186
+ const n = l, { t: s, locale: r } = Kt(), { currentReport: d, editingTile: p } = se(Pe());
1187
+ let { timeRange: f, dateRange: g, selectedLocationIds: h, timezone: i } = se(Me()), { globalFilters: F } = se(Ge()), { schemas: P } = se(Pl()), {
1188
+ showMore: ne,
1189
+ getGlobalFilter: _,
1190
+ setGlobalFilter: D,
1191
+ setIncludeUnavailable: u,
1192
+ getGlobalFilterKey: m,
1193
+ isMenuOpen: v,
1194
+ getGlobalFilterLabel: N,
1195
+ incrementAppliedTilesFiltersVersion: k
1196
+ } = Ge();
1197
+ const O = ve(() => s("report.input.empty")), B = ["NULL", "", " "];
1198
+ let Q;
1199
+ const U = nn(), { getWidgetResult: te } = U, { widgetResults: X, isAllWidgetResultLoaded: le } = se(U), w = ye(!1), x = ye(!1), J = ye(""), z = ye({}), Y = ve(() => {
1200
+ var e;
1201
+ return n.globalFilterId ?? ((e = d.value) == null ? void 0 : e.id) ?? "";
1202
+ }), ae = ve(() => n.report ?? d.value), K = ye([]);
1203
+ function R(e) {
1204
+ return `${Y.value}|instance:${e}`;
1205
+ }
1206
+ function be(e) {
1207
+ return ct(e) ? !1 : w.value ? !0 : n.isDialogGlobalFilter ? x.value : !le.value && e.options.length === 0;
1208
+ }
1209
+ function ie(e, t) {
1210
+ return (e == null ? void 0 : e.startDate) === (t == null ? void 0 : t.startDate) && (e == null ? void 0 : e.endDate) === (t == null ? void 0 : t.endDate);
1211
+ }
1212
+ function he(e, t) {
1213
+ var o, a, b, V, y, $, E, A;
1214
+ return ((o = e == null ? void 0 : e.start) == null ? void 0 : o.hour) === ((a = t == null ? void 0 : t.start) == null ? void 0 : a.hour) && ((b = e == null ? void 0 : e.start) == null ? void 0 : b.minute) === ((V = t == null ? void 0 : t.start) == null ? void 0 : V.minute) && ((y = e == null ? void 0 : e.end) == null ? void 0 : y.hour) === (($ = t == null ? void 0 : t.end) == null ? void 0 : $.hour) && ((E = e == null ? void 0 : e.end) == null ? void 0 : E.minute) === ((A = t == null ? void 0 : t.end) == null ? void 0 : A.minute);
1215
+ }
1216
+ function ue(e, t) {
1217
+ return !e || !t ? e === t : e.length === t.length && e.every((o, a) => o === t[a]);
1218
+ }
1219
+ const ge = ve(() => {
1220
+ if (!(n.isDialogGlobalFilter || !!p.value))
1221
+ return !1;
1222
+ const t = n.dateRange ?? g.value, o = n.timeRange ?? f.value, a = n.locationIds ?? h.value;
1223
+ return ie(t, g.value) && he(o, f.value) && ue(a, h.value);
1224
+ });
1225
+ function we(e) {
1226
+ return e ? [...e.tileIds ?? []] : Array.from(new Set(He.value.flatMap((t) => t.tileIds ?? [])));
1227
+ }
1228
+ function ce(e) {
1229
+ n.isDialogGlobalFilter || k(we(e));
1230
+ }
1231
+ function Z(e) {
1232
+ return e.filter((t) => t !== Se);
1233
+ }
1234
+ function De(e) {
1235
+ const t = e.some(
1236
+ (a) => a === Ne || a === "NULL" || typeof a == "string" && (a === "" || a === " ")
1237
+ ), o = e.flatMap(
1238
+ (a) => a === Ne ? [...B] : [a]
1239
+ );
1240
+ return t ? Array.from(/* @__PURE__ */ new Set([...o, ...B])) : Array.from(new Set(o));
1241
+ }
1242
+ function Te(e) {
1243
+ const t = _(
1244
+ e.globalFilter,
1245
+ R(e.id)
1246
+ ).selectedValues;
1247
+ return t != null && t.length ? t : e.selectedValues || [];
1248
+ }
1249
+ function at(e) {
1250
+ e.selectedValues = [], e.globalFilter.values = [], D(e.globalFilter, R(e.id), { selectedValues: [] });
1251
+ }
1252
+ function st(e) {
1253
+ const t = Je(e);
1254
+ e.selectedValues = [...t], e.globalFilter.values = il(e), D(e.globalFilter, R(e.id), {
1255
+ selectedValues: t
1256
+ });
1257
+ }
1258
+ function tl(e) {
1259
+ e.options = [], at(e);
1260
+ }
1261
+ function wt(e) {
1262
+ e.keepSelection || at(e);
1263
+ }
1264
+ function ll(e) {
1265
+ const t = Z(Te(e));
1266
+ z.value[e.id] = [...t], at(e);
1267
+ }
1268
+ function nl() {
1269
+ var a, b, V, y;
1270
+ const e = g.value, t = f.value, o = h.value || [];
1271
+ return JSON.stringify({
1272
+ globalFilterId: Y.value,
1273
+ startDate: (e == null ? void 0 : e.startDate) ?? null,
1274
+ endDate: (e == null ? void 0 : e.endDate) ?? null,
1275
+ startHour: ((a = t == null ? void 0 : t.start) == null ? void 0 : a.hour) ?? null,
1276
+ startMinute: ((b = t == null ? void 0 : t.start) == null ? void 0 : b.minute) ?? null,
1277
+ endHour: ((V = t == null ? void 0 : t.end) == null ? void 0 : V.hour) ?? null,
1278
+ endMinute: ((y = t == null ? void 0 : t.end) == null ? void 0 : y.minute) ?? null,
1279
+ locationIds: o
1280
+ });
1281
+ }
1282
+ function Je(e) {
1283
+ const t = e.selectedValues || [];
1284
+ return Ve(t) ? [Se] : e.keepSelection ? Z(t) : t;
1285
+ }
1286
+ function de(e) {
1287
+ const t = Z(e.selectedValues || []);
1288
+ if (t.length)
1289
+ return t.map((a) => String(a));
1290
+ const o = Z(
1291
+ _(e.globalFilter, R(e.id)).selectedValues
1292
+ );
1293
+ return o.length ? o.map((a) => String(a)) : (e.globalFilter.values ?? []).map((a) => String(a));
1294
+ }
1295
+ function al(e) {
1296
+ if (Ve(e.selectedValues || []))
1297
+ return [Se];
1298
+ const t = Z(e.selectedValues || []);
1299
+ if (t.length)
1300
+ return t;
1301
+ const o = _(
1302
+ e.globalFilter,
1303
+ R(e.id)
1304
+ ).selectedValues;
1305
+ return Ve(o || []) ? [Se] : Z(o);
1306
+ }
1307
+ function Ve(e) {
1308
+ return e.includes(Se);
1309
+ }
1310
+ function Dt(e) {
1311
+ return e === Ne || String(e ?? "").trim() === "";
1312
+ }
1313
+ function rt(e) {
1314
+ return [...e].sort((t, o) => {
1315
+ const a = Dt(t.value), b = Dt(o.value);
1316
+ return a !== b ? a ? -1 : 1 : t.label.localeCompare(o.label, r.value, {
1317
+ numeric: !0,
1318
+ sensitivity: "base"
1319
+ });
1320
+ });
1321
+ }
1322
+ function Tt(e) {
1323
+ return e.type === pe.String && !Be(e.globalFilter);
1324
+ }
1325
+ function ot(e) {
1326
+ return (e.options || []).map((t) => t.value);
1327
+ }
1328
+ function it(e) {
1329
+ return ot(e).length > 0;
1330
+ }
1331
+ function Ee(e) {
1332
+ const t = Z(e.selectedValues || []);
1333
+ return t.length ? t : Ve(e.selectedValues || []) ? [] : it(e) ? ot(e) : [];
1334
+ }
1335
+ function ut(e, t) {
1336
+ const o = new Set((e.options || []).map((a) => a.value));
1337
+ return Z(t).filter((a) => o.has(a));
1338
+ }
1339
+ function sl(e) {
1340
+ const o = _(e.globalFilter, R(e.id)).selectedValues, a = n.isDialogGlobalFilter ? al(e) : [];
1341
+ if (Ve(e.selectedValues || []))
1342
+ return [Se];
1343
+ if (Ve(o || []))
1344
+ return [Se];
1345
+ if ((e.options || []).map((V) => V.value).length > 0) {
1346
+ const V = ut(
1347
+ e,
1348
+ a
1349
+ );
1350
+ if (V.length)
1351
+ return V;
1352
+ const y = ut(e, o);
1353
+ if (y.length)
1354
+ return y;
1355
+ if (e.keepSelection) {
1356
+ const $ = ut(
1357
+ e,
1358
+ Te(e)
1359
+ );
1360
+ if ($.length)
1361
+ return $;
1362
+ }
1363
+ return [];
1364
+ }
1365
+ return a.length ? [...a] : o.length ? [...o] : e.keepSelection ? Te(e) : [];
1366
+ }
1367
+ function rl(e, t) {
1368
+ const o = new Set(Z(t));
1369
+ if (!o.size) return !1;
1370
+ const a = (e.options || []).map((b) => b.value);
1371
+ return a.length ? a.every((b) => o.has(b)) : !1;
1372
+ }
1373
+ function ol(e) {
1374
+ const t = e.selectedValues || [];
1375
+ return Ve(t) || !it(e) ? !1 : Z(t).length === 0;
1376
+ }
1377
+ function il(e) {
1378
+ const t = Je(e), o = Z(t), a = De(o), b = Ve(t);
1379
+ if (ol(e))
1380
+ return [];
1381
+ if (rl(e, t))
1382
+ return [];
1383
+ if (!e.keepSelection || n.isDialogGlobalFilter)
1384
+ return a.length ? a : b ? [Ne] : [];
1385
+ if (!it(e))
1386
+ return a.length ? a : b ? [Ne] : [];
1387
+ const V = new Set(
1388
+ (e.options || []).filter((E) => E.available !== !1).map((E) => E.value)
1389
+ ), y = o.filter(
1390
+ (E) => V.has(E)
1391
+ ), $ = De(y);
1392
+ return $.length ? $ : b ? [Ne] : [];
1393
+ }
1394
+ function Ye(e) {
1395
+ const t = z.value[e.id];
1396
+ if (t) {
1397
+ e.selectedValues = [...t], st(e), delete z.value[e.id];
1398
+ return;
1399
+ }
1400
+ e.selectedValues = sl(e), st(e);
1401
+ }
1402
+ function ul() {
1403
+ K.value.forEach((e) => {
1404
+ ge.value || wt(e);
1405
+ });
1406
+ }
1407
+ function cl() {
1408
+ const e = nl();
1409
+ J.value !== e && K.value.forEach((o) => {
1410
+ if (o.keepSelection) {
1411
+ ll(o);
1412
+ return;
1413
+ }
1414
+ wt(o);
1415
+ }), J.value = e;
1416
+ }
1417
+ const He = ve(() => n.globalFilters ?? F.value);
1418
+ function dl(e) {
1419
+ return {
1420
+ schemaName: e.schemaName,
1421
+ name: e.name,
1422
+ operator: e.operator,
1423
+ option: e.option,
1424
+ dataFormula: e.dataFormula,
1425
+ tileIds: [...e.tileIds ?? []],
1426
+ filters: e.filters ?? [],
1427
+ customOptions: e.customOptions ?? [],
1428
+ customTimeRanges: e.customTimeRanges ?? []
1429
+ };
1430
+ }
1431
+ function ml(e) {
1432
+ return e.map((t) => dl(t));
1433
+ }
1434
+ function pl(e, t) {
1435
+ const o = `${m(e, Y.value)}|${t}`, a = _(e, R(o)), b = a.selectedValues.length ? [...a.selectedValues] : [...e.values ?? []];
1436
+ return {
1437
+ id: o,
1438
+ globalFilter: e,
1439
+ search: a.search,
1440
+ options: a.options,
1441
+ type: Ct(e),
1442
+ selectedValues: b,
1443
+ visibleCount: a.visibleCount,
1444
+ keepSelection: a.keepSelection,
1445
+ showAdvanced: a.showAdvanced
1446
+ };
1447
+ }
1448
+ function fl() {
1449
+ K.value = He.value.map(
1450
+ (e, t) => pl(e, t)
1451
+ );
1452
+ }
1453
+ const bl = ve(
1454
+ () => JSON.stringify(ml(He.value))
1455
+ ), hl = ve(() => {
1456
+ const e = He.value.map(
1457
+ (t) => Et(t, Rt())
1458
+ );
1459
+ return JSON.stringify(
1460
+ e.map((t) => ({
1461
+ key: t,
1462
+ values: X.value[t] ?? []
1463
+ }))
1464
+ );
1465
+ });
1466
+ Ie(
1467
+ () => ({
1468
+ globalFilterId: Y.value,
1469
+ globalFiltersConfigSignature: bl.value
1470
+ }),
1471
+ (e, t) => {
1472
+ t && t.globalFilterId !== e.globalFilterId && K.value.forEach((o) => {
1473
+ o.options = [];
1474
+ }), fl(), t && t.globalFiltersConfigSignature !== e.globalFiltersConfigSignature && ce(), le.value && Xe();
1475
+ },
1476
+ { immediate: !0 }
1477
+ ), Ie(
1478
+ [
1479
+ le,
1480
+ f,
1481
+ g,
1482
+ h,
1483
+ () => n.timeRange,
1484
+ () => n.dateRange,
1485
+ () => n.locationIds
1486
+ ],
1487
+ async () => {
1488
+ n.isDialogGlobalFilter ? ul() : cl(), await Xe();
1489
+ },
1490
+ { immediate: !0 }
1491
+ ), Ie(
1492
+ [() => p.value],
1493
+ async () => {
1494
+ K.value.forEach((e) => {
1495
+ e.options = [];
1496
+ }), await Xe();
1497
+ },
1498
+ { deep: !0 }
1499
+ ), Ie(
1500
+ () => hl.value,
1501
+ async (e, t) => {
1502
+ e !== t && t && (n.isDialogGlobalFilter || _t() || await Xe());
1503
+ }
1504
+ ), Ie(
1505
+ () => r.value,
1506
+ () => {
1507
+ vl();
1508
+ }
1509
+ );
1510
+ function Vt(e, t) {
1511
+ var o;
1512
+ return t === !0 ? s("report.common.yes") || "Yes" : t === !1 ? s("report.common.no") || "No" : String(t).trim() === "" || t === Ne ? O.value : e.type === pe.Timestamp && e.globalFilter.option !== M.DateTime && e.globalFilter.option !== M.TimeOfDay ? ((o = pt({
1513
+ dimensionOption: e.globalFilter.option,
1514
+ t: s
1515
+ }).find((b) => String(b.value) === String(t))) == null ? void 0 : o.label) ?? String(t) : String(t);
1516
+ }
1517
+ function vl() {
1518
+ K.value.forEach((e) => {
1519
+ if (!e.options.length) return;
1520
+ const t = e.options.map((o) => ({
1521
+ ...o,
1522
+ label: Vt(e, o.value)
1523
+ }));
1524
+ e.options = Tt(e) ? rt(t) : t;
1525
+ });
1526
+ }
1527
+ function Ct(e) {
1528
+ var o;
1529
+ const t = (o = P.value.find((a) => a.name === e.schemaName)) == null ? void 0 : o.fields.find((a) => a.name === e.name);
1530
+ return t == null ? void 0 : t.type;
1531
+ }
1532
+ function yl(e) {
1533
+ var $, E;
1534
+ if (!ae.value && !p.value) return [];
1535
+ if (!(($ = e.tileIds) != null && $.length)) return [];
1536
+ const t = p.value ? [p.value] : Ue((E = ae.value) == null ? void 0 : E.tiles), { name: o = "", schemaName: a = "" } = e, b = t.filter((A) => {
1537
+ var oe, S;
1538
+ const G = (oe = A == null ? void 0 : A.widget) == null ? void 0 : oe.config;
1539
+ if (!G || (S = e.tileIds) != null && S.length && !e.tileIds.includes(A.id)) return !1;
1540
+ const c = (G.dimensions ?? []).some(
1541
+ (_e) => _e.schemaName === a && _e.name === o
1542
+ ), j = (G.joinDatasources ?? []).some(
1543
+ (_e) => (_e.dimensions ?? []).some((ze) => ze.schemaName === a && ze.name === o)
1544
+ ), C = (G.schemaNames ?? []).includes(a);
1545
+ return c || j || C;
1546
+ });
1547
+ if (!b.length) return [];
1548
+ const V = (A, G) => {
1549
+ const c = /* @__PURE__ */ new Map(), j = (C) => {
1550
+ const oe = `${C.schemaName}:${C.name}:${C.operator}:${C.option ?? ""}:${C.dataFormula ?? ""}`, S = c.get(oe);
1551
+ S ? [W.Like, W.NotLike].includes(C.operator) ? S.values = Array.from(/* @__PURE__ */ new Set([...S.values ?? [], ...C.values ?? []])) : c.set(oe, { ...C }) : c.set(oe, { ...C });
1552
+ };
1553
+ return A.forEach(j), G.forEach(j), Array.from(c.values());
1554
+ }, y = (A) => {
1555
+ var c;
1556
+ const G = (c = A.dimensions) == null ? void 0 : c.find(
1557
+ (j) => j.schemaName === a && j.name === o
1558
+ );
1559
+ return {
1560
+ name: o,
1561
+ schemaName: a,
1562
+ label: (G == null ? void 0 : G.label) ?? o,
1563
+ hide: !1,
1564
+ option: e.option ?? null,
1565
+ dataFormula: G == null ? void 0 : G.dataFormula
1566
+ };
1567
+ };
1568
+ return b.reduce((A, G) => {
1569
+ var ze, $t;
1570
+ const c = (ze = G == null ? void 0 : G.widget) == null ? void 0 : ze.config;
1571
+ if (!c) return A;
1572
+ const j = y(c), C = (c.dimensions ?? []).some((Ce) => Ce.schemaName === a) || (c.schemaNames ?? []).includes(a), oe = V(
1573
+ c.filters ?? [],
1574
+ (e.filters ?? []).filter((Ce) => {
1575
+ var Re;
1576
+ return (Re = c.schemaNames) == null ? void 0 : Re.includes(Ce.schemaName);
1577
+ })
1578
+ ), S = ($t = c.joinDatasources) == null ? void 0 : $t.find(
1579
+ (Ce) => (Ce.schemaNames ?? []).includes(a) || (Ce.dimensions ?? []).some((Re) => Re.schemaName === a)
1580
+ ), _e = V(
1581
+ (S == null ? void 0 : S.filters) ?? [],
1582
+ (e.filters ?? []).filter((Ce) => {
1583
+ var Re;
1584
+ return (Re = S == null ? void 0 : S.schemaNames) == null ? void 0 : Re.includes(Ce.schemaName);
1585
+ })
1586
+ );
1587
+ return A.push({
1588
+ type: Lt.Table,
1589
+ title: "Global Filter",
1590
+ config: {
1591
+ schemaNames: c.schemaNames,
1592
+ schemas: c.schemas,
1593
+ dimensions: C ? [j] : [],
1594
+ filters: oe,
1595
+ sorts: C ? [{ name: o, schemaName: a, type: Mt.Asc, aggregation: null, dimensionOption: null }] : [],
1596
+ joinDatasources: !C && S ? [
1597
+ {
1598
+ ...S,
1599
+ dimensions: [j],
1600
+ sorts: [
1601
+ {
1602
+ name: o,
1603
+ schemaName: a,
1604
+ type: Mt.Asc,
1605
+ aggregation: null,
1606
+ dimensionOption: null
1607
+ }
1608
+ ],
1609
+ filters: _e
1610
+ }
1611
+ ] : [],
1612
+ rowIds: [],
1613
+ metrics: [],
1614
+ limit: null,
1615
+ rollup: void 0,
1616
+ drillDimension: void 0,
1617
+ showGrandTotal: !1,
1618
+ breakdownDimension: void 0,
1619
+ sparklineDimension: void 0,
1620
+ isTransposed: !1,
1621
+ isDrillable: !1,
1622
+ rowHeight: null,
1623
+ colWidths: null,
1624
+ isBlend: !1
1625
+ }
1626
+ }), A;
1627
+ }, []);
1628
+ }
1629
+ function Nt(e) {
1630
+ const t = new Set(Ee(e));
1631
+ return e.options.every((o) => t.has(o.value));
1632
+ }
1633
+ function gl(e) {
1634
+ Nt(e) ? e.selectedValues = [Se] : e.selectedValues = [];
1635
+ }
1636
+ function Ot(e, t) {
1637
+ return Ee(e).includes(t);
1638
+ }
1639
+ const kt = ve(
1640
+ () => K.value.map((e) => {
1641
+ const t = e.options, o = e.search.toLowerCase() ?? "";
1642
+ return t.filter(
1643
+ (b) => b.label.toLowerCase().includes(o.toLowerCase())
1644
+ ).slice(0, e.visibleCount);
1645
+ })
1646
+ );
1647
+ function Sl(e) {
1648
+ e.visibleCount += 50, ne(e.globalFilter, R(e.id), 50);
1649
+ }
1650
+ function Fl(e, t) {
1651
+ D(e.globalFilter, R(e.id), { search: t });
1652
+ }
1653
+ function Be(e) {
1654
+ var t, o;
1655
+ return (((t = e.customOptions) == null ? void 0 : t.length) ?? 0) > 0 || (((o = e.customTimeRanges) == null ? void 0 : o.length) ?? 0) > 0;
1656
+ }
1657
+ function ct(e) {
1658
+ var t;
1659
+ return !((t = e.globalFilter.tileIds) != null && t.length);
1660
+ }
1661
+ function _t() {
1662
+ return (n.isDialogGlobalFilter || !!p.value) && !ge.value;
1663
+ }
1664
+ function Rt() {
1665
+ var e;
1666
+ return n.isDialogGlobalFilter && ge.value && ((e = d.value) != null && e.id) ? d.value.id : Y.value;
1667
+ }
1668
+ function Ze(e) {
1669
+ return String(e ?? "").trim() === "" ? Ne : String(e);
1670
+ }
1671
+ function wl(e) {
1672
+ var t, o;
1673
+ return (((t = e.customTimeRanges) == null ? void 0 : t.length) ?? 0) > 0 ? e.customTimeRanges.map((a) => ({
1674
+ label: Ze(a.name),
1675
+ value: Ze(a.name),
1676
+ available: !0
1677
+ })) : (((o = e.customOptions) == null ? void 0 : o.length) ?? 0) > 0 ? e.customOptions.map((a) => ({
1678
+ label: Ze(a.label),
1679
+ value: Ze(a.label),
1680
+ available: !0
1681
+ })) : [];
1682
+ }
1683
+ function Dl(e) {
1684
+ const t = Z(e.selectedValues || []);
1685
+ if (!t.length) return;
1686
+ const o = new Set(e.options.map((b) => b.value)), a = t.filter((b) => !o.has(b)).map((b) => ({
1687
+ value: b,
1688
+ label: Vt(e, b),
1689
+ available: !1
1690
+ }));
1691
+ if (a.length) {
1692
+ const b = [...e.options, ...a];
1693
+ e.options = Tt(e) ? rt(b) : b;
1694
+ }
1695
+ }
1696
+ function Tl(e) {
1697
+ if (e.keepSelection) {
1698
+ Dl(e);
1699
+ const o = Te(e);
1700
+ e.selectedValues = o.length ? [...o] : [...e.selectedValues || []];
1701
+ } else {
1702
+ const o = Z(Te(e));
1703
+ e.options = e.options.filter((V) => V.available !== !1);
1704
+ const a = new Set(e.options.map((V) => V.value)), b = o.filter(
1705
+ (V) => a.has(V)
1706
+ );
1707
+ e.selectedValues = b;
1708
+ }
1709
+ const t = Je(e);
1710
+ e.selectedValues = [...t], D(e.globalFilter, R(e.id), {
1711
+ selectedValues: t
1712
+ });
1713
+ }
1714
+ async function Vl(e, t) {
1715
+ var o;
1716
+ if (e.options = [], !((o = e.globalFilter.tileIds) != null && o.length)) {
1717
+ tl(e);
1718
+ return;
1719
+ }
1720
+ if (!(!e.type && (e.type = Ct(e.globalFilter), !e.type))) {
1721
+ if (Be(e.globalFilter)) {
1722
+ e.options = wl(e.globalFilter), Ye(e);
1723
+ return;
1724
+ }
1725
+ switch (e.type) {
1726
+ case pe.String:
1727
+ try {
1728
+ const a = yl(e.globalFilter);
1729
+ if (!a.length) {
1730
+ e.options = [];
1731
+ return;
1732
+ }
1733
+ const b = _t(), V = [];
1734
+ for (const c of a) {
1735
+ if (t.aborted) return;
1736
+ if (b) {
1737
+ const C = await tn({
1738
+ widget: c,
1739
+ signal: t,
1740
+ scopedLocationIds: n.locationIds,
1741
+ scopedTimeRange: n.timeRange,
1742
+ scopedDateRange: n.dateRange,
1743
+ scopedGlobalFilters: n.globalFilters
1744
+ });
1745
+ (C == null ? void 0 : C.type) === Lt.Table && V.push(...C.rows.map((oe) => {
1746
+ var S;
1747
+ return ((S = oe.cells) == null ? void 0 : S[0]) ?? " ";
1748
+ }));
1749
+ continue;
1750
+ }
1751
+ const j = te(
1752
+ Et(e.globalFilter, Rt())
1753
+ );
1754
+ V.push(...j);
1755
+ }
1756
+ const y = Array.from(new Set(V)), $ = Te(e), E = e.keepSelection ? Array.from(/* @__PURE__ */ new Set([...y, ...$])) : y, A = new Set(V), G = new Set(y);
1757
+ e.options = rt(
1758
+ Bl(E, {
1759
+ unknownLabel: O.value,
1760
+ getAvailable: (c) => e.keepSelection ? A.has(c) : G.has(c)
1761
+ })
1762
+ ), Ye(e);
1763
+ } catch (a) {
1764
+ if ((a == null ? void 0 : a.code) === "ERR_CANCELED" || (a == null ? void 0 : a.name) === "CanceledError")
1765
+ return;
1766
+ throw a;
1767
+ }
1768
+ break;
1769
+ case pe.Bool: {
1770
+ e.options = [
1771
+ { label: s("report.common.yes"), value: !0 },
1772
+ { label: s("report.common.no"), value: !1 }
1773
+ ], Ye(e);
1774
+ break;
1775
+ }
1776
+ case pe.Timestamp:
1777
+ if (e.globalFilter.option !== M.DateTime && e.globalFilter.option !== M.TimeOfDay) {
1778
+ const a = e.globalFilter.option;
1779
+ e.options = pt({ dimensionOption: a, t: s }), e.globalFilter.values = e.options.length ? e.options.map((b) => b.value) : ["NULL"];
1780
+ }
1781
+ Ye(e);
1782
+ break;
1783
+ case pe.Numeric:
1784
+ break;
1785
+ }
1786
+ }
1787
+ }
1788
+ async function Xe() {
1789
+ if (!Y.value || !K.value.length) return;
1790
+ Q && Q.abort();
1791
+ const e = new AbortController();
1792
+ Q = e, w.value = !0, n.isDialogGlobalFilter && (x.value = !0);
1793
+ try {
1794
+ await Promise.all(
1795
+ K.value.map(
1796
+ (t) => Vl(t, e.signal)
1797
+ )
1798
+ );
1799
+ } finally {
1800
+ Q === e && (w.value = !1), n.isDialogGlobalFilter && Q === e && (x.value = !1);
1801
+ }
1802
+ }
1803
+ function It(e, t) {
1804
+ const o = ot(e), a = Ee(e);
1805
+ if (a.includes(t)) {
1806
+ const y = a.filter(($) => $ !== t);
1807
+ e.selectedValues = y.length > 0 ? y : [Se];
1808
+ } else {
1809
+ const y = [...a, t], $ = o.length > 0 && o.every((E) => y.includes(E));
1810
+ e.selectedValues = $ ? [] : y;
1811
+ }
1812
+ const V = Je(e);
1813
+ e.selectedValues = [...V], D(e.globalFilter, R(e.id), {
1814
+ selectedValues: V
1815
+ });
1816
+ }
1817
+ function xt(e, t) {
1818
+ const o = e.globalFilter, a = t ? [
1819
+ I(t.startDate).tz(i.value).startOf("day").utc().toISOString(),
1820
+ I(t.endDate).tz(i.value).endOf("day").utc().toISOString()
1821
+ ] : [];
1822
+ t === null ? o.values = [] : o.values = a, e.selectedValues = [...a], e.keepSelection = t !== null, D(e.globalFilter, R(e.id), {
1823
+ keepSelection: e.keepSelection,
1824
+ selectedValues: [...a]
1825
+ }), ce(e.globalFilter);
1826
+ }
1827
+ function Cl(e) {
1828
+ const t = Ee(e);
1829
+ return `${s("report.section.filter.selectAll")} (${t.length}/${e.options.length})`;
1830
+ }
1831
+ function Nl() {
1832
+ return s("report.section.filter.search");
1833
+ }
1834
+ function et(e) {
1835
+ const t = N(e.globalFilter), o = e.options.length > 0 ? "(0 selected)" : "";
1836
+ if (e.type === pe.Timestamp && !Be(e.globalFilter)) {
1837
+ const y = de(e), $ = y.length === 2;
1838
+ if (e.globalFilter.option === M.DateTime)
1839
+ return { preview: $ ? `${t} is between ${El({
1840
+ startDate: y[0] || null,
1841
+ endDate: y[1] || null,
1842
+ locale: r.value,
1843
+ timezone: i.value
1844
+ })}` : t, suffix: "" };
1845
+ if (e.globalFilter.option === M.TimeOfDay) {
1846
+ const E = y[0] ? I(y[0]).tz(i.value) : null, A = y[1] ? I(y[1]).tz(i.value) : null, G = (j) => j && j.isValid() ? { hour: j.hour(), minute: j.minute() } : null;
1847
+ return { preview: $ ? `${t} is between ${jt({
1848
+ startTime: G(E),
1849
+ endTime: G(A),
1850
+ locale: r.value
1851
+ })}` : t, suffix: "" };
1852
+ }
1853
+ if (e.globalFilter.option !== M.DateTime && e.globalFilter.option !== M.TimeOfDay) {
1854
+ const E = pt({
1855
+ dimensionOption: e.globalFilter.option,
1856
+ t: s
1857
+ }), A = new Map(E.map((C) => [String(C.value), C.label])), c = Ee(e).map((C) => A.get(String(C)) ?? String(C)), j = c.map((C) => C.length > 20 ? `${C.slice(0, 20)}…` : C).join(", ");
1858
+ return c.length ? {
1859
+ preview: `${t}: ${j}`,
1860
+ suffix: `(${c.length} selected)`
1861
+ } : { preview: t, suffix: o };
1862
+ }
1863
+ }
1864
+ const b = Ee(e).map((y) => y === !0 ? s("report.common.yes") || "Yes" : y === !1 ? s("report.common.no") || "No" : String(y).trim() === "" ? O.value : String(y)), V = b.map((y) => y.length > 20 ? `${y.slice(0, 20)}…` : y).join(", ");
1865
+ return b.length ? {
1866
+ preview: `${t}: ${V}`,
1867
+ suffix: `(${b.length} selected)`
1868
+ } : { preview: t, suffix: o };
1869
+ }
1870
+ function Ol(e) {
1871
+ st(e), ce(e.globalFilter), document.body.click();
1872
+ }
1873
+ function kl(e) {
1874
+ const t = _(
1875
+ e.globalFilter,
1876
+ R(e.id)
1877
+ ).selectedValues;
1878
+ e.selectedValues = t.length ? [...t] : [...e.globalFilter.values || []], D(e.globalFilter, R(e.id), {
1879
+ selectedValues: e.selectedValues
1880
+ }), document.body.click();
1881
+ }
1882
+ function _l(e) {
1883
+ e.showAdvanced = !e.showAdvanced, D(e.globalFilter, R(e.id), {
1884
+ showAdvanced: e.showAdvanced
1885
+ });
1886
+ }
1887
+ function Rl(e) {
1888
+ e.keepSelection = !e.keepSelection, u(e.keepSelection), D(e.globalFilter, R(e.id), {
1889
+ keepSelection: e.keepSelection
1890
+ }), Tl(e);
1891
+ }
1892
+ function Il(e, t) {
1893
+ return e ? e.length > t ? `${e.slice(0, t)}…` : e : O.value;
1894
+ }
1895
+ function At(e, t) {
1896
+ var b, V, y, $;
1897
+ const o = e.globalFilter;
1898
+ let a = [];
1899
+ if (t === null)
1900
+ o.values = [];
1901
+ else {
1902
+ const E = I().tz(i.value).set("hour", Number((b = t.start) == null ? void 0 : b.hour)).set("minute", Number((V = t.start) == null ? void 0 : V.minute)).toISOString(), A = I().tz(i.value).set("hour", Number((y = t.end) == null ? void 0 : y.hour)).set("minute", Number(($ = t.end) == null ? void 0 : $.minute)).toISOString();
1903
+ a = [E, A], o.values = a;
1904
+ }
1905
+ e.selectedValues = [...a], e.keepSelection = t !== null, D(e.globalFilter, R(e.id), {
1906
+ keepSelection: e.keepSelection,
1907
+ selectedValues: [...a]
1908
+ }), ce(e.globalFilter);
1909
+ }
1910
+ return (e, t) => {
1911
+ const o = ee("FmCircularProgress"), a = ee("FmTextField"), b = ee("FmMenuItem"), V = ee("FmTooltip"), y = ee("FmIcon"), $ = ee("FmMenuDivider"), E = ee("FmSwitch"), A = ee("FmButton"), G = ee("FmMenu");
1912
+ return H(), me("div", hn, [
1913
+ (H(!0), me(Le, null, ht(K.value, (c, j) => (H(), me("div", {
1914
+ key: c.id
1915
+ }, [
1916
+ c.globalFilter.option === T(M).DateTime && !Be(c.globalFilter) ? (H(), Fe(Gl, {
1917
+ key: 0,
1918
+ "date-range": {
1919
+ startDate: de(c)[0],
1920
+ endDate: de(c)[1]
1921
+ },
1922
+ class: "w-full",
1923
+ label: et(c).preview,
1924
+ removable: de(c).length === 2,
1925
+ onUpdate: (C) => xt(c, C),
1926
+ onChipClosed: () => xt(c, null)
1927
+ }, null, 8, ["date-range", "label", "removable", "onUpdate", "onChipClosed"])) : c.globalFilter.option === T(M).TimeOfDay && !Be(c.globalFilter) ? (H(), Fe(fn, {
1928
+ key: 1,
1929
+ "time-range": {
1930
+ start: de(c)[0] ? {
1931
+ hour: T(I)(de(c)[0]).tz(T(i)).hour(),
1932
+ minute: T(I)(de(c)[0]).tz(T(i)).minute()
1933
+ } : null,
1934
+ end: de(c)[1] ? {
1935
+ hour: T(I)(de(c)[1]).tz(T(i)).hour(),
1936
+ minute: T(I)(de(c)[1]).tz(T(i)).minute()
1937
+ } : null
1938
+ },
1939
+ class: "w-full",
1940
+ label: et(c).preview,
1941
+ removable: de(c).length === 2,
1942
+ onUpdate: (C) => At(c, C),
1943
+ onChipClosed: () => At(c, null)
1944
+ }, null, 8, ["time-range", "label", "removable", "onUpdate", "onChipClosed"])) : (H(), Fe(G, {
1945
+ key: 2,
1946
+ "close-on-click": !1,
1947
+ shift: !0,
1948
+ open: T(v)(c.id)
1949
+ }, {
1950
+ "menu-button": re(() => [
1951
+ q("div", vn, [
1952
+ L(qt, {
1953
+ "left-icon": "filter_alt",
1954
+ "trailing-icon": "expand_more",
1955
+ loading: be(c),
1956
+ label: et(c).preview,
1957
+ class: "w-full"
1958
+ }, {
1959
+ default: re(() => [
1960
+ nt(fe(et(c).suffix), 1)
1961
+ ]),
1962
+ _: 2
1963
+ }, 1032, ["loading", "label"])
1964
+ ])
1965
+ ]),
1966
+ "menu-wrapper": re(({ maxHeight: C, width: oe }) => [
1967
+ q("div", {
1968
+ class: "flex flex-col bg-fm-color-neutral-white p-2 rounded-lg shadow-light-300",
1969
+ style: $l({ maxHeight: `${C}px`, width: oe })
1970
+ }, [
1971
+ be(c) ? (H(), me("div", yn, [
1972
+ L(o)
1973
+ ])) : c.options.length > 0 ? (H(), me(Le, { key: 1 }, [
1974
+ q("div", gn, [
1975
+ L(a, {
1976
+ modelValue: c.search,
1977
+ "onUpdate:modelValue": [(S) => c.search = S, (S) => Fl(c, S)],
1978
+ type: "text",
1979
+ "prepend-icon": "search",
1980
+ placeholder: Nl(),
1981
+ class: "border px-2 pb-8 text-sm mb-1 rounded"
1982
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])
1983
+ ]),
1984
+ q("div", Sn, [
1985
+ q("div", Fn, [
1986
+ L(b, {
1987
+ label: Cl(c),
1988
+ "has-checkbox": !0,
1989
+ "model-value": Nt(c),
1990
+ indeterminate: !0,
1991
+ onClick: (S) => gl(c)
1992
+ }, null, 8, ["label", "model-value", "onClick"]),
1993
+ (H(!0), me(Le, null, ht(kt.value[j], (S) => (H(), me(Le, {
1994
+ key: S.value
1995
+ }, [
1996
+ S.label && S.label.length > 110 ? (H(), Fe(V, {
1997
+ key: 0,
1998
+ placement: "right",
1999
+ "hide-arrow": !0,
2000
+ "z-index": 2e3
2001
+ }, {
2002
+ content: re(() => [
2003
+ nt(fe(S.label), 1)
2004
+ ]),
2005
+ default: re(() => [
2006
+ q("div", wn, [
2007
+ L(b, {
2008
+ label: Il(S.label, 110),
2009
+ "has-checkbox": !0,
2010
+ "model-value": Ot(c, S.value),
2011
+ class: Gt([
2012
+ "flex-1 text-left",
2013
+ { "bg-gray-200": S.available === !1 }
2014
+ ]),
2015
+ onClick: () => It(c, S.value)
2016
+ }, null, 8, ["label", "model-value", "class", "onClick"])
2017
+ ])
2018
+ ]),
2019
+ _: 2
2020
+ }, 1024)) : (H(), Fe(b, {
2021
+ key: 1,
2022
+ label: S.label,
2023
+ "has-checkbox": !0,
2024
+ "model-value": Ot(c, S.value),
2025
+ class: Gt(["flex-1 text-left", { "bg-gray-100": S.available === !1 }]),
2026
+ onClick: () => It(c, S.value)
2027
+ }, null, 8, ["label", "model-value", "class", "onClick"]))
2028
+ ], 64))), 128)),
2029
+ kt.value[j].length < c.options.length && !c.search ? (H(), Fe(b, {
2030
+ key: 0,
2031
+ class: "fm-typo-en-body-md-400 -ml-2",
2032
+ label: T(s)("report.section.filter.loadMore"),
2033
+ onClick: dt((S) => Sl(c), ["stop"]),
2034
+ icon: "autorenew"
2035
+ }, null, 8, ["label", "onClick"])) : bt("", !0)
2036
+ ])
2037
+ ]),
2038
+ q("div", {
2039
+ class: "px-12 py-2 flex items-center gap-2 cursor-pointer hover:bg-fm-color-neutral-50 transition-colors",
2040
+ onClick: (S) => _l(c)
2041
+ }, [
2042
+ L(y, {
2043
+ name: c.showAdvanced ? "keyboard_arrow_up" : "keyboard_arrow_down",
2044
+ size: "md",
2045
+ class: ""
2046
+ }, null, 8, ["name"]),
2047
+ q("span", Tn, fe(T(s)("report.section.filter.advanced")), 1)
2048
+ ], 8, Dn),
2049
+ L($),
2050
+ c.showAdvanced ? (H(), me("div", Vn, [
2051
+ q("div", Cn, [
2052
+ q("div", Nn, [
2053
+ L(E, {
2054
+ "model-value": c.keepSelection,
2055
+ label: T(s)("report.section.filter.keepSelection"),
2056
+ labelPlacement: "right",
2057
+ "onUpdate:modelValue": () => Rl(c)
2058
+ }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
2059
+ L(V, {
2060
+ placement: "top",
2061
+ "z-index": 2e3
2062
+ }, {
2063
+ content: re(() => [
2064
+ q("div", On, fe(T(s)("report.section.filter.keepSelectionTooltip")), 1)
2065
+ ]),
2066
+ default: re(() => [
2067
+ L(y, {
2068
+ name: "info",
2069
+ size: "md",
2070
+ class: "text-fm-color-primary"
2071
+ })
2072
+ ]),
2073
+ _: 1
2074
+ })
2075
+ ])
2076
+ ])
2077
+ ])) : bt("", !0),
2078
+ q("div", kn, [
2079
+ L(A, {
2080
+ variant: "tertiary",
2081
+ label: T(s)("report.common.cancel"),
2082
+ onClick: dt((S) => kl(c), ["stop"])
2083
+ }, null, 8, ["label", "onClick"]),
2084
+ L(A, {
2085
+ color: "primary",
2086
+ onClick: dt((S) => Ol(c), ["stop"]),
2087
+ label: T(s)("report.common.apply")
2088
+ }, null, 8, ["onClick", "label"])
2089
+ ])
2090
+ ], 64)) : (H(), Fe(zl, {
2091
+ key: 2,
2092
+ title: ct(c) ? T(s)("report.messages.noWidgetsApplied") : void 0,
2093
+ "sub-title": ct(c) ? T(s)("report.messages.assignWidgetsToUseThisFilter") : void 0
2094
+ }, null, 8, ["title", "sub-title"]))
2095
+ ], 4)
2096
+ ]),
2097
+ _: 2
2098
+ }, 1032, ["open"]))
2099
+ ]))), 128)),
2100
+ Ut(e.$slots, "default")
2101
+ ]);
2102
+ };
2103
+ }
2104
+ });
2105
+ export {
2106
+ xe as I,
2107
+ Jt as R,
2108
+ Jn as _,
2109
+ jn as a,
2110
+ Qn as b,
2111
+ Kn as c,
2112
+ Mn as d,
2113
+ Wt as e,
2114
+ fn as f,
2115
+ qn as g,
2116
+ jl as h,
2117
+ Pn as i,
2118
+ nn as j,
2119
+ Un as k,
2120
+ Wn as l,
2121
+ Bn as m,
2122
+ tn as q,
2123
+ zn as r,
2124
+ an as s,
2125
+ zt as t,
2126
+ Yt as u
2127
+ };