@feedmepos/mf-menu 0.32.3-beta.1 → 0.32.4-dev

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 (84) hide show
  1. package/dist/{App-DJBZBaaC.js → App-5YVGeojR.js} +5 -5
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-c9SlmPp2.js → ApplyProduct.vue_vue_type_script_setup_true_lang-DhoHYIHW.js} +20 -20
  3. package/dist/{Catalog-Ct9jk3A_.js → Catalog-BTNv5n_D.js} +18 -18
  4. package/dist/{Category-Cf5KfKdv.js → Category-BE-kkKcL.js} +22 -23
  5. package/dist/{Category-CTTAtG31.js → Category-DuLhbRxE.js} +21 -22
  6. package/dist/{CookingGuide-BaNzajgf.js → CookingGuide-JtE8QMC6.js} +92 -93
  7. package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-CRodr6tr.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-DdJ-o_PW.js} +1 -1
  8. package/dist/FormItem.vue_vue_type_script_setup_true_lang-B3Ixruh-.js +26 -0
  9. package/dist/{Group-BfRPCCbK.js → Group-BP-j3K6J.js} +1 -1
  10. package/dist/{Group-BJep-xq-.js → Group-DhS9e2E3.js} +3 -3
  11. package/dist/{Group.vue_vue_type_script_setup_true_lang-CoCq0edM.js → Group.vue_vue_type_script_setup_true_lang-DXUQrXXI.js} +33 -34
  12. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-DviXfima.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-CXzz4ClS.js} +24 -23
  13. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-DSrxcKIK.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-Bpt-8tbe.js} +11525 -11504
  14. package/dist/{Ingredient-BnzW69zW.js → Ingredient-NSl0x-0T.js} +5 -6
  15. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-D8m1pyLp.js → InventoryBinding.vue_vue_type_script_setup_true_lang-ByrNVvzs.js} +2 -2
  16. package/dist/LinkProductSideSheet-B_R_2iH6.js +692 -0
  17. package/dist/MenuSetting-C7cpv4S3.js +580 -0
  18. package/dist/{PrintRoute-CLsiDIkn.js → PrintRoute-DmP7KH58.js} +10 -11
  19. package/dist/{Product-DHE0XtX1.js → Product-B6gwN4g0.js} +1 -1
  20. package/dist/{Product.vue_vue_type_script_setup_true_lang-CVR8j-XT.js → Product.vue_vue_type_script_setup_true_lang-BKhn8Txf.js} +15 -16
  21. package/dist/{ProductInternalTools-BQOXHzYp.js → ProductInternalTools-D5xIh2j2.js} +5 -5
  22. package/dist/Products-Cxx8pJGK.js +692 -0
  23. package/dist/{Publish-BlEcoJaI.js → Publish-ZCzRBB5V.js} +21 -22
  24. package/dist/{Recipe-CkcNxf7p.js → Recipe-DcHdr_5J.js} +9 -10
  25. package/dist/RuleView.vue_vue_type_script_setup_true_lang-edNbsZTq.js +3282 -0
  26. package/dist/{Scheduler-DV0s_qkV.js → Scheduler-ZhDXk5gQ.js} +18 -19
  27. package/dist/{ServingSequence-CFd8Nwws.js → ServingSequence-DcfMbHjn.js} +15 -16
  28. package/dist/{Setting-B55IsZCX.js → Setting-fqf_sOIc.js} +45 -44
  29. package/dist/{Subcategory-BXCcVdR3.js → Subcategory-BidmfEOK.js} +18 -19
  30. package/dist/{Takeaway-BDvcwBHP.js → Takeaway-C83SKEvl.js} +1 -1
  31. package/dist/{Takeaway--U_lsgYi.js → Takeaway-p6thRg74.js} +4 -4
  32. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-DaYk2xdF.js → Takeaway.vue_vue_type_script_setup_true_lang-Dq6CjXCv.js} +48 -49
  33. package/dist/{Thumbnail.vue_vue_type_script_setup_true_lang-VBpTghy9.js → Thumbnail.vue_vue_type_script_setup_true_lang-CjLOy2k9.js} +10 -10
  34. package/dist/{TreeEditorOpenner.vue_vue_type_script_setup_true_lang-IBM6rC5M.js → TreeEditorOpenner.vue_vue_type_script_setup_true_lang-CWdsp9eo.js} +17 -16
  35. package/dist/{Unit-DkvTsQWA.js → Unit-CKIaBxVE.js} +7 -8
  36. package/dist/{Variant-tte76SbR.js → Variant-CE21vKC4.js} +38 -39
  37. package/dist/{_id_-AVMi3j91.js → _id_-BhWpg9Kj.js} +10 -10
  38. package/dist/{app-0s3jY-aE.js → app-BkcVM9nE.js} +1 -1
  39. package/dist/app-CEIhTuYG.js +363 -0
  40. package/dist/app.js +1 -1
  41. package/dist/apps/mf-menu/src/app.d.ts +250 -0
  42. package/dist/apps/mf-menu/src/components/rule_group/CatalogLinkItemRuleForm.vue.d.ts +146 -0
  43. package/dist/apps/mf-menu/src/components/rule_group/CatalogLinkItemRuleView.vue.d.ts +158 -0
  44. package/dist/apps/mf-menu/src/components/rule_group/RuleCondition.vue.d.ts +103 -0
  45. package/dist/apps/mf-menu/src/components/rule_group/RuleConditionListView.vue.d.ts +54 -0
  46. package/dist/apps/mf-menu/src/components/rule_group/RuleConditionSelector.vue.d.ts +50 -0
  47. package/dist/apps/mf-menu/src/components/rule_group/RuleForm.vue.d.ts +117 -0
  48. package/dist/apps/mf-menu/src/components/rule_group/RuleView.vue.d.ts +141 -0
  49. package/dist/apps/mf-menu/src/composable/attributes.d.ts +10 -0
  50. package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +2 -3
  51. package/dist/apps/mf-menu/src/helper/menuExport.d.ts +3 -1
  52. package/dist/apps/mf-menu/src/helper/menuImport.d.ts +3 -2
  53. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  54. package/dist/assets/{linked-status-DEGoFflv.js → linked-status-CStQ46Ze.js} +2 -2
  55. package/dist/assets/{override-menu-CZe07SCm.js → override-menu-DHTQAnIJ.js} +2 -2
  56. package/dist/assets/{validate-menu-BnHfAUEN.js → validate-menu-C_kUDOhd.js} +2 -2
  57. package/dist/{catalog-YE_knev1.js → catalog-WBrPmQwl.js} +1 -1
  58. package/dist/{catalogSetting-CeVHRHOo.js → catalogSetting-BAry7I_V.js} +1 -1
  59. package/dist/{category-Dph1iWr8.js → category-bW36h16p.js} +1 -1
  60. package/dist/{currency-Byslycrk.js → currency-vVxHIVBs.js} +1 -1
  61. package/dist/{index-C0T32LLy.js → index-Ba5-dCQA.js} +1 -1
  62. package/dist/{index-CUTY6cCm.js → index-C0EV3eSc.js} +20 -20
  63. package/dist/{index-DycbrG1l.js → index-XZlEgR2k.js} +8 -7
  64. package/dist/{index-Ddt_Nw9F.js → index-pxnQHVnU.js} +4 -4
  65. package/dist/{menu-tHhzkxDL.js → index.vue_vue_type_script_setup_true_lang-CFPMPQFg.js} +18612 -18558
  66. package/dist/item-mFv0bFSn.js +7648 -0
  67. package/dist/{iteration-CcobmcUk.js → iteration-CaFp1Rtz.js} +3 -3
  68. package/dist/{jszip.min-DQrtMdm5.js → jszip.min-BkSmQKmf.js} +353 -353
  69. package/dist/{menu-DkRrqTVY.js → menu-ud-tWfIM.js} +1 -1
  70. package/dist/{menuV2-DJevKCqE.js → menuV2-xUMdUls0.js} +65 -65
  71. package/dist/mf-menu.css +1 -1
  72. package/dist/{priceTier-Bkogs1qc.js → priceTier-BVTab4k1.js} +1 -1
  73. package/dist/{scheduler-BGQ_lxUL.js → scheduler-CAt7sELO.js} +13 -12
  74. package/dist/{subcategory-DvxvLe8X.js → subcategory-DMZuedoM.js} +2 -2
  75. package/dist/{toExcel-DQ4jlZPI.js → toExcel-CczXOnKy.js} +2 -2
  76. package/dist/{unit-DoxpI5dG.js → unit-CbD3sYqC.js} +2 -2
  77. package/package.json +4 -3
  78. package/dist/LinkProductSideSheet-C4yBnJSM.js +0 -361
  79. package/dist/MenuSetting-Fxl8F6N5.js +0 -618
  80. package/dist/Products-BLvwrz9P.js +0 -689
  81. package/dist/app-CjfWVFOg.js +0 -363
  82. package/dist/customAttributes-DvbvCfOd.js +0 -180
  83. package/dist/index.vue_vue_type_script_setup_true_lang-B1_JqsYF.js +0 -57
  84. package/dist/item-x1WWjISR.js +0 -9175
@@ -0,0 +1,692 @@
1
+ var de = Object.defineProperty;
2
+ var pe = (v, e, n) => e in v ? de(v, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : v[e] = n;
3
+ var K = (v, e, n) => pe(v, typeof e != "symbol" ? e + "" : e, n);
4
+ import { defineComponent as j, computed as D, ref as oe, resolveComponent as $, createBlock as N, openBlock as T, unref as l, withCtx as E, createElementVNode as S, toDisplayString as ae, createVNode as _, createCommentVNode as re, createElementBlock as B, Fragment as H } from "vue";
5
+ import { D as V } from "./iteration-CaFp1Rtz.js";
6
+ import { m as A, A as O, f as g, a as L, b as J, e as P, n as U, w as fe } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-Bpt-8tbe.js";
7
+ import { J as be, F as he } from "./jszip.min-BkSmQKmf.js";
8
+ import { u as ne, D as ie, A as z, G as q, z as se, B as ge, H as X, I as Z } from "./index.vue_vue_type_script_setup_true_lang-CFPMPQFg.js";
9
+ import { useCoreStore as ce, useI18n as ye } from "@feedmepos/mf-common";
10
+ import { useDialog as me, useDialogChild as _e, useSnackbar as le, useBreakpoints as ke, FmButtonVariant as Y, FmButtonColorThemeVariant as G } from "@feedmepos/ui-library";
11
+ import { _ as W } from "./ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js";
12
+ import { _ as ve, a as Q } from "./BottomSheetMenuItem.vue_vue_type_script_setup_true_lang-CnCoRLDg.js";
13
+ import { _ as we } from "./PageLayout.vue_vue_type_script_setup_true_lang-vFqWGM6P.js";
14
+ import { u as xe, a as Ce } from "./menu-ud-tWfIM.js";
15
+ import { u as Fe } from "./item-mFv0bFSn.js";
16
+ import { _ as ee, a as Me } from "./Product.vue_vue_type_script_setup_true_lang-BKhn8Txf.js";
17
+ import { L as te } from "./LinkProductSideSheet-B_R_2iH6.js";
18
+ import { _ as Ie } from "./TreeEditorOpenner.vue_vue_type_script_setup_true_lang-CWdsp9eo.js";
19
+ import { u as Se } from "./Thumbnail.vue_vue_type_script_setup_true_lang-CjLOy2k9.js";
20
+ import { m as Ee } from "./toExcel-CczXOnKy.js";
21
+ const Te = { class: "space-y-24 mb-24" }, De = ["innerHTML"], Ne = { class: "flex justify-end gap-8" }, Ke = /* @__PURE__ */ j({
22
+ __name: "ConfirmActionDialog",
23
+ props: {
24
+ description: {},
25
+ value: {},
26
+ message: { default: "To confirm your action, type <b>[[value]]</b> in the text field." }
27
+ },
28
+ setup(v) {
29
+ const e = v, n = D(() => e.message.replace("[[value]]", e.value)), i = oe(""), t = me(), { emitAction: o } = _e();
30
+ return (r, a) => {
31
+ const m = $("FmTextField"), c = $("FmButton"), u = $("FmForm");
32
+ return T(), N(u, {
33
+ "on-validation-success": () => l(o)("primary"),
34
+ "blame-form-child-on-validation-failed": ""
35
+ }, {
36
+ default: E(() => [
37
+ S("div", Te, [
38
+ S("div", null, ae(v.description), 1),
39
+ S("div", { innerHTML: n.value }, null, 8, De),
40
+ S("div", null, [
41
+ _(m, {
42
+ modelValue: i.value,
43
+ "onUpdate:modelValue": [
44
+ a[0] || (a[0] = (s) => i.value = s),
45
+ a[1] || (a[1] = () => {
46
+ })
47
+ ],
48
+ placeholder: v.value,
49
+ rules: [(s) => s === v.value || "Value does not match"]
50
+ }, null, 8, ["modelValue", "placeholder", "rules"])
51
+ ]),
52
+ S("div", Ne, [
53
+ _(c, {
54
+ label: "Cancel",
55
+ variant: "secondary",
56
+ onClick: a[2] || (a[2] = (s) => l(t).close())
57
+ }),
58
+ _(c, {
59
+ label: "Confirm",
60
+ type: "submit"
61
+ })
62
+ ])
63
+ ])
64
+ ]),
65
+ _: 1
66
+ }, 8, ["on-validation-success"]);
67
+ };
68
+ }
69
+ }), Ge = /* @__PURE__ */ j({
70
+ __name: "Migrate",
71
+ setup(v) {
72
+ const e = ne(), n = ce(), i = le(), { minor: t } = ie(i), o = oe(!1), r = me();
73
+ async function a() {
74
+ m.value || o.value || r.open({
75
+ title: "Migrate to new version",
76
+ contentComponent: Ke,
77
+ contentComponentProps: {
78
+ value: "MIGRATE",
79
+ description: "Do you want to migrate to new version? Once migrate it will unable to revert to the older version."
80
+ }
81
+ }).onPrimary(async () => {
82
+ r.close(), await t(
83
+ async () => {
84
+ await e.migrate(), setTimeout(() => {
85
+ window.location.reload();
86
+ }, 2e3);
87
+ },
88
+ {
89
+ isLoading: o,
90
+ customId: e.state.menu._id,
91
+ message: "Migrating menu",
92
+ successMessage: "Migration completed"
93
+ }
94
+ );
95
+ });
96
+ }
97
+ const m = D(() => {
98
+ const c = n.restaurants.value;
99
+ if (!c.length) return "Required at least one restaurant to migrate";
100
+ const u = c.filter((d) => !d.posVersion || !z.Pos.canUse({ feature: q.F_FEATURE.enum.menuV4, posVersion: d.posVersion }));
101
+ return u.length ? `Upgrade POS to V${z.Pos.minVersionToUse(q.F_FEATURE.enum.menuV4)} to use new menu: ${u.map((d) => d.profile.name).join(", ")}` : null;
102
+ });
103
+ return D(() => m.value ? m.value : "Migrate your menu to new version to enjoy more features. Content of new menu will remain the same as current."), (c, u) => {
104
+ const s = $("FmSnackbar");
105
+ return !m.value && l(e).version !== l(se.F_MENU_VERSION).enum.v4 ? (T(), N(s, {
106
+ key: 0,
107
+ class: "!max-w-full",
108
+ title: "New version of menu is out now!",
109
+ description: "Migrate your current menu version to the latest to enjoy more features such as product sequential dispatch, serving sequence, scheduler and more! Your content and current setting will be preserved.",
110
+ variant: "info",
111
+ action: "Migrate",
112
+ "z-index": 0,
113
+ onOnAction: a
114
+ })) : re("", !0);
115
+ };
116
+ }
117
+ });
118
+ class Ve {
119
+ constructor(e, n) {
120
+ K(this, "menu");
121
+ K(this, "categoryMap");
122
+ K(this, "takeawayMap");
123
+ K(this, "subCategoryMap");
124
+ K(this, "attributeSettings");
125
+ this.menu = e, this.attributeSettings = n, this.categoryMap = e.modules.category.reduce((t, o) => (t[o._id] = o, t), {}), this.takeawayMap = e.modules.takeaway.reduce((t, o) => (t[o._id] = o, t), {});
126
+ const i = e.modules.subCategory || [];
127
+ this.subCategoryMap = i.reduce((t, o) => (t[o._id] = o, t), {});
128
+ }
129
+ transformData() {
130
+ let e = [];
131
+ return this.menu.modules.item.forEach((n) => {
132
+ var a;
133
+ const i = n.variant ? A(this.menu, n.variant.variantGroupIds) : {}, t = this.transformProductToDataRow(n, i), r = (((a = n.variant) == null ? void 0 : a.variantCombinations) ?? []).reduce(
134
+ (m, c) => {
135
+ const u = this.transformProductToDataRow(
136
+ n,
137
+ i,
138
+ c.combinationKey
139
+ );
140
+ return m.push(u), m;
141
+ },
142
+ [t]
143
+ );
144
+ e = [...e, ...r];
145
+ }), {
146
+ rows: e,
147
+ metaData: {
148
+ priceTiers: []
149
+ }
150
+ };
151
+ }
152
+ transformOverrideData(e) {
153
+ let n = [], i = [];
154
+ const t = e.reduce(
155
+ (o, r) => (o[r._id] || (o[r._id] = []), r.combinationKey && o[r._id].push(r.combinationKey), o),
156
+ {}
157
+ );
158
+ for (let o = 0; o < e.length; o++) {
159
+ const r = e[o], a = this.menu.modules.item.find((m) => m._id === r._id);
160
+ if (a && a.variant) {
161
+ const m = a.variant.variantCombinations.map(
162
+ (d) => d.combinationKey
163
+ ), c = t[r._id] || [], u = m.filter((d) => !c.includes(d)), s = [];
164
+ if (u.forEach((d) => {
165
+ const f = a.variant.variantCombinations.find(
166
+ (w) => w.combinationKey === d
167
+ );
168
+ f && (s.push({
169
+ _id: r._id,
170
+ combinationKey: d,
171
+ price: f.price,
172
+ orderFrom: f.orderFrom
173
+ }), t[r._id].push(d));
174
+ }), s.length > 0) {
175
+ const d = e.findIndex((w) => w._id === r._id && !w.combinationKey), f = d >= 0 ? d + 1 : o + 1;
176
+ e.splice(f, 0, ...s), o += s.length;
177
+ }
178
+ }
179
+ }
180
+ for (let o = 0; o < e.length; o++) {
181
+ const r = e[o], a = this.menu.modules.item.find((s) => s._id === r._id);
182
+ if (!a)
183
+ throw new Error(`Invalid item ${r._id} in catalog`);
184
+ const m = a.variant ? A(this.menu, a.variant.variantGroupIds) : {}, u = [this.transformOverrideDataToRow(r, m)];
185
+ i = [...i, ...u.flatMap((s) => Object.keys(s.priceTier))], n = [...n, ...u];
186
+ }
187
+ return {
188
+ rows: n,
189
+ metaData: {
190
+ priceTiers: []
191
+ }
192
+ };
193
+ }
194
+ getSubCategoryNames(e, n) {
195
+ return n || !e.subCategories ? "" : e.subCategories.map((i) => {
196
+ var t;
197
+ return ((t = this.subCategoryMap[i]) == null ? void 0 : t.name) || "";
198
+ }).filter((i) => i).join(",");
199
+ }
200
+ transformProductToDataRow(e, n, i) {
201
+ var m, c, u;
202
+ const t = (m = e.variant) == null ? void 0 : m.variantCombinations.find(
203
+ (s) => s.combinationKey === i
204
+ );
205
+ if (i && !t)
206
+ throw new Error(`Invalid combination key ${i}`);
207
+ const o = e.category ? (c = this.categoryMap[e.category]) == null ? void 0 : c.name : O;
208
+ let r;
209
+ if (t ? r = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0 : r = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0, !o)
210
+ throw new Error(`Invalid category ${e.category}`);
211
+ const a = this.getSubCategoryNames(e, !!t);
212
+ return {
213
+ _id: e._id,
214
+ code: t && t.code || e.code,
215
+ name: e.name,
216
+ variantKey: (t == null ? void 0 : t.combinationKey) ?? "",
217
+ variantName: t ? n[t.combinationKey] : "",
218
+ category: o,
219
+ subCategories: a,
220
+ orderFrom: t ? t.orderFrom ?? e.orderFrom : e.orderFrom,
221
+ perXUnit: e.perXUnit || "",
222
+ unit: e.unit || "",
223
+ openPrice: e.openPrice === !0 ? "T" : "",
224
+ price: t ? t.price ? parseFloat(g(t.price)) : parseFloat(g(e.price)) : parseFloat(g(e.price)),
225
+ priceTier: e.priceTiers || {},
226
+ trackingCost: e.costing ? parseFloat(g(e.costing)) : "",
227
+ minPrice: e.minPrice ? parseFloat(g(e.minPrice)) : "",
228
+ groupByParent: ((u = e.print) == null ? void 0 : u.toRoot) === !0 ? "" : "T",
229
+ takeawayName: (r == null ? void 0 : r.name) || "",
230
+ takeawayPrice: r != null && r.price ? parseFloat(g(r == null ? void 0 : r.price)) : "",
231
+ tag: e.customAttributes || {}
232
+ };
233
+ }
234
+ transformOverrideDataToRow(e, n, i) {
235
+ var c, u;
236
+ const t = this.menu.modules.item.find((s) => s._id === e._id);
237
+ if (!t)
238
+ throw new Error(`Invalid item ${e._id} in catelog`);
239
+ const o = (c = t.variant) == null ? void 0 : c.variantCombinations.find(
240
+ (s) => s.combinationKey === e.combinationKey
241
+ );
242
+ if (i && !o)
243
+ throw new Error(`Invalid combination key ${i}`);
244
+ const r = () => {
245
+ var s, d;
246
+ return e.category ? e.category ? (d = this.categoryMap[e.category]) == null ? void 0 : d.name : O : t.category ? (s = this.categoryMap[t.category]) == null ? void 0 : s.name : O;
247
+ };
248
+ let a;
249
+ o ? e.takeawayUsed ? a = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : a = o.takeawayUsed ? this.takeawayMap[o.takeawayUsed] : void 0 : e.takeawayUsed ? a = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : a = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0;
250
+ const m = this.getSubCategoryNames(e, !!o);
251
+ return {
252
+ _id: e._id,
253
+ code: e.code ? e.code : o && o.code || t.code,
254
+ name: t.name,
255
+ variantKey: e.combinationKey ? e.combinationKey : (o == null ? void 0 : o.combinationKey) ?? "",
256
+ variantName: o ? n[o.combinationKey] : "",
257
+ category: r(),
258
+ subCategories: m,
259
+ orderFrom: e.orderFrom ? e.orderFrom : o ? o.orderFrom ?? t.orderFrom : t.orderFrom,
260
+ perXUnit: t.perXUnit || "",
261
+ unit: t.unit || "",
262
+ openPrice: t.openPrice === !0 ? "T" : "",
263
+ price: e.price ? parseFloat(g(e.price)) : o ? o.price ? parseFloat(g(o.price)) : parseFloat(g(t.price)) : parseFloat(g(t.price)),
264
+ priceTier: t.priceTiers || {},
265
+ trackingCost: t.costing ? parseFloat(g(t.costing)) : "",
266
+ minPrice: e.minPrice ? parseFloat(g(e.minPrice)) : t.minPrice ? parseFloat(g(t.minPrice)) : "",
267
+ groupByParent: ((u = t.print) == null ? void 0 : u.toRoot) === !0 ? "" : "T",
268
+ takeawayName: (a == null ? void 0 : a.name) || "",
269
+ takeawayPrice: a != null && a.price ? parseFloat(g(a == null ? void 0 : a.price)) : "",
270
+ tag: t.customAttributes || {}
271
+ };
272
+ }
273
+ transformAddonGroup() {
274
+ return this.mapAddonGroup(this.menu.modules.group);
275
+ }
276
+ transformOverrideAddonGroup(e) {
277
+ return this.mapCatalogAddonGroup(e);
278
+ }
279
+ mapCatalogAddonGroup(e) {
280
+ const n = this.menu.modules.group.map((t) => t._id), i = e.map((t) => t._id);
281
+ return n.forEach((t) => {
282
+ if (!i.includes(t)) {
283
+ const o = this.menu.modules.group.find((r) => r._id === t);
284
+ e.push({
285
+ ...o,
286
+ groupKey: ""
287
+ });
288
+ }
289
+ }), e.sort((t, o) => n.indexOf(t._id) - n.indexOf(o._id)), e.flatMap((t) => {
290
+ const o = this.menu.modules.group.find((a) => a._id === t._id);
291
+ if (!o)
292
+ throw new Error("Invalid addon group id");
293
+ const r = {};
294
+ return o.items.map((a, m) => {
295
+ var b, C, F;
296
+ const c = this.menu.modules.item.find((h) => h._id === a._id);
297
+ if (!c)
298
+ throw new Error("Invalid item id");
299
+ let u;
300
+ a.combinationKey && (u = (b = c.variant) == null ? void 0 : b.variantCombinations.find(
301
+ (h) => h.combinationKey === a.combinationKey
302
+ ));
303
+ const s = (C = t.items) == null ? void 0 : C.find(
304
+ (h) => h._id === a._id && h.combinationKey === a.combinationKey
305
+ ), d = c.name, f = A(
306
+ this.menu,
307
+ ((F = c.variant) == null ? void 0 : F.variantGroupIds) ?? []
308
+ ), w = (s == null ? void 0 : s.price) ?? a.price ?? (u == null ? void 0 : u.price) ?? c.price;
309
+ return a.name && !a.combinationKey && (r[a._id] = a.name), {
310
+ id: t._id,
311
+ name: o.name,
312
+ min: o.min,
313
+ max: o.max,
314
+ stackable: o.stackable === !0 ? "T" : "",
315
+ itemId: a._id,
316
+ itemCode: c.code || "",
317
+ itemName: d,
318
+ itemNameOverrider: r[a._id] || "",
319
+ combinationKey: a.combinationKey ?? "",
320
+ combinationName: a.combinationKey ? f[a.combinationKey] : "",
321
+ price: parseFloat(g(w)),
322
+ priceTier: a.priceTiers || {},
323
+ orderFrom: (s == null ? void 0 : s.orderFrom) ?? a.orderFrom ?? c.orderFrom ?? "ALL",
324
+ isDefault: a.isDefault === !0 ? "T" : "",
325
+ index: m
326
+ };
327
+ });
328
+ });
329
+ }
330
+ mapAddonGroup(e) {
331
+ return e.flatMap((n) => {
332
+ let i = {};
333
+ return i = n.items.reduce((t, o) => (t[o._id] || o.name && !o.combinationKey && (t[o._id] = o.name), t), {}), n.items.map((t, o) => {
334
+ var u, s;
335
+ const r = this.menu.modules.item.find((d) => d._id === t._id);
336
+ if (!r)
337
+ throw new Error("Invalid item id");
338
+ let a;
339
+ t.combinationKey && (a = (u = r.variant) == null ? void 0 : u.variantCombinations.find(
340
+ (d) => d.combinationKey === t.combinationKey
341
+ ));
342
+ const m = t.price ?? (a == null ? void 0 : a.price) ?? r.price, c = A(
343
+ this.menu,
344
+ ((s = r.variant) == null ? void 0 : s.variantGroupIds) ?? []
345
+ );
346
+ return {
347
+ id: n._id,
348
+ name: n.name,
349
+ min: n.min,
350
+ max: n.max,
351
+ stackable: n.stackable === !0 ? "T" : "",
352
+ itemId: t._id,
353
+ itemCode: r.code || "",
354
+ itemName: r.name,
355
+ itemNameOverrider: i[t._id] || "",
356
+ combinationKey: t.combinationKey ?? "",
357
+ combinationName: t.combinationKey ? c[t.combinationKey] : "",
358
+ price: parseFloat(g(m)),
359
+ priceTier: t.priceTiers || {},
360
+ orderFrom: t.orderFrom ?? r.orderFrom,
361
+ isDefault: t.isDefault === !0 ? "T" : "",
362
+ index: o
363
+ };
364
+ });
365
+ });
366
+ }
367
+ transformItemsLinkWithGroup() {
368
+ const e = {}, n = this.menu.modules.item.reduce((i, t) => (i[t._id] = {
369
+ itemId: t._id,
370
+ itemName: t.name,
371
+ defaultCatalog: ""
372
+ }, i), {});
373
+ return this.menu.modules.group.forEach((i) => {
374
+ e[i._id] = JSON.parse(JSON.stringify(n));
375
+ }), this.menu.modules.item.forEach((i) => {
376
+ i.groups.length > 0 && i.groups.forEach((t) => {
377
+ e[t._id][i._id] = {
378
+ ...e[t._id][i._id],
379
+ defaultCatalog: "T"
380
+ };
381
+ });
382
+ }), e;
383
+ }
384
+ exportToExcel() {
385
+ var w;
386
+ const e = [], { rows: n, metaData: i } = this.transformData();
387
+ i.priceTiers = ((w = this.menu.priceTierSettings) == null ? void 0 : w.map((b) => b.key)) || [];
388
+ const t = n.map(({ priceTier: b, tag: C, ...F }) => {
389
+ const h = Object.entries(F), M = h.findIndex(([y]) => y === "price");
390
+ return [
391
+ ...h.slice(0, M + 1).map(([, y]) => y),
392
+ ...i.priceTiers.map(
393
+ (y) => parseFloat(g(b[y])) || ""
394
+ ),
395
+ ...h.slice(M + 1).map(([, y]) => y),
396
+ ...this.attributeSettings.map((y) => C[y.key] || "")
397
+ ];
398
+ }), o = this.createWorkbookExcelJS(
399
+ t,
400
+ "Default Catalog",
401
+ this.exportCatalogToExcelExcelJS()
402
+ ), r = o.worksheets[0];
403
+ L(r, this.attributeSettings, i.priceTiers), this.formatWorkbookCell(o);
404
+ const m = this.transformAddonGroup().map(({ priceTier: b, ...C }) => {
405
+ const { index: F, ...h } = C, M = Object.entries(h), y = M.findIndex(([p]) => p === "price");
406
+ return [
407
+ ...M.slice(0, y + 1).map(([, p]) => p),
408
+ ...i.priceTiers.map(
409
+ (p) => parseFloat(g(b[p])) || ""
410
+ ),
411
+ ...M.slice(y + 1).map(([, p]) => p)
412
+ ];
413
+ }), c = this.createWorkbookExcelJS(
414
+ m,
415
+ "Default AddonGroup",
416
+ this.exportCatalogAddonToExcelExcelJS()
417
+ ), u = c.worksheets[0];
418
+ J(u, i.priceTiers), this.formatWorkbookCell(c);
419
+ const s = this.transformItemsLinkWithGroup(), d = Object.keys(s), f = new P.Workbook();
420
+ if (d.length > 0)
421
+ d.forEach((b, C) => {
422
+ const F = Object.values(s[b]), h = this.menu.modules.group.find((p) => p._id === b);
423
+ if (!h) throw new Error(`Group not found for id: ${b}`);
424
+ const M = U(`${C + 1}. ${h.name}`), y = f.addWorksheet(M);
425
+ y.columns = [
426
+ { header: "Group ID", key: "groupId" },
427
+ { header: "Item ID", key: "itemId" },
428
+ { header: "Item Name", key: "itemName" },
429
+ { header: "Default Catalog", key: "defaultCatalog" }
430
+ ], F.forEach((p) => {
431
+ y.addRow({
432
+ groupId: b,
433
+ itemId: p.itemId,
434
+ itemName: p.itemName,
435
+ defaultCatalog: p.defaultCatalog
436
+ });
437
+ });
438
+ });
439
+ else {
440
+ const b = f.addWorksheet("Group Name");
441
+ b.columns = [
442
+ { header: "Group ID", key: "groupId" },
443
+ { header: "Item ID", key: "itemId" },
444
+ { header: "Item Name", key: "itemName" },
445
+ { header: "Default Catalog", key: "defaultCatalog" }
446
+ ];
447
+ }
448
+ return this.formatWorkbookCell(f), e.push(o, c, f), e;
449
+ }
450
+ createWorkbookExcelJS(e, n, i) {
451
+ const t = new P.Workbook(), o = t.addWorksheet(n);
452
+ return e.forEach((r) => {
453
+ o.addRow(r);
454
+ }), i && i.worksheets.forEach((r) => {
455
+ const a = t.addWorksheet(r.name);
456
+ r.eachRow({ includeEmpty: !0 }, (m) => {
457
+ const c = m.values;
458
+ a.addRow(c.slice(1));
459
+ });
460
+ }), t;
461
+ }
462
+ formatWorkbookCell(e) {
463
+ e.eachSheet((n) => {
464
+ n.eachRow({ includeEmpty: !0 }, (t) => {
465
+ t.eachCell({ includeEmpty: !0 }, (o) => {
466
+ o.font = {
467
+ name: "Calibri",
468
+ size: 12
469
+ }, t.number === 1 && (o.fill = {
470
+ type: "pattern",
471
+ pattern: "solid",
472
+ fgColor: { argb: "FABF8F" }
473
+ }, o.alignment = { horizontal: "center", vertical: "middle" });
474
+ });
475
+ });
476
+ const i = n.getRow(1);
477
+ n.autoFilter = {
478
+ from: {
479
+ row: 1,
480
+ column: 1
481
+ },
482
+ to: {
483
+ row: 1,
484
+ column: i.cellCount
485
+ }
486
+ };
487
+ });
488
+ }
489
+ exportCatalogToExcelExcelJS() {
490
+ const e = new P.Workbook();
491
+ return this.menu.modules.catalog.forEach((n) => {
492
+ const i = Object.values(n.override.items).flatMap((c) => c), { rows: t, metaData: o } = this.transformOverrideData(i), r = t.map(({ priceTier: c, tag: u, ...s }) => [
493
+ ...Object.entries(s).map(([, f]) => f),
494
+ ...this.attributeSettings.map((f) => u[f.key] || "")
495
+ ]), a = U(n.name), m = e.addWorksheet(a);
496
+ r.forEach((c) => {
497
+ m.addRow(c);
498
+ }), L(m, this.attributeSettings, o.priceTiers, n);
499
+ }), e;
500
+ }
501
+ exportCatalogAddonToExcelExcelJS() {
502
+ const e = new P.Workbook();
503
+ return this.menu.modules.catalog.forEach((n) => {
504
+ const i = Object.values(n.override.groups).flatMap(
505
+ (m) => m
506
+ ), o = this.transformOverrideAddonGroup(i).map(({ priceTier: m, ...c }) => {
507
+ const { index: u, ...s } = c;
508
+ return [...Object.entries(s).map(([, f]) => f)];
509
+ }), r = U(n.name), a = e.addWorksheet(r);
510
+ o.forEach((m) => {
511
+ a.addRow(m);
512
+ }), J(a);
513
+ }), e;
514
+ }
515
+ }
516
+ const $e = { class: "flex-1 flex justify-between gap-8 pl-8" }, Re = { class: "flex items-center" }, Ae = { class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4" }, Pe = { class: "fm-typo-en-body-md-600 font-semibold" }, Oe = { class: "flex gap-8" }, nt = /* @__PURE__ */ j({
517
+ __name: "Products",
518
+ setup(v) {
519
+ const { t: e } = ye(), n = ce(), i = ie(le()), t = ne(), o = D(() => t.rules.item), r = Fe(), a = D(() => !t.state.currentSchedulerId), { selectedCategories: m } = xe(), c = D(() => ({
520
+ ...ge.menuV4ToV3(X(t.state.menu)),
521
+ _id: t.state.menu._id,
522
+ _rev: t.state.menu._rev
523
+ })), u = D(() => {
524
+ const p = Z.flatten(m.value.map((x) => x.items));
525
+ return Z.uniqBy(p, (x) => x._id).length;
526
+ });
527
+ async function s(p, x) {
528
+ const I = new be();
529
+ for (let R = 0; R < p.length; R++) {
530
+ const ue = await p[R].xlsx.writeBuffer();
531
+ I.file(`${x[R]}.xlsx`, ue);
532
+ }
533
+ const k = await I.generateAsync({ type: "blob" });
534
+ he.saveAs(k, `books_${V().format("DD-MM-YYYY_HH-mm")}.zip`);
535
+ }
536
+ async function d() {
537
+ await i.minor(
538
+ async () => {
539
+ var p;
540
+ if (await t.readMenu(), t.version === se.F_MENU_VERSION.enum.v4) {
541
+ const x = X(t.state.menu), I = new Ve(
542
+ x,
543
+ ((p = n.currentBusiness.value) == null ? void 0 : p.attributeSettings) ?? []
544
+ ).exportToExcel(), k = [
545
+ `menu_${V().format("DD-MM-YYYY_HH-mm")}`,
546
+ `addonGroup_${V().format("DD-MM-YYYY_HH-mm")}`,
547
+ `itemLinkedAddon${V().format("DD-MM-YYYY_HH-mm")}`
548
+ ];
549
+ s(I, k);
550
+ } else {
551
+ const x = Ee(c.value), I = `menu_${V().format("DD-MM-YYYY_HH-mm")}`;
552
+ await fe(x, `${I}.xlsx`, {
553
+ bookType: "xlsx",
554
+ bookSST: !1,
555
+ type: "array"
556
+ });
557
+ }
558
+ },
559
+ { successMessage: "Menu exported", customId: t.state.menu._id }
560
+ );
561
+ }
562
+ const {
563
+ menuItems: f,
564
+ categories: w,
565
+ linkItemRules: b,
566
+ handleSubmit: C,
567
+ catalogManager: F,
568
+ schedulerManager: h
569
+ } = Se(!1), M = ke(), y = D(() => M.breakpoints.value.xs);
570
+ return Ce().resetOnMount(), (p, x) => {
571
+ const I = $("fm-button");
572
+ return T(), N(we, {
573
+ heading: l(e)("menu.products.title")
574
+ }, {
575
+ default: E(() => [
576
+ _(Ge),
577
+ _(Me)
578
+ ]),
579
+ "append-heading": E(() => [
580
+ S("div", $e, [
581
+ S("div", Re, [
582
+ S("div", Ae, [
583
+ S("p", Pe, ae(u.value), 1)
584
+ ])
585
+ ]),
586
+ S("div", Oe, [
587
+ y.value ? (T(), N(ee, { key: 1 }, {
588
+ default: E(({ trigger: k }) => [
589
+ _(ve, null, {
590
+ default: E(() => [
591
+ _(Q, {
592
+ label: l(e)("menu.products.actions.export"),
593
+ onClick: d
594
+ }, null, 8, ["label"]),
595
+ _(Q, {
596
+ label: l(e)("menu.products.actions.import"),
597
+ onClick: k
598
+ }, null, 8, ["label", "onClick"])
599
+ ]),
600
+ _: 2
601
+ }, 1024)
602
+ ]),
603
+ _: 1
604
+ })) : (T(), B(H, { key: 0 }, [
605
+ _(Ie, null, {
606
+ default: E(({ trigger: k }) => [
607
+ _(I, {
608
+ label: l(e)("menu.tree_editor.title"),
609
+ "bg-color": l(G).NeutralGray100,
610
+ "text-color": l(G).TypoSecondary,
611
+ variant: l(Y).Primary,
612
+ onClick: k
613
+ }, null, 8, ["label", "bg-color", "text-color", "variant", "onClick"])
614
+ ]),
615
+ _: 1
616
+ }),
617
+ _(I, {
618
+ "bg-color": l(G).NeutralGray100,
619
+ "text-color": l(G).TypoSecondary,
620
+ variant: l(Y).Primary,
621
+ label: l(e)("menu.products.actions.export"),
622
+ onClick: d
623
+ }, null, 8, ["bg-color", "text-color", "variant", "label"]),
624
+ _(ee, null, {
625
+ default: E(({ trigger: k }) => [
626
+ _(I, {
627
+ "bg-color": l(G).NeutralGray100,
628
+ "text-color": l(G).TypoSecondary,
629
+ variant: l(Y).Primary,
630
+ label: l(e)("menu.products.actions.import"),
631
+ onClick: k
632
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])
633
+ ]),
634
+ _: 1
635
+ })
636
+ ], 64)),
637
+ u.value > 0 ? (T(), B(H, { key: 2 }, [
638
+ o.value.create ? (T(), N(W, {
639
+ key: 0,
640
+ label: l(e)("menu.products.actions.add"),
641
+ "prepend-icon": "add",
642
+ onClick: x[0] || (x[0] = (k) => l(r).create(null))
643
+ }, null, 8, ["label"])) : a.value ? (T(), N(te, {
644
+ key: 1,
645
+ "categorized-items": l(F).linkableItems.value,
646
+ "initial-value": l(F).currentItems.value,
647
+ "show-variant": !1,
648
+ "menu-items": l(f),
649
+ categories: l(w),
650
+ "link-item-rules": l(b),
651
+ "no-scheduler": a.value,
652
+ onSubmit: l(C)
653
+ }, {
654
+ default: E(({ trigger: k }) => [
655
+ _(W, {
656
+ label: l(e)("menu.products.actions.link"),
657
+ "prepend-icon": "link",
658
+ onClick: k
659
+ }, null, 8, ["label", "onClick"])
660
+ ]),
661
+ _: 1
662
+ }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"])) : (T(), N(te, {
663
+ key: 2,
664
+ "categorized-items": l(h).linkableItems.value,
665
+ "initial-value": l(h).currentItems.value,
666
+ "show-variant": !1,
667
+ "menu-items": l(f),
668
+ categories: l(w),
669
+ "link-item-rules": l(b),
670
+ "no-scheduler": a.value,
671
+ onSubmit: l(C)
672
+ }, {
673
+ default: E(({ trigger: k }) => [
674
+ _(W, {
675
+ label: l(e)("menu.products.actions.apply_scheduler"),
676
+ onClick: k
677
+ }, null, 8, ["label", "onClick"])
678
+ ]),
679
+ _: 1
680
+ }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"]))
681
+ ], 64)) : re("", !0)
682
+ ])
683
+ ])
684
+ ]),
685
+ _: 1
686
+ }, 8, ["heading"]);
687
+ };
688
+ }
689
+ });
690
+ export {
691
+ nt as default
692
+ };