@feedmepos/mf-inventory-portal 1.7.13-dev.4 → 1.7.13-dev.6

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 (270) hide show
  1. package/dist/{App-Cfp4CqzQ.js → App-JqoqVVdP.js} +354 -348
  2. package/dist/{ApprovalView-DO91AQ5f.js → ApprovalView-JiWbXkVU.js} +9 -9
  3. package/dist/{BindingsDialog-DUj0z6N7.js → BindingsDialog-BK4xofWu.js} +2 -2
  4. package/dist/{BindingsPicker-CD2J6-_Z.js → BindingsPicker-CLMsAseG.js} +2 -2
  5. package/dist/{BindingsTable-B2FEKZXU.js → BindingsTable-DKrBQTxN.js} +4 -4
  6. package/dist/{BulkReceiveRequestView-ejHyukEp.js → BulkReceiveRequestView-bttHw2ub.js} +19 -19
  7. package/dist/{ClosingDraftView-tIvrsfYH.js → ClosingDraftView-Bhdwo-n8.js} +19 -19
  8. package/dist/ClosingHistoryView-DrQPWnr6.js +761 -0
  9. package/dist/{ClosingTemplateView-C-hL9uPv.js → ClosingTemplateView-UkwXCrz_.js} +16 -16
  10. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BffF8S_q.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DNtMdFVF.js} +1 -1
  11. package/dist/{DefaultView-BLbtx0Ho.js → DefaultView-sGrYeUGh.js} +2 -2
  12. package/dist/{DeliveryOrderPrintPreview-BLQHL7aB.js → DeliveryOrderPrintPreview-CVnqC9Jy.js} +10 -10
  13. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-BnTAuutB.js → EmailDialog.vue_vue_type_script_setup_true_lang-CYtHQ2Ru.js} +2250 -2250
  14. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Mxhn0b6c.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-DXTdvT0C.js} +1 -1
  15. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-hrk0cTBX.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DtfiRgsD.js} +2 -2
  16. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-yBIbCJYy.js +243 -0
  17. package/dist/{FmMultiselectDialog-Bpi5rI0h.js → FmMultiselectDialog-A9VIMLGn.js} +1 -1
  18. package/dist/{FmMultiselectDialog-Bi6XlAAU.js → FmMultiselectDialog-DL00XnUc.js} +2 -2
  19. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-e55tnl4u.js → FmUnitInput.vue_vue_type_script_setup_true_lang-RJKOB-cm.js} +66 -63
  20. package/dist/{ImportView-xPTzBekx.js → ImportView-DPrLnJO8.js} +6 -6
  21. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-tvmS42s_.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-IAQyFPmi.js} +1 -1
  22. package/dist/{IngredientGroupView-RFcqjF8T.js → IngredientGroupView-DyhC6lJ8.js} +5 -5
  23. package/dist/{IngredientsView-CvWOgquN.js → IngredientsView-P4AqPikD.js} +15 -15
  24. package/dist/{IntegrationExplorerView-CYNhsJSS.js → IntegrationExplorerView-CujhjHHV.js} +4 -4
  25. package/dist/{IntegrationView-ZtLokbu3.js → IntegrationView-CFqsZyzI.js} +3074 -2999
  26. package/dist/{InventoryBindingForm-DwiAIf5v.js → InventoryBindingForm-B0NJ8H51.js} +1 -1
  27. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-njDaQe10.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-bbIpFo_4.js} +5 -5
  28. package/dist/{InventoryBindingSummary-zim_Bp5_.js → InventoryBindingSummary-CBgO_tCz.js} +1 -1
  29. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CfTgt5xW.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DuuXzyKH.js} +1 -1
  30. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-LLtd1VvM.js → PremiumBadge.vue_vue_type_script_setup_true_lang-C418f34P.js} +1 -1
  31. package/dist/ProductionRunDetailView-tSByC3nQ.js +5165 -0
  32. package/dist/ProductionRunPreparePrintView-zPAATL-n.js +31 -0
  33. package/dist/ProductionRunTabs.vue_vue_type_script_setup_true_lang-DgtZJgrs.js +3506 -0
  34. package/dist/ProductionRunView-BsP02jgC.js +815 -0
  35. package/dist/{PublishView-DFXOi7Hx.js → PublishView-Cf0Tn7xt.js} +3 -3
  36. package/dist/{PurchaseOrderPrintPreview-CG6kBQ26.js → PurchaseOrderPrintPreview-BTlSyQqZ.js} +6 -6
  37. package/dist/{ReceiveRequestView-DKMVMo7M.js → ReceiveRequestView-9LFOl2hJ.js} +14 -14
  38. package/dist/{RecipeView-cLLKlLmE.js → RecipeView-C4KxMCpQ.js} +17 -17
  39. package/dist/{SettingsView-Cmf2ZOUL.js → SettingsView-ShrefnTM.js} +4 -4
  40. package/dist/{StockView-DTai8l8U.js → StockView-BVd6f7Fr.js} +21 -21
  41. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BlKm7GLw.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B-rB7p9o.js} +1 -1
  42. package/dist/{SupplierView-CRAHOOLm.js → SupplierView-DZSY6_eU.js} +12 -12
  43. package/dist/{SurchargeView-3XymEvcr.js → SurchargeView-UUYoT8MK.js} +6 -6
  44. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-DcXfQr_8.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BLMxzi1C.js} +2 -2
  45. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-qhJVHahS.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-z3qIVKP7.js} +1 -1
  46. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CibsrZXw.js → TransferDetails.vue_vue_type_script_setup_true_lang-DEO8CP-X.js} +20 -20
  47. package/dist/{TransferTemplateView-ByhvK4Ua.js → TransferTemplateView-C21o2V_1.js} +20 -20
  48. package/dist/{UnitCostHistoryView-DHHWNJYA.js → UnitCostHistoryView-DPEGVLBP.js} +4 -4
  49. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-bQu2KOI7.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-BuGmmHBk.js} +4 -4
  50. package/dist/{UnitView-BZTS-Ahu.js → UnitView-Bx03E4uc.js} +7 -7
  51. package/dist/{WarehouseView-DVak1RPs.js → WarehouseView-BehHQ9Ao.js} +6 -6
  52. package/dist/{WastageTemplateView-CUDL3HUD.js → WastageTemplateView-gmr7doXL.js} +14 -14
  53. package/dist/api/netsuite.d.ts +13 -0
  54. package/dist/api/production-run-error.d.ts +36 -0
  55. package/dist/api/production-run-error.spec.d.ts +1 -0
  56. package/dist/api/production-run.d.ts +58 -0
  57. package/dist/api/stock.d.ts +0 -6
  58. package/dist/{app-BUQUpe4c.js → app-BT7hD4az.js} +16491 -12629
  59. package/dist/app.d.ts +2958 -14
  60. package/dist/app.js +1 -1
  61. package/dist/{closing-template-DzxDiEQB.js → closing-template-BNfr1RIX.js} +1 -1
  62. package/dist/components/FmInventoryBanner.vue.d.ts +39 -0
  63. package/dist/components/FmUnitInput.spec.d.ts +1 -0
  64. package/dist/components/FmUnitInputProps.d.ts +2 -0
  65. package/dist/composable/useModalA11y.d.ts +9 -0
  66. package/dist/composable/useModalA11y.spec.d.ts +1 -0
  67. package/dist/{date2-6jkfRNS_.js → date2-CAh7rsAp.js} +1 -1
  68. package/dist/{dayjs.min-ByRnXzrl.js → dayjs.min-BJk-edO7.js} +7 -7
  69. package/dist/{decimal-CqWBdj8E.js → decimal-DYlKNkVX.js} +2 -2
  70. package/dist/{defineDeepModel-CaT-4fiq.js → defineDeepModel-BPHl7mTD.js} +1 -1
  71. package/dist/{duplicate-template-Cyvx-WK7.js → duplicate-template-BWUUIdzG.js} +1 -1
  72. package/dist/{feature-FjXz4WXw.js → feature-CSvVyBN2.js} +2 -2
  73. package/dist/{format-time-from-id-cSri3OoO.js → format-time-from-id-Dh3lxXpc.js} +1 -1
  74. package/dist/{format-unit-display-DPbcT7Ff.js → format-unit-display-B1ft2wxm.js} +12 -12
  75. package/dist/{import-export.helper-_yqcePYs.js → import-export.helper-txDvkMf0.js} +6 -6
  76. package/dist/{index-CyJVMHQW.js → index-AmTodx3_.js} +1 -1
  77. package/dist/{index-CGvNoBid.js → index-B4wQijn6.js} +1 -1
  78. package/dist/{index-nSL5yxNn.js → index-TIX5DyQk.js} +3 -3
  79. package/dist/inventory-core-dart.default-BpMxAF-0.js +31060 -0
  80. package/dist/{lz-string-iyER1Klb.js → lz-string-CFDYH-K6.js} +1 -1
  81. package/dist/{netsuite-BD8LVxaA.js → netsuite-CdW9v92G.js} +477 -462
  82. package/dist/{number-C7CJ9ZfE.js → number-DRRlTYv7.js} +6 -6
  83. package/dist/{predefined-templates-o-_pKVSM.js → predefined-templates-C68U85pc.js} +1 -1
  84. package/dist/production-run-display-DmyfdjHR.js +239 -0
  85. package/dist/production-run-prepare-sheet-BvxMd19E.js +189 -0
  86. package/dist/{purchase-order-template-BHS8T1VA.js → purchase-order-template-BvED3CpO.js} +1 -1
  87. package/dist/{recalculationUtils-BCByr_CU.js → recalculationUtils-9rFepwwr.js} +1 -1
  88. package/dist/router/name.d.ts +2 -0
  89. package/dist/{rules-wZo-8FZ0.js → rules-C8RmopTe.js} +2 -2
  90. package/dist/{stock-DwqEvWM5.js → stock-BKkluaaM.js} +26 -36
  91. package/dist/{stock-CnAjxV7P.js → stock-CiCsT5JK.js} +3 -3
  92. package/dist/stores/integration/codemax.d.ts +1 -1
  93. package/dist/stores/integration/netsuite.d.ts +54 -0
  94. package/dist/style.css +1 -1
  95. package/dist/{supplier-DkqNwQmi.js → supplier--zZMQHPc.js} +2 -2
  96. package/dist/{surcharge-Csj1WYbH.js → surcharge-BLF3XV0G.js} +1 -1
  97. package/dist/tsconfig.app.tsbuildinfo +1 -1
  98. package/dist/{uom-rules-BI1CdWeS.js → uom-rules-CjCCXiGL.js} +1 -1
  99. package/dist/{use-ingredient-select-dialog-5AqoZJDA.js → use-ingredient-select-dialog-DnUiY-Ic.js} +2 -2
  100. package/dist/{use-inventory-binding-dialog-ChiyhiuP.js → use-inventory-binding-dialog-BAU-P8kV.js} +2 -2
  101. package/dist/{use-template-enabled-locations-BqXxegct.js → use-template-enabled-locations-DZMzYCi-.js} +2 -2
  102. package/dist/{use-transfer-locations-Ckj_diGt.js → use-transfer-locations-DomGLsT2.js} +2 -2
  103. package/dist/{useHrmPermission-USG_KRoq.js → useHrmPermission-CrhsV_5z.js} +1 -1
  104. package/dist/{useNavigationMenu-BhYf87KI.js → useNavigationMenu-1h-G_-el.js} +2 -2
  105. package/dist/{useSseClient-BqoE-ir6.js → useSseClient-o_3wiqhX.js} +1 -1
  106. package/dist/views/changelog/composables/use-inventory-record-commits.d.ts +1 -1
  107. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -1
  108. package/dist/views/integration/components/ApplyProductDialogCodemax.vue.d.ts +2 -2
  109. package/dist/views/integration/components/CodemaxDialog.vue.d.ts +2 -2
  110. package/dist/views/integration/components/netsuite/business/vendor-publish.d.ts +7 -0
  111. package/dist/views/integration/components/netsuite/business/vendor-publish.spec.d.ts +1 -0
  112. package/dist/views/production-run/ProductionRunDetailView.spec.d.ts +1 -0
  113. package/dist/views/production-run/ProductionRunDetailView.vue.d.ts +15 -0
  114. package/dist/views/production-run/ProductionRunPreparePrintView.spec.d.ts +1 -0
  115. package/dist/views/production-run/ProductionRunPreparePrintView.vue.d.ts +2 -0
  116. package/dist/views/production-run/ProductionRunView.spec.d.ts +1 -0
  117. package/dist/views/production-run/ProductionRunView.vue.d.ts +2 -0
  118. package/dist/views/production-run/components/CancelRunDialog.spec.d.ts +1 -0
  119. package/dist/views/production-run/components/CancelRunDialog.vue.d.ts +918 -0
  120. package/dist/views/production-run/components/CancelRunDialogProps.d.ts +9 -0
  121. package/dist/views/production-run/components/CloseRunDialog.spec.d.ts +1 -0
  122. package/dist/views/production-run/components/CloseRunDialog.vue.d.ts +918 -0
  123. package/dist/views/production-run/components/CloseRunDialogProps.d.ts +29 -0
  124. package/dist/views/production-run/components/PrepareRunConfirmationDialog.spec.d.ts +1 -0
  125. package/dist/views/production-run/components/PrepareRunConfirmationDialog.vue.d.ts +29 -0
  126. package/dist/views/production-run/components/PrepareRunDialog.spec.d.ts +1 -0
  127. package/dist/views/production-run/components/PrepareRunDialog.vue.d.ts +18 -0
  128. package/dist/views/production-run/components/PrepareRunDialogProps.d.ts +29 -0
  129. package/dist/views/production-run/components/PrepareSheetDialog.spec.d.ts +1 -0
  130. package/dist/views/production-run/components/PrepareSheetDialog.vue.d.ts +26 -0
  131. package/dist/views/{stock/components/dialog/SnapshotRecalculationDialog.vue.d.ts → production-run/components/ProductionRunActionMenuItem.vue.d.ts} +7 -10
  132. package/dist/views/production-run/components/ProductionRunActionsCell.spec.d.ts +1 -0
  133. package/dist/views/production-run/components/ProductionRunActionsCell.vue.d.ts +20 -0
  134. package/dist/views/production-run/components/ProductionRunActivityTab.spec.d.ts +1 -0
  135. package/dist/views/production-run/components/ProductionRunActivityTab.vue.d.ts +15 -0
  136. package/dist/views/production-run/components/ProductionRunBanner.spec.d.ts +1 -0
  137. package/dist/views/production-run/components/ProductionRunBanner.vue.d.ts +42 -0
  138. package/dist/views/production-run/components/ProductionRunBatchCard.spec.d.ts +1 -0
  139. package/dist/views/production-run/components/ProductionRunBatchCard.vue.d.ts +69 -0
  140. package/dist/views/production-run/components/ProductionRunBatchWastageDetails.spec.d.ts +1 -0
  141. package/dist/views/production-run/components/ProductionRunBatchWastageDetails.vue.d.ts +33 -0
  142. package/dist/views/production-run/components/ProductionRunBindingsDisclosure.spec.d.ts +1 -0
  143. package/dist/views/production-run/components/ProductionRunBindingsDisclosure.vue.d.ts +25 -0
  144. package/dist/views/production-run/components/ProductionRunBindingsList.vue.d.ts +51 -0
  145. package/dist/views/production-run/components/ProductionRunCompactDisclosure.vue.d.ts +25 -0
  146. package/dist/views/production-run/components/ProductionRunContributorBranch.spec.d.ts +1 -0
  147. package/dist/views/production-run/components/ProductionRunContributorBranch.vue.d.ts +25 -0
  148. package/dist/views/production-run/components/ProductionRunCostRail.spec.d.ts +1 -0
  149. package/dist/views/production-run/components/ProductionRunCostRail.vue.d.ts +77 -0
  150. package/dist/views/production-run/components/ProductionRunDialog.spec.d.ts +1 -0
  151. package/dist/views/production-run/components/ProductionRunDialog.vue.d.ts +24 -0
  152. package/dist/views/production-run/components/ProductionRunDialogProps.d.ts +15 -0
  153. package/dist/views/production-run/components/ProductionRunDialogSurface.vue.d.ts +33 -0
  154. package/dist/views/production-run/components/ProductionRunDiscardDialog.spec.d.ts +1 -0
  155. package/dist/views/production-run/components/ProductionRunDiscardDialog.vue.d.ts +21 -0
  156. package/dist/views/production-run/components/ProductionRunDuplicateDialog.spec.d.ts +1 -0
  157. package/dist/views/production-run/components/ProductionRunDuplicateDialog.vue.d.ts +51 -0
  158. package/dist/views/production-run/components/ProductionRunFormDialog.spec.d.ts +1 -0
  159. package/dist/views/production-run/components/ProductionRunFormDialog.vue.d.ts +918 -0
  160. package/dist/views/production-run/components/ProductionRunFormDialogProps.d.ts +22 -0
  161. package/dist/views/production-run/components/ProductionRunHeader.spec.d.ts +1 -0
  162. package/dist/views/production-run/components/ProductionRunHeader.vue.d.ts +65 -0
  163. package/dist/views/production-run/components/ProductionRunHelpPopover.spec.d.ts +1 -0
  164. package/dist/views/production-run/components/ProductionRunHelpPopover.vue.d.ts +52 -0
  165. package/dist/views/production-run/components/ProductionRunIngredientTree.spec.d.ts +1 -0
  166. package/dist/views/production-run/components/ProductionRunIngredientTree.vue.d.ts +42 -0
  167. package/dist/views/production-run/components/ProductionRunIngredientsTab.spec.d.ts +1 -0
  168. package/dist/views/production-run/components/ProductionRunIngredientsTab.vue.d.ts +63 -0
  169. package/dist/views/production-run/components/ProductionRunInstructionsCard.spec.d.ts +1 -0
  170. package/dist/views/production-run/components/ProductionRunInstructionsCard.vue.d.ts +15 -0
  171. package/dist/views/production-run/components/ProductionRunItemPickerDialog.spec.d.ts +1 -0
  172. package/dist/views/production-run/components/ProductionRunItemPickerDialog.vue.d.ts +30 -0
  173. package/dist/views/production-run/components/ProductionRunItemsCell.spec.d.ts +1 -0
  174. package/dist/views/production-run/components/ProductionRunItemsCell.vue.d.ts +33 -0
  175. package/dist/views/production-run/components/ProductionRunItemsTable.spec.d.ts +1 -0
  176. package/dist/views/production-run/components/ProductionRunItemsTable.vue.d.ts +73 -0
  177. package/dist/views/production-run/components/ProductionRunLoadBannerContract.spec.d.ts +1 -0
  178. package/dist/views/production-run/components/ProductionRunNoBindingsHelp.spec.d.ts +1 -0
  179. package/dist/views/production-run/components/ProductionRunNoBindingsHelp.vue.d.ts +15 -0
  180. package/dist/views/production-run/components/ProductionRunOutputTab.spec.d.ts +1 -0
  181. package/dist/views/production-run/components/ProductionRunOutputTab.vue.d.ts +26 -0
  182. package/dist/views/production-run/components/ProductionRunOverviewTab.spec.d.ts +1 -0
  183. package/dist/views/production-run/components/ProductionRunOverviewTab.vue.d.ts +999 -0
  184. package/dist/views/production-run/components/ProductionRunPlanCard.spec.d.ts +1 -0
  185. package/dist/views/production-run/components/ProductionRunPlanCard.vue.d.ts +50 -0
  186. package/dist/views/production-run/components/ProductionRunPlanner.spec.d.ts +1 -0
  187. package/dist/views/production-run/components/ProductionRunPlanner.vue.d.ts +61 -0
  188. package/dist/views/production-run/components/ProductionRunPrepareSheet.vue.d.ts +16 -0
  189. package/dist/views/production-run/components/ProductionRunProjectionFeedback.spec.d.ts +1 -0
  190. package/dist/views/production-run/components/ProductionRunProjectionFeedback.vue.d.ts +41 -0
  191. package/dist/views/production-run/components/ProductionRunRecordOutputDetails.spec.d.ts +1 -0
  192. package/dist/views/production-run/components/ProductionRunRecordOutputDetails.vue.d.ts +43 -0
  193. package/dist/views/production-run/components/ProductionRunRecordOutputWastageStatus.spec.d.ts +1 -0
  194. package/dist/views/production-run/components/ProductionRunRecordOutputWastageStatus.vue.d.ts +31 -0
  195. package/dist/views/production-run/components/ProductionRunRequestedOverview.spec.d.ts +1 -0
  196. package/dist/views/production-run/components/ProductionRunRequestedOverview.vue.d.ts +48 -0
  197. package/dist/views/production-run/components/ProductionRunResultTable.spec.d.ts +1 -0
  198. package/dist/views/production-run/components/ProductionRunResultTable.vue.d.ts +31 -0
  199. package/dist/views/production-run/components/ProductionRunScrollHint.spec.d.ts +1 -0
  200. package/dist/views/production-run/components/ProductionRunScrollHint.vue.d.ts +31 -0
  201. package/dist/views/production-run/components/ProductionRunSelectionCheckbox.vue.d.ts +31 -0
  202. package/dist/views/production-run/components/ProductionRunSelectionControls.spec.d.ts +1 -0
  203. package/dist/views/production-run/components/ProductionRunSelectionRadio.spec.d.ts +1 -0
  204. package/dist/views/production-run/components/ProductionRunSelectionRadio.vue.d.ts +37 -0
  205. package/dist/views/production-run/components/ProductionRunSideSheet.spec.d.ts +1 -0
  206. package/dist/views/production-run/components/ProductionRunSideSheet.vue.d.ts +77 -0
  207. package/dist/views/production-run/components/ProductionRunSideSheetSurface.vue.d.ts +52 -0
  208. package/dist/views/production-run/components/ProductionRunSortHeader.spec.d.ts +1 -0
  209. package/dist/views/production-run/components/ProductionRunSortHeader.vue.d.ts +25 -0
  210. package/dist/views/production-run/components/ProductionRunStatusBadge.vue.d.ts +15 -0
  211. package/dist/views/production-run/components/ProductionRunTabs.spec.d.ts +1 -0
  212. package/dist/views/production-run/components/ProductionRunTabs.vue.d.ts +47 -0
  213. package/dist/views/production-run/components/ProductionRunTerminalNotice.spec.d.ts +1 -0
  214. package/dist/views/production-run/components/ProductionRunTerminalNotice.vue.d.ts +15 -0
  215. package/dist/views/production-run/components/ProductionRunTextarea.spec.d.ts +1 -0
  216. package/dist/views/production-run/components/ProductionRunTextarea.vue.d.ts +53 -0
  217. package/dist/views/production-run/components/ProductionRunUnitInput.spec.d.ts +1 -0
  218. package/dist/views/production-run/components/ProductionRunUnitInput.vue.d.ts +34 -0
  219. package/dist/views/production-run/components/ProductionRunWastageDisclosure.spec.d.ts +1 -0
  220. package/dist/views/production-run/components/ProductionRunWastageDisclosure.vue.d.ts +23 -0
  221. package/dist/views/production-run/components/RecordOutputDialog.spec.d.ts +1 -0
  222. package/dist/views/production-run/components/RecordOutputDialog.vue.d.ts +20 -0
  223. package/dist/views/production-run/components/RecordOutputDialogProps.d.ts +28 -0
  224. package/dist/views/production-run/components/TargetReachedDialog.spec.d.ts +1 -0
  225. package/dist/views/production-run/components/TargetReachedDialog.vue.d.ts +927 -0
  226. package/dist/views/production-run/components/production-run-deduction-parity.spec.d.ts +1 -0
  227. package/dist/views/production-run/components/production-run-prepare-sheet.d.ts +17 -0
  228. package/dist/views/production-run/components/production-run-typography-contract.spec.d.ts +1 -0
  229. package/dist/views/production-run/components/production-run-unit-snapshot.d.ts +39 -0
  230. package/dist/views/production-run/composables/production-run-display.d.ts +272 -0
  231. package/dist/views/production-run/composables/production-run-display.spec.d.ts +1 -0
  232. package/dist/views/production-run/composables/production-run-list.d.ts +46 -0
  233. package/dist/views/production-run/composables/production-run-list.spec.d.ts +1 -0
  234. package/dist/views/production-run/composables/production-run-request-confirmation.d.ts +20 -0
  235. package/dist/views/production-run/composables/use-production-run-actions.d.ts +37 -0
  236. package/dist/views/production-run/composables/use-production-run-actions.spec.d.ts +1 -0
  237. package/dist/views/production-run/composables/use-production-run-cost.d.ts +672 -0
  238. package/dist/views/production-run/composables/use-production-run-cost.spec.d.ts +1 -0
  239. package/dist/views/production-run/composables/use-production-run-detail.d.ts +1894 -0
  240. package/dist/views/production-run/composables/use-production-run-detail.spec.d.ts +1 -0
  241. package/dist/views/production-run/composables/use-production-run-disclosure.d.ts +15 -0
  242. package/dist/views/production-run/composables/use-production-run-disclosure.spec.d.ts +1 -0
  243. package/dist/views/production-run/composables/use-production-run-duplicate-sources.d.ts +19 -0
  244. package/dist/views/production-run/composables/use-production-run-duplicate-sources.spec.d.ts +1 -0
  245. package/dist/views/production-run/composables/use-production-run-economics.d.ts +92 -0
  246. package/dist/views/production-run/composables/use-production-run-economics.spec.d.ts +1 -0
  247. package/dist/views/production-run/composables/use-production-run-form.d.ts +277 -0
  248. package/dist/views/production-run/composables/use-production-run-form.spec.d.ts +1 -0
  249. package/dist/views/production-run/composables/use-production-run-record-output.d.ts +261 -0
  250. package/dist/views/production-run/composables/use-production-run-record-output.spec.d.ts +1 -0
  251. package/dist/views/production-run/composables/use-production-run-scroll-hint.d.ts +9 -0
  252. package/dist/views/production-run/composables/use-production-run-table.d.ts +19 -0
  253. package/dist/views/production-run/composables/use-production-run-table.spec.d.ts +1 -0
  254. package/dist/views/production-run/helpers/production-run-precision.helper.d.ts +31 -0
  255. package/dist/views/production-run/helpers/production-run-quantity.helper.d.ts +55 -0
  256. package/dist/views/production-run/helpers/production-run-quantity.helper.spec.d.ts +1 -0
  257. package/dist/views/production-run/production-run.fixture.d.ts +70 -0
  258. package/dist/views/production-run/production-run.fixture.spec.d.ts +1 -0
  259. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +3 -3
  260. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +3 -3
  261. package/dist/views/stock/components/dialog/RecalculationDialog.vue.d.ts +2 -17
  262. package/dist/{vue-i18n-DoKioQ81.js → vue-i18n-hE8n67Ig.js} +202 -202
  263. package/dist/{xlsx.util-BXjE2o-3.js → xlsx.util-Jv7EpwFc.js} +2 -2
  264. package/package.json +4 -4
  265. package/dist/ChangeLocationComponent.vue_vue_type_script_setup_true_lang-ashHOuZt.js +0 -130
  266. package/dist/ClosingHistoryView-BYVZ01Ma.js +0 -1112
  267. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-hTQmIyaf.js +0 -120
  268. package/dist/ProductionView-BWn7RBEg.js +0 -1441
  269. package/dist/inventory-core-dart.default-DSYRPQNZ.js +0 -25155
  270. package/dist/views/stock/components/StockRecalculateDialog.vue.d.ts +0 -9
@@ -0,0 +1,3506 @@
1
+ import { defineComponent as Y, computed as S, createElementBlock as k, openBlock as m, createElementVNode as u, normalizeClass as G, toDisplayString as y, resolveComponent as Z, createVNode as E, createCommentVNode as B, renderSlot as se, ref as N, Fragment as ee, renderList as pe, watch as ke, toValue as Ze, onUpdated as Ft, onMounted as Te, onBeforeUnmount as We, nextTick as he, unref as i, createBlock as M, resolveDynamicComponent as Ut, withCtx as H, createTextVNode as ue, mergeProps as Je, onBeforeMount as Pt, watchEffect as Bt, useAttrs as ot, withModifiers as Ae, createSlots as kt } from "vue";
2
+ import { useI18n as de } from "@feedmepos/mf-common";
3
+ import { c as Vt, d as Et, e as Dt } from "./inventory-core-dart.default-BpMxAF-0.js";
4
+ import { _ as Ie } from "./_plugin-vue_export-helper-CHgC5LLL.js";
5
+ import { useDialog as Lt, useSnackbar as qt } from "@feedmepos/ui-library";
6
+ import { d as Tt, u as _t, O as Nt, a as xt } from "./app-BT7hD4az.js";
7
+ import { b as Ot, x as Ee, N as lt, f as fe } from "./production-run-display-DmyfdjHR.js";
8
+ import { u as Mt } from "./stock-CiCsT5JK.js";
9
+ import { F as ye } from "./decimal-DYlKNkVX.js";
10
+ import { g as jt } from "./number-DRRlTYv7.js";
11
+ import { _ as Ht } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-RJKOB-cm.js";
12
+ const zt = Tt((s, e) => {
13
+ const t = _t(), l = () => `${s.inventoryBackendUrl}/${t.currentLocationDBName}/production-run`;
14
+ return {
15
+ async list(o) {
16
+ const r = o ? `?status=${o}` : "";
17
+ return await e.get(`${l()}${r}`);
18
+ },
19
+ async read(o) {
20
+ return await e.get(`${l()}/${o}`);
21
+ },
22
+ async create(o) {
23
+ return await e.post(l(), o);
24
+ },
25
+ async update(o, r) {
26
+ return await e.post(`${l()}/${o}`, r);
27
+ },
28
+ async request(o, r) {
29
+ return await e.post(`${l()}/${o}/request`, { remark: r ?? null });
30
+ },
31
+ // The single goods-issue event: deducts `BOM × committed` for the whole run
32
+ // in one adjustment and freezes the issued cost pool on that movement.
33
+ async prepare(o, r) {
34
+ return await e.post(`${l()}/${o}/prepare`, r);
35
+ },
36
+ // Record one batch of output. Receipt-only — ingredients are never touched
37
+ // again. The key identifies the attempt, but QA does not claim recovery
38
+ // from an ambiguous response; the operator must reload before acting.
39
+ async complete(o, r) {
40
+ return await e.post(`${l()}/${o}/complete`, r);
41
+ },
42
+ async close(o, r) {
43
+ return await e.post(`${l()}/${o}/close`, { remark: r ?? null });
44
+ },
45
+ async cancel(o, r) {
46
+ return await e.post(`${l()}/${o}/cancel`, { reason: r ?? null });
47
+ }
48
+ };
49
+ }), Kt = /^Cannot (update|request|prepare|complete|close|cancel) production run #/;
50
+ function ut(s) {
51
+ const e = Gt(s);
52
+ if (s instanceof Nt)
53
+ return { kind: "timeout", message: e, retrySameKey: !1, mustReload: !0, shortages: [] };
54
+ const t = wt(s);
55
+ if ((t == null ? void 0 : t.statusCode) === 409 && t.code === "SHORTAGE_ACKNOWLEDGEMENT_REQUIRED" && Array.isArray(t.shortages))
56
+ return {
57
+ kind: "shortageAcknowledgementRequired",
58
+ message: e,
59
+ retrySameKey: !1,
60
+ mustReload: !1,
61
+ shortages: t.shortages
62
+ };
63
+ switch (Qt(s)) {
64
+ case 409:
65
+ return { kind: "conflict", message: e, retrySameKey: !1, mustReload: !0, shortages: [] };
66
+ case 404:
67
+ return { kind: "notFound", message: e, retrySameKey: !1, mustReload: !0, shortages: [] };
68
+ case 400:
69
+ return Kt.test(e) ? {
70
+ kind: "illegalAction",
71
+ message: e,
72
+ retrySameKey: !1,
73
+ mustReload: !0,
74
+ shortages: []
75
+ } : { kind: "badRequest", message: e, retrySameKey: !1, mustReload: !1, shortages: [] };
76
+ default:
77
+ return { kind: "unknown", message: e, retrySameKey: !1, mustReload: !0, shortages: [] };
78
+ }
79
+ }
80
+ function Qt(s) {
81
+ const e = wt(s);
82
+ return typeof (e == null ? void 0 : e.statusCode) == "number" ? e.statusCode : null;
83
+ }
84
+ function wt(s) {
85
+ return s == null ? void 0 : s.errorResponse;
86
+ }
87
+ function Gt(s) {
88
+ var l;
89
+ const e = (l = s == null ? void 0 : s.errorResponse) == null ? void 0 : l.message;
90
+ if (Array.isArray(e)) return e.join(", ");
91
+ if (typeof e == "string" && e) return e;
92
+ const t = s == null ? void 0 : s.message;
93
+ return typeof t == "string" && t ? t : "Something went wrong.";
94
+ }
95
+ const Wt = [
96
+ { key: "all", label: "All" },
97
+ { key: "drafts", label: "Drafts" },
98
+ { key: "active", label: "Active" },
99
+ { key: "history", label: "History" }
100
+ ], Jt = {
101
+ drafts: ["DRAFT"],
102
+ active: ["REQUESTING", "PREPARING"],
103
+ history: ["CLOSED", "CANCEL"]
104
+ }, Yt = {
105
+ DRAFT: 0,
106
+ REQUESTING: 1,
107
+ PREPARING: 2,
108
+ CLOSED: 3,
109
+ CANCEL: 4
110
+ };
111
+ function Hs(s) {
112
+ const e = Yt[s];
113
+ if (e == null) throw new Error(`Unsupported production run status: ${s}`);
114
+ return e;
115
+ }
116
+ function Xt(s, e) {
117
+ return e === "all" ? !0 : Jt[e].includes(s.status);
118
+ }
119
+ function zs(s) {
120
+ const e = {};
121
+ for (const { key: t } of Wt)
122
+ e[t] = s.filter((l) => Xt(l, t)).length;
123
+ return e;
124
+ }
125
+ function vt(s) {
126
+ const e = s.activityLogs;
127
+ if (!e.length) return null;
128
+ const t = e[e.length - 1];
129
+ return { action: t.action, at: t.performedAt };
130
+ }
131
+ function et(s, e) {
132
+ var l;
133
+ const t = e.replace(new RegExp(`\\s+#${s.runNo}$`), "");
134
+ return ((l = s.runName) == null ? void 0 : l.trim()) || `${t} #${s.runNo}`;
135
+ }
136
+ function Ks(s) {
137
+ var l;
138
+ const e = String(s.runNo).padStart(12, "0"), t = (l = s.runName) == null ? void 0 : l.trim().toLowerCase();
139
+ return t ? `0:${t}` : `1:${e}`;
140
+ }
141
+ function Qs(s, e, t = () => null) {
142
+ var r;
143
+ const l = e.trim().toLowerCase().replace(/^#/, "");
144
+ return l ? [
145
+ ((r = s.runName) == null ? void 0 : r.trim()) ?? "",
146
+ `${s.runNo}`,
147
+ ...s.items.map((c) => {
148
+ var a;
149
+ return ((a = t(c.skuId)) == null ? void 0 : a.name) ?? "";
150
+ })
151
+ ].some((c) => c.toLowerCase().includes(l)) : !0;
152
+ }
153
+ const Zt = {
154
+ update: "Edit",
155
+ request: "Submit request",
156
+ prepare: "Review & prepare",
157
+ // "Record output" over "Complete run": this action adds finished goods and
158
+ // may be one of several batches, so "complete" overstates it.
159
+ complete: "Record output",
160
+ close: "Close run",
161
+ cancel: "Cancel run"
162
+ };
163
+ function Gs(s) {
164
+ return Vt.legalEvents({ run: s }).filter((e) => e !== "create").map((e) => ({ action: e, label: Zt[e] }));
165
+ }
166
+ function eo(s) {
167
+ switch (s) {
168
+ case "DRAFT":
169
+ return "fm-status-badge-draft";
170
+ case "REQUESTING":
171
+ return "fm-status-badge-receiving";
172
+ case "PREPARING":
173
+ return "fm-status-badge-requesting";
174
+ case "CLOSED":
175
+ return "fm-status-badge-close";
176
+ case "CANCEL":
177
+ return "fm-status-badge-cancel";
178
+ default:
179
+ throw new Error(`Unsupported production run status: ${s}`);
180
+ }
181
+ }
182
+ function Le(s) {
183
+ return {
184
+ id: s._id,
185
+ name: s.name,
186
+ abbrev: s.abbrev,
187
+ baseUnitId: s._id,
188
+ conversion: { amount: 1, precision: 0 }
189
+ };
190
+ }
191
+ function $t(s, e) {
192
+ return {
193
+ ...e,
194
+ baseUnitId: s._id,
195
+ conversion: { ...e.conversion }
196
+ };
197
+ }
198
+ function It(s) {
199
+ const e = s;
200
+ return !!e && Number.isSafeInteger(e.amount) && Number.isSafeInteger(e.precision) && e.precision >= 0;
201
+ }
202
+ function dt(s, e) {
203
+ function t(r) {
204
+ let c = r.amount, a = r.precision;
205
+ for (; a > 0 && c % 10 === 0; )
206
+ c /= 10, a--;
207
+ return { amount: c, precision: a };
208
+ }
209
+ const l = t(s), o = t(e);
210
+ return l.amount === o.amount && l.precision === o.precision;
211
+ }
212
+ function $e(s) {
213
+ const e = s, t = e == null ? void 0 : e.conversion;
214
+ if (!e || typeof e.id != "string" || !e.id || typeof e.baseUnitId != "string" || !e.baseUnitId || typeof e.name != "string" || typeof e.abbrev != "string" || !t || !It(t))
215
+ return !1;
216
+ const l = t.amount / 10 ** t.precision;
217
+ return t.amount > 0 && Number.isFinite(l) && l > 0;
218
+ }
219
+ function ct(s, e) {
220
+ return $e(s) && $e(e) && s.id === e.id && s.baseUnitId === e.baseUnitId && dt(s.conversion, e.conversion);
221
+ }
222
+ function ge(s, e) {
223
+ return !$e(s) || s.baseUnitId !== e._id ? !1 : s.id === e._id ? dt(s.conversion, { amount: 1, precision: 0 }) : e.measurements.some(
224
+ (t) => t.id === s.id && It(t.conversion) && dt(t.conversion, s.conversion)
225
+ );
226
+ }
227
+ function qe(s, e) {
228
+ return $e(s) && ge(s, e) ? { ...s, conversion: { ...s.conversion } } : null;
229
+ }
230
+ const to = { class: "flex" }, oo = /* @__PURE__ */ Y({
231
+ __name: "ProductionRunStatusBadge",
232
+ props: {
233
+ status: {}
234
+ },
235
+ setup(s) {
236
+ const e = s, { t } = de(), l = S(() => t(`inventory.production.run.list.status.${e.status}`)), o = S(() => eo(e.status));
237
+ return (r, c) => (m(), k("div", to, [
238
+ u("div", {
239
+ class: G(["fm-status-badge production-run-status-badge", o.value])
240
+ }, y(l.value), 3)
241
+ ]));
242
+ }
243
+ }), Ws = /* @__PURE__ */ Ie(oo, [["__scopeId", "data-v-0a0172e5"]]), no = { class: "flex gap-12 items-start px-16 py-12 grow" }, ro = { class: "grow min-w-0" }, so = {
244
+ key: 0,
245
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary mt-4"
246
+ }, io = {
247
+ key: 1,
248
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-primary mt-8"
249
+ }, ao = {
250
+ key: 0,
251
+ class: "flex gap-8 items-center shrink-0"
252
+ }, mt = /* @__PURE__ */ Y({
253
+ __name: "FmInventoryBanner",
254
+ props: {
255
+ tone: {},
256
+ title: {},
257
+ message: { default: void 0 }
258
+ },
259
+ setup(s) {
260
+ const e = s, t = {
261
+ info: {
262
+ surface: "bg-fm-color-system-info-100",
263
+ typo: "text-fm-color-typo-info",
264
+ accent: "bg-fm-color-system-info-400",
265
+ icon: "info"
266
+ },
267
+ warn: {
268
+ surface: "bg-fm-color-system-warning-100",
269
+ typo: "text-fm-color-typo-warning",
270
+ accent: "bg-fm-color-system-warning-400",
271
+ icon: "warning"
272
+ },
273
+ critical: {
274
+ surface: "bg-fm-color-system-error-100",
275
+ typo: "text-fm-color-typo-error",
276
+ accent: "bg-fm-color-system-error-400",
277
+ icon: "error"
278
+ },
279
+ success: {
280
+ surface: "bg-fm-color-system-success-100",
281
+ typo: "text-fm-color-typo-success",
282
+ accent: "bg-fm-color-system-success-400",
283
+ icon: "check_circle"
284
+ }
285
+ }, l = S(() => t[e.tone]);
286
+ return (o, r) => {
287
+ const c = Z("FmIcon");
288
+ return m(), k("div", {
289
+ class: G(["flex items-stretch overflow-hidden fm-corner-radius-md", l.value.surface]),
290
+ role: "status"
291
+ }, [
292
+ u("div", {
293
+ class: G(["w-4 shrink-0", l.value.accent])
294
+ }, null, 2),
295
+ u("div", no, [
296
+ E(c, {
297
+ name: l.value.icon,
298
+ size: "sm",
299
+ outline: "",
300
+ class: G([l.value.typo, "shrink-0 mt-2"])
301
+ }, null, 8, ["name", "class"]),
302
+ u("div", ro, [
303
+ u("p", {
304
+ class: G(["fm-typo-en-body-md-600", l.value.typo])
305
+ }, y(e.title), 3),
306
+ e.message ? (m(), k("p", so, y(e.message), 1)) : B("", !0),
307
+ o.$slots.default ? (m(), k("div", io, [
308
+ se(o.$slots, "default")
309
+ ])) : B("", !0)
310
+ ]),
311
+ o.$slots.actions ? (m(), k("div", ao, [
312
+ se(o.$slots, "actions")
313
+ ])) : B("", !0)
314
+ ])
315
+ ], 2);
316
+ };
317
+ }
318
+ });
319
+ function lo(s) {
320
+ return {
321
+ title: s("inventory.production.run.form.submit.title"),
322
+ message: s("inventory.production.run.form.submit.message"),
323
+ primaryActions: {
324
+ text: s("inventory.production.run.form.submit.confirm"),
325
+ close: !0
326
+ },
327
+ secondaryActions: {
328
+ text: s("inventory.production.run.form.submit.keep"),
329
+ close: !0,
330
+ variant: "tertiary"
331
+ }
332
+ };
333
+ }
334
+ function uo(s) {
335
+ return s.filter(
336
+ (e) => De(e.model.amount) && e.model.amount.amount > 0 && e.bindingCount === 0
337
+ ).map((e) => e.name);
338
+ }
339
+ function De(s) {
340
+ const e = s.amount / 10 ** s.precision;
341
+ return Number.isSafeInteger(s.amount) && Number.isSafeInteger(s.precision) && s.precision >= 0 && s.amount >= 0 && Number.isFinite(e) && (s.amount === 0 || e > 0);
342
+ }
343
+ function co() {
344
+ const s = zt(), e = xt(), t = Mt(), l = N(!1), o = N(null), r = N(!1), c = N(""), a = N(""), n = N(!1), f = N(0), w = N(!1), U = N([]), _ = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), R = S(
345
+ () => new Map((t.stockBalance.skus ?? []).map((h) => [h.id, h.balance]))
346
+ );
347
+ function T() {
348
+ return (e.skus ?? []).map((h) => ({
349
+ doc: h,
350
+ balance: R.value.get(h._id) ?? { amount: 0, precision: 0 },
351
+ abbrev: h.unit.abbrev,
352
+ uom: []
353
+ }));
354
+ }
355
+ function z() {
356
+ return {
357
+ stocks: T(),
358
+ recipes: e.recipes ?? []
359
+ };
360
+ }
361
+ const D = Et({
362
+ env: z()
363
+ }), g = Dt({
364
+ env: z()
365
+ });
366
+ let te = 0;
367
+ function J() {
368
+ try {
369
+ const h = D.state().items;
370
+ g.resetState(), g.addItems(h.map((V) => V.inventoryStock));
371
+ for (const V of h) {
372
+ const P = ce(V), d = _.get(V.key) ?? null, v = b.get(V.key) ?? V.requested, $ = De(v) && !!d && ge(d, P.unit);
373
+ g.updateItem(
374
+ V.key,
375
+ $ ? Ee(v, d) : { amount: 0, precision: 0 },
376
+ P.unit._id
377
+ );
378
+ }
379
+ w.value = !1;
380
+ } catch (h) {
381
+ w.value = !0, console.error("[production-run] ingredient projection failed", h);
382
+ } finally {
383
+ f.value++;
384
+ }
385
+ }
386
+ function L() {
387
+ D.updateEnv(z()), g.updateEnv(z()), J();
388
+ }
389
+ async function q() {
390
+ const h = ++te;
391
+ l.value = !0, o.value = null;
392
+ try {
393
+ return await e.readInventory(), await t.readStockBalance(), h !== te ? !1 : (L(), !0);
394
+ } catch (V) {
395
+ return h === te && (o.value = ut(V)), !1;
396
+ } finally {
397
+ h === te && (l.value = !1);
398
+ }
399
+ }
400
+ async function A() {
401
+ await t.readStockBalance(), D.updateBalances(T()), g.updateBalances(T()), J();
402
+ }
403
+ function j() {
404
+ D.resetState(), _.clear(), b.clear(), c.value = "", a.value = "", n.value = !1, U.value = [], J();
405
+ }
406
+ function x(h) {
407
+ var $;
408
+ D.resetState();
409
+ const V = h.items.filter(
410
+ (p) => $e(p.measurement)
411
+ );
412
+ D.seedFromRunItems(V);
413
+ const P = new Set(D.state().items.map((p) => p.key)), d = new Set(
414
+ h.items.filter((p) => !P.has(p.skuId)).map((p) => p.skuId)
415
+ ), v = T().filter((p) => d.has(p.doc._id));
416
+ v.length && D.addItems(v), _.clear(), b.clear();
417
+ for (const p of D.state().items) {
418
+ const O = ce(p), F = h.items.filter((oe) => oe.skuId === O._id), W = F.map(
419
+ (oe) => qe(oe.measurement, O.unit)
420
+ );
421
+ if (!F.length || W.some((oe) => !oe)) {
422
+ const oe = ($ = F[0]) == null ? void 0 : $.measurement, Ve = F.length === 1 && $e(oe) ? { ...oe, conversion: { ...oe.conversion } } : null;
423
+ _.set(p.key, Ve), b.set(
424
+ p.key,
425
+ F.length === 1 ? F[0].requestedAmount : { amount: 0, precision: p.requested.precision }
426
+ );
427
+ continue;
428
+ }
429
+ const Q = W, re = Q[0], le = Q.every(
430
+ (oe) => ct(oe, re)
431
+ ), we = Q.every((oe) => oe.baseUnitId === O.unit._id), Re = le ? { ...re, conversion: { ...re.conversion } } : we ? Le(O.unit) : null, je = le ? F.map((oe) => oe.requestedAmount).reduce(ye.addDecimal) : we ? F.map((oe, Ve) => Ee(oe.requestedAmount, Q[Ve])).reduce(ye.addDecimal) : { amount: 0, precision: p.requested.precision };
432
+ _.set(p.key, Re), b.set(p.key, je);
433
+ const Ye = !!Re && ge(Re, O.unit);
434
+ D.updateItem(
435
+ p.key,
436
+ Ye ? Ee(je, Re) : { amount: 0, precision: je.precision },
437
+ O.unit._id
438
+ );
439
+ }
440
+ U.value = C(h), c.value = h.runName ?? "", a.value = h.instructions ?? "", n.value = !1, J();
441
+ }
442
+ function C(h) {
443
+ const V = (P) => {
444
+ var d;
445
+ return ((d = e.skuById[P]) == null ? void 0 : d.unit.abbrev) ?? "";
446
+ };
447
+ return D.duplicateItemMerges().map((P) => {
448
+ var O;
449
+ const d = h == null ? void 0 : h.items.filter((F) => F.skuId === P.skuId), v = e.skuById[P.skuId], $ = d == null ? void 0 : d.map(
450
+ (F) => v ? qe(F.measurement, v.unit) : null
451
+ ), p = !d || !!($ != null && $[0]) && $.every(
452
+ (F) => !!F && F.baseUnitId === $[0].baseUnitId
453
+ );
454
+ return {
455
+ skuId: P.skuId,
456
+ name: P.skuName,
457
+ sources: (d ?? P.sources).map((F, W) => {
458
+ var Q, re;
459
+ return {
460
+ amount: ye.toDouble(
461
+ "requestedAmount" in F ? F.requestedAmount : F.amount
462
+ ),
463
+ unit: ((Q = $ == null ? void 0 : $[W]) == null ? void 0 : Q.abbrev) ?? ("measurement" in F ? (re = F.measurement) == null ? void 0 : re.abbrev : null) ?? ""
464
+ };
465
+ }),
466
+ amount: p ? ye.toDouble(P.combined) : null,
467
+ unit: p ? ((O = P.measurement) == null ? void 0 : O.abbrev) ?? V(P.skuId) : null
468
+ };
469
+ });
470
+ }
471
+ function _e(h) {
472
+ const V = T().filter((d) => h.includes(d.doc._id));
473
+ if (!V.length) return;
474
+ const P = new Set(D.state().items.map((d) => d.key));
475
+ D.addItems(V);
476
+ for (const d of V.filter((v) => !P.has(v.doc._id))) {
477
+ const v = Le(d.doc.unit), $ = { amount: 1, precision: 0 };
478
+ _.set(d.doc._id, v), b.set(d.doc._id, $), D.updateItem(d.doc._id, $, d.doc.unit._id);
479
+ }
480
+ n.value = !0, J();
481
+ }
482
+ function Fe(h) {
483
+ D.removeItem(h), _.delete(h), b.delete(h), n.value = !0, J();
484
+ }
485
+ function xe() {
486
+ for (const h of [...D.state().items]) D.removeItem(h.key);
487
+ _.clear(), b.clear(), n.value = !0, J();
488
+ }
489
+ function ve(h, V, P, d = {}) {
490
+ var O;
491
+ const v = new Set(D.state().items.map((F) => F.key)), $ = h.items.filter(
492
+ (F) => V.includes(F.skuId) && (P === "replace" || !v.has(F.skuId))
493
+ );
494
+ P === "replace" && xe();
495
+ const p = /* @__PURE__ */ new Map();
496
+ for (const F of $) {
497
+ const W = p.get(F.skuId) ?? [], Q = d[F.skuId];
498
+ W.push(Q ? { ...F, measurement: Q } : F), p.set(F.skuId, W);
499
+ }
500
+ _e([...p.keys()]);
501
+ for (const [F, W] of p) {
502
+ const Q = D.state().items.find((ne) => ne.key === F);
503
+ if (!Q) continue;
504
+ const re = ce(Q), le = W.map(
505
+ (ne) => qe(ne.measurement, re.unit)
506
+ ), we = le[0], Re = !!we && le.every(
507
+ (ne) => !!ne && ct(ne, we)
508
+ ), je = we ? { ...we, conversion: { ...we.conversion } } : null, Ye = le.every(
509
+ (ne) => !!ne && ne.baseUnitId === re.unit._id
510
+ ), oe = (O = W[0]) == null ? void 0 : O.measurement, Ve = W.length === 1 && $e(oe) ? { ...oe, conversion: { ...oe.conversion } } : null, be = Re ? je : Ye ? Le(re.unit) : Ve, He = Re ? W.map((ne) => ne.requestedAmount).reduce(ye.addDecimal) : Ye ? W.map((ne, at) => Ee(ne.requestedAmount, le[at])).reduce(ye.addDecimal) : Ve ? W[0].requestedAmount : { amount: 0, precision: 0 }, Rt = be ? He : { amount: 0, precision: He.precision };
511
+ _.set(Q.key, be), b.set(Q.key, Rt);
512
+ const At = !!be && ge(be, re.unit);
513
+ D.updateItem(
514
+ Q.key,
515
+ At ? Ee(He, be) : { amount: 0, precision: He.precision },
516
+ re.unit._id
517
+ ), U.value = U.value.filter((ne) => ne.skuId !== F), W.length > 1 && U.value.push({
518
+ skuId: F,
519
+ name: re.name,
520
+ sources: W.map((ne, at) => {
521
+ var pt, ft;
522
+ return {
523
+ amount: ye.toDouble(ne.requestedAmount),
524
+ unit: ((pt = le[at]) == null ? void 0 : pt.abbrev) ?? ((ft = ne.measurement) == null ? void 0 : ft.abbrev) ?? ""
525
+ };
526
+ }),
527
+ amount: be ? ye.toDouble(He) : null,
528
+ unit: (be == null ? void 0 : be.abbrev) ?? null
529
+ });
530
+ }
531
+ n.value = !0, J();
532
+ }
533
+ function Ue(h, V) {
534
+ const P = D.state().items.find(($) => $.key === h);
535
+ if (!P) return;
536
+ _.set(h, V.measurement), b.set(h, V.amount);
537
+ const d = ce(P), v = De(V.amount) && !!V.measurement && ge(V.measurement, d.unit);
538
+ D.updateItem(
539
+ h,
540
+ v ? Ee(V.amount, V.measurement) : { amount: 0, precision: 0 },
541
+ d.unit._id
542
+ ), n.value = !0, J();
543
+ }
544
+ function Ne(h) {
545
+ c.value = h, n.value = !0;
546
+ }
547
+ function Oe(h) {
548
+ a.value = h, n.value = !0;
549
+ }
550
+ const Se = S(() => (f.value, g.getItemBreakdown()));
551
+ function ce(h) {
552
+ return h.inventoryStock.doc;
553
+ }
554
+ const Ce = S(() => (f.value, D.state().items.map((h) => {
555
+ var $;
556
+ const V = (($ = Se.value.find((p) => p.item.key === h.key)) == null ? void 0 : $.lines) ?? [], P = ce(h), d = _.get(h.key) ?? null, v = b.get(h.key) ?? h.requested;
557
+ return {
558
+ key: h.key,
559
+ skuId: P._id,
560
+ name: P.name,
561
+ code: P.code,
562
+ baseUnit: P.unit.abbrev,
563
+ enteredUnit: (d == null ? void 0 : d.abbrev) ?? "",
564
+ onHand: R.value.has(P._id) ? ye.toDouble(R.value.get(P._id)) : null,
565
+ // The durable amount + snapshot pair is the quantity truth. The old
566
+ // controller may hold that same figure in base units when a copied
567
+ // measurement no longer exists live; converting its internal value
568
+ // here would apply the stored factor twice.
569
+ baseQuantity: De(v) && d && ge(d, P.unit) ? Ot(v, d) : 0,
570
+ sku: P,
571
+ model: { amount: v, measurement: d },
572
+ bindingCount: V.length,
573
+ bindingLines: V.map((p) => ({
574
+ id: p.skuId,
575
+ name: p.name,
576
+ amount: p.perUnit,
577
+ unit: p.unit
578
+ }))
579
+ };
580
+ }))), Pe = S(() => {
581
+ f.value;
582
+ const h = Ce.value;
583
+ return D.canSubmit() && h.some((V) => V.model.amount.amount > 0) && h.every(
584
+ (V) => De(V.model.amount) && !!V.model.measurement && ge(V.model.measurement, V.sku.unit)
585
+ );
586
+ }), Me = S(() => Pe.value && !w.value), I = S(() => {
587
+ f.value;
588
+ const h = /* @__PURE__ */ new Map();
589
+ for (const P of Se.value)
590
+ if (!(P.qty <= 0))
591
+ for (const d of P.lines) {
592
+ if (d.total <= 0) continue;
593
+ const v = h.get(d.skuId) ?? [];
594
+ v.push({
595
+ itemSkuId: P.item.key,
596
+ name: P.item.inventoryStock.doc.name,
597
+ perUnit: d.perUnit,
598
+ sourceQuantity: P.qty,
599
+ sourceUnit: P.item.inventoryStock.doc.unit.abbrev,
600
+ amount: d.total
601
+ }), h.set(d.skuId, v);
602
+ }
603
+ const V = new Map(g.getIngredientImpacts().map((P) => [P.skuId, P]));
604
+ return [...h.entries()].map(([P, d]) => {
605
+ var p, O;
606
+ const v = V.get(P), $ = d.reduce((F, W) => F + W.amount, 0);
607
+ return {
608
+ skuId: P,
609
+ name: (v == null ? void 0 : v.name) ?? ((p = e.skuById[P]) == null ? void 0 : p.name) ?? P,
610
+ unit: (v == null ? void 0 : v.unit) ?? ((O = e.skuById[P]) == null ? void 0 : O.unit.abbrev) ?? "",
611
+ need: $,
612
+ current: (v == null ? void 0 : v.current) ?? null,
613
+ after: (v == null ? void 0 : v.after) ?? null,
614
+ // No impact row means no resolved balance — not a healthy one.
615
+ status: v ? String(v.status) : "unknown",
616
+ contributors: d
617
+ };
618
+ });
619
+ }), K = S(
620
+ () => I.value.filter((h) => h.status === "shortage").map((h) => ({
621
+ name: h.name,
622
+ over: Math.abs(Math.min(0, h.after ?? 0)),
623
+ unit: h.unit
624
+ }))
625
+ ), X = S(() => (f.value, (e.skus ?? []).filter((h) => h.convert != null).map((h) => ({
626
+ sku: h,
627
+ hasBindings: D.itemHasBindings(h._id),
628
+ // The Stock store normalizes every catalog sku to an explicit zero row;
629
+ // a read failure blocks the form before candidates render.
630
+ onHand: ye.toDouble(
631
+ R.value.get(h._id) ?? {
632
+ amount: 0,
633
+ precision: 0
634
+ }
635
+ )
636
+ }))));
637
+ function me() {
638
+ return D.state().items.flatMap((h) => {
639
+ var d;
640
+ const V = _.get(h.key);
641
+ if (!V) throw new Error(`Production run item ${h.key} has no unit snapshot`);
642
+ if (!ge(V, ce(h).unit))
643
+ throw new Error(
644
+ `Production run item ${h.key} has a unit snapshot that does not belong to its live unit`
645
+ );
646
+ const P = (d = Ce.value.find((v) => v.key === h.key)) == null ? void 0 : d.model;
647
+ if (!P) throw new Error(`Production run item ${h.key} is unavailable`);
648
+ if (!De(P.amount))
649
+ throw new Error(
650
+ `Production run item ${h.key} does not have a valid non-negative decimal`
651
+ );
652
+ return P.amount.amount === 0 ? [] : [
653
+ {
654
+ skuId: h.key,
655
+ requestedAmount: P.amount,
656
+ measurement: V
657
+ }
658
+ ];
659
+ });
660
+ }
661
+ function ae() {
662
+ return {
663
+ items: me(),
664
+ // The create contract requires the choice explicitly: null means the
665
+ // operator left this optional label blank.
666
+ runName: c.value.trim() || null,
667
+ // Blank normalises to null, never `''` — see the entity's own note on
668
+ // the field. Sent on create as well as update so the two payloads make
669
+ // the same statement about an empty box.
670
+ instructions: a.value.trim() || null
671
+ };
672
+ }
673
+ function Be() {
674
+ return {
675
+ items: me(),
676
+ runName: c.value.trim() || null,
677
+ instructions: a.value.trim() || null
678
+ };
679
+ }
680
+ async function ie() {
681
+ r.value = !0;
682
+ try {
683
+ return await s.create(ae());
684
+ } finally {
685
+ r.value = !1;
686
+ }
687
+ }
688
+ async function st(h) {
689
+ r.value = !0;
690
+ try {
691
+ return await s.update(h, Be());
692
+ } finally {
693
+ r.value = !1;
694
+ }
695
+ }
696
+ async function it() {
697
+ r.value = !0;
698
+ try {
699
+ const h = await s.create(ae());
700
+ try {
701
+ return { run: await s.request(h._id), requested: !0, failure: null };
702
+ } catch (V) {
703
+ return { run: h, requested: !1, failure: ut(V) };
704
+ }
705
+ } finally {
706
+ r.value = !1;
707
+ }
708
+ }
709
+ return {
710
+ loading: l,
711
+ loadFailure: o,
712
+ submitting: r,
713
+ dirty: n,
714
+ runName: c,
715
+ instructions: a,
716
+ items: Ce,
717
+ commits: I,
718
+ shortages: K,
719
+ candidates: X,
720
+ projectionFailed: w,
721
+ duplicateMerges: U,
722
+ canSubmit: Pe,
723
+ canRequest: Me,
724
+ load: q,
725
+ refreshStock: A,
726
+ retryProjection: J,
727
+ reset: j,
728
+ seedFrom: x,
729
+ addItems: _e,
730
+ removeItem: Fe,
731
+ clearAll: xe,
732
+ duplicateItems: ve,
733
+ updateItemModel: Ue,
734
+ updateRunName: Ne,
735
+ updateInstructions: Oe,
736
+ createDraft: ie,
737
+ updateDraft: st,
738
+ createAndRequest: it,
739
+ displayName: et
740
+ };
741
+ }
742
+ function mo(s) {
743
+ return jt(s.unit);
744
+ }
745
+ function po() {
746
+ const s = xt();
747
+ return (e) => {
748
+ const t = s.skuById[e];
749
+ return t ? mo(t) : null;
750
+ };
751
+ }
752
+ const fo = { class: "relative pb-[4px] pl-[12px] text-[12px] leading-[16px]" }, vo = ["role"], yo = ["title"], bo = { class: "shrink-0 font-medium text-fm-color-typo-primary tabular-nums" }, go = /* @__PURE__ */ Y({
753
+ __name: "ProductionRunContributorBranch",
754
+ props: {
755
+ entries: {},
756
+ itemRole: {}
757
+ },
758
+ setup(s) {
759
+ return (e, t) => (m(), k("ul", fo, [
760
+ (m(!0), k(ee, null, pe(e.entries, (l, o) => (m(), k("li", {
761
+ key: l.key,
762
+ role: e.itemRole,
763
+ class: "relative flex items-center justify-between gap-[12px] py-[2px] pl-[8px] pr-[8px] text-fm-color-typo-secondary"
764
+ }, [
765
+ u("span", {
766
+ "data-testid": "ingredient-connector-vertical",
767
+ "aria-hidden": "true",
768
+ class: G(["absolute -left-[12px] border-l border-fm-color-border-default", [
769
+ o === 0 ? "-top-[4px]" : "top-0",
770
+ o === e.entries.length - 1 ? "bottom-1/2" : "bottom-0"
771
+ ]])
772
+ }, null, 2),
773
+ t[0] || (t[0] = u("span", {
774
+ "data-testid": "ingredient-connector-horizontal",
775
+ "aria-hidden": "true",
776
+ class: "absolute -left-[12px] top-1/2 w-[20px] border-t border-fm-color-border-default"
777
+ }, null, -1)),
778
+ u("span", {
779
+ class: "min-w-0 truncate",
780
+ title: l.label
781
+ }, y(l.label), 9, yo),
782
+ u("strong", bo, y(l.value), 1)
783
+ ], 8, vo))), 128))
784
+ ]));
785
+ }
786
+ });
787
+ function nt(s = !0) {
788
+ const e = N(null), t = N(!1);
789
+ let l = 0, o = !1;
790
+ function r() {
791
+ const a = e.value;
792
+ t.value = Ze(s) && !!a && a.scrollHeight - a.scrollTop - a.clientHeight > 1;
793
+ }
794
+ function c() {
795
+ o || (o = !0, l = requestAnimationFrame(() => {
796
+ o = !1, l = 0, he(r);
797
+ }));
798
+ }
799
+ return ke([e, () => Ze(s)], c, { immediate: !0 }), Ft(c), Te(() => window.addEventListener("resize", c)), We(() => {
800
+ cancelAnimationFrame(l), window.removeEventListener("resize", c);
801
+ }), { scroller: e, canScrollFurther: t, measure: r, scheduleMeasure: c, onScroll: r };
802
+ }
803
+ const ho = ["data-testid", "data-visible"], Ge = /* @__PURE__ */ Y({
804
+ __name: "ProductionRunScrollHint",
805
+ props: {
806
+ visible: { type: Boolean },
807
+ testid: { default: "production-run-scroll-hint" }
808
+ },
809
+ setup(s) {
810
+ return (e, t) => (m(), k("div", {
811
+ "data-testid": e.testid,
812
+ "data-visible": String(e.visible),
813
+ class: G([e.visible ? "opacity-100" : "opacity-0", "pointer-events-none sticky inset-x-0 bottom-0 z-10 -mt-10 h-10 shrink-0 bg-gradient-to-t from-fm-color-surface-primary via-fm-color-surface-primary to-transparent transition-opacity"]),
814
+ "aria-hidden": "true"
815
+ }, null, 10, ho));
816
+ }
817
+ }), ko = ["data-mode", "aria-labelledby"], _o = { class: "flex min-h-56 items-center justify-between gap-8 border-b border-fm-color-neutral-gray-200 px-16 py-12" }, xo = ["id"], wo = {
818
+ key: 1,
819
+ "data-testid": "production-run-ingredient-empty",
820
+ class: "flex items-center justify-center px-16 py-32 text-center text-[14px] font-normal leading-[20px] text-fm-color-typo-secondary"
821
+ }, $o = ["role", "aria-labelledby"], Io = ["role", "aria-expanded"], So = {
822
+ key: 1,
823
+ "aria-hidden": "true"
824
+ }, Co = { class: "contents" }, Ro = { class: "fm-typo-en-body-md-600 line-clamp-1 text-fm-color-typo-primary" }, Ao = { class: "text-fm-color-typo-error" }, Fo = {
825
+ key: 3,
826
+ "data-testid": "production-run-ingredient-tree-footer",
827
+ class: "fm-typo-en-body-sm-400 mt-auto flex shrink-0 items-center gap-[6px] border-t border-fm-color-neutral-gray-200 px-16 py-12 text-fm-color-typo-secondary"
828
+ }, Uo = /* @__PURE__ */ Y({
829
+ __name: "ProductionRunIngredientTree",
830
+ props: {
831
+ mode: {},
832
+ rows: {},
833
+ noItems: { type: Boolean },
834
+ unboundNames: { default: () => [] },
835
+ constrained: { type: Boolean, default: !0 }
836
+ },
837
+ setup(s) {
838
+ const e = s, { t } = de(), l = po(), o = N(/* @__PURE__ */ new Set()), r = S(() => e.mode !== "requested"), c = S(
839
+ () => e.mode === "planner" ? "inventory.production.run.form.commits.title" : "inventory.production.run.detail.requested.ingredientsTitle"
840
+ ), a = S(() => e.unboundNames ?? []), n = S(() => e.rows.filter((A) => A.status === "shortage").length), f = S(() => e.rows.filter((A) => A.status === "unknown").length), w = S(() => r.value && e.constrained), {
841
+ scroller: U,
842
+ canScrollFurther: _,
843
+ onScroll: b
844
+ } = nt(w);
845
+ function R(A) {
846
+ const j = /* @__PURE__ */ new Map();
847
+ for (const x of A.contributors) {
848
+ const C = j.get(x.itemSkuId);
849
+ C ? C.amount += x.amount : j.set(x.itemSkuId, { ...x });
850
+ }
851
+ return [...j.values()];
852
+ }
853
+ const T = S(
854
+ () => e.rows.map((A) => ({ ...A, displayContributors: R(A) }))
855
+ ), z = S(
856
+ () => r.value ? new Set(
857
+ T.value.filter((A) => A.displayContributors.length).map((A) => A.skuId)
858
+ ) : /* @__PURE__ */ new Set()
859
+ ), D = S(() => [...z.value].some((A) => o.value.has(A)));
860
+ ke(
861
+ [() => e.mode, z],
862
+ ([A, j]) => {
863
+ if (A === "requested") {
864
+ o.value = /* @__PURE__ */ new Set();
865
+ return;
866
+ }
867
+ const x = [...o.value].filter((C) => j.has(C));
868
+ x.length !== o.value.size && (o.value = new Set(x));
869
+ },
870
+ { immediate: !0 }
871
+ );
872
+ function g(A, j, x) {
873
+ return fe(A, x, { precision: l(j) });
874
+ }
875
+ function te(A) {
876
+ if (!z.value.has(A)) return;
877
+ const j = new Set(o.value);
878
+ j.has(A) ? j.delete(A) : j.add(A), o.value = j;
879
+ }
880
+ function J() {
881
+ o.value = D.value ? /* @__PURE__ */ new Set() : new Set(z.value);
882
+ }
883
+ function L(A, j) {
884
+ return A.map((x) => ({
885
+ key: x.itemSkuId,
886
+ label: x.name,
887
+ value: g(x.amount, j.skuId, j.unit)
888
+ }));
889
+ }
890
+ function q() {
891
+ return a.value.length ? e.mode === "planner" ? "inventory.production.run.form.commits.noBindings" : "inventory.production.run.detail.requested.ingredientsEmpty" : e.noItems ? "inventory.production.run.form.commits.empty" : "inventory.production.run.form.commits.noQuantities";
892
+ }
893
+ return (A, j) => {
894
+ const x = Z("FmIcon");
895
+ return m(), k("aside", {
896
+ "data-testid": "production-run-ingredient-tree",
897
+ "data-mode": A.mode,
898
+ "aria-labelledby": `production-run-ingredient-title-${A.mode}`,
899
+ class: G(["fm-corner-radius-md flex min-w-0 flex-col overflow-hidden border border-fm-color-neutral-gray-200", A.mode !== "requested" && A.constrained ? "max-h-[60dvh]" : ""])
900
+ }, [
901
+ u("header", _o, [
902
+ u("h3", {
903
+ id: `production-run-ingredient-title-${A.mode}`,
904
+ class: "whitespace-nowrap text-[16px] font-semibold leading-[24px] text-fm-color-typo-primary"
905
+ }, y(i(t)(c.value)), 9, xo),
906
+ r.value && z.value.size ? (m(), k("button", {
907
+ key: 0,
908
+ type: "button",
909
+ class: "fm-typo-en-body-sm-400 shrink-0 whitespace-nowrap text-fm-color-typo-primary",
910
+ onClick: J
911
+ }, y(D.value ? i(t)("inventory.production.run.form.commits.collapseAll") : i(t)("inventory.production.run.form.commits.expandAll")), 1)) : B("", !0)
912
+ ]),
913
+ A.rows.length ? (m(), k("div", {
914
+ key: 0,
915
+ ref_key: "ingredientRowsScroll",
916
+ ref: U,
917
+ class: "fm-typo-en-body-md-400 flex shrink-0 gap-4 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 px-16 py-8 text-fm-color-typo-secondary"
918
+ }, [
919
+ u("span", null, y(A.rows.length === 1 ? i(t)("inventory.production.run.form.commits.summaryOne", { count: A.rows.length }) : i(t)("inventory.production.run.form.commits.summary", { count: A.rows.length })), 1),
920
+ j[1] || (j[1] = u("span", { "aria-hidden": "true" }, "·", -1)),
921
+ u("span", {
922
+ class: G(
923
+ n.value ? "text-fm-color-typo-error" : f.value ? "text-fm-color-typo-warning" : ""
924
+ )
925
+ }, y(n.value > 0 ? n.value === 1 ? i(t)("inventory.production.run.form.commits.shortageOne") : i(t)("inventory.production.run.form.commits.shortCount", {
926
+ count: n.value
927
+ }) : f.value ? i(t)("inventory.production.run.form.commits.stockUnknown") : i(t)("inventory.production.run.form.commits.noShortages")), 3)
928
+ ], 512)) : B("", !0),
929
+ A.rows.length ? B("", !0) : (m(), k("div", wo, y(i(t)(q())), 1)),
930
+ A.rows.length ? (m(), k("div", {
931
+ key: 2,
932
+ role: r.value ? "tree" : void 0,
933
+ "aria-labelledby": `production-run-ingredient-title-${A.mode}`,
934
+ "data-testid": "production-run-ingredient-rows",
935
+ class: G(["flex min-h-0 flex-1 flex-col", r.value ? "overflow-y-auto" : ""]),
936
+ onScroll: j[0] || (j[0] = //@ts-ignore
937
+ (...C) => i(b) && i(b)(...C))
938
+ }, [
939
+ (m(!0), k(ee, null, pe(T.value, (C) => (m(), k("div", {
940
+ key: C.skuId,
941
+ role: r.value ? "treeitem" : void 0,
942
+ "aria-expanded": z.value.has(C.skuId) ? o.value.has(C.skuId) : void 0,
943
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
944
+ }, [
945
+ (m(), M(Ut(z.value.has(C.skuId) ? "button" : "div"), {
946
+ type: z.value.has(C.skuId) ? "button" : void 0,
947
+ "data-testid": z.value.has(C.skuId) ? "production-run-ingredient-toggle" : void 0,
948
+ class: G(["grid w-full items-start gap-x-8 px-8 py-4 text-left", [
949
+ r.value ? "grid-cols-[1rem_minmax(0,1fr)_auto]" : "grid-cols-[minmax(0,1fr)_auto]",
950
+ z.value.has(C.skuId) ? "hover:bg-fm-color-opacity-sm" : ""
951
+ ]]),
952
+ "aria-expanded": z.value.has(C.skuId) ? o.value.has(C.skuId) : void 0,
953
+ onClick: (_e) => te(C.skuId)
954
+ }, {
955
+ default: H(() => [
956
+ z.value.has(C.skuId) ? (m(), M(x, {
957
+ key: 0,
958
+ name: "chevron_right",
959
+ size: "sm",
960
+ class: G(["mt-[1px] text-fm-color-typo-tertiary transition-transform", { "rotate-90": o.value.has(C.skuId) }])
961
+ }, null, 8, ["class"])) : r.value ? (m(), k("span", So)) : B("", !0),
962
+ u("span", Co, [
963
+ u("span", Ro, y(C.name), 1),
964
+ u("strong", {
965
+ class: G(["fm-typo-en-body-md-600 whitespace-nowrap px-8 text-fm-color-typo-primary", C.status === "shortage" ? "!text-fm-color-typo-error" : ""])
966
+ }, y(g(C.need, C.skuId, C.unit)), 3),
967
+ u("span", {
968
+ "data-testid": "production-run-ingredient-balance",
969
+ class: G(["fm-typo-en-body-sm-400 col-span-2 text-fm-color-typo-secondary", r.value ? "col-start-2" : "col-start-1"])
970
+ }, [
971
+ C.current === null || C.after === null ? (m(), k(ee, { key: 0 }, [
972
+ ue(y(i(lt)) + " · " + y(i(t)("inventory.production.run.form.commits.stockUnknown")), 1)
973
+ ], 64)) : C.status === "shortage" ? (m(), k(ee, { key: 1 }, [
974
+ ue(y(i(t)("inventory.production.run.form.items.columns.inStock")) + " " + y(g(C.current, C.skuId)) + " → ", 1),
975
+ u("strong", Ao, y(i(t)("inventory.production.run.form.commits.shortBy", {
976
+ amount: `−${g(Math.abs(C.after), C.skuId, C.unit)}`
977
+ })), 1)
978
+ ], 64)) : (m(), k(ee, { key: 2 }, [
979
+ ue(y(i(t)("inventory.production.run.form.items.columns.inStock")) + " " + y(g(C.current, C.skuId)) + " → " + y(g(C.after, C.skuId)) + " " + y(C.unit), 1)
980
+ ], 64))
981
+ ], 2),
982
+ C.displayContributors.length > 1 ? (m(), k("span", {
983
+ key: 0,
984
+ class: G(["fm-typo-en-body-sm-400 col-span-2 text-fm-color-typo-tertiary", r.value ? "col-start-2" : "col-start-1"])
985
+ }, y(i(t)("inventory.production.run.form.commits.across", {
986
+ count: C.displayContributors.length
987
+ })), 3)) : B("", !0)
988
+ ])
989
+ ]),
990
+ _: 2
991
+ }, 1032, ["type", "data-testid", "class", "aria-expanded", "onClick"])),
992
+ r.value && o.value.has(C.skuId) ? (m(), M(go, {
993
+ key: 0,
994
+ role: "group",
995
+ "item-role": "treeitem",
996
+ entries: L(C.displayContributors, C),
997
+ class: "ml-[40px] mr-[8px] mt-[8px]"
998
+ }, null, 8, ["entries"])) : B("", !0)
999
+ ], 8, Io))), 128)),
1000
+ w.value ? (m(), M(Ge, {
1001
+ key: 0,
1002
+ visible: i(_),
1003
+ testid: "production-run-ingredient-scroll-hint"
1004
+ }, null, 8, ["visible"])) : B("", !0)
1005
+ ], 42, $o)) : B("", !0),
1006
+ A.mode === "planner" && !A.noItems ? (m(), k("footer", Fo, [
1007
+ E(x, {
1008
+ name: "info",
1009
+ size: "sm",
1010
+ outline: "",
1011
+ class: "!size-[14px] shrink-0"
1012
+ }),
1013
+ u("span", null, y(i(t)("inventory.production.run.detail.draft.stockTiming")), 1)
1014
+ ])) : B("", !0)
1015
+ ], 10, ko);
1016
+ };
1017
+ }
1018
+ }), Po = {
1019
+ key: 0,
1020
+ "data-testid": "production-run-instructions",
1021
+ class: "overflow-hidden border border-fm-color-border-default bg-fm-color-surface-primary fm-corner-radius-md"
1022
+ }, Bo = { class: "px-16 py-12" }, Vo = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Eo = {
1023
+ "data-testid": "production-run-instructions-body",
1024
+ class: "border-t border-fm-color-border-default px-16 py-12 fm-typo-en-body-md-400 whitespace-pre-wrap break-words text-fm-color-typo-primary"
1025
+ }, Do = /* @__PURE__ */ Y({
1026
+ __name: "ProductionRunInstructionsCard",
1027
+ props: {
1028
+ instructions: {}
1029
+ },
1030
+ setup(s) {
1031
+ const e = s, { t } = de(), l = S(() => {
1032
+ var o;
1033
+ return ((o = e.instructions) == null ? void 0 : o.trim()) || null;
1034
+ });
1035
+ return (o, r) => l.value ? (m(), k("section", Po, [
1036
+ u("header", Bo, [
1037
+ u("h2", Vo, y(i(t)("inventory.production.run.form.instructions")), 1)
1038
+ ]),
1039
+ u("p", Eo, y(l.value), 1)
1040
+ ])) : B("", !0);
1041
+ }
1042
+ }), Lo = ["data-testid", "aria-controls", "aria-expanded"], qo = /* @__PURE__ */ Y({
1043
+ inheritAttrs: !1,
1044
+ __name: "ProductionRunCompactDisclosure",
1045
+ props: {
1046
+ expanded: { type: Boolean },
1047
+ controls: {},
1048
+ label: {},
1049
+ testid: {}
1050
+ },
1051
+ emits: ["toggle"],
1052
+ setup(s) {
1053
+ return (e, t) => {
1054
+ const l = Z("FmIcon");
1055
+ return m(), k("button", Je(e.$attrs, {
1056
+ type: "button",
1057
+ "data-testid": e.testid,
1058
+ class: "production-run-compact-disclosure inline-flex min-h-24 items-center gap-[2px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
1059
+ "aria-controls": e.controls,
1060
+ "aria-expanded": e.expanded,
1061
+ onClick: t[0] || (t[0] = (o) => e.$emit("toggle"))
1062
+ }), [
1063
+ E(l, {
1064
+ name: "chevron_right",
1065
+ size: "sm",
1066
+ "aria-hidden": "true",
1067
+ class: G(["!size-12 shrink-0 !text-[12px] !leading-[12px] transition-transform", e.expanded && "rotate-90"])
1068
+ }, null, 8, ["class"]),
1069
+ ue(" " + y(e.label), 1)
1070
+ ], 16, Lo);
1071
+ };
1072
+ }
1073
+ }), yt = /* @__PURE__ */ Y({
1074
+ __name: "ProductionRunBindingsDisclosure",
1075
+ props: {
1076
+ count: {},
1077
+ controls: {},
1078
+ expanded: { type: Boolean },
1079
+ testid: {}
1080
+ },
1081
+ emits: ["toggle"],
1082
+ setup(s, { emit: e }) {
1083
+ const t = e, { t: l } = de();
1084
+ return (o, r) => (m(), M(qo, {
1085
+ testid: o.testid,
1086
+ class: "w-fit rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-fm-color-primary",
1087
+ controls: o.controls,
1088
+ expanded: o.expanded,
1089
+ label: i(l)("inventory.production.run.form.bindings.count", { count: o.count }),
1090
+ onToggle: r[0] || (r[0] = (c) => t("toggle"))
1091
+ }, null, 8, ["testid", "controls", "expanded", "label"]));
1092
+ }
1093
+ }), To = ["id", "data-testid"], No = {
1094
+ key: 0,
1095
+ class: "mb-4 fm-typo-en-body-sm-600 text-fm-color-typo-secondary"
1096
+ }, Oo = ["aria-label"], Mo = ["title"], jo = { class: "shrink-0 tabular-nums text-fm-color-typo-secondary" }, Ho = /* @__PURE__ */ Y({
1097
+ __name: "ProductionRunBindingsList",
1098
+ props: {
1099
+ id: {},
1100
+ count: {},
1101
+ unit: {},
1102
+ lines: {},
1103
+ itemName: {},
1104
+ testid: {},
1105
+ showHeading: { type: Boolean, default: !0 }
1106
+ },
1107
+ setup(s) {
1108
+ const { t: e } = de();
1109
+ return (t, l) => (m(), k("div", {
1110
+ id: t.id,
1111
+ "data-testid": t.testid
1112
+ }, [
1113
+ t.showHeading ? (m(), k("p", No, y(i(e)("inventory.production.run.form.bindings.perBaseUnit", { unit: t.unit })), 1)) : B("", !0),
1114
+ u("ul", {
1115
+ class: "production-run-bindings-list grid grid-cols-2 gap-x-24 gap-y-4 rounded-md bg-fm-color-neutral-gray-100 px-12 py-8",
1116
+ "aria-label": `${i(e)("inventory.production.run.form.bindings.count", { count: t.count })}: ${t.itemName}`
1117
+ }, [
1118
+ (m(!0), k(ee, null, pe(t.lines, (o) => (m(), k("li", {
1119
+ key: o.id,
1120
+ class: "fm-typo-en-body-sm-400 flex min-w-0 items-center justify-between gap-12"
1121
+ }, [
1122
+ u("span", {
1123
+ class: "truncate",
1124
+ title: o.name
1125
+ }, y(o.name), 9, Mo),
1126
+ u("span", jo, y(i(fe)(o.amount, o.unit)), 1)
1127
+ ]))), 128))
1128
+ ], 8, Oo)
1129
+ ], 8, To));
1130
+ }
1131
+ }), bt = /* @__PURE__ */ Ie(Ho, [["__scopeId", "data-v-eb324d63"]]);
1132
+ function zo() {
1133
+ const s = N(!1), e = N(!1), t = N(!1), l = S(() => s.value || e.value), o = S(() => l.value || t.value);
1134
+ function r() {
1135
+ s.value = !0;
1136
+ }
1137
+ function c() {
1138
+ s.value = !1;
1139
+ }
1140
+ function a() {
1141
+ e.value = !0;
1142
+ }
1143
+ function n() {
1144
+ e.value = !1;
1145
+ }
1146
+ function f() {
1147
+ s.value = !1, e.value = !1;
1148
+ }
1149
+ function w() {
1150
+ f(), t.value = !1;
1151
+ }
1152
+ function U() {
1153
+ t.value = !t.value;
1154
+ }
1155
+ function _(b) {
1156
+ b || w();
1157
+ }
1158
+ return {
1159
+ hovered: s,
1160
+ focused: e,
1161
+ pinned: t,
1162
+ transientOpen: l,
1163
+ open: o,
1164
+ enterTrigger: r,
1165
+ leaveTrigger: c,
1166
+ focusTrigger: a,
1167
+ blurTrigger: n,
1168
+ dismissTransient: f,
1169
+ dismiss: w,
1170
+ togglePinned: U,
1171
+ onPopoverChanged: _
1172
+ };
1173
+ }
1174
+ const Ko = [
1175
+ "a[href]",
1176
+ "button:not([disabled])",
1177
+ "input:not([disabled])",
1178
+ "select:not([disabled])",
1179
+ "textarea:not([disabled])",
1180
+ '[tabindex]:not([tabindex="-1"])'
1181
+ ].join(","), St = ".fm-dialog,.fm-side-sheet";
1182
+ function gt(s) {
1183
+ return [...s.querySelectorAll(Ko)].filter((e) => e.offsetParent === null && e !== document.activeElement ? !1 : e.getAttribute("aria-hidden") !== "true");
1184
+ }
1185
+ function ze(s) {
1186
+ return (s == null ? void 0 : s.closest(St)) ?? s;
1187
+ }
1188
+ function ht(s) {
1189
+ const e = [...document.querySelectorAll(St)];
1190
+ return e.length === 0 || e[e.length - 1] === s;
1191
+ }
1192
+ const Qo = 4, Qe = [];
1193
+ typeof document < "u" && document.addEventListener(
1194
+ "focusin",
1195
+ (s) => {
1196
+ const e = s.target;
1197
+ !e || e === document.body || Qe[0] === e || (Qe.unshift(e), Qe.length = Math.min(Qe.length, Qo));
1198
+ },
1199
+ !0
1200
+ );
1201
+ function Ct(s, e) {
1202
+ const t = N(null);
1203
+ let l = [];
1204
+ function o(n) {
1205
+ const f = e === void 0 ? null : Ze(e);
1206
+ return typeof f == "string" ? n.querySelector(f) : f && n.contains(f) ? f : null;
1207
+ }
1208
+ function r(n) {
1209
+ var w;
1210
+ const f = o(n);
1211
+ f == null || f.focus(), !(f && document.activeElement === f) && ((w = gt(n)[0]) == null || w.focus());
1212
+ }
1213
+ function c(n) {
1214
+ const f = ze(t.value);
1215
+ if (n.key !== "Tab" || !f || !ht(f)) return;
1216
+ const w = gt(f);
1217
+ if (!w.length) {
1218
+ n.preventDefault();
1219
+ return;
1220
+ }
1221
+ const U = w[0], _ = w[w.length - 1], b = document.activeElement;
1222
+ if (!b || !f.contains(b)) {
1223
+ n.preventDefault(), U.focus();
1224
+ return;
1225
+ }
1226
+ n.shiftKey && b === U ? (n.preventDefault(), _.focus()) : !n.shiftKey && b === _ && (n.preventDefault(), U.focus());
1227
+ }
1228
+ function a(n) {
1229
+ const f = ze(t.value);
1230
+ if (!f || !ht(f)) return;
1231
+ const w = n.target;
1232
+ !w || f.contains(w) || r(f);
1233
+ }
1234
+ return Pt(() => {
1235
+ l = [...Qe];
1236
+ }), Te(() => {
1237
+ Bt(() => {
1238
+ const n = ze(t.value);
1239
+ if (!n) return;
1240
+ n.getAttribute("role") || n.setAttribute("role", "dialog"), n.getAttribute("aria-modal") || n.setAttribute("aria-modal", "true");
1241
+ const f = s === void 0 ? "" : Ze(s);
1242
+ f && !n.getAttribute("aria-labelledby") && n.setAttribute("aria-label", f);
1243
+ }), document.addEventListener("keydown", c, !0), document.addEventListener("focusin", a, !0), requestAnimationFrame(() => {
1244
+ const n = ze(t.value);
1245
+ n && r(n);
1246
+ });
1247
+ }), We(() => {
1248
+ var w, U;
1249
+ document.removeEventListener("keydown", c, !0), document.removeEventListener("focusin", a, !0);
1250
+ const n = document.activeElement;
1251
+ (!n || n === document.body || (w = ze(t.value)) != null && w.contains(n)) && ((U = l.find((_) => _.isConnected)) == null || U.focus());
1252
+ }), { container: t };
1253
+ }
1254
+ const Go = ["id"], Wo = ["id"], Jo = ["aria-label"], Yo = { class: "production-run-dialog-footer flex w-full items-center justify-end gap-8" }, Xo = /* @__PURE__ */ Y({
1255
+ inheritAttrs: !1,
1256
+ __name: "ProductionRunDialogSurface",
1257
+ props: {
1258
+ modelValue: { type: Boolean },
1259
+ title: {},
1260
+ description: {},
1261
+ notice: {},
1262
+ closeLabel: {},
1263
+ maxWidth: {},
1264
+ hideClose: { type: Boolean },
1265
+ mobileInset: { type: Boolean },
1266
+ dismissAway: { type: Boolean },
1267
+ role: {},
1268
+ initialFocus: {},
1269
+ variant: {},
1270
+ footerDivider: { type: Boolean },
1271
+ titleId: {},
1272
+ descriptionId: {},
1273
+ rootAttrs: {}
1274
+ },
1275
+ emits: ["update:modelValue"],
1276
+ setup(s, { emit: e }) {
1277
+ const t = s, l = e, { container: o } = Ct(
1278
+ () => t.title,
1279
+ () => t.initialFocus
1280
+ ), r = S(() => ({
1281
+ ...t.rootAttrs,
1282
+ class: [
1283
+ t.mobileInset ? "production-run-dialog production-run-dialog--mobile-inset" : "production-run-dialog",
1284
+ t.variant === "compact-confirmation" && "production-run-dialog--compact-confirmation",
1285
+ t.variant === "confirmation" && "production-run-dialog--confirmation",
1286
+ t.footerDivider === !1 && "production-run-dialog--footer-dividerless",
1287
+ t.rootAttrs.class
1288
+ ],
1289
+ role: t.role ?? "dialog",
1290
+ "aria-modal": "true",
1291
+ "aria-labelledby": t.titleId,
1292
+ ...t.description ? { "aria-describedby": t.descriptionId } : {}
1293
+ }));
1294
+ function c() {
1295
+ var w;
1296
+ const n = (w = o.value) == null ? void 0 : w.closest(".fm-dialog");
1297
+ return n ? [...document.querySelectorAll(".fm-dialog,.fm-side-sheet")].at(-1) === n : !1;
1298
+ }
1299
+ function a(n) {
1300
+ n.key !== "Escape" || !c() || (n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation(), n.type === "keyup" && l("update:modelValue", !1));
1301
+ }
1302
+ return Te(() => {
1303
+ window.addEventListener("keydown", a, !0), window.addEventListener("keyup", a, !0);
1304
+ }), We(() => {
1305
+ window.removeEventListener("keydown", a, !0), window.removeEventListener("keyup", a, !0);
1306
+ }), (n, f) => {
1307
+ const w = Z("FmIcon"), U = Z("FmDialog");
1308
+ return m(), M(U, {
1309
+ "model-value": n.modelValue,
1310
+ "close-button": !1,
1311
+ "dismiss-away": n.dismissAway,
1312
+ "max-width": n.maxWidth,
1313
+ "max-height": "calc(100dvh - 32px)",
1314
+ "is-component-props": r.value,
1315
+ "onUpdate:modelValue": f[1] || (f[1] = (_) => l("update:modelValue", _))
1316
+ }, {
1317
+ "dialog-header": H(() => [
1318
+ u("div", {
1319
+ ref_key: "trap",
1320
+ ref: o,
1321
+ class: "flex w-full min-w-0 items-start justify-between gap-0"
1322
+ }, [
1323
+ u("div", {
1324
+ class: G(["flex min-w-0 flex-col", n.variant === "confirmation" ? "gap-8" : "gap-4"])
1325
+ }, [
1326
+ u("h2", {
1327
+ id: n.titleId,
1328
+ class: G(["production-run-dialog-title whitespace-normal font-semibold leading-[28px]", n.variant === "confirmation" ? "text-[20px]" : "text-[18px]"])
1329
+ }, y(n.title), 11, Go),
1330
+ n.description ? (m(), k("p", {
1331
+ key: 0,
1332
+ id: n.descriptionId,
1333
+ class: "text-[14px] font-normal leading-[20px] text-fm-color-typo-secondary"
1334
+ }, y(n.description), 9, Wo)) : B("", !0)
1335
+ ], 2),
1336
+ n.hideClose ? B("", !0) : (m(), k("button", {
1337
+ key: 0,
1338
+ type: "button",
1339
+ class: "production-run-dialog-close inline-grid size-32 shrink-0 place-items-center rounded-full text-fm-color-typo-primary hover:bg-fm-color-opacity-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-fm-color-border-focused",
1340
+ "aria-label": n.closeLabel,
1341
+ onClick: f[0] || (f[0] = (_) => l("update:modelValue", !1))
1342
+ }, [
1343
+ E(w, {
1344
+ name: "close",
1345
+ size: "sm",
1346
+ "aria-hidden": "true"
1347
+ })
1348
+ ], 8, Jo))
1349
+ ], 512)
1350
+ ]),
1351
+ "dialog-footer": H(() => [
1352
+ u("div", Yo, [
1353
+ se(n.$slots, "footer")
1354
+ ])
1355
+ ]),
1356
+ default: H(() => [
1357
+ se(n.$slots, "default")
1358
+ ]),
1359
+ _: 3
1360
+ }, 8, ["model-value", "dismiss-away", "max-width", "is-component-props"]);
1361
+ };
1362
+ }
1363
+ }), Zo = {
1364
+ key: 0,
1365
+ role: "status",
1366
+ "aria-live": "polite",
1367
+ "aria-atomic": "true",
1368
+ class: "production-run-dialog-notice flex shrink-0 items-start gap-8 border-y border-fm-color-neutral-gray-200 bg-fm-color-system-info-100 py-12 text-fm-color-typo-primary"
1369
+ }, en = {
1370
+ "aria-hidden": "true",
1371
+ class: "production-run-dialog-notice-icon flex h-[20px] w-[16px] shrink-0 items-center justify-center text-fm-color-typo-info"
1372
+ }, tn = { class: "production-run-dialog-notice-copy text-[14px] font-normal leading-[20px]" };
1373
+ let on = 0;
1374
+ const rt = /* @__PURE__ */ Y({
1375
+ inheritAttrs: !1,
1376
+ __name: "ProductionRunDialog",
1377
+ props: {
1378
+ modelValue: { type: Boolean },
1379
+ title: {},
1380
+ description: {},
1381
+ notice: {},
1382
+ closeLabel: {},
1383
+ maxWidth: {},
1384
+ hideClose: { type: Boolean },
1385
+ mobileInset: { type: Boolean },
1386
+ dismissAway: { type: Boolean },
1387
+ role: {},
1388
+ initialFocus: {},
1389
+ variant: {},
1390
+ footerDivider: { type: Boolean }
1391
+ },
1392
+ emits: ["update:modelValue"],
1393
+ setup(s, { emit: e }) {
1394
+ const t = ot(), l = e, o = ++on, r = `production-run-dialog-title-${o}`, c = `production-run-dialog-description-${o}`;
1395
+ return (a, n) => {
1396
+ const f = Z("FmIcon");
1397
+ return a.modelValue ? (m(), M(Xo, {
1398
+ key: 0,
1399
+ "model-value": !0,
1400
+ title: a.title,
1401
+ description: a.description,
1402
+ "close-label": a.closeLabel,
1403
+ "max-width": a.maxWidth,
1404
+ "hide-close": a.hideClose,
1405
+ "mobile-inset": a.mobileInset,
1406
+ "dismiss-away": a.dismissAway,
1407
+ role: a.role,
1408
+ "initial-focus": a.initialFocus,
1409
+ variant: a.variant,
1410
+ "footer-divider": a.footerDivider,
1411
+ "title-id": r,
1412
+ "description-id": c,
1413
+ "root-attrs": i(t),
1414
+ "onUpdate:modelValue": n[0] || (n[0] = (w) => l("update:modelValue", w))
1415
+ }, {
1416
+ footer: H(() => [
1417
+ se(a.$slots, "footer")
1418
+ ]),
1419
+ default: H(() => [
1420
+ u("div", {
1421
+ class: G([
1422
+ "production-run-dialog-content",
1423
+ a.variant === "compact-confirmation" ? "production-run-dialog-content--compact-confirmation" : a.variant === "confirmation" ? "production-run-dialog-content--confirmation" : "production-run-dialog-content--standard"
1424
+ ])
1425
+ }, [
1426
+ a.notice ? (m(), k("div", Zo, [
1427
+ u("span", en, [
1428
+ E(f, {
1429
+ name: "info",
1430
+ size: "sm",
1431
+ outline: "",
1432
+ class: "!text-[16px] !leading-[16px]",
1433
+ "aria-hidden": "true"
1434
+ })
1435
+ ]),
1436
+ u("span", tn, y(a.notice), 1)
1437
+ ])) : B("", !0),
1438
+ se(a.$slots, "default")
1439
+ ], 2)
1440
+ ]),
1441
+ _: 3
1442
+ }, 8, ["title", "description", "close-label", "max-width", "hide-close", "mobile-inset", "dismiss-away", "role", "initial-focus", "variant", "footer-divider", "root-attrs"])) : B("", !0);
1443
+ };
1444
+ }
1445
+ }), nn = ["aria-label", "aria-expanded"], rn = {
1446
+ "data-testid": "production-no-bindings-tooltip",
1447
+ role: "tooltip",
1448
+ class: "w-[min(352px,calc(100vw-16px))] rounded-8 border border-fm-color-line bg-fm-color-surface-default p-12 text-[14px] leading-[20px] font-normal text-fm-color-typo-primary shadow-light-300"
1449
+ }, sn = { class: "flex flex-col gap-12 pb-4" }, an = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, ln = { class: "flex flex-col gap-8" }, un = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" }, dn = { class: "fm-typo-en-body-md-400 list-decimal space-y-4 pl-[20px] text-fm-color-typo-primary" };
1450
+ let cn = 0;
1451
+ const tt = /* @__PURE__ */ Y({
1452
+ __name: "ProductionRunNoBindingsHelp",
1453
+ props: {
1454
+ itemName: {}
1455
+ },
1456
+ setup(s) {
1457
+ const { t: e } = de(), t = N(null), l = `production-no-bindings-description-${++cn}`, {
1458
+ transientOpen: o,
1459
+ enterTrigger: r,
1460
+ leaveTrigger: c,
1461
+ focusTrigger: a,
1462
+ blurTrigger: n,
1463
+ dismissTransient: f
1464
+ } = zo(), w = N(!1), U = N(!1), _ = S(
1465
+ () => !U.value && !w.value && o.value
1466
+ ), b = ["open", "item", "convertible", "link", "save", "return"];
1467
+ function R() {
1468
+ f(), w.value = !0, U.value = !0;
1469
+ }
1470
+ function T() {
1471
+ w.value = !1, r();
1472
+ }
1473
+ function z() {
1474
+ c(), U.value || (w.value = !1);
1475
+ }
1476
+ function D() {
1477
+ n(), U.value || (w.value = !1);
1478
+ }
1479
+ function g(J) {
1480
+ J || (f(), U.value || (w.value = !1));
1481
+ }
1482
+ function te(J) {
1483
+ U.value = J;
1484
+ }
1485
+ return (J, L) => {
1486
+ const q = Z("FmIcon"), A = Z("FmPopover"), j = Z("FmButton");
1487
+ return m(), k(ee, null, [
1488
+ E(A, {
1489
+ class: "flex w-fit",
1490
+ "z-index": 1100,
1491
+ "show-popover": _.value,
1492
+ placement: "bottom-start",
1493
+ onPopoverChanged: g
1494
+ }, {
1495
+ "popover-button": H(() => [
1496
+ u("button", {
1497
+ ref_key: "trigger",
1498
+ ref: t,
1499
+ type: "button",
1500
+ "data-no-bindings": "",
1501
+ "data-testid": "production-no-bindings-help",
1502
+ class: "flex w-fit items-center gap-4 whitespace-nowrap text-[12px] leading-[16px] text-fm-color-typo-error focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-fm-color-border-focused",
1503
+ "aria-label": i(e)("inventory.production.run.form.bindings.noneHelp.show"),
1504
+ "aria-describedby": l,
1505
+ "aria-expanded": U.value,
1506
+ "aria-haspopup": "dialog",
1507
+ onMouseenter: T,
1508
+ onMouseleave: z,
1509
+ onFocus: L[0] || (L[0] = //@ts-ignore
1510
+ (...x) => i(a) && i(a)(...x)),
1511
+ onBlur: D,
1512
+ onClick: Ae(R, ["stop"])
1513
+ }, [
1514
+ ue(y(i(e)("inventory.production.run.form.bindings.noneHelp.label")) + " ", 1),
1515
+ E(q, {
1516
+ name: "error_outline",
1517
+ size: "sm",
1518
+ class: "!size-12 !text-[12px] !leading-[12px]",
1519
+ "aria-hidden": "true"
1520
+ }),
1521
+ u("span", {
1522
+ id: l,
1523
+ class: "sr-only"
1524
+ }, y(i(e)("inventory.production.run.form.bindings.noneHelp.tooltip")), 1)
1525
+ ], 40, nn)
1526
+ ]),
1527
+ default: H(() => [
1528
+ u("div", rn, y(i(e)("inventory.production.run.form.bindings.noneHelp.tooltip")), 1)
1529
+ ]),
1530
+ _: 1
1531
+ }, 8, ["show-popover"]),
1532
+ E(rt, {
1533
+ "model-value": U.value,
1534
+ "mobile-inset": "",
1535
+ title: i(e)("inventory.production.run.form.bindings.noneHelp.title"),
1536
+ description: J.itemName,
1537
+ "close-label": i(e)("inventory.production.run.form.bindings.noneHelp.close"),
1538
+ "max-width": "448px",
1539
+ "footer-divider": !1,
1540
+ "initial-focus": "[data-testid='production-no-bindings-got-it']",
1541
+ "onUpdate:modelValue": te
1542
+ }, {
1543
+ footer: H(() => [
1544
+ E(j, {
1545
+ "data-testid": "production-no-bindings-got-it",
1546
+ variant: "secondary",
1547
+ label: i(e)("inventory.production.run.form.bindings.noneHelp.gotIt"),
1548
+ onClick: L[1] || (L[1] = (x) => te(!1))
1549
+ }, null, 8, ["label"])
1550
+ ]),
1551
+ default: H(() => [
1552
+ u("div", sn, [
1553
+ u("p", an, y(i(e)("inventory.production.run.form.bindings.noneHelp.body")), 1),
1554
+ u("div", ln, [
1555
+ u("p", un, y(i(e)("inventory.production.run.form.bindings.noneHelp.stepsTitle")), 1),
1556
+ u("ol", dn, [
1557
+ (m(), k(ee, null, pe(b, (x) => u("li", { key: x }, y(i(e)(`inventory.production.run.form.bindings.noneHelp.steps.${x}`)), 1)), 64))
1558
+ ])
1559
+ ])
1560
+ ])
1561
+ ]),
1562
+ _: 1
1563
+ }, 8, ["model-value", "title", "description", "close-label"])
1564
+ ], 64);
1565
+ };
1566
+ }
1567
+ }), mn = ["data-unit-resolved"], pn = {
1568
+ key: 0,
1569
+ "aria-hidden": "true",
1570
+ class: "mt-4 block min-h-16 w-full"
1571
+ }, fn = /* @__PURE__ */ Y({
1572
+ inheritAttrs: !1,
1573
+ __name: "ProductionRunUnitInput",
1574
+ props: {
1575
+ modelValue: {},
1576
+ unit: {},
1577
+ disableUnit: { type: Boolean },
1578
+ disabled: { type: Boolean },
1579
+ label: {},
1580
+ ariaLabel: {},
1581
+ compact: { type: Boolean },
1582
+ reserveConversionSpace: { type: Boolean }
1583
+ },
1584
+ emits: ["update:modelValue"],
1585
+ setup(s, { emit: e }) {
1586
+ const t = s, l = e, { t: o } = de(), r = ot(), c = S(
1587
+ () => !!t.modelValue.measurement && ge(t.modelValue.measurement, t.unit)
1588
+ ), a = S(
1589
+ () => {
1590
+ var b;
1591
+ return c.value && ((b = t.modelValue.measurement) == null ? void 0 : b.id) !== t.unit._id;
1592
+ }
1593
+ ), n = S(() => c.value ? t.unit : {
1594
+ ...t.unit,
1595
+ _id: `${t.unit._id}__production_run_unresolved`,
1596
+ abbrev: o("inventory.production.run.form.duplicate.chooseOriginalUnitPlaceholder"),
1597
+ measurements: [
1598
+ {
1599
+ id: t.unit._id,
1600
+ name: t.unit.name,
1601
+ abbrev: t.unit.abbrev,
1602
+ conversion: Le(t.unit).conversion
1603
+ },
1604
+ ...t.unit.measurements
1605
+ ]
1606
+ }), f = S(() => {
1607
+ var b;
1608
+ return {
1609
+ amount: t.modelValue.amount,
1610
+ measurement: !c.value || ((b = t.modelValue.measurement) == null ? void 0 : b.id) === t.unit._id ? null : t.modelValue.measurement
1611
+ };
1612
+ });
1613
+ let w = t.modelValue.amount;
1614
+ ke(
1615
+ () => t.modelValue.amount,
1616
+ (b) => {
1617
+ w = b;
1618
+ }
1619
+ );
1620
+ function U(b) {
1621
+ w = b.amount, l("update:modelValue", {
1622
+ amount: b.amount,
1623
+ // Editing the number is not an implicit unit choice.
1624
+ measurement: t.modelValue.measurement
1625
+ });
1626
+ }
1627
+ function _(b) {
1628
+ if (!b && !c.value) return;
1629
+ const R = b && b.id !== t.unit._id ? $t(t.unit, b) : Le(t.unit);
1630
+ l("update:modelValue", { amount: w, measurement: R });
1631
+ }
1632
+ return (b, R) => (m(), k("div", {
1633
+ class: G(["production-run-unit-input flex flex-col items-end", [
1634
+ b.compact && "production-run-unit-input--compact",
1635
+ b.reserveConversionSpace && "production-run-unit-input--reserve-conversion",
1636
+ !b.reserveConversionSpace && "gap-2"
1637
+ ]]),
1638
+ "data-unit-resolved": c.value
1639
+ }, [
1640
+ E(Ht, Je(i(r), {
1641
+ class: "w-full",
1642
+ "model-value": f.value,
1643
+ unit: n.value,
1644
+ "disable-unit": b.disableUnit,
1645
+ disabled: b.disabled,
1646
+ label: b.label,
1647
+ "aria-label": b.ariaLabel,
1648
+ "aria-invalid": !c.value,
1649
+ "immediate-model-update": "",
1650
+ "onUpdate:modelValue": U,
1651
+ "onUpdate:measurement": _
1652
+ }), null, 16, ["model-value", "unit", "disable-unit", "disabled", "label", "aria-label", "aria-invalid"]),
1653
+ b.reserveConversionSpace && !a.value ? (m(), k("span", pn)) : B("", !0),
1654
+ !c.value && !b.disabled ? (m(), k("span", {
1655
+ key: 1,
1656
+ role: "alert",
1657
+ class: G(["fm-typo-en-body-sm-400 text-fm-color-typo-error", b.reserveConversionSpace && "mt-2"])
1658
+ }, y(i(o)("inventory.production.run.form.items.unitRequired")), 3)) : B("", !0)
1659
+ ], 10, mn));
1660
+ }
1661
+ }), vn = /* @__PURE__ */ Ie(fn, [["__scopeId", "data-v-6cde3541"]]), yn = ["aria-label"], bn = { class: "production-run-plan-header flex flex-wrap items-center justify-between gap-8 px-12 py-12" }, gn = { class: "text-[16px] font-semibold leading-[24px] whitespace-nowrap text-fm-color-typo-primary" }, hn = {
1662
+ key: 0,
1663
+ class: "production-run-plan-actions flex items-center gap-4"
1664
+ }, kn = { class: "w-[220px] bg-white p-4" }, _n = {
1665
+ "data-testid": "production-run-duplicate-menu-label",
1666
+ class: "fm-typo-en-body-md-400"
1667
+ }, xn = {
1668
+ "data-testid": "production-run-clear-menu-label",
1669
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-error"
1670
+ }, wn = {
1671
+ key: 0,
1672
+ "data-testid": "production-run-empty-state",
1673
+ class: "production-run-empty-state flex min-h-0 flex-1 flex-col items-center justify-center gap-8 px-16 py-16 text-center"
1674
+ }, $n = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, In = { class: "fm-typo-en-body-md-400 max-w-[40ch] text-fm-color-typo-secondary" }, Sn = {
1675
+ key: 0,
1676
+ "data-testid": "empty-production-run-actions",
1677
+ class: "production-run-empty-actions mt-8 flex max-w-full flex-wrap items-center justify-center gap-8"
1678
+ }, Cn = ["aria-label"], Rn = {
1679
+ "data-testid": "production-run-plan-readonly-table",
1680
+ class: "w-full min-w-[40rem] table-fixed"
1681
+ }, An = { class: "fm-typo-en-body-sm-600 bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary" }, Fn = { class: "px-16 py-8 text-left" }, Un = { class: "px-16 py-8 text-center" }, Pn = { class: "whitespace-nowrap px-16 py-8 text-center" }, Bn = {
1682
+ "data-testid": "production-run-plan-readonly-row",
1683
+ class: "border-t border-fm-color-neutral-gray-200 first:border-t-0"
1684
+ }, Vn = { class: "max-w-64 px-16 py-12 align-top" }, En = ["title"], Dn = {
1685
+ "data-testid": "production-run-on-hand",
1686
+ class: "fm-typo-en-body-md-400 whitespace-nowrap px-16 py-12 text-center align-top tabular-nums text-fm-color-typo-secondary"
1687
+ }, Ln = { class: "fm-typo-en-body-md-600 whitespace-nowrap px-16 py-12 text-center align-top tabular-nums text-fm-color-typo-primary" }, qn = { class: "block" }, Tn = ["aria-hidden"], Nn = { key: 0 }, On = {
1688
+ colspan: "3",
1689
+ class: "px-16 pb-12"
1690
+ }, Mn = {
1691
+ "data-testid": "production-run-plan-columns",
1692
+ class: "fm-typo-en-body-sm-600 grid min-h-40 shrink-0 grid-cols-[minmax(0,1fr)_144px_176px_40px] items-center border-y border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary xs:hidden"
1693
+ }, jn = { class: "px-16 py-8" }, Hn = { class: "px-16 py-8 text-center" }, zn = { class: "px-8 py-8" }, Kn = {
1694
+ "data-testid": "production-run-plan-row",
1695
+ class: "production-run-plan-row grid min-h-72 grid-cols-[minmax(0,1fr)_144px_176px_40px] items-center gap-y-8"
1696
+ }, Qn = { class: "production-run-plan-identity flex min-w-0 flex-col gap-4 px-16 py-12" }, Gn = { class: "production-run-plan-item-name fm-typo-en-body-md-600 line-clamp-1 text-fm-color-typo-primary" }, Wn = {
1697
+ "data-testid": "production-run-on-hand",
1698
+ class: "production-run-plan-stock mb-[20px] justify-self-center whitespace-nowrap px-8 py-12 fm-typo-en-body-md-400 text-fm-color-typo-secondary xs:mb-0"
1699
+ }, Jn = { class: "hidden xs:inline" }, Yn = { class: "production-run-plan-quantity flex min-w-0 flex-col gap-4 px-8 py-12" }, Xn = { class: "fm-typo-en-body-sm-400 hidden text-fm-color-typo-secondary xs:block" }, Zn = {
1700
+ key: 0,
1701
+ class: "flex shrink-0 justify-end border-t border-fm-color-neutral-gray-200 px-16 py-8"
1702
+ }, er = /* @__PURE__ */ Y({
1703
+ __name: "ProductionRunPlanCard",
1704
+ props: {
1705
+ items: {},
1706
+ editable: { type: Boolean, default: !0 },
1707
+ canDuplicate: { type: Boolean, default: !1 }
1708
+ },
1709
+ emits: ["add", "duplicate", "clear", "remove", "update:item"],
1710
+ setup(s, { emit: e }) {
1711
+ const t = s, l = e, { t: o } = de(), r = S(() => t.items.length === 0), c = N(/* @__PURE__ */ new Set()), a = N(/* @__PURE__ */ new Set()), {
1712
+ scroller: n,
1713
+ canScrollFurther: f,
1714
+ onScroll: w
1715
+ } = nt(() => t.editable && !r.value);
1716
+ function U(b) {
1717
+ const R = new Set(c.value);
1718
+ R.has(b) ? R.delete(b) : R.add(b), c.value = R;
1719
+ }
1720
+ function _(b) {
1721
+ const R = new Set(a.value);
1722
+ R.has(b) ? R.delete(b) : R.add(b), a.value = R;
1723
+ }
1724
+ return (b, R) => {
1725
+ const T = Z("FmButton"), z = Z("FmMenuItem"), D = Z("FmMenu");
1726
+ return m(), k("section", {
1727
+ "data-testid": "production-run-plan-card",
1728
+ class: G(["fm-corner-radius-md flex min-w-0 flex-col overflow-hidden border border-fm-color-neutral-gray-200", { "h-[232px]": r.value, "max-h-[60dvh]": b.editable }]),
1729
+ "aria-label": `${i(o)("inventory.production.run.form.items.title")} (${b.items.length})`
1730
+ }, [
1731
+ u("header", bn, [
1732
+ u("h3", gn, y(i(o)("inventory.production.run.form.items.title")) + " (" + y(b.items.length) + ") ", 1),
1733
+ b.editable && !r.value ? (m(), k("div", hn, [
1734
+ E(D, { trigger: "click" }, {
1735
+ "menu-button": H(() => [
1736
+ E(T, {
1737
+ "data-testid": "production-run-item-actions",
1738
+ variant: "tertiary",
1739
+ icon: "more_vert",
1740
+ size: "md",
1741
+ "aria-label": i(o)("inventory.production.run.form.items.more")
1742
+ }, null, 8, ["aria-label"])
1743
+ ]),
1744
+ default: H(() => [
1745
+ u("div", kn, [
1746
+ b.canDuplicate ? (m(), M(z, {
1747
+ key: 0,
1748
+ onClick: R[0] || (R[0] = (g) => l("duplicate"))
1749
+ }, {
1750
+ label: H(() => [
1751
+ u("span", _n, y(i(o)("inventory.production.run.form.duplicate.action")), 1)
1752
+ ]),
1753
+ _: 1
1754
+ })) : B("", !0),
1755
+ E(z, {
1756
+ onClick: R[1] || (R[1] = (g) => l("clear"))
1757
+ }, {
1758
+ label: H(() => [
1759
+ u("span", xn, y(i(o)("inventory.production.run.form.items.clearAll")), 1)
1760
+ ]),
1761
+ _: 1
1762
+ })
1763
+ ])
1764
+ ]),
1765
+ _: 1
1766
+ }),
1767
+ E(T, {
1768
+ "data-testid": "production-run-add-items",
1769
+ variant: "secondary",
1770
+ size: "md",
1771
+ "prepend-icon": "add",
1772
+ label: i(o)("inventory.production.run.form.items.add"),
1773
+ onClick: R[2] || (R[2] = (g) => l("add"))
1774
+ }, null, 8, ["label"])
1775
+ ])) : B("", !0)
1776
+ ]),
1777
+ r.value ? (m(), k("div", wn, [
1778
+ u("span", $n, y(i(o)("inventory.production.run.form.items.emptyTitle")), 1),
1779
+ u("span", In, y(i(o)("inventory.production.run.form.items.emptyDescription")), 1),
1780
+ b.editable ? (m(), k("div", Sn, [
1781
+ b.canDuplicate ? (m(), M(T, {
1782
+ key: 0,
1783
+ "data-testid": "production-run-duplicate-items",
1784
+ class: "shrink-0",
1785
+ variant: "secondary",
1786
+ size: "md",
1787
+ "prepend-icon": "content_copy",
1788
+ label: i(o)("inventory.production.run.form.duplicate.emptyAction"),
1789
+ onClick: R[3] || (R[3] = (g) => l("duplicate"))
1790
+ }, null, 8, ["label"])) : B("", !0),
1791
+ E(T, {
1792
+ "data-testid": "production-run-add-items",
1793
+ class: "shrink-0",
1794
+ size: "md",
1795
+ "prepend-icon": "add",
1796
+ label: i(o)("inventory.production.run.form.items.add"),
1797
+ onClick: R[4] || (R[4] = (g) => l("add"))
1798
+ }, null, 8, ["label"])
1799
+ ])) : B("", !0)
1800
+ ])) : b.editable ? (m(), k(ee, { key: 2 }, [
1801
+ u("div", Mn, [
1802
+ u("span", jn, y(i(o)("inventory.production.run.form.items.columns.item")), 1),
1803
+ u("span", Hn, y(i(o)("inventory.production.run.form.items.columns.inStock")), 1),
1804
+ u("span", zn, y(i(o)("inventory.production.run.form.items.columns.quantity")), 1),
1805
+ R[8] || (R[8] = u("span", null, null, -1))
1806
+ ]),
1807
+ u("div", {
1808
+ ref_key: "editableItemsScroll",
1809
+ ref: n,
1810
+ class: "flex min-h-0 flex-1 flex-col overflow-y-auto",
1811
+ onScroll: R[5] || (R[5] = //@ts-ignore
1812
+ (...g) => i(w) && i(w)(...g))
1813
+ }, [
1814
+ (m(!0), k(ee, null, pe(b.items, (g) => (m(), k("div", {
1815
+ key: g.key,
1816
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1817
+ }, [
1818
+ u("div", Kn, [
1819
+ u("div", Qn, [
1820
+ u("span", Gn, y(g.name), 1),
1821
+ g.bindingLines.length ? (m(), M(yt, {
1822
+ key: 0,
1823
+ count: g.bindingCount,
1824
+ controls: `production-run-plan-bindings-${g.key}`,
1825
+ expanded: c.value.has(g.key),
1826
+ testid: "production-run-item-bindings",
1827
+ onToggle: (te) => U(g.key)
1828
+ }, null, 8, ["count", "controls", "expanded", "onToggle"])) : (m(), M(tt, {
1829
+ key: 1,
1830
+ "item-name": g.name
1831
+ }, null, 8, ["item-name"]))
1832
+ ]),
1833
+ u("span", Wn, [
1834
+ u("span", Jn, y(i(o)("inventory.production.run.form.items.columns.inStock")) + " · ", 1),
1835
+ ue(" " + y(g.onHand === null ? i(lt) : i(fe)(g.onHand, g.baseUnit)), 1)
1836
+ ]),
1837
+ u("div", Yn, [
1838
+ u("span", Xn, y(i(o)("inventory.production.run.form.items.columns.quantity")), 1),
1839
+ b.editable ? (m(), M(vn, {
1840
+ key: 0,
1841
+ class: "w-full",
1842
+ compact: "",
1843
+ "reserve-conversion-space": "",
1844
+ "model-value": g.model,
1845
+ unit: g.sku.unit,
1846
+ "aria-label": i(o)("inventory.production.run.form.items.quantityLabel", { name: g.name }),
1847
+ "onUpdate:modelValue": (te) => l("update:item", g.key, te)
1848
+ }, null, 8, ["model-value", "unit", "aria-label", "onUpdate:modelValue"])) : B("", !0)
1849
+ ]),
1850
+ b.editable ? (m(), M(T, {
1851
+ key: 0,
1852
+ class: "production-run-plan-remove mb-[20px] xs:mb-0",
1853
+ variant: "tertiary",
1854
+ icon: "close",
1855
+ size: "md",
1856
+ "aria-label": i(o)("inventory.production.run.form.items.remove", { name: g.name }),
1857
+ onClick: (te) => l("remove", g.key)
1858
+ }, null, 8, ["aria-label", "onClick"])) : B("", !0)
1859
+ ]),
1860
+ c.value.has(g.key) ? (m(), M(bt, {
1861
+ key: 0,
1862
+ id: `production-run-plan-bindings-${g.key}`,
1863
+ testid: "production-run-plan-bindings-expanded",
1864
+ class: "px-16 pb-12 pt-8",
1865
+ count: g.bindingCount,
1866
+ unit: g.baseUnit,
1867
+ lines: g.bindingLines,
1868
+ "item-name": g.name
1869
+ }, null, 8, ["id", "count", "unit", "lines", "item-name"])) : B("", !0)
1870
+ ]))), 128)),
1871
+ E(Ge, {
1872
+ visible: i(f),
1873
+ testid: "production-run-plan-scroll-hint"
1874
+ }, null, 8, ["visible"])
1875
+ ], 544),
1876
+ b.editable ? (m(), k("footer", Zn, [
1877
+ E(T, {
1878
+ "data-testid": "production-run-plan-bottom-add",
1879
+ variant: "secondary",
1880
+ size: "md",
1881
+ "prepend-icon": "add",
1882
+ label: i(o)("inventory.production.run.form.items.add"),
1883
+ onClick: R[6] || (R[6] = (g) => l("add"))
1884
+ }, null, 8, ["label"])
1885
+ ])) : B("", !0)
1886
+ ], 64)) : (m(), k("div", {
1887
+ key: 1,
1888
+ "data-testid": "production-run-plan-readonly-scroll",
1889
+ class: "min-h-0 flex-1 overflow-x-auto",
1890
+ tabindex: "0",
1891
+ "aria-label": i(o)("inventory.production.run.form.items.title")
1892
+ }, [
1893
+ u("table", Rn, [
1894
+ R[7] || (R[7] = u("colgroup", null, [
1895
+ u("col"),
1896
+ u("col", { class: "w-[144px]" }),
1897
+ u("col", { class: "w-[144px]" })
1898
+ ], -1)),
1899
+ u("thead", null, [
1900
+ u("tr", An, [
1901
+ u("th", Fn, y(i(o)("inventory.production.run.form.items.columns.item")), 1),
1902
+ u("th", Un, y(i(o)("inventory.production.run.form.items.columns.inStock")), 1),
1903
+ u("th", Pn, y(i(o)("inventory.production.run.form.items.columns.quantity")), 1)
1904
+ ])
1905
+ ]),
1906
+ u("tbody", null, [
1907
+ (m(!0), k(ee, null, pe(b.items, (g) => (m(), k(ee, {
1908
+ key: g.key
1909
+ }, [
1910
+ u("tr", Bn, [
1911
+ u("td", Vn, [
1912
+ u("span", {
1913
+ class: "fm-typo-en-body-md-600 block truncate text-fm-color-typo-primary",
1914
+ title: g.name
1915
+ }, y(g.name), 9, En),
1916
+ g.bindingLines.length ? (m(), M(yt, {
1917
+ key: 0,
1918
+ class: "mt-2",
1919
+ count: g.bindingCount,
1920
+ controls: `production-run-plan-bindings-${g.key}`,
1921
+ expanded: a.value.has(g.key),
1922
+ testid: "production-run-plan-readonly-bindings-toggle",
1923
+ onToggle: (te) => _(g.key)
1924
+ }, null, 8, ["count", "controls", "expanded", "onToggle"])) : (m(), M(tt, {
1925
+ key: 1,
1926
+ "item-name": g.name
1927
+ }, null, 8, ["item-name"]))
1928
+ ]),
1929
+ u("td", Dn, y(g.onHand === null ? i(lt) : i(fe)(g.onHand, g.baseUnit)), 1),
1930
+ u("td", Ln, [
1931
+ u("span", qn, y(i(fe)(g.model.amount, g.enteredUnit)), 1),
1932
+ u("span", {
1933
+ class: "fm-typo-en-body-sm-400 block min-h-16 text-fm-color-typo-secondary",
1934
+ "aria-hidden": g.enteredUnit === g.baseUnit ? "true" : void 0
1935
+ }, [
1936
+ g.enteredUnit !== g.baseUnit ? (m(), k(ee, { key: 0 }, [
1937
+ ue(" = " + y(i(fe)(g.baseQuantity, g.baseUnit)), 1)
1938
+ ], 64)) : B("", !0)
1939
+ ], 8, Tn)
1940
+ ])
1941
+ ]),
1942
+ a.value.has(g.key) ? (m(), k("tr", Nn, [
1943
+ u("td", On, [
1944
+ E(bt, {
1945
+ id: `production-run-plan-bindings-${g.key}`,
1946
+ testid: "production-run-plan-readonly-bindings",
1947
+ count: g.bindingCount,
1948
+ unit: g.baseUnit,
1949
+ lines: g.bindingLines,
1950
+ "item-name": g.name
1951
+ }, null, 8, ["id", "count", "unit", "lines", "item-name"])
1952
+ ])
1953
+ ])) : B("", !0)
1954
+ ], 64))), 128))
1955
+ ])
1956
+ ])
1957
+ ], 8, Cn))
1958
+ ], 10, yn);
1959
+ };
1960
+ }
1961
+ }), tr = /* @__PURE__ */ Ie(er, [["__scopeId", "data-v-6ef0e148"]]), or = { class: "flex flex-col gap-16" }, nr = {
1962
+ "data-testid": "production-run-planner-layout",
1963
+ class: "grid grid-cols-[3fr_2fr] items-start gap-16 xs:grid-cols-1 sm:grid-cols-1 md:grid-cols-1"
1964
+ }, rr = {
1965
+ "data-testid": "production-run-planner-left",
1966
+ class: "flex min-w-0 flex-col gap-16"
1967
+ }, sr = /* @__PURE__ */ Y({
1968
+ __name: "ProductionRunPlanner",
1969
+ props: {
1970
+ items: {},
1971
+ commits: {},
1972
+ instructions: { default: null },
1973
+ editable: { type: Boolean, default: !0 },
1974
+ canDuplicate: { type: Boolean, default: !1 }
1975
+ },
1976
+ emits: ["add", "duplicate", "clear", "remove", "update:item"],
1977
+ setup(s, { emit: e }) {
1978
+ const t = s, l = e, o = S(() => uo(t.items));
1979
+ return (r, c) => (m(), k("div", or, [
1980
+ u("div", nr, [
1981
+ u("div", rr, [
1982
+ E(Do, { instructions: r.instructions }, null, 8, ["instructions"]),
1983
+ E(tr, {
1984
+ "data-testid": "production-plan",
1985
+ items: r.items,
1986
+ editable: r.editable,
1987
+ "can-duplicate": r.canDuplicate,
1988
+ onAdd: c[0] || (c[0] = (a) => l("add")),
1989
+ onDuplicate: c[1] || (c[1] = (a) => l("duplicate")),
1990
+ onClear: c[2] || (c[2] = (a) => l("clear")),
1991
+ onRemove: c[3] || (c[3] = (a) => l("remove", a)),
1992
+ "onUpdate:item": c[4] || (c[4] = (a, n) => l("update:item", a, n))
1993
+ }, null, 8, ["items", "editable", "can-duplicate"])
1994
+ ]),
1995
+ r.items.length > 0 ? (m(), M(Uo, {
1996
+ key: 0,
1997
+ mode: "planner",
1998
+ rows: r.commits,
1999
+ "no-items": !r.items.length,
2000
+ "unbound-names": o.value,
2001
+ constrained: r.editable
2002
+ }, null, 8, ["rows", "no-items", "unbound-names", "constrained"])) : B("", !0)
2003
+ ])
2004
+ ]));
2005
+ }
2006
+ }), ir = ["inert", "aria-hidden"], ar = { class: "flex min-w-0 flex-col gap-2" }, lr = ["id"], ur = {
2007
+ key: 0,
2008
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
2009
+ }, dr = { class: "flex shrink-0 items-center gap-8" }, cr = {
2010
+ "data-testid": "production-run-side-sheet-body",
2011
+ class: "flex h-full min-h-0 min-w-0 flex-col overflow-y-auto"
2012
+ }, mr = {
2013
+ "data-testid": "production-run-side-sheet-footer",
2014
+ class: "w-full"
2015
+ }, pr = /* @__PURE__ */ Y({
2016
+ inheritAttrs: !1,
2017
+ __name: "ProductionRunSideSheetSurface",
2018
+ props: {
2019
+ modelValue: { type: Boolean },
2020
+ title: {},
2021
+ subtitle: {},
2022
+ closeLabel: {},
2023
+ dismissAway: { type: Boolean },
2024
+ initialFocus: {},
2025
+ containerClass: {},
2026
+ hideClose: { type: Boolean },
2027
+ headerInert: { type: Boolean },
2028
+ titleId: {},
2029
+ rootAttrs: {}
2030
+ },
2031
+ emits: ["update:modelValue", "request-close"],
2032
+ setup(s, { emit: e }) {
2033
+ const t = s, l = e, { container: o } = Ct(
2034
+ () => t.title,
2035
+ () => t.initialFocus
2036
+ ), r = S(() => {
2037
+ var c;
2038
+ return {
2039
+ ...t.rootAttrs,
2040
+ class: ["production-run-side-sheet", t.containerClass, (c = t.rootAttrs) == null ? void 0 : c.class],
2041
+ role: "dialog",
2042
+ "aria-modal": "true",
2043
+ "aria-labelledby": t.titleId
2044
+ };
2045
+ });
2046
+ return (c, a) => {
2047
+ const n = Z("FmButton"), f = Z("FmSideSheet");
2048
+ return m(), M(f, {
2049
+ "model-value": c.modelValue,
2050
+ "max-width": 9999,
2051
+ "close-button": !1,
2052
+ "dismiss-away": c.dismissAway,
2053
+ "is-container-props": r.value,
2054
+ "onUpdate:modelValue": a[1] || (a[1] = (w) => l("update:modelValue", w))
2055
+ }, kt({
2056
+ "side-sheet-header": H(() => [
2057
+ u("div", {
2058
+ ref_key: "trap",
2059
+ ref: o,
2060
+ "data-testid": "production-run-side-sheet-header",
2061
+ class: "flex w-full min-w-0 items-start justify-between gap-12",
2062
+ inert: c.headerInert ? !0 : void 0,
2063
+ "aria-hidden": c.headerInert ? "true" : void 0
2064
+ }, [
2065
+ u("div", ar, [
2066
+ u("h2", {
2067
+ id: c.titleId,
2068
+ class: "fm-typo-en-title-sm-800 text-fm-color-typo-primary"
2069
+ }, [
2070
+ se(c.$slots, "title", {}, () => [
2071
+ ue(y(c.title), 1)
2072
+ ])
2073
+ ], 8, lr),
2074
+ c.subtitle || c.$slots.subtitle ? (m(), k("div", ur, [
2075
+ se(c.$slots, "subtitle", {}, () => [
2076
+ ue(y(c.subtitle), 1)
2077
+ ])
2078
+ ])) : B("", !0)
2079
+ ]),
2080
+ u("div", dr, [
2081
+ se(c.$slots, "header-actions"),
2082
+ c.hideClose ? B("", !0) : (m(), M(n, {
2083
+ key: 0,
2084
+ "data-testid": "production-run-side-sheet-close",
2085
+ variant: "tertiary",
2086
+ icon: "close",
2087
+ "aria-label": c.closeLabel,
2088
+ onClick: a[0] || (a[0] = (w) => l("request-close"))
2089
+ }, null, 8, ["aria-label"]))
2090
+ ])
2091
+ ], 8, ir)
2092
+ ]),
2093
+ default: H(() => [
2094
+ u("div", cr, [
2095
+ se(c.$slots, "default")
2096
+ ])
2097
+ ]),
2098
+ _: 2
2099
+ }, [
2100
+ c.$slots.footer ? {
2101
+ name: "side-sheet-footer",
2102
+ fn: H(() => [
2103
+ u("div", mr, [
2104
+ se(c.$slots, "footer")
2105
+ ])
2106
+ ]),
2107
+ key: "0"
2108
+ } : void 0
2109
+ ]), 1032, ["model-value", "dismiss-away", "is-container-props"]);
2110
+ };
2111
+ }
2112
+ });
2113
+ let fr = 0;
2114
+ const vr = /* @__PURE__ */ Y({
2115
+ inheritAttrs: !1,
2116
+ __name: "ProductionRunSideSheet",
2117
+ props: {
2118
+ modelValue: { type: Boolean },
2119
+ title: {},
2120
+ subtitle: { default: void 0 },
2121
+ closeLabel: {},
2122
+ dismissAway: { type: Boolean, default: !1 },
2123
+ initialFocus: { default: null },
2124
+ containerClass: { default: "" },
2125
+ hideClose: { type: Boolean, default: !1 },
2126
+ headerInert: { type: Boolean, default: !1 }
2127
+ },
2128
+ emits: ["update:modelValue", "request-close"],
2129
+ setup(s, { emit: e }) {
2130
+ const t = e, l = ot(), o = `production-run-side-sheet-title-${++fr}`;
2131
+ return (r, c) => r.modelValue ? (m(), M(pr, {
2132
+ key: 0,
2133
+ "model-value": !0,
2134
+ title: r.title,
2135
+ subtitle: r.subtitle,
2136
+ "close-label": r.closeLabel,
2137
+ "dismiss-away": r.dismissAway,
2138
+ "initial-focus": r.initialFocus,
2139
+ "container-class": r.containerClass,
2140
+ "hide-close": r.hideClose,
2141
+ "header-inert": r.headerInert,
2142
+ "title-id": o,
2143
+ "root-attrs": i(l),
2144
+ onRequestClose: c[0] || (c[0] = (a) => t("request-close")),
2145
+ "onUpdate:modelValue": c[1] || (c[1] = (a) => t("update:modelValue", a))
2146
+ }, kt({
2147
+ default: H(() => [
2148
+ se(r.$slots, "default")
2149
+ ]),
2150
+ _: 2
2151
+ }, [
2152
+ r.$slots.title ? {
2153
+ name: "title",
2154
+ fn: H(() => [
2155
+ se(r.$slots, "title")
2156
+ ]),
2157
+ key: "0"
2158
+ } : void 0,
2159
+ r.$slots.subtitle ? {
2160
+ name: "subtitle",
2161
+ fn: H(() => [
2162
+ se(r.$slots, "subtitle")
2163
+ ]),
2164
+ key: "1"
2165
+ } : void 0,
2166
+ r.$slots["header-actions"] ? {
2167
+ name: "header-actions",
2168
+ fn: H(() => [
2169
+ se(r.$slots, "header-actions")
2170
+ ]),
2171
+ key: "2"
2172
+ } : void 0,
2173
+ r.$slots.footer ? {
2174
+ name: "footer",
2175
+ fn: H(() => [
2176
+ se(r.$slots, "footer")
2177
+ ]),
2178
+ key: "3"
2179
+ } : void 0
2180
+ ]), 1032, ["title", "subtitle", "close-label", "dismiss-away", "initial-focus", "container-class", "hide-close", "header-inert", "root-attrs"])) : B("", !0);
2181
+ }
2182
+ }), yr = /* @__PURE__ */ Y({
2183
+ inheritAttrs: !1,
2184
+ __name: "ProductionRunTextarea",
2185
+ props: {
2186
+ modelValue: {},
2187
+ rows: {},
2188
+ label: {},
2189
+ labelMark: { default: "none" },
2190
+ placeholder: { default: "" },
2191
+ disabled: { type: Boolean },
2192
+ helperText: {},
2193
+ helperState: { default: "none" }
2194
+ },
2195
+ emits: ["update:modelValue"],
2196
+ setup(s, { emit: e }) {
2197
+ const t = s, l = e, o = ot(), r = N(null);
2198
+ async function c() {
2199
+ var n;
2200
+ await he();
2201
+ const a = (n = r.value) == null ? void 0 : n.querySelector("textarea");
2202
+ a && (a.rows = t.rows);
2203
+ }
2204
+ return Te(c), ke(() => t.rows, c, { flush: "post" }), (a, n) => {
2205
+ const f = Z("FmTextarea");
2206
+ return m(), k("div", Je(i(o), {
2207
+ ref_key: "root",
2208
+ ref: r,
2209
+ class: ["production-run-textarea", [
2210
+ `production-run-textarea--${a.rows === 1 ? "one" : "three"}-row`,
2211
+ !a.helperText && "production-run-textarea--without-helper"
2212
+ ]]
2213
+ }), [
2214
+ E(f, {
2215
+ "model-value": a.modelValue,
2216
+ label: a.label,
2217
+ "label-mark": a.labelMark,
2218
+ placeholder: a.placeholder,
2219
+ disabled: a.disabled,
2220
+ "helper-text": a.helperText,
2221
+ "helper-state": a.helperState,
2222
+ "onUpdate:modelValue": n[0] || (n[0] = (w) => l("update:modelValue", w))
2223
+ }, null, 8, ["model-value", "label", "label-mark", "placeholder", "disabled", "helper-text", "helper-state"])
2224
+ ], 16);
2225
+ };
2226
+ }
2227
+ }), br = /* @__PURE__ */ Ie(yr, [["__scopeId", "data-v-779d31c5"]]), gr = /* @__PURE__ */ Y({
2228
+ __name: "ProductionRunProjectionFeedback",
2229
+ props: {
2230
+ loadFailure: { default: null },
2231
+ projectionFailed: { type: Boolean, default: !1 }
2232
+ },
2233
+ emits: ["retry-load", "retry-projection"],
2234
+ setup(s, { emit: e }) {
2235
+ const t = e, { t: l } = de();
2236
+ return (o, r) => {
2237
+ const c = Z("FmButton");
2238
+ return o.loadFailure ? (m(), M(mt, {
2239
+ key: 0,
2240
+ role: "alert",
2241
+ tone: "critical",
2242
+ title: i(l)("inventory.production.run.form.error.load"),
2243
+ message: o.loadFailure.message
2244
+ }, {
2245
+ actions: H(() => [
2246
+ E(c, {
2247
+ "data-testid": "production-run-form-load-retry",
2248
+ variant: "secondary",
2249
+ label: i(l)("inventory.production.run.list.error.retry"),
2250
+ onClick: r[0] || (r[0] = (a) => t("retry-load"))
2251
+ }, null, 8, ["label"])
2252
+ ]),
2253
+ _: 1
2254
+ }, 8, ["title", "message"])) : o.projectionFailed ? (m(), M(mt, {
2255
+ key: 1,
2256
+ role: "alert",
2257
+ tone: "warn",
2258
+ title: i(l)("inventory.production.run.form.error.projection"),
2259
+ message: i(l)("inventory.production.run.form.error.projectionMessage")
2260
+ }, {
2261
+ actions: H(() => [
2262
+ E(c, {
2263
+ "data-testid": "production-run-form-projection-retry",
2264
+ variant: "secondary",
2265
+ label: i(l)("inventory.production.run.list.error.retry"),
2266
+ onClick: r[1] || (r[1] = (a) => t("retry-projection"))
2267
+ }, null, 8, ["label"])
2268
+ ]),
2269
+ _: 1
2270
+ }, 8, ["title", "message"])) : B("", !0);
2271
+ };
2272
+ }
2273
+ }), hr = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary" }, Ke = "inventory.production.run.form.discard", kr = /* @__PURE__ */ Y({
2274
+ __name: "ProductionRunDiscardDialog",
2275
+ props: {
2276
+ show: { type: Boolean }
2277
+ },
2278
+ emits: ["update:show", "discard"],
2279
+ setup(s, { emit: e }) {
2280
+ const t = e, { t: l } = de();
2281
+ return (o, r) => {
2282
+ const c = Z("FmButton");
2283
+ return m(), M(rt, {
2284
+ "model-value": o.show,
2285
+ title: i(l)(`${Ke}.title`),
2286
+ "close-label": i(l)(`${Ke}.keep`),
2287
+ "max-width": "min(calc(100% - 32px), 448px)",
2288
+ "hide-close": "",
2289
+ role: "alertdialog",
2290
+ variant: "confirmation",
2291
+ "initial-focus": "[data-testid='keep-production-run']",
2292
+ "onUpdate:modelValue": r[2] || (r[2] = (a) => t("update:show", a))
2293
+ }, {
2294
+ footer: H(() => [
2295
+ E(c, {
2296
+ "data-testid": "keep-production-run",
2297
+ variant: "tertiary",
2298
+ label: i(l)(`${Ke}.keep`),
2299
+ onClick: r[0] || (r[0] = (a) => t("update:show", !1))
2300
+ }, null, 8, ["label"]),
2301
+ E(c, {
2302
+ variant: "destructive",
2303
+ label: i(l)(`${Ke}.confirm`),
2304
+ onClick: r[1] || (r[1] = (a) => t("discard"))
2305
+ }, null, 8, ["label"])
2306
+ ]),
2307
+ default: H(() => [
2308
+ u("p", hr, y(i(l)(`${Ke}.message`)), 1)
2309
+ ]),
2310
+ _: 1
2311
+ }, 8, ["model-value", "title", "close-label"]);
2312
+ };
2313
+ }
2314
+ }), _r = ["data-indeterminate"], xr = /* @__PURE__ */ Y({
2315
+ inheritAttrs: !1,
2316
+ __name: "ProductionRunSelectionCheckbox",
2317
+ props: {
2318
+ modelValue: { type: Boolean },
2319
+ value: {},
2320
+ accessibleLabel: {},
2321
+ disabled: { type: Boolean },
2322
+ indeterminate: { type: Boolean },
2323
+ label: {}
2324
+ },
2325
+ emits: ["update:modelValue"],
2326
+ setup(s, { expose: e, emit: t }) {
2327
+ const l = t, o = N(null);
2328
+ return e({
2329
+ focus: () => {
2330
+ var r, c;
2331
+ return (c = (r = o.value) == null ? void 0 : r.querySelector("input")) == null ? void 0 : c.focus();
2332
+ }
2333
+ }), (r, c) => {
2334
+ const a = Z("FmCheckbox");
2335
+ return m(), k("span", Je({
2336
+ ref_key: "root",
2337
+ ref: o
2338
+ }, r.$attrs, {
2339
+ class: ["production-run-selection-checkbox", { "production-run-selection-checkbox--label-visually-hidden": !r.label }],
2340
+ "data-indeterminate": String(!!r.indeterminate)
2341
+ }), [
2342
+ E(a, {
2343
+ "model-value": r.modelValue,
2344
+ value: r.value,
2345
+ label: r.label || r.accessibleLabel,
2346
+ disabled: r.disabled,
2347
+ indeterminate: r.indeterminate,
2348
+ "onUpdate:modelValue": c[0] || (c[0] = (n) => l("update:modelValue", n))
2349
+ }, null, 8, ["model-value", "value", "label", "disabled", "indeterminate"])
2350
+ ], 16, _r);
2351
+ };
2352
+ }
2353
+ }), Xe = /* @__PURE__ */ Ie(xr, [["__scopeId", "data-v-c0d0d057"]]), wr = { class: "flex flex-col" }, $r = {
2354
+ "data-testid": "production-run-picker-toolbar",
2355
+ class: "production-run-dialog-content--full-bleed flex items-center justify-between gap-12 border-y border-fm-color-neutral-gray-200 px-[20px] py-16 xs:flex-col xs:items-stretch xs:gap-[7px]"
2356
+ }, Ir = {
2357
+ "data-testid": "production-run-picker-search-focus",
2358
+ class: "w-[268px] min-w-0 xs:w-full"
2359
+ }, Sr = {
2360
+ "data-testid": "production-run-picker-desktop",
2361
+ role: "table",
2362
+ class: "w-full xs:hidden"
2363
+ }, Cr = { role: "rowgroup" }, Rr = {
2364
+ "data-testid": "production-run-picker-desktop-header",
2365
+ role: "row",
2366
+ class: "fm-typo-en-body-sm-600 sticky top-0 z-10 grid grid-cols-[32px_minmax(0,1fr)_144px] gap-x-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 px-[20px] py-8 text-fm-color-typo-secondary"
2367
+ }, Ar = {
2368
+ role: "columnheader",
2369
+ class: "text-center"
2370
+ }, Fr = { class: "sr-only" }, Ur = {
2371
+ role: "columnheader",
2372
+ class: "text-left"
2373
+ }, Pr = {
2374
+ role: "columnheader",
2375
+ class: "text-center"
2376
+ }, Br = { role: "rowgroup" }, Vr = ["data-testid", "onClick"], Er = ["data-testid"], Dr = {
2377
+ role: "cell",
2378
+ class: "min-w-0"
2379
+ }, Lr = { class: "flex min-w-0 flex-1 flex-col gap-2" }, qr = { class: "line-clamp-1 fm-typo-en-body-md-600 text-fm-color-typo-primary" }, Tr = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-tertiary" }, Nr = {
2380
+ role: "cell",
2381
+ class: "fm-typo-en-body-md-400 self-center whitespace-nowrap text-center text-fm-color-typo-primary"
2382
+ }, Or = {
2383
+ "data-testid": "production-run-picker-mobile",
2384
+ class: "hidden xs:block"
2385
+ }, Mr = ["data-testid", "onClick"], jr = {
2386
+ "data-testid": "production-run-picker-mobile-content",
2387
+ class: "flex min-w-0 flex-1 flex-col gap-0"
2388
+ }, Hr = ["title"], zr = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-tertiary" }, Kr = {
2389
+ "data-testid": "production-run-picker-mobile-stock",
2390
+ class: "fm-typo-en-body-sm-400 mt-[4px] text-center text-fm-color-typo-secondary"
2391
+ }, Qr = {
2392
+ key: 0,
2393
+ class: "fm-typo-en-body-md-400 px-16 py-24 text-center text-fm-color-typo-secondary"
2394
+ }, Gr = { class: "flex w-full items-center justify-end gap-8" }, Wr = /* @__PURE__ */ Y({
2395
+ __name: "ProductionRunItemPickerDialog",
2396
+ props: {
2397
+ show: { type: Boolean },
2398
+ candidates: {},
2399
+ existingSkuIds: {}
2400
+ },
2401
+ emits: ["update:show", "select"],
2402
+ setup(s, { emit: e }) {
2403
+ const t = s, l = e, { t: o } = de(), r = S(() => o("inventory.production.run.form.picker.title")), c = N(""), a = N(/* @__PURE__ */ new Set()), {
2404
+ scroller: n,
2405
+ canScrollFurther: f,
2406
+ onScroll: w
2407
+ } = nt(), U = S({
2408
+ get: () => t.show,
2409
+ set: (L) => l("update:show", L)
2410
+ }), _ = S(() => new Set(t.existingSkuIds)), b = S(() => t.candidates.filter((L) => !_.value.has(L.sku._id))), R = S(() => {
2411
+ const L = c.value.trim().toLocaleLowerCase();
2412
+ return L ? t.candidates.filter(
2413
+ (q) => `${q.sku.name} ${q.sku.code}`.toLocaleLowerCase().includes(L)
2414
+ ) : t.candidates;
2415
+ }), T = S(
2416
+ () => R.value.filter((L) => !_.value.has(L.sku._id)).map((L) => L.sku._id)
2417
+ ), z = S(
2418
+ () => T.value.length > 0 && T.value.every((L) => a.value.has(L))
2419
+ ), D = S(() => {
2420
+ const L = T.value.filter((q) => a.value.has(q)).length;
2421
+ return L > 0 && L < T.value.length;
2422
+ });
2423
+ ke(
2424
+ () => t.show,
2425
+ (L) => {
2426
+ L && (c.value = "", a.value = /* @__PURE__ */ new Set());
2427
+ },
2428
+ { immediate: !0 }
2429
+ );
2430
+ function g(L, q) {
2431
+ if (_.value.has(L)) return;
2432
+ const A = new Set(a.value);
2433
+ q ? A.add(L) : A.delete(L), a.value = A;
2434
+ }
2435
+ function te() {
2436
+ const L = new Set(a.value);
2437
+ z.value ? T.value.forEach((q) => L.delete(q)) : T.value.forEach((q) => L.add(q)), a.value = L;
2438
+ }
2439
+ function J() {
2440
+ const L = b.value.map((q) => q.sku._id).filter((q) => a.value.has(q));
2441
+ L.length && (l("select", L), U.value = !1);
2442
+ }
2443
+ return (L, q) => {
2444
+ const A = Z("FmTextField"), j = Z("FmButton");
2445
+ return m(), M(rt, {
2446
+ "model-value": U.value,
2447
+ title: r.value,
2448
+ "close-label": i(o)("inventory.production.run.form.picker.dismiss"),
2449
+ "max-width": "min(calc(100% - 32px), 576px)",
2450
+ "initial-focus": "[data-testid='production-run-picker-search-focus'] input",
2451
+ "onUpdate:modelValue": q[5] || (q[5] = (x) => U.value = x)
2452
+ }, {
2453
+ footer: H(() => [
2454
+ u("div", Gr, [
2455
+ E(j, {
2456
+ variant: "tertiary",
2457
+ label: i(o)("inventory.production.run.form.picker.close"),
2458
+ onClick: q[4] || (q[4] = (x) => U.value = !1)
2459
+ }, null, 8, ["label"]),
2460
+ E(j, {
2461
+ "data-testid": "production-run-picker-confirm",
2462
+ label: i(o)("inventory.production.run.form.picker.confirm"),
2463
+ disabled: a.value.size === 0,
2464
+ onClick: J
2465
+ }, null, 8, ["label", "disabled"])
2466
+ ])
2467
+ ]),
2468
+ default: H(() => [
2469
+ u("div", wr, [
2470
+ u("div", $r, [
2471
+ E(Xe, {
2472
+ "data-testid": "production-run-picker-select-visible",
2473
+ "model-value": z.value,
2474
+ indeterminate: D.value,
2475
+ label: i(o)("inventory.production.run.form.picker.selectVisible", { count: a.value.size }),
2476
+ value: "visible",
2477
+ "accessible-label": i(o)("inventory.production.run.form.picker.selectVisible", { count: a.value.size }),
2478
+ disabled: T.value.length === 0,
2479
+ class: "h-[24px]",
2480
+ "onUpdate:modelValue": te
2481
+ }, null, 8, ["model-value", "indeterminate", "label", "accessible-label", "disabled"]),
2482
+ u("div", Ir, [
2483
+ E(A, {
2484
+ "model-value": c.value,
2485
+ "onUpdate:modelValue": q[0] || (q[0] = (x) => c.value = x),
2486
+ "data-testid": "production-run-picker-search",
2487
+ class: "w-full",
2488
+ "prepend-icon": "search",
2489
+ placeholder: i(o)("inventory.production.run.form.picker.search")
2490
+ }, null, 8, ["model-value", "placeholder"])
2491
+ ])
2492
+ ]),
2493
+ u("div", {
2494
+ ref_key: "pickerScroll",
2495
+ ref: n,
2496
+ "data-testid": "production-run-picker-list",
2497
+ class: "production-run-dialog-content--full-bleed max-h-[320px] overflow-y-auto border-b border-fm-color-neutral-gray-200",
2498
+ onScroll: q[3] || (q[3] = //@ts-ignore
2499
+ (...x) => i(w) && i(w)(...x))
2500
+ }, [
2501
+ u("div", Sr, [
2502
+ u("div", Cr, [
2503
+ u("div", Rr, [
2504
+ u("span", Ar, [
2505
+ u("span", Fr, y(i(o)("inventory.production.run.form.picker.selectColumn")), 1)
2506
+ ]),
2507
+ u("span", Ur, y(i(o)("inventory.production.run.form.picker.itemColumn")), 1),
2508
+ u("span", Pr, y(i(o)("inventory.production.run.form.picker.stockColumn")), 1)
2509
+ ])
2510
+ ]),
2511
+ u("div", Br, [
2512
+ (m(!0), k(ee, null, pe(R.value, (x) => (m(), k("div", {
2513
+ key: x.sku._id,
2514
+ "data-testid": `production-run-picker-row-${x.sku._id}`,
2515
+ role: "row",
2516
+ class: G([
2517
+ "grid grid-cols-[32px_minmax(0,1fr)_144px] gap-x-12 border-b border-fm-color-neutral-gray-200 px-[20px] py-8 last:border-b-0 hover:bg-fm-color-opacity-sm",
2518
+ _.value.has(x.sku._id) ? "cursor-default opacity-60" : "cursor-pointer"
2519
+ ]),
2520
+ onClick: (C) => !_.value.has(x.sku._id) && g(x.sku._id, !a.value.has(x.sku._id))
2521
+ }, [
2522
+ u("div", {
2523
+ "data-testid": `production-run-picker-selection-${x.sku._id}`,
2524
+ role: "cell",
2525
+ class: "self-center text-center"
2526
+ }, [
2527
+ E(Xe, {
2528
+ value: x.sku._id,
2529
+ "model-value": a.value.has(x.sku._id),
2530
+ disabled: _.value.has(x.sku._id),
2531
+ "accessible-label": x.sku.name,
2532
+ class: "inline-flex shrink-0",
2533
+ onClick: q[1] || (q[1] = Ae(() => {
2534
+ }, ["stop"])),
2535
+ "onUpdate:modelValue": (C) => g(x.sku._id, C)
2536
+ }, null, 8, ["value", "model-value", "disabled", "accessible-label", "onUpdate:modelValue"])
2537
+ ], 8, Er),
2538
+ u("div", Dr, [
2539
+ u("span", Lr, [
2540
+ u("span", qr, y(x.sku.name), 1),
2541
+ u("span", Tr, [
2542
+ ue(y(x.sku.code) + " ", 1),
2543
+ _.value.has(x.sku._id) ? (m(), k(ee, { key: 0 }, [
2544
+ ue(" · " + y(i(o)("inventory.production.run.form.picker.alreadyAdded")), 1)
2545
+ ], 64)) : B("", !0)
2546
+ ]),
2547
+ x.hasBindings ? B("", !0) : (m(), M(tt, {
2548
+ key: 0,
2549
+ "item-name": x.sku.name
2550
+ }, null, 8, ["item-name"]))
2551
+ ])
2552
+ ]),
2553
+ u("div", Nr, y(i(fe)(x.onHand, x.sku.unit.abbrev)), 1)
2554
+ ], 10, Vr))), 128))
2555
+ ])
2556
+ ]),
2557
+ u("div", Or, [
2558
+ (m(!0), k(ee, null, pe(R.value, (x) => (m(), k("div", {
2559
+ key: x.sku._id,
2560
+ "data-testid": `production-run-picker-mobile-row-${x.sku._id}`,
2561
+ class: G([
2562
+ "flex items-start gap-[16px] px-[20px] py-[12px] hover:bg-fm-color-opacity-sm",
2563
+ _.value.has(x.sku._id) ? "cursor-default opacity-60" : "cursor-pointer"
2564
+ ]),
2565
+ onClick: (C) => !_.value.has(x.sku._id) && g(x.sku._id, !a.value.has(x.sku._id))
2566
+ }, [
2567
+ E(Xe, {
2568
+ "data-testid": "production-run-picker-mobile-selection",
2569
+ value: x.sku._id,
2570
+ "model-value": a.value.has(x.sku._id),
2571
+ disabled: _.value.has(x.sku._id),
2572
+ "accessible-label": x.sku.name,
2573
+ class: "ml-[4px] mt-[5px] shrink-0",
2574
+ onClick: q[2] || (q[2] = Ae(() => {
2575
+ }, ["stop"])),
2576
+ "onUpdate:modelValue": (C) => g(x.sku._id, C)
2577
+ }, null, 8, ["value", "model-value", "disabled", "accessible-label", "onUpdate:modelValue"]),
2578
+ u("span", jr, [
2579
+ u("span", {
2580
+ class: "line-clamp-1 max-w-[144px] fm-typo-en-body-md-600 text-fm-color-typo-primary",
2581
+ title: x.sku.name
2582
+ }, y(x.sku.name), 9, Hr),
2583
+ u("span", zr, [
2584
+ ue(y(x.sku.code) + " ", 1),
2585
+ _.value.has(x.sku._id) ? (m(), k(ee, { key: 0 }, [
2586
+ ue(" · " + y(i(o)("inventory.production.run.form.picker.alreadyAdded")), 1)
2587
+ ], 64)) : B("", !0)
2588
+ ]),
2589
+ x.hasBindings ? B("", !0) : (m(), M(tt, {
2590
+ key: 0,
2591
+ "item-name": x.sku.name
2592
+ }, null, 8, ["item-name"])),
2593
+ u("span", Kr, y(i(o)("inventory.production.run.form.picker.stockColumn")) + " " + y(i(fe)(x.onHand, x.sku.unit.abbrev)), 1)
2594
+ ])
2595
+ ], 10, Mr))), 128))
2596
+ ]),
2597
+ R.value.length === 0 ? (m(), k("div", Qr, y(i(o)("inventory.production.run.form.picker.empty")), 1)) : B("", !0),
2598
+ E(Ge, {
2599
+ visible: i(f),
2600
+ testid: "production-run-picker-scroll-hint"
2601
+ }, null, 8, ["visible"])
2602
+ ], 544)
2603
+ ])
2604
+ ]),
2605
+ _: 1
2606
+ }, 8, ["model-value", "title", "close-label"]);
2607
+ };
2608
+ }
2609
+ }), Jr = { class: "sr-only" }, Yr = /* @__PURE__ */ Y({
2610
+ inheritAttrs: !1,
2611
+ __name: "ProductionRunSelectionRadio",
2612
+ props: {
2613
+ modelValue: {},
2614
+ value: {},
2615
+ accessibleLabel: {},
2616
+ name: {},
2617
+ disabled: { type: Boolean }
2618
+ },
2619
+ emits: ["update:modelValue"],
2620
+ setup(s, { expose: e, emit: t }) {
2621
+ const l = s, o = t, r = N(null);
2622
+ function c() {
2623
+ var _;
2624
+ return ((_ = r.value) == null ? void 0 : _.querySelector('input[type="radio"]')) ?? null;
2625
+ }
2626
+ function a() {
2627
+ const _ = c();
2628
+ _ && (_.name = l.name, _.dataset.choice = l.value, _.setAttribute("aria-checked", String(l.modelValue === l.value)));
2629
+ }
2630
+ function n() {
2631
+ var _;
2632
+ (_ = c()) == null || _.focus();
2633
+ }
2634
+ function f() {
2635
+ l.disabled || (n(), o("update:modelValue", l.value));
2636
+ }
2637
+ function w() {
2638
+ l.disabled || (n(), o("update:modelValue", l.value));
2639
+ }
2640
+ function U(_) {
2641
+ if (l.disabled || !["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(_.key))
2642
+ return;
2643
+ const b = c();
2644
+ if (!b || _.target !== b) return;
2645
+ const R = [...document.querySelectorAll('input[type="radio"]')].filter(
2646
+ (g) => g.name === l.name && !g.disabled
2647
+ ), T = R.indexOf(b);
2648
+ if (T < 0 || R.length < 2) return;
2649
+ _.preventDefault(), _.stopPropagation();
2650
+ const z = _.key === "ArrowRight" || _.key === "ArrowDown" ? 1 : -1, D = R[(T + z + R.length) % R.length];
2651
+ D.focus({ preventScroll: !0 }), D.click();
2652
+ }
2653
+ return Te(a), ke(() => [l.modelValue, l.value, l.name], a, {
2654
+ flush: "post"
2655
+ }), e({ focus: n }), (_, b) => {
2656
+ const R = Z("FmRadio");
2657
+ return m(), k("div", Je({
2658
+ ref_key: "root",
2659
+ ref: r
2660
+ }, _.$attrs, {
2661
+ class: ["production-run-selection-radio flex min-w-0 items-start gap-0", _.disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"],
2662
+ onPointerdown: b[1] || (b[1] = Ae(() => {
2663
+ }, ["prevent"])),
2664
+ onClick: f,
2665
+ onKeydown: U
2666
+ }), [
2667
+ E(R, {
2668
+ "model-value": _.modelValue,
2669
+ value: _.value,
2670
+ disabled: _.disabled,
2671
+ class: "mt-[1px] shrink-0",
2672
+ onClick: b[0] || (b[0] = Ae(() => {
2673
+ }, ["stop"])),
2674
+ "onUpdate:modelValue": w
2675
+ }, {
2676
+ label: H(() => [
2677
+ u("span", Jr, y(_.accessibleLabel), 1)
2678
+ ]),
2679
+ _: 1
2680
+ }, 8, ["model-value", "value", "disabled"]),
2681
+ se(_.$slots, "default")
2682
+ ], 16);
2683
+ };
2684
+ }
2685
+ }), Xr = {
2686
+ "data-testid": "production-run-duplicate-body",
2687
+ class: "production-run-duplicate-body flex min-h-0 flex-col"
2688
+ }, Zr = {
2689
+ key: 0,
2690
+ class: "production-run-dialog-content--full-bleed fm-typo-en-body-md-400 border-b border-fm-color-neutral-gray-200 px-16 py-24 text-center text-fm-color-typo-secondary"
2691
+ }, es = ["aria-label"], ts = { class: "flex flex-col" }, os = { class: "flex min-w-0 flex-1 flex-col gap-[2px]" }, ns = { class: "line-clamp-1 text-[14px] font-semibold leading-[18px] text-fm-color-typo-primary" }, rs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-tertiary" }, ss = { class: "production-run-dialog-content--full-bleed flex items-center justify-between gap-8 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 px-16 py-[10px]" }, is = {
2692
+ "data-testid": "production-run-duplicate-selection-summary",
2693
+ class: "text-[14px] font-semibold leading-[20px] tabular-nums text-fm-color-typo-primary"
2694
+ }, as = {
2695
+ key: 0,
2696
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
2697
+ }, ls = ["data-testid", "onClick"], us = { class: "flex min-w-0 flex-1 flex-col gap-2" }, ds = { class: "flex flex-wrap items-center gap-4" }, cs = { class: "truncate" }, ms = {
2698
+ key: 0,
2699
+ class: "fm-typo-en-body-sm-600 rounded-full border border-fm-color-neutral-gray-200 px-8 py-4 text-fm-color-typo-secondary"
2700
+ }, ps = {
2701
+ key: 1,
2702
+ class: "fm-typo-en-body-sm-600 rounded-full bg-fm-color-neutral-gray-100 px-8 py-4 text-fm-color-typo-secondary"
2703
+ }, fs = {
2704
+ key: 2,
2705
+ class: "fm-typo-en-body-sm-600 rounded-full bg-fm-color-neutral-gray-100 px-8 py-4 text-fm-color-typo-secondary"
2706
+ }, vs = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ys = {
2707
+ key: 0,
2708
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-error"
2709
+ }, bs = {
2710
+ key: 1,
2711
+ class: "fm-typo-en-body-sm-400 mt-[4px] flex items-center gap-[8px] text-fm-color-typo-secondary"
2712
+ }, gs = ["data-testid", "value", "aria-label", "onChange"], hs = {
2713
+ value: "",
2714
+ disabled: ""
2715
+ }, ks = ["value"], _s = 999, xs = /* @__PURE__ */ Y({
2716
+ __name: "ProductionRunDuplicateDialog",
2717
+ props: {
2718
+ show: { type: Boolean },
2719
+ runs: {},
2720
+ catalog: {},
2721
+ currentSkuIds: {},
2722
+ currentRunId: { default: void 0 }
2723
+ },
2724
+ emits: ["update:show", "select"],
2725
+ setup(s, { emit: e }) {
2726
+ const t = s, l = e, o = N("source"), { t: r } = de(), c = S(
2727
+ () => r(
2728
+ o.value === "source" ? "inventory.production.run.form.duplicate.title" : "inventory.production.run.form.duplicate.itemsTitle"
2729
+ )
2730
+ ), a = N(null), n = N(/* @__PURE__ */ new Set()), f = N(/* @__PURE__ */ new Map()), w = N(null), U = /* @__PURE__ */ new Map(), _ = N(null), b = N(null), R = N(null);
2731
+ let T = null;
2732
+ const {
2733
+ scroller: z,
2734
+ canScrollFurther: D,
2735
+ onScroll: g
2736
+ } = nt();
2737
+ function te(d) {
2738
+ var $;
2739
+ const v = d;
2740
+ typeof (v == null ? void 0 : v.focus) == "function" ? v.focus() : ($ = v == null ? void 0 : v.$el) == null || $.focus();
2741
+ }
2742
+ function J() {
2743
+ T !== null && clearTimeout(T), he(() => {
2744
+ !t.show || !w.value || (T = setTimeout(() => {
2745
+ te(w.value), T = null;
2746
+ }));
2747
+ });
2748
+ }
2749
+ function L(d, v, $) {
2750
+ const p = $;
2751
+ p ? U.set(d, p) : U.delete(d), v === 0 && (w.value = p);
2752
+ }
2753
+ const q = S({
2754
+ get: () => t.show,
2755
+ set: (d) => l("update:show", d)
2756
+ });
2757
+ We(() => {
2758
+ T !== null && clearTimeout(T);
2759
+ });
2760
+ const A = S(
2761
+ () => t.runs.filter((d) => d._id !== t.currentRunId && d.items.length > 0).sort((d, v) => {
2762
+ var O, F;
2763
+ const $ = ((O = vt(d)) == null ? void 0 : O.at) ?? d.createdAt, p = ((F = vt(v)) == null ? void 0 : F.at) ?? v.createdAt;
2764
+ return Date.parse(p) - Date.parse($) || v.runNo - d.runNo;
2765
+ })
2766
+ ), j = S(() => A.value.find((d) => d._id === a.value) ?? null), x = S(() => new Map(t.catalog.map((d) => [d._id, d]))), C = S(() => {
2767
+ var v;
2768
+ const d = /* @__PURE__ */ new Map();
2769
+ for (const $ of ((v = j.value) == null ? void 0 : v.items) ?? []) {
2770
+ const p = d.get($.skuId) ?? [];
2771
+ p.push($), d.set($.skuId, p);
2772
+ }
2773
+ return [...d.entries()].map(([$, p]) => {
2774
+ const O = x.value.get($), F = O ? p.map((le) => qe(le.measurement, O.unit)).filter($e) : [], W = !!O && p.every((le) => !!qe(le.measurement, O.unit)), Q = F.length === p.length && !!F[0] && F.every((le) => ct(le, F[0])), re = !!O && !W && (p.length === 1 || Q);
2775
+ return {
2776
+ skuId: $,
2777
+ items: p,
2778
+ sku: O,
2779
+ overlap: t.currentSkuIds.includes($),
2780
+ storedUnitResolved: W,
2781
+ canChooseOriginalUnit: re,
2782
+ ambiguousStoredUnit: !!O && !W && !re,
2783
+ unitResolved: W || re && f.value.has($)
2784
+ };
2785
+ });
2786
+ }), _e = S(() => n.value.size), Fe = S(
2787
+ () => C.value.filter((d) => d.overlap && n.value.has(d.skuId)).length
2788
+ ), xe = S(
2789
+ () => C.value.filter(
2790
+ (d) => !!d.sku && d.unitResolved && n.value.has(d.skuId)
2791
+ )
2792
+ ), ve = S(() => xe.value.filter((d) => !d.overlap)), Ue = S(
2793
+ () => C.value.some((d) => !!d.sku && !d.unitResolved)
2794
+ ), Ne = S(
2795
+ () => {
2796
+ var d;
2797
+ return ((d = C.value.find((v) => !!v.sku && v.unitResolved)) == null ? void 0 : d.skuId) ?? null;
2798
+ }
2799
+ ), Oe = S(
2800
+ () => {
2801
+ var d;
2802
+ return ((d = C.value.find((v) => !!v.sku && v.canChooseOriginalUnit)) == null ? void 0 : d.skuId) ?? null;
2803
+ }
2804
+ ), Se = S(
2805
+ () => ve.value.length && ve.value.length <= _s ? r(
2806
+ "inventory.production.run.form.duplicate.addCount",
2807
+ { count: ve.value.length },
2808
+ ve.value.length
2809
+ ) : r("inventory.production.run.form.duplicate.addItems")
2810
+ ), ce = (d) => et(d, r("inventory.production.run.list.untitled")), Ce = S(() => j.value ? ce(j.value) : ""), Pe = S(
2811
+ () => o.value === "source" ? r("inventory.production.run.form.duplicate.description") : r("inventory.production.run.form.duplicate.fromSource", { name: Ce.value })
2812
+ ), Me = S(
2813
+ () => r(
2814
+ o.value === "source" ? "inventory.production.run.form.duplicate.guidanceSource" : t.currentSkuIds.length ? "inventory.production.run.form.duplicate.guidanceItems" : "inventory.production.run.form.duplicate.guidanceEmpty"
2815
+ )
2816
+ );
2817
+ ke(
2818
+ () => t.show,
2819
+ (d) => {
2820
+ d && (o.value = "source", a.value = null, n.value = /* @__PURE__ */ new Set(), f.value = /* @__PURE__ */ new Map(), J());
2821
+ },
2822
+ { immediate: !0 }
2823
+ );
2824
+ function I(d) {
2825
+ return r(
2826
+ "inventory.production.run.form.duplicate.itemCount",
2827
+ { count: d.items.length },
2828
+ d.items.length
2829
+ );
2830
+ }
2831
+ function K() {
2832
+ j.value && (n.value = new Set(
2833
+ C.value.filter((d) => !!d.sku).map((d) => d.skuId)
2834
+ ), f.value = /* @__PURE__ */ new Map(), _.value = null, b.value = null, o.value = "items", he(() => te(_.value ?? b.value ?? R.value)));
2835
+ }
2836
+ function X(d) {
2837
+ a.value = d;
2838
+ }
2839
+ function me() {
2840
+ o.value = "source", he(
2841
+ () => te(
2842
+ (a.value ? U.get(a.value) : null) ?? w.value
2843
+ )
2844
+ );
2845
+ }
2846
+ function ae(d, v) {
2847
+ d === Ne.value && (_.value = v);
2848
+ }
2849
+ function Be(d, v) {
2850
+ d === Oe.value && (b.value = v);
2851
+ }
2852
+ function ie(d, v) {
2853
+ const $ = new Set(n.value);
2854
+ v ? $.add(d) : $.delete(d), n.value = $;
2855
+ }
2856
+ function st(d) {
2857
+ return [
2858
+ { id: d.unit._id, label: d.unit.abbrev },
2859
+ ...d.unit.measurements.map((v) => ({
2860
+ id: v.id,
2861
+ label: v.abbrev
2862
+ }))
2863
+ ];
2864
+ }
2865
+ function it(d, v) {
2866
+ const $ = x.value.get(d);
2867
+ if (!$) return;
2868
+ const p = v === $.unit._id ? Le($.unit) : (() => {
2869
+ const F = $.unit.measurements.find((W) => W.id === v);
2870
+ return F ? $t($.unit, F) : null;
2871
+ })(), O = new Map(f.value);
2872
+ p ? O.set(d, p) : O.delete(d), f.value = O;
2873
+ }
2874
+ function h(d, v, $) {
2875
+ const p = (v ? qe(d.measurement, v.unit) : null) ?? $, O = p == null ? void 0 : p.abbrev, F = fe(d.requestedAmount, O, {
2876
+ precision: d.requestedAmount.precision
2877
+ });
2878
+ return O ? F : `${F} · ${r("inventory.production.run.list.itemsUnitUnresolved")}`;
2879
+ }
2880
+ function V(d) {
2881
+ const v = f.value.get(d.skuId);
2882
+ return d.items.map(($) => h($, d.sku, v)).join(" + ");
2883
+ }
2884
+ function P(d) {
2885
+ if (!j.value) return;
2886
+ const v = d === "add" ? ve.value : xe.value;
2887
+ v.length !== 0 && (l("select", {
2888
+ sourceRunId: j.value._id,
2889
+ skuIds: v.map(($) => $.skuId),
2890
+ mode: d,
2891
+ measurementOverrides: Object.fromEntries(
2892
+ v.flatMap(($) => {
2893
+ const p = f.value.get($.skuId);
2894
+ return p ? [[$.skuId, p]] : [];
2895
+ })
2896
+ )
2897
+ }), q.value = !1);
2898
+ }
2899
+ return (d, v) => {
2900
+ const $ = Z("FmButton");
2901
+ return m(), M(rt, {
2902
+ class: "production-run-duplicate-dialog",
2903
+ "model-value": q.value,
2904
+ title: c.value,
2905
+ description: Pe.value,
2906
+ notice: Me.value,
2907
+ "close-label": i(r)("inventory.production.run.form.duplicate.dismiss"),
2908
+ "max-width": "min(calc(100% - 32px), 672px)",
2909
+ "onUpdate:modelValue": v[7] || (v[7] = (p) => q.value = p)
2910
+ }, {
2911
+ footer: H(() => [
2912
+ u("div", {
2913
+ "data-testid": "production-run-duplicate-footer",
2914
+ class: G(["production-run-duplicate-footer flex w-full items-center justify-end gap-8", o.value === "items" && "production-run-duplicate-footer--items"])
2915
+ }, [
2916
+ E($, {
2917
+ ref: (p) => R.value = p,
2918
+ variant: "tertiary",
2919
+ label: o.value === "items" ? i(r)("inventory.production.run.form.duplicate.back") : i(r)("inventory.production.run.form.duplicate.cancel"),
2920
+ onClick: v[4] || (v[4] = (p) => o.value === "items" ? me() : q.value = !1)
2921
+ }, null, 8, ["label"]),
2922
+ o.value === "source" ? (m(), M($, {
2923
+ key: 0,
2924
+ label: i(r)("inventory.production.run.form.duplicate.next"),
2925
+ disabled: !a.value,
2926
+ onClick: K
2927
+ }, null, 8, ["label", "disabled"])) : d.currentSkuIds.length ? (m(), M($, {
2928
+ key: 1,
2929
+ variant: "destructive",
2930
+ label: i(r)("inventory.production.run.form.duplicate.replace"),
2931
+ disabled: Ue.value || xe.value.length === 0,
2932
+ onClick: v[5] || (v[5] = (p) => P("replace"))
2933
+ }, null, 8, ["label", "disabled"])) : B("", !0),
2934
+ o.value === "items" ? (m(), M($, {
2935
+ key: 2,
2936
+ label: Se.value,
2937
+ disabled: Ue.value || ve.value.length === 0,
2938
+ onClick: v[6] || (v[6] = (p) => P("add"))
2939
+ }, null, 8, ["label", "disabled"])) : B("", !0)
2940
+ ], 2)
2941
+ ]),
2942
+ default: H(() => [
2943
+ u("div", Xr, [
2944
+ o.value === "source" ? (m(), k(ee, { key: 0 }, [
2945
+ A.value.length === 0 ? (m(), k("div", Zr, y(i(r)("inventory.production.run.form.duplicate.empty")), 1)) : (m(), k("div", {
2946
+ key: 1,
2947
+ ref_key: "duplicateScroll",
2948
+ ref: z,
2949
+ role: "radiogroup",
2950
+ "data-testid": "production-run-duplicate-source-list",
2951
+ class: "production-run-dialog-content--full-bleed min-h-0 max-h-[320px] flex-1 overflow-y-auto border-b border-fm-color-neutral-gray-200 p-12",
2952
+ "aria-label": i(r)("inventory.production.run.form.duplicate.title"),
2953
+ onScroll: v[0] || (v[0] = //@ts-ignore
2954
+ (...p) => i(g) && i(g)(...p))
2955
+ }, [
2956
+ u("div", ts, [
2957
+ (m(!0), k(ee, null, pe(A.value, (p, O) => (m(), M(Yr, {
2958
+ key: p._id,
2959
+ "data-testid": `production-run-duplicate-source-row-${p._id}`,
2960
+ ref_for: !0,
2961
+ ref: (F) => {
2962
+ L(p._id, O, F);
2963
+ },
2964
+ "model-value": a.value,
2965
+ value: p._id,
2966
+ "accessible-label": ce(p),
2967
+ name: "production-run-duplicate-source",
2968
+ class: "production-run-source-option fm-corner-radius-md hover:bg-fm-color-opacity-sm",
2969
+ "onUpdate:modelValue": X
2970
+ }, {
2971
+ default: H(() => [
2972
+ u("div", os, [
2973
+ u("span", ns, y(ce(p)), 1),
2974
+ u("span", rs, " #" + y(p.runNo) + " · " + y(I(p)) + " · " + y(i(r)(`inventory.production.run.list.status.${p.status}`)), 1)
2975
+ ])
2976
+ ]),
2977
+ _: 2
2978
+ }, 1032, ["data-testid", "model-value", "value", "accessible-label"]))), 128))
2979
+ ]),
2980
+ E(Ge, {
2981
+ visible: i(D),
2982
+ testid: "production-run-duplicate-source-scroll-hint"
2983
+ }, null, 8, ["visible"])
2984
+ ], 40, es))
2985
+ ], 64)) : (m(), k(ee, { key: 1 }, [
2986
+ u("div", ss, [
2987
+ u("span", is, y(i(r)("inventory.production.run.form.duplicate.selectionSummary", {
2988
+ selected: _e.value
2989
+ })), 1),
2990
+ Fe.value ? (m(), k("span", as, y(i(r)("inventory.production.run.form.duplicate.overlapSummary", { overlap: Fe.value })), 1)) : B("", !0)
2991
+ ]),
2992
+ u("div", {
2993
+ ref_key: "duplicateScroll",
2994
+ ref: z,
2995
+ "data-testid": "production-run-duplicate-item-list",
2996
+ class: "production-run-dialog-content--full-bleed production-run-duplicate-item-list min-h-0 max-h-[320px] overflow-y-auto border-b border-fm-color-neutral-gray-200 py-[4px]",
2997
+ onScroll: v[3] || (v[3] = //@ts-ignore
2998
+ (...p) => i(g) && i(g)(...p))
2999
+ }, [
3000
+ (m(!0), k(ee, null, pe(C.value, (p) => {
3001
+ var O, F, W;
3002
+ return m(), k("div", {
3003
+ key: p.skuId,
3004
+ "data-testid": `production-run-duplicate-item-row-${p.skuId}`,
3005
+ class: G([
3006
+ "fm-corner-radius-md flex items-start gap-[8px] px-[20px] py-[8px] hover:bg-fm-color-opacity-sm",
3007
+ !p.sku || !p.unitResolved ? "cursor-not-allowed opacity-60" : "cursor-pointer"
3008
+ ]),
3009
+ onClick: (Q) => p.sku && p.unitResolved && ie(p.skuId, !n.value.has(p.skuId))
3010
+ }, [
3011
+ E(Xe, {
3012
+ ref_for: !0,
3013
+ ref: (Q) => ae(p.skuId, Q),
3014
+ "model-value": n.value.has(p.skuId),
3015
+ disabled: !p.sku || !p.unitResolved,
3016
+ "accessible-label": ((O = p.sku) == null ? void 0 : O.name) ?? p.skuId,
3017
+ value: p.skuId,
3018
+ class: "mt-[1px] shrink-0",
3019
+ onClick: v[1] || (v[1] = Ae(() => {
3020
+ }, ["stop"])),
3021
+ "onUpdate:modelValue": (Q) => ie(p.skuId, Q)
3022
+ }, null, 8, ["model-value", "disabled", "accessible-label", "value", "onUpdate:modelValue"]),
3023
+ u("span", us, [
3024
+ u("span", ds, [
3025
+ u("strong", cs, y(((F = p.sku) == null ? void 0 : F.name) ?? i(r)("inventory.production.run.form.duplicate.unavailable", {
3026
+ id: p.skuId
3027
+ })), 1),
3028
+ p.overlap ? (m(), k("span", ms, y(i(r)("inventory.production.run.form.duplicate.alreadyInPlan")), 1)) : p.sku ? p.unitResolved ? B("", !0) : (m(), k("span", fs, y(i(r)("inventory.production.run.list.itemsUnitUnresolved")), 1)) : (m(), k("span", ps, y(i(r)("inventory.production.run.form.duplicate.noLongerAvailable")), 1))
3029
+ ]),
3030
+ u("span", vs, y(V(p)), 1),
3031
+ p.ambiguousStoredUnit ? (m(), k("span", ys, y(i(r)("inventory.production.run.form.duplicate.ambiguousRepeatedUnit")), 1)) : B("", !0),
3032
+ p.sku && p.canChooseOriginalUnit ? (m(), k("label", bs, [
3033
+ u("span", {
3034
+ class: G([
3035
+ "min-w-0 flex-1",
3036
+ p.unitResolved ? "text-fm-color-typo-secondary" : "text-fm-color-typo-error"
3037
+ ])
3038
+ }, y(i(r)("inventory.production.run.form.duplicate.unitUnresolved")), 3),
3039
+ u("select", {
3040
+ ref_for: !0,
3041
+ ref: (Q) => Be(p.skuId, Q),
3042
+ "data-testid": `production-run-duplicate-unit-${p.skuId}`,
3043
+ class: "fm-corner-radius-md h-[36px] w-[112px] shrink-0 border border-fm-color-neutral-gray-300 bg-white px-[8px] text-fm-color-typo-primary",
3044
+ value: ((W = f.value.get(p.skuId)) == null ? void 0 : W.id) ?? "",
3045
+ "aria-label": i(r)("inventory.production.run.form.duplicate.chooseOriginalUnitFor", {
3046
+ name: p.sku.name
3047
+ }),
3048
+ onClick: v[2] || (v[2] = Ae(() => {
3049
+ }, ["stop"])),
3050
+ onChange: (Q) => it(p.skuId, Q.target.value)
3051
+ }, [
3052
+ u("option", hs, y(i(r)("inventory.production.run.form.duplicate.chooseOriginalUnitPlaceholder")), 1),
3053
+ (m(!0), k(ee, null, pe(st(p.sku), (Q) => (m(), k("option", {
3054
+ key: Q.id,
3055
+ value: Q.id
3056
+ }, y(Q.label), 9, ks))), 128))
3057
+ ], 40, gs)
3058
+ ])) : B("", !0)
3059
+ ])
3060
+ ], 10, ls);
3061
+ }), 128)),
3062
+ E(Ge, {
3063
+ visible: i(D),
3064
+ testid: "production-run-duplicate-item-scroll-hint"
3065
+ }, null, 8, ["visible"])
3066
+ ], 544)
3067
+ ], 64))
3068
+ ])
3069
+ ]),
3070
+ _: 1
3071
+ }, 8, ["model-value", "title", "description", "notice", "close-label"]);
3072
+ };
3073
+ }
3074
+ }), ws = /* @__PURE__ */ Ie(xs, [["__scopeId", "data-v-59cc3003"]]), $s = {
3075
+ "data-testid": "production-run-details-grid",
3076
+ class: "grid grid-cols-1 items-start gap-x-16 gap-y-8 md:grid-cols-[3fr_2fr] lg:grid-cols-[3fr_2fr]"
3077
+ }, Is = {
3078
+ "data-testid": "production-run-name-field",
3079
+ class: "production-run-name min-w-0"
3080
+ }, Ss = {
3081
+ key: 1,
3082
+ class: "flex justify-center py-32"
3083
+ }, Cs = {
3084
+ "data-testid": "production-run-form-footer",
3085
+ class: "production-run-form-footer flex w-full flex-row flex-wrap items-center justify-between gap-4"
3086
+ }, Rs = {
3087
+ "data-testid": "production-run-form-primary-actions",
3088
+ class: "production-run-form-primary-actions flex w-auto flex-row gap-8"
3089
+ }, As = /* @__PURE__ */ Y({
3090
+ __name: "ProductionRunFormDialog",
3091
+ props: {
3092
+ show: { type: Boolean },
3093
+ run: {},
3094
+ duplicateSources: {}
3095
+ },
3096
+ emits: ["update:show", "saved"],
3097
+ setup(s, { emit: e }) {
3098
+ const t = s, l = e, { t: o } = de(), r = Lt(), c = qt(), a = _t(), n = co(), f = N(!1), w = N(!1), U = N(!1), _ = N(null);
3099
+ let b = null;
3100
+ async function R() {
3101
+ await n.load() && t.run && n.seedFrom(t.run);
3102
+ }
3103
+ const T = S(() => !!t.run), z = S(
3104
+ () => (t.duplicateSources ?? []).filter(
3105
+ (I) => {
3106
+ var K;
3107
+ return I._id !== ((K = t.run) == null ? void 0 : K._id) && I.items.length > 0;
3108
+ }
3109
+ )
3110
+ ), D = S(
3111
+ () => T.value ? o("inventory.production.run.form.edit.title") : o("inventory.production.run.form.create.title")
3112
+ ), g = S(() => {
3113
+ const I = a._currentLocation;
3114
+ return I ? `${I.name} (${I.doc.profile.code ?? "--"})` : o("inventory.production.run.form.noLocation");
3115
+ });
3116
+ ke(
3117
+ () => t.show,
3118
+ async (I) => {
3119
+ I && (f.value = !1, n.reset(), await R());
3120
+ },
3121
+ { immediate: !0 }
3122
+ );
3123
+ const te = S(() => {
3124
+ const I = n.duplicateMerges.value;
3125
+ if (!I.length) return null;
3126
+ const K = I.map((X) => {
3127
+ const me = X.sources.map((ae) => fe(ae.amount, ae.unit)).join(" + ");
3128
+ return X.amount == null ? o("inventory.production.run.form.duplicates.unresolvedLine", {
3129
+ name: X.name,
3130
+ sources: me
3131
+ }) : o("inventory.production.run.form.duplicates.line", {
3132
+ name: X.name,
3133
+ sources: me,
3134
+ combined: fe(X.amount, X.unit)
3135
+ });
3136
+ });
3137
+ return o("inventory.production.run.form.duplicates.message", { lines: K.join(" ") });
3138
+ });
3139
+ function J() {
3140
+ if (!n.submitting.value) {
3141
+ if (!n.dirty.value) {
3142
+ l("update:show", !1);
3143
+ return;
3144
+ }
3145
+ U.value = !0;
3146
+ }
3147
+ }
3148
+ function L() {
3149
+ n.submitting.value || (U.value = !1, n.reset(), l("update:show", !1));
3150
+ }
3151
+ function q() {
3152
+ var me;
3153
+ const I = (me = _.value) == null ? void 0 : me.closest(
3154
+ '.production-run-side-sheet, [role="dialog"][aria-modal="true"]'
3155
+ ), X = [
3156
+ ...document.querySelectorAll('.fm-dialog, [role="dialog"][aria-modal="true"]')
3157
+ ].filter(
3158
+ (ae) => !ae.hidden && ae.getAttribute("aria-hidden") !== "true" && ae.style.display !== "none"
3159
+ ).at(-1);
3160
+ return !!X && X !== I;
3161
+ }
3162
+ function A(I) {
3163
+ !t.show || I.key !== "Escape" || f.value || w.value || U.value || q() || (I.preventDefault(), I.stopPropagation(), I.stopImmediatePropagation(), I.type === "keyup" && J());
3164
+ }
3165
+ Te(() => {
3166
+ window.addEventListener("keydown", A, !0), window.addEventListener("keyup", A, !0);
3167
+ }), We(() => {
3168
+ window.removeEventListener("keydown", A, !0), window.removeEventListener("keyup", A, !0);
3169
+ });
3170
+ function j(I) {
3171
+ I || J();
3172
+ }
3173
+ function x() {
3174
+ b = document.activeElement instanceof HTMLElement ? document.activeElement : null, w.value = !0;
3175
+ }
3176
+ function C() {
3177
+ b = document.activeElement instanceof HTMLElement ? document.activeElement : null, f.value = !0;
3178
+ }
3179
+ async function _e() {
3180
+ const I = b;
3181
+ b = null, await he(), I == null || I.focus();
3182
+ }
3183
+ function Fe(I) {
3184
+ w.value = I, I || _e();
3185
+ }
3186
+ function xe(I) {
3187
+ f.value = I, I || _e();
3188
+ }
3189
+ function ve(I) {
3190
+ n.addItems(I);
3191
+ }
3192
+ async function Ue() {
3193
+ var K, X;
3194
+ await he();
3195
+ const I = n.items.value.length ? '[data-testid="production-run-item-actions"]' : '[data-testid="production-run-add-items"]';
3196
+ (X = (K = _.value) == null ? void 0 : K.querySelector(I)) == null || X.focus();
3197
+ }
3198
+ function Ne() {
3199
+ const I = n.items.value.length;
3200
+ I && r.open({
3201
+ title: o("inventory.production.run.form.items.clearConfirm.title"),
3202
+ message: o(
3203
+ I === 1 ? "inventory.production.run.form.items.clearConfirm.messageOne" : "inventory.production.run.form.items.clearConfirm.message",
3204
+ { count: I }
3205
+ ),
3206
+ primaryActions: {
3207
+ text: o("inventory.production.run.form.items.clearConfirm.confirm"),
3208
+ close: !0,
3209
+ variant: "destructive"
3210
+ },
3211
+ secondaryActions: {
3212
+ text: o("inventory.production.run.form.items.clearConfirm.keep"),
3213
+ close: !0,
3214
+ variant: "tertiary"
3215
+ }
3216
+ }).onPrimary(() => {
3217
+ n.clearAll();
3218
+ }).onClose(Ue);
3219
+ }
3220
+ async function Oe(I) {
3221
+ const K = z.value.find((X) => X._id === I.sourceRunId);
3222
+ K && (n.duplicateItems(K, I.skuIds, I.mode, I.measurementOverrides), await n.refreshStock());
3223
+ }
3224
+ function Se(I, K) {
3225
+ const X = ut(K);
3226
+ c == null || c.open({ title: o(I), message: X.message, type: "error" });
3227
+ }
3228
+ async function ce() {
3229
+ if (!n.submitting.value)
3230
+ try {
3231
+ const I = t.run ? await n.updateDraft(t.run._id) : await n.createDraft();
3232
+ c == null || c.open({
3233
+ title: o(
3234
+ t.run ? "inventory.production.run.form.success.updated" : "inventory.production.run.form.success.draft",
3235
+ {
3236
+ name: et(I, o("inventory.production.run.list.untitled"))
3237
+ }
3238
+ ),
3239
+ type: "success"
3240
+ }), n.dirty.value = !1, l("saved", I), l("update:show", !1);
3241
+ } catch (I) {
3242
+ Se(
3243
+ t.run ? "inventory.production.run.form.error.update" : "inventory.production.run.form.error.save",
3244
+ I
3245
+ );
3246
+ }
3247
+ }
3248
+ async function Ce() {
3249
+ var I;
3250
+ if (!n.submitting.value)
3251
+ try {
3252
+ const K = await n.createAndRequest(), X = et(K.run, o("inventory.production.run.list.untitled"));
3253
+ K.requested ? c == null || c.open({
3254
+ title: o("inventory.production.run.form.success.submitted", { name: X }),
3255
+ type: "success"
3256
+ }) : c == null || c.open({
3257
+ title: o("inventory.production.run.form.error.submitPartial", { name: X }),
3258
+ message: (I = K.failure) == null ? void 0 : I.message,
3259
+ type: "warning"
3260
+ }), n.dirty.value = !1, l("saved", K.run), l("update:show", !1);
3261
+ } catch (K) {
3262
+ Se("inventory.production.run.form.error.save", K);
3263
+ }
3264
+ }
3265
+ function Pe() {
3266
+ n.submitting.value || r.open(lo(o)).onPrimary(() => void Ce());
3267
+ }
3268
+ function Me() {
3269
+ n.retryProjection();
3270
+ }
3271
+ return (I, K) => {
3272
+ var Be;
3273
+ const X = Z("FmTextField"), me = Z("FmCircularProgress"), ae = Z("FmButton");
3274
+ return m(), k(ee, null, [
3275
+ E(vr, {
3276
+ "model-value": I.show,
3277
+ title: D.value,
3278
+ subtitle: i(o)("inventory.production.run.form.forLocation", { location: g.value }),
3279
+ "close-label": i(o)("inventory.production.run.form.dismiss"),
3280
+ "initial-focus": "[data-testid='production-run-name-field'] input",
3281
+ "container-class": "production-run-form-sheet",
3282
+ "dismiss-away": !i(n).dirty.value && !i(n).submitting.value,
3283
+ "hide-close": i(n).submitting.value,
3284
+ onRequestClose: J,
3285
+ "onUpdate:modelValue": j
3286
+ }, {
3287
+ default: H(() => [
3288
+ u("div", {
3289
+ ref_key: "formContent",
3290
+ ref: _,
3291
+ class: "production-run-form-content flex min-w-0 flex-col gap-16"
3292
+ }, [
3293
+ u("div", $s, [
3294
+ u("div", Is, [
3295
+ E(X, {
3296
+ "model-value": i(n).runName.value,
3297
+ label: i(o)("inventory.production.run.form.runName"),
3298
+ placeholder: i(o)("inventory.production.run.form.runNamePlaceholder"),
3299
+ "label-mark": "optional",
3300
+ "onUpdate:modelValue": K[0] || (K[0] = (ie) => i(n).updateRunName(ie ?? ""))
3301
+ }, null, 8, ["model-value", "label", "placeholder"])
3302
+ ]),
3303
+ E(br, {
3304
+ "data-testid": "production-run-instructions-field",
3305
+ rows: 1,
3306
+ "model-value": i(n).instructions.value,
3307
+ label: i(o)("inventory.production.run.form.instructions"),
3308
+ placeholder: i(o)("inventory.production.run.form.instructionsPlaceholder"),
3309
+ "label-mark": "optional",
3310
+ "onUpdate:modelValue": K[1] || (K[1] = (ie) => i(n).updateInstructions(ie ?? ""))
3311
+ }, null, 8, ["model-value", "label", "placeholder"])
3312
+ ]),
3313
+ te.value ? (m(), M(mt, {
3314
+ key: 0,
3315
+ tone: "warn",
3316
+ title: i(o)("inventory.production.run.form.duplicates.title"),
3317
+ message: te.value
3318
+ }, null, 8, ["title", "message"])) : B("", !0),
3319
+ E(gr, {
3320
+ "load-failure": i(n).loadFailure.value,
3321
+ "projection-failed": i(n).projectionFailed.value,
3322
+ onRetryLoad: R,
3323
+ onRetryProjection: Me
3324
+ }, null, 8, ["load-failure", "projection-failed"]),
3325
+ i(n).loading.value ? (m(), k("div", Ss, [
3326
+ E(me, { size: "lg" })
3327
+ ])) : i(n).loadFailure.value ? B("", !0) : (m(), M(sr, {
3328
+ key: 2,
3329
+ items: i(n).items.value,
3330
+ commits: i(n).commits.value,
3331
+ "can-duplicate": "",
3332
+ onAdd: x,
3333
+ onDuplicate: C,
3334
+ onClear: Ne,
3335
+ onRemove: i(n).removeItem,
3336
+ "onUpdate:item": i(n).updateItemModel
3337
+ }, null, 8, ["items", "commits", "onRemove", "onUpdate:item"]))
3338
+ ], 512)
3339
+ ]),
3340
+ footer: H(() => [
3341
+ u("div", Cs, [
3342
+ E(ae, {
3343
+ class: "shrink-0",
3344
+ variant: "tertiary",
3345
+ label: i(o)("inventory.production.run.form.actions.cancel"),
3346
+ disabled: i(n).submitting.value,
3347
+ onClick: J
3348
+ }, null, 8, ["label", "disabled"]),
3349
+ u("div", Rs, [
3350
+ E(ae, {
3351
+ variant: "secondary",
3352
+ label: T.value ? i(o)("inventory.production.run.form.actions.saveChanges") : i(o)("inventory.production.run.form.actions.saveDraft"),
3353
+ class: "shrink-0",
3354
+ disabled: !i(n).canSubmit.value || i(n).submitting.value,
3355
+ loading: i(n).submitting.value,
3356
+ onClick: ce
3357
+ }, null, 8, ["label", "disabled", "loading"]),
3358
+ T.value ? B("", !0) : (m(), M(ae, {
3359
+ key: 0,
3360
+ label: i(o)("inventory.production.run.form.actions.submitRequest"),
3361
+ class: "shrink-0",
3362
+ disabled: !i(n).canRequest.value || i(n).submitting.value,
3363
+ loading: i(n).submitting.value,
3364
+ onClick: Pe
3365
+ }, null, 8, ["label", "disabled", "loading"]))
3366
+ ])
3367
+ ])
3368
+ ]),
3369
+ _: 1
3370
+ }, 8, ["model-value", "title", "subtitle", "close-label", "dismiss-away", "hide-close"]),
3371
+ f.value ? (m(), M(ws, {
3372
+ key: 0,
3373
+ show: !0,
3374
+ runs: z.value,
3375
+ catalog: i(n).candidates.value.map((ie) => ie.sku),
3376
+ "current-sku-ids": i(n).items.value.map((ie) => ie.skuId),
3377
+ "current-run-id": (Be = I.run) == null ? void 0 : Be._id,
3378
+ "onUpdate:show": xe,
3379
+ onSelect: Oe
3380
+ }, null, 8, ["runs", "catalog", "current-sku-ids", "current-run-id"])) : B("", !0),
3381
+ w.value ? (m(), M(Wr, {
3382
+ key: 1,
3383
+ show: !0,
3384
+ candidates: i(n).candidates.value,
3385
+ "existing-sku-ids": i(n).items.value.map((ie) => ie.skuId),
3386
+ "onUpdate:show": Fe,
3387
+ onSelect: ve
3388
+ }, null, 8, ["candidates", "existing-sku-ids"])) : B("", !0),
3389
+ U.value ? (m(), M(kr, {
3390
+ key: 2,
3391
+ show: !0,
3392
+ "onUpdate:show": K[2] || (K[2] = (ie) => U.value = ie),
3393
+ onDiscard: L
3394
+ })) : B("", !0)
3395
+ ], 64);
3396
+ };
3397
+ }
3398
+ }), Js = /* @__PURE__ */ Ie(As, [["__scopeId", "data-v-1d7a9efc"]]), Fs = ["aria-label"], Us = ["id", "aria-selected", "aria-controls", "tabindex", "onClick", "onKeydown"], Ps = {
3399
+ key: 0,
3400
+ "data-testid": "production-run-tab-badge",
3401
+ class: "fm-typo-en-label-sm-600 min-w-[20px] rounded-full bg-fm-color-system-error-400 px-[6px] py-[2px] text-center text-white"
3402
+ }, Ys = /* @__PURE__ */ Y({
3403
+ __name: "ProductionRunTabs",
3404
+ props: {
3405
+ items: {},
3406
+ modelValue: {},
3407
+ ariaLabel: {},
3408
+ density: {}
3409
+ },
3410
+ emits: ["update:modelValue"],
3411
+ setup(s, { emit: e }) {
3412
+ const t = s, l = e, o = N([]);
3413
+ function r(a, n = !1) {
3414
+ const f = t.items[a];
3415
+ f && (l("update:modelValue", f.value), n && he(() => {
3416
+ var w;
3417
+ return (w = o.value[a]) == null ? void 0 : w.focus();
3418
+ }));
3419
+ }
3420
+ function c(a, n) {
3421
+ let f = null;
3422
+ a.key === "ArrowRight" && (f = (n + 1) % t.items.length), a.key === "ArrowLeft" && (f = (n - 1 + t.items.length) % t.items.length), a.key === "Home" && (f = 0), a.key === "End" && (f = t.items.length - 1), f !== null && (a.preventDefault(), r(f, !0));
3423
+ }
3424
+ return ke(
3425
+ () => t.modelValue,
3426
+ async (a) => {
3427
+ var f, w;
3428
+ await he();
3429
+ const n = t.items.findIndex((U) => U.value === a);
3430
+ (w = (f = o.value[n]) == null ? void 0 : f.scrollIntoView) == null || w.call(f, { block: "nearest", inline: "nearest" });
3431
+ },
3432
+ { immediate: !0 }
3433
+ ), (a, n) => (m(), k("nav", {
3434
+ role: "tablist",
3435
+ "aria-label": a.ariaLabel,
3436
+ class: G(["overflow-x-auto", a.density === "detail" && "print:hidden"])
3437
+ }, [
3438
+ u("div", {
3439
+ class: G(["flex min-w-max items-center", a.density === "list" ? "border-b border-fm-color-neutral-gray-100" : "gap-8"])
3440
+ }, [
3441
+ (m(!0), k(ee, null, pe(a.items, (f, w) => (m(), k("button", {
3442
+ id: f.id,
3443
+ key: f.value,
3444
+ ref_for: !0,
3445
+ ref: (U) => o.value[w] = U,
3446
+ type: "button",
3447
+ role: "tab",
3448
+ "aria-selected": a.modelValue === f.value,
3449
+ "aria-controls": f.controls,
3450
+ tabindex: a.modelValue === f.value ? 0 : -1,
3451
+ class: G(["shrink-0 border-b-2 px-12 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-fm-color-border-focused", [
3452
+ a.density === "list" ? "fm-typo-en-body-md-400 flex h-[44px] items-center gap-[6px]" : "flex h-40 items-center gap-[6px] text-[14px] leading-[18px]",
3453
+ a.modelValue === f.value ? "border-fm-color-primary font-semibold text-fm-color-primary" : "border-transparent font-normal text-fm-color-typo-secondary hover:text-fm-color-typo-primary"
3454
+ ]]),
3455
+ onClick: (U) => r(w),
3456
+ onKeydown: (U) => c(U, w)
3457
+ }, [
3458
+ u("span", null, y(f.label), 1),
3459
+ f.badge && f.badge > 0 ? (m(), k("span", Ps, y(f.badge), 1)) : B("", !0)
3460
+ ], 42, Us))), 128))
3461
+ ], 2)
3462
+ ], 10, Fs));
3463
+ }
3464
+ });
3465
+ export {
3466
+ nt as A,
3467
+ uo as B,
3468
+ gr as C,
3469
+ mt as D,
3470
+ yt as E,
3471
+ vn as F,
3472
+ bt as G,
3473
+ Ge as H,
3474
+ br as I,
3475
+ ge as J,
3476
+ Le as K,
3477
+ sr as L,
3478
+ Ws as P,
3479
+ Ys as _,
3480
+ Gs as a,
3481
+ vt as b,
3482
+ zs as c,
3483
+ Wt as d,
3484
+ Qs as e,
3485
+ Js as f,
3486
+ ut as g,
3487
+ Hs as h,
3488
+ $e as i,
3489
+ Ks as j,
3490
+ zo as k,
3491
+ Zt as l,
3492
+ Xt as m,
3493
+ qo as n,
3494
+ go as o,
3495
+ et as p,
3496
+ mo as q,
3497
+ Do as r,
3498
+ qe as s,
3499
+ Uo as t,
3500
+ zt as u,
3501
+ tt as v,
3502
+ rt as w,
3503
+ vr as x,
3504
+ co as y,
3505
+ po as z
3506
+ };