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