@feedmepos/mf-inventory-portal 0.0.23-dev.38 → 0.0.23-dev.40

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