@feedmepos/mf-inventory-portal 1.2.64 → 1.2.66-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 (142) hide show
  1. package/dist/{App-apJIvz1w.js → App-BUNonuLz.js} +82 -78
  2. package/dist/{ApprovalView-CnT6gEI8.js → ApprovalView-BlS1tfbh.js} +6 -6
  3. package/dist/{BindingsDialog-DLEGDbV2.js → BindingsDialog-tRpsVTm0.js} +5 -5
  4. package/dist/{BindingsPicker-1Xt1vCu9.js → BindingsPicker-CUvkqcAG.js} +3 -3
  5. package/dist/{BindingsTable-_0cOM0Kx.js → BindingsTable-B86pWYMk.js} +5 -5
  6. package/dist/{ClosingDraftView-DsVPsN87.js → ClosingDraftView-gMVnQcWw.js} +226 -224
  7. package/dist/ClosingHistoryView-DhbE1pEl.js +1147 -0
  8. package/dist/{ClosingTemplateView-DB3F1wul.js → ClosingTemplateView-Ywbdj05y.js} +15 -15
  9. package/dist/{DeliveryOrderPrintPreview-CglCMgHc.js → DeliveryOrderPrintPreview-BPhVNc_r.js} +7 -7
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-MMPTJodu.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BrPh_Nvx.js} +16 -16
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CCID5O2Y.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CkUwLhut.js} +3 -3
  12. package/dist/{FmMultiselectDialog-B8xFmCsH.js → FmMultiselectDialog-C6E_KMFO.js} +1 -1
  13. package/dist/{FmMultiselectDialog-lQM1qEEW.js → FmMultiselectDialog-DBXpkw5b.js} +16 -16
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BLDz8wwK.js → FmUnitInput.vue_vue_type_script_setup_true_lang-D-ZqJ8sU.js} +23 -22
  15. package/dist/{ImportView-DeC-MPFn.js → ImportView-DV1e51qk.js} +7 -7
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-BGDZlmsr.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DkQL7hK2.js} +1 -1
  17. package/dist/{IngredientGroupView-CuFwQ8Bo.js → IngredientGroupView-CdXGO34J.js} +6 -6
  18. package/dist/{IngredientsView-CfloqEqn.js → IngredientsView-D2qffNiJ.js} +26 -25
  19. package/dist/{IntegrationView-CFU0yG6C.js → IntegrationView-RFJIHXQv.js} +19 -18
  20. package/dist/{InventoryBindingForm-i7eNurS2.js → InventoryBindingForm-CPn-IXgg.js} +1 -1
  21. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-zOo9YVJe.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-0Vrih8D5.js} +17 -16
  22. package/dist/{InventoryBindingSummary-BbHLCdjj.js → InventoryBindingSummary-B_WUQ6By.js} +1 -1
  23. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NEPqmkHR.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BmDuR4Yb.js} +5 -5
  24. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-DhIHSpzG.js +93 -0
  25. package/dist/{PublishView-CbwCLtph.js → PublishView-BtTSOUyL.js} +9 -9
  26. package/dist/{PurchaseOrderPrintPreview-DLhgjhHB.js → PurchaseOrderPrintPreview-CxhMPx5u.js} +11 -11
  27. package/dist/{ReceiveRequestView-CE2aQR-o.js → ReceiveRequestView-CsqEjf7r.js} +144 -142
  28. package/dist/RecipeView-DASoba97.js +1558 -0
  29. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-mvRR4CrP.js +254 -0
  30. package/dist/StockView-B4Km4DgB.js +2395 -0
  31. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-D0BDdq4d.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cki-LAZR.js} +1 -1
  32. package/dist/{SupplierView-wSzWjZLY.js → SupplierView-CrzFvBIx.js} +21 -20
  33. package/dist/{SurchargeView-G8OyE60y.js → SurchargeView-BoNWpxFY.js} +7 -7
  34. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CROQL761.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-Dcp5vZPM.js} +3 -3
  35. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-IAknr-ye.js +292 -0
  36. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D1AGDeEP.js → TransferDetails.vue_vue_type_script_setup_true_lang-D9aNX0oM.js} +131 -130
  37. package/dist/{TransferTemplateView-CVfi8jsk.js → TransferTemplateView-DwIU0paO.js} +23 -22
  38. package/dist/UnitCostHistoryView-Bjs4RwyR.js +651 -0
  39. package/dist/UnitDisplayControl.vue_vue_type_script_setup_true_lang-BH0PxivU.js +137 -0
  40. package/dist/{UnitView-Dn3nuQHm.js → UnitView-BbQ0jOgS.js} +12 -10
  41. package/dist/{WarehouseView-GSxQ_Ev2.js → WarehouseView-DzPttKzE.js} +6 -6
  42. package/dist/WastageTemplateView-CxyZz5JC.js +2327 -0
  43. package/dist/api/adjustment-template.d.ts +1 -0
  44. package/dist/api/closing.d.ts +2 -0
  45. package/dist/api/inventory.d.ts +126 -36
  46. package/dist/api/netsuite.d.ts +8 -1
  47. package/dist/api/stock.d.ts +5 -1
  48. package/dist/api/unit-cost-history.d.ts +28 -0
  49. package/dist/{app-CYbiMVcX.js → app-EoCCjoRh.js} +9021 -7945
  50. package/dist/app.d.ts +236 -0
  51. package/dist/app.js +1 -1
  52. package/dist/{closing-template-Dq16W8vW.js → closing-template-O_hzhisU.js} +5 -1
  53. package/dist/components/TemplatePublishDialog.d.ts +1 -0
  54. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +37 -1
  55. package/dist/components/shell/inventory/binding-dialog.vue.d.ts +14 -0
  56. package/dist/components/shell/inventory/binding-ui.vue.d.ts +16 -1
  57. package/dist/{date2-De3BHKh5.js → date2-CTHKdfXp.js} +1 -1
  58. package/dist/{dayjs.min-DxdfVXA-.js → dayjs.min-Ccv4NdEp.js} +16 -16
  59. package/dist/decimal-tRyklLh0.js +99 -0
  60. package/dist/{defineDeepModel-2n_afItE.js → defineDeepModel-rmOd66to.js} +1 -1
  61. package/dist/{duplicate-template-DM7YIgor.js → duplicate-template-k8Erwdzo.js} +1 -1
  62. package/dist/export-TmaGpV98.js +25 -0
  63. package/dist/{feature-_nNpSZuh.js → feature-D4-lt7R6.js} +94 -89
  64. package/dist/{format-time-from-id-D5HSMsS-.js → format-time-from-id-Cru7cG1h.js} +1 -1
  65. package/dist/{format-unit-display-CQUFDxVm.js → format-unit-display-DZDD796a.js} +16 -15
  66. package/dist/{import-export.helper-BoxczUsX.js → import-export.helper-BjzXGudc.js} +16 -15
  67. package/dist/{index-B6nDUCCe.js → index-BeEz64I1.js} +3 -3
  68. package/dist/{index-Cp_mpu5S.js → index-DKCY6354.js} +1471 -1412
  69. package/dist/{index-CdfF5GGW.js → index-gGbN4qbt.js} +1 -1
  70. package/dist/{lodash-2R7Rgorb.js → lodash-BSCFf0k7.js} +1 -1
  71. package/dist/{netsuite-Bss4fURp.js → netsuite-DwoCq3Mv.js} +92 -92
  72. package/dist/number-CEUoMyIk.js +138 -0
  73. package/dist/{purchase-order-template-CBSvv0b2.js → purchase-order-template-DWTdjo9l.js} +1 -1
  74. package/dist/router/name.d.ts +1 -0
  75. package/dist/rules-CyW1Bx31.js +98 -0
  76. package/dist/{stock-DMX_hH5c.js → stock-DYWJ4DZW.js} +28 -27
  77. package/dist/stock-Ds3GNgHG.js +75 -0
  78. package/dist/stores/feature.d.ts +2 -0
  79. package/dist/stores/integration/netsuite.d.ts +8 -1
  80. package/dist/stores/inventory.d.ts +120 -30
  81. package/dist/{supplier-Cf5HW15s.js → supplier-DwUb1oVo.js} +2 -2
  82. package/dist/{surcharge-CyReT8lG.js → surcharge-UTJFNBLN.js} +1 -1
  83. package/dist/tsconfig.app.tsbuildinfo +1 -1
  84. package/dist/{use-ingredient-select-dialog-BCyydlHR.js → use-ingredient-select-dialog-D8A3bPTe.js} +2 -2
  85. package/dist/{use-inventory-binding-dialog-WGQs-_2i.js → use-inventory-binding-dialog-DFmiAQ9d.js} +2 -2
  86. package/dist/{use-template-enabled-locations-2-B0nlqUjb.js → use-template-enabled-locations-2-snlITfW8.js} +2 -2
  87. package/dist/views/adjustment-template/wastage-template/table.d.ts +10 -1
  88. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +68 -12
  89. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +204 -36
  90. package/dist/views/closing-history/ClosingDetailDialog.vue.d.ts +23 -0
  91. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +8 -1
  92. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +96 -12
  93. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +96 -12
  94. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +18 -18
  95. package/dist/views/ingredients/components/convert/ConvertForm.vue.d.ts +14 -0
  96. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +32 -4
  97. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +28 -0
  98. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +169 -0
  99. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingAlternative.vue.d.ts +43 -0
  100. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryBindingRule.vue.d.ts +25 -0
  101. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +125 -0
  102. package/dist/views/ingredients/components/inventory-binding/v2/components/InventorySkuBindingV2Field.vue.d.ts +129 -0
  103. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-alternative-table.d.ts +30 -0
  104. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +4 -0
  105. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +8 -1
  106. package/dist/views/integration/components/netsuite/InventoryTransferIngredientTable.vue.d.ts +16 -2
  107. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +33 -5
  108. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +16 -2
  109. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +32 -4
  110. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +8 -1
  111. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +41 -6
  112. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +246 -36
  113. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +287 -42
  114. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +16 -0
  115. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -0
  116. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +16 -2
  117. package/dist/views/stock/components/dialog/SnapshotRecalculationDialog.vue.d.ts +11 -0
  118. package/dist/views/stock/components/dialog/recalculationUtils.d.ts +16 -0
  119. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +16 -2
  120. package/dist/views/transfer-template/components/transfer-template-form/components/NetSuiteCustomCodeSelection.vue.d.ts +16 -2
  121. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItemTable.vue.d.ts +16 -2
  122. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +8 -1
  123. package/dist/views/transfer-template/composables/use-netsuite-custom-field.d.ts +24 -3
  124. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +96 -12
  125. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +96 -12
  126. package/dist/views/unit-cost-history/UnitCostHistoryView.vue.d.ts +2 -0
  127. package/dist/views/unit-cost-history/components/UnitCostDetailsSideSheet.vue.d.ts +19 -0
  128. package/dist/views/unit-cost-history/components/UnitCostRecalculationDialog.vue.d.ts +11 -0
  129. package/dist/views/unit-cost-history/composables/use-unit-cost-history.d.ts +65 -0
  130. package/dist/{vue-i18n-DwS_fjo9.js → vue-i18n-CY4442Fb.js} +510 -510
  131. package/dist/{xlsx-9MOvXxhT.js → xlsx-Kc1XotGV.js} +1 -1
  132. package/dist/{xlsx.util-D1DdGA1N.js → xlsx.util-Dy4jmPyv.js} +1 -1
  133. package/package.json +1 -1
  134. package/dist/ClosingHistoryView-YrEVWvGu.js +0 -447
  135. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BDVHkTSE.js +0 -116
  136. package/dist/RecipeView-B-gmrXHR.js +0 -646
  137. package/dist/SingleColumnLayout.vue_vue_type_script_setup_true_lang-CWZkVCAj.js +0 -251
  138. package/dist/StockView-BNe2_5bA.js +0 -2520
  139. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CwV2luel.js +0 -263
  140. package/dist/WastageTemplateView-BG-y48uc.js +0 -2388
  141. package/dist/rules-T-fs8_4_.js +0 -327
  142. package/dist/stock-CFWu5bRA.js +0 -75
@@ -0,0 +1,1558 @@
1
+ import { defineComponent as O, ref as D, onMounted as he, resolveComponent as I, openBlock as w, createElementBlock as A, Fragment as ee, createElementVNode as _, toDisplayString as K, createVNode as h, createCommentVNode as S, computed as R, unref as m, normalizeClass as fe, withCtx as N, h as G, createBlock as P, renderList as se, watch as Ve, isRef as re, normalizeStyle as ke, Teleport as Be, normalizeProps as we, guardReactiveProps as xe } from "vue";
2
+ import { a as z, c as oe, S as Fe, F as Z, w as Ce, x as Ie, j as de, u as Ae } from "./app-EoCCjoRh.js";
3
+ import { useDialog as ie, useSnackbar as le, components as J, useProxiedModel as ue, useBreakpoints as Re } from "@feedmepos/ui-library";
4
+ import { i as $e, _ as Se } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
+ import { F as U } from "./form-mode.enum-BKiNVH6A.js";
6
+ import { _ as ve } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-DkQL7hK2.js";
7
+ import { defineStore as Ee, storeToRefs as Te } from "pinia";
8
+ import { D as me, R as X } from "./row-action.enum-BcW_L_nE.js";
9
+ import { c as Ue } from "./component-DpCUABT3.js";
10
+ import { a as j, c as De } from "./number-CEUoMyIk.js";
11
+ import { useI18n as Y, useCoreStore as Pe } from "@feedmepos/mf-common";
12
+ import { u as Me, _ as Ge } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-mvRR4CrP.js";
13
+ import { b as Ne, c as ye, I as ze, A as ne, U as be, R as Le } from "./rules-CyW1Bx31.js";
14
+ import { _ as Ke } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-0Vrih8D5.js";
15
+ import "./dayjs.min-Ccv4NdEp.js";
16
+ import { a as ce } from "./FmMultiselectDialog-DBXpkw5b.js";
17
+ import { d as ge } from "./defineDeepModel-rmOd66to.js";
18
+ import { L as je, P as Oe, D as Ye } from "./app-DiX-EfV6.js";
19
+ import { _ as qe, c as He, d as We } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-D-ZqJ8sU.js";
20
+ import { u as Je } from "./FmMultiselectDialog-C6E_KMFO.js";
21
+ import { u as Qe } from "./vue-i18n-CY4442Fb.js";
22
+ import { F as Xe, u as Ze } from "./feature-D4-lt7R6.js";
23
+ import { _ as en } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js";
24
+ import { _ as nn, F as pe } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
25
+ import { b as tn, d as on } from "./xlsx.util-Dy4jmPyv.js";
26
+ import { f as ln } from "./date2-CTHKdfXp.js";
27
+ import { _ as an } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CkUwLhut.js";
28
+ const sn = {
29
+ key: 0,
30
+ class: "flex flex-col items-center w-full h-full gap-24"
31
+ }, rn = { key: 1 }, dn = { key: 0 }, un = /* @__PURE__ */ O({
32
+ __name: "DeleteDialog",
33
+ props: {
34
+ type: {},
35
+ data: {},
36
+ message: {},
37
+ bindedItems: {}
38
+ },
39
+ setup(f) {
40
+ const k = f, v = D(k.bindedItems || []), d = D(!1);
41
+ he(() => {
42
+ r();
43
+ });
44
+ async function r() {
45
+ var c, l;
46
+ !d.value && ((c = k.data) != null && c._id) && (d.value = !0, v.value = await z().getAffectedMenu((l = k.data) == null ? void 0 : l._id), d.value = !1);
47
+ }
48
+ return (c, l) => {
49
+ const a = I("FmSpacer"), n = I("FmCircularProgress");
50
+ return w(), A(ee, null, [
51
+ _("p", null, K(c.message), 1),
52
+ d.value ? (w(), A("div", sn, [
53
+ h(a),
54
+ _("div", null, [
55
+ h(n, { size: "xl" })
56
+ ]),
57
+ l[0] || (l[0] = _("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
58
+ h(a)
59
+ ])) : (w(), A("div", rn, [
60
+ l[2] || (l[2] = _("br", null, null, -1)),
61
+ v.value.length > 0 ? (w(), A("div", dn, [
62
+ l[1] || (l[1] = _("p", { class: "fm-typo-en-body-lg-600" }, "Affected menu items:", -1)),
63
+ h(ve, {
64
+ name: "Menu",
65
+ bindings: v.value
66
+ }, null, 8, ["bindings"])
67
+ ])) : S("", !0)
68
+ ]))
69
+ ], 64);
70
+ };
71
+ }
72
+ }), te = Ee("recipeForm", function() {
73
+ const k = ie(), v = le(), d = z(), r = D(!1), c = D();
74
+ function l() {
75
+ const e = {
76
+ recipe: {},
77
+ mode: U.CREATE,
78
+ show: !0,
79
+ "onUpdate:show"(i) {
80
+ c.value.show = i;
81
+ }
82
+ };
83
+ c.value = e;
84
+ }
85
+ async function a(e) {
86
+ const i = {
87
+ recipe: oe(e),
88
+ mode: U.UPDATE,
89
+ show: !0,
90
+ "onUpdate:show"(y) {
91
+ c.value.show = y;
92
+ }
93
+ };
94
+ c.value = i;
95
+ }
96
+ async function n(e) {
97
+ r.value = !0;
98
+ try {
99
+ await d.deleteRecipe(e), v.open({
100
+ title: "Success",
101
+ message: `Deleted ${e.name}`,
102
+ type: "success"
103
+ });
104
+ } catch (i) {
105
+ i instanceof Fe && $e(i) ? k.open({
106
+ title: "Cannot delete recipe",
107
+ contentComponent: Se,
108
+ contentComponentProps: {
109
+ subject: (e == null ? void 0 : e.name) ?? "",
110
+ items: i.errorResponse.message
111
+ },
112
+ secondaryActions: {
113
+ text: "Close",
114
+ close: !0
115
+ }
116
+ }) : console.log("unable to delete recipe", i), v.open({
117
+ title: `Cannot delete ${e == null ? void 0 : e.name}`,
118
+ message: "Please try again.",
119
+ type: "error"
120
+ }), console.error("failed to delete recipe", i);
121
+ } finally {
122
+ r.value = !1;
123
+ }
124
+ }
125
+ function t(e) {
126
+ k.open({
127
+ title: `Delete ${(e == null ? void 0 : e.name) ?? "recipe"}?`,
128
+ closeButton: !1,
129
+ primaryActions: {
130
+ text: "Delete",
131
+ close: !0,
132
+ variant: "destructive"
133
+ },
134
+ secondaryActions: {
135
+ text: "Cancel",
136
+ close: !0
137
+ },
138
+ contentComponent: un,
139
+ contentComponentProps: {
140
+ type: "menu",
141
+ data: e,
142
+ message: "You may not be able to delete this recipe if it is linked in any of the inventory modules."
143
+ }
144
+ }).onPrimary(() => n(e));
145
+ }
146
+ return {
147
+ createRecipe: l,
148
+ updateRecipe: a,
149
+ deleteRecipe: t,
150
+ recipeDialogProps: c,
151
+ recipeViewLoading: r
152
+ };
153
+ });
154
+ function mn() {
155
+ const { updateRecipe: f, deleteRecipe: k } = te(), v = z(), { t: d } = Y();
156
+ async function r(n, t) {
157
+ const e = oe(t);
158
+ if (n === X.Edit) {
159
+ await f(e);
160
+ return;
161
+ }
162
+ if (n === X.Delete) {
163
+ await k(e);
164
+ return;
165
+ }
166
+ }
167
+ function c(n, t) {
168
+ const e = n.filter((s) => s.type === Z.enum.SKU), i = n.filter(
169
+ (s) => s.type === Z.enum.SKU_GROUP
170
+ ), y = n.filter((s) => s.type === Z.enum.RECIPE);
171
+ return [
172
+ ...e.map((s) => ({ ...s, recipeIds: [...t] })),
173
+ ...i.map((s) => ({ ...s, isGroup: !0, recipeIds: [...t] })),
174
+ ...y.filter((s) => v.recipeById[s.id] && !t.has(s.id)).flatMap(
175
+ (s) => c(v.recipeById[s.id].contains, /* @__PURE__ */ new Set([...t, s.id]))
176
+ )
177
+ ];
178
+ }
179
+ const l = [
180
+ {
181
+ accessorKey: "recipe",
182
+ header: () => d("inventory.recipe.name"),
183
+ size: 400
184
+ },
185
+ {
186
+ accessorKey: "ingredients",
187
+ header: () => d("inventory.recipe.ingredients"),
188
+ size: "auto"
189
+ },
190
+ {
191
+ id: "action",
192
+ header: "",
193
+ cell(n) {
194
+ return Ue(
195
+ [me[X.Edit], me[X.Delete]],
196
+ (t) => {
197
+ r(t, n.row.original.original);
198
+ }
199
+ );
200
+ },
201
+ enableSorting: !1,
202
+ size: 40,
203
+ meta: {
204
+ cellClass: "",
205
+ headerClass: ""
206
+ }
207
+ }
208
+ ];
209
+ function a(n) {
210
+ const t = z();
211
+ return n.map((e) => ({
212
+ recipe: e.name,
213
+ ingredients: c(e.contains, /* @__PURE__ */ new Set([e._id])).map((i) => {
214
+ var s, B, o, b, V, F;
215
+ if (i.isGroup) {
216
+ const p = t.skuGroupById[i.id];
217
+ return i.recipeIds.slice(1).length ? `(${(s = t.recipeById[i.recipeIds.at(-1) ?? ""]) == null ? void 0 : s.name}) ${p.name} (x ${j(i.amount)})` : `${p.name} (x${j(i.amount)})`;
218
+ }
219
+ const y = t.skuById[i.id];
220
+ return y ? i.recipeIds.slice(1).length ? `(${(B = t.recipeById[i.recipeIds.at(-1) ?? ""]) == null ? void 0 : B.name}) ${y.name} (${j(i.amount)}${((o = i.measurement) == null ? void 0 : o.abbrev) ?? ((b = y == null ? void 0 : y.unit) == null ? void 0 : b.abbrev)})` : `${y.name} (${j(i.amount)}${((V = i.measurement) == null ? void 0 : V.abbrev) ?? ((F = y == null ? void 0 : y.unit) == null ? void 0 : F.abbrev)})` : null;
221
+ }).filter((i) => i).join(", "),
222
+ original: e
223
+ }));
224
+ }
225
+ return { columnDefs: l, formatRowData: a };
226
+ }
227
+ function cn() {
228
+ const f = z(), k = ie();
229
+ async function v(r, c, l, a = []) {
230
+ var s, B;
231
+ const n = r.filter((o) => o.type === "SKU"), t = r.filter((o) => o.type !== "SKU"), e = /* @__PURE__ */ new Set();
232
+ if (l)
233
+ for (const o of f.skus)
234
+ !a.some((V) => V === o._id) && o._id !== l && !((B = (s = o.convert) == null ? void 0 : s.inventoryBindings) != null && B.some((V) => V.id === l)) || e.add(o._id);
235
+ const i = f.skus.map((o) => ({
236
+ label: o.name,
237
+ sublabel: `${o.code}${e.has(o._id) ? " (Cannot bind, will cause recursive binding)" : ""}`,
238
+ value: o,
239
+ disabled: e.has(o._id)
240
+ })), y = i.filter(
241
+ (o) => n.find((b) => b.id === o.value._id) && !e.has(o.value._id)
242
+ ).map((o) => o.value);
243
+ k.open({
244
+ title: "Select ingredients",
245
+ contentComponent: ce,
246
+ contentComponentProps: {
247
+ items: i,
248
+ modelValue: y,
249
+ virtualScroll: !0
250
+ },
251
+ primaryActions: {
252
+ text: "Confirm",
253
+ close: !0
254
+ },
255
+ secondaryActions: {
256
+ text: "Close",
257
+ close: !0,
258
+ variant: "tertiary"
259
+ }
260
+ }).onPrimary((o) => {
261
+ const b = [
262
+ ...t,
263
+ ...r.filter((V) => o.find((F) => F._id === V.id)),
264
+ ...o.filter((V) => !r.find((F) => F.id === V._id)).map((V) => ({
265
+ type: "SKU",
266
+ id: V._id,
267
+ amount: {
268
+ amount: 1,
269
+ precision: 0
270
+ }
271
+ }))
272
+ ];
273
+ c(b);
274
+ });
275
+ }
276
+ async function d(r, c, l = []) {
277
+ var y;
278
+ const a = r.filter((s) => s.type === "RECIPE"), n = r.filter((s) => s.type !== "RECIPE"), t = /* @__PURE__ */ new Set();
279
+ if (l.length)
280
+ for (const s of f.recipes) {
281
+ const B = ((y = f.recipeBindingFlattenCache[s._id]) == null ? void 0 : y.inventoryBindings) ?? [], o = B.some(
282
+ (F) => F.bindingPaths.some((p) => l.some((x) => x === p.id))
283
+ ), b = B.some(
284
+ (F) => "success" in F && l.includes(F.ingredient._id)
285
+ );
286
+ (l.some((F) => F === s._id) || o || b) && t.add(s._id);
287
+ }
288
+ const e = f.recipes.filter((s) => !l.includes(s._id)).map((s) => ({
289
+ label: s.name,
290
+ sublabel: t.has(s._id) ? "(Cannot bind, will cause recursive binding)" : `${s.contains.length} inventory bindings`,
291
+ value: s,
292
+ disabled: t.has(s._id)
293
+ })), i = e.filter(
294
+ (s) => a.find((B) => B.id === s.value._id) && !t.has(s.value._id)
295
+ ).map((s) => s.value);
296
+ k.open({
297
+ title: "Select recipes",
298
+ contentComponent: ce,
299
+ contentComponentProps: {
300
+ items: e,
301
+ modelValue: i,
302
+ virtualScroll: !0
303
+ },
304
+ primaryActions: {
305
+ text: "Confirm",
306
+ close: !0
307
+ },
308
+ secondaryActions: {
309
+ text: "Close",
310
+ close: !0,
311
+ variant: "tertiary"
312
+ }
313
+ }).onPrimary((s) => {
314
+ const B = [
315
+ ...r.filter((o) => s.find((b) => b._id === o.id)),
316
+ ...s.filter((o) => !r.find((b) => b.id === o._id)).map((o) => ({
317
+ type: "RECIPE",
318
+ id: o._id,
319
+ amount: {
320
+ amount: 1,
321
+ precision: 0
322
+ }
323
+ })),
324
+ ...n
325
+ ];
326
+ c(B);
327
+ });
328
+ }
329
+ return {
330
+ promptIngredientsBinding: v,
331
+ promptRecipesBinding: d
332
+ };
333
+ }
334
+ const pn = { class: "flex flex-col" }, fn = { class: "flex flex-col gap-4" }, _e = /* @__PURE__ */ O({
335
+ __name: "InventoryBindingRule",
336
+ props: {
337
+ disabled: { type: Boolean },
338
+ modelValue: {},
339
+ minCount: {},
340
+ maxCount: {}
341
+ },
342
+ emits: ["update:modelValue"],
343
+ setup(f, { emit: k }) {
344
+ const v = f, d = k, { t: r } = Y(), c = Pe(), l = R(() => {
345
+ var i;
346
+ const t = /* @__PURE__ */ new Map(), e = c.restaurants.value.map((y) => y.customAttributes ?? {});
347
+ for (const y of e)
348
+ for (const [s, B] of Object.entries(y))
349
+ t.has(s) || t.set(s, /* @__PURE__ */ new Set()), B && ((i = t.get(s)) == null || i.add(B));
350
+ return t;
351
+ }), a = R(() => [
352
+ ...[...l.value.entries()].map(([e, i]) => ({
353
+ type: "string",
354
+ key: e,
355
+ entity: "restaurant",
356
+ values: [...i]
357
+ }))
358
+ ]), n = R({
359
+ get() {
360
+ return v.modelValue ? je.build(v.modelValue) : null;
361
+ },
362
+ set(t) {
363
+ d("update:modelValue", t ? Oe.build(t) : null);
364
+ }
365
+ });
366
+ return (t, e) => {
367
+ const i = I("FmLabel"), y = I("FmFormGroup");
368
+ return w(), A("div", pn, [
369
+ _("div", fn, [
370
+ h(i, {
371
+ label: m(r)("inventory.ingredientGroup.form.rules.title"),
372
+ required: t.minCount != null && t.minCount > 0
373
+ }, null, 8, ["label", "required"]),
374
+ h(m(Ye), {
375
+ modelValue: n.value,
376
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => n.value = s),
377
+ attributes: a.value
378
+ }, null, 8, ["modelValue", "attributes"])
379
+ ]),
380
+ h(y, {
381
+ "model-value": n.value,
382
+ rules: [
383
+ (s) => {
384
+ const B = s ? 1 : 0;
385
+ return v.minCount !== void 0 && B < v.minCount ? m(r)("inventory.ingredientGroup.form.rules.validation.minCount", {
386
+ count: v.minCount
387
+ }) : v.maxCount !== void 0 && B > v.maxCount ? m(r)("inventory.ingredientGroup.form.rules.validation.maxCount", {
388
+ count: v.maxCount
389
+ }) : !0;
390
+ }
391
+ ]
392
+ }, null, 8, ["model-value", "rules"])
393
+ ]);
394
+ };
395
+ }
396
+ }), vn = { class: "border-1 mx-3 my-1 rounded-md" }, yn = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, bn = {
397
+ class: "flex items-center",
398
+ style: { "min-height": "48px" }
399
+ }, gn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, _n = { class: "flex flex-col" }, hn = { class: "line-clamp-1" }, Vn = { class: "w-[200px]" }, kn = {
400
+ key: 0,
401
+ class: "w-[52px]"
402
+ }, Bn = {
403
+ key: 1,
404
+ class: "w-[52px]"
405
+ }, wn = {
406
+ key: 0,
407
+ class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-8"
408
+ }, xn = { class: "px-12 pb-4" }, Fn = /* @__PURE__ */ O({
409
+ __name: "InventoryRecipeBindingV2Field",
410
+ props: {
411
+ disabled: { type: Boolean },
412
+ readonly: { type: Boolean },
413
+ modelValue: {},
414
+ displayName: {},
415
+ showError: { type: Boolean },
416
+ showSettingsButton: { type: Boolean }
417
+ },
418
+ emits: ["update:modelValue", "delete", "settings"],
419
+ setup(f, { emit: k }) {
420
+ const { t: v } = Y(), d = ge("modelValue");
421
+ function r(c) {
422
+ const l = +c;
423
+ c.length > 0 && isFinite(l) ? d.amount = De(l) : d.amount = { amount: 0, precision: 0 };
424
+ }
425
+ return (c, l) => {
426
+ const a = I("FmTooltip"), n = I("FmTextField"), t = I("FmButton"), e = I("FmIcon"), i = I("FmFormGroup");
427
+ return w(), A("div", vn, [
428
+ h(i, {
429
+ class: fe(["mb-2"]),
430
+ disabled: c.disabled,
431
+ modelValue: +m(j)(m(d).amount),
432
+ rules: [m(Ne)(0), m(ye)(-1)]
433
+ }, {
434
+ default: N(({ invalid: y }) => [
435
+ _("div", yn, [
436
+ _("div", bn, [
437
+ _("div", gn, [
438
+ _("div", _n, [
439
+ h(a, {
440
+ zIndex: 51,
441
+ variant: "plain",
442
+ placement: "top",
443
+ content: c.displayName
444
+ }, {
445
+ default: N(() => [
446
+ _("span", hn, K(c.displayName), 1)
447
+ ]),
448
+ _: 1
449
+ }, 8, ["content"])
450
+ ])
451
+ ]),
452
+ _("div", Vn, [
453
+ h(n, {
454
+ class: "w-full",
455
+ disabled: c.disabled,
456
+ modelValue: +m(j)(m(d).amount),
457
+ "onUpdate:modelValue": l[0] || (l[0] = (s) => r(s)),
458
+ invalid: y
459
+ }, null, 8, ["disabled", "modelValue", "invalid"])
460
+ ]),
461
+ c.showSettingsButton ? (w(), A("div", kn, [
462
+ h(t, {
463
+ disabled: c.disabled,
464
+ type: "button",
465
+ variant: "tertiary",
466
+ icon: "settings",
467
+ onClick: () => {
468
+ }
469
+ }, null, 8, ["disabled"])
470
+ ])) : S("", !0),
471
+ c.readonly ? S("", !0) : (w(), A("div", Bn, [
472
+ h(t, {
473
+ disabled: c.disabled,
474
+ type: "button",
475
+ variant: "plain",
476
+ icon: "delete",
477
+ "icon-color": "#000000",
478
+ onClick: () => {
479
+ }
480
+ }, null, 8, ["disabled"])
481
+ ]))
482
+ ]),
483
+ c.showError ? (w(), A("div", wn, [
484
+ h(e, {
485
+ name: "error",
486
+ color: "system-error-300",
487
+ size: "sm"
488
+ }),
489
+ _("div", null, K(m(v)("inventory.inventoryBindings.circularError")), 1)
490
+ ])) : S("", !0)
491
+ ])
492
+ ]),
493
+ _: 1
494
+ }, 8, ["disabled", "modelValue", "rules"]),
495
+ _("div", xn, [
496
+ h(_e, {
497
+ modelValue: m(d).rules,
498
+ "onUpdate:modelValue": l[1] || (l[1] = (y) => m(d).rules = y),
499
+ disabled: c.disabled
500
+ }, null, 8, ["modelValue", "disabled"])
501
+ ])
502
+ ]);
503
+ };
504
+ }
505
+ });
506
+ function Cn(f) {
507
+ const k = Je(), { t: v } = Qe(), d = z(), r = R(() => [
508
+ {
509
+ id: "delete",
510
+ header: "",
511
+ cell(a) {
512
+ const n = a.row.original;
513
+ return G(
514
+ "div",
515
+ { class: "w-full flex justify-end" },
516
+ G(J.FmButton, {
517
+ class: "delete-button",
518
+ key: n._id,
519
+ type: "button",
520
+ icon: "delete",
521
+ variant: "tertiary",
522
+ size: "md",
523
+ disabled: f.disabled ?? !1,
524
+ onClick: () => {
525
+ f.bindingAlternatives = f.bindingAlternatives.filter(
526
+ (t) => t._id !== n._id
527
+ );
528
+ }
529
+ })
530
+ );
531
+ },
532
+ enableSorting: !1,
533
+ size: 40,
534
+ meta: {
535
+ cellClass: "",
536
+ headerClass: ""
537
+ }
538
+ },
539
+ {
540
+ id: "alternative",
541
+ header: () => v("inventory.inventoryBindings.alternativeTable.ingredient"),
542
+ accessorFn: (a) => {
543
+ var n, t;
544
+ return `${((n = d.skuById[a._id]) == null ? void 0 : n.name) ?? ""} (${((t = d.skuById[a._id]) == null ? void 0 : t.code) ?? ""})`;
545
+ },
546
+ cell: ({ row: a }) => {
547
+ const n = d.skuById[a.original._id];
548
+ return G(
549
+ "div",
550
+ {
551
+ class: "w-full flex flex-col"
552
+ },
553
+ [
554
+ G("div", { class: "fm-typo-en-body-lg-400 line-clamp-1" }, n.name),
555
+ G(
556
+ "div",
557
+ { class: "fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary" },
558
+ n.code
559
+ )
560
+ ]
561
+ );
562
+ },
563
+ size: "auto",
564
+ enableSorting: !1
565
+ },
566
+ {
567
+ id: "unit",
568
+ header: () => v("inventory.inventoryBindings.alternativeTable.unit"),
569
+ accessorFn: (a) => {
570
+ const n = d.skuById[a._id];
571
+ return n.unit.measurements.computeFirst(
572
+ (t) => t.id === a.trackingMeasurement ? t.name : null
573
+ ) ?? n.unit.name;
574
+ },
575
+ enableSorting: !1
576
+ },
577
+ {
578
+ id: "unitOption",
579
+ header: () => v("inventory.inventoryBindings.alternativeTable.unit"),
580
+ accessorKey: "trackingMeasurement",
581
+ cell(a) {
582
+ const n = d.skuById[a.row.original._id];
583
+ if (!n) return null;
584
+ const t = [
585
+ {
586
+ label: n.unit.name,
587
+ sublabel: n.unit.abbrev,
588
+ value: null
589
+ },
590
+ ...n.unit.measurements.map((e) => ({
591
+ label: `${e.name} (${e.abbrev})`,
592
+ sublabel: v("inventory.inventoryBindings.alternativeTable.measurementOption"),
593
+ value: e.id
594
+ }))
595
+ ].filter((e) => !e.label.toLowerCase().includes("inactive"));
596
+ return G(J.FmSelect, {
597
+ modelValue: a.row.original.trackingMeasurement ?? null,
598
+ items: t,
599
+ disabled: f.disabled ?? !1,
600
+ "onUpdate:modelValue": (e) => {
601
+ f.bindingAlternatives = f.bindingAlternatives.map((i) => i._id === a.row.original._id ? { ...i, trackingMeasurement: e } : i);
602
+ }
603
+ });
604
+ },
605
+ enableSorting: !1
606
+ },
607
+ {
608
+ id: "priority",
609
+ header: () => v("inventory.inventoryBindings.alternativeTable.priority"),
610
+ accessorKey: "priority",
611
+ enableSorting: !0,
612
+ cell(a) {
613
+ const n = a.row.original;
614
+ return G(J.FmTextField, {
615
+ modelValue: n.priority ?? a.row.index + 1,
616
+ rules: [
617
+ ze(),
618
+ ne(1),
619
+ be(
620
+ f.bindingAlternatives.filter((t) => t._id !== n._id).map((t) => {
621
+ const e = d.skuById[t._id];
622
+ return {
623
+ label: e == null ? void 0 : e.name,
624
+ value: t.priority
625
+ };
626
+ })
627
+ )
628
+ ],
629
+ "onUpdate:modelValue": (t) => {
630
+ const e = Number(t);
631
+ isNaN(e) || (f.bindingAlternatives = f.bindingAlternatives.map((i) => i._id === a.row.original._id ? { ...i, priority: e } : i));
632
+ }
633
+ });
634
+ }
635
+ },
636
+ {
637
+ id: "default",
638
+ header: () => "",
639
+ accessorKey: "default",
640
+ cell(a) {
641
+ const n = d.skuById[a.row.original._id];
642
+ return n ? G(J.FmCheckbox, {
643
+ modelValue: a.row.original.default ?? !1,
644
+ value: n._id,
645
+ disabled: f.disabled ?? !1,
646
+ "onUpdate:modelValue": () => {
647
+ f.bindingAlternatives = f.bindingAlternatives.map((t) => t._id === a.row.original._id ? { ...t, default: !0 } : { ...t, default: !1 });
648
+ }
649
+ }) : null;
650
+ },
651
+ enableSorting: !1,
652
+ size: 40,
653
+ meta: {
654
+ cellClass: "",
655
+ headerClass: ""
656
+ }
657
+ },
658
+ {
659
+ id: "move",
660
+ header: "",
661
+ cell(a) {
662
+ const n = a.row.original;
663
+ return G("div", { class: "w-full flex justify-end" }, [
664
+ G(J.FmButton, {
665
+ key: n._id,
666
+ type: "button",
667
+ icon: "keyboard_arrow_up",
668
+ variant: "tertiary",
669
+ size: "md",
670
+ disabled: f.disabled ?? !1,
671
+ onClick: () => {
672
+ const t = [...f.bindingAlternatives], e = t.findIndex((i) => i._id === n._id);
673
+ if (e > 0) {
674
+ const i = t[e - 1];
675
+ t[e - 1] = n, t[e] = i;
676
+ }
677
+ f.bindingAlternatives = [...t];
678
+ }
679
+ }),
680
+ G(J.FmButton, {
681
+ key: n._id,
682
+ type: "button",
683
+ icon: "keyboard_arrow_down",
684
+ variant: "tertiary",
685
+ size: "md",
686
+ disabled: f.disabled ?? !1,
687
+ onClick: () => {
688
+ const t = [...f.bindingAlternatives], e = t.findIndex((i) => i._id === n._id);
689
+ if (e < t.length - 1) {
690
+ const i = t[e + 1];
691
+ t[e + 1] = n, t[e] = i;
692
+ }
693
+ f.bindingAlternatives = [...t];
694
+ }
695
+ })
696
+ ]);
697
+ },
698
+ enableSorting: !1,
699
+ size: 40,
700
+ meta: {
701
+ cellClass: "",
702
+ headerClass: ""
703
+ }
704
+ }
705
+ ]);
706
+ return {
707
+ get columnDefs() {
708
+ return r.value;
709
+ },
710
+ promptAddIngredient: async (l) => {
711
+ const a = [];
712
+ for (const e of d.skus)
713
+ l.includes(e._id) || a.push({
714
+ label: e.name,
715
+ sublabel: e.code,
716
+ value: e._id,
717
+ disabled: l.includes(e._id)
718
+ });
719
+ const n = (f.bindingAlternatives ?? []).map((e) => e._id), t = await k.multiSelect(a, n, (e) => {
720
+ var y, s, B, o, b, V;
721
+ const i = (y = f.bindingAlternatives) == null ? void 0 : y.findIndex((F) => F._id === e);
722
+ return {
723
+ _id: e,
724
+ trackingMeasurement: typeof i != "number" || i == -1 ? (s = d.skuById[e]) == null ? void 0 : s.trackingMeasurement : (o = (B = f.bindingAlternatives) == null ? void 0 : B[i]) == null ? void 0 : o.trackingMeasurement,
725
+ priority: ((V = (b = f.bindingAlternatives) == null ? void 0 : b[i]) == null ? void 0 : V.priority) ?? f.bindingAlternatives.length,
726
+ default: !1
727
+ };
728
+ });
729
+ f.bindingAlternatives = t ?? f.bindingAlternatives;
730
+ },
731
+ columnVisibility: {
732
+ delete: !0,
733
+ unit: !1,
734
+ unitOption: !0,
735
+ default: !1,
736
+ // previous demo: sort priority by moving sku element in the array,
737
+ // new demo: sort priority using priority field.
738
+ // can reenable if this use case is requested to be restored
739
+ move: !1
740
+ }
741
+ };
742
+ }
743
+ const In = { class: "flex flex-col gap-16" }, An = { class: "flex flex-col" }, Rn = { class: "flex justify-between items-center px-2" }, $n = /* @__PURE__ */ O({
744
+ __name: "InventoryBindingAlternative",
745
+ props: {
746
+ disabled: { type: Boolean },
747
+ modelValue: {},
748
+ filterIngredientIds: {}
749
+ },
750
+ emits: ["update:modelValue"],
751
+ setup(f, { emit: k }) {
752
+ const v = f, d = k, { t: r } = Y(), c = Cn({
753
+ get disabled() {
754
+ return v.disabled ?? !1;
755
+ },
756
+ get bindingAlternatives() {
757
+ return v.modelValue ?? [];
758
+ },
759
+ set bindingAlternatives(n) {
760
+ d("update:modelValue", n);
761
+ }
762
+ }), l = (n) => n && n.some((t) => v.filterIngredientIds.includes(t._id)) ? "Contains invalid ingredient" : !0, a = (n) => n && n.length > 5 ? r("inventory.binding.alternative.maximumExceeded", { max: 5 }) : !0;
763
+ return (n, t) => {
764
+ var B;
765
+ const e = I("FmLabel"), i = I("FmButton"), y = I("FmFormGroup"), s = I("FmTable");
766
+ return w(), A("div", In, [
767
+ _("div", An, [
768
+ _("div", Rn, [
769
+ h(e, {
770
+ label: m(r)("inventory.alternatives")
771
+ }, null, 8, ["label"]),
772
+ h(i, {
773
+ disabled: n.disabled,
774
+ "prepend-icon": "link",
775
+ variant: "primary",
776
+ class: "border-1 rounded-lg border-fm-color-primary",
777
+ onClick: t[0] || (t[0] = (o) => m(c).promptAddIngredient(n.filterIngredientIds)),
778
+ size: "md"
779
+ }, null, 8, ["disabled"])
780
+ ]),
781
+ h(y, {
782
+ "model-value": n.modelValue,
783
+ rules: [l, a]
784
+ }, null, 8, ["model-value", "rules"])
785
+ ]),
786
+ h(s, {
787
+ "row-data": n.modelValue ?? [],
788
+ "column-defs": m(c).columnDefs,
789
+ "page-size": ((B = n.modelValue) == null ? void 0 : B.length) || 0,
790
+ "shrink-at": 9999,
791
+ "column-visibility": m(c).columnVisibility,
792
+ "hide-footer": ""
793
+ }, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
794
+ ]);
795
+ };
796
+ }
797
+ }), Sn = { class: "border-1 mx-3 my-1 rounded-md" }, En = { class: "flex flex-col border-b border-fm-color-neutral-gray-100" }, Tn = {
798
+ class: "flex items-center w-full",
799
+ style: { "min-height": "48px" }
800
+ }, Un = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, Dn = { class: "line-clamp-1 w-full" }, Pn = { class: "w-[150px]" }, Mn = {
801
+ key: 0,
802
+ class: "w-[52px]"
803
+ }, Gn = { class: "flex flex-col px-12 pb-4" }, Nn = /* @__PURE__ */ O({
804
+ __name: "InventorySkuBindingV2Field",
805
+ props: {
806
+ disabled: { type: Boolean },
807
+ readonly: { type: Boolean },
808
+ modelValue: {},
809
+ displayName: {},
810
+ unit: {},
811
+ showError: { type: Boolean },
812
+ ableToConfigureAlternative: { type: Boolean },
813
+ ableToApplyRules: { type: Boolean }
814
+ },
815
+ emits: ["update:modelValue", "delete", "settings"],
816
+ setup(f, { emit: k }) {
817
+ const v = k, { t: d } = Y(), r = ge("modelValue");
818
+ function c(a) {
819
+ a && (r.amount = a.amount, r.measurement = a.measurement);
820
+ }
821
+ function l() {
822
+ return {
823
+ modelValue: {
824
+ amount: r.amount,
825
+ measurement: r.measurement
826
+ },
827
+ amountAsString: Xe.toFormatString({
828
+ value: r.amount
829
+ })
830
+ };
831
+ }
832
+ return (a, n) => {
833
+ const t = I("FmTooltip"), e = I("FmButton"), i = I("FmFormGroup");
834
+ return w(), A("div", Sn, [
835
+ _("div", En, [
836
+ _("div", Tn, [
837
+ _("div", Un, [
838
+ h(t, {
839
+ zIndex: 51,
840
+ variant: "plain",
841
+ placement: "top",
842
+ content: a.displayName
843
+ }, {
844
+ default: N(() => [
845
+ _("span", Dn, K(a.displayName), 1)
846
+ ]),
847
+ _: 1
848
+ }, 8, ["content"])
849
+ ]),
850
+ _("div", Pn, [
851
+ h(qe, {
852
+ "model-value": { amount: m(r).amount, measurement: m(r).measurement },
853
+ "onUpdate:modelValue": c,
854
+ unit: a.unit,
855
+ placement: "bottom",
856
+ "convert-amount-on-change-unit": "",
857
+ disabled: a.readonly
858
+ }, null, 8, ["model-value", "unit", "disabled"])
859
+ ]),
860
+ a.readonly ? S("", !0) : (w(), A("div", Mn, [
861
+ h(e, {
862
+ disabled: a.disabled,
863
+ type: "button",
864
+ variant: "tertiary",
865
+ icon: "delete",
866
+ onClick: n[0] || (n[0] = () => v("delete", m(r).id))
867
+ }, null, 8, ["disabled"])
868
+ ]))
869
+ ]),
870
+ _("div", Gn, [
871
+ h(i, {
872
+ modelValue: m(r).amount,
873
+ rules: [m(ye)(0)]
874
+ }, null, 8, ["modelValue", "rules"]),
875
+ h(i, {
876
+ modelValue: l(),
877
+ rules: [
878
+ m(He)(),
879
+ m(We)(a.unit),
880
+ () => a.showError ? m(d)("inventory.inventoryBindings.invalidWarning") : !0
881
+ ]
882
+ }, null, 8, ["modelValue", "rules"])
883
+ ]),
884
+ a.ableToApplyRules ? (w(), P(_e, {
885
+ key: 0,
886
+ modelValue: m(r).rules,
887
+ "onUpdate:modelValue": n[1] || (n[1] = (y) => m(r).rules = y),
888
+ disabled: a.disabled
889
+ }, null, 8, ["modelValue", "disabled"])) : S("", !0),
890
+ a.ableToConfigureAlternative ? (w(), P($n, {
891
+ key: 1,
892
+ modelValue: m(r).alternatives,
893
+ "onUpdate:modelValue": n[2] || (n[2] = (y) => m(r).alternatives = y),
894
+ disabled: a.disabled,
895
+ filterIngredientIds: [m(r).id]
896
+ }, null, 8, ["modelValue", "disabled", "filterIngredientIds"])) : S("", !0)
897
+ ])
898
+ ]);
899
+ };
900
+ }
901
+ });
902
+ exports.FfCalculator;
903
+ const zn = { class: "flex flex-col gap-24" }, Ln = {
904
+ key: 0,
905
+ class: "flex flex-col gap-16"
906
+ }, Kn = { class: "flex items-center" }, jn = { class: "flex-1 fm-typo-en-title-sm-600" }, On = { class: "flex flex-col" }, Yn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, qn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Hn = {
907
+ key: 0,
908
+ class: "w-[52px]"
909
+ }, Wn = {
910
+ key: 1,
911
+ class: "w-[52px]"
912
+ }, Jn = { class: "flex flex-col gap-16" }, Qn = { class: "flex items-center" }, Xn = { class: "flex-1 fm-typo-en-title-sm-600" }, Zn = { class: "flex flex-col" }, et = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, nt = { class: "flex-1 fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, tt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary w-[150px] px-16" }, ot = {
913
+ key: 0,
914
+ class: "w-[52px]"
915
+ }, it = /* @__PURE__ */ O({
916
+ __name: "InventoryBindingFormV2",
917
+ props: {
918
+ id: {},
919
+ modelValue: { default: () => [] },
920
+ excludeBindingId: {},
921
+ rules: { default: () => [] },
922
+ iframeMode: { type: Boolean },
923
+ disabled: { type: Boolean },
924
+ readonly: { type: Boolean },
925
+ recipeBindingConfig: { default: () => ({ enabled: !0, ableToApplyRules: !1 }) },
926
+ skuBindingConfig: { default: () => ({
927
+ enabled: !0,
928
+ ableToApplyRules: !1,
929
+ ableToConfigureAlternative: !1
930
+ }) }
931
+ },
932
+ emits: ["update:modelValue", "click:pick-inventory-bindings"],
933
+ setup(f, { emit: k }) {
934
+ const { t: v } = Y(), d = z(), r = R(() => d.recipeById), c = R(() => d.skuById), l = f, a = k, n = R(() => Ce({
935
+ parentId: l.id,
936
+ bindings: l.modelValue,
937
+ recipes: d.recipes.map((C) => C._id === l.id ? {
938
+ ...C,
939
+ contains: l.modelValue
940
+ } : C),
941
+ skus: d.skus.map((C) => C._id === l.id ? {
942
+ ...C,
943
+ convert: {
944
+ inventoryBindings: l.modelValue
945
+ }
946
+ } : C),
947
+ skuGroups: d.skuGroups
948
+ }).inventoryBindings.filter((C) => "error" in C && C.error).map((C) => C).filter((C) => C.reason === Ie.enum.circularDependency)), t = R(
949
+ () => new Set(n.value.map((p) => {
950
+ var x;
951
+ return (x = p.bindingPaths[0]) == null ? void 0 : x.id;
952
+ }))
953
+ ), e = R(() => l.modelValue.filter((p) => p.type === "RECIPE")), { promptIngredientsBinding: i, promptRecipesBinding: y } = cn();
954
+ async function s() {
955
+ if (l.iframeMode) {
956
+ a("click:pick-inventory-bindings", "RECIPE");
957
+ return;
958
+ }
959
+ y(
960
+ l.modelValue,
961
+ (p) => a("update:modelValue", p),
962
+ l.id ? [l.id] : []
963
+ );
964
+ }
965
+ const B = R(() => l.modelValue.filter((p) => p.type === "SKU") ?? []);
966
+ async function o() {
967
+ if (l.iframeMode) {
968
+ a("click:pick-inventory-bindings", "SKU");
969
+ return;
970
+ }
971
+ i(
972
+ l.modelValue,
973
+ (p) => a("update:modelValue", p),
974
+ l.excludeBindingId,
975
+ l.id ? [l.id] : []
976
+ );
977
+ }
978
+ function b(p) {
979
+ const x = l.modelValue.map((C) => C.id === p.id ? p : C);
980
+ a("update:modelValue", x);
981
+ }
982
+ function V(p) {
983
+ const x = l.modelValue.filter((C) => C.id !== p);
984
+ a("update:modelValue", x);
985
+ }
986
+ function F(p) {
987
+ var C, u;
988
+ if (p.type !== Z.enum.SKU)
989
+ throw new Error("Non-SKU binding does not have unit");
990
+ if (!((C = c.value[p.id]) == null ? void 0 : C.unit))
991
+ throw new Error(`Cannot find ingredient: ${p.id}`);
992
+ return (u = c.value[p.id]) == null ? void 0 : u.unit;
993
+ }
994
+ return (p, x) => {
995
+ var g, L, q;
996
+ const C = I("FmFormGroup"), u = I("FmButton");
997
+ return w(), A("div", zn, [
998
+ h(C, {
999
+ disabled: p.disabled,
1000
+ "model-value": p.modelValue,
1001
+ rules: [
1002
+ ...p.rules,
1003
+ () => n.value.length ? "There is a binding error in your configuration" : !0
1004
+ ]
1005
+ }, {
1006
+ label: N(() => x[4] || (x[4] = [
1007
+ _("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Define the inventory bindings for this recipe or ingredient. ", -1)
1008
+ ])),
1009
+ _: 1
1010
+ }, 8, ["disabled", "model-value", "rules"]),
1011
+ ((g = p.recipeBindingConfig) == null ? void 0 : g.enabled) !== !1 ? (w(), A("div", Ln, [
1012
+ _("div", Kn, [
1013
+ _("div", jn, K(m(v)("inventory.inventoryBindings.recipe")), 1),
1014
+ p.readonly ? S("", !0) : (w(), P(u, {
1015
+ key: 0,
1016
+ variant: "secondary",
1017
+ "text-color": "primary",
1018
+ "border-color": "primary",
1019
+ label: m(v)("inventory.inventoryBindings.linkRecipe"),
1020
+ "prepend-icon": "link",
1021
+ onClick: s
1022
+ }, null, 8, ["label"]))
1023
+ ]),
1024
+ _("div", On, [
1025
+ _("div", Yn, [
1026
+ _("div", qn, K(m(v)("inventory.inventoryBindings.recipe")), 1),
1027
+ x[5] || (x[5] = _("div", { class: "w-[200px]" }, null, -1)),
1028
+ p.recipeBindingConfig.ableToApplyRules ? (w(), A("div", Hn)) : S("", !0),
1029
+ p.readonly ? S("", !0) : (w(), A("div", Wn))
1030
+ ]),
1031
+ (w(!0), A(ee, null, se(e.value, (E) => {
1032
+ var T;
1033
+ return w(), P(Fn, {
1034
+ key: E.id,
1035
+ "model-value": E,
1036
+ "display-name": (T = r.value[E.id]) == null ? void 0 : T.name,
1037
+ "show-error": t.value.has(E.id),
1038
+ "show-settings-button": (p.recipeBindingConfig.ableToApplyRules && !p.readonly) === !0,
1039
+ readonly: p.readonly,
1040
+ disabled: p.disabled,
1041
+ "onUpdate:modelValue": x[0] || (x[0] = (M) => b(M)),
1042
+ onDelete: x[1] || (x[1] = (M) => V(M))
1043
+ }, null, 8, ["model-value", "display-name", "show-error", "show-settings-button", "readonly", "disabled"]);
1044
+ }), 128))
1045
+ ])
1046
+ ])) : S("", !0),
1047
+ _("div", Jn, [
1048
+ _("div", Qn, [
1049
+ _("div", Xn, K(m(v)("inventory.inventoryBindings.ingredient")), 1),
1050
+ p.readonly ? S("", !0) : (w(), P(u, {
1051
+ key: 0,
1052
+ variant: "secondary",
1053
+ "text-color": "primary",
1054
+ "border-color": "primary",
1055
+ label: m(v)("inventory.inventoryBindings.linkIngredient"),
1056
+ "prepend-icon": "link",
1057
+ onClick: o
1058
+ }, null, 8, ["label"]))
1059
+ ]),
1060
+ _("div", Zn, [
1061
+ _("div", et, [
1062
+ _("div", nt, K(m(v)("inventory.inventoryBindings.ingredient")), 1),
1063
+ _("div", tt, K(m(v)("inventory.inventoryBindings.amount")), 1),
1064
+ x[6] || (x[6] = _("div", { class: "w-[52px]" }, null, -1)),
1065
+ (L = p.skuBindingConfig) != null && L.ableToApplyRules || (q = p.skuBindingConfig) != null && q.ableToConfigureAlternative ? (w(), A("div", ot)) : S("", !0)
1066
+ ]),
1067
+ (w(!0), A(ee, null, se(B.value, (E) => {
1068
+ var T, M, W;
1069
+ return w(), P(Nn, {
1070
+ key: E.id,
1071
+ "model-value": E,
1072
+ "display-name": (T = c.value[E.id]) == null ? void 0 : T.name,
1073
+ unit: F(E),
1074
+ "show-error": t.value.has(E.id),
1075
+ "able-to-apply-rules": ((M = p.skuBindingConfig) == null ? void 0 : M.ableToApplyRules) === !0,
1076
+ "able-to-configure-alternative": ((W = p.skuBindingConfig) == null ? void 0 : W.ableToConfigureAlternative) === !0,
1077
+ readonly: p.readonly,
1078
+ disabled: p.disabled,
1079
+ "onUpdate:modelValue": x[2] || (x[2] = ($) => b($)),
1080
+ onDelete: x[3] || (x[3] = ($) => V($))
1081
+ }, null, 8, ["model-value", "display-name", "unit", "show-error", "able-to-apply-rules", "able-to-configure-alternative", "readonly", "disabled"]);
1082
+ }), 128))
1083
+ ])
1084
+ ])
1085
+ ]);
1086
+ };
1087
+ }
1088
+ }), lt = { class: "flex flex-col gap-40" }, at = {
1089
+ key: 0,
1090
+ class: "flex flex-col gap-16"
1091
+ }, st = {
1092
+ key: 0,
1093
+ class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
1094
+ }, rt = {
1095
+ key: 0,
1096
+ class: "flex flex-col items-center w-full h-full gap-24"
1097
+ }, dt = { key: 1 }, ut = { class: "mt-32" }, mt = /* @__PURE__ */ O({
1098
+ __name: "RecipeForm",
1099
+ props: {
1100
+ mode: {},
1101
+ modelValue: {},
1102
+ disabled: { type: Boolean }
1103
+ },
1104
+ emits: ["update:modelValue", "click:submit"],
1105
+ setup(f, { expose: k, emit: v }) {
1106
+ var C;
1107
+ const d = f, r = v, c = Ze(), { t: l } = Y(), a = R({
1108
+ get() {
1109
+ var u;
1110
+ return ((u = d.modelValue) == null ? void 0 : u.name) ?? "";
1111
+ },
1112
+ set(u) {
1113
+ const g = d.modelValue ?? {};
1114
+ g.name = u, r("update:modelValue", g);
1115
+ }
1116
+ }), n = R({
1117
+ get() {
1118
+ var u;
1119
+ return ((u = d.modelValue) == null ? void 0 : u.contains) ?? [];
1120
+ },
1121
+ set(u) {
1122
+ const g = d.modelValue ?? {};
1123
+ g.contains = u, r("update:modelValue", g);
1124
+ }
1125
+ }), t = R({
1126
+ get() {
1127
+ var u;
1128
+ return ((u = d.modelValue) == null ? void 0 : u.customAttributes) ?? {};
1129
+ },
1130
+ set(u) {
1131
+ const g = d.modelValue ? {
1132
+ ...d.modelValue
1133
+ } : {};
1134
+ g.customAttributes = u, r("update:modelValue", g);
1135
+ }
1136
+ }), e = R({
1137
+ get() {
1138
+ var u;
1139
+ return ((u = d.modelValue) == null ? void 0 : u.version) ?? null;
1140
+ },
1141
+ set(u) {
1142
+ const g = d.modelValue ? { ...d.modelValue } : {};
1143
+ g.version = u, r("update:modelValue", g);
1144
+ }
1145
+ }), i = R({
1146
+ get() {
1147
+ return e.value === "v2";
1148
+ },
1149
+ set(u) {
1150
+ e.value = u ? "v2" : null;
1151
+ }
1152
+ });
1153
+ function y() {
1154
+ r("click:submit");
1155
+ }
1156
+ const s = D();
1157
+ k({
1158
+ validateInputs: () => {
1159
+ var u, g;
1160
+ (g = (u = s.value) == null ? void 0 : u.validateInputs) == null || g.call(u);
1161
+ },
1162
+ resetInputsValidation: () => {
1163
+ var u, g;
1164
+ (g = (u = s.value) == null ? void 0 : u.resetInputsValidation) == null || g.call(u);
1165
+ },
1166
+ resetInputs: () => {
1167
+ var u, g;
1168
+ (g = (u = s.value) == null ? void 0 : u.resetInputs) == null || g.call(u);
1169
+ }
1170
+ });
1171
+ const B = z(), o = D([]), b = D(!1), V = D(!1);
1172
+ Ve(b, async (u) => {
1173
+ F(u);
1174
+ });
1175
+ async function F(u) {
1176
+ var g, L;
1177
+ u && !V.value && ((g = d.modelValue) != null && g._id) && (V.value = !0, o.value = await B.getAffectedMenu((L = d.modelValue) == null ? void 0 : L._id).delayed(500), V.value = !1);
1178
+ }
1179
+ const p = R(
1180
+ () => B.recipes.map((u) => ({ label: u.name, value: u.name }))
1181
+ ), x = D((C = d.modelValue) == null ? void 0 : C.name);
1182
+ return (u, g) => {
1183
+ const L = I("FmTextField"), q = I("FmSwitch"), E = I("FmCard"), T = I("FmSpacer"), M = I("FmCircularProgress"), W = I("FmForm");
1184
+ return w(), P(W, {
1185
+ ref_key: "formRef",
1186
+ ref: s,
1187
+ onValidationSuccess: y
1188
+ }, {
1189
+ default: N(() => [
1190
+ _("div", lt, [
1191
+ h(L, {
1192
+ disabled: u.disabled,
1193
+ label: m(l)("inventory.recipe.name"),
1194
+ "model-value": a.value,
1195
+ "onUpdate:modelValue": g[0] || (g[0] = ($) => a.value = $),
1196
+ rules: [
1197
+ m(Le)(),
1198
+ m(be)(p.value, x.value, ($) => `[${$.value}] already exists`)
1199
+ ],
1200
+ "label-mark": "required"
1201
+ }, null, 8, ["disabled", "label", "model-value", "rules"]),
1202
+ m(c).enableRecipeV2 ? (w(), A("div", at, [
1203
+ h(q, {
1204
+ modelValue: i.value,
1205
+ "onUpdate:modelValue": g[1] || (g[1] = ($) => i.value = $),
1206
+ value: !0,
1207
+ label: m(l)("inventory.recipe.enableRecipeV2"),
1208
+ "label-placement": "right",
1209
+ disabled: u.disabled,
1210
+ sublabel: m(l)("inventory.recipe.recipeV2Warning")
1211
+ }, null, 8, ["modelValue", "label", "disabled", "sublabel"])
1212
+ ])) : S("", !0),
1213
+ h(E, {
1214
+ variant: "outlined",
1215
+ class: "p-16"
1216
+ }, {
1217
+ default: N(() => {
1218
+ var $, Q;
1219
+ return [
1220
+ m(c).enableRecipeV2 ? (w(), P(it, {
1221
+ key: 0,
1222
+ id: ($ = u.modelValue) == null ? void 0 : $._id,
1223
+ disabled: u.disabled,
1224
+ "model-value": n.value,
1225
+ "onUpdate:modelValue": g[2] || (g[2] = (H) => n.value = H),
1226
+ rules: [m(ne)(1)],
1227
+ "enable-ingredient-group": m(c).enableIngredientGroup,
1228
+ "recipe-binding-config": { enabled: !i.value, ableToApplyRules: i.value },
1229
+ "sku-binding-config": {
1230
+ ableToConfigureAlternative: i.value
1231
+ }
1232
+ }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group", "recipe-binding-config", "sku-binding-config"])) : (w(), P(Ke, {
1233
+ key: 1,
1234
+ id: (Q = u.modelValue) == null ? void 0 : Q._id,
1235
+ disabled: u.disabled,
1236
+ "model-value": n.value,
1237
+ "onUpdate:modelValue": g[3] || (g[3] = (H) => n.value = H),
1238
+ rules: [m(ne)(1)],
1239
+ "enable-ingredient-group": m(c).enableIngredientGroup
1240
+ }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group"]))
1241
+ ];
1242
+ }),
1243
+ _: 1
1244
+ })
1245
+ ]),
1246
+ u.mode !== m(U).CREATE ? (w(), A("div", st, [
1247
+ h(q, {
1248
+ label: "Show binded items",
1249
+ modelValue: b.value,
1250
+ "onUpdate:modelValue": g[4] || (g[4] = ($) => b.value = $),
1251
+ "label-placement": "right",
1252
+ disabled: V.value
1253
+ }, null, 8, ["modelValue", "disabled"]),
1254
+ V.value ? (w(), A("div", rt, [
1255
+ h(T),
1256
+ _("div", null, [
1257
+ h(M, { size: "xl" })
1258
+ ]),
1259
+ g[6] || (g[6] = _("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
1260
+ h(T)
1261
+ ])) : b.value && o.value.length ? (w(), A("div", dt, [
1262
+ h(ve, {
1263
+ name: "Menu",
1264
+ bindings: o.value
1265
+ }, null, 8, ["bindings"])
1266
+ ])) : S("", !0)
1267
+ ])) : S("", !0),
1268
+ _("div", ut, [
1269
+ h(en, {
1270
+ entity: "inventoryRecipe",
1271
+ modelValue: t.value,
1272
+ "onUpdate:modelValue": g[5] || (g[5] = ($) => t.value = $)
1273
+ }, null, 8, ["modelValue"])
1274
+ ])
1275
+ ]),
1276
+ _: 1
1277
+ }, 512);
1278
+ };
1279
+ }
1280
+ }), ct = { class: "flex gap-4" }, pt = /* @__PURE__ */ O({
1281
+ __name: "RecipeDialog",
1282
+ props: {
1283
+ show: { type: Boolean },
1284
+ recipe: {},
1285
+ mode: { default: U.READ }
1286
+ },
1287
+ emits: ["update:show"],
1288
+ setup(f) {
1289
+ const k = f, v = z(), d = le(), { t: r } = Y(), c = ue(k, "show"), l = ue(k, "recipe"), a = R(() => {
1290
+ switch (k.mode) {
1291
+ case U.READ:
1292
+ return "";
1293
+ case U.UPDATE:
1294
+ return r("inventory.recipe.update.title");
1295
+ case U.CREATE:
1296
+ return r("inventory.recipe.create.title");
1297
+ }
1298
+ return "";
1299
+ }), n = R(() => {
1300
+ switch (k.mode) {
1301
+ case U.READ:
1302
+ return "";
1303
+ case U.UPDATE:
1304
+ return r("common.save");
1305
+ case U.CREATE:
1306
+ return r("common.add");
1307
+ }
1308
+ return "";
1309
+ }), t = D(), e = D(!1);
1310
+ async function i() {
1311
+ e.value = !0;
1312
+ try {
1313
+ const o = oe(l.value);
1314
+ o.precision ?? (o.precision = 0), o.measurements ?? (o.measurements = []), await v.createRecipe(o), c.value = !1, d.open({
1315
+ title: r("inventory.common.success"),
1316
+ message: r("inventory.recipe.create.success", { name: l.value.name }),
1317
+ type: "success"
1318
+ });
1319
+ } catch (o) {
1320
+ o instanceof de || d.open({
1321
+ title: r("inventory.recipe.create.error.title"),
1322
+ message: r("inventory.recipe.create.error.message"),
1323
+ type: "error"
1324
+ });
1325
+ } finally {
1326
+ e.value = !1;
1327
+ }
1328
+ }
1329
+ async function y() {
1330
+ e.value = !0;
1331
+ try {
1332
+ await v.updateRecipe(l.value), c.value = !1, d.open({
1333
+ title: r("inventory.common.success"),
1334
+ message: r("inventory.recipe.update.success", { name: l.value.name }),
1335
+ type: "success"
1336
+ });
1337
+ } catch (o) {
1338
+ o instanceof de || d.open({
1339
+ title: r("inventory.recipe.update.error.title"),
1340
+ message: r("inventory.recipe.update.error.message"),
1341
+ type: "error"
1342
+ });
1343
+ } finally {
1344
+ e.value = !1;
1345
+ }
1346
+ }
1347
+ function s() {
1348
+ var o, b;
1349
+ (b = (o = t.value) == null ? void 0 : o.validateInputs) == null || b.call(o);
1350
+ }
1351
+ function B() {
1352
+ switch (k.mode) {
1353
+ case U.READ:
1354
+ return;
1355
+ case U.UPDATE:
1356
+ return y();
1357
+ case U.CREATE:
1358
+ return i();
1359
+ }
1360
+ }
1361
+ return (o, b) => {
1362
+ const V = I("FmButton"), F = I("FmSideSheet");
1363
+ return w(), P(F, {
1364
+ "model-value": m(c),
1365
+ "onUpdate:modelValue": b[3] || (b[3] = (p) => re(c) ? c.value = p : null),
1366
+ header: a.value,
1367
+ "close-button": "",
1368
+ "dismiss-away": "",
1369
+ "max-width": 800
1370
+ }, {
1371
+ "side-sheet-footer": N(() => [
1372
+ _("div", ct, [
1373
+ h(V, {
1374
+ loading: e.value,
1375
+ label: n.value,
1376
+ onClick: s
1377
+ }, null, 8, ["loading", "label"]),
1378
+ h(V, {
1379
+ disabled: e.value,
1380
+ label: m(r)("common.close"),
1381
+ variant: "tertiary",
1382
+ onClick: b[2] || (b[2] = (p) => c.value = !1)
1383
+ }, null, 8, ["disabled", "label"])
1384
+ ])
1385
+ ]),
1386
+ default: N(() => [
1387
+ h(mt, {
1388
+ class: "w-full",
1389
+ ref_key: "hasValidationExpose",
1390
+ ref: t,
1391
+ modelValue: m(l),
1392
+ "onUpdate:modelValue": b[0] || (b[0] = (p) => re(l) ? l.value = p : null),
1393
+ mode: o.mode,
1394
+ disabled: e.value,
1395
+ "onClick:submit": b[1] || (b[1] = (p) => B())
1396
+ }, null, 8, ["modelValue", "mode", "disabled"])
1397
+ ]),
1398
+ _: 1
1399
+ }, 8, ["model-value", "header"]);
1400
+ };
1401
+ }
1402
+ });
1403
+ function ft(f) {
1404
+ return !f || Object.keys(f).length === 0 ? "" : Object.entries(f).map(([k, v]) => `${k}: ${v}`).join(", ");
1405
+ }
1406
+ function vt() {
1407
+ const f = z(), k = f.recipes, v = f.recipeById, d = f.skuById, r = f.skuGroupById, c = k.flatMap((n, t) => {
1408
+ var i;
1409
+ const e = ft(n.customAttributes);
1410
+ if ((i = n.contains) != null && i.length) {
1411
+ const y = n.contains.filter((o) => o.type === "RECIPE"), s = n.contains.filter((o) => o.type === "SKU"), B = n.contains.filter((o) => o.type === "SKU_GROUP");
1412
+ return [
1413
+ ...t === 0 ? [] : [["", "", "", "", "", "", ""]],
1414
+ ...y.map(
1415
+ (o, b) => {
1416
+ var V;
1417
+ return [
1418
+ b === 0 ? n.name : "",
1419
+ "RECIPE",
1420
+ "",
1421
+ (V = v[o.id]) == null ? void 0 : V.name,
1422
+ j(o.amount),
1423
+ "UNIT",
1424
+ b === 0 ? e : ""
1425
+ ];
1426
+ }
1427
+ ),
1428
+ ...s.map(
1429
+ (o, b) => {
1430
+ var V, F, p, x;
1431
+ return [
1432
+ !y.length && b === 0 ? n.name : "",
1433
+ "INGREDIENT",
1434
+ (V = d[o.id]) == null ? void 0 : V.code,
1435
+ (F = d[o.id]) == null ? void 0 : F.name,
1436
+ j(o.amount),
1437
+ o.measurement ? o.measurement.abbrev : (x = (p = d[o.id]) == null ? void 0 : p.unit) == null ? void 0 : x.abbrev,
1438
+ !y.length && b === 0 ? e : ""
1439
+ ];
1440
+ }
1441
+ ),
1442
+ ...B.map(
1443
+ (o, b) => {
1444
+ var V, F;
1445
+ return [
1446
+ y.length === 0 && s.length === 0 && b === 0 ? n.name : "",
1447
+ "SKU_GROUP",
1448
+ ((V = r[o.id]) == null ? void 0 : V.ref) || "",
1449
+ (F = r[o.id]) == null ? void 0 : F.name,
1450
+ j(o.amount),
1451
+ "UNIT",
1452
+ y.length === 0 && s.length === 0 && b === 0 ? e : ""
1453
+ ];
1454
+ }
1455
+ )
1456
+ ];
1457
+ }
1458
+ return [
1459
+ ...t === 0 ? [] : [["", "", "", "", "", "", ""]],
1460
+ [n.name, "No bindings", "", "", "", "", e]
1461
+ ];
1462
+ }), a = tn(c, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
1463
+ on(a, `RECIPE_${ln(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
1464
+ }
1465
+ const yt = { class: "flex flex-col py-8" }, bt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, gt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yt = /* @__PURE__ */ O({
1466
+ __name: "RecipeView",
1467
+ setup(f) {
1468
+ const k = z(), v = R(() => k.recipes), d = Ae(), { createRecipe: r, updateRecipe: c } = te(), { recipeDialogProps: l, recipeViewLoading: a } = Te(te()), { columnDefs: n, formatRowData: t } = mn(), e = R(() => t(v.value));
1469
+ ie(), le(), D(!1);
1470
+ function i(p) {
1471
+ if (p === "add")
1472
+ return r();
1473
+ if (p === "export")
1474
+ return vt();
1475
+ }
1476
+ const y = D(""), s = R(() => a.value), { breakpoints: B } = Re(), o = R(() => B.value.xs || B.value.sm), b = R(() => o.value ? 10 : 20), V = Me(), { t: F } = Y();
1477
+ return (p, x) => {
1478
+ const C = I("FmTable");
1479
+ return w(), P(Ge, {
1480
+ title: m(F)("inventory.recipe.title"),
1481
+ actions: [
1482
+ {
1483
+ label: m(F)("inventory.recipe.create.title"),
1484
+ value: "add",
1485
+ isPrimary: !0,
1486
+ prependIcon: "add"
1487
+ },
1488
+ { label: m(F)("common.export"), value: "export", isPrimary: !1 }
1489
+ ],
1490
+ "onClick:action": i
1491
+ }, {
1492
+ default: N(() => [
1493
+ _("div", {
1494
+ class: fe([
1495
+ "flex flex-col gap-8 max-h-full",
1496
+ {
1497
+ "p-0": o.value,
1498
+ "px-24 ": !o.value
1499
+ }
1500
+ ])
1501
+ }, [
1502
+ h(an, {
1503
+ searchable: "",
1504
+ search: y.value,
1505
+ "onUpdate:search": x[0] || (x[0] = (u) => y.value = u)
1506
+ }, null, 8, ["search"]),
1507
+ (w(), P(C, {
1508
+ style: ke(m(V).tableHeight),
1509
+ "column-defs": m(n),
1510
+ "row-data": e.value,
1511
+ "search-value": y.value,
1512
+ loading: !m(d)._currentLocation || s.value,
1513
+ onRowClick: x[1] || (x[1] = (u) => m(c)(u.original.original)),
1514
+ key: v.value.length,
1515
+ "page-size": b.value
1516
+ }, {
1517
+ "list-row": N((u) => [
1518
+ h(nn, {
1519
+ row: u,
1520
+ onRowClick: (g) => m(c)(g.original)
1521
+ }, {
1522
+ default: N((g) => {
1523
+ var L, q, E, T, M, W, $, Q, H, ae;
1524
+ return [
1525
+ _("div", yt, [
1526
+ _("div", bt, [
1527
+ h(m(pe), {
1528
+ render: (E = (q = (L = g.recipe) == null ? void 0 : L.column) == null ? void 0 : q.columnDef) == null ? void 0 : E.cell,
1529
+ props: (M = (T = g.recipe) == null ? void 0 : T.getContext) == null ? void 0 : M.call(T)
1530
+ }, null, 8, ["render", "props"])
1531
+ ]),
1532
+ _("div", gt, [
1533
+ h(m(pe), {
1534
+ render: (Q = ($ = (W = g.ingredients) == null ? void 0 : W.column) == null ? void 0 : $.columnDef) == null ? void 0 : Q.cell,
1535
+ props: (ae = (H = g.ingredients) == null ? void 0 : H.getContext) == null ? void 0 : ae.call(H)
1536
+ }, null, 8, ["render", "props"])
1537
+ ])
1538
+ ])
1539
+ ];
1540
+ }),
1541
+ _: 2
1542
+ }, 1032, ["row", "onRowClick"])
1543
+ ]),
1544
+ _: 1
1545
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1546
+ ], 2),
1547
+ (w(), P(Be, { to: "body" }, [
1548
+ h(pt, we(xe(m(l))), null, 16)
1549
+ ]))
1550
+ ]),
1551
+ _: 1
1552
+ }, 8, ["title", "actions"]);
1553
+ };
1554
+ }
1555
+ });
1556
+ export {
1557
+ Yt as default
1558
+ };