@feedmepos/mf-inventory-portal 1.2.30-dev.1 → 1.2.31-dev.1

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 (83) hide show
  1. package/dist/{App-kX4bqoEe.js → App-DfKh34ES.js} +43 -41
  2. package/dist/{ApprovalView-DCNKqVE2.js → ApprovalView-DyoKsEqh.js} +34 -28
  3. package/dist/{BindingsDialog-d7f1f8gf.js → BindingsDialog-7rGLzkyA.js} +8 -8
  4. package/dist/{BindingsPicker-2HJOx0QW.js → BindingsPicker-Cj1DvhQN.js} +6 -5
  5. package/dist/{BindingsTable-CPAjxOZG.js → BindingsTable-CAreptqr.js} +28 -24
  6. package/dist/{ClosingDraftView-CUng41eo.js → ClosingDraftView-DoDGz9Y8.js} +183 -175
  7. package/dist/{ClosingHistoryView-CcGc2NwU.js → ClosingHistoryView-BJSE7ZSv.js} +43 -41
  8. package/dist/{ClosingTemplateView-D8IAdhDb.js → ClosingTemplateView-Dr2eJk4h.js} +94 -76
  9. package/dist/{DeliveryOrderPrintPreview-BsM-CCc5.js → DeliveryOrderPrintPreview-BzYLm6J6.js} +15 -14
  10. package/dist/FmDroppableField-J0xUsOTV.js +154 -0
  11. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-cuggJ5Xd.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-16r_hkBE.js} +74 -72
  12. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Csesow4V.js +279 -0
  13. package/dist/FmMultiselectDialog-BGhSjgbj.js +597 -0
  14. package/dist/{FmMultiselectDialog-BGbrqXUF.js → FmMultiselectDialog-DUrpqAkF.js} +1 -1
  15. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-isogcN1O.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CSv7osJW.js} +51 -49
  16. package/dist/{ImportView-wAVrMEwL.js → ImportView-BAkyTU_3.js} +81 -74
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DVUF4I2Q.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-z0IAsrH_.js} +5 -5
  18. package/dist/{IngredientGroupView-BZczeXdL.js → IngredientGroupView-D7gurA7T.js} +73 -65
  19. package/dist/{IngredientsView-D5N5Y1ZY.js → IngredientsView-hwfpMtTX.js} +358 -345
  20. package/dist/{IntegrationView-Hrslmuc1.js → IntegrationView-DwqzQ6E3.js} +1618 -1593
  21. package/dist/{InventoryBindingForm-DH6wgxOG.js → InventoryBindingForm-CwjM6Rqk.js} +1 -1
  22. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Drr5vD6f.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BPr8PDwu.js} +41 -40
  23. package/dist/{InventoryBindingSummary-BU1ehpQZ.js → InventoryBindingSummary-B7UFFMkm.js} +1 -1
  24. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-1ueC4GfZ.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Djo2b2Ix.js} +5 -5
  25. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-FHcU1zZt.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BSgGGiN6.js} +22 -21
  26. package/dist/{PublishView-CQtj0f31.js → PublishView-CA9gFV_r.js} +26 -23
  27. package/dist/{PurchaseOrderPrintPreview-BQyXtHST.js → PurchaseOrderPrintPreview-BeHd82Y0.js} +10 -9
  28. package/dist/{ReceiveRequestView-Dm-h_SrY.js → ReceiveRequestView-DEthRdM1.js} +472 -456
  29. package/dist/{RecipeView-DNNRvr1w.js → RecipeView-D45gkYHY.js} +73 -64
  30. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js +251 -0
  31. package/dist/{StockView-CaOm5BCx.js → StockView-COx7A4Ac.js} +292 -282
  32. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Z91XRszD.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DX35xDkm.js} +1 -1
  33. package/dist/{SupplierView-JSII9qwL.js → SupplierView-DHM3dJMZ.js} +92 -80
  34. package/dist/SystemTrailDialog.vue_vue_type_script_setup_true_lang-Bg2K2ULw.js +177 -0
  35. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js +135 -0
  36. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CyMEGFh5.js +123 -0
  37. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Mehd4lGs.js → TransferDetails.vue_vue_type_script_setup_true_lang-CVm2bXic.js} +318 -305
  38. package/dist/{TransferTemplateView-DyCpNKJd.js → TransferTemplateView-BtYozLuk.js} +228 -216
  39. package/dist/{UnitView-CqN7mlJ2.js → UnitView-B4mqodQa.js} +70 -63
  40. package/dist/{WarehouseView-gFWD-m8e.js → WarehouseView-CjDM8L_V.js} +123 -114
  41. package/dist/WastageTemplateView-Be4Y_zV8.js +2288 -0
  42. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  43. package/dist/api/netsuite.d.ts +9 -3
  44. package/dist/app-DYsP0gKj.js +64121 -0
  45. package/dist/app-rgirz_52.js +8024 -0
  46. package/dist/app.js +6 -6
  47. package/dist/closing-template-BVy1ga2g.js +117 -0
  48. package/dist/date2-BO7HiZTk.js +116 -0
  49. package/dist/dayjs.min-HNt4C1ja.js +282 -0
  50. package/dist/{decimal-DfF_g5rc.js → decimal-BJ8rKm1R.js} +4 -3
  51. package/dist/defineDeepModel-CidpVmK7.js +19 -0
  52. package/dist/duplicate-template-C25Z0lvq.js +34 -0
  53. package/dist/feature-DCia3aqG.js +20162 -0
  54. package/dist/form-mode.enum-BKiNVH6A.js +4 -0
  55. package/dist/format-time-from-id-BPws326b.js +15 -0
  56. package/dist/{format-unit-display-ivAljvlo.js → format-unit-display-C2P3mS8l.js} +308 -297
  57. package/dist/{import-export.helper-B2MWv9v7.js → import-export.helper-Dt6ZMAPT.js} +56 -52
  58. package/dist/{index-DZaT0ZaL.js → index-6zxXdF-V.js} +1 -1
  59. package/dist/index-BjUDHtA2.js +45 -0
  60. package/dist/{index-BbhuWHyh.js → index-tZj47B-j.js} +16 -14
  61. package/dist/lodash-DLMgBu6M.js +3678 -0
  62. package/dist/netsuite-BSMLXIQa.js +4979 -0
  63. package/dist/{purchase-order-template-DdybMC_P.js → purchase-order-template-D5NGCbI2.js} +1 -1
  64. package/dist/router/shared.spec.d.ts +1 -0
  65. package/dist/row-action.enum-BcW_L_nE.js +67 -0
  66. package/dist/rules-BiaGzhvQ.js +201 -0
  67. package/dist/{stock-BYagIdsj.js → stock-DOCQ91Jh.js} +1 -1
  68. package/dist/{stock-V4ciPiBe.js → stock-Ty-89Ap8.js} +11 -10
  69. package/dist/stores/integration/netsuite.d.ts +5 -1
  70. package/dist/style.css +1 -1
  71. package/dist/{supplier-CgtB1I9I.js → supplier-Dxb5ULjF.js} +27 -26
  72. package/dist/tsconfig.app.tsbuildinfo +1 -1
  73. package/dist/{use-ingredient-select-dialog-BIQovyZX.js → use-ingredient-select-dialog-BI0yIG6A.js} +4 -3
  74. package/dist/{use-inventory-binding-dialog-DyjicXgc.js → use-inventory-binding-dialog-CbZC-VuL.js} +4 -3
  75. package/dist/use-template-enabled-locations-2-Dhttpl0B.js +111 -0
  76. package/dist/views/adjustment-template/wastage-template/table.d.ts +1 -1
  77. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +1 -1
  78. package/dist/views/integration/components/netsuite/business/BusinessNetSuiteSideSheet.vue.d.ts +6 -2
  79. package/dist/vue-i18n-Cqx7gNJF.js +2365 -0
  80. package/dist/xlsx-ex8Bmftq.js +24004 -0
  81. package/dist/xlsx.util-C8YXEqEl.js +78 -0
  82. package/package.json +2 -2
  83. package/dist/app-CnQ49Lyb.js +0 -131483
@@ -0,0 +1,2288 @@
1
+ import { ref as R, h as P, defineComponent as K, resolveComponent as D, openBlock as I, createElementBlock as A, createElementVNode as g, normalizeClass as H, createTextVNode as me, toDisplayString as C, unref as w, createCommentVNode as z, createVNode as S, createBlock as U, Fragment as Y, renderList as Q, computed as B, watch as ve, createSlots as Le, withCtx as V, isRef as Ue, normalizeStyle as Qe, Teleport as Xe, normalizeProps as Ze, guardReactiveProps as et, mergeProps as Ve } from "vue";
2
+ import { u as tt, _ as nt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js";
3
+ import { useI18n as G, useCoreStore as Be } from "@feedmepos/mf-common";
4
+ import { D as re, R as L } from "./row-action.enum-BcW_L_nE.js";
5
+ import { _ as ot } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Csesow4V.js";
6
+ import { useDialog as X, useDialogChild as st, useSnackbar as Z, FmButtonVariant as ie, components as W, useProxiedModel as Ne, useBreakpoints as at } from "@feedmepos/ui-library";
7
+ import { defineStore as ze, storeToRefs as Oe } from "pinia";
8
+ import { c as lt, _ as rt, F as ce } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
9
+ import { u as ye, c as We, a as ee, C as j, n as it, A as de } from "./app-DYsP0gKj.js";
10
+ import { F as J } from "./form-mode.enum-BKiNVH6A.js";
11
+ import { f as ct } from "./format-time-from-id-BPws326b.js";
12
+ import { u as te } from "./closing-template-BVy1ga2g.js";
13
+ import { _ as ut } from "./TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CyMEGFh5.js";
14
+ import { t as pe, a as He, d as Ye, s as Ke, r as mt } from "./xlsx.util-C8YXEqEl.js";
15
+ import { f as dt, a as ue } from "./date2-BO7HiZTk.js";
16
+ import { u as pt } from "./netsuite-BSMLXIQa.js";
17
+ import { F as ft } from "./FmDroppableField-J0xUsOTV.js";
18
+ import { u as vt } from "./duplicate-template-C25Z0lvq.js";
19
+ import { A as yt, R as Ge } from "./rules-BiaGzhvQ.js";
20
+ import { d as ht } from "./defineDeepModel-CidpVmK7.js";
21
+ import { u as gt } from "./use-template-enabled-locations-2-Dhttpl0B.js";
22
+ import { a as bt } from "./FmMultiselectDialog-BGhSjgbj.js";
23
+ import { _ as _t } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-Bg2K2ULw.js";
24
+ import { _ as xt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
25
+ const ne = ze(
26
+ "wastageTable",
27
+ function() {
28
+ const { t: s } = G(), m = X(), h = fe(), a = R({}), c = R(new Array()), l = R(!1), t = ye(), r = te(), o = R({}), u = R();
29
+ async function b() {
30
+ if (t._currentLocation)
31
+ try {
32
+ u.value = await r.getReasons();
33
+ } catch (n) {
34
+ console.log("Something went wrong when fetching reasons:", n);
35
+ }
36
+ }
37
+ function v() {
38
+ var e;
39
+ if (!u.value) return !1;
40
+ const n = (e = a.value.publishedRevs) == null ? void 0 : e[u.value._id];
41
+ return u.value._rev === n;
42
+ }
43
+ function T(n) {
44
+ const e = {
45
+ title: n.name,
46
+ doc: n,
47
+ controller: {
48
+ publishAll: async () => {
49
+ var y;
50
+ const i = await r.publishSingleDoc(
51
+ n._id,
52
+ (y = n.locations) == null ? void 0 : y.map((_) => _.dbName)
53
+ );
54
+ return o.value = i.publishedRevByLocation || {}, o.value;
55
+ },
56
+ publishAtLocation: async (i) => {
57
+ const y = await r.publishSingleDoc(n._id, [
58
+ i.dbName
59
+ ]);
60
+ return o.value = y.publishedRevByLocation || {}, o.value;
61
+ }
62
+ },
63
+ initialPublishedRev: o.value,
64
+ locations: t.locations,
65
+ enabledLocations: n.locations
66
+ };
67
+ m.open({
68
+ title: "Publish template",
69
+ contentComponent: ut,
70
+ contentComponentProps: e,
71
+ closeButton: !0,
72
+ primaryActions: {
73
+ text: s("common.close"),
74
+ close: !0,
75
+ variant: "tertiary"
76
+ }
77
+ });
78
+ }
79
+ async function d() {
80
+ if (c.value = [], !!t._currentLocation) {
81
+ l.value = !0;
82
+ try {
83
+ const [n, e, i] = await Promise.all([
84
+ r.readTemplates(),
85
+ r.getRecentPublishingJob(),
86
+ r.getRecentPublishInfo()
87
+ ]).delayed(1e3);
88
+ c.value = n, a.value = e, o.value = (i == null ? void 0 : i.publishedRevByLocation) || {}, await b();
89
+ } catch (n) {
90
+ console.log("Something went wrong when fetching templates:", n);
91
+ } finally {
92
+ l.value = !1;
93
+ }
94
+ }
95
+ }
96
+ async function x(n) {
97
+ if (!c.value.find((e) => e._id) && t._currentLocation) {
98
+ l.value = !0;
99
+ try {
100
+ const [e] = await Promise.all([
101
+ r.getTemplate(n),
102
+ new Promise((i) => setTimeout(i, 1e3))
103
+ ]);
104
+ c.value = [e];
105
+ } catch (e) {
106
+ console.log("Something went wrong when fetching templates:", e);
107
+ } finally {
108
+ l.value = !1;
109
+ }
110
+ }
111
+ }
112
+ function k(n, e) {
113
+ switch (e = We(e), n) {
114
+ case L.Details:
115
+ return h.viewTemplate(e);
116
+ case L.Edit:
117
+ return h.updateTemplate(e);
118
+ case L.Delete:
119
+ return h.deleteTemplate(e, l, d);
120
+ case L.Publish:
121
+ return T(e);
122
+ case L.Duplicate:
123
+ return h.duplicateTemplate(e, l, d);
124
+ }
125
+ }
126
+ return {
127
+ columnDefs: [
128
+ {
129
+ id: "_id",
130
+ accessorKey: "_id",
131
+ header: () => s("inventory.adjustment.template.table.createdAt"),
132
+ cell(n) {
133
+ return ct(`${n.getValue()}`);
134
+ },
135
+ enableSorting: !0
136
+ },
137
+ {
138
+ id: "name",
139
+ accessorKey: "name",
140
+ header: () => s("inventory.adjustment.template.table.name"),
141
+ enableSorting: !0,
142
+ size: 200
143
+ },
144
+ {
145
+ id: "noOfItems",
146
+ accessorKey: "items.length",
147
+ header: () => s("inventory.adjustment.template.table.noOfItems"),
148
+ enableSorting: !1,
149
+ meta: {
150
+ width: "10rem",
151
+ textAlign: "right"
152
+ }
153
+ },
154
+ {
155
+ id: "enabledLocations",
156
+ accessorKey: "locations.length",
157
+ header: () => s("inventory.adjustment.template.table.enabledOutlets"),
158
+ cell(n) {
159
+ var i;
160
+ const e = (i = n.row.original.locations) == null ? void 0 : i.length;
161
+ return e ? `${e}` : "All";
162
+ },
163
+ enableSorting: !1,
164
+ meta: {
165
+ width: "10rem",
166
+ textAlign: "right"
167
+ }
168
+ },
169
+ {
170
+ id: "status",
171
+ header: () => s("inventory.adjustment.template.table.status"),
172
+ enableSorting: !1,
173
+ cell(n) {
174
+ const e = n.row.original, i = e._rev, y = n.row.original.locations || t.locations, $ = y.filter((F) => !!(o.value[F.dbName] || []).find((E) => E._id === e._id && E._rev === i)).length === y.length;
175
+ return P(
176
+ "div",
177
+ {
178
+ class: "flex items-center gap-8"
179
+ },
180
+ P(
181
+ "div",
182
+ {
183
+ class: [
184
+ "fm-status-badge",
185
+ $ ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
186
+ ]
187
+ },
188
+ $ ? "Published" : "Unpublished"
189
+ )
190
+ );
191
+ }
192
+ },
193
+ {
194
+ id: "action",
195
+ cell(n) {
196
+ const e = n.row.original, i = [
197
+ re[L.Edit],
198
+ re[L.Duplicate],
199
+ re[L.Delete],
200
+ re[L.Publish]
201
+ ];
202
+ return lt(i, (y) => k(y, e));
203
+ },
204
+ enableSorting: !1,
205
+ size: 40,
206
+ meta: {
207
+ cellClass: "",
208
+ headerClass: ""
209
+ }
210
+ }
211
+ ],
212
+ recentPublish: a,
213
+ templates: c,
214
+ reasons: u,
215
+ isReasonPublished: v,
216
+ loading: l,
217
+ fetchTemplates: d,
218
+ loadTemplate: x
219
+ };
220
+ }
221
+ );
222
+ var he = /* @__PURE__ */ ((f) => (f.Ingredients = "Ingredients", f))(he || {});
223
+ function Je(f, s, m) {
224
+ var a, c, l;
225
+ const h = [];
226
+ if (f.type == j.Enum.sku) {
227
+ const t = new Set(f.disabledMeasurements), r = (a = s.sku) == null ? void 0 : a.find((o) => o._id === f.id);
228
+ if (r) {
229
+ const o = {
230
+ type: f.type,
231
+ code: f.code,
232
+ name: f.name,
233
+ unit: r.unit.abbrev,
234
+ enabled: !t.has(r.unit._id)
235
+ };
236
+ h.push(
237
+ o,
238
+ ...r.unit.measurements.map((u) => ({
239
+ unit: u.abbrev,
240
+ enabled: !t.has(u.id)
241
+ }))
242
+ );
243
+ }
244
+ }
245
+ return f.type == j.Enum.recipe && ((c = s.recipe) != null && c.find((r) => r._id === f.id)) && h.push(f), f.type == j.Enum.menu && ((l = m == null ? void 0 : m.modules.item) != null && l.find((r) => r._id === f.id)) && h.push(f), h;
246
+ }
247
+ function qe() {
248
+ return [
249
+ {
250
+ id: "code",
251
+ name: "Code"
252
+ },
253
+ {
254
+ id: "type",
255
+ name: "Type"
256
+ },
257
+ {
258
+ id: "name",
259
+ name: "Name"
260
+ },
261
+ {
262
+ id: "unit",
263
+ name: "Unit"
264
+ },
265
+ {
266
+ id: "enabled",
267
+ name: "Enabled (Unit)"
268
+ }
269
+ ];
270
+ }
271
+ function wt(f) {
272
+ var o;
273
+ const s = Be(), m = ee(), h = m.menu.cache, a = s.currentBusiness.value, l = (o = f.map((u) => {
274
+ var k;
275
+ const b = u.items.flatMap(
276
+ (p) => Je(p, m.state.inventory, h)
277
+ ), v = qe(), T = [
278
+ ["Template ID", u._id],
279
+ ["Template name", u.name],
280
+ ["Business name", a == null ? void 0 : a.name],
281
+ ["Business ID", a == null ? void 0 : a._id],
282
+ ["Menu version", a == null ? void 0 : a.menuVersion],
283
+ [
284
+ "Locations",
285
+ ...(k = u.locations) != null && k.length ? u.locations.map((p) => `${p.name} (${p.dbName})`) : ["All"]
286
+ ],
287
+ // ['Reference', template.ref ?? ''],
288
+ [],
289
+ v.map((p) => p.name),
290
+ ...b.map((p) => v.map((n) => p[n.id]))
291
+ ], d = v.map((p) => `system:${p.id}`), x = pe(T, d);
292
+ return { name: u.name, sheet: x };
293
+ }).reduce(
294
+ (u, b) => {
295
+ var T;
296
+ const v = b.name.slice(0, 12);
297
+ return (T = u.sheetOccurence)[v] ?? (T[v] = 0), u.sheetOccurence[v] += 1, u.sheets[`${v} (${u.sheetOccurence[v]})`] = b.sheet, u;
298
+ },
299
+ {
300
+ sheets: {},
301
+ sheetOccurence: {}
302
+ }
303
+ )) == null ? void 0 : o.sheets, t = `${a == null ? void 0 : a.name} adjustment templates (${dt(/* @__PURE__ */ new Date())}).xlsx`, r = He(l);
304
+ return Ye(r, t), t;
305
+ }
306
+ function Tt() {
307
+ var k;
308
+ const f = Be(), s = ee(), m = pt(), h = (k = s.state.inventory.sku) == null ? void 0 : k[0];
309
+ if (!h)
310
+ throw new Error("No inventory items");
311
+ const c = Je(
312
+ {
313
+ type: j.Enum.sku,
314
+ code: h.code,
315
+ id: h._id,
316
+ name: h.name
317
+ },
318
+ s.state.inventory,
319
+ s.menu.cache
320
+ )[0], l = f.currentBusiness.value, t = qe(), r = [
321
+ ["Template ID (leave empty to create new)", ""],
322
+ ["Template Name", "New template"],
323
+ ["Business name", l == null ? void 0 : l.name],
324
+ ["Business ID", l == null ? void 0 : l._id],
325
+ ["Menu version", l == null ? void 0 : l.menuVersion],
326
+ [
327
+ "Location codes (leave empty to enable all)",
328
+ "Example outlet (restaurant_xxx)",
329
+ "Example outlet 2 (restaurant_xxx)"
330
+ ],
331
+ // ['Reference:'],
332
+ [],
333
+ t.map((p) => p.name),
334
+ t.map((p) => c[p.id])
335
+ ], o = t.map((p) => `system:${p.id}`), u = pe(r, o), b = m.isEnabled ? m.state.setting.childItems ?? [] : [], v = b.reduce(
336
+ (p, n) => {
337
+ var $, F;
338
+ const e = ($ = m.netSuiteItemIdToSkuId.get(n.parentNetSuiteId)) == null ? void 0 : $[0], i = (F = m.netSuiteMeasurementIdToMeasurementId.get(
339
+ n.unitOfMeasureId
340
+ )) == null ? void 0 : F[0];
341
+ if (!n.externalId)
342
+ return p;
343
+ if (!e)
344
+ return console.error(`Item ${n.externalId} cannot be mapped to parent FdoInventorySku.`, n), p;
345
+ const y = s.skuById[e], _ = y.unit.measurements.find((M) => M.id === i);
346
+ return _ ? (p[n.externalId] = {
347
+ sku: y,
348
+ measurement: _
349
+ }, p) : (console.error(
350
+ `Item ${n.externalId} found parent FdoInventorySku of ${y.code} ${y.name} but the measurement of netsuite id ${n.unitOfMeasureId} cannot be found.`,
351
+ n
352
+ ), p);
353
+ },
354
+ {}
355
+ ), T = pe(
356
+ [
357
+ ...s.skus.flatMap((p) => [
358
+ [p.code, p.name, p.unit.abbrev, !0],
359
+ ...p.unit.measurements.map((e) => [
360
+ "",
361
+ "",
362
+ e.abbrev,
363
+ !e.abbrev.toLocaleLowerCase("en-us").includes("inactive")
364
+ ])
365
+ ]),
366
+ ...Object.entries(v).map(([p, { sku: n, measurement: e }]) => [
367
+ n.code,
368
+ n.name,
369
+ e.abbrev,
370
+ !e.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
371
+ p
372
+ ])
373
+ ],
374
+ [
375
+ "Code",
376
+ "Type",
377
+ "Name",
378
+ "Units",
379
+ "Enabled (true/false)",
380
+ ...b.length ? ["Netsuite Parent"] : []
381
+ ]
382
+ ), d = He({
383
+ Template: u,
384
+ Ingredients: T
385
+ }), x = `${l == null ? void 0 : l.name} transfer templates import.xlsx`;
386
+ return Ye(d, x), x;
387
+ }
388
+ function kt(f) {
389
+ if (!f.length || `${f[0]}`.toLocaleLowerCase() === "all")
390
+ return [];
391
+ const s = /(.*) \(((warehouse_|restaurant_).{24,})\)/, h = ye().locationByDbName;
392
+ return f.map((a) => {
393
+ const c = new Array(), l = a.trim(), t = s.exec(l);
394
+ if (!t)
395
+ return c.push(`Enabled location value of ${l} cannot be read.`), {
396
+ errors: c
397
+ };
398
+ const r = t[1], o = t[2], u = h[o];
399
+ return u ? (r !== u.name && c.push(
400
+ `Location id ${o} has non-matching name. Found ${r} but expected ${u.name}`
401
+ ), {
402
+ errors: c,
403
+ location: u
404
+ }) : (c.push(`Location (${r}) of id ${o} is not found.`), {
405
+ errors: c
406
+ });
407
+ });
408
+ }
409
+ function $t(f) {
410
+ const [
411
+ s,
412
+ m,
413
+ h,
414
+ a,
415
+ c,
416
+ l,
417
+ t,
418
+ r
419
+ ] = Ke(f);
420
+ return {
421
+ id: `${m[1] ?? ""}`.trim(),
422
+ name: `${h[1] ?? ""}`.trim(),
423
+ locations: t.slice(1).map((o) => `${o}`.trim()).filter((o) => o),
424
+ reference: `${r[1] ?? ""}`.trim()
425
+ };
426
+ }
427
+ function It(f) {
428
+ const [
429
+ s,
430
+ m,
431
+ h,
432
+ a,
433
+ c,
434
+ l,
435
+ t,
436
+ r,
437
+ o,
438
+ ...u
439
+ ] = Ke(f);
440
+ if (!s || !s.length || s.some((x) => x.length && !x.startsWith("system:")))
441
+ throw new Error("Missing meta header. Excel file does not come from the template.");
442
+ const b = s.map((x) => x.split(":")[1]), T = [
443
+ "code",
444
+ "type",
445
+ "name",
446
+ "unit",
447
+ "enabled"
448
+ ].filter((x) => !b.includes(x));
449
+ if (T.length)
450
+ throw new Error(
451
+ `Missing meta headers (${T.join()}). Excel file does not come from the template.`
452
+ );
453
+ return u.map((x, k) => {
454
+ const p = {};
455
+ for (const n in b) {
456
+ const e = b[n];
457
+ Object.assign(p, { [e]: x[n] });
458
+ }
459
+ return {
460
+ index: k,
461
+ data: p
462
+ };
463
+ });
464
+ }
465
+ function St(f) {
466
+ return f.reduce(
467
+ (s, m) => {
468
+ var c;
469
+ const h = m.data, a = m.index;
470
+ if (h.type == j.Enum.recipe)
471
+ s.result.push({ parent: m, children: [] });
472
+ else if (h.type == j.Enum.menu)
473
+ h.code ? s.result.push({ parent: m, children: [] }) : s.errors.push(`Menu item row ${a + 9} does not have a code.`);
474
+ else {
475
+ if (!h.unit) return s;
476
+ h.code ? s.result.push({ parent: m, children: [] }) : s.result.length ? (c = s.result.at(-1)) == null || c.children.push(m) : s.errors.push(`Cannot find parent for row ${a + 9}`);
477
+ }
478
+ return s;
479
+ },
480
+ { result: new Array(), errors: new Array() }
481
+ );
482
+ }
483
+ function Ft(f) {
484
+ var r;
485
+ const s = f.parent.data, m = new Array(), h = ee();
486
+ if (f.parent.data.type == j.Enum.menu) {
487
+ const o = h.menu.cache, u = (r = o == null ? void 0 : o.modules.item) == null ? void 0 : r.find((v) => v.code === s.code);
488
+ if (!u)
489
+ return m.push(`Cannot find menu module of id ${s.code}`), { errors: m };
490
+ const b = {
491
+ type: j.Enum.menu,
492
+ code: u.code,
493
+ id: u._id,
494
+ name: u.name ?? ""
495
+ };
496
+ return { errors: m, templateItem: b };
497
+ }
498
+ if (f.parent.data.type == j.Enum.recipe) {
499
+ const u = h.recipes.find((v) => v.name === s.name);
500
+ if (!u)
501
+ return m.push(`Cannot find recipe module of id ${s.code}`), { errors: m };
502
+ const b = {
503
+ type: j.Enum.recipe,
504
+ id: u._id,
505
+ name: u.name ?? ""
506
+ };
507
+ return { errors: m, templateItem: b };
508
+ }
509
+ const a = h.skuByCode[s.code ?? ""];
510
+ if (!a)
511
+ return m.push(`Cannot find ingredient of code [${s.code}] [${s.name}]`), { errors: m };
512
+ const c = {
513
+ type: j.Enum.sku,
514
+ code: s.code,
515
+ id: a._id,
516
+ name: s.name ?? "",
517
+ disabledMeasurements: []
518
+ }, l = a.unit.measurements.find((o) => o.abbrev === s.unit);
519
+ s.unit !== a.unit.abbrev && !l ? m.push(
520
+ `Cannot find measurement unit of ${s.unit} for (${s.code}) ${s.name}.`
521
+ ) : (!s.enabled || `${s.enabled}`.toLocaleLowerCase() === "false") && (c.disabledMeasurements ?? (c.disabledMeasurements = []), c.disabledMeasurements.push((l == null ? void 0 : l.id) ?? a.unit._id));
522
+ for (const o of f.children) {
523
+ const u = o.data, b = u.unit === a.unit.abbrev ? a.unit : void 0, v = a.unit.measurements.find((T) => T.abbrev === u.unit);
524
+ if (!v && !b) {
525
+ m.push(
526
+ `Cannot find measurement unit of ${u.unit} for (${s.code}) ${s.name}.`
527
+ );
528
+ continue;
529
+ }
530
+ (!u.enabled || `${u.enabled}`.toLocaleLowerCase() === "false") && (c.disabledMeasurements ?? (c.disabledMeasurements = []), c.disabledMeasurements.push((v == null ? void 0 : v.id) ?? (b == null ? void 0 : b._id) ?? ""));
531
+ }
532
+ const t = new Set(c.disabledMeasurements);
533
+ return t.has(a.unit._id) && a.unit.measurements.every((o) => t.has(o.id)) && m.push(`Ingredient ${a.code} - ${a.name} must have at least one unit enabled.`), { errors: m, templateItem: c };
534
+ }
535
+ function Ct(f) {
536
+ const s = f.SheetNames.filter(
537
+ (c) => !Object.values(he).map(String).includes(c)
538
+ ), h = ne().templates, a = it(h, "_id");
539
+ try {
540
+ return s.reduce(
541
+ (l, t) => {
542
+ const r = new Array(), o = f.Sheets[t], u = $t(o), b = kt(u.locations), v = b.filter((e) => e.location).map((e) => e.location);
543
+ r.push(...b.flatMap((e) => e.errors));
544
+ const T = It(o).filter((e) => {
545
+ const i = e.data;
546
+ return i.type == j.Enum.menu ? i.code : i.type == j.Enum.recipe ? i.name : e.data.code || e.data.unit;
547
+ }), d = St(T);
548
+ r.push(...d.errors);
549
+ const x = d.result.map(
550
+ (e) => Ft(e)
551
+ );
552
+ r.push(...x.flatMap((e) => e.errors));
553
+ const k = x.filter((e) => e.templateItem).map((e) => e.templateItem);
554
+ if (u.id) {
555
+ const e = a[u.id];
556
+ if (!e) {
557
+ const y = {
558
+ type: de.Enum.WASTAGE,
559
+ _id: u.id,
560
+ _rev: "",
561
+ name: u.name || `(unnamed from sheet ${t || "<unnamed sheet>"})`,
562
+ items: []
563
+ };
564
+ return r.push(`Template ID ${u.id} is not found.`), l.importUpdateResult.push({
565
+ type: "update",
566
+ original: y,
567
+ template: y,
568
+ excelSheetName: t,
569
+ errors: r
570
+ }), l;
571
+ }
572
+ const i = {
573
+ type: "update",
574
+ original: e,
575
+ template: {
576
+ ...e,
577
+ name: u.name,
578
+ locations: v.length ? v : null,
579
+ items: k
580
+ },
581
+ excelSheetName: t,
582
+ errors: r
583
+ };
584
+ return l.importUpdateResult.push(i), l;
585
+ }
586
+ const n = {
587
+ type: "create",
588
+ template: {
589
+ type: de.Enum.WASTAGE,
590
+ name: u.name,
591
+ locations: v.length ? v : null,
592
+ items: k
593
+ },
594
+ excelSheetName: t,
595
+ errors: r
596
+ };
597
+ return l.importCreateResult.push(n), l;
598
+ },
599
+ {
600
+ invalidExcel: !1,
601
+ importCreateResult: new Array(),
602
+ importUpdateResult: new Array()
603
+ }
604
+ );
605
+ } catch (c) {
606
+ return {
607
+ invalidExcel: !0,
608
+ invalidExcelMessage: (c == null ? void 0 : c.message) ?? "Invalid excel",
609
+ importCreateResult: [],
610
+ importUpdateResult: []
611
+ };
612
+ }
613
+ }
614
+ const At = { class: "flex" }, Mt = { class: "flex flex-col flex-1" }, Rt = { class: "flex flex-col" }, Dt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Et = {
615
+ key: 0,
616
+ class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
617
+ }, Pt = { key: 0 }, Vt = { class: "ml-auto" }, jt = { key: 0 }, je = /* @__PURE__ */ K({
618
+ __name: "AdjustmentTemplateImportItem",
619
+ props: {
620
+ type: {},
621
+ name: {},
622
+ locations: {},
623
+ items: {},
624
+ errors: {}
625
+ },
626
+ setup(f) {
627
+ const s = f, { t: m } = G(), h = R(!1), a = () => {
628
+ s.errors.length && (h.value = !h.value);
629
+ };
630
+ return (c, l) => {
631
+ var r, o, u;
632
+ const t = D("FmIcon");
633
+ return I(), A("div", At, [
634
+ l[0] || (l[0] = g("div", null, "•", -1)),
635
+ g("div", Mt, [
636
+ g("div", {
637
+ class: H(["flex items-center gap-12 pl-8", {
638
+ "cursor-pointer": c.errors.length
639
+ }]),
640
+ onClick: a
641
+ }, [
642
+ g("div", Rt, [
643
+ g("div", Dt, [
644
+ g("div", {
645
+ class: H({
646
+ "text-fm-color-system-error-300": c.errors.length
647
+ })
648
+ }, [
649
+ me(C(c.name) + " ", 1),
650
+ c.type === "create" ? (I(), A("span", Et, "(" + C(w(m)("inventory.closing.template.import.new")) + ")", 1)) : z("", !0)
651
+ ], 2),
652
+ c.errors.length ? (I(), A("div", Pt, [
653
+ S(t, {
654
+ name: "error",
655
+ size: "sm",
656
+ color: "system-error-300"
657
+ })
658
+ ])) : z("", !0)
659
+ ]),
660
+ g("div", {
661
+ class: H([
662
+ "fm-typo-en-body-sm-400",
663
+ {
664
+ "text-fm-color-system-error-200": c.errors.length,
665
+ "text-fm-color-typo-secondary": !c.errors.length
666
+ }
667
+ ])
668
+ }, C((r = c.locations) != null && r.length ? w(m)("inventory.closing.template.import.nLocations", { count: (o = c.locations) == null ? void 0 : o.length }) : w(m)("inventory.closing.template.import.allLocations")) + ", " + C(w(m)("inventory.closing.template.import.nItems", { count: (u = c.items) == null ? void 0 : u.length })), 3)
669
+ ]),
670
+ g("div", Vt, [
671
+ c.errors.length ? (I(), U(t, {
672
+ key: 0,
673
+ name: h.value ? "keyboard_arrow_up" : "keyboard_arrow_down",
674
+ size: "md"
675
+ }, null, 8, ["name"])) : z("", !0)
676
+ ])
677
+ ], 2),
678
+ h.value ? (I(), A("div", {
679
+ key: 0,
680
+ class: H(["flex flex-col gap-4 pl-8 fm-typo-en-body-sm-400", {
681
+ "text-fm-color-typo-secondary": !c.errors.length,
682
+ "text-fm-color-system-error-300": c.errors.length
683
+ }])
684
+ }, [
685
+ c.errors.length ? (I(), A("div", jt, [
686
+ g("ol", null, [
687
+ (I(!0), A(Y, null, Q(c.errors, (b, v) => (I(), A("li", { key: v }, C(b), 1))), 128))
688
+ ])
689
+ ])) : z("", !0)
690
+ ], 2)) : z("", !0)
691
+ ])
692
+ ]);
693
+ };
694
+ }
695
+ }), Lt = { class: "flex flex-col gap-24" }, Ut = { class: "fm-typo-en-body-md-400" }, Bt = {
696
+ key: 0,
697
+ class: "flex items-center gap-8"
698
+ }, Nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, zt = { class: "flex flex-col gap-8" }, Ot = { class: "line-clamp-2 text-ellipsis break-all" }, Wt = {
699
+ key: 2,
700
+ class: "shrink-0"
701
+ }, Ht = {
702
+ key: 0,
703
+ class: "flex flex-col"
704
+ }, Yt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Kt = {
705
+ key: 0,
706
+ class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
707
+ }, Gt = { class: "fm-typo-en-body-lg-600" }, Jt = /* @__PURE__ */ K({
708
+ __name: "AdjustmentTemplateImport",
709
+ setup(f) {
710
+ const s = R(null), m = st(), h = Z(), a = R(!1), c = R(!1), l = R(new Array()), t = R([]), r = R([]), o = B(
711
+ () => !!l.value.length || t.value.some((T) => T.errors.length) || r.value.some((T) => T.errors.length)
712
+ ), u = B(
713
+ () => !!t.value.length || !!r.value.length
714
+ ), { t: b } = G();
715
+ async function v(T) {
716
+ l.value = [], t.value = [], r.value = [];
717
+ try {
718
+ a.value = !0;
719
+ const [d] = await Promise.all([
720
+ mt(T),
721
+ // fake buffer
722
+ new Promise((n) => setTimeout(n, 1e3))
723
+ ]);
724
+ if (!d.SheetNames.filter(
725
+ (n) => !Object.values(he).map(String).includes(n)
726
+ ).find((n) => n)) {
727
+ l.value.push(b("inventory.ingredient.import.fileError.noSheet"));
728
+ return;
729
+ }
730
+ const p = Ct(d);
731
+ if (p.invalidExcel) {
732
+ l.value.push(
733
+ p.invalidExcelMessage ?? b("inventory.ingredient.import.fileError.invalidExcel")
734
+ );
735
+ return;
736
+ }
737
+ if (t.value = p.importCreateResult, r.value = p.importUpdateResult, !t.value.length && !r.value.length) {
738
+ l.value.push(b("inventory.ingredient.import.fileError.noData"));
739
+ return;
740
+ }
741
+ m.emitData(p);
742
+ } catch (d) {
743
+ h.open({
744
+ title: b("inventory.ingredient.import.fileError.unableToRead"),
745
+ message: d == null ? void 0 : d.message,
746
+ type: "error"
747
+ }), console.error("Error in reading file", d);
748
+ } finally {
749
+ l.value.length && h.open({
750
+ title: b("inventory.ingredient.import.fileError.invalidExcel"),
751
+ type: "error"
752
+ }), a.value = !1;
753
+ }
754
+ }
755
+ return ve(s, (T) => {
756
+ T && v(T);
757
+ }), (T, d) => {
758
+ const x = D("FmCircularProgress"), k = D("FmIcon"), p = D("FmButton");
759
+ return I(), A("div", Lt, [
760
+ g("div", Ut, C(w(b)("inventory.adjustment.template.import.message")), 1),
761
+ c.value ? (I(), A("div", Bt, [
762
+ g("div", null, [
763
+ S(x, {
764
+ size: "md",
765
+ color: "neutral-gray-200"
766
+ })
767
+ ]),
768
+ g("div", Nt, C(w(b)("inventory.formField.loading")), 1)
769
+ ])) : (I(), A(Y, { key: 1 }, [
770
+ S(ft, {
771
+ class: H({
772
+ "w-full": !0,
773
+ "h-[200px]": !s.value
774
+ }),
775
+ accept: ".xlsx",
776
+ onFileUpload: d[0] || (d[0] = (n) => s.value = n),
777
+ label: w(b)("inventory.ingredient.import.uploadTemplate"),
778
+ "button-label": w(b)("inventory.ingredient.import.selectFile")
779
+ }, Le({ _: 2 }, [
780
+ s.value ? {
781
+ name: "default",
782
+ fn: V(({ openFileDialog: n }) => [
783
+ g("div", zt, [
784
+ g("div", {
785
+ class: H([
786
+ "fm-corner-radius-md p-16 flex items-center gap-16",
787
+ {
788
+ "border border-fm-color-neutral-gray-100": a.value,
789
+ "border border-fm-color-neutral-gray-200": !a.value && !o.value,
790
+ "border border-fm-color-system-error-200": o.value
791
+ }
792
+ ])
793
+ }, [
794
+ a.value ? (I(), U(x, {
795
+ key: 0,
796
+ size: "md",
797
+ color: "neutral-gray-200"
798
+ })) : (I(), U(k, {
799
+ key: 1,
800
+ name: o.value ? "error" : "attach_file",
801
+ outline: "",
802
+ color: o.value ? "system-error-300" : void 0
803
+ }, null, 8, ["name", "color"])),
804
+ g("div", {
805
+ class: H([
806
+ "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
807
+ {
808
+ "text-fm-color-typo-disabled": a.value,
809
+ "text-fm-color-typo-primary": !a.value
810
+ }
811
+ ])
812
+ }, [
813
+ g("div", Ot, C(s.value.name), 1)
814
+ ], 2),
815
+ a.value ? z("", !0) : (I(), A("div", Wt, [
816
+ S(p, {
817
+ label: w(b)("inventory.ingredient.import.replaceFile"),
818
+ variant: o.value ? "destructive" : "secondary",
819
+ "prepend-icon": o.value ? void 0 : "autorenew",
820
+ onClick: n
821
+ }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
822
+ ]))
823
+ ], 2),
824
+ l.value.length ? (I(), A("div", Ht, [
825
+ (I(!0), A(Y, null, Q(l.value, (e, i) => (I(), A("div", {
826
+ key: i,
827
+ class: "flex gap-8 items-center"
828
+ }, [
829
+ S(k, {
830
+ name: "error",
831
+ size: "sm",
832
+ color: "system-error-300"
833
+ }),
834
+ g("div", Yt, C(e), 1)
835
+ ]))), 128))
836
+ ])) : z("", !0)
837
+ ])
838
+ ]),
839
+ key: "0"
840
+ } : void 0
841
+ ]), 1032, ["class", "label", "button-label"]),
842
+ u.value ? (I(), A("div", Kt, [
843
+ g("div", Gt, C(w(b)("inventory.ingredient.import.summary")), 1),
844
+ (I(!0), A(Y, null, Q(t.value, (n, e) => (I(), U(je, {
845
+ key: e,
846
+ name: n.template.name,
847
+ locations: n.template.locations,
848
+ items: n.template.items,
849
+ errors: n.errors,
850
+ type: "create"
851
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128)),
852
+ (I(!0), A(Y, null, Q(r.value, (n) => (I(), U(je, {
853
+ key: n.template._id,
854
+ name: n.template.name,
855
+ locations: n.template.locations,
856
+ items: n.template.items,
857
+ errors: n.errors,
858
+ type: "update"
859
+ }, null, 8, ["name", "locations", "items", "errors"]))), 128))
860
+ ])) : z("", !0)
861
+ ], 64))
862
+ ]);
863
+ };
864
+ }
865
+ }), fe = ze("wastageTemplateAction", () => {
866
+ const { t: f } = G(), s = X(), m = Z(), h = te(), a = vt(), c = ne(), { loading: l } = Oe(c), t = R({});
867
+ function r() {
868
+ t.value = {
869
+ mode: J.CREATE,
870
+ show: !0,
871
+ "onUpdate:show"(e) {
872
+ t.value.show = e;
873
+ }
874
+ };
875
+ }
876
+ function o(e) {
877
+ t.value = {
878
+ mode: J.UPDATE,
879
+ modelValue: e,
880
+ show: !0,
881
+ "onUpdate:show"(i) {
882
+ t.value.show = i;
883
+ }
884
+ };
885
+ }
886
+ function u(e, i, y) {
887
+ s.open({
888
+ title: `Confirm deleting template ${e.name}?`,
889
+ message: "Deleted template can no longer be retrieved",
890
+ primaryActions: {
891
+ text: "Delete",
892
+ variant: ie.Destructive,
893
+ close: !0
894
+ },
895
+ secondaryActions: {
896
+ text: "Cancel",
897
+ variant: ie.Plain,
898
+ close: !0
899
+ }
900
+ }).onPrimary(async () => {
901
+ m.open({
902
+ title: `Deleting ${e.name}`,
903
+ type: "info"
904
+ });
905
+ try {
906
+ i.value = !0;
907
+ const [_] = await Promise.allSettled([
908
+ h.deleteTemplate(e),
909
+ new Promise(($) => setTimeout($, 1e3))
910
+ ]);
911
+ if (_.status === "rejected") throw _.reason;
912
+ m.open({
913
+ title: `Deleted ${e.name}`,
914
+ type: "success"
915
+ });
916
+ } catch (_) {
917
+ m.open({
918
+ title: `Unable to delete ${e.name}`,
919
+ message: `See error from server: ${_}`,
920
+ type: "error"
921
+ }), console.error("error on deleting adjustment template", _);
922
+ } finally {
923
+ i.value = !1, y();
924
+ }
925
+ });
926
+ }
927
+ function b(e, i, y) {
928
+ let _;
929
+ s.open({
930
+ title: `Confirm duplicating template "${e.name}"?`,
931
+ message: "Duplicated template can be edited after creation",
932
+ primaryActions: {
933
+ text: "Duplicate",
934
+ variant: ie.Destructive,
935
+ close: !0
936
+ },
937
+ secondaryActions: {
938
+ text: "Cancel",
939
+ variant: ie.Plain,
940
+ close: !0
941
+ },
942
+ contentComponent: K({
943
+ props: ["modelValue"],
944
+ emits: ["update:modelValue"],
945
+ setup($) {
946
+ return () => P(W.FmTextField, {
947
+ modelValue: $.modelValue,
948
+ "onUpdate:modelValue": (F) => _ = F,
949
+ label: "New Template Name",
950
+ size: "md",
951
+ variant: "primary"
952
+ });
953
+ }
954
+ })
955
+ }).onPrimary(async () => {
956
+ m.open({
957
+ title: `Duplicating "${e.name}"`,
958
+ type: "info"
959
+ });
960
+ try {
961
+ i.value = !0;
962
+ const [$] = await Promise.allSettled([
963
+ a.duplicateWastagetemplate(e._id, _),
964
+ new Promise((F) => setTimeout(F, 1e3))
965
+ ]);
966
+ if ($.status === "rejected") throw $.reason;
967
+ m.open({
968
+ title: `Duplicated "${e.name}"`,
969
+ type: "success"
970
+ });
971
+ } catch ($) {
972
+ m.open({
973
+ title: `Unable to duplicate "${e.name}"`,
974
+ message: `See error from server: ${$}`,
975
+ type: "error"
976
+ }), console.error("error on duplicating adjustment template", $);
977
+ } finally {
978
+ i.value = !1, y();
979
+ }
980
+ });
981
+ }
982
+ const v = R({});
983
+ function T(e) {
984
+ v.value = {
985
+ template: e,
986
+ show: !0,
987
+ "onUpdate:show"(i) {
988
+ v.value.show = i;
989
+ },
990
+ "onAction:edit"() {
991
+ v.value.show = !1, o(We(e));
992
+ }
993
+ };
994
+ }
995
+ function d() {
996
+ if (!c.templates.length) {
997
+ m.open({
998
+ title: "No data to export",
999
+ type: "error"
1000
+ });
1001
+ return;
1002
+ }
1003
+ const e = wt(c.templates);
1004
+ m.open({
1005
+ title: f("inventory.ingredient.export.success"),
1006
+ message: f("inventory.ingredient.export.filename", [e]),
1007
+ type: "success"
1008
+ });
1009
+ }
1010
+ function x() {
1011
+ c.loading || s.open({
1012
+ title: f("inventory.adjustment.template.import.title"),
1013
+ contentComponent: Jt,
1014
+ overlay: !0,
1015
+ closeButton: !0,
1016
+ primaryActions: {
1017
+ text: f("common.import"),
1018
+ close: !1
1019
+ },
1020
+ secondaryActions: {
1021
+ text: f("common.close"),
1022
+ close: !0
1023
+ },
1024
+ tertiaryActions: {
1025
+ text: f("inventory.ingredient.import.actions.downloadTemplate"),
1026
+ close: !1,
1027
+ variant: "plain"
1028
+ }
1029
+ }).onPrimary((e) => {
1030
+ if (!e) {
1031
+ m.open({
1032
+ title: f("inventory.ingredient.import.error.noData"),
1033
+ type: "error"
1034
+ });
1035
+ return;
1036
+ }
1037
+ if (!e.importCreateResult.length && !e.importUpdateResult.length) {
1038
+ m.open({
1039
+ title: f("inventory.ingredient.import.error.invalidContent"),
1040
+ message: f("inventory.ingredient.import.error.noImportData"),
1041
+ type: "error"
1042
+ });
1043
+ return;
1044
+ }
1045
+ if (e.importCreateResult.some((i) => i.errors.length) || e.importUpdateResult.some((i) => i.errors.length)) {
1046
+ m.open({
1047
+ title: f("inventory.ingredient.import.error.invalidContent"),
1048
+ message: f("inventory.ingredient.import.error.hasErrors"),
1049
+ type: "error"
1050
+ });
1051
+ return;
1052
+ }
1053
+ s.close(), k(e);
1054
+ }).onTertiary(Tt);
1055
+ }
1056
+ async function k(e) {
1057
+ l.value = !0;
1058
+ try {
1059
+ const i = [
1060
+ ...e.importCreateResult.map(
1061
+ (F) => F.template
1062
+ ),
1063
+ ...e.importUpdateResult.map(
1064
+ (F) => F.template
1065
+ )
1066
+ ], y = 100;
1067
+ let _ = 0;
1068
+ const $ = () => {
1069
+ _ += y, m.open({
1070
+ title: f("inventory.ingredient.import.progress", [
1071
+ Math.min(_, i.length),
1072
+ i.length
1073
+ ])
1074
+ });
1075
+ };
1076
+ for (const F of i.chunk(100))
1077
+ $(), await h.importTemplates(F);
1078
+ m.open({
1079
+ title: f("inventory.ingredient.import.success"),
1080
+ type: "success"
1081
+ });
1082
+ } catch (i) {
1083
+ m.open({
1084
+ title: f("inventory.ingredient.import.error.failed"),
1085
+ message: f("inventory.ingredient.import.error.systemMessage", [i == null ? void 0 : i.message]),
1086
+ type: "error"
1087
+ }), console.error("Error in importing skus", e, i);
1088
+ } finally {
1089
+ l.value = !1, c.fetchTemplates();
1090
+ }
1091
+ }
1092
+ const p = R({});
1093
+ function n() {
1094
+ p.value = {
1095
+ show: !0,
1096
+ "onUpdate:show"(e) {
1097
+ p.value.show = e;
1098
+ }
1099
+ };
1100
+ }
1101
+ return {
1102
+ createTemplate: r,
1103
+ viewTemplate: T,
1104
+ updateTemplate: o,
1105
+ deleteTemplate: u,
1106
+ duplicateTemplate: b,
1107
+ exportTemplates: d,
1108
+ importTemplates: x,
1109
+ viewReason: n,
1110
+ templateDialogProps: t,
1111
+ templateDetailsProps: v,
1112
+ templateReasonProps: p
1113
+ };
1114
+ });
1115
+ function qt(f) {
1116
+ const s = ee(), m = B(() => {
1117
+ const a = /* @__PURE__ */ new Map();
1118
+ for (const c of s.skus)
1119
+ a.set(c._id, c);
1120
+ return a;
1121
+ });
1122
+ return {
1123
+ columnDefs: B(() => {
1124
+ const a = f.items.map((l) => l.type !== "sku" ? 0 : m.value.get(l.id).unit.measurements.length).reduce((l, t) => Math.max(l, t), 0);
1125
+ return [
1126
+ {
1127
+ id: "Delete",
1128
+ header: "",
1129
+ cell(l) {
1130
+ const t = l.row.original;
1131
+ return P(
1132
+ "div",
1133
+ { class: "w-full flex justify-end" },
1134
+ P(W.FmButton, {
1135
+ class: "delete-button",
1136
+ key: t.id,
1137
+ type: "button",
1138
+ icon: "delete",
1139
+ variant: "tertiary",
1140
+ size: "md",
1141
+ disabled: f.disabled,
1142
+ onClick: () => {
1143
+ f.deleteItem(t);
1144
+ }
1145
+ })
1146
+ );
1147
+ },
1148
+ enableSorting: !1,
1149
+ size: 40,
1150
+ meta: {
1151
+ cellClass: "",
1152
+ headerClass: ""
1153
+ }
1154
+ },
1155
+ {
1156
+ id: "Name",
1157
+ header: () => "Name",
1158
+ enableSorting: !1,
1159
+ size: 400,
1160
+ minSize: 400,
1161
+ accessorFn: (l) => `${l.name} ${l.code}`,
1162
+ cell(l) {
1163
+ const t = l.row.original;
1164
+ return P("div", { class: "flex", style: { minWidth: "400px" } }, [
1165
+ P(
1166
+ "div",
1167
+ {
1168
+ class: "flex flex-col grow"
1169
+ },
1170
+ [
1171
+ P(
1172
+ W.FmTooltip,
1173
+ {
1174
+ content: t.name,
1175
+ placement: "top",
1176
+ variant: "plain",
1177
+ zIndex: 50
1178
+ },
1179
+ P(
1180
+ "span",
1181
+ {
1182
+ class: "flex-auto fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1"
1183
+ },
1184
+ t.name
1185
+ )
1186
+ ),
1187
+ P(
1188
+ "span",
1189
+ { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
1190
+ t.code ?? ""
1191
+ )
1192
+ ]
1193
+ ),
1194
+ P(
1195
+ "div",
1196
+ {
1197
+ class: "flex flex-col justify-center"
1198
+ },
1199
+ [
1200
+ P(
1201
+ W.FmChip,
1202
+ {
1203
+ compact: !0
1204
+ },
1205
+ t.type === "sku" ? "Ingredient" : t.type === "recipe" ? "Recipe" : "Menu"
1206
+ )
1207
+ ]
1208
+ )
1209
+ ]);
1210
+ }
1211
+ },
1212
+ {
1213
+ id: "Unit",
1214
+ header: () => "Enable unit",
1215
+ enableSorting: !1,
1216
+ minSize: 200,
1217
+ maxSize: 400,
1218
+ cell(l) {
1219
+ var o, u, b;
1220
+ const t = l.row.original;
1221
+ if (t.type !== "sku") return P("span", "N/A");
1222
+ const r = m.value.get(t.id);
1223
+ return P("div", { class: "flex items-center gap-32" }, [
1224
+ P(
1225
+ W.FmFormGroup,
1226
+ {
1227
+ value: r.unit._id,
1228
+ modelValue: !((o = t.disabledMeasurements) != null && o.includes(r.unit._id))
1229
+ },
1230
+ P(
1231
+ "div",
1232
+ {
1233
+ class: "flex items-center gap-4",
1234
+ style: { width: "120px" }
1235
+ },
1236
+ [
1237
+ P(W.FmCheckbox, {
1238
+ value: r.unit._id,
1239
+ modelValue: !((u = t.disabledMeasurements) != null && u.includes(r.unit._id)),
1240
+ disabled: f.disabled || !((b = t.disabledMeasurements) != null && b.includes(r.unit._id)) && r.unit.measurements.every(
1241
+ (v) => {
1242
+ var T;
1243
+ return (T = t.disabledMeasurements) == null ? void 0 : T.includes(v.id);
1244
+ }
1245
+ ),
1246
+ "onUpdate:modelValue"(v) {
1247
+ var T;
1248
+ if (console.log("active", v), v)
1249
+ f.updateItem({
1250
+ ...t,
1251
+ disabledMeasurements: (T = t.disabledMeasurements) == null ? void 0 : T.filter(
1252
+ (d) => d !== r.unit._id
1253
+ )
1254
+ });
1255
+ else {
1256
+ const d = t.disabledMeasurements ?? [];
1257
+ f.updateItem({
1258
+ ...t,
1259
+ disabledMeasurements: [...d, r.unit._id]
1260
+ });
1261
+ }
1262
+ }
1263
+ }),
1264
+ P(
1265
+ W.FmTooltip,
1266
+ { zIndex: 51 },
1267
+ {
1268
+ content() {
1269
+ return m.value.get(t.id).unit.abbrev;
1270
+ },
1271
+ default() {
1272
+ const v = m.value.get(t.id);
1273
+ return P(
1274
+ "div",
1275
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1276
+ v.unit.abbrev
1277
+ );
1278
+ }
1279
+ }
1280
+ )
1281
+ ]
1282
+ )
1283
+ ),
1284
+ ...Array.from({ length: Math.max(a, 0) }).map((v, T) => {
1285
+ var p, n, e, i;
1286
+ const d = l.row.original, x = m.value.get(d.id), k = x.unit.measurements[T];
1287
+ return k ? P(
1288
+ W.FmFormGroup,
1289
+ {
1290
+ modelValue: !((p = d.disabledMeasurements) != null && p.includes(k.id)),
1291
+ value: k.id
1292
+ },
1293
+ P(
1294
+ "div",
1295
+ {
1296
+ class: "flex items-center gap-4",
1297
+ style: { width: "120px" }
1298
+ },
1299
+ [
1300
+ P(W.FmCheckbox, {
1301
+ value: k.id,
1302
+ modelValue: !((n = d.disabledMeasurements) != null && n.includes(k.id)),
1303
+ disabled: f.disabled || !((e = d.disabledMeasurements) != null && e.includes(k.id)) && ((i = d.disabledMeasurements) == null ? void 0 : i.includes(x.unit._id)) && x.unit.measurements.filter((y) => y.id != k.id).every((y) => {
1304
+ var _;
1305
+ return (_ = d.disabledMeasurements) == null ? void 0 : _.includes(y.id);
1306
+ }),
1307
+ "onUpdate:modelValue"(y) {
1308
+ var _;
1309
+ if (console.log("active", y), y)
1310
+ f.updateItem({
1311
+ ...d,
1312
+ disabledMeasurements: (_ = d.disabledMeasurements) == null ? void 0 : _.filter(
1313
+ ($) => $ !== k.id
1314
+ )
1315
+ });
1316
+ else {
1317
+ const $ = d.disabledMeasurements ?? [];
1318
+ f.updateItem({
1319
+ ...d,
1320
+ disabledMeasurements: [...$, k.id]
1321
+ });
1322
+ }
1323
+ }
1324
+ }),
1325
+ P(
1326
+ W.FmTooltip,
1327
+ { zIndex: 51 },
1328
+ {
1329
+ content() {
1330
+ return k.abbrev;
1331
+ },
1332
+ default() {
1333
+ return P(
1334
+ "div",
1335
+ { class: "line-clamp-2 fm-typo-en-body-lg-400" },
1336
+ k.abbrev
1337
+ );
1338
+ }
1339
+ }
1340
+ )
1341
+ ]
1342
+ )
1343
+ ) : null;
1344
+ })
1345
+ ]);
1346
+ }
1347
+ }
1348
+ ];
1349
+ })
1350
+ };
1351
+ }
1352
+ const Qt = { class: "flex flex-col gap-16" }, Xt = { class: "flex items-center" }, Zt = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, en = /* @__PURE__ */ K({
1353
+ __name: "WastageTemplateItemTable",
1354
+ props: {
1355
+ modelValue: {},
1356
+ disabled: { type: Boolean }
1357
+ },
1358
+ emits: ["update:modelValue"],
1359
+ setup(f, { expose: s, emit: m }) {
1360
+ const h = f, a = R(h.modelValue), { t: c } = G(), l = m, t = ee(), r = X(), o = R(), u = R("");
1361
+ s({
1362
+ validateInputs: () => {
1363
+ var d, x;
1364
+ (x = (d = o.value) == null ? void 0 : d.validateInputs) == null || x.call(d);
1365
+ },
1366
+ resetInputsValidation: () => {
1367
+ var d, x;
1368
+ (x = (d = o.value) == null ? void 0 : d.resetInputsValidation) == null || x.call(d);
1369
+ },
1370
+ resetInputs: () => {
1371
+ var d, x;
1372
+ (x = (d = o.value) == null ? void 0 : d.resetInputs) == null || x.call(d);
1373
+ }
1374
+ });
1375
+ const b = qt({
1376
+ updateItem: (d) => {
1377
+ a.value = a.value.map((x) => x.id !== d.id ? x : d), l("update:modelValue", a.value);
1378
+ },
1379
+ deleteItem: (d) => {
1380
+ a.value = a.value.filter((x) => x.id !== d.id), l("update:modelValue", a.value);
1381
+ },
1382
+ get items() {
1383
+ return a.value;
1384
+ },
1385
+ get disabled() {
1386
+ return h.disabled;
1387
+ }
1388
+ }), v = B(() => b.columnDefs.value);
1389
+ function T() {
1390
+ var y;
1391
+ const d = t.skus.map((_) => {
1392
+ var $, F;
1393
+ return {
1394
+ type: "sku",
1395
+ name: _.name,
1396
+ description: _.code,
1397
+ data: _,
1398
+ searchKeys: ($ = _.customAttributes) != null && $.tag ? [(F = _.customAttributes) == null ? void 0 : F.tag] : void 0
1399
+ };
1400
+ }), x = t.recipes.map((_) => {
1401
+ var $, F;
1402
+ return {
1403
+ type: "recipe",
1404
+ name: _.name,
1405
+ description: "",
1406
+ data: _,
1407
+ searchKeys: ($ = _.customAttributes) != null && $.tag ? [(F = _.customAttributes) == null ? void 0 : F.tag] : void 0
1408
+ };
1409
+ }), k = ((y = t.menu.cache) == null ? void 0 : y.modules.item.map((_) => ({
1410
+ type: "menu",
1411
+ name: _.name,
1412
+ description: `${_.code}`,
1413
+ data: _
1414
+ }))) ?? [], p = [...d, ...x, ...k].map((_) => {
1415
+ var F;
1416
+ const $ = [_.type == "sku" ? "Ingredient" : _.type == "recipe" ? "Recipe" : "Menu"];
1417
+ if (_.type == "sku" || _.type == "recipe") {
1418
+ const E = (F = _.data.customAttributes) == null ? void 0 : F.tag;
1419
+ E && $.push(E);
1420
+ }
1421
+ return {
1422
+ label: _.name,
1423
+ sublabel: _.description,
1424
+ value: _,
1425
+ tags: $,
1426
+ searchKeys: _.searchKeys
1427
+ };
1428
+ }), n = /* @__PURE__ */ new Set();
1429
+ p.forEach((_) => {
1430
+ _.tags && _.tags.forEach(($) => {
1431
+ n.add($);
1432
+ });
1433
+ });
1434
+ const e = n.size > 0 ? [
1435
+ {
1436
+ type: "string",
1437
+ key: "tags",
1438
+ entity: "item",
1439
+ values: Array.from(n)
1440
+ }
1441
+ ] : [], i = p.filter((_) => a.value.find(($) => $.id === _.value.data._id)).map((_) => _.value);
1442
+ r.open({
1443
+ title: c("inventory.closing.form.items.selectItem"),
1444
+ closeButton: !0,
1445
+ contentComponent: bt,
1446
+ contentComponentProps: {
1447
+ modelValue: i,
1448
+ items: p,
1449
+ virtualScroll: !0,
1450
+ filterAttributes: e
1451
+ },
1452
+ primaryActions: {
1453
+ text: c("common.confirm"),
1454
+ close: !0
1455
+ },
1456
+ secondaryActions: {
1457
+ text: c("common.close"),
1458
+ close: !0,
1459
+ variant: "tertiary"
1460
+ }
1461
+ }).onPrimary((_) => {
1462
+ const $ = a.value ?? [], F = _.map((M) => {
1463
+ const E = $.find((N) => N.id === M.data._id);
1464
+ return E ? {
1465
+ ...E
1466
+ } : {
1467
+ id: M.data._id,
1468
+ name: M.name,
1469
+ code: M.description,
1470
+ type: M.type,
1471
+ disabledMeasurements: []
1472
+ };
1473
+ });
1474
+ F.sort((M, E) => M.name.localeCompare(E.name)), console.log(a.value), a.value = F, l("update:modelValue", a.value);
1475
+ });
1476
+ }
1477
+ return (d, x) => {
1478
+ const k = D("FmButton"), p = D("FmIcon"), n = D("FmTextField"), e = D("FmTable"), i = D("FmFormGroup");
1479
+ return I(), A("div", Qt, [
1480
+ g("div", Xt, [
1481
+ g("div", Zt, C(w(c)("inventory.closing.form.items.title")), 1),
1482
+ S(k, {
1483
+ disabled: d.disabled,
1484
+ label: w(c)("inventory.closing.form.items.addItem"),
1485
+ "prepend-icon": "add",
1486
+ variant: "plain",
1487
+ class: "border-2 rounded-lg border-fm-color-primary",
1488
+ onClick: x[0] || (x[0] = (y) => T()),
1489
+ size: "md"
1490
+ }, null, 8, ["disabled", "label"])
1491
+ ]),
1492
+ S(n, {
1493
+ placeholder: "Filter items",
1494
+ modelValue: u.value,
1495
+ "onUpdate:modelValue": x[2] || (x[2] = (y) => u.value = y)
1496
+ }, Le({ _: 2 }, [
1497
+ u.value ? {
1498
+ name: "append",
1499
+ fn: V(() => [
1500
+ S(p, {
1501
+ name: "close",
1502
+ onClick: x[1] || (x[1] = (y) => u.value = ""),
1503
+ class: "cursor-pointer"
1504
+ })
1505
+ ]),
1506
+ key: "0"
1507
+ } : void 0
1508
+ ]), 1032, ["modelValue"]),
1509
+ (I(), U(e, {
1510
+ "search-value": u.value,
1511
+ "column-defs": v.value,
1512
+ "row-data": a.value,
1513
+ key: a.value.map((y) => y.id).join("."),
1514
+ "hide-footer": a.value.length <= 10,
1515
+ "page-size": Math.min(10, a.value.length)
1516
+ }, null, 8, ["search-value", "column-defs", "row-data", "hide-footer", "page-size"])),
1517
+ S(i, {
1518
+ "model-value": a.value.length,
1519
+ rules: [w(yt)(1)]
1520
+ }, null, 8, ["model-value", "rules"])
1521
+ ]);
1522
+ };
1523
+ }
1524
+ }), tn = { class: "flex flex-col gap-16" }, nn = { class: "flex flex-col gap-24" }, on = { class: "flex flex-col gap-16" }, sn = { class: "flex items-center" }, an = { class: "flex-1 fm-typo-en-title-sm-600" }, ln = /* @__PURE__ */ K({
1525
+ __name: "WastageTemplateForm",
1526
+ props: {
1527
+ modelValue: {},
1528
+ disabled: { type: Boolean }
1529
+ },
1530
+ setup(f, { expose: s }) {
1531
+ const m = ht(), { t: h } = G(), {
1532
+ promptSelectLocations: a,
1533
+ columnDefs: c,
1534
+ rowData: l
1535
+ } = gt({
1536
+ getLocations() {
1537
+ return m.locations;
1538
+ },
1539
+ setLocations(r) {
1540
+ m.locations = r;
1541
+ }
1542
+ }), t = R();
1543
+ return s({
1544
+ validateInputs: () => {
1545
+ var r, o;
1546
+ (o = (r = t.value) == null ? void 0 : r.validateInputs) == null || o.call(r);
1547
+ },
1548
+ resetInputsValidation: () => {
1549
+ var r, o;
1550
+ (o = (r = t.value) == null ? void 0 : r.resetInputsValidation) == null || o.call(r);
1551
+ },
1552
+ resetInputs: () => {
1553
+ var r, o;
1554
+ (o = (r = t.value) == null ? void 0 : r.resetInputs) == null || o.call(r);
1555
+ }
1556
+ }), (r, o) => {
1557
+ const u = D("FmTextField"), b = D("FmButton"), v = D("FmTable"), T = D("FmForm");
1558
+ return I(), U(T, {
1559
+ ref_key: "formRef",
1560
+ ref: t,
1561
+ class: "flex flex-col gap-32",
1562
+ disabled: r.disabled
1563
+ }, {
1564
+ default: V(() => [
1565
+ g("div", tn, [
1566
+ g("div", nn, [
1567
+ S(u, {
1568
+ label: w(h)("inventory.closing.form.name"),
1569
+ "label-mark": "required",
1570
+ modelValue: w(m).name,
1571
+ "onUpdate:modelValue": o[0] || (o[0] = (d) => w(m).name = d),
1572
+ rules: [w(Ge)()]
1573
+ }, null, 8, ["label", "modelValue", "rules"])
1574
+ ])
1575
+ ]),
1576
+ g("div", on, [
1577
+ g("div", sn, [
1578
+ g("div", an, C(w(h)("inventory.closing.form.locations")), 1),
1579
+ S(b, {
1580
+ disabled: r.disabled,
1581
+ label: w(h)("inventory.closing.form.selectLocation"),
1582
+ "prepend-icon": "add",
1583
+ variant: "plain",
1584
+ class: "border-2 rounded-lg border-fm-color-primary",
1585
+ onClick: w(a)
1586
+ }, null, 8, ["disabled", "label", "onClick"])
1587
+ ]),
1588
+ S(v, {
1589
+ "column-defs": w(c),
1590
+ "row-data": w(l),
1591
+ "shrink-at": 9999,
1592
+ onRowClick: w(a),
1593
+ "hide-footer": ""
1594
+ }, null, 8, ["column-defs", "row-data", "onRowClick"])
1595
+ ]),
1596
+ S(en, {
1597
+ "model-value": w(m).items,
1598
+ "onUpdate:modelValue": o[1] || (o[1] = (d) => w(m).items = d)
1599
+ }, null, 8, ["model-value"])
1600
+ ]),
1601
+ _: 1
1602
+ }, 8, ["disabled"]);
1603
+ };
1604
+ }
1605
+ }), rn = { class: "flex items-center" }, cn = { class: "fm-typo-en-title-md-600" }, un = { class: "flex justify-between" }, mn = { class: "fm-typo-en-body-lg-600" }, dn = { class: "flex flex-col gap-8" }, pn = { class: "flex flex-col gap-4" }, fn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vn = { class: "flex items-center gap-8" }, yn = { class: "fm-typo-en-body-lg-600" }, hn = { class: "flex gap-4" }, gn = /* @__PURE__ */ K({
1606
+ __name: "WastageTemplateDialog",
1607
+ props: {
1608
+ mode: {},
1609
+ modelValue: {},
1610
+ show: { type: Boolean }
1611
+ },
1612
+ emits: ["update:show", "submitted"],
1613
+ setup(f, { expose: s, emit: m }) {
1614
+ var e;
1615
+ const h = f, a = m, c = te(), l = Z(), { t } = G(), r = Ne(h, "show");
1616
+ function o() {
1617
+ return {
1618
+ _id: "",
1619
+ name: "",
1620
+ type: de.Enum.WASTAGE,
1621
+ items: []
1622
+ };
1623
+ }
1624
+ const u = R(h.modelValue ?? o()), b = R(((e = h.modelValue) == null ? void 0 : e._id) ?? `${Math.random()}`);
1625
+ ve(
1626
+ () => h.show,
1627
+ (i) => {
1628
+ var y;
1629
+ i && (u.value = h.modelValue ?? o(), b.value = ((y = h.modelValue) == null ? void 0 : y._id) ?? `${Math.random()}`);
1630
+ }
1631
+ );
1632
+ const v = R(!1), T = B(() => {
1633
+ switch (h.mode) {
1634
+ case J.READ:
1635
+ return "";
1636
+ case J.CREATE:
1637
+ return t("inventory.adjustment.template.create.title");
1638
+ case J.UPDATE:
1639
+ return t("inventory.adjustment.template.update.title");
1640
+ }
1641
+ return "";
1642
+ }), d = R();
1643
+ s({
1644
+ validateInputs: () => {
1645
+ var i, y;
1646
+ (y = (i = d.value) == null ? void 0 : i.validateInputs) == null || y.call(i);
1647
+ },
1648
+ resetInputsValidation: () => {
1649
+ var i, y;
1650
+ (y = (i = d.value) == null ? void 0 : i.resetInputsValidation) == null || y.call(i);
1651
+ },
1652
+ resetInputs: () => {
1653
+ var i, y;
1654
+ (y = (i = d.value) == null ? void 0 : i.resetInputs) == null || y.call(i);
1655
+ }
1656
+ });
1657
+ async function x() {
1658
+ const i = u.value;
1659
+ if (i) {
1660
+ v.value = !0;
1661
+ try {
1662
+ await c.createTemplate(i), await new Promise((y) => setTimeout(y, 1e3)), l.open({
1663
+ title: t("inventory.adjustment.template.create.success"),
1664
+ message: t("inventory.adjustment.template.create.successMessage"),
1665
+ type: "success"
1666
+ }), a("update:show", !1), a("submitted");
1667
+ } catch (y) {
1668
+ l.open({
1669
+ title: t("inventory.adjustment.template.create.error"),
1670
+ message: t("inventory.adjustment.template.create.errorMessage"),
1671
+ type: "error"
1672
+ }), console.error("Error in creating adjustment template", y);
1673
+ } finally {
1674
+ v.value = !1;
1675
+ }
1676
+ }
1677
+ }
1678
+ async function k() {
1679
+ const i = u.value;
1680
+ if (i) {
1681
+ v.value = !0;
1682
+ try {
1683
+ await c.updateTemplate({
1684
+ ...i,
1685
+ _rev: i._rev ?? ""
1686
+ }), await new Promise((y) => setTimeout(y, 1e3)), l.open({
1687
+ title: t("inventory.adjustment.template.update.success"),
1688
+ message: t("inventory.adjustment.template.update.successMessage"),
1689
+ type: "success"
1690
+ }), a("update:show", !1), a("submitted");
1691
+ } catch (y) {
1692
+ l.open({
1693
+ title: t("inventory.adjustment.template.update.error"),
1694
+ message: t("inventory.adjustment.template.update.errorMessage"),
1695
+ type: "error"
1696
+ }), console.error("Error in updating adjustment template", y);
1697
+ } finally {
1698
+ v.value = !1;
1699
+ }
1700
+ }
1701
+ }
1702
+ function p() {
1703
+ switch (h.mode) {
1704
+ case J.CREATE:
1705
+ return x();
1706
+ case J.UPDATE:
1707
+ return k();
1708
+ }
1709
+ }
1710
+ function n() {
1711
+ var i, y;
1712
+ (y = (i = d.value) == null ? void 0 : i.validateInputs) == null || y.call(i);
1713
+ }
1714
+ return (i, y) => {
1715
+ const _ = D("FmMenuDivider"), $ = D("FmCard"), F = D("FmButton"), M = D("FmSideSheet");
1716
+ return I(), U(M, {
1717
+ modelValue: w(r),
1718
+ "onUpdate:modelValue": y[2] || (y[2] = (E) => Ue(r) ? r.value = E : null),
1719
+ "dismiss-away": "",
1720
+ "close-button": "",
1721
+ "max-width": 800
1722
+ }, {
1723
+ "side-sheet-header": V(() => [
1724
+ g("div", rn, [
1725
+ g("div", cn, C(T.value), 1)
1726
+ ])
1727
+ ]),
1728
+ default: V(() => [
1729
+ u.value.updatedAt ? (I(), A(Y, { key: 0 }, [
1730
+ u.value.updatedAt ? (I(), U($, {
1731
+ key: 0,
1732
+ variant: "outlined",
1733
+ class: "flex flex-col gap-8 px-12 py-16 mb-16"
1734
+ }, {
1735
+ default: V(() => {
1736
+ var E;
1737
+ return [
1738
+ g("div", un, [
1739
+ g("div", mn, C(w(t)("inventory.transfer.template.details.templateSummary")), 1)
1740
+ ]),
1741
+ S(_),
1742
+ g("div", dn, [
1743
+ g("div", pn, [
1744
+ g("div", fn, C(w(t)("inventory.transfer.receiveRequest.details.updatedAt")), 1),
1745
+ g("div", vn, [
1746
+ g("div", yn, [
1747
+ me(C(w(ue)(u.value.updatedAt)) + " ", 1),
1748
+ (E = u.value.updatedBy) != null && E.name ? (I(), A(Y, { key: 0 }, [
1749
+ me(" (" + C(u.value.updatedBy.name) + ") ", 1)
1750
+ ], 64)) : z("", !0)
1751
+ ]),
1752
+ S(_t, {
1753
+ "adjustment-id": u.value._id
1754
+ }, null, 8, ["adjustment-id"])
1755
+ ])
1756
+ ])
1757
+ ])
1758
+ ];
1759
+ }),
1760
+ _: 1
1761
+ })) : z("", !0)
1762
+ ], 64)) : z("", !0),
1763
+ (I(), U(ln, {
1764
+ class: "w-full",
1765
+ ref_key: "formRef",
1766
+ ref: d,
1767
+ onValidationSuccess: p,
1768
+ "model-value": u.value,
1769
+ "onUpdate:modelValue": y[0] || (y[0] = (E) => u.value = E),
1770
+ disabled: v.value,
1771
+ key: b.value
1772
+ }, null, 8, ["model-value", "disabled"]))
1773
+ ]),
1774
+ "side-sheet-footer": V(() => [
1775
+ g("div", hn, [
1776
+ S(F, {
1777
+ loading: v.value,
1778
+ label: w(t)("common.save"),
1779
+ onClick: n
1780
+ }, null, 8, ["loading", "label"]),
1781
+ S(F, {
1782
+ disabled: v.value,
1783
+ variant: "tertiary",
1784
+ label: w(t)("common.close"),
1785
+ onClick: y[1] || (y[1] = (E) => a("update:show", !1))
1786
+ }, null, 8, ["disabled", "label"])
1787
+ ])
1788
+ ]),
1789
+ _: 1
1790
+ }, 8, ["modelValue"]);
1791
+ };
1792
+ }
1793
+ }), bn = {};
1794
+ function _n(f, s) {
1795
+ return I(), A("div");
1796
+ }
1797
+ const xn = /* @__PURE__ */ xt(bn, [["render", _n]]), wn = { class: "flex flex-col gap-40" }, Tn = { key: 0 }, kn = {
1798
+ key: 1,
1799
+ class: "flex gap-8 items-center"
1800
+ }, $n = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, In = {
1801
+ key: 2,
1802
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
1803
+ }, Sn = {
1804
+ key: 3,
1805
+ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
1806
+ }, Fn = { class: "fm-typo-en-body-md-600" }, Cn = { class: "fm-typo-en-body-md-600" }, An = { key: 4 }, Mn = { class: "fm-typo-en-body-md-600" }, Rn = { class: "fm-typo-en-body-md-600" }, Dn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, En = /* @__PURE__ */ K({
1807
+ __name: "WastageTemplatePublish",
1808
+ emits: ["close"],
1809
+ setup(f, { emit: s }) {
1810
+ const m = R(!1), h = Z(), a = te(), c = ne(), { t: l } = G(), t = s;
1811
+ async function r() {
1812
+ m.value = !0;
1813
+ try {
1814
+ await a.startNewPublish().delayed(1e3), h.open({
1815
+ title: "Success",
1816
+ message: "You may refresh after a while to review publish status",
1817
+ type: "success"
1818
+ }), b();
1819
+ } catch (v) {
1820
+ h.open({
1821
+ title: "Something went wrong",
1822
+ message: "Please try again",
1823
+ type: "error"
1824
+ }), console.error("error on creating publish task", v);
1825
+ } finally {
1826
+ m.value = !1;
1827
+ }
1828
+ }
1829
+ const o = B(() => c.recentPublish.recentJob), u = B(
1830
+ () => c.templates.length && (!o.value || o.value.outlets.length === o.value.completed.length)
1831
+ );
1832
+ function b() {
1833
+ t("close");
1834
+ }
1835
+ return (v, T) => {
1836
+ const d = D("FmCircularProgress"), x = D("i18n-t"), k = D("FmButton");
1837
+ return I(), A("div", wn, [
1838
+ w(c).templates.length ? m.value ? (I(), A("div", kn, [
1839
+ g("div", null, [
1840
+ S(d, {
1841
+ size: "md",
1842
+ color: "neutral-gray-300"
1843
+ })
1844
+ ]),
1845
+ g("div", $n, [
1846
+ g("span", null, C(w(l)("inventory.adjustment.template.publish.publishing")), 1)
1847
+ ])
1848
+ ])) : o.value ? o.value.outlets.length === o.value.completed.length ? (I(), A("div", Sn, [
1849
+ S(x, {
1850
+ keypath: "inventory.adjustment.template.publish.recentlyPublishedAt",
1851
+ tag: "p"
1852
+ }, {
1853
+ started: V(() => [
1854
+ g("span", Fn, C(w(ue)(new Date(o.value.createdAt))), 1)
1855
+ ]),
1856
+ finished: V(() => [
1857
+ g("span", Cn, C(w(ue)(new Date(o.value.updatedAt))), 1)
1858
+ ]),
1859
+ _: 1
1860
+ }),
1861
+ g("p", null, C(w(l)("inventory.adjustment.template.publish.message")), 1)
1862
+ ])) : (I(), A("div", An, [
1863
+ S(x, {
1864
+ keypath: "inventory.adjustment.template.publish.stillPublishing",
1865
+ tag: "p"
1866
+ }, {
1867
+ started: V(() => [
1868
+ g("span", Mn, C(w(ue)(new Date(o.value.createdAt))), 1)
1869
+ ]),
1870
+ progress: V(() => [
1871
+ g("span", Rn, " (" + C(o.value.completed.length) + "/" + C(o.value.outlets.length) + " completed) ", 1)
1872
+ ]),
1873
+ _: 1
1874
+ }),
1875
+ me(" Your recent publishing task is still pending (" + C(o.value.completed.length) + " / " + C(o.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
1876
+ ])) : (I(), A("div", In, [
1877
+ g("p", null, C(w(l)("inventory.adjustment.template.publish.noRecentActivity")), 1),
1878
+ g("p", null, C(w(l)("inventory.adjustment.template.publish.message")), 1)
1879
+ ])) : (I(), A("div", Tn, [
1880
+ g("p", null, C(w(l)("inventory.adjustment.template.publish.nothingToPublish")), 1)
1881
+ ])),
1882
+ g("div", Dn, [
1883
+ S(k, {
1884
+ disabled: !u.value,
1885
+ loading: m.value,
1886
+ label: "Publish to all outlets",
1887
+ onClick: r
1888
+ }, null, 8, ["disabled", "loading"]),
1889
+ S(k, {
1890
+ variant: "tertiary",
1891
+ label: "Close",
1892
+ onClick: b
1893
+ })
1894
+ ])
1895
+ ]);
1896
+ };
1897
+ }
1898
+ }), Pn = { class: "flex flex-col gap-16" }, Vn = { class: "flex" }, jn = { class: "flex gap-24" }, Ln = { class: "flex" }, Un = { class: "flex-1" }, Bn = { class: "flex" }, Nn = { class: "flex gap-8 items-center justify-start" }, zn = /* @__PURE__ */ K({
1899
+ __name: "WastageTemplateReason",
1900
+ props: {
1901
+ show: { type: Boolean }
1902
+ },
1903
+ emits: ["update:show", "submitted"],
1904
+ setup(f, { emit: s }) {
1905
+ const m = f, h = Ne(m, "show"), a = R(""), c = Z(), l = X(), t = R([]), r = s, o = ne(), u = te(), b = R(!1);
1906
+ ve(
1907
+ () => m.show,
1908
+ (p) => {
1909
+ var n;
1910
+ p && (t.value = ((n = o.reasons) == null ? void 0 : n.value) ?? []);
1911
+ }
1912
+ );
1913
+ const v = (p) => {
1914
+ if (t.value.indexOf(t.value[p]) === -1)
1915
+ return;
1916
+ const n = t.value[p];
1917
+ if (n.trim() === "") {
1918
+ t.value.splice(p, 1);
1919
+ return;
1920
+ }
1921
+ l.open({
1922
+ title: "Delete reason",
1923
+ message: `Are you sure you want to delete this reason? "${n}"`,
1924
+ primaryActions: {
1925
+ text: "Delete",
1926
+ close: !0,
1927
+ variant: "destructive"
1928
+ },
1929
+ secondaryActions: {
1930
+ text: "Cancel",
1931
+ close: !0,
1932
+ variant: "secondary"
1933
+ }
1934
+ }).onPrimary(() => {
1935
+ t.value.splice(p, 1);
1936
+ });
1937
+ }, T = () => {
1938
+ t.value.push("");
1939
+ const p = a.value.trim();
1940
+ if (p) {
1941
+ if (t.value.some((n) => n === p)) {
1942
+ c.open({
1943
+ title: "Reason already exists",
1944
+ message: "Please enter a different reason",
1945
+ type: "error"
1946
+ });
1947
+ return;
1948
+ }
1949
+ a.value = "";
1950
+ }
1951
+ }, d = async () => {
1952
+ const p = t.value.map((n) => n.trim()).filter((n) => n);
1953
+ if (o.reasons) {
1954
+ b.value = !0;
1955
+ try {
1956
+ await u.update({
1957
+ _id: o.reasons._id,
1958
+ _rev: o.reasons._rev,
1959
+ value: p
1960
+ }), c.open({
1961
+ title: "Reasons updated",
1962
+ message: "Reasons have been updated successfully",
1963
+ type: "success"
1964
+ }), r("update:show", !1), r("submitted");
1965
+ } catch {
1966
+ c.open({
1967
+ title: "Error updating reasons",
1968
+ message: "There was an error updating reasons",
1969
+ type: "error"
1970
+ });
1971
+ } finally {
1972
+ b.value = !1;
1973
+ }
1974
+ }
1975
+ }, x = R(), k = () => {
1976
+ var p, n;
1977
+ (n = (p = x.value) == null ? void 0 : p.validateInputs) == null || n.call(p);
1978
+ };
1979
+ return (p, n) => {
1980
+ const e = D("FmButton"), i = D("FmAvatar"), y = D("FmTextField"), _ = D("FmList"), $ = D("FmForm"), F = D("FmSideSheet");
1981
+ return I(), U(F, {
1982
+ modelValue: w(h),
1983
+ "onUpdate:modelValue": n[0] || (n[0] = (M) => Ue(h) ? h.value = M : null),
1984
+ header: "Reason for wastage",
1985
+ "close-button": "",
1986
+ "dismiss-away": !b.value,
1987
+ "max-width": 500
1988
+ }, {
1989
+ default: V(() => [
1990
+ S($, {
1991
+ ref_key: "formRef",
1992
+ ref: x,
1993
+ class: "flex flex-col gap-32",
1994
+ blameFormChildOnValidationFailed: "",
1995
+ onValidationSuccess: d
1996
+ }, {
1997
+ default: V(() => [
1998
+ g("div", Pn, [
1999
+ g("div", Vn, [
2000
+ S(e, {
2001
+ class: "ml-auto px-5",
2002
+ variant: "primary",
2003
+ label: "Add new reason",
2004
+ size: "md",
2005
+ onClick: T
2006
+ })
2007
+ ])
2008
+ ]),
2009
+ g("div", jn, [
2010
+ S(_, {
2011
+ class: "w-full",
2012
+ separator: ""
2013
+ }, {
2014
+ default: V(() => [
2015
+ (I(!0), A(Y, null, Q(t.value, (M, E) => (I(), A("div", {
2016
+ key: E,
2017
+ class: "flex items-center gap-8 px-1 py-2"
2018
+ }, [
2019
+ g("div", Ln, [
2020
+ S(i, {
2021
+ initials: String(E + 1),
2022
+ size: "sm"
2023
+ }, null, 8, ["initials"])
2024
+ ]),
2025
+ g("div", Un, [
2026
+ S(y, {
2027
+ class: "cursor-pointer text-fm-color-typo-tertiary",
2028
+ modelValue: t.value[E],
2029
+ "onUpdate:modelValue": (q) => t.value[E] = q,
2030
+ maxLength: 500,
2031
+ rules: [w(Ge)()]
2032
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "rules"])
2033
+ ]),
2034
+ g("div", Bn, [
2035
+ S(e, {
2036
+ variant: "tertiary",
2037
+ size: "md",
2038
+ "prepend-icon": "delete",
2039
+ onClick: (q) => v(E)
2040
+ }, null, 8, ["onClick"])
2041
+ ])
2042
+ ]))), 128))
2043
+ ]),
2044
+ _: 1
2045
+ })
2046
+ ])
2047
+ ]),
2048
+ _: 1
2049
+ }, 512)
2050
+ ]),
2051
+ "side-sheet-footer": V(() => [
2052
+ g("div", Nn, [
2053
+ S(e, {
2054
+ variant: "primary",
2055
+ label: "Save",
2056
+ size: "lg",
2057
+ onClick: k,
2058
+ disabled: b.value,
2059
+ loading: b.value
2060
+ }, null, 8, ["disabled", "loading"]),
2061
+ S(e, {
2062
+ variant: "secondary",
2063
+ label: "Close",
2064
+ size: "lg"
2065
+ })
2066
+ ])
2067
+ ]),
2068
+ _: 1
2069
+ }, 8, ["modelValue", "dismiss-away"]);
2070
+ };
2071
+ }
2072
+ }), On = { class: "flex items-center gap-5" }, Wn = { class: "flex items-center gap-2" }, Hn = { class: "flex-1 flex flex-col gap-8" }, Yn = { class: "flex flex-col" }, Kn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Gn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Jn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, xo = /* @__PURE__ */ K({
2073
+ __name: "WastageTemplateView",
2074
+ setup(f) {
2075
+ const { t: s } = G(), { createTemplate: m, updateTemplate: h, exportTemplates: a, importTemplates: c, viewReason: l } = fe(), { templateDialogProps: t, templateDetailsProps: r, templateReasonProps: o } = Oe(
2076
+ fe()
2077
+ ), u = ye(), b = X(), v = ne(), T = tt(), { breakpoints: d } = at();
2078
+ u.watchLocation(v.fetchTemplates);
2079
+ const x = B(() => v.loading), k = R(""), p = B(() => d.value.xs || d.value.sm), n = B(() => p.value ? 10 : 20);
2080
+ function e(F) {
2081
+ switch (F) {
2082
+ case L.Add:
2083
+ return m();
2084
+ case "publish":
2085
+ return i();
2086
+ case "import":
2087
+ return c();
2088
+ case "export":
2089
+ return a();
2090
+ case "refresh":
2091
+ return v.fetchTemplates();
2092
+ }
2093
+ }
2094
+ function i() {
2095
+ b.open({
2096
+ title: "Publish wastage templates",
2097
+ contentComponent: En,
2098
+ contentComponentProps: {
2099
+ onClose() {
2100
+ b.close();
2101
+ }
2102
+ }
2103
+ });
2104
+ }
2105
+ function y(F) {
2106
+ return F;
2107
+ }
2108
+ const _ = B(() => p.value ? [
2109
+ {
2110
+ label: s("inventory.adjustment.template.create.title"),
2111
+ value: L.Add,
2112
+ isPrimary: !0,
2113
+ prependIcon: "add"
2114
+ },
2115
+ {
2116
+ label: s("inventory.common.refresh"),
2117
+ value: "refresh",
2118
+ isPrimary: !1
2119
+ },
2120
+ {
2121
+ label: s("inventory.common.publish"),
2122
+ value: "publish",
2123
+ isPrimary: !1
2124
+ },
2125
+ {
2126
+ label: s("inventory.common.import"),
2127
+ value: "import",
2128
+ isPrimary: !1
2129
+ },
2130
+ {
2131
+ label: s("inventory.common.export"),
2132
+ value: "export",
2133
+ isPrimary: !1
2134
+ }
2135
+ ] : [
2136
+ {
2137
+ label: s("inventory.adjustment.template.create.title"),
2138
+ value: L.Add,
2139
+ isPrimary: !0,
2140
+ prependIcon: "add"
2141
+ },
2142
+ {
2143
+ label: s("inventory.common.publish"),
2144
+ value: "publish",
2145
+ isPrimary: !1
2146
+ },
2147
+ {
2148
+ label: s("inventory.common.import"),
2149
+ value: "import",
2150
+ isPrimary: !1
2151
+ },
2152
+ {
2153
+ label: s("inventory.common.refresh"),
2154
+ value: "refresh",
2155
+ isPrimary: !1
2156
+ },
2157
+ {
2158
+ label: s("inventory.common.export"),
2159
+ value: "export",
2160
+ isPrimary: !1
2161
+ }
2162
+ ]), $ = () => {
2163
+ l();
2164
+ };
2165
+ return (F, M) => {
2166
+ const E = D("FmButton"), q = D("FmTable");
2167
+ return I(), A(Y, null, [
2168
+ S(nt, {
2169
+ title: w(s)("inventory.adjustment.template.wastage.title"),
2170
+ actions: _.value,
2171
+ "onClick:action": e
2172
+ }, {
2173
+ default: V(() => [
2174
+ g("div", {
2175
+ class: H([
2176
+ "flex flex-col gap-8 max-h-full",
2177
+ {
2178
+ "p-0": p.value,
2179
+ "px-24 ": !p.value
2180
+ }
2181
+ ])
2182
+ }, [
2183
+ g("div", On, [
2184
+ S(E, {
2185
+ class: "ml-auto",
2186
+ "prepend-icon": "edit",
2187
+ key: "Reason for wastage",
2188
+ label: "Default label",
2189
+ "bg-color": "neutral-gray-100",
2190
+ "text-color": "neutral-gray-400",
2191
+ onClick: $
2192
+ }, {
2193
+ default: V(() => [
2194
+ g("div", Wn, [
2195
+ M[4] || (M[4] = g("span", null, "Reasons", -1)),
2196
+ g("div", {
2197
+ class: H([
2198
+ "fm-status-badge",
2199
+ w(v).isReasonPublished() ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
2200
+ ])
2201
+ }, C(w(v).isReasonPublished() ? "Published" : "Unpublished"), 3)
2202
+ ])
2203
+ ]),
2204
+ _: 1
2205
+ }),
2206
+ S(ot, {
2207
+ class: "flex-1",
2208
+ searchable: "",
2209
+ search: k.value,
2210
+ "onUpdate:search": M[0] || (M[0] = (N) => k.value = N)
2211
+ }, null, 8, ["search"])
2212
+ ]),
2213
+ S(q, {
2214
+ style: Qe(w(T).tableHeight),
2215
+ "column-defs": w(v).columnDefs,
2216
+ "row-data": w(v).templates,
2217
+ "search-value": k.value,
2218
+ loading: x.value,
2219
+ onRowClick: M[1] || (M[1] = (N) => w(h)(N.original)),
2220
+ "page-size": n.value
2221
+ }, {
2222
+ "list-row": V((N) => [
2223
+ S(rt, {
2224
+ row: N,
2225
+ onRowClick: (O) => w(h)(O)
2226
+ }, {
2227
+ default: V((O) => {
2228
+ var ge, be, _e, oe, xe, we, Te, ke, se, $e, Ie, Se, Fe, Ce, Ae, ae, Me, Re, De, Ee, le, Pe;
2229
+ return [
2230
+ g("div", Hn, [
2231
+ g("div", Yn, [
2232
+ g("div", Kn, [
2233
+ S(w(ce), {
2234
+ render: (_e = (be = (ge = O._id) == null ? void 0 : ge.column) == null ? void 0 : be.columnDef) == null ? void 0 : _e.cell,
2235
+ props: (xe = (oe = O._id) == null ? void 0 : oe.getContext) == null ? void 0 : xe.call(oe)
2236
+ }, null, 8, ["render", "props"])
2237
+ ]),
2238
+ g("div", Gn, [
2239
+ S(w(ce), {
2240
+ render: (ke = (Te = (we = O.name) == null ? void 0 : we.column) == null ? void 0 : Te.columnDef) == null ? void 0 : ke.cell,
2241
+ props: ($e = (se = O.name) == null ? void 0 : se.getContext) == null ? void 0 : $e.call(se)
2242
+ }, null, 8, ["render", "props"])
2243
+ ]),
2244
+ g("div", null, C((Ie = N.original.locations) != null && Ie.length ? w(s)("inventory.adjustment.template.table.enabledForN", {
2245
+ count: ((Se = N.original.locations) == null ? void 0 : Se.length) ?? 0
2246
+ }) : w(s)("inventory.adjustment.template.table.enabledForAll")), 1),
2247
+ M[5] || (M[5] = g("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, null, -1)),
2248
+ g("div", Jn, [
2249
+ S(w(ce), {
2250
+ render: (Ae = (Ce = (Fe = O.ref) == null ? void 0 : Fe.column) == null ? void 0 : Ce.columnDef) == null ? void 0 : Ae.cell,
2251
+ props: (Me = (ae = O.ref) == null ? void 0 : ae.getContext) == null ? void 0 : Me.call(ae)
2252
+ }, null, 8, ["render", "props"])
2253
+ ])
2254
+ ]),
2255
+ g("div", null, [
2256
+ S(w(ce), {
2257
+ render: (Ee = (De = (Re = O.status) == null ? void 0 : Re.column) == null ? void 0 : De.columnDef) == null ? void 0 : Ee.cell,
2258
+ props: (Pe = (le = O.status) == null ? void 0 : le.getContext) == null ? void 0 : Pe.call(le)
2259
+ }, null, 8, ["render", "props"])
2260
+ ])
2261
+ ])
2262
+ ];
2263
+ }),
2264
+ _: 2
2265
+ }, 1032, ["row", "onRowClick"])
2266
+ ]),
2267
+ _: 1
2268
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
2269
+ ], 2)
2270
+ ]),
2271
+ _: 1
2272
+ }, 8, ["title", "actions"]),
2273
+ (I(), U(Xe, { to: "body" }, [
2274
+ S(xn, Ze(et(w(r))), null, 16),
2275
+ S(gn, Ve(w(t), {
2276
+ onSubmitted: M[2] || (M[2] = (N) => w(v).fetchTemplates())
2277
+ }), null, 16),
2278
+ S(zn, Ve(w(o), {
2279
+ onSubmitted: M[3] || (M[3] = (N) => w(v).fetchTemplates())
2280
+ }), null, 16)
2281
+ ]))
2282
+ ], 64);
2283
+ };
2284
+ }
2285
+ });
2286
+ export {
2287
+ xo as default
2288
+ };