@feedmepos/mf-inventory-portal 0.0.23-dev.1 → 0.0.23-dev.10

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