@feedmepos/mf-inventory-portal 0.0.23-dev.4 → 0.0.23-dev.5

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