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

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 (138) hide show
  1. package/dist/App-Blx6Ojzj.js +311 -0
  2. package/dist/{ApprovalView-DO91AQ5f.js → ApprovalView-BPDiAWh_.js} +9 -9
  3. package/dist/{BindingsDialog-DUj0z6N7.js → BindingsDialog-RUlhC05W.js} +2 -2
  4. package/dist/{BindingsPicker-CD2J6-_Z.js → BindingsPicker-voEXbc8p.js} +2 -2
  5. package/dist/{BindingsTable-B2FEKZXU.js → BindingsTable-QuFV3fHq.js} +4 -4
  6. package/dist/BulkReceiveRequestView-Bix6MV0Z.js +2595 -0
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-ashHOuZt.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CSxFa-Hr.js} +2 -6
  8. package/dist/{ClosingDraftView-tIvrsfYH.js → ClosingDraftView-BUWt7ufW.js} +19 -19
  9. package/dist/ClosingHistoryView-BzQ7f_31.js +761 -0
  10. package/dist/{ClosingTemplateView-C-hL9uPv.js → ClosingTemplateView-BoDHKL2a.js} +16 -16
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-BffF8S_q.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-B-t0N1PO.js} +1 -1
  12. package/dist/{DefaultView-BLbtx0Ho.js → DefaultView-CO4Fk0X3.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-BLQHL7aB.js → DeliveryOrderPrintPreview-Clslc2Wf.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-BnTAuutB.js → EmailDialog.vue_vue_type_script_setup_true_lang-BfQdw5-j.js} +2254 -2259
  15. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Mxhn0b6c.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Brtj-hCD.js} +6 -6
  16. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-hrk0cTBX.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CHUQOFif.js} +2 -2
  17. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-hTQmIyaf.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BqIWvN-i.js} +2 -2
  18. package/dist/{FmMultiselectDialog-Bpi5rI0h.js → FmMultiselectDialog-D7cnUmM5.js} +1 -1
  19. package/dist/{FmMultiselectDialog-Bi6XlAAU.js → FmMultiselectDialog-GAdb6F9O.js} +2 -2
  20. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-e55tnl4u.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DAjM0Dya.js} +6 -6
  21. package/dist/{ImportView-xPTzBekx.js → ImportView-CrmY9zsK.js} +496 -499
  22. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-tvmS42s_.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-Sm0goJ7U.js} +1 -1
  23. package/dist/{IngredientGroupView-RFcqjF8T.js → IngredientGroupView-BebnVDQI.js} +5 -5
  24. package/dist/{IngredientsView-CvWOgquN.js → IngredientsView-CZ6Angq_.js} +17 -18
  25. package/dist/{IntegrationExplorerView-CYNhsJSS.js → IntegrationExplorerView-DxjMZi_f.js} +4 -4
  26. package/dist/{IntegrationView-ZtLokbu3.js → IntegrationView-Dm6Bkv1g.js} +15 -19
  27. package/dist/{InventoryBindingForm-DwiAIf5v.js → InventoryBindingForm-B5Dd6UGk.js} +1 -1
  28. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-D4shlQ9Z.js +441 -0
  29. package/dist/{InventoryBindingSummary-zim_Bp5_.js → InventoryBindingSummary-BO8imeDG.js} +1 -1
  30. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CfTgt5xW.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Dp6O-oVL.js} +1 -1
  31. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-LLtd1VvM.js → PremiumBadge.vue_vue_type_script_setup_true_lang-Mkt2BoGf.js} +1 -1
  32. package/dist/{ProductionView-BWn7RBEg.js → ProductionView-DIwvqo6L.js} +7 -7
  33. package/dist/{PublishView-DFXOi7Hx.js → PublishView-CbeljE1v.js} +3 -3
  34. package/dist/{PurchaseOrderPrintPreview-CG6kBQ26.js → PurchaseOrderPrintPreview-PzYdJJW9.js} +2 -2
  35. package/dist/{ReceiveRequestView-DKMVMo7M.js → ReceiveRequestView-NKnqWM_b.js} +14 -14
  36. package/dist/RecipeView-COQ6WUcz.js +3584 -0
  37. package/dist/{SettingsView-Cmf2ZOUL.js → SettingsView-BjX4I2pe.js} +4 -4
  38. package/dist/{StockView-DTai8l8U.js → StockView--9-NLfX0.js} +21 -21
  39. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BlKm7GLw.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BWHPauQW.js} +1 -1
  40. package/dist/{SupplierView-CRAHOOLm.js → SupplierView-B8T6cose.js} +12 -12
  41. package/dist/{SurchargeView-3XymEvcr.js → SurchargeView-eVcM29Ss.js} +6 -6
  42. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-DcXfQr_8.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CYXfguPD.js} +2 -2
  43. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-qhJVHahS.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CMM1DWU3.js} +1 -1
  44. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CuNAt9UU.js +4733 -0
  45. package/dist/{TransferTemplateView-ByhvK4Ua.js → TransferTemplateView-D_oKyOUD.js} +20 -20
  46. package/dist/{UnitCostHistoryView-DHHWNJYA.js → UnitCostHistoryView-DThFdkNP.js} +4 -4
  47. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-bQu2KOI7.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-B6cHxf2Q.js} +4 -4
  48. package/dist/{UnitView-BZTS-Ahu.js → UnitView-BQZepbTS.js} +8 -8
  49. package/dist/WarehouseView-BZSn9BHl.js +1079 -0
  50. package/dist/{WastageTemplateView-CUDL3HUD.js → WastageTemplateView-BQO1geZz.js} +14 -14
  51. package/dist/api/purchase-order.d.ts +0 -2
  52. package/dist/api/stock.d.ts +0 -6
  53. package/dist/{app-BUQUpe4c.js → app-KaSY7GIt.js} +9137 -10098
  54. package/dist/app.d.ts +9 -952
  55. package/dist/app.js +1 -1
  56. package/dist/{closing-template-DzxDiEQB.js → closing-template-BFEWl8-N.js} +1 -1
  57. package/dist/cypress/support/component.d.ts +2 -1
  58. package/dist/{date2-6jkfRNS_.js → date2-DnqAk4pp.js} +5 -5
  59. package/dist/{dayjs.min-ByRnXzrl.js → dayjs.min-e3pyVvVk.js} +1 -1
  60. package/dist/{decimal-CqWBdj8E.js → decimal-DUKpY1WE.js} +2 -2
  61. package/dist/{defineDeepModel-CaT-4fiq.js → defineDeepModel-T75uoBAd.js} +1 -1
  62. package/dist/{duplicate-template-Cyvx-WK7.js → duplicate-template-CdBNGLA2.js} +1 -1
  63. package/dist/{feature-FjXz4WXw.js → feature-dE--ixN-.js} +2 -2
  64. package/dist/{format-time-from-id-cSri3OoO.js → format-time-from-id-D8SWSpBR.js} +1 -1
  65. package/dist/{format-unit-display-DPbcT7Ff.js → format-unit-display-ChGKpRsq.js} +27 -27
  66. package/dist/{import-export.helper-_yqcePYs.js → import-export.helper-BGjE6JjK.js} +6 -6
  67. package/dist/{index-nSL5yxNn.js → index-D_QylMOJ.js} +3 -3
  68. package/dist/{index-CyJVMHQW.js → index-DdMg0SgN.js} +1 -1
  69. package/dist/{index-CGvNoBid.js → index-JPtVC3tk.js} +3232 -3306
  70. package/dist/{inventory-core-dart.default-DSYRPQNZ.js → inventory-core-dart.default-0h8jmf3F.js} +1428 -1322
  71. package/dist/{lz-string-iyER1Klb.js → lz-string-NnYfN1XC.js} +1 -1
  72. package/dist/{netsuite-BD8LVxaA.js → netsuite-CAphkhg7.js} +1387 -1397
  73. package/dist/{number-C7CJ9ZfE.js → number-C8J8sC6d.js} +3 -3
  74. package/dist/{predefined-templates-o-_pKVSM.js → predefined-templates-CB1opHrA.js} +1 -1
  75. package/dist/{purchase-order-template-BHS8T1VA.js → purchase-order-template-p6EdpieI.js} +1 -1
  76. package/dist/{recalculationUtils-BCByr_CU.js → recalculationUtils-C5whNKrN.js} +1 -1
  77. package/dist/{rules-wZo-8FZ0.js → rules-sRZqLpuQ.js} +2 -2
  78. package/dist/{stock-CnAjxV7P.js → stock-BpfRRZPr.js} +3 -3
  79. package/dist/stock-DWrhlch4.js +85 -0
  80. package/dist/stores/bulk-job.d.ts +0 -13
  81. package/dist/style.css +1 -1
  82. package/dist/{supplier-DkqNwQmi.js → supplier-MzC5sRqv.js} +2 -2
  83. package/dist/{surcharge-Csj1WYbH.js → surcharge-ClMtrRgS.js} +8 -8
  84. package/dist/tsconfig.app.tsbuildinfo +1 -1
  85. package/dist/{uom-rules-BI1CdWeS.js → uom-rules-Di7y-2Xl.js} +1 -1
  86. package/dist/{use-ingredient-select-dialog-5AqoZJDA.js → use-ingredient-select-dialog-BPhQJhXq.js} +2 -2
  87. package/dist/{use-inventory-binding-dialog-ChiyhiuP.js → use-inventory-binding-dialog-BStbsMsT.js} +2 -2
  88. package/dist/{use-template-enabled-locations-BqXxegct.js → use-template-enabled-locations-ChCTz0-t.js} +2 -2
  89. package/dist/{use-transfer-locations-Ckj_diGt.js → use-transfer-locations-D8N8x1cE.js} +2 -2
  90. package/dist/{useHrmPermission-USG_KRoq.js → useHrmPermission-DCSqbLxW.js} +1 -1
  91. package/dist/{useNavigationMenu-BhYf87KI.js → useNavigationMenu-D3-zmwIs.js} +2 -2
  92. package/dist/{useSseClient-BqoE-ir6.js → useSseClient-BRHLaPnM.js} +1 -1
  93. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +0 -2
  94. package/dist/views/ingredients/components/inventory-binding/v2/InventoryBindingFormV2.vue.d.ts +0 -2
  95. package/dist/views/ingredients/components/inventory-binding/v2/components/InventoryRecipeBindingV2Field.vue.d.ts +0 -4
  96. package/dist/views/receive-request/components/email-dialog/EmailDialogProps.d.ts +9 -23
  97. package/dist/views/recipe/composables/use-recipe-table.d.ts +0 -11
  98. package/dist/views/stock/components/dialog/RecalculationDialog.vue.d.ts +2 -17
  99. package/dist/{vue-i18n-DoKioQ81.js → vue-i18n-BMo8ADYz.js} +196 -196
  100. package/dist/{xlsx.util-BXjE2o-3.js → xlsx.util-BSzjcX4G.js} +2 -2
  101. package/package.json +2 -2
  102. package/dist/App-Cfp4CqzQ.js +0 -1470
  103. package/dist/BulkReceiveRequestView-ejHyukEp.js +0 -2657
  104. package/dist/ClosingHistoryView-BYVZ01Ma.js +0 -1112
  105. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-njDaQe10.js +0 -563
  106. package/dist/RecipeView-cLLKlLmE.js +0 -3625
  107. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CibsrZXw.js +0 -4781
  108. package/dist/WarehouseView-DVak1RPs.js +0 -1082
  109. package/dist/api/changelog.d.ts +0 -132
  110. package/dist/cypress/component/ChangelogPanel.cy.d.ts +0 -1
  111. package/dist/stock-DwqEvWM5.js +0 -95
  112. package/dist/views/changelog/components/ChangelogDialog.vue.d.ts +0 -19
  113. package/dist/views/changelog/components/ChangelogFloatingButton.spec.d.ts +0 -1
  114. package/dist/views/changelog/components/ChangelogFloatingButton.vue.d.ts +0 -2
  115. package/dist/views/changelog/components/ChangelogPanel.spec.d.ts +0 -1
  116. package/dist/views/changelog/components/ChangelogPanel.vue.d.ts +0 -20
  117. package/dist/views/changelog/composables/change-path.d.ts +0 -10
  118. package/dist/views/changelog/composables/commit-message.d.ts +0 -9
  119. package/dist/views/changelog/composables/commit-message.spec.d.ts +0 -1
  120. package/dist/views/changelog/composables/fab-position.d.ts +0 -21
  121. package/dist/views/changelog/composables/json-line-diff.d.ts +0 -10
  122. package/dist/views/changelog/composables/json-line-diff.spec.d.ts +0 -1
  123. package/dist/views/changelog/composables/use-changelog.d.ts +0 -90
  124. package/dist/views/changelog/composables/use-changelog.spec.d.ts +0 -1
  125. package/dist/views/changelog/composables/use-inventory-record-commits.d.ts +0 -97
  126. package/dist/views/changelog/composables/use-inventory-record-commits.spec.d.ts +0 -1
  127. package/dist/views/changelog/composables/use-snapshot-diff.d.ts +0 -29
  128. package/dist/views/changelog/composables/use-snapshot-diff.spec.d.ts +0 -1
  129. package/dist/views/changelog/composables/value-tree.d.ts +0 -14
  130. package/dist/views/changelog/composables/value-tree.spec.d.ts +0 -1
  131. package/dist/views/import/helper/submit-rows.d.ts +0 -13
  132. package/dist/views/import/helper/submit-rows.spec.d.ts +0 -1
  133. package/dist/views/ingredients/components/inventory-binding/RecipeBindingBreakdown.vue.d.ts +0 -25
  134. package/dist/views/ingredients/components/inventory-binding/composables/recipe-breakdown.d.ts +0 -34
  135. package/dist/views/ingredients/components/inventory-binding/composables/recipe-breakdown.spec.d.ts +0 -1
  136. package/dist/views/receive-request/components/email-dialog/EmailDialog.spec.d.ts +0 -1
  137. package/dist/views/stock/components/StockRecalculateDialog.vue.d.ts +0 -9
  138. package/dist/views/stock/components/dialog/SnapshotRecalculationDialog.vue.d.ts +0 -24
@@ -1,1470 +0,0 @@
1
- import { ref as S, onUnmounted as ct, computed as C, defineComponent as ce, watch as q, onMounted as Fe, resolveComponent as H, createElementBlock as c, openBlock as i, createBlock as pe, createCommentVNode as E, unref as $, createVNode as D, createElementVNode as g, toDisplayString as _, Fragment as z, renderList as ne, withKeys as Me, normalizeClass as se, withModifiers as dt, withCtx as te, createTextVNode as re, h as ft, onBeforeUnmount as mt, nextTick as pt, Teleport as vt, normalizeStyle as gt, withDirectives as yt, vModelText as ht } from "vue";
2
- import { _ as _t } from "./empty-placeholder-B0QU467o.js";
3
- import { u as je, a as Ke, R as ue, d as xt, S as bt, b as wt } from "./app-BUQUpe4c.js";
4
- import { useCoreStore as ge, useI18n as he } from "@feedmepos/mf-common";
5
- import { useRouter as Ee, useRoute as kt } from "vue-router";
6
- import { u as St, a as $t, I as Lt } from "./feature-FjXz4WXw.js";
7
- import { u as Rt } from "./netsuite-BD8LVxaA.js";
8
- import { u as He } from "./useNavigationMenu-BhYf87KI.js";
9
- import { useBreakpoints as Ct } from "@feedmepos/ui-library";
10
- import { F as Pe } from "./FmAdminBadge-DlplQOHb.js";
11
- import { i as Dt, _ as It } from "./FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-Mxhn0b6c.js";
12
- import { F as Ft } from "./decimal-CqWBdj8E.js";
13
- import { t as Et, a as Pt } from "./date2-6jkfRNS_.js";
14
- import { _ as Nt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
15
- import { u as Tt } from "./useTabStorage-BkIVScW_.js";
16
- import { u as Vt } from "./googlemap-D9vA7GsS.js";
17
- function Bt() {
18
- return {
19
- loadingHookInstalled: !1,
20
- isLoading: !1
21
- };
22
- }
23
- const me = S(Bt());
24
- function Ut() {
25
- const o = Ee();
26
- if (!me.value.loadingHookInstalled) {
27
- me.value.loadingHookInstalled = !0;
28
- const e = o.beforeEach(() => {
29
- me.value.isLoading = !0;
30
- }), t = o.afterEach(() => {
31
- me.value.isLoading = !1;
32
- });
33
- ct(() => {
34
- me.value.loadingHookInstalled = !1, e(), t();
35
- });
36
- }
37
- return {
38
- get isLoading() {
39
- return me.value.isLoading;
40
- }
41
- };
42
- }
43
- function At() {
44
- const { firstAccessibleRouteName: o } = He();
45
- return { hasAnyAccessibleInventoryRoute: C(() => o.value !== null) };
46
- }
47
- const Mt = {
48
- key: 0,
49
- class: "flex flex-col items-center w-full h-full gap-24"
50
- }, Ot = {
51
- key: 1,
52
- class: "flex flex-col pt-[200px] gap-32 items-center"
53
- }, zt = { class: "flex flex-col gap-12 items-center text-center px-24 max-w-[600px]" }, Gt = { class: "fm-typo-en-title-lg-600" }, jt = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, Kt = {
54
- key: 2,
55
- class: "flex flex-col pt-[200px] gap-32 items-center"
56
- }, Ht = { class: "flex flex-col gap-12 items-center text-center px-24 max-w-[1000px]" }, Jt = { class: "fm-typo-en-title-lg-600" }, Yt = { class: "text-fm-color-typo-secondary fm-typo-en-body-md-400" }, Xt = { class: "flex gap-16" }, Wt = { href: "https://feedme.ai/product/inventory/features?tab=plans_%26_prices" }, qt = { href: "https://feedme.ai/form" }, Zt = /* @__PURE__ */ ce({
57
- __name: "InventoryView",
58
- setup(o) {
59
- const e = je(), t = Ke(), l = Rt(), s = ge(), a = Ee(), u = Ut(), r = St(), { t: v } = he(), { hasAnyAccessibleInventoryRoute: m } = At();
60
- q(
61
- [() => s.sessionUser.value, () => s.currentBusiness.value],
62
- ([O, I]) => {
63
- h(O, I);
64
- }
65
- ), Fe(async () => {
66
- await r.init(), await s.readBusinesses();
67
- const O = s.sessionUser.value, I = s.currentBusiness.value;
68
- h(O, I);
69
- });
70
- function h(O, I) {
71
- !O || !I || w();
72
- }
73
- async function w() {
74
- return await e.init(), await l.readSetting().catch((O) => {
75
- console.error("[all] error on reading netsuite store", O);
76
- }), await t.init();
77
- }
78
- const N = C(() => a.currentRoute.value.name === ue.TRANSFER_TEMPLATE ? r.enablePoTemplate : a.currentRoute.value.name === ue.INGREDIENT_GROUP ? r.enableIngredientGroup : !0), U = C(
79
- () => a.currentRoute.value.matched.some((O) => {
80
- var R;
81
- const I = O.meta, Y = I == null ? void 0 : I.validationManifest;
82
- return (((R = Y == null ? void 0 : Y.requiredCaslPermissions) == null ? void 0 : R.length) ?? 0) > 0;
83
- })
84
- ), oe = C(() => {
85
- if (!s.sessionUser.value) return !1;
86
- if (e._locations !== null && e.locations.length === 0) return !0;
87
- if (!r.isLoaded) return !1;
88
- const Y = a.currentRoute.value.name === ue.LOADING;
89
- return !m.value && (Y || U.value);
90
- });
91
- return (O, I) => {
92
- const Y = H("FmSpacer"), R = H("FmCircularProgress"), T = H("FmButton"), G = H("RouterView");
93
- return i(), c("div", null, [
94
- $(u).isLoading ? (i(), c("div", Mt, [
95
- D(Y),
96
- g("div", null, [
97
- D(R, { size: "xl" })
98
- ]),
99
- I[0] || (I[0] = g("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading page...", -1)),
100
- D(Y)
101
- ])) : oe.value ? (i(), c("div", Ot, [
102
- I[1] || (I[1] = g("img", {
103
- src: _t,
104
- alt: "No permission",
105
- class: "w-[200px] h-[200px]"
106
- }, null, -1)),
107
- g("div", zt, [
108
- g("div", Gt, _($(v)("inventory.common.noPermission.title")), 1),
109
- g("div", jt, _($(v)("inventory.common.noPermission.description")), 1)
110
- ])
111
- ])) : N.value ? $(s).sessionUser.value ? (i(), pe(G, { key: 3 })) : E("", !0) : (i(), c("div", Kt, [
112
- g("div", Ht, [
113
- g("div", Jt, _($(v)("inventory.common.proPlan.title")), 1),
114
- g("div", Yt, _($(v)("inventory.common.proPlan.subtitle")), 1)
115
- ]),
116
- g("div", Xt, [
117
- g("a", Wt, [
118
- D(T, {
119
- label: $(v)("inventory.common.proPlan.comparePlans"),
120
- variant: "secondary"
121
- }, null, 8, ["label"])
122
- ]),
123
- g("a", qt, [
124
- D(T, {
125
- label: $(v)("inventory.common.proPlan.callUs"),
126
- "prepend-icon": "call"
127
- }, null, 8, ["label"])
128
- ])
129
- ])
130
- ]))
131
- ]);
132
- };
133
- }
134
- }), Re = {
135
- // Template/PO item rows carry no id of their own — the embedded sku's _id is
136
- // the element identity, and kit names the element from that object's name
137
- // field, so an item change reads "Items › <sku name> › …" instead of a bare
138
- // index. Arrays where the key isn't usable (an element without sku._id, or
139
- // duplicates) fall back to identity_fields, then positional — unchanged.
140
- array_keys: { items: "sku._id" },
141
- identity_fields: ["_id", "id"],
142
- name_fields: ["name", "code"],
143
- ignored_fields: [
144
- "_id",
145
- "_rev",
146
- "_deleted",
147
- "__v",
148
- "updatedAt",
149
- "createdAt",
150
- "updatedBy",
151
- "createdBy"
152
- ],
153
- label_keys: {
154
- prefix: "inventory.changelog.label.",
155
- fields: [
156
- "abbrev",
157
- "alternatives",
158
- "amount",
159
- "code",
160
- "contains",
161
- "conversion",
162
- "convert",
163
- "costPerUnit",
164
- "customAttributes",
165
- "default",
166
- "defaultCost",
167
- "defaultRemark",
168
- "disabledMeasurements",
169
- "groups",
170
- "inventoryBindings",
171
- "isInactive",
172
- "items",
173
- "locations",
174
- "low",
175
- "measurement",
176
- "measurements",
177
- "mid",
178
- "name",
179
- "operationalGroup",
180
- "position",
181
- "precision",
182
- "priority",
183
- "recipe",
184
- "ref",
185
- "rules",
186
- "sku",
187
- "skuId",
188
- "thresholds",
189
- "trackingMeasurement",
190
- "type",
191
- "unit",
192
- "valuation",
193
- "version"
194
- ]
195
- }
196
- }, Ce = {
197
- ...Re,
198
- array_keys: {
199
- measurements: "id",
200
- "unit.measurements": "id",
201
- "convert.inventoryBindings": "id",
202
- "convert.inventoryBindings.alternatives": "_id",
203
- contains: "id",
204
- "contains.alternatives": "_id"
205
- }
206
- };
207
- function Qt(o) {
208
- return o instanceof bt && o.errorResponse.statusCode === 409;
209
- }
210
- const _e = xt((o, e) => ({
211
- /**
212
- * Commits for one record. recordId is the changelog docId, `${dbName}/${id}`.
213
- * The dbName scopes the (access-checked) backend route; only the bare id is
214
- * sent — the backend rebuilds the docId server-side.
215
- */
216
- async getRecordChangelog(t, l, s, a) {
217
- const u = t.indexOf("/");
218
- if (u < 0) return [];
219
- const r = t.slice(0, u), v = t.slice(u + 1), m = new URLSearchParams({ id: v });
220
- l != null && m.set("limit", String(l)), a && m.set("before", a), s && (m.set("explain", "1"), m.set("schema", JSON.stringify(s)));
221
- const h = `${o.inventoryBackendUrl}/${r}/changelog?${m.toString()}`;
222
- return await e.get(h);
223
- },
224
- /**
225
- * Purchase orders in a date range, each with when it last changed. The
226
- * backend joins the orders to their newest commit, so no ids travel and the
227
- * browser makes one request instead of list-then-ask-for-timestamps.
228
- */
229
- async listPurchaseOrders(t, l, s) {
230
- if (!t) return [];
231
- const a = new URLSearchParams({ start: l, end: s }), u = `${o.inventoryBackendUrl}/${t}/changelog/purchase-order?${a}`;
232
- return await e.get(u);
233
- },
234
- /**
235
- * Closing drafts created in a date range, each with when it last changed.
236
- * Closing groups come back as rows of their own — their submit/approve/
237
- * reject is recorded against the group document, not its parent.
238
- */
239
- async listClosingDrafts(t, l, s) {
240
- if (!t) return [];
241
- const a = new URLSearchParams({ start: l, end: s }), u = `${o.inventoryBackendUrl}/${t}/changelog/closing-draft?${a}`;
242
- return await e.get(u);
243
- },
244
- /**
245
- * A kit-dialect record's whole document, at HEAD or as of (and including)
246
- * commit `at`. Same dbName/id split as getRecordChangelog. Rejects with a
247
- * 409 (see isStateConflict) when the record's history predates the kit
248
- * write path — the backend passthrough for kit httpapi's GET /api/state.
249
- */
250
- async getState(t, l, s) {
251
- const a = new URLSearchParams({ id: l });
252
- s && a.set("at", s);
253
- const u = `${o.inventoryBackendUrl}/${t}/changelog/state?${a.toString()}`;
254
- return await e.get(u);
255
- },
256
- /**
257
- * The domains the browser lists generically, declared in
258
- * changelog-domains-pkg and served by the backend — a new browsable domain
259
- * becomes a tab without a portal change. Backends predating the route
260
- * yield an error the caller treats as "no extra domains".
261
- */
262
- async listDomains(t) {
263
- if (!t) return [];
264
- const l = `${o.inventoryBackendUrl}/business_${t}/changelog/domains`;
265
- return await e.get(l);
266
- },
267
- /**
268
- * One generic domain's records, each with when it last changed. Business-
269
- * scoped: the generic domains are configuration documents of the business
270
- * db, not of a location.
271
- */
272
- async listDomainRecords(t, l) {
273
- if (!t) return [];
274
- const s = `${o.inventoryBackendUrl}/business_${t}/changelog/domain/${encodeURIComponent(l)}`;
275
- return await e.get(s);
276
- },
277
- /**
278
- * One inventory module's records, each with when it last changed. Business-
279
- * scoped, so the db is `business_<id>` — the same prefixed name the record's
280
- * own changelog docId carries.
281
- */
282
- async listInventory(t, l) {
283
- if (!t) return [];
284
- const s = `${o.inventoryBackendUrl}/business_${t}/changelog/inventory?module=${l}`;
285
- return await e.get(s);
286
- }
287
- })), Se = 50;
288
- function en() {
289
- const o = _e(), e = S([]), t = S(!1), l = S(!1);
290
- let s = null, a = 0;
291
- async function u(v, m, h) {
292
- const w = ++a;
293
- if (s = null, l.value = !1, !v) {
294
- e.value = [];
295
- return;
296
- }
297
- t.value = !0;
298
- try {
299
- const N = m ?? Se, U = await o.getRecordChangelog(v, N, h);
300
- if (w !== a) return;
301
- e.value = U, m == null && (s = { recordId: v, explain: h }, l.value = U.length === N);
302
- } catch (N) {
303
- throw w === a && (e.value = []), N;
304
- } finally {
305
- w === a && (t.value = !1);
306
- }
307
- }
308
- async function r() {
309
- const v = e.value[e.value.length - 1];
310
- if (!s || !v || t.value || !l.value) return;
311
- const m = a;
312
- t.value = !0;
313
- try {
314
- const h = await o.getRecordChangelog(s.recordId, Se, s.explain, v.id);
315
- if (m !== a) return;
316
- e.value = [...e.value, ...h], l.value = h.length === Se;
317
- } finally {
318
- m === a && (t.value = !1);
319
- }
320
- }
321
- return { commits: e, isLoading: t, hasMore: l, load: u, loadMore: r };
322
- }
323
- const Je = 1e3;
324
- function tn(o, e) {
325
- return [...o, ...e].sort((t, l) => l.at.localeCompare(t.at));
326
- }
327
- function nn() {
328
- const o = _e(), e = S([]);
329
- async function t(l) {
330
- if (e.value = [], !!l)
331
- try {
332
- e.value = await o.getRecordChangelog(
333
- l,
334
- Je,
335
- Ce
336
- );
337
- } catch (s) {
338
- console.error("changelog per-entity load failed", s);
339
- }
340
- }
341
- return { commits: e, load: t };
342
- }
343
- function Ye(o) {
344
- if (!o) return null;
345
- try {
346
- const e = JSON.parse(o);
347
- return typeof (e == null ? void 0 : e.changelogLabelKey) == "string" && typeof (e == null ? void 0 : e.verb) == "string" ? {
348
- labelKey: e.changelogLabelKey,
349
- verb: e.verb,
350
- ...typeof e.name == "string" ? { name: e.name } : {}
351
- } : null;
352
- } catch {
353
- return null;
354
- }
355
- }
356
- function Xe(o) {
357
- return o.startsWith("inventory.changelog.");
358
- }
359
- const We = "";
360
- function De(o) {
361
- const e = o.indexOf(We);
362
- return e === -1 ? { raw: o, human: o } : { raw: o.slice(0, e), human: o.slice(e + 1) };
363
- }
364
- const on = [
365
- "inventory.changelog.label.recipe",
366
- "inventory.changelog.label.sku",
367
- "inventory.changelog.label.unit"
368
- ], an = [...on, "Recipe", "Ingredient", "Unit"];
369
- function sn(o) {
370
- const { human: e } = De(o);
371
- if (!e) return { type: "Document", name: "", field: [] };
372
- const t = e.split(" › ");
373
- return t.length >= 2 && an.includes(t[0]) ? { type: t[0], name: t[1], field: t.slice(2) } : { type: "Document", name: "", field: t };
374
- }
375
- const Oe = 800;
376
- function qe(o, e, t = 2) {
377
- const l = ze(o), s = ze(e);
378
- if (!l || !s) return null;
379
- let a = 0;
380
- for (; a < l.length && a < s.length && l[a] === s[a]; ) a++;
381
- let u = 0;
382
- for (; u < l.length - a && u < s.length - a && l[l.length - 1 - u] === s[s.length - 1 - u]; )
383
- u++;
384
- const r = l.slice(a, l.length - u), v = s.slice(a, s.length - u);
385
- if (r.length > Oe || v.length > Oe) return null;
386
- const m = (h) => ({ type: "same", text: h });
387
- return rn(
388
- [...l.slice(0, a).map(m), ...ln(r, v), ...l.slice(l.length - u).map(m)],
389
- t
390
- );
391
- }
392
- function ze(o) {
393
- try {
394
- const e = JSON.parse(o);
395
- return e === null || typeof e != "object" ? null : JSON.stringify(e, null, 2).split(`
396
- `);
397
- } catch {
398
- return null;
399
- }
400
- }
401
- function ln(o, e) {
402
- const t = o.length, l = e.length, s = Array.from({ length: t + 1 }, () => new Uint32Array(l + 1));
403
- for (let v = t - 1; v >= 0; v--)
404
- for (let m = l - 1; m >= 0; m--)
405
- s[v][m] = o[v] === e[m] ? s[v + 1][m + 1] + 1 : Math.max(s[v + 1][m], s[v][m + 1]);
406
- const a = [];
407
- let u = 0, r = 0;
408
- for (; u < t && r < l; )
409
- o[u] === e[r] ? (a.push({ type: "same", text: o[u] }), u++, r++) : s[u + 1][r] >= s[u][r + 1] ? (a.push({ type: "del", text: o[u] }), u++) : (a.push({ type: "add", text: e[r] }), r++);
410
- for (; u < t; ) a.push({ type: "del", text: o[u++] });
411
- for (; r < l; ) a.push({ type: "add", text: e[r++] });
412
- return a;
413
- }
414
- function rn(o, e) {
415
- const t = o.map(() => !1);
416
- o.forEach((a, u) => {
417
- if (a.type !== "same")
418
- for (let r = Math.max(0, u - e); r <= Math.min(o.length - 1, u + e); r++)
419
- t[r] = !0;
420
- });
421
- const l = [];
422
- let s = !1;
423
- return o.forEach((a, u) => {
424
- t[u] ? (l.push(a), s = !1) : s || (l.push({ type: "skip", text: "⋯" }), s = !0);
425
- }), l;
426
- }
427
- function un(o, e) {
428
- let t;
429
- try {
430
- t = JSON.parse(o);
431
- } catch {
432
- return o;
433
- }
434
- return t === null ? "—" : typeof t == "number" ? t.toLocaleString() : typeof t == "boolean" ? e(t ? "inventory.changelog.yes" : "inventory.changelog.no") : String(t);
435
- }
436
- function Ie(o, e, t = 0, l) {
437
- var m;
438
- const s = o.label == null ? void 0 : Xe(o.label) ? e(o.label) : o.label, a = s != null || o.value != null || o.display != null, u = !((m = o.kids) != null && m.length), r = [];
439
- a && r.push({
440
- depth: t,
441
- // A bare array index says nothing a reader needs — a leaf list entry
442
- // shows just its value. Branch nodes keep the index as their header.
443
- label: s != null && u && /^\d+$/.test(s) ? void 0 : s,
444
- text: u ? cn(o, e, l) : void 0,
445
- bookkeeping: !!o.bookkeeping
446
- });
447
- const v = a ? t + 1 : t;
448
- for (const h of o.kids ?? [])
449
- r.push(...Ie(h, e, v, l));
450
- return r;
451
- }
452
- function cn(o, e, t) {
453
- if (o.value == null) return o.display || void 0;
454
- const l = un(o.value, e);
455
- return (t == null ? void 0 : t(l)) ?? o.display ?? l;
456
- }
457
- function $e(o, e) {
458
- return JSON.stringify(o, null, 2).split(`
459
- `).map((t) => ({ type: e, text: t }));
460
- }
461
- function dn() {
462
- const o = _e(), e = /* @__PURE__ */ new Map(), t = S(!1), l = S(null);
463
- async function s(a) {
464
- const u = e.get(a.id);
465
- if (u) {
466
- l.value = u;
467
- return;
468
- }
469
- t.value = !0;
470
- try {
471
- const r = a.doc_id.indexOf("/"), v = a.doc_id.slice(0, r), m = a.doc_id.slice(r + 1), [h, w] = await Promise.all([
472
- a.parent ? o.getState(v, m, a.parent) : Promise.resolve({}),
473
- o.getState(v, m, a.id)
474
- ]), U = { diff: a.parent ? qe(JSON.stringify(h), JSON.stringify(w)) ?? [
475
- ...$e(h, "del"),
476
- ...$e(w, "add")
477
- ] : $e(w, "add"), conflict: !1 };
478
- e.set(a.id, U), l.value = U;
479
- } catch (r) {
480
- if (!Qt(r))
481
- throw l.value = null, r;
482
- const v = { diff: null, conflict: !0 };
483
- e.set(a.id, v), l.value = v;
484
- } finally {
485
- t.value = !1;
486
- }
487
- }
488
- return { isLoading: t, result: l, load: s };
489
- }
490
- const fn = {
491
- key: 0,
492
- class: "flex justify-center p-16"
493
- }, mn = {
494
- key: 1,
495
- class: "p-16 text-center text-gray-500"
496
- }, pn = {
497
- key: 2,
498
- class: "flex h-full min-h-0 gap-8"
499
- }, vn = { class: "w-1/3 shrink-0 overflow-y-auto border-r border-gray-200 pr-4" }, gn = ["onClick", "onKeydown"], yn = { class: "fm-typo-en-body-md-600" }, hn = { class: "text-xs text-gray-500" }, _n = {
500
- key: 0,
501
- class: "flex-1 overflow-y-auto pl-4"
502
- }, xn = { class: "mb-12 flex flex-col gap-2 border-b border-gray-200 pb-8" }, bn = { class: "flex flex-wrap items-center gap-8" }, wn = { class: "fm-typo-en-body-lg-600" }, kn = {
503
- key: 0,
504
- class: "rounded-full bg-gray-100 px-8 text-xs text-gray-500"
505
- }, Sn = { class: "text-xs text-gray-500" }, $n = { class: "mb-12" }, Ln = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary pl-8" }, Rn = {
506
- key: 0,
507
- class: "mb-12"
508
- }, Cn = {
509
- key: 1,
510
- class: "text-sm text-gray-400"
511
- }, Dn = {
512
- key: 2,
513
- class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
514
- }, In = {
515
- key: 0,
516
- class: "text-xs text-gray-400"
517
- }, Fn = { class: "fm-typo-en-body-md-600" }, En = { class: "flex flex-col gap-6" }, Pn = {
518
- key: 0,
519
- class: "text-gray-700"
520
- }, Nn = { class: "min-w-[120px] shrink-0 text-gray-500" }, Tn = {
521
- key: 0,
522
- class: "flex w-full flex-col gap-4"
523
- }, Vn = {
524
- key: 0,
525
- class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
526
- }, Bn = { key: 0 }, Un = { key: 1 }, An = {
527
- key: 1,
528
- class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
529
- }, Mn = { key: 0 }, On = { key: 1 }, zn = {
530
- key: 1,
531
- class: "w-full overflow-x-auto rounded border border-gray-200 py-4 font-mono text-xs"
532
- }, Gn = {
533
- key: 2,
534
- class: "flex w-full flex-wrap items-baseline gap-4"
535
- }, jn = {
536
- key: 0,
537
- class: "rounded bg-red-50 px-4 text-red-700"
538
- }, Kn = {
539
- key: 1,
540
- class: "text-gray-400"
541
- }, Hn = {
542
- key: 2,
543
- class: "rounded bg-green-50 px-4 text-green-700"
544
- }, Jn = {
545
- key: 1,
546
- class: "text-sm text-gray-500"
547
- }, Yn = {
548
- key: 2,
549
- class: "mt-16 break-all border-t border-gray-200 pt-8 font-mono text-xs text-gray-400"
550
- }, Xn = { key: 0 }, Wn = "capture baseline", qn = /* @__PURE__ */ ce({
551
- __name: "ChangelogPanel",
552
- props: {
553
- commits: {},
554
- isLoading: { type: Boolean },
555
- resolveName: { type: Function }
556
- },
557
- setup(o) {
558
- const e = o, { t } = he(), l = S(null), s = C(
559
- () => e.commits.find((p) => p.id === l.value)
560
- ), a = /* @__PURE__ */ new Set(["updatedAt", "createdAt", "updatedBy", "createdBy", "_rev"]), u = C(() => {
561
- var b;
562
- return (((b = s.value) == null ? void 0 : b.changes) ?? []).filter((B) => {
563
- const { raw: V } = De(B.path);
564
- return V === "@payload" || B.from == null && B.to == null ? !1 : !V.split(".").some((X) => a.has(X));
565
- });
566
- });
567
- q(
568
- () => e.commits,
569
- (p) => {
570
- var b;
571
- p.find((B) => B.id === l.value) || (l.value = ((b = p[0]) == null ? void 0 : b.id) ?? null);
572
- },
573
- { immediate: !0 }
574
- );
575
- const r = S(!1), { isLoading: v, result: m, load: h } = dn();
576
- q([r, s], ([p, b]) => {
577
- m.value = null, !(!p || !b) && h(b).catch((B) => {
578
- console.error("changelog snapshot load failed", B), r.value = !1;
579
- });
580
- });
581
- function w(p) {
582
- return p ? p.slice(0, 8) : "";
583
- }
584
- function N(p) {
585
- return p ? new Date(p).toLocaleString() : "";
586
- }
587
- function U(p) {
588
- if (p == null) return "";
589
- let b;
590
- try {
591
- b = JSON.parse(p);
592
- } catch {
593
- return p;
594
- }
595
- return b === null ? "—" : typeof b == "string" ? b : typeof b == "number" ? b.toLocaleString() : typeof b == "boolean" ? t(b ? "inventory.changelog.yes" : "inventory.changelog.no") : JSON.stringify(b, null, 2);
596
- }
597
- function oe(p) {
598
- return (p.authors || []).join(", ") || t("inventory.changelog.unknownActor");
599
- }
600
- function O(p) {
601
- if (p.message === Wn) return t("inventory.changelog.captureBaseline");
602
- const b = Ye(p.message);
603
- if (!b) return p.message || t("inventory.changelog.noMessage");
604
- const B = I(b.labelKey);
605
- return b.name ? t(`inventory.changelog.message.${b.verb}`, { module: B, name: b.name }) : t(`inventory.changelog.message.${b.verb}NoName`, { module: B });
606
- }
607
- function I(p) {
608
- return Xe(p) ? t(p) : p;
609
- }
610
- const Y = (p) => /[^a-zA-Z]/.test(p);
611
- function R(p, b) {
612
- return p == null || b == null ? null : qe(p, b);
613
- }
614
- function T(p) {
615
- if (!(!p.to_value && !p.from_value))
616
- return {
617
- toTree: p.to_value ? Ie(p.to_value, t, 0, e.resolveName) : void 0,
618
- fromTree: p.from_value ? Ie(p.from_value, t, 0, e.resolveName) : void 0
619
- };
620
- }
621
- function G(p) {
622
- return p === "add" ? "bg-green-50 text-green-700" : p === "del" ? "bg-red-50 text-red-700" : p === "skip" ? "text-gray-400" : "text-gray-600";
623
- }
624
- function j(p) {
625
- return p.type === "skip" ? p.text : (p.type === "add" ? "+ " : p.type === "del" ? "- " : " ") + p.text;
626
- }
627
- const Q = C(() => {
628
- const p = /* @__PURE__ */ new Map(), b = [], B = (y, f) => {
629
- let F = p.get(y);
630
- return F || (F = f(), p.set(y, F), b.push(F)), F;
631
- }, V = () => B("@doc", () => ({ header: "", lines: [] })), X = (y, f) => {
632
- var P;
633
- if (y == null) return f;
634
- let F;
635
- try {
636
- F = JSON.parse(y);
637
- } catch {
638
- F = y;
639
- }
640
- return (typeof F == "string" ? (P = e.resolveName) == null ? void 0 : P.call(e, F) : void 0) ?? f;
641
- }, K = (y, f, F) => {
642
- var P, J, Z, ee;
643
- const x = T(f);
644
- x ? y.lines.push({ label: F, ...x }) : f.from != null && f.to != null ? y.lines.push({
645
- label: F,
646
- from: f.from,
647
- to: f.to,
648
- diff: R(f.from, f.to),
649
- fromDisplay: X(f.from, (P = f.display) == null ? void 0 : P.from),
650
- toDisplay: X(f.to, (J = f.display) == null ? void 0 : J.to)
651
- }) : f.to != null ? y.lines.push({ label: F, to: f.to, toDisplay: X(f.to, (Z = f.display) == null ? void 0 : Z.to) }) : y.lines.push({ label: F, from: f.from, fromDisplay: X(f.from, (ee = f.display) == null ? void 0 : ee.from) });
652
- }, L = (y) => {
653
- var F;
654
- const f = y.element;
655
- if (f) {
656
- const x = B(`kit:${(f.trail ?? []).join(".")}:${f.id ?? ""}`, () => ({
657
- kind: (f.trail ?? []).map(I).join(" › "),
658
- header: f.name || f.id || "",
659
- lines: []
660
- }));
661
- if ((F = y.field) != null && F.length)
662
- K(x, y, y.field.map(I).join(" › "));
663
- else {
664
- x.badge = y.to != null ? "added" : "removed";
665
- const P = T(y);
666
- P && x.lines.push(P);
667
- }
668
- return;
669
- }
670
- K(V(), y, (y.field ?? []).map(I).join(" › "));
671
- };
672
- for (const y of u.value) {
673
- const { raw: f, human: F } = De(y.path);
674
- if (y.kind === "create" && !f) {
675
- const Z = T(y);
676
- V().lines.push(
677
- Z ? { label: t("inventory.changelog.kind.created"), ...Z } : { text: t("inventory.changelog.kind.created") }
678
- );
679
- continue;
680
- }
681
- if (!y.path.includes(We) && (y.field || y.element)) {
682
- L(y);
683
- continue;
684
- }
685
- const x = f ? f.split(".") : [], P = F ? F.split(" › ") : [], J = x.findIndex((Z, ee) => ee > 0 && Y(Z));
686
- if (J > 0 && P.length === x.length) {
687
- const Z = P[J], ee = B(x.slice(0, J + 1).join("."), () => ({
688
- kind: P.slice(0, J).map(I).join(" › "),
689
- header: Z,
690
- lines: []
691
- })), ie = P.slice(J + 1).map(I).join(" › ");
692
- if (ie) K(ee, y, ie);
693
- else if (y.from != null && y.to != null) K(ee, y, Z);
694
- else {
695
- ee.badge = y.to != null ? "added" : "removed";
696
- const de = T(y);
697
- de && ee.lines.push(de);
698
- }
699
- continue;
700
- }
701
- K(V(), y, P.map(I).join(" › "));
702
- }
703
- return b;
704
- });
705
- return (p, b) => {
706
- var X, K;
707
- const B = H("FmCircularProgress"), V = H("FmSwitch");
708
- return p.isLoading ? (i(), c("div", fn, [
709
- D(B)
710
- ])) : p.commits.length ? (i(), c("div", pn, [
711
- g("ol", vn, [
712
- (i(!0), c(z, null, ne(p.commits, (L) => (i(), c("li", {
713
- key: L.id,
714
- role: "button",
715
- tabindex: "0",
716
- class: se([
717
- "cursor-pointer border-l-2 py-8 pl-12",
718
- L.id === l.value ? "border-fm-color-primary bg-fm-color-primary-50" : "border-gray-200 hover:bg-gray-50"
719
- ]),
720
- onClick: (y) => l.value = L.id,
721
- onKeydown: [
722
- Me((y) => l.value = L.id, ["enter"]),
723
- Me(dt((y) => l.value = L.id, ["prevent"]), ["space"])
724
- ]
725
- }, [
726
- g("div", yn, _(O(L)), 1),
727
- g("div", hn, _(oe(L)) + " · " + _(N(L.at)) + " · " + _(w(L.id)), 1)
728
- ], 42, gn))), 128))
729
- ]),
730
- s.value ? (i(), c("div", _n, [
731
- g("div", xn, [
732
- g("div", bn, [
733
- g("div", wn, _(O(s.value)), 1),
734
- s.value.parent ? E("", !0) : (i(), c("span", kn, _($(t)("inventory.changelog.rootCommit")), 1))
735
- ]),
736
- g("div", Sn, _(oe(s.value)) + " · " + _(N(s.value.at)), 1)
737
- ]),
738
- g("div", $n, [
739
- D(Pe, null, {
740
- default: te(() => [
741
- g("span", Ln, _($(t)("inventory.changelog.dataDiff")), 1),
742
- D(V, {
743
- modelValue: r.value,
744
- "onUpdate:modelValue": b[0] || (b[0] = (L) => r.value = L)
745
- }, null, 8, ["modelValue"])
746
- ]),
747
- _: 1
748
- })
749
- ]),
750
- r.value ? (i(), c("div", Rn, [
751
- $(v) ? (i(), pe(B, { key: 0 })) : (X = $(m)) != null && X.conflict ? (i(), c("div", Cn, _($(t)("inventory.changelog.snapshotUnavailable")), 1)) : (K = $(m)) != null && K.diff ? (i(), c("div", Dn, [
752
- (i(!0), c(z, null, ne($(m).diff, (L, y) => (i(), c("div", {
753
- key: y,
754
- class: se(["whitespace-pre px-4", G(L.type)])
755
- }, _(j(L)), 3))), 128))
756
- ])) : E("", !0)
757
- ])) : E("", !0),
758
- (i(!0), c(z, null, ne(Q.value, (L, y) => (i(), c("div", {
759
- key: y,
760
- class: "mb-12 rounded-lg border border-gray-200 p-12"
761
- }, [
762
- L.kind || L.header || L.badge ? (i(), c("div", {
763
- key: 0,
764
- class: se(["flex flex-wrap items-baseline gap-8", L.lines.length ? "mb-8" : ""])
765
- }, [
766
- L.kind ? (i(), c("span", In, _(L.kind), 1)) : E("", !0),
767
- g("span", Fn, _(L.header), 1),
768
- L.badge ? (i(), c("span", {
769
- key: 1,
770
- class: se(["rounded-full px-8 text-xs", L.badge === "added" ? "bg-green-100 text-green-700" : "bg-red-100 text-red-700"])
771
- }, _(L.badge === "added" ? $(t)("inventory.changelog.added") : $(t)("inventory.changelog.kind.removed")), 3)) : E("", !0)
772
- ], 2)) : E("", !0),
773
- g("ul", En, [
774
- (i(!0), c(z, null, ne(L.lines, (f, F) => (i(), c("li", {
775
- key: F,
776
- class: "flex flex-wrap items-baseline gap-8 text-sm"
777
- }, [
778
- f.text ? (i(), c("span", Pn, _(f.text), 1)) : (i(), c(z, { key: 1 }, [
779
- g("span", Nn, _(f.label), 1),
780
- f.toTree || f.fromTree ? (i(), c("div", Tn, [
781
- f.fromTree ? (i(), c("div", Vn, [
782
- (i(!0), c(z, null, ne(f.fromTree, (x, P) => (i(), c("div", {
783
- key: P,
784
- class: se(["flex items-baseline gap-4 px-4", x.bookkeeping ? "text-gray-400" : "text-red-700"])
785
- }, [
786
- (i(!0), c(z, null, ne(x.depth, (J) => (i(), c("span", {
787
- key: J,
788
- class: "inline-block w-16"
789
- }))), 128)),
790
- x.label ? (i(), c("span", Bn, [
791
- re(_(x.label), 1),
792
- x.text ? (i(), c(z, { key: 0 }, [
793
- re(":")
794
- ], 64)) : E("", !0)
795
- ])) : E("", !0),
796
- x.text ? (i(), c("span", Un, _(x.text), 1)) : E("", !0)
797
- ], 2))), 128))
798
- ])) : E("", !0),
799
- f.toTree ? (i(), c("div", An, [
800
- (i(!0), c(z, null, ne(f.toTree, (x, P) => (i(), c("div", {
801
- key: P,
802
- class: se(["flex items-baseline gap-4 px-4", x.bookkeeping ? "text-gray-400" : "text-green-700"])
803
- }, [
804
- (i(!0), c(z, null, ne(x.depth, (J) => (i(), c("span", {
805
- key: J,
806
- class: "inline-block w-16"
807
- }))), 128)),
808
- x.label ? (i(), c("span", Mn, [
809
- re(_(x.label), 1),
810
- x.text ? (i(), c(z, { key: 0 }, [
811
- re(":")
812
- ], 64)) : E("", !0)
813
- ])) : E("", !0),
814
- x.text ? (i(), c("span", On, _(x.text), 1)) : E("", !0)
815
- ], 2))), 128))
816
- ])) : E("", !0)
817
- ])) : f.diff ? (i(), c("div", zn, [
818
- (i(!0), c(z, null, ne(f.diff, (x, P) => (i(), c("div", {
819
- key: P,
820
- class: se(["whitespace-pre px-4", G(x.type)])
821
- }, _(j(x)), 3))), 128))
822
- ])) : (i(), c("span", Gn, [
823
- f.from != null ? (i(), c("span", jn, _(f.fromDisplay ?? U(f.from)), 1)) : E("", !0),
824
- f.from != null && f.to != null ? (i(), c("span", Kn, "→")) : E("", !0),
825
- f.to != null ? (i(), c("span", Hn, _(f.toDisplay ?? U(f.to)), 1)) : E("", !0)
826
- ]))
827
- ], 64))
828
- ]))), 128))
829
- ])
830
- ]))), 128)),
831
- Q.value.length ? E("", !0) : (i(), c("div", Jn, _($(t)("inventory.changelog.empty")), 1)),
832
- r.value ? (i(), c("div", Yn, [
833
- re(_(s.value.id) + " ", 1),
834
- s.value.parent ? (i(), c("span", Xn, "← " + _(s.value.parent), 1)) : E("", !0)
835
- ])) : E("", !0)
836
- ])) : E("", !0)
837
- ])) : (i(), c("div", mn, _($(t)("inventory.changelog.empty")), 1));
838
- };
839
- }
840
- }), Zn = { class: "flex flex-col gap-8" }, Qn = { class: "flex flex-wrap items-center gap-16" }, eo = { class: "fm-typo-en-heading-lg-600" }, to = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, no = { class: "flex h-full min-h-0 flex-col gap-12 p-16" }, oo = { class: "flex flex-wrap items-center gap-12" }, ao = { class: "flex shrink-0 items-center gap-8" }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, lo = { class: "flex flex-wrap items-center gap-12" }, ro = {
841
- key: 0,
842
- class: "fm-typo-en-body-md-600"
843
- }, io = { class: "fm-typo-en-heading-md-600" }, uo = {
844
- key: 0,
845
- class: "flex justify-center py-8"
846
- }, Le = "inventory.changelog.label.", co = /* @__PURE__ */ ce({
847
- __name: "ChangelogDialog",
848
- props: {
849
- modelValue: { type: Boolean }
850
- },
851
- emits: ["update:modelValue"],
852
- setup(o, { emit: e }) {
853
- const t = o, l = e, s = C({
854
- get: () => t.modelValue,
855
- set: (n) => l("update:modelValue", n)
856
- }), { t: a } = he(), u = ge(), r = Ke(), v = je(), m = _e(), { breakpoints: h } = Ct(), w = C(() => h.value.xs || h.value.sm), N = C(() => w.value ? "98vw" : "72vw"), { commits: U, isLoading: oe, hasMore: O, load: I, loadMore: Y } = en();
857
- function R() {
858
- Y().catch((n) => console.error("changelog load more failed", n));
859
- }
860
- function T(n) {
861
- return n ? new Date(n).toLocaleString() : "—";
862
- }
863
- function G(n) {
864
- return [...n].sort((d, k) => (k.lastUpdate ?? "").localeCompare(d.lastUpdate ?? ""));
865
- }
866
- function j(n, d, k) {
867
- I(n, d, k).catch((A) => console.error("changelog load failed", A));
868
- }
869
- const Q = S([]);
870
- async function p() {
871
- var d;
872
- const n = (d = u.currentBusiness.value) == null ? void 0 : d._id;
873
- if (n)
874
- try {
875
- Q.value = await m.listDomains(n);
876
- } catch (k) {
877
- console.error("changelog domain list load failed", k), Q.value = [];
878
- }
879
- }
880
- const b = C(() => [
881
- { label: a("inventory.changelog.label.purchaseOrder"), value: "purchaseOrder" },
882
- { label: a("inventory.changelog.label.closingDraft"), value: "closingDraft" },
883
- { label: a("inventory.changelog.domainInventory"), value: "inventory" },
884
- ...Q.value.map((n) => ({ label: a(n.labelKey), value: n.domain }))
885
- ]), B = S(b.value[0]), V = C(() => {
886
- var n;
887
- return ((n = B.value) == null ? void 0 : n.value) ?? "purchaseOrder";
888
- }), X = C(
889
- () => Q.value.some((n) => n.domain === V.value)
890
- ), K = S(!1), L = C(
891
- () => ["sku", "recipe", "unit"].map((n) => ({
892
- label: a(Le + n),
893
- value: n
894
- }))
895
- ), y = S(L.value[0]), f = C(() => {
896
- var n;
897
- return ((n = y.value) == null ? void 0 : n.value) ?? "sku";
898
- }), F = S(""), x = S(null), P = S(!1), J = C(() => {
899
- var k;
900
- const n = (k = u.currentBusiness.value) == null ? void 0 : k._id, d = r.inventory._id;
901
- return n && d ? `business_${n}/${d}` : "";
902
- }), Z = C(() => {
903
- const n = /* @__PURE__ */ new Map(), d = r.inventory;
904
- for (const k of [d.sku, d.recipe, d.unit, d.skuGroup])
905
- for (const A of k ?? [])
906
- A._id && A.name && n.set(A._id, A.name);
907
- for (const k of d.unit ?? [])
908
- for (const A of k.measurements ?? []) {
909
- if (!A.id) continue;
910
- const W = A.abbrev || A.name;
911
- if (!W) continue;
912
- const ae = Ft.toDouble(A.conversion);
913
- n.set(A.id, ae ? `${W} (1 ${W} = ${ae} ${k.abbrev})` : W);
914
- }
915
- return n;
916
- }), ee = (n) => Z.value.get(n), ie = S([]), de = S(!1);
917
- async function Ne() {
918
- var d;
919
- const n = (d = u.currentBusiness.value) == null ? void 0 : d._id;
920
- if (n) {
921
- de.value = !0;
922
- try {
923
- ie.value = G(
924
- await m.listInventory(n, f.value)
925
- );
926
- } catch (k) {
927
- console.error("changelog inventory list load failed", k), ie.value = [];
928
- } finally {
929
- de.value = !1;
930
- }
931
- }
932
- }
933
- const Ze = C(
934
- () => P.value ? ie.value : ie.value.filter((n) => !n.deleted)
935
- ), Qe = C(() => [
936
- { accessorKey: "id", header: () => a("inventory.closing.draft.table.id"), size: 320 },
937
- {
938
- id: "name",
939
- header: () => a("inventory.common.name"),
940
- accessorFn: (n) => n.name,
941
- // Deleted records sit in the same list as live ones, so the row says which
942
- // it is; nothing else distinguishes them.
943
- cell: ({ row: n }) => n.original.deleted ? ft(
944
- "span",
945
- { "data-deleted": "" },
946
- `${n.original.name} (${a("inventory.changelog.deleted")})`
947
- ) : n.original.name
948
- },
949
- {
950
- id: "lastUpdate",
951
- header: () => a("inventory.changelog.column.lastUpdate"),
952
- size: 200,
953
- // Raw ISO is the sort key — clicking the header on formatted dates would
954
- // order them lexicographically by locale string. Formatted only to display.
955
- accessorFn: (n) => n.lastUpdate ?? "",
956
- cell: ({ getValue: n }) => T(n() || void 0)
957
- }
958
- ]), { commits: et, load: tt } = nn();
959
- function nt(n) {
960
- x.value = n, K.value = !0, j(J.value, Je, Ce), n.id && tt(`${J.value}/${f.value}/${n.id}`).catch(
961
- (d) => console.error("changelog per-entity load failed", d)
962
- );
963
- }
964
- function ot(n, d) {
965
- const k = Ye(n.message);
966
- return k && k.labelKey === Le + f.value && k.name === d.name ? !0 : (n.changes ?? []).some((A) => {
967
- const W = sn(A.path);
968
- return W.type === Le + f.value && W.name === d.name;
969
- });
970
- }
971
- const at = C(() => {
972
- const n = x.value;
973
- if (!n) return [];
974
- const d = U.value.filter((k) => ot(k, n));
975
- return tn(d, et.value);
976
- }), xe = S([]), be = S(!1), we = S(null);
977
- async function st() {
978
- var d;
979
- const n = (d = u.currentBusiness.value) == null ? void 0 : d._id;
980
- if (n) {
981
- be.value = !0;
982
- try {
983
- xe.value = G(
984
- await m.listDomainRecords(n, V.value)
985
- );
986
- } catch (k) {
987
- console.error("changelog domain records load failed", k), xe.value = [];
988
- } finally {
989
- be.value = !1;
990
- }
991
- }
992
- }
993
- function lt(n) {
994
- var k;
995
- const d = (k = u.currentBusiness.value) == null ? void 0 : k._id;
996
- d && (we.value = n, K.value = !0, j(`business_${d}/${n.id}`, void 0, Re));
997
- }
998
- const ve = S(Dt()), ye = S([]), ke = S(!1), fe = S(null), Te = C(() => {
999
- const n = v._currentLocation;
1000
- return n ? `${n.name} (${n.doc.profile.code ?? "--"})` : "";
1001
- }), Ve = C(() => [
1002
- { accessorKey: "id", header: () => a("inventory.closing.draft.table.id"), size: 320 },
1003
- {
1004
- accessorKey: "name",
1005
- header: () => V.value === "purchaseOrder" ? a("inventory.changelog.column.seq") : a("inventory.common.name"),
1006
- size: 240
1007
- },
1008
- {
1009
- id: "lastUpdate",
1010
- header: () => a("inventory.changelog.column.lastUpdate"),
1011
- size: 200,
1012
- // Raw ISO is the sort key; see the note on the inventory table.
1013
- accessorFn: (n) => n.lastUpdate ?? "",
1014
- cell: ({ getValue: n }) => T(n() || void 0)
1015
- }
1016
- ]);
1017
- async function Be() {
1018
- var A;
1019
- const n = (A = v._currentLocation) == null ? void 0 : A.dbName;
1020
- if (!n) return;
1021
- const d = Et(new Date(ve.value.startDate)).toISOString(), k = Pt(new Date(ve.value.endDate)).toISOString();
1022
- ke.value = !0;
1023
- try {
1024
- ye.value = G(
1025
- V.value === "purchaseOrder" ? await m.listPurchaseOrders(n, d, k) : await m.listClosingDrafts(n, d, k)
1026
- );
1027
- } catch (W) {
1028
- console.error("changelog location list load failed", W), ye.value = [];
1029
- } finally {
1030
- ke.value = !1;
1031
- }
1032
- fe.value && !ye.value.find((W) => {
1033
- var ae;
1034
- return W.id === ((ae = fe.value) == null ? void 0 : ae.id);
1035
- }) && (fe.value = null, j(""));
1036
- }
1037
- function rt(n) {
1038
- fe.value = n, K.value = !0, j(`${v.currentLocationDBName}/${n.id}`, void 0, Re);
1039
- }
1040
- const it = C(() => {
1041
- var n, d, k;
1042
- return V.value === "inventory" ? ((n = x.value) == null ? void 0 : n.name) ?? "" : X.value ? ((d = we.value) == null ? void 0 : d.name) ?? "" : ((k = fe.value) == null ? void 0 : k.name) ?? "";
1043
- });
1044
- function Ue() {
1045
- K.value = !1, V.value === "inventory" ? (x.value = null, P.value = !1, j(""), Ne().catch(
1046
- (n) => console.error("changelog inventory list failed", n)
1047
- )) : X.value ? (we.value = null, j(""), st().catch(
1048
- (n) => console.error("changelog domain records failed", n)
1049
- )) : (fe.value = null, j(""), Be().catch((n) => console.error("changelog location list failed", n)));
1050
- }
1051
- return q(s, (n) => {
1052
- n && (p().catch((d) => console.error("changelog domain list failed", d)), Ue());
1053
- }), q(V, () => {
1054
- s.value && Ue();
1055
- }), q(ve, () => {
1056
- s.value && V.value !== "inventory" && !X.value && Be().catch((n) => console.error("changelog location list failed", n));
1057
- }), q(P, (n) => {
1058
- var d;
1059
- !n && ((d = x.value) != null && d.deleted) && (x.value = null, K.value = !1);
1060
- }), q(f, () => {
1061
- x.value = null, K.value = !1, s.value && V.value === "inventory" && Ne().catch(
1062
- (n) => console.error("changelog inventory list failed", n)
1063
- );
1064
- }), q(J, (n) => {
1065
- x.value = null, s.value && V.value === "inventory" && j(n, void 0, Ce);
1066
- }), (n, d) => {
1067
- const k = H("FmButtonGroup"), A = H("FmSearch"), W = H("FmSwitch"), ae = H("FmTable"), Ae = H("FmDialog"), ut = H("FmButton");
1068
- return i(), c(z, null, [
1069
- D(Ae, {
1070
- modelValue: s.value,
1071
- "onUpdate:modelValue": d[8] || (d[8] = (M) => s.value = M),
1072
- "close-button": "",
1073
- "dismiss-away": "",
1074
- "min-width": "98vw",
1075
- "max-width": "98vw",
1076
- "max-height": "94vh",
1077
- "content-class": "!p-0 h-[86vh]"
1078
- }, {
1079
- "dialog-header": te(() => [
1080
- g("div", Zn, [
1081
- g("div", Qn, [
1082
- g("div", eo, _($(a)("inventory.changelog.title")), 1),
1083
- D(k, {
1084
- modelValue: B.value,
1085
- "onUpdate:modelValue": d[0] || (d[0] = (M) => B.value = M),
1086
- items: b.value
1087
- }, null, 8, ["modelValue", "items"])
1088
- ]),
1089
- g("div", to, _($(a)("inventory.changelog.scopeDescription")), 1)
1090
- ])
1091
- ]),
1092
- default: te(() => [
1093
- g("div", no, [
1094
- V.value === "inventory" ? (i(), c(z, { key: 0 }, [
1095
- g("div", oo, [
1096
- D(k, {
1097
- modelValue: y.value,
1098
- "onUpdate:modelValue": d[1] || (d[1] = (M) => y.value = M),
1099
- items: L.value
1100
- }, null, 8, ["modelValue", "items"]),
1101
- D(A, {
1102
- modelValue: F.value,
1103
- "onUpdate:modelValue": d[2] || (d[2] = (M) => F.value = M),
1104
- class: "flex-1",
1105
- placeholder: $(a)("inventory.changelog.searchInventory")
1106
- }, null, 8, ["modelValue", "placeholder"]),
1107
- g("div", ao, [
1108
- g("span", so, _($(a)("inventory.changelog.includeDeleted")), 1),
1109
- D(W, {
1110
- modelValue: P.value,
1111
- "onUpdate:modelValue": d[3] || (d[3] = (M) => P.value = M)
1112
- }, null, 8, ["modelValue"])
1113
- ])
1114
- ]),
1115
- D(ae, {
1116
- class: "min-h-0 flex-1",
1117
- "row-data": Ze.value,
1118
- "column-defs": Qe.value,
1119
- "search-value": F.value,
1120
- loading: de.value,
1121
- "page-size": 20,
1122
- onRowClick: d[4] || (d[4] = (M) => nt(M.original))
1123
- }, null, 8, ["row-data", "column-defs", "search-value", "loading"])
1124
- ], 64)) : X.value ? (i(), pe(ae, {
1125
- key: 1,
1126
- class: "min-h-0 flex-1",
1127
- "row-data": xe.value,
1128
- "column-defs": Ve.value,
1129
- loading: be.value,
1130
- "page-size": 20,
1131
- onRowClick: d[5] || (d[5] = (M) => lt(M.original))
1132
- }, null, 8, ["row-data", "column-defs", "loading"])) : (i(), c(z, { key: 2 }, [
1133
- g("div", lo, [
1134
- D(It, {
1135
- modelValue: ve.value,
1136
- "onUpdate:modelValue": d[6] || (d[6] = (M) => ve.value = M)
1137
- }, null, 8, ["modelValue"]),
1138
- Te.value ? (i(), c("span", ro, _(Te.value), 1)) : E("", !0)
1139
- ]),
1140
- D(ae, {
1141
- class: "min-h-0 flex-1",
1142
- "row-data": ye.value,
1143
- "column-defs": Ve.value,
1144
- loading: ke.value,
1145
- "page-size": 20,
1146
- onRowClick: d[7] || (d[7] = (M) => rt(M.original))
1147
- }, null, 8, ["row-data", "column-defs", "loading"])
1148
- ], 64))
1149
- ])
1150
- ]),
1151
- _: 1
1152
- }, 8, ["modelValue"]),
1153
- D(Ae, {
1154
- modelValue: K.value,
1155
- "onUpdate:modelValue": d[9] || (d[9] = (M) => K.value = M),
1156
- "close-button": "",
1157
- "dismiss-away": "",
1158
- "min-width": N.value,
1159
- "max-width": N.value,
1160
- "max-height": "86vh"
1161
- }, {
1162
- "dialog-header": te(() => [
1163
- g("div", io, _(it.value), 1)
1164
- ]),
1165
- default: te(() => [
1166
- D(qn, {
1167
- commits: V.value === "inventory" ? at.value : $(U),
1168
- "is-loading": $(oe),
1169
- "resolve-name": ee
1170
- }, null, 8, ["commits", "is-loading"]),
1171
- V.value !== "inventory" && $(O) ? (i(), c("div", uo, [
1172
- D(ut, {
1173
- label: $(a)("inventory.changelog.loadMore"),
1174
- variant: "secondary",
1175
- disabled: $(oe),
1176
- onClick: R
1177
- }, null, 8, ["label", "disabled"])
1178
- ])) : E("", !0)
1179
- ]),
1180
- _: 1
1181
- }, 8, ["modelValue", "min-width", "max-width"])
1182
- ], 64);
1183
- };
1184
- }
1185
- }), fo = /* @__PURE__ */ Nt(co, [["__scopeId", "data-v-ae9bd171"]]), le = 8;
1186
- function mo(o, e) {
1187
- return { x: le, y: Math.max(le, e - o - le) };
1188
- }
1189
- const po = ["title"], Ge = 48, vo = 8, go = /* @__PURE__ */ ce({
1190
- __name: "ChangelogFloatingButton",
1191
- setup(o) {
1192
- const { t: e } = he(), t = ge(), l = C(() => {
1193
- var R;
1194
- return !!((R = t.sessionUser.value) != null && R.role.isAdmin);
1195
- }), s = S(!1), a = S(null);
1196
- function u() {
1197
- var R, T;
1198
- return {
1199
- width: ((R = a.value) == null ? void 0 : R.offsetWidth) ?? Ge,
1200
- height: ((T = a.value) == null ? void 0 : T.offsetHeight) ?? Ge
1201
- };
1202
- }
1203
- const r = S({ x: 0, y: 0 });
1204
- function v(R, T, G) {
1205
- return Math.min(Math.max(R, T), G);
1206
- }
1207
- function m() {
1208
- const { width: R, height: T } = u(), G = Math.max(le, window.innerWidth - R - le - vo), j = Math.max(le, window.innerHeight - T - le), Q = r.value.x + R / 2;
1209
- r.value = {
1210
- x: Q < window.innerWidth / 2 ? le : G,
1211
- y: v(r.value.y, le, j)
1212
- };
1213
- }
1214
- function h() {
1215
- r.value = mo(u().height, window.innerHeight);
1216
- }
1217
- Fe(() => {
1218
- h(), window.addEventListener("resize", m), window.addEventListener("orientationchange", m);
1219
- }), mt(() => {
1220
- window.removeEventListener("resize", m), window.removeEventListener("orientationchange", m);
1221
- }), q(l, async (R) => {
1222
- R && (await pt(), h());
1223
- });
1224
- const w = S(!1);
1225
- let N = null, U = !1;
1226
- function oe(R) {
1227
- N = { x: R.clientX, y: R.clientY, px: r.value.x, py: r.value.y }, w.value = !0, U = !1, R.currentTarget.setPointerCapture(R.pointerId);
1228
- }
1229
- function O(R) {
1230
- if (!N) return;
1231
- const T = R.clientX - N.x, G = R.clientY - N.y;
1232
- Math.abs(T) + Math.abs(G) > 3 && (U = !0);
1233
- const { width: j, height: Q } = u();
1234
- r.value = {
1235
- x: v(N.px + T, 0, window.innerWidth - j),
1236
- y: v(N.py + G, 0, window.innerHeight - Q)
1237
- };
1238
- }
1239
- function I() {
1240
- N = null, w.value = !1, m();
1241
- }
1242
- function Y() {
1243
- N && (I(), U || (s.value = !0));
1244
- }
1245
- return (R, T) => {
1246
- const G = H("FmIcon");
1247
- return i(), pe(vt, { to: "body" }, [
1248
- l.value ? (i(), c(z, { key: 0 }, [
1249
- g("div", {
1250
- ref_key: "wrapperRef",
1251
- ref: a,
1252
- class: se(["fixed z-50 cursor-grab touch-none", w.value ? "" : "transition-[left,top] duration-200 ease-out"]),
1253
- style: gt({ left: `${r.value.x}px`, top: `${r.value.y}px` })
1254
- }, [
1255
- D(Pe, null, {
1256
- default: te(() => [
1257
- g("button", {
1258
- type: "button",
1259
- title: $(e)("inventory.changelog.title"),
1260
- class: se(["fm-typo-en-body-sm-600 flex h-48 items-center gap-8 whitespace-nowrap rounded-full border border-gray-200 bg-white px-16 shadow-lg hover:bg-gray-50", w.value ? "cursor-grabbing" : "cursor-grab"]),
1261
- onPointerdown: oe,
1262
- onPointermove: O,
1263
- onPointerup: Y,
1264
- onPointercancel: I
1265
- }, [
1266
- D(G, {
1267
- name: "history",
1268
- size: "md",
1269
- outline: ""
1270
- }),
1271
- g("span", null, _($(e)("inventory.changelog.fabLabel")), 1)
1272
- ], 42, po)
1273
- ]),
1274
- _: 1
1275
- })
1276
- ], 6),
1277
- D(fo, {
1278
- modelValue: s.value,
1279
- "onUpdate:modelValue": T[0] || (T[0] = (j) => s.value = j)
1280
- }, null, 8, ["modelValue"])
1281
- ], 64)) : E("", !0)
1282
- ]);
1283
- };
1284
- }
1285
- }), yo = { class: "flex items-center gap-2" }, ho = { class: "text-xs text-gray-400 font-normal" }, _o = { class: "flex flex-col gap-3" }, xo = { class: "max-h-[480px] flex flex-col gap-1" }, bo = { class: "font-mono text-xs text-gray-700 break-all min-w-0" }, wo = {
1286
- key: 0,
1287
- class: "inline-flex items-center gap-1 text-xs font-medium text-green-700 bg-green-50 px-2 py-0.5 rounded-full"
1288
- }, ko = {
1289
- key: 1,
1290
- class: "inline-flex items-center gap-1 text-xs font-medium text-red-700 bg-red-50 px-2 py-0.5 rounded-full"
1291
- }, So = {
1292
- key: 2,
1293
- class: "inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 px-2 py-0.5 rounded-full"
1294
- }, $o = {
1295
- key: 0,
1296
- class: "text-center text-sm text-gray-400 py-4"
1297
- }, Lo = /* @__PURE__ */ ce({
1298
- __name: "FmFeatureFlagDialog",
1299
- setup(o) {
1300
- const e = S(!1), t = S(""), l = C(() => {
1301
- const { getFlagValue: u } = $t();
1302
- return Object.values(Lt).map((r) => {
1303
- const v = u(r, (m) => m === "true");
1304
- return {
1305
- name: r,
1306
- enabled: v
1307
- };
1308
- });
1309
- }), s = C(() => {
1310
- const u = t.value.toLowerCase();
1311
- return u ? l.value.filter((r) => r.name.toLowerCase().includes(u)) : l.value;
1312
- }), a = C(() => {
1313
- const u = l.value.filter((m) => m.enabled === !0).length, r = l.value.filter((m) => m.enabled === !1).length, v = l.value.filter((m) => m.enabled === null).length;
1314
- return { enabled: u, disabled: r, unknown: v, total: l.value.length };
1315
- });
1316
- return (u, r) => {
1317
- const v = H("FmButton"), m = H("FmSpacer"), h = H("FmDialog");
1318
- return i(), pe(h, {
1319
- modelValue: e.value,
1320
- "onUpdate:modelValue": r[2] || (r[2] = (w) => e.value = w),
1321
- overlay: !0
1322
- }, {
1323
- "dialog-button": te(() => [
1324
- D(Pe, null, {
1325
- default: te(() => [
1326
- D(v, {
1327
- variant: "secondary",
1328
- label: "Feature flags"
1329
- })
1330
- ]),
1331
- _: 1
1332
- })
1333
- ]),
1334
- "dialog-header": te(() => [
1335
- g("div", yo, [
1336
- r[3] || (r[3] = g("span", null, "Feature Flags", -1)),
1337
- g("span", ho, _(a.value.enabled) + " enabled · " + _(a.value.disabled) + " disabled · " + _(a.value.unknown) + " unknown ", 1)
1338
- ])
1339
- ]),
1340
- "dialog-footer": te(() => [
1341
- D(m, { class: "sm:hidden xs:hidden" }),
1342
- D(v, {
1343
- class: "sm:w-full xs:w-full",
1344
- label: "Close",
1345
- size: "md",
1346
- variant: "primary",
1347
- onClick: r[1] || (r[1] = (w) => e.value = !1)
1348
- })
1349
- ]),
1350
- default: te(() => [
1351
- g("div", _o, [
1352
- yt(g("input", {
1353
- "onUpdate:modelValue": r[0] || (r[0] = (w) => t.value = w),
1354
- type: "text",
1355
- placeholder: "Search flags...",
1356
- class: "w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500"
1357
- }, null, 512), [
1358
- [ht, t.value]
1359
- ]),
1360
- g("div", xo, [
1361
- (i(!0), c(z, null, ne(s.value, (w) => (i(), c("div", {
1362
- key: w.name,
1363
- class: "flex items-start justify-between gap-2 px-3 py-2 rounded-md hover:bg-gray-50 text-sm"
1364
- }, [
1365
- g("span", bo, _(w.name), 1),
1366
- w.enabled === !0 ? (i(), c("span", wo, r[4] || (r[4] = [
1367
- g("span", { class: "w-1.5 h-1.5 rounded-full bg-green-500" }, null, -1),
1368
- re(" Enabled ")
1369
- ]))) : w.enabled === !1 ? (i(), c("span", ko, r[5] || (r[5] = [
1370
- g("span", { class: "w-1.5 h-1.5 rounded-full bg-red-500" }, null, -1),
1371
- re(" Disabled ")
1372
- ]))) : (i(), c("span", So, r[6] || (r[6] = [
1373
- g("span", { class: "w-1.5 h-1.5 rounded-full bg-gray-400" }, null, -1),
1374
- re(" Unknown ")
1375
- ])))
1376
- ]))), 128)),
1377
- s.value.length === 0 ? (i(), c("div", $o, ' No flags matching "' + _(t.value) + '" ', 1)) : E("", !0)
1378
- ])
1379
- ])
1380
- ]),
1381
- _: 1
1382
- }, 8, ["modelValue"]);
1383
- };
1384
- }
1385
- }), Ro = { class: "h-full flex flex-col overflow-auto py-16 gap-2" }, Co = /* @__PURE__ */ ce({
1386
- __name: "NavigationTab",
1387
- setup(o) {
1388
- const e = kt(), t = Ee(), l = ge(), s = Tt(), { menuItems: a } = He();
1389
- q([() => l.currentBusiness.value, () => e.name], ([h, w]) => {
1390
- (h == null ? void 0 : h.menuVersion) === "v3" && (w === ue.INGREDIENTS || w === ue.RECIPE || w === ue.UNIT) && t.push({ name: ue.STOCK });
1391
- });
1392
- const u = C({
1393
- get() {
1394
- if (e.name)
1395
- return String(e.name);
1396
- },
1397
- set(h) {
1398
- h && t.push({ name: h });
1399
- }
1400
- }), r = C(
1401
- () => {
1402
- var h;
1403
- return `NavigationTab.${(h = l.currentBusiness.value) == null ? void 0 : h._id}`;
1404
- }
1405
- ), v = S(!1), m = C({
1406
- get() {
1407
- return v.value;
1408
- },
1409
- set(h) {
1410
- v.value = h, h || s.setItem(r.value, "true");
1411
- }
1412
- });
1413
- return q([() => r.value], () => {
1414
- v.value = !1, setTimeout(() => {
1415
- m.value = !s.getItem(r.value);
1416
- }, 2e3);
1417
- }), (h, w) => {
1418
- const N = H("FmCollapsibleTabs");
1419
- return i(), c("div", Ro, [
1420
- D(Lo),
1421
- D(N, {
1422
- modelValue: u.value,
1423
- "onUpdate:modelValue": w[0] || (w[0] = (U) => u.value = U),
1424
- items: $(a)
1425
- }, null, 8, ["modelValue", "items"])
1426
- ]);
1427
- };
1428
- }
1429
- });
1430
- typeof Promise.withResolvers > "u" && (Promise.withResolvers = () => {
1431
- let o, e;
1432
- return { promise: new Promise((l, s) => {
1433
- o = l, e = s;
1434
- }), resolve: o, reject: e };
1435
- });
1436
- typeof Promise.prototype.delayed > "u" && (Promise.prototype.delayed = async function(o) {
1437
- return await new Promise((e) => setTimeout(e, o)), Promise.resolve(this);
1438
- });
1439
- const Ko = /* @__PURE__ */ ce({
1440
- __name: "App",
1441
- setup(o) {
1442
- const e = ge(), t = Vt(), l = wt(), s = window.location.href.includes("print-preview");
1443
- Fe(() => {
1444
- if (window.location.href.includes("print-preview")) {
1445
- e.setEmbedded(!0), document.body.classList.add("print-mode");
1446
- return;
1447
- }
1448
- e.registerSidebarComponent(Co), t.initGoogleMap(l.appApi.googleMap).catch(() => {
1449
- console.error("Google map cannot be loaded");
1450
- });
1451
- }), q([() => e.currentCountry.value], () => {
1452
- a();
1453
- });
1454
- async function a() {
1455
- var u;
1456
- try {
1457
- await e.readBusinesses(), e.currentBusiness.value = (u = e.businesses.value) == null ? void 0 : u.find((r) => r);
1458
- } catch (r) {
1459
- console.error("error when trying to reset businesses:", r);
1460
- }
1461
- }
1462
- return (u, r) => (i(), c(z, null, [
1463
- D(Zt),
1464
- $(s) ? E("", !0) : (i(), pe(go, { key: 0 }))
1465
- ], 64));
1466
- }
1467
- });
1468
- export {
1469
- Ko as default
1470
- };