@feedmepos/mf-inventory-portal 1.8.0-dev.7 → 1.8.0-dev.8

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