@feedmepos/mf-menu 0.31.33-beta.1 → 0.31.33-beta.6

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 (89) hide show
  1. package/dist/{App-B4rnpCXN.js → App-Dt6RQiUh.js} +6 -6
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-LtwWMoPW.js → ApplyProduct.vue_vue_type_script_setup_true_lang-B_SQpWg7.js} +2 -2
  3. package/dist/{Catalog-Cd7J8de0.js → Catalog-CFx7t_Nu.js} +79 -79
  4. package/dist/{Category-p8UUDEiv.js → Category-CPMx86rY.js} +23 -19
  5. package/dist/{Category-D3WDm9Fe.js → Category-OjK-v--G.js} +5 -5
  6. package/dist/{CookingGuide-hFtxmtGj.js → CookingGuide-ANnXKBjc.js} +3 -3
  7. package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-D-1OzZ-i.js +113 -0
  8. package/dist/{Group-Bv0dyi8v.js → Group--DJjkGab.js} +1 -1
  9. package/dist/{Group-BTrqZgFd.js → Group-K4925_bP.js} +3 -3
  10. package/dist/Group.vue_vue_type_script_setup_true_lang-36O78xv0.js +684 -0
  11. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BIX-gPUO.js +372 -0
  12. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-CxPaVLVu.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-C-z1m3jh.js} +13987 -13378
  13. package/dist/{Ingredient-BCostN4Y.js → Ingredient-G4Txx6_0.js} +3 -3
  14. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-MAqpI7ZD.js → InventoryBinding.vue_vue_type_script_setup_true_lang-HgHBlflo.js} +2 -2
  15. package/dist/{LinkProductSideSheet-abzVzmo3.js → LinkProductSideSheet-CWNarCEs.js} +1 -1
  16. package/dist/{MenuSetting-TfAo82-E.js → MenuSetting-Cx-EHG-6.js} +4 -4
  17. package/dist/{PrintRoute-B43rP5A9.js → PrintRoute-IxHGvGzF.js} +3 -3
  18. package/dist/{Product-C7cYyDHH.js → Product-D1gqn5J6.js} +1 -1
  19. package/dist/Product.vue_vue_type_script_setup_true_lang-BCQd-ks4.js +1641 -0
  20. package/dist/{ProductInternalTools-CkswVuAF.js → ProductInternalTools-GJ2OE5gU.js} +5 -5
  21. package/dist/Products-DJqgSe-Y.js +270 -0
  22. package/dist/{Publish-DIKqaH2f.js → Publish-C86rd413.js} +3 -3
  23. package/dist/{Recipe-_ApT00c_.js → Recipe-BbQKou9p.js} +4 -4
  24. package/dist/{Scheduler-DWY1kKHO.js → Scheduler-DUeTkyGQ.js} +3 -3
  25. package/dist/{ServingSequence-Z1S9zOTO.js → ServingSequence-BROo5rC_.js} +3 -3
  26. package/dist/Setting-D-ueTlwO.js +259 -0
  27. package/dist/{Subcategory-Lqq6XHz2.js → Subcategory-DVewA8HX.js} +4 -4
  28. package/dist/{Takeaway-DiGzrarg.js → Takeaway-B4lDGQDh.js} +4 -4
  29. package/dist/{Takeaway-DGvM9SBP.js → Takeaway-DyPjHuCl.js} +1 -1
  30. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-BfWy217t.js → Takeaway.vue_vue_type_script_setup_true_lang-BTDlzYuX.js} +6 -6
  31. package/dist/{TreeEditorOpenner.vue_vue_type_script_setup_true_lang-B2wC_Mf0.js → TreeEditorOpenner.vue_vue_type_script_setup_true_lang-B5BAKDRP.js} +642 -642
  32. package/dist/{Unit-D11rRFAf.js → Unit-CVF0dom4.js} +2 -2
  33. package/dist/{Variant-LaKYPxDe.js → Variant-DmccAgFU.js} +3 -3
  34. package/dist/_id_-CWtK62Fy.js +178 -0
  35. package/dist/{app-C5UXrJGj.js → app-CV_q8OdE.js} +75 -75
  36. package/dist/{app-Br9mC24D.js → app-ClinzawZ.js} +1 -1
  37. package/dist/app-DvG3mOom.js +8024 -0
  38. package/dist/app.js +1 -1
  39. package/dist/apps/mf-menu/src/app.d.ts +60 -1
  40. package/dist/apps/mf-menu/src/components/feature/AttributesSelector.vue.d.ts +2 -0
  41. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductUnifiedSideSheet.vue.d.ts +12 -0
  42. package/dist/apps/mf-menu/src/components/feature/PriceTier/LinkPriceTierSection.vue.d.ts +24 -0
  43. package/dist/apps/mf-menu/src/components/feature/PriceTier/PriceTierRuleEditor.vue.d.ts +30 -0
  44. package/dist/apps/mf-menu/src/components/feature/TreeEditor/store/menuV2.d.ts +77 -0
  45. package/dist/apps/mf-menu/src/composable/customAttributes.d.ts +88 -0
  46. package/dist/apps/mf-menu/src/helper/{menuImport.d.ts → import-export.d.ts} +204 -3
  47. package/dist/apps/mf-menu/src/helper/menu.d.ts +77 -0
  48. package/dist/apps/mf-menu/src/helper/setting/catalogSetting.d.ts +11 -2
  49. package/dist/apps/mf-menu/src/manager/menu/item.d.ts +77 -0
  50. package/dist/apps/mf-menu/src/stores/manager/catalog.d.ts +2 -0
  51. package/dist/apps/mf-menu/src/stores/menu.d.ts +79 -0
  52. package/dist/apps/mf-menu/src/views/Publish/UpdateCatalogDialog.vue.d.ts +82 -0
  53. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  54. package/dist/assets/linked-status-fZD691Js.js +24 -0
  55. package/dist/assets/override-menu-Cjy1BJuz.js +24 -0
  56. package/dist/assets/validate-menu-uwysUwDP.js +24 -0
  57. package/dist/{catalog-BDyG_i9q.js → catalog-Wx88K6iI.js} +1 -1
  58. package/dist/catalogSetting-DTEHDSAd.js +71 -0
  59. package/dist/{category-Bi6gpIYU.js → category-BRTw76Vf.js} +1 -1
  60. package/dist/{currency-DDseyYg1.js → currency-562bPc2l.js} +1 -1
  61. package/dist/customAttributes-CXzd5ud1.js +33 -0
  62. package/dist/{dayjs.min-DoQgN0KD.js → dayjs.min-Cnfm8bQm.js} +1 -1
  63. package/dist/{index-DxrEwDTr.js → index-4hf9vONw.js} +2 -2
  64. package/dist/{index-C-zLHAG1.js → index-Crs_eZ0i.js} +28 -28
  65. package/dist/{index-DTUmry92.js → index-DJXrJdeQ.js} +3 -3
  66. package/dist/{item-DqXzPUy9.js → item-CuIxc9FT.js} +377 -377
  67. package/dist/{jszip.min-iAC5WNVU.js → jszip.min-C9xLIvo4.js} +245 -245
  68. package/dist/menu-ILWxqJQe.js +133263 -0
  69. package/dist/{menu-D6df9rcz.js → menu-Mkzv9c8C.js} +4 -4
  70. package/dist/{priceTier-C56BYecC.js → priceTier-D4joq_kN.js} +1 -1
  71. package/dist/{scheduler-DCSpt65t.js → scheduler-DuxWoNVb.js} +3 -3
  72. package/dist/{subcategory-CydaPy_X.js → subcategory-CLLMagXY.js} +43 -43
  73. package/dist/{toExcel-Bil8CwJs.js → toExcel-hGfpS_Uo.js} +2 -2
  74. package/dist/{unit-8DyuBx-X.js → unit-9fycj1fu.js} +1 -1
  75. package/package.json +4 -4
  76. package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-Cf17Iy5i.js +0 -7949
  77. package/dist/Group.vue_vue_type_script_setup_true_lang-vk1J9IxK.js +0 -698
  78. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-B1wrLnf6.js +0 -206
  79. package/dist/Product.vue_vue_type_script_setup_true_lang-BOq8wMzq.js +0 -1560
  80. package/dist/Products-C7BtAjhB.js +0 -659
  81. package/dist/Setting-Bfuf26Gc.js +0 -258
  82. package/dist/_id_-Q_Tyhr4U.js +0 -200
  83. package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +0 -123
  84. package/dist/apps/mf-menu/src/helper/menuExport.d.ts +0 -32
  85. package/dist/assets/linked-status-BhGrXd73.js +0 -24
  86. package/dist/assets/override-menu-CUNDHOWA.js +0 -24
  87. package/dist/assets/validate-menu-BqOizHsX.js +0 -24
  88. package/dist/catalogSetting-C33p_dck.js +0 -65
  89. package/dist/menu-Cir-22ei.js +0 -108039
@@ -0,0 +1,1641 @@
1
+ import { defineComponent as B, computed as x, ref as V, resolveComponent as U, createElementBlock as w, openBlock as v, Fragment as le, createElementVNode as _, createVNode as c, withCtx as I, normalizeClass as ae, toDisplayString as j, unref as n, h as q, createBlock as $, renderList as we, createCommentVNode as R, withModifiers as ce, mergeModels as Qe, useModel as Ye, renderSlot as ve, watch as re, createTextVNode as Ze, watchEffect as Je, nextTick as Te, resolveDynamicComponent as Xe, onMounted as et, isRef as Ne, normalizeStyle as ft } from "vue";
2
+ import { u as ue, Q as xe, A as se, H as Ae, I as me, U as gt, ab as bt, ac as _t, ad as $e, ae as yt, P as ht, af as je } from "./menu-ILWxqJQe.js";
3
+ import { useI18n as fe, useCoreStore as Fe } from "@feedmepos/mf-common";
4
+ import { components as Y, useBreakpoints as tt, useDialog as xt, FmButtonColorThemeVariant as Q, FmButtonVariant as J } from "@feedmepos/ui-library";
5
+ import { u as lt } from "./customAttributes-CXzd5ud1.js";
6
+ import { u as ke } from "./menu-Mkzv9c8C.js";
7
+ import { _ as pe } from "./index.vue_vue_type_script_setup_true_lang-BgqsTzLI.js";
8
+ import { L as Ct } from "./LinkProductSideSheet-CWNarCEs.js";
9
+ import { r as wt, _ as kt, a as St, b as Ft } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-C-z1m3jh.js";
10
+ import { _ as Pe, a as Be } from "./CustomAttributeChip.vue_vue_type_script_setup_true_lang-D-1OzZ-i.js";
11
+ import { f as Vt, o as It, b as $t, m as Tt } from "./subcategory-CLLMagXY.js";
12
+ import { u as at, C as At } from "./item-CuIxc9FT.js";
13
+ import { b as Ee, H as Pt } from "./app-DvG3mOom.js";
14
+ import { F as Dt } from "./index-Crs_eZ0i.js";
15
+ import { _ as Ue, u as Ut } from "./app-CV_q8OdE.js";
16
+ import { _ as Ce } from "./TextChip.vue_vue_type_script_setup_true_lang-8frWuZFL.js";
17
+ import { _ as zt } from "./index-DJXrJdeQ.js";
18
+ import { _ as De } from "./Thumbnail.vue_vue_type_script_setup_true_lang-DzQ8_6Bi.js";
19
+ import { c as Ot } from "./check-C9mY6LiX.js";
20
+ import { f as Rt } from "./currency-562bPc2l.js";
21
+ import { w as Mt } from "./tooltip-B5BiPMx9.js";
22
+ import { r as Kt } from "./index-Ce4v8o7D.js";
23
+ const Nt = {
24
+ class: /* @__PURE__ */ ae(["fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap", "text-fm-color-neutral-gray-400"])
25
+ }, jt = {
26
+ class: "fm-typo-en-title-sm-600"
27
+ }, Bt = {
28
+ class: "max-h-[60vh] flex-1 overflow-y-auto min-h-0"
29
+ }, Ge = /* @__PURE__ */ B({
30
+ __name: "AttributesSelector",
31
+ setup(k) {
32
+ const {
33
+ t: e
34
+ } = fe(), {
35
+ attributes: r
36
+ } = lt(Fe().restaurants, "restaurant"), s = x(() => r.value), l = [{
37
+ header: () => e("portalshell.customAttributes.form.key"),
38
+ accessorKey: "key",
39
+ enableSorting: !1
40
+ }, {
41
+ header: () => e("portalshell.customAttributes.form.value"),
42
+ accessorKey: "values",
43
+ enableSorting: !1,
44
+ cell: (i) => {
45
+ const p = i.row.original, b = p.values;
46
+ return q(Y.FmSelect, {
47
+ modelValue: p.value,
48
+ placeholder: e("portalshell.customAttributes.form.valuePlaceholder"),
49
+ items: b.map((h) => ({
50
+ label: h,
51
+ value: h
52
+ })),
53
+ "onUpdate:modelValue": (h) => p.value = h
54
+ });
55
+ }
56
+ }], d = () => {
57
+ const i = r.value.filter((p) => p.value);
58
+ i.length > 0 ? ue().setRestaurantCustomAttributes(i.reduce((p, b) => (p[b.key] = b.value, p), {})) : ue().setRestaurantCustomAttributes({}), g();
59
+ }, t = V(!1);
60
+ function u() {
61
+ t.value = !0;
62
+ const i = ue().state.currentRestaurantCustomAttributes ?? {};
63
+ Object.keys(i).forEach((p) => {
64
+ s.value.forEach((b) => {
65
+ b.key === p ? b.value = i[p] : b.value = null;
66
+ });
67
+ });
68
+ }
69
+ function g() {
70
+ t.value = !1;
71
+ }
72
+ return (i, p) => {
73
+ const b = U("FmIcon"), h = U("FmChip"), E = U("FmTable"), X = U("FmSpacer"), S = U("fm-button"), W = U("FmDialog");
74
+ return v(), w(le, null, [_("div", {
75
+ class: "inline-flex items-center cursor-pointer",
76
+ onClick: u
77
+ }, [c(h, null, {
78
+ default: I(() => [_("div", Nt, j(n(e)("menu.catalog.form.restaurant_attributes_title")), 1), c(b, {
79
+ color: "neutral-gray-400",
80
+ name: "launch",
81
+ size: "sm"
82
+ })]),
83
+ _: 1
84
+ })]), c(W, {
85
+ modelValue: t.value,
86
+ "onUpdate:modelValue": p[0] || (p[0] = (H) => t.value = H),
87
+ overlay: !0,
88
+ "min-width": "min(calc(100% - 48px), 560px)"
89
+ }, {
90
+ "dialog-header": I(() => [_("div", jt, j(n(e)("menu.catalog.form.restaurant_attributes_title")), 1)]),
91
+ "dialog-footer": I(() => [c(X), c(S, {
92
+ label: n(e)("menu.common.actions.confirm"),
93
+ size: "lg",
94
+ type: "submit",
95
+ variant: "primary",
96
+ onClick: d
97
+ }, null, 8, ["label"]), c(S, {
98
+ label: n(e)("menu.common.actions.cancel"),
99
+ size: "lg",
100
+ variant: "tertiary",
101
+ onClick: g
102
+ }, null, 8, ["label"])]),
103
+ default: I(() => [_("div", Bt, [c(E, {
104
+ "column-defs": l,
105
+ "row-data": s.value,
106
+ "shrink-at": !1,
107
+ "page-size": s.value.length,
108
+ "hide-footer": ""
109
+ }, null, 8, ["row-data", "page-size"])])]),
110
+ _: 1
111
+ }, 8, ["modelValue"])], 64);
112
+ };
113
+ }
114
+ });
115
+ function Et(k, e) {
116
+ const r = V(!0), s = x(() => {
117
+ var u, g;
118
+ return !r.value && (!e.value || ((u = e.value) == null ? void 0 : u.length) === ((g = k.value) == null ? void 0 : g.length));
119
+ }), l = x(() => {
120
+ var u, g, i, p;
121
+ return !!((u = e.value) != null && u.length && ((g = e.value) == null ? void 0 : g.length) > 0 && ((i = e.value) == null ? void 0 : i.length) < ((p = k.value) == null ? void 0 : p.length));
122
+ });
123
+ return { allCleared: r, allSelected: s, indeterminate: l, toggleAll: () => {
124
+ e.value = void 0, r.value = !r.value;
125
+ }, toggleOption: (u) => {
126
+ var i, p, b;
127
+ let g;
128
+ e.value === void 0 && r.value ? g = [u] : e.value === void 0 && !r.value ? g = (i = k.value.map((h) => h.value)) == null ? void 0 : i.filter((h) => h !== u) : (p = e.value) != null && p.includes(u) ? g = (b = e.value) == null ? void 0 : b.filter((h) => h !== u) : g = [...e.value || [], u], g.length === 0 ? (e.value = void 0, r.value = !0) : g.length === k.value.length ? (e.value = void 0, r.value = !1) : e.value = g;
129
+ } };
130
+ }
131
+ const Gt = { class: "inline-flex items-center" }, Lt = {
132
+ key: 0,
133
+ class: /* @__PURE__ */ ae([
134
+ "fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap",
135
+ "text-fm-color-neutral-gray-400"
136
+ ])
137
+ }, qt = { class: "p-4" }, Wt = { class: "flex-1 overflow-y-auto min-h-0" }, Le = /* @__PURE__ */ B({
138
+ __name: "CategorySelector",
139
+ emits: ["toggleAttributeFilter"],
140
+ setup(k, { emit: e }) {
141
+ const r = e, s = ue(), { categories: l, selectedCategories: d } = ke(), t = x(() => s.state.currentCategoryIds), u = x(
142
+ () => l.value.map((P) => ({ label: P.name, value: P.id }))
143
+ ), g = x(() => u.value.filter(
144
+ (P) => P.label.toLowerCase().includes(b.value.toLowerCase())
145
+ )), { t: i } = fe(), p = x(() => {
146
+ var P, K, O;
147
+ return l.value.length === ((P = d.value) == null ? void 0 : P.length) ? i("menu.category.selector.all") : ((K = d.value) == null ? void 0 : K.length) === 1 ? d.value[0].name : `${(O = d.value) == null ? void 0 : O.length}`;
148
+ }), b = V(""), h = x({
149
+ get: () => t.value,
150
+ set: (P) => {
151
+ s.selectCategory(P);
152
+ }
153
+ }), { allSelected: E, toggleAll: X, toggleOption: S, indeterminate: W } = Et(
154
+ u,
155
+ h
156
+ ), H = Fe(), te = x(() => H.itemAttributeSettings.value.length > 0);
157
+ function de() {
158
+ r("toggleAttributeFilter");
159
+ }
160
+ return (P, K) => {
161
+ const O = U("FmIcon"), D = U("FmChip"), z = U("FmSearch"), T = U("FmMenuItem"), L = U("FmMenu");
162
+ return v(), $(L, {
163
+ "close-on-click": !1,
164
+ width: 220
165
+ }, {
166
+ "menu-button": I(() => [
167
+ _("div", Gt, [
168
+ c(D, null, {
169
+ default: I(() => [
170
+ p.value ? (v(), w("div", Lt, j(n(i)("menu.category.selector.title", { label: p.value })), 1)) : R("", !0),
171
+ c(O, {
172
+ color: "neutral-gray-400",
173
+ name: "expand_more",
174
+ size: "sm"
175
+ }),
176
+ te.value ? (v(), w("div", {
177
+ key: 1,
178
+ class: "pl-8 flex items-center justify-center border-l border-fm-color-neutral-gray-200",
179
+ onClick: ce(de, ["stop"])
180
+ }, [
181
+ c(O, {
182
+ name: "filter_alt",
183
+ outline: "",
184
+ color: "neutral-gray-400",
185
+ size: "sm",
186
+ onClick: K[0] || (K[0] = ce(() => {
187
+ }, ["prevent"]))
188
+ })
189
+ ])) : R("", !0)
190
+ ]),
191
+ _: 1
192
+ })
193
+ ])
194
+ ]),
195
+ default: I(() => [
196
+ _("div", qt, [
197
+ c(z, {
198
+ autofocus: "",
199
+ modelValue: b.value,
200
+ "onUpdate:modelValue": K[1] || (K[1] = (N) => b.value = N),
201
+ placeholder: n(i)("menu.common.actions.search")
202
+ }, null, 8, ["modelValue", "placeholder"])
203
+ ]),
204
+ _("div", Wt, [
205
+ c(T, {
206
+ label: "All",
207
+ "has-checkbox": "",
208
+ "model-value": n(E),
209
+ indeterminate: n(W),
210
+ onClick: n(X)
211
+ }, null, 8, ["model-value", "indeterminate", "onClick"]),
212
+ (v(!0), w(le, null, we(g.value, (N) => {
213
+ var M;
214
+ return v(), $(T, {
215
+ key: N.value || "",
216
+ label: N.label,
217
+ "has-checkbox": "",
218
+ "model-value": n(E) || ((M = h.value) == null ? void 0 : M.includes(N.value)),
219
+ onClick: (A) => n(S)(N.value)
220
+ }, null, 8, ["label", "model-value", "onClick"]);
221
+ }), 128))
222
+ ])
223
+ ]),
224
+ _: 1
225
+ });
226
+ };
227
+ }
228
+ }), Ht = { class: "flex flex-wrap gap-8" }, Qt = { class: "py-12 px-16 space-y-12" }, Yt = { class: "fm-typo-en-body-md-600 text-fm-color-neutral-gray-600" }, Zt = { class: "flex flex-wrap gap-8" }, Jt = {
229
+ key: 0,
230
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
231
+ }, Xt = { key: 0 }, el = {
232
+ key: 1,
233
+ class: "inline-block w-8"
234
+ }, tl = { key: 0 }, ll = { key: 1 }, qe = /* @__PURE__ */ B({
235
+ __name: "CategoriesChip",
236
+ props: {
237
+ categories: { default: () => [] },
238
+ ellipsis: { type: Boolean, default: !0 }
239
+ },
240
+ setup(k) {
241
+ const e = k, { t: r } = fe(), s = tt(), l = x(() => s.breakpoints.value.xs), d = x(() => e.ellipsis ? l.value ? 1 : 2 : 1 / 0), t = x(() => e.categories.length <= d.value ? e.categories : e.categories.slice(0, d.value)), u = V(!0), g = x(() => {
242
+ if (u.value) {
243
+ const p = t.value.join(", ");
244
+ return p.length > 20 ? p.slice(0, 20) + "..." : p;
245
+ }
246
+ return e.categories.join(", ");
247
+ });
248
+ return (i, p) => {
249
+ const b = U("FmTooltip");
250
+ return l.value ? (v(), w(le, { key: 1 }, [
251
+ i.categories.length > 0 ? (v(), w("p", Jt, [
252
+ _("span", null, j(n(r)("menu.product.table.columns.category")) + ": ", 1),
253
+ _("span", null, j(g.value), 1),
254
+ u.value ? (v(), w("span", el)) : (v(), w("br", Xt)),
255
+ i.categories.length > d.value ? (v(), w("span", {
256
+ key: 2,
257
+ class: "fm-typo-en-body-md-400 text-fm-color-primary cursor-pointer",
258
+ onClick: p[0] || (p[0] = ce((h) => u.value = !u.value, ["stop", "prevent"]))
259
+ }, [
260
+ u.value ? (v(), w("span", tl, j(n(r)("menu.product.table.category.expand", { count: i.categories.length - d.value })), 1)) : (v(), w("span", ll, j(n(r)("menu.product.table.category.collapse")), 1))
261
+ ])) : R("", !0)
262
+ ])) : R("", !0)
263
+ ], 64)) : (v(), $(b, {
264
+ key: 0,
265
+ class: "flex",
266
+ variant: "rich",
267
+ placement: "top",
268
+ "z-index": 50
269
+ }, {
270
+ content: I(() => [
271
+ _("div", Qt, [
272
+ _("p", Yt, j(n(r)("menu.product.table.category.all")), 1),
273
+ _("div", Zt, [
274
+ (v(!0), w(le, null, we(e.categories, (h) => (v(), $(Ce, {
275
+ key: h,
276
+ label: h,
277
+ variant: "neutral"
278
+ }, null, 8, ["label"]))), 128))
279
+ ])
280
+ ])
281
+ ]),
282
+ default: I(() => [
283
+ _("div", Ht, [
284
+ (v(!0), w(le, null, we(t.value, (h) => (v(), $(Ce, {
285
+ key: h,
286
+ label: h,
287
+ variant: "neutral"
288
+ }, null, 8, ["label"]))), 128)),
289
+ i.categories.length > d.value ? (v(), $(Ce, {
290
+ key: 0,
291
+ label: "...",
292
+ variant: "neutral"
293
+ })) : R("", !0)
294
+ ])
295
+ ]),
296
+ _: 1
297
+ }));
298
+ };
299
+ }
300
+ }), al = /* @__PURE__ */ B({
301
+ __name: "ProductSearcher",
302
+ props: /* @__PURE__ */ Qe({
303
+ label: {},
304
+ helperText: {},
305
+ menu: {}
306
+ }, {
307
+ modelValue: { required: !0 },
308
+ modelModifiers: {}
309
+ }),
310
+ emits: ["update:modelValue"],
311
+ setup(k) {
312
+ const e = k, r = Ye(k, "modelValue"), s = x(() => e.menu.modules.item.map((l) => ({
313
+ label: l.code ? `${l.code} ${l.name}` : l.name,
314
+ value: l._id
315
+ })));
316
+ return (l, d) => {
317
+ const t = U("FmSelect");
318
+ return v(), $(t, {
319
+ modelValue: r.value,
320
+ "onUpdate:modelValue": d[0] || (d[0] = (u) => r.value = u),
321
+ items: s.value,
322
+ searchable: !0,
323
+ "search-target": "label",
324
+ placeholder: "Search by product name or code",
325
+ label: l.label,
326
+ "helper-text": l.helperText
327
+ }, null, 8, ["modelValue", "items", "label", "helper-text"]);
328
+ };
329
+ }
330
+ }), ol = { class: "flex" }, nl = { class: "w-[260px] space-y-16 h-full" }, rl = { class: "flex items-center gap-4 px-8" }, sl = { class: "fm-typo-en-title-sm-600" }, ul = {
331
+ key: 0,
332
+ class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4"
333
+ }, il = { class: "fm-typo-en-body-md-600" }, cl = { class: "flex-1" }, ot = /* @__PURE__ */ B({
334
+ __name: "ViewLayout",
335
+ props: /* @__PURE__ */ Qe({
336
+ title: {},
337
+ titleBadge: {},
338
+ items: {}
339
+ }, {
340
+ modelValue: { required: !0 },
341
+ modelModifiers: {}
342
+ }),
343
+ emits: ["update:modelValue"],
344
+ setup(k) {
345
+ const e = Ye(k, "modelValue");
346
+ return (r, s) => {
347
+ const l = U("FmCollapsibleTabs");
348
+ return v(), w("div", ol, [
349
+ _("div", nl, [
350
+ _("div", rl, [
351
+ _("p", sl, j(r.title), 1),
352
+ r.titleBadge !== void 0 ? (v(), w("div", ul, [
353
+ _("p", il, j(r.titleBadge), 1)
354
+ ])) : R("", !0)
355
+ ]),
356
+ c(Ue, null, {
357
+ default: I(() => [
358
+ c(l, {
359
+ modelValue: e.value,
360
+ "onUpdate:modelValue": s[0] || (s[0] = (d) => e.value = d),
361
+ items: r.items
362
+ }, null, 8, ["modelValue", "items"])
363
+ ]),
364
+ _: 1
365
+ })
366
+ ]),
367
+ s[1] || (s[1] = _("div", { class: "w-[1px] min-h-full ml-4 mr-12 bg-fm-color-neutral-gray-100 self-stretch" }, null, -1)),
368
+ _("div", cl, [
369
+ ve(r.$slots, "default")
370
+ ])
371
+ ]);
372
+ };
373
+ }
374
+ }), Se = /* @__PURE__ */ B({
375
+ __name: "OrderFromChip",
376
+ props: {
377
+ orderFrom: {}
378
+ },
379
+ setup(k) {
380
+ const e = k, r = xe();
381
+ return (s, l) => {
382
+ var d, t;
383
+ return v(), $(Ce, {
384
+ label: ((d = n(r)[e.orderFrom]) == null ? void 0 : d.label) || e.orderFrom,
385
+ variant: (t = n(r)[e.orderFrom]) == null ? void 0 : t.variant
386
+ }, null, 8, ["label", "variant"]);
387
+ };
388
+ }
389
+ }), dl = /* @__PURE__ */ B({
390
+ __name: "GroupViewTable",
391
+ props: {
392
+ data: {}
393
+ },
394
+ setup(k) {
395
+ const e = k, r = [{
396
+ accessorKey: "code",
397
+ header: () => "Code",
398
+ enableSorting: !1,
399
+ cell: ({
400
+ row: t
401
+ }) => {
402
+ const u = t.original;
403
+ return u.subRows ? c("div", {
404
+ class: "flex items-center gap-2 fm-typo-en-body-md-600 text-fm-color-typo-secondary"
405
+ }, [c(Y.FmButton, {
406
+ icon: "keyboard_arrow_up",
407
+ variant: "tertiary",
408
+ class: ["cursor-pointer", "transition-transform", t.getIsExpanded() ? "transform rotate-180" : ""],
409
+ onClick: t.getToggleExpandedHandler()
410
+ }, null), Ze("Found in group: "), u.groupName]) : u.code;
411
+ },
412
+ meta: {
413
+ colspan: (t) => t.original.subRows ? 5 : 1
414
+ }
415
+ }, {
416
+ accessorKey: "productName",
417
+ header: () => "Product name",
418
+ enableSorting: !1,
419
+ meta: {
420
+ colspan: (t) => t.original.subRows ? 0 : 1
421
+ }
422
+ }, {
423
+ accessorKey: "variant",
424
+ header: () => "Variant",
425
+ enableSorting: !1,
426
+ meta: {
427
+ colspan: (t) => t.original.subRows ? 0 : 1
428
+ }
429
+ }, {
430
+ accessorKey: "price",
431
+ header: () => "Price",
432
+ enableSorting: !1,
433
+ meta: {
434
+ colspan: (t) => t.original.subRows ? 0 : 1
435
+ }
436
+ }, {
437
+ accessorKey: "orderFrom",
438
+ header: () => "Order from",
439
+ enableSorting: !1,
440
+ cell: (t) => {
441
+ const u = t.row.original;
442
+ return c(Se, {
443
+ orderFrom: u.orderFrom ?? ""
444
+ }, null);
445
+ },
446
+ meta: {
447
+ colspan: (t) => t.original.subRows ? 0 : 1
448
+ }
449
+ }], s = V({}), l = (t) => t.subRows;
450
+ function d() {
451
+ s.value = Object.fromEntries(e.data.map((t, u) => [u, !0]));
452
+ }
453
+ return re(() => e.data, () => {
454
+ d();
455
+ }), (t, u) => {
456
+ const g = U("FmTable");
457
+ return v(), $(Ue, null, {
458
+ default: I(() => [c(g, {
459
+ "column-defs": r,
460
+ "row-data": t.data,
461
+ "hide-footer": !0,
462
+ "page-size": 1e6,
463
+ "get-sub-row": l,
464
+ "expanded-state": s.value,
465
+ "shrink-at": !1,
466
+ "onUpdate:expandedState": u[0] || (u[0] = (i) => s.value = i)
467
+ }, null, 8, ["row-data", "expanded-state"])]),
468
+ _: 1
469
+ });
470
+ };
471
+ }
472
+ }), ml = /* @__PURE__ */ B({
473
+ __name: "GroupView",
474
+ props: {
475
+ itemId: {},
476
+ menu: {}
477
+ },
478
+ setup(k) {
479
+ const e = k, r = V(""), s = x(() => l.value.reduce((i, p) => i + (typeof p.badge == "number" ? p.badge ?? 1 : 0), 0)), l = V([]), d = x(() => {
480
+ const i = l.value.find((b) => b.value === r.value);
481
+ return ((i == null ? void 0 : i.itemInGroup) || []).map((b) => ({
482
+ groupName: b.group.name,
483
+ subRows: b.items.map((h) => ({
484
+ // @ts-ignore
485
+ code: h.code || h.fallbackCode,
486
+ productName: h.combinationKey ? "" : h.name ?? "",
487
+ price: h.price ? se.Dinero.fromFdoDinero(h.price).toFormat() : "--",
488
+ orderFrom: h.orderFrom ?? void 0,
489
+ variant: h.combinationKey ? h.name ?? "" : void 0
490
+ }))
491
+ }));
492
+ });
493
+ function t() {
494
+ return [{
495
+ label: "Master product",
496
+ value: "",
497
+ catalogId: null,
498
+ data: [],
499
+ disabled: !1,
500
+ badge: void 0,
501
+ itemInGroup: []
502
+ }, ...e.menu.modules.catalog.map((p) => ({
503
+ label: p.name,
504
+ value: p._id,
505
+ catalogId: p._id,
506
+ data: [],
507
+ disabled: !1,
508
+ badge: void 0,
509
+ itemInGroup: []
510
+ }))];
511
+ }
512
+ x(() => l.value.find((i) => i.value === r.value));
513
+ async function u(i) {
514
+ const p = l.value.find((b) => b.catalogId === i);
515
+ if (p) {
516
+ p.badge = () => c(Y.FmCircularProgress, {
517
+ size: "md"
518
+ }, null);
519
+ const b = await Vt(Ae(e.menu), i, e.itemId);
520
+ p.badge = b.length, p.disabled = b.length <= 0, p.itemInGroup = b;
521
+ }
522
+ }
523
+ function g() {
524
+ l.value = t(), l.value.forEach((i) => {
525
+ u(i.catalogId);
526
+ });
527
+ }
528
+ return re([() => e.menu, () => e.itemId], () => {
529
+ e.menu && e.itemId && g();
530
+ }, {
531
+ immediate: !0
532
+ }), (i, p) => (v(), $(ot, {
533
+ modelValue: r.value,
534
+ "onUpdate:modelValue": p[0] || (p[0] = (b) => r.value = b),
535
+ items: l.value,
536
+ title: "Catalog",
537
+ "title-badge": s.value
538
+ }, {
539
+ default: I(() => [c(dl, {
540
+ data: d.value
541
+ }, null, 8, ["data"])]),
542
+ _: 1
543
+ }, 8, ["modelValue", "items", "title-badge"]));
544
+ }
545
+ }), pl = {
546
+ class: "scroll-x-auto"
547
+ }, vl = /* @__PURE__ */ B({
548
+ __name: "ProductViewTable",
549
+ props: {
550
+ itemId: {},
551
+ menu: {},
552
+ catalogId: {},
553
+ schedulerIds: {}
554
+ },
555
+ setup(k) {
556
+ const e = k, r = [{
557
+ accessorKey: "scheduler",
558
+ header: () => "Scheduler",
559
+ enableSorting: !1,
560
+ cell: (d) => {
561
+ const t = d.row.original, u = t.loading ? c(Y.FmCircularProgress, {
562
+ size: "md"
563
+ }, null) : null;
564
+ return c("div", {
565
+ class: "flex items-center gap-2"
566
+ }, [t.scheduler, u]);
567
+ }
568
+ }, {
569
+ accessorKey: "code",
570
+ header: () => "Code",
571
+ enableSorting: !1
572
+ }, {
573
+ accessorKey: "productName",
574
+ header: () => "Product name",
575
+ enableSorting: !1
576
+ }, {
577
+ accessorKey: "price",
578
+ header: () => "Price",
579
+ enableSorting: !1
580
+ }, {
581
+ accessorKey: "orderFrom",
582
+ header: () => "Order from",
583
+ cell: (d) => {
584
+ const t = d.row.original;
585
+ return c(Se, {
586
+ orderFrom: t.orderFrom
587
+ }, null);
588
+ },
589
+ enableSorting: !1
590
+ }], s = V([]);
591
+ function l(d, t) {
592
+ return {
593
+ loading: !0,
594
+ schedulerId: d,
595
+ scheduler: t,
596
+ code: "--",
597
+ productName: "--",
598
+ price: "--",
599
+ orderFrom: "--"
600
+ };
601
+ }
602
+ return re([() => e.menu, () => e.catalogId, () => e.schedulerIds], async () => {
603
+ s.value = [l(null, "All day"), ...e.schedulerIds.map((d) => {
604
+ var t;
605
+ return l(d, ((t = e.menu.modules.scheduler.find((u) => u._id === d)) == null ? void 0 : t.name) || "Unknown");
606
+ })], s.value.forEach(async (d) => {
607
+ const u = (await It(Ae(e.menu), e.catalogId, d.schedulerId)).modules.item.find((i) => i._id === e.itemId), g = s.value.findIndex((i) => i.schedulerId === d.schedulerId);
608
+ if (u) {
609
+ const i = Ae(s.value);
610
+ i[g].loading = !1, i[g].code = u.code || "--", i[g].productName = u.name || "--", i[g].price = se.Dinero.fromFdoDinero(u.price).toFormat(), i[g].orderFrom = u.orderFrom || "--", s.value = i;
611
+ }
612
+ });
613
+ }), (d, t) => {
614
+ const u = U("FmTable");
615
+ return v(), $(Ue, null, {
616
+ default: I(() => [_("div", pl, [c(u, {
617
+ class: "min-w-[800px]",
618
+ "column-defs": r,
619
+ "row-data": s.value,
620
+ "hide-footer": !0,
621
+ "page-size": s.value.length,
622
+ "shrink-at": !1
623
+ }, null, 8, ["row-data", "page-size"])])]),
624
+ _: 1
625
+ });
626
+ };
627
+ }
628
+ }), fl = /* @__PURE__ */ B({
629
+ __name: "ProductView",
630
+ props: {
631
+ itemId: {},
632
+ menu: {}
633
+ },
634
+ setup(k) {
635
+ const e = k, r = V(null);
636
+ Je(async () => {
637
+ r.value = await $t(e.menu, e.itemId), await Te(), s.value = l.value[0].value;
638
+ });
639
+ const s = V(""), l = x(() => {
640
+ var g, i;
641
+ const t = {
642
+ label: "Master product",
643
+ value: "",
644
+ catalogId: null,
645
+ badge: (((g = r.value) == null ? void 0 : g.schedulers.length) || 0) + 1,
646
+ schedulerIds: (i = r.value) == null ? void 0 : i.schedulers
647
+ };
648
+ if (!r.value)
649
+ return [t];
650
+ const u = e.menu.modules.catalog.map((p) => {
651
+ const b = r.value.catalogs[p._id];
652
+ return {
653
+ label: p.name,
654
+ value: p._id,
655
+ disabled: !b,
656
+ catalogId: p._id,
657
+ badge: b ? ((b == null ? void 0 : b.schedulers.length) || 0) + 1 : 0,
658
+ schedulerIds: b == null ? void 0 : b.schedulers
659
+ };
660
+ });
661
+ return [t, ...u];
662
+ }), d = x(() => l.value.find((t) => t.value === s.value));
663
+ return (t, u) => (v(), $(ot, {
664
+ modelValue: s.value,
665
+ "onUpdate:modelValue": u[0] || (u[0] = (g) => s.value = g),
666
+ items: l.value,
667
+ title: "Catalog",
668
+ "title-badge": l.value.filter((g) => !g.disabled).length
669
+ }, {
670
+ default: I(() => {
671
+ var g, i;
672
+ return [
673
+ c(vl, {
674
+ menu: t.menu,
675
+ "item-id": t.itemId,
676
+ "catalog-id": ((g = d.value) == null ? void 0 : g.catalogId) || null,
677
+ "scheduler-ids": ((i = d.value) == null ? void 0 : i.schedulerIds) || []
678
+ }, null, 8, ["menu", "item-id", "catalog-id", "scheduler-ids"])
679
+ ];
680
+ }),
681
+ _: 1
682
+ }, 8, ["modelValue", "items", "title-badge"]));
683
+ }
684
+ }), gl = { class: "flex items-center gap-8" }, bl = { class: "space-y-4" }, _l = { class: "fm-typo-en-title-md-600" }, yl = { key: 0 }, hl = { class: "text-fm-color-typo-secondary" }, xl = {
685
+ key: 0,
686
+ class: "text-fm-color-typo-secondary"
687
+ }, Cl = { class: "flex items-center gap-4" }, wl = /* @__PURE__ */ B({
688
+ __name: "ProductBaseInfo",
689
+ props: {
690
+ itemId: {},
691
+ menu: {}
692
+ },
693
+ setup(k) {
694
+ const e = k, r = x(() => e.menu.modules.item.find((l) => l._id === e.itemId)), s = x(() => {
695
+ var l;
696
+ return se.Dinero.fromFdoDinero((l = r.value) == null ? void 0 : l.price).toFormat(!0);
697
+ });
698
+ return (l, d) => {
699
+ var t, u, g, i, p, b, h;
700
+ return v(), w("div", gl, [
701
+ c(De, {
702
+ alt: ((t = r.value) == null ? void 0 : t.name) ?? null,
703
+ size: 72,
704
+ src: (u = r.value) == null ? void 0 : u.thumbnail,
705
+ crossorigin: !1
706
+ }, null, 8, ["alt", "src"]),
707
+ _("div", bl, [
708
+ _("p", _l, [
709
+ (g = r.value) != null && g.code ? (v(), w("span", yl, j((i = r.value) == null ? void 0 : i.code) + ", ", 1)) : R("", !0),
710
+ _("span", null, j((p = r.value) == null ? void 0 : p.name), 1)
711
+ ]),
712
+ _("p", hl, "Base price: " + j(s.value), 1),
713
+ (b = r.value) != null && b.customAttributes ? (v(), w("div", xl, [
714
+ _("div", Cl, [
715
+ d[0] || (d[0] = _("span", null, "Tagging:", -1)),
716
+ c(Pe, {
717
+ ellipsis: !1,
718
+ "custom-attributes": (h = r.value) == null ? void 0 : h.customAttributes
719
+ }, null, 8, ["custom-attributes"])
720
+ ])
721
+ ])) : R("", !0)
722
+ ])
723
+ ]);
724
+ };
725
+ }
726
+ }), kl = { class: "space-y-16" }, Sl = /* @__PURE__ */ B({
727
+ __name: "ProductViewer",
728
+ props: {
729
+ itemId: {},
730
+ menu: {}
731
+ },
732
+ setup(k) {
733
+ const e = V("product"), r = x(() => [
734
+ {
735
+ value: "product",
736
+ label: "Product",
737
+ component: fl
738
+ },
739
+ {
740
+ value: "group",
741
+ label: "Group",
742
+ component: ml
743
+ }
744
+ ]);
745
+ return (s, l) => {
746
+ var t;
747
+ const d = U("FmTabs");
748
+ return v(), w("div", kl, [
749
+ c(wl, {
750
+ "item-id": s.itemId,
751
+ menu: s.menu
752
+ }, null, 8, ["item-id", "menu"]),
753
+ _("div", null, [
754
+ c(d, {
755
+ modelValue: e.value,
756
+ "onUpdate:modelValue": l[0] || (l[0] = (u) => e.value = u),
757
+ items: r.value
758
+ }, null, 8, ["modelValue", "items"])
759
+ ]),
760
+ _("div", null, [
761
+ (v(), $(Xe((t = r.value.find((u) => u.value === e.value)) == null ? void 0 : t.component), {
762
+ "item-id": s.itemId,
763
+ menu: s.menu
764
+ }, null, 8, ["item-id", "menu"]))
765
+ ])
766
+ ]);
767
+ };
768
+ }
769
+ }), Fl = { class: "space-y-24" }, Vl = { key: 0 }, Il = /* @__PURE__ */ B({
770
+ __name: "ProductOverview",
771
+ props: {
772
+ itemId: {},
773
+ showSearch: { type: Boolean, default: !1 }
774
+ },
775
+ setup(k) {
776
+ const e = k, r = ue(), s = V(null);
777
+ return et(() => {
778
+ s.value = e.itemId;
779
+ }), (l, d) => (v(), w("div", Fl, [
780
+ l.showSearch ? (v(), w("div", Vl, [
781
+ c(al, {
782
+ modelValue: s.value,
783
+ "onUpdate:modelValue": d[0] || (d[0] = (t) => s.value = t),
784
+ class: "w-1/2",
785
+ label: "Search and compare prices",
786
+ "helper-text": "Quickly find products and view their prices across different catalogs and schedules.",
787
+ menu: n(r).state.menu
788
+ }, null, 8, ["modelValue", "menu"])
789
+ ])) : R("", !0),
790
+ _("div", null, [
791
+ s.value ? (v(), $(Sl, {
792
+ key: 0,
793
+ "item-id": s.value,
794
+ menu: n(r).state.menu
795
+ }, null, 8, ["item-id", "menu"])) : R("", !0)
796
+ ])
797
+ ]));
798
+ }
799
+ }), $l = /* @__PURE__ */ B({
800
+ __name: "OverviewSheet",
801
+ setup(k) {
802
+ const e = V(null), r = V(!1);
803
+ function s(l) {
804
+ r.value = !r.value, l && (e.value = l);
805
+ }
806
+ return (l, d) => {
807
+ const t = U("FmSideSheet");
808
+ return v(), w(le, null, [
809
+ ve(l.$slots, "default", { trigger: s }),
810
+ c(t, {
811
+ id: "product-overview",
812
+ modelValue: r.value,
813
+ "onUpdate:modelValue": d[0] || (d[0] = (u) => r.value = u),
814
+ "max-width": 1200,
815
+ "dismiss-away": ""
816
+ }, {
817
+ "side-sheet-header": I(() => d[1] || (d[1] = [
818
+ _("p", { class: "fm-typo-en-title-md-600" }, "Product Overview", -1)
819
+ ])),
820
+ default: I(() => [
821
+ _("div", null, [
822
+ r.value && e.value ? (v(), $(Il, {
823
+ key: 0,
824
+ "item-id": e.value
825
+ }, null, 8, ["item-id"])) : R("", !0)
826
+ ])
827
+ ]),
828
+ _: 1
829
+ }, 8, ["modelValue"])
830
+ ], 64);
831
+ };
832
+ }
833
+ });
834
+ var Tl = wt();
835
+ const We = /* @__PURE__ */ B({
836
+ __name: "ImportButton",
837
+ setup(k) {
838
+ const e = V(!1);
839
+ function r() {
840
+ e.value = !e.value;
841
+ }
842
+ const s = Fe();
843
+ return et(() => {
844
+ const l = s.currentCountry.value;
845
+ if (l)
846
+ try {
847
+ Tl.setCountryConfig(l);
848
+ } catch (d) {
849
+ console.log("Unable to set country config", d);
850
+ }
851
+ }), (l, d) => (v(), w(le, null, [
852
+ c(kt, {
853
+ modelValue: e.value,
854
+ "onUpdate:modelValue": d[0] || (d[0] = (t) => e.value = t)
855
+ }, null, 8, ["modelValue"]),
856
+ ve(l.$slots, "default", { trigger: r })
857
+ ], 64));
858
+ }
859
+ }), He = (k) => c("div", {
860
+ class: "flex flex-1 justify-end"
861
+ }, [c("span", null, [k, Ze(" ")])]), Al = {
862
+ class: "flex justify-between items-center space-x-8"
863
+ }, Pl = {
864
+ class: "flex space-x-8 items-center"
865
+ }, Dl = {
866
+ class: "w-[320px]"
867
+ }, Ul = {
868
+ key: 0
869
+ }, zl = {
870
+ key: 1,
871
+ class: /* @__PURE__ */ ae(["flex-1 flex flex-col", "divide-y divide-fm-color-neutral-gray-100", "overflow-hidden"])
872
+ }, Ol = {
873
+ key: 0,
874
+ class: "flex items-center p-4"
875
+ }, Rl = {
876
+ class: /* @__PURE__ */ ae(["mr-8", "fm-typo-en-body-md-400"])
877
+ }, Ml = {
878
+ key: 1,
879
+ class: "px-16 py-4 space-x-8 flex justify-end"
880
+ }, Kl = {
881
+ key: 2
882
+ }, Nl = {
883
+ class: "flex space-x-8"
884
+ }, jl = {
885
+ key: 1,
886
+ class: "pt-8 flex flex-col flex-1 overflow-hidden"
887
+ }, Bl = {
888
+ class: "space-y-8 pb-8"
889
+ }, El = {
890
+ class: "w-full px-8"
891
+ }, Gl = {
892
+ class: "flex space-x-8 px-8"
893
+ }, Ll = {
894
+ key: 0,
895
+ class: "px-8"
896
+ }, ql = {
897
+ key: 0,
898
+ class: /* @__PURE__ */ ae(["flex flex-col flex-1", "overflow-scroll", "divide-y divide-fm-color-neutral-gray-100", "pb-64"])
899
+ }, Wl = ["onClick"], Hl = {
900
+ class: "min-w-0 flex flex-1 items-center justify-start space-x-16"
901
+ }, Ql = {
902
+ class: "flex-1 min-w-0"
903
+ }, Yl = {
904
+ class: "flex justify-between items-center gap-8 pb-4"
905
+ }, Zl = {
906
+ class: "flex-1 min-w-0 fm-typo-en-body-lg-600 line-clamp-2"
907
+ }, Jl = {
908
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
909
+ }, Xl = {
910
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
911
+ }, ea = {
912
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
913
+ }, ta = {
914
+ key: 1
915
+ }, la = {
916
+ class: "flex space-x-8"
917
+ }, aa = /* @__PURE__ */ B({
918
+ __name: "ProductTable",
919
+ props: {
920
+ modelValue: {},
921
+ originalValue: {},
922
+ isCalculating: {
923
+ type: Boolean
924
+ }
925
+ },
926
+ emits: ["update:model-value", "reset:model-value", "update:editing", "update:search-key"],
927
+ setup(k, {
928
+ expose: e,
929
+ emit: r
930
+ }) {
931
+ const s = k, {
932
+ t: l
933
+ } = fe(), d = Fe(), t = ue(), u = xt(), g = at(), i = d.currentCountry, p = x(() => i.value ? se.Country.getCountry(i.value) : null), b = x(() => t.rules.item), {
934
+ selectedCategories: h
935
+ } = ke(), E = x(() => {
936
+ const a = me.flatten(h.value.map((o) => o.items));
937
+ return me.uniqBy(a, (o) => o._id);
938
+ }), X = r, S = V(!1);
939
+ re(() => S.value, (a) => {
940
+ X("update:editing", a);
941
+ });
942
+ const W = (a) => {
943
+ Ot.isBoolean(a) ? S.value = a : S.value = !S.value;
944
+ }, H = V(!1), te = V(null);
945
+ async function de() {
946
+ H.value = !H.value, H.value && (await Te(), te.value && te.value.toggleProperty(!0));
947
+ }
948
+ e({
949
+ toggleAttributeFilter: de
950
+ });
951
+ const {
952
+ attributes: P,
953
+ filterRule: K,
954
+ mongoQuery: O
955
+ } = lt(E, "item"), D = V(""), z = Kt(D, 300), T = x(() => {
956
+ const a = (m) => {
957
+ var C;
958
+ return !z.value || !z.value.trim() ? !0 : [m.code, m.name, Re(m), ...$e(L.value, m), (C = xe()[m.orderFrom]) == null ? void 0 : C.label, Object.values(m.customAttributes ?? {}).join(" ")].join(" ").toLowerCase().includes(z.value.toLowerCase());
959
+ }, o = (m) => K.value ? Pt(m.customAttributes, O.value) : !0;
960
+ return E.value.filter((m) => a(m) && o(m));
961
+ }), {
962
+ categories: L
963
+ } = ke(), N = x(() => t.categories.map((a) => ({
964
+ label: a.name,
965
+ value: a._id || null
966
+ }))), M = (a, o, m) => {
967
+ let f = me.clone(s.modelValue);
968
+ const C = f[a];
969
+ C && (typeof o == "object" && o !== null ? f[a] = {
970
+ ...C,
971
+ ...o
972
+ } : f[a] = {
973
+ ...C,
974
+ [o]: m
975
+ }, X("update:model-value", f));
976
+ }, A = bt(() => s.originalValue, () => s.modelValue), Z = me.debounce(M, 300), G = (a) => (o) => !!o || l("menu.product.table.validation.name_required", {
977
+ field: a
978
+ }), oe = (a) => a >= 0 || l("menu.product.table.validation.price_min"), ge = [G("Name")], be = () => [(a) => oe(typeof a == "number" ? a : Number(a) ?? 0)], _e = xe(), nt = x(() => {
979
+ const a = t.isV4;
980
+ return gt.setCoreStore(d).taxSetting(a);
981
+ }), ze = x(() => [{
982
+ accessorKey: "thumbnail",
983
+ header: "",
984
+ size: 110,
985
+ meta: {
986
+ cellClass: "px-0",
987
+ headerContentClass: "px-0"
988
+ },
989
+ cell: (a) => {
990
+ var o, m;
991
+ return q(De, {
992
+ src: a.getValue(),
993
+ alt: (m = (o = a == null ? void 0 : a.row) == null ? void 0 : o.original) == null ? void 0 : m.name,
994
+ className: "my-8 mx-12",
995
+ size: 72,
996
+ crossorigin: !1
997
+ });
998
+ },
999
+ enableSorting: !1
1000
+ }, {
1001
+ accessorKey: "code",
1002
+ header: () => l("menu.product.table.columns.code"),
1003
+ enableSorting: !1,
1004
+ size: 100,
1005
+ cell: (a) => {
1006
+ const o = a.row.original, m = a.getValue() || "--";
1007
+ if (!S.value) return c("span", {
1008
+ class: "break-all"
1009
+ }, [m]);
1010
+ const f = Ie(o._id);
1011
+ return q(Y.FmTextField, {
1012
+ disabled: !b.value.code,
1013
+ modelValue: A(o._id, "code") ?? (f == null ? void 0 : f.code),
1014
+ placeholder: s.modelValue[o._id].fallbackCode,
1015
+ "onUpdate:modelValue": (C) => {
1016
+ Z(o._id, "code", C);
1017
+ }
1018
+ });
1019
+ }
1020
+ }, {
1021
+ accessorKey: "name",
1022
+ header: () => l("menu.product.table.columns.name"),
1023
+ enableSorting: !1,
1024
+ size: 200,
1025
+ cell: (a) => {
1026
+ const o = a.row.original, m = a.getValue();
1027
+ return S.value ? q(Y.FmTextField, {
1028
+ disabled: !b.value.name,
1029
+ modelValue: A(o._id, "name") ?? o.name,
1030
+ "onUpdate:modelValue": (f) => {
1031
+ Z(o._id, "name", f);
1032
+ },
1033
+ rules: ge,
1034
+ placeholder: o.fallbackName
1035
+ }) : m;
1036
+ }
1037
+ }, {
1038
+ accessorKey: "price",
1039
+ header: () => {
1040
+ var a;
1041
+ return He(l("menu.product.table.columns.price", {
1042
+ currency: (a = p.value) == null ? void 0 : a.currency.symbol
1043
+ }));
1044
+ },
1045
+ enableSorting: !1,
1046
+ size: 140,
1047
+ meta: {
1048
+ textAlign: "right"
1049
+ },
1050
+ cell: (a) => {
1051
+ var C;
1052
+ const o = a.getValue();
1053
+ if (!S.value) return se.Dinero.fromFdoDinero(o).toFormat();
1054
+ const m = s.modelValue[a.row.original._id], f = m.fallbackPrice;
1055
+ return q(zt, {
1056
+ min: 0,
1057
+ disabled: !m.editPrice,
1058
+ // @ts-ignore
1059
+ placeholder: f ? Rt(f, !1) : void 0,
1060
+ modelValue: A(m._id, "price") ?? ((C = Ie(m._id)) == null ? void 0 : C.price),
1061
+ // @ts-ignore
1062
+ "onUpdate:modelValue": (F) => {
1063
+ M(m._id, "price", F);
1064
+ },
1065
+ rules: be()
1066
+ });
1067
+ }
1068
+ }, {
1069
+ accessorKey: "taxes",
1070
+ header: () => He(nt.value.systemCode),
1071
+ size: S.value ? 120 : 80,
1072
+ enableSorting: !1,
1073
+ meta: {
1074
+ textAlign: "right"
1075
+ },
1076
+ cell: (a) => {
1077
+ const o = a.getValue(), m = a.row.original, f = t.taxSetting.countryTaxOptions, C = t.getSelectedTax(o, m.fallbackTaxes, t.taxSetting.countryTaxOptions), F = f.find((ee) => ee.value === C);
1078
+ if (!S.value)
1079
+ return `${F != null && F.meta.rate ? _t(F.meta.rate) : 0}%`;
1080
+ const y = t.getSelectedTax(A(m._id, "taxes") ?? o, m.fallbackTaxes, t.taxSetting.countryTaxOptions);
1081
+ return q(Y.FmSelect, {
1082
+ disabled: !b.value.tax,
1083
+ items: t.taxSetting.countryTaxOptions,
1084
+ modelValue: y,
1085
+ "onUpdate:modelValue": async (ee) => {
1086
+ const he = t.decodeTax(ee);
1087
+ Z(m._id, "taxes", [he]);
1088
+ }
1089
+ });
1090
+ }
1091
+ }, {
1092
+ accessorKey: "category",
1093
+ header: () => l("menu.product.table.columns.category"),
1094
+ enableSorting: !1,
1095
+ size: 140,
1096
+ cell: (a) => {
1097
+ const o = a.row.original;
1098
+ if (!S.value)
1099
+ return q(qe, {
1100
+ categories: $e(L.value, o)
1101
+ });
1102
+ const m = yt(s.originalValue, s.modelValue, o._id) ?? ht(o), f = (m == null ? void 0 : m.map((F) => F._id)) ?? [], C = m == null ? void 0 : m.reduce((F, y) => (F[y._id] = y, F), {});
1103
+ return q(At, {
1104
+ shouldShowChips: !1,
1105
+ shouldShowSelectedItemsWithinPlaceholder: !0,
1106
+ modelValue: f.length > 0 ? f : [null],
1107
+ items: N.value,
1108
+ disabled: !!(t.state.currentCatalogId || t.state.currentSchedulerId),
1109
+ "onUpdate:modelValue": async (F) => {
1110
+ const [y, ...ee] = F;
1111
+ Z(o._id, {
1112
+ category: y,
1113
+ additionalCategories: ee.map((he) => {
1114
+ const Ke = C == null ? void 0 : C[he];
1115
+ return Ke || {
1116
+ _id: he,
1117
+ position: null
1118
+ };
1119
+ })
1120
+ });
1121
+ }
1122
+ });
1123
+ }
1124
+ }, {
1125
+ id: "tagging",
1126
+ accessorKey: "tagging",
1127
+ header: () => l("menu.product.table.columns.tagging"),
1128
+ enableSorting: !1,
1129
+ size: 140,
1130
+ cell: (a) => {
1131
+ const o = a.row.original;
1132
+ return q(Pe, {
1133
+ customAttributes: o.customAttributes
1134
+ });
1135
+ }
1136
+ }, {
1137
+ accessorKey: "orderFrom",
1138
+ header: () => l("menu.product.table.columns.order_from"),
1139
+ enableSorting: !0,
1140
+ sortingFn: (a, o) => {
1141
+ const [m, f] = [a, o].map((C) => _e[C.original.orderFrom].sortingIndex);
1142
+ return m - f;
1143
+ },
1144
+ size: 140,
1145
+ cell: (a) => {
1146
+ const o = a.getValue(), m = a.row.original;
1147
+ return S.value ? q(Y.FmSelect, {
1148
+ disabled: !b.value.orderFrom,
1149
+ items: Object.values(xe()),
1150
+ modelValue: A(m._id, "orderFrom") ?? o,
1151
+ "onUpdate:modelValue": async (f) => {
1152
+ M(m._id, "orderFrom", f);
1153
+ }
1154
+ }) : q(Se, {
1155
+ orderFrom: o
1156
+ });
1157
+ }
1158
+ }, {
1159
+ id: "actions",
1160
+ size: 100,
1161
+ meta: {
1162
+ cellClass: "pl-16",
1163
+ headerClass: "py-4",
1164
+ textAlign: "right"
1165
+ },
1166
+ header: () => q("div", {
1167
+ class: "w-full px-4 flex justify-end"
1168
+ }, [Mt(q(Y.FmButton, {
1169
+ variant: J.Tertiary,
1170
+ textColor: Q.NeutralGray400,
1171
+ prependIcon: "edit",
1172
+ class: "flex justify-end",
1173
+ onClick: W,
1174
+ type: "button"
1175
+ }), "Bulk edit")]),
1176
+ cell: (a) => {
1177
+ const o = a.row.original;
1178
+ return c("div", {
1179
+ class: "px-4 flex justify-end"
1180
+ }, [c($l, null, {
1181
+ default: ({
1182
+ trigger: m
1183
+ }) => c(Y.FmButton, {
1184
+ icon: "overview",
1185
+ variant: "tertiary",
1186
+ textColor: Q.NeutralGray400,
1187
+ onClick: ce(() => {
1188
+ m(o._id);
1189
+ }, ["stop", "prevent"])
1190
+ }, null)
1191
+ }), c(Y.FmButton, {
1192
+ icon: "delete",
1193
+ variant: "tertiary",
1194
+ textColor: Q.NeutralGray400,
1195
+ onClick: ce(async () => {
1196
+ await g.deleteItem([{
1197
+ _id: o._id,
1198
+ name: o.name,
1199
+ thumbnail: o.thumbnail
1200
+ }]);
1201
+ }, ["stop", "prevent"])
1202
+ }, null)]);
1203
+ }
1204
+ }]);
1205
+ t.taxSetting.systemCode || ze.value.splice(4, 1);
1206
+ const ie = V({}), ne = V([]);
1207
+ re([() => ie.value, () => T.value], (a) => {
1208
+ let o = [];
1209
+ Object.keys(a[0]).forEach((m) => {
1210
+ const f = a[0][m], C = T.value[parseInt(m)];
1211
+ C && (f ? o.push(C) : ne.value = o.filter((F) => F !== C));
1212
+ }), ne.value = o;
1213
+ }), re(() => E.value, () => {
1214
+ ie.value = {}, ne.value = [];
1215
+ }), re(() => S.value, () => {
1216
+ ie.value = {}, ne.value = [];
1217
+ });
1218
+ const rt = () => {
1219
+ ie.value = {};
1220
+ };
1221
+ async function Oe() {
1222
+ await Te();
1223
+ const a = () => !!t.currentCatalog || !!t.state.currentSchedulerId, o = (f) => f === "" || f === null ? a() ? "" : null : f, m = Object.values(s.modelValue).filter((f) => {
1224
+ const C = Object.values(s.originalValue).find((F) => F._id === f._id);
1225
+ return je(C, f);
1226
+ }).map((f) => ({
1227
+ _id: f._id,
1228
+ name: f.name,
1229
+ code: f.code,
1230
+ price: f.price,
1231
+ orderFrom: f.orderFrom ?? null,
1232
+ taxes: f.taxes,
1233
+ category: o(f.category || null),
1234
+ additionalCategories: f.additionalCategories
1235
+ }));
1236
+ await g.updateMany(m), W(!1);
1237
+ }
1238
+ const st = async () => {
1239
+ await g.deleteItem(ne.value.map((a) => ({
1240
+ _id: a._id,
1241
+ name: a.name,
1242
+ thumbnail: a.thumbnail
1243
+ })));
1244
+ }, ye = () => {
1245
+ X("reset:model-value");
1246
+ }, Ve = () => {
1247
+ Object.entries(s.modelValue).some(([o, m]) => je(m, s.originalValue[o])) ? u.open({
1248
+ title: "You have unsaved changes!",
1249
+ message: "Are you sure you want to discard? You will lose all the changes if discard edit.",
1250
+ primaryActions: {
1251
+ text: "Discard",
1252
+ close: !0,
1253
+ variant: J.Destructive
1254
+ },
1255
+ secondaryActions: {
1256
+ text: "Cancel",
1257
+ close: !0
1258
+ }
1259
+ }).onPrimary(() => {
1260
+ ye(), W(!1);
1261
+ }) : (W(!1), ye());
1262
+ }, ut = x(() => {
1263
+ var a, o;
1264
+ return {
1265
+ thumbnail: !S.value,
1266
+ actions: !S.value,
1267
+ tagging: !S.value && ((o = (a = d.itemAttributeSettings) == null ? void 0 : a.value) == null ? void 0 : o.length) > 0
1268
+ };
1269
+ }), it = (a) => {
1270
+ g.update(a._id);
1271
+ };
1272
+ async function ct(a) {
1273
+ await g.update(a.original._id);
1274
+ }
1275
+ function Re(a) {
1276
+ var y;
1277
+ const o = a.price ?? // TODO: fix type error
1278
+ // @ts-ignore
1279
+ a.fallbackPrice ?? se.Dinero.fromNumber({
1280
+ number: 0
1281
+ }).toObject(), m = a.taxes, f = t.taxSetting.countryTaxOptions, C = se.Dinero.fromFdoDinero(o).toFormat(), F = (y = p.value) == null ? void 0 : y.currency.symbol;
1282
+ return t.getSelectedTax(
1283
+ m,
1284
+ // TODO: fix type error
1285
+ // @ts-ignore
1286
+ a.fallbackTaxes,
1287
+ f
1288
+ ), `${F == null ? void 0 : F.toUpperCase()}${C}`;
1289
+ }
1290
+ function Ie(a) {
1291
+ var f;
1292
+ const o = t.currentCatalog, m = t.state.currentSchedulerId;
1293
+ if (o && m) {
1294
+ const C = o.override.scheduler[m] ?? {}, F = (f = C == null ? void 0 : C.items) == null ? void 0 : f.filter((y) => y._id === a);
1295
+ return F == null ? void 0 : F[0];
1296
+ } else return o ? o.override.items[a][0] : m ? t.schedulers.find((y) => y._id === m).items.filter((y) => y._id === a)[0] : E.value.find((C) => C._id === a);
1297
+ }
1298
+ const dt = tt(), mt = x(() => dt.breakpoints.value.xs), Me = V(null), pt = Ut(Me, H), vt = x(() => {
1299
+ var o;
1300
+ return {
1301
+ height: `calc(100vh - ${((o = pt.value) == null ? void 0 : o.top) + 24}px)`
1302
+ };
1303
+ });
1304
+ return (a, o) => {
1305
+ const m = U("fm-search"), f = U("fm-button"), C = U("fm-table"), F = U("fm-form");
1306
+ return mt.value ? (v(), w("div", jl, [_("div", Bl, [_("div", El, [c(m, {
1307
+ "model-value": D.value,
1308
+ "onUpdate:modelValue": o[5] || (o[5] = (y) => D.value = y),
1309
+ autofocus: "",
1310
+ placeholder: n(l)("menu.product.table.search.placeholder")
1311
+ }, null, 8, ["model-value", "placeholder"])]), o[8] || (o[8] = _("div", {
1312
+ class: "w-full h-[1px] bg-fm-color-neutral-gray-100"
1313
+ }, null, -1)), _("div", Gl, [ve(a.$slots, "filter")]), H.value ? (v(), w("div", Ll, [c(n(Ee), {
1314
+ ref_key: "attributeFilterRef",
1315
+ ref: te,
1316
+ attributes: n(P),
1317
+ modelValue: n(K),
1318
+ "onUpdate:modelValue": o[6] || (o[6] = (y) => Ne(K) ? K.value = y : null)
1319
+ }, null, 8, ["attributes", "modelValue"])])) : R("", !0)]), E.value.length ? (v(), w("div", ql, [(v(!0), w(le, null, we(T.value, (y) => {
1320
+ var ee;
1321
+ return v(), w("div", {
1322
+ key: y._id,
1323
+ class: "max-w-full py-12 px-16 space-x-16 flex items-center",
1324
+ onClick: () => it(y)
1325
+ }, [_("div", Hl, [c(De, {
1326
+ alt: y.name,
1327
+ size: 72,
1328
+ src: y.thumbnail
1329
+ }, null, 8, ["alt", "src"]), _("div", Ql, [_("div", Yl, [_("p", Zl, j(y.name), 1), c(Se, {
1330
+ "order-from": y.orderFrom
1331
+ }, null, 8, ["order-from"])]), _("p", Jl, j(Re(y)), 1), _("p", Xl, j(n(l)("menu.product.table.columns.code")) + ": " + j(((ee = Ie(y._id)) == null ? void 0 : ee.code) || "--"), 1), _("p", ea, [c(qe, {
1332
+ categories: n($e)(n(L), y)
1333
+ }, null, 8, ["categories"])]), c(Pe, {
1334
+ "custom-attributes": y.customAttributes
1335
+ }, null, 8, ["custom-attributes"])])]), c(f, {
1336
+ "text-color": n(Q).NeutralGray400,
1337
+ variant: n(J).Tertiary,
1338
+ "prepend-icon": "delete",
1339
+ onClick: ce(() => n(g).deleteItem([{
1340
+ _id: y._id,
1341
+ name: y.name,
1342
+ thumbnail: y.thumbnail
1343
+ }]), ["stop"])
1344
+ }, null, 8, ["text-color", "variant", "onClick"])], 8, Wl);
1345
+ }), 128))])) : (v(), w("div", ta, [c(pe, {
1346
+ subtitle: n(l)("menu.product.table.empty.subtitle"),
1347
+ title: n(l)("menu.product.table.empty.title")
1348
+ }, {
1349
+ action: I(() => [_("div", la, [c(f, {
1350
+ variant: n(J).Primary,
1351
+ label: n(l)("menu.product.table.empty.actions.add"),
1352
+ "prepend-icon": "add",
1353
+ onClick: o[7] || (o[7] = (y) => n(g).create(null))
1354
+ }, null, 8, ["variant", "label"]), c(We, null, {
1355
+ default: I(({
1356
+ trigger: y
1357
+ }) => [c(f, {
1358
+ "bg-color": n(Q).NeutralGray100,
1359
+ "text-color": n(Q).NeutralGray400,
1360
+ variant: n(J).Primary,
1361
+ label: n(l)("menu.product.table.empty.actions.import"),
1362
+ "prepend-icon": "download",
1363
+ onClick: y
1364
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
1365
+ _: 1
1366
+ })])]),
1367
+ _: 1
1368
+ }, 8, ["subtitle", "title"])]))])) : (v(), $(F, {
1369
+ key: 0,
1370
+ "blame-form-child-on-validation-failed": "",
1371
+ class: "flex flex-col flex-1 space-y-8 overflow-hidden",
1372
+ onValidationSuccess: Oe
1373
+ }, {
1374
+ default: I(() => [_("div", Al, [_("div", Pl, [ve(a.$slots, "filter")]), _("div", Dl, [c(m, {
1375
+ "model-value": D.value,
1376
+ "onUpdate:modelValue": o[0] || (o[0] = (y) => D.value = y),
1377
+ autofocus: "",
1378
+ placeholder: n(l)("menu.product.table.search.placeholder")
1379
+ }, null, 8, ["model-value", "placeholder"])])]), H.value ? (v(), w("div", Ul, [c(n(Ee), {
1380
+ ref_key: "attributeFilterRef",
1381
+ ref: te,
1382
+ attributes: n(P),
1383
+ modelValue: n(K),
1384
+ "onUpdate:modelValue": o[1] || (o[1] = (y) => Ne(K) ? K.value = y : null)
1385
+ }, null, 8, ["attributes", "modelValue"])])) : R("", !0), E.value.length ? (v(), w("div", zl, [ne.value.length && !S.value ? (v(), w("div", Ol, [_("p", Rl, j(n(l)("menu.product.table.selection.count", {
1386
+ count: ne.value.length
1387
+ })), 1), c(f, {
1388
+ label: n(l)("menu.product.table.selection.actions.deselect_all"),
1389
+ type: "button",
1390
+ variant: "plain",
1391
+ onClick: rt
1392
+ }, null, 8, ["label"]), c(f, {
1393
+ "border-color": n(Q).SystemError300,
1394
+ "text-color": n(Q).SystemError300,
1395
+ class: "ml-auto",
1396
+ label: n(l)("menu.product.table.selection.actions.remove"),
1397
+ "prepend-icon": "delete",
1398
+ variant: "secondary",
1399
+ onClick: st
1400
+ }, null, 8, ["border-color", "text-color", "label"])])) : R("", !0), S.value ? (v(), w("div", Ml, [c(f, {
1401
+ variant: n(J).Tertiary,
1402
+ label: n(l)("menu.product.table.bulk_edit.actions.reset_all"),
1403
+ onClick: ye
1404
+ }, null, 8, ["variant", "label"]), c(f, {
1405
+ variant: n(J).Tertiary,
1406
+ label: n(l)("menu.common.actions.cancel"),
1407
+ onClick: Ve
1408
+ }, null, 8, ["variant", "label"]), c(f, {
1409
+ borderColor: n(Q).ColorPrimary,
1410
+ textColor: n(Q).ColorPrimary,
1411
+ variant: n(J).Secondary,
1412
+ label: n(l)("menu.product.table.bulk_edit.actions.save"),
1413
+ type: "submit"
1414
+ }, null, 8, ["borderColor", "textColor", "variant", "label"])])) : R("", !0), _("div", {
1415
+ ref_key: "tableWrapper",
1416
+ ref: Me
1417
+ }, [(v(), $(Xe(S.value ? Dt : "div"), {
1418
+ ref: "fullWrapper",
1419
+ title: S.value ? n(l)("menu.product.table.bulk_edit.title") : "",
1420
+ show: S.value,
1421
+ "primary-action": {
1422
+ label: n(l)("menu.product.table.bulk_edit.actions.save")
1423
+ },
1424
+ "secondary-actions": [{
1425
+ label: n(l)("menu.product.table.bulk_edit.actions.reset_all"),
1426
+ click: ye
1427
+ }, {
1428
+ label: n(l)("menu.common.actions.cancel"),
1429
+ click: Ve
1430
+ }],
1431
+ class: "overflow-x-scroll",
1432
+ style: ft(vt.value),
1433
+ onOnPrimary: Oe,
1434
+ onOnCancel: Ve
1435
+ }, {
1436
+ default: I(() => [c(C, {
1437
+ class: ae({
1438
+ "min-w-[1100px]": !0,
1439
+ "mt-24": S.value
1440
+ }),
1441
+ modelValue: ie.value,
1442
+ "onUpdate:modelValue": o[2] || (o[2] = (y) => ie.value = y),
1443
+ "column-defs": ze.value,
1444
+ "column-visibility": ut.value,
1445
+ loading: a.isCalculating,
1446
+ "page-size": T.value.length,
1447
+ "row-data": T.value,
1448
+ "shrink-at": !1,
1449
+ selection: S.value ? void 0 : "multiple",
1450
+ virtual: !0,
1451
+ "virtual-row-height": S.value ? 48 : 91,
1452
+ "hide-footer": "",
1453
+ "pin-header-row": "",
1454
+ onRowClick: o[3] || (o[3] = (y) => S.value ? void 0 : ct(y))
1455
+ }, null, 8, ["class", "modelValue", "column-defs", "column-visibility", "loading", "page-size", "row-data", "selection", "virtual-row-height"])]),
1456
+ _: 1
1457
+ }, 40, ["title", "show", "primary-action", "secondary-actions", "style"]))], 512)])) : (v(), w("div", Kl, [c(pe, {
1458
+ subtitle: n(l)("menu.product.table.empty.subtitle"),
1459
+ title: n(l)("menu.product.table.empty.title")
1460
+ }, {
1461
+ action: I(() => [_("div", Nl, [c(f, {
1462
+ variant: n(J).Primary,
1463
+ label: n(l)("menu.product.table.empty.actions.add"),
1464
+ "prepend-icon": "add",
1465
+ onClick: o[4] || (o[4] = (y) => n(g).create(null))
1466
+ }, null, 8, ["variant", "label"]), c(We, null, {
1467
+ default: I(({
1468
+ trigger: y
1469
+ }) => [c(f, {
1470
+ "bg-color": n(Q).NeutralGray100,
1471
+ "text-color": n(Q).NeutralGray400,
1472
+ variant: n(J).Primary,
1473
+ label: n(l)("menu.product.table.empty.actions.import"),
1474
+ "prepend-icon": "download",
1475
+ onClick: y
1476
+ }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
1477
+ _: 1
1478
+ })])]),
1479
+ _: 1
1480
+ }, 8, ["subtitle", "title"])]))]),
1481
+ _: 3
1482
+ }));
1483
+ };
1484
+ }
1485
+ }), oa = {
1486
+ key: 0,
1487
+ class: /* @__PURE__ */ ae(["flex flex-col", "flex-1", "overflow-hidden"])
1488
+ }, na = {
1489
+ class: /* @__PURE__ */ ae(["pt-16 xs:pt-0", "flex xs:flex-col", "flex-1", "w-full", "overflow-hidden"])
1490
+ }, ra = { class: "flex flex-col flex-1 overflow-hidden" }, sa = {
1491
+ key: 1,
1492
+ class: "pt-16 xs:pt-8 space-y-24"
1493
+ }, ua = { class: "flex items-center gap-8 px-16" }, Aa = /* @__PURE__ */ B({
1494
+ __name: "Product",
1495
+ setup(k) {
1496
+ const e = ue(), r = x(() => e.rules.item), s = St(), l = at(), d = x(() => !e.state.currentCatalogId), t = x(() => e.rules.item), u = x(() => !e.state.currentSchedulerId), g = V(!1), i = V(!1), p = x(() => {
1497
+ var D, z, T, L;
1498
+ if (d.value && u.value) return;
1499
+ if (u.value) {
1500
+ const N = (D = e.currentCatalog) == null ? void 0 : D.override.items;
1501
+ return N ? Object.entries(N).reduce((M, [A, Z]) => {
1502
+ const G = Z.find((oe) => !oe.combinationKey);
1503
+ return G && (M[A] = G), M;
1504
+ }, {}) : {};
1505
+ }
1506
+ return ((d.value ? (z = e.currentScheduler) == null ? void 0 : z.items : (L = (T = e.currentCatalog) == null ? void 0 : T.override.scheduler[e.state.currentSchedulerId]) == null ? void 0 : L.items) ?? []).reduce((N, M) => (M.combinationKey || (N[M._id] = M), N), {});
1507
+ }), b = V({}), h = V({}), E = async () => {
1508
+ var L, N;
1509
+ i.value = !0;
1510
+ const O = !!p.value, D = me.flatten(S.value.map((M) => M.items)), z = O && g.value ? await Tt(
1511
+ e.mergedMenu,
1512
+ D,
1513
+ e.state.menu,
1514
+ (L = e.currentCatalog) == null ? void 0 : L._id,
1515
+ (N = e.currentScheduler) == null ? void 0 : N._id,
1516
+ !1
1517
+ ) : void 0, T = D.reduce((M, A, Z) => {
1518
+ var oe, ge, be, _e;
1519
+ const G = (oe = p.value) == null ? void 0 : oe[A._id];
1520
+ return M[A._id] = {
1521
+ _id: A._id,
1522
+ name: A.name,
1523
+ code: O ? G == null ? void 0 : G.code : A == null ? void 0 : A.code,
1524
+ category: A.category,
1525
+ additionalCategories: A.additionalCategories,
1526
+ price: O && t.value.editPrice ? G == null ? void 0 : G.price : A.price,
1527
+ orderFrom: O ? G == null ? void 0 : G.orderFrom : A.orderFrom,
1528
+ taxes: O ? null : A.taxes,
1529
+ thumbnail: A.thumbnail,
1530
+ fallbackPrice: (ge = z == null ? void 0 : z[Z]) == null ? void 0 : ge.price,
1531
+ fallbackName: O ? A.name : void 0,
1532
+ fallbackCode: (be = z == null ? void 0 : z[Z]) == null ? void 0 : be.code,
1533
+ fallbackOrder: (_e = z == null ? void 0 : z[Z]) == null ? void 0 : _e.orderFrom,
1534
+ fallbackTaxes: O ? A.taxes : null
1535
+ }, M;
1536
+ }, {});
1537
+ b.value = T, h.value = { ...T }, i.value = !1;
1538
+ }, { categories: X, selectedCategories: S } = ke(), W = V(null);
1539
+ function H() {
1540
+ W.value && W.value.toggleAttributeFilter();
1541
+ }
1542
+ Je(async () => {
1543
+ S.value && await E();
1544
+ });
1545
+ function te() {
1546
+ l.create(null);
1547
+ }
1548
+ const de = () => {
1549
+ S.value && E();
1550
+ }, { t: P } = fe(), K = x(() => {
1551
+ var O, D;
1552
+ return (D = (O = e.currentCatalog) == null ? void 0 : O.linkItemRules) == null ? void 0 : D.length;
1553
+ });
1554
+ return (O, D) => {
1555
+ const z = U("fm-button");
1556
+ return n(X).length ? (v(), w("div", oa, [
1557
+ _("div", na, [
1558
+ _("div", ra, [
1559
+ n(S) ? (v(), $(aa, {
1560
+ key: 0,
1561
+ ref_key: "productTableRef",
1562
+ ref: W,
1563
+ "is-calculating": i.value,
1564
+ "model-value": b.value,
1565
+ "original-value": h.value,
1566
+ "onUpdate:modelValue": D[0] || (D[0] = (T) => b.value = T),
1567
+ "onReset:modelValue": de,
1568
+ "onUpdate:editing": D[1] || (D[1] = (T) => g.value = T)
1569
+ }, {
1570
+ filter: I(() => [
1571
+ c(Le, { onToggleAttributeFilter: H }),
1572
+ t.value.multiScheduler ? (v(), $(Be, { key: 0 })) : R("", !0),
1573
+ K.value ? (v(), $(Ge, { key: 1 })) : R("", !0)
1574
+ ]),
1575
+ _: 1
1576
+ }, 8, ["is-calculating", "model-value", "original-value"])) : R("", !0)
1577
+ ])
1578
+ ])
1579
+ ])) : (v(), w("div", sa, [
1580
+ _("div", ua, [
1581
+ c(Le),
1582
+ t.value.multiScheduler ? (v(), $(Be, { key: 0 })) : R("", !0),
1583
+ K.value ? (v(), $(Ge, { key: 1 })) : R("", !0)
1584
+ ]),
1585
+ r.value.create ? (v(), $(pe, {
1586
+ key: 0,
1587
+ action: {
1588
+ text: n(P)("menu.product.empty.with_create.action"),
1589
+ callback: te
1590
+ },
1591
+ subtitle: n(P)("menu.product.empty.with_create.subtitle"),
1592
+ title: n(P)("menu.product.empty.with_create.title")
1593
+ }, null, 8, ["action", "subtitle", "title"])) : u.value ? (v(), $(pe, {
1594
+ key: 1,
1595
+ subtitle: n(P)("menu.product.empty.no_scheduler.subtitle"),
1596
+ title: n(P)("menu.product.empty.no_scheduler.title")
1597
+ }, {
1598
+ action: I(() => [
1599
+ c(Ft, null, {
1600
+ default: I(({ trigger: T }) => [
1601
+ c(z, {
1602
+ label: n(P)("menu.common.actions.link_product"),
1603
+ "prepend-icon": "link",
1604
+ onClick: T
1605
+ }, null, 8, ["label", "onClick"])
1606
+ ]),
1607
+ _: 1
1608
+ })
1609
+ ]),
1610
+ _: 1
1611
+ }, 8, ["subtitle", "title"])) : (v(), $(pe, {
1612
+ key: 2,
1613
+ subtitle: n(P)("menu.product.empty.with_scheduler.subtitle"),
1614
+ title: n(P)("menu.product.empty.with_scheduler.title")
1615
+ }, {
1616
+ action: I(() => [
1617
+ c(Ct, {
1618
+ "categorized-items": n(s).linkableItems.value,
1619
+ "initial-value": n(s).currentItems.value,
1620
+ "show-variant": !1,
1621
+ onSubmit: D[2] || (D[2] = (T) => n(s).applyProduct(T.map((L) => L._id)))
1622
+ }, {
1623
+ default: I(({ trigger: T }) => [
1624
+ c(z, {
1625
+ label: n(P)("menu.common.actions.apply_product"),
1626
+ onClick: T
1627
+ }, null, 8, ["label", "onClick"])
1628
+ ]),
1629
+ _: 1
1630
+ }, 8, ["categorized-items", "initial-value"])
1631
+ ]),
1632
+ _: 1
1633
+ }, 8, ["subtitle", "title"]))
1634
+ ]));
1635
+ };
1636
+ }
1637
+ });
1638
+ export {
1639
+ We as _,
1640
+ Aa as a
1641
+ };