@feedmepos/mf-inventory-portal 0.0.23-dev.18 → 0.0.23-dev.2

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 (95) hide show
  1. package/dist/{App-Dfryh3pQ.js → App-DRE3c1lJ.js} +31 -36
  2. package/dist/{ApprovalView-CRrJeRCQ.js → ApprovalView-B4ZYcS3B.js} +4 -4
  3. package/dist/{BindingsDialog-Zh8FzTSI.js → BindingsDialog-Df1yrWHU.js} +2 -2
  4. package/dist/{BindingsPicker-BXChBNxv.js → BindingsPicker-BERMWh4w.js} +2 -2
  5. package/dist/{BindingsTable-BXB-X1N3.js → BindingsTable-DRIapOWW.js} +6 -6
  6. package/dist/{ClosingTemplateView-Bj6SiRlA.js → ClosingTemplateView-CbFn3Sdy.js} +31 -32
  7. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-7JYNssTm.js +267 -0
  8. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-B8RhFmN_.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-KbYSywk2.js} +2 -2
  9. package/dist/{FmMultiselectDialog-DWMt9hvV.js → FmMultiselectDialog-Da9JMCYa.js} +15 -15
  10. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-BHSGZyJL.js +326 -0
  11. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Be_B1iME.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DH5IQchQ.js} +1 -1
  12. package/dist/{IngredientGroupView-DCOz2AOB.js → IngredientGroupView-DoETcEvV.js} +11 -12
  13. package/dist/IngredientsView-DHAhj9pV.js +1613 -0
  14. package/dist/{IntegrationView-BfoCYVHZ.js → IntegrationView-D1HeBiGF.js} +50 -50
  15. package/dist/{InventoryBindingForm-2Gs2vUtC.js → InventoryBindingForm-Dmz9BQ37.js} +1 -1
  16. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-D9Of6ewh.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DoyqVBOd.js} +13 -13
  17. package/dist/{InventoryBindingSummary-IUJt469w.js → InventoryBindingSummary-DrpwiRGZ.js} +1 -1
  18. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BtdmfQRZ.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-yNEswIEI.js} +1 -1
  19. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-C97vZfAO.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Br4_VUza.js} +2 -2
  20. package/dist/{PurchaseOrderPrintPreview-BRVCfgd3.js → PurchaseOrderPrintPreview-cp671yWE.js} +1 -1
  21. package/dist/ReceiveRequestView-C1WBlpho.js +4082 -0
  22. package/dist/{RecipeView-Br8u4xZZ.js → RecipeView-CD_dAWLo.js} +10 -11
  23. package/dist/{StockView-B2vBQLJf.js → StockView-DfUzFC1b.js} +1457 -1356
  24. package/dist/{SupplierView-S_qigSL4.js → SupplierView-DB-zrNxh.js} +783 -2352
  25. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-2mzqFGCz.js +1144 -0
  26. package/dist/TransferTemplateView-CaAJrqU6.js +1262 -0
  27. package/dist/{UnitView-CR019bWO.js → UnitView-BlC9-WOA.js} +80 -81
  28. package/dist/{WarehouseView-BX7K073o.js → WarehouseView-CgEY87Lo.js} +24 -25
  29. package/dist/api/bill.d.ts +2 -2
  30. package/dist/api/closing.d.ts +0 -1
  31. package/dist/api/netsuite.d.ts +0 -69
  32. package/dist/{app-BY6TZxqB.js → app-CAyFhmAz.js} +3343 -3426
  33. package/dist/app.d.ts +0 -5
  34. package/dist/app.js +1 -1
  35. package/dist/components/FmMinMaxInputRules.d.ts +1 -4
  36. package/dist/components/row-action.enum.d.ts +0 -1
  37. package/dist/{date2-C385gf6_.js → date2-D9i5izMt.js} +1 -1
  38. package/dist/{dayjs.min-CuXsxyJ4.js → dayjs.min-SJKP9zBL.js} +17 -17
  39. package/dist/{decimal-DmIrlkyN.js → decimal-D7BCubZO.js} +1 -1
  40. package/dist/{defineDeepModel-CJEdL37p.js → defineDeepModel-DS4Shctf.js} +1 -1
  41. package/dist/{feature-DM4scjOG.js → feature-BR-MsGYt.js} +9 -23
  42. package/dist/{format-time-from-id-DmDFxNOY.js → format-time-from-id-CUby60uW.js} +1 -1
  43. package/dist/format-unit-display-D25Al2JZ.js +1198 -0
  44. package/dist/{fuzzy-D2QbaWQl.js → fuzzy-BryBtMz_.js} +1 -1
  45. package/dist/{index-UtLEzrzf.js → index-ByJbUSIQ.js} +1 -1
  46. package/dist/index-CFA_VFyX.js +10545 -0
  47. package/dist/{index-BgM27D6z.js → index-CTvgBOum.js} +25 -28
  48. package/dist/netsuite-D0G4B60k.js +146 -0
  49. package/dist/normalizeArguments-DP7Hrren.js +1552 -0
  50. package/dist/router/name.d.ts +0 -1
  51. package/dist/{row-action.enum-7rGLGZ5v.js → row-action.enum-PMKMRrZR.js} +5 -10
  52. package/dist/{rules-WXcRCM31.js → rules-DxVY0b7F.js} +35 -40
  53. package/dist/stores/feature.d.ts +0 -2
  54. package/dist/stores/integration/netsuite.d.ts +0 -81
  55. package/dist/stores/inventory.d.ts +4 -1
  56. package/dist/style.css +1 -1
  57. package/dist/{supplier-Cg0hV-1Z.js → supplier-aBuwVukl.js} +22 -22
  58. package/dist/tsconfig.app.tsbuildinfo +1 -1
  59. package/dist/{use-inventory-binding-dialog-C4A0C-q4.js → use-inventory-binding-dialog-CLQ0LUmW.js} +2 -2
  60. package/dist/{use-template-enabled-locations-2-ClTvBbS6.js → use-template-enabled-locations-2-BgTiwy_3.js} +2 -2
  61. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +192 -24
  62. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +192 -24
  63. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +34 -34
  64. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +0 -1
  65. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +54 -54
  66. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +54 -54
  67. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
  68. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +8 -8
  69. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +96 -96
  70. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +96 -96
  71. package/dist/{xlsx-jlUdZfql.js → xlsx-BbtURTDy.js} +1 -1
  72. package/dist/{xlsx.util-C4YF_j8p.js → xlsx.util-zYS4OJFi.js} +1 -1
  73. package/package.json +3 -3
  74. package/dist/ClosingDraftView-ZKdMqDrV.js +0 -1122
  75. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CZ1NPD07.js +0 -283
  76. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-C--mzLIB.js +0 -329
  77. package/dist/IngredientsView-D3ptwZy1.js +0 -1666
  78. package/dist/ReceiveRequestView-Brh9jtUz.js +0 -4195
  79. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang--DGNx2VJ.js +0 -1235
  80. package/dist/TransferTemplateView-B0_EXehN.js +0 -1275
  81. package/dist/api/closing-draft.d.ts +0 -6
  82. package/dist/form-mode.enum-BKiNVH6A.js +0 -4
  83. package/dist/format-unit-display-DnZmCO-i.js +0 -1217
  84. package/dist/index-CKCFZ2N2.js +0 -12087
  85. package/dist/netsuite-CxzWHfIf.js +0 -251
  86. package/dist/stock-BVyJ8TZF.js +0 -111
  87. package/dist/views/closing-draft/ClosingDraftView.vue.d.ts +0 -2
  88. package/dist/views/closing-draft/components/closing-draft-action/ClosingDraftAction.vue.d.ts +0 -22
  89. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +0 -451
  90. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +0 -25
  91. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +0 -2601
  92. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +0 -1
  93. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +0 -19
  94. package/dist/views/closing-draft/helpers/get-calculated-total.helper.d.ts +0 -4
  95. package/dist/views/receive-request/helper/check-netsuite-subsidiary.helper.d.ts +0 -1
@@ -0,0 +1,1613 @@
1
+ import { ref as N, defineComponent as ae, computed as C, resolveComponent as U, openBlock as g, createBlock as D, withCtx as S, createVNode as p, unref as u, createElementBlock as T, Fragment as q, createElementVNode as d, createCommentVNode as O, onMounted as nt, watch as ze, normalizeClass as Z, createTextVNode as He, toDisplayString as B, renderList as ee, isRef as Ee, createSlots as Oe, normalizeStyle as ot, Teleport as Re, normalizeProps as lt, guardReactiveProps as rt } from "vue";
2
+ import { a as te, c as je, S as at, d as be, e as de, f as Ae, C as xe, h as De, i as st, u as it } from "./app-CAyFhmAz.js";
3
+ import { useDialog as Ye, useSnackbar as he, useProxiedModel as Te, useDialogChild as ut, useBreakpoints as dt } from "@feedmepos/ui-library";
4
+ import { i as mt, _ as ct } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
+ import { F as j, D as Pe, R as ye } from "./row-action.enum-PMKMRrZR.js";
6
+ import { useI18n as ne, useCoreStore as me } from "@feedmepos/mf-common";
7
+ import { defineStore as pt, storeToRefs as vt } from "pinia";
8
+ import { c as ft, _ as yt, F as Be } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
9
+ import { u as gt, _ as bt, a as ht } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-KbYSywk2.js";
10
+ import { A as ge, a as Ge, t as qe, R as Ve, U as _t, M as xt, I as Vt } from "./rules-DxVY0b7F.js";
11
+ import { g as kt, _ as ke, S as Ce } from "./StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js";
12
+ import { _ as Ct } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-DoyqVBOd.js";
13
+ import { _ as we } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-DH5IQchQ.js";
14
+ import { u as We } from "./feature-BR-MsGYt.js";
15
+ import { _ as Se } from "./PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js";
16
+ import { t as Ke, d as Je, s as wt, r as St } from "./xlsx.util-zYS4OJFi.js";
17
+ import { f as Ft } from "./date2-D9i5izMt.js";
18
+ import { F as Mt } from "./FmDroppableField-8RzKjEdL.js";
19
+ import "./array-hChJVZLE.js";
20
+ const Fe = pt("ingredientForm", function() {
21
+ const a = Ye(), f = he(), s = te(), n = N(!1), { t: l } = ne(), o = N();
22
+ function c() {
23
+ const b = {
24
+ unit: {},
25
+ mode: j.CREATE,
26
+ show: !0,
27
+ "onUpdate:show"(i) {
28
+ o.value.show = i;
29
+ }
30
+ };
31
+ o.value = b;
32
+ }
33
+ async function y(b) {
34
+ const i = {
35
+ unit: je(b),
36
+ mode: j.UPDATE,
37
+ show: !0,
38
+ "onUpdate:show"(_) {
39
+ o.value.show = _;
40
+ }
41
+ };
42
+ o.value = i;
43
+ }
44
+ async function h(b) {
45
+ n.value = !0;
46
+ try {
47
+ await s.deleteSku(b), f.open({
48
+ title: "Success",
49
+ message: `Deleted ${b.name}`,
50
+ type: "success"
51
+ });
52
+ } catch (i) {
53
+ i instanceof at && mt(i) ? a.open({
54
+ title: "Cannot delete ingredient",
55
+ contentComponent: ct,
56
+ contentComponentProps: {
57
+ subject: (b == null ? void 0 : b.name) ?? "",
58
+ items: i.errorResponse.message
59
+ },
60
+ secondaryActions: {
61
+ text: "Close",
62
+ close: !0
63
+ }
64
+ }) : console.log("unable to delete ingredient", i), f.open({
65
+ title: `Cannot delete ${b.name}`,
66
+ message: "Please try again.",
67
+ type: "error"
68
+ }), console.error("failed to delete ingredient", i);
69
+ } finally {
70
+ n.value = !1;
71
+ }
72
+ }
73
+ function v(b) {
74
+ a.open({
75
+ title: l("inventory.ingredient.delete.title", [(b == null ? void 0 : b.name) ?? ""]),
76
+ closeButton: !1,
77
+ message: l("inventory.ingredient.delete.message"),
78
+ primaryActions: {
79
+ text: l("common.delete"),
80
+ close: !0,
81
+ variant: "destructive"
82
+ },
83
+ secondaryActions: {
84
+ text: l("common.cancel"),
85
+ close: !0
86
+ }
87
+ }).onPrimary(() => h(b));
88
+ }
89
+ return {
90
+ createIngredient: c,
91
+ updateIngredient: y,
92
+ deleteIngredient: v,
93
+ ingredientDialogProps: o,
94
+ ingredientViewLoading: n
95
+ };
96
+ });
97
+ function It() {
98
+ const { updateIngredient: r, deleteIngredient: a } = Fe(), { t: f } = ne();
99
+ async function s(l, o) {
100
+ const c = je(o);
101
+ if (l === ye.Edit) {
102
+ await r(c);
103
+ return;
104
+ }
105
+ if (l === ye.Delete) {
106
+ await a(c);
107
+ return;
108
+ }
109
+ }
110
+ return { columnDefs: [
111
+ {
112
+ accessorKey: "code",
113
+ header: () => f("inventory.ingredient.code"),
114
+ enableSorting: !0,
115
+ size: 300
116
+ },
117
+ {
118
+ accessorKey: "name",
119
+ header: () => f("inventory.ingredient.name"),
120
+ enableSorting: !0,
121
+ size: 300
122
+ },
123
+ {
124
+ id: "unit",
125
+ header: () => f("inventory.ingredient.unit"),
126
+ cell(l) {
127
+ var c;
128
+ const o = l.row.original;
129
+ if (o.trackingMeasurement) {
130
+ const y = (c = o.unit.measurements) == null ? void 0 : c.find(
131
+ (h) => h.id === o.trackingMeasurement
132
+ );
133
+ if (y)
134
+ return `${y.name} (${y.abbrev})`;
135
+ }
136
+ return `${o.unit.name} (${o.unit.abbrev})`;
137
+ },
138
+ enableSorting: !1,
139
+ size: "auto"
140
+ },
141
+ {
142
+ id: "action",
143
+ header: "",
144
+ cell(l) {
145
+ return ft(
146
+ [Pe[ye.Edit], Pe[ye.Delete]],
147
+ (o) => {
148
+ s(o, l.row.original);
149
+ }
150
+ );
151
+ },
152
+ enableSorting: !1,
153
+ size: 40,
154
+ meta: {
155
+ cellClass: "",
156
+ headerClass: ""
157
+ }
158
+ }
159
+ ] };
160
+ }
161
+ const Ut = /* @__PURE__ */ ae({
162
+ __name: "ConvertForm",
163
+ props: {
164
+ modelValue: {},
165
+ rootValue: {},
166
+ disabled: { type: Boolean }
167
+ },
168
+ emits: ["update:modelValue"],
169
+ setup(r, { emit: a }) {
170
+ const f = r, s = C(() => {
171
+ var i;
172
+ return (i = f.rootValue) == null ? void 0 : i.unit;
173
+ }), n = C(() => {
174
+ var i;
175
+ return (i = f.rootValue) == null ? void 0 : i._id;
176
+ }), l = a, { t: o } = ne(), c = C({
177
+ get() {
178
+ return !!f.modelValue;
179
+ },
180
+ set(i) {
181
+ i ? l("update:modelValue", {
182
+ measurement: null,
183
+ inventoryBindings: []
184
+ }) : l("update:modelValue", null);
185
+ }
186
+ }), y = C(() => kt(s.value));
187
+ function h(i) {
188
+ const _ = f.modelValue ?? {};
189
+ _.measurement = i ? `${i}` : null, l("update:modelValue", _);
190
+ }
191
+ function v(i) {
192
+ const _ = f.modelValue ?? {};
193
+ _.inventoryBindings = i, l("update:modelValue", _);
194
+ }
195
+ const b = C(() => {
196
+ if (!f.modelValue) return null;
197
+ const i = f.modelValue;
198
+ return i.measurement ? y.value.find((_) => _.value === i.measurement) ?? null : y.value.find((_) => _.value === null) ?? null;
199
+ });
200
+ return (i, _) => {
201
+ const R = U("FmSwitch"), V = U("FmSelect"), F = U("FmCard");
202
+ return g(), D(F, {
203
+ variant: "outlined",
204
+ class: "p-16 flex flex-col gap-16"
205
+ }, {
206
+ default: S(() => {
207
+ var w, I;
208
+ return [
209
+ p(R, {
210
+ value: "",
211
+ "model-value": c.value,
212
+ "onUpdate:modelValue": _[0] || (_[0] = (z) => c.value = z),
213
+ label: u(o)("inventory.ingredient.convertible.title"),
214
+ sublabel: u(o)("inventory.ingredient.convertible.subtitle"),
215
+ labelPlacement: "right"
216
+ }, null, 8, ["model-value", "label", "sublabel"]),
217
+ c.value ? (g(), T(q, { key: 0 }, [
218
+ d("div", null, [
219
+ p(V, {
220
+ label: u(o)("inventory.ingredient.convertible.convertTo"),
221
+ modelValue: (w = b.value) == null ? void 0 : w.value,
222
+ "onUpdate:modelValue": h,
223
+ items: y.value
224
+ }, null, 8, ["label", "modelValue", "items"])
225
+ ]),
226
+ p(Ct, {
227
+ id: n.value,
228
+ "model-value": ((I = i.modelValue) == null ? void 0 : I.inventoryBindings) ?? [],
229
+ "onUpdate:modelValue": v,
230
+ "exclude-binding-id": n.value,
231
+ rules: [u(ge)(1)]
232
+ }, null, 8, ["id", "model-value", "exclude-binding-id", "rules"])
233
+ ], 64)) : O("", !0)
234
+ ];
235
+ }),
236
+ _: 1
237
+ });
238
+ };
239
+ }
240
+ });
241
+ function re() {
242
+ return {
243
+ low: 6,
244
+ mid: 14
245
+ };
246
+ }
247
+ const $t = { class: "flex gap-8" }, Et = { class: "flex-1" }, Rt = { class: "flex-1" }, At = { class: "text-fm-color-typo-secondary" }, Dt = { class: "text-fm-color-typo-secondary whitespace-nowrap" }, Tt = {
248
+ type: "button",
249
+ class: "inline-flex h-32 items-center"
250
+ }, Pt = {
251
+ key: 2,
252
+ class: "border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
253
+ }, Bt = { class: "flex flex-col gap-12" }, Lt = { class: "flex flex-col gap-4" }, Nt = { class: "fm-typo-en-title-sm-800" }, zt = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ht = { class: "flex flex-col gap-4" }, Ot = { class: "flex fm-corner-radius-md border-1 border-fm-color-neutral-gray-200" }, jt = { class: "flex-1 p-12 flex flex-col gap-8" }, Yt = { class: "mx-auto" }, Gt = { class: "flex flex-col" }, qt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Wt = { class: "flex-1 p-12 flex flex-col gap-8" }, Kt = { class: "mx-auto" }, Jt = { class: "flex flex-col" }, Qt = { class: "fm-typo-en-body-sm-600 translate-y-4" }, Xt = { class: "flex-1 p-12 flex flex-col gap-8" }, Zt = { class: "mx-auto" }, en = { class: "flex flex-col" }, tn = { class: "fm-typo-en-body-sm-600 translate-y-4" };
254
+ var Me = /* @__PURE__ */ ((r) => (r.Daily = "Daily", r.Consumables = "Consumables", r.ShortTerm = "Short term", r.Kitchen = "Kitchen", r))(Me || {});
255
+ const nn = /* @__PURE__ */ ae({
256
+ __name: "IngredientForm",
257
+ props: {
258
+ mode: {},
259
+ modelValue: {},
260
+ disabled: { type: Boolean }
261
+ },
262
+ emits: ["update:modelValue", "click:submit"],
263
+ setup(r, { expose: a, emit: f }) {
264
+ var X;
265
+ const { t: s } = ne(), n = r, l = f, o = te(), c = me(), y = We();
266
+ function h(e) {
267
+ if (e.length === 0) return;
268
+ const t = e[0], m = n.modelValue ?? {
269
+ unit: o.units.find((x) => x)
270
+ };
271
+ m.unit || (m.unit = t, l("update:modelValue", m));
272
+ }
273
+ nt(() => {
274
+ h(o.units);
275
+ }), ze([() => o.units], ([e]) => {
276
+ h(e);
277
+ });
278
+ function v() {
279
+ l("click:submit");
280
+ }
281
+ const b = C({
282
+ get() {
283
+ var e;
284
+ return ((e = n.modelValue) == null ? void 0 : e.code) ?? "";
285
+ },
286
+ set(e) {
287
+ const t = n.modelValue ? {
288
+ ...n.modelValue
289
+ } : {};
290
+ t.code = e, l("update:modelValue", t);
291
+ }
292
+ }), i = C({
293
+ get() {
294
+ var e;
295
+ return ((e = n.modelValue) == null ? void 0 : e.name) ?? "";
296
+ },
297
+ set(e) {
298
+ const t = n.modelValue ? {
299
+ ...n.modelValue
300
+ } : {};
301
+ t.name = e, l("update:modelValue", t);
302
+ }
303
+ }), _ = C({
304
+ get() {
305
+ var t, m;
306
+ const e = (m = (t = n.modelValue) == null ? void 0 : t.defaultCost) == null ? void 0 : m.costPerUnit;
307
+ return e ? +Ge(e) : 0;
308
+ },
309
+ set(e) {
310
+ var m, x, $, M;
311
+ const t = n.modelValue ? {
312
+ ...n.modelValue
313
+ } : {};
314
+ t.defaultCost ?? (t.defaultCost = {
315
+ costPerUnit: {
316
+ amount: 0,
317
+ precision: 2,
318
+ currency: ((m = be(c.currentCountry.value)) == null ? void 0 : m.currency) ?? "MYR"
319
+ },
320
+ measurement: (M = ($ = (x = n.modelValue) == null ? void 0 : x.unit) == null ? void 0 : $.measurements) == null ? void 0 : M.find(
321
+ (G) => {
322
+ var Y;
323
+ return G.id === ((Y = n.modelValue) == null ? void 0 : Y.trackingMeasurement);
324
+ }
325
+ )
326
+ }), t.defaultCost.costPerUnit = {
327
+ ...t.defaultCost.costPerUnit,
328
+ ...qe(+e, 4)
329
+ }, l("update:modelValue", t);
330
+ }
331
+ }), R = C(() => {
332
+ var t, m, x;
333
+ const e = ((t = n.modelValue) == null ? void 0 : t.unit) ?? o.units.find(($) => $);
334
+ return e ? {
335
+ _id: e._id,
336
+ measurement: (m = n.modelValue) == null ? void 0 : m.trackingMeasurement,
337
+ name: ((x = e.measurements.find(($) => {
338
+ var M;
339
+ return $.id === ((M = n.modelValue) == null ? void 0 : M.trackingMeasurement);
340
+ })) == null ? void 0 : x.name) ?? e.name
341
+ } : null;
342
+ }), V = C({
343
+ get() {
344
+ var e;
345
+ return ((e = n.modelValue) == null ? void 0 : e.operationalGroup) ?? null;
346
+ },
347
+ set(e) {
348
+ const t = n.modelValue ? {
349
+ ...n.modelValue
350
+ } : {};
351
+ t.operationalGroup = e, l("update:modelValue", t);
352
+ }
353
+ }), F = C(
354
+ () => [
355
+ ...new Set(
356
+ o.skus.map((e) => e.operationalGroup ?? "").filter((e) => e && !Object.values(Me).includes(e))
357
+ )
358
+ ].sort()
359
+ ), w = C({
360
+ get() {
361
+ return V.value !== null;
362
+ },
363
+ set(e) {
364
+ e ? V.value = "" : V.value = null;
365
+ }
366
+ }), I = C(
367
+ () => o.units.flatMap(({ name: e, _id: t, abbrev: m, measurements: x }) => [
368
+ {
369
+ label: `${e}`,
370
+ value: null,
371
+ displayAsSection: !0
372
+ },
373
+ {
374
+ label: `${e} (${m})`,
375
+ value: { _id: t },
376
+ displayAsSection: !1
377
+ },
378
+ ...x.map(({ id: $, name: M, abbrev: G }) => ({
379
+ label: `${M} (${G})`,
380
+ value: { _id: t, measurement: $ },
381
+ displayAsSection: !1
382
+ }))
383
+ ])
384
+ );
385
+ function z(e) {
386
+ var t, m, x, $, M;
387
+ return ((m = (t = n.modelValue) == null ? void 0 : t.unit) == null ? void 0 : m._id) === ((x = e.value) == null ? void 0 : x._id) && (($ = n.modelValue) == null ? void 0 : $.trackingMeasurement) === ((M = e.value) == null ? void 0 : M.measurement);
388
+ }
389
+ function se(e) {
390
+ var G, Y;
391
+ if (!e) return;
392
+ const { _id: t, measurement: m } = e, x = m || void 0, $ = o.units.find((le) => le._id === t);
393
+ if (!$)
394
+ return;
395
+ const M = n.modelValue ?? {};
396
+ M.unit = $, M.trackingMeasurement = x, M.convert && (M.convert.measurement = x || null), y.enableTotalCost && (M.defaultCost = {
397
+ measurement: $.measurements.find((le) => le.id === x),
398
+ costPerUnit: {
399
+ ...((G = M.defaultCost) == null ? void 0 : G.costPerUnit) ?? {
400
+ amount: 0,
401
+ precision: 2,
402
+ currency: ((Y = be(c.currentCountry.value)) == null ? void 0 : Y.currency) ?? "MYR"
403
+ }
404
+ }
405
+ }), l("update:modelValue", M);
406
+ }
407
+ const ce = C({
408
+ get() {
409
+ var e;
410
+ return ((e = n.modelValue) == null ? void 0 : e.convert) ?? null;
411
+ },
412
+ set(e) {
413
+ const t = n.modelValue ? {
414
+ ...n.modelValue
415
+ } : {};
416
+ e ? t.convert = e : t.convert = null, l("update:modelValue", t);
417
+ }
418
+ }), _e = C(() => de.options.filter(
419
+ (e) => e === de.enum.FIFO || e === de.enum.WAVG
420
+ ).map((e) => ({
421
+ label: s(`inventory.ingredient.valuationMethod.${e}`),
422
+ value: e
423
+ }))), pe = C({
424
+ get() {
425
+ var e;
426
+ return ((e = n.modelValue) == null ? void 0 : e.valuation) ?? "WAVG";
427
+ },
428
+ set(e) {
429
+ const t = n.modelValue ? {
430
+ ...n.modelValue
431
+ } : {};
432
+ t.valuation = e, l("update:modelValue", t);
433
+ }
434
+ }), J = N();
435
+ a({
436
+ validateInputs: () => {
437
+ var e, t;
438
+ (t = (e = J.value) == null ? void 0 : e.validateInputs) == null || t.call(e);
439
+ },
440
+ resetInputsValidation: () => {
441
+ var e, t;
442
+ (t = (e = J.value) == null ? void 0 : e.resetInputsValidation) == null || t.call(e);
443
+ },
444
+ resetInputs: () => {
445
+ var e, t;
446
+ (t = (e = J.value) == null ? void 0 : e.resetInputs) == null || t.call(e);
447
+ }
448
+ });
449
+ const W = N(!1), ve = C(
450
+ () => {
451
+ var e, t, m;
452
+ return (e = n.modelValue) != null && e._id ? ((m = o.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
453
+ (x) => x.from === "INGREDIENT"
454
+ )) ?? [] : [];
455
+ }
456
+ ), A = C(
457
+ () => {
458
+ var e, t, m;
459
+ return (e = n.modelValue) != null && e._id ? ((m = o.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter(
460
+ (x) => x.from === "RECIPE"
461
+ )) ?? [] : [];
462
+ }
463
+ ), E = C(
464
+ () => {
465
+ var e, t, m;
466
+ return (e = n.modelValue) != null && e._id ? ((m = o.menu.bindedBySkuId[(t = n.modelValue) == null ? void 0 : t._id]) == null ? void 0 : m.filter((x) => x.from === "MENU")) ?? [] : [];
467
+ }
468
+ ), ie = C(
469
+ () => o.skus.map((e) => ({ label: e.name, value: e.code }))
470
+ ), oe = N((X = n.modelValue) == null ? void 0 : X.code);
471
+ function ue(e) {
472
+ var m;
473
+ const t = e.el;
474
+ t && ((m = t.querySelector("[x-should-scroll-into=true]")) == null || m.scrollIntoView());
475
+ }
476
+ function P(e) {
477
+ switch (e) {
478
+ case xe.MY:
479
+ return "MYR";
480
+ case xe.SG:
481
+ return "SGD";
482
+ case xe.ID:
483
+ return "IDR";
484
+ default:
485
+ return "MYR";
486
+ }
487
+ }
488
+ const H = C(
489
+ () => {
490
+ var e, t, m, x, $, M;
491
+ return ((x = (m = (t = (e = n.modelValue) == null ? void 0 : e.unit) == null ? void 0 : t.measurements) == null ? void 0 : m.find(
492
+ (G) => {
493
+ var Y;
494
+ return G.id === ((Y = n.modelValue) == null ? void 0 : Y.trackingMeasurement);
495
+ }
496
+ )) == null ? void 0 : x.abbrev) ?? ((M = ($ = n.modelValue) == null ? void 0 : $.unit) == null ? void 0 : M.abbrev);
497
+ }
498
+ ), Q = C({
499
+ get() {
500
+ var e, t;
501
+ return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.low) ?? re().low;
502
+ },
503
+ set(e) {
504
+ var x;
505
+ const t = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? re();
506
+ t.low = e;
507
+ const m = n.modelValue ? {
508
+ ...n.modelValue
509
+ } : {};
510
+ m.thresholds = t, l("update:modelValue", m);
511
+ }
512
+ }), K = C({
513
+ get() {
514
+ var e, t;
515
+ return ((t = (e = n.modelValue) == null ? void 0 : e.thresholds) == null ? void 0 : t.mid) ?? re().mid;
516
+ },
517
+ set(e) {
518
+ var x;
519
+ const t = ((x = n.modelValue) == null ? void 0 : x.thresholds) ?? re();
520
+ t.mid = e;
521
+ const m = n.modelValue ? {
522
+ ...n.modelValue
523
+ } : {};
524
+ m.thresholds = t, l("update:modelValue", m);
525
+ }
526
+ });
527
+ function fe() {
528
+ return function(t) {
529
+ return typeof (t == null ? void 0 : t.low) != "number" || typeof (t == null ? void 0 : t.mid) != "number" ? "Required" : t.low >= t.mid ? "Days for red indicator should be less than yellow indicator." : !0;
530
+ };
531
+ }
532
+ return (e, t) => {
533
+ const m = U("FmTextField"), x = U("FmLabel"), $ = U("FmField"), M = U("FmMenuHeader"), G = U("FmMenuDivider"), Y = U("FmMenuItem"), le = U("FmMenu"), Ie = U("FmFormGroup"), Xe = U("FmSelect"), Ue = U("FmSwitch"), Ze = U("FmIcon"), et = U("FmCard"), $e = U("FmStepperField"), tt = U("FmForm");
534
+ return g(), D(tt, {
535
+ disabled: e.disabled,
536
+ ref_key: "formRef",
537
+ ref: J,
538
+ class: "flex flex-col gap-32",
539
+ onValidationSuccess: v
540
+ }, {
541
+ default: S(() => [
542
+ d("div", $t, [
543
+ d("div", Et, [
544
+ p(m, {
545
+ label: u(s)("inventory.ingredient.code"),
546
+ "model-value": b.value,
547
+ "onUpdate:modelValue": t[0] || (t[0] = (k) => b.value = k),
548
+ rules: [u(Ve)(), u(_t)(ie.value, oe.value)],
549
+ "label-mark": "required"
550
+ }, null, 8, ["label", "model-value", "rules"])
551
+ ]),
552
+ d("div", Rt, [
553
+ p(m, {
554
+ label: u(s)("inventory.ingredient.name"),
555
+ "model-value": i.value,
556
+ "onUpdate:modelValue": t[1] || (t[1] = (k) => i.value = k),
557
+ rules: [u(Ve)()],
558
+ "label-mark": "required"
559
+ }, null, 8, ["label", "model-value", "rules"])
560
+ ])
561
+ ]),
562
+ p(Ie, {
563
+ "model-value": R.value,
564
+ rules: [u(Ve)()],
565
+ "label-mark": "required"
566
+ }, {
567
+ label: S(() => [
568
+ p(x, {
569
+ label: u(s)("inventory.ingredient.unit")
570
+ }, null, 8, ["label"])
571
+ ]),
572
+ default: S(({ invalid: k }) => [
573
+ p(le, null, {
574
+ "menu-button": S(() => [
575
+ p($, {
576
+ class: Z([
577
+ "fm-typo-en-body-lg-400",
578
+ {
579
+ "text-fm-color-typo-primary": !e.disabled,
580
+ "text-fm-color-typo-disabled": e.disabled
581
+ }
582
+ ]),
583
+ invalid: k,
584
+ "append-icon": "expand_more"
585
+ }, {
586
+ default: S(() => {
587
+ var L;
588
+ return [
589
+ He(B((L = R.value) == null ? void 0 : L.name), 1)
590
+ ];
591
+ }),
592
+ _: 2
593
+ }, 1032, ["class", "invalid"])
594
+ ]),
595
+ default: S(() => [
596
+ d("div", {
597
+ class: "overflow-x-hidden overflow-y-auto max-h-[300px]",
598
+ onVnodeMounted: ue
599
+ }, [
600
+ (g(!0), T(q, null, ee(I.value, (L) => (g(), T(q, {
601
+ key: L.label
602
+ }, [
603
+ L.displayAsSection ? (g(), T(q, { key: 0 }, [
604
+ p(M, {
605
+ label: L.label
606
+ }, null, 8, ["label"]),
607
+ p(G)
608
+ ], 64)) : (g(), D(Y, {
609
+ key: 1,
610
+ label: L.label,
611
+ "model-value": z(L),
612
+ onClick: (Rn) => se(L.value),
613
+ "x-should-scroll-into": `${z(L)}`
614
+ }, null, 8, ["label", "model-value", "onClick", "x-should-scroll-into"]))
615
+ ], 64))), 128))
616
+ ], 512)
617
+ ]),
618
+ _: 2
619
+ }, 1024)
620
+ ]),
621
+ _: 1
622
+ }, 8, ["model-value", "rules"]),
623
+ u(y).enableTotalCost ? (g(), D(Xe, {
624
+ key: 0,
625
+ class: "col-span-1",
626
+ "model-value": pe.value,
627
+ "onUpdate:modelValue": t[2] || (t[2] = (k) => pe.value = k),
628
+ items: _e.value
629
+ }, {
630
+ label: S(() => [
631
+ p(Se, { "z-index": 50 }, {
632
+ default: S(() => [
633
+ p(x, {
634
+ label: u(s)("inventory.ingredient.valuationMethod.title")
635
+ }, null, 8, ["label"])
636
+ ]),
637
+ _: 1
638
+ })
639
+ ]),
640
+ _: 1
641
+ }, 8, ["model-value", "items"])) : O("", !0),
642
+ u(y).enableTotalCost ? (g(), D(m, {
643
+ key: 1,
644
+ "model-value": _.value,
645
+ "onUpdate:modelValue": t[3] || (t[3] = (k) => _.value = k),
646
+ rules: [u(ge)(0), u(xt)(4)]
647
+ }, {
648
+ label: S(() => [
649
+ p(Se, { "z-index": 50 }, {
650
+ default: S(() => [
651
+ p(x, {
652
+ label: u(s)("inventory.ingredient.pricePerUnit")
653
+ }, null, 8, ["label"])
654
+ ]),
655
+ _: 1
656
+ })
657
+ ]),
658
+ prepend: S(() => {
659
+ var k, L;
660
+ return [
661
+ d("div", At, B(P(((k = u(c).currentCountry) == null ? void 0 : k.value) ?? u(Ae)) === "MYR" ? "RM" : P(((L = u(c).currentCountry) == null ? void 0 : L.value) ?? u(Ae))), 1)
662
+ ];
663
+ }),
664
+ append: S(() => [
665
+ d("div", Dt, " / " + B(H.value), 1)
666
+ ]),
667
+ _: 1
668
+ }, 8, ["model-value", "rules"])) : O("", !0),
669
+ p(et, {
670
+ variant: "outlined",
671
+ class: "p-16 flex flex-col gap-16"
672
+ }, {
673
+ default: S(() => [
674
+ p(Ue, {
675
+ value: "",
676
+ "model-value": w.value,
677
+ "onUpdate:modelValue": t[4] || (t[4] = (k) => w.value = k),
678
+ label: u(s)("inventory.ingredient.operational.applyOperationalGroup"),
679
+ sublabel: u(s)("inventory.ingredient.operational.subtitle"),
680
+ labelPlacement: "right"
681
+ }, null, 8, ["model-value", "label", "sublabel"]),
682
+ w.value ? (g(), D(le, { key: 0 }, {
683
+ "menu-button": S(() => [
684
+ p(m, {
685
+ label: "Operational label",
686
+ modelValue: V.value,
687
+ "onUpdate:modelValue": t[5] || (t[5] = (k) => V.value = k),
688
+ placeholder: "Input text or select preset"
689
+ }, {
690
+ append: S(() => [
691
+ d("button", Tt, [
692
+ p(Ze, { name: "expand_more" })
693
+ ])
694
+ ]),
695
+ _: 1
696
+ }, 8, ["modelValue"])
697
+ ]),
698
+ default: S(() => [
699
+ p(M, { label: "Preset" }),
700
+ (g(!0), T(q, null, ee(Object.values(Me), (k) => (g(), D(Y, {
701
+ key: k,
702
+ label: k,
703
+ "model-value": V.value === k,
704
+ onClick: (L) => V.value = k
705
+ }, null, 8, ["label", "model-value", "onClick"]))), 128)),
706
+ F.value.length ? (g(), D(M, {
707
+ key: 0,
708
+ label: "Custom"
709
+ })) : O("", !0),
710
+ (g(!0), T(q, null, ee(F.value, (k) => (g(), D(Y, {
711
+ key: k,
712
+ label: k,
713
+ "model-value": V.value === k,
714
+ onClick: (L) => V.value = k
715
+ }, null, 8, ["label", "model-value", "onClick"]))), 128))
716
+ ]),
717
+ _: 1
718
+ })) : O("", !0)
719
+ ]),
720
+ _: 1
721
+ }),
722
+ p(Ut, {
723
+ "model-value": ce.value,
724
+ "onUpdate:modelValue": t[6] || (t[6] = (k) => ce.value = k),
725
+ "root-value": e.modelValue
726
+ }, null, 8, ["model-value", "root-value"]),
727
+ e.mode !== u(j).CREATE ? (g(), T("div", Pt, [
728
+ d("div", null, [
729
+ p(Ue, {
730
+ label: u(s)("inventory.ingredient.bindedItems.title"),
731
+ modelValue: W.value,
732
+ "onUpdate:modelValue": t[7] || (t[7] = (k) => W.value = k),
733
+ "label-placement": "right"
734
+ }, null, 8, ["label", "modelValue"])
735
+ ]),
736
+ W.value && ve.value.length ? (g(), D(we, {
737
+ key: 0,
738
+ name: u(s)("inventory.ingredient.bindedItems.ingredient"),
739
+ bindings: ve.value
740
+ }, null, 8, ["name", "bindings"])) : O("", !0),
741
+ W.value && A.value.length ? (g(), D(we, {
742
+ key: 1,
743
+ name: u(s)("inventory.ingredient.bindedItems.recipe"),
744
+ bindings: A.value
745
+ }, null, 8, ["name", "bindings"])) : O("", !0),
746
+ W.value && E.value.length ? (g(), D(we, {
747
+ key: 2,
748
+ name: u(s)("inventory.ingredient.bindedItems.menu"),
749
+ bindings: E.value
750
+ }, null, 8, ["name", "bindings"])) : O("", !0)
751
+ ])) : O("", !0),
752
+ d("div", Bt, [
753
+ d("div", Lt, [
754
+ p(Se, null, {
755
+ default: S(() => [
756
+ d("div", Nt, B(u(s)("inventory.ingredient.threshold.title")), 1)
757
+ ]),
758
+ _: 1
759
+ }),
760
+ d("div", zt, B(u(s)("inventory.ingredient.threshold.subtitle")), 1)
761
+ ]),
762
+ d("div", Ht, [
763
+ p(Ie, {
764
+ "model-value": { low: Q.value, mid: K.value },
765
+ rules: [fe()]
766
+ }, null, 8, ["model-value", "rules"]),
767
+ d("div", Ot, [
768
+ d("div", jt, [
769
+ d("div", Yt, [
770
+ p(ke, {
771
+ days: Q.value,
772
+ level: u(Ce).low
773
+ }, null, 8, ["days", "level"])
774
+ ]),
775
+ d("div", Gt, [
776
+ d("div", qt, B(u(s)("inventory.ingredient.threshold.whenRemaining")), 1),
777
+ p($e, {
778
+ modelValue: Q.value,
779
+ "onUpdate:modelValue": t[8] || (t[8] = (k) => Q.value = k),
780
+ rules: [u(ge)(0)]
781
+ }, {
782
+ append: S(() => t[10] || (t[10] = [
783
+ d("div", {
784
+ class: "text-fm-color-typo-secondary",
785
+ style: { "padding-right": "32px" }
786
+ }, "days", -1)
787
+ ])),
788
+ _: 1
789
+ }, 8, ["modelValue", "rules"])
790
+ ])
791
+ ]),
792
+ t[12] || (t[12] = d("div", {
793
+ class: "h-full bg-fm-color-neutral-gray-200 relative",
794
+ style: { width: "1px" }
795
+ }, [
796
+ d("div", {
797
+ class: "absolute bg-white",
798
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
799
+ }, " < ")
800
+ ], -1)),
801
+ d("div", Wt, [
802
+ d("div", Kt, [
803
+ p(ke, {
804
+ days: K.value,
805
+ level: u(Ce).mid
806
+ }, null, 8, ["days", "level"])
807
+ ]),
808
+ d("div", Jt, [
809
+ d("div", Qt, B(u(s)("inventory.ingredient.threshold.whenRemaining")), 1),
810
+ p($e, {
811
+ modelValue: K.value,
812
+ "onUpdate:modelValue": t[9] || (t[9] = (k) => K.value = k),
813
+ rules: [u(ge)(0)]
814
+ }, {
815
+ append: S(() => t[11] || (t[11] = [
816
+ d("div", {
817
+ class: "text-fm-color-typo-secondary",
818
+ style: { "padding-right": "32px" }
819
+ }, "days", -1)
820
+ ])),
821
+ _: 1
822
+ }, 8, ["modelValue", "rules"])
823
+ ])
824
+ ]),
825
+ t[13] || (t[13] = d("div", {
826
+ class: "h-full bg-fm-color-neutral-gray-200 relative",
827
+ style: { width: "1px" }
828
+ }, [
829
+ d("div", {
830
+ class: "absolute bg-white",
831
+ style: { transform: "translate(-50%, -50%)", left: "50%", top: "24px" }
832
+ }, " < ")
833
+ ], -1)),
834
+ d("div", Xt, [
835
+ d("div", Zt, [
836
+ p(ke, {
837
+ days: K.value + 1,
838
+ level: u(Ce).high
839
+ }, null, 8, ["days", "level"])
840
+ ]),
841
+ d("div", en, [
842
+ d("div", tn, B(u(s)("inventory.ingredient.threshold.stockIsStaple")), 1)
843
+ ])
844
+ ])
845
+ ])
846
+ ])
847
+ ])
848
+ ]),
849
+ _: 1
850
+ }, 8, ["disabled"]);
851
+ };
852
+ }
853
+ }), on = { class: "flex gap-4" }, ln = /* @__PURE__ */ ae({
854
+ __name: "IngredientDialog",
855
+ props: {
856
+ show: { type: Boolean },
857
+ unit: {},
858
+ mode: { default: j.READ }
859
+ },
860
+ emits: ["update:show"],
861
+ setup(r) {
862
+ const a = r, f = te(), s = he(), { t: n } = ne(), l = Te(a, "show"), o = Te(a, "unit"), c = C(() => {
863
+ switch (a.mode) {
864
+ case j.READ:
865
+ return "";
866
+ case j.UPDATE:
867
+ return n("inventory.ingredient.update.title");
868
+ case j.CREATE:
869
+ return n("inventory.ingredient.create.title");
870
+ }
871
+ return "";
872
+ }), y = C(() => {
873
+ switch (a.mode) {
874
+ case j.READ:
875
+ return "";
876
+ case j.UPDATE:
877
+ return n("common.save");
878
+ case j.CREATE:
879
+ return n("common.add");
880
+ }
881
+ return "";
882
+ }), h = N(), v = N(!1);
883
+ async function b() {
884
+ v.value = !0;
885
+ try {
886
+ await f.createSku(o.value), l.value = !1, s.open({
887
+ title: n("inventory.common.success"),
888
+ message: n("inventory.ingredient.create.success", { name: o.value.name }),
889
+ type: "success"
890
+ });
891
+ } catch (V) {
892
+ V instanceof De || s.open({
893
+ title: n("inventory.ingredient.create.error.title"),
894
+ message: n("inventory.ingredient.create.error.message"),
895
+ type: "error"
896
+ });
897
+ } finally {
898
+ v.value = !1;
899
+ }
900
+ }
901
+ async function i() {
902
+ v.value = !0;
903
+ try {
904
+ await f.updateSku(o.value), v.value = !1, l.value = !1, s.open({
905
+ title: n("inventory.common.success"),
906
+ message: n("inventory.ingredient.update.success", { name: o.value.name }),
907
+ type: "success"
908
+ });
909
+ } catch (V) {
910
+ V instanceof De || s.open({
911
+ title: n("inventory.ingredient.update.error.title"),
912
+ message: n("inventory.ingredient.update.error.message"),
913
+ type: "error"
914
+ });
915
+ } finally {
916
+ v.value = !1;
917
+ }
918
+ }
919
+ function _() {
920
+ var V, F;
921
+ (F = (V = h.value) == null ? void 0 : V.validateInputs) == null || F.call(V);
922
+ }
923
+ function R() {
924
+ switch (a.mode) {
925
+ case j.READ:
926
+ return;
927
+ case j.UPDATE:
928
+ return i();
929
+ case j.CREATE:
930
+ return b();
931
+ }
932
+ }
933
+ return (V, F) => {
934
+ const w = U("FmButton"), I = U("FmSideSheet");
935
+ return g(), D(I, {
936
+ "model-value": u(l),
937
+ "onUpdate:modelValue": F[3] || (F[3] = (z) => Ee(l) ? l.value = z : null),
938
+ header: c.value,
939
+ "close-button": "",
940
+ "dismiss-away": "",
941
+ "max-width": 500
942
+ }, {
943
+ "side-sheet-footer": S(() => [
944
+ d("div", on, [
945
+ p(w, {
946
+ loading: v.value,
947
+ label: y.value,
948
+ onClick: _
949
+ }, null, 8, ["loading", "label"]),
950
+ p(w, {
951
+ disabled: v.value,
952
+ label: u(n)("common.close"),
953
+ variant: "tertiary",
954
+ onClick: F[2] || (F[2] = (z) => l.value = !1)
955
+ }, null, 8, ["disabled", "label"])
956
+ ])
957
+ ]),
958
+ default: S(() => [
959
+ p(nn, {
960
+ class: "w-full",
961
+ ref_key: "hasValidationExpose",
962
+ ref: h,
963
+ modelValue: u(o),
964
+ "onUpdate:modelValue": F[0] || (F[0] = (z) => Ee(o) ? o.value = z : null),
965
+ mode: V.mode,
966
+ disabled: v.value,
967
+ "onClick:submit": F[1] || (F[1] = (z) => R())
968
+ }, null, 8, ["modelValue", "mode", "disabled"])
969
+ ]),
970
+ _: 1
971
+ }, 8, ["model-value", "header"]);
972
+ };
973
+ }
974
+ });
975
+ function* rn(r) {
976
+ for (; ; )
977
+ yield r[Math.floor(Math.random() * r.length)];
978
+ }
979
+ function an(r = 4, a = rn("qwertyuiopasdfghjklzxcvbnm".split(""))) {
980
+ return Array.from({ length: r }).map(() => a.next().value).join("");
981
+ }
982
+ function sn() {
983
+ return `sku_${(/* @__PURE__ */ new Date()).toISOString()}_${an()}`;
984
+ }
985
+ const un = {
986
+ _id: "",
987
+ name: "",
988
+ abbrev: "",
989
+ precision: 0,
990
+ measurements: []
991
+ };
992
+ function dn(r) {
993
+ var f, s, n, l, o;
994
+ return {
995
+ code: r.code,
996
+ name: r.name,
997
+ unit: ((f = r.unit.measurements.find((c) => c.id === r.trackingMeasurement)) == null ? void 0 : f.abbrev) ?? r.unit.abbrev,
998
+ baseUnit: r.unit.abbrev,
999
+ valuationMethod: r.valuation ?? "WAVG",
1000
+ pricePerUnit: (s = r.defaultCost) != null && s.costPerUnit ? +Ge((n = r.defaultCost) == null ? void 0 : n.costPerUnit) : 0,
1001
+ thresholdLow: ((l = r.thresholds) == null ? void 0 : l.low) ?? re().low,
1002
+ thresholdMid: ((o = r.thresholds) == null ? void 0 : o.mid) ?? re().mid
1003
+ };
1004
+ }
1005
+ function Qe() {
1006
+ var n;
1007
+ const r = [
1008
+ {
1009
+ id: "code",
1010
+ name: "Code"
1011
+ },
1012
+ {
1013
+ id: "name",
1014
+ name: "Name"
1015
+ },
1016
+ {
1017
+ id: "unit",
1018
+ name: "Unit"
1019
+ },
1020
+ {
1021
+ id: "baseUnit",
1022
+ name: "Base unit"
1023
+ }
1024
+ ], a = We(), f = me(), s = be(f.currentCountry.value);
1025
+ return a.enableTotalCost && r.push(
1026
+ {
1027
+ id: "valuationMethod",
1028
+ name: "Valuation method"
1029
+ },
1030
+ {
1031
+ id: "pricePerUnit",
1032
+ name: `Price per unit (${s == null ? void 0 : s.currency})`
1033
+ }
1034
+ ), ((n = f.currentBusiness.value) == null ? void 0 : n.menuVersion) === "v4" && r.push(
1035
+ {
1036
+ id: "thresholdLow",
1037
+ name: "Show RED when remaining"
1038
+ },
1039
+ {
1040
+ id: "thresholdMid",
1041
+ name: "Show YELLOW when remaining"
1042
+ }
1043
+ ), r;
1044
+ }
1045
+ function mn() {
1046
+ const a = te().skus.map(dn), s = me().currentBusiness.value, n = Qe(), l = [
1047
+ ["Business name:", s == null ? void 0 : s.name],
1048
+ ["Business ID:", s == null ? void 0 : s._id],
1049
+ ["Menu version", s == null ? void 0 : s.menuVersion],
1050
+ [],
1051
+ n.map((h) => h.name),
1052
+ ...a.map((h) => n.map((v) => h[v.id]))
1053
+ ], o = n.map((h) => `system:${h.id}`), c = Ke(l, o), y = `${s == null ? void 0 : s.name} ingredients (${Ft(/* @__PURE__ */ new Date())}).xlsx`;
1054
+ return Je(c, y), y;
1055
+ }
1056
+ function cn() {
1057
+ const a = me().currentBusiness.value, f = Qe(), s = [
1058
+ ["Business name:", a == null ? void 0 : a.name],
1059
+ ["Business ID:", a == null ? void 0 : a._id],
1060
+ ["Menu version", a == null ? void 0 : a.menuVersion],
1061
+ [],
1062
+ f.map((c) => c.name)
1063
+ ], n = f.map((c) => `system:${c.id}`), l = Ke(s, n), o = "FeedMe ingredients template.xlsx";
1064
+ return Je(l, o), o;
1065
+ }
1066
+ function pn(r) {
1067
+ const [
1068
+ a,
1069
+ f,
1070
+ s,
1071
+ n,
1072
+ l,
1073
+ o,
1074
+ ...c
1075
+ ] = wt(r);
1076
+ if (!a || !a.length || a.some((i) => i.length && !i.startsWith("system:")))
1077
+ throw new Error("Missing meta header. Excel file does not come from the template.");
1078
+ const y = a.map((i) => i.split(":")[1]), v = ["code", "name", "unit", "baseUnit"].filter((i) => !y.includes(i));
1079
+ if (v.length)
1080
+ throw new Error(
1081
+ `Missing meta headers (${v.join()}). Excel file does not come from the template.`
1082
+ );
1083
+ return c.map((i, _) => {
1084
+ const R = {};
1085
+ for (const V in y) {
1086
+ const F = y[V];
1087
+ Object.assign(R, { [F]: i[V] });
1088
+ }
1089
+ return {
1090
+ index: _,
1091
+ data: R
1092
+ };
1093
+ });
1094
+ }
1095
+ function Le(r, a, f) {
1096
+ var w;
1097
+ const n = te().units, l = new Array(), o = f.filter((I) => I.data.code === r.code);
1098
+ o.length > 1 && l.push(
1099
+ `Code ${r.code} is already used in row ${o.map((I) => I.index + 6).join()}.`
1100
+ );
1101
+ const c = n.find((I) => I.abbrev === r.baseUnit), y = c == null ? void 0 : c.measurements.find((I) => I.abbrev === r.unit);
1102
+ if (!c)
1103
+ l.push(`Cannot find base unit of symbol ${r.baseUnit}.`);
1104
+ else if (r.baseUnit !== r.unit && !y) {
1105
+ const I = `Cannot find unit conversion for ${r.baseUnit} with symbol ${r.unit || "[empty]"}.`;
1106
+ l.push(I);
1107
+ }
1108
+ const h = de.options.find(
1109
+ (I) => I === r.valuationMethod
1110
+ );
1111
+ r.valuationMethod && !h && l.push(
1112
+ `Expected valuation method to be one of ${de.options.join()} but got ${r.valuationMethod} instead.`
1113
+ );
1114
+ const b = me().currentCountry.value, i = (I) => `${I}`.length && Vt()(I) === !0, _ = i(`${r.pricePerUnit}`) === !0 ? {
1115
+ costPerUnit: {
1116
+ ...qe(Number(r.pricePerUnit) || 0),
1117
+ currency: ((w = be(b)) == null ? void 0 : w.currency) ?? "MYR"
1118
+ },
1119
+ measurement: y
1120
+ } : void 0, R = i(`${r.thresholdLow}`) && i(`${r.thresholdMid}`) ? {
1121
+ low: Number(r.thresholdLow) || 0,
1122
+ mid: Number(r.thresholdMid) || 0
1123
+ } : void 0;
1124
+ return {
1125
+ type: "create",
1126
+ sku: {
1127
+ _id: sn(),
1128
+ code: r.code,
1129
+ name: r.name,
1130
+ unit: c ?? n.find((I) => I) ?? un,
1131
+ trackingMeasurement: y == null ? void 0 : y.id,
1132
+ valuation: h,
1133
+ defaultCost: _,
1134
+ thresholds: R
1135
+ },
1136
+ errors: l,
1137
+ excelRowNumber: a + 6
1138
+ };
1139
+ }
1140
+ function vn(r) {
1141
+ try {
1142
+ const a = pn(r).filter((h) => h.data.code), s = te().skus, n = st(s, "code"), l = a.filter((h) => !n[h.data.code]), o = a.filter((h) => n[h.data.code]), c = l.map(
1143
+ (h) => Le(h.data, h.index, a)
1144
+ ), y = o.map((h) => {
1145
+ const v = Le(h.data, h.index, a), b = n[h.data.code];
1146
+ return {
1147
+ ...v,
1148
+ type: "update",
1149
+ original: b,
1150
+ sku: {
1151
+ // to maintain original props not in the import excel, e.g. inventory binding, etc...
1152
+ ...b,
1153
+ code: v.sku.code || b.code,
1154
+ name: v.sku.name || b.name,
1155
+ unit: v.sku.unit || b.unit,
1156
+ trackingMeasurement: v.sku.trackingMeasurement || b.trackingMeasurement,
1157
+ valuation: v.sku.valuation || b.valuation,
1158
+ defaultCost: v.sku.defaultCost || b.defaultCost,
1159
+ thresholds: v.sku.thresholds || b.thresholds
1160
+ }
1161
+ };
1162
+ });
1163
+ return {
1164
+ invalidExcel: !1,
1165
+ importCreateResult: c,
1166
+ importUpdateResult: y
1167
+ };
1168
+ } catch (a) {
1169
+ return {
1170
+ invalidExcel: !0,
1171
+ invalidExcelMessage: (a == null ? void 0 : a.message) ?? "Invalid excel",
1172
+ importCreateResult: [],
1173
+ importUpdateResult: []
1174
+ };
1175
+ }
1176
+ }
1177
+ const fn = { class: "flex items-center gap-12 pl-8" }, yn = { class: "flex flex-col" }, gn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, bn = {
1178
+ key: 0,
1179
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
1180
+ }, hn = { key: 0 }, Ne = /* @__PURE__ */ ae({
1181
+ __name: "ImportIngredientItem",
1182
+ props: {
1183
+ type: {},
1184
+ code: {},
1185
+ name: {},
1186
+ errors: {}
1187
+ },
1188
+ setup(r) {
1189
+ return (a, f) => {
1190
+ const s = U("FmIcon"), n = U("FmTooltip");
1191
+ return g(), T("div", fn, [
1192
+ f[0] || (f[0] = d("div", null, "•", -1)),
1193
+ d("div", yn, [
1194
+ d("div", gn, [
1195
+ d("div", {
1196
+ class: Z({
1197
+ "text-fm-color-system-error-300": a.errors.length
1198
+ })
1199
+ }, [
1200
+ He(B(a.name) + " ", 1),
1201
+ a.type === "create" ? (g(), T("span", bn, "(new)")) : O("", !0)
1202
+ ], 2),
1203
+ a.errors.length ? (g(), T("div", hn, [
1204
+ p(n, { "z-index": 50 }, {
1205
+ content: S(() => [
1206
+ d("ol", null, [
1207
+ (g(!0), T(q, null, ee(a.errors, (l, o) => (g(), T("li", { key: o }, B(l), 1))), 128))
1208
+ ])
1209
+ ]),
1210
+ default: S(() => [
1211
+ p(s, {
1212
+ name: "error",
1213
+ size: "sm",
1214
+ color: "system-error-300"
1215
+ })
1216
+ ]),
1217
+ _: 1
1218
+ })
1219
+ ])) : O("", !0)
1220
+ ]),
1221
+ d("div", {
1222
+ class: Z([
1223
+ "fm-typo-en-body-sm-400",
1224
+ {
1225
+ "text-fm-color-system-error-200": a.errors.length,
1226
+ "text-fm-color-typo-secondary": !a.errors.length
1227
+ }
1228
+ ])
1229
+ }, B(a.code), 3)
1230
+ ])
1231
+ ]);
1232
+ };
1233
+ }
1234
+ }), _n = { class: "flex flex-col gap-24" }, xn = { class: "fm-typo-en-body-md-400" }, Vn = { class: "flex flex-col gap-8" }, kn = { class: "line-clamp-2 text-ellipsis break-all" }, Cn = {
1235
+ key: 2,
1236
+ class: "shrink-0"
1237
+ }, wn = {
1238
+ key: 0,
1239
+ class: "flex flex-col"
1240
+ }, Sn = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Fn = {
1241
+ key: 0,
1242
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
1243
+ }, Mn = { class: "fm-typo-en-body-lg-600" }, In = /* @__PURE__ */ ae({
1244
+ __name: "ImportIngredients",
1245
+ setup(r) {
1246
+ const a = N(null), f = ut(), s = he(), n = N(!1), l = N(new Array()), o = N([]), c = N([]), y = C(
1247
+ () => !!l.value.length || o.value.some((i) => i.errors.length) || c.value.some((i) => i.errors.length)
1248
+ ), h = C(
1249
+ () => !!o.value.length || !!c.value.length
1250
+ ), { t: v } = ne();
1251
+ async function b(i) {
1252
+ l.value = [], o.value = [], c.value = [];
1253
+ try {
1254
+ n.value = !0;
1255
+ const [_] = await Promise.all([
1256
+ St(i),
1257
+ // fake buffer
1258
+ new Promise((F) => setTimeout(F, 1e3))
1259
+ ]), R = _.SheetNames.find((F) => F);
1260
+ if (!R) {
1261
+ l.value.push(v("inventory.ingredient.import.fileError.noSheet"));
1262
+ return;
1263
+ }
1264
+ const V = vn(_.Sheets[R]);
1265
+ if (V.invalidExcel) {
1266
+ l.value.push(V.invalidExcelMessage ?? v("inventory.ingredient.import.fileError.invalidExcel"));
1267
+ return;
1268
+ }
1269
+ if (o.value = V.importCreateResult, c.value = V.importUpdateResult, !o.value.length && !c.value.length) {
1270
+ l.value.push(v("inventory.ingredient.import.fileError.noData"));
1271
+ return;
1272
+ }
1273
+ f.emitData(V);
1274
+ } catch (_) {
1275
+ s.open({
1276
+ title: v("inventory.ingredient.import.fileError.unableToRead"),
1277
+ message: _ == null ? void 0 : _.message,
1278
+ type: "error"
1279
+ }), console.error("Error in reading file", _);
1280
+ } finally {
1281
+ l.value.length && s.open({
1282
+ title: v("inventory.ingredient.import.fileError.invalidExcel"),
1283
+ type: "error"
1284
+ }), n.value = !1;
1285
+ }
1286
+ }
1287
+ return ze(a, (i) => {
1288
+ i && b(i);
1289
+ }), (i, _) => {
1290
+ const R = U("FmCircularProgress"), V = U("FmIcon"), F = U("FmButton");
1291
+ return g(), T("div", _n, [
1292
+ d("div", xn, B(u(v)("inventory.ingredient.import.uploadDescription")), 1),
1293
+ p(Mt, {
1294
+ class: Z({
1295
+ "w-full": !0,
1296
+ "h-[200px]": !a.value
1297
+ }),
1298
+ accept: ".xlsx",
1299
+ onFileUpload: _[0] || (_[0] = (w) => a.value = w),
1300
+ label: u(v)("inventory.ingredient.import.uploadTemplate"),
1301
+ "button-label": u(v)("inventory.ingredient.import.selectFile")
1302
+ }, Oe({ _: 2 }, [
1303
+ a.value ? {
1304
+ name: "default",
1305
+ fn: S(({ openFileDialog: w }) => [
1306
+ d("div", Vn, [
1307
+ d("div", {
1308
+ class: Z([
1309
+ "fm-corner-radius-md p-16 flex items-center gap-16",
1310
+ {
1311
+ "border border-fm-color-neutral-gray-100": n.value,
1312
+ "border border-fm-color-neutral-gray-200": !n.value && !y.value,
1313
+ "border border-fm-color-system-error-200": y.value
1314
+ }
1315
+ ])
1316
+ }, [
1317
+ n.value ? (g(), D(R, {
1318
+ key: 0,
1319
+ size: "md",
1320
+ color: "neutral-gray-200"
1321
+ })) : (g(), D(V, {
1322
+ key: 1,
1323
+ name: y.value ? "error" : "attach_file",
1324
+ outline: "",
1325
+ color: y.value ? "system-error-300" : void 0
1326
+ }, null, 8, ["name", "color"])),
1327
+ d("div", {
1328
+ class: Z([
1329
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
1330
+ {
1331
+ "text-fm-color-typo-disabled": n.value,
1332
+ "text-fm-color-typo-primary": !n.value
1333
+ }
1334
+ ])
1335
+ }, [
1336
+ d("div", kn, B(a.value.name), 1)
1337
+ ], 2),
1338
+ n.value ? O("", !0) : (g(), T("div", Cn, [
1339
+ p(F, {
1340
+ label: u(v)("inventory.ingredient.import.replaceFile"),
1341
+ variant: y.value ? "destructive" : "secondary",
1342
+ "prepend-icon": y.value ? void 0 : "autorenew",
1343
+ onClick: w
1344
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
1345
+ ]))
1346
+ ], 2),
1347
+ l.value.length ? (g(), T("div", wn, [
1348
+ (g(!0), T(q, null, ee(l.value, (I, z) => (g(), T("div", {
1349
+ key: z,
1350
+ class: "flex gap-8 items-center"
1351
+ }, [
1352
+ p(V, {
1353
+ name: "error",
1354
+ size: "sm",
1355
+ color: "system-error-300"
1356
+ }),
1357
+ d("div", Sn, B(I), 1)
1358
+ ]))), 128))
1359
+ ])) : O("", !0)
1360
+ ])
1361
+ ]),
1362
+ key: "0"
1363
+ } : void 0
1364
+ ]), 1032, ["class", "label", "button-label"]),
1365
+ h.value ? (g(), T("div", Fn, [
1366
+ d("div", Mn, B(u(v)("inventory.ingredient.import.summary")), 1),
1367
+ (g(!0), T(q, null, ee(o.value, (w) => (g(), D(Ne, {
1368
+ key: w.sku._id,
1369
+ code: w.sku.code,
1370
+ name: w.sku.name,
1371
+ errors: w.errors,
1372
+ type: "create"
1373
+ }, null, 8, ["code", "name", "errors"]))), 128)),
1374
+ (g(!0), T(q, null, ee(c.value, (w) => (g(), D(Ne, {
1375
+ key: w.sku._id,
1376
+ code: w.sku.code,
1377
+ name: w.sku.name,
1378
+ errors: w.errors,
1379
+ type: "update"
1380
+ }, null, 8, ["code", "name", "errors"]))), 128))
1381
+ ])) : O("", !0)
1382
+ ]);
1383
+ };
1384
+ }
1385
+ }), Un = { class: "flex flex-col py-8" }, $n = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, En = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Zn = /* @__PURE__ */ ae({
1386
+ __name: "IngredientsView",
1387
+ setup(r) {
1388
+ const a = te(), f = C(() => a.skus), s = it(), n = Ye(), l = he(), { t: o } = ne(), { createIngredient: c, updateIngredient: y } = Fe(), { ingredientDialogProps: h, ingredientViewLoading: v } = vt(Fe()), { columnDefs: b } = It();
1389
+ function i(A) {
1390
+ switch (A) {
1391
+ case "add":
1392
+ return c();
1393
+ case "import":
1394
+ return W();
1395
+ case "export":
1396
+ return J();
1397
+ }
1398
+ }
1399
+ const _ = N(""), R = N(!1), V = C(() => R.value || v.value), { breakpoints: F } = dt(), w = C(() => F.value.xs || F.value.sm), I = C(() => w.value ? 10 : 20), z = gt(), se = N(!1), ce = [
1400
+ {
1401
+ value: "import",
1402
+ label: o("common.import")
1403
+ },
1404
+ {
1405
+ value: "export",
1406
+ label: o("common.export")
1407
+ }
1408
+ ];
1409
+ function _e(A) {
1410
+ switch (se.value = !1, A) {
1411
+ case "import":
1412
+ return W();
1413
+ case "export":
1414
+ return J();
1415
+ }
1416
+ }
1417
+ const pe = C(() => [
1418
+ {
1419
+ label: o("inventory.ingredient.create.title"),
1420
+ value: "add",
1421
+ isPrimary: !0,
1422
+ prependIcon: "add"
1423
+ },
1424
+ { label: o("common.import"), value: "import" },
1425
+ { label: o("common.export"), value: "export" }
1426
+ ]);
1427
+ function J() {
1428
+ const A = mn();
1429
+ l.open({
1430
+ title: o("inventory.ingredient.export.success"),
1431
+ message: o("inventory.ingredient.export.filename", [A]),
1432
+ type: "success"
1433
+ });
1434
+ }
1435
+ function W() {
1436
+ n.open({
1437
+ title: o("inventory.ingredient.import.title"),
1438
+ contentComponent: In,
1439
+ overlay: !0,
1440
+ closeButton: !0,
1441
+ primaryActions: {
1442
+ text: o("common.import"),
1443
+ close: !1
1444
+ },
1445
+ secondaryActions: {
1446
+ text: o("common.close"),
1447
+ close: !0
1448
+ },
1449
+ tertiaryActions: {
1450
+ text: o("inventory.ingredient.import.actions.downloadTemplate"),
1451
+ close: !1,
1452
+ variant: "plain"
1453
+ }
1454
+ }).onPrimary((A) => {
1455
+ if (!A) {
1456
+ l.open({
1457
+ title: o("inventory.ingredient.import.error.noData"),
1458
+ type: "error"
1459
+ });
1460
+ return;
1461
+ }
1462
+ if (!A.importCreateResult.length && !A.importUpdateResult.length) {
1463
+ l.open({
1464
+ title: o("inventory.ingredient.import.error.invalidContent"),
1465
+ message: o("inventory.ingredient.import.error.noImportData"),
1466
+ type: "error"
1467
+ });
1468
+ return;
1469
+ }
1470
+ if (A.importCreateResult.some((E) => E.errors.length) || A.importUpdateResult.some((E) => E.errors.length)) {
1471
+ l.open({
1472
+ title: o("inventory.ingredient.import.error.invalidContent"),
1473
+ message: o("inventory.ingredient.import.error.hasErrors"),
1474
+ type: "error"
1475
+ });
1476
+ return;
1477
+ }
1478
+ n.close(), ve(A);
1479
+ }).onTertiary(cn);
1480
+ }
1481
+ async function ve(A) {
1482
+ R.value = !0;
1483
+ try {
1484
+ const E = [
1485
+ ...A.importCreateResult.map(({ sku: P }) => ({ type: "create", sku: P })),
1486
+ ...A.importUpdateResult.map(({ sku: P }) => ({ type: "update", sku: P }))
1487
+ ], ie = 100;
1488
+ let oe = 0;
1489
+ const ue = () => {
1490
+ oe += ie, l.open({
1491
+ title: o("inventory.ingredient.import.progress", [
1492
+ Math.min(oe, E.length),
1493
+ E.length
1494
+ ])
1495
+ });
1496
+ };
1497
+ for (const P of E.chunk(100))
1498
+ ue(), await a.importSkus({
1499
+ create: P.filter((H) => H.type === "create").map((H) => H.sku),
1500
+ update: P.filter((H) => H.type === "update").map((H) => H.sku)
1501
+ });
1502
+ l.open({
1503
+ title: o("inventory.ingredient.import.success"),
1504
+ type: "success"
1505
+ });
1506
+ } catch (E) {
1507
+ l.open({
1508
+ title: o("inventory.ingredient.import.error.failed"),
1509
+ message: o("inventory.ingredient.import.error.systemMessage", [E == null ? void 0 : E.message]),
1510
+ type: "error"
1511
+ }), console.error("Error in importing skus", A, E);
1512
+ } finally {
1513
+ R.value = !1;
1514
+ }
1515
+ }
1516
+ return (A, E) => {
1517
+ const ie = U("FmTable"), oe = U("FmCollapsibleTabs"), ue = U("FmBottomSheet");
1518
+ return g(), D(bt, {
1519
+ title: u(o)("inventory.ingredient.title"),
1520
+ actions: pe.value,
1521
+ "onClick:action": i
1522
+ }, {
1523
+ default: S(() => [
1524
+ d("div", {
1525
+ class: Z([
1526
+ "flex flex-col gap-8 max-h-full",
1527
+ {
1528
+ "p-0": w.value,
1529
+ "px-24 ": !w.value
1530
+ }
1531
+ ])
1532
+ }, [
1533
+ p(ht, {
1534
+ searchable: "",
1535
+ search: _.value,
1536
+ "onUpdate:search": E[0] || (E[0] = (P) => _.value = P)
1537
+ }, null, 8, ["search"]),
1538
+ p(ie, {
1539
+ style: ot(u(z).tableHeight),
1540
+ "column-defs": u(b),
1541
+ "row-data": f.value,
1542
+ "search-value": _.value,
1543
+ loading: !u(s)._currentLocation || V.value,
1544
+ "loading-text": "Loading",
1545
+ onRowClick: E[1] || (E[1] = (P) => u(y)(P.original)),
1546
+ "page-size": I.value
1547
+ }, {
1548
+ "list-row": S((P) => [
1549
+ p(yt, {
1550
+ row: P,
1551
+ onRowClick: u(y)
1552
+ }, Oe({
1553
+ default: S((H) => {
1554
+ var Q, K, fe, X, e, t, m, x, $, M;
1555
+ return [
1556
+ d("div", Un, [
1557
+ d("div", $n, [
1558
+ p(u(Be), {
1559
+ render: (fe = (K = (Q = H.code) == null ? void 0 : Q.column) == null ? void 0 : K.columnDef) == null ? void 0 : fe.cell,
1560
+ props: (e = (X = H.code) == null ? void 0 : X.getContext) == null ? void 0 : e.call(X)
1561
+ }, null, 8, ["render", "props"])
1562
+ ]),
1563
+ d("div", En, [
1564
+ p(u(Be), {
1565
+ render: (x = (m = (t = H.name) == null ? void 0 : t.column) == null ? void 0 : m.columnDef) == null ? void 0 : x.cell,
1566
+ props: (M = ($ = H.name) == null ? void 0 : $.getContext) == null ? void 0 : M.call($)
1567
+ }, null, 8, ["render", "props"])
1568
+ ])
1569
+ ])
1570
+ ];
1571
+ }),
1572
+ _: 2
1573
+ }, [
1574
+ R.value ? {
1575
+ name: "loading-text",
1576
+ fn: S(() => [
1577
+ d("div", null, B(u(o)("inventory.ingredient.table.importing")), 1)
1578
+ ]),
1579
+ key: "0"
1580
+ } : void 0
1581
+ ]), 1032, ["row", "onRowClick"])
1582
+ ]),
1583
+ _: 1
1584
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
1585
+ ], 2),
1586
+ (g(), D(Re, { to: "body" }, [
1587
+ p(ln, lt(rt(u(h))), null, 16)
1588
+ ])),
1589
+ (g(), D(Re, { to: "body" }, [
1590
+ p(ue, {
1591
+ "dismiss-away": "",
1592
+ modelValue: se.value,
1593
+ "onUpdate:modelValue": E[3] || (E[3] = (P) => se.value = P)
1594
+ }, {
1595
+ default: S(() => [
1596
+ p(oe, {
1597
+ class: "pb-8",
1598
+ items: ce,
1599
+ "onUpdate:modelValue": E[2] || (E[2] = (P) => _e(P))
1600
+ })
1601
+ ]),
1602
+ _: 1
1603
+ }, 8, ["modelValue"])
1604
+ ]))
1605
+ ]),
1606
+ _: 1
1607
+ }, 8, ["title", "actions"]);
1608
+ };
1609
+ }
1610
+ });
1611
+ export {
1612
+ Zn as default
1613
+ };