@feedmepos/mf-report 5.26.9 → 5.27.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 (27) hide show
  1. package/dist/{App-B9jsVITx.js → App-BVm7F3co.js} +4 -4
  2. package/dist/{DateRangeSelect.vue_vue_type_script_setup_true_lang-D_dvvhqx.js → DateRangeSelect.vue_vue_type_script_setup_true_lang-_xN_Strd.js} +1 -1
  3. package/dist/{Default.vue_vue_type_script_setup_true_lang-BO7p8Mq_.js → Default.vue_vue_type_script_setup_true_lang-DFfPxCRx.js} +1 -1
  4. package/dist/{DynamicWidget.vue_vue_type_script_setup_true_lang-CYk44w69.js → DynamicWidget.vue_vue_type_script_setup_true_lang-Du46mNK_.js} +1663 -1642
  5. package/dist/{GlobalFilterSelect.vue_vue_type_script_setup_true_lang-DXusNtLu.js → GlobalFilterSelect.vue_vue_type_script_setup_true_lang-DvHJgIIm.js} +1448 -1359
  6. package/dist/{InsightView-DHWIOLCi.js → InsightView-BDQtiuUV.js} +4 -4
  7. package/dist/{Integration-K4zEQ9xo.js → Integration-BFvC5yD4.js} +3 -3
  8. package/dist/{Integrations-KyNsy5yd.js → Integrations-CaJP86Sf.js} +2 -2
  9. package/dist/{Layout-BGGSx2Bv.js → Layout-BTLiqkeM.js} +1 -1
  10. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-gFC74Kpl.js → MenuTab.vue_vue_type_script_setup_true_lang-CVfKW6b8.js} +4 -4
  11. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-DGY2NPZT.js → NavigationTab.vue_vue_type_script_setup_true_lang-DVtWhfhI.js} +3 -3
  12. package/dist/OverviewView-Cmm7K0gk.js +62 -0
  13. package/dist/{Report-B2ypN6sG.js → Report-BpKD0ID4.js} +3 -3
  14. package/dist/ReportEditor-CFWTQJCY.js +1812 -0
  15. package/dist/{ReportView-X8UyQe1R.js → ReportView--Bk9WgOn.js} +93 -93
  16. package/dist/{Setting-BIYwCHo7.js → Setting-B6jvJDeO.js} +6 -6
  17. package/dist/{Template-B7ywcdv7.js → Template-CnE3UZvX.js} +3 -3
  18. package/dist/{TileEditor-D0mCJNfG.js → TileEditor-DNCRKHLE.js} +1620 -1600
  19. package/dist/TileGrid.vue_vue_type_script_setup_true_lang-WLjTXh0g.js +143 -0
  20. package/dist/{TransitionFade-BGQPx3Xb.js → TransitionFade-Chjh8CeF.js} +164 -162
  21. package/dist/{app-T2BFgO-M.js → app-CZUC85Jj.js} +80 -24
  22. package/dist/app.js +1 -1
  23. package/dist/style.css +1 -1
  24. package/dist/{useRestaurantPermission-DV8KEXT1.js → useRestaurantPermission-CrybQQkI.js} +1 -1
  25. package/package.json +1 -1
  26. package/dist/OverviewView-pLaPV8q1.js +0 -62
  27. package/dist/ReportEditor-BSIMLrn7.js +0 -1594
@@ -0,0 +1,1812 @@
1
+ import { defineComponent as Ve, mergeModels as Ie, useModel as Re, ref as P, computed as p, resolveComponent as F, createBlock as k, openBlock as u, withCtx as b, createElementVNode as g, createVNode as n, unref as l, normalizeClass as Pe, createTextVNode as Ae, toDisplayString as z, createElementBlock as I, Fragment as Ce, renderSlot as pt, createCommentVNode as L, watch as we, renderList as Ee, onMounted as vt, onUnmounted as Tt, resolveDynamicComponent as $t, isRef as ft, normalizeStyle as lt } from "vue";
2
+ import { W as St, g as Dt, _ as Ot, a as It, e as Be, d as gt, b as bt, i as Rt, S as We, T as Nt, c as Ut } from "./TransitionFade-Chjh8CeF.js";
3
+ import { C as De, D as fe, c as qe, g as Bt, u as at, M as yt, r as Mt, d as st, n as qt, e as Et, f as Pt, h as Lt, i as zt, a as At, j as Ye, k as Xe, m as Gt, Q as He, o as Wt, l as Ht, b as ut, p as jt } from "./GlobalFilterSelect.vue_vue_type_script_setup_true_lang-DvHJgIIm.js";
4
+ import { storeToRefs as Me } from "pinia";
5
+ import { useRouter as nt, useRoute as rt } from "vue-router";
6
+ import { useBreakpoints as je, useSnackbar as ht, FmButtonColorThemeVariant as Oe } from "@feedmepos/ui-library";
7
+ import { u as it } from "./message-dialog-UoMWOnil.js";
8
+ import { u as Le, a as Jt } from "./vue-i18n-DVWuTfed.js";
9
+ import { r as Ge } from "./i18n-CI_sQ5d_.js";
10
+ import { _ as Ze } from "./TileGrid.vue_vue_type_script_setup_true_lang-WLjTXh0g.js";
11
+ import { a as et, _ as tt } from "./SelectComponent.vue_vue_type_script_setup_true_lang-BL1jpiXN.js";
12
+ import { useCoreStore as Kt } from "@feedmepos/mf-common";
13
+ import { u as Qt, a as Yt } from "./app-CZUC85Jj.js";
14
+ import { d as Xt } from "./DateRangeSelect.vue_vue_type_script_setup_true_lang-_xN_Strd.js";
15
+ const Zt = /* @__PURE__ */ Ve({
16
+ __name: "WidgetDialog",
17
+ props: /* @__PURE__ */ Ie({
18
+ isOpen: { type: Boolean }
19
+ }, {
20
+ modelValue: {},
21
+ modelModifiers: {}
22
+ }),
23
+ emits: /* @__PURE__ */ Ie(["update:isOpen"], ["update:modelValue"]),
24
+ setup(R, { emit: r }) {
25
+ const { t: a } = Le(), { breakpoints: m } = je(), v = Re(R, "modelValue"), f = R, M = r;
26
+ function le() {
27
+ M("update:isOpen", !1);
28
+ }
29
+ function V() {
30
+ y.value && (v.value = y.value, y.value = void 0, M("update:isOpen", !1));
31
+ }
32
+ const y = P(), x = p(() => !y.value);
33
+ return (N, G) => {
34
+ const q = F("FmButton"), A = F("FmDialog");
35
+ return u(), k(A, {
36
+ "model-value": f.isOpen
37
+ }, {
38
+ "dialog-header": b(() => [
39
+ Ae(z(l(a)("report.widget.type")), 1)
40
+ ]),
41
+ default: b(() => [
42
+ n(St, {
43
+ modelValue: y.value,
44
+ "onUpdate:modelValue": G[0] || (G[0] = ($) => y.value = $),
45
+ class: Pe(`grid ${l(m).lg || l(m).md ? "grid-cols-3 gap-3" : "grid-cols-2 gap-3"}`),
46
+ "child-class": "p-[8px] flex flex-col"
47
+ }, null, 8, ["modelValue", "class"])
48
+ ]),
49
+ "dialog-footer": b(() => [
50
+ G[1] || (G[1] = g("div", { class: "grow" }, null, -1)),
51
+ n(q, {
52
+ label: l(a)("report.common.cancel"),
53
+ variant: "tertiary",
54
+ onClick: le
55
+ }, null, 8, ["label"]),
56
+ n(q, {
57
+ label: l(a)("report.common.confirm"),
58
+ disabled: x.value,
59
+ onClick: V
60
+ }, null, 8, ["label", "disabled"])
61
+ ]),
62
+ _: 1
63
+ }, 8, ["model-value"]);
64
+ };
65
+ }
66
+ }), el = { class: "fm-typo-en-body-lg-600" }, ot = /* @__PURE__ */ Ve({
67
+ __name: "ReportEditorTabHeader",
68
+ props: /* @__PURE__ */ Ie({
69
+ icon: {
70
+ type: String,
71
+ required: !0
72
+ }
73
+ }, {
74
+ modelValue: { type: Boolean, required: !0, default: !1 },
75
+ modelModifiers: {}
76
+ }),
77
+ emits: ["update:modelValue"],
78
+ setup(R) {
79
+ const { t: r } = Le(), a = Re(R, "modelValue"), m = R;
80
+ return (v, f) => {
81
+ const M = F("FmIcon");
82
+ return u(), I("div", {
83
+ class: "px-6 py-16 flex items-center gap-2 bg-fm-color-neutral-white border cursor-pointer",
84
+ onClick: f[0] || (f[0] = (le) => a.value = !a.value)
85
+ }, [
86
+ g("p", el, z(l(r)("report.editor.customizeReport")), 1),
87
+ f[1] || (f[1] = g("div", { class: "grow" }, null, -1)),
88
+ n(M, {
89
+ name: m.icon
90
+ }, null, 8, ["name"])
91
+ ]);
92
+ };
93
+ }
94
+ }), tl = /* @__PURE__ */ Ve({
95
+ __name: "ReportEditorTabDesktop",
96
+ props: {
97
+ modelValue: { required: !0, default: !1 },
98
+ modelModifiers: {}
99
+ },
100
+ emits: ["update:modelValue"],
101
+ setup(R) {
102
+ const r = Re(R, "modelValue");
103
+ return (a, m) => (u(), I(Ce, null, [
104
+ n(ot, {
105
+ modelValue: r.value,
106
+ "onUpdate:modelValue": m[0] || (m[0] = (v) => r.value = v),
107
+ icon: "keyboard_double_arrow_left"
108
+ }, null, 8, ["modelValue"]),
109
+ pt(a.$slots, "default")
110
+ ], 64));
111
+ }
112
+ }), ll = /* @__PURE__ */ Ve({
113
+ __name: "ReportEditorTabMobile",
114
+ props: {
115
+ modelValue: { required: !0, default: !1 },
116
+ modelModifiers: {}
117
+ },
118
+ emits: ["update:modelValue"],
119
+ setup(R) {
120
+ const r = Re(R, "modelValue");
121
+ return (a, m) => {
122
+ const v = F("FmTopSheet"), f = F("FmCard");
123
+ return u(), k(f, { class: "fixed bottom-0 w-full" }, {
124
+ default: b(() => [
125
+ n(ot, {
126
+ modelValue: r.value,
127
+ "onUpdate:modelValue": m[0] || (m[0] = (M) => r.value = M),
128
+ icon: "keyboard_double_arrow_up"
129
+ }, null, 8, ["modelValue"]),
130
+ n(v, {
131
+ modelValue: r.value,
132
+ "onUpdate:modelValue": m[2] || (m[2] = (M) => r.value = M),
133
+ "fullscreen-size": "sm"
134
+ }, {
135
+ default: b(() => [
136
+ n(ot, {
137
+ modelValue: r.value,
138
+ "onUpdate:modelValue": m[1] || (m[1] = (M) => r.value = M),
139
+ icon: "keyboard_double_arrow_down"
140
+ }, null, 8, ["modelValue"]),
141
+ r.value ? pt(a.$slots, "default", { key: 0 }) : L("", !0)
142
+ ]),
143
+ _: 3
144
+ }, 8, ["modelValue"])
145
+ ]),
146
+ _: 3
147
+ });
148
+ };
149
+ }
150
+ }), ol = {
151
+ key: 2,
152
+ class: "flex flex-col gap-3 mt-2 border border-neutral-300 p-3"
153
+ }, al = { class: "grid grid-cols-1 gap-2 rounded-md border border-neutral-300 p-2 sm:grid-cols-[1.3fr_1fr_1fr_auto] sm:items-end" }, nl = {
154
+ key: 0,
155
+ class: "flex justify-end sm:pb-[2px]"
156
+ }, rl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, il = { class: "pl-1" }, sl = {
157
+ key: 0,
158
+ class: "flex justify-end sm:pb-[2px]"
159
+ }, ul = {
160
+ key: 4,
161
+ class: "flex flex-col gap-2"
162
+ }, dl = /* @__PURE__ */ Ve({
163
+ __name: "GlobalFilterDialog",
164
+ props: /* @__PURE__ */ Ie({
165
+ schemas: {
166
+ type: Array,
167
+ default: () => []
168
+ },
169
+ tiles: {
170
+ type: Array,
171
+ required: !0
172
+ }
173
+ }, {
174
+ globalFilter: {
175
+ default: () => null
176
+ },
177
+ globalFilterModifiers: {},
178
+ isOpen: { type: Boolean, default: () => !1, required: !0 },
179
+ isOpenModifiers: {}
180
+ }),
181
+ emits: ["update:globalFilter", "update:isOpen"],
182
+ setup(R) {
183
+ const { t: r, te: a } = Le(), m = Re(R, "globalFilter"), v = Re(R, "isOpen"), f = ht(), M = R, le = P(""), V = P(), y = P(), x = P(), N = P([]), G = P([]), q = P(""), A = P(!1), $ = P(!1), U = P([]), B = P([]), se = P(De.Equal);
184
+ function me(t) {
185
+ return JSON.parse(JSON.stringify(t));
186
+ }
187
+ function K(t, e) {
188
+ return { hour: t, minute: e };
189
+ }
190
+ function w(t) {
191
+ return t ? `${String(t.hour).padStart(2, "0")}:${String(t.minute).padStart(2, "0")}` : null;
192
+ }
193
+ function Fe(t) {
194
+ if (!t) return null;
195
+ const [e, h] = t.split(":").map(Number);
196
+ return Number.isNaN(e) || Number.isNaN(h) ? null : { hour: e, minute: h };
197
+ }
198
+ const ce = p(() => y.value ? !(y.value.type === fe.Timestamp && x.value === qe.DateTime) : !1), oe = p(
199
+ () => {
200
+ var t;
201
+ return ((t = y.value) == null ? void 0 : t.type) === fe.Timestamp && x.value === qe.TimeOfDay;
202
+ }
203
+ ), pe = p(() => {
204
+ var t;
205
+ return (((t = y.value) == null ? void 0 : t.filterOperators) ?? []).filter((e) => e !== De.And && e !== De.Or).map((e) => ({
206
+ label: r(`report.section.comparisonOperator.${e}`),
207
+ value: e
208
+ }));
209
+ });
210
+ function ge() {
211
+ var e;
212
+ const t = (e = pe.value[0]) == null ? void 0 : e.value;
213
+ return t || (y.value ? ve(y.value.type, x.value ?? null) : De.Equal);
214
+ }
215
+ function he(t) {
216
+ if (y.value)
217
+ return Bt({
218
+ operator: t ?? ge(),
219
+ dataType: y.value.type,
220
+ dimensionOption: y.value.type === fe.Timestamp ? x.value ?? null : null,
221
+ t: r
222
+ });
223
+ }
224
+ function E(t, e) {
225
+ if (typeof (e == null ? void 0 : e.default) == "boolean" || t.length > 0 && t.every((C) => typeof C == "boolean")) {
226
+ const C = t.reduce((D, X) => (typeof X == "boolean" && D.push(X), D), []);
227
+ if (e)
228
+ for (e.fixed && C.splice(e.count); C.length < e.count; )
229
+ C.push(typeof e.default == "boolean" ? e.default : !1);
230
+ return C;
231
+ }
232
+ const _ = t.reduce((C, D) => (typeof D == "string" && C.push(D), C), []);
233
+ if (e)
234
+ for (e.fixed && _.splice(e.count); _.length < e.count; )
235
+ _.push(typeof e.default == "string" ? e.default : "");
236
+ return _;
237
+ }
238
+ function W(t = se.value) {
239
+ const e = he(t), h = E(
240
+ e ? Array(e.count).fill(e.default) : [],
241
+ e
242
+ );
243
+ return {
244
+ label: "",
245
+ operator: t,
246
+ values: h
247
+ };
248
+ }
249
+ function Z() {
250
+ return {
251
+ name: "",
252
+ startTime: K(0, 0),
253
+ endTime: K(23, 59)
254
+ };
255
+ }
256
+ function be() {
257
+ if (!(!ce.value || !$.value)) {
258
+ if (oe.value) {
259
+ B.value.length === 0 && (B.value = [Z()]);
260
+ return;
261
+ }
262
+ U.value.length === 0 && (U.value = [W()]);
263
+ }
264
+ }
265
+ function xe() {
266
+ var h, _, C;
267
+ const t = me(((h = m.value) == null ? void 0 : h.customOptions) ?? []), e = me(((_ = m.value) == null ? void 0 : _.customTimeRanges) ?? []);
268
+ se.value = ((C = t[0]) == null ? void 0 : C.operator) ?? ge(), $.value = t.length > 0 || e.length > 0, U.value = t, B.value = e, be();
269
+ }
270
+ function ee(t) {
271
+ se.value = t, U.value = U.value.map((e, h) => {
272
+ const _ = U.value[h];
273
+ if (!_)
274
+ return W(t);
275
+ const C = he(t), D = E(
276
+ Array.isArray(_.values) ? [..._.values] : [],
277
+ C
278
+ );
279
+ return {
280
+ ..._,
281
+ operator: t,
282
+ values: D
283
+ };
284
+ });
285
+ }
286
+ function ke() {
287
+ U.value = [...U.value, W()];
288
+ }
289
+ function ae(t) {
290
+ U.value.length <= 1 || (U.value = U.value.filter((e, h) => h !== t));
291
+ }
292
+ function Te() {
293
+ B.value = [...B.value, Z()];
294
+ }
295
+ function Ne(t) {
296
+ B.value.length <= 1 || (B.value = B.value.filter(
297
+ (e, h) => h !== t
298
+ ));
299
+ }
300
+ function Ue(t, e, h) {
301
+ const _ = B.value[t];
302
+ _ && (B.value[t] = {
303
+ ..._,
304
+ [e]: Fe(h)
305
+ });
306
+ }
307
+ function $e(t) {
308
+ return t.length === 0 || t.some((e) => e == null || e === "");
309
+ }
310
+ function Se() {
311
+ if (!$.value) return !0;
312
+ if (oe.value) {
313
+ const h = B.value.map((C) => C.name.trim()).filter(Boolean);
314
+ return B.value.some(
315
+ (C) => !C.name.trim() || !C.startTime || !C.endTime
316
+ ) ? (f.open({
317
+ message: r("report.section.filter.invalidCustomTimeRange"),
318
+ type: "error"
319
+ }), !1) : new Set(h).size !== h.length ? (f.open({
320
+ message: r("report.section.filter.customTimeRangeNamesMustBeUnique"),
321
+ type: "error"
322
+ }), !1) : !0;
323
+ }
324
+ const t = U.value.map((h) => h.label.trim()).filter(Boolean);
325
+ return U.value.some(
326
+ (h) => !h.label.trim() || $e(h.values)
327
+ ) ? (f.open({ message: r("report.section.filter.invalidCustomOption"), type: "error" }), !1) : new Set(t).size !== t.length ? (f.open({
328
+ message: r("report.section.filter.customOptionLabelsMustBeUnique"),
329
+ type: "error"
330
+ }), !1) : !0;
331
+ }
332
+ we(v, (t) => {
333
+ var e, h, _, C, D, X, re;
334
+ t && (le.value = ((e = m.value) == null ? void 0 : e.label) || "", V.value = M.schemas.find(
335
+ (ie) => {
336
+ var j;
337
+ return ie.name === ((j = m.value) == null ? void 0 : j.schemaName);
338
+ }
339
+ ), y.value = (h = c.value.find(
340
+ (ie) => {
341
+ var j;
342
+ return ie.value.name === ((j = m.value) == null ? void 0 : j.name);
343
+ }
344
+ )) == null ? void 0 : h.value, x.value = (_ = m.value) == null ? void 0 : _.option, N.value = ((C = m.value) == null ? void 0 : C.tileIds) || [], G.value = ((D = m.value) == null ? void 0 : D.filters) || [], A.value = !!((X = m.value) != null && X.dataFormula), q.value = ((re = m.value) == null ? void 0 : re.dataFormula) || "", xe());
345
+ }), we($, (t) => {
346
+ var e;
347
+ t && (se.value = ((e = U.value[0]) == null ? void 0 : e.operator) ?? ge(), be());
348
+ }), we(ce, (t) => {
349
+ if (!t) {
350
+ $.value = !1, U.value = [], B.value = [];
351
+ return;
352
+ }
353
+ be();
354
+ }), we(oe, () => {
355
+ be();
356
+ }), we(pe, (t) => {
357
+ var h;
358
+ const e = (h = t[0]) == null ? void 0 : h.value;
359
+ e && (t.some((_) => _.value === se.value) || ee(e));
360
+ });
361
+ const i = p(
362
+ () => M.schemas.map((t) => ({
363
+ label: t.label || t.name,
364
+ value: t
365
+ }))
366
+ ), c = p(() => {
367
+ var t;
368
+ return (((t = V.value) == null ? void 0 : t.fields) || []).filter((e) => e.type !== fe.Numeric).map((e) => ({
369
+ label: e.label || e.name,
370
+ value: e
371
+ }));
372
+ }), H = p(() => {
373
+ var t;
374
+ return ((t = y.value) == null ? void 0 : t.type) !== fe.Timestamp ? [] : Dt(r);
375
+ }), ue = p(() => M.tiles.reduce((t, e, h) => {
376
+ var D, X, re, ie, j;
377
+ const _ = ((D = e.widget) == null ? void 0 : D.config.schemaNames) ?? [], C = (((X = e.widget) == null ? void 0 : X.config.joinDatasources) ?? []).flatMap(
378
+ (ze) => ze.schemaNames ?? []
379
+ );
380
+ return [..._, ...C].includes(((re = V.value) == null ? void 0 : re.name) || "") && t.push({
381
+ label: (j = (ie = e.widget) == null ? void 0 : ie.title) != null && j.trim() ? e.widget.title : `Widget ${h + 1}`,
382
+ value: e.id
383
+ }), t;
384
+ }, [])), te = p(
385
+ () => M.schemas.flatMap(
386
+ (t) => (t.fields ?? []).map((e) => ({
387
+ ...e,
388
+ labels: [
389
+ Ge(r, a, t.label, "schema"),
390
+ Ge(r, a, e.label || e.name, "other")
391
+ ]
392
+ }))
393
+ )
394
+ );
395
+ function Q(t) {
396
+ var e;
397
+ t.name !== ((e = V.value) == null ? void 0 : e.name) && (V.value = t, y.value = void 0, se.value = De.Equal, $.value = !1, U.value = [], B.value = []);
398
+ }
399
+ function ye(t) {
400
+ y.value = t, x.value = t.type === fe.Timestamp ? qe.DateTime : void 0, se.value = ge(), $.value = !1, U.value = [], B.value = [];
401
+ }
402
+ function ve(t, e) {
403
+ switch (t) {
404
+ case fe.Timestamp:
405
+ return e === qe.DateTime || e === qe.TimeOfDay ? De.Between : De.Equal;
406
+ case fe.Bool:
407
+ case fe.String:
408
+ case fe.Numeric:
409
+ return De.Equal;
410
+ default:
411
+ throw new Error(`Unsupported data type: ${t}`);
412
+ }
413
+ }
414
+ function Y() {
415
+ if (!V.value) {
416
+ f.open({ message: r("report.section.filter.invalidSchema"), type: "error" });
417
+ return;
418
+ }
419
+ if (!y.value) {
420
+ f.open({ message: r("report.section.filter.invalidDimension"), type: "error" });
421
+ return;
422
+ }
423
+ const t = G.value.filter((_) => _ ? !i.value.some((D) => D.value.name === _.schemaName) : !0);
424
+ if (t.length > 0) {
425
+ const _ = t.filter((D) => !!D).map((D) => D.schemaName), C = t.some((D) => !D) ? `, ${r("report.section.filter.unknownFilters")}` : "";
426
+ f.open({
427
+ message: r("report.section.filter.invalidFiltersSchemaNotFound", {
428
+ schemas: _.join(", "),
429
+ unknownFiltersSuffix: C
430
+ }),
431
+ type: "error"
432
+ });
433
+ return;
434
+ }
435
+ if (!Se())
436
+ return;
437
+ const e = $.value && !oe.value ? U.value.map((_) => ({
438
+ label: _.label.trim(),
439
+ operator: _.operator ?? ge(),
440
+ values: E(
441
+ [..._.values],
442
+ he(_.operator)
443
+ )
444
+ })) : void 0, h = $.value && oe.value ? B.value.map((_) => ({
445
+ name: _.name.trim(),
446
+ startTime: _.startTime,
447
+ endTime: _.endTime
448
+ })) : void 0;
449
+ m.value = {
450
+ schemaName: V.value.name,
451
+ name: y.value.name,
452
+ label: le.value,
453
+ operator: ve(
454
+ y.value.type,
455
+ y.value.type === fe.Timestamp ? x.value ?? qe.DateTime : null
456
+ ),
457
+ option: y.value.type === fe.Timestamp ? x.value : null,
458
+ values: [],
459
+ tileIds: [...N.value],
460
+ filters: me(G.value),
461
+ dataFormula: A.value ? q.value : void 0,
462
+ customOptions: e,
463
+ customTimeRanges: h
464
+ }, v.value = !1;
465
+ }
466
+ function _e() {
467
+ v.value = !1;
468
+ }
469
+ const T = p(() => {
470
+ var t;
471
+ return [
472
+ (t = V.value) == null ? void 0 : t.name,
473
+ ...G.value.map((e) => e.schemaName)
474
+ ];
475
+ });
476
+ function de(t) {
477
+ var D, X, re, ie;
478
+ const e = M.tiles.find((j) => j.id === t.value), h = ((X = (D = e == null ? void 0 : e.widget) == null ? void 0 : D.config) == null ? void 0 : X.schemaNames) ?? [], _ = (((ie = (re = e == null ? void 0 : e.widget) == null ? void 0 : re.config) == null ? void 0 : ie.joinDatasources) ?? []).flatMap(
479
+ (j) => j.schemaNames ?? []
480
+ ), C = [...h, ..._];
481
+ return T.value.filter((j) => !!j).some((j) => !C.includes(j));
482
+ }
483
+ return (t, e) => {
484
+ const h = F("FmTextField"), _ = F("FmSelect"), C = F("FmCheckbox"), D = F("FmTimePicker"), X = F("FmButton"), re = F("FmTextarea"), ie = F("FmLabel"), j = F("FmIcon"), ze = F("FmTooltip"), s = F("FmForm"), o = F("FmDialog");
485
+ return u(), k(o, {
486
+ modelValue: v.value,
487
+ "onUpdate:modelValue": e[11] || (e[11] = (O) => v.value = O),
488
+ overlay: !0,
489
+ "z-index": 10
490
+ }, {
491
+ "dialog-header": b(() => [
492
+ Ae(z(l(r)("report.section.filter.globalFilter")), 1)
493
+ ]),
494
+ default: b(() => [
495
+ n(s, {
496
+ ref: "form",
497
+ class: "flex flex-col gap-2 w-[490px]"
498
+ }, {
499
+ default: b(() => {
500
+ var O;
501
+ return [
502
+ n(h, {
503
+ modelValue: le.value,
504
+ "onUpdate:modelValue": e[0] || (e[0] = (d) => le.value = d),
505
+ placeholder: l(r)("report.section.filter.displayName"),
506
+ label: l(r)("report.section.filter.displayName"),
507
+ class: "mb-2"
508
+ }, null, 8, ["modelValue", "placeholder", "label"]),
509
+ n(et, {
510
+ "model-value": V.value,
511
+ items: i.value,
512
+ placeholder: l(r)("report.section.schema.title"),
513
+ label: l(r)("report.section.schema.title"),
514
+ "onUpdate:modelValue": e[1] || (e[1] = (d) => Q(d))
515
+ }, null, 8, ["model-value", "items", "placeholder", "label"]),
516
+ n(et, {
517
+ "model-value": y.value,
518
+ items: c.value,
519
+ placeholder: l(r)("report.section.dimension.title"),
520
+ label: l(r)("report.section.dimension.title"),
521
+ "onUpdate:modelValue": e[2] || (e[2] = (d) => ye(d))
522
+ }, null, 8, ["model-value", "items", "placeholder", "label"]),
523
+ ((O = y.value) == null ? void 0 : O.type) === l(fe).Timestamp ? (u(), k(_, {
524
+ key: 0,
525
+ modelValue: x.value,
526
+ "onUpdate:modelValue": e[3] || (e[3] = (d) => x.value = d),
527
+ items: H.value,
528
+ placeholder: l(r)("report.section.filter.timeFormatter"),
529
+ label: l(r)("report.section.filter.timeFormatter")
530
+ }, null, 8, ["modelValue", "items", "placeholder", "label"])) : L("", !0),
531
+ ce.value ? (u(), k(C, {
532
+ key: 1,
533
+ modelValue: $.value,
534
+ "onUpdate:modelValue": e[4] || (e[4] = (d) => $.value = d),
535
+ label: l(r)("report.section.filter.customOptions"),
536
+ value: !0
537
+ }, null, 8, ["modelValue", "label"])) : L("", !0),
538
+ ce.value && $.value ? (u(), I("div", ol, [
539
+ oe.value ? (u(!0), I(Ce, { key: 0 }, Ee(B.value, (d, J) => (u(), I("div", {
540
+ key: `custom-time-range-${J}`,
541
+ class: "flex flex-col gap-2"
542
+ }, [
543
+ g("div", al, [
544
+ n(h, {
545
+ modelValue: d.name,
546
+ "onUpdate:modelValue": (ne) => d.name = ne,
547
+ label: l(r)("report.section.filter.label")
548
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
549
+ n(D, {
550
+ "model-value": w(d.startTime),
551
+ label: l(r)("report.date.startingTime"),
552
+ "onUpdate:modelValue": (ne) => Ue(J, "startTime", ne)
553
+ }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
554
+ n(D, {
555
+ "model-value": w(d.endTime),
556
+ label: l(r)("report.date.endingTime"),
557
+ "onUpdate:modelValue": (ne) => Ue(J, "endTime", ne)
558
+ }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
559
+ B.value.length > 1 ? (u(), I("div", nl, [
560
+ n(X, {
561
+ icon: "delete",
562
+ variant: "tertiary",
563
+ onClick: (ne) => Ne(J)
564
+ }, null, 8, ["onClick"])
565
+ ])) : L("", !0)
566
+ ])
567
+ ]))), 128)) : (u(), I(Ce, { key: 1 }, [
568
+ g("p", rl, z(l(r)("report.section.filter.operator")), 1),
569
+ pe.value.length > 0 ? (u(), k(et, {
570
+ key: 0,
571
+ "model-value": se.value,
572
+ items: pe.value,
573
+ placeholder: l(r)("report.section.filter.operator"),
574
+ "onUpdate:modelValue": e[5] || (e[5] = (d) => ee(d))
575
+ }, null, 8, ["model-value", "items", "placeholder"])) : L("", !0),
576
+ (u(!0), I(Ce, null, Ee(U.value, (d, J) => (u(), I("div", {
577
+ key: `custom-option-${J}`,
578
+ class: "flex flex-col gap-2"
579
+ }, [
580
+ g("div", {
581
+ class: Pe([
582
+ "grid grid-cols-1 gap-2 p-2 sm:items-end text-fm-color-typo-primary fm-typo-en-body-lg-600 border-neutral-300 rounded-md border",
583
+ "sm:grid-cols-[1fr_1.6fr_auto]"
584
+ ])
585
+ }, [
586
+ g("span", il, z(l(r)("report.section.filter.label")), 1),
587
+ n(h, {
588
+ modelValue: d.label,
589
+ "onUpdate:modelValue": (ne) => d.label = ne
590
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
591
+ (u(), k(Ot, {
592
+ key: `custom-option-value-${J}-${d.operator ?? ""}-${x.value ?? ""}`,
593
+ modelValue: d.values,
594
+ "onUpdate:modelValue": (ne) => d.values = ne,
595
+ config: he(d.operator),
596
+ option: x.value
597
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "config", "option"])),
598
+ U.value.length > 1 ? (u(), I("div", sl, [
599
+ n(X, {
600
+ icon: "delete",
601
+ variant: "tertiary",
602
+ onClick: (ne) => ae(J)
603
+ }, null, 8, ["onClick"])
604
+ ])) : L("", !0)
605
+ ])
606
+ ]))), 128))
607
+ ], 64)),
608
+ n(X, {
609
+ class: "w-full",
610
+ variant: "primary",
611
+ icon: "add",
612
+ "icon-position": "prepend",
613
+ onClick: e[6] || (e[6] = (d) => oe.value ? Te() : ke())
614
+ })
615
+ ])) : L("", !0),
616
+ n(C, {
617
+ modelValue: A.value,
618
+ "onUpdate:modelValue": e[7] || (e[7] = (d) => A.value = d),
619
+ label: l(r)("report.section.filter.advance"),
620
+ value: !0
621
+ }, null, 8, ["modelValue", "label"]),
622
+ A.value ? (u(), k(re, {
623
+ key: 3,
624
+ modelValue: q.value,
625
+ "onUpdate:modelValue": e[8] || (e[8] = (d) => q.value = d),
626
+ placeholder: l(r)("report.section.filter.dataFormula")
627
+ }, null, 8, ["modelValue", "placeholder"])) : L("", !0),
628
+ n(It, {
629
+ modelValue: G.value,
630
+ "onUpdate:modelValue": e[9] || (e[9] = (d) => G.value = d),
631
+ options: te.value
632
+ }, null, 8, ["modelValue", "options"]),
633
+ n(ie, { class: "mt-2 fm-typo-en-body-lg-600" }, {
634
+ default: b(() => [
635
+ Ae(z(l(r)("report.section.filter.applyWidget")), 1)
636
+ ]),
637
+ _: 1
638
+ }),
639
+ R.tiles.length > 0 ? (u(), I("div", ul, [
640
+ (u(!0), I(Ce, null, Ee(ue.value, (d) => (u(), I("div", {
641
+ key: d.value,
642
+ class: "flex items-center"
643
+ }, [
644
+ n(C, {
645
+ modelValue: N.value,
646
+ "onUpdate:modelValue": e[10] || (e[10] = (J) => N.value = J),
647
+ label: d.label,
648
+ value: d.value
649
+ }, null, 8, ["modelValue", "label", "value"]),
650
+ de(d) ? (u(), k(ze, {
651
+ key: 0,
652
+ content: l(r)("report.section.filter.missingFilterSchema"),
653
+ "z-index": 99,
654
+ class: "ml-2"
655
+ }, {
656
+ default: b(() => [
657
+ n(j, {
658
+ name: "warning",
659
+ class: "text-fm-color-system-error-300"
660
+ })
661
+ ]),
662
+ _: 1
663
+ }, 8, ["content"])) : L("", !0)
664
+ ]))), 128))
665
+ ])) : (u(), k(ie, {
666
+ key: 5,
667
+ class: "fm-typo-en-body-lg-400",
668
+ label: l(r)("report.section.filter.noWidget")
669
+ }, null, 8, ["label"]))
670
+ ];
671
+ }),
672
+ _: 1
673
+ }, 512)
674
+ ]),
675
+ "dialog-footer": b(() => [
676
+ e[12] || (e[12] = g("div", { class: "grow" }, null, -1)),
677
+ n(X, {
678
+ label: l(r)("report.common.cancel"),
679
+ variant: "tertiary",
680
+ onClick: _e
681
+ }, null, 8, ["label"]),
682
+ n(X, {
683
+ label: l(r)("report.common.confirm"),
684
+ onClick: Y
685
+ }, null, 8, ["label"])
686
+ ]),
687
+ _: 1
688
+ }, 8, ["modelValue"]);
689
+ };
690
+ }
691
+ }), ml = 8.4375, cl = 1024 ** 4, pl = {
692
+ MY: { rate: 4, currency: "MYR", symbol: "RM" },
693
+ TH: { rate: 33, currency: "THB", symbol: "฿" },
694
+ SG: { rate: 1.29, currency: "SGD", symbol: "S$" },
695
+ ID: { rate: 17900, currency: "IDR", symbol: "Rp" }
696
+ }, vl = { rate: 1, currency: "USD", symbol: "$" };
697
+ function dt(R, r) {
698
+ const a = R / cl * ml, { rate: m, currency: v, symbol: f } = pl[r] ?? vl;
699
+ return {
700
+ amount: a * m,
701
+ currency: v,
702
+ symbol: f,
703
+ costUsd: a
704
+ };
705
+ }
706
+ function mt(R, r) {
707
+ return R < 0.01 ? `< ${r}0.01` : `${r}${R.toFixed(2)}`;
708
+ }
709
+ const fl = { class: "flex flex-col gap-16" }, gl = {
710
+ key: 0,
711
+ class: "flex flex-col gap-8"
712
+ }, bl = { class: "flex items-center gap-4 pb-8 border-b border-neutral-300" }, yl = ["title"], hl = {
713
+ key: 1,
714
+ class: "rounded-md border border-dashed border-neutral-300 p-12 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
715
+ }, _l = ["onClick"], wl = ["title"], Fl = {
716
+ key: 0,
717
+ class: "text-fm-color-typo-secondary"
718
+ }, xl = { class: "text-fm-color-system-error-300" }, Cl = { class: "w-full text-left" }, Vl = /* @__PURE__ */ Ve({
719
+ __name: "TileDrillPanel",
720
+ props: {
721
+ report: {}
722
+ },
723
+ emits: ["add-widget"],
724
+ setup(R, { emit: r }) {
725
+ const a = R, m = r, { t: v, te: f } = Le(), M = nt(), le = rt(), { promptMessage: V } = it(), y = at(), x = p(() => {
726
+ const i = [];
727
+ let c = a.report.tiles;
728
+ for (const H of Be.value) {
729
+ const ue = c.find((te) => te.id === H);
730
+ if (!ue) break;
731
+ i.push(ue), c = ue.tiles ?? [];
732
+ }
733
+ return i;
734
+ });
735
+ we(x, (i) => {
736
+ i.length !== Be.value.length && (Be.value = i.map((c) => c.id));
737
+ });
738
+ const N = p(() => x.value[x.value.length - 1] ?? null), G = p(() => x.value[x.value.length - 2] ?? null), q = p(
739
+ () => N.value ? N.value.tiles ?? [] : a.report.tiles
740
+ ), A = p(() => {
741
+ var i;
742
+ return ((i = N.value) == null ? void 0 : i.id) ?? null;
743
+ }), $ = p(() => x.value.length === 0), U = p(() => {
744
+ var i;
745
+ return ((i = N.value) == null ? void 0 : i.tab) === !0;
746
+ }), B = p(() => {
747
+ var i;
748
+ return ((i = G.value) == null ? void 0 : i.tab) === !0;
749
+ }), se = p(
750
+ () => x.value.reduce((i, c) => c.tab ? i : i + 1, 1)
751
+ ), me = p(() => !U.value && se.value < yt), K = p(() => $.value);
752
+ function w(i) {
753
+ i.widget || (Be.value = [...Be.value, i.id]);
754
+ }
755
+ function Fe() {
756
+ Be.value = Be.value.slice(0, -1);
757
+ }
758
+ function ce(i) {
759
+ if (!i) return "";
760
+ const c = `report.widget.types.${i.toLowerCase()}`;
761
+ return f(c) ? v(c) : Ge(v, f, i, "other");
762
+ }
763
+ function oe(i, c) {
764
+ return i.widget ? i.widget.title ? ce(i.widget.title) : v("report.editor.widget", { index: c + 1 }) : i.tabTitle !== void 0 ? i.tabTitle || v("report.editor.tab", { index: c + 1 }) : i.tab ? v("report.editor.tabGroup") : v("report.editor.group");
765
+ }
766
+ function pe(i, c) {
767
+ return !i.widget && U.value ? i.tabTitle || v("report.editor.tab", { index: c + 1 }) : oe(i, c);
768
+ }
769
+ function ge(i) {
770
+ var c;
771
+ return ((c = i.tiles) == null ? void 0 : c.length) ?? 0;
772
+ }
773
+ const he = p(
774
+ () => x.value.map((i, c) => oe(i, c)).join(" › ")
775
+ );
776
+ function E(i, c) {
777
+ bt.value = A.value, y.editingTileIndex = c, y.editingTile = JSON.parse(JSON.stringify(i)), M.push({ name: "tileEditor", query: le.query });
778
+ }
779
+ function W(i, c) {
780
+ q.value.splice(c + 1, 0, Mt(i));
781
+ }
782
+ async function Z(i, c) {
783
+ var te;
784
+ if (!await V({
785
+ title: v("report.editor.deleteWidget"),
786
+ message: v("report.editor.deleteWidgetConfirm", { title: pe(i, c) })
787
+ })) return;
788
+ const ue = st(i);
789
+ q.value.splice(c, 1), (te = a.report.globalFilters) == null || te.forEach((Q) => {
790
+ var ye;
791
+ Q.tileIds = (ye = Q.tileIds) == null ? void 0 : ye.filter((ve) => !ue.includes(ve));
792
+ });
793
+ }
794
+ function be() {
795
+ N.value && (N.value.tiles || (N.value.tiles = []), N.value.tiles.push(qt(N.value.tiles.length + 1)));
796
+ }
797
+ function xe() {
798
+ q.value.push(Et());
799
+ }
800
+ function ee() {
801
+ q.value.push(Pt());
802
+ }
803
+ function ke(i) {
804
+ var H;
805
+ const c = Number((H = i.size) == null ? void 0 : H.width);
806
+ i.size || (i.size = { width: 12, height: 12 }), !Number.isFinite(c) || c < 1 ? i.size.width = 1 : c > 12 && (i.size.width = 12);
807
+ }
808
+ const ae = P(!1), Te = P(null), Ne = P([]);
809
+ function Ue(i) {
810
+ const c = [
811
+ { parentId: null, label: v("report.editor.topLevel"), level: 1 }
812
+ ], H = (te, Q, ye) => {
813
+ let ve = 0;
814
+ te.forEach((Y) => {
815
+ var _e;
816
+ if (!Y.widget)
817
+ if (Y.tab) {
818
+ const T = `${ye}${v("report.editor.tabGroup")}`;
819
+ (_e = Y.tiles) == null || _e.forEach((de, t) => {
820
+ const e = `${T} › ${de.tabTitle || v("report.editor.tab", { index: t + 1 })}`;
821
+ c.push({ parentId: de.id, label: e, level: Q + 1 }), H(de.tiles ?? [], Q + 1, `${e} › `);
822
+ });
823
+ } else {
824
+ ve += 1;
825
+ const T = `${ye}${v("report.editor.group")} ${ve}`;
826
+ c.push({ parentId: Y.id, label: T, level: Q + 1 }), H(Y.tiles ?? [], Q + 1, `${T} › `);
827
+ }
828
+ });
829
+ };
830
+ H(a.report.tiles, 1, "");
831
+ const ue = new Set(st(i));
832
+ return c.filter(
833
+ (te) => te.parentId !== A.value && !(te.parentId && ue.has(te.parentId)) && zt(i, te.level)
834
+ );
835
+ }
836
+ function $e(i) {
837
+ Te.value = i, Ne.value = Ue(i), ae.value = !0;
838
+ }
839
+ function Se(i) {
840
+ const c = Te.value;
841
+ if (!c) return;
842
+ const H = q.value.indexOf(c);
843
+ H >= 0 && q.value.splice(H, 1), Lt(a.report.tiles, i.parentId).push(c), ae.value = !1, Te.value = null;
844
+ }
845
+ return (i, c) => {
846
+ const H = F("FmButton"), ue = F("FmTextField"), te = F("FmIcon"), Q = F("FmMenuItem"), ye = F("FmMenu"), ve = F("FmList"), Y = F("FmListItem"), _e = F("FmDialog");
847
+ return u(), I("div", fl, [
848
+ $.value ? L("", !0) : (u(), I("div", gl, [
849
+ g("div", bl, [
850
+ n(H, {
851
+ icon: "arrow_back",
852
+ variant: "tertiary",
853
+ class: "-ml-8",
854
+ onClick: Fe
855
+ }),
856
+ g("p", {
857
+ class: "fm-typo-en-body-md-600 line-clamp-1 overflow-hidden break-all min-w-0 grow text-left",
858
+ title: he.value
859
+ }, z(he.value), 9, yl)
860
+ ]),
861
+ B.value && N.value ? (u(), k(ue, {
862
+ key: 0,
863
+ modelValue: N.value.tabTitle,
864
+ "onUpdate:modelValue": c[0] || (c[0] = (T) => N.value.tabTitle = T),
865
+ label: l(v)("report.editor.tabName"),
866
+ placeholder: l(v)("report.editor.tabName")
867
+ }, null, 8, ["modelValue", "label", "placeholder"])) : L("", !0),
868
+ !B.value && N.value ? (u(), k(ue, {
869
+ key: 1,
870
+ modelValue: N.value.size.width,
871
+ "onUpdate:modelValue": c[1] || (c[1] = (T) => N.value.size.width = T),
872
+ modelModifiers: { number: !0 },
873
+ type: "number",
874
+ label: l(v)("report.editor.width"),
875
+ onBlur: c[2] || (c[2] = (T) => ke(N.value))
876
+ }, null, 8, ["modelValue", "label"])) : L("", !0)
877
+ ])),
878
+ q.value.length === 0 ? (u(), I("div", hl, z(l(v)("report.editor.emptyLevel")), 1)) : (u(), k(ve, { key: 2 }, {
879
+ default: b(() => [
880
+ n(l(gt), {
881
+ list: q.value,
882
+ "item-key": "id",
883
+ class: "flex flex-col gap-2 cursor-grab",
884
+ handle: ".handle"
885
+ }, {
886
+ item: b(({ element: T, index: de }) => [
887
+ g("div", {
888
+ class: Pe(["flex items-center gap-8 px-12 py-8 border rounded-md border-neutral-300 hover:bg-fm-color-opacity-sm", T.widget ? "cursor-grab" : "cursor-pointer"]),
889
+ onClick: (t) => w(T)
890
+ }, [
891
+ n(te, {
892
+ name: "drag_handle",
893
+ class: "handle shrink-0 !cursor-grab"
894
+ }),
895
+ g("p", {
896
+ class: "flex-1 min-w-0 truncate text-left fm-typo-en-body-lg-400",
897
+ title: pe(T, de)
898
+ }, [
899
+ Ae(z(pe(T, de)) + " ", 1),
900
+ T.widget ? L("", !0) : (u(), I("span", Fl, " · " + z(ge(T)), 1))
901
+ ], 8, wl),
902
+ T.widget ? L("", !0) : (u(), k(te, {
903
+ key: 0,
904
+ name: "chevron_right",
905
+ class: "shrink-0"
906
+ })),
907
+ n(ye, {
908
+ trigger: "click",
909
+ shift: !0,
910
+ "stop-click-propagation": !0,
911
+ class: "shrink-0"
912
+ }, {
913
+ "menu-button": b(() => [
914
+ n(H, {
915
+ "append-icon": "more_vert",
916
+ variant: "tertiary"
917
+ })
918
+ ]),
919
+ default: b(() => [
920
+ T.widget ? (u(), k(Q, {
921
+ key: 0,
922
+ label: l(v)("report.common.edit"),
923
+ onClick: (t) => E(T, de)
924
+ }, null, 8, ["label", "onClick"])) : L("", !0),
925
+ T.tab ? L("", !0) : (u(), k(Q, {
926
+ key: 1,
927
+ label: l(v)("report.editor.moveTo"),
928
+ onClick: (t) => $e(T)
929
+ }, null, 8, ["label", "onClick"])),
930
+ n(Q, {
931
+ label: l(v)("report.common.duplicate"),
932
+ onClick: (t) => W(T, de)
933
+ }, null, 8, ["label", "onClick"]),
934
+ n(Q, {
935
+ onClick: (t) => Z(T, de)
936
+ }, {
937
+ label: b(() => [
938
+ g("p", xl, z(l(v)("report.common.remove")), 1)
939
+ ]),
940
+ _: 2
941
+ }, 1032, ["onClick"])
942
+ ]),
943
+ _: 2
944
+ }, 1024)
945
+ ], 10, _l)
946
+ ]),
947
+ _: 1
948
+ }, 8, ["list"])
949
+ ]),
950
+ _: 1
951
+ })),
952
+ U.value ? (u(), k(H, {
953
+ key: 3,
954
+ label: l(v)("report.editor.addTab"),
955
+ variant: "secondary",
956
+ icon: "add",
957
+ "icon-position": "prepend",
958
+ "border-color": l(Oe).ColorPrimary,
959
+ "text-color": l(Oe).ColorPrimary,
960
+ onClick: be
961
+ }, null, 8, ["label", "border-color", "text-color"])) : (u(), k(ye, {
962
+ key: 4,
963
+ trigger: "click",
964
+ shift: !0
965
+ }, {
966
+ "menu-button": b(() => [
967
+ n(H, {
968
+ label: l(v)("report.common.add"),
969
+ variant: "secondary",
970
+ icon: "add",
971
+ "icon-position": "prepend",
972
+ class: "w-full",
973
+ "border-color": l(Oe).ColorPrimary,
974
+ "text-color": l(Oe).ColorPrimary
975
+ }, null, 8, ["label", "border-color", "text-color"])
976
+ ]),
977
+ default: b(() => [
978
+ n(Q, {
979
+ label: l(v)("report.editor.addWidget"),
980
+ onClick: c[3] || (c[3] = (T) => m("add-widget", A.value))
981
+ }, null, 8, ["label"]),
982
+ me.value ? (u(), k(Q, {
983
+ key: 0,
984
+ label: l(v)("report.editor.addGroup"),
985
+ onClick: xe
986
+ }, null, 8, ["label"])) : L("", !0),
987
+ K.value ? (u(), k(Q, {
988
+ key: 1,
989
+ label: l(v)("report.editor.addTabGroup"),
990
+ onClick: ee
991
+ }, null, 8, ["label"])) : L("", !0)
992
+ ]),
993
+ _: 1
994
+ })),
995
+ n(_e, {
996
+ modelValue: ae.value,
997
+ "onUpdate:modelValue": c[4] || (c[4] = (T) => ae.value = T),
998
+ overlay: !0,
999
+ "z-index": 10
1000
+ }, {
1001
+ "dialog-header": b(() => [
1002
+ Ae(z(l(v)("report.editor.moveTo")), 1)
1003
+ ]),
1004
+ default: b(() => [
1005
+ n(ve, null, {
1006
+ default: b(() => [
1007
+ (u(!0), I(Ce, null, Ee(Ne.value, (T) => (u(), k(Y, {
1008
+ key: T.parentId ?? "root",
1009
+ onClick: (de) => Se(T)
1010
+ }, {
1011
+ default: b(() => [
1012
+ g("p", Cl, z(T.label), 1)
1013
+ ]),
1014
+ _: 2
1015
+ }, 1032, ["onClick"]))), 128))
1016
+ ]),
1017
+ _: 1
1018
+ })
1019
+ ]),
1020
+ _: 1
1021
+ }, 8, ["modelValue"])
1022
+ ]);
1023
+ };
1024
+ }
1025
+ }), kl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Tl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, $l = { class: "flex items-center gap-8" }, Sl = {
1026
+ key: 2,
1027
+ class: "flex flex-col gap-8 rounded-md border border-fm-color-border px-16 py-12"
1028
+ }, Dl = { class: "fm-typo-en-body-sm-400" }, Ol = { class: "fm-typo-en-body-sm-400 font-bold" }, Il = { class: "space-y-1 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Rl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Nl = { class: "flex items-center gap-1 max-w-[195px] w-[195px]" }, Ul = { class: "line-clamp-2 overflow-hidden max-w-[195px] w-[195px]" }, ct = /* @__PURE__ */ Ve({
1029
+ __name: "ReportEditorTab",
1030
+ props: /* @__PURE__ */ Ie({
1031
+ hideConfiguration: {
1032
+ type: Boolean,
1033
+ default: !1
1034
+ }
1035
+ }, {
1036
+ modelValue: { required: !0 },
1037
+ modelModifiers: {}
1038
+ }),
1039
+ emits: /* @__PURE__ */ Ie(["hideConfiguration"], ["update:modelValue"]),
1040
+ setup(R, { emit: r }) {
1041
+ const a = Re(R, "modelValue"), { breakpoints: m } = je(), v = R, f = r, M = nt(), le = rt(), V = P(), {
1042
+ currentSelectWidgetType: y,
1043
+ categories: x,
1044
+ editingTile: N,
1045
+ editingTileIndex: G,
1046
+ editingGlobalFilter: q,
1047
+ editingGlobalFilterIndex: A
1048
+ } = Me(at()), { schemas: $ } = Me(At()), { globalFilters: U } = Me(Ye()), { getGlobalFilterLabel: B } = Ye(), { promptMessage: se } = it(), me = P(!1), K = P(!1), { t: w, te: Fe, locale: ce } = Le(), oe = P(void 0), pe = p(() => {
1049
+ const s = Xe(a.value.tiles).flatMap((o) => {
1050
+ var J;
1051
+ const O = o.widget.config.schemaNames ?? [], d = ((J = o.widget.config.joinDatasources) == null ? void 0 : J.flatMap((ne) => ne.schemaNames ?? [])) ?? [];
1052
+ return [...O, ...d];
1053
+ });
1054
+ return [...new Set(s)].reduce((o, O) => {
1055
+ const d = $.value.find((J) => J.name === O);
1056
+ return d && o.push(d), o;
1057
+ }, []);
1058
+ }), ge = P(null);
1059
+ function he(s) {
1060
+ ge.value = s, K.value = !0;
1061
+ }
1062
+ we(
1063
+ () => y.value,
1064
+ () => {
1065
+ y.value !== void 0 && (oe.value = Rt(y.value), N.value = oe.value, G.value = -1, bt.value = ge.value, M.push({
1066
+ name: "tileEditor",
1067
+ query: le.query
1068
+ }));
1069
+ },
1070
+ { immediate: !0 }
1071
+ ), we(
1072
+ () => a.value.tiles,
1073
+ (s) => {
1074
+ Gt(s);
1075
+ },
1076
+ { immediate: !0, deep: !0 }
1077
+ );
1078
+ const E = [
1079
+ {
1080
+ label: "report.common.edit",
1081
+ selected: !1,
1082
+ variant: "tertiary",
1083
+ onClick: (s) => {
1084
+ var o;
1085
+ A.value = s, q.value = JSON.parse(JSON.stringify((o = a.value.globalFilters) == null ? void 0 : o[s])), me.value = !0;
1086
+ }
1087
+ },
1088
+ {
1089
+ label: "report.common.duplicate",
1090
+ selected: !1,
1091
+ variant: "tertiary",
1092
+ onClick: (s) => {
1093
+ var d;
1094
+ const o = (d = a.value.globalFilters) == null ? void 0 : d[s];
1095
+ if (!o) return;
1096
+ const O = JSON.parse(JSON.stringify(o));
1097
+ a.value.globalFilters || (a.value.globalFilters = []), a.value.globalFilters.push(O);
1098
+ }
1099
+ },
1100
+ {
1101
+ label: "report.common.remove",
1102
+ selected: !1,
1103
+ variant: "destructive",
1104
+ onClick: async (s) => {
1105
+ var d, J;
1106
+ const o = (d = a.value.globalFilters) == null ? void 0 : d[s];
1107
+ if (!o) return;
1108
+ await se({
1109
+ title: w("report.editor.deleteWidget"),
1110
+ message: w("report.editor.deleteWidgetConfirm", {
1111
+ title: B(o)
1112
+ })
1113
+ }) && ((J = a.value.globalFilters) == null || J.splice(s, 1));
1114
+ }
1115
+ }
1116
+ ], W = p(() => x.value.map((s) => ({
1117
+ label: w(`report.category.${s.name}`),
1118
+ value: s.id
1119
+ }))), { sessionUser: Z } = Kt(), be = p(
1120
+ () => {
1121
+ var s, o, O, d;
1122
+ return ((o = (s = Z.value) == null ? void 0 : s.role) == null ? void 0 : o.isAdmin) === !0 || ((d = (O = Z.value) == null ? void 0 : O.role) == null ? void 0 : d.isStaff) === !0;
1123
+ }
1124
+ ), xe = p({
1125
+ get: () => a.value.queryVersion === "v2",
1126
+ set: (s) => {
1127
+ a.value.queryVersion = s ? "v2" : "v1", s ? a.value.queryDatasource = a.value.queryDatasource ?? He.Postgres : a.value.queryDatasource = void 0;
1128
+ }
1129
+ }), ee = [
1130
+ { label: w("report.common.postgresql"), value: He.Postgres },
1131
+ { label: w("report.common.bigquery"), value: He.BigQuery }
1132
+ ], ke = [
1133
+ { label: w("report.common.noBatch"), value: "none" },
1134
+ { label: w("report.common.days"), value: "days" },
1135
+ { label: w("report.common.locations"), value: "locations" }
1136
+ ], ae = p({
1137
+ get: () => {
1138
+ var s, o;
1139
+ return (s = a.value.batch) != null && s.days ? "days" : (o = a.value.batch) != null && o.locations ? "locations" : "none";
1140
+ },
1141
+ set: (s) => {
1142
+ var o, O;
1143
+ s === "none" ? a.value.batch = void 0 : s === "days" ? a.value.batch = { days: ((o = a.value.batch) == null ? void 0 : o.days) || 1 } : s === "locations" && (a.value.batch = { locations: ((O = a.value.batch) == null ? void 0 : O.locations) || 10 });
1144
+ }
1145
+ }), Te = p({
1146
+ get: () => {
1147
+ var s, o;
1148
+ if (ae.value === "days") return ((s = a.value.batch) == null ? void 0 : s.days) ?? 1;
1149
+ if (ae.value === "locations") return ((o = a.value.batch) == null ? void 0 : o.locations) ?? 1;
1150
+ },
1151
+ set: (s) => {
1152
+ s && (ae.value === "days" ? a.value.batch = { days: s } : ae.value === "locations" && (a.value.batch = { locations: s }));
1153
+ }
1154
+ }), Ne = p({
1155
+ get: () => Ge(w, Fe, a.value.name, "other"),
1156
+ set: (s) => {
1157
+ a.value.name = s;
1158
+ }
1159
+ }), { country: Ue } = Me(Qt()), {
1160
+ dateRange: $e,
1161
+ compareDateRange: Se,
1162
+ timeRange: i,
1163
+ selectedLocationIds: c,
1164
+ businessDataVersion: H,
1165
+ restaurants: ue,
1166
+ warehouses: te
1167
+ } = Me(Yt()), { isAllGlobalFiltersLoaded: Q } = Me(Ye()), ye = p(
1168
+ () => a.value.queryVersion === "v2" && a.value.queryDatasource === He.BigQuery
1169
+ ), ve = p(() => ye.value && be.value), Y = P(null), _e = P(!1), T = p(() => {
1170
+ const s = $e.value.startDate ?? $e.value.endDate;
1171
+ return s ? {
1172
+ startDate: s,
1173
+ endDate: s
1174
+ } : $e.value;
1175
+ }), de = p(() => {
1176
+ const s = Se.value.startDate ?? Se.value.endDate;
1177
+ return s ? {
1178
+ startDate: s,
1179
+ endDate: s
1180
+ } : Se.value;
1181
+ }), t = p(() => {
1182
+ const s = a.value.batch;
1183
+ if (!s) return 1;
1184
+ if (s.locations) {
1185
+ const o = ue.value.length + te.value.length;
1186
+ return Math.max(1, Math.ceil(o / s.locations));
1187
+ }
1188
+ return 1;
1189
+ }), e = p(() => {
1190
+ if (Y.value == null || Y.value === 0) return null;
1191
+ const s = Y.value * t.value;
1192
+ return dt(s, Ue.value);
1193
+ }), h = p(() => Y.value == null || Y.value === 0 ? null : dt(Y.value, Ue.value)), _ = p(() => e.value ? mt(e.value.amount, e.value.symbol) : ""), C = p(() => h.value ? mt(h.value.amount, h.value.symbol) : ""), D = p(() => t.value === 1 ? w("report.common.estimatedCostBatchSingular") : w("report.common.estimatedCostBatchPlural")), X = p(() => _e.value ? "..." : !_.value || !C.value ? "--" : w("report.common.estimatedCostFormula", {
1194
+ batchCount: t.value,
1195
+ batchLabel: D.value,
1196
+ baseCost: C.value,
1197
+ totalCost: _.value
1198
+ }));
1199
+ let re = [];
1200
+ const ie = Xt(async () => {
1201
+ if (!ve.value) return;
1202
+ const s = Xe(a.value.tiles).filter(
1203
+ (o) => {
1204
+ var O;
1205
+ return ((O = o.widget.config.schemaNames) == null ? void 0 : O.length) > 0;
1206
+ }
1207
+ );
1208
+ if (s.length === 0) {
1209
+ Y.value = null;
1210
+ return;
1211
+ }
1212
+ _e.value = !0, re.forEach((o) => o.abort()), re = [];
1213
+ try {
1214
+ const o = await Promise.all(
1215
+ s.map((O) => {
1216
+ const d = new AbortController();
1217
+ return re.push(d), Wt({
1218
+ widget: O.widget,
1219
+ signal: d.signal,
1220
+ tileId: O.id,
1221
+ scopedDateRange: T.value,
1222
+ scopedCompareDateRange: de.value
1223
+ });
1224
+ })
1225
+ );
1226
+ Y.value = o.reduce((O, d) => O + (d.totalBytesProcessed ?? 0), 0);
1227
+ } catch (o) {
1228
+ o.code !== "ERR_CANCELED" && (Y.value = null);
1229
+ } finally {
1230
+ _e.value = !1;
1231
+ }
1232
+ }, 1e3);
1233
+ we(
1234
+ [
1235
+ () => a.value.tiles,
1236
+ () => a.value.queryVersion,
1237
+ () => a.value.queryDatasource,
1238
+ () => a.value.batch,
1239
+ () => $e.value,
1240
+ () => i.value,
1241
+ () => Se.value,
1242
+ () => c.value,
1243
+ () => H.value,
1244
+ () => Q.value
1245
+ ],
1246
+ () => {
1247
+ ie();
1248
+ },
1249
+ { deep: !0 }
1250
+ ), vt(() => {
1251
+ ie();
1252
+ }), Tt(() => {
1253
+ re.forEach((s) => s.abort());
1254
+ });
1255
+ function j(s) {
1256
+ var o;
1257
+ return !((o = s.tileIds) != null && o.length);
1258
+ }
1259
+ function ze(s) {
1260
+ return !pe.value.find((o) => o.name === s.schemaName);
1261
+ }
1262
+ return we(
1263
+ () => a.value.globalFilters,
1264
+ (s) => {
1265
+ U.value = JSON.parse(JSON.stringify(s || []));
1266
+ },
1267
+ { deep: !0, immediate: !0 }
1268
+ ), (s, o) => {
1269
+ const O = F("FmTextField"), d = F("FmSelect"), J = F("FmSwitch"), ne = F("FmButton"), Je = F("FmIcon"), Ke = F("FmTooltip"), _t = F("FmMenuItem"), wt = F("FmMenu"), Ft = F("FmListItem"), xt = F("FmList"), Ct = F("FmForm");
1270
+ return u(), k($t(l(m).lg || l(m).md ? tl : ll), {
1271
+ "model-value": v.hideConfiguration,
1272
+ "onUpdate:modelValue": o[12] || (o[12] = (S) => f("hideConfiguration", S))
1273
+ }, {
1274
+ default: b(() => [
1275
+ n(dl, {
1276
+ "is-open": me.value,
1277
+ "onUpdate:isOpen": o[0] || (o[0] = (S) => me.value = S),
1278
+ "global-filter": l(q),
1279
+ tiles: l(Xe)(a.value.tiles),
1280
+ schemas: pe.value,
1281
+ "onUpdate:globalFilter": o[1] || (o[1] = (S) => {
1282
+ S && (a.value.globalFilters || (a.value.globalFilters = []), typeof l(A) == "number" && l(A) >= 0 ? a.value.globalFilters[l(A)] = S : a.value.globalFilters.push(S));
1283
+ })
1284
+ }, null, 8, ["is-open", "global-filter", "tiles", "schemas"]),
1285
+ n(Zt, {
1286
+ modelValue: l(y),
1287
+ "onUpdate:modelValue": o[2] || (o[2] = (S) => ft(y) ? y.value = S : null),
1288
+ "is-open": K.value,
1289
+ "onUpdate:isOpen": o[3] || (o[3] = (S) => K.value = S)
1290
+ }, null, 8, ["modelValue", "is-open"]),
1291
+ n(Ct, {
1292
+ ref_key: "form",
1293
+ ref: V,
1294
+ class: "px-6 py-16 flex flex-col gap-24 overflow-y-auto overflow-x-hidden"
1295
+ }, {
1296
+ default: b(() => [
1297
+ n(We, { class: "border-solid" }, {
1298
+ header: b(() => [
1299
+ g("p", null, z(l(w)("report.editor.reportInfo")), 1),
1300
+ o[13] || (o[13] = g("div", { class: "grow" }, null, -1))
1301
+ ]),
1302
+ content: b(() => [
1303
+ g("div", kl, [
1304
+ n(O, {
1305
+ modelValue: Ne.value,
1306
+ "onUpdate:modelValue": o[4] || (o[4] = (S) => Ne.value = S),
1307
+ label: l(w)("report.common.name"),
1308
+ placeholder: l(w)("report.common.name")
1309
+ }, null, 8, ["modelValue", "label", "placeholder"]),
1310
+ (u(), k(d, {
1311
+ key: `category-${l(ce)}`,
1312
+ modelValue: a.value.category,
1313
+ "onUpdate:modelValue": o[5] || (o[5] = (S) => a.value.category = S),
1314
+ label: l(w)("report.common.category"),
1315
+ items: W.value
1316
+ }, null, 8, ["modelValue", "label", "items"])),
1317
+ n(O, {
1318
+ modelValue: a.value.description,
1319
+ "onUpdate:modelValue": o[6] || (o[6] = (S) => a.value.description = S),
1320
+ label: l(w)("report.common.description"),
1321
+ placeholder: l(w)("report.common.description")
1322
+ }, null, 8, ["modelValue", "label", "placeholder"])
1323
+ ])
1324
+ ]),
1325
+ _: 1
1326
+ }),
1327
+ n(We, {
1328
+ class: "border-solid",
1329
+ "is-open": !1
1330
+ }, {
1331
+ header: b(() => [
1332
+ g("p", null, z(l(w)("report.editor.advancedUsage")), 1),
1333
+ o[14] || (o[14] = g("div", { class: "grow" }, null, -1))
1334
+ ]),
1335
+ content: b(() => [
1336
+ g("div", Tl, [
1337
+ g("div", $l, [
1338
+ o[15] || (o[15] = g("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, "V2", -1)),
1339
+ n(J, {
1340
+ modelValue: xe.value,
1341
+ "onUpdate:modelValue": o[7] || (o[7] = (S) => xe.value = S)
1342
+ }, null, 8, ["modelValue"])
1343
+ ]),
1344
+ xe.value && be.value ? (u(), k(d, {
1345
+ key: 0,
1346
+ modelValue: a.value.queryDatasource,
1347
+ "onUpdate:modelValue": o[8] || (o[8] = (S) => a.value.queryDatasource = S),
1348
+ label: l(w)("report.common.queryDatasource"),
1349
+ items: ee
1350
+ }, null, 8, ["modelValue", "label"])) : L("", !0),
1351
+ n(d, {
1352
+ modelValue: ae.value,
1353
+ "onUpdate:modelValue": o[9] || (o[9] = (S) => ae.value = S),
1354
+ label: l(w)("report.common.batch"),
1355
+ items: ke
1356
+ }, null, 8, ["modelValue", "label"]),
1357
+ ae.value !== "none" ? (u(), k(O, {
1358
+ key: 1,
1359
+ modelValue: Te.value,
1360
+ "onUpdate:modelValue": o[10] || (o[10] = (S) => Te.value = S),
1361
+ modelModifiers: { number: !0 },
1362
+ label: ae.value === "days" ? l(w)("report.common.days") : l(w)("report.common.locations"),
1363
+ type: "number"
1364
+ }, null, 8, ["modelValue", "label"])) : L("", !0),
1365
+ ve.value ? (u(), I("div", Sl, [
1366
+ g("span", Dl, z(l(w)("report.common.estimatedBqCost")), 1),
1367
+ g("p", Ol, z(X.value), 1),
1368
+ g("div", Il, [
1369
+ g("div", null, "* " + z(l(w)("report.common.estimatedCostGuidelineBigQuery")), 1),
1370
+ g("div", null, "* " + z(l(w)("report.common.estimatedCostGuidelineDateRange")), 1),
1371
+ g("div", null, "* " + z(l(w)("report.common.estimatedCostGuidelineLocationBatch")), 1)
1372
+ ])
1373
+ ])) : L("", !0)
1374
+ ])
1375
+ ]),
1376
+ _: 1
1377
+ }),
1378
+ n(We, {
1379
+ class: "border-solid",
1380
+ "is-open": !1
1381
+ }, {
1382
+ header: b(() => [
1383
+ g("p", null, z(l(w)("report.section.filter.globalFilter")), 1),
1384
+ o[16] || (o[16] = g("div", { class: "grow" }, null, -1))
1385
+ ]),
1386
+ content: b(() => [
1387
+ g("div", Rl, [
1388
+ n(ne, {
1389
+ label: l(w)("report.section.filter.addGlobalFilter"),
1390
+ variant: "secondary",
1391
+ icon: "add",
1392
+ "icon-position": "prepend",
1393
+ "border-color": l(Oe).ColorPrimary,
1394
+ "text-color": l(Oe).ColorPrimary,
1395
+ onClick: o[11] || (o[11] = () => {
1396
+ A.value = null, q.value = null, me.value = !0;
1397
+ })
1398
+ }, null, 8, ["label", "border-color", "text-color"]),
1399
+ n(xt, null, {
1400
+ default: b(() => [
1401
+ n(l(gt), {
1402
+ list: a.value.globalFilters,
1403
+ "item-key": "`${element.schemaName}-${element.name}`",
1404
+ class: "flex flex-col gap-2 cursor-grab",
1405
+ handle: ".handle"
1406
+ }, {
1407
+ item: b(({ element: S, index: Vt }) => [
1408
+ n(Ft, { class: "!cursor-grab border rounded-md border-neutral-300" }, {
1409
+ default: b(() => [
1410
+ n(Je, {
1411
+ name: "drag_handle",
1412
+ class: "handle"
1413
+ }),
1414
+ g("div", Nl, [
1415
+ n(Ke, {
1416
+ "z-index": 99,
1417
+ content: l(B)(S),
1418
+ class: "handle"
1419
+ }, {
1420
+ default: b(() => [
1421
+ g("p", Ul, z(l(B)(S)), 1)
1422
+ ]),
1423
+ _: 2
1424
+ }, 1032, ["content"]),
1425
+ ze(S) ? (u(), k(Ke, {
1426
+ key: 0,
1427
+ content: l(w)("report.section.filter.missingSchema"),
1428
+ "z-index": 99
1429
+ }, {
1430
+ default: b(() => [
1431
+ n(Je, {
1432
+ name: "warning",
1433
+ class: "text-fm-color-system-error-300"
1434
+ })
1435
+ ]),
1436
+ _: 1
1437
+ }, 8, ["content"])) : j(S) ? (u(), k(Ke, {
1438
+ key: 1,
1439
+ content: l(w)("report.section.filter.missingTileIds"),
1440
+ "z-index": 99
1441
+ }, {
1442
+ default: b(() => [
1443
+ n(Je, {
1444
+ name: "warning",
1445
+ class: "text-fm-color-system-warning-300"
1446
+ })
1447
+ ]),
1448
+ _: 1
1449
+ }, 8, ["content"])) : L("", !0)
1450
+ ]),
1451
+ o[17] || (o[17] = g("div", { class: "grow" }, null, -1)),
1452
+ n(wt, {
1453
+ trigger: "click",
1454
+ shift: !0,
1455
+ "stop-click-propagation": !0
1456
+ }, {
1457
+ "menu-button": b(() => [
1458
+ n(ne, {
1459
+ "append-icon": "more_vert",
1460
+ variant: "tertiary"
1461
+ })
1462
+ ]),
1463
+ default: b(() => [
1464
+ (u(), I(Ce, null, Ee(E, (Qe, kt) => n(_t, {
1465
+ key: kt,
1466
+ onClick: (Yl) => Qe.onClick(Vt)
1467
+ }, {
1468
+ label: b(() => [
1469
+ g("p", {
1470
+ class: Pe(
1471
+ Qe.variant === "destructive" ? " text-fm-color-system-error-300" : ""
1472
+ )
1473
+ }, z(l(w)(Qe.label)), 3)
1474
+ ]),
1475
+ _: 2
1476
+ }, 1032, ["onClick"])), 64))
1477
+ ]),
1478
+ _: 2
1479
+ }, 1024)
1480
+ ]),
1481
+ _: 2
1482
+ }, 1024)
1483
+ ]),
1484
+ _: 1
1485
+ }, 8, ["list"])
1486
+ ]),
1487
+ _: 1
1488
+ })
1489
+ ])
1490
+ ]),
1491
+ _: 1
1492
+ }),
1493
+ n(We, { class: "border-solid" }, {
1494
+ header: b(() => [
1495
+ g("p", null, z(l(w)("report.editor.widgets")), 1),
1496
+ o[18] || (o[18] = g("div", { class: "grow" }, null, -1))
1497
+ ]),
1498
+ content: b(() => [
1499
+ n(Vl, {
1500
+ report: a.value,
1501
+ onAddWidget: he
1502
+ }, null, 8, ["report"])
1503
+ ]),
1504
+ _: 1
1505
+ })
1506
+ ]),
1507
+ _: 1
1508
+ }, 512)
1509
+ ]),
1510
+ _: 1
1511
+ }, 8, ["model-value"]);
1512
+ };
1513
+ }
1514
+ }), Bl = { class: "h-full w-full overflow-x-hidden" }, Ml = { class: "flex flex-col bg-fm-color-neutral-white w-[400px]" }, ql = { class: "flex bg-fm-color-neutral-white w-[88px]" }, El = {
1515
+ key: 1,
1516
+ class: "w-full overflow-y-auto"
1517
+ }, Pl = {
1518
+ key: 0,
1519
+ class: "w-full grid grid-cols-12 gap-[24px] p-24"
1520
+ }, Ll = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, zl = { key: 2 }, Al = {
1521
+ key: 0,
1522
+ class: "grid grid-cols-12 gap-[16px]"
1523
+ }, Gl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, Wl = {
1524
+ key: 3,
1525
+ class: "h-full w-full flex items-start justify-center bg-fm-color-neutral-white py-24",
1526
+ style: { backgroundColor: "#F6F8FC" }
1527
+ }, Hl = {
1528
+ key: 0,
1529
+ class: "w-full grid grid-cols-12 gap-[24px] p-24"
1530
+ }, jl = /* @__PURE__ */ Ve({
1531
+ __name: "ReportEditorViewport",
1532
+ props: /* @__PURE__ */ Ie({
1533
+ hideConfiguration: { type: Boolean, required: !1, default: !1 },
1534
+ previewWidth: { type: Number, required: !0 },
1535
+ previewHeight: { type: Number, required: !0 },
1536
+ previewScale: { type: Number, required: !0 }
1537
+ }, {
1538
+ modelValue: { required: !0, default: () => {
1539
+ } },
1540
+ modelModifiers: {}
1541
+ }),
1542
+ emits: /* @__PURE__ */ Ie(["hideConfiguration"], ["update:modelValue"]),
1543
+ setup(R, { emit: r }) {
1544
+ const { breakpoints: a } = je(), m = Re(R, "modelValue"), v = p(() => {
1545
+ var y;
1546
+ return Ht((y = m.value) == null ? void 0 : y.tiles);
1547
+ }), f = R, M = p(() => f.previewWidth > 0 && f.previewHeight > 0), le = p(() => a.value.sm || a.value.xs), V = r;
1548
+ return (y, x) => {
1549
+ const N = F("FmCircularProgress"), G = F("FmButton"), q = F("FmMenuDivider"), A = F("FmCard");
1550
+ return u(), I("div", Bl, [
1551
+ m.value ? (u(), I(Ce, { key: 1 }, [
1552
+ M.value ? L("", !0) : (u(), k(Nt, {
1553
+ key: 0,
1554
+ "model-value": !f.hideConfiguration
1555
+ }, {
1556
+ right: b(() => [
1557
+ g("div", Ml, [
1558
+ m.value ? (u(), k(ct, {
1559
+ key: 0,
1560
+ modelValue: m.value,
1561
+ "onUpdate:modelValue": x[0] || (x[0] = ($) => m.value = $),
1562
+ "hide-configuration": f.hideConfiguration,
1563
+ onHideConfiguration: x[1] || (x[1] = ($) => V("hideConfiguration", $))
1564
+ }, null, 8, ["modelValue", "hide-configuration"])) : L("", !0)
1565
+ ])
1566
+ ]),
1567
+ left: b(() => [
1568
+ g("div", ql, [
1569
+ n(G, {
1570
+ variant: "secondary",
1571
+ icon: "keyboard_double_arrow_right",
1572
+ "border-color": l(Oe).ColorPrimary,
1573
+ "text-color": l(Oe).ColorPrimary,
1574
+ class: "m-24 my-16",
1575
+ size: "md",
1576
+ onClick: x[2] || (x[2] = ($) => V("hideConfiguration", !f.hideConfiguration))
1577
+ }, null, 8, ["border-color", "text-color"])
1578
+ ])
1579
+ ]),
1580
+ _: 1
1581
+ }, 8, ["model-value"])),
1582
+ n(q, {
1583
+ vertical: "",
1584
+ style: { margin: "0px" }
1585
+ }),
1586
+ !le.value && !M.value ? (u(), I("div", El, [
1587
+ m.value.tiles.length > 0 ? (u(), I("div", Pl, [
1588
+ g("div", Ll, [
1589
+ n(ut)
1590
+ ]),
1591
+ n(Ze, {
1592
+ tiles: m.value.tiles,
1593
+ "report-id": m.value.id || "editing",
1594
+ "leaf-index-by-id": v.value,
1595
+ "hide-export": !0
1596
+ }, null, 8, ["tiles", "report-id", "leaf-index-by-id"])
1597
+ ])) : (u(), k(tt, { key: 1 }))
1598
+ ])) : le.value && !M.value ? (u(), I("div", zl, [
1599
+ n(A, { class: "px-5 pb-28" }, {
1600
+ default: b(() => [
1601
+ m.value.tiles.length > 0 ? (u(), I("div", Al, [
1602
+ g("div", Gl, [
1603
+ n(ut)
1604
+ ]),
1605
+ n(Ze, {
1606
+ tiles: m.value.tiles,
1607
+ "report-id": m.value.id || "editing",
1608
+ "leaf-index-by-id": v.value,
1609
+ "hide-export": !0
1610
+ }, null, 8, ["tiles", "report-id", "leaf-index-by-id"])
1611
+ ])) : (u(), k(tt, { key: 1 }))
1612
+ ]),
1613
+ _: 1
1614
+ }),
1615
+ m.value ? (u(), k(ct, {
1616
+ key: 0,
1617
+ modelValue: m.value,
1618
+ "onUpdate:modelValue": x[3] || (x[3] = ($) => m.value = $),
1619
+ "hide-configuration": f.hideConfiguration,
1620
+ onHideConfiguration: x[4] || (x[4] = ($) => {
1621
+ V("hideConfiguration", $);
1622
+ })
1623
+ }, null, 8, ["modelValue", "hide-configuration"])) : L("", !0)
1624
+ ])) : (u(), I("div", Wl, [
1625
+ g("div", {
1626
+ style: lt({
1627
+ transformOrigin: "top center",
1628
+ transform: `scale(${f.previewScale})`
1629
+ })
1630
+ }, [
1631
+ g("div", {
1632
+ class: "overflow-y-auto bg-white rounded-lg",
1633
+ style: lt({
1634
+ width: f.previewWidth + "px",
1635
+ height: f.previewHeight + "px"
1636
+ })
1637
+ }, [
1638
+ m.value.tiles.length > 0 ? (u(), I("div", Hl, [
1639
+ n(Ze, {
1640
+ tiles: m.value.tiles,
1641
+ "report-id": m.value.id || "editing",
1642
+ "leaf-index-by-id": v.value,
1643
+ "hide-export": !0,
1644
+ "custom-screen-width": f.previewWidth
1645
+ }, null, 8, ["tiles", "report-id", "leaf-index-by-id", "custom-screen-width"])
1646
+ ])) : (u(), k(tt, { key: 1 }))
1647
+ ], 4)
1648
+ ], 4)
1649
+ ]))
1650
+ ], 64)) : (u(), k(N, { key: 0 }))
1651
+ ]);
1652
+ };
1653
+ }
1654
+ }), Jl = { class: "flex items-center gap-4" }, Kl = { class: "flex justify-center items-center gap-2 w-full" }, Ql = { class: "flex gap-4" }, po = /* @__PURE__ */ Ve({
1655
+ __name: "ReportEditor",
1656
+ setup(R) {
1657
+ const r = nt(), a = rt(), m = at(), { promptLoader: v } = Jt(), { t: f, te: M } = Le(), { currentReport: le, editingReport: V } = Me(m), { breakpoints: y } = je(), x = p(() => {
1658
+ var E;
1659
+ return !((E = V.value) != null && E.editable);
1660
+ }), N = p(() => {
1661
+ var E;
1662
+ return ((E = V.value) == null ? void 0 : E.name) ?? f("report.editor.newReport");
1663
+ }), G = p(() => Ge(f, M, N.value, "other")), q = ht(), { promptMessage: A } = it(), $ = P(!1), U = p(() => [
1664
+ { label: f("report.common.cancel"), value: "cancel", isPrimary: !1 },
1665
+ { label: f("report.common.save"), value: "save", isPrimary: !0, prependIcon: "download" }
1666
+ ]);
1667
+ async function B() {
1668
+ if (!V.value || V.value.tiles.length === 0) {
1669
+ q.open({ message: f("report.messages.noWidget"), type: "error" });
1670
+ return;
1671
+ }
1672
+ if (jt(V.value.tiles) > yt) {
1673
+ q.open({ message: f("report.messages.tooDeepNesting"), type: "error" });
1674
+ return;
1675
+ }
1676
+ const E = x.value ? f("report.common.clone") : f("report.common.save");
1677
+ if (await A({
1678
+ title: `${f("report.messages.saveReport")}`,
1679
+ message: f("report.messages.confirmAction", { action: E, name: G.value })
1680
+ }))
1681
+ try {
1682
+ await v(async () => {
1683
+ if (x.value) {
1684
+ const Z = JSON.parse(JSON.stringify(V.value));
1685
+ Z.editable = !0, Z.id = "", Z.name = `${Z.name} ${f("report.common.duplicate")}`, Z.isDefault = !1, await m.createOrUpdateReport(Z);
1686
+ } else
1687
+ V.value && await m.createOrUpdateReport(V.value);
1688
+ r.push({
1689
+ name: "reportView",
1690
+ query: a.query
1691
+ });
1692
+ });
1693
+ } catch (Z) {
1694
+ console.log(Z), q.open({
1695
+ message: f("report.messages.failedToAction", { action: E }),
1696
+ type: "error"
1697
+ });
1698
+ }
1699
+ }
1700
+ async function se() {
1701
+ var W;
1702
+ if (!V.value) return;
1703
+ await A({
1704
+ title: f("report.common.report", 1),
1705
+ message: f("report.editor.notSaved", { name: (W = V.value) == null ? void 0 : W.name })
1706
+ }) && (V.value = JSON.parse(JSON.stringify(le.value)), r.back());
1707
+ }
1708
+ vt(() => {
1709
+ V.value || r.push({ name: "reports" });
1710
+ });
1711
+ const me = [
1712
+ {
1713
+ labelKey: "report.common.default",
1714
+ width: void 0,
1715
+ height: void 0
1716
+ },
1717
+ {
1718
+ labelKey: "report.editor.devices.desktop",
1719
+ width: 1920,
1720
+ height: 1080
1721
+ },
1722
+ {
1723
+ labelKey: "report.editor.devices.tablet",
1724
+ width: 820,
1725
+ height: 1180
1726
+ },
1727
+ {
1728
+ labelKey: "report.editor.devices.phone",
1729
+ width: 390,
1730
+ height: 859
1731
+ }
1732
+ ], K = P(me[0]), w = P(!1), Fe = p(() => w.value ? Math.max(K.value.width || 0, K.value.height || 0) : Math.min(K.value.width || 0, K.value.height || 0)), ce = p(() => w.value ? Math.min(K.value.width || 0, K.value.height || 0) : Math.max(K.value.width || 0, K.value.height || 0)), oe = p(() => window.innerHeight - 72 - 56), pe = p(() => {
1733
+ if (!Fe.value) return 1;
1734
+ let E = (oe.value - 48) / Fe.value, W = ce.value * E;
1735
+ return W > window.innerWidth && (E = window.innerWidth / ce.value, W = ce.value * E), E > 1 ? 1 : E;
1736
+ });
1737
+ function ge(E) {
1738
+ K.value = E;
1739
+ }
1740
+ function he() {
1741
+ w.value = !w.value;
1742
+ }
1743
+ return (E, W) => {
1744
+ const Z = F("FmTooltip"), be = F("FmButton"), xe = F("FmPageHead");
1745
+ return u(), k(Ut, null, {
1746
+ default: b(() => [
1747
+ n(xe, {
1748
+ "data-editor-header": "true",
1749
+ actions: U.value,
1750
+ "onClick:action": W[0] || (W[0] = (ee) => {
1751
+ ee === "cancel" && se(), ee === "save" && B();
1752
+ })
1753
+ }, {
1754
+ title: b(() => [
1755
+ g("div", Jl, [
1756
+ n(Z, {
1757
+ content: G.value,
1758
+ placement: "bottom"
1759
+ }, {
1760
+ default: b(() => [
1761
+ g("p", {
1762
+ class: Pe(`${l(y).sm || l(y).xs ? "hidden" : ""} text-ellipsis overflow-hidden text-nowrap fm-typo-en-title-md-600 w-[250px]`)
1763
+ }, z(G.value), 3)
1764
+ ]),
1765
+ _: 1
1766
+ }, 8, ["content"]),
1767
+ g("div", Kl, [
1768
+ g("div", Ql, [
1769
+ (u(), I(Ce, null, Ee(me, (ee) => {
1770
+ var ke;
1771
+ return n(be, {
1772
+ key: ee.labelKey,
1773
+ label: l(f)(ee.labelKey),
1774
+ variant: ((ke = K.value) == null ? void 0 : ke.labelKey) === ee.labelKey ? "primary" : "secondary",
1775
+ size: "md",
1776
+ onClick: (ae) => ge(ee)
1777
+ }, null, 8, ["label", "variant", "onClick"]);
1778
+ }), 64))
1779
+ ]),
1780
+ n(be, {
1781
+ icon: "screen_rotation",
1782
+ variant: "tertiary",
1783
+ size: "md",
1784
+ class: "text-fm-color-typo-primary",
1785
+ onClick: he
1786
+ })
1787
+ ])
1788
+ ])
1789
+ ]),
1790
+ _: 1
1791
+ }, 8, ["actions"]),
1792
+ l(V) ? (u(), k(jl, {
1793
+ key: 0,
1794
+ modelValue: l(V),
1795
+ "onUpdate:modelValue": W[1] || (W[1] = (ee) => ft(V) ? V.value = ee : null),
1796
+ style: lt({ height: oe.value + "px" }),
1797
+ class: Pe(l(y).lg || l(y).md ? "flex" : ""),
1798
+ "hide-configuration": $.value,
1799
+ "preview-width": ce.value,
1800
+ "preview-height": Fe.value,
1801
+ "preview-scale": pe.value,
1802
+ onHideConfiguration: W[2] || (W[2] = (ee) => $.value = ee)
1803
+ }, null, 8, ["modelValue", "style", "class", "hide-configuration", "preview-width", "preview-height", "preview-scale"])) : L("", !0)
1804
+ ]),
1805
+ _: 1
1806
+ });
1807
+ };
1808
+ }
1809
+ });
1810
+ export {
1811
+ po as default
1812
+ };