@feedmepos/mf-menu 0.19.12 → 0.19.13

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 (51) hide show
  1. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-DetNZI3I.js → ApplyProduct.vue_vue_type_script_setup_true_lang-Bvkr0nD3.js} +2 -2
  2. package/dist/{ApplyProducts.vue_vue_type_script_setup_true_lang-CwAUrR4F.js → ApplyProducts.vue_vue_type_script_setup_true_lang-Hx8MMYfJ.js} +2 -2
  3. package/dist/{Catalog-DIm2_Pve.js → Catalog-C3Cx3sFF.js} +3 -3
  4. package/dist/{Category-Bj7VMtJ-.js → Category-C_5RCWZ_.js} +6 -6
  5. package/dist/{CookingGuide-DDV0xBos.js → CookingGuide-BzLjzKZI.js} +3 -3
  6. package/dist/{Group-DLh05bcU.js → Group-DJm-Mk3u.js} +4 -4
  7. package/dist/{Group-DZo7HAf2.js → Group-DjTfdOWl.js} +1 -1
  8. package/dist/{Group.vue_vue_type_script_setup_true_lang-ooVmvatG.js → Group.vue_vue_type_script_setup_true_lang-DBk_yau1.js} +127 -127
  9. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-B3FXm_t8.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-By61Cx0K.js} +2 -2
  10. package/dist/{Ingredient-N8t1Zg1B.js → Ingredient-CN3KCmFG.js} +4 -4
  11. package/dist/{LinkProductSideSheet-DfPSfCPO.js → LinkProductSideSheet-DBx4NpGw.js} +2 -2
  12. package/dist/{PrintRoute-COjWuW4S.js → PrintRoute-DMUblGYw.js} +3 -3
  13. package/dist/{Product-CcSZnVtx.js → Product-BVAvSbra.js} +1 -1
  14. package/dist/Product.vue_vue_type_script_setup_true_lang-D5gHIGvK.js +841 -0
  15. package/dist/{Products-DC50oMNz.js → Products-CM4pI3iG.js} +8 -8
  16. package/dist/{Publish-C7wZimbw.js → Publish-MLYmwkhU.js} +2 -2
  17. package/dist/{Recipe-KeudfKx-.js → Recipe-CtY40lpO.js} +4 -4
  18. package/dist/{Scheduler-Ci0qqmD0.js → Scheduler-DDL5yw94.js} +2 -2
  19. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-DkzeDjf4.js +61 -0
  20. package/dist/ServingSequence-OCghftu3.js +4 -0
  21. package/dist/{Setting-R8hJKnp6.js → Setting-B9VYv_FV.js} +1 -1
  22. package/dist/{Setting.vue_vue_type_script_setup_true_lang-C8YEErhA.js → Setting.vue_vue_type_script_setup_true_lang-q4SDPU1B.js} +3 -3
  23. package/dist/{Takeaway-DfZUEYul.js → Takeaway-BNKH3pYw.js} +4 -4
  24. package/dist/{Takeaway-D1YJ51Pm.js → Takeaway-CDQjt5mB.js} +1 -1
  25. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-CxrKOffq.js → Takeaway.vue_vue_type_script_setup_true_lang-DLs6tg28.js} +4 -4
  26. package/dist/{TaxSetting-Cyx64cle.js → TaxSetting-LXV73pLm.js} +4 -4
  27. package/dist/{Unit-CSw2nzb3.js → Unit-YqlS_aYJ.js} +2 -2
  28. package/dist/{Variant-BexkJbX8.js → Variant-Cfec4-WR.js} +2 -2
  29. package/dist/{_id_-DL_--BAT.js → _id_-B3cTaq5i.js} +6 -6
  30. package/dist/{app-DBSpCrEz.js → app-r8ZKmdn1.js} +28 -28
  31. package/dist/app.js +2 -2
  32. package/dist/assets/{linked-status-BbVXICkq.js → linked-status-CWjLtoRl.js} +3 -3
  33. package/dist/assets/{validate-menu-xvp-KAet.js → validate-menu-3nJfxanr.js} +3 -3
  34. package/dist/{catalog-DIgmR7H0.js → catalog-CIHro4Q-.js} +432 -432
  35. package/dist/{catalog-BAExZa6M.js → catalog-Gpaw0veN.js} +1 -1
  36. package/dist/{category--Ezee0GQ.js → category-C1Nv2k2C.js} +1 -1
  37. package/dist/{currency-Cab-BTrJ.js → currency-CWaEAteR.js} +1 -1
  38. package/dist/{index-crmsscjz.js → index-DiPpC8uS.js} +3 -3
  39. package/dist/{index-Doj4vOci.js → index-q8vb7C-b.js} +2 -2
  40. package/dist/{item-C3RFNcK2.js → item-DF8-obPB.js} +11 -11
  41. package/dist/{lodash-Cag9qz8o.js → lodash-DT3SfcPy.js} +1 -1
  42. package/dist/{menu-Baw4oOOx.js → menu-BtnsqPSW.js} +1 -1
  43. package/dist/{object-D4QR8YOW.js → object-GEcPWoWM.js} +1 -1
  44. package/dist/{scheduler-Dmy-SRLI.js → scheduler-Cdw2OBBp.js} +125 -125
  45. package/dist/{takeaway-BVcxbDAX.js → takeaway-5q1fUkoY.js} +4 -4
  46. package/dist/{toExcel-CkwPnj8n.js → toExcel-D59bd39T.js} +2 -2
  47. package/dist/{unit-D7o6p3IX.js → unit-DYZD3TgN.js} +2 -2
  48. package/package.json +3 -3
  49. package/dist/Product.vue_vue_type_script_setup_true_lang-BZL3JDpp.js +0 -826
  50. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-6gxIvwfz.js +0 -49
  51. package/dist/ServingSequence-DsBZhvaK.js +0 -4
@@ -0,0 +1,841 @@
1
+ import { ref as D, computed as g, defineComponent as ce, resolveComponent as G, openBlock as b, createBlock as R, withCtx as O, createVNode as u, createElementVNode as f, toDisplayString as Q, unref as l, createElementBlock as N, Fragment as xe, renderList as Ne, createTextVNode as He, mergeModels as Ze, useModel as Je, renderSlot as he, watch as pe, h as E, withModifiers as Ve, createCommentVNode as ue, resolveDynamicComponent as Qe, normalizeStyle as Xe, normalizeClass as se, nextTick as et, watchEffect as tt } from "vue";
2
+ import { u as ye, a as De, c as ve, y as fe, F as lt, z as at, k as ie, g as ot, A as Fe, i as je } from "./app-r8ZKmdn1.js";
3
+ import { _ as $e } from "./SchedulerSelector.vue_vue_type_script_setup_true_lang-DkzeDjf4.js";
4
+ import { useI18n as Ce, useCoreStore as nt } from "@feedmepos/mf-common";
5
+ import { useSnackbar as Ue, useDialog as Be, components as re, FmButtonVariant as W, FmButtonColorThemeVariant as L, useBreakpoints as Ae } from "@feedmepos/ui-library";
6
+ import "vue-router";
7
+ import { u as ge } from "./menu-BtnsqPSW.js";
8
+ import { u as Ee } from "./category-C1Nv2k2C.js";
9
+ import "./vuedraggable-WU01qJgi.js";
10
+ import { _ as rt, c as Ie, a as st, u as ut } from "./catalog-CIHro4Q-.js";
11
+ import { _ as it } from "./takeaway-5q1fUkoY.js";
12
+ import { f as ct } from "./currency-CWaEAteR.js";
13
+ import { l as be } from "./lodash-DT3SfcPy.js";
14
+ import { u as Ke, m as dt } from "./item-DF8-obPB.js";
15
+ import { w as mt } from "./InfoBasic.vue_vue_type_script_setup_true_lang-DxQBDu16.js";
16
+ import { F as pt } from "./object-GEcPWoWM.js";
17
+ import { _ as Te } from "./TextChip.vue_vue_type_script_setup_true_lang-CNp85hoQ.js";
18
+ import { L as Oe } from "./LinkProductSideSheet-DBx4NpGw.js";
19
+ function vt(M, d) {
20
+ const m = D(!0), n = g(() => {
21
+ var p, y;
22
+ return !m.value && (!d.value || ((p = d.value) == null ? void 0 : p.length) === ((y = M.value) == null ? void 0 : y.length));
23
+ }), F = g(() => {
24
+ var p, y, $, _;
25
+ return !!((p = d.value) != null && p.length && ((y = d.value) == null ? void 0 : y.length) > 0 && (($ = d.value) == null ? void 0 : $.length) < ((_ = M.value) == null ? void 0 : _.length));
26
+ });
27
+ return { allCleared: m, allSelected: n, indeterminate: F, toggleAll: () => {
28
+ d.value = void 0, m.value = !m.value;
29
+ }, toggleOption: (p) => {
30
+ var $, _, q;
31
+ let y;
32
+ d.value === void 0 && m.value ? y = [p] : d.value === void 0 && !m.value ? y = ($ = M.value.map((I) => I.value)) == null ? void 0 : $.filter((I) => I !== p) : (_ = d.value) != null && _.includes(p) ? y = (q = d.value) == null ? void 0 : q.filter((I) => I !== p) : y = [...d.value || [], p], y.length === 0 ? (d.value = void 0, m.value = !0) : y.length === M.value.length ? (d.value = void 0, m.value = !1) : d.value = y;
33
+ } };
34
+ }
35
+ const ft = { class: "p-4" }, bt = { class: "flex-1 overflow-y-auto min-h-0" }, Me = /* @__PURE__ */ ce({
36
+ __name: "CategorySelector",
37
+ setup(M) {
38
+ const d = ye(), { categories: m, selectedCategories: n } = ge(), F = g(() => d.state.currentCategoryIds), r = g(
39
+ () => m.value.map((C) => ({ label: C.name, value: C.id }))
40
+ ), J = g(() => r.value.filter(
41
+ (C) => C.label.toLowerCase().includes($.value.toLowerCase())
42
+ )), { t: p } = Ce(), y = g(() => {
43
+ var C, c, j;
44
+ return m.value.length === ((C = n.value) == null ? void 0 : C.length) ? p("menu.category.selector.all") : ((c = n.value) == null ? void 0 : c.length) === 1 ? n.value[0].name : `${(j = n.value) == null ? void 0 : j.length}`;
45
+ }), $ = D(""), _ = g({
46
+ get: () => F.value,
47
+ set: (C) => {
48
+ d.selectCategory(C);
49
+ }
50
+ }), { allCleared: q, allSelected: I, toggleAll: Y, toggleOption: H, indeterminate: P } = vt(r, _);
51
+ return (C, c) => {
52
+ const j = G("FmIcon"), K = G("FmChip"), Z = G("FmSearch"), ae = G("FmMenuItem"), X = G("FmMenu");
53
+ return b(), R(X, {
54
+ "close-on-click": !1,
55
+ width: "220px"
56
+ }, {
57
+ "menu-button": O(() => [
58
+ u(K, {
59
+ label: y.value,
60
+ class: "fm-typo-en-body-md-600 text-fm-color-neutral-gray-400"
61
+ }, {
62
+ default: O(() => [
63
+ f("p", null, Q(l(p)("menu.category.selector.title", { label: y.value })), 1),
64
+ u(j, { name: "expand_more" })
65
+ ]),
66
+ _: 1
67
+ }, 8, ["label"])
68
+ ]),
69
+ default: O(() => [
70
+ f("div", ft, [
71
+ u(Z, {
72
+ autofocus: "",
73
+ modelValue: $.value,
74
+ "onUpdate:modelValue": c[0] || (c[0] = (U) => $.value = U),
75
+ placeholder: l(p)("menu.common.actions.search")
76
+ }, null, 8, ["modelValue", "placeholder"])
77
+ ]),
78
+ f("div", bt, [
79
+ u(ae, {
80
+ label: "All",
81
+ "has-checkbox": "",
82
+ "model-value": l(I),
83
+ indeterminate: l(P),
84
+ onClick: l(Y)
85
+ }, null, 8, ["model-value", "indeterminate", "onClick"]),
86
+ (b(!0), N(xe, null, Ne(J.value, (U) => {
87
+ var S;
88
+ return b(), R(ae, {
89
+ key: U.value || "",
90
+ label: U.label,
91
+ "has-checkbox": "",
92
+ "model-value": l(I) || ((S = _.value) == null ? void 0 : S.includes(U.value)),
93
+ onClick: (B) => l(H)(U.value)
94
+ }, null, 8, ["label", "model-value", "onClick"]);
95
+ }), 128))
96
+ ])
97
+ ]),
98
+ _: 1
99
+ });
100
+ };
101
+ }
102
+ }), Pe = (M) => u("div", {
103
+ class: "flex flex-1 justify-end"
104
+ }, [u("span", null, [M, He(" ")])]), gt = /* @__PURE__ */ ce({
105
+ __name: "CategorySelectorSingle",
106
+ props: /* @__PURE__ */ Ze({
107
+ disabled: { type: Boolean, default: !1 }
108
+ }, {
109
+ modelValue: {},
110
+ modelModifiers: {}
111
+ }),
112
+ emits: ["update:modelValue"],
113
+ setup(M) {
114
+ const d = ye(), m = Je(M, "modelValue"), n = g(() => d.categories.map((F) => ({
115
+ label: F.name,
116
+ value: F._id || null
117
+ })));
118
+ return (F, r) => {
119
+ const J = G("FmSelect");
120
+ return b(), R(J, {
121
+ items: n.value,
122
+ modelValue: m.value,
123
+ "onUpdate:modelValue": r[0] || (r[0] = (p) => m.value = p),
124
+ disabled: F.disabled
125
+ }, null, 8, ["items", "modelValue", "disabled"]);
126
+ };
127
+ }
128
+ }), ze = /* @__PURE__ */ ce({
129
+ __name: "ImportButton",
130
+ setup(M) {
131
+ const d = D(!1);
132
+ function m() {
133
+ d.value = !d.value;
134
+ }
135
+ return (n, F) => (b(), N(xe, null, [
136
+ u(rt, {
137
+ modelValue: d.value,
138
+ "onUpdate:modelValue": F[0] || (F[0] = (r) => d.value = r)
139
+ }, null, 8, ["modelValue"]),
140
+ he(n.$slots, "default", { trigger: m })
141
+ ], 64));
142
+ }
143
+ }), yt = {
144
+ class: "flex justify-between items-center space-x-8"
145
+ }, _t = {
146
+ class: "flex space-x-8"
147
+ }, ht = {
148
+ class: "w-[320px]"
149
+ }, xt = {
150
+ key: 0,
151
+ class: /* @__PURE__ */ se(["flex-1 flex flex-col", "divide-y divide-fm-color-neutral-gray-100", "overflow-hidden"])
152
+ }, Ct = {
153
+ key: 0,
154
+ class: "flex items-center p-4"
155
+ }, kt = {
156
+ class: /* @__PURE__ */ se(["mr-8", "fm-typo-en-body-md-400"])
157
+ }, St = {
158
+ key: 1,
159
+ class: "px-16 py-4 space-x-8 flex justify-end"
160
+ }, wt = {
161
+ key: 1
162
+ }, Vt = {
163
+ class: "flex space-x-8"
164
+ }, Ft = {
165
+ key: 1,
166
+ class: "pt-8 flex flex-col flex-1 overflow-hidden"
167
+ }, $t = {
168
+ class: "space-y-8 pb-8"
169
+ }, It = {
170
+ class: "w-full px-8"
171
+ }, Tt = {
172
+ class: "flex space-x-8 px-8"
173
+ }, Ot = {
174
+ key: 0,
175
+ class: /* @__PURE__ */ se(["flex flex-col flex-1", "overflow-scroll", "divide-y divide-fm-color-neutral-gray-100", "pb-64"])
176
+ }, Mt = ["onClick"], Pt = {
177
+ class: "min-w-0 flex flex-1 items-center justify-start space-x-16"
178
+ }, zt = {
179
+ class: "flex-1 min-w-0"
180
+ }, Nt = {
181
+ class: "flex justify-between items-center gap-8 pb-4"
182
+ }, Dt = {
183
+ class: "flex-1 min-w-0 fm-typo-en-body-lg-600 line-clamp-2"
184
+ }, jt = {
185
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
186
+ }, Ut = {
187
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
188
+ }, Bt = {
189
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
190
+ }, At = {
191
+ key: 1
192
+ }, Et = {
193
+ class: "flex space-x-8"
194
+ }, Kt = /* @__PURE__ */ ce({
195
+ __name: "ProductTable",
196
+ props: {
197
+ modelValue: {},
198
+ originalValue: {},
199
+ isCalculating: {
200
+ type: Boolean
201
+ }
202
+ },
203
+ emits: ["update:model-value", "reset:model-value", "update:editing", "update:search-key"],
204
+ setup(M, {
205
+ emit: d
206
+ }) {
207
+ const m = M, {
208
+ t: n
209
+ } = Ce(), F = nt(), r = ye(), J = Ue(), p = Be(), y = De(J), $ = je(y);
210
+ Ee({
211
+ dialog: p,
212
+ menuLoader: $
213
+ });
214
+ const _ = Ke();
215
+ g(() => !r.state.currentSchedulerId);
216
+ const q = F.currentCountry, I = g(() => q.value ? ve.Country.getCountry(q.value) : null), Y = g(() => r.rules.item);
217
+ g(() => H.value.length === 1 && H.value[0].id === null);
218
+ const {
219
+ selectedCategories: H
220
+ } = ge(), P = g(() => be.flatten(H.value.map((e) => e.items))), C = d, c = D(!1);
221
+ pe(() => c.value, (e) => {
222
+ C("update:editing", e);
223
+ });
224
+ const j = (e) => {
225
+ ot.isBoolean(e) ? c.value = e : c.value = !c.value;
226
+ }, K = D(""), Z = g(() => P.value.filter((e) => {
227
+ var o;
228
+ return !K.value || !K.value.trim() ? !0 : `${e.code} ${e.name} ${ke(e)} ${X(e.category || null)} ${(o = fe()[e.orderFrom]) == null ? void 0 : o.label}`.toLowerCase().includes(K.value.toLowerCase());
229
+ })), {
230
+ categories: ae
231
+ } = ge(), X = (e) => {
232
+ const t = ae.value.find((o) => o.id === e || e === null && o.id === "");
233
+ return t == null ? void 0 : t.name;
234
+ }, U = (e, t, o) => {
235
+ let a = be.clone(m.modelValue);
236
+ const i = a[e];
237
+ i && (a[e] = {
238
+ ...i,
239
+ [t]: o
240
+ }, C("update:model-value", a));
241
+ }, S = be.debounce(U, 300), B = (e) => (t) => !!t || n("menu.product.table.validation.name_required", {
242
+ field: e
243
+ }), w = (e) => e >= 0 || n("menu.product.table.validation.price_min"), V = [B("Name")], h = () => [(e) => w(typeof e == "number" ? e : Number(e) ?? 0)], z = fe(), A = D([{
244
+ accessorKey: "thumbnail",
245
+ header: "",
246
+ size: 64,
247
+ meta: {
248
+ cellClass: "px-0",
249
+ headerContentClass: "px-0"
250
+ },
251
+ cell: (e) => {
252
+ var t, o;
253
+ return E(Ie, {
254
+ src: e.getValue(),
255
+ alt: (o = (t = e == null ? void 0 : e.row) == null ? void 0 : t.original) == null ? void 0 : o.name,
256
+ className: "my-8 mx-12",
257
+ size: 72
258
+ });
259
+ },
260
+ enableSorting: !1
261
+ }, {
262
+ accessorKey: "code",
263
+ header: () => n("menu.product.table.columns.code"),
264
+ enableSorting: !1,
265
+ size: 100,
266
+ cell: (e) => {
267
+ const t = e.row.original, o = e.getValue() || "--";
268
+ if (!c.value) return o;
269
+ const a = _e(t._id);
270
+ return E(re.FmTextField, {
271
+ disabled: !Y.value.code,
272
+ modelValue: a == null ? void 0 : a.code,
273
+ placeholder: m.modelValue[t._id].fallbackCode,
274
+ "onUpdate:modelValue": (i) => {
275
+ S(t._id, "code", i);
276
+ }
277
+ });
278
+ }
279
+ }, {
280
+ accessorKey: "name",
281
+ header: () => n("menu.product.table.columns.name"),
282
+ enableSorting: !1,
283
+ size: 240,
284
+ cell: (e) => {
285
+ const t = e.row.original, o = e.getValue();
286
+ return c.value ? E(re.FmTextField, {
287
+ disabled: !Y.value.name,
288
+ modelValue: t.name,
289
+ "onUpdate:modelValue": (a) => {
290
+ S(t._id, "name", a);
291
+ },
292
+ rules: V,
293
+ placeholder: t.fallbackName
294
+ }) : o;
295
+ }
296
+ }, {
297
+ accessorKey: "price",
298
+ header: () => {
299
+ var e;
300
+ return Pe(n("menu.product.table.columns.price", {
301
+ currency: (e = I.value) == null ? void 0 : e.currency.symbol
302
+ }));
303
+ },
304
+ enableSorting: !1,
305
+ size: 140,
306
+ meta: {
307
+ textAlign: "right"
308
+ },
309
+ cell: (e) => {
310
+ var i;
311
+ const t = e.getValue();
312
+ if (!c.value) return ve.Dinero.fromFdoDinero(t).toFormat();
313
+ const o = m.modelValue[e.row.original._id], a = o.fallbackPrice;
314
+ return E(it, {
315
+ min: 0,
316
+ disabled: !o.editPrice,
317
+ // @ts-ignore
318
+ placeholder: a ? ct(a, !1) : void 0,
319
+ modelValue: (i = _e(o._id)) == null ? void 0 : i.price,
320
+ // @ts-ignore
321
+ "onUpdate:modelValue": (k) => {
322
+ U(o._id, "price", k);
323
+ },
324
+ rules: h()
325
+ });
326
+ }
327
+ }, {
328
+ accessorKey: "taxes",
329
+ header: () => Pe("SST"),
330
+ size: 62,
331
+ enableSorting: !1,
332
+ meta: {
333
+ textAlign: "right"
334
+ },
335
+ cell: (e) => {
336
+ const t = e.getValue(), o = e.row.original, a = r.taxSetting.countryTaxOptions, i = r.getSelectedTax(t, o.fallbackTaxes, r.taxSetting.countryTaxOptions), k = a.find((le) => le.value === i);
337
+ if (!c.value)
338
+ return `${k != null && k.meta.rate ? lt(k.meta.rate) : 0}%`;
339
+ const s = r.getSelectedTax(t, o.fallbackTaxes, r.taxSetting.countryTaxOptions);
340
+ return E(re.FmSelect, {
341
+ disabled: !Y.value.tax,
342
+ items: r.taxSetting.countryTaxOptions,
343
+ modelValue: s,
344
+ "onUpdate:modelValue": async (le) => {
345
+ const me = r.decodeTax(le);
346
+ S(o._id, "taxes", [me]);
347
+ }
348
+ });
349
+ }
350
+ }, {
351
+ accessorKey: "category",
352
+ header: () => n("menu.product.table.columns.category"),
353
+ enableSorting: !1,
354
+ size: 140,
355
+ cell: (e) => {
356
+ const t = e.row.original;
357
+ return c.value ? E(gt, {
358
+ "model-value": m.modelValue[t._id].category,
359
+ disabled: !!(r.state.currentCatalogId || r.state.currentSchedulerId),
360
+ "onUpdate:modelValue": async (o) => {
361
+ S(t._id, "category", o);
362
+ }
363
+ }) : X(t.category || null);
364
+ }
365
+ }, {
366
+ accessorKey: "orderFrom",
367
+ header: () => n("menu.product.table.columns.order_from"),
368
+ enableSorting: !0,
369
+ sortingFn: (e, t) => {
370
+ const [o, a] = [e, t].map((i) => z[i.original.orderFrom].sortingIndex);
371
+ return o - a;
372
+ },
373
+ size: 110,
374
+ cell: (e) => {
375
+ var i, k;
376
+ const t = e.getValue(), o = e.row.original, a = fe();
377
+ return c.value ? E(re.FmSelect, {
378
+ disabled: !Y.value.orderFrom,
379
+ items: Object.values(fe()),
380
+ modelValue: t,
381
+ "onUpdate:modelValue": async (s) => {
382
+ U(o._id, "orderFrom", s);
383
+ }
384
+ }) : E(Te, {
385
+ label: (i = a[t]) == null ? void 0 : i.label,
386
+ variant: (k = a[t]) == null ? void 0 : k.variant
387
+ });
388
+ }
389
+ }, {
390
+ id: "actions",
391
+ size: 52,
392
+ meta: {
393
+ cellClass: "pl-16",
394
+ headerClass: "py-4",
395
+ textAlign: "right"
396
+ },
397
+ header: () => E("div", {
398
+ class: "w-full px-4 flex justify-end"
399
+ }, [mt(E(re.FmButton, {
400
+ variant: W.Tertiary,
401
+ textColor: L.NeutralGray400,
402
+ prependIcon: "edit",
403
+ class: "flex justify-end",
404
+ onClick: j,
405
+ type: "button"
406
+ }), "Bulk edit")]),
407
+ cell: (e) => {
408
+ const t = e.row.original;
409
+ return E("div", {
410
+ class: "px-4 flex justify-end"
411
+ }, [E(re.FmButton, {
412
+ icon: "delete",
413
+ variant: "tertiary",
414
+ textColor: L.NeutralGray400,
415
+ onClick: Ve(async () => {
416
+ await _.deleteItem([{
417
+ _id: t._id,
418
+ name: t.name,
419
+ thumbnail: t.thumbnail
420
+ }]);
421
+ }, ["stop", "prevent"])
422
+ })]);
423
+ }
424
+ }]);
425
+ r.taxSetting.systemCode || A.value.splice(4, 1);
426
+ const x = D({}), v = D([]);
427
+ pe(() => x.value, (e) => {
428
+ let t = [];
429
+ Object.keys(e).forEach((o) => {
430
+ e[o] ? t.push(P.value[parseInt(o)]) : v.value = t.filter((i) => i !== P.value[parseInt(o)]);
431
+ }), v.value = t;
432
+ }), pe(() => P.value, () => {
433
+ x.value = {}, v.value = [];
434
+ }), pe(() => c.value, () => {
435
+ x.value = {}, v.value = [];
436
+ });
437
+ const ee = () => {
438
+ x.value = {};
439
+ };
440
+ async function T() {
441
+ await et();
442
+ const e = () => !!r.currentCatalog || !!r.state.currentSchedulerId, t = (a) => a === "" || a === null ? e() ? "" : null : a, o = Object.values(m.modelValue).filter((a) => {
443
+ const i = Object.values(m.originalValue).find((k) => k._id === a._id);
444
+ return Fe(i, a);
445
+ }).map((a) => ({
446
+ _id: a._id,
447
+ name: a.name,
448
+ code: a.code,
449
+ price: a.price,
450
+ orderFrom: a.orderFrom ?? null,
451
+ taxes: a.taxes,
452
+ category: t(a.category || null)
453
+ }));
454
+ await _.updateMany(o), j(!1);
455
+ }
456
+ const oe = async () => {
457
+ await _.deleteItem(v.value.map((e) => ({
458
+ _id: e._id,
459
+ name: e.name,
460
+ thumbnail: e.thumbnail
461
+ })));
462
+ }, te = () => {
463
+ C("reset:model-value");
464
+ }, ne = () => {
465
+ Object.entries(m.modelValue).some(([t, o]) => Fe(o, m.originalValue[t])) ? p.open({
466
+ title: "You have unsaved changes!",
467
+ message: "Are you sure you want to discard? You will lose all the changes if discard edit.",
468
+ primaryActions: {
469
+ text: "Discard",
470
+ close: !0,
471
+ variant: W.Destructive
472
+ },
473
+ secondaryActions: {
474
+ text: "Cancel",
475
+ close: !0
476
+ }
477
+ }).onPrimary(() => {
478
+ te(), j(!1);
479
+ }) : (j(!1), te());
480
+ }, de = g(() => ({
481
+ thumbnail: !c.value,
482
+ actions: !c.value
483
+ })), Le = (e) => {
484
+ _.update(e._id);
485
+ };
486
+ async function Re(e) {
487
+ await _.update(e.original._id);
488
+ }
489
+ function ke(e) {
490
+ var k;
491
+ const t = e.price ?? // TODO: fix type error
492
+ // @ts-ignore
493
+ e.fallbackPrice ?? ve.Dinero.fromNumber({
494
+ number: 0
495
+ }).toObject(), o = e.taxes;
496
+ r.taxSetting.countryTaxOptions;
497
+ const a = ve.Dinero.fromFdoDinero(t).toFormat(), i = (k = I.value) == null ? void 0 : k.currency.symbol;
498
+ return r.getSelectedTax(
499
+ o,
500
+ // TODO: fix type error
501
+ // @ts-ignore
502
+ e.fallbackTaxes,
503
+ r.taxSetting.countryTaxOptions
504
+ ), `${i == null ? void 0 : i.toUpperCase()}${a}`;
505
+ }
506
+ function _e(e) {
507
+ var a;
508
+ const t = r.currentCatalog, o = r.state.currentSchedulerId;
509
+ if (t && o) {
510
+ const i = t.override.scheduler[o] ?? {
511
+ _id: o
512
+ };
513
+ return ((a = i == null ? void 0 : i.items) == null ? void 0 : a.filter((s) => s._id === e))[0];
514
+ } else return t ? t.override.items[e][0] : o ? r.schedulers.find((s) => s._id === o).items.filter((s) => s._id === e)[0] : P.value.find((i) => i._id === e);
515
+ }
516
+ const Ge = Ae(), qe = g(() => Ge.breakpoints.value.xs), Se = D(null), We = at(Se), Ye = g(() => {
517
+ var t;
518
+ return {
519
+ height: `calc(100vh - ${((t = We.value) == null ? void 0 : t.top) + 24}px)`
520
+ };
521
+ });
522
+ return (e, t) => {
523
+ const o = G("fm-search"), a = G("fm-button"), i = G("fm-table"), k = G("fm-form");
524
+ return qe.value ? (b(), N("div", Ft, [f("div", $t, [f("div", It, [u(o, {
525
+ "model-value": K.value,
526
+ "onUpdate:modelValue": t[4] || (t[4] = (s) => K.value = s),
527
+ autofocus: "",
528
+ placeholder: l(n)("menu.product.table.search.placeholder")
529
+ }, null, 8, ["model-value", "placeholder"])]), t[6] || (t[6] = f("div", {
530
+ class: "w-full h-[1px] bg-fm-color-neutral-gray-100"
531
+ }, null, -1)), f("div", Tt, [he(e.$slots, "filter")])]), P.value.length ? (b(), N("div", Ot, [(b(!0), N(xe, null, Ne(Z.value, (s) => {
532
+ var le, me, we;
533
+ return b(), N("div", {
534
+ key: s._id,
535
+ class: "max-w-full py-12 px-16 space-x-16 flex items-center",
536
+ onClick: () => Le(s)
537
+ }, [f("div", Pt, [u(Ie, {
538
+ alt: s.name,
539
+ size: 72,
540
+ src: s.thumbnail
541
+ }, null, 8, ["alt", "src"]), f("div", zt, [f("div", Nt, [f("p", Dt, Q(s.name), 1), u(Te, {
542
+ label: (le = l(z)[s.orderFrom || ""]) == null ? void 0 : le.label,
543
+ variant: (me = l(z)[s.orderFrom || ""]) == null ? void 0 : me.variant
544
+ }, null, 8, ["label", "variant"])]), f("p", jt, Q(ke(s)), 1), f("p", Ut, Q(l(n)("menu.product.table.columns.code")) + ": " + Q(((we = _e(s._id)) == null ? void 0 : we.code) || "--"), 1), f("p", Bt, Q(l(n)("menu.product.table.columns.category")) + ": " + Q(X(s.category || null)), 1)])]), u(a, {
545
+ "text-color": l(L).NeutralGray400,
546
+ variant: l(W).Tertiary,
547
+ "prepend-icon": "delete",
548
+ onClick: Ve(() => l(_).deleteItem([{
549
+ _id: s._id,
550
+ name: s.name,
551
+ thumbnail: s.thumbnail
552
+ }]), ["stop"])
553
+ }, null, 8, ["text-color", "variant", "onClick"])], 8, Mt);
554
+ }), 128))])) : (b(), N("div", At, [u(ie, {
555
+ subtitle: l(n)("menu.product.table.empty.subtitle"),
556
+ title: l(n)("menu.product.table.empty.title")
557
+ }, {
558
+ action: O(() => [f("div", Et, [u(a, {
559
+ variant: l(W).Primary,
560
+ label: l(n)("menu.product.table.empty.actions.add"),
561
+ "prepend-icon": "add",
562
+ onClick: t[5] || (t[5] = (s) => l(_).create(null))
563
+ }, null, 8, ["variant", "label"]), u(ze, null, {
564
+ default: O(({
565
+ trigger: s
566
+ }) => [u(a, {
567
+ "bg-color": l(L).NeutralGray100,
568
+ "text-color": l(L).NeutralGray400,
569
+ variant: l(W).Primary,
570
+ label: l(n)("menu.product.table.empty.actions.import"),
571
+ "prepend-icon": "download",
572
+ onClick: s
573
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
574
+ _: 1
575
+ })])]),
576
+ _: 1
577
+ }, 8, ["subtitle", "title"])]))])) : (b(), R(k, {
578
+ key: 0,
579
+ "blame-form-child-on-validation-failed": "",
580
+ class: "flex flex-col flex-1 space-y-8 overflow-hidden",
581
+ onValidationSuccess: T
582
+ }, {
583
+ default: O(() => [f("div", yt, [f("div", _t, [he(e.$slots, "filter")]), f("div", ht, [u(o, {
584
+ "model-value": K.value,
585
+ "onUpdate:modelValue": t[0] || (t[0] = (s) => K.value = s),
586
+ autofocus: "",
587
+ placeholder: l(n)("menu.product.table.search.placeholder")
588
+ }, null, 8, ["model-value", "placeholder"])])]), P.value.length ? (b(), N("div", xt, [v.value.length && !c.value ? (b(), N("div", Ct, [f("p", kt, Q(l(n)("menu.product.table.selection.count", {
589
+ count: v.value.length
590
+ })), 1), u(a, {
591
+ label: l(n)("menu.product.table.selection.actions.deselect_all"),
592
+ type: "button",
593
+ variant: "plain",
594
+ onClick: ee
595
+ }, null, 8, ["label"]), u(a, {
596
+ "border-color": l(L).SystemError300,
597
+ "text-color": l(L).SystemError300,
598
+ class: "ml-auto",
599
+ label: l(n)("menu.product.table.selection.actions.remove"),
600
+ "prepend-icon": "delete",
601
+ variant: "secondary",
602
+ onClick: oe
603
+ }, null, 8, ["border-color", "text-color", "label"])])) : ue("", !0), c.value ? (b(), N("div", St, [u(a, {
604
+ variant: l(W).Tertiary,
605
+ label: l(n)("menu.product.table.bulk_edit.actions.reset_all"),
606
+ onClick: te
607
+ }, null, 8, ["variant", "label"]), u(a, {
608
+ variant: l(W).Tertiary,
609
+ label: l(n)("menu.common.actions.cancel"),
610
+ onClick: ne
611
+ }, null, 8, ["variant", "label"]), u(a, {
612
+ borderColor: l(L).ColorPrimary,
613
+ textColor: l(L).ColorPrimary,
614
+ variant: l(W).Secondary,
615
+ label: l(n)("menu.product.table.bulk_edit.actions.save"),
616
+ type: "submit"
617
+ }, null, 8, ["borderColor", "textColor", "variant", "label"])])) : ue("", !0), f("div", {
618
+ ref_key: "tableWrapper",
619
+ ref: Se
620
+ }, [(b(), R(Qe(c.value ? pt : "div"), {
621
+ title: l(n)("menu.product.table.bulk_edit.title"),
622
+ show: c.value,
623
+ "primary-action": {
624
+ label: l(n)("menu.product.table.bulk_edit.actions.save")
625
+ },
626
+ "secondary-actions": [{
627
+ label: l(n)("menu.product.table.bulk_edit.actions.reset_all"),
628
+ click: te
629
+ }, {
630
+ label: l(n)("menu.common.actions.cancel"),
631
+ click: ne
632
+ }],
633
+ class: "overflow-hidden",
634
+ style: Xe(Ye.value),
635
+ onOnPrimary: T,
636
+ onOnCancel: ne
637
+ }, {
638
+ default: O(() => [u(i, {
639
+ class: se({
640
+ "mt-24": c.value
641
+ }),
642
+ modelValue: x.value,
643
+ "onUpdate:modelValue": t[1] || (t[1] = (s) => x.value = s),
644
+ "column-defs": A.value,
645
+ "column-visibility": de.value,
646
+ loading: e.isCalculating,
647
+ "page-size": P.value.length,
648
+ "row-data": Z.value,
649
+ selection: c.value ? void 0 : "multiple",
650
+ "shrink-at": !1,
651
+ "hide-footer": "",
652
+ "pin-header-row": "",
653
+ onRowClick: t[2] || (t[2] = (s) => c.value ? void 0 : Re(s))
654
+ }, null, 8, ["class", "modelValue", "column-defs", "column-visibility", "loading", "page-size", "row-data", "selection"])]),
655
+ _: 1
656
+ }, 40, ["title", "show", "primary-action", "secondary-actions", "style"]))], 512)])) : (b(), N("div", wt, [u(ie, {
657
+ subtitle: l(n)("menu.product.table.empty.subtitle"),
658
+ title: l(n)("menu.product.table.empty.title")
659
+ }, {
660
+ action: O(() => [f("div", Vt, [u(a, {
661
+ variant: l(W).Primary,
662
+ label: l(n)("menu.product.table.empty.actions.add"),
663
+ "prepend-icon": "add",
664
+ onClick: t[3] || (t[3] = (s) => l(_).create(null))
665
+ }, null, 8, ["variant", "label"]), u(ze, null, {
666
+ default: O(({
667
+ trigger: s
668
+ }) => [u(a, {
669
+ "bg-color": l(L).NeutralGray100,
670
+ "text-color": l(L).NeutralGray400,
671
+ variant: l(W).Primary,
672
+ label: l(n)("menu.product.table.empty.actions.import"),
673
+ "prepend-icon": "download",
674
+ onClick: s
675
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
676
+ _: 1
677
+ })])]),
678
+ _: 1
679
+ }, 8, ["subtitle", "title"])]))]),
680
+ _: 3
681
+ }));
682
+ };
683
+ }
684
+ }), Lt = {
685
+ key: 0,
686
+ class: /* @__PURE__ */ se(["flex flex-col", "flex-1", "overflow-hidden"])
687
+ }, Rt = {
688
+ class: /* @__PURE__ */ se(["pt-16 xs:pt-0", "flex xs:flex-col", "flex-1", "w-full", "overflow-hidden"])
689
+ }, Gt = { class: "flex flex-col flex-1 overflow-hidden" }, qt = {
690
+ key: 1,
691
+ class: "pt-16 xs:pt-8 space-y-24"
692
+ }, Wt = { class: "flex items-center gap-8 px-16" }, ml = /* @__PURE__ */ ce({
693
+ __name: "Product",
694
+ setup(M) {
695
+ const d = Be(), m = Ue(), n = De(m), F = je(n);
696
+ Ee({
697
+ dialog: d,
698
+ menuLoader: F
699
+ });
700
+ const r = ye(), J = g(() => r.rules.item), p = st(), y = Ke(), $ = ut(), _ = g(() => !r.state.currentCatalogId), q = g(() => r.rules.item), I = g(() => !r.state.currentSchedulerId), Y = D(!1), H = D(!1), P = g(() => {
701
+ var w, V, h, z;
702
+ if (_.value && I.value) return;
703
+ if (I.value) {
704
+ const A = (w = r.currentCatalog) == null ? void 0 : w.override.items;
705
+ return A ? Object.entries(A).reduce((x, [v, ee]) => {
706
+ const T = ee.find((oe) => !oe.combinationKey);
707
+ return T && (x[v] = T), x;
708
+ }, {}) : {};
709
+ }
710
+ return ((_.value ? (V = r.currentScheduler) == null ? void 0 : V.items : (z = (h = r.currentCatalog) == null ? void 0 : h.override.scheduler[r.state.currentSchedulerId]) == null ? void 0 : z.items) ?? []).reduce((A, x) => (x.combinationKey || (A[x._id] = x), A), {});
711
+ }), C = D({}), c = D({}), j = async () => {
712
+ var z, A;
713
+ H.value = !0;
714
+ const B = !!P.value, w = be.flatten(Z.value.map((x) => x.items)), V = B && Y.value ? await dt(
715
+ r.mergedMenu,
716
+ w,
717
+ r.state.menu,
718
+ (z = r.currentCatalog) == null ? void 0 : z._id,
719
+ (A = r.currentScheduler) == null ? void 0 : A._id,
720
+ !1
721
+ ) : void 0, h = w.reduce((x, v, ee) => {
722
+ var oe, te, ne, de;
723
+ const T = (oe = P.value) == null ? void 0 : oe[v._id];
724
+ return x[v._id] = {
725
+ _id: v._id,
726
+ name: v.name,
727
+ code: B ? T == null ? void 0 : T.code : v == null ? void 0 : v.code,
728
+ category: v.category,
729
+ price: B && q.value.editPrice ? T == null ? void 0 : T.price : v.price,
730
+ orderFrom: B ? T == null ? void 0 : T.orderFrom : v.orderFrom,
731
+ taxes: B ? null : v.taxes,
732
+ thumbnail: v.thumbnail,
733
+ fallbackPrice: (te = V == null ? void 0 : V[ee]) == null ? void 0 : te.price,
734
+ fallbackName: B ? v.name : void 0,
735
+ fallbackCode: (ne = V == null ? void 0 : V[ee]) == null ? void 0 : ne.code,
736
+ fallbackOrder: (de = V == null ? void 0 : V[ee]) == null ? void 0 : de.orderFrom,
737
+ fallbackTaxes: B ? v.taxes : null
738
+ }, x;
739
+ }, {});
740
+ C.value = h, c.value = { ...h }, H.value = !1;
741
+ }, { categories: K, selectedCategories: Z } = ge();
742
+ tt(async () => {
743
+ Z.value && await j();
744
+ });
745
+ function ae() {
746
+ y.create(null);
747
+ }
748
+ const X = () => {
749
+ Z.value && j();
750
+ }, U = Ae();
751
+ g(() => U.breakpoints.value.xs);
752
+ const { t: S } = Ce();
753
+ return (B, w) => {
754
+ const V = G("fm-button");
755
+ return l(K).length ? (b(), N("div", Lt, [
756
+ f("div", Rt, [
757
+ f("div", Gt, [
758
+ l(Z) ? (b(), R(Kt, {
759
+ key: 0,
760
+ "is-calculating": H.value,
761
+ "model-value": C.value,
762
+ "original-value": c.value,
763
+ "onUpdate:modelValue": w[0] || (w[0] = (h) => C.value = h),
764
+ "onReset:modelValue": X,
765
+ "onUpdate:editing": w[1] || (w[1] = (h) => Y.value = h)
766
+ }, {
767
+ filter: O(() => [
768
+ u(Me),
769
+ q.value.multiScheduler ? (b(), R($e, { key: 0 })) : ue("", !0)
770
+ ]),
771
+ _: 1
772
+ }, 8, ["is-calculating", "model-value", "original-value"])) : ue("", !0)
773
+ ])
774
+ ])
775
+ ])) : (b(), N("div", qt, [
776
+ f("div", Wt, [
777
+ u(Me),
778
+ q.value.multiScheduler ? (b(), R($e, { key: 0 })) : ue("", !0)
779
+ ]),
780
+ J.value.create ? (b(), R(ie, {
781
+ key: 0,
782
+ action: {
783
+ text: l(S)("menu.product.empty.with_create.action"),
784
+ callback: ae
785
+ },
786
+ subtitle: l(S)("menu.product.empty.with_create.subtitle"),
787
+ title: l(S)("menu.product.empty.with_create.title")
788
+ }, null, 8, ["action", "subtitle", "title"])) : I.value ? (b(), R(ie, {
789
+ key: 1,
790
+ subtitle: l(S)("menu.product.empty.no_scheduler.subtitle"),
791
+ title: l(S)("menu.product.empty.no_scheduler.title")
792
+ }, {
793
+ action: O(() => [
794
+ u(Oe, {
795
+ "categorized-items": l($).linkableItems.value,
796
+ "initial-value": l($).currentItems.value,
797
+ "show-variant": !1,
798
+ onSubmit: w[2] || (w[2] = (h) => l($).applyProduct(h.map((z) => z._id)))
799
+ }, {
800
+ default: O(({ trigger: h }) => [
801
+ u(V, {
802
+ label: l(S)("menu.common.actions.link_product"),
803
+ "prepend-icon": "link",
804
+ onClick: h
805
+ }, null, 8, ["label", "onClick"])
806
+ ]),
807
+ _: 1
808
+ }, 8, ["categorized-items", "initial-value"])
809
+ ]),
810
+ _: 1
811
+ }, 8, ["subtitle", "title"])) : (b(), R(ie, {
812
+ key: 2,
813
+ subtitle: l(S)("menu.product.empty.with_scheduler.subtitle"),
814
+ title: l(S)("menu.product.empty.with_scheduler.title")
815
+ }, {
816
+ action: O(() => [
817
+ u(Oe, {
818
+ "categorized-items": l(p).linkableItems.value,
819
+ "initial-value": l(p).currentItems.value,
820
+ "show-variant": !1,
821
+ onSubmit: w[3] || (w[3] = (h) => l(p).applyProduct(h.map((z) => z._id)))
822
+ }, {
823
+ default: O(({ trigger: h }) => [
824
+ u(V, {
825
+ label: l(S)("menu.common.actions.apply_product"),
826
+ onClick: h
827
+ }, null, 8, ["label", "onClick"])
828
+ ]),
829
+ _: 1
830
+ }, 8, ["categorized-items", "initial-value"])
831
+ ]),
832
+ _: 1
833
+ }, 8, ["subtitle", "title"]))
834
+ ]));
835
+ };
836
+ }
837
+ });
838
+ export {
839
+ ml as _,
840
+ ze as a
841
+ };