@feedmepos/mf-inventory-portal 1.8.0-dev.2 → 1.8.0-dev.21

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 (248) hide show
  1. package/dist/App-BxpqrT2x.js +1445 -0
  2. package/dist/{ApprovalView-RaXuWWSu.js → ApprovalView-DZBM9n1Y.js} +26 -25
  3. package/dist/{BindingsDialog-DomvXijP.js → BindingsDialog-jjHrmqY_.js} +2 -2
  4. package/dist/{BindingsPicker-DGnzxEs7.js → BindingsPicker-Dv1KwHIQ.js} +2 -2
  5. package/dist/{BindingsTable-DfG9kWrv.js → BindingsTable-Ch_TlrZu.js} +10 -10
  6. package/dist/BulkReceiveRequestPage-BVB3PNxF.js +2839 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CVekIoiN.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DpHYhOmI.js} +1 -1
  8. package/dist/{ClosingDraftView-C3n66bbh.js → ClosingDraftView-DQQkWYOh.js} +748 -746
  9. package/dist/ClosingHistoryView-CXXd0Csp.js +769 -0
  10. package/dist/{ClosingTemplateView-DwGloYxn.js → ClosingTemplateView-Bf5Ivxjw.js} +22 -21
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-9eY_r8LF.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-C3Y_rwNE.js} +1 -1
  12. package/dist/{DefaultView-JC_e4xgC.js → DefaultView-Bt8ZFV10.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-BBCvI67S.js → DeliveryOrderPrintPreview-BS5ZKe1f.js} +15 -15
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-H4FWc9ga.js → EmailDialog.vue_vue_type_script_setup_true_lang-BvDFKrFF.js} +10077 -9950
  15. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-B389iY-f.js +48 -0
  16. package/dist/FeatureCapabilityGate-BAOroN-j.js +82 -0
  17. package/dist/FeaturePageGate.vue_vue_type_script_setup_true_lang-Xapa8xyy.js +189 -0
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Q8Mptiv3.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CgbvPK8u.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CE1_yyHe.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DnCj1qv6.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CGJi3f86.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CUb4VGOc.js} +2 -2
  21. package/dist/{FmMultiselectDialog-DCaRlBIy.js → FmMultiselectDialog-Bz8bNuK2.js} +2 -2
  22. package/dist/FmMultiselectDialog-CosTDuNE.js +123 -0
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-ClaLVtpK.js → FmUnitInput.vue_vue_type_script_setup_true_lang-3OrHiybe.js} +105 -99
  24. package/dist/ImportView-BoTmcCyn.js +1540 -0
  25. package/dist/{IngredientsView-DPj9lBTK.js → IngredientsView-VED94pGW.js} +691 -689
  26. package/dist/{IntegrationExplorerView-CO2wpUR_.js → IntegrationExplorerView-B9ZY9hG1.js} +1537 -1620
  27. package/dist/IntegrationPlatformView-Bar1zj3R.js +13385 -0
  28. package/dist/{IntegrationView-DIeZoey0.js → IntegrationView-BvzBDBGp.js} +2604 -2565
  29. package/dist/{InventoryBindingForm-Cj4_Chue.js → InventoryBindingForm-DWhXHIaL.js} +1 -1
  30. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-mZRrPywY.js +472 -0
  31. package/dist/{InventoryBindingSummary-yzGzd7jJ.js → InventoryBindingSummary-Imo2J8O2.js} +1 -1
  32. package/dist/JsonViewer.vue_vue_type_script_setup_true_lang-C_hg75l0.js +25 -0
  33. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CChCnKxa.js +79 -0
  34. package/dist/PlanTierBadge.vue_vue_type_script_setup_true_lang-CM3gtYZo.js +19 -0
  35. package/dist/PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-0F-yOcPC.js +79 -0
  36. package/dist/PremiumUpgradePage.vue_vue_type_script_setup_true_lang-DGAxPOEh.js +58 -0
  37. package/dist/ProductionRunDetailPage-KFKeWhhY.js +2317 -0
  38. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-BYyiiAWb.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-CobaPkUr.js} +3053 -3163
  39. package/dist/ProductionRunPage-BrXsPo-A.js +954 -0
  40. package/dist/{PublishView-CPK9NeVF.js → PublishView-_k3N44Pl.js} +3 -3
  41. package/dist/{PurchaseOrderPrintPreview-DosqWQeN.js → PurchaseOrderPrintPreview-DXVEhy-G.js} +17 -17
  42. package/dist/{ReceiveRequestView-BxSkpK2t.js → ReceiveRequestView-ByWddqiL.js} +17 -16
  43. package/dist/RecipeView-C29uNZxj.js +3272 -0
  44. package/dist/SettingsView-CyE6ZM8x.js +1005 -0
  45. package/dist/StockView-BBR404Ie.js +3003 -0
  46. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-GdGJCuc0.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Cmnk66T9.js} +1 -1
  47. package/dist/{SupplierView-BKxKoi_0.js → SupplierView-CIB5GCwp.js} +304 -301
  48. package/dist/{SurchargeView-Db4cwhZv.js → SurchargeView-DNtEbO7I.js} +7 -7
  49. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-CpkF77Ow.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-ClCi5rLI.js} +2 -2
  50. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-gJQQKKAC.js +71 -0
  51. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-C19KOLrQ.js +332 -0
  52. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DD5nMsrn.js +4953 -0
  53. package/dist/TransferTemplateView-BftwH1_W.js +2347 -0
  54. package/dist/{UnitCostHistoryView-CqcyjCCd.js → UnitCostHistoryView-CE-1joTV.js} +4 -4
  55. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DO80_8SZ.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-reJFavQF.js} +4 -4
  56. package/dist/{UnitView-BqdK1AM_.js → UnitView-T-Vo8IpV.js} +111 -106
  57. package/dist/{WarehouseView-COJM9IXM.js → WarehouseView-CzQcj5VY.js} +12 -11
  58. package/dist/{WastageTemplateView-DW3viTHN.js → WastageTemplateView-Cm5_V2zN.js} +19 -18
  59. package/dist/api/bill.d.ts +4 -2
  60. package/dist/api/bill.spec.d.ts +1 -0
  61. package/dist/api/closing.d.ts +1 -0
  62. package/dist/api/feature-flags.d.ts +4 -0
  63. package/dist/api/integration-sync-log.d.ts +0 -13
  64. package/dist/api/license.d.ts +0 -2
  65. package/dist/api/netsuite-explorer.d.ts +1 -0
  66. package/dist/api/stock.d.ts +1 -1
  67. package/dist/{app-yvK__CBL.js → app-DnOtng5V.js} +10177 -10126
  68. package/dist/app.d.ts +151 -164
  69. package/dist/app.js +1 -1
  70. package/dist/bulk-edit-simulation.helper-BZRyNbpM.js +178 -0
  71. package/dist/{closing-template-DezidSM0.js → closing-template-BiJRchG9.js} +4 -4
  72. package/dist/components/FeatureCapabilityBadge.vue.d.ts +4 -0
  73. package/dist/components/FeatureCapabilityGate.spec.d.ts +1 -0
  74. package/dist/components/FeatureCapabilityGate.vue.d.ts +5 -0
  75. package/dist/components/FeatureGateLayout.vue.d.ts +11 -0
  76. package/dist/components/FeaturePageGate.spec.d.ts +1 -0
  77. package/dist/components/FeaturePageGate.vue.d.ts +34 -0
  78. package/dist/components/FmAdminCollapsiblePanel.vue.d.ts +1 -1
  79. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  80. package/dist/components/FmInventoryTableToolbar.vue.d.ts +2 -2
  81. package/dist/components/FmUnitInputProps.d.ts +1 -0
  82. package/dist/components/FmUnitInputRules.d.ts +1 -1
  83. package/dist/components/HrmPermissionGuard.vue.d.ts +1 -1
  84. package/dist/components/NumberPrecisionInput.spec.d.ts +1 -0
  85. package/dist/{views/ingredient-group/IngredientGroupView.vue.d.ts → components/PremiumUpgradePage.vue.d.ts} +0 -1
  86. package/dist/components/TemplatePublishDialog.d.ts +2 -0
  87. package/dist/components/TemplatePublishDialog.spec.d.ts +1 -0
  88. package/dist/composable/defineApi.d.ts +1 -1
  89. package/dist/{date2-2XjepIqc.js → date2-Bzlk0lSj.js} +1 -1
  90. package/dist/{dayjs.min-CNp5DLBB.js → dayjs.min-B8gqMYa7.js} +1 -1
  91. package/dist/{decimal-Z7oJdGk8.js → decimal-utE08Cjv.js} +2 -2
  92. package/dist/{defineDeepModel-CMxJn_H2.js → defineDeepModel-D_tKNP-n.js} +5 -5
  93. package/dist/{duplicate-template-BetV5oy_.js → duplicate-template-lCi99jVD.js} +1 -1
  94. package/dist/{feature-CkWaZ-5K.js → feature-Zeyz4pJe.js} +2089 -2854
  95. package/dist/feature-flags/core.d.ts +4 -2
  96. package/dist/feature-flags/portal-feature-catalog.d.ts +1 -6
  97. package/dist/feature-flags/portal-feature-catalog.spec.d.ts +1 -0
  98. package/dist/feature-flags/vue.d.ts +24 -1
  99. package/dist/feature-flags/vue.spec.d.ts +1 -0
  100. package/dist/{format-time-from-id-DatSI9uD.js → format-time-from-id-v_KvI4jM.js} +1 -1
  101. package/dist/{format-unit-display-DM5We5cx.js → format-unit-display-C8oexlpM.js} +209 -208
  102. package/dist/helper/country.spec.d.ts +1 -0
  103. package/dist/helper/menu-usage-module.d.ts +2 -1
  104. package/dist/helper/number.d.ts +5 -1
  105. package/dist/helper/rules.d.ts +1 -1
  106. package/dist/{id-to-date-Dxw2jKhy.js → id-to-date-Doi1vn9Q.js} +1 -1
  107. package/dist/{import-export.helper-BOmADwUw.js → import-export.helper-DyRPa4wa.js} +17 -17
  108. package/dist/{index-CIH9NCvs.js → index-B-SVjo8N.js} +1 -1
  109. package/dist/{index-ClYgfwW7.js → index-Bl8qrC1m.js} +2234 -2163
  110. package/dist/{JsonViewer.vue_vue_type_script_setup_true_lang-ig2zSXAB.js → index-C25C1Dg7.js} +1074 -1066
  111. package/dist/{index-7fz5sGDO.js → index-DZ9i-1uy.js} +3 -3
  112. package/dist/index-eGvSlWMU.js +1892 -0
  113. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -1
  114. package/dist/{lz-string-CCsc2X7t.js → lz-string-pPNhTzCj.js} +1 -1
  115. package/dist/menu-usage-module-Bq_KLsO4.js +74 -0
  116. package/dist/{netsuite-COumFXC2.js → netsuite-C5s0JXRA.js} +254 -263
  117. package/dist/netsuite-explorer-BF-bujxD.js +79 -0
  118. package/dist/{predefined-templates-Bw9A9LNA.js → predefined-templates-C6hmqqhm.js} +1 -1
  119. package/dist/production-run-list-DR1WsaBR.js +61 -0
  120. package/dist/{purchase-order-template-BaZjdGq8.js → purchase-order-template-C0XlITpK.js} +1 -1
  121. package/dist/{recalculationUtils-t32wAurN.js → recalculationUtils-CnzCEyIJ.js} +1 -1
  122. package/dist/router/name.d.ts +2 -2
  123. package/dist/{row-action.enum-BDeudY4d.js → row-action.enum-Ci5mHFdS.js} +1 -1
  124. package/dist/rules-rAD4INHX.js +243 -0
  125. package/dist/{stock-B59sfN28.js → stock-CukGlv0u.js} +1 -1
  126. package/dist/stock-DUQYl3xe.js +78 -0
  127. package/dist/stores/feature.d.ts +41 -11
  128. package/dist/stores/feature.load-state.spec.d.ts +1 -0
  129. package/dist/stores/inventory.d.ts +0 -47
  130. package/dist/stores/inventory.no-location.spec.d.ts +1 -0
  131. package/dist/stores/supplier.d.ts +1 -1
  132. package/dist/stores/warehouse.d.ts +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/{supplier-DnbLJ_cS.js → supplier-CDPdi2B5.js} +2 -2
  135. package/dist/{surcharge-C1uE3uQa.js → surcharge-XABFccMt.js} +1 -1
  136. package/dist/tsconfig.app.tsbuildinfo +1 -1
  137. package/dist/{uom-rules-DjfyrFHJ.js → uom-rules-BbNTM-Xw.js} +1 -1
  138. package/dist/{use-ingredient-select-dialog-7A7fWyEH.js → use-ingredient-select-dialog-CxrFXfoM.js} +2 -2
  139. package/dist/use-inventory-binding-dialog-BZpguHE1.js +113 -0
  140. package/dist/{use-template-enabled-locations-C-Hqqgzt.js → use-template-enabled-locations-B9n-uc36.js} +2 -2
  141. package/dist/{use-transfer-locations-CqsXvOI2.js → use-transfer-locations-z78M6XgR.js} +14 -14
  142. package/dist/{useHrmPermission-BzwD3Ctc.js → useHrmPermission-CfMWeFGZ.js} +1 -1
  143. package/dist/{useNavigationMenu-PrZg9HS7.js → useNavigationMenu-B6dCSflb.js} +111 -117
  144. package/dist/{useSseClient-FCyLWq8k.js → useSseClient-ICUObHUB.js} +1 -1
  145. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +2 -2
  146. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +1 -1
  147. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -1
  148. package/dist/views/import/helper/submit-rows.d.ts +1 -1
  149. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +0 -1
  150. package/dist/views/ingredients/components/inventory-binding/composables/use-inventory-binding-dialog.d.ts +0 -1
  151. package/dist/views/ingredients/components/inventory-binding/recipe-amount-validation.spec.d.ts +1 -0
  152. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +0 -1
  153. package/dist/views/ingredients/components/inventory-binding/v2/composables/use-inventory-binding-dialog.d.ts +0 -1
  154. package/dist/views/ingredients/helper/is-linked-ingredient-error.d.ts +3 -1
  155. package/dist/views/{ingredient-group/components/ingredient-group-rule-field/IngredientGroupRuleField.vue.d.ts → integration/IntegrationPlatformView.vue.d.ts} +11 -24
  156. package/dist/views/integration/components/Synergy/importFn.spec.d.ts +1 -0
  157. package/dist/views/integration/components/Xilnex/importFn.spec.d.ts +1 -0
  158. package/dist/views/integration/helper/opening-balance.d.ts +22 -0
  159. package/dist/views/integration/helper/opening-balance.spec.d.ts +1 -0
  160. package/dist/views/production-run/ProductionRunDetailPage.spec.d.ts +1 -0
  161. package/dist/views/{integration/components/IntegrationSyncLogTab.vue.d.ts → production-run/ProductionRunDetailPage.vue.d.ts} +2 -2
  162. package/dist/views/production-run/ProductionRunPage.vue.d.ts +2 -0
  163. package/dist/views/production-run/features/detail/ProductionRunItemsTable.vue.d.ts +2 -2
  164. package/dist/views/production-run/features/detail/ProductionRunOverviewTab.vue.d.ts +4 -4
  165. package/dist/views/production-run/features/detail/use-production-run-detail.d.ts +19 -9
  166. package/dist/views/production-run/features/lifecycle/CancelRunDialog.vue.d.ts +4 -4
  167. package/dist/views/production-run/features/lifecycle/CloseRunDialog.vue.d.ts +4 -4
  168. package/dist/views/production-run/features/lifecycle/ProductionRunLifecycleDialogs.vue.d.ts +14 -14
  169. package/dist/views/production-run/features/lifecycle/TargetReachedDialog.vue.d.ts +4 -4
  170. package/dist/views/production-run/features/planning/ProductionRunFormDialog.vue.d.ts +4 -4
  171. package/dist/views/production-run/features/planning/ProductionRunPlanner.vue.d.ts +1 -1
  172. package/dist/views/production-run/features/planning/use-production-run-duplicate-sources.d.ts +6 -6
  173. package/dist/views/production-run/shared/helpers/production-run-navigation.d.ts +0 -1
  174. package/dist/views/production-run/shared/model/production-run-list.d.ts +1 -1
  175. package/dist/views/production-run/shared/ui/ProductionRunInfoBadge.vue.d.ts +1 -1
  176. package/dist/views/production-run/shared/ui/ProductionRunInfoText.vue.d.ts +1 -1
  177. package/dist/views/production-run/shared/ui/ProductionRunScrollHint.vue.d.ts +2 -2
  178. package/dist/views/production-run/shared/ui/ProductionRunTextarea.vue.d.ts +3 -3
  179. package/dist/views/receive-request/composables/netsuite-order-label.d.ts +11 -0
  180. package/dist/views/receive-request/composables/netsuite-order-label.spec.d.ts +1 -0
  181. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +1 -1
  182. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +9 -9
  183. package/dist/views/receive-request/composables/use-receive-request-form.spec.d.ts +1 -0
  184. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +7 -7
  185. package/dist/views/receive-request/import/export.spec.d.ts +1 -0
  186. package/dist/views/receive-request-bulk/BulkReceiveRequestPage.vue.d.ts +2 -0
  187. package/dist/views/receive-request-bulk/components/CreateTransferWizard.spec.d.ts +1 -0
  188. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +20 -20
  189. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.readiness.spec.d.ts +1 -0
  190. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-table.d.ts +2 -2
  191. package/dist/views/recipe/components/recipe-bulk-editor/components/ModificationCard.spec.d.ts +1 -0
  192. package/dist/views/recipe/helper/bulk-edit-simulation.helper.d.ts +0 -1
  193. package/dist/views/recipe/helper/import-recipe.d.ts +32 -2
  194. package/dist/views/recipe/helper/import-recipe.spec.d.ts +1 -0
  195. package/dist/views/settings/PlanLicenseDisplay.spec.d.ts +1 -0
  196. package/dist/views/settings/PlanLicenseDisplay.vue.d.ts +2 -0
  197. package/dist/views/stock/components/StockRecordCard.spec.d.ts +1 -0
  198. package/dist/views/stock/components/StockRecordCard.vue.d.ts +19 -865
  199. package/dist/views/stock/components/dialog/AmendAdjustmentForm.spec.d.ts +1 -0
  200. package/dist/views/stock/components/dialog/BillInventoryInfoDialog.spec.d.ts +1 -0
  201. package/dist/views/stock/components/dialog/BillInventoryInfoDialog.vue.d.ts +36 -0
  202. package/dist/views/stock/components/dialog/ConvertSkuDialog.spec.d.ts +1 -0
  203. package/dist/views/stock/composables/use-last-closing-summary.d.ts +4 -0
  204. package/dist/views/stock/composables/use-last-closing-summary.spec.d.ts +1 -0
  205. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.spec.d.ts +1 -0
  206. package/dist/views/transfer-template/helpers/template-item.error.helper.spec.d.ts +1 -0
  207. package/dist/views/unit/composables/use-unit-form.spec.d.ts +1 -0
  208. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -2
  209. package/dist/vue-DBxqzbt5.js +295 -0
  210. package/dist/{vue-i18n-C34f-Tph.js → vue-i18n-CdbY8MsR.js} +539 -539
  211. package/dist/{xlsx.util-X4amwe_k.js → xlsx.util-CD5NablT.js} +2 -2
  212. package/package.json +71 -66
  213. package/dist/App-DVHgBTHP.js +0 -1499
  214. package/dist/BulkReceiveRequestView-DxHWrfbi.js +0 -2656
  215. package/dist/ClosingHistoryView-kdpYGy1Y.js +0 -761
  216. package/dist/DeprecateSoonWarningDialog.vue_vue_type_script_setup_true_lang-5Cc08Svt.js +0 -58
  217. package/dist/FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-C1C8aDA6.js +0 -61
  218. package/dist/FmMultiselectDialog-yVPY5aBV.js +0 -77
  219. package/dist/ImportView-DQrVMzxN.js +0 -1302
  220. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-7lT5UZc8.js +0 -51
  221. package/dist/IngredientGroupView-BMUnEaY7.js +0 -1000
  222. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-CaBOK7NC.js +0 -563
  223. package/dist/NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DzzTPdyF.js +0 -72
  224. package/dist/ProductionRunDetailView-Cw-ecaey.js +0 -2312
  225. package/dist/ProductionRunView-C11eseXQ.js +0 -930
  226. package/dist/RecipeView-oHDWsT0P.js +0 -3624
  227. package/dist/SettingsView-QlUNwFhM.js +0 -983
  228. package/dist/StockView-a8LbVZ_7.js +0 -2614
  229. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js +0 -84
  230. package/dist/TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CCCj4WVF.js +0 -299
  231. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CFNPXqt5.js +0 -4796
  232. package/dist/TransferTemplateView-CzwxOBMQ.js +0 -2326
  233. package/dist/menu-usage-module-BdjYEk3s.js +0 -57
  234. package/dist/number-gSLvxNqA.js +0 -138
  235. package/dist/portal-feature-catalog-yGIESKTc.js +0 -246
  236. package/dist/random-CSbEbElR.js +0 -10
  237. package/dist/rules-C1btu0Md.js +0 -98
  238. package/dist/stock-BF86TMW0.js +0 -75
  239. package/dist/use-inventory-binding-dialog-Cc1tjTfV.js +0 -152
  240. package/dist/usePromise-CbVUCxhj.js +0 -29
  241. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialog.vue.d.ts +0 -31
  242. package/dist/views/ingredient-group/components/ingredient-group-dialog/IngredientGroupDialogProps.d.ts +0 -10
  243. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupForm.vue.d.ts +0 -21
  244. package/dist/views/ingredient-group/components/ingredient-group-form/IngredientGroupFormProps.d.ts +0 -12
  245. package/dist/views/ingredient-group/composables/use-ingredient-group-actions.d.ts +0 -24
  246. package/dist/views/ingredient-group/composables/use-ingredient-group-rule-item.d.ts +0 -31
  247. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +0 -77
  248. package/dist/views/integration/composables/use-integration-sync-log.d.ts +0 -45
@@ -1,3624 +0,0 @@
1
- import { defineComponent as le, ref as W, onMounted as pt, resolveComponent as G, createElementBlock as V, openBlock as g, Fragment as Q, createElementVNode as y, toDisplayString as U, createVNode as x, createCommentVNode as T, h as re, computed as F, watch as ue, unref as n, withCtx as J, createBlock as Y, renderList as me, isRef as Me, mergeProps as Ie, createTextVNode as mt, withModifiers as ft, normalizeClass as De, normalizeStyle as vt, Teleport as yt, normalizeProps as bt, guardReactiveProps as gt } from "vue";
2
- import { a as ne, c as Oe, S as _t, F as ge, u as tt, t as kt, v as ht, j as Je } from "./app-yvK__CBL.js";
3
- import { useDialog as je, useSnackbar as Le, components as ye, useProxiedModel as Ge, useBreakpoints as xt } from "@feedmepos/ui-library";
4
- import { i as wt, _ as $t, m as It } from "./menu-usage-module-BdjYEk3s.js";
5
- import { F as de } from "./form-mode.enum-BKiNVH6A.js";
6
- import { _ as nt } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-7lT5UZc8.js";
7
- import { defineStore as ot, storeToRefs as Et } from "pinia";
8
- import { D as He, R as Ve } from "./row-action.enum-BDeudY4d.js";
9
- import { c as Vt } from "./component-BmLAdDiY.js";
10
- import { a as Z, c as Ke } from "./number-gSLvxNqA.js";
11
- import { useI18n as ie, useCoreStore as St } from "@feedmepos/mf-common";
12
- import { u as Ct, _ as Bt } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DpwneGOV.js";
13
- import { b as it, c as qe, I as Rt, A as Ne, U as lt, R as Ft } from "./rules-C1btu0Md.js";
14
- import { a as At, _ as Tt } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-CaBOK7NC.js";
15
- import { a as Ue } from "./FmMultiselectDialog-DCaRlBIy.js";
16
- import { d as at } from "./defineDeepModel-CMxJn_H2.js";
17
- import { L as Ut, P as Pt, D as Mt } from "./app-C39bYJmq.js";
18
- import { _ as Ce, c as Dt, d as Gt, e as be } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-ClaLVtpK.js";
19
- import { u as Nt } from "./FmMultiselectDialog-yVPY5aBV.js";
20
- import { u as zt } from "./vue-i18n-C34f-Tph.js";
21
- import { F as Ot, u as We } from "./feature-CkWaZ-5K.js";
22
- import { _ as jt } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-CG1m-B2p.js";
23
- import { F as he } from "./decimal-Z7oJdGk8.js";
24
- import { _ as Be } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CE1_yyHe.js";
25
- import { b as rt, d as st } from "./xlsx.util-X4amwe_k.js";
26
- import { f as dt } from "./date2-2XjepIqc.js";
27
- import { _ as Lt, F as Qe } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DAMpuZ1X.js";
28
- import { _ as Kt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CGJi3f86.js";
29
- const qt = {
30
- key: 0,
31
- class: "flex flex-col items-center w-full h-full gap-24"
32
- }, Wt = { key: 1 }, Yt = { key: 0 }, Jt = /* @__PURE__ */ le({
33
- __name: "DeleteDialog",
34
- props: {
35
- type: {},
36
- data: {},
37
- message: {},
38
- bindedItems: {}
39
- },
40
- setup(m) {
41
- const s = m, l = W(s.bindedItems || []), t = W(!1);
42
- pt(() => {
43
- o();
44
- });
45
- async function o() {
46
- var a, $;
47
- !t.value && ((a = s.data) != null && a._id) && (t.value = !0, l.value = await ne().getAffectedMenu(($ = s.data) == null ? void 0 : $._id), t.value = !1);
48
- }
49
- return (a, $) => {
50
- const d = G("FmSpacer"), r = G("FmCircularProgress");
51
- return g(), V(Q, null, [
52
- y("p", null, U(a.message), 1),
53
- t.value ? (g(), V("div", qt, [
54
- x(d),
55
- y("div", null, [
56
- x(r, { size: "xl" })
57
- ]),
58
- $[0] || ($[0] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
59
- x(d)
60
- ])) : (g(), V("div", Wt, [
61
- $[2] || ($[2] = y("br", null, null, -1)),
62
- l.value.length > 0 ? (g(), V("div", Yt, [
63
- $[1] || ($[1] = y("p", { class: "fm-typo-en-body-lg-600" }, "Affected menu items:", -1)),
64
- x(nt, {
65
- name: "Menu",
66
- bindings: l.value
67
- }, null, 8, ["bindings"])
68
- ])) : T("", !0)
69
- ]))
70
- ], 64);
71
- };
72
- }
73
- }), ze = ot("recipeForm", function() {
74
- const s = je(), l = Le(), t = ne(), o = W(!1), a = W();
75
- function $() {
76
- const i = {
77
- recipe: {},
78
- mode: de.CREATE,
79
- show: !0,
80
- "onUpdate:show"(f) {
81
- a.value.show = f;
82
- }
83
- };
84
- a.value = i;
85
- }
86
- async function d(i) {
87
- const f = {
88
- recipe: Oe(i),
89
- mode: de.UPDATE,
90
- show: !0,
91
- "onUpdate:show"(v) {
92
- a.value.show = v;
93
- }
94
- };
95
- a.value = f;
96
- }
97
- async function r(i) {
98
- o.value = !0;
99
- try {
100
- await t.deleteRecipe(i), l.open({
101
- title: "Success",
102
- message: `Deleted ${i.name}`,
103
- type: "success"
104
- });
105
- } catch (f) {
106
- if (f instanceof _t && wt(f)) {
107
- s.open({
108
- title: "Cannot delete recipe",
109
- contentComponent: $t,
110
- contentComponentProps: {
111
- subject: (i == null ? void 0 : i.name) ?? "",
112
- items: f.errorResponse.errors.map((v) => {
113
- var C;
114
- return {
115
- chain: [
116
- {
117
- itemName: v.name,
118
- moduleKey: (C = v.message) != null && C.startsWith("modules.") ? It(v.message) : v.module
119
- }
120
- ]
121
- };
122
- })
123
- },
124
- secondaryActions: {
125
- text: "Close",
126
- close: !0
127
- }
128
- });
129
- return;
130
- }
131
- l.open({
132
- title: `Cannot delete ${i == null ? void 0 : i.name}`,
133
- message: "Please try again.",
134
- type: "error"
135
- }), console.error("failed to delete recipe", f);
136
- } finally {
137
- o.value = !1;
138
- }
139
- }
140
- function u(i) {
141
- s.open({
142
- title: `Delete ${(i == null ? void 0 : i.name) ?? "recipe"}?`,
143
- closeButton: !1,
144
- primaryActions: {
145
- text: "Delete",
146
- close: !0,
147
- variant: "destructive"
148
- },
149
- secondaryActions: {
150
- text: "Cancel",
151
- close: !0
152
- },
153
- contentComponent: Jt,
154
- contentComponentProps: {
155
- type: "menu",
156
- data: i,
157
- message: "You may not be able to delete this recipe if it is linked in any of the inventory modules."
158
- }
159
- }).onPrimary(() => r(i));
160
- }
161
- return {
162
- createRecipe: $,
163
- updateRecipe: d,
164
- deleteRecipe: u,
165
- recipeDialogProps: a,
166
- recipeViewLoading: o
167
- };
168
- });
169
- function Ht() {
170
- const { updateRecipe: m, deleteRecipe: s } = ze(), l = ne(), { t } = ie();
171
- async function o(i, f) {
172
- const v = Oe(f);
173
- if (i === Ve.Edit) {
174
- await m(v);
175
- return;
176
- }
177
- if (i === Ve.Delete) {
178
- await s(v);
179
- return;
180
- }
181
- }
182
- function a(i, f) {
183
- const v = i.filter((c) => c.type === ge.enum.SKU), C = i.filter(
184
- (c) => c.type === ge.enum.SKU_GROUP
185
- ), w = i.filter((c) => c.type === ge.enum.RECIPE);
186
- return [
187
- ...v.map((c) => ({ ...c, recipeIds: [...f] })),
188
- ...C.map((c) => ({ ...c, isGroup: !0, recipeIds: [...f] })),
189
- ...w.filter((c) => l.recipeById[c.id] && !f.has(c.id)).flatMap(
190
- (c) => a(l.recipeById[c.id].contains, /* @__PURE__ */ new Set([...f, c.id]))
191
- )
192
- ];
193
- }
194
- const $ = [
195
- {
196
- accessorKey: "recipe",
197
- header: () => t("inventory.recipe.name"),
198
- size: 400
199
- },
200
- {
201
- accessorKey: "ingredients",
202
- header: () => t("inventory.recipe.ingredients"),
203
- size: "auto",
204
- // accessor keeps the plain text so filtering still matches; the cell only restyles it
205
- cell: (i) => re(
206
- "div",
207
- { class: "flex flex-col items-start gap-4" },
208
- i.row.original.bindings.map(
209
- (f) => re(
210
- "div",
211
- {
212
- class: "flex flex-wrap items-center gap-8 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-md px-8 py-4"
213
- },
214
- [
215
- f.parentRecipe ? re(ye.FmChip, { compact: !0 }, f.parentRecipe) : null,
216
- f.labels.join(", ")
217
- ]
218
- )
219
- )
220
- )
221
- },
222
- {
223
- id: "action",
224
- header: "",
225
- cell(i) {
226
- return Vt(
227
- [He[Ve.Edit], He[Ve.Delete]],
228
- (f) => {
229
- o(f, i.row.original.original);
230
- }
231
- );
232
- },
233
- enableSorting: !1,
234
- size: 40,
235
- meta: {
236
- cellClass: "",
237
- headerClass: ""
238
- }
239
- }
240
- ];
241
- function d(i) {
242
- const f = ne();
243
- return a(i.contains, /* @__PURE__ */ new Set([i._id])).map((v) => {
244
- var c, k, I;
245
- const C = v.recipeIds.slice(1).length ? ((c = f.recipeById[v.recipeIds.at(-1) ?? ""]) == null ? void 0 : c.name) ?? null : null;
246
- if (v.isGroup) {
247
- const _ = f.skuGroupById[v.id];
248
- return _ ? { parentRecipe: C, label: `${_.name} (x${Z(v.amount)})` } : null;
249
- }
250
- const w = f.skuById[v.id];
251
- return w ? {
252
- parentRecipe: C,
253
- label: `${w.name} (${Z(v.amount)}${((k = v.measurement) == null ? void 0 : k.abbrev) ?? ((I = w == null ? void 0 : w.unit) == null ? void 0 : I.abbrev)})`
254
- } : null;
255
- }).filter((v) => !!v);
256
- }
257
- function r(i) {
258
- const f = [];
259
- for (const v of i) {
260
- const C = v.parentRecipe ? f.find((w) => w.parentRecipe === v.parentRecipe) : void 0;
261
- C ? C.labels.push(v.label) : f.push({ parentRecipe: v.parentRecipe, labels: [v.label] });
262
- }
263
- return f;
264
- }
265
- function u(i) {
266
- return i.map((f) => {
267
- const v = d(f);
268
- return {
269
- recipe: f.name,
270
- ingredients: v.map((C) => C.parentRecipe ? `(${C.parentRecipe}) ${C.label}` : C.label).join(", "),
271
- bindings: r(v),
272
- original: f
273
- };
274
- });
275
- }
276
- return { columnDefs: $, formatRowData: u };
277
- }
278
- function Qt() {
279
- const m = ne(), s = je();
280
- async function l(a, $, d, r = []) {
281
- var w, c;
282
- const u = a.filter((k) => k.type === "SKU"), i = a.filter((k) => k.type !== "SKU"), f = /* @__PURE__ */ new Set();
283
- if (d)
284
- for (const k of m.skus)
285
- !r.some((_) => _ === k._id) && k._id !== d && !((c = (w = k.convert) == null ? void 0 : w.inventoryBindings) != null && c.some((_) => _.id === d)) || f.add(k._id);
286
- const v = m.skus.map((k) => ({
287
- label: k.name,
288
- sublabel: `${k.code}${f.has(k._id) ? " (Cannot bind, will cause recursive binding)" : ""}`,
289
- value: k,
290
- disabled: f.has(k._id)
291
- })), C = v.filter(
292
- (k) => u.find((I) => I.id === k.value._id) && !f.has(k.value._id)
293
- ).map((k) => k.value);
294
- s.open({
295
- title: "Select ingredients",
296
- contentComponent: Ue,
297
- contentComponentProps: {
298
- items: v,
299
- modelValue: C,
300
- virtualScroll: !0
301
- },
302
- primaryActions: {
303
- text: "Confirm",
304
- close: !0
305
- },
306
- secondaryActions: {
307
- text: "Close",
308
- close: !0,
309
- variant: "tertiary"
310
- }
311
- }).onPrimary((k) => {
312
- const I = [
313
- ...i,
314
- ...a.filter((_) => k.find((e) => e._id === _.id)),
315
- ...k.filter((_) => !a.find((e) => e.id === _._id)).map((_) => ({
316
- type: "SKU",
317
- id: _._id,
318
- amount: {
319
- amount: 1,
320
- precision: 0
321
- }
322
- }))
323
- ];
324
- $(I);
325
- });
326
- }
327
- async function t(a, $, d = []) {
328
- var C;
329
- const r = a.filter((w) => w.type === "RECIPE"), u = a.filter((w) => w.type !== "RECIPE"), i = /* @__PURE__ */ new Set();
330
- if (d.length)
331
- for (const w of m.recipes) {
332
- const c = ((C = m.recipeBindingFlattenCache[w._id]) == null ? void 0 : C.inventoryBindings) ?? [], k = c.some(
333
- (e) => e.bindingPaths.some((S) => d.some((p) => p === S.id))
334
- ), I = c.some(
335
- (e) => "success" in e && d.includes(e.ingredient._id)
336
- );
337
- (d.some((e) => e === w._id) || k || I) && i.add(w._id);
338
- }
339
- const f = m.recipes.filter((w) => !d.includes(w._id)).map((w) => ({
340
- label: w.name,
341
- sublabel: i.has(w._id) ? "(Cannot bind, will cause recursive binding)" : `${w.contains.length} inventory bindings`,
342
- value: w,
343
- disabled: i.has(w._id)
344
- })), v = f.filter(
345
- (w) => r.find((c) => c.id === w.value._id) && !i.has(w.value._id)
346
- ).map((w) => w.value);
347
- s.open({
348
- title: "Select recipes",
349
- contentComponent: Ue,
350
- contentComponentProps: {
351
- items: f,
352
- modelValue: v,
353
- virtualScroll: !0
354
- },
355
- primaryActions: {
356
- text: "Confirm",
357
- close: !0
358
- },
359
- secondaryActions: {
360
- text: "Close",
361
- close: !0,
362
- variant: "tertiary"
363
- }
364
- }).onPrimary((w) => {
365
- const c = [
366
- ...a.filter((k) => w.find((I) => I._id === k.id)),
367
- ...w.filter((k) => !a.find((I) => I.id === k._id)).map((k) => ({
368
- type: "RECIPE",
369
- id: k._id,
370
- amount: {
371
- amount: 1,
372
- precision: 0
373
- }
374
- })),
375
- ...u
376
- ];
377
- $(c);
378
- });
379
- }
380
- async function o(a, $, d = []) {
381
- const r = a.filter((v) => v.type === "SKU_GROUP"), u = a.filter((v) => v.type !== "SKU_GROUP"), i = m.skuGroups.filter((v) => !d.includes(v._id)).map((v) => ({
382
- label: v.name,
383
- value: v
384
- })), f = i.filter((v) => r.find((C) => C.id === v.value._id)).map((v) => v.value);
385
- s.open({
386
- title: "Select ingredient group",
387
- contentComponent: Ue,
388
- contentComponentProps: {
389
- items: i,
390
- modelValue: f,
391
- virtualScroll: !0
392
- },
393
- primaryActions: {
394
- text: "Confirm",
395
- close: !0
396
- },
397
- secondaryActions: {
398
- text: "Close",
399
- close: !0,
400
- variant: "tertiary"
401
- }
402
- }).onPrimary((v) => {
403
- const C = [
404
- ...a.filter((w) => v.find((c) => c._id === w.id)),
405
- ...v.filter((w) => !a.find((c) => c.id === w._id)).map((w) => ({
406
- type: "SKU_GROUP",
407
- id: w._id,
408
- amount: {
409
- amount: 1,
410
- precision: 0
411
- }
412
- })),
413
- ...u
414
- ];
415
- $(C);
416
- });
417
- }
418
- return {
419
- promptIngredientsBinding: l,
420
- promptRecipesBinding: t,
421
- promptIngredientGroupsBinding: o
422
- };
423
- }
424
- const Xt = { class: "flex flex-col" }, Zt = { class: "flex flex-col gap-4" }, Re = /* @__PURE__ */ le({
425
- __name: "InventoryBindingRule",
426
- props: {
427
- disabled: { type: Boolean },
428
- modelValue: {},
429
- minCount: {},
430
- maxCount: {}
431
- },
432
- emits: ["update:modelValue"],
433
- setup(m, { emit: s }) {
434
- const l = m, t = s, { t: o } = ie(), a = St(), $ = tt(), d = F(() => {
435
- var w;
436
- const v = /* @__PURE__ */ new Map(), C = a.restaurants.value.map((c) => c.customAttributes ?? {});
437
- for (const c of C)
438
- for (const [k, I] of Object.entries(c))
439
- v.has(k) || v.set(k, /* @__PURE__ */ new Set()), I && ((w = v.get(k)) == null || w.add(I));
440
- return v;
441
- }), r = F(
442
- () => a.restaurants.value.filter((v) => {
443
- var C;
444
- return (C = v.profile) == null ? void 0 : C.code;
445
- }).map((v) => ({ value: v.profile.code, label: `${v.profile.name} (${v.profile.code})` }))
446
- ), u = F(() => [
447
- ...[...d.value.entries()].map(([C, w]) => ({
448
- type: "string",
449
- key: C,
450
- entity: "restaurant",
451
- values: [...w]
452
- })),
453
- {
454
- type: "string",
455
- key: "state",
456
- entity: "restaurant",
457
- values: [
458
- ...new Set($.locations.map((C) => C.doc.profile.address.state).filter(Boolean))
459
- ]
460
- },
461
- ...r.value.length > 0 ? [
462
- {
463
- type: "string",
464
- key: "outlet",
465
- entity: "restaurant",
466
- options: r.value
467
- }
468
- ] : []
469
- ]), i = W(null);
470
- let f = null;
471
- return ue(
472
- () => l.modelValue,
473
- (v) => {
474
- JSON.stringify(v) !== JSON.stringify(f) && (i.value = v ? Ut.build(v) : null);
475
- },
476
- { immediate: !0 }
477
- ), ue(
478
- i,
479
- (v) => {
480
- f = v ? Pt.build(v) : null, t("update:modelValue", f);
481
- },
482
- { deep: !0 }
483
- ), (v, C) => {
484
- const w = G("FmLabel"), c = G("FmFormGroup");
485
- return g(), V("div", Xt, [
486
- y("div", Zt, [
487
- x(w, {
488
- label: n(o)("inventory.ingredientGroup.form.rules.title"),
489
- required: v.minCount != null && v.minCount > 0
490
- }, null, 8, ["label", "required"]),
491
- x(n(Mt), {
492
- modelValue: i.value,
493
- "onUpdate:modelValue": C[0] || (C[0] = (k) => i.value = k),
494
- attributes: u.value
495
- }, null, 8, ["modelValue", "attributes"])
496
- ]),
497
- x(c, {
498
- "model-value": i.value,
499
- rules: [
500
- (k) => {
501
- const I = k ? 1 : 0;
502
- return l.minCount !== void 0 && I < l.minCount ? n(o)("inventory.ingredientGroup.form.rules.validation.minCount", {
503
- count: l.minCount
504
- }) : l.maxCount !== void 0 && I > l.maxCount ? n(o)("inventory.ingredientGroup.form.rules.validation.maxCount", {
505
- count: l.maxCount
506
- }) : !0;
507
- }
508
- ]
509
- }, null, 8, ["model-value", "rules"])
510
- ]);
511
- };
512
- }
513
- }), en = { class: "border-1 mx-3 my-1 rounded-md" }, tn = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, nn = {
514
- class: "flex items-center",
515
- style: { "min-height": "48px" }
516
- }, on = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, ln = { class: "line-clamp-1" }, an = { class: "w-[200px]" }, rn = {
517
- key: 0,
518
- class: "w-[52px]"
519
- }, sn = {
520
- key: 0,
521
- class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-8"
522
- }, dn = { class: "px-12 pb-4" }, un = /* @__PURE__ */ le({
523
- __name: "InventoryRecipeBindingV2Field",
524
- props: {
525
- disabled: { type: Boolean },
526
- readonly: { type: Boolean },
527
- modelValue: {},
528
- displayName: {},
529
- showError: { type: Boolean },
530
- allowRecipeDecimal: { type: Boolean }
531
- },
532
- emits: ["update:modelValue", "delete", "settings"],
533
- setup(m, { emit: s }) {
534
- const l = s, { t } = ie(), o = at("modelValue"), a = W(Z(o.amount)), $ = F(() => +a.value);
535
- ue(
536
- () => o.amount,
537
- (u) => {
538
- const i = Z(u);
539
- +a.value != +i && (a.value = i);
540
- }
541
- );
542
- let d = null;
543
- function r(u) {
544
- a.value = u, d && clearTimeout(d), d = setTimeout(() => {
545
- const i = +u;
546
- u.length > 0 && isFinite(i) ? o.amount = Ke(i) : o.amount = { amount: 0, precision: 0 };
547
- }, 300);
548
- }
549
- return (u, i) => {
550
- const f = G("FmTooltip"), v = G("FmTextField"), C = G("FmFormGroup"), w = G("FmButton"), c = G("FmIcon");
551
- return g(), V("div", en, [
552
- y("div", tn, [
553
- y("div", nn, [
554
- y("div", on, [
555
- x(f, {
556
- zIndex: 51,
557
- variant: "plain",
558
- placement: "top",
559
- content: u.displayName
560
- }, {
561
- default: J(() => [
562
- y("span", ln, U(u.displayName), 1)
563
- ]),
564
- _: 1
565
- }, 8, ["content"])
566
- ]),
567
- y("div", an, [
568
- x(C, {
569
- disabled: u.disabled,
570
- modelValue: $.value,
571
- rules: [n(it)(u.allowRecipeDecimal ? 5 : 0), n(qe)(-1)]
572
- }, {
573
- default: J(({ invalid: k }) => [
574
- x(v, {
575
- class: "w-full",
576
- disabled: u.disabled,
577
- modelValue: a.value,
578
- "onUpdate:modelValue": i[0] || (i[0] = (I) => r(I)),
579
- invalid: k
580
- }, null, 8, ["disabled", "modelValue", "invalid"])
581
- ]),
582
- _: 1
583
- }, 8, ["disabled", "modelValue", "rules"])
584
- ]),
585
- u.readonly ? T("", !0) : (g(), V("div", rn, [
586
- x(w, {
587
- disabled: u.disabled,
588
- type: "button",
589
- variant: "plain",
590
- icon: "delete",
591
- "icon-color": "#000000",
592
- onClick: i[1] || (i[1] = () => l("delete", n(o).id))
593
- }, null, 8, ["disabled"])
594
- ]))
595
- ]),
596
- x(At, {
597
- "recipe-id": n(o).id,
598
- multiplier: a.value
599
- }, null, 8, ["recipe-id", "multiplier"]),
600
- u.showError ? (g(), V("div", sn, [
601
- x(c, {
602
- name: "error",
603
- color: "system-error-300",
604
- size: "sm"
605
- }),
606
- y("div", null, U(n(t)("inventory.inventoryBindings.circularError")), 1)
607
- ])) : T("", !0)
608
- ]),
609
- y("div", dn, [
610
- x(Re, {
611
- modelValue: n(o).rules,
612
- "onUpdate:modelValue": i[2] || (i[2] = (k) => n(o).rules = k),
613
- disabled: u.disabled
614
- }, null, 8, ["modelValue", "disabled"])
615
- ])
616
- ]);
617
- };
618
- }
619
- });
620
- function cn(m) {
621
- const s = Nt(), { t: l } = zt(), t = ne(), o = F(() => [
622
- {
623
- id: "delete",
624
- header: "",
625
- cell(d) {
626
- const r = d.row.original;
627
- return re(
628
- "div",
629
- { class: "w-full flex justify-end" },
630
- re(ye.FmButton, {
631
- class: "delete-button",
632
- key: r._id,
633
- type: "button",
634
- icon: "delete",
635
- variant: "tertiary",
636
- size: "md",
637
- disabled: m.disabled ?? !1,
638
- onClick: () => {
639
- m.bindingAlternatives = m.bindingAlternatives.filter(
640
- (u) => u._id !== r._id
641
- );
642
- }
643
- })
644
- );
645
- },
646
- enableSorting: !1,
647
- size: 40,
648
- meta: {
649
- cellClass: "",
650
- headerClass: ""
651
- }
652
- },
653
- {
654
- id: "alternative",
655
- header: () => l("inventory.inventoryBindings.alternativeTable.ingredient"),
656
- accessorFn: (d) => {
657
- var r, u;
658
- return `${((r = t.skuById[d._id]) == null ? void 0 : r.name) ?? ""} (${((u = t.skuById[d._id]) == null ? void 0 : u.code) ?? ""})`;
659
- },
660
- cell: ({ row: d }) => {
661
- const r = t.skuById[d.original._id];
662
- return re(
663
- "div",
664
- {
665
- class: "w-full flex flex-col"
666
- },
667
- [
668
- re("div", { class: "fm-typo-en-body-lg-400 line-clamp-1" }, r.name),
669
- re(
670
- "div",
671
- { class: "fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary" },
672
- r.code
673
- )
674
- ]
675
- );
676
- },
677
- size: "auto",
678
- enableSorting: !1
679
- },
680
- {
681
- id: "unit",
682
- header: () => l("inventory.inventoryBindings.alternativeTable.unit"),
683
- accessorFn: (d) => {
684
- const r = t.skuById[d._id];
685
- return r.unit.measurements.computeFirst(
686
- (u) => u.id === d.trackingMeasurement ? u.name : null
687
- ) ?? r.unit.name;
688
- },
689
- enableSorting: !1
690
- },
691
- {
692
- id: "unitOption",
693
- header: () => l("inventory.inventoryBindings.alternativeTable.unit"),
694
- accessorKey: "trackingMeasurement",
695
- cell(d) {
696
- const r = t.skuById[d.row.original._id];
697
- if (!r) return null;
698
- const u = [
699
- {
700
- label: r.unit.name,
701
- sublabel: r.unit.abbrev,
702
- value: null
703
- },
704
- ...r.unit.measurements.map((i) => ({
705
- label: `${i.name} (${i.abbrev})`,
706
- sublabel: l("inventory.inventoryBindings.alternativeTable.measurementOption"),
707
- value: i.id
708
- }))
709
- ].filter((i) => !i.label.toLowerCase().includes("inactive"));
710
- return re(ye.FmSelect, {
711
- modelValue: d.row.original.trackingMeasurement ?? null,
712
- items: u,
713
- disabled: m.disabled ?? !1,
714
- "onUpdate:modelValue": (i) => {
715
- m.bindingAlternatives = m.bindingAlternatives.map((f) => f._id === d.row.original._id ? { ...f, trackingMeasurement: i } : f);
716
- }
717
- });
718
- },
719
- enableSorting: !1
720
- },
721
- {
722
- id: "priority",
723
- header: () => l("inventory.inventoryBindings.alternativeTable.priority"),
724
- accessorKey: "priority",
725
- enableSorting: !0,
726
- cell(d) {
727
- const r = d.row.original;
728
- return re(ye.FmTextField, {
729
- modelValue: r.priority ?? d.row.index + 1,
730
- rules: [
731
- Rt(),
732
- Ne(1),
733
- lt(
734
- m.bindingAlternatives.filter((u) => u._id !== r._id).map((u) => {
735
- const i = t.skuById[u._id];
736
- return {
737
- label: i == null ? void 0 : i.name,
738
- value: u.priority
739
- };
740
- })
741
- )
742
- ],
743
- "onUpdate:modelValue": (u) => {
744
- const i = Number(u);
745
- isNaN(i) || (m.bindingAlternatives = m.bindingAlternatives.map((f) => f._id === d.row.original._id ? { ...f, priority: i } : f));
746
- }
747
- });
748
- }
749
- },
750
- {
751
- id: "default",
752
- header: () => "",
753
- accessorKey: "default",
754
- cell(d) {
755
- const r = t.skuById[d.row.original._id];
756
- return r ? re(ye.FmCheckbox, {
757
- modelValue: d.row.original.default ?? !1,
758
- value: r._id,
759
- disabled: m.disabled ?? !1,
760
- "onUpdate:modelValue": () => {
761
- m.bindingAlternatives = m.bindingAlternatives.map((u) => u._id === d.row.original._id ? { ...u, default: !0 } : { ...u, default: !1 });
762
- }
763
- }) : null;
764
- },
765
- enableSorting: !1,
766
- size: 40,
767
- meta: {
768
- cellClass: "",
769
- headerClass: ""
770
- }
771
- },
772
- {
773
- id: "move",
774
- header: "",
775
- cell(d) {
776
- const r = d.row.original;
777
- return re("div", { class: "w-full flex justify-end" }, [
778
- re(ye.FmButton, {
779
- key: r._id,
780
- type: "button",
781
- icon: "keyboard_arrow_up",
782
- variant: "tertiary",
783
- size: "md",
784
- disabled: m.disabled ?? !1,
785
- onClick: () => {
786
- const u = [...m.bindingAlternatives], i = u.findIndex((f) => f._id === r._id);
787
- if (i > 0) {
788
- const f = u[i - 1];
789
- u[i - 1] = r, u[i] = f;
790
- }
791
- m.bindingAlternatives = [...u];
792
- }
793
- }),
794
- re(ye.FmButton, {
795
- key: r._id,
796
- type: "button",
797
- icon: "keyboard_arrow_down",
798
- variant: "tertiary",
799
- size: "md",
800
- disabled: m.disabled ?? !1,
801
- onClick: () => {
802
- const u = [...m.bindingAlternatives], i = u.findIndex((f) => f._id === r._id);
803
- if (i < u.length - 1) {
804
- const f = u[i + 1];
805
- u[i + 1] = r, u[i] = f;
806
- }
807
- m.bindingAlternatives = [...u];
808
- }
809
- })
810
- ]);
811
- },
812
- enableSorting: !1,
813
- size: 40,
814
- meta: {
815
- cellClass: "",
816
- headerClass: ""
817
- }
818
- }
819
- ]);
820
- return {
821
- get columnDefs() {
822
- return o.value;
823
- },
824
- promptAddIngredient: async ($) => {
825
- const d = [];
826
- for (const i of t.skus)
827
- $.includes(i._id) || d.push({
828
- label: i.name,
829
- sublabel: i.code,
830
- value: i._id,
831
- disabled: $.includes(i._id)
832
- });
833
- const r = (m.bindingAlternatives ?? []).map((i) => i._id), u = await s.multiSelect(d, r, (i) => {
834
- var v, C, w, c, k, I;
835
- const f = (v = m.bindingAlternatives) == null ? void 0 : v.findIndex((_) => _._id === i);
836
- return {
837
- _id: i,
838
- trackingMeasurement: typeof f != "number" || f == -1 ? (C = t.skuById[i]) == null ? void 0 : C.trackingMeasurement : (c = (w = m.bindingAlternatives) == null ? void 0 : w[f]) == null ? void 0 : c.trackingMeasurement,
839
- priority: ((I = (k = m.bindingAlternatives) == null ? void 0 : k[f]) == null ? void 0 : I.priority) ?? m.bindingAlternatives.length,
840
- default: !1
841
- };
842
- });
843
- m.bindingAlternatives = u ?? m.bindingAlternatives;
844
- },
845
- columnVisibility: {
846
- delete: !0,
847
- unit: !1,
848
- unitOption: !0,
849
- default: !1,
850
- // previous demo: sort priority by moving sku element in the array,
851
- // new demo: sort priority using priority field.
852
- // can reenable if this use case is requested to be restored
853
- move: !1
854
- }
855
- };
856
- }
857
- const pn = { class: "flex flex-col gap-16" }, mn = { class: "flex flex-col" }, fn = { class: "flex justify-between items-center px-2" }, Se = /* @__PURE__ */ le({
858
- __name: "InventoryBindingAlternative",
859
- props: {
860
- disabled: { type: Boolean },
861
- modelValue: {},
862
- filterIngredientIds: {}
863
- },
864
- emits: ["update:modelValue"],
865
- setup(m, { emit: s }) {
866
- const l = m, t = s, { t: o } = ie(), a = cn({
867
- get disabled() {
868
- return l.disabled ?? !1;
869
- },
870
- get bindingAlternatives() {
871
- return l.modelValue ?? [];
872
- },
873
- set bindingAlternatives(r) {
874
- t("update:modelValue", r);
875
- }
876
- }), $ = (r) => r && r.some((u) => l.filterIngredientIds.includes(u._id)) ? "Contains invalid ingredient" : !0, d = (r) => r && r.length > 5 ? o("inventory.binding.alternative.maximumExceeded", { max: 5 }) : !0;
877
- return (r, u) => {
878
- var w;
879
- const i = G("FmLabel"), f = G("FmButton"), v = G("FmFormGroup"), C = G("FmTable");
880
- return g(), V("div", pn, [
881
- y("div", mn, [
882
- y("div", fn, [
883
- x(i, {
884
- label: n(o)("inventory.alternatives")
885
- }, null, 8, ["label"]),
886
- x(f, {
887
- disabled: r.disabled,
888
- "prepend-icon": "link",
889
- variant: "primary",
890
- class: "border-1 rounded-lg border-fm-color-primary",
891
- onClick: u[0] || (u[0] = (c) => n(a).promptAddIngredient(r.filterIngredientIds)),
892
- size: "md"
893
- }, null, 8, ["disabled"])
894
- ]),
895
- x(v, {
896
- "model-value": r.modelValue,
897
- rules: [$, d]
898
- }, null, 8, ["model-value", "rules"])
899
- ]),
900
- x(C, {
901
- "row-data": r.modelValue ?? [],
902
- "column-defs": n(a).columnDefs,
903
- "page-size": ((w = r.modelValue) == null ? void 0 : w.length) || 0,
904
- "shrink-at": 9999,
905
- "column-visibility": n(a).columnVisibility,
906
- "hide-footer": ""
907
- }, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
908
- ]);
909
- };
910
- }
911
- }), vn = { class: "border-1 mx-3 my-1 rounded-md" }, yn = { class: "flex flex-col border-b border-fm-color-neutral-gray-100" }, bn = {
912
- class: "flex items-center w-full",
913
- style: { "min-height": "48px" }
914
- }, gn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, _n = { class: "line-clamp-1 w-full" }, kn = { class: "w-[150px]" }, hn = {
915
- key: 0,
916
- class: "w-[52px]"
917
- }, xn = { class: "flex flex-col px-12 pb-4" }, wn = /* @__PURE__ */ le({
918
- __name: "InventorySkuBindingV2Field",
919
- props: {
920
- disabled: { type: Boolean },
921
- readonly: { type: Boolean },
922
- modelValue: {},
923
- displayName: {},
924
- unit: {},
925
- showError: { type: Boolean },
926
- ableToConfigureAlternative: { type: Boolean },
927
- ableToApplyRules: { type: Boolean }
928
- },
929
- emits: ["update:modelValue", "delete", "settings"],
930
- setup(m, { emit: s }) {
931
- const l = s, { t } = ie(), o = at("modelValue");
932
- function a(d) {
933
- d && (o.amount = d.amount, o.measurement = d.measurement);
934
- }
935
- function $() {
936
- return {
937
- modelValue: {
938
- amount: o.amount,
939
- measurement: o.measurement
940
- },
941
- amountAsString: Ot.toFormatString({
942
- value: o.amount
943
- })
944
- };
945
- }
946
- return (d, r) => {
947
- const u = G("FmTooltip"), i = G("FmButton"), f = G("FmFormGroup");
948
- return g(), V("div", vn, [
949
- y("div", yn, [
950
- y("div", bn, [
951
- y("div", gn, [
952
- x(u, {
953
- zIndex: 51,
954
- variant: "plain",
955
- placement: "top",
956
- content: d.displayName
957
- }, {
958
- default: J(() => [
959
- y("span", _n, U(d.displayName), 1)
960
- ]),
961
- _: 1
962
- }, 8, ["content"])
963
- ]),
964
- y("div", kn, [
965
- x(Ce, {
966
- "model-value": { amount: n(o).amount, measurement: n(o).measurement },
967
- "onUpdate:modelValue": a,
968
- unit: d.unit,
969
- placement: "bottom",
970
- "convert-amount-on-change-unit": "",
971
- disabled: d.readonly
972
- }, null, 8, ["model-value", "unit", "disabled"])
973
- ]),
974
- d.readonly ? T("", !0) : (g(), V("div", hn, [
975
- x(i, {
976
- disabled: d.disabled,
977
- type: "button",
978
- variant: "tertiary",
979
- icon: "delete",
980
- onClick: r[0] || (r[0] = () => l("delete", n(o).id))
981
- }, null, 8, ["disabled"])
982
- ]))
983
- ]),
984
- y("div", xn, [
985
- x(f, {
986
- modelValue: n(o).amount,
987
- rules: [n(qe)(0)]
988
- }, null, 8, ["modelValue", "rules"]),
989
- x(f, {
990
- modelValue: $(),
991
- rules: [
992
- n(Dt)(),
993
- n(Gt)(d.unit),
994
- () => d.showError ? n(t)("inventory.inventoryBindings.invalidWarning") : !0
995
- ]
996
- }, null, 8, ["modelValue", "rules"])
997
- ]),
998
- d.ableToApplyRules ? (g(), Y(Re, {
999
- key: 0,
1000
- modelValue: n(o).rules,
1001
- "onUpdate:modelValue": r[1] || (r[1] = (v) => n(o).rules = v),
1002
- disabled: d.disabled
1003
- }, null, 8, ["modelValue", "disabled"])) : T("", !0),
1004
- d.ableToConfigureAlternative ? (g(), Y(Se, {
1005
- key: 1,
1006
- modelValue: n(o).alternatives,
1007
- "onUpdate:modelValue": r[2] || (r[2] = (v) => n(o).alternatives = v),
1008
- disabled: d.disabled,
1009
- filterIngredientIds: [n(o).id]
1010
- }, null, 8, ["modelValue", "disabled", "filterIngredientIds"])) : T("", !0)
1011
- ])
1012
- ]);
1013
- };
1014
- }
1015
- });
1016
- exports.FfCalculator;
1017
- const $n = { class: "flex flex-col gap-24" }, In = {
1018
- key: 0,
1019
- class: "flex flex-col gap-16"
1020
- }, En = { class: "flex items-center" }, Vn = { class: "flex-1 fm-typo-en-title-sm-600" }, Sn = { class: "flex flex-col" }, Cn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Bn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Rn = {
1021
- key: 0,
1022
- class: "w-[52px]"
1023
- }, Fn = {
1024
- key: 1,
1025
- class: "w-[52px]"
1026
- }, An = {
1027
- key: 1,
1028
- class: "flex flex-col gap-16"
1029
- }, Tn = { class: "flex items-center" }, Un = { class: "flex-1 fm-typo-en-title-sm-600" }, Pn = { class: "flex flex-col" }, Mn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Dn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Gn = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, Nn = {
1030
- key: 0,
1031
- class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400"
1032
- }, zn = {
1033
- class: "flex items-center",
1034
- style: { "min-height": "48px" }
1035
- }, On = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, jn = { class: "flex flex-col" }, Ln = { class: "w-[200px]" }, Kn = {
1036
- key: 0,
1037
- class: "w-[52px]"
1038
- }, qn = { class: "flex flex-col gap-16" }, Wn = { class: "flex items-center" }, Yn = { class: "flex-1 fm-typo-en-title-sm-600" }, Jn = { class: "flex flex-col" }, Hn = { 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: "flex-1 fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Xn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary w-[150px] px-16" }, Zn = {
1039
- key: 0,
1040
- class: "w-[52px]"
1041
- }, eo = {
1042
- key: 0,
1043
- class: "flex flex-col border-b border-fm-color-neutral-gray-100"
1044
- }, to = {
1045
- class: "flex items-center w-full",
1046
- style: { "min-height": "48px" }
1047
- }, no = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12 text-fm-color-typo-secondary line-clamp-1" }, oo = {
1048
- key: 0,
1049
- class: "w-[52px]"
1050
- }, io = { class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-12 pb-4" }, lo = /* @__PURE__ */ le({
1051
- __name: "InventoryBindingFormV2",
1052
- props: {
1053
- id: {},
1054
- modelValue: { default: () => [] },
1055
- excludeBindingId: {},
1056
- rules: { default: () => [] },
1057
- iframeMode: { type: Boolean },
1058
- disabled: { type: Boolean },
1059
- readonly: { type: Boolean },
1060
- recipeBindingConfig: { default: () => ({ enabled: !0, ableToApplyRules: !1 }) },
1061
- skuBindingConfig: { default: () => ({
1062
- enabled: !0,
1063
- ableToApplyRules: !1,
1064
- ableToConfigureAlternative: !1
1065
- }) },
1066
- enableIngredientGroup: { type: Boolean },
1067
- allowRecipeDecimal: { type: Boolean }
1068
- },
1069
- emits: ["update:modelValue", "click:pick-inventory-bindings"],
1070
- setup(m, { emit: s }) {
1071
- const { t: l } = ie(), t = ne(), o = F(() => t.recipeById), a = F(() => t.skuById), $ = F(() => t.skuGroupById), d = m, r = s, u = F(() => kt({
1072
- parentId: d.id,
1073
- bindings: d.modelValue,
1074
- recipes: t.recipes.map((R) => R._id === d.id ? {
1075
- ...R,
1076
- contains: d.modelValue
1077
- } : R),
1078
- skus: t.skus.map((R) => R._id === d.id ? {
1079
- ...R,
1080
- convert: {
1081
- inventoryBindings: d.modelValue
1082
- }
1083
- } : R),
1084
- skuGroups: t.skuGroups
1085
- }).inventoryBindings.filter((R) => "error" in R && R.error).map((R) => R).filter((R) => R.reason === ht.enum.circularDependency)), i = F(
1086
- () => new Set(u.value.map((b) => {
1087
- var B;
1088
- return (B = b.bindingPaths[0]) == null ? void 0 : B.id;
1089
- }))
1090
- ), f = F(() => d.modelValue.filter((b) => b.type === "RECIPE")), { promptIngredientsBinding: v, promptRecipesBinding: C, promptIngredientGroupsBinding: w } = Qt();
1091
- async function c() {
1092
- if (d.iframeMode) {
1093
- r("click:pick-inventory-bindings", "RECIPE");
1094
- return;
1095
- }
1096
- C(
1097
- d.modelValue,
1098
- (b) => r("update:modelValue", b),
1099
- d.id ? [d.id] : []
1100
- );
1101
- }
1102
- const k = F(() => d.modelValue.filter((b) => b.type === "SKU_GROUP"));
1103
- async function I() {
1104
- w(
1105
- d.modelValue,
1106
- (b) => r("update:modelValue", b),
1107
- d.id ? [d.id] : []
1108
- );
1109
- }
1110
- function _(b, B, R) {
1111
- const A = +B;
1112
- let P = R;
1113
- B.length > 0 && isFinite(A) ? P = R.map((K) => (K.id !== b || (K.amount = Ke(A)), K)) : P = R.map((K) => (K.id !== b || (K.amount = { amount: 0, precision: 0 }), K)), r("update:modelValue", P);
1114
- }
1115
- const e = F(() => d.modelValue.filter((b) => b.type === "SKU") ?? []);
1116
- async function S() {
1117
- if (d.iframeMode) {
1118
- r("click:pick-inventory-bindings", "SKU");
1119
- return;
1120
- }
1121
- v(
1122
- d.modelValue,
1123
- (b) => r("update:modelValue", b),
1124
- d.excludeBindingId,
1125
- d.id ? [d.id] : []
1126
- );
1127
- }
1128
- function p(b) {
1129
- const B = d.modelValue.map((R) => R.id === b.id ? b : R);
1130
- r("update:modelValue", B);
1131
- }
1132
- function h(b) {
1133
- const B = d.modelValue.filter((R) => R.id !== b);
1134
- r("update:modelValue", B);
1135
- }
1136
- function N(b) {
1137
- var R, A;
1138
- if (b.type !== ge.enum.SKU)
1139
- throw new Error("Non-SKU binding does not have unit");
1140
- if (!((R = a.value[b.id]) == null ? void 0 : R.unit))
1141
- throw new Error(`Cannot find ingredient: ${b.id}`);
1142
- return (A = a.value[b.id]) == null ? void 0 : A.unit;
1143
- }
1144
- function z(b) {
1145
- return !a.value[b.id];
1146
- }
1147
- return (b, B) => {
1148
- var H, ee, O;
1149
- const R = G("FmFormGroup"), A = G("FmButton"), P = G("FmIcon"), K = G("FmTextField");
1150
- return g(), V("div", $n, [
1151
- x(R, {
1152
- disabled: b.disabled,
1153
- "model-value": b.modelValue,
1154
- rules: [
1155
- ...b.rules,
1156
- () => u.value.length ? "There is a binding error in your configuration" : !0
1157
- ]
1158
- }, {
1159
- label: J(() => B[4] || (B[4] = [
1160
- y("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Define the inventory bindings for this recipe or ingredient. ", -1)
1161
- ])),
1162
- _: 1
1163
- }, 8, ["disabled", "model-value", "rules"]),
1164
- ((H = b.recipeBindingConfig) == null ? void 0 : H.enabled) !== !1 ? (g(), V("div", In, [
1165
- y("div", En, [
1166
- y("div", Vn, U(n(l)("inventory.inventoryBindings.recipe")), 1),
1167
- b.readonly ? T("", !0) : (g(), Y(A, {
1168
- key: 0,
1169
- variant: "secondary",
1170
- "text-color": "primary",
1171
- "border-color": "primary",
1172
- label: n(l)("inventory.inventoryBindings.linkRecipe"),
1173
- "prepend-icon": "link",
1174
- onClick: c
1175
- }, null, 8, ["label"]))
1176
- ]),
1177
- y("div", Sn, [
1178
- y("div", Cn, [
1179
- y("div", Bn, U(n(l)("inventory.inventoryBindings.recipe")), 1),
1180
- B[5] || (B[5] = y("div", { class: "w-[200px]" }, null, -1)),
1181
- b.recipeBindingConfig.ableToApplyRules ? (g(), V("div", Rn)) : T("", !0),
1182
- b.readonly ? T("", !0) : (g(), V("div", Fn))
1183
- ]),
1184
- (g(!0), V(Q, null, me(f.value, (M) => {
1185
- var j;
1186
- return g(), Y(un, {
1187
- key: M.id,
1188
- "model-value": M,
1189
- "display-name": (j = o.value[M.id]) == null ? void 0 : j.name,
1190
- "show-error": i.value.has(M.id),
1191
- readonly: b.readonly,
1192
- disabled: b.disabled,
1193
- "allow-recipe-decimal": b.allowRecipeDecimal,
1194
- "onUpdate:modelValue": B[0] || (B[0] = (q) => p(q)),
1195
- onDelete: B[1] || (B[1] = (q) => h(q))
1196
- }, null, 8, ["model-value", "display-name", "show-error", "readonly", "disabled", "allow-recipe-decimal"]);
1197
- }), 128))
1198
- ])
1199
- ])) : T("", !0),
1200
- b.enableIngredientGroup ? (g(), V("div", An, [
1201
- y("div", Tn, [
1202
- y("div", Un, U(n(l)("inventory.inventoryBindings.ingredientGroup")), 1),
1203
- b.readonly ? T("", !0) : (g(), Y(A, {
1204
- key: 0,
1205
- variant: "secondary",
1206
- "text-color": "primary",
1207
- "border-color": "primary",
1208
- label: n(l)("inventory.inventoryBindings.linkIngredientGroup"),
1209
- "prepend-icon": "link",
1210
- onClick: I
1211
- }, null, 8, ["label"]))
1212
- ]),
1213
- y("div", Pn, [
1214
- y("div", Mn, [
1215
- y("div", Dn, U(n(l)("inventory.inventoryBindings.ingredientGroup")), 1),
1216
- B[6] || (B[6] = y("div", { class: "w-[200px]" }, null, -1)),
1217
- B[7] || (B[7] = y("div", { class: "w-[52px]" }, null, -1))
1218
- ]),
1219
- (g(!0), V(Q, null, me(k.value, (M) => (g(), Y(R, {
1220
- key: M.id,
1221
- disabled: b.disabled,
1222
- modelValue: +n(Z)(M.amount ?? { amount: 1, precision: 0 }),
1223
- rules: [n(it)(0), n(qe)(0)]
1224
- }, {
1225
- default: J(({ invalid: j }) => {
1226
- var q;
1227
- return [
1228
- y("div", Gn, [
1229
- i.value.has(M.id) ? (g(), V("div", Nn, [
1230
- x(P, {
1231
- name: "error",
1232
- color: "system-error-300",
1233
- size: "sm"
1234
- }),
1235
- y("div", null, U(n(l)("inventory.inventoryBindings.circularError")), 1)
1236
- ])) : T("", !0),
1237
- y("div", zn, [
1238
- y("div", On, [
1239
- y("div", jn, U((q = $.value[M.id]) == null ? void 0 : q.name), 1)
1240
- ]),
1241
- y("div", Ln, [
1242
- x(K, {
1243
- class: "w-full",
1244
- disabled: b.disabled,
1245
- modelValue: +n(Z)(M.amount ?? { amount: 1, precision: 0 }),
1246
- "onUpdate:modelValue": (oe) => _(M.id, oe, b.modelValue),
1247
- invalid: j
1248
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"])
1249
- ]),
1250
- b.readonly ? T("", !0) : (g(), V("div", Kn, [
1251
- x(A, {
1252
- disabled: b.disabled,
1253
- type: "button",
1254
- variant: "plain",
1255
- icon: "delete",
1256
- "icon-color": "#000000",
1257
- onClick: (oe) => h(M.id)
1258
- }, null, 8, ["disabled", "onClick"])
1259
- ]))
1260
- ])
1261
- ])
1262
- ];
1263
- }),
1264
- _: 2
1265
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
1266
- ])
1267
- ])) : T("", !0),
1268
- y("div", qn, [
1269
- y("div", Wn, [
1270
- y("div", Yn, U(n(l)("inventory.inventoryBindings.ingredient")), 1),
1271
- b.readonly ? T("", !0) : (g(), Y(A, {
1272
- key: 0,
1273
- variant: "secondary",
1274
- "text-color": "primary",
1275
- "border-color": "primary",
1276
- label: n(l)("inventory.inventoryBindings.linkIngredient"),
1277
- "prepend-icon": "link",
1278
- onClick: S
1279
- }, null, 8, ["label"]))
1280
- ]),
1281
- y("div", Jn, [
1282
- y("div", Hn, [
1283
- y("div", Qn, U(n(l)("inventory.inventoryBindings.ingredient")), 1),
1284
- y("div", Xn, U(n(l)("inventory.inventoryBindings.amount")), 1),
1285
- B[8] || (B[8] = y("div", { class: "w-[52px]" }, null, -1)),
1286
- (ee = b.skuBindingConfig) != null && ee.ableToApplyRules || (O = b.skuBindingConfig) != null && O.ableToConfigureAlternative ? (g(), V("div", Zn)) : T("", !0)
1287
- ]),
1288
- (g(!0), V(Q, null, me(e.value, (M) => {
1289
- var j, q, oe;
1290
- return g(), V(Q, {
1291
- key: M.id
1292
- }, [
1293
- z(M) ? (g(), V("div", eo, [
1294
- y("div", to, [
1295
- y("div", no, U(M.id), 1),
1296
- b.readonly ? T("", !0) : (g(), V("div", oo, [
1297
- x(A, {
1298
- disabled: b.disabled,
1299
- type: "button",
1300
- variant: "tertiary",
1301
- icon: "delete",
1302
- onClick: () => h(M.id)
1303
- }, null, 8, ["disabled", "onClick"])
1304
- ]))
1305
- ]),
1306
- y("div", io, [
1307
- x(P, {
1308
- name: "error",
1309
- color: "system-error-300",
1310
- size: "sm"
1311
- }),
1312
- y("div", null, U(n(l)("inventory.inventoryBindings.missingIngredient")), 1)
1313
- ])
1314
- ])) : (g(), Y(wn, {
1315
- key: 1,
1316
- "model-value": M,
1317
- "display-name": (j = a.value[M.id]) == null ? void 0 : j.name,
1318
- unit: N(M),
1319
- "show-error": i.value.has(M.id),
1320
- "able-to-apply-rules": ((q = b.skuBindingConfig) == null ? void 0 : q.ableToApplyRules) === !0,
1321
- "able-to-configure-alternative": ((oe = b.skuBindingConfig) == null ? void 0 : oe.ableToConfigureAlternative) === !0,
1322
- readonly: b.readonly,
1323
- disabled: b.disabled,
1324
- "onUpdate:modelValue": B[2] || (B[2] = (X) => p(X)),
1325
- onDelete: B[3] || (B[3] = (X) => h(X))
1326
- }, null, 8, ["model-value", "display-name", "unit", "show-error", "able-to-apply-rules", "able-to-configure-alternative", "readonly", "disabled"]))
1327
- ], 64);
1328
- }), 128))
1329
- ])
1330
- ])
1331
- ]);
1332
- };
1333
- }
1334
- }), ao = { class: "flex flex-col gap-40" }, ro = {
1335
- key: 0,
1336
- class: "flex flex-col gap-16"
1337
- }, so = {
1338
- key: 0,
1339
- 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"
1340
- }, uo = {
1341
- key: 0,
1342
- class: "flex flex-col items-center w-full h-full gap-24"
1343
- }, co = { key: 1 }, po = { class: "mt-32" }, mo = /* @__PURE__ */ le({
1344
- __name: "RecipeForm",
1345
- props: {
1346
- mode: {},
1347
- modelValue: {},
1348
- disabled: { type: Boolean }
1349
- },
1350
- emits: ["update:modelValue", "click:submit"],
1351
- setup(m, { expose: s, emit: l }) {
1352
- const t = m, o = l, a = We(), { t: $ } = ie(), d = F({
1353
- get() {
1354
- var p;
1355
- return ((p = t.modelValue) == null ? void 0 : p.name) ?? "";
1356
- },
1357
- set(p) {
1358
- const h = t.modelValue ?? {};
1359
- h.name = p, o("update:modelValue", h);
1360
- }
1361
- }), r = F({
1362
- get() {
1363
- var p;
1364
- return ((p = t.modelValue) == null ? void 0 : p.contains) ?? [];
1365
- },
1366
- set(p) {
1367
- const h = t.modelValue ?? {};
1368
- h.contains = p, o("update:modelValue", h);
1369
- }
1370
- }), u = F({
1371
- get() {
1372
- var p;
1373
- return ((p = t.modelValue) == null ? void 0 : p.customAttributes) ?? {};
1374
- },
1375
- set(p) {
1376
- const h = t.modelValue ? {
1377
- ...t.modelValue
1378
- } : {};
1379
- h.customAttributes = p, o("update:modelValue", h);
1380
- }
1381
- }), i = F({
1382
- get() {
1383
- var p;
1384
- return ((p = t.modelValue) == null ? void 0 : p.version) ?? null;
1385
- },
1386
- set(p) {
1387
- const h = t.modelValue ? { ...t.modelValue } : {};
1388
- h.version = p, o("update:modelValue", h);
1389
- }
1390
- }), f = F({
1391
- get() {
1392
- return i.value === "v2";
1393
- },
1394
- set(p) {
1395
- i.value = p ? "v2" : null;
1396
- }
1397
- });
1398
- function v() {
1399
- o("click:submit");
1400
- }
1401
- const C = W();
1402
- s({
1403
- validateInputs: () => {
1404
- var p, h;
1405
- (h = (p = C.value) == null ? void 0 : p.validateInputs) == null || h.call(p);
1406
- },
1407
- resetInputsValidation: () => {
1408
- var p, h;
1409
- (h = (p = C.value) == null ? void 0 : p.resetInputsValidation) == null || h.call(p);
1410
- },
1411
- resetInputs: () => {
1412
- var p, h;
1413
- (h = (p = C.value) == null ? void 0 : p.resetInputs) == null || h.call(p);
1414
- }
1415
- });
1416
- const w = ne(), c = W([]), k = W(!1), I = W(!1);
1417
- ue(k, async (p) => {
1418
- _(p);
1419
- });
1420
- async function _(p) {
1421
- var h, N;
1422
- p && !I.value && ((h = t.modelValue) != null && h._id) && (I.value = !0, c.value = await w.getAffectedMenu((N = t.modelValue) == null ? void 0 : N._id).delayed(500), I.value = !1);
1423
- }
1424
- const e = F(
1425
- () => w.recipes.map((p) => ({ label: p.name, value: p.name }))
1426
- ), S = F(() => {
1427
- var p;
1428
- return ((p = t.modelValue) == null ? void 0 : p.name) ?? "";
1429
- });
1430
- return (p, h) => {
1431
- const N = G("FmTextField"), z = G("FmSwitch"), b = G("FmCard"), B = G("FmSpacer"), R = G("FmCircularProgress"), A = G("FmForm");
1432
- return g(), Y(A, {
1433
- ref_key: "formRef",
1434
- ref: C,
1435
- onValidationSuccess: v
1436
- }, {
1437
- default: J(() => [
1438
- y("div", ao, [
1439
- x(N, {
1440
- disabled: p.disabled,
1441
- label: n($)("inventory.recipe.name"),
1442
- "model-value": d.value,
1443
- "onUpdate:modelValue": h[0] || (h[0] = (P) => d.value = P),
1444
- rules: [
1445
- n(Ft)(),
1446
- n(lt)(e.value, S.value, (P) => `[${P.value}] already exists`)
1447
- ],
1448
- "label-mark": "required"
1449
- }, null, 8, ["disabled", "label", "model-value", "rules"]),
1450
- n(a).enableRecipeV2 ? (g(), V("div", ro, [
1451
- x(z, {
1452
- modelValue: f.value,
1453
- "onUpdate:modelValue": h[1] || (h[1] = (P) => f.value = P),
1454
- value: !0,
1455
- label: n($)("inventory.recipe.enableRecipeV2"),
1456
- "label-placement": "right",
1457
- disabled: p.disabled,
1458
- sublabel: n($)("inventory.recipe.recipeV2Warning")
1459
- }, null, 8, ["modelValue", "label", "disabled", "sublabel"])
1460
- ])) : T("", !0),
1461
- x(b, {
1462
- variant: "outlined",
1463
- class: "p-16"
1464
- }, {
1465
- default: J(() => {
1466
- var P, K;
1467
- return [
1468
- n(a).enableRecipeV2 ? (g(), Y(lo, {
1469
- key: 0,
1470
- id: (P = p.modelValue) == null ? void 0 : P._id,
1471
- disabled: p.disabled,
1472
- "model-value": r.value,
1473
- "onUpdate:modelValue": h[2] || (h[2] = (H) => r.value = H),
1474
- rules: [n(Ne)(1)],
1475
- "enable-ingredient-group": n(a).enableIngredientGroup,
1476
- "allow-recipe-decimal": "",
1477
- "recipe-binding-config": { enabled: !f.value, ableToApplyRules: f.value },
1478
- "sku-binding-config": {
1479
- ableToConfigureAlternative: f.value
1480
- }
1481
- }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group", "recipe-binding-config", "sku-binding-config"])) : (g(), Y(Tt, {
1482
- key: 1,
1483
- id: (K = p.modelValue) == null ? void 0 : K._id,
1484
- disabled: p.disabled,
1485
- "model-value": r.value,
1486
- "onUpdate:modelValue": h[3] || (h[3] = (H) => r.value = H),
1487
- rules: [n(Ne)(1)],
1488
- "enable-ingredient-group": n(a).enableIngredientGroup,
1489
- "allow-recipe-decimal": ""
1490
- }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group"]))
1491
- ];
1492
- }),
1493
- _: 1
1494
- })
1495
- ]),
1496
- p.mode !== n(de).CREATE ? (g(), V("div", so, [
1497
- x(z, {
1498
- label: "Show binded items",
1499
- modelValue: k.value,
1500
- "onUpdate:modelValue": h[4] || (h[4] = (P) => k.value = P),
1501
- "label-placement": "right",
1502
- disabled: I.value
1503
- }, null, 8, ["modelValue", "disabled"]),
1504
- I.value ? (g(), V("div", uo, [
1505
- x(B),
1506
- y("div", null, [
1507
- x(R, { size: "xl" })
1508
- ]),
1509
- h[6] || (h[6] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
1510
- x(B)
1511
- ])) : k.value && c.value.length ? (g(), V("div", co, [
1512
- x(nt, {
1513
- name: "Menu",
1514
- bindings: c.value
1515
- }, null, 8, ["bindings"])
1516
- ])) : T("", !0)
1517
- ])) : T("", !0),
1518
- y("div", po, [
1519
- x(jt, {
1520
- entity: "inventoryRecipe",
1521
- modelValue: u.value,
1522
- "onUpdate:modelValue": h[5] || (h[5] = (P) => u.value = P)
1523
- }, null, 8, ["modelValue"])
1524
- ])
1525
- ]),
1526
- _: 1
1527
- }, 512);
1528
- };
1529
- }
1530
- }), fo = { class: "flex gap-4" }, vo = /* @__PURE__ */ le({
1531
- __name: "RecipeDialog",
1532
- props: {
1533
- show: { type: Boolean },
1534
- recipe: {},
1535
- mode: { default: de.READ }
1536
- },
1537
- emits: ["update:show"],
1538
- setup(m) {
1539
- const s = m, l = ne(), t = Le(), { t: o } = ie(), a = Ge(s, "show"), $ = Ge(s, "recipe"), d = F(() => {
1540
- switch (s.mode) {
1541
- case de.READ:
1542
- return "";
1543
- case de.UPDATE:
1544
- return o("inventory.recipe.update.title");
1545
- case de.CREATE:
1546
- return o("inventory.recipe.create.title");
1547
- }
1548
- return "";
1549
- }), r = F(() => {
1550
- switch (s.mode) {
1551
- case de.READ:
1552
- return "";
1553
- case de.UPDATE:
1554
- return o("common.save");
1555
- case de.CREATE:
1556
- return o("common.add");
1557
- }
1558
- return "";
1559
- }), u = W(), i = W(!1);
1560
- async function f() {
1561
- i.value = !0;
1562
- try {
1563
- const c = Oe($.value);
1564
- c.precision ?? (c.precision = 0), c.measurements ?? (c.measurements = []), await l.createRecipe(c), a.value = !1, t.open({
1565
- title: o("inventory.common.success"),
1566
- message: o("inventory.recipe.create.success", { name: $.value.name }),
1567
- type: "success"
1568
- });
1569
- } catch (c) {
1570
- c instanceof Je || t.open({
1571
- title: o("inventory.recipe.create.error.title"),
1572
- message: o("inventory.recipe.create.error.message"),
1573
- type: "error"
1574
- });
1575
- } finally {
1576
- i.value = !1;
1577
- }
1578
- }
1579
- async function v() {
1580
- i.value = !0;
1581
- try {
1582
- await l.updateRecipe($.value), a.value = !1, t.open({
1583
- title: o("inventory.common.success"),
1584
- message: o("inventory.recipe.update.success", { name: $.value.name }),
1585
- type: "success"
1586
- });
1587
- } catch (c) {
1588
- c instanceof Je || t.open({
1589
- title: o("inventory.recipe.update.error.title"),
1590
- message: o("inventory.recipe.update.error.message"),
1591
- type: "error"
1592
- });
1593
- } finally {
1594
- i.value = !1;
1595
- }
1596
- }
1597
- function C() {
1598
- var c, k;
1599
- (k = (c = u.value) == null ? void 0 : c.validateInputs) == null || k.call(c);
1600
- }
1601
- function w() {
1602
- switch (s.mode) {
1603
- case de.READ:
1604
- return;
1605
- case de.UPDATE:
1606
- return v();
1607
- case de.CREATE:
1608
- return f();
1609
- }
1610
- }
1611
- return (c, k) => {
1612
- const I = G("FmButton"), _ = G("FmSideSheet");
1613
- return g(), Y(_, {
1614
- "model-value": n(a),
1615
- "onUpdate:modelValue": k[3] || (k[3] = (e) => Me(a) ? a.value = e : null),
1616
- header: d.value,
1617
- "close-button": "",
1618
- "dismiss-away": "",
1619
- "max-width": 800
1620
- }, {
1621
- "side-sheet-footer": J(() => [
1622
- y("div", fo, [
1623
- x(I, {
1624
- loading: i.value,
1625
- label: r.value,
1626
- onClick: C
1627
- }, null, 8, ["loading", "label"]),
1628
- x(I, {
1629
- disabled: i.value,
1630
- label: n(o)("common.close"),
1631
- variant: "tertiary",
1632
- onClick: k[2] || (k[2] = (e) => a.value = !1)
1633
- }, null, 8, ["disabled", "label"])
1634
- ])
1635
- ]),
1636
- default: J(() => [
1637
- x(mo, {
1638
- class: "w-full",
1639
- ref_key: "hasValidationExpose",
1640
- ref: u,
1641
- modelValue: n($),
1642
- "onUpdate:modelValue": k[0] || (k[0] = (e) => Me($) ? $.value = e : null),
1643
- mode: c.mode,
1644
- disabled: i.value,
1645
- "onClick:submit": k[1] || (k[1] = (e) => w())
1646
- }, null, 8, ["modelValue", "mode", "disabled"])
1647
- ]),
1648
- _: 1
1649
- }, 8, ["model-value", "header"]);
1650
- };
1651
- }
1652
- });
1653
- function ke(m, s, l) {
1654
- const t = [];
1655
- for (const o of m)
1656
- if (o.type === ge.enum.SKU)
1657
- t.push({ ...o, recipeIds: [...s] });
1658
- else if (o.type === ge.enum.SKU_GROUP)
1659
- t.push({ ...o, isGroup: !0, recipeIds: [...s] });
1660
- else if (o.type === ge.enum.RECIPE) {
1661
- const a = l[o.id];
1662
- a && !s.has(o.id) && t.push(
1663
- ...ke(a.contains, /* @__PURE__ */ new Set([...s, o.id]), l)
1664
- );
1665
- }
1666
- return t;
1667
- }
1668
- function yo(m, s) {
1669
- return he.equal(m, s);
1670
- }
1671
- function Fe(m) {
1672
- if (m == null) return null;
1673
- const s = m.$and, l = m.$or;
1674
- return Array.isArray(s) && s.length === 0 || Array.isArray(l) && l.length === 0 || Object.keys(m).length === 0 ? null : JSON.stringify(m);
1675
- }
1676
- function Ae(m) {
1677
- const s = (m ?? []).map((l) => ({
1678
- _id: l._id,
1679
- trackingMeasurement: l.trackingMeasurement ?? null,
1680
- priority: l.priority ?? null,
1681
- default: l.default ?? null
1682
- })).sort((l, t) => l._id.localeCompare(t._id));
1683
- return JSON.stringify(s);
1684
- }
1685
- function Xe(m) {
1686
- return m.measurement ? he.multiplyDecimal(m.amount, m.measurement.conversion) : m.amount;
1687
- }
1688
- function Pe(m, s) {
1689
- var o, a;
1690
- if (m.type !== s.type || m.id !== s.id || !yo(Xe(m), Xe(s))) return !1;
1691
- const l = ((o = m.measurement) == null ? void 0 : o.id) ?? null, t = ((a = s.measurement) == null ? void 0 : a.id) ?? null;
1692
- return !(l !== t || Fe(m.rules) !== Fe(s.rules) || Ae(m.alternatives) !== Ae(s.alternatives));
1693
- }
1694
- function Ze(m, s) {
1695
- return m.type === s.type && m.id === s.id;
1696
- }
1697
- function bo(m, s) {
1698
- const l = [];
1699
- let t = [...m.contains];
1700
- for (const a of s)
1701
- switch (a.type) {
1702
- case "remove-binding": {
1703
- const $ = t.findIndex(
1704
- (d) => d.type === a.target.type && d.id === a.target.id
1705
- );
1706
- $ === -1 ? l.push({ change: a, outcome: "ignored", reason: "Source binding not found in target" }) : (t = [...t.slice(0, $), ...t.slice($ + 1)], l.push({ change: a, outcome: "applied" }));
1707
- break;
1708
- }
1709
- case "add-binding": {
1710
- if (t.find((r) => Pe(r, a.binding))) {
1711
- l.push({ change: a, outcome: "already-satisfied", reason: "Exact binding already present" });
1712
- break;
1713
- }
1714
- if (t.find((r) => Ze(r, a.binding))) {
1715
- l.push({ change: a, outcome: "blocked", reason: "A similar but non-exact binding already exists" });
1716
- break;
1717
- }
1718
- if (m.version === "v2" && a.binding.type === "RECIPE") {
1719
- l.push({ change: a, outcome: "blocked", reason: "Cannot add RECIPE binding to a V2 recipe" });
1720
- break;
1721
- }
1722
- if (m.version !== "v2" && (a.binding.alternatives ?? []).length > 0) {
1723
- l.push({ change: a, outcome: "blocked", reason: "Cannot add a binding with alternatives to a non-V2 recipe" });
1724
- break;
1725
- }
1726
- t = [...t, a.binding], l.push({ change: a, outcome: "applied" });
1727
- break;
1728
- }
1729
- case "replace-binding": {
1730
- const $ = t.findIndex(
1731
- (u) => u.type === a.from.type && u.id === a.from.id
1732
- ), d = t.find((u) => Pe(u, a.to)), r = t.find((u, i) => i !== $ && Ze(u, a.to) && !Pe(u, a.to));
1733
- if ($ === -1) {
1734
- d ? l.push({ change: a, outcome: "already-satisfied", reason: "Target already has exact replacement" }) : l.push({ change: a, outcome: "ignored", reason: "Source binding not found in target" });
1735
- break;
1736
- }
1737
- if (m.version === "v2" && a.to.type === "RECIPE") {
1738
- l.push({ change: a, outcome: "blocked", reason: "Cannot add RECIPE binding to a V2 recipe" });
1739
- break;
1740
- }
1741
- if (m.version !== "v2" && (a.to.alternatives ?? []).length > 0) {
1742
- l.push({ change: a, outcome: "blocked", reason: "Cannot apply a binding with alternatives to a non-V2 recipe" });
1743
- break;
1744
- }
1745
- if (r) {
1746
- l.push({ change: a, outcome: "blocked", reason: "A similar but non-exact replacement binding already exists" });
1747
- break;
1748
- }
1749
- d ? (t = [...t.slice(0, $), ...t.slice($ + 1)], l.push({ change: a, outcome: "applied", reason: "Source removed; replacement already present" })) : (t = [
1750
- ...t.slice(0, $),
1751
- a.to,
1752
- ...t.slice($ + 1)
1753
- ], l.push({ change: a, outcome: "applied" }));
1754
- break;
1755
- }
1756
- case "update-binding-rule": {
1757
- const $ = t.findIndex(
1758
- (i) => i.type === a.target.type && i.id === a.target.id
1759
- );
1760
- if ($ === -1) {
1761
- l.push({ change: a, outcome: "ignored", reason: "Binding not found in target" });
1762
- break;
1763
- }
1764
- const d = t[$], r = d.rules ?? null, u = a.rule ?? null;
1765
- if (Fe(r) === Fe(u)) {
1766
- l.push({ change: a, outcome: "already-satisfied", reason: "Rule already matches" });
1767
- break;
1768
- }
1769
- t = [
1770
- ...t.slice(0, $),
1771
- { ...d, rules: u },
1772
- ...t.slice($ + 1)
1773
- ], l.push({ change: a, outcome: "applied" });
1774
- break;
1775
- }
1776
- case "update-alternatives": {
1777
- if (m.version !== "v2") {
1778
- l.push({ change: a, outcome: "blocked", reason: "Cannot update alternatives on a non-V2 recipe" });
1779
- break;
1780
- }
1781
- const $ = t.findIndex(
1782
- (i) => i.type === a.target.type && i.id === a.target.id
1783
- );
1784
- if ($ === -1) {
1785
- l.push({ change: a, outcome: "ignored", reason: "Binding not found in target" });
1786
- break;
1787
- }
1788
- const d = t[$], r = Ae(d.alternatives), u = Ae(a.alternatives);
1789
- if (r === u) {
1790
- l.push({ change: a, outcome: "already-satisfied", reason: "Alternatives already match" });
1791
- break;
1792
- }
1793
- t = [
1794
- ...t.slice(0, $),
1795
- { ...d, alternatives: a.alternatives },
1796
- ...t.slice($ + 1)
1797
- ], l.push({ change: a, outcome: "applied" });
1798
- break;
1799
- }
1800
- }
1801
- return { projected: { ...m, contains: t }, results: l };
1802
- }
1803
- function et(m) {
1804
- switch (m.type) {
1805
- case "add-binding":
1806
- return m.binding.id !== "";
1807
- case "remove-binding":
1808
- return m.target.id !== "";
1809
- case "replace-binding":
1810
- return m.from.id !== "" && m.to.id !== "";
1811
- case "update-binding-rule":
1812
- return m.target.id !== "";
1813
- case "update-alternatives":
1814
- return m.target.id !== "";
1815
- }
1816
- }
1817
- function go(m) {
1818
- if (m.length === 0) return "no-applicable-changes";
1819
- let s = 0, l = 0, t = 0, o = 0;
1820
- for (const a of m)
1821
- a.outcome === "applied" ? s++ : a.outcome === "blocked" ? l++ : a.outcome === "ignored" ? t++ : a.outcome === "already-satisfied" && o++;
1822
- return l > 0 && s === 0 ? "blocked" : o === m.length ? "already-satisfied" : s > 0 && (t > 0 || l > 0) ? "partially-ignored" : s > 0 ? "will-update" : "no-applicable-changes";
1823
- }
1824
- let _o = 0;
1825
- function ko(m = null) {
1826
- return {
1827
- id: String(++_o),
1828
- type: m,
1829
- itemId: null,
1830
- amountModel: be()
1831
- };
1832
- }
1833
- function ut(m, s, l, t) {
1834
- for (const o of m)
1835
- if (o.type === "RECIPE") {
1836
- if (o.id === s) return !0;
1837
- if (!l.has(o.id)) {
1838
- const a = t[o.id];
1839
- if (a && ut(a.contains, s, /* @__PURE__ */ new Set([...l, o.id]), t))
1840
- return !0;
1841
- }
1842
- }
1843
- return !1;
1844
- }
1845
- const _e = ot("recipeBulkEditor", function() {
1846
- const s = ne(), l = Le(), { t } = ie(), o = W(!1), a = W(1), $ = W(null), d = W(/* @__PURE__ */ new Set()), r = W([]), u = W({}), i = W(!1), f = W(/* @__PURE__ */ new Map()), v = W(""), C = W([]), w = F(() => {
1847
- let O = s.recipes;
1848
- const M = $.value;
1849
- if (M != null && M.nameSearch) {
1850
- const j = M.nameSearch.trim().toLowerCase();
1851
- j && (O = O.filter((q) => q.name.toLowerCase().includes(j)));
1852
- }
1853
- if (M != null && M.filters && M.filters.length > 0) {
1854
- const j = /* @__PURE__ */ new Map();
1855
- for (const q of O)
1856
- j.set(
1857
- q._id,
1858
- ke(q.contains, /* @__PURE__ */ new Set([q._id]), s.recipeById)
1859
- );
1860
- for (const q of M.filters)
1861
- if (q.type === "ingredient") {
1862
- const { itemId: oe, amount: X, measurementId: se } = q;
1863
- O = O.filter((fe) => (j.get(fe._id) ?? []).some((ae) => {
1864
- var ce;
1865
- if (ae.type !== "SKU" || ae.id !== oe) return !1;
1866
- if (ae.recipeIds.length === 1) {
1867
- if (X != null) {
1868
- const Te = ae.measurement ? he.multiplyDecimal(ae.amount, ae.measurement.conversion) : ae.amount;
1869
- if (!he.equal(Te, X)) return !1;
1870
- }
1871
- if (se != null && (((ce = ae.measurement) == null ? void 0 : ce.id) ?? null) !== se)
1872
- return !1;
1873
- }
1874
- return !0;
1875
- }));
1876
- } else if (q.type === "recipe") {
1877
- const oe = q.itemId;
1878
- O = O.filter(
1879
- (X) => ut(X.contains, oe, /* @__PURE__ */ new Set([X._id]), s.recipeById)
1880
- );
1881
- }
1882
- }
1883
- return O;
1884
- }), c = F(
1885
- () => w.value.filter((O) => !d.value.has(O._id))
1886
- ), k = F(() => c.value.length > 0), I = F(() => {
1887
- const O = r.value.filter(et);
1888
- if (O.length === 0) {
1889
- const j = {};
1890
- for (const q of c.value)
1891
- j[q._id] = {
1892
- recipeId: q._id,
1893
- recipeName: q.name,
1894
- original: q,
1895
- projected: null,
1896
- status: "no-applicable-changes",
1897
- changes: [],
1898
- counts: { applied: 0, ignored: 0, blocked: 0, satisfied: 0 }
1899
- };
1900
- return j;
1901
- }
1902
- const M = {};
1903
- for (const j of c.value) {
1904
- const q = JSON.parse(JSON.stringify(j)), { projected: oe, results: X } = bo(q, O), se = go(X);
1905
- let fe = 0, xe = 0, ae = 0, ve = 0;
1906
- for (const ce of X)
1907
- ce.outcome === "applied" ? fe++ : ce.outcome === "ignored" ? xe++ : ce.outcome === "blocked" ? ae++ : ce.outcome === "already-satisfied" && ve++;
1908
- M[j._id] = {
1909
- recipeId: j._id,
1910
- recipeName: j.name,
1911
- original: q,
1912
- projected: se === "will-update" || se === "partially-ignored" ? oe : null,
1913
- status: se,
1914
- changes: X,
1915
- counts: { applied: fe, ignored: xe, blocked: ae, satisfied: ve }
1916
- };
1917
- }
1918
- return M;
1919
- }), _ = F(() => r.value.some(et) ? Object.values(I.value).some(
1920
- (O) => O.status === "will-update" || O.status === "partially-ignored"
1921
- ) : !1);
1922
- function e() {
1923
- p(), o.value = !0;
1924
- }
1925
- function S() {
1926
- o.value = !1;
1927
- }
1928
- function p() {
1929
- a.value = 1, $.value = null, d.value = /* @__PURE__ */ new Set(), r.value = [], u.value = {}, i.value = !1, f.value = /* @__PURE__ */ new Map(), v.value = "", C.value = [];
1930
- }
1931
- function h(O) {
1932
- $.value = O;
1933
- }
1934
- function N(O) {
1935
- const M = new Set(d.value);
1936
- M.add(O), d.value = M;
1937
- }
1938
- function z() {
1939
- d.value = /* @__PURE__ */ new Set();
1940
- }
1941
- function b(O) {
1942
- r.value = [...r.value, O];
1943
- }
1944
- function B(O, M) {
1945
- const j = [...r.value];
1946
- j[O] = M, r.value = j;
1947
- }
1948
- function R(O) {
1949
- r.value = r.value.filter((M, j) => j !== O);
1950
- }
1951
- function A(O, M) {
1952
- const j = [...r.value], [q] = j.splice(O, 1);
1953
- j.splice(M, 0, q), r.value = j;
1954
- }
1955
- function P() {
1956
- u.value = { ...I.value }, a.value = 3;
1957
- }
1958
- function K() {
1959
- u.value = {}, a.value = 2;
1960
- }
1961
- function H() {
1962
- return Object.values(u.value).filter(
1963
- (O) => (O.status === "will-update" || O.status === "partially-ignored") && O.projected != null
1964
- ).map((O) => O.projected);
1965
- }
1966
- async function ee() {
1967
- if (!i.value) {
1968
- i.value = !0, f.value = /* @__PURE__ */ new Map();
1969
- try {
1970
- const O = H(), M = await s.importRecipes({
1971
- create: [],
1972
- update: O
1973
- }), j = (M == null ? void 0 : M.errors) ?? [];
1974
- if (j.length > 0) {
1975
- const q = /* @__PURE__ */ new Map();
1976
- for (const { data: oe, error: X } of j) {
1977
- const se = typeof X == "string" ? X : (X == null ? void 0 : X.message) ?? t("inventory.recipe.bulkEditor.step3.unknownError");
1978
- q.set(oe._id, se);
1979
- }
1980
- f.value = q, l.open({
1981
- title: t("inventory.recipe.bulkEditor.step3.partialErrorTitle"),
1982
- message: t("inventory.recipe.bulkEditor.step3.partialErrorMessage", {
1983
- count: j.length
1984
- }),
1985
- type: "warning"
1986
- });
1987
- } else
1988
- l.open({
1989
- title: t("inventory.recipe.bulkEditor.step3.successTitle"),
1990
- message: t("inventory.recipe.bulkEditor.step3.successMessage", {
1991
- count: O.length
1992
- }),
1993
- type: "success"
1994
- }), o.value = !1, p();
1995
- } catch (O) {
1996
- l.open({
1997
- title: t("inventory.recipe.bulkEditor.step3.errorTitle"),
1998
- message: t("inventory.recipe.bulkEditor.step3.errorMessage"),
1999
- type: "error"
2000
- }), console.error("confirmAndApply failed", O);
2001
- } finally {
2002
- i.value = !1;
2003
- }
2004
- }
2005
- }
2006
- return {
2007
- // state
2008
- show: o,
2009
- currentStep: a,
2010
- query: $,
2011
- excludedRecipeIds: d,
2012
- modifications: r,
2013
- entries: u,
2014
- isSaving: i,
2015
- applyErrors: f,
2016
- nameSearch: v,
2017
- filterRows: C,
2018
- // computed
2019
- matchedRecipes: w,
2020
- selectedRecipes: c,
2021
- livePreviewEntries: I,
2022
- canGoToStep2: k,
2023
- canGoToStep3: _,
2024
- // actions
2025
- openDialog: e,
2026
- closeDialog: S,
2027
- reset: p,
2028
- updateQuery: h,
2029
- removeRecipe: N,
2030
- restoreAllRecipes: z,
2031
- addModification: b,
2032
- updateModification: B,
2033
- removeModification: R,
2034
- reorderModification: A,
2035
- goToStep3: P,
2036
- backToStep2: K,
2037
- buildPayload: H,
2038
- confirmAndApply: ee
2039
- };
2040
- }), ho = { class: "flex flex-col h-full" }, xo = { class: "px-16 pt-16 pb-8 shrink-0 flex items-center justify-between" }, wo = { class: "fm-typo-en-heading-sm-700 text-fm-color-typo-primary" }, $o = { class: "px-16 pt-12 pb-16 border-b border-fm-color-border-default bg-fm-color-surface-default flex flex-col gap-12 shrink-0" }, Io = {
2041
- key: 0,
2042
- class: "flex flex-wrap items-center gap-8"
2043
- }, Eo = {
2044
- type: "button",
2045
- class: "inline-flex items-center gap-4 h-[30px] pl-8 pr-6 rounded-l-md border border-r-0 border-fm-color-border-default bg-fm-color-surface-secondary hover:bg-fm-color-surface-hover cursor-pointer select-none transition-colors"
2046
- }, Vo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-primary" }, So = { class: "flex flex-col gap-8 p-12 min-w-[260px]" }, Co = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, Bo = {
2047
- key: 0,
2048
- class: "flex flex-col gap-4"
2049
- }, Ro = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Fo = { class: "text-fm-color-typo-placeholder ml-4" }, Ao = ["title", "onClick"], To = { class: "flex-1 overflow-y-auto" }, Uo = {
2050
- key: 0,
2051
- class: "flex flex-col items-center justify-center h-full gap-8 px-24 text-center"
2052
- }, Po = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Mo = {
2053
- key: 1,
2054
- class: "divide-y divide-fm-color-border-default"
2055
- }, Do = { class: "flex-1 min-w-0" }, Go = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary truncate" }, No = {
2056
- key: 0,
2057
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-1 whitespace-normal break-words"
2058
- }, zo = { class: "flex items-center gap-4 mt-2" }, Oo = /* @__PURE__ */ le({
2059
- __name: "RecipeBulkEditorStep1",
2060
- setup(m) {
2061
- const { t: s } = ie(), l = ne(), t = _e(), o = F({
2062
- get: () => t.nameSearch,
2063
- set: (_) => {
2064
- t.nameSearch = _;
2065
- }
2066
- }), a = F(() => t.filterRows), $ = W({});
2067
- function d(_) {
2068
- return $.value[_] ?? !1;
2069
- }
2070
- function r(_, e) {
2071
- $.value = { ...$.value, [_]: e };
2072
- }
2073
- const u = F(
2074
- () => l.skus.map((_) => ({
2075
- label: _.name,
2076
- sublabel: _.code,
2077
- value: _._id
2078
- }))
2079
- ), i = F(
2080
- () => l.recipes.map((_) => ({
2081
- label: _.name,
2082
- value: _._id
2083
- }))
2084
- );
2085
- function f(_) {
2086
- return _.type !== "ingredient" || !_.itemId ? null : l.skuById[_.itemId] ?? null;
2087
- }
2088
- function v(_) {
2089
- var e;
2090
- if (!_.type) return s("inventory.recipe.bulkEditor.step1.filter");
2091
- if (_.type === "ingredient") {
2092
- if (!_.itemId) return s("inventory.recipe.bulkEditor.step1.filterTypeIngredient");
2093
- const S = l.skuById[_.itemId];
2094
- if (!S) return s("inventory.recipe.bulkEditor.step1.filterTypeIngredient");
2095
- const { amount: p, measurement: h } = _.amountModel;
2096
- if (!(p != null && p.amount > 0)) return S.name;
2097
- const z = (h == null ? void 0 : h.abbrev) ?? ((e = S.unit) == null ? void 0 : e.abbrev) ?? "", b = Z(p);
2098
- return `${S.name} (${b}${z})`;
2099
- }
2100
- if (_.type === "recipe") {
2101
- if (!_.itemId) return s("inventory.recipe.bulkEditor.step1.filterTypeRecipe");
2102
- const S = l.recipeById[_.itemId];
2103
- return S ? S.name : s("inventory.recipe.bulkEditor.step1.filterTypeRecipe");
2104
- }
2105
- return "";
2106
- }
2107
- function C(_) {
2108
- const e = ko(_);
2109
- t.filterRows.push(e), r(e.id, !0);
2110
- }
2111
- function w(_) {
2112
- t.filterRows = t.filterRows.filter((S) => S.id !== _);
2113
- const e = { ...$.value };
2114
- delete e[_], $.value = e;
2115
- }
2116
- function c(_) {
2117
- _.amountModel = be(), r(_.id, !0);
2118
- }
2119
- ue(
2120
- [o, a],
2121
- () => {
2122
- const _ = [];
2123
- for (const p of a.value)
2124
- if (!(!p.type || !p.itemId))
2125
- if (p.type === "ingredient") {
2126
- const h = f(p), { amount: N, measurement: z } = p.amountModel, b = N != null && N.amount > 0;
2127
- let B, R;
2128
- h && b && (B = z ? he.multiplyDecimal(N, z.conversion) : N, R = (z == null ? void 0 : z.id) ?? null), _.push({
2129
- id: p.id,
2130
- type: "ingredient",
2131
- itemId: p.itemId,
2132
- amount: B ?? null,
2133
- measurementId: R
2134
- });
2135
- } else p.type === "recipe" && _.push({
2136
- id: p.id,
2137
- type: "recipe",
2138
- itemId: p.itemId
2139
- });
2140
- t.updateQuery({
2141
- nameSearch: o.value,
2142
- filters: _
2143
- });
2144
- const e = o.value.trim().length > 0, S = _.length > 0;
2145
- !e && !S && t.restoreAllRecipes();
2146
- },
2147
- { deep: !0, immediate: !0 }
2148
- );
2149
- function k(_) {
2150
- var h, N, z, b;
2151
- if (_.isGroup) {
2152
- const B = l.skuGroupById[_.id];
2153
- if (!B) return null;
2154
- const R = `x${Z(_.amount)}`;
2155
- return _.recipeIds.slice(1).length ? `(${((h = l.recipeById[_.recipeIds.at(-1) ?? ""]) == null ? void 0 : h.name) ?? ""}) ${B.name} (${R})` : `${B.name} (${R})`;
2156
- }
2157
- const e = l.skuById[_.id];
2158
- if (!e) return null;
2159
- const S = ((N = _.measurement) == null ? void 0 : N.abbrev) ?? ((z = e.unit) == null ? void 0 : z.abbrev) ?? "", p = `${Z(_.amount)}${S}`;
2160
- return _.recipeIds.slice(1).length ? `(${((b = l.recipeById[_.recipeIds.at(-1) ?? ""]) == null ? void 0 : b.name) ?? ""}) ${e.name} (${p})` : `${e.name} (${p})`;
2161
- }
2162
- function I(_) {
2163
- return ke(_.contains, /* @__PURE__ */ new Set([_._id]), l.recipeById).map(k).filter((e) => e !== null).join(", ");
2164
- }
2165
- return (_, e) => {
2166
- const S = G("FmButton"), p = G("FmSearch"), h = G("FmSelect"), N = G("FmPopover"), z = G("FmIcon"), b = G("FmMenuItem"), B = G("FmMenu"), R = G("FmChip");
2167
- return g(), V("div", ho, [
2168
- y("div", xo, [
2169
- y("span", wo, U(n(s)("inventory.recipe.bulkEditor.step1.selectedCount", {
2170
- count: n(t).selectedRecipes.length
2171
- })), 1),
2172
- n(t).excludedRecipeIds.size > 0 ? (g(), Y(S, {
2173
- key: 0,
2174
- label: n(s)("inventory.recipe.bulkEditor.step1.restoreAll"),
2175
- variant: "tertiary",
2176
- size: "md",
2177
- onClick: e[0] || (e[0] = (A) => n(t).restoreAllRecipes())
2178
- }, null, 8, ["label"])) : T("", !0)
2179
- ]),
2180
- y("div", $o, [
2181
- x(p, {
2182
- modelValue: o.value,
2183
- "onUpdate:modelValue": e[1] || (e[1] = (A) => o.value = A),
2184
- placeholder: n(s)("inventory.recipe.bulkEditor.query.nameSearchPlaceholder")
2185
- }, null, 8, ["modelValue", "placeholder"]),
2186
- a.value.length > 0 ? (g(), V("div", Io, [
2187
- (g(!0), V(Q, null, me(a.value, (A) => (g(), V("div", {
2188
- key: A.id,
2189
- class: "flex items-center"
2190
- }, [
2191
- x(N, {
2192
- "show-popover": d(A.id),
2193
- "exclude-el-from-click-outside": ["fm-menu"],
2194
- placement: "bottom-start",
2195
- onPopoverChanged: (P) => r(A.id, P)
2196
- }, {
2197
- "popover-button": J(() => [
2198
- y("button", Eo, [
2199
- y("span", Vo, U(v(A)), 1)
2200
- ])
2201
- ]),
2202
- default: J(() => [
2203
- y("div", So, [
2204
- y("p", Co, U(A.type === "ingredient" ? n(s)("inventory.recipe.bulkEditor.step1.filterTypeIngredient") : n(s)("inventory.recipe.bulkEditor.step1.filterTypeRecipe")), 1),
2205
- A.type === "ingredient" ? (g(), V(Q, { key: 0 }, [
2206
- x(h, {
2207
- modelValue: A.itemId,
2208
- "onUpdate:modelValue": [(P) => A.itemId = P, (P) => c(A)],
2209
- items: u.value,
2210
- placeholder: n(s)("inventory.recipe.bulkEditor.step1.selectIngredient"),
2211
- clearable: ""
2212
- }, {
2213
- "menu-wrapper": J((P) => [
2214
- x(Be, Ie({ ref_for: !0 }, P, {
2215
- items: u.value,
2216
- "model-value": A.itemId
2217
- }), null, 16, ["items", "model-value"])
2218
- ]),
2219
- _: 2
2220
- }, 1032, ["modelValue", "onUpdate:modelValue", "items", "placeholder"]),
2221
- f(A) ? (g(), V("div", Bo, [
2222
- y("span", Ro, [
2223
- mt(U(n(s)("inventory.recipe.bulkEditor.step1.amountLabel")) + " ", 1),
2224
- y("span", Fo, U(n(s)("inventory.recipe.bulkEditor.step1.amountOptional")), 1)
2225
- ]),
2226
- x(Ce, {
2227
- modelValue: A.amountModel,
2228
- "onUpdate:modelValue": (P) => A.amountModel = P,
2229
- unit: f(A).unit,
2230
- placeholder: n(s)("inventory.recipe.bulkEditor.step1.amountPlaceholder"),
2231
- "convert-amount-on-change-unit": ""
2232
- }, null, 8, ["modelValue", "onUpdate:modelValue", "unit", "placeholder"])
2233
- ])) : T("", !0)
2234
- ], 64)) : A.type === "recipe" ? (g(), Y(h, {
2235
- key: 1,
2236
- modelValue: A.itemId,
2237
- "onUpdate:modelValue": [(P) => A.itemId = P, (P) => c(A)],
2238
- items: i.value,
2239
- placeholder: n(s)("inventory.recipe.bulkEditor.step1.selectRecipe"),
2240
- clearable: ""
2241
- }, {
2242
- "menu-wrapper": J((P) => [
2243
- x(Be, Ie({ ref_for: !0 }, P, {
2244
- items: i.value,
2245
- "model-value": A.itemId
2246
- }), null, 16, ["items", "model-value"])
2247
- ]),
2248
- _: 2
2249
- }, 1032, ["modelValue", "onUpdate:modelValue", "items", "placeholder"])) : T("", !0)
2250
- ])
2251
- ]),
2252
- _: 2
2253
- }, 1032, ["show-popover", "onPopoverChanged"]),
2254
- y("button", {
2255
- type: "button",
2256
- class: "inline-flex items-center justify-center h-[30px] w-[26px] rounded-r-md border border-l-0 border-fm-color-border-default bg-fm-color-surface-secondary hover:bg-fm-color-surface-hover text-fm-color-typo-secondary hover:text-fm-color-typo-primary cursor-pointer transition-colors",
2257
- title: n(s)("inventory.recipe.bulkEditor.step1.removeFilter"),
2258
- onClick: (P) => w(A.id)
2259
- }, [
2260
- x(z, {
2261
- name: "close",
2262
- size: "sm"
2263
- })
2264
- ], 8, Ao)
2265
- ]))), 128))
2266
- ])) : T("", !0),
2267
- x(B, {
2268
- "close-on-click": !0,
2269
- placement: "bottom-start"
2270
- }, {
2271
- "menu-button": J(() => [
2272
- x(S, {
2273
- label: n(s)("inventory.recipe.bulkEditor.step1.filter"),
2274
- variant: "secondary",
2275
- size: "md",
2276
- "prepend-icon": "add",
2277
- class: "self-start"
2278
- }, null, 8, ["label"])
2279
- ]),
2280
- default: J(() => [
2281
- x(b, {
2282
- label: n(s)("inventory.recipe.bulkEditor.step1.filterTypeIngredient"),
2283
- icon: "inventory_2",
2284
- onClick: e[2] || (e[2] = (A) => C("ingredient"))
2285
- }, null, 8, ["label"]),
2286
- x(b, {
2287
- label: n(s)("inventory.recipe.bulkEditor.step1.filterTypeRecipe"),
2288
- icon: "restaurant_menu",
2289
- onClick: e[3] || (e[3] = (A) => C("recipe"))
2290
- }, null, 8, ["label"])
2291
- ]),
2292
- _: 1
2293
- })
2294
- ]),
2295
- y("div", To, [
2296
- n(t).selectedRecipes.length === 0 ? (g(), V("div", Uo, [
2297
- x(z, {
2298
- name: "search_off",
2299
- size: "lg",
2300
- class: "text-fm-color-typo-placeholder"
2301
- }),
2302
- y("p", Po, U(n(s)("inventory.recipe.bulkEditor.query.noResults")), 1)
2303
- ])) : (g(), V("div", Mo, [
2304
- (g(!0), V(Q, null, me(n(t).selectedRecipes, (A) => (g(), V("div", {
2305
- key: A._id,
2306
- class: "flex items-center gap-12 px-16 py-12 hover:bg-fm-color-surface-hover transition-colors"
2307
- }, [
2308
- y("div", Do, [
2309
- y("div", Go, U(A.name), 1),
2310
- A.contains.length > 0 ? (g(), V("div", No, U(I(A)), 1)) : T("", !0),
2311
- y("div", zo, [
2312
- A.version === "v2" ? (g(), Y(R, {
2313
- key: 0,
2314
- size: "sm",
2315
- label: "V2",
2316
- variant: "info"
2317
- })) : T("", !0)
2318
- ])
2319
- ]),
2320
- x(S, {
2321
- variant: "tertiary",
2322
- icon: "do_not_disturb_on",
2323
- title: n(s)("inventory.recipe.bulkEditor.step1.removeRecipeTooltip"),
2324
- onClick: (P) => n(t).removeRecipe(A._id)
2325
- }, null, 8, ["title", "onClick"])
2326
- ]))), 128))
2327
- ]))
2328
- ])
2329
- ]);
2330
- };
2331
- }
2332
- }), jo = { class: "flex flex-col gap-0 rounded-lg border border-fm-color-border-default bg-fm-color-surface-default overflow-hidden" }, Lo = { class: "flex items-start gap-12 px-16 py-12" }, Ko = { class: "flex-1" }, qo = { class: "flex-1" }, Wo = {
2333
- key: 0,
2334
- class: "border-t border-fm-color-border-default px-16 py-10 flex items-center gap-10"
2335
- }, Yo = {
2336
- key: 1,
2337
- class: "border-t border-fm-color-border-default px-16 py-10 flex items-start gap-8 bg-fm-color-surface-warning"
2338
- }, Jo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-warning" }, Ho = {
2339
- key: 2,
2340
- class: "border-t border-fm-color-border-default px-16 py-12 flex flex-col gap-12"
2341
- }, Qo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary -mb-4" }, Xo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Zo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ei = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-warning" }, ti = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary -mt-8" }, ni = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary -mb-4" }, oi = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ii = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, li = /* @__PURE__ */ le({
2342
- __name: "ModificationCard",
2343
- props: {
2344
- modelValue: {},
2345
- livePreviewEntries: {}
2346
- },
2347
- emits: ["update:modelValue"],
2348
- setup(m, { emit: s }) {
2349
- const l = m, t = s, { t: o } = ie(), a = ne(), $ = We();
2350
- function d(E) {
2351
- const D = E.type === "replace-binding" ? E.from.type : E.type === "remove-binding" || E.type === "update-binding-rule" || E.type === "update-alternatives" ? E.target.type : E.type === "add-binding" ? E.binding.type : null;
2352
- return D ? D === "RECIPE" ? "recipe" : "ingredient" : null;
2353
- }
2354
- function r(E) {
2355
- return E.type === "update-alternatives" ? !0 : E.type === "add-binding" ? (E.binding.alternatives ?? []).length > 0 : E.type === "replace-binding" ? (E.to.alternatives ?? []).length > 0 : !1;
2356
- }
2357
- function u(E) {
2358
- switch (E.type) {
2359
- case "add-binding":
2360
- return "link";
2361
- case "replace-binding":
2362
- return E.from.id === E.to.id ? "update" : null;
2363
- case "remove-binding":
2364
- return "remove";
2365
- case "update-binding-rule":
2366
- return null;
2367
- case "update-alternatives":
2368
- return "alts";
2369
- }
2370
- }
2371
- function i(E) {
2372
- return E.type === "replace-binding" ? E.from.id || null : (E.type === "remove-binding" || E.type === "update-binding-rule" || E.type === "update-alternatives") && E.target.id || null;
2373
- }
2374
- function f(E) {
2375
- return E.type === "add-binding" && E.binding.id || null;
2376
- }
2377
- function v(E) {
2378
- const D = E.type === "replace-binding" ? E.to : E.type === "add-binding" ? E.binding : null;
2379
- return D ? { amount: D.amount, measurement: D.measurement ?? null } : be();
2380
- }
2381
- function C(E) {
2382
- return E.type === "replace-binding" ? E.to.rules ?? null : E.type === "add-binding" ? E.binding.rules ?? null : null;
2383
- }
2384
- function w(E) {
2385
- return E.type === "update-alternatives" ? E.alternatives ?? [] : E.type === "add-binding" ? E.binding.alternatives ?? [] : [];
2386
- }
2387
- const c = W(d(l.modelValue)), k = W(u(l.modelValue)), I = W(r(l.modelValue)), _ = W(i(l.modelValue)), e = W(f(l.modelValue)), S = W(v(l.modelValue)), p = W(C(l.modelValue)), h = W(w(l.modelValue)), N = W(
2388
- (() => {
2389
- const E = v(l.modelValue);
2390
- return E.amount ? Z(E.amount) : "";
2391
- })()
2392
- );
2393
- let z = null;
2394
- function b(E) {
2395
- N.value = E, z && clearTimeout(z), z = setTimeout(() => {
2396
- const D = +E;
2397
- S.value = {
2398
- amount: E.length > 0 && isFinite(D) ? Ke(D) : { amount: 0, precision: 0 },
2399
- measurement: null
2400
- };
2401
- }, 300);
2402
- }
2403
- ue(c, () => {
2404
- k.value = null, I.value = !1, _.value = null, e.value = null, S.value = be(), p.value = null, h.value = [], N.value = "";
2405
- }), ue(k, () => {
2406
- _.value = null, e.value = null, S.value = be(), p.value = null, h.value = [], N.value = "";
2407
- }), ue(I, (E) => {
2408
- E || (h.value = [], k.value === "alts" && (k.value = null));
2409
- });
2410
- const B = F(() => [
2411
- { label: o("inventory.recipe.bulkEditor.step2.fieldIngredient"), value: "ingredient" },
2412
- { label: o("inventory.recipe.bulkEditor.step2.fieldRecipe"), value: "recipe" }
2413
- ]), R = F(() => {
2414
- const E = [
2415
- { label: o("inventory.recipe.bulkEditor.step2.actionLink"), value: "link" },
2416
- { label: o("inventory.recipe.bulkEditor.step2.actionUpdate"), value: "update" },
2417
- { label: o("inventory.recipe.bulkEditor.step2.actionRemove"), value: "remove" }
2418
- ];
2419
- return c.value === "ingredient" && I.value && $.enableRecipeV2 && E.push({ label: o("inventory.recipe.bulkEditor.step2.actionAlts"), value: "alts" }), E;
2420
- }), A = F(() => c.value !== null && k.value !== null), P = F(
2421
- () => k.value === "update" || k.value === "remove" || k.value === "alts"
2422
- ), K = F(
2423
- () => k.value === "link"
2424
- ), H = F(
2425
- () => k.value === "update" && _.value !== null
2426
- ), ee = F(
2427
- () => c.value === "ingredient" && I.value && $.enableRecipeV2
2428
- ), O = F(
2429
- () => a.skus.map((E) => ({ label: E.name, sublabel: E.code, value: E._id }))
2430
- ), M = F(
2431
- () => a.recipes.map((E) => ({ label: E.name, value: E._id }))
2432
- ), j = F(() => c.value === "recipe" ? M.value : O.value), q = F(() => c.value === "recipe" ? M.value : O.value), oe = F(() => c.value !== "ingredient" || !e.value ? null : a.skuById[e.value] ?? null), X = F(() => c.value !== "ingredient" || !_.value ? null : a.skuById[_.value] ?? null), se = F(() => {
2433
- const E = _.value ?? e.value;
2434
- return E ? [E] : [];
2435
- }), fe = F(() => ee.value ? Object.values(l.livePreviewEntries).filter(
2436
- (E) => E.original.version !== "v2"
2437
- ).length : 0), xe = F(() => Object.values(l.livePreviewEntries).length);
2438
- ue(
2439
- () => [k.value, _.value],
2440
- ([E, D], [te, pe]) => {
2441
- if (E !== "alts" || D === pe) return;
2442
- if (!D) {
2443
- h.value = [];
2444
- return;
2445
- }
2446
- const we = Object.values(l.livePreviewEntries).find(
2447
- (L) => L.original.version === "v2" && L.original.contains.some(($e) => $e.type === "SKU" && $e.id === D)
2448
- );
2449
- if (we) {
2450
- const L = we.original.contains.find(($e) => $e.type === "SKU" && $e.id === D);
2451
- h.value = L != null && L.alternatives ? [...L.alternatives] : [];
2452
- } else
2453
- h.value = [];
2454
- }
2455
- );
2456
- const ae = F(() => k.value !== "alts" || !_.value ? 0 : Object.values(l.livePreviewEntries).filter(
2457
- (E) => E.original.version === "v2" && E.original.contains.some((D) => D.type === "SKU" && D.id === _.value)
2458
- ).length);
2459
- function ve() {
2460
- return c.value === "recipe" ? "RECIPE" : "SKU";
2461
- }
2462
- function ce() {
2463
- const E = ve(), D = be().amount, te = {
2464
- type: E,
2465
- id: "",
2466
- amount: D,
2467
- measurement: null,
2468
- rules: null,
2469
- alternatives: []
2470
- };
2471
- switch (k.value) {
2472
- case "update":
2473
- return { type: "replace-binding", from: { type: E, id: "" }, to: te };
2474
- case "remove":
2475
- return { type: "remove-binding", target: { type: E, id: "" } };
2476
- case "alts":
2477
- return { type: "update-alternatives", target: { type: E, id: "" }, alternatives: [] };
2478
- case "link":
2479
- default:
2480
- return { type: "add-binding", binding: te };
2481
- }
2482
- }
2483
- function Te() {
2484
- return _.value ? { type: ve(), id: _.value } : null;
2485
- }
2486
- function Ye(E = !1) {
2487
- const D = E ? _.value : e.value;
2488
- if (!D) return null;
2489
- const { amount: te, measurement: pe } = S.value, Ee = pe ? he.multiplyDecimal(te, pe.conversion) : te;
2490
- return {
2491
- type: ve(),
2492
- id: D,
2493
- amount: Ee,
2494
- measurement: pe ?? null,
2495
- rules: c.value === "recipe" ? p.value ?? null : null,
2496
- alternatives: ee.value ? h.value : []
2497
- };
2498
- }
2499
- function ct() {
2500
- if (!c.value) return;
2501
- if (!k.value) {
2502
- t("update:modelValue", ce());
2503
- return;
2504
- }
2505
- const E = Te(), D = Ye(!1);
2506
- let te = null;
2507
- switch (k.value) {
2508
- case "link":
2509
- D && (te = { type: "add-binding", binding: D });
2510
- break;
2511
- case "update": {
2512
- const pe = Ye(!0);
2513
- E && pe && (te = { type: "replace-binding", from: E, to: pe });
2514
- break;
2515
- }
2516
- case "remove":
2517
- E && (te = { type: "remove-binding", target: E });
2518
- break;
2519
- case "alts":
2520
- E && (te = { type: "update-alternatives", target: E, alternatives: h.value });
2521
- break;
2522
- }
2523
- t("update:modelValue", te ?? ce());
2524
- }
2525
- return ue(
2526
- [c, k, I, _, e, S, p, h],
2527
- () => ct(),
2528
- { deep: !0 }
2529
- ), (E, D) => {
2530
- const te = G("FmSelect"), pe = G("FmSwitch"), Ee = G("FmIcon"), we = G("FmTextField");
2531
- return g(), V("div", jo, [
2532
- y("div", Lo, [
2533
- y("div", Ko, [
2534
- x(te, {
2535
- modelValue: c.value,
2536
- "onUpdate:modelValue": D[0] || (D[0] = (L) => c.value = L),
2537
- items: B.value,
2538
- label: n(o)("inventory.recipe.bulkEditor.step2.sectionField"),
2539
- placeholder: n(o)("inventory.recipe.bulkEditor.step2.sectionField")
2540
- }, null, 8, ["modelValue", "items", "label", "placeholder"])
2541
- ]),
2542
- y("div", qo, [
2543
- x(te, {
2544
- modelValue: k.value,
2545
- "onUpdate:modelValue": D[1] || (D[1] = (L) => k.value = L),
2546
- items: R.value,
2547
- label: n(o)("inventory.recipe.bulkEditor.step2.sectionAction"),
2548
- placeholder: n(o)("inventory.recipe.bulkEditor.step2.sectionAction")
2549
- }, null, 8, ["modelValue", "items", "label", "placeholder"])
2550
- ])
2551
- ]),
2552
- c.value === "ingredient" && n($).enableRecipeV2 ? (g(), V("div", Wo, [
2553
- x(pe, {
2554
- modelValue: I.value,
2555
- "onUpdate:modelValue": D[2] || (D[2] = (L) => I.value = L),
2556
- label: n(o)("inventory.recipe.bulkEditor.step2.includeAlternativesToggle")
2557
- }, null, 8, ["modelValue", "label"])
2558
- ])) : T("", !0),
2559
- ee.value && fe.value > 0 ? (g(), V("div", Yo, [
2560
- x(Ee, {
2561
- name: "warning",
2562
- size: "sm",
2563
- class: "text-fm-color-typo-warning mt-1 shrink-0"
2564
- }),
2565
- y("p", Jo, U(n(o)("inventory.recipe.bulkEditor.step2.v1AlternativesWarning", {
2566
- v1Count: fe.value,
2567
- total: xe.value
2568
- })), 1)
2569
- ])) : T("", !0),
2570
- A.value ? (g(), V("div", Ho, [
2571
- P.value ? (g(), V(Q, { key: 0 }, [
2572
- y("p", Qo, U(n(o)("inventory.recipe.bulkEditor.addModification.targetLabel")), 1),
2573
- x(te, {
2574
- modelValue: _.value,
2575
- "onUpdate:modelValue": D[3] || (D[3] = (L) => _.value = L),
2576
- items: j.value,
2577
- placeholder: c.value === "recipe" ? n(o)("inventory.recipe.bulkEditor.addModification.recipePlaceholder") : n(o)("inventory.recipe.bulkEditor.addModification.skuPlaceholder"),
2578
- clearable: ""
2579
- }, {
2580
- "menu-wrapper": J((L) => [
2581
- x(Be, Ie(L, {
2582
- items: j.value,
2583
- "model-value": _.value
2584
- }), null, 16, ["items", "model-value"])
2585
- ]),
2586
- _: 1
2587
- }, 8, ["modelValue", "items", "placeholder"]),
2588
- H.value ? (g(), V(Q, { key: 0 }, [
2589
- c.value === "ingredient" && X.value ? (g(), Y(Ce, {
2590
- key: 0,
2591
- modelValue: S.value,
2592
- "onUpdate:modelValue": D[4] || (D[4] = (L) => S.value = L),
2593
- unit: X.value.unit,
2594
- placeholder: n(o)("inventory.recipe.bulkEditor.query.amountPlaceholder"),
2595
- "convert-amount-on-change-unit": ""
2596
- }, null, 8, ["modelValue", "unit", "placeholder"])) : c.value === "recipe" ? (g(), Y(we, {
2597
- key: 1,
2598
- "model-value": N.value,
2599
- label: n(o)("inventory.recipe.bulkEditor.addModification.amountLabel"),
2600
- type: "number",
2601
- "onUpdate:modelValue": D[5] || (D[5] = (L) => b(L))
2602
- }, null, 8, ["model-value", "label"])) : T("", !0),
2603
- c.value === "recipe" ? (g(), V(Q, { key: 2 }, [
2604
- y("p", Xo, U(n(o)("inventory.recipe.bulkEditor.addModification.optionalRuleLabel")), 1),
2605
- x(Re, {
2606
- modelValue: p.value,
2607
- "onUpdate:modelValue": D[6] || (D[6] = (L) => p.value = L)
2608
- }, null, 8, ["modelValue"])
2609
- ], 64)) : T("", !0),
2610
- ee.value ? (g(), V(Q, { key: 3 }, [
2611
- y("p", Zo, U(n(o)("inventory.recipe.bulkEditor.addModification.optionalAlternativesLabel")), 1),
2612
- x(Se, {
2613
- modelValue: h.value,
2614
- "onUpdate:modelValue": D[7] || (D[7] = (L) => h.value = L),
2615
- "filter-ingredient-ids": se.value
2616
- }, null, 8, ["modelValue", "filter-ingredient-ids"])
2617
- ], 64)) : T("", !0)
2618
- ], 64)) : T("", !0),
2619
- k.value === "alts" && _.value ? (g(), V(Q, { key: 1 }, [
2620
- y("p", ei, U(ae.value > 0 ? n(o)("inventory.recipe.bulkEditor.addModification.altsOverwriteWarning", { count: ae.value }) : n(o)("inventory.recipe.bulkEditor.addModification.altsNotFoundWarning")), 1),
2621
- y("p", ti, U(n(o)("inventory.recipe.bulkEditor.addModification.altsClearNote")), 1),
2622
- x(Se, {
2623
- modelValue: h.value,
2624
- "onUpdate:modelValue": D[8] || (D[8] = (L) => h.value = L),
2625
- "filter-ingredient-ids": se.value
2626
- }, null, 8, ["modelValue", "filter-ingredient-ids"])
2627
- ], 64)) : T("", !0)
2628
- ], 64)) : T("", !0),
2629
- K.value ? (g(), V(Q, { key: 1 }, [
2630
- y("p", ni, U(n(o)("inventory.recipe.bulkEditor.addModification.bindingLabel")), 1),
2631
- x(te, {
2632
- modelValue: e.value,
2633
- "onUpdate:modelValue": D[9] || (D[9] = (L) => e.value = L),
2634
- items: q.value,
2635
- placeholder: c.value === "recipe" ? n(o)("inventory.recipe.bulkEditor.addModification.recipePlaceholder") : n(o)("inventory.recipe.bulkEditor.addModification.skuPlaceholder"),
2636
- clearable: ""
2637
- }, {
2638
- "menu-wrapper": J((L) => [
2639
- x(Be, Ie(L, {
2640
- items: q.value,
2641
- "model-value": e.value
2642
- }), null, 16, ["items", "model-value"])
2643
- ]),
2644
- _: 1
2645
- }, 8, ["modelValue", "items", "placeholder"]),
2646
- e.value ? (g(), V(Q, { key: 0 }, [
2647
- c.value === "ingredient" && oe.value ? (g(), Y(Ce, {
2648
- key: 0,
2649
- modelValue: S.value,
2650
- "onUpdate:modelValue": D[10] || (D[10] = (L) => S.value = L),
2651
- unit: oe.value.unit,
2652
- placeholder: n(o)("inventory.recipe.bulkEditor.query.amountPlaceholder"),
2653
- "convert-amount-on-change-unit": ""
2654
- }, null, 8, ["modelValue", "unit", "placeholder"])) : c.value === "recipe" ? (g(), Y(we, {
2655
- key: 1,
2656
- "model-value": N.value,
2657
- label: n(o)("inventory.recipe.bulkEditor.addModification.amountLabel"),
2658
- type: "number",
2659
- "onUpdate:modelValue": D[11] || (D[11] = (L) => b(L))
2660
- }, null, 8, ["model-value", "label"])) : T("", !0),
2661
- c.value === "recipe" ? (g(), V(Q, { key: 2 }, [
2662
- y("p", oi, U(n(o)("inventory.recipe.bulkEditor.addModification.optionalRuleLabel")), 1),
2663
- x(Re, {
2664
- modelValue: p.value,
2665
- "onUpdate:modelValue": D[12] || (D[12] = (L) => p.value = L)
2666
- }, null, 8, ["modelValue"])
2667
- ], 64)) : T("", !0),
2668
- ee.value ? (g(), V(Q, { key: 3 }, [
2669
- y("p", ii, U(n(o)("inventory.recipe.bulkEditor.addModification.optionalAlternativesLabel")), 1),
2670
- x(Se, {
2671
- modelValue: h.value,
2672
- "onUpdate:modelValue": D[13] || (D[13] = (L) => h.value = L),
2673
- "filter-ingredient-ids": se.value
2674
- }, null, 8, ["modelValue", "filter-ingredient-ids"])
2675
- ], 64)) : T("", !0)
2676
- ], 64)) : T("", !0)
2677
- ], 64)) : T("", !0)
2678
- ])) : T("", !0)
2679
- ]);
2680
- };
2681
- }
2682
- }), ai = { class: "flex flex-col gap-8" }, ri = { class: "flex flex-wrap items-center gap-12 px-4" }, si = {
2683
- key: 0,
2684
- class: "flex items-center gap-6"
2685
- }, di = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ui = {
2686
- key: 1,
2687
- class: "flex items-center gap-6"
2688
- }, ci = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, pi = {
2689
- key: 2,
2690
- class: "flex items-center gap-6"
2691
- }, mi = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, fi = { class: "rounded-lg border border-fm-color-border-default overflow-hidden" }, vi = {
2692
- key: 0,
2693
- class: "px-16 py-12 text-center fm-typo-en-body-sm-400 text-fm-color-typo-placeholder"
2694
- }, yi = {
2695
- key: 1,
2696
- class: "divide-y divide-fm-color-border-default"
2697
- }, bi = { class: "flex items-center gap-12" }, gi = { class: "flex-1 fm-typo-en-body-sm-600 text-fm-color-typo-primary truncate" }, _i = {
2698
- key: 0,
2699
- class: "flex flex-col gap-4 pl-8"
2700
- }, ki = { class: "flex-1 fm-typo-en-body-xs-400 text-fm-color-typo-secondary font-mono truncate" }, hi = /* @__PURE__ */ le({
2701
- __name: "LivePreviewTable",
2702
- setup(m) {
2703
- const { t: s } = ie(), l = _e(), t = ne(), o = {
2704
- "will-update": 0,
2705
- "partially-ignored": 1,
2706
- "already-satisfied": 2,
2707
- blocked: 3,
2708
- "no-applicable-changes": 4
2709
- }, a = F(
2710
- () => Object.values(l.livePreviewEntries).sort(
2711
- (e, S) => o[e.status] - o[S.status]
2712
- )
2713
- ), $ = F(
2714
- () => a.value.filter((e) => e.status === "will-update").length
2715
- ), d = F(
2716
- () => a.value.filter((e) => e.status === "partially-ignored").length
2717
- ), r = F(
2718
- () => a.value.filter((e) => e.status === "already-satisfied").length
2719
- ), u = F(
2720
- () => a.value.filter((e) => e.status === "blocked").length
2721
- );
2722
- function i(e) {
2723
- switch (e) {
2724
- case "will-update":
2725
- return s("inventory.recipe.bulkEditor.status.willUpdate");
2726
- case "already-satisfied":
2727
- return s("inventory.recipe.bulkEditor.status.alreadySatisfied");
2728
- case "partially-ignored":
2729
- return s("inventory.recipe.bulkEditor.status.partiallyIgnored");
2730
- case "blocked":
2731
- return s("inventory.recipe.bulkEditor.status.blocked");
2732
- case "no-applicable-changes":
2733
- return s("inventory.recipe.bulkEditor.status.noApplicableChanges");
2734
- default:
2735
- return "";
2736
- }
2737
- }
2738
- function f(e) {
2739
- switch (e) {
2740
- case "will-update":
2741
- return "success";
2742
- case "already-satisfied":
2743
- return "info";
2744
- case "partially-ignored":
2745
- return "warning";
2746
- case "blocked":
2747
- return "critical";
2748
- case "no-applicable-changes":
2749
- return "neutral";
2750
- default:
2751
- return "neutral";
2752
- }
2753
- }
2754
- function v(e, S) {
2755
- var p, h, N;
2756
- return e === "SKU" ? ((p = t.skuById[S]) == null ? void 0 : p.name) ?? S : e === "SKU_GROUP" ? ((h = t.skuGroupById[S]) == null ? void 0 : h.name) ?? S : e === "RECIPE" ? ((N = t.recipeById[S]) == null ? void 0 : N.name) ?? S : S;
2757
- }
2758
- function C(e) {
2759
- var p, h;
2760
- const S = v(e.type, e.id);
2761
- if (e.type === "SKU") {
2762
- const N = t.skuById[e.id], z = ((p = e.measurement) == null ? void 0 : p.abbrev) ?? ((h = N == null ? void 0 : N.unit) == null ? void 0 : h.abbrev) ?? "";
2763
- return `${S} (${Z(e.amount)} ${z})`.trim();
2764
- }
2765
- return e.type === "RECIPE" ? `${S} ×${Z(e.amount)}` : S;
2766
- }
2767
- function w(e) {
2768
- return v(e.type, e.id);
2769
- }
2770
- function c(e, S) {
2771
- const p = S.contains.find((h) => h.type === e.type && h.id === e.id);
2772
- return p ? C(p) : w(e);
2773
- }
2774
- function k(e, S) {
2775
- switch (e.type) {
2776
- case "add-binding":
2777
- return `+ ${C(e.binding)}`;
2778
- case "remove-binding":
2779
- return `− ${w(e.target)}`;
2780
- case "replace-binding":
2781
- return `${c(e.from, S)} → ${C(e.to)}`;
2782
- case "update-binding-rule":
2783
- return `Rule: ${w(e.target)}`;
2784
- case "update-alternatives":
2785
- return `Alternatives: ${w(e.target)}`;
2786
- }
2787
- }
2788
- function I(e) {
2789
- switch (e) {
2790
- case "applied":
2791
- return "success";
2792
- case "already-satisfied":
2793
- return "info";
2794
- case "ignored":
2795
- return "neutral";
2796
- case "blocked":
2797
- return "critical";
2798
- default:
2799
- return "neutral";
2800
- }
2801
- }
2802
- function _(e) {
2803
- switch (e) {
2804
- case "applied":
2805
- return s("inventory.recipe.bulkEditor.livePreview.outcomeApplied");
2806
- case "already-satisfied":
2807
- return s("inventory.recipe.bulkEditor.livePreview.outcomeAlreadySatisfied");
2808
- case "ignored":
2809
- return s("inventory.recipe.bulkEditor.livePreview.outcomeIgnored");
2810
- case "blocked":
2811
- return s("inventory.recipe.bulkEditor.livePreview.outcomeBlocked");
2812
- default:
2813
- return e;
2814
- }
2815
- }
2816
- return (e, S) => {
2817
- const p = G("FmChip");
2818
- return g(), V("div", ai, [
2819
- y("div", ri, [
2820
- $.value + d.value > 0 ? (g(), V("div", si, [
2821
- x(p, {
2822
- size: "sm",
2823
- label: String($.value + d.value),
2824
- variant: "success"
2825
- }, null, 8, ["label"]),
2826
- y("span", di, U(n(s)("inventory.recipe.bulkEditor.livePreview.willUpdate")), 1)
2827
- ])) : T("", !0),
2828
- r.value > 0 ? (g(), V("div", ui, [
2829
- x(p, {
2830
- size: "sm",
2831
- label: String(r.value),
2832
- variant: "info"
2833
- }, null, 8, ["label"]),
2834
- y("span", ci, U(n(s)("inventory.recipe.bulkEditor.livePreview.alreadySatisfied")), 1)
2835
- ])) : T("", !0),
2836
- u.value > 0 ? (g(), V("div", pi, [
2837
- x(p, {
2838
- size: "sm",
2839
- label: String(u.value),
2840
- variant: "critical"
2841
- }, null, 8, ["label"]),
2842
- y("span", mi, U(n(s)("inventory.recipe.bulkEditor.livePreview.blocked")), 1)
2843
- ])) : T("", !0)
2844
- ]),
2845
- y("div", fi, [
2846
- a.value.length === 0 ? (g(), V("div", vi, U(n(s)("inventory.recipe.bulkEditor.livePreview.noRecipes")), 1)) : (g(), V("div", yi, [
2847
- (g(!0), V(Q, null, me(a.value, (h) => (g(), V("div", {
2848
- key: h.recipeId,
2849
- class: "flex flex-col gap-6 px-16 py-10"
2850
- }, [
2851
- y("div", bi, [
2852
- y("span", gi, U(h.recipeName), 1),
2853
- x(p, {
2854
- size: "sm",
2855
- label: i(h.status),
2856
- variant: f(h.status)
2857
- }, null, 8, ["label", "variant"])
2858
- ]),
2859
- h.changes.length > 0 ? (g(), V("div", _i, [
2860
- (g(!0), V(Q, null, me(h.changes, (N, z) => (g(), V("div", {
2861
- key: z,
2862
- class: "flex items-center gap-8"
2863
- }, [
2864
- y("span", ki, U(k(N.change, h.original)), 1),
2865
- x(p, {
2866
- size: "sm",
2867
- label: _(N.outcome),
2868
- variant: I(N.outcome)
2869
- }, null, 8, ["label", "variant"])
2870
- ]))), 128))
2871
- ])) : T("", !0)
2872
- ]))), 128))
2873
- ]))
2874
- ])
2875
- ]);
2876
- };
2877
- }
2878
- }), xi = { class: "flex flex-col h-full overflow-hidden" }, wi = { class: "flex flex-col min-h-0 shrink-0" }, $i = { class: "flex items-center gap-8 px-16 pt-12 border-b border-fm-color-border-default" }, Ii = { class: "flex-1 overflow-x-auto min-w-0" }, Ei = {
2879
- class: "px-16 py-14 overflow-y-auto",
2880
- style: { "max-height": "45vh" }
2881
- }, Vi = {
2882
- key: 0,
2883
- class: "flex flex-col items-center justify-center py-40 gap-8 text-center rounded-lg border border-dashed border-fm-color-border-default"
2884
- }, Si = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ci = { class: "flex-1 overflow-y-auto px-16 py-14 flex flex-col gap-12 min-h-0" }, Bi = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary shrink-0" }, Ri = /* @__PURE__ */ le({
2885
- __name: "RecipeBulkEditorStep2",
2886
- setup(m) {
2887
- const { t: s } = ie(), l = _e(), t = W(null);
2888
- ue(
2889
- () => l.modifications.length,
2890
- (r) => {
2891
- r === 0 ? t.value = null : (t.value === null || t.value >= r) && (t.value = r - 1);
2892
- },
2893
- { immediate: !0 }
2894
- );
2895
- function o(r, u) {
2896
- const i = r.type === "replace-binding" ? r.from.type : r.type === "remove-binding" || r.type === "update-binding-rule" || r.type === "update-alternatives" ? r.target.type : r.type === "add-binding" ? r.binding.type : null;
2897
- return i === "RECIPE" ? s("inventory.recipe.bulkEditor.step2.fieldRecipe") : i === "SKU" || i === "SKU_GROUP" ? s("inventory.recipe.bulkEditor.step2.fieldIngredient") : s("inventory.recipe.bulkEditor.step2.tabLabel", { n: u + 1 });
2898
- }
2899
- const a = F(
2900
- () => l.modifications.map((r, u) => ({
2901
- label: o(r, u),
2902
- value: u
2903
- }))
2904
- );
2905
- function $() {
2906
- const u = {
2907
- type: "add-binding",
2908
- binding: {
2909
- type: "SKU",
2910
- id: "",
2911
- amount: be().amount,
2912
- measurement: null,
2913
- rules: null,
2914
- alternatives: []
2915
- }
2916
- };
2917
- l.addModification(u), t.value = l.modifications.length - 1;
2918
- }
2919
- function d(r) {
2920
- l.removeModification(r);
2921
- }
2922
- return (r, u) => {
2923
- const i = G("FmButton"), f = G("FmTab"), v = G("FmTabs"), C = G("FmIcon");
2924
- return g(), V("div", xi, [
2925
- y("div", wi, [
2926
- y("div", $i, [
2927
- y("div", Ii, [
2928
- a.value.length > 0 ? (g(), Y(v, {
2929
- key: 0,
2930
- "model-value": t.value,
2931
- items: a.value,
2932
- "onUpdate:modelValue": u[1] || (u[1] = (w) => t.value = w)
2933
- }, {
2934
- default: J((w) => [
2935
- x(f, Ie(w, {
2936
- "model-value": t.value,
2937
- "onUpdate:modelValue": u[0] || (u[0] = (c) => t.value = c)
2938
- }), {
2939
- append: J(() => [
2940
- x(i, {
2941
- variant: "tertiary",
2942
- icon: "close",
2943
- size: "md",
2944
- onClick: ft((c) => d(w.value), ["stop"])
2945
- }, null, 8, ["onClick"])
2946
- ]),
2947
- _: 2
2948
- }, 1040, ["model-value"])
2949
- ]),
2950
- _: 1
2951
- }, 8, ["model-value", "items"])) : T("", !0)
2952
- ]),
2953
- x(i, {
2954
- label: n(s)("inventory.recipe.bulkEditor.step2.addModification"),
2955
- variant: "secondary",
2956
- size: "md",
2957
- "prepend-icon": "add",
2958
- class: "shrink-0",
2959
- onClick: $
2960
- }, null, 8, ["label"])
2961
- ]),
2962
- y("div", Ei, [
2963
- n(l).modifications.length === 0 ? (g(), V("div", Vi, [
2964
- x(C, {
2965
- name: "edit_note",
2966
- size: "lg",
2967
- class: "text-fm-color-typo-placeholder"
2968
- }),
2969
- y("p", Si, U(n(s)("inventory.recipe.bulkEditor.step2.emptyState")), 1)
2970
- ])) : t.value !== null && n(l).modifications[t.value] ? (g(), Y(li, {
2971
- key: t.value,
2972
- "model-value": n(l).modifications[t.value],
2973
- "live-preview-entries": n(l).livePreviewEntries,
2974
- "onUpdate:modelValue": u[2] || (u[2] = (w) => n(l).updateModification(t.value, w))
2975
- }, null, 8, ["model-value", "live-preview-entries"])) : T("", !0)
2976
- ])
2977
- ]),
2978
- u[3] || (u[3] = y("div", { class: "border-t border-fm-color-border-default shrink-0" }, null, -1)),
2979
- y("div", Ci, [
2980
- y("span", Bi, U(n(s)("inventory.recipe.bulkEditor.step2.livePreviewTitle")), 1),
2981
- x(hi)
2982
- ])
2983
- ]);
2984
- };
2985
- }
2986
- });
2987
- function Fi(m) {
2988
- return !m || Object.keys(m).length === 0 ? "" : Object.entries(m).map(([s, l]) => `${s}: ${l}`).join(", ");
2989
- }
2990
- function Ai() {
2991
- const m = ne(), s = _e(), l = m.skuById, t = m.recipeById, o = m.skuGroupById, $ = Object.values(s.entries).filter(
2992
- (u) => u.status === "will-update" || u.status === "partially-ignored"
2993
- ).flatMap((u, i) => {
2994
- var C;
2995
- const f = u.projected ?? u.original, v = Fi(f.customAttributes);
2996
- if ((C = f.contains) != null && C.length) {
2997
- const w = f.contains.filter((I) => I.type === "RECIPE"), c = f.contains.filter((I) => I.type === "SKU"), k = f.contains.filter((I) => I.type === "SKU_GROUP");
2998
- return [
2999
- ...i === 0 ? [] : [["", "", "", "", "", "", ""]],
3000
- ...w.map(
3001
- (I, _) => {
3002
- var e;
3003
- return [
3004
- _ === 0 ? f.name : "",
3005
- "RECIPE",
3006
- "",
3007
- ((e = t[I.id]) == null ? void 0 : e.name) ?? I.id,
3008
- Z(I.amount),
3009
- "UNIT",
3010
- _ === 0 ? v : ""
3011
- ];
3012
- }
3013
- ),
3014
- ...c.map(
3015
- (I, _) => {
3016
- var e, S, p, h;
3017
- return [
3018
- !w.length && _ === 0 ? f.name : "",
3019
- "INGREDIENT",
3020
- ((e = l[I.id]) == null ? void 0 : e.code) ?? "",
3021
- ((S = l[I.id]) == null ? void 0 : S.name) ?? I.id,
3022
- Z(I.amount),
3023
- I.measurement ? I.measurement.abbrev : ((h = (p = l[I.id]) == null ? void 0 : p.unit) == null ? void 0 : h.abbrev) ?? "",
3024
- !w.length && _ === 0 ? v : ""
3025
- ];
3026
- }
3027
- ),
3028
- ...k.map(
3029
- (I, _) => {
3030
- var e, S;
3031
- return [
3032
- w.length === 0 && c.length === 0 && _ === 0 ? f.name : "",
3033
- "SKU_GROUP",
3034
- ((e = o[I.id]) == null ? void 0 : e.ref) ?? "",
3035
- ((S = o[I.id]) == null ? void 0 : S.name) ?? I.id,
3036
- Z(I.amount),
3037
- "UNIT",
3038
- w.length === 0 && c.length === 0 && _ === 0 ? v : ""
3039
- ];
3040
- }
3041
- )
3042
- ];
3043
- }
3044
- return [
3045
- ...i === 0 ? [] : [["", "", "", "", "", "", ""]],
3046
- [f.name, "No bindings", "", "", "", "", v]
3047
- ];
3048
- }), r = rt($, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
3049
- st(r, `RECIPE_BULK_EDIT_${dt(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
3050
- }
3051
- const Ti = { class: "flex flex-col gap-16" }, Ui = { class: "rounded-lg border border-fm-color-border-default bg-fm-color-surface-secondary p-16" }, Pi = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary mb-8" }, Mi = { class: "flex flex-wrap gap-12" }, Di = { class: "flex items-center gap-6" }, Gi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ni = {
3052
- key: 0,
3053
- class: "flex items-center gap-6"
3054
- }, zi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Oi = {
3055
- key: 1,
3056
- class: "flex items-center gap-6"
3057
- }, ji = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Li = {
3058
- key: 2,
3059
- class: "flex items-center gap-6"
3060
- }, Ki = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, qi = {
3061
- key: 3,
3062
- class: "flex items-center gap-6"
3063
- }, Wi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Yi = { class: "mt-12" }, Ji = ["onClick"], Hi = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary flex-1 truncate" }, Qi = {
3064
- key: 0,
3065
- class: "px-12 py-8 border-b border-fm-color-border-default"
3066
- }, Xi = { class: "px-12 py-10 leading-relaxed" }, Zi = {
3067
- key: 2,
3068
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-placeholder italic"
3069
- }, el = { class: "flex items-center gap-12 px-12 py-8 border-t border-fm-color-border-default bg-fm-color-surface-secondary text-fm-color-typo-secondary fm-typo-en-body-xs-400" }, tl = { key: 0 }, nl = { key: 1 }, ol = {
3070
- key: 2,
3071
- class: "text-fm-color-warning"
3072
- }, il = {
3073
- key: 3,
3074
- class: "text-fm-color-error"
3075
- }, ll = {
3076
- key: 4,
3077
- class: "text-fm-color-typo-placeholder"
3078
- }, al = /* @__PURE__ */ le({
3079
- __name: "RecipeBulkEditorSummaryStep",
3080
- setup(m) {
3081
- const { t: s } = ie(), l = ne(), t = _e(), o = F(() => Object.values(t.entries)), a = F(
3082
- () => o.value.filter((e) => e.status === "will-update").length
3083
- ), $ = F(
3084
- () => o.value.filter((e) => e.status === "partially-ignored").length
3085
- ), d = F(
3086
- () => o.value.filter((e) => e.status === "already-satisfied").length
3087
- ), r = F(
3088
- () => o.value.filter((e) => e.status === "blocked").length
3089
- ), u = F(
3090
- () => o.value.filter((e) => e.status === "no-applicable-changes").length
3091
- ), i = W(/* @__PURE__ */ new Set());
3092
- function f(e) {
3093
- return i.value.has(e);
3094
- }
3095
- function v(e) {
3096
- const S = new Set(i.value);
3097
- S.has(e) ? S.delete(e) : S.add(e), i.value = S;
3098
- }
3099
- function C(e) {
3100
- var h, N, z;
3101
- const S = [], p = ke(e.contains, /* @__PURE__ */ new Set([e._id]), l.recipeById);
3102
- for (let b = 0; b < p.length; b++) {
3103
- const B = p[b], R = B.recipeIds.slice(1).length > 0, A = R ? ((h = l.recipeById[B.recipeIds.at(-1) ?? ""]) == null ? void 0 : h.name) ?? "" : "";
3104
- let P;
3105
- if (B.isGroup) {
3106
- const K = l.skuGroupById[B.id];
3107
- if (!K) continue;
3108
- const H = `x${Z(B.amount)}`;
3109
- P = R ? `(${A}) ${K.name} (${H})` : `${K.name} (${H})`;
3110
- } else {
3111
- const K = l.skuById[B.id];
3112
- if (!K) continue;
3113
- const H = ((N = B.measurement) == null ? void 0 : N.abbrev) ?? ((z = K.unit) == null ? void 0 : z.abbrev) ?? "", ee = `${Z(B.amount)}${H}`;
3114
- P = R ? `(${A}) ${K.name} (${ee})` : `${K.name} (${ee})`;
3115
- }
3116
- b > 0 && S.push({ text: ", " }), S.push({ text: P });
3117
- }
3118
- return S;
3119
- }
3120
- function w(e) {
3121
- var b, B, R, A;
3122
- if (e.isGroup) {
3123
- const P = l.skuGroupById[e.id];
3124
- if (!P) return "";
3125
- const K = e.recipeIds.slice(1).length > 0, H = K ? ((b = l.recipeById[e.recipeIds.at(-1) ?? ""]) == null ? void 0 : b.name) ?? "" : "", ee = `x${Z(e.amount)}`;
3126
- return K ? `(${H}) ${P.name} (${ee})` : `${P.name} (${ee})`;
3127
- }
3128
- const S = l.skuById[e.id];
3129
- if (!S) return "";
3130
- const p = e.recipeIds.slice(1).length > 0, h = p ? ((B = l.recipeById[e.recipeIds.at(-1) ?? ""]) == null ? void 0 : B.name) ?? "" : "", N = ((R = e.measurement) == null ? void 0 : R.abbrev) ?? ((A = S.unit) == null ? void 0 : A.abbrev) ?? "", z = `${Z(e.amount)}${N}`;
3131
- return p ? `(${h}) ${S.name} (${z})` : `${S.name} (${z})`;
3132
- }
3133
- function c(e) {
3134
- if (!e.projected) return [];
3135
- const S = ke(e.original.contains, /* @__PURE__ */ new Set([e.recipeId]), l.recipeById), p = ke(e.projected.contains, /* @__PURE__ */ new Set([e.recipeId]), l.recipeById), h = /* @__PURE__ */ new Map();
3136
- for (const R of S) h.set(`${R.type}:${R.id}`, R);
3137
- const N = /* @__PURE__ */ new Map();
3138
- for (const R of p) N.set(`${R.type}:${R.id}`, R);
3139
- const z = [];
3140
- let b = !0;
3141
- function B(R, A) {
3142
- A && (b || z.push({ kind: "unchanged", text: ", " }), z.push({ kind: R, text: A }), b = !1);
3143
- }
3144
- for (const [R, A] of h) {
3145
- const P = N.get(R);
3146
- if (!P)
3147
- B("removed", w(A));
3148
- else {
3149
- const K = w(A), H = w(P);
3150
- K === H ? B("unchanged", K) : (B("removed", K), B("added", H));
3151
- }
3152
- }
3153
- for (const [R, A] of N)
3154
- h.has(R) || B("added", w(A));
3155
- return z;
3156
- }
3157
- const k = F(() => {
3158
- const e = /* @__PURE__ */ new Map();
3159
- for (const S of o.value)
3160
- e.set(S.recipeId, c(S));
3161
- return e;
3162
- });
3163
- function I(e) {
3164
- switch (e) {
3165
- case "will-update":
3166
- return s("inventory.recipe.bulkEditor.status.willUpdate");
3167
- case "already-satisfied":
3168
- return s("inventory.recipe.bulkEditor.status.alreadySatisfied");
3169
- case "partially-ignored":
3170
- return s("inventory.recipe.bulkEditor.status.partiallyIgnored");
3171
- case "blocked":
3172
- return s("inventory.recipe.bulkEditor.status.blocked");
3173
- case "no-applicable-changes":
3174
- return s("inventory.recipe.bulkEditor.status.noApplicableChanges");
3175
- default:
3176
- return "";
3177
- }
3178
- }
3179
- function _(e) {
3180
- switch (e) {
3181
- case "will-update":
3182
- return "success";
3183
- case "already-satisfied":
3184
- return "info";
3185
- case "partially-ignored":
3186
- return "warning";
3187
- case "blocked":
3188
- return "critical";
3189
- case "no-applicable-changes":
3190
- return "neutral";
3191
- default:
3192
- return "neutral";
3193
- }
3194
- }
3195
- return (e, S) => {
3196
- const p = G("FmChip"), h = G("FmButton"), N = G("FmBanner"), z = G("FmIcon");
3197
- return g(), V("div", Ti, [
3198
- y("div", Ui, [
3199
- y("p", Pi, U(n(s)("inventory.recipe.bulkEditor.summary.title")), 1),
3200
- y("div", Mi, [
3201
- y("div", Di, [
3202
- x(p, {
3203
- size: "sm",
3204
- label: String(a.value),
3205
- variant: "success"
3206
- }, null, 8, ["label"]),
3207
- y("span", Gi, U(n(s)("inventory.recipe.bulkEditor.summary.countWillUpdate")), 1)
3208
- ]),
3209
- $.value > 0 ? (g(), V("div", Ni, [
3210
- x(p, {
3211
- size: "sm",
3212
- label: String($.value),
3213
- variant: "warning"
3214
- }, null, 8, ["label"]),
3215
- y("span", zi, U(n(s)("inventory.recipe.bulkEditor.summary.countPartiallyIgnored")), 1)
3216
- ])) : T("", !0),
3217
- d.value > 0 ? (g(), V("div", Oi, [
3218
- x(p, {
3219
- size: "sm",
3220
- label: String(d.value),
3221
- variant: "info"
3222
- }, null, 8, ["label"]),
3223
- y("span", ji, U(n(s)("inventory.recipe.bulkEditor.summary.countAlreadySatisfied")), 1)
3224
- ])) : T("", !0),
3225
- r.value > 0 ? (g(), V("div", Li, [
3226
- x(p, {
3227
- size: "sm",
3228
- label: String(r.value),
3229
- variant: "critical"
3230
- }, null, 8, ["label"]),
3231
- y("span", Ki, U(n(s)("inventory.recipe.bulkEditor.summary.countBlocked")), 1)
3232
- ])) : T("", !0),
3233
- u.value > 0 ? (g(), V("div", qi, [
3234
- x(p, {
3235
- size: "sm",
3236
- label: String(u.value),
3237
- variant: "neutral"
3238
- }, null, 8, ["label"]),
3239
- y("span", Wi, U(n(s)("inventory.recipe.bulkEditor.summary.countNoChanges")), 1)
3240
- ])) : T("", !0)
3241
- ]),
3242
- y("div", Yi, [
3243
- x(h, {
3244
- label: n(s)("common.export"),
3245
- variant: "secondary",
3246
- size: "md",
3247
- onClick: n(Ai)
3248
- }, null, 8, ["label", "onClick"])
3249
- ]),
3250
- a.value === 0 && $.value === 0 ? (g(), Y(N, {
3251
- key: 0,
3252
- class: "mt-12",
3253
- type: "warning",
3254
- message: n(s)("inventory.recipe.bulkEditor.summary.nothingToSubmit")
3255
- }, null, 8, ["message"])) : T("", !0)
3256
- ]),
3257
- (g(!0), V(Q, null, me(o.value, (b) => (g(), V("div", {
3258
- key: b.recipeId,
3259
- class: "rounded-lg border border-fm-color-border-default overflow-hidden"
3260
- }, [
3261
- y("button", {
3262
- type: "button",
3263
- class: De(["w-full flex items-center gap-8 px-12 py-10 bg-fm-color-surface-secondary border-b border-fm-color-border-default text-left cursor-pointer", { "border-b-0": !f(b.recipeId) }]),
3264
- onClick: (B) => v(b.recipeId)
3265
- }, [
3266
- x(z, {
3267
- name: f(b.recipeId) ? "expand_less" : "expand_more",
3268
- size: "sm",
3269
- class: "text-fm-color-typo-secondary flex-shrink-0"
3270
- }, null, 8, ["name"]),
3271
- y("span", Hi, U(b.recipeName), 1),
3272
- b.original.version === "v2" ? (g(), Y(p, {
3273
- key: 0,
3274
- size: "sm",
3275
- label: "V2",
3276
- variant: "info"
3277
- })) : T("", !0),
3278
- x(p, {
3279
- size: "sm",
3280
- label: I(b.status),
3281
- variant: _(b.status)
3282
- }, null, 8, ["label", "variant"])
3283
- ], 10, Ji),
3284
- f(b.recipeId) ? (g(), V(Q, { key: 0 }, [
3285
- n(t).applyErrors.has(b.recipeId) ? (g(), V("div", Qi, [
3286
- x(N, {
3287
- type: "error",
3288
- message: n(t).applyErrors.get(b.recipeId)
3289
- }, null, 8, ["message"])
3290
- ])) : T("", !0),
3291
- y("div", Xi, [
3292
- b.projected ? (k.value.get(b.recipeId) ?? []).length > 0 ? (g(!0), V(Q, { key: 1 }, me(k.value.get(b.recipeId), (B, R) => (g(), V("span", {
3293
- key: R,
3294
- class: De(["fm-typo-en-body-sm-400", {
3295
- "text-fm-color-typo-secondary": B.kind === "unchanged",
3296
- "line-through text-fm-color-error font-medium": B.kind === "removed",
3297
- "text-fm-color-success font-medium": B.kind === "added"
3298
- }])
3299
- }, U(B.text), 3))), 128)) : (g(), V("span", Zi, U(n(s)("inventory.recipe.bulkEditor.summary.emptyBindings")), 1)) : (g(!0), V(Q, { key: 0 }, me(C(b.original), (B, R) => (g(), V("span", {
3300
- key: R,
3301
- class: "fm-typo-en-body-sm-400 text-fm-color-typo-placeholder"
3302
- }, U(B.text), 1))), 128))
3303
- ]),
3304
- y("div", el, [
3305
- b.counts.applied > 0 ? (g(), V("span", tl, U(n(s)("inventory.recipe.bulkEditor.summary.footerApplied", { count: b.counts.applied })), 1)) : T("", !0),
3306
- b.counts.satisfied > 0 ? (g(), V("span", nl, U(n(s)("inventory.recipe.bulkEditor.summary.footerSatisfied", { count: b.counts.satisfied })), 1)) : T("", !0),
3307
- b.counts.ignored > 0 ? (g(), V("span", ol, U(n(s)("inventory.recipe.bulkEditor.summary.footerIgnored", { count: b.counts.ignored })), 1)) : T("", !0),
3308
- b.counts.blocked > 0 ? (g(), V("span", il, U(n(s)("inventory.recipe.bulkEditor.summary.footerBlocked", { count: b.counts.blocked })), 1)) : T("", !0),
3309
- b.counts.applied === 0 && b.counts.satisfied === 0 && b.counts.ignored === 0 && b.counts.blocked === 0 ? (g(), V("span", ll, U(n(s)("inventory.recipe.bulkEditor.summary.noChangesDetail")), 1)) : T("", !0)
3310
- ])
3311
- ], 64)) : T("", !0)
3312
- ]))), 128))
3313
- ]);
3314
- };
3315
- }
3316
- }), rl = { class: "flex items-center gap-12" }, sl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, dl = {
3317
- key: 0,
3318
- class: "h-[calc(98vh-120px)] overflow-hidden flex flex-col"
3319
- }, ul = {
3320
- key: 1,
3321
- class: "h-[calc(98vh-120px)] overflow-hidden flex flex-col"
3322
- }, cl = {
3323
- key: 2,
3324
- class: "h-[calc(98vh-120px)] overflow-y-auto px-24 py-20"
3325
- }, pl = {
3326
- key: 0,
3327
- class: "flex items-center gap-8 px-4"
3328
- }, ml = {
3329
- key: 1,
3330
- class: "flex items-center gap-8 px-4"
3331
- }, fl = {
3332
- key: 2,
3333
- class: "flex items-center gap-8 px-4"
3334
- }, vl = /* @__PURE__ */ le({
3335
- __name: "RecipeBulkEditorDialog",
3336
- props: {
3337
- show: { type: Boolean }
3338
- },
3339
- emits: ["update:show"],
3340
- setup(m, { emit: s }) {
3341
- const l = m, { t } = ie(), o = _e(), a = Ge(l, "show"), $ = je(), d = F(() => o.currentStep === 1), r = F(() => o.currentStep === 2), u = F(() => o.currentStep === 3);
3342
- function i() {
3343
- o.currentStep = 2;
3344
- }
3345
- function f() {
3346
- o.currentStep = 1;
3347
- }
3348
- function v() {
3349
- o.goToStep3();
3350
- }
3351
- function C() {
3352
- o.backToStep2();
3353
- }
3354
- function w() {
3355
- $.open({
3356
- title: t("inventory.recipe.bulkEditor.step3.confirmTitle"),
3357
- message: t("inventory.recipe.bulkEditor.step3.confirmMessage"),
3358
- primaryActions: {
3359
- text: t("inventory.recipe.bulkEditor.step3.confirmButton"),
3360
- variant: "primary",
3361
- close: !0
3362
- },
3363
- secondaryActions: {
3364
- text: t("common.cancel"),
3365
- close: !0
3366
- }
3367
- }).onPrimary(async () => {
3368
- await o.confirmAndApply();
3369
- });
3370
- }
3371
- function c() {
3372
- a.value = !1, o.reset();
3373
- }
3374
- return (k, I) => {
3375
- const _ = G("FmChip"), e = G("FmButton"), S = G("FmDialog");
3376
- return g(), Y(S, {
3377
- modelValue: n(a),
3378
- "onUpdate:modelValue": [
3379
- I[0] || (I[0] = (p) => Me(a) ? a.value = p : null),
3380
- I[1] || (I[1] = (p) => {
3381
- p || n(o).reset();
3382
- })
3383
- ],
3384
- overlay: !0,
3385
- "close-button": "",
3386
- "max-width": "98vw",
3387
- "max-height": "98vh"
3388
- }, {
3389
- "dialog-header": J(() => [
3390
- y("div", rl, [
3391
- y("span", sl, U(n(t)("inventory.recipe.bulkEditor.title")), 1),
3392
- x(_, {
3393
- size: "sm",
3394
- label: n(t)("inventory.recipe.bulkEditor.stepIndicator", { step: n(o).currentStep, total: 3 }),
3395
- variant: "neutral"
3396
- }, null, 8, ["label"])
3397
- ])
3398
- ]),
3399
- "dialog-footer": J(() => [
3400
- d.value ? (g(), V("div", pl, [
3401
- x(e, {
3402
- label: n(t)("common.next"),
3403
- disabled: !n(o).canGoToStep2,
3404
- onClick: i
3405
- }, null, 8, ["label", "disabled"]),
3406
- x(e, {
3407
- label: n(t)("common.close"),
3408
- variant: "tertiary",
3409
- onClick: c
3410
- }, null, 8, ["label"])
3411
- ])) : r.value ? (g(), V("div", ml, [
3412
- x(e, {
3413
- label: n(t)("inventory.recipe.bulkEditor.step2.reviewButton"),
3414
- disabled: !n(o).canGoToStep3,
3415
- onClick: v
3416
- }, null, 8, ["label", "disabled"]),
3417
- x(e, {
3418
- label: n(t)("common.back"),
3419
- variant: "secondary",
3420
- onClick: f
3421
- }, null, 8, ["label"]),
3422
- x(e, {
3423
- label: n(t)("common.close"),
3424
- variant: "tertiary",
3425
- onClick: c
3426
- }, null, 8, ["label"])
3427
- ])) : u.value ? (g(), V("div", fl, [
3428
- x(e, {
3429
- label: n(t)("inventory.recipe.bulkEditor.step3.confirmButton"),
3430
- disabled: n(o).isSaving,
3431
- loading: n(o).isSaving,
3432
- onClick: w
3433
- }, null, 8, ["label", "disabled", "loading"]),
3434
- x(e, {
3435
- label: n(t)("common.back"),
3436
- variant: "secondary",
3437
- disabled: n(o).isSaving,
3438
- onClick: C
3439
- }, null, 8, ["label", "disabled"]),
3440
- x(e, {
3441
- label: n(t)("common.close"),
3442
- variant: "tertiary",
3443
- disabled: n(o).isSaving,
3444
- onClick: c
3445
- }, null, 8, ["label", "disabled"])
3446
- ])) : T("", !0)
3447
- ]),
3448
- default: J(() => [
3449
- d.value ? (g(), V("div", dl, [
3450
- x(Oo)
3451
- ])) : r.value ? (g(), V("div", ul, [
3452
- x(Ri)
3453
- ])) : u.value ? (g(), V("div", cl, [
3454
- x(al)
3455
- ])) : T("", !0)
3456
- ]),
3457
- _: 1
3458
- }, 8, ["modelValue"]);
3459
- };
3460
- }
3461
- });
3462
- function yl(m) {
3463
- return !m || Object.keys(m).length === 0 ? "" : Object.entries(m).map(([s, l]) => `${s}: ${l}`).join(", ");
3464
- }
3465
- function bl() {
3466
- const m = ne(), s = m.recipes, l = m.recipeById, t = m.skuById, o = m.skuGroupById, a = s.flatMap((r, u) => {
3467
- var f;
3468
- const i = yl(r.customAttributes);
3469
- if ((f = r.contains) != null && f.length) {
3470
- const v = r.contains.filter((c) => c.type === "RECIPE"), C = r.contains.filter((c) => c.type === "SKU"), w = r.contains.filter((c) => c.type === "SKU_GROUP");
3471
- return [
3472
- ...u === 0 ? [] : [["", "", "", "", "", "", ""]],
3473
- ...v.map(
3474
- (c, k) => {
3475
- var I;
3476
- return [
3477
- k === 0 ? r.name : "",
3478
- "RECIPE",
3479
- "",
3480
- (I = l[c.id]) == null ? void 0 : I.name,
3481
- Z(c.amount),
3482
- "UNIT",
3483
- k === 0 ? i : ""
3484
- ];
3485
- }
3486
- ),
3487
- ...C.map(
3488
- (c, k) => {
3489
- var I, _, e, S;
3490
- return [
3491
- !v.length && k === 0 ? r.name : "",
3492
- "INGREDIENT",
3493
- (I = t[c.id]) == null ? void 0 : I.code,
3494
- (_ = t[c.id]) == null ? void 0 : _.name,
3495
- Z(c.amount),
3496
- c.measurement ? c.measurement.abbrev : (S = (e = t[c.id]) == null ? void 0 : e.unit) == null ? void 0 : S.abbrev,
3497
- !v.length && k === 0 ? i : ""
3498
- ];
3499
- }
3500
- ),
3501
- ...w.map(
3502
- (c, k) => {
3503
- var I, _;
3504
- return [
3505
- v.length === 0 && C.length === 0 && k === 0 ? r.name : "",
3506
- "SKU_GROUP",
3507
- ((I = o[c.id]) == null ? void 0 : I.ref) || "",
3508
- (_ = o[c.id]) == null ? void 0 : _.name,
3509
- Z(c.amount),
3510
- "UNIT",
3511
- v.length === 0 && C.length === 0 && k === 0 ? i : ""
3512
- ];
3513
- }
3514
- )
3515
- ];
3516
- }
3517
- return [
3518
- ...u === 0 ? [] : [["", "", "", "", "", "", ""]],
3519
- [r.name, "No bindings", "", "", "", "", i]
3520
- ];
3521
- }), d = rt(a, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
3522
- st(d, `RECIPE_${dt(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
3523
- }
3524
- const gl = { class: "flex flex-col py-8" }, _l = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, kl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Jl = /* @__PURE__ */ le({
3525
- __name: "RecipeView",
3526
- setup(m) {
3527
- const s = ne(), l = F(() => s.recipes), t = tt(), { createRecipe: o, updateRecipe: a } = ze(), { recipeDialogProps: $, recipeViewLoading: d } = Et(ze()), { columnDefs: r, formatRowData: u } = Ht(), i = F(() => u(l.value)), f = _e(), v = We();
3528
- W(!1);
3529
- function C(p) {
3530
- if (p === "add")
3531
- return o();
3532
- if (p === "export")
3533
- return bl();
3534
- p === "bulk-edit" && f.openDialog();
3535
- }
3536
- const w = W(""), c = F(() => d.value), { breakpoints: k } = xt(), I = F(() => k.value.xs || k.value.sm), _ = F(() => I.value ? 10 : 20), e = Ct(), { t: S } = ie();
3537
- return (p, h) => {
3538
- const N = G("FmTable");
3539
- return g(), Y(Bt, {
3540
- title: n(S)("inventory.recipe.title"),
3541
- actions: [
3542
- {
3543
- label: n(S)("inventory.recipe.create.title"),
3544
- value: "add",
3545
- isPrimary: !0,
3546
- prependIcon: "add"
3547
- },
3548
- ...n(v).enableBulkEditRecipes ? [{ label: n(S)("inventory.recipe.bulkEditor.title"), value: "bulk-edit", isPrimary: !1 }] : [],
3549
- { label: n(S)("common.export"), value: "export", isPrimary: !1 }
3550
- ],
3551
- "onClick:action": C
3552
- }, {
3553
- default: J(() => [
3554
- y("div", {
3555
- class: De([
3556
- "relative flex flex-col gap-8 max-h-full",
3557
- {
3558
- "p-0": I.value,
3559
- "px-24 ": !I.value
3560
- }
3561
- ])
3562
- }, [
3563
- x(Kt, {
3564
- searchable: "",
3565
- search: w.value,
3566
- "onUpdate:search": h[0] || (h[0] = (z) => w.value = z)
3567
- }, null, 8, ["search"]),
3568
- (g(), Y(N, {
3569
- style: vt(n(e).tableHeight),
3570
- "column-defs": n(r),
3571
- "row-data": i.value,
3572
- "search-value": w.value,
3573
- loading: !n(t)._currentLocation || c.value,
3574
- onRowClick: h[1] || (h[1] = (z) => n(a)(z.original.original)),
3575
- key: l.value.length,
3576
- "page-size": _.value
3577
- }, {
3578
- "list-row": J((z) => [
3579
- x(Lt, {
3580
- row: z,
3581
- onRowClick: (b) => n(a)(b.original)
3582
- }, {
3583
- default: J((b) => {
3584
- var B, R, A, P, K, H, ee, O, M, j;
3585
- return [
3586
- y("div", gl, [
3587
- y("div", _l, [
3588
- x(n(Qe), {
3589
- render: (A = (R = (B = b.recipe) == null ? void 0 : B.column) == null ? void 0 : R.columnDef) == null ? void 0 : A.cell,
3590
- props: (K = (P = b.recipe) == null ? void 0 : P.getContext) == null ? void 0 : K.call(P)
3591
- }, null, 8, ["render", "props"])
3592
- ]),
3593
- y("div", kl, [
3594
- x(n(Qe), {
3595
- render: (O = (ee = (H = b.ingredients) == null ? void 0 : H.column) == null ? void 0 : ee.columnDef) == null ? void 0 : O.cell,
3596
- props: (j = (M = b.ingredients) == null ? void 0 : M.getContext) == null ? void 0 : j.call(M)
3597
- }, null, 8, ["render", "props"])
3598
- ])
3599
- ])
3600
- ];
3601
- }),
3602
- _: 2
3603
- }, 1032, ["row", "onRowClick"])
3604
- ]),
3605
- _: 1
3606
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
3607
- ], 2),
3608
- (g(), Y(yt, { to: "body" }, [
3609
- x(vo, bt(gt(n($))), null, 16),
3610
- n(v).enableBulkEditRecipes ? (g(), Y(vl, {
3611
- key: 0,
3612
- show: n(f).show,
3613
- "onUpdate:show": h[2] || (h[2] = (z) => n(f).show = z)
3614
- }, null, 8, ["show"])) : T("", !0)
3615
- ]))
3616
- ]),
3617
- _: 1
3618
- }, 8, ["title", "actions"]);
3619
- };
3620
- }
3621
- });
3622
- export {
3623
- Jl as default
3624
- };