@feedmepos/mf-report 5.23.9 → 5.24.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/{App-BZrJScUy.js → App-Ca8EX9o9.js} +61 -61
  2. package/dist/{BaseDialog.vue_vue_type_script_setup_true_lang-pYe2bX3S.js → BaseDialog.vue_vue_type_script_setup_true_lang-Dz0x7TdH.js} +543 -536
  3. package/dist/{DateRangeSelect.vue_vue_type_script_setup_true_lang-XYtSMlzj.js → DateRangeSelect.vue_vue_type_script_setup_true_lang-Bgd59D_l.js} +1 -1
  4. package/dist/{Default.vue_vue_type_script_setup_true_lang-cdffEExQ.js → Default.vue_vue_type_script_setup_true_lang-2y-2eXo6.js} +1 -1
  5. package/dist/{FilterSelector.vue_vue_type_script_setup_true_lang-DclkRCoN.js → FilterSelector.vue_vue_type_script_setup_true_lang-BMuFxssD.js} +176 -176
  6. package/dist/{InsightView-Tv1zwcZH.js → InsightView-CLAdR01F.js} +4 -4
  7. package/dist/{Integration-IU2PWqnn.js → Integration-DHPhQlqN.js} +3 -3
  8. package/dist/{Integrations-BWvWAEZY.js → Integrations-Cs6eso8_.js} +2 -2
  9. package/dist/{Layout-B1evYsv9.js → Layout-ZDKsMVWv.js} +1 -1
  10. package/dist/{MenuTab.vue_vue_type_script_setup_true_lang-BQPCJYFc.js → MenuTab.vue_vue_type_script_setup_true_lang-BDVdQQNa.js} +5 -5
  11. package/dist/{NavigationTab.vue_vue_type_script_setup_true_lang-BLvQUAWn.js → NavigationTab.vue_vue_type_script_setup_true_lang-BPdE2225.js} +3 -3
  12. package/dist/{OverviewView-Cz66yY79.js → OverviewView-D9IsJtB8.js} +4 -4
  13. package/dist/{Report-I1TVhc_5.js → Report-C_raNCzj.js} +3 -3
  14. package/dist/ReportEditor-CHjaWaKZ.js +1442 -0
  15. package/dist/{ReportView-T2ThdsZQ.js → ReportView-DLzw1TOE.js} +6 -6
  16. package/dist/{Setting-BjVIDt8e.js → Setting-DdiCM7TR.js} +3 -3
  17. package/dist/{TileEditor-VPautwYN.js → TileEditor-CXyPjAFT.js} +5 -5
  18. package/dist/{TransitionFade-BCxLswdT.js → TransitionFade-CUbwBbWF.js} +4 -4
  19. package/dist/{app-AWxvVekP.js → app-CxNoJZY6.js} +32 -16
  20. package/dist/app.js +1 -1
  21. package/dist/assets/{processTableData.worker-CC1ehXtr.js → formatChartData.worker-C3U_CcDO.js} +29 -29
  22. package/dist/assets/{formatChartData.worker-DkfLOO1x.js → processTableData.worker-D_oiIvNW.js} +29 -29
  23. package/dist/{useRestaurantPermission-C0aF3n_j.js → useRestaurantPermission-DAxXW0Qp.js} +1 -1
  24. package/package.json +1 -1
  25. package/dist/ReportEditor-CHns80TI.js +0 -1406
@@ -0,0 +1,1442 @@
1
+ import { defineComponent as he, mergeModels as be, useModel as ye, ref as R, computed as S, resolveComponent as _, createBlock as T, openBlock as s, withCtx as v, createElementVNode as h, createVNode as a, unref as o, normalizeClass as Te, createTextVNode as He, toDisplayString as X, createElementBlock as C, Fragment as le, renderSlot as Ye, createCommentVNode as G, watch as ge, renderList as pe, resolveDynamicComponent as sl, isRef as Ze, normalizeStyle as je, onMounted as ul } from "vue";
2
+ import { W as dl, g as ml, _ as cl, a as pl, i as vl, S as Ge, d as Ke, T as fl, b as gl } from "./TransitionFade-CUbwBbWF.js";
3
+ import { C as fe, D as Q, b as ke, u as el, a as bl, v as Oe } from "./BaseDialog.vue_vue_type_script_setup_true_lang-Dz0x7TdH.js";
4
+ import { storeToRefs as Ie } from "pinia";
5
+ import { useRouter as ll, useRoute as tl } from "vue-router";
6
+ import { useBreakpoints as qe, useSnackbar as ol, FmButtonColorThemeVariant as Ce } from "@feedmepos/ui-library";
7
+ import { u as al } from "./message-dialog-UoMWOnil.js";
8
+ import { u as Ne, a as yl } from "./vue-i18n-DVWuTfed.js";
9
+ import { r as $e } from "./i18n-CI_sQ5d_.js";
10
+ import { g as hl, a as Qe, _ as Ee } from "./FilterSelector.vue_vue_type_script_setup_true_lang-BMuFxssD.js";
11
+ import { _ as Pe } from "./NoData.vue_vue_type_script_setup_true_lang-CDKHIlF2.js";
12
+ import { a as Je } from "./SelectComponent.vue_vue_type_script_setup_true_lang-Df40itH5.js";
13
+ import { a as _l, i as Le } from "./app-CxNoJZY6.js";
14
+ import { useCoreStore as wl } from "@feedmepos/mf-common";
15
+ const Fl = /* @__PURE__ */ he({
16
+ __name: "WidgetDialog",
17
+ props: /* @__PURE__ */ be({
18
+ isOpen: { type: Boolean }
19
+ }, {
20
+ modelValue: {},
21
+ modelModifiers: {}
22
+ }),
23
+ emits: /* @__PURE__ */ be(["update:isOpen"], ["update:modelValue"]),
24
+ setup(M, { emit: r }) {
25
+ const { t: n } = Ne(), { breakpoints: d } = qe(), x = ye(M, "modelValue"), f = M, O = r;
26
+ function P() {
27
+ O("update:isOpen", !1);
28
+ }
29
+ function F() {
30
+ u.value && (x.value = u.value, u.value = void 0, O("update:isOpen", !1));
31
+ }
32
+ const u = R(), B = S(() => !u.value);
33
+ return (Y, D) => {
34
+ const J = _("FmButton"), w = _("FmDialog");
35
+ return s(), T(w, {
36
+ "model-value": f.isOpen
37
+ }, {
38
+ "dialog-header": v(() => [
39
+ He(X(o(n)("report.widget.type")), 1)
40
+ ]),
41
+ default: v(() => [
42
+ a(dl, {
43
+ modelValue: u.value,
44
+ "onUpdate:modelValue": D[0] || (D[0] = (V) => u.value = V),
45
+ class: Te(`grid ${o(d).lg || o(d).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": v(() => [
50
+ D[1] || (D[1] = h("div", { class: "grow" }, null, -1)),
51
+ a(J, {
52
+ label: o(n)("report.common.cancel"),
53
+ variant: "tertiary",
54
+ onClick: P
55
+ }, null, 8, ["label"]),
56
+ a(J, {
57
+ label: o(n)("report.common.confirm"),
58
+ disabled: B.value,
59
+ onClick: F
60
+ }, null, 8, ["label", "disabled"])
61
+ ]),
62
+ _: 1
63
+ }, 8, ["model-value"]);
64
+ };
65
+ }
66
+ }), Vl = { class: "fm-typo-en-body-lg-600" }, Ae = /* @__PURE__ */ he({
67
+ __name: "ReportEditorTabHeader",
68
+ props: /* @__PURE__ */ be({
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(M) {
79
+ const { t: r } = Ne(), n = ye(M, "modelValue"), d = M;
80
+ return (x, f) => {
81
+ const O = _("FmIcon");
82
+ return s(), C("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] = (P) => n.value = !n.value)
85
+ }, [
86
+ h("p", Vl, X(o(r)("report.editor.customizeReport")), 1),
87
+ f[1] || (f[1] = h("div", { class: "grow" }, null, -1)),
88
+ a(O, {
89
+ name: d.icon
90
+ }, null, 8, ["name"])
91
+ ]);
92
+ };
93
+ }
94
+ }), xl = /* @__PURE__ */ he({
95
+ __name: "ReportEditorTabDesktop",
96
+ props: {
97
+ modelValue: { required: !0, default: !1 },
98
+ modelModifiers: {}
99
+ },
100
+ emits: ["update:modelValue"],
101
+ setup(M) {
102
+ const r = ye(M, "modelValue");
103
+ return (n, d) => (s(), C(le, null, [
104
+ a(Ae, {
105
+ modelValue: r.value,
106
+ "onUpdate:modelValue": d[0] || (d[0] = (x) => r.value = x),
107
+ icon: "keyboard_double_arrow_left"
108
+ }, null, 8, ["modelValue"]),
109
+ Ye(n.$slots, "default")
110
+ ], 64));
111
+ }
112
+ }), kl = /* @__PURE__ */ he({
113
+ __name: "ReportEditorTabMobile",
114
+ props: {
115
+ modelValue: { required: !0, default: !1 },
116
+ modelModifiers: {}
117
+ },
118
+ emits: ["update:modelValue"],
119
+ setup(M) {
120
+ const r = ye(M, "modelValue");
121
+ return (n, d) => {
122
+ const x = _("FmTopSheet"), f = _("FmCard");
123
+ return s(), T(f, { class: "fixed bottom-0 w-full" }, {
124
+ default: v(() => [
125
+ a(Ae, {
126
+ modelValue: r.value,
127
+ "onUpdate:modelValue": d[0] || (d[0] = (O) => r.value = O),
128
+ icon: "keyboard_double_arrow_up"
129
+ }, null, 8, ["modelValue"]),
130
+ a(x, {
131
+ modelValue: r.value,
132
+ "onUpdate:modelValue": d[2] || (d[2] = (O) => r.value = O),
133
+ "fullscreen-size": "sm"
134
+ }, {
135
+ default: v(() => [
136
+ a(Ae, {
137
+ modelValue: r.value,
138
+ "onUpdate:modelValue": d[1] || (d[1] = (O) => r.value = O),
139
+ icon: "keyboard_double_arrow_down"
140
+ }, null, 8, ["modelValue"]),
141
+ r.value ? Ye(n.$slots, "default", { key: 0 }) : G("", !0)
142
+ ]),
143
+ _: 3
144
+ }, 8, ["modelValue"])
145
+ ]),
146
+ _: 3
147
+ });
148
+ };
149
+ }
150
+ }), Cl = {
151
+ key: 2,
152
+ class: "flex flex-col gap-3 mt-2 border border-neutral-300 p-3"
153
+ }, Tl = { 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" }, Sl = {
154
+ key: 0,
155
+ class: "flex justify-end sm:pb-[2px]"
156
+ }, Ol = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, $l = { class: "pl-1" }, Nl = {
157
+ key: 0,
158
+ class: "flex justify-end sm:pb-[2px]"
159
+ }, Ul = {
160
+ key: 4,
161
+ class: "flex flex-col gap-2"
162
+ }, Ml = /* @__PURE__ */ he({
163
+ __name: "GlobalFilterDialog",
164
+ props: /* @__PURE__ */ be({
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(M) {
183
+ const { t: r, te: n } = Ne(), d = ye(M, "globalFilter"), x = ye(M, "isOpen"), f = ol(), O = M, P = R(""), F = R(), u = R(), B = R(), Y = R([]), D = R([]), J = R(""), w = R(!1), V = R(!1), $ = R([]), U = R([]), H = R(fe.Equal);
184
+ function ne(l) {
185
+ return JSON.parse(JSON.stringify(l));
186
+ }
187
+ function m(l, e) {
188
+ return { hour: l, minute: e };
189
+ }
190
+ function te(l) {
191
+ return l ? `${String(l.hour).padStart(2, "0")}:${String(l.minute).padStart(2, "0")}` : null;
192
+ }
193
+ function _e(l) {
194
+ if (!l) return null;
195
+ const [e, p] = l.split(":").map(Number);
196
+ return Number.isNaN(e) || Number.isNaN(p) ? null : { hour: e, minute: p };
197
+ }
198
+ const Z = S(() => u.value ? !(u.value.type === Q.Timestamp && B.value === ke.DateTime) : !1), K = S(
199
+ () => {
200
+ var l;
201
+ return ((l = u.value) == null ? void 0 : l.type) === Q.Timestamp && B.value === ke.TimeOfDay;
202
+ }
203
+ ), ie = S(() => {
204
+ var l;
205
+ return (((l = u.value) == null ? void 0 : l.filterOperators) ?? []).filter((e) => e !== fe.And && e !== fe.Or).map((e) => ({
206
+ label: r(`report.section.comparisonOperator.${e}`),
207
+ value: e
208
+ }));
209
+ });
210
+ function se() {
211
+ var e;
212
+ const l = (e = ie.value[0]) == null ? void 0 : e.value;
213
+ return l || (u.value ? Se(u.value.type, B.value ?? null) : fe.Equal);
214
+ }
215
+ function ve(l) {
216
+ if (u.value)
217
+ return hl({
218
+ operator: l ?? se(),
219
+ dataType: u.value.type,
220
+ dimensionOption: u.value.type === Q.Timestamp ? B.value ?? null : null,
221
+ t: r
222
+ });
223
+ }
224
+ function N(l, e) {
225
+ if (typeof (e == null ? void 0 : e.default) == "boolean" || l.length > 0 && l.every((y) => typeof y == "boolean")) {
226
+ const y = l.reduce((k, E) => (typeof E == "boolean" && k.push(E), k), []);
227
+ if (e)
228
+ for (e.fixed && y.splice(e.count); y.length < e.count; )
229
+ y.push(typeof e.default == "boolean" ? e.default : !1);
230
+ return y;
231
+ }
232
+ const c = l.reduce((y, k) => (typeof k == "string" && y.push(k), y), []);
233
+ if (e)
234
+ for (e.fixed && c.splice(e.count); c.length < e.count; )
235
+ c.push(typeof e.default == "string" ? e.default : "");
236
+ return c;
237
+ }
238
+ function I(l = H.value) {
239
+ const e = ve(l), p = N(
240
+ e ? Array(e.count).fill(e.default) : [],
241
+ e
242
+ );
243
+ return {
244
+ label: "",
245
+ operator: l,
246
+ values: p
247
+ };
248
+ }
249
+ function L() {
250
+ return {
251
+ name: "",
252
+ startTime: m(0, 0),
253
+ endTime: m(23, 59)
254
+ };
255
+ }
256
+ function ue() {
257
+ if (!(!Z.value || !V.value)) {
258
+ if (K.value) {
259
+ U.value.length === 0 && (U.value = [L()]);
260
+ return;
261
+ }
262
+ $.value.length === 0 && ($.value = [I()]);
263
+ }
264
+ }
265
+ function ee() {
266
+ var p, c, y;
267
+ const l = ne(((p = d.value) == null ? void 0 : p.customOptions) ?? []), e = ne(((c = d.value) == null ? void 0 : c.customTimeRanges) ?? []);
268
+ H.value = ((y = l[0]) == null ? void 0 : y.operator) ?? se(), V.value = l.length > 0 || e.length > 0, $.value = l, U.value = e, ue();
269
+ }
270
+ function W(l) {
271
+ H.value = l, $.value = $.value.map((e, p) => {
272
+ const c = $.value[p];
273
+ if (!c)
274
+ return I(l);
275
+ const y = ve(l), k = N(
276
+ Array.isArray(c.values) ? [...c.values] : [],
277
+ y
278
+ );
279
+ return {
280
+ ...c,
281
+ operator: l,
282
+ values: k
283
+ };
284
+ });
285
+ }
286
+ function we() {
287
+ $.value = [...$.value, I()];
288
+ }
289
+ function Ue(l) {
290
+ $.value.length <= 1 || ($.value = $.value.filter((e, p) => p !== l));
291
+ }
292
+ function We() {
293
+ U.value = [...U.value, L()];
294
+ }
295
+ function i(l) {
296
+ U.value.length <= 1 || (U.value = U.value.filter(
297
+ (e, p) => p !== l
298
+ ));
299
+ }
300
+ function t(l, e, p) {
301
+ const c = U.value[l];
302
+ c && (U.value[l] = {
303
+ ...c,
304
+ [e]: _e(p)
305
+ });
306
+ }
307
+ function z(l) {
308
+ return l.length === 0 || l.some((e) => e == null || e === "");
309
+ }
310
+ function q() {
311
+ if (!V.value) return !0;
312
+ if (K.value) {
313
+ const p = U.value.map((y) => y.name.trim()).filter(Boolean);
314
+ return U.value.some(
315
+ (y) => !y.name.trim() || !y.startTime || !y.endTime
316
+ ) ? (f.open({
317
+ message: r("report.section.filter.invalidCustomTimeRange"),
318
+ type: "error"
319
+ }), !1) : new Set(p).size !== p.length ? (f.open({
320
+ message: r("report.section.filter.customTimeRangeNamesMustBeUnique"),
321
+ type: "error"
322
+ }), !1) : !0;
323
+ }
324
+ const l = $.value.map((p) => p.label.trim()).filter(Boolean);
325
+ return $.value.some(
326
+ (p) => !p.label.trim() || z(p.values)
327
+ ) ? (f.open({ message: r("report.section.filter.invalidCustomOption"), type: "error" }), !1) : new Set(l).size !== l.length ? (f.open({
328
+ message: r("report.section.filter.customOptionLabelsMustBeUnique"),
329
+ type: "error"
330
+ }), !1) : !0;
331
+ }
332
+ ge(x, (l) => {
333
+ var e, p, c, y, k, E, me;
334
+ l && (P.value = ((e = d.value) == null ? void 0 : e.label) || "", F.value = O.schemas.find(
335
+ (ce) => {
336
+ var A;
337
+ return ce.name === ((A = d.value) == null ? void 0 : A.schemaName);
338
+ }
339
+ ), u.value = (p = oe.value.find(
340
+ (ce) => {
341
+ var A;
342
+ return ce.value.name === ((A = d.value) == null ? void 0 : A.name);
343
+ }
344
+ )) == null ? void 0 : p.value, B.value = (c = d.value) == null ? void 0 : c.option, Y.value = ((y = d.value) == null ? void 0 : y.tileIds) || [], D.value = ((k = d.value) == null ? void 0 : k.filters) || [], w.value = !!((E = d.value) != null && E.dataFormula), J.value = ((me = d.value) == null ? void 0 : me.dataFormula) || "", ee());
345
+ }), ge(V, (l) => {
346
+ var e;
347
+ l && (H.value = ((e = $.value[0]) == null ? void 0 : e.operator) ?? se(), ue());
348
+ }), ge(Z, (l) => {
349
+ if (!l) {
350
+ V.value = !1, $.value = [], U.value = [];
351
+ return;
352
+ }
353
+ ue();
354
+ }), ge(K, () => {
355
+ ue();
356
+ }), ge(ie, (l) => {
357
+ var p;
358
+ const e = (p = l[0]) == null ? void 0 : p.value;
359
+ e && (l.some((c) => c.value === H.value) || W(e));
360
+ });
361
+ const j = S(
362
+ () => O.schemas.map((l) => ({
363
+ label: l.label || l.name,
364
+ value: l
365
+ }))
366
+ ), oe = S(() => {
367
+ var l;
368
+ return (((l = F.value) == null ? void 0 : l.fields) || []).filter((e) => e.type !== Q.Numeric).map((e) => ({
369
+ label: e.label || e.name,
370
+ value: e
371
+ }));
372
+ }), Ve = S(() => {
373
+ var l;
374
+ return ((l = u.value) == null ? void 0 : l.type) !== Q.Timestamp ? [] : ml(r);
375
+ }), xe = S(() => O.tiles.reduce((l, e, p) => {
376
+ var k, E;
377
+ const c = e.widget.config.schemaNames ?? [], y = (e.widget.config.joinDatasources ?? []).flatMap(
378
+ (me) => me.schemaNames ?? []
379
+ );
380
+ return [...c, ...y].includes(((k = F.value) == null ? void 0 : k.name) || "") && l.push({
381
+ label: (E = e == null ? void 0 : e.widget.title) != null && E.trim() ? e.widget.title : `Widget ${p + 1}`,
382
+ value: e.id
383
+ }), l;
384
+ }, [])), Me = S(
385
+ () => O.schemas.flatMap(
386
+ (l) => (l.fields ?? []).map((e) => ({
387
+ ...e,
388
+ labels: [
389
+ $e(r, n, l.label, "schema"),
390
+ $e(r, n, e.label || e.name, "other")
391
+ ]
392
+ }))
393
+ )
394
+ );
395
+ function Be(l) {
396
+ var e;
397
+ l.name !== ((e = F.value) == null ? void 0 : e.name) && (F.value = l, u.value = void 0, H.value = fe.Equal, V.value = !1, $.value = [], U.value = []);
398
+ }
399
+ function De(l) {
400
+ u.value = l, B.value = l.type === Q.Timestamp ? ke.DateTime : void 0, H.value = se(), V.value = !1, $.value = [], U.value = [];
401
+ }
402
+ function Se(l, e) {
403
+ switch (l) {
404
+ case Q.Timestamp:
405
+ return e === ke.DateTime || e === ke.TimeOfDay ? fe.Between : fe.Equal;
406
+ case Q.Bool:
407
+ case Q.String:
408
+ case Q.Numeric:
409
+ return fe.Equal;
410
+ default:
411
+ throw new Error(`Unsupported data type: ${l}`);
412
+ }
413
+ }
414
+ function ze() {
415
+ if (!F.value) {
416
+ f.open({ message: r("report.section.filter.invalidSchema"), type: "error" });
417
+ return;
418
+ }
419
+ if (!u.value) {
420
+ f.open({ message: r("report.section.filter.invalidDimension"), type: "error" });
421
+ return;
422
+ }
423
+ const l = D.value.filter((c) => c ? !j.value.some((k) => k.value.name === c.schemaName) : !0);
424
+ if (l.length > 0) {
425
+ const c = l.filter((k) => !!k).map((k) => k.schemaName), y = l.some((k) => !k) ? `, ${r("report.section.filter.unknownFilters")}` : "";
426
+ f.open({
427
+ message: r("report.section.filter.invalidFiltersSchemaNotFound", {
428
+ schemas: c.join(", "),
429
+ unknownFiltersSuffix: y
430
+ }),
431
+ type: "error"
432
+ });
433
+ return;
434
+ }
435
+ if (!q())
436
+ return;
437
+ const e = V.value && !K.value ? $.value.map((c) => ({
438
+ label: c.label.trim(),
439
+ operator: c.operator ?? se(),
440
+ values: N(
441
+ [...c.values],
442
+ ve(c.operator)
443
+ )
444
+ })) : void 0, p = V.value && K.value ? U.value.map((c) => ({
445
+ name: c.name.trim(),
446
+ startTime: c.startTime,
447
+ endTime: c.endTime
448
+ })) : void 0;
449
+ d.value = {
450
+ schemaName: F.value.name,
451
+ name: u.value.name,
452
+ label: P.value,
453
+ operator: Se(
454
+ u.value.type,
455
+ u.value.type === Q.Timestamp ? B.value ?? ke.DateTime : null
456
+ ),
457
+ option: u.value.type === Q.Timestamp ? B.value : null,
458
+ values: [],
459
+ tileIds: [...Y.value],
460
+ filters: ne(D.value),
461
+ dataFormula: w.value ? J.value : void 0,
462
+ customOptions: e,
463
+ customTimeRanges: p
464
+ }, x.value = !1;
465
+ }
466
+ function g() {
467
+ x.value = !1;
468
+ }
469
+ const Fe = S(() => {
470
+ var l;
471
+ return [
472
+ (l = F.value) == null ? void 0 : l.name,
473
+ ...D.value.map((e) => e.schemaName)
474
+ ];
475
+ });
476
+ function de(l) {
477
+ var k, E, me, ce;
478
+ const e = O.tiles.find((A) => A.id === l.value), p = ((E = (k = e == null ? void 0 : e.widget) == null ? void 0 : k.config) == null ? void 0 : E.schemaNames) ?? [], c = (((ce = (me = e == null ? void 0 : e.widget) == null ? void 0 : me.config) == null ? void 0 : ce.joinDatasources) ?? []).flatMap(
479
+ (A) => A.schemaNames ?? []
480
+ ), y = [...p, ...c];
481
+ return Fe.value.filter((A) => !!A).some((A) => !y.includes(A));
482
+ }
483
+ return (l, e) => {
484
+ const p = _("FmTextField"), c = _("FmSelect"), y = _("FmCheckbox"), k = _("FmTimePicker"), E = _("FmButton"), me = _("FmTextarea"), ce = _("FmLabel"), A = _("FmIcon"), nl = _("FmTooltip"), rl = _("FmForm"), il = _("FmDialog");
485
+ return s(), T(il, {
486
+ modelValue: x.value,
487
+ "onUpdate:modelValue": e[11] || (e[11] = (Re) => x.value = Re),
488
+ overlay: !0,
489
+ "z-index": 10
490
+ }, {
491
+ "dialog-header": v(() => [
492
+ He(X(o(r)("report.section.filter.globalFilter")), 1)
493
+ ]),
494
+ default: v(() => [
495
+ a(rl, {
496
+ ref: "form",
497
+ class: "flex flex-col gap-2 w-[490px]"
498
+ }, {
499
+ default: v(() => {
500
+ var Re;
501
+ return [
502
+ a(p, {
503
+ modelValue: P.value,
504
+ "onUpdate:modelValue": e[0] || (e[0] = (b) => P.value = b),
505
+ placeholder: o(r)("report.section.filter.displayName"),
506
+ label: o(r)("report.section.filter.displayName"),
507
+ class: "mb-2"
508
+ }, null, 8, ["modelValue", "placeholder", "label"]),
509
+ a(Je, {
510
+ "model-value": F.value,
511
+ items: j.value,
512
+ placeholder: o(r)("report.section.schema.title"),
513
+ label: o(r)("report.section.schema.title"),
514
+ "onUpdate:modelValue": e[1] || (e[1] = (b) => Be(b))
515
+ }, null, 8, ["model-value", "items", "placeholder", "label"]),
516
+ a(Je, {
517
+ "model-value": u.value,
518
+ items: oe.value,
519
+ placeholder: o(r)("report.section.dimension.title"),
520
+ label: o(r)("report.section.dimension.title"),
521
+ "onUpdate:modelValue": e[2] || (e[2] = (b) => De(b))
522
+ }, null, 8, ["model-value", "items", "placeholder", "label"]),
523
+ ((Re = u.value) == null ? void 0 : Re.type) === o(Q).Timestamp ? (s(), T(c, {
524
+ key: 0,
525
+ modelValue: B.value,
526
+ "onUpdate:modelValue": e[3] || (e[3] = (b) => B.value = b),
527
+ items: Ve.value,
528
+ placeholder: o(r)("report.section.filter.timeFormatter"),
529
+ label: o(r)("report.section.filter.timeFormatter")
530
+ }, null, 8, ["modelValue", "items", "placeholder", "label"])) : G("", !0),
531
+ Z.value ? (s(), T(y, {
532
+ key: 1,
533
+ modelValue: V.value,
534
+ "onUpdate:modelValue": e[4] || (e[4] = (b) => V.value = b),
535
+ label: o(r)("report.section.filter.customOptions"),
536
+ value: !0
537
+ }, null, 8, ["modelValue", "label"])) : G("", !0),
538
+ Z.value && V.value ? (s(), C("div", Cl, [
539
+ K.value ? (s(!0), C(le, { key: 0 }, pe(U.value, (b, re) => (s(), C("div", {
540
+ key: `custom-time-range-${re}`,
541
+ class: "flex flex-col gap-2"
542
+ }, [
543
+ h("div", Tl, [
544
+ a(p, {
545
+ modelValue: b.name,
546
+ "onUpdate:modelValue": (ae) => b.name = ae,
547
+ label: o(r)("report.section.filter.label")
548
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
549
+ a(k, {
550
+ "model-value": te(b.startTime),
551
+ label: o(r)("report.date.startingTime"),
552
+ "onUpdate:modelValue": (ae) => t(re, "startTime", ae)
553
+ }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
554
+ a(k, {
555
+ "model-value": te(b.endTime),
556
+ label: o(r)("report.date.endingTime"),
557
+ "onUpdate:modelValue": (ae) => t(re, "endTime", ae)
558
+ }, null, 8, ["model-value", "label", "onUpdate:modelValue"]),
559
+ U.value.length > 1 ? (s(), C("div", Sl, [
560
+ a(E, {
561
+ icon: "delete",
562
+ variant: "tertiary",
563
+ onClick: (ae) => i(re)
564
+ }, null, 8, ["onClick"])
565
+ ])) : G("", !0)
566
+ ])
567
+ ]))), 128)) : (s(), C(le, { key: 1 }, [
568
+ h("p", Ol, X(o(r)("report.section.filter.operator")), 1),
569
+ ie.value.length > 0 ? (s(), T(Je, {
570
+ key: 0,
571
+ "model-value": H.value,
572
+ items: ie.value,
573
+ placeholder: o(r)("report.section.filter.operator"),
574
+ "onUpdate:modelValue": e[5] || (e[5] = (b) => W(b))
575
+ }, null, 8, ["model-value", "items", "placeholder"])) : G("", !0),
576
+ (s(!0), C(le, null, pe($.value, (b, re) => (s(), C("div", {
577
+ key: `custom-option-${re}`,
578
+ class: "flex flex-col gap-2"
579
+ }, [
580
+ h("div", {
581
+ class: Te([
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
+ h("span", $l, X(o(r)("report.section.filter.label")), 1),
587
+ a(p, {
588
+ modelValue: b.label,
589
+ "onUpdate:modelValue": (ae) => b.label = ae
590
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
591
+ (s(), T(cl, {
592
+ key: `custom-option-value-${re}-${b.operator ?? ""}-${B.value ?? ""}`,
593
+ modelValue: b.values,
594
+ "onUpdate:modelValue": (ae) => b.values = ae,
595
+ config: ve(b.operator),
596
+ option: B.value
597
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "config", "option"])),
598
+ $.value.length > 1 ? (s(), C("div", Nl, [
599
+ a(E, {
600
+ icon: "delete",
601
+ variant: "tertiary",
602
+ onClick: (ae) => Ue(re)
603
+ }, null, 8, ["onClick"])
604
+ ])) : G("", !0)
605
+ ])
606
+ ]))), 128))
607
+ ], 64)),
608
+ a(E, {
609
+ class: "w-full",
610
+ variant: "primary",
611
+ icon: "add",
612
+ "icon-position": "prepend",
613
+ onClick: e[6] || (e[6] = (b) => K.value ? We() : we())
614
+ })
615
+ ])) : G("", !0),
616
+ a(y, {
617
+ modelValue: w.value,
618
+ "onUpdate:modelValue": e[7] || (e[7] = (b) => w.value = b),
619
+ label: o(r)("report.section.filter.advance"),
620
+ value: !0
621
+ }, null, 8, ["modelValue", "label"]),
622
+ w.value ? (s(), T(me, {
623
+ key: 3,
624
+ modelValue: J.value,
625
+ "onUpdate:modelValue": e[8] || (e[8] = (b) => J.value = b),
626
+ placeholder: o(r)("report.section.filter.dataFormula")
627
+ }, null, 8, ["modelValue", "placeholder"])) : G("", !0),
628
+ a(pl, {
629
+ modelValue: D.value,
630
+ "onUpdate:modelValue": e[9] || (e[9] = (b) => D.value = b),
631
+ options: Me.value
632
+ }, null, 8, ["modelValue", "options"]),
633
+ a(ce, { class: "mt-2 fm-typo-en-body-lg-600" }, {
634
+ default: v(() => [
635
+ He(X(o(r)("report.section.filter.applyWidget")), 1)
636
+ ]),
637
+ _: 1
638
+ }),
639
+ M.tiles.length > 0 ? (s(), C("div", Ul, [
640
+ (s(!0), C(le, null, pe(xe.value, (b) => (s(), C("div", {
641
+ key: b.value,
642
+ class: "flex items-center"
643
+ }, [
644
+ a(y, {
645
+ modelValue: Y.value,
646
+ "onUpdate:modelValue": e[10] || (e[10] = (re) => Y.value = re),
647
+ label: b.label,
648
+ value: b.value
649
+ }, null, 8, ["modelValue", "label", "value"]),
650
+ de(b) ? (s(), T(nl, {
651
+ key: 0,
652
+ content: o(r)("report.section.filter.missingFilterSchema"),
653
+ "z-index": 99,
654
+ class: "ml-2"
655
+ }, {
656
+ default: v(() => [
657
+ a(A, {
658
+ name: "warning",
659
+ class: "text-fm-color-system-error-300"
660
+ })
661
+ ]),
662
+ _: 1
663
+ }, 8, ["content"])) : G("", !0)
664
+ ]))), 128))
665
+ ])) : (s(), T(ce, {
666
+ key: 5,
667
+ class: "fm-typo-en-body-lg-400",
668
+ label: o(r)("report.section.filter.noWidget")
669
+ }, null, 8, ["label"]))
670
+ ];
671
+ }),
672
+ _: 1
673
+ }, 512)
674
+ ]),
675
+ "dialog-footer": v(() => [
676
+ e[12] || (e[12] = h("div", { class: "grow" }, null, -1)),
677
+ a(E, {
678
+ label: o(r)("report.common.cancel"),
679
+ variant: "tertiary",
680
+ onClick: g
681
+ }, null, 8, ["label"]),
682
+ a(E, {
683
+ label: o(r)("report.common.confirm"),
684
+ onClick: ze
685
+ }, null, 8, ["label"])
686
+ ]),
687
+ _: 1
688
+ }, 8, ["modelValue"]);
689
+ };
690
+ }
691
+ }), Bl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Dl = { class: "flex items-center gap-8" }, Rl = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Il = { class: "flex items-center gap-1 max-w-[195px] w-[195px]" }, ql = { class: "line-clamp-2 overflow-hidden max-w-[195px] w-[195px]" }, Wl = { class: "flex flex-col gap-24" }, zl = { class: "line-clamp-2 overflow-hidden max-w-[195px] w-[195px]" }, Xe = /* @__PURE__ */ he({
692
+ __name: "ReportEditorTab",
693
+ props: /* @__PURE__ */ be({
694
+ hideConfiguration: {
695
+ type: Boolean,
696
+ default: !1
697
+ }
698
+ }, {
699
+ modelValue: { required: !0 },
700
+ modelModifiers: {}
701
+ }),
702
+ emits: /* @__PURE__ */ be(["hideConfiguration"], ["update:modelValue"]),
703
+ setup(M, { emit: r }) {
704
+ const n = ye(M, "modelValue"), { breakpoints: d } = qe(), x = M, f = r, O = ll(), P = tl(), F = R(), {
705
+ currentSelectWidgetType: u,
706
+ categories: B,
707
+ editingTile: Y,
708
+ editingTileIndex: D,
709
+ editingGlobalFilter: J,
710
+ editingGlobalFilterIndex: w
711
+ } = Ie(el()), { schemas: V } = Ie(bl()), { globalFilters: $ } = Ie(_l()), { promptMessage: U } = al(), H = R(!1), ne = R(!1), { t: m, te, locale: _e } = Ne(), Z = R(void 0), K = S(() => {
712
+ const i = n.value.tiles.flatMap((t) => {
713
+ var j;
714
+ const z = t.widget.config.schemaNames ?? [], q = ((j = t.widget.config.joinDatasources) == null ? void 0 : j.flatMap((oe) => oe.schemaNames ?? [])) ?? [];
715
+ return [...z, ...q];
716
+ });
717
+ return [...new Set(i)].reduce((t, z) => {
718
+ const q = V.value.find((j) => j.name === z);
719
+ return q && t.push(q), t;
720
+ }, []);
721
+ });
722
+ function ie(i) {
723
+ if (!i) return "";
724
+ const t = `report.widget.types.${i.toLowerCase()}`;
725
+ return te(t) ? m(t) : $e(m, te, i, "other");
726
+ }
727
+ ge(
728
+ () => u.value,
729
+ () => {
730
+ u.value !== void 0 && (Z.value = vl(u.value), Y.value = Z.value, D.value = -1, O.push({
731
+ name: "tileEditor",
732
+ query: P.query
733
+ }));
734
+ },
735
+ { immediate: !0 }
736
+ ), ge(
737
+ () => n.value.tiles,
738
+ (i) => {
739
+ i.forEach((t) => {
740
+ t.id || (t.id = Oe());
741
+ });
742
+ },
743
+ { immediate: !0, deep: !0 }
744
+ );
745
+ const se = [
746
+ {
747
+ label: "report.common.edit",
748
+ selected: !1,
749
+ variant: "tertiary",
750
+ onClick: (i) => {
751
+ D.value = i, Y.value = JSON.parse(JSON.stringify(n.value.tiles[i])), O.push({
752
+ name: "tileEditor",
753
+ query: P.query
754
+ });
755
+ }
756
+ },
757
+ {
758
+ label: "report.common.duplicate",
759
+ selected: !1,
760
+ variant: "tertiary",
761
+ onClick: (i) => {
762
+ const t = {
763
+ ...JSON.parse(JSON.stringify(n.value.tiles[i])),
764
+ id: Oe()
765
+ };
766
+ n.value.tiles.push(t);
767
+ }
768
+ },
769
+ {
770
+ label: "report.common.remove",
771
+ selected: !1,
772
+ variant: "destructive",
773
+ onClick: async (i) => {
774
+ if (await U({
775
+ title: m("report.editor.deleteWidget"),
776
+ message: m("report.editor.deleteWidgetConfirm", {
777
+ title: n.value.tiles[i].widget.title
778
+ })
779
+ })) {
780
+ const z = n.value.tiles[i].id;
781
+ n.value.tiles.splice(i, 1), n.value.globalFilters && n.value.globalFilters.forEach((q) => {
782
+ var j;
783
+ q.tileIds = (j = q.tileIds) == null ? void 0 : j.filter((oe) => oe !== z);
784
+ });
785
+ }
786
+ }
787
+ }
788
+ ], ve = [
789
+ {
790
+ label: "report.common.edit",
791
+ selected: !1,
792
+ variant: "tertiary",
793
+ onClick: (i) => {
794
+ var t;
795
+ w.value = i, J.value = JSON.parse(JSON.stringify((t = n.value.globalFilters) == null ? void 0 : t[i])), H.value = !0;
796
+ }
797
+ },
798
+ {
799
+ label: "report.common.duplicate",
800
+ selected: !1,
801
+ variant: "tertiary",
802
+ onClick: (i) => {
803
+ var q;
804
+ const t = (q = n.value.globalFilters) == null ? void 0 : q[i];
805
+ if (!t) return;
806
+ const z = JSON.parse(JSON.stringify(t));
807
+ n.value.globalFilters || (n.value.globalFilters = []), n.value.globalFilters.push(z);
808
+ }
809
+ },
810
+ {
811
+ label: "report.common.remove",
812
+ selected: !1,
813
+ variant: "destructive",
814
+ onClick: async (i) => {
815
+ var q, j;
816
+ const t = (q = n.value.globalFilters) == null ? void 0 : q[i];
817
+ if (!t) return;
818
+ await U({
819
+ title: m("report.editor.deleteWidget"),
820
+ message: m("report.editor.deleteWidgetConfirm", {
821
+ title: Le(t)
822
+ })
823
+ }) && ((j = n.value.globalFilters) == null || j.splice(i, 1));
824
+ }
825
+ }
826
+ ], N = S(() => B.value.map((i) => ({
827
+ label: m(`report.category.${i.name}`),
828
+ value: i.id
829
+ }))), { sessionUser: I } = wl(), L = S({
830
+ get: () => n.value.queryVersion === "v2",
831
+ set: (i) => {
832
+ n.value.queryVersion = i ? "v2" : "v1";
833
+ }
834
+ }), ue = [
835
+ { label: m("report.common.noBatch"), value: "none" },
836
+ { label: m("report.common.days"), value: "days" },
837
+ { label: m("report.common.locations"), value: "locations" }
838
+ ], ee = S({
839
+ get: () => {
840
+ var i, t;
841
+ return (i = n.value.batch) != null && i.days ? "days" : (t = n.value.batch) != null && t.locations ? "locations" : "none";
842
+ },
843
+ set: (i) => {
844
+ var t, z;
845
+ i === "none" ? n.value.batch = void 0 : i === "days" ? n.value.batch = { days: ((t = n.value.batch) == null ? void 0 : t.days) || 1 } : i === "locations" && (n.value.batch = { locations: ((z = n.value.batch) == null ? void 0 : z.locations) || 10 });
846
+ }
847
+ }), W = S({
848
+ get: () => {
849
+ var i, t;
850
+ if (ee.value === "days") return ((i = n.value.batch) == null ? void 0 : i.days) ?? 1;
851
+ if (ee.value === "locations") return ((t = n.value.batch) == null ? void 0 : t.locations) ?? 1;
852
+ },
853
+ set: (i) => {
854
+ i && (ee.value === "days" ? n.value.batch = { days: i } : ee.value === "locations" && (n.value.batch = { locations: i }));
855
+ }
856
+ }), we = S({
857
+ get: () => $e(m, te, n.value.name, "other"),
858
+ set: (i) => {
859
+ n.value.name = i;
860
+ }
861
+ });
862
+ function Ue(i) {
863
+ var t;
864
+ return !((t = i.tileIds) != null && t.length);
865
+ }
866
+ function We(i) {
867
+ return !K.value.find((t) => t.name === i.schemaName);
868
+ }
869
+ return ge(
870
+ () => n.value.globalFilters,
871
+ (i) => {
872
+ $.value = JSON.parse(JSON.stringify(i || []));
873
+ },
874
+ { deep: !0, immediate: !0 }
875
+ ), (i, t) => {
876
+ const z = _("FmTextField"), q = _("FmSelect"), j = _("FmSwitch"), oe = _("FmButton"), Ve = _("FmIcon"), xe = _("FmTooltip"), Me = _("FmMenuItem"), Be = _("FmMenu"), De = _("FmListItem"), Se = _("FmList"), ze = _("FmForm");
877
+ return s(), T(sl(o(d).lg || o(d).md ? xl : kl), {
878
+ "model-value": x.hideConfiguration,
879
+ "onUpdate:modelValue": t[12] || (t[12] = (g) => f("hideConfiguration", g))
880
+ }, {
881
+ default: v(() => [
882
+ a(Ml, {
883
+ "is-open": H.value,
884
+ "onUpdate:isOpen": t[0] || (t[0] = (g) => H.value = g),
885
+ "global-filter": o(J),
886
+ tiles: n.value.tiles,
887
+ schemas: K.value,
888
+ "onUpdate:globalFilter": t[1] || (t[1] = (g) => {
889
+ g && (n.value.globalFilters || (n.value.globalFilters = []), typeof o(w) == "number" && o(w) >= 0 ? n.value.globalFilters[o(w)] = g : n.value.globalFilters.push(g));
890
+ })
891
+ }, null, 8, ["is-open", "global-filter", "tiles", "schemas"]),
892
+ a(Fl, {
893
+ modelValue: o(u),
894
+ "onUpdate:modelValue": t[2] || (t[2] = (g) => Ze(u) ? u.value = g : null),
895
+ "is-open": ne.value,
896
+ "onUpdate:isOpen": t[3] || (t[3] = (g) => ne.value = g)
897
+ }, null, 8, ["modelValue", "is-open"]),
898
+ a(ze, {
899
+ ref_key: "form",
900
+ ref: F,
901
+ class: "px-6 py-16 flex flex-col gap-24 overflow-y-auto overflow-x-hidden"
902
+ }, {
903
+ default: v(() => [
904
+ a(Ge, { class: "border-solid" }, {
905
+ header: v(() => [
906
+ h("p", null, X(o(m)("report.editor.reportInfo")), 1),
907
+ t[13] || (t[13] = h("div", { class: "grow" }, null, -1))
908
+ ]),
909
+ content: v(() => [
910
+ h("div", Bl, [
911
+ a(z, {
912
+ modelValue: we.value,
913
+ "onUpdate:modelValue": t[4] || (t[4] = (g) => we.value = g),
914
+ label: o(m)("report.common.name"),
915
+ placeholder: o(m)("report.common.name")
916
+ }, null, 8, ["modelValue", "label", "placeholder"]),
917
+ (s(), T(q, {
918
+ key: `category-${o(_e)}`,
919
+ modelValue: n.value.category,
920
+ "onUpdate:modelValue": t[5] || (t[5] = (g) => n.value.category = g),
921
+ label: o(m)("report.common.category"),
922
+ items: N.value
923
+ }, null, 8, ["modelValue", "label", "items"])),
924
+ a(z, {
925
+ modelValue: n.value.description,
926
+ "onUpdate:modelValue": t[6] || (t[6] = (g) => n.value.description = g),
927
+ label: o(m)("report.common.description"),
928
+ placeholder: o(m)("report.common.description")
929
+ }, null, 8, ["modelValue", "label", "placeholder"]),
930
+ h("div", Dl, [
931
+ t[14] || (t[14] = h("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, "V2", -1)),
932
+ a(j, {
933
+ modelValue: L.value,
934
+ "onUpdate:modelValue": t[7] || (t[7] = (g) => L.value = g)
935
+ }, null, 8, ["modelValue"])
936
+ ]),
937
+ a(q, {
938
+ modelValue: ee.value,
939
+ "onUpdate:modelValue": t[8] || (t[8] = (g) => ee.value = g),
940
+ label: o(m)("report.common.batch"),
941
+ items: ue
942
+ }, null, 8, ["modelValue", "label"]),
943
+ ee.value !== "none" ? (s(), T(z, {
944
+ key: 0,
945
+ modelValue: W.value,
946
+ "onUpdate:modelValue": t[9] || (t[9] = (g) => W.value = g),
947
+ modelModifiers: { number: !0 },
948
+ label: ee.value === "days" ? o(m)("report.common.days") : o(m)("report.common.locations"),
949
+ type: "number"
950
+ }, null, 8, ["modelValue", "label"])) : G("", !0)
951
+ ])
952
+ ]),
953
+ _: 1
954
+ }),
955
+ a(Ge, {
956
+ class: "border-solid",
957
+ "is-open": !1
958
+ }, {
959
+ header: v(() => [
960
+ h("p", null, X(o(m)("report.section.filter.globalFilter")), 1),
961
+ t[15] || (t[15] = h("div", { class: "grow" }, null, -1))
962
+ ]),
963
+ content: v(() => [
964
+ h("div", Rl, [
965
+ a(oe, {
966
+ label: o(m)("report.section.filter.addGlobalFilter"),
967
+ variant: "secondary",
968
+ icon: "add",
969
+ "icon-position": "prepend",
970
+ "border-color": o(Ce).ColorPrimary,
971
+ "text-color": o(Ce).ColorPrimary,
972
+ onClick: t[10] || (t[10] = () => {
973
+ w.value = null, J.value = null, H.value = !0;
974
+ })
975
+ }, null, 8, ["label", "border-color", "text-color"]),
976
+ a(Se, null, {
977
+ default: v(() => [
978
+ a(o(Ke), {
979
+ list: n.value.globalFilters,
980
+ "item-key": "`${element.schemaName}-${element.name}`",
981
+ class: "flex flex-col gap-2 cursor-grab",
982
+ handle: ".handle"
983
+ }, {
984
+ item: v(({ element: g, index: Fe }) => [
985
+ a(De, { class: "!cursor-grab border rounded-md border-neutral-300" }, {
986
+ default: v(() => [
987
+ a(Ve, {
988
+ name: "drag_handle",
989
+ class: "handle"
990
+ }),
991
+ h("div", Il, [
992
+ a(xe, {
993
+ "z-index": 99,
994
+ content: o(Le)(g),
995
+ class: "handle"
996
+ }, {
997
+ default: v(() => [
998
+ h("p", ql, X(o(Le)(g)), 1)
999
+ ]),
1000
+ _: 2
1001
+ }, 1032, ["content"]),
1002
+ We(g) ? (s(), T(xe, {
1003
+ key: 0,
1004
+ content: o(m)("report.section.filter.missingSchema"),
1005
+ "z-index": 99
1006
+ }, {
1007
+ default: v(() => [
1008
+ a(Ve, {
1009
+ name: "warning",
1010
+ class: "text-fm-color-system-error-300"
1011
+ })
1012
+ ]),
1013
+ _: 1
1014
+ }, 8, ["content"])) : Ue(g) ? (s(), T(xe, {
1015
+ key: 1,
1016
+ content: o(m)("report.section.filter.missingTileIds"),
1017
+ "z-index": 99
1018
+ }, {
1019
+ default: v(() => [
1020
+ a(Ve, {
1021
+ name: "warning",
1022
+ class: "text-fm-color-system-warning-300"
1023
+ })
1024
+ ]),
1025
+ _: 1
1026
+ }, 8, ["content"])) : G("", !0)
1027
+ ]),
1028
+ t[16] || (t[16] = h("div", { class: "grow" }, null, -1)),
1029
+ a(Be, {
1030
+ trigger: "click",
1031
+ shift: !0,
1032
+ "stop-click-propagation": !0
1033
+ }, {
1034
+ "menu-button": v(() => [
1035
+ a(oe, {
1036
+ "append-icon": "more_vert",
1037
+ variant: "tertiary"
1038
+ })
1039
+ ]),
1040
+ default: v(() => [
1041
+ (s(), C(le, null, pe(ve, (de, l) => a(Me, {
1042
+ key: l,
1043
+ onClick: (e) => de.onClick(Fe)
1044
+ }, {
1045
+ label: v(() => [
1046
+ h("p", {
1047
+ class: Te(
1048
+ de.variant === "destructive" ? " text-fm-color-system-error-300" : ""
1049
+ )
1050
+ }, X(o(m)(de.label)), 3)
1051
+ ]),
1052
+ _: 2
1053
+ }, 1032, ["onClick"])), 64))
1054
+ ]),
1055
+ _: 2
1056
+ }, 1024)
1057
+ ]),
1058
+ _: 2
1059
+ }, 1024)
1060
+ ]),
1061
+ _: 1
1062
+ }, 8, ["list"])
1063
+ ]),
1064
+ _: 1
1065
+ })
1066
+ ])
1067
+ ]),
1068
+ _: 1
1069
+ }),
1070
+ h("div", Wl, [
1071
+ a(oe, {
1072
+ label: o(m)("report.editor.addWidget"),
1073
+ variant: "secondary",
1074
+ icon: "add",
1075
+ "icon-position": "prepend",
1076
+ "border-color": o(Ce).ColorPrimary,
1077
+ "text-color": o(Ce).ColorPrimary,
1078
+ onClick: t[11] || (t[11] = (g) => ne.value = !0)
1079
+ }, null, 8, ["label", "border-color", "text-color"]),
1080
+ a(Se, null, {
1081
+ default: v(() => [
1082
+ a(o(Ke), {
1083
+ list: n.value.tiles,
1084
+ "item-key": "id",
1085
+ class: "flex flex-col gap-2 cursor-grab",
1086
+ handle: ".handle"
1087
+ }, {
1088
+ item: v(({ element: g, index: Fe }) => [
1089
+ a(De, { class: "!cursor-grab border rounded-md border-neutral-300" }, {
1090
+ default: v(() => [
1091
+ a(Ve, {
1092
+ name: "drag_handle",
1093
+ class: "handle"
1094
+ }),
1095
+ a(xe, {
1096
+ content: g.widget.title ? ie(g.widget.title) : o(m)("report.editor.widget", { index: Fe + 1 }),
1097
+ class: "handle"
1098
+ }, {
1099
+ default: v(() => [
1100
+ h("p", zl, X(g.widget.title ? ie(g.widget.title) : o(m)("report.editor.widget", { index: Fe + 1 })), 1)
1101
+ ]),
1102
+ _: 2
1103
+ }, 1032, ["content"]),
1104
+ t[17] || (t[17] = h("div", { class: "grow" }, null, -1)),
1105
+ a(Be, {
1106
+ trigger: "click",
1107
+ shift: !0,
1108
+ "stop-click-propagation": !0
1109
+ }, {
1110
+ "menu-button": v(() => [
1111
+ a(oe, {
1112
+ "append-icon": "more_vert",
1113
+ variant: "tertiary"
1114
+ })
1115
+ ]),
1116
+ default: v(() => [
1117
+ (s(), C(le, null, pe(se, (de, l) => a(Me, {
1118
+ key: l,
1119
+ onClick: (e) => de.onClick(Fe)
1120
+ }, {
1121
+ label: v(() => [
1122
+ h("p", {
1123
+ class: Te(
1124
+ de.variant === "destructive" ? " text-fm-color-system-error-300" : ""
1125
+ )
1126
+ }, X(o(m)(de.label)), 3)
1127
+ ]),
1128
+ _: 2
1129
+ }, 1032, ["onClick"])), 64))
1130
+ ]),
1131
+ _: 2
1132
+ }, 1024)
1133
+ ]),
1134
+ _: 2
1135
+ }, 1024)
1136
+ ]),
1137
+ _: 1
1138
+ }, 8, ["list"])
1139
+ ]),
1140
+ _: 1
1141
+ })
1142
+ ])
1143
+ ]),
1144
+ _: 1
1145
+ }, 512)
1146
+ ]),
1147
+ _: 1
1148
+ }, 8, ["model-value"]);
1149
+ };
1150
+ }
1151
+ }), El = { class: "h-full w-full overflow-x-hidden" }, Pl = { class: "flex flex-col bg-fm-color-neutral-white w-[400px]" }, Jl = { class: "flex bg-fm-color-neutral-white w-[88px]" }, Ll = {
1152
+ key: 1,
1153
+ class: "w-full overflow-y-auto"
1154
+ }, Hl = {
1155
+ key: 0,
1156
+ class: "w-full grid grid-cols-12 gap-[24px] p-24"
1157
+ }, jl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, Al = { key: 2 }, Gl = {
1158
+ key: 0,
1159
+ class: "grid grid-cols-12 gap-[16px]"
1160
+ }, Kl = { class: "col-span-12 mb-4 flex flex-wrap gap-2 pb-2" }, Ql = {
1161
+ key: 3,
1162
+ class: "h-full w-full flex items-start justify-center bg-fm-color-neutral-white py-24",
1163
+ style: { backgroundColor: "#F6F8FC" }
1164
+ }, Xl = {
1165
+ key: 0,
1166
+ class: "w-full grid grid-cols-12 gap-[24px] p-24"
1167
+ }, Yl = /* @__PURE__ */ he({
1168
+ __name: "ReportEditorViewport",
1169
+ props: /* @__PURE__ */ be({
1170
+ hideConfiguration: { type: Boolean, required: !1, default: !1 },
1171
+ previewWidth: { type: Number, required: !0 },
1172
+ previewHeight: { type: Number, required: !0 },
1173
+ previewScale: { type: Number, required: !0 }
1174
+ }, {
1175
+ modelValue: { required: !0, default: () => {
1176
+ } },
1177
+ modelModifiers: {}
1178
+ }),
1179
+ emits: /* @__PURE__ */ be(["hideConfiguration"], ["update:modelValue"]),
1180
+ setup(M, { emit: r }) {
1181
+ const { breakpoints: n } = qe(), d = ye(M, "modelValue"), x = M, f = S(() => x.previewWidth > 0 && x.previewHeight > 0), O = S(() => n.value.sm || n.value.xs), P = r;
1182
+ return (F, u) => {
1183
+ const B = _("FmCircularProgress"), Y = _("FmButton"), D = _("FmMenuDivider"), J = _("FmCard");
1184
+ return s(), C("div", El, [
1185
+ d.value ? (s(), C(le, { key: 1 }, [
1186
+ f.value ? G("", !0) : (s(), T(fl, {
1187
+ key: 0,
1188
+ "model-value": !x.hideConfiguration
1189
+ }, {
1190
+ right: v(() => [
1191
+ h("div", Pl, [
1192
+ d.value ? (s(), T(Xe, {
1193
+ key: 0,
1194
+ modelValue: d.value,
1195
+ "onUpdate:modelValue": u[0] || (u[0] = (w) => d.value = w),
1196
+ "hide-configuration": x.hideConfiguration,
1197
+ onHideConfiguration: u[1] || (u[1] = (w) => P("hideConfiguration", w))
1198
+ }, null, 8, ["modelValue", "hide-configuration"])) : G("", !0)
1199
+ ])
1200
+ ]),
1201
+ left: v(() => [
1202
+ h("div", Jl, [
1203
+ a(Y, {
1204
+ variant: "secondary",
1205
+ icon: "keyboard_double_arrow_right",
1206
+ "border-color": o(Ce).ColorPrimary,
1207
+ "text-color": o(Ce).ColorPrimary,
1208
+ class: "m-24 my-16",
1209
+ size: "md",
1210
+ onClick: u[2] || (u[2] = (w) => P("hideConfiguration", !x.hideConfiguration))
1211
+ }, null, 8, ["border-color", "text-color"])
1212
+ ])
1213
+ ]),
1214
+ _: 1
1215
+ }, 8, ["model-value"])),
1216
+ a(D, {
1217
+ vertical: "",
1218
+ style: { margin: "0px" }
1219
+ }),
1220
+ !O.value && !f.value ? (s(), C("div", Ll, [
1221
+ d.value.tiles.length > 0 ? (s(), C("div", Hl, [
1222
+ h("div", jl, [
1223
+ a(Qe)
1224
+ ]),
1225
+ (s(!0), C(le, null, pe(d.value.tiles, (w, V) => (s(), T(Ee, {
1226
+ key: `${o(Oe)()}_${V}`,
1227
+ "model-value": w,
1228
+ index: V,
1229
+ "hide-export": !0
1230
+ }, null, 8, ["model-value", "index"]))), 128))
1231
+ ])) : (s(), T(Pe, { key: 1 }))
1232
+ ])) : O.value && !f.value ? (s(), C("div", Al, [
1233
+ a(J, { class: "px-5 pb-28" }, {
1234
+ default: v(() => [
1235
+ d.value.tiles.length > 0 ? (s(), C("div", Gl, [
1236
+ h("div", Kl, [
1237
+ a(Qe)
1238
+ ]),
1239
+ (s(!0), C(le, null, pe(d.value.tiles, (w, V) => (s(), T(Ee, {
1240
+ key: `${o(Oe)()}_${V}`,
1241
+ "model-value": w,
1242
+ index: V,
1243
+ "hide-export": !0
1244
+ }, null, 8, ["model-value", "index"]))), 128))
1245
+ ])) : (s(), T(Pe, { key: 1 }))
1246
+ ]),
1247
+ _: 1
1248
+ }),
1249
+ d.value ? (s(), T(Xe, {
1250
+ key: 0,
1251
+ modelValue: d.value,
1252
+ "onUpdate:modelValue": u[3] || (u[3] = (w) => d.value = w),
1253
+ "hide-configuration": x.hideConfiguration,
1254
+ onHideConfiguration: u[4] || (u[4] = (w) => {
1255
+ P("hideConfiguration", w);
1256
+ })
1257
+ }, null, 8, ["modelValue", "hide-configuration"])) : G("", !0)
1258
+ ])) : (s(), C("div", Ql, [
1259
+ h("div", {
1260
+ style: je({
1261
+ transformOrigin: "top center",
1262
+ transform: `scale(${x.previewScale})`
1263
+ })
1264
+ }, [
1265
+ h("div", {
1266
+ class: "overflow-y-auto bg-white rounded-lg",
1267
+ style: je({
1268
+ width: x.previewWidth + "px",
1269
+ height: x.previewHeight + "px"
1270
+ })
1271
+ }, [
1272
+ d.value.tiles.length > 0 ? (s(), C("div", Xl, [
1273
+ (s(!0), C(le, null, pe(d.value.tiles, (w, V) => (s(), T(Ee, {
1274
+ key: `${o(Oe)()}_${V}`,
1275
+ "model-value": w,
1276
+ index: V,
1277
+ "hide-export": !0,
1278
+ "custom-screen-width": x.previewWidth
1279
+ }, null, 8, ["model-value", "index", "custom-screen-width"]))), 128))
1280
+ ])) : (s(), T(Pe, { key: 1 }))
1281
+ ], 4)
1282
+ ], 4)
1283
+ ]))
1284
+ ], 64)) : (s(), T(B, { key: 0 }))
1285
+ ]);
1286
+ };
1287
+ }
1288
+ }), Zl = { class: "flex items-center gap-4" }, et = { class: "flex justify-center items-center gap-2 w-full" }, lt = { class: "flex gap-4" }, gt = /* @__PURE__ */ he({
1289
+ __name: "ReportEditor",
1290
+ setup(M) {
1291
+ const r = ll(), n = tl(), d = el(), { promptLoader: x } = yl(), { t: f, te: O } = Ne(), { currentReport: P, editingReport: F } = Ie(d), { breakpoints: u } = qe(), B = S(() => {
1292
+ var N;
1293
+ return !((N = F.value) != null && N.editable);
1294
+ }), Y = S(() => {
1295
+ var N;
1296
+ return ((N = F.value) == null ? void 0 : N.name) ?? f("report.editor.newReport");
1297
+ }), D = S(() => $e(f, O, Y.value, "other")), J = ol(), { promptMessage: w } = al(), V = R(!1), $ = S(() => [
1298
+ { label: f("report.common.cancel"), value: "cancel", isPrimary: !1 },
1299
+ { label: f("report.common.save"), value: "save", isPrimary: !0, prependIcon: "download" }
1300
+ ]);
1301
+ async function U() {
1302
+ if (!F.value || F.value.tiles.length === 0) {
1303
+ J.open({ message: f("report.messages.noWidget"), type: "error" });
1304
+ return;
1305
+ }
1306
+ const N = B.value ? f("report.common.clone") : f("report.common.save");
1307
+ if (await w({
1308
+ title: `${f("report.messages.saveReport")}`,
1309
+ message: f("report.messages.confirmAction", { action: N, name: D.value })
1310
+ }))
1311
+ try {
1312
+ await x(async () => {
1313
+ if (B.value) {
1314
+ const L = JSON.parse(JSON.stringify(F.value));
1315
+ L.editable = !0, L.id = "", L.name = `${L.name} ${f("report.common.duplicate")}`, L.isDefault = !1, await d.createOrUpdateReport(L);
1316
+ } else
1317
+ F.value && await d.createOrUpdateReport(F.value);
1318
+ r.push({
1319
+ name: "reportView",
1320
+ query: n.query
1321
+ });
1322
+ });
1323
+ } catch (L) {
1324
+ console.log(L), J.open({
1325
+ message: f("report.messages.failedToAction", { action: N }),
1326
+ type: "error"
1327
+ });
1328
+ }
1329
+ }
1330
+ async function H() {
1331
+ var I;
1332
+ if (!F.value) return;
1333
+ await w({
1334
+ title: f("report.common.report", 1),
1335
+ message: f("report.editor.notSaved", { name: (I = F.value) == null ? void 0 : I.name })
1336
+ }) && (F.value = JSON.parse(JSON.stringify(P.value)), r.back());
1337
+ }
1338
+ ul(() => {
1339
+ F.value || r.push({ name: "reports" });
1340
+ });
1341
+ const ne = [
1342
+ {
1343
+ labelKey: "report.common.default",
1344
+ width: void 0,
1345
+ height: void 0
1346
+ },
1347
+ {
1348
+ labelKey: "report.editor.devices.desktop",
1349
+ width: 1920,
1350
+ height: 1080
1351
+ },
1352
+ {
1353
+ labelKey: "report.editor.devices.tablet",
1354
+ width: 820,
1355
+ height: 1180
1356
+ },
1357
+ {
1358
+ labelKey: "report.editor.devices.phone",
1359
+ width: 390,
1360
+ height: 859
1361
+ }
1362
+ ], m = R(ne[0]), te = R(!1), _e = S(() => te.value ? Math.max(m.value.width || 0, m.value.height || 0) : Math.min(m.value.width || 0, m.value.height || 0)), Z = S(() => te.value ? Math.min(m.value.width || 0, m.value.height || 0) : Math.max(m.value.width || 0, m.value.height || 0)), K = S(() => window.innerHeight - 72 - 56), ie = S(() => {
1363
+ if (!_e.value) return 1;
1364
+ let N = (K.value - 48) / _e.value, I = Z.value * N;
1365
+ return I > window.innerWidth && (N = window.innerWidth / Z.value, I = Z.value * N), N > 1 ? 1 : N;
1366
+ });
1367
+ function se(N) {
1368
+ m.value = N;
1369
+ }
1370
+ function ve() {
1371
+ te.value = !te.value;
1372
+ }
1373
+ return (N, I) => {
1374
+ const L = _("FmTooltip"), ue = _("FmButton"), ee = _("FmPageHead");
1375
+ return s(), T(gl, null, {
1376
+ default: v(() => [
1377
+ a(ee, {
1378
+ "data-editor-header": "true",
1379
+ actions: $.value,
1380
+ "onClick:action": I[0] || (I[0] = (W) => {
1381
+ W === "cancel" && H(), W === "save" && U();
1382
+ })
1383
+ }, {
1384
+ title: v(() => [
1385
+ h("div", Zl, [
1386
+ a(L, {
1387
+ content: D.value,
1388
+ placement: "bottom"
1389
+ }, {
1390
+ default: v(() => [
1391
+ h("p", {
1392
+ class: Te(`${o(u).sm || o(u).xs ? "hidden" : ""} text-ellipsis overflow-hidden text-nowrap fm-typo-en-title-md-600 w-[250px]`)
1393
+ }, X(D.value), 3)
1394
+ ]),
1395
+ _: 1
1396
+ }, 8, ["content"]),
1397
+ h("div", et, [
1398
+ h("div", lt, [
1399
+ (s(), C(le, null, pe(ne, (W) => {
1400
+ var we;
1401
+ return a(ue, {
1402
+ key: W.labelKey,
1403
+ label: o(f)(W.labelKey),
1404
+ variant: ((we = m.value) == null ? void 0 : we.labelKey) === W.labelKey ? "primary" : "secondary",
1405
+ size: "md",
1406
+ onClick: (Ue) => se(W)
1407
+ }, null, 8, ["label", "variant", "onClick"]);
1408
+ }), 64))
1409
+ ]),
1410
+ a(ue, {
1411
+ icon: "screen_rotation",
1412
+ variant: "tertiary",
1413
+ size: "md",
1414
+ class: "text-fm-color-typo-primary",
1415
+ onClick: ve
1416
+ })
1417
+ ])
1418
+ ])
1419
+ ]),
1420
+ _: 1
1421
+ }, 8, ["actions"]),
1422
+ o(F) ? (s(), T(Yl, {
1423
+ key: 0,
1424
+ modelValue: o(F),
1425
+ "onUpdate:modelValue": I[1] || (I[1] = (W) => Ze(F) ? F.value = W : null),
1426
+ style: je({ height: K.value + "px" }),
1427
+ class: Te(o(u).lg || o(u).md ? "flex" : ""),
1428
+ "hide-configuration": V.value,
1429
+ "preview-width": Z.value,
1430
+ "preview-height": _e.value,
1431
+ "preview-scale": ie.value,
1432
+ onHideConfiguration: I[2] || (I[2] = (W) => V.value = W)
1433
+ }, null, 8, ["modelValue", "style", "class", "hide-configuration", "preview-width", "preview-height", "preview-scale"])) : G("", !0)
1434
+ ]),
1435
+ _: 1
1436
+ });
1437
+ };
1438
+ }
1439
+ });
1440
+ export {
1441
+ gt as default
1442
+ };