@feedmepos/mf-inventory-portal 1.8.0-dev.14 → 1.8.0-dev.16

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 (136) hide show
  1. package/dist/{App-CzQWarWw.js → App-xSsyvQV_.js} +515 -536
  2. package/dist/{ApprovalView-DMNKR7wK.js → ApprovalView-DfJ0FAiD.js} +9 -9
  3. package/dist/{BindingsDialog-CxvJTu9s.js → BindingsDialog-oAZyjgrN.js} +2 -2
  4. package/dist/{BindingsPicker-AWSDYiBa.js → BindingsPicker-CEIo7myR.js} +8 -8
  5. package/dist/{BindingsTable-JkouRY4D.js → BindingsTable-BKa-JYRR.js} +4 -4
  6. package/dist/BulkReceiveRequestPage-C6Oyg5-E.js +2839 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CKiD86iq.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BvleQo5y.js} +1 -1
  8. package/dist/{ClosingDraftView-WgUrDT0l.js → ClosingDraftView-tJrjqyAC.js} +19 -19
  9. package/dist/{ClosingHistoryView-BXaFh_Rr.js → ClosingHistoryView-CJQlK4Xc.js} +7 -7
  10. package/dist/{ClosingTemplateView-xqSkU-RJ.js → ClosingTemplateView-DYRtdK5h.js} +18 -18
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-VUlMHb_3.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DEwi7wFf.js} +1 -1
  12. package/dist/{DefaultView-d0j4MbPH.js → DefaultView-CxTBlkln.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-ksFXHv4f.js → DeliveryOrderPrintPreview-Bywdjc2U.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-C8XVdGly.js → EmailDialog.vue_vue_type_script_setup_true_lang-DcFAUTdO.js} +38 -33
  15. package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-DTBcxB8e.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-C8c6rmJv.js} +11 -10
  16. package/dist/FeatureCapabilityGate-B41dULfm.js +77 -0
  17. package/dist/FeaturePageGate.vue_vue_type_script_setup_true_lang-D4G6i1D6.js +189 -0
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-2cESr8tE.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CnqH115V.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-sV1ZAWmY.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-QBviJzAO.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CGGNqDIn.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BqHtzo20.js} +2 -2
  21. package/dist/{FmMultiselectDialog-NvS_JqaH.js → FmMultiselectDialog-CFNZMzlC.js} +2 -2
  22. package/dist/{FmMultiselectDialog-fKCMgcn6.js → FmMultiselectDialog-M6CvNFW1.js} +2 -2
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BZYyW6iC.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BGco50Ma.js} +5 -5
  24. package/dist/{ImportView-D-DqrgHA.js → ImportView-C2GOmpuK.js} +6 -6
  25. package/dist/{IngredientsView-gZ8iZciS.js → IngredientsView-wB9kGiOK.js} +15 -15
  26. package/dist/{IntegrationExplorerView-Bz-Tz2L9.js → IntegrationExplorerView-BujwGE4q.js} +1414 -1485
  27. package/dist/{IntegrationPlatformView-WnMM86kt.js → IntegrationPlatformView-Wnvj6-BG.js} +5331 -5028
  28. package/dist/{IntegrationView-CAJJmfis.js → IntegrationView-C77rSbpn.js} +14 -14
  29. package/dist/{InventoryBindingForm-C2Tp1u_B.js → InventoryBindingForm-Bs7Duwfj.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BH8O5C0v.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DawAEeuP.js} +4 -4
  31. package/dist/{InventoryBindingSummary-BrNst2ma.js → InventoryBindingSummary-BefkYWIr.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D_5jwx36.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BpUMK6fj.js} +2 -2
  33. package/dist/PlanTierBadge.vue_vue_type_script_setup_true_lang-CM3gtYZo.js +19 -0
  34. package/dist/{PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-CvXURft2.js → PlanUpgradeDialog.vue_vue_type_script_setup_true_lang-0F-yOcPC.js} +1 -1
  35. package/dist/PremiumUpgradePage.vue_vue_type_script_setup_true_lang-DGAxPOEh.js +58 -0
  36. package/dist/ProductionRunDetailPage-CVx9LS-P.js +2316 -0
  37. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-C9nqRuMd.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-4aYz5NwS.js} +1626 -1712
  38. package/dist/ProductionRunPage-CuXzmWMc.js +953 -0
  39. package/dist/{PublishView-CYIc_f14.js → PublishView-Bu8J6ndy.js} +3 -3
  40. package/dist/{PurchaseOrderPrintPreview-BPrGWnuA.js → PurchaseOrderPrintPreview-DaslFe8u.js} +2 -2
  41. package/dist/{ReceiveRequestView-DeyAASZ5.js → ReceiveRequestView-CKPBpN4x.js} +13 -13
  42. package/dist/{RecipeView-Ig8TlbZH.js → RecipeView-BeZ9ljtA.js} +15 -15
  43. package/dist/{SettingsView-CC5Jmu8c.js → SettingsView-CWhMdNfn.js} +10 -9
  44. package/dist/{StockView-DHUGj4mg.js → StockView-C5IhPGxi.js} +21 -21
  45. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DnFn9Agf.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B9Rx_9b7.js} +1 -1
  46. package/dist/{SupplierView-D1Xp7HM6.js → SupplierView-BSGajl9V.js} +13 -13
  47. package/dist/{SurchargeView-DtIlho7s.js → SurchargeView-DtAszxTN.js} +7 -7
  48. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-Crb3A1_I.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CfxroS8u.js} +2 -2
  49. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BG1ubC4e.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CTj_jYK1.js} +1 -1
  50. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-B_9i5LzY.js +4900 -0
  51. package/dist/{TransferTemplateView-CmWURuLd.js → TransferTemplateView-D6_AfMja.js} +19 -19
  52. package/dist/{UnitCostHistoryView-DRGW-OrJ.js → UnitCostHistoryView-kisQehVE.js} +4 -4
  53. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-B81OEVLz.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-DKoPNZoW.js} +4 -4
  54. package/dist/{UnitView-zDYaqm5D.js → UnitView-jSLennZW.js} +7 -7
  55. package/dist/{WarehouseView-DBCd2vjM.js → WarehouseView-CUdWJCMq.js} +8 -8
  56. package/dist/{WastageTemplateView-Bav8IIF6.js → WastageTemplateView--B0LSwHa.js} +15 -15
  57. package/dist/api/netsuite-explorer.d.ts +1 -0
  58. package/dist/{app-PyK-6tB0.js → app-Bb5HLWTu.js} +2041 -2045
  59. package/dist/app.d.ts +6 -6
  60. package/dist/app.js +1 -1
  61. package/dist/{closing-template-VFldhdBn.js → closing-template-CgDMayoo.js} +1 -1
  62. package/dist/components/FeatureCapabilityGate.vue.d.ts +2 -0
  63. package/dist/components/FeatureGateLayout.vue.d.ts +11 -0
  64. package/dist/components/FeaturePageGate.spec.d.ts +1 -0
  65. package/dist/components/FeaturePageGate.vue.d.ts +34 -0
  66. package/dist/components/FmAdminCollapsiblePanel.vue.d.ts +1 -1
  67. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  68. package/dist/components/FmInventoryTableToolbar.vue.d.ts +2 -2
  69. package/dist/components/HrmPermissionGuard.vue.d.ts +1 -1
  70. package/dist/components/PremiumUpgradePage.vue.d.ts +2 -0
  71. package/dist/{date2-yujh-zNX.js → date2-D9gB9BE-.js} +1 -1
  72. package/dist/{dayjs.min-CV_1QtOH.js → dayjs.min-CumM_kH7.js} +1 -1
  73. package/dist/{decimal-D8CtprfB.js → decimal-CVF1rRoj.js} +2 -2
  74. package/dist/{defineDeepModel-C7pf41A8.js → defineDeepModel-DE-DsQjm.js} +1 -1
  75. package/dist/{duplicate-template-C9zx63wv.js → duplicate-template-CFYtQfQn.js} +1 -1
  76. package/dist/feature-flags/vue.d.ts +22 -1
  77. package/dist/{feature-XC9N9tdn.js → feature-kti8bU8q.js} +412 -346
  78. package/dist/{format-time-from-id-Dhbt_dm1.js → format-time-from-id-CWZ5VGvM.js} +1 -1
  79. package/dist/{format-unit-display-B7Uz9FY7.js → format-unit-display-BlxdvskN.js} +12 -12
  80. package/dist/{id-to-date-BSON0a4_.js → id-to-date-BaH_1Kui.js} +1 -1
  81. package/dist/{import-export.helper-BNCatkGG.js → import-export.helper-8rKrOB0E.js} +5 -5
  82. package/dist/{index-cVQR3Kk1.js → index-B9p_OEdk.js} +1 -1
  83. package/dist/{index-C6sBGx8j.js → index-BHc3cNyz.js} +3 -3
  84. package/dist/{index-CcvB5MN8.js → index-MEUJonBr.js} +1 -1
  85. package/dist/layout/SingleColumnLayout.vue.d.ts +1 -1
  86. package/dist/{lz-string-jbv5KMfI.js → lz-string-IiazGN0W.js} +1 -1
  87. package/dist/{netsuite-BmyXyxHN.js → netsuite-BeDxaeKM.js} +2 -2
  88. package/dist/netsuite-explorer-4IluitzS.js +79 -0
  89. package/dist/{predefined-templates-Y9FBS3da.js → predefined-templates-D4qVID1q.js} +1 -1
  90. package/dist/{purchase-order-template-kpccxptg.js → purchase-order-template-GTOntq3C.js} +1 -1
  91. package/dist/{recalculationUtils-CQW3lPhm.js → recalculationUtils-Dye8x2TO.js} +1 -1
  92. package/dist/{row-action.enum-COTllbyK.js → row-action.enum-CVJbq_-y.js} +1 -1
  93. package/dist/{rules-kY8blQHT.js → rules-Y3zXVj3i.js} +3 -3
  94. package/dist/{stock-CCyBIj_s.js → stock-BIjTQFsR.js} +2 -2
  95. package/dist/{stock-CbUvnTcJ.js → stock-BR8x3nlx.js} +1 -1
  96. package/dist/stores/feature.d.ts +21 -1
  97. package/dist/stores/feature.load-state.spec.d.ts +1 -0
  98. package/dist/stores/warehouse.d.ts +1 -1
  99. package/dist/style.css +1 -1
  100. package/dist/{supplier-CR1Gy8T6.js → supplier-CbdCjiIB.js} +2 -2
  101. package/dist/{surcharge-ig3dYG2X.js → surcharge-BoXLK6o0.js} +1 -1
  102. package/dist/tsconfig.app.tsbuildinfo +1 -1
  103. package/dist/{uom-rules-D8R1q-3z.js → uom-rules-C5h1AoPJ.js} +1 -1
  104. package/dist/{use-ingredient-select-dialog-DVPfhAsz.js → use-ingredient-select-dialog-D196q_qk.js} +2 -2
  105. package/dist/{use-inventory-binding-dialog-DAepuYag.js → use-inventory-binding-dialog-B4IhhCjM.js} +2 -2
  106. package/dist/{use-template-enabled-locations-CM2dKs8u.js → use-template-enabled-locations-CDKP3kTS.js} +2 -2
  107. package/dist/{use-transfer-locations-C5TquwpD.js → use-transfer-locations-DE4vxSDp.js} +2 -2
  108. package/dist/{useHrmPermission-fAyejBrQ.js → useHrmPermission-D1dkveCP.js} +1 -1
  109. package/dist/{useNavigationMenu-D_2-vpQ_.js → useNavigationMenu-N5_7da8m.js} +39 -39
  110. package/dist/{useSseClient-CbZwkJYC.js → useSseClient-CKpNaz5g.js} +1 -1
  111. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +2 -2
  112. package/dist/views/integration/IntegrationPlatformView.vue.d.ts +2 -0
  113. package/dist/views/production-run/ProductionRunDetailPage.spec.d.ts +1 -0
  114. package/dist/views/production-run/ProductionRunDetailPage.vue.d.ts +15 -0
  115. package/dist/views/production-run/ProductionRunPage.vue.d.ts +2 -0
  116. package/dist/views/production-run/features/detail/use-production-run-detail.d.ts +11 -1
  117. package/dist/views/production-run/shared/helpers/production-run-navigation.d.ts +0 -1
  118. package/dist/views/production-run/shared/ui/ProductionRunInfoBadge.vue.d.ts +1 -1
  119. package/dist/views/production-run/shared/ui/ProductionRunInfoText.vue.d.ts +1 -1
  120. package/dist/views/production-run/shared/ui/ProductionRunScrollHint.vue.d.ts +2 -2
  121. package/dist/views/production-run/shared/ui/ProductionRunTextarea.vue.d.ts +3 -3
  122. package/dist/views/receive-request/composables/use-receive-request-form.spec.d.ts +1 -0
  123. package/dist/views/receive-request-bulk/BulkReceiveRequestPage.vue.d.ts +2 -0
  124. package/dist/views/receive-request-bulk/components/CreateTransferWizard.spec.d.ts +1 -0
  125. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.d.ts +6 -6
  126. package/dist/views/receive-request-bulk/composables/use-bulk-receive-request-form.readiness.spec.d.ts +1 -0
  127. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +2 -2
  128. package/dist/{PlanTierBadge.vue_vue_type_script_setup_true_lang-DHh9jsto.js → vue-CxSKQOrZ.js} +84 -68
  129. package/dist/{vue-i18n-DhknAI0B.js → vue-i18n-CTR_IUvd.js} +568 -568
  130. package/dist/{xlsx.util-BHPeb50D.js → xlsx.util-J9pxGRQD.js} +2 -2
  131. package/package.json +3 -3
  132. package/dist/BulkReceiveRequestView-CsToXNOy.js +0 -2657
  133. package/dist/FeatureCapabilityGate-DSNY6YtI.js +0 -74
  134. package/dist/ProductionRunDetailView-m9bXSe76.js +0 -2312
  135. package/dist/ProductionRunView-CAdxSdol.js +0 -931
  136. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-yA9fCxzS.js +0 -4847
@@ -0,0 +1,2316 @@
1
+ import { defineComponent as K, computed as $, ref as j, resolveComponent as te, createElementBlock as m, openBlock as s, Fragment as H, createElementVNode as n, createBlock as B, createCommentVNode as R, createVNode as P, withCtx as ne, createTextVNode as ie, toDisplayString as p, unref as e, renderList as oe, Teleport as Ce, normalizeClass as U, watch as ae, renderSlot as me, createSlots as Je, nextTick as Ie, toValue as fe, onBeforeUnmount as Xe } from "vue";
2
+ import { useRouter as Se } from "vue-router";
3
+ import { _ as re, a as et } from "./FeaturePageGate.vue_vue_type_script_setup_true_lang-D4G6i1D6.js";
4
+ import { u as Ae, n as tt } from "./app-Bb5HLWTu.js";
5
+ import { useBreakpoints as nt, useDialog as ot } from "@feedmepos/ui-library";
6
+ import { useI18n as J } from "@feedmepos/mf-common";
7
+ import { p as at, e as de, c as rt, _ as st, h as Le, v as it, w as Ee, x as De, y as Me, z as lt, A as Ve, B as Ue, C as He, N as le, f as E, D as ze, E as We, F as ut, G as he, H as dt, I as ct, J as pt, K as mt, L as Ge, M as bt, b as vt, O as Ne, Q as yt, R as ft, S as ht, u as Ke, T as gt, U as we, V as _t, W as kt, X as $t, i as xt, a as wt, o as be, Y as Pe, g as It, j as Rt, Z as St, $ as At, a0 as Lt, a1 as Pt, n as Tt, t as qt } from "./ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-4aYz5NwS.js";
8
+ import { _ as ce } from "./_plugin-vue_export-helper-CHgC5LLL.js";
9
+ import { g as Oe } from "./rules-Y3zXVj3i.js";
10
+ const Bt = { class: "flex flex-col gap-12" }, Ct = {
11
+ "data-testid": "production-run-header-layout",
12
+ class: "relative flex flex-col items-stretch gap-16 lg:flex-row lg:items-start"
13
+ }, Nt = {
14
+ "data-testid": "production-run-header-copy",
15
+ class: "grow min-w-0 flex flex-col gap-4"
16
+ }, Ot = { class: "fm-typo-en-title-lg-600 break-words text-fm-color-typo-primary" }, Ft = {
17
+ "data-testid": "production-run-caption",
18
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
19
+ }, jt = { class: "mt-4 flex items-center" }, Et = {
20
+ "data-testid": "production-run-header-actions",
21
+ class: "flex shrink-0 flex-wrap items-center justify-start gap-8 lg:justify-end"
22
+ }, Dt = { key: 0 }, Mt = {
23
+ key: 0,
24
+ "data-testid": "production-run-header-overflow"
25
+ }, Vt = ["data-testid"], Ut = {
26
+ key: 2,
27
+ "data-testid": "production-run-header-secondary-print"
28
+ }, Ht = { class: "fixed bottom-64 right-16 z-40" }, Fe = "__print_prepare_sheet__", zt = /* @__PURE__ */ K({
29
+ __name: "ProductionRunHeader",
30
+ props: {
31
+ run: {},
32
+ locationName: {},
33
+ primaryAction: {},
34
+ secondaryActions: {},
35
+ dangerActions: {},
36
+ canPrintPrepareSheet: { type: Boolean },
37
+ backTo: {},
38
+ backLabel: {},
39
+ statusDescription: {},
40
+ targetReached: { type: Boolean },
41
+ busy: { type: Boolean }
42
+ },
43
+ emits: ["action", "print-prepare-sheet"],
44
+ setup(L, { emit: c }) {
45
+ const t = L, _ = c, { t: l } = J(), { breakpoints: u } = nt(), w = $(() => u.value.xs), f = $(() => u.value.sm || u.value.md), x = j(!1), a = $(
46
+ () => at(t.run, l("inventory.production.run.list.untitled"))
47
+ ), h = $(() => {
48
+ const v = t.run.activityLogs, S = v.length ? v[v.length - 1] : null, y = (S == null ? void 0 : S.performedAt) ?? t.run.createdAt, C = S && S.action !== "create" ? l("inventory.production.run.list.columns.updated") : l("inventory.production.run.detail.created"), N = [`# ${t.run.runNo}`, t.locationName].filter(Boolean);
49
+ return y && N.push(`${C} ${de(y)}`), N.join(" · ");
50
+ }), I = (v) => v === "complete" && Le(t.run) ? l("inventory.production.run.detail.pendingStock.resume") : v === "complete" && t.targetReached ? l("inventory.production.run.detail.action.recordAdditionalOutput") : l(`inventory.production.run.detail.action.${v}`, it[v]), i = $(() => t.dangerActions.length > 0), r = $(
51
+ () => t.dangerActions.map((v) => ({
52
+ id: v,
53
+ label: I(v),
54
+ destructive: !0,
55
+ disabled: t.busy
56
+ }))
57
+ ), k = $(() => [
58
+ ...t.secondaryActions.map((v) => ({
59
+ id: v,
60
+ label: I(v),
61
+ disabled: t.busy
62
+ })),
63
+ ...t.canPrintPrepareSheet ? [
64
+ {
65
+ id: Fe,
66
+ label: l("inventory.production.run.detail.printPrepareSheet"),
67
+ disabled: t.busy
68
+ }
69
+ ] : [],
70
+ ...r.value
71
+ ]), o = $(
72
+ () => k.value.map(
73
+ (v) => ({
74
+ label: v.label,
75
+ value: v.id,
76
+ disabled: v.disabled
77
+ })
78
+ )
79
+ ), d = $(() => {
80
+ const v = i.value ? [{ key: "overflow", kind: "overflow" }] : [], S = t.secondaryActions.map((N) => ({
81
+ key: `secondary-${N}`,
82
+ kind: "lifecycle",
83
+ action: N,
84
+ variant: "secondary"
85
+ })), y = t.canPrintPrepareSheet ? [{ key: "print", kind: "print" }] : [], C = t.primaryAction ? [
86
+ {
87
+ key: `primary-${t.primaryAction}`,
88
+ kind: "lifecycle",
89
+ action: t.primaryAction,
90
+ variant: "primary"
91
+ }
92
+ ] : [];
93
+ return f.value ? [...C, ...S, ...y, ...v] : [...v, ...S, ...y, ...C];
94
+ });
95
+ function b(v) {
96
+ _("action", v);
97
+ }
98
+ function q(v) {
99
+ if (!t.busy) {
100
+ if (x.value = !1, v === Fe) {
101
+ _("print-prepare-sheet");
102
+ return;
103
+ }
104
+ b(v);
105
+ }
106
+ }
107
+ const O = $(() => l(`inventory.production.run.list.status.${t.run.status}`)), D = $(
108
+ () => l("inventory.production.run.detail.statusHelp", { status: O.value })
109
+ );
110
+ return (v, S) => {
111
+ const y = te("FmIcon"), C = te("RouterLink"), N = te("FmButton"), X = te("FmCollapsibleTabs"), z = te("FmBottomSheet");
112
+ return s(), m(H, null, [
113
+ n("header", Bt, [
114
+ P(C, {
115
+ to: v.backTo,
116
+ "data-testid": "production-run-back",
117
+ class: "-ml-12 inline-flex h-32 w-fit items-center gap-4 rounded-md px-12 fm-typo-en-body-sm-600 leading-[18px] text-fm-color-typo-secondary hover:bg-fm-color-opacity-sm hover:text-fm-color-typo-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-fm-color-primary print:hidden"
118
+ }, {
119
+ default: ne(() => [
120
+ P(y, {
121
+ name: "arrow_back",
122
+ size: "sm",
123
+ "aria-hidden": "true"
124
+ }),
125
+ ie(" " + p(v.backLabel ?? e(l)("inventory.production.run.detail.back")), 1)
126
+ ]),
127
+ _: 1
128
+ }, 8, ["to"]),
129
+ n("div", Ct, [
130
+ n("div", Nt, [
131
+ n("h1", Ot, p(a.value), 1),
132
+ n("p", Ft, p(h.value), 1),
133
+ n("div", jt, [
134
+ P(rt, {
135
+ status: v.run.status,
136
+ tooltip: v.statusDescription,
137
+ "accessible-label": D.value,
138
+ "help-icon": ""
139
+ }, null, 8, ["status", "tooltip", "accessible-label"])
140
+ ])
141
+ ]),
142
+ n("div", Et, [
143
+ w.value && k.value.length ? (s(), m("div", Dt, [
144
+ P(N, {
145
+ type: "button",
146
+ variant: "tertiary",
147
+ "prepend-icon": "more_vert",
148
+ "aria-label": e(l)("inventory.production.run.detail.moreActions"),
149
+ disabled: v.busy,
150
+ "data-testid": "production-run-detail-mobile-more",
151
+ onClick: S[0] || (S[0] = (F) => x.value = !0)
152
+ }, null, 8, ["aria-label", "disabled"])
153
+ ])) : R("", !0),
154
+ (s(!0), m(H, null, oe(w.value ? [] : d.value, (F) => (s(), m(H, {
155
+ key: F.key
156
+ }, [
157
+ F.kind === "overflow" ? (s(), m("div", Mt, [
158
+ P(st, {
159
+ items: r.value,
160
+ placement: "bottom-end",
161
+ "accessible-label": e(l)("inventory.production.run.detail.moreActions"),
162
+ disabled: v.busy,
163
+ onSelect: b
164
+ }, null, 8, ["items", "accessible-label", "disabled"])
165
+ ])) : F.kind === "lifecycle" ? (s(), m("div", {
166
+ key: 1,
167
+ "data-testid": `production-run-header-${F.variant}-${F.action}`
168
+ }, [
169
+ P(N, {
170
+ variant: F.variant,
171
+ label: I(F.action),
172
+ disabled: v.busy,
173
+ loading: F.variant === "primary" && v.busy,
174
+ onClick: (Z) => _("action", F.action)
175
+ }, null, 8, ["variant", "label", "disabled", "loading", "onClick"])
176
+ ], 8, Vt)) : (s(), m("div", Ut, [
177
+ P(N, {
178
+ variant: "secondary",
179
+ icon: "print",
180
+ label: e(l)("inventory.production.run.detail.printPrepareSheet"),
181
+ disabled: v.busy,
182
+ onClick: S[1] || (S[1] = (Z) => _("print-prepare-sheet"))
183
+ }, null, 8, ["label", "disabled"])
184
+ ]))
185
+ ], 64))), 128))
186
+ ])
187
+ ])
188
+ ]),
189
+ w.value && v.primaryAction ? (s(), B(Ce, {
190
+ key: 0,
191
+ to: "body"
192
+ }, [
193
+ n("div", Ht, [
194
+ P(N, {
195
+ "data-testid": "production-run-detail-mobile-primary",
196
+ variant: "fab",
197
+ label: I(v.primaryAction),
198
+ "prepend-icon": v.primaryAction === "complete" ? "add" : void 0,
199
+ loading: v.busy,
200
+ onClick: S[2] || (S[2] = (F) => _("action", v.primaryAction))
201
+ }, null, 8, ["label", "prepend-icon", "loading"])
202
+ ])
203
+ ])) : R("", !0),
204
+ w.value && k.value.length ? (s(), B(Ce, {
205
+ key: 1,
206
+ to: "body"
207
+ }, [
208
+ P(z, {
209
+ modelValue: x.value,
210
+ "onUpdate:modelValue": S[3] || (S[3] = (F) => x.value = F),
211
+ "dismiss-away": "",
212
+ "no-header": ""
213
+ }, {
214
+ default: ne(() => [
215
+ P(X, {
216
+ class: "pb-8",
217
+ items: o.value,
218
+ "data-testid": "production-run-detail-mobile-menu",
219
+ "onUpdate:modelValue": q
220
+ }, null, 8, ["items"])
221
+ ]),
222
+ _: 1
223
+ }, 8, ["modelValue"])
224
+ ])) : R("", !0)
225
+ ], 64);
226
+ };
227
+ }
228
+ }), Wt = /* @__PURE__ */ ce(zt, [["__scopeId", "data-v-9715608c"]]), Gt = ["aria-labelledby"], Kt = { class: "flex min-h-56 items-center px-16 py-12" }, Qt = ["id"], Zt = ["aria-label"], Yt = { key: 0 }, Jt = { class: "border-y border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100" }, Xt = { class: "production-run-table-header h-40 border-b border-fm-color-neutral-gray-200 fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, en = { class: "text-left px-16 py-8 font-inherit" }, tn = {
229
+ key: 0,
230
+ class: "text-right px-16 py-8 font-inherit"
231
+ }, nn = { class: "px-16 py-12 align-top fm-typo-en-body-md-400 text-fm-color-typo-primary" }, on = { class: "block fm-typo-en-body-md-600" }, an = {
232
+ key: 0,
233
+ class: "px-16 py-12 text-right fm-typo-en-body-md-400 text-fm-color-typo-secondary tabular-nums"
234
+ }, rn = { key: 0 }, sn = {
235
+ key: 1,
236
+ class: "text-fm-color-typo-disabled"
237
+ }, ln = { key: 0 }, un = {
238
+ key: 1,
239
+ class: "text-fm-color-typo-success"
240
+ }, dn = { key: 0 }, cn = ["colspan"], pn = { class: "production-run-items-bindings-sticky bg-fm-color-surface-primary px-16 pb-12 pt-4" }, mn = {
241
+ key: 0,
242
+ "data-testid": "unattributed-issued-ingredients",
243
+ class: "border-t border-fm-color-border-default bg-fm-color-surface-secondary px-16 py-12"
244
+ }, bn = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-warning" }, vn = { class: "mt-2 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, yn = /* @__PURE__ */ K({
245
+ __name: "ProductionRunItemsTable",
246
+ props: {
247
+ run: {},
248
+ names: {},
249
+ ingredientContributions: { default: () => ({}) },
250
+ unattributedIngredients: { default: () => [] },
251
+ unissuedSkuIds: { default: () => [] },
252
+ titleKey: { default: "inventory.production.run.detail.items.title" },
253
+ presentation: { default: "review" }
254
+ },
255
+ setup(L) {
256
+ const c = L, { t } = J(), _ = j(/* @__PURE__ */ new Set()), l = $(() => c.presentation === "preparing"), u = $(
257
+ () => {
258
+ var o;
259
+ return /* @__PURE__ */ new Set([
260
+ ...((o = c.run.plan.requirements) == null ? void 0 : o.skippedSkuIds) ?? [],
261
+ ...c.run.preparation.issuances.flatMap((d) => d.skippedSkuIds ?? [])
262
+ ]);
263
+ }
264
+ ), w = $(() => new Set(c.unissuedSkuIds));
265
+ function f(o) {
266
+ return l.value ? u.value.has(o) ? !0 : !c.run.plan.requirements && c.unattributedIngredients.length === 0 && w.value.has(o) : !1;
267
+ }
268
+ function x(o) {
269
+ return c.ingredientContributions[o] ?? [];
270
+ }
271
+ function a(o, d) {
272
+ return d > 0 ? o.issued / d : o.issued;
273
+ }
274
+ function h(o) {
275
+ return `production-run-output-ingredients-${o}`;
276
+ }
277
+ function I(o) {
278
+ const d = new Set(_.value);
279
+ d.has(o) ? d.delete(o) : d.add(o), _.value = d;
280
+ }
281
+ function i(o) {
282
+ return x(o.skuId).map((d) => ({
283
+ id: d.skuId,
284
+ name: d.name,
285
+ amount: a(d, o.committed),
286
+ unit: d.unit ?? ""
287
+ }));
288
+ }
289
+ function r(o) {
290
+ return `production-run-committed-description-${o.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
291
+ }
292
+ const k = $(() => {
293
+ var D;
294
+ const o = Ee(c.run), d = De(c.run), b = Me(c.run), q = {}, O = /* @__PURE__ */ new Set();
295
+ for (const v of c.run.plan.items) {
296
+ const S = (D = c.run.preparation.issuances.flatMap((C) => C.items).find((C) => C.sku._id === v.skuId)) == null ? void 0 : D.sku.unit, y = S ? lt(v.measurement, S) : null;
297
+ if (!y) {
298
+ O.add(v.skuId), q[v.skuId] = null;
299
+ continue;
300
+ }
301
+ O.has(v.skuId) || (q[v.skuId] = (q[v.skuId] ?? 0) + Ve(v.requestedAmount, y));
302
+ }
303
+ return Object.keys(o).map((v) => {
304
+ var S, y;
305
+ return {
306
+ skuId: v,
307
+ name: ((S = c.names[v]) == null ? void 0 : S.name) ?? v,
308
+ unit: ((y = c.names[v]) == null ? void 0 : y.unit) ?? null,
309
+ requested: q[v] ?? null,
310
+ committed: o[v] ?? 0,
311
+ produced: d[v] ?? 0,
312
+ remaining: b[v] ?? 0
313
+ };
314
+ });
315
+ });
316
+ return (o, d) => (s(), m("section", {
317
+ class: "border border-fm-color-neutral-gray-200 fm-corner-radius-md overflow-hidden bg-fm-color-surface-primary",
318
+ "aria-labelledby": l.value ? "items-to-produce-title" : void 0
319
+ }, [
320
+ n("header", Kt, [
321
+ n("h2", {
322
+ id: l.value ? "items-to-produce-title" : void 0,
323
+ class: "fm-typo-en-body-lg-600"
324
+ }, [
325
+ ie(p(e(t)(o.titleKey)), 1),
326
+ l.value ? (s(), m(H, { key: 0 }, [
327
+ ie(" (" + p(k.value.length) + ")", 1)
328
+ ], 64)) : R("", !0)
329
+ ], 8, Qt)
330
+ ]),
331
+ n("div", {
332
+ "data-testid": "production-run-items-scroll",
333
+ class: "production-run-items-scroll overflow-x-auto",
334
+ role: "region",
335
+ tabindex: "0",
336
+ "aria-label": e(t)(o.titleKey)
337
+ }, [
338
+ n("table", {
339
+ class: U(["w-full min-w-[44rem]", { "table-fixed": l.value }])
340
+ }, [
341
+ l.value ? (s(), m("colgroup", Yt, d[0] || (d[0] = [
342
+ n("col", null, null, -1),
343
+ n("col", { class: "w-36" }, null, -1),
344
+ n("col", { class: "w-36" }, null, -1),
345
+ n("col", { class: "w-36" }, null, -1)
346
+ ]))) : R("", !0),
347
+ n("thead", Jt, [
348
+ n("tr", Xt, [
349
+ n("th", en, p(e(t)("inventory.production.run.detail.items.item")), 1),
350
+ l.value ? R("", !0) : (s(), m("th", tn, p(e(t)("inventory.production.run.detail.items.requested")), 1)),
351
+ n("th", {
352
+ class: U([l.value ? "text-center" : "text-right", "px-16 py-8 font-inherit"])
353
+ }, p(e(t)(
354
+ l.value ? "inventory.production.run.detail.preparing.toProduce" : "inventory.production.run.detail.items.committed"
355
+ )), 3),
356
+ n("th", {
357
+ class: U([l.value ? "text-center" : "text-right", "px-16 py-8 font-inherit"])
358
+ }, p(e(t)(
359
+ l.value ? "inventory.production.run.detail.preparing.recorded" : "inventory.production.run.detail.items.produced"
360
+ )), 3),
361
+ n("th", {
362
+ class: U([l.value ? "text-center" : "text-right", "px-16 py-8 font-inherit"])
363
+ }, p(e(t)(
364
+ l.value ? "inventory.production.run.detail.preparing.remaining" : "inventory.production.run.detail.items.left"
365
+ )), 3)
366
+ ])
367
+ ]),
368
+ (s(!0), m(H, null, oe(k.value, (b) => (s(), m("tbody", {
369
+ key: b.skuId,
370
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
371
+ }, [
372
+ n("tr", {
373
+ class: U({ "production-run-preparing-row": l.value })
374
+ }, [
375
+ n("td", nn, [
376
+ n("span", on, p(b.name), 1),
377
+ x(b.skuId).length ? (s(), B(Ue, {
378
+ key: 0,
379
+ class: "mt-[2px]",
380
+ count: x(b.skuId).length,
381
+ controls: h(b.skuId),
382
+ expanded: _.value.has(b.skuId),
383
+ testid: `output-ingredient-disclosure-${b.skuId}`,
384
+ onToggle: (q) => I(b.skuId)
385
+ }, null, 8, ["count", "controls", "expanded", "testid", "onToggle"])) : f(b.skuId) ? (s(), B(He, {
386
+ key: 1,
387
+ "item-name": b.name
388
+ }, null, 8, ["item-name"])) : R("", !0)
389
+ ]),
390
+ l.value ? R("", !0) : (s(), m("td", an, p(b.requested === null ? e(le) : e(E)(b.requested, b.unit)), 1)),
391
+ n("td", {
392
+ class: U(["px-16 py-12 fm-typo-en-body-md-400 tabular-nums", [
393
+ l.value ? "text-center" : "text-right",
394
+ b.requested !== null && b.committed !== b.requested ? "text-fm-color-typo-warning fm-typo-en-body-md-600" : "text-fm-color-typo-primary"
395
+ ]])
396
+ }, [
397
+ n("span", {
398
+ class: U(["inline-flex items-center gap-2", l.value ? "justify-center" : "justify-end"])
399
+ }, [
400
+ n("span", null, p(e(E)(b.committed, b.unit)), 1),
401
+ !l.value && b.requested !== null && b.committed !== b.requested ? (s(), B(ze, {
402
+ key: 0,
403
+ "description-id": r(b.skuId),
404
+ "trigger-label": e(t)("inventory.production.run.detail.items.committedHelpLabel"),
405
+ description: e(t)("inventory.production.run.detail.items.committedHelp", {
406
+ requested: e(E)(b.requested, b.unit)
407
+ }),
408
+ testid: `committed-quantity-help-${b.skuId}`,
409
+ compact: ""
410
+ }, null, 8, ["description-id", "trigger-label", "description", "testid"])) : R("", !0)
411
+ ], 2)
412
+ ], 2),
413
+ n("td", {
414
+ class: U(["px-16 py-12 fm-typo-en-body-md-400 tabular-nums", l.value ? "text-center" : "text-right"])
415
+ }, [
416
+ l.value || b.produced > 0 ? (s(), m("span", rn, p(e(E)(b.produced, b.unit)), 1)) : (s(), m("span", sn, p(e(le)), 1))
417
+ ], 2),
418
+ n("td", {
419
+ class: U([
420
+ "px-16 py-12 tabular-nums",
421
+ l.value ? "text-center fm-typo-en-body-md-600" : "text-right fm-typo-en-body-md-400"
422
+ ])
423
+ }, [
424
+ l.value || b.remaining > 0 ? (s(), m("span", ln, p(e(E)(b.remaining, b.unit)), 1)) : (s(), m("span", un, p(e(t)("inventory.production.run.detail.items.done")), 1))
425
+ ], 2)
426
+ ], 2),
427
+ _.value.has(b.skuId) ? (s(), m("tr", dn, [
428
+ n("td", {
429
+ colspan: l.value ? 4 : 5,
430
+ class: "production-run-items-bindings-cell"
431
+ }, [
432
+ n("div", pn, [
433
+ P(We, {
434
+ id: h(b.skuId),
435
+ testid: "production-run-output-ingredient-list",
436
+ count: x(b.skuId).length,
437
+ unit: b.unit ?? "",
438
+ lines: i(b),
439
+ "item-name": b.name
440
+ }, null, 8, ["id", "count", "unit", "lines", "item-name"])
441
+ ])
442
+ ], 8, cn)
443
+ ])) : R("", !0)
444
+ ]))), 128))
445
+ ], 2)
446
+ ], 8, Zt),
447
+ o.unattributedIngredients.length ? (s(), m("div", mn, [
448
+ n("p", bn, p(e(t)("inventory.production.run.detail.items.unattributedTitle")), 1),
449
+ n("p", vn, p(e(t)("inventory.production.run.detail.items.unattributedMessage")), 1)
450
+ ])) : R("", !0)
451
+ ], 8, Gt));
452
+ }
453
+ }), Qe = /* @__PURE__ */ ce(yn, [["__scopeId", "data-v-b5fad4a9"]]), fn = {
454
+ "data-testid": "closed-production-result",
455
+ class: "min-w-0 overflow-hidden border border-fm-color-neutral-gray-200 fm-corner-radius-md bg-fm-color-surface-primary",
456
+ "aria-labelledby": "production-run-result-title"
457
+ }, hn = { class: "flex h-56 items-center justify-between gap-16 border-b border-fm-color-neutral-gray-200 px-16 py-12" }, gn = {
458
+ id: "production-run-result-title",
459
+ class: "fm-typo-en-body-lg-600"
460
+ }, _n = {
461
+ "data-testid": "closed-targets-reached",
462
+ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
463
+ }, kn = ["aria-label"], $n = ["aria-label"], xn = { class: "bg-fm-color-neutral-gray-100" }, wn = { class: "h-40 border-b border-fm-color-neutral-gray-200 fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, In = { class: "whitespace-nowrap px-16 py-8 text-left font-inherit" }, Rn = { class: "whitespace-nowrap px-8 py-8 text-center font-inherit" }, Sn = { class: "whitespace-nowrap px-8 py-8 text-center font-inherit" }, An = { class: "min-w-0 px-16 py-12" }, Ln = ["title"], Pn = {
464
+ "data-testid": "closed-item-yield",
465
+ class: "whitespace-nowrap px-8 py-12 text-center tabular-nums"
466
+ }, Tn = { class: "block fm-typo-en-body-md-400" }, qn = {
467
+ "data-testid": "closed-item-variance",
468
+ class: "whitespace-nowrap px-8 py-12 text-center tabular-nums"
469
+ }, ee = "inventory.production.run.detail.result", Bn = /* @__PURE__ */ K({
470
+ __name: "ProductionRunResultTable",
471
+ props: {
472
+ run: {},
473
+ names: {}
474
+ },
475
+ setup(L) {
476
+ const c = L, { t } = J(), _ = $(() => {
477
+ const x = Ee(c.run), a = De(c.run);
478
+ return Object.keys(x).map((h) => {
479
+ var o, d, b;
480
+ const I = x[h] ?? 0, i = a[h] ?? 0, r = i - I, k = I > 0 ? Math.round(i / I * 1e8) / 1e6 : null;
481
+ return {
482
+ skuId: h,
483
+ name: ((o = c.names[h]) == null ? void 0 : o.name) ?? h,
484
+ unit: ((d = c.names[h]) == null ? void 0 : d.unit) ?? null,
485
+ precision: ((b = c.names[h]) == null ? void 0 : b.precision) ?? null,
486
+ target: I,
487
+ produced: i,
488
+ variance: r,
489
+ rate: k,
490
+ reached: i >= I
491
+ };
492
+ });
493
+ }), l = $(() => _.value.filter((x) => x.reached).length);
494
+ function u(x) {
495
+ return x === null ? "—" : `${E(x)}%`;
496
+ }
497
+ function w(x, a, h) {
498
+ if (x === 0) return E(0, a, { precision: h });
499
+ const I = E(Math.abs(x), a, { precision: h });
500
+ return x > 0 ? `+${I}` : `−${I}`;
501
+ }
502
+ function f(x, a) {
503
+ if (x === 0) return t(`${ee}.atTarget`);
504
+ if (a <= 0) return x > 0 ? t(`${ee}.aboveTarget`) : t(`${ee}.belowTarget`);
505
+ const h = E(Math.abs(x / a) * 100);
506
+ return t(`${ee}.${x > 0 ? "above" : "below"}`, { percent: h });
507
+ }
508
+ return (x, a) => (s(), m("section", fn, [
509
+ n("header", hn, [
510
+ n("h2", gn, p(e(t)(`${ee}.title`)), 1),
511
+ n("span", _n, p(e(t)(`${ee}.targetsReached`, { reached: l.value, total: _.value.length })), 1)
512
+ ]),
513
+ n("div", {
514
+ class: "overflow-x-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-fm-color-border-focused",
515
+ role: "region",
516
+ "aria-label": e(t)(`${ee}.ledger`),
517
+ tabindex: "0"
518
+ }, [
519
+ n("table", {
520
+ "aria-label": e(t)(`${ee}.title`),
521
+ class: "min-w-[24rem] w-full table-fixed"
522
+ }, [
523
+ a[0] || (a[0] = n("colgroup", null, [
524
+ n("col"),
525
+ n("col", { class: "w-96" }),
526
+ n("col", { class: "w-112" })
527
+ ], -1)),
528
+ n("thead", xn, [
529
+ n("tr", wn, [
530
+ n("th", In, p(e(t)(`${ee}.item`)), 1),
531
+ n("th", Rn, p(e(t)(`${ee}.yield`)), 1),
532
+ n("th", Sn, p(e(t)(`${ee}.variance`)), 1)
533
+ ])
534
+ ]),
535
+ n("tbody", null, [
536
+ (s(!0), m(H, null, oe(_.value, (h) => (s(), m("tr", {
537
+ key: h.skuId,
538
+ class: "border-b border-fm-color-neutral-gray-200 fm-typo-en-body-md-400 last:border-b-0"
539
+ }, [
540
+ n("td", An, [
541
+ n("strong", {
542
+ class: "block break-words fm-typo-en-body-md-600",
543
+ title: h.name
544
+ }, p(h.name), 9, Ln)
545
+ ]),
546
+ n("td", Pn, [
547
+ n("span", Tn, p(e(E)(h.produced, h.unit, { precision: h.precision })), 1),
548
+ n("span", {
549
+ "data-testid": "closed-item-rate",
550
+ class: U([
551
+ "block fm-typo-en-body-sm-400",
552
+ h.rate !== null && h.rate !== 100 ? "text-fm-color-typo-warning" : "text-fm-color-typo-secondary"
553
+ ])
554
+ }, p(u(h.rate)), 3)
555
+ ]),
556
+ n("td", qn, [
557
+ n("strong", {
558
+ class: U(["block fm-typo-en-body-md-600", h.variance === 0 ? "" : "text-fm-color-typo-warning"])
559
+ }, p(w(h.variance, h.unit, h.precision)), 3),
560
+ n("span", {
561
+ class: U([
562
+ "block fm-typo-en-body-sm-400",
563
+ h.variance === 0 ? "text-fm-color-typo-secondary" : "text-fm-color-typo-warning"
564
+ ])
565
+ }, p(f(h.variance, h.target)), 3)
566
+ ])
567
+ ]))), 128))
568
+ ])
569
+ ], 8, $n)
570
+ ], 8, kn)
571
+ ]));
572
+ }
573
+ }), Cn = ["id", "aria-label"], Nn = { class: "flex min-w-[680px] flex-col gap-8" }, On = {
574
+ "data-testid": "batch-wastage-headings",
575
+ role: "row",
576
+ class: "production-run-batch-wastage-headings grid min-h-40 grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)] items-center gap-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 px-12 py-8 fm-typo-en-body-sm-600 text-fm-color-typo-secondary"
577
+ }, Fn = { role: "columnheader" }, jn = {
578
+ role: "columnheader",
579
+ class: "text-center"
580
+ }, En = { role: "columnheader" }, Dn = { role: "columnheader" }, Mn = {
581
+ role: "rowgroup",
582
+ class: "flex flex-col gap-8"
583
+ }, Vn = {
584
+ role: "cell",
585
+ class: "min-w-0"
586
+ }, Un = ["title"], Hn = {
587
+ role: "cell",
588
+ class: "min-w-0"
589
+ }, zn = {
590
+ "data-testid": "batch-wastage-quantity",
591
+ class: "production-run-batch-wastage-quantity block whitespace-nowrap text-center tabular-nums"
592
+ }, Wn = {
593
+ role: "cell",
594
+ class: "min-w-0"
595
+ }, Gn = {
596
+ "data-testid": "batch-wastage-reason",
597
+ class: "break-words text-fm-color-typo-primary"
598
+ }, Kn = {
599
+ role: "cell",
600
+ class: "min-w-0"
601
+ }, Qn = {
602
+ "data-testid": "batch-wastage-remark",
603
+ class: "whitespace-pre-wrap break-words text-fm-color-typo-primary"
604
+ }, ge = /* @__PURE__ */ K({
605
+ __name: "ProductionRunBatchWastageDetails",
606
+ props: {
607
+ id: {},
608
+ label: {},
609
+ lines: {},
610
+ names: {}
611
+ },
612
+ setup(L) {
613
+ const { t: c } = J();
614
+ function t(_) {
615
+ const l = ut(_);
616
+ return l ? c(l) : le;
617
+ }
618
+ return (_, l) => (s(), m("div", {
619
+ id: _.id,
620
+ tabindex: "0",
621
+ role: "table",
622
+ "aria-label": _.label,
623
+ class: "overflow-x-auto overscroll-x-contain pb-12"
624
+ }, [
625
+ n("div", Nn, [
626
+ n("div", On, [
627
+ n("span", Fn, p(e(c)("inventory.production.run.detail.batch.ingredient")), 1),
628
+ n("span", jn, p(e(c)("inventory.production.run.detail.batch.quantityLost")), 1),
629
+ n("span", En, p(e(c)("inventory.production.run.detail.batch.reason")), 1),
630
+ n("span", Dn, p(e(c)("inventory.production.run.detail.batch.remark")), 1)
631
+ ]),
632
+ n("div", Mn, [
633
+ (s(!0), m(H, null, oe(_.lines, (u, w) => {
634
+ var f, x, a, h, I;
635
+ return s(), m("div", {
636
+ key: `${u.skuId}-${w}`,
637
+ "data-testid": "batch-wastage-line",
638
+ role: "row",
639
+ class: "production-run-batch-wastage-row grid grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)] items-start gap-12 fm-corner-radius-md bg-fm-color-surface-secondary p-12 fm-typo-en-body-sm-400"
640
+ }, [
641
+ n("div", Vn, [
642
+ n("span", {
643
+ "data-testid": "batch-wastage-ingredient",
644
+ class: "production-run-batch-wastage-ingredient block truncate",
645
+ title: ((f = _.names[u.skuId]) == null ? void 0 : f.name) ?? u.skuId
646
+ }, p(((x = _.names[u.skuId]) == null ? void 0 : x.name) ?? u.skuId), 9, Un)
647
+ ]),
648
+ n("div", Hn, [
649
+ n("span", zn, p(e(E)(
650
+ e(Ve)(u.amount, u.measurement),
651
+ ((a = _.names[u.skuId]) == null ? void 0 : a.unit) ?? null,
652
+ { precision: ((h = _.names[u.skuId]) == null ? void 0 : h.precision) ?? null }
653
+ )), 1)
654
+ ]),
655
+ n("div", Wn, [
656
+ n("span", Gn, p(t(u.reason)), 1)
657
+ ]),
658
+ n("div", Kn, [
659
+ n("span", Qn, p(((I = u.remark) == null ? void 0 : I.trim()) || e(le)), 1)
660
+ ])
661
+ ]);
662
+ }), 128))
663
+ ])
664
+ ])
665
+ ], 8, Cn));
666
+ }
667
+ }), Zn = {
668
+ key: 0,
669
+ "data-testid": "batch-stock-pending",
670
+ role: "status",
671
+ class: "border-b border-fm-color-border-default bg-fm-color-surface-secondary px-16 py-8 fm-typo-en-body-sm-600 text-fm-color-typo-warning"
672
+ }, Yn = {
673
+ key: 1,
674
+ class: "flex items-start justify-between gap-12 px-16 pt-12"
675
+ }, Jn = { class: "min-w-0" }, Xn = {
676
+ "data-testid": "batch-title",
677
+ class: "fm-typo-en-body-md-600"
678
+ }, eo = ["title"], to = {
679
+ key: 2,
680
+ class: "flex items-center gap-8 flex-wrap px-16 py-12 border-b border-fm-color-border-default"
681
+ }, no = { class: "fm-typo-en-body-md-600" }, oo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, ao = {
682
+ key: 0,
683
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary bg-fm-color-surface-secondary px-8 py-2 fm-corner-radius-sm"
684
+ }, ro = ["aria-label"], so = { class: "p-12 max-w-[320px] fm-typo-en-body-sm-400 text-fm-color-typo-primary" }, io = {
685
+ key: 3,
686
+ class: "overflow-x-auto px-16 pb-12"
687
+ }, lo = {
688
+ key: 0,
689
+ "data-testid": "batch-note",
690
+ class: "mt-12 whitespace-pre-wrap break-words fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
691
+ }, uo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, co = ["aria-label"], po = { class: "border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100" }, mo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, bo = { class: "px-12 py-8 text-left font-semibold" }, vo = { class: "px-12 py-8 text-center font-semibold" }, yo = { class: "px-12 py-8 align-top" }, fo = ["data-testid", "title"], ho = ["data-testid"], go = { key: 0 }, _o = {
692
+ colspan: "2",
693
+ class: "px-16"
694
+ }, ko = { key: 0 }, $o = {
695
+ colspan: "2",
696
+ class: "border-t border-fm-color-neutral-gray-200 px-16 py-8 text-center"
697
+ }, xo = {
698
+ key: 4,
699
+ class: "flex flex-col px-16"
700
+ }, wo = { class: "flex items-start justify-between gap-12 py-12" }, Io = { class: "min-w-0 flex-1" }, Ro = ["data-testid", "title"], So = { class: "fm-typo-en-body-md-400 tabular-nums shrink-0" }, Ao = {
701
+ key: 0,
702
+ class: "border-t border-fm-color-border-default py-8 text-center"
703
+ }, Lo = {
704
+ key: 5,
705
+ "data-testid": "batch-note",
706
+ class: "px-16 py-10 border-t border-fm-color-border-default fm-typo-en-body-sm-400 text-fm-color-typo-secondary whitespace-pre-wrap break-words"
707
+ }, Po = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, To = {
708
+ key: 6,
709
+ class: "flex items-center justify-between gap-12 px-16 py-8 border-t border-fm-color-border-default fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
710
+ }, qo = { key: 0 }, Re = /* @__PURE__ */ K({
711
+ __name: "ProductionRunBatchCard",
712
+ props: {
713
+ batch: {},
714
+ names: {},
715
+ summary: {},
716
+ total: {},
717
+ presentation: { default: "overview" }
718
+ },
719
+ setup(L) {
720
+ const c = L, { t } = J(), _ = $(() => c.presentation === "output"), l = $(() => {
721
+ var o;
722
+ return ((o = c.batch.remark) == null ? void 0 : o.trim()) ?? "";
723
+ }), u = j(/* @__PURE__ */ new Set()), w = $(() => {
724
+ var D;
725
+ const o = /* @__PURE__ */ new Map(), d = new Set(c.batch.items.map((v) => v.skuId)), b = c.batch.items.length === 1 ? (D = c.batch.items[0]) == null ? void 0 : D.skuId : void 0;
726
+ for (const v of c.batch.wastages) {
727
+ const y = v.itemSkuId ?? b, C = y && d.has(y) ? y : "unattributed";
728
+ o.set(C, [...o.get(C) ?? [], v]);
729
+ }
730
+ const q = c.batch.items.flatMap((v) => {
731
+ const S = o.get(v.skuId);
732
+ return S != null && S.length ? [{ key: v.skuId, lines: S }] : [];
733
+ }), O = o.get("unattributed");
734
+ return O != null && O.length ? [...q, { key: "unattributed", lines: O }] : q;
735
+ });
736
+ ae(
737
+ () => c.batch.id,
738
+ () => {
739
+ u.value = /* @__PURE__ */ new Set();
740
+ }
741
+ );
742
+ function f(o) {
743
+ return w.value.find((d) => d.key === o);
744
+ }
745
+ function x(o) {
746
+ return `batch-${c.batch.id}-wastage-${o}`;
747
+ }
748
+ function a(o) {
749
+ var d;
750
+ return t("inventory.production.run.detail.batch.wastage", {
751
+ count: ((d = f(o)) == null ? void 0 : d.lines.length) ?? 0
752
+ });
753
+ }
754
+ function h(o) {
755
+ var d;
756
+ return `${a(o)}: ${((d = c.names[o]) == null ? void 0 : d.name) ?? o}`;
757
+ }
758
+ function I(o) {
759
+ return u.value.has(o);
760
+ }
761
+ function i(o) {
762
+ const d = new Set(u.value);
763
+ d.has(o) ? d.delete(o) : d.add(o), u.value = d;
764
+ }
765
+ const r = $(() => {
766
+ var b;
767
+ if (!c.summary) return null;
768
+ const o = (b = c.batch.items[0]) == null ? void 0 : b.skuId, d = o ? c.names[o] : void 0;
769
+ return {
770
+ ...c.summary,
771
+ unit: (d == null ? void 0 : d.unit) ?? null,
772
+ precision: (d == null ? void 0 : d.precision) ?? null,
773
+ percent: c.summary.committed > 0 ? Math.round(c.summary.cumulative / c.summary.committed * 100) : null
774
+ };
775
+ }), k = $(
776
+ () => c.batch.isBackdated ? t("inventory.production.run.detail.batch.hintBackdated", {
777
+ name: c.batch.recordedBy,
778
+ at: de(c.batch.recordedAt)
779
+ }) : t("inventory.production.run.detail.batch.hint", {
780
+ name: c.batch.recordedBy,
781
+ at: de(c.batch.recordedAt)
782
+ })
783
+ );
784
+ return (o, d) => {
785
+ var O, D, v, S;
786
+ const b = te("FmIcon"), q = te("FmPopover");
787
+ return s(), m("article", {
788
+ class: U([
789
+ "border fm-corner-radius-md overflow-hidden bg-fm-color-surface-primary",
790
+ _.value ? "border-fm-color-neutral-gray-200" : "border-fm-color-border-default"
791
+ ])
792
+ }, [
793
+ o.batch.stockApplicationStatus === "PENDING" ? (s(), m("p", Zn, p(e(t)("inventory.production.run.detail.pendingStock.title")), 1)) : R("", !0),
794
+ _.value ? (s(), m("header", Yn, [
795
+ n("div", Jn, [
796
+ n("h2", Xn, [
797
+ me(o.$slots, "title", {}, () => [
798
+ ie(p(e(t)("inventory.production.run.detail.batch.shortTitle", { index: o.batch.index })), 1)
799
+ ])
800
+ ]),
801
+ n("p", {
802
+ "data-testid": "batch-provenance",
803
+ class: "mt-1 fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
804
+ title: o.batch.isBackdated ? k.value : void 0
805
+ }, p(e(t)("inventory.production.run.detail.batch.provenance", {
806
+ at: e(de)(o.batch.producedAt),
807
+ name: o.batch.recordedBy
808
+ })), 9, eo)
809
+ ]),
810
+ me(o.$slots, "nav")
811
+ ])) : (s(), m("header", to, [
812
+ n("span", no, p(e(t)("inventory.production.run.detail.batch.title", { index: o.batch.index, total: o.total })), 1),
813
+ n("span", oo, p(e(de)(o.batch.producedAt)), 1),
814
+ o.batch.isBackdated ? (s(), m("span", ao, p(e(t)("inventory.production.run.detail.batch.entered", {
815
+ at: e(de)(o.batch.recordedAt)
816
+ })), 1)) : R("", !0),
817
+ P(q, { placement: "bottom-start" }, {
818
+ "popover-button": ne(() => [
819
+ n("button", {
820
+ type: "button",
821
+ class: "flex text-fm-color-typo-disabled hover:text-fm-color-typo-primary",
822
+ "aria-label": e(t)("inventory.production.run.detail.moreDetail")
823
+ }, [
824
+ P(b, {
825
+ name: "info",
826
+ size: "sm",
827
+ outline: ""
828
+ })
829
+ ], 8, ro)
830
+ ]),
831
+ default: ne(() => [
832
+ n("p", so, p(k.value), 1)
833
+ ]),
834
+ _: 1
835
+ }),
836
+ d[2] || (d[2] = n("span", { class: "grow" }, null, -1)),
837
+ me(o.$slots, "nav")
838
+ ])),
839
+ _.value ? (s(), m("div", io, [
840
+ l.value ? (s(), m("p", lo, [
841
+ n("span", uo, p(e(t)("inventory.production.run.detail.batch.batchNote")), 1),
842
+ ie(" " + p(l.value), 1)
843
+ ])) : R("", !0),
844
+ n("table", {
845
+ class: "mt-12 w-full table-fixed",
846
+ "aria-label": e(t)("inventory.production.run.detail.batch.outputTableLabel", { index: o.batch.index })
847
+ }, [
848
+ d[3] || (d[3] = n("colgroup", null, [
849
+ n("col"),
850
+ n("col", { class: "w-[144px]" })
851
+ ], -1)),
852
+ n("thead", po, [
853
+ n("tr", mo, [
854
+ n("th", bo, p(e(t)("inventory.production.run.detail.items.item")), 1),
855
+ n("th", vo, p(e(t)("inventory.production.run.detail.batch.yield")), 1)
856
+ ])
857
+ ]),
858
+ (s(!0), m(H, null, oe(o.batch.items, (y) => {
859
+ var C, N, X, z, F, Z;
860
+ return s(), m("tbody", {
861
+ key: y.skuId,
862
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
863
+ }, [
864
+ n("tr", null, [
865
+ n("td", yo, [
866
+ n("span", {
867
+ "data-testid": `batch-output-name-${y.skuId}`,
868
+ class: "block truncate fm-typo-en-body-md-400",
869
+ title: ((C = o.names[y.skuId]) == null ? void 0 : C.name) ?? y.skuId
870
+ }, p(((N = o.names[y.skuId]) == null ? void 0 : N.name) ?? y.skuId), 9, fo),
871
+ f(y.skuId) ? (s(), B(he, {
872
+ key: 0,
873
+ "data-testid": `batch-wastage-toggle-${y.skuId}`,
874
+ class: "mt-2",
875
+ expanded: I(y.skuId),
876
+ controls: x(y.skuId),
877
+ label: a(y.skuId),
878
+ "aria-label": h(y.skuId),
879
+ onToggle: (pe) => i(y.skuId)
880
+ }, null, 8, ["data-testid", "expanded", "controls", "label", "aria-label", "onToggle"])) : R("", !0)
881
+ ]),
882
+ n("td", {
883
+ "data-testid": `batch-output-yield-${y.skuId}`,
884
+ class: "whitespace-nowrap px-12 py-8 text-center align-top fm-typo-en-body-md-400 tabular-nums"
885
+ }, [
886
+ n("span", null, p(e(E)(y.amount, ((X = o.names[y.skuId]) == null ? void 0 : X.unit) ?? null, {
887
+ precision: ((z = o.names[y.skuId]) == null ? void 0 : z.precision) ?? null
888
+ })), 1)
889
+ ], 8, ho)
890
+ ]),
891
+ f(y.skuId) && I(y.skuId) ? (s(), m("tr", go, [
892
+ n("td", _o, [
893
+ P(ge, {
894
+ id: x(y.skuId),
895
+ label: e(t)("inventory.production.run.detail.batch.wastageFor", {
896
+ name: ((F = o.names[y.skuId]) == null ? void 0 : F.name) ?? y.skuId
897
+ }),
898
+ lines: ((Z = f(y.skuId)) == null ? void 0 : Z.lines) ?? [],
899
+ names: o.names
900
+ }, null, 8, ["id", "label", "lines", "names"])
901
+ ])
902
+ ])) : R("", !0)
903
+ ]);
904
+ }), 128)),
905
+ f("unattributed") ? (s(), m("tbody", ko, [
906
+ n("tr", null, [
907
+ n("td", $o, [
908
+ P(he, {
909
+ "data-testid": "batch-wastage-toggle-unattributed",
910
+ expanded: I("unattributed"),
911
+ controls: x("unattributed"),
912
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastage", {
913
+ count: ((O = f("unattributed")) == null ? void 0 : O.lines.length) ?? 0
914
+ }),
915
+ onToggle: d[0] || (d[0] = (y) => i("unattributed"))
916
+ }, null, 8, ["expanded", "controls", "label"]),
917
+ I("unattributed") ? (s(), B(ge, {
918
+ key: 0,
919
+ id: x("unattributed"),
920
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastageLabel"),
921
+ lines: ((D = f("unattributed")) == null ? void 0 : D.lines) ?? [],
922
+ names: o.names,
923
+ class: "mt-8 text-left"
924
+ }, null, 8, ["id", "label", "lines", "names"])) : R("", !0)
925
+ ])
926
+ ])
927
+ ])) : R("", !0)
928
+ ], 8, co)
929
+ ])) : (s(), m("div", xo, [
930
+ (s(!0), m(H, null, oe(o.batch.items, (y) => {
931
+ var C, N, X, z, F, Z;
932
+ return s(), m("div", {
933
+ key: y.skuId,
934
+ class: "border-b border-fm-color-border-default last:border-b-0"
935
+ }, [
936
+ n("div", wo, [
937
+ n("div", Io, [
938
+ n("span", {
939
+ "data-testid": `batch-output-name-${y.skuId}`,
940
+ class: "block break-words fm-typo-en-body-md-600 sm:truncate",
941
+ title: ((C = o.names[y.skuId]) == null ? void 0 : C.name) ?? y.skuId
942
+ }, p(((N = o.names[y.skuId]) == null ? void 0 : N.name) ?? y.skuId), 9, Ro),
943
+ f(y.skuId) ? (s(), B(he, {
944
+ key: 0,
945
+ "data-testid": `batch-wastage-toggle-${y.skuId}`,
946
+ class: "mt-2",
947
+ expanded: I(y.skuId),
948
+ controls: x(y.skuId),
949
+ label: a(y.skuId),
950
+ "aria-label": h(y.skuId),
951
+ onToggle: (pe) => i(y.skuId)
952
+ }, null, 8, ["data-testid", "expanded", "controls", "label", "aria-label", "onToggle"])) : R("", !0)
953
+ ]),
954
+ n("span", So, p(e(E)(y.amount, ((X = o.names[y.skuId]) == null ? void 0 : X.unit) ?? null, {
955
+ precision: ((z = o.names[y.skuId]) == null ? void 0 : z.precision) ?? null
956
+ })), 1)
957
+ ]),
958
+ f(y.skuId) && I(y.skuId) ? (s(), B(ge, {
959
+ key: 0,
960
+ id: x(y.skuId),
961
+ label: e(t)("inventory.production.run.detail.batch.wastageFor", {
962
+ name: ((F = o.names[y.skuId]) == null ? void 0 : F.name) ?? y.skuId
963
+ }),
964
+ lines: ((Z = f(y.skuId)) == null ? void 0 : Z.lines) ?? [],
965
+ names: o.names
966
+ }, null, 8, ["id", "label", "lines", "names"])) : R("", !0)
967
+ ]);
968
+ }), 128)),
969
+ f("unattributed") ? (s(), m("div", Ao, [
970
+ P(he, {
971
+ "data-testid": "batch-wastage-toggle-unattributed",
972
+ expanded: I("unattributed"),
973
+ controls: x("unattributed"),
974
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastage", {
975
+ count: ((v = f("unattributed")) == null ? void 0 : v.lines.length) ?? 0
976
+ }),
977
+ onToggle: d[1] || (d[1] = (y) => i("unattributed"))
978
+ }, null, 8, ["expanded", "controls", "label"]),
979
+ I("unattributed") ? (s(), B(ge, {
980
+ key: 0,
981
+ id: x("unattributed"),
982
+ label: e(t)("inventory.production.run.detail.batch.unattributedWastageLabel"),
983
+ lines: ((S = f("unattributed")) == null ? void 0 : S.lines) ?? [],
984
+ names: o.names,
985
+ class: "mt-8 text-left"
986
+ }, null, 8, ["id", "label", "lines", "names"])) : R("", !0)
987
+ ])) : R("", !0)
988
+ ])),
989
+ l.value && !_.value ? (s(), m("p", Lo, [
990
+ n("span", Po, p(e(t)("inventory.production.run.detail.batch.batchNote")), 1),
991
+ ie(" " + p(l.value), 1)
992
+ ])) : R("", !0),
993
+ r.value && !_.value ? (s(), m("footer", To, [
994
+ n("span", null, p(e(t)("inventory.production.run.detail.batch.ofCommitted", {
995
+ amount: e(E)(r.value.amount, r.value.unit, {
996
+ precision: r.value.precision
997
+ }),
998
+ committed: e(E)(r.value.committed, r.value.unit, {
999
+ precision: r.value.precision
1000
+ })
1001
+ })), 1),
1002
+ r.value.percent !== null ? (s(), m("span", qo, p(e(t)("inventory.production.run.detail.batch.cumulative", { percent: r.value.percent })), 1)) : R("", !0)
1003
+ ])) : R("", !0)
1004
+ ], 2);
1005
+ };
1006
+ }
1007
+ }), Bo = { class: "flex flex-col gap-16" }, Co = {
1008
+ key: 2,
1009
+ "data-testid": "production-run-last-output",
1010
+ class: "flex min-w-0 flex-col gap-8",
1011
+ "aria-labelledby": "production-run-last-output-title"
1012
+ }, No = { class: "flex items-center justify-between gap-12" }, Oo = {
1013
+ id: "production-run-last-output-title",
1014
+ class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary"
1015
+ }, Fo = {
1016
+ key: 3,
1017
+ class: "production-run-review-layout grid grid-cols-1 gap-16 items-start"
1018
+ }, jo = { class: "flex flex-col gap-16 min-w-0" }, Eo = { class: "flex items-center justify-between fm-typo-en-body-sm-500 uppercase tracking-wider text-fm-color-typo-secondary" }, Do = { class: "flex items-center gap-4" }, Mo = /* @__PURE__ */ K({
1019
+ __name: "ProductionRunOverviewTab",
1020
+ props: {
1021
+ run: {},
1022
+ names: {},
1023
+ batches: {},
1024
+ committed: {},
1025
+ unit: {},
1026
+ hasIssuance: { type: Boolean },
1027
+ operational: { type: Boolean, default: !1 }
1028
+ },
1029
+ emits: ["view-all"],
1030
+ setup(L, { emit: c }) {
1031
+ const t = L, _ = c, { t: l } = J(), u = j(null), w = $(() => {
1032
+ if (!t.batches.length) return null;
1033
+ const i = t.batches.length - 1, r = u.value === null || u.value >= t.batches.length ? i : u.value;
1034
+ return { batch: t.batches[r], i: r };
1035
+ }), f = $(() => {
1036
+ const i = t.batches.length - 1;
1037
+ return i >= 0 ? { batch: t.batches[i], i } : null;
1038
+ }), x = $(() => {
1039
+ const i = new Set(
1040
+ t.run.preparation.issuances.flatMap((r) => r.items.map((k) => k.sku._id))
1041
+ );
1042
+ return i.size === 1 ? [...i][0] : null;
1043
+ });
1044
+ function a(i) {
1045
+ const r = t.committed;
1046
+ if (!i || x.value === null || r === null) return null;
1047
+ const k = x.value;
1048
+ if (t.batches.some((b) => b.items.some((q) => q.skuId !== k))) return null;
1049
+ const o = i.batch.items.reduce((b, q) => b + q.amount, 0), d = t.batches.slice(0, i.i + 1).reduce(
1050
+ (b, q) => b + q.items.reduce((O, D) => O + D.amount, 0),
1051
+ 0
1052
+ );
1053
+ return { amount: o, cumulative: d, committed: r };
1054
+ }
1055
+ const h = $(() => a(w.value)), I = $(() => t.run.status === "CLOSED");
1056
+ return (i, r) => {
1057
+ const k = te("FmButton");
1058
+ return s(), m("div", Bo, [
1059
+ i.operational ? me(i.$slots, "operational", { key: 0 }, void 0, !0) : me(i.$slots, "planner", { key: 1 }, void 0, !0),
1060
+ i.operational && i.run.status === "PREPARING" && f.value ? (s(), m("section", Co, [
1061
+ n("header", No, [
1062
+ n("h2", Oo, p(e(l)("inventory.production.run.detail.output.lastOutput")), 1),
1063
+ P(k, {
1064
+ variant: "secondary",
1065
+ label: e(l)("inventory.production.run.detail.output.viewAllOutput"),
1066
+ onClick: r[0] || (r[0] = (o) => _("view-all"))
1067
+ }, null, 8, ["label"])
1068
+ ]),
1069
+ P(Re, {
1070
+ batch: f.value.batch,
1071
+ names: i.names,
1072
+ summary: null,
1073
+ total: i.batches.length,
1074
+ presentation: "output"
1075
+ }, {
1076
+ title: ne(() => [
1077
+ ie(p(e(l)("inventory.production.run.detail.batch.title", {
1078
+ index: f.value.batch.index,
1079
+ total: i.batches.length
1080
+ })), 1)
1081
+ ]),
1082
+ _: 1
1083
+ }, 8, ["batch", "names", "total"])
1084
+ ])) : R("", !0),
1085
+ !i.operational && i.hasIssuance ? (s(), m("div", Fo, [
1086
+ n("div", jo, [
1087
+ I.value ? (s(), B(Bn, {
1088
+ key: 0,
1089
+ run: i.run,
1090
+ names: i.names
1091
+ }, null, 8, ["run", "names"])) : (s(), m(H, { key: 1 }, [
1092
+ P(Qe, {
1093
+ run: i.run,
1094
+ names: i.names
1095
+ }, null, 8, ["run", "names"]),
1096
+ w.value ? (s(), m(H, { key: 0 }, [
1097
+ n("div", Eo, [
1098
+ n("span", null, p(e(l)("inventory.production.run.detail.output.recorded")), 1),
1099
+ n("span", null, p(e(l)("inventory.production.run.detail.output.count", { count: i.batches.length })), 1)
1100
+ ]),
1101
+ P(Re, {
1102
+ batch: w.value.batch,
1103
+ names: i.names,
1104
+ summary: h.value,
1105
+ total: i.batches.length
1106
+ }, Je({ _: 2 }, [
1107
+ i.batches.length > 1 ? {
1108
+ name: "nav",
1109
+ fn: ne(() => [
1110
+ n("div", Do, [
1111
+ P(k, {
1112
+ variant: "tertiary",
1113
+ icon: "chevron_left",
1114
+ disabled: w.value.i === 0,
1115
+ "aria-label": e(l)("inventory.production.run.detail.output.previous"),
1116
+ onClick: r[1] || (r[1] = (o) => u.value = w.value.i - 1)
1117
+ }, null, 8, ["disabled", "aria-label"]),
1118
+ P(k, {
1119
+ variant: "tertiary",
1120
+ icon: "chevron_right",
1121
+ disabled: w.value.i === i.batches.length - 1,
1122
+ "aria-label": e(l)("inventory.production.run.detail.output.next"),
1123
+ onClick: r[2] || (r[2] = (o) => u.value = w.value.i + 1)
1124
+ }, null, 8, ["disabled", "aria-label"]),
1125
+ P(k, {
1126
+ variant: "tertiary",
1127
+ label: e(l)("inventory.production.run.detail.output.viewAll"),
1128
+ onClick: r[3] || (r[3] = (o) => _("view-all"))
1129
+ }, null, 8, ["label"])
1130
+ ])
1131
+ ]),
1132
+ key: "0"
1133
+ } : void 0
1134
+ ]), 1032, ["batch", "names", "summary", "total"])
1135
+ ], 64)) : R("", !0)
1136
+ ], 64))
1137
+ ]),
1138
+ P(dt)
1139
+ ])) : R("", !0)
1140
+ ]);
1141
+ };
1142
+ }
1143
+ }), Vo = /* @__PURE__ */ ce(Mo, [["__scopeId", "data-v-844d1a9b"]]), Uo = { class: "flex flex-col gap-16" }, Ho = {
1144
+ key: 0,
1145
+ class: "border border-dashed border-fm-color-border-default fm-corner-radius-md px-16 py-24 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1146
+ }, zo = /* @__PURE__ */ K({
1147
+ __name: "ProductionRunOutputTab",
1148
+ props: {
1149
+ batches: {},
1150
+ names: {}
1151
+ },
1152
+ setup(L) {
1153
+ const { t: c } = J();
1154
+ return (t, _) => (s(), m("div", Uo, [
1155
+ t.batches.length ? (s(!0), m(H, { key: 1 }, oe(t.batches, (l) => (s(), B(Re, {
1156
+ key: l.id,
1157
+ batch: l,
1158
+ names: t.names,
1159
+ summary: null,
1160
+ total: t.batches.length,
1161
+ presentation: "output"
1162
+ }, null, 8, ["batch", "names", "total"]))), 128)) : (s(), m("p", Ho, p(e(c)("inventory.production.run.detail.output.empty")), 1))
1163
+ ]));
1164
+ }
1165
+ }), Wo = ["aria-label"], Go = {
1166
+ key: 0,
1167
+ role: "status",
1168
+ class: "border border-dashed border-fm-color-border-default px-16 py-24 fm-corner-radius-md fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1169
+ }, Ko = {
1170
+ key: 1,
1171
+ class: "border border-dashed border-fm-color-border-default px-16 py-24 fm-corner-radius-md fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1172
+ }, Qo = {
1173
+ key: 2,
1174
+ class: "border border-dashed border-fm-color-border-default px-16 py-24 fm-corner-radius-md fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1175
+ }, Zo = {
1176
+ key: 3,
1177
+ "data-testid": "ingredient-issue-card",
1178
+ class: "overflow-hidden border border-fm-color-neutral-gray-200 bg-fm-color-surface-primary fm-corner-radius-md"
1179
+ }, Yo = ["aria-label"], Jo = ["aria-label"], Xo = { class: "ingredient-ledger__head bg-fm-color-neutral-gray-100" }, ea = { class: "h-40 fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, ta = { class: "px-16 py-8 text-left" }, na = { class: "whitespace-nowrap px-8 py-8 text-center" }, oa = { class: "whitespace-nowrap px-8 py-8 text-center" }, aa = ["data-testid"], ra = { class: "ingredient-ledger__ingredient col-span-1 min-w-0 px-16 py-8 align-top" }, sa = ["data-testid"], ia = ["title"], la = ["data-testid"], ua = ["data-testid"], da = ["data-testid"], ca = {
1180
+ key: 0,
1181
+ class: "ingredient-ledger__contributors-row"
1182
+ }, pa = {
1183
+ colspan: "3",
1184
+ class: "px-0 pb-0 pt-0"
1185
+ }, ma = {
1186
+ "data-testid": "issued-ingredient-contributors-width",
1187
+ class: "max-w-full"
1188
+ }, ba = {
1189
+ "data-testid": "issued-ingredient-contributors-content",
1190
+ class: "ingredient-ledger__contributors-content w-3/5"
1191
+ }, G = "inventory.production.run.detail.ingredients", va = /* @__PURE__ */ K({
1192
+ __name: "ProductionRunIngredientsTab",
1193
+ props: {
1194
+ runId: {},
1195
+ loading: { type: Boolean },
1196
+ snapshotAvailable: { type: Boolean },
1197
+ lines: {},
1198
+ ingredientContributions: {},
1199
+ outputNames: {},
1200
+ unattributedIngredients: {}
1201
+ },
1202
+ setup(L) {
1203
+ const c = L, { t } = J(), _ = j(/* @__PURE__ */ new Set()), l = $(() => {
1204
+ var r, k, o;
1205
+ const i = {};
1206
+ for (const [d, b] of Object.entries(c.ingredientContributions ?? {}))
1207
+ for (const q of b)
1208
+ (i[r = q.skuId] ?? (i[r] = [])).push({
1209
+ outputSkuId: d,
1210
+ outputName: ((o = (k = c.outputNames) == null ? void 0 : k[d]) == null ? void 0 : o.name) ?? d,
1211
+ issued: q.issued,
1212
+ unit: q.unit
1213
+ });
1214
+ return i;
1215
+ }), u = $(
1216
+ () => new Set(
1217
+ Object.entries(l.value).filter(([, i]) => i.length > 0).map(([i]) => i)
1218
+ )
1219
+ );
1220
+ ae(
1221
+ () => c.runId,
1222
+ () => _.value = /* @__PURE__ */ new Set()
1223
+ ), ae(
1224
+ () => [...u.value].sort().join("|"),
1225
+ () => {
1226
+ _.value = new Set(
1227
+ [..._.value].filter((i) => u.value.has(i))
1228
+ );
1229
+ }
1230
+ );
1231
+ function w(i) {
1232
+ return l.value[i] ?? [];
1233
+ }
1234
+ function f(i) {
1235
+ return `production-run-ingredient-contributors-${c.runId}-${i}`;
1236
+ }
1237
+ function x(i) {
1238
+ const r = new Set(_.value);
1239
+ r.has(i) ? r.delete(i) : r.add(i), _.value = r;
1240
+ }
1241
+ function a(i) {
1242
+ const r = w(i).length;
1243
+ return t(r === 1 ? `${G}.acrossItem` : `${G}.acrossItems`, { count: r });
1244
+ }
1245
+ function h(i) {
1246
+ return w(i).map((r) => ({
1247
+ key: r.outputSkuId,
1248
+ label: r.outputName,
1249
+ value: E(r.issued, r.unit)
1250
+ }));
1251
+ }
1252
+ function I(i) {
1253
+ if (i.stockBefore === null || i.stockAfter === null) return le;
1254
+ const r = E(i.stockBefore, i.unit);
1255
+ if (i.stockAfter >= 0) return `${r} → ${E(i.stockAfter, i.unit)}`;
1256
+ const k = t("inventory.production.run.form.commits.shortBy", {
1257
+ amount: `−${E(Math.abs(i.stockAfter), i.unit)}`
1258
+ });
1259
+ return `${r} → ${k}`;
1260
+ }
1261
+ return (i, r) => {
1262
+ var k;
1263
+ return s(), m("section", {
1264
+ class: "flex flex-col gap-16",
1265
+ "aria-label": e(t)(`${G}.title`)
1266
+ }, [
1267
+ i.loading ? (s(), m("p", Go, p(e(t)(`${G}.loading`)), 1)) : i.snapshotAvailable ? i.lines.length ? (s(), m("div", Zo, [
1268
+ n("div", {
1269
+ "data-testid": "ingredient-ledger-scroll",
1270
+ class: "overflow-x-auto overscroll-x-contain",
1271
+ role: "region",
1272
+ tabindex: "0",
1273
+ "aria-label": e(t)(`${G}.tableLabel`)
1274
+ }, [
1275
+ n("table", {
1276
+ class: "ingredient-ledger w-full min-w-[44rem]",
1277
+ "aria-label": e(t)(`${G}.tableLabel`)
1278
+ }, [
1279
+ r[0] || (r[0] = n("colgroup", { class: "ingredient-ledger__columns" }, [
1280
+ n("col"),
1281
+ n("col", { class: "w-36" }),
1282
+ n("col", { class: "w-36" })
1283
+ ], -1)),
1284
+ n("thead", Xo, [
1285
+ n("tr", ea, [
1286
+ n("th", ta, p(e(t)(`${G}.ingredient`)), 1),
1287
+ n("th", na, p(e(t)(`${G}.requestedQty`)), 1),
1288
+ n("th", oa, p(e(t)(`${G}.committedQty`)), 1)
1289
+ ])
1290
+ ]),
1291
+ (s(!0), m(H, null, oe(i.lines, (o) => (s(), m("tbody", {
1292
+ key: o.skuId,
1293
+ class: "ingredient-ledger__body"
1294
+ }, [
1295
+ n("tr", {
1296
+ "data-testid": `ingredient-row-${o.skuId}`,
1297
+ class: "ingredient-ledger__row border-t border-fm-color-neutral-gray-200"
1298
+ }, [
1299
+ n("td", ra, [
1300
+ n("div", {
1301
+ "data-testid": `issued-ingredient-identity-${o.skuId}`,
1302
+ class: "flex min-w-0 flex-col items-start gap-0"
1303
+ }, [
1304
+ n("strong", {
1305
+ class: "ingredient-ledger__identity-name block max-w-full truncate fm-typo-en-body-md-600",
1306
+ title: o.name
1307
+ }, p(o.name), 9, ia),
1308
+ o.stockAfter !== null && o.stockAfter < 0 ? (s(), B(ct, {
1309
+ key: 0,
1310
+ class: "ingredient-ledger__identity-stock",
1311
+ testid: `ingredient-stock-${o.skuId}`,
1312
+ "help-testid": `ingredient-stock-help-${o.skuId}`,
1313
+ type: "hint",
1314
+ "icon-placement": "trailing",
1315
+ variant: "danger",
1316
+ size: "sm",
1317
+ text: `${e(t)(`${G}.stock`)} ${I(o)}`,
1318
+ "accessible-label": e(t)("inventory.production.run.detail.ingredients.negativeStockHelp"),
1319
+ tooltip: e(t)("inventory.production.run.detail.ingredients.negativeStockHelp")
1320
+ }, null, 8, ["testid", "help-testid", "text", "accessible-label", "tooltip"])) : (s(), m("p", {
1321
+ key: 1,
1322
+ "data-testid": `ingredient-stock-${o.skuId}`,
1323
+ class: "ingredient-ledger__identity-stock fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1324
+ }, p(e(t)(`${G}.stock`)) + " " + p(I(o)), 9, la)),
1325
+ u.value.has(o.skuId) ? (s(), B(pt, {
1326
+ key: 2,
1327
+ class: "ingredient-ledger__disclosure mt-[2px] w-fit",
1328
+ testid: `ingredient-contributor-disclosure-${o.skuId}`,
1329
+ controls: f(o.skuId),
1330
+ expanded: _.value.has(o.skuId),
1331
+ label: a(o.skuId),
1332
+ onToggle: (d) => x(o.skuId)
1333
+ }, null, 8, ["testid", "controls", "expanded", "label", "onToggle"])) : R("", !0)
1334
+ ], 8, sa)
1335
+ ]),
1336
+ n("td", {
1337
+ "data-testid": `ingredient-requested-${o.skuId}`,
1338
+ class: U([
1339
+ "ingredient-ledger__value ingredient-ledger__requested px-8 py-8 text-center align-middle fm-typo-en-body-md-400 tabular-nums",
1340
+ o.requested === null ? "text-fm-color-typo-secondary" : "text-fm-color-typo-primary"
1341
+ ])
1342
+ }, p(o.requested === null ? e(le) : e(E)(o.requested, o.unit)), 11, ua),
1343
+ n("td", {
1344
+ "data-testid": `ingredient-committed-${o.skuId}`,
1345
+ class: "ingredient-ledger__value ingredient-ledger__committed px-8 py-8 text-center align-middle fm-typo-en-body-md-400 text-fm-color-typo-primary tabular-nums"
1346
+ }, p(e(E)(o.issued, o.unit)), 9, da)
1347
+ ], 8, aa),
1348
+ u.value.has(o.skuId) && _.value.has(o.skuId) ? (s(), m("tr", ca, [
1349
+ n("td", pa, [
1350
+ n("div", ma, [
1351
+ n("div", ba, [
1352
+ P(mt, {
1353
+ id: f(o.skuId),
1354
+ role: "list",
1355
+ "aria-label": e(t)(`${G}.contributorsFor`, { name: o.name }),
1356
+ entries: h(o.skuId),
1357
+ class: "ml-[22px] mr-[8px]"
1358
+ }, null, 8, ["id", "aria-label", "entries"])
1359
+ ])
1360
+ ])
1361
+ ])
1362
+ ])) : R("", !0)
1363
+ ]))), 128))
1364
+ ], 8, Jo)
1365
+ ], 8, Yo)
1366
+ ])) : (s(), m("p", Qo, p(e(t)(`${G}.noBindings`)), 1)) : (s(), m("p", Ko, p(e(t)(`${G}.snapshotUnavailable`)), 1)),
1367
+ (k = i.unattributedIngredients) != null && k.length ? (s(), B(re, {
1368
+ key: 4,
1369
+ "data-testid": "unattributed-issued-ingredients",
1370
+ tone: "warn",
1371
+ title: e(t)("inventory.production.run.detail.items.unattributedTitle"),
1372
+ message: e(t)("inventory.production.run.detail.items.unattributedMessage")
1373
+ }, null, 8, ["title", "message"])) : R("", !0)
1374
+ ], 8, Wo);
1375
+ };
1376
+ }
1377
+ }), ya = /* @__PURE__ */ ce(va, [["__scopeId", "data-v-2a6f6173"]]), fa = { "aria-labelledby": "activity-title" }, ha = { class: "flex items-center gap-8" }, ga = {
1378
+ id: "activity-title",
1379
+ class: "text-[18px] font-semibold leading-[28px]"
1380
+ }, _a = {
1381
+ key: 0,
1382
+ class: "mt-[20px] space-y-16"
1383
+ }, ka = {
1384
+ class: "mt-[2px] grid size-24 place-items-center rounded-full bg-fm-color-system-success-100 text-fm-color-system-success-400",
1385
+ "aria-hidden": "true"
1386
+ }, $a = { class: "min-w-0" }, xa = {
1387
+ "data-testid": "activity-title",
1388
+ class: "text-[14px] font-medium leading-[18px] text-fm-color-typo-primary"
1389
+ }, wa = {
1390
+ key: 0,
1391
+ "data-testid": "activity-description",
1392
+ class: "mt-4 text-[14px] font-normal leading-[20px] text-fm-color-typo-secondary"
1393
+ }, Ia = {
1394
+ "data-testid": "activity-meta",
1395
+ class: "mt-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1396
+ }, Ra = {
1397
+ key: 1,
1398
+ class: "mt-[20px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1399
+ }, Sa = /* @__PURE__ */ K({
1400
+ __name: "ProductionRunActivityTab",
1401
+ props: {
1402
+ run: {}
1403
+ },
1404
+ setup(L) {
1405
+ const c = L, { t } = J(), _ = $(
1406
+ () => [...c.run.activityLogs].reverse().map((l, u) => {
1407
+ var w;
1408
+ return {
1409
+ key: `${l.action}-${l.performedAt}-${u}`,
1410
+ label: l.action === "close" && Ge(c.run) === "below-target" ? t("inventory.production.run.list.activity.closeBelowTarget") : t(`inventory.production.run.list.activity.${l.action}`),
1411
+ description: l.remark,
1412
+ meta: [de(l.performedAt), (w = l.performedBy) == null ? void 0 : w.name].filter(Boolean).join(" · ")
1413
+ };
1414
+ })
1415
+ );
1416
+ return (l, u) => {
1417
+ const w = te("FmIcon");
1418
+ return s(), m("section", fa, [
1419
+ n("header", ha, [
1420
+ P(w, {
1421
+ name: "history",
1422
+ size: "sm",
1423
+ "aria-hidden": "true",
1424
+ class: "production-run-activity-history"
1425
+ }),
1426
+ n("h2", ga, p(e(t)("inventory.production.run.detail.tab.activity")), 1)
1427
+ ]),
1428
+ _.value.length ? (s(), m("ol", _a, [
1429
+ (s(!0), m(H, null, oe(_.value, (f) => (s(), m("li", {
1430
+ key: f.key,
1431
+ class: "grid grid-cols-[24px_1fr] gap-12"
1432
+ }, [
1433
+ n("span", ka, [
1434
+ P(w, {
1435
+ name: "check_circle",
1436
+ size: "sm",
1437
+ class: "production-run-activity-check"
1438
+ })
1439
+ ]),
1440
+ n("div", $a, [
1441
+ n("div", xa, p(f.label), 1),
1442
+ f.description ? (s(), m("p", wa, p(f.description), 1)) : R("", !0),
1443
+ n("p", Ia, p(f.meta), 1)
1444
+ ])
1445
+ ]))), 128))
1446
+ ])) : (s(), m("p", Ra, p(e(t)("inventory.production.run.list.activity.none")), 1))
1447
+ ]);
1448
+ };
1449
+ }
1450
+ }), Aa = /* @__PURE__ */ ce(Sa, [["__scopeId", "data-v-ea0bca54"]]), La = { class: "production-run-requested-layout grid grid-cols-1 items-start gap-16" }, Pa = {
1451
+ "data-testid": "production-run-requested-left",
1452
+ class: "flex min-w-0 flex-col gap-16"
1453
+ }, Ta = {
1454
+ "data-stage-card": "items",
1455
+ class: "overflow-hidden border border-fm-color-neutral-gray-200 bg-fm-color-surface-primary fm-corner-radius-md"
1456
+ }, qa = { class: "flex min-h-[60px] items-center border-b border-fm-color-neutral-gray-200 px-16 py-12" }, Ba = { class: "inline-flex items-center gap-4 fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Ca = { "data-output-count": "" }, Na = { class: "grid grid-cols-[minmax(0,1fr)_auto] gap-x-12 px-16 py-12" }, Oa = { class: "fm-typo-en-body-md-600 truncate text-fm-color-typo-primary" }, Fa = {
1457
+ "data-requested-quantity": "",
1458
+ class: "fm-typo-en-body-md-600 justify-self-end text-right tabular-nums text-fm-color-typo-primary"
1459
+ }, ja = {
1460
+ key: 0,
1461
+ "data-output-stock": "",
1462
+ "data-output-stock-transition": "",
1463
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1464
+ }, Ea = /* @__PURE__ */ K({
1465
+ __name: "ProductionRunRequestedOverview",
1466
+ props: {
1467
+ run: {},
1468
+ items: {},
1469
+ ingredients: {},
1470
+ refreshable: { type: Boolean, default: !1 },
1471
+ refreshing: { type: Boolean, default: !1 },
1472
+ showStockProjection: { type: Boolean, default: !0 }
1473
+ },
1474
+ emits: ["refresh"],
1475
+ setup(L, { emit: c }) {
1476
+ const t = L, _ = c, { t: l } = J(), u = $(() => new Map(t.items.map((r) => [r.skuId, r]))), w = $(() => {
1477
+ var r;
1478
+ return new Set(((r = t.run.plan.requirements) == null ? void 0 : r.skippedSkuIds) ?? []);
1479
+ }), f = $(() => bt(t.run.plan)), x = j(/* @__PURE__ */ new Set());
1480
+ ae(
1481
+ () => t.run._id,
1482
+ () => x.value = /* @__PURE__ */ new Set()
1483
+ );
1484
+ function a(r) {
1485
+ return `requested-item-ingredients-${t.run._id}-${r}`.replace(/[^a-zA-Z0-9_-]/g, "-");
1486
+ }
1487
+ function h(r) {
1488
+ const k = new Set(x.value);
1489
+ k.has(r) ? k.delete(r) : k.add(r), x.value = k;
1490
+ }
1491
+ const I = $(
1492
+ () => [...w.value].map((r) => {
1493
+ var k;
1494
+ return ((k = u.value.get(r)) == null ? void 0 : k.name) ?? r;
1495
+ })
1496
+ ), i = $(
1497
+ () => t.run.plan.items.map((r) => {
1498
+ const k = u.value.get(r.skuId), o = vt(r.measurement) ? r.measurement : null;
1499
+ return {
1500
+ skuId: r.skuId,
1501
+ name: (k == null ? void 0 : k.name) ?? r.skuId,
1502
+ stock: (k == null ? void 0 : k.onHand) != null && o && k.sku && k.baseQuantity != null && k.baseUnit ? `${l("inventory.production.run.form.items.columns.inStock")} ${E(
1503
+ k.onHand,
1504
+ null,
1505
+ {
1506
+ precision: Ne(k.sku)
1507
+ }
1508
+ )} → ${E(k.onHand + k.baseQuantity, k.baseUnit, {
1509
+ precision: Ne(k.sku)
1510
+ })}` : le,
1511
+ // Read-only history renders its own structurally valid frozen snapshot.
1512
+ // Catalogue compatibility is checked only before a new write.
1513
+ requested: o ? E(r.requestedAmount, o.abbrev, {
1514
+ precision: r.requestedAmount.precision
1515
+ }) : le,
1516
+ ingredientBreakdown: f.value.get(r.skuId) ?? null,
1517
+ hasNoBindings: w.value.has(r.skuId)
1518
+ };
1519
+ })
1520
+ );
1521
+ return (r, k) => {
1522
+ var o;
1523
+ return s(), m("div", La, [
1524
+ n("div", Pa, [
1525
+ P(yt, {
1526
+ instructions: r.run.instructions
1527
+ }, null, 8, ["instructions"]),
1528
+ P(ft, {
1529
+ "data-stage-card": "ingredients",
1530
+ mode: "requested",
1531
+ rows: r.ingredients,
1532
+ "no-items": !((o = r.run.plan.requirements) != null && o.ingredients.length),
1533
+ "unbound-names": I.value,
1534
+ refreshable: r.refreshable && r.showStockProjection,
1535
+ refreshing: r.refreshing,
1536
+ "show-stock-projection": r.showStockProjection,
1537
+ onRefresh: k[0] || (k[0] = (d) => _("refresh"))
1538
+ }, null, 8, ["rows", "no-items", "unbound-names", "refreshable", "refreshing", "show-stock-projection"])
1539
+ ]),
1540
+ n("section", Ta, [
1541
+ n("header", qa, [
1542
+ n("h2", Ba, [
1543
+ ie(p(e(l)("inventory.production.run.form.items.title")) + " ", 1),
1544
+ n("span", Ca, "(" + p(i.value.length) + ")", 1),
1545
+ P(ze, {
1546
+ "description-id": "requested-quantity-help",
1547
+ testid: "requested-quantity-help-trigger",
1548
+ "trigger-label": e(l)("inventory.production.run.detail.requested.quantityHelpLabel"),
1549
+ description: e(l)("inventory.production.run.detail.requested.quantityHelp")
1550
+ }, null, 8, ["trigger-label", "description"])
1551
+ ])
1552
+ ]),
1553
+ (s(!0), m(H, null, oe(i.value, (d) => {
1554
+ var b, q;
1555
+ return s(), m("div", {
1556
+ key: d.skuId,
1557
+ class: "border-b border-fm-color-neutral-gray-200 last:border-b-0"
1558
+ }, [
1559
+ n("div", Na, [
1560
+ n("span", Oa, p(d.name), 1),
1561
+ n("span", Fa, p(d.requested), 1),
1562
+ r.showStockProjection ? (s(), m("span", ja, p(d.stock), 1)) : R("", !0),
1563
+ n("span", {
1564
+ "data-requested-label": "",
1565
+ class: U(["fm-typo-en-body-sm-400 text-right text-fm-color-typo-secondary", r.showStockProjection ? "" : "col-start-2"])
1566
+ }, p(e(l)("inventory.production.run.detail.items.requested")), 3),
1567
+ d.hasNoBindings ? (s(), B(He, {
1568
+ key: 1,
1569
+ class: "col-span-2 mt-4",
1570
+ "item-name": d.name
1571
+ }, null, 8, ["item-name"])) : (b = d.ingredientBreakdown) != null && b.lines.length ? (s(), B(Ue, {
1572
+ key: 2,
1573
+ class: "col-span-2 mt-4",
1574
+ testid: "requested-item-ingredients-toggle",
1575
+ count: d.ingredientBreakdown.lines.length,
1576
+ controls: a(d.skuId),
1577
+ expanded: x.value.has(d.skuId),
1578
+ onToggle: (O) => h(d.skuId)
1579
+ }, null, 8, ["count", "controls", "expanded", "onToggle"])) : R("", !0)
1580
+ ]),
1581
+ x.value.has(d.skuId) && ((q = d.ingredientBreakdown) != null && q.lines.length) ? (s(), B(We, {
1582
+ key: 0,
1583
+ id: a(d.skuId),
1584
+ testid: "requested-item-ingredients-list",
1585
+ class: "px-16 pb-12",
1586
+ count: d.ingredientBreakdown.lines.length,
1587
+ unit: d.ingredientBreakdown.basisUnit,
1588
+ lines: d.ingredientBreakdown.lines,
1589
+ "item-name": d.name
1590
+ }, null, 8, ["id", "count", "unit", "lines", "item-name"])) : R("", !0)
1591
+ ]);
1592
+ }), 128))
1593
+ ])
1594
+ ]);
1595
+ };
1596
+ }
1597
+ }), Da = /* @__PURE__ */ ce(Ea, [["__scopeId", "data-v-ff35cbd5"]]), Ma = ["aria-label"], Va = { class: "flex min-w-max items-center gap-8" }, Ua = ["id", "aria-selected", "aria-controls", "tabindex", "onClick", "onKeydown"], Ha = /* @__PURE__ */ K({
1598
+ __name: "ProductionRunDetailTabs",
1599
+ props: {
1600
+ items: {},
1601
+ modelValue: {},
1602
+ ariaLabel: {}
1603
+ },
1604
+ emits: ["update:modelValue"],
1605
+ setup(L, { emit: c }) {
1606
+ const t = L, _ = c, l = j([]);
1607
+ function u(f, x = !1) {
1608
+ const a = t.items[f];
1609
+ a && (_("update:modelValue", a.value), x && Ie(() => {
1610
+ var h;
1611
+ return (h = l.value[f]) == null ? void 0 : h.focus();
1612
+ }));
1613
+ }
1614
+ function w(f, x) {
1615
+ let a = null;
1616
+ f.key === "ArrowRight" && (a = (x + 1) % t.items.length), f.key === "ArrowLeft" && (a = (x - 1 + t.items.length) % t.items.length), f.key === "Home" && (a = 0), f.key === "End" && (a = t.items.length - 1), a !== null && (f.preventDefault(), u(a, !0));
1617
+ }
1618
+ return ae(
1619
+ () => t.modelValue,
1620
+ async (f) => {
1621
+ var a, h;
1622
+ await Ie();
1623
+ const x = t.items.findIndex((I) => I.value === f);
1624
+ (h = (a = l.value[x]) == null ? void 0 : a.scrollIntoView) == null || h.call(a, { block: "nearest", inline: "nearest" });
1625
+ },
1626
+ { immediate: !0 }
1627
+ ), (f, x) => (s(), m("nav", {
1628
+ role: "tablist",
1629
+ "aria-label": f.ariaLabel,
1630
+ class: "overflow-x-auto print:hidden"
1631
+ }, [
1632
+ n("div", Va, [
1633
+ (s(!0), m(H, null, oe(f.items, (a, h) => (s(), m("button", {
1634
+ id: a.id,
1635
+ key: a.value,
1636
+ ref_for: !0,
1637
+ ref: (I) => l.value[h] = I,
1638
+ type: "button",
1639
+ role: "tab",
1640
+ "aria-selected": f.modelValue === a.value,
1641
+ "aria-controls": a.controls,
1642
+ tabindex: f.modelValue === a.value ? 0 : -1,
1643
+ class: U(["flex h-40 shrink-0 items-center gap-[6px] border-b-2 px-12 text-[14px] leading-[18px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-fm-color-border-focused", [
1644
+ f.modelValue === a.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"
1645
+ ]]),
1646
+ onClick: (I) => u(h),
1647
+ onKeydown: (I) => w(I, h)
1648
+ }, [
1649
+ n("span", null, p(a.label), 1)
1650
+ ], 42, Ua))), 128))
1651
+ ])
1652
+ ], 8, Ma));
1653
+ }
1654
+ }), za = {
1655
+ key: 0,
1656
+ "data-testid": "production-run-close-remark"
1657
+ }, Wa = /* @__PURE__ */ K({
1658
+ __name: "ProductionRunTerminalNotice",
1659
+ props: {
1660
+ run: {}
1661
+ },
1662
+ setup(L) {
1663
+ const c = L, { t } = J(), _ = $(() => ht(c.run)), l = $(
1664
+ () => {
1665
+ var u, w;
1666
+ return ((w = (u = [...c.run.activityLogs].reverse().find((f) => f.action === "close")) == null ? void 0 : u.remark) == null ? void 0 : w.trim()) || null;
1667
+ }
1668
+ );
1669
+ return (u, w) => _.value === "above-target" ? (s(), B(re, {
1670
+ key: 0,
1671
+ "data-testid": "closed-run-notice",
1672
+ role: "note",
1673
+ tone: "warn",
1674
+ title: e(t)("inventory.production.run.detail.banner.closedAbove.title")
1675
+ }, null, 8, ["title"])) : _.value === "below-target" ? (s(), B(re, {
1676
+ key: 1,
1677
+ "data-testid": "closed-run-notice",
1678
+ role: "note",
1679
+ tone: "warn",
1680
+ title: e(t)("inventory.production.run.detail.banner.closed.title")
1681
+ }, {
1682
+ default: ne(() => [
1683
+ l.value ? (s(), m("p", za, p(l.value), 1)) : R("", !0)
1684
+ ]),
1685
+ _: 1
1686
+ }, 8, ["title"])) : u.run.status === "CANCEL" ? (s(), B(re, {
1687
+ key: 2,
1688
+ "data-testid": "cancelled-run-notice",
1689
+ role: "note",
1690
+ tone: "critical",
1691
+ title: e(t)("inventory.production.run.detail.banner.cancelled.title"),
1692
+ message: u.run.cancelReason || void 0
1693
+ }, null, 8, ["title", "message"])) : R("", !0);
1694
+ }
1695
+ }), je = {
1696
+ failed: 4,
1697
+ unavailable: 3,
1698
+ unknown: 2,
1699
+ dispatched: 1
1700
+ };
1701
+ function Ga(L) {
1702
+ switch (L.stockRecalculationDispatch) {
1703
+ case "failed":
1704
+ return "failed";
1705
+ case "dispatched":
1706
+ return "dispatched";
1707
+ case "unavailable":
1708
+ return "unavailable";
1709
+ case "not-required":
1710
+ return null;
1711
+ default:
1712
+ return L.stockRecalculationRequired ? "unknown" : null;
1713
+ }
1714
+ }
1715
+ function Ka(L, { leaveOnLocationChange: c = !0 } = {}) {
1716
+ const t = Ke(), _ = Ae(), l = Se(), u = j(null), w = j("waitingForLocation"), f = j(null), x = j("overview"), a = j(null), h = $(() => a.value !== null);
1717
+ let I = null, i = 0, r = null;
1718
+ async function k() {
1719
+ const A = ++i;
1720
+ r = null;
1721
+ const M = _._currentLocation;
1722
+ if (!M) {
1723
+ w.value = "waitingForLocation";
1724
+ return;
1725
+ }
1726
+ if (I && I !== M.dbName) {
1727
+ u.value = null, c ? (I = null, await l.replace(Pe())) : w.value = "loading";
1728
+ return;
1729
+ }
1730
+ const W = fe(L);
1731
+ if (!W) {
1732
+ w.value = "error";
1733
+ return;
1734
+ }
1735
+ w.value = "loading", f.value = null, r = { dbName: M.dbName, id: W };
1736
+ try {
1737
+ const se = await t.read(W);
1738
+ if (A !== i) return;
1739
+ r = null, u.value = se, I = M.dbName, w.value = "ready";
1740
+ } catch (se) {
1741
+ if (A !== i) return;
1742
+ r = null;
1743
+ const ye = be(se);
1744
+ w.value = ye.kind === "notFound" ? "notInLocation" : "error", f.value = ye.message, u.value = null;
1745
+ }
1746
+ }
1747
+ async function o() {
1748
+ const A = fe(L);
1749
+ if (!A || !_._currentLocation) return;
1750
+ const M = ++i;
1751
+ r = null;
1752
+ try {
1753
+ const W = await t.read(A);
1754
+ if (M !== i) return;
1755
+ u.value = W, w.value = "ready";
1756
+ } catch (W) {
1757
+ if (M !== i) return;
1758
+ const se = be(W);
1759
+ w.value = se.kind === "notFound" ? "notInLocation" : "error", f.value = se.message;
1760
+ }
1761
+ }
1762
+ async function d() {
1763
+ var M;
1764
+ const A = (M = _._currentLocation) == null ? void 0 : M.dbName;
1765
+ A && A === I && w.value !== "waitingForLocation" || A && w.value === "loading" && (r == null ? void 0 : r.dbName) === A && r.id === fe(L) || await k();
1766
+ }
1767
+ _.watchLocation(d), ae(
1768
+ () => fe(L),
1769
+ (A, M) => {
1770
+ !A || A === M || (u.value = null, x.value = "overview", a.value = null, k());
1771
+ }
1772
+ );
1773
+ function b(A) {
1774
+ if (!("run" in A)) {
1775
+ u.value = A;
1776
+ return;
1777
+ }
1778
+ u.value = A.run;
1779
+ const M = Ga(A);
1780
+ if (!M) return;
1781
+ const W = a.value;
1782
+ (!W || je[M] > je[W]) && (a.value = M);
1783
+ }
1784
+ const q = $(() => {
1785
+ var A;
1786
+ return ((A = _._currentLocation) == null ? void 0 : A.name) ?? "";
1787
+ }), O = $(() => {
1788
+ var A;
1789
+ return (((A = u.value) == null ? void 0 : A.preparation.issuances.length) ?? 0) > 0;
1790
+ }), D = $(
1791
+ () => u.value ? gt(u.value) : []
1792
+ ), v = $(() => O.value ? D.value.length > 0 || !!u.value && we(u.value) ? ["overview", "output", "ingredients", "activity"] : ["overview", "ingredients", "activity"] : ["overview", "activity"]), S = $(() => !!u.value && !_t(u.value)), y = $(() => u.value && S.value ? kt(u.value) : null), C = $(() => u.value && S.value ? $t(u.value) : null), N = $(
1793
+ () => u.value && S.value ? Object.values(Me(u.value)).reduce((A, M) => A + M, 0) : null
1794
+ ), X = $(() => y.value === null || C.value === null ? null : y.value > 0 && C.value > 0 ? C.value / y.value * 100 : u.value && we(u.value) ? 0 : null), z = $(() => !!u.value && xt(u.value)), F = $(
1795
+ () => z.value && !!u.value && !we(u.value) && !Le(u.value)
1796
+ ), Z = $(() => u.value ? Ge(u.value) : null), pe = $(() => u.value ? wt(u.value) : []), _e = $(() => pe.value.map((A) => A.action));
1797
+ function ue(A) {
1798
+ return _e.value.includes(A);
1799
+ }
1800
+ const ve = $(() => {
1801
+ if (F.value && ue("close")) return "close";
1802
+ for (const A of ["complete", "prepare", "request"])
1803
+ if (ue(A)) return A;
1804
+ return null;
1805
+ }), ke = $(
1806
+ () => ["complete", "close", "update"].filter(
1807
+ (A) => ue(A) && A !== ve.value
1808
+ )
1809
+ ), $e = $(
1810
+ () => ["cancel"].filter((A) => ue(A))
1811
+ );
1812
+ return {
1813
+ run: u,
1814
+ phase: w,
1815
+ errorMessage: f,
1816
+ activeTab: x,
1817
+ tabs: v,
1818
+ locationName: q,
1819
+ stockRecalculation: a,
1820
+ stockRecalculationRequired: h,
1821
+ /** The one way to take a stock-moving write's answer onto the page. */
1822
+ adoptWriteResult: b,
1823
+ hasIssuance: O,
1824
+ batches: D,
1825
+ committed: y,
1826
+ produced: C,
1827
+ remaining: N,
1828
+ attainmentPercent: X,
1829
+ atTarget: z,
1830
+ targetReachedOpen: F,
1831
+ outcome: Z,
1832
+ summable: S,
1833
+ legalActions: pe,
1834
+ /** Legality asked as a question, so callers never re-derive the table. */
1835
+ can: ue,
1836
+ primaryAction: ve,
1837
+ secondaryActions: ke,
1838
+ dangerActions: $e,
1839
+ load: k,
1840
+ reload: o
1841
+ };
1842
+ }
1843
+ function Qa(L) {
1844
+ const c = j([]), t = j(null), _ = j(!1), l = j(!1), u = j(null);
1845
+ let w = 0;
1846
+ const f = $(() => ({
1847
+ loading: _.value,
1848
+ loaded: l.value,
1849
+ hasMore: t.value !== null,
1850
+ error: u.value
1851
+ }));
1852
+ function x() {
1853
+ w++, c.value = [], t.value = null, _.value = !1, l.value = !1, u.value = null;
1854
+ }
1855
+ async function a(i) {
1856
+ const r = w, k = L.runId(), o = L.locationId(), d = () => r === w && L.runId() === k && L.locationId() === o;
1857
+ _.value = !0, u.value = null;
1858
+ try {
1859
+ const b = await L.list(i);
1860
+ if (!d()) return;
1861
+ if (i && b.nextCursor === i)
1862
+ throw new Error(
1863
+ "The next page could not be advanced. Reopen the editor to refresh history."
1864
+ );
1865
+ const q = new Set(c.value.map((O) => O._id));
1866
+ c.value = [...c.value, ...b.items.filter((O) => !q.has(O._id))], t.value = b.nextCursor, l.value = !0;
1867
+ } catch (b) {
1868
+ d() && (u.value = be(b).message);
1869
+ } finally {
1870
+ d() && (_.value = !1);
1871
+ }
1872
+ }
1873
+ async function h() {
1874
+ x(), await a();
1875
+ }
1876
+ async function I() {
1877
+ if (!_.value) {
1878
+ if (!l.value) return await h();
1879
+ t.value !== null && await a(t.value);
1880
+ }
1881
+ }
1882
+ return { sources: c, state: f, load: h, loadMore: I, invalidate: x };
1883
+ }
1884
+ const Za = { class: "flex flex-col w-full h-full bg-fm-color-surface-primary overflow-y-auto" }, Ya = {
1885
+ key: 0,
1886
+ class: "flex flex-col gap-16 p-24"
1887
+ }, Ja = {
1888
+ key: 1,
1889
+ class: "flex flex-col gap-16 p-24 max-w-[640px]"
1890
+ }, Xa = {
1891
+ key: 2,
1892
+ class: "flex flex-col gap-16 p-24 max-w-[640px]"
1893
+ }, er = {
1894
+ key: 1,
1895
+ class: "flex justify-center py-32"
1896
+ }, tr = /* @__PURE__ */ K({
1897
+ __name: "ProductionRunDetailView",
1898
+ props: {
1899
+ id: {}
1900
+ },
1901
+ setup(L) {
1902
+ const c = L, { t } = J(), _ = Se(), l = ot(), u = tt(), w = Ke(), f = Ae(), x = $(() => Pe());
1903
+ It();
1904
+ const a = Ka(() => c.id, { leaveOnLocationChange: !1 }), h = Rt(() => a.run.value), I = Qa({
1905
+ list: (g) => w.list(g ? { cursor: g } : {}),
1906
+ runId: () => c.id,
1907
+ locationId: () => f.currentLocationId
1908
+ }), i = I.sources, r = St(), k = j(!1), o = $(
1909
+ () => a.run.value ? r.requestedIngredientRows(a.run.value) : []
1910
+ );
1911
+ async function d() {
1912
+ if (!a.run.value) return;
1913
+ const g = c.id;
1914
+ if (a.run.value.status === "CANCEL") {
1915
+ k.value = !0, await r.loadCatalogue();
1916
+ return;
1917
+ }
1918
+ !await r.load({ livePlan: a.run.value.status === "DRAFT" }) || g !== c.id || !a.run.value || (r.seedFrom(a.run.value), k.value = !0);
1919
+ }
1920
+ const b = $(() => {
1921
+ const g = a.run.value, T = g == null ? void 0 : g.status;
1922
+ return T === "DRAFT" ? "draft" : T === "REQUESTING" ? "requested" : T === "PREPARING" ? "preparing" : T === "CANCEL" ? g != null && g.plan.requirements ? "requested" : "draft" : "review";
1923
+ }), q = $(() => {
1924
+ var g;
1925
+ return ((g = a.run.value) == null ? void 0 : g.status) !== "CANCEL";
1926
+ }), O = $(() => {
1927
+ const g = a.run.value;
1928
+ return g && g.status === "CANCEL" ? r.historicalItems(g) : void 0;
1929
+ });
1930
+ ae(
1931
+ () => [a.phase.value, a.hasIssuance.value],
1932
+ async ([g, T]) => {
1933
+ g !== "ready" || T || k.value || !a.run.value || await d();
1934
+ },
1935
+ { immediate: !0 }
1936
+ );
1937
+ const D = j(null);
1938
+ let v = null;
1939
+ const S = j("review"), y = j(!1), C = j(null);
1940
+ let N = 0;
1941
+ Xe(() => {
1942
+ N++;
1943
+ }), ae(
1944
+ () => c.id,
1945
+ () => {
1946
+ I.invalidate(), k.value = !1, M.value = !1, D.value = null, N++, y.value = !1;
1947
+ }
1948
+ );
1949
+ const X = $(() => a.run.value ? At(a.run.value) : null), z = $(() => {
1950
+ var T, V;
1951
+ const g = {};
1952
+ for (const Y of ((T = a.run.value) == null ? void 0 : T.preparation.issuances) ?? [])
1953
+ for (const Q of Y.items)
1954
+ g[Q.sku._id] = {
1955
+ name: Q.sku.name,
1956
+ unit: ((V = Q.sku.unit) == null ? void 0 : V.abbrev) ?? null,
1957
+ precision: Q.sku.unit ? Oe(Q.sku.unit) : null
1958
+ };
1959
+ for (const Y of h.ingredientLines.value)
1960
+ g[Y.skuId] || (g[Y.skuId] = {
1961
+ name: Y.name,
1962
+ unit: Y.unit,
1963
+ precision: Y.unitRef ? Oe(Y.unitRef) : null
1964
+ });
1965
+ return g;
1966
+ }), F = $(
1967
+ () => a.tabs.value.map((g) => ({
1968
+ label: t(`inventory.production.run.detail.tab.${g}`),
1969
+ value: g,
1970
+ id: `production-run-tab-${g}`,
1971
+ controls: `production-run-panel-${g}`
1972
+ }))
1973
+ ), Z = $(
1974
+ () => !!a.run.value && Le(a.run.value)
1975
+ ), pe = $(() => {
1976
+ const g = a.run.value;
1977
+ if (!g) return "";
1978
+ if (Z.value) return t("inventory.production.run.detail.pendingStock.message");
1979
+ let T;
1980
+ switch (g.status) {
1981
+ case "REQUESTING":
1982
+ T = "requested";
1983
+ break;
1984
+ case "PREPARING":
1985
+ T = g.batches.length > 0 ? "issuedWithOutput" : "issued";
1986
+ break;
1987
+ case "CLOSED":
1988
+ T = "closed";
1989
+ break;
1990
+ case "CANCEL":
1991
+ T = "cancelled";
1992
+ break;
1993
+ default:
1994
+ T = "draft";
1995
+ }
1996
+ return t(`inventory.production.run.detail.next.${T}`);
1997
+ }), _e = $(
1998
+ () => h.ingredientLines.value.map((g) => ({
1999
+ skuId: g.skuId,
2000
+ name: g.name,
2001
+ unit: g.unit,
2002
+ unitRef: g.unitRef,
2003
+ outputSkuIds: g.outputSkuIds
2004
+ }))
2005
+ );
2006
+ function ue(g) {
2007
+ var T;
2008
+ if (a.can(g)) {
2009
+ if (g === "update") {
2010
+ D.value = "update", I.load();
2011
+ return;
2012
+ }
2013
+ if (g === "request") {
2014
+ const V = (T = a.run.value) == null ? void 0 : T._id, Y = f.currentLocationDBName, Q = N;
2015
+ l.open(qt(t)).onPrimary(() => {
2016
+ var Be;
2017
+ Q !== N || V !== ((Be = a.run.value) == null ? void 0 : Be._id) || Y !== f.currentLocationDBName || ke();
2018
+ });
2019
+ return;
2020
+ }
2021
+ g === "prepare" && (S.value = "review"), v = document.activeElement instanceof HTMLElement ? document.activeElement : null, D.value = g;
2022
+ }
2023
+ }
2024
+ function ve() {
2025
+ a.can("prepare") && (S.value = "print", v = document.activeElement instanceof HTMLElement ? document.activeElement : null, D.value = "prepare");
2026
+ }
2027
+ async function ke() {
2028
+ if (!a.can("request")) return;
2029
+ const g = a.run.value;
2030
+ if (!g) return;
2031
+ const T = ++N;
2032
+ y.value = !0;
2033
+ try {
2034
+ const V = await w.request(g._id);
2035
+ if (T !== N) return;
2036
+ a.run.value = V, u.success(t("inventory.production.run.detail.toast.requested"));
2037
+ } catch (V) {
2038
+ if (T !== N) return;
2039
+ u.error(be(V).message);
2040
+ } finally {
2041
+ T === N && (y.value = !1);
2042
+ }
2043
+ }
2044
+ function $e(g) {
2045
+ a.adoptWriteResult(g), u.success(t("inventory.production.run.detail.toast.issued"));
2046
+ }
2047
+ function A(g) {
2048
+ a.adoptWriteResult(g), h.refresh(), u.success(t("inventory.production.run.detail.toast.recorded")), M.value = a.can("close") && a.atTarget.value;
2049
+ }
2050
+ const M = j(!1), W = $(() => {
2051
+ const g = a.stockRecalculation.value;
2052
+ return g ? {
2053
+ tone: g === "dispatched" ? "info" : "warn",
2054
+ key: `inventory.production.run.detail.recalculation.${g}`
2055
+ } : null;
2056
+ }), se = $(() => {
2057
+ const g = a.locationName.value;
2058
+ return g ? t("inventory.production.run.detail.notInLocation.title", { location: g }) : t("inventory.production.run.detail.notInLocation.titleUnknown");
2059
+ });
2060
+ function ye(g) {
2061
+ D.value = null, I.invalidate(), xe(g), k.value && r.seedFrom(g), h.refresh();
2062
+ }
2063
+ function Te() {
2064
+ a.reload(), h.refresh();
2065
+ }
2066
+ ae(
2067
+ () => a.activeTab.value,
2068
+ (g, T) => {
2069
+ g === "ingredients" && T !== "ingredients" && Te();
2070
+ }
2071
+ );
2072
+ async function qe() {
2073
+ try {
2074
+ await r.refreshStock();
2075
+ } catch (g) {
2076
+ u.error(be(g).message);
2077
+ }
2078
+ }
2079
+ async function Ze(g) {
2080
+ var T;
2081
+ if (g === null) {
2082
+ const V = v;
2083
+ v = null, D.value = null, I.invalidate(), await Ie(), V != null && V.isConnected ? V.focus() : (T = C.value) == null || T.focus();
2084
+ }
2085
+ }
2086
+ function xe(g) {
2087
+ a.run.value = g;
2088
+ }
2089
+ function Ye() {
2090
+ _.push(x.value);
2091
+ }
2092
+ return (g, T) => {
2093
+ const V = te("FmButton"), Y = te("FmCircularProgress");
2094
+ return s(), m("div", Za, [
2095
+ e(a).phase.value === "waitingForLocation" || e(a).phase.value === "loading" ? (s(), m("div", Ya, T[3] || (T[3] = [
2096
+ n("div", { class: "h-24 w-1/3 rounded bg-fm-color-neutral-gray-100 animate-pulse" }, null, -1),
2097
+ n("div", { class: "h-16 w-1/2 rounded bg-fm-color-neutral-gray-100 animate-pulse" }, null, -1),
2098
+ n("div", { class: "h-[240px] rounded bg-fm-color-neutral-gray-100 animate-pulse" }, null, -1)
2099
+ ]))) : e(a).phase.value === "notInLocation" ? (s(), m("div", Ja, [
2100
+ P(re, {
2101
+ tone: "warn",
2102
+ title: se.value,
2103
+ message: e(t)("inventory.production.run.detail.notInLocation.message")
2104
+ }, {
2105
+ actions: ne(() => [
2106
+ P(V, {
2107
+ variant: "secondary",
2108
+ label: e(t)("inventory.production.run.detail.notInLocation.action"),
2109
+ onClick: Ye
2110
+ }, null, 8, ["label"])
2111
+ ]),
2112
+ _: 1
2113
+ }, 8, ["title", "message"])
2114
+ ])) : e(a).phase.value === "error" ? (s(), m("div", Xa, [
2115
+ P(re, {
2116
+ role: "alert",
2117
+ tone: "critical",
2118
+ title: e(t)("inventory.production.run.detail.error.title"),
2119
+ message: e(a).errorMessage.value ?? void 0
2120
+ }, {
2121
+ actions: ne(() => [
2122
+ P(V, {
2123
+ variant: "secondary",
2124
+ label: e(t)("inventory.production.run.detail.error.retry"),
2125
+ onClick: T[0] || (T[0] = (Q) => e(a).load())
2126
+ }, null, 8, ["label"])
2127
+ ]),
2128
+ _: 1
2129
+ }, 8, ["title", "message"])
2130
+ ])) : e(a).run.value ? (s(), m("div", {
2131
+ key: 3,
2132
+ ref_key: "detailContent",
2133
+ ref: C,
2134
+ tabindex: "-1",
2135
+ "data-testid": "production-run-detail-content",
2136
+ class: "production-run-detail-content mx-auto flex w-full max-w-[1228px] flex-col gap-16"
2137
+ }, [
2138
+ P(Wt, {
2139
+ run: e(a).run.value,
2140
+ "location-name": e(a).locationName.value,
2141
+ "back-to": x.value,
2142
+ "primary-action": e(a).primaryAction.value,
2143
+ "secondary-actions": e(a).secondaryActions.value,
2144
+ "danger-actions": e(a).dangerActions.value,
2145
+ "can-print-prepare-sheet": e(a).primaryAction.value === "prepare",
2146
+ "status-description": pe.value,
2147
+ "target-reached": e(a).targetReachedOpen.value,
2148
+ busy: y.value,
2149
+ onAction: ue,
2150
+ onPrintPrepareSheet: ve
2151
+ }, null, 8, ["run", "location-name", "back-to", "primary-action", "secondary-actions", "danger-actions", "can-print-prepare-sheet", "status-description", "target-reached", "busy"]),
2152
+ Z.value ? (s(), B(re, {
2153
+ key: 0,
2154
+ "data-testid": "production-run-pending-stock",
2155
+ role: "status",
2156
+ tone: "warn",
2157
+ title: e(t)("inventory.production.run.detail.pendingStock.title"),
2158
+ message: e(t)("inventory.production.run.detail.pendingStock.message")
2159
+ }, null, 8, ["title", "message"])) : R("", !0),
2160
+ W.value ? (s(), B(re, {
2161
+ key: 1,
2162
+ tone: W.value.tone,
2163
+ title: e(t)(`${W.value.key}.title`),
2164
+ message: e(t)(`${W.value.key}.message`)
2165
+ }, null, 8, ["tone", "title", "message"])) : R("", !0),
2166
+ M.value && e(a).targetReachedOpen.value ? (s(), B(re, {
2167
+ key: 2,
2168
+ "data-testid": "target-reached-notice",
2169
+ tone: "info",
2170
+ title: e(t)("inventory.production.run.detail.targetOffer.title"),
2171
+ message: e(t)("inventory.production.run.detail.targetOffer.message")
2172
+ }, null, 8, ["title", "message"])) : R("", !0),
2173
+ P(Wa, {
2174
+ run: e(a).run.value
2175
+ }, null, 8, ["run"]),
2176
+ P(Ha, {
2177
+ modelValue: e(a).activeTab.value,
2178
+ "onUpdate:modelValue": T[1] || (T[1] = (Q) => e(a).activeTab.value = Q),
2179
+ class: "mb-4",
2180
+ items: F.value,
2181
+ ariaLabel: e(t)("inventory.production.run.detail.tabsLabel")
2182
+ }, null, 8, ["modelValue", "items", "ariaLabel"]),
2183
+ e(a).activeTab.value === "overview" ? (s(), B(Vo, {
2184
+ key: 3,
2185
+ id: "production-run-panel-overview",
2186
+ role: "tabpanel",
2187
+ "aria-labelledby": "production-run-tab-overview",
2188
+ run: e(a).run.value,
2189
+ names: z.value,
2190
+ batches: e(a).batches.value,
2191
+ committed: e(a).committed.value,
2192
+ unit: X.value,
2193
+ "has-issuance": e(a).hasIssuance.value,
2194
+ operational: b.value !== "review",
2195
+ onViewAll: T[2] || (T[2] = (Q) => e(a).activeTab.value = "output")
2196
+ }, {
2197
+ operational: ne(() => [
2198
+ q.value && b.value !== "preparing" && (e(r).loadFailure.value || e(r).projectionFailed.value) ? (s(), B(Lt, {
2199
+ key: 0,
2200
+ "load-failure": e(r).loadFailure.value,
2201
+ "projection-failed": e(r).projectionFailed.value,
2202
+ onRetryLoad: d,
2203
+ onRetryProjection: e(r).retryProjection
2204
+ }, null, 8, ["load-failure", "projection-failed", "onRetryProjection"])) : q.value && b.value !== "preparing" && e(r).loading.value ? (s(), m("div", er, [
2205
+ P(Y, { size: "lg" })
2206
+ ])) : b.value === "draft" && k.value ? (s(), B(Pt, {
2207
+ key: 2,
2208
+ items: e(r).items.value,
2209
+ "historical-items": O.value,
2210
+ commits: e(r).commits.value,
2211
+ instructions: e(a).run.value.instructions,
2212
+ editable: !1,
2213
+ refreshable: q.value,
2214
+ refreshing: e(r).refreshingStock.value,
2215
+ "show-stock-projection": q.value,
2216
+ onRefresh: qe
2217
+ }, null, 8, ["items", "historical-items", "commits", "instructions", "refreshable", "refreshing", "show-stock-projection"])) : b.value === "requested" && k.value ? (s(), B(Da, {
2218
+ key: 3,
2219
+ run: e(a).run.value,
2220
+ items: O.value ?? e(r).items.value,
2221
+ ingredients: o.value,
2222
+ refreshable: q.value,
2223
+ refreshing: e(r).refreshingStock.value,
2224
+ "show-stock-projection": q.value,
2225
+ onRefresh: qe
2226
+ }, null, 8, ["run", "items", "ingredients", "refreshable", "refreshing", "show-stock-projection"])) : b.value === "preparing" ? (s(), B(Qe, {
2227
+ key: 4,
2228
+ run: e(a).run.value,
2229
+ names: z.value,
2230
+ "ingredient-contributions": e(h).ingredientContributions.value,
2231
+ "unattributed-ingredients": e(h).unattributedIngredientLines.value,
2232
+ "unissued-sku-ids": e(h).unissuedOutputs.value.map((Q) => Q.skuId),
2233
+ "title-key": "inventory.production.run.form.items.title",
2234
+ presentation: "preparing"
2235
+ }, null, 8, ["run", "names", "ingredient-contributions", "unattributed-ingredients", "unissued-sku-ids"])) : R("", !0)
2236
+ ]),
2237
+ _: 1
2238
+ }, 8, ["run", "names", "batches", "committed", "unit", "has-issuance", "operational"])) : e(a).activeTab.value === "output" ? (s(), B(zo, {
2239
+ key: 4,
2240
+ id: "production-run-panel-output",
2241
+ role: "tabpanel",
2242
+ "aria-labelledby": "production-run-tab-output",
2243
+ batches: e(a).batches.value,
2244
+ names: z.value
2245
+ }, null, 8, ["batches", "names"])) : e(a).activeTab.value === "ingredients" ? (s(), B(ya, {
2246
+ key: 5,
2247
+ id: "production-run-panel-ingredients",
2248
+ role: "tabpanel",
2249
+ "aria-labelledby": "production-run-tab-ingredients",
2250
+ "run-id": e(a).run.value._id,
2251
+ loading: e(h).loading.value,
2252
+ "snapshot-available": e(h).adjustment.value !== null,
2253
+ lines: e(h).ingredientLines.value,
2254
+ "ingredient-contributions": e(h).ingredientContributions.value,
2255
+ "output-names": z.value,
2256
+ "unattributed-ingredients": e(h).unattributedIngredientLines.value
2257
+ }, null, 8, ["run-id", "loading", "snapshot-available", "lines", "ingredient-contributions", "output-names", "unattributed-ingredients"])) : (s(), B(Aa, {
2258
+ key: 6,
2259
+ id: "production-run-panel-activity",
2260
+ role: "tabpanel",
2261
+ "aria-labelledby": "production-run-tab-activity",
2262
+ run: e(a).run.value
2263
+ }, null, 8, ["run"])),
2264
+ P(Tt, {
2265
+ action: D.value,
2266
+ run: e(a).run.value,
2267
+ "location-name": e(a).locationName.value,
2268
+ "duplicate-sources": e(i),
2269
+ "duplicate-source-state": e(I).state.value,
2270
+ onLoadMoreDuplicateSources: e(I).loadMore,
2271
+ "prepare-initial-view": S.value,
2272
+ "at-target": e(a).atTarget.value,
2273
+ ingredients: _e.value,
2274
+ "onUpdate:action": Ze,
2275
+ onEdited: ye,
2276
+ onIssued: $e,
2277
+ onRecorded: A,
2278
+ onClosed: xe,
2279
+ onCancelled: xe,
2280
+ onReload: Te
2281
+ }, null, 8, ["action", "run", "location-name", "duplicate-sources", "duplicate-source-state", "onLoadMoreDuplicateSources", "prepare-initial-view", "at-target", "ingredients"])
2282
+ ], 512)) : R("", !0)
2283
+ ]);
2284
+ };
2285
+ }
2286
+ }), nr = /* @__PURE__ */ ce(tr, [["__scopeId", "data-v-19386a44"]]), pr = /* @__PURE__ */ K({
2287
+ __name: "ProductionRunDetailPage",
2288
+ props: {
2289
+ id: {}
2290
+ },
2291
+ setup(L) {
2292
+ var w;
2293
+ const c = L, t = Se(), _ = Ae(), l = j(!1);
2294
+ let u = (w = _._currentLocation) == null ? void 0 : w.dbName;
2295
+ return ae(
2296
+ () => {
2297
+ var f;
2298
+ return (f = _._currentLocation) == null ? void 0 : f.dbName;
2299
+ },
2300
+ (f) => {
2301
+ !f || l.value || (u && f !== u && (l.value = !0, t.replace(Pe())), u = f);
2302
+ }
2303
+ ), (f, x) => (s(), B(et, { "feature-key": "production-runs" }, {
2304
+ default: ne(() => [
2305
+ l.value ? R("", !0) : (s(), B(nr, {
2306
+ key: 0,
2307
+ id: c.id
2308
+ }, null, 8, ["id"]))
2309
+ ]),
2310
+ _: 1
2311
+ }));
2312
+ }
2313
+ });
2314
+ export {
2315
+ pr as default
2316
+ };