@feedmepos/mf-inventory-portal 0.0.24-dev.3 → 0.0.24-dev.49

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