@feedmepos/mf-inventory-portal 0.0.19-dev.2 → 0.0.19-dev.3

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 (53) hide show
  1. package/dist/{ApprovalView-DU7oB2Zk.js → ApprovalView-CS7NtcBA.js} +16 -17
  2. package/dist/{BindingsDialog-BgfV0G46.js → BindingsDialog-BA2w-qkY.js} +5 -6
  3. package/dist/{BindingsPicker-tUI5WYBk.js → BindingsPicker-wf7b30Bk.js} +6 -7
  4. package/dist/{BindingsTable-8G-Nc4pC.js → BindingsTable-mqqSPDbO.js} +14 -17
  5. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DaHXKF1s.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CViUEhuw.js} +16 -17
  6. package/dist/IngredientsView-BVX31o67.js +1750 -0
  7. package/dist/IntegrationView-DFdl_238.js +1172 -0
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BKlWhMnB.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BENFVQkL.js} +1 -1
  9. package/dist/{PurchaseOrderPrintPreview-YFcOtdfJ.js → PurchaseOrderPrintPreview-06PokYt4.js} +13 -13
  10. package/dist/{ReceiveRequestView-bIXyVVX9.js → ReceiveRequestView-ck-05Ly7.js} +165 -172
  11. package/dist/RecipeView-CiOb2lvU.js +572 -0
  12. package/dist/StockView-5LkTxYI2.js +1876 -0
  13. package/dist/{SupplierView-BiSqTXnz.js → SupplierView-BAfC5Wcw.js} +34 -37
  14. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-CvbKNb0C.js → TransferDetails.vue_vue_type_script_setup_true_lang-qZDMkkIZ.js} +34 -36
  15. package/dist/UnitView-wsbXOcbf.js +638 -0
  16. package/dist/{WarehouseView-B8UxxAL6.js → WarehouseView-DHhDNAk8.js} +49 -50
  17. package/dist/app-DNCC20Aq.js +66729 -0
  18. package/dist/app.d.ts +29 -0
  19. package/dist/app.js +4 -3
  20. package/dist/{decimal-BtIn4K57.js → decimal-DaXHxukU.js} +1 -1
  21. package/dist/{stock-estimate-C4PL0Fcz.js → id-to-date-XiomI6dP.js} +12 -13
  22. package/dist/{layout-ITqYtCVu.js → layout-DvgFrTEG.js} +14 -14
  23. package/dist/router/name.d.ts +1 -2
  24. package/dist/{supplier-CA0OR3DU.js → supplier-BepZrUgL.js} +3 -3
  25. package/dist/tsconfig.app.tsbuildinfo +1 -1
  26. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +14 -2
  27. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -2
  28. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +12 -12
  29. package/dist/views/recipe/composables/use-recipe-form.d.ts +14 -2
  30. package/dist/views/recipe/composables/use-recipe-table.d.ts +1 -2
  31. package/dist/views/stock/composables/use-stock-action.d.ts +26 -0
  32. package/dist/views/stock/composables/use-stock-table.d.ts +1 -8
  33. package/dist/views/unit/composables/use-unit-form.d.ts +14 -2
  34. package/dist/views/unit/composables/use-unit-table.d.ts +1 -2
  35. package/dist/{xlsx-DAVatAlv.js → xlsx-DaxqUL1h.js} +660 -660
  36. package/dist/{xlsx.util-BsZI2tNE.js → xlsx.util-Dwiw0sTo.js} +2 -2
  37. package/package.json +1 -1
  38. package/dist/FmMultiselectDialog.vue_vue_type_script_setup_true_lang-CxOk5ule.js +0 -143
  39. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-D-vJDMKb.js +0 -236
  40. package/dist/IngredientsView-CAh7D4tL.js +0 -1760
  41. package/dist/IntegrationView-Bf7yHuS8.js +0 -1166
  42. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-BdVrpR9J.js +0 -277
  43. package/dist/RecipeView-BD0mvxCg.js +0 -575
  44. package/dist/StockView-BCq37bGl.js +0 -1865
  45. package/dist/UnitView-DSdn__9m.js +0 -643
  46. package/dist/app-RVyC2D4O.js +0 -43892
  47. package/dist/date2-C2PfOqbB.js +0 -95
  48. package/dist/dayjs.min-0pzT_dbr.js +0 -282
  49. package/dist/fuzzy-yzIM5KUK.js +0 -41
  50. package/dist/index-l87_vggM.js +0 -21515
  51. package/dist/number-B5d98l0m.js +0 -97
  52. package/dist/rules-CCwuHe8Y.js +0 -85
  53. package/dist/use-inventory-binding-dialog-CTriImiV.js +0 -93
@@ -0,0 +1,1172 @@
1
+ import { defineComponent as q, mergeModels as de, useModel as ue, onMounted as ce, ref as P, computed as K, resolveComponent as B, openBlock as $, createElementBlock as A, createElementVNode as m, toDisplayString as I, createVNode as M, createBlock as U, withCtx as N, Fragment as O, renderList as W, normalizeClass as T, normalizeStyle as fe, createSlots as me, unref as F, createCommentVNode as E, withModifiers as pe, reactive as X, watch as ee, isRef as te, Teleport as ge } from "vue";
2
+ import { E as ve } from "./empty-placeholder-wf6-BWE8.js";
3
+ import { ab as ne, ac as ye, c as z, ad as be, j as he } from "./app-DNCC20Aq.js";
4
+ import { useDialogChild as _e, useDialog as oe, useProxiedModel as ie, useSnackbar as Ce } from "@feedmepos/ui-library";
5
+ import { useI18n as R, useCoreStore as xe } from "@feedmepos/mf-common";
6
+ import { _ as we, a as He } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CViUEhuw.js";
7
+ const $e = "data:image/svg+xml,%3csvg%20width='200'%20height='101'%20viewBox='0%200%20200%20101'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M98.9161%2038.4456V24.1772H108.527V27.1988H102.12V30.2202H107.347V32.7382H102.12V38.4456H98.9161Z'%20fill='%235D5359'/%3e%3cpath%20d='M110.382%2031.2276C110.382%2027.5345%20113.249%2024.1772%20117.127%2024.1772C121.174%2024.1772%20123.872%2027.7024%20123.872%2031.3953C123.872%2035.0884%20121.005%2038.6133%20117.127%2038.6133C113.08%2038.4456%20110.382%2034.9204%20110.382%2031.2276ZM117.127%2035.5919C119.487%2035.5919%20120.499%2033.4096%20120.499%2031.2276C120.499%2029.0452%20119.319%2027.0309%20117.127%2027.0309C114.935%2027.0309%20113.754%2029.213%20113.754%2031.2276C113.754%2033.5776%20114.935%2035.5919%20117.127%2035.5919Z'%20fill='%235D5359'/%3e%3cpath%20d='M126.232%2031.2276C126.232%2027.5345%20129.099%2024.1772%20132.977%2024.1772C137.024%2024.1772%20139.722%2027.7024%20139.722%2031.3953C139.722%2035.0884%20136.855%2038.6133%20132.977%2038.6133C128.93%2038.4456%20126.232%2034.9204%20126.232%2031.2276ZM132.977%2035.5919C135.337%2035.5919%20136.349%2033.4096%20136.349%2031.2276C136.349%2029.0452%20135.169%2027.0309%20132.977%2027.0309C130.785%2027.0309%20129.604%2029.213%20129.604%2031.2276C129.604%2033.5776%20130.785%2035.5919%20132.977%2035.5919Z'%20fill='%235D5359'/%3e%3cpath%20d='M142.926%2038.4455V24.345H148.153C152.874%2024.345%20155.235%2027.5343%20155.235%2031.3952C155.235%2035.5918%20152.368%2038.4455%20148.153%2038.4455H142.926ZM148.153%2027.0308H146.129V35.4238H148.153C150.513%2035.4238%20151.862%2033.5775%20151.862%2031.2272C151.862%2028.8773%20150.513%2027.0308%20148.153%2027.0308Z'%20fill='%235D5359'/%3e%3cpath%20d='M110.045%2057.5607V49.1676L107.009%2055.2107H105.324L102.12%2049.1676V57.5607H98.9161V43.4604H102.457L106.167%2050.8465L109.876%2043.4604H113.417V57.5607H110.045Z'%20fill='%235D5359'/%3e%3cpath%20d='M115.947%2057.5607L121.342%2043.4604H124.04L129.436%2057.5607H125.895L124.715%2054.3716H120.331L119.319%2057.5607H115.947ZM122.691%2046.9856L121.005%2052.1893H124.378L122.691%2046.9856Z'%20fill='%235D5359'/%3e%3cpath%20d='M131.965%2057.5607V43.4604H138.373C141.07%2043.4604%20142.925%2045.8105%20142.925%2048.1605C142.925%2049.8393%20142.082%2051.5179%20140.565%2052.1893L143.768%2057.393H140.059L137.192%2052.8607H135V57.393H131.965V57.5607ZM135.169%2050.175H138.204C139.047%2050.175%20139.553%2049.3356%20139.553%2048.1605C139.553%2046.9856%20138.71%2046.3142%20138.035%2046.3142H135.169V50.175Z'%20fill='%235D5359'/%3e%3cpath%20d='M146.635%2057.5607V43.4604H150.007V49.8393L155.403%2043.4604H158.776L153.548%2049.6713L159.281%2057.5607H155.74L151.693%2051.5179L150.007%2053.3642V57.5607H146.635Z'%20fill='%235D5359'/%3e%3cpath%20d='M171.422%2054.7073V57.5607H161.474V43.4604H171.253V46.3142H164.677V48.9999H170.242V51.6856H164.677V54.7073H171.422Z'%20fill='%235D5359'/%3e%3cpath%20d='M185.417%2046.3142H181.202V57.5607H177.829V46.3142H173.614V43.4604H185.417V46.3142Z'%20fill='%235D5359'/%3e%3cpath%20d='M111.057%2062.5967V76.6973H107.853V70.9898H102.12V76.6973H98.9161V62.5967H102.12V68.1361H107.853V62.5967H111.057Z'%20fill='%235D5359'/%3e%3cpath%20d='M124.04%2069.815V62.5967H127.244V69.815C127.244%2073.6758%20125.389%2076.865%20121.005%2076.865C116.453%2076.865%20114.766%2073.5078%20114.766%2069.815V62.5967H117.97V69.815C117.97%2071.997%20118.813%2074.0115%20121.005%2074.0115C123.366%2074.0115%20124.04%2071.997%20124.04%2069.815Z'%20fill='%235D5359'/%3e%3cpath%20d='M138.036%2076.6973H131.122V62.5967H139.047C141.071%2062.5967%20142.251%2064.4433%20142.251%2066.2898C142.251%2067.6327%20141.576%2068.9755%20140.228%2069.4793C141.914%2069.9827%20142.926%2071.1578%20142.926%2073.1721C142.757%2075.5221%20140.733%2076.6973%20138.036%2076.6973ZM134.326%2065.4504V68.3041H137.53C138.204%2068.3041%20138.879%2067.8004%20138.879%2066.7933C138.879%2065.7861%20138.373%2065.2827%20137.698%2065.2827H134.326V65.4504ZM138.204%2070.8221H134.494V73.8435H138.204C139.047%2073.8435%20139.722%2073.1721%20139.722%2072.3327C139.553%2071.6613%20138.879%2070.8221%20138.204%2070.8221Z'%20fill='%235D5359'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M73.4753%2051.4994C78.7281%2050.5396%2082.8911%2046.4891%2083.9954%2041.3137L84.1232%2040.7134L83.9445%2040.1256C80.5804%2029.066%2071.9945%2020.2704%2061.0373%2016.5726C57.4%2015.3451%2053.5046%2014.6804%2049.458%2014.6804C45.4112%2014.6804%2041.5158%2015.3451%2037.8784%2016.5726C26.9214%2020.2704%2018.3354%2029.066%2014.9712%2040.1256L14.7924%2040.7134L14.9206%2041.3137C16.0247%2046.4891%2020.1875%2050.5396%2025.4405%2051.4994V58.8839H14.4183C14.6758%2059.9557%2014.9818%2061.0088%2015.3337%2062.0411C20.1553%2076.1811%2033.6083%2086.3619%2049.458%2086.3619C65.3074%2086.3619%2078.7606%2076.1811%2083.5822%2062.0411C83.9342%2061.0088%2084.2399%2059.9557%2084.4974%2058.8839H73.4753V51.4994ZM41.0517%2020.5973V38.5742C41.0517%2043.1931%2044.8155%2046.9371%2049.458%2046.9371C54.1005%2046.9371%2057.8641%2043.1931%2057.8641%2038.5742V20.5973C55.1919%2019.856%2052.3732%2019.4592%2049.458%2019.4592C46.5428%2019.4592%2043.7241%2019.856%2041.0517%2020.5973ZM62.6675%2022.3673V38.5742C62.6675%2043.1931%2066.431%2046.9371%2071.0735%2046.9371C74.9051%2046.9371%2078.1425%2044.3848%2079.1528%2040.8942C76.4672%2032.6902%2070.4379%2025.9824%2062.6675%2022.3673ZM60.2658%2046.1322C57.8753%2049.5094%2053.9255%2051.7159%2049.458%2051.7159C44.9902%2051.7159%2041.0408%2049.5094%2038.65%2046.1322C36.6982%2048.8894%2033.7074%2050.8662%2030.2439%2051.4994V58.8839H68.6718V51.4994C65.2083%2050.8662%2062.2175%2048.8894%2060.2658%2046.1322ZM21.1583%2063.6628C26.1349%2074.2514%2036.9382%2081.5834%2049.458%2081.5834C61.9776%2081.5834%2072.781%2074.2514%2077.7574%2063.6628H21.1583ZM36.2482%2038.5742V22.3673C28.4779%2025.9824%2022.4486%2032.6902%2019.7631%2040.8942C20.7733%2044.3848%2024.0106%2046.9371%2027.8422%2046.9371C32.4847%2046.9371%2036.2482%2043.1931%2036.2482%2038.5742Z'%20fill='%23FFC35D'/%3e%3c/svg%3e";
8
+ function J(h, y) {
9
+ return ne.filter(h, y).length > 0;
10
+ }
11
+ function ke(h, y) {
12
+ if (!h)
13
+ return {
14
+ label: y,
15
+ segments: [
16
+ {
17
+ isMatch: !1,
18
+ segment: y
19
+ }
20
+ ],
21
+ matched: !1
22
+ };
23
+ const [o] = ne.filter(h.toLocaleLowerCase(), [y], {
24
+ pre: "|",
25
+ post: "|"
26
+ });
27
+ if (!o)
28
+ return {
29
+ label: y,
30
+ segments: [{ segment: y, isMatch: !1 }],
31
+ matched: !1
32
+ };
33
+ const p = o.string.toString().replace(/\|\|/g, "").split("|").reduce((l, c, H) => (l.push({
34
+ segment: c,
35
+ isMatch: H % 2 !== 0
36
+ //e.g. index 1, 3, 5, ...
37
+ }), l), new Array());
38
+ return {
39
+ label: y,
40
+ segments: p,
41
+ matched: !0
42
+ };
43
+ }
44
+ function Z(h) {
45
+ return Object.prototype.hasOwnProperty.call(h, "children");
46
+ }
47
+ const Fe = { class: "flex flex-col gap-12 h-[350px]" }, Me = { class: "flex items-center" }, Ve = {
48
+ class: "flex-1",
49
+ "data-cy": "items-selected"
50
+ }, Se = {
51
+ class: "flex-1",
52
+ "data-cy": "filter-field"
53
+ }, Ae = ["data-cy"], Be = { class: "flex flex-col" }, Le = { class: "fm-typo-en-body-md-400" }, Ie = {
54
+ key: 1,
55
+ class: "w-full py-16 text-fm-color-typo-disabled fm-typo-en-body-md-400 text-center"
56
+ }, se = /* @__PURE__ */ q({
57
+ __name: "FmNestedMultiselectDialog",
58
+ props: /* @__PURE__ */ de({
59
+ modelValue: {}
60
+ }, {
61
+ modelValue: {},
62
+ modelModifiers: {}
63
+ }),
64
+ emits: ["update:modelValue"],
65
+ setup(h) {
66
+ const y = ue(h, "modelValue"), o = _e();
67
+ ce(() => {
68
+ o.emitData(y.value);
69
+ });
70
+ const p = P("");
71
+ function l(e) {
72
+ return J(
73
+ p.value,
74
+ e.sublabel ? [e.label, e.sublabel] : [e.label]
75
+ );
76
+ }
77
+ function c(e) {
78
+ return l(e) ? !0 : Z(e) ? e.children.some(c) : !1;
79
+ }
80
+ function H(e, i) {
81
+ if (!p.value)
82
+ return !0;
83
+ const [r, ...f] = e;
84
+ if (typeof r != "number")
85
+ return !1;
86
+ const d = i[r];
87
+ return J(
88
+ p.value,
89
+ d.sublabel ? [d.label, d.sublabel] : [d.label]
90
+ ) ? !0 : f.length === 0 ? c(d) : Z(d) ? H(f, d.children) : !1;
91
+ }
92
+ function V(e, i, r = 0, f = !1) {
93
+ if (Z(e) && e.children.length) {
94
+ const { children: d, ...L } = e, D = d.flatMap(
95
+ (x, j) => V(x, [...i, j], r + 1, f || e.disabled)
96
+ );
97
+ return [
98
+ {
99
+ ...L,
100
+ keys: i,
101
+ indent: r,
102
+ collapsible: !0,
103
+ disabled: f || e.disabled
104
+ },
105
+ ...D
106
+ ];
107
+ }
108
+ return [
109
+ {
110
+ ...e,
111
+ keys: i,
112
+ indent: r,
113
+ collapsible: !1,
114
+ disabled: f || e.disabled
115
+ }
116
+ ];
117
+ }
118
+ const S = K(() => y.value.flatMap(
119
+ (e, i) => V(e, [i]).filter((r) => H(r.keys, y.value))
120
+ ));
121
+ function k(e) {
122
+ if (Z(e)) {
123
+ if (c(e)) {
124
+ const i = l(e) ? e.children : e.children.filter(c);
125
+ return i.length === 0 ? !1 : i.every(k);
126
+ }
127
+ return e.children.every(k);
128
+ }
129
+ return e.active ?? !1;
130
+ }
131
+ function w(e, i) {
132
+ const [r, ...f] = e;
133
+ if (typeof r != "number")
134
+ return !1;
135
+ const d = i[r];
136
+ return f.length === 0 ? k(d ?? []) : Z(d) ? w(f, d.children ?? []) : !1;
137
+ }
138
+ function g(e) {
139
+ if (Z(e)) {
140
+ if (c(e)) {
141
+ const i = l(e) ? e.children : e.children.filter(c);
142
+ return i.length === 0 ? !1 : i.some(k) && !i.every(k);
143
+ }
144
+ return !1;
145
+ }
146
+ return !1;
147
+ }
148
+ function C(e, i) {
149
+ const [r, ...f] = e;
150
+ if (typeof r != "number")
151
+ return !1;
152
+ const d = i[r];
153
+ return f.length === 0 ? g(d ?? []) : Z(d) ? C(f, (d == null ? void 0 : d.children) ?? []) : !1;
154
+ }
155
+ function v(e, i) {
156
+ if (e.disabled)
157
+ return e;
158
+ if (Z(e)) {
159
+ if (c(e)) {
160
+ const r = l(e) ? e.children : e.children.filter(c);
161
+ return {
162
+ ...e,
163
+ children: e.children.map((f) => r.find((L) => ye(L.value, f.value)) ? v(f, i) : f)
164
+ };
165
+ }
166
+ return {
167
+ ...e,
168
+ children: e.children.map((r) => v(r, i))
169
+ };
170
+ }
171
+ return {
172
+ ...e,
173
+ active: i
174
+ };
175
+ }
176
+ function _(e, i, r) {
177
+ const [f, ...d] = e;
178
+ return typeof f != "number" ? i : d.length === 0 ? i.map((L, D) => f !== D ? L : v(L, r)) : i.map(
179
+ (L, D) => f === D && Z(L) ? {
180
+ ...L,
181
+ children: _(d, L.children, r)
182
+ } : L
183
+ );
184
+ }
185
+ const b = P(new Array());
186
+ function s(e) {
187
+ const i = e.join();
188
+ return b.value.find((r) => i === r);
189
+ }
190
+ function t(e) {
191
+ const i = e.join();
192
+ s(e) ? b.value = b.value.filter((r) => r !== i) : b.value = [...b.value, i];
193
+ }
194
+ function n(e) {
195
+ const i = e.join();
196
+ return b.value.find((r) => i.startsWith(r) && i !== r);
197
+ }
198
+ const a = K(
199
+ () => S.value.filter((e) => H(e.keys, y.value) && e.active).length
200
+ );
201
+ function u(e, i, r) {
202
+ y.value = _(e, i, r), o.emitData(y.value);
203
+ }
204
+ return (e, i) => {
205
+ const r = B("FmSearch"), f = B("FmCheckbox"), d = B("FmButton"), L = B("FmListItem"), D = B("FmList");
206
+ return $(), A("div", Fe, [
207
+ m("div", Me, [
208
+ m("div", Ve, I(a.value) + " items selected", 1),
209
+ m("div", Se, [
210
+ M(r, {
211
+ modelValue: p.value,
212
+ "onUpdate:modelValue": i[0] || (i[0] = (x) => p.value = x),
213
+ placeholder: "Filter items"
214
+ }, null, 8, ["modelValue"])
215
+ ])
216
+ ]),
217
+ S.value.length ? ($(), U(D, {
218
+ key: 0,
219
+ class: "flex-1 overflow-y-auto"
220
+ }, {
221
+ default: N(() => [
222
+ ($(!0), A(O, null, W(S.value, (x) => ($(), A("div", {
223
+ key: x.keys.join(),
224
+ class: T([
225
+ "transition-all overflow-y-clip",
226
+ n(x.keys) ? "max-h-0 opacity-0" : "max-h-[50px] opacity-100"
227
+ ]),
228
+ "data-cy": `nested-${x.keys.join("-")}-${x.label}`
229
+ }, [
230
+ M(L, {
231
+ clickable: x.selectable !== !1,
232
+ onClick: () => x.selectable === !1 || x.disabled || u(x.keys, y.value, !w(x.keys, y.value)),
233
+ style: fe({
234
+ paddingLeft: `${16 + x.indent * 16}px`,
235
+ paddingTop: "4px",
236
+ paddingBottom: "4px"
237
+ }),
238
+ disabled: x.selectable !== !1 && x.disabled
239
+ }, me({
240
+ default: N(() => [
241
+ m("div", Be, [
242
+ m("div", Le, [
243
+ ($(!0), A(O, null, W(F(ke)(p.value, x.label).segments, (j, ae) => ($(), A("span", {
244
+ key: ae,
245
+ class: T({
246
+ "font-bold": j.isMatch
247
+ })
248
+ }, I(j.segment), 3))), 128))
249
+ ]),
250
+ x.sublabel ? ($(), A("div", {
251
+ key: 0,
252
+ class: T([
253
+ "fm-typo-en-body-sm-400",
254
+ x.disabled ? "" : "text-fm-color-typo-secondary"
255
+ ])
256
+ }, I(x.sublabel), 3)) : E("", !0)
257
+ ])
258
+ ]),
259
+ _: 2
260
+ }, [
261
+ x.selectable !== !1 ? {
262
+ name: "prepend",
263
+ fn: N(() => [
264
+ M(f, {
265
+ disabled: x.disabled,
266
+ "model-value": w(x.keys, y.value),
267
+ value: x.keys,
268
+ indeterminate: C(x.keys, y.value)
269
+ }, null, 8, ["disabled", "model-value", "value", "indeterminate"])
270
+ ]),
271
+ key: "0"
272
+ } : void 0,
273
+ x.collapsible ? {
274
+ name: "append",
275
+ fn: N(() => [
276
+ M(d, {
277
+ "prepend-icon": s(x.keys) ? "expand_less" : "expand_more",
278
+ size: "md",
279
+ variant: "tertiary",
280
+ onClick: pe(() => t(x.keys), ["stop"])
281
+ }, null, 8, ["prepend-icon", "onClick"])
282
+ ]),
283
+ key: "1"
284
+ } : void 0
285
+ ]), 1032, ["clickable", "onClick", "style", "disabled"])
286
+ ], 10, Ae))), 128))
287
+ ]),
288
+ _: 1
289
+ })) : ($(), A("div", Ie, " No results found "))
290
+ ]);
291
+ };
292
+ }
293
+ }), Ke = { class: "flex flex-col rounded border border-fm-color-neutral-gray-100 px-5 py-5 gap-5" }, De = { class: "flex items-center" }, Ne = { class: "text-lg font-bold flex-grow" }, Ze = {
294
+ key: 0,
295
+ class: "table-auto w-full"
296
+ }, Pe = { class: "text-left" }, je = { class: "min-w-64" }, Ue = /* @__PURE__ */ m("th", { class: "w-1" }, " ", -1), ze = /* @__PURE__ */ m("tr", { class: "block h-8" }, null, -1), Oe = { class: "flex flex-col" }, Ee = { class: "fm-typo-en-body-md-400" }, qe = {
297
+ key: 0,
298
+ class: "fm-typo-en-body-sm-400 text-fm-color-neutral-gray-400"
299
+ }, Re = { class: "w-1" }, Te = /* @__PURE__ */ q({
300
+ __name: "ApplyAddon",
301
+ props: {
302
+ groups: {
303
+ type: Array,
304
+ required: !0
305
+ },
306
+ modifiers: {
307
+ type: Array,
308
+ required: !0
309
+ },
310
+ items: {
311
+ type: Array,
312
+ required: !0
313
+ },
314
+ loading: {
315
+ type: Boolean
316
+ }
317
+ },
318
+ emits: ["update:modifiers"],
319
+ setup(h, { emit: y }) {
320
+ const o = h, p = y, l = oe(), c = K(() => {
321
+ const g = o.groups.flatMap((C) => C.items.map((v) => {
322
+ const _ = o.items.find((b) => b._id === v._id);
323
+ return {
324
+ ...v,
325
+ groupName: C.name,
326
+ name: v.name ?? (_ == null ? void 0 : _.name) ?? "-"
327
+ };
328
+ }));
329
+ return o.modifiers.map((C) => {
330
+ const v = g.find((s) => s.selection === C.selection), _ = (v == null ? void 0 : v.name) ?? "-", b = (v == null ? void 0 : v.groupName) ?? "";
331
+ return {
332
+ ...C,
333
+ name: _,
334
+ groupName: b
335
+ };
336
+ });
337
+ }), H = K(() => o.groups.flatMap((g) => g.items.map((C) => ({ ...C, groupId: g._id }))));
338
+ function V({ selection: g }) {
339
+ p(
340
+ "update:modifiers",
341
+ o.modifiers.filter((C) => C.selection !== g)
342
+ );
343
+ }
344
+ function S({ selection: g }, C) {
345
+ const v = o.modifiers.find((_) => _.selection === g);
346
+ v && (v.code = C);
347
+ }
348
+ function k() {
349
+ let g = [];
350
+ o.groups.forEach((v) => {
351
+ let _ = !1;
352
+ v.items.every((b) => b._id.startsWith("item")) && (_ = !0), g.push({
353
+ label: v.name,
354
+ sublabel: "Group",
355
+ value: v._id,
356
+ disabled: _,
357
+ children: v.items.reduce((b, s) => {
358
+ var a;
359
+ const t = o.items.find((u) => u._id === s._id), n = (a = t == null ? void 0 : t.variant) == null ? void 0 : a.variantCombinations.find(
360
+ (u) => u.combinationKey === (s == null ? void 0 : s.combinationKey)
361
+ );
362
+ return [
363
+ ...b,
364
+ {
365
+ label: `${s.name ?? (t == null ? void 0 : t.name)} ${n ? `(${n.name})` : ""}`,
366
+ value: `${s.selection}${n ? `/${n == null ? void 0 : n.combinationKey}` : ""}`,
367
+ disabled: _,
368
+ active: !!o.modifiers.find(({ selection: u }) => u === s.selection)
369
+ }
370
+ ];
371
+ }, [])
372
+ });
373
+ });
374
+ const C = {
375
+ modelValue: g
376
+ };
377
+ l.open({
378
+ title: "Select Addons",
379
+ contentComponent: se,
380
+ contentComponentProps: C,
381
+ primaryActions: {
382
+ text: "Confirm",
383
+ close: !0
384
+ }
385
+ }).onPrimary((v) => {
386
+ const _ = z(o.modifiers);
387
+ let b = [];
388
+ function s(t, n) {
389
+ if (n(t), Z(t))
390
+ for (let a of t.children)
391
+ s(a, n);
392
+ }
393
+ v.forEach((t) => {
394
+ s(t, (n) => {
395
+ var i;
396
+ if (o.groups.find(({ _id: r }) => r === n.value)) return;
397
+ const u = H.value.find(({ selection: r }) => r === n.value), e = b.find(({ selection: r }) => n.value === r);
398
+ !Z(n) && n.active && e === void 0 && b.push({
399
+ addonGroupId: (u == null ? void 0 : u.groupId) ?? "",
400
+ selection: n.value,
401
+ code: ((i = _.find(({ selection: r }) => n.value === r)) == null ? void 0 : i.code) ?? ""
402
+ });
403
+ });
404
+ }), p("update:modifiers", b);
405
+ });
406
+ }
407
+ const { t: w } = R();
408
+ return (g, C) => {
409
+ const v = B("FmButton"), _ = B("FmTextField");
410
+ return $(), A("div", Ke, [
411
+ m("div", De, [
412
+ m("div", Ne, I(F(w)("inventory.integration.apply.addons")), 1),
413
+ M(v, {
414
+ type: "button",
415
+ variant: "plain",
416
+ size: "md",
417
+ icon: "link",
418
+ label: F(w)("inventory.integration.apply.applyAddon"),
419
+ onClick: C[0] || (C[0] = (b) => k())
420
+ }, null, 8, ["label"])
421
+ ]),
422
+ m("div", null, [
423
+ c.value.length > 0 ? ($(), A("table", Ze, [
424
+ m("tr", Pe, [
425
+ m("th", je, I(F(w)("inventory.integration.apply.name")), 1),
426
+ m("th", null, I(F(w)("inventory.integration.apply.code")), 1),
427
+ Ue
428
+ ]),
429
+ ($(!0), A(O, null, W(c.value, (b, s) => ($(), A(O, { key: s }, [
430
+ ze,
431
+ m("tr", null, [
432
+ m("td", null, [
433
+ m("div", Oe, [
434
+ m("div", Ee, I(b.name), 1),
435
+ b.groupName ? ($(), A("div", qe, I(b.groupName), 1)) : E("", !0)
436
+ ])
437
+ ]),
438
+ m("td", null, [
439
+ M(_, {
440
+ disabled: h.loading,
441
+ "model-value": b.code,
442
+ "onUpdate:modelValue": [(t) => b.code = t, (t) => S(b, t)],
443
+ rules: [
444
+ function(n) {
445
+ return !!n || "Required";
446
+ }
447
+ ]
448
+ }, null, 8, ["disabled", "model-value", "onUpdate:modelValue", "rules"])
449
+ ]),
450
+ m("td", Re, [
451
+ M(v, {
452
+ disabled: h.loading,
453
+ type: "button",
454
+ variant: "tertiary",
455
+ icon: "delete",
456
+ "icon-color": "#000000",
457
+ size: "md",
458
+ onClick: (t) => V(b)
459
+ }, null, 8, ["disabled", "onClick"])
460
+ ])
461
+ ])
462
+ ], 64))), 128))
463
+ ])) : E("", !0)
464
+ ])
465
+ ]);
466
+ };
467
+ }
468
+ });
469
+ function Ge(h, y = []) {
470
+ const o = y.map((l) => h.find((c) => c._id === l)).filter((l) => !!l);
471
+ return Ye(o).reduce((l, c) => (l[c.combinationKey] = c.selectionName.join(" / "), l), {});
472
+ }
473
+ function We(h, y, o) {
474
+ const p = o.reduce((c, H) => {
475
+ var w, g, C;
476
+ const V = H.category || "", S = Ge(y, (w = H.variant) == null ? void 0 : w.variantGroupIds), k = {
477
+ ...H,
478
+ codeName: [H.code, H.name].filter((v) => !!v).join(" "),
479
+ variant: {
480
+ variantGroupIds: ((g = H.variant) == null ? void 0 : g.variantGroupIds) || [],
481
+ variantCombinations: (((C = H.variant) == null ? void 0 : C.variantCombinations) || []).map((v) => {
482
+ const _ = v.code, b = v.name || S[v.combinationKey || ""];
483
+ return {
484
+ ...v,
485
+ codeName: [_, b].filter((s) => !!s).join(" ").trim() || "-"
486
+ };
487
+ })
488
+ }
489
+ };
490
+ return c[V] = c[V] ? [...c[V], k] : [k], c;
491
+ }, {}), l = Object.values(p)[0];
492
+ return h.length === 0 && l ? l.map((c) => ({
493
+ id: c._id,
494
+ name: c.name ?? "",
495
+ items: p[c._id || ""] || []
496
+ })) || [] : h.map((c) => ({
497
+ id: c._id,
498
+ name: c.name ?? "",
499
+ items: p[c._id || ""] || []
500
+ }));
501
+ }
502
+ function re(h, y) {
503
+ if (h.length == 1)
504
+ return h[0];
505
+ const o = h[0], p = h.slice(1, h.length), l = re(p, y);
506
+ return o.reduce((H, V) => [...H, ...l.map((S) => y(V, S))], new Array());
507
+ }
508
+ function Ye(h) {
509
+ if (h.length === 0) return [];
510
+ const y = h.map(
511
+ (p) => (p.options ?? []).map(
512
+ (l) => ({
513
+ combinationKey: [`${p._id}/${l._id}`],
514
+ selectionName: [l.name ?? ""]
515
+ })
516
+ )
517
+ );
518
+ return re(y, (p, l) => ({
519
+ combinationKey: [...p.combinationKey, ...l.combinationKey],
520
+ selectionName: [...p.selectionName, ...l.selectionName]
521
+ })).map((p) => {
522
+ const l = [...p.combinationKey];
523
+ return l.sort(), {
524
+ combinationKey: l.join("/"),
525
+ active: !0,
526
+ selectionName: p.selectionName
527
+ };
528
+ });
529
+ }
530
+ const Je = { class: "flex flex-col rounded border border-fm-color-neutral-gray-100 px-5 py-5 gap-5 mb-3" }, Qe = { class: "flex items-center" }, Xe = { class: "text-lg font-bold flex-grow" }, et = {
531
+ key: 0,
532
+ class: "table-auto w-full"
533
+ }, tt = { class: "text-left" }, nt = { class: "min-w-64" }, ot = /* @__PURE__ */ m("th", { class: "w-1" }, " ", -1), it = /* @__PURE__ */ m("tr", { class: "block h-8" }, null, -1), st = { class: "flex flex-col" }, rt = { class: "fm-typo-en-body-md-400" }, lt = {
534
+ key: 0,
535
+ class: "fm-typo-en-body-sm-400 text-fm-color-neutral-gray-400"
536
+ }, at = { class: "w-1" }, Y = /* @__PURE__ */ q({
537
+ __name: "ApplyProduct",
538
+ props: {
539
+ isAddon: {
540
+ type: Boolean,
541
+ default: !1
542
+ },
543
+ bindings: {
544
+ type: Array,
545
+ required: !0
546
+ },
547
+ categories: {
548
+ type: Array,
549
+ required: !0
550
+ },
551
+ variants: {
552
+ type: Object,
553
+ required: !0
554
+ },
555
+ menus: {
556
+ type: Array,
557
+ required: !0
558
+ }
559
+ },
560
+ emits: ["update:bindings"],
561
+ setup(h, { emit: y }) {
562
+ const o = h, p = y, l = oe(), c = K(() => o.isAddon ? "Addons" : "Products"), H = K(() => o.isAddon ? [] : o.categories), V = K(
563
+ () => We(H.value, o.variants, o.menus)
564
+ ), S = K(() => {
565
+ if (o.isAddon)
566
+ return o.bindings.map((n) => {
567
+ const a = o.menus.find((e) => e._id === n.productId), u = (a == null ? void 0 : a.name) ?? "-";
568
+ return {
569
+ ...n,
570
+ name: u,
571
+ itemCode: (a == null ? void 0 : a.code) ?? "-"
572
+ };
573
+ });
574
+ const t = V.value.flatMap((n) => n.items);
575
+ return o.bindings.map((n) => {
576
+ var r;
577
+ const a = t.find((f) => f._id === n.productId), u = (a == null ? void 0 : a.name) ?? "-";
578
+ let e = (a == null ? void 0 : a.code) ?? "-", i;
579
+ if (n.combinationKey) {
580
+ const f = (((r = a == null ? void 0 : a.variant) == null ? void 0 : r.variantCombinations) || []).find(
581
+ (d) => d.combinationKey === n.combinationKey
582
+ );
583
+ i = (f == null ? void 0 : f.name) ?? (f == null ? void 0 : f.codeName) ?? "", e = (f == null ? void 0 : f.code) ?? e;
584
+ }
585
+ return {
586
+ ...n,
587
+ name: u,
588
+ itemCode: e,
589
+ variantName: i
590
+ };
591
+ });
592
+ });
593
+ function k(t) {
594
+ p(
595
+ "update:bindings",
596
+ o.bindings.filter(
597
+ (n) => n.productId !== t.productId || n.combinationKey !== t.combinationKey
598
+ )
599
+ );
600
+ }
601
+ function w({ productId: t, combinationKey: n }, a) {
602
+ const u = o.bindings.find(
603
+ (e) => e.productId === t && e.combinationKey === n
604
+ );
605
+ u && (u.code = a);
606
+ }
607
+ function g() {
608
+ return V.value.map((t) => ({
609
+ label: t.name,
610
+ sublabel: "Category",
611
+ value: t.name,
612
+ disabled: !1,
613
+ children: t.items.map((n) => {
614
+ var u;
615
+ const a = (u = n.variant) == null ? void 0 : u.variantCombinations;
616
+ return a != null && a.length ? {
617
+ label: n.name ?? "",
618
+ value: n._id,
619
+ sublabel: "Product",
620
+ children: [
621
+ {
622
+ label: n.codeName ?? "",
623
+ value: {
624
+ productId: n._id
625
+ },
626
+ active: !!o.bindings.find(
627
+ ({ productId: e, combinationKey: i }) => n._id === e && !i
628
+ )
629
+ },
630
+ ...a.map((e) => ({
631
+ label: e.codeName ?? "",
632
+ value: {
633
+ productId: n._id,
634
+ combinationKey: e.combinationKey
635
+ },
636
+ sublabel: "Variant",
637
+ active: !!o.bindings.find(
638
+ ({ productId: i, combinationKey: r }) => n._id === i && e.combinationKey === r
639
+ )
640
+ }))
641
+ ]
642
+ } : {
643
+ label: n.codeName ?? "",
644
+ value: {
645
+ productId: n._id
646
+ },
647
+ active: !!o.bindings.find(
648
+ ({ productId: e, combinationKey: i }) => n._id === e && !i
649
+ )
650
+ };
651
+ })
652
+ }));
653
+ }
654
+ function C() {
655
+ return o.menus.map((t) => ({
656
+ label: t.name,
657
+ value: { productId: t._id },
658
+ active: !!o.bindings.find(
659
+ ({ productId: n, combinationKey: a }) => t._id === n && !a
660
+ )
661
+ }));
662
+ }
663
+ function v(t) {
664
+ const n = z(o.bindings);
665
+ return t.flatMap((a) => a.children.flatMap((u) => {
666
+ var i;
667
+ if (Z(u))
668
+ return u.children.filter((r) => r.active).map((r) => {
669
+ var L, D;
670
+ const { productId: f, combinationKey: d } = r.value;
671
+ return d ? {
672
+ productId: f,
673
+ combinationKey: d,
674
+ code: ((L = n.find(
675
+ ({ productId: x, combinationKey: j }) => f === x && d === j
676
+ )) == null ? void 0 : L.code) ?? ""
677
+ } : {
678
+ productId: f,
679
+ code: ((D = n.find(({ productId: x, combinationKey: j }) => f === x && !j)) == null ? void 0 : D.code) ?? ""
680
+ };
681
+ });
682
+ if (!u.active)
683
+ return [];
684
+ const { productId: e } = u.value;
685
+ return [
686
+ {
687
+ productId: e,
688
+ code: ((i = n.find(({ productId: r, combinationKey: f }) => e === r && !f)) == null ? void 0 : i.code) ?? ""
689
+ }
690
+ ];
691
+ }));
692
+ }
693
+ function _(t) {
694
+ const n = z(o.bindings);
695
+ return t.filter((a) => a.active).map(
696
+ (a) => {
697
+ var u;
698
+ return {
699
+ productId: a.value.productId,
700
+ code: ((u = n.find(({ productId: e }) => e === a.value.productId)) == null ? void 0 : u.code) ?? ""
701
+ };
702
+ }
703
+ );
704
+ }
705
+ function b() {
706
+ let t;
707
+ o.isAddon ? t = C() : t = g();
708
+ const n = {
709
+ modelValue: t
710
+ };
711
+ l.open({
712
+ title: `Select ${c.value}`,
713
+ contentComponent: se,
714
+ contentComponentProps: n,
715
+ primaryActions: {
716
+ text: "Confirm",
717
+ close: !0
718
+ }
719
+ }).onPrimary((a) => {
720
+ let u;
721
+ o.isAddon ? u = _(a) : u = v(a), p("update:bindings", u);
722
+ });
723
+ }
724
+ const { t: s } = R();
725
+ return (t, n) => {
726
+ const a = B("FmButton"), u = B("FmTextField");
727
+ return $(), A("div", Je, [
728
+ m("div", Qe, [
729
+ m("div", Xe, I(h.isAddon ? F(s)("inventory.integration.apply.addons") : F(s)("inventory.integration.apply.products")), 1),
730
+ M(a, {
731
+ type: "button",
732
+ variant: "plain",
733
+ size: "md",
734
+ icon: "link",
735
+ label: h.isAddon ? F(s)("inventory.integration.apply.applyAddon") : F(s)("inventory.integration.apply.applyProduct"),
736
+ onClick: n[0] || (n[0] = (e) => b())
737
+ }, null, 8, ["label"])
738
+ ]),
739
+ m("div", null, [
740
+ S.value.length > 0 ? ($(), A("table", et, [
741
+ m("tr", tt, [
742
+ m("th", nt, I(F(s)("inventory.integration.apply.name")), 1),
743
+ m("th", null, I(F(s)("inventory.integration.apply.code")), 1),
744
+ ot
745
+ ]),
746
+ ($(!0), A(O, null, W(S.value, (e, i) => ($(), A(O, { key: i }, [
747
+ it,
748
+ m("tr", null, [
749
+ m("td", null, [
750
+ m("div", st, [
751
+ m("div", rt, I(e.itemCode) + " " + I(e.name), 1),
752
+ e.variantName ? ($(), A("div", lt, I(e.variantName), 1)) : E("", !0)
753
+ ])
754
+ ]),
755
+ m("td", null, [
756
+ M(u, {
757
+ "model-value": e.code,
758
+ "onUpdate:modelValue": [(r) => e.code = r, (r) => w(e, r)],
759
+ rules: [
760
+ function(f) {
761
+ return !!f || "Required";
762
+ }
763
+ ]
764
+ }, null, 8, ["model-value", "onUpdate:modelValue", "rules"])
765
+ ]),
766
+ m("td", at, [
767
+ M(a, {
768
+ type: "button",
769
+ variant: "tertiary",
770
+ icon: "delete",
771
+ "icon-color": "#000000",
772
+ size: "md",
773
+ onClick: (r) => k(e)
774
+ }, null, 8, ["onClick"])
775
+ ])
776
+ ])
777
+ ], 64))), 128))
778
+ ])) : E("", !0)
779
+ ])
780
+ ]);
781
+ };
782
+ }
783
+ }), dt = { class: "flex flex-col gap-8 w-full" }, ut = /* @__PURE__ */ q({
784
+ __name: "ApplyProductDialog",
785
+ props: {
786
+ categories: { default: () => [] },
787
+ variants: { default: () => [] },
788
+ menus: { default: () => [] },
789
+ groups: { default: () => [] },
790
+ setting: {},
791
+ show: { type: Boolean },
792
+ loading: { type: Boolean }
793
+ },
794
+ emits: ["update:setting", "update:show", "submit"],
795
+ setup(h, { emit: y }) {
796
+ const o = h, p = y, l = X(z(o.setting));
797
+ ee([() => o.show], ([w]) => {
798
+ if (w)
799
+ for (const g of Object.keys(o.setting))
800
+ l[g] = o.setting[g];
801
+ });
802
+ const c = P(), H = ie(o, "show");
803
+ function V() {
804
+ var w, g;
805
+ (g = (w = c.value) == null ? void 0 : w.validateInputs) == null || g.call(w);
806
+ }
807
+ function S() {
808
+ p("update:setting", z(l)), p("submit");
809
+ }
810
+ const { t: k } = R();
811
+ return (w, g) => {
812
+ const C = B("FmChip"), v = B("FmForm"), _ = B("FmButton"), b = B("FmSideSheet");
813
+ return $(), U(b, {
814
+ modelValue: F(H),
815
+ "onUpdate:modelValue": g[4] || (g[4] = (s) => te(H) ? H.value = s : null),
816
+ header: F(k)("inventory.integration.apply.title"),
817
+ "dismiss-away": "",
818
+ "close-button": "",
819
+ "max-width": 500
820
+ }, {
821
+ default: N(() => [
822
+ m("div", dt, [
823
+ m("div", null, [
824
+ M(C, { label: "Menu v3" })
825
+ ]),
826
+ M(v, {
827
+ ref_key: "formRef",
828
+ ref: c,
829
+ onValidationSuccess: g[2] || (g[2] = (s) => S())
830
+ }, {
831
+ default: N(() => [
832
+ M(Y, {
833
+ bindings: l.bindings,
834
+ categories: w.categories,
835
+ variants: w.variants,
836
+ menus: w.menus,
837
+ "onUpdate:bindings": g[0] || (g[0] = (s) => l.bindings = s)
838
+ }, null, 8, ["bindings", "categories", "variants", "menus"]),
839
+ M(Te, {
840
+ form: c.value,
841
+ modifiers: l.modifiers ?? [],
842
+ groups: w.groups ?? [],
843
+ items: w.menus ?? [],
844
+ "onUpdate:modifiers": g[1] || (g[1] = (s) => l.modifiers = s)
845
+ }, null, 8, ["form", "modifiers", "groups", "items"])
846
+ ]),
847
+ _: 1
848
+ }, 512)
849
+ ])
850
+ ]),
851
+ "side-sheet-footer": N(() => [
852
+ M(_, {
853
+ loading: w.loading,
854
+ type: "submit",
855
+ label: F(k)("common.confirm"),
856
+ onClick: g[3] || (g[3] = (s) => V())
857
+ }, null, 8, ["loading", "label"])
858
+ ]),
859
+ _: 1
860
+ }, 8, ["modelValue", "header"]);
861
+ };
862
+ }
863
+ }), ct = { class: "flex flex-col gap-8 w-full" }, ft = /* @__PURE__ */ q({
864
+ __name: "ApplyProductDialogV4",
865
+ props: {
866
+ categories: { default: () => [] },
867
+ variants: { default: () => [] },
868
+ menus: { default: () => [] },
869
+ groups: { default: () => [] },
870
+ setting: {},
871
+ show: { type: Boolean },
872
+ loading: { type: Boolean }
873
+ },
874
+ emits: ["update:setting", "update:show", "submit"],
875
+ setup(h, { emit: y }) {
876
+ const o = h, p = y, l = X(z(o.setting));
877
+ ee([() => o.show], ([s]) => {
878
+ if (s)
879
+ for (const t of Object.keys(o.setting))
880
+ l[t] = o.setting[t];
881
+ });
882
+ const c = K(() => o.menus.filter((s) => (s == null ? void 0 : s.category) === null)), H = K(() => l.bindings.filter((s) => {
883
+ const t = o.menus.find((n) => n._id === s.productId);
884
+ return t ? (t == null ? void 0 : t.category) === null : !1;
885
+ })), V = K(() => o.menus.filter((s) => (s == null ? void 0 : s.category) !== null)), S = K(() => l.bindings.filter((s) => {
886
+ const t = o.menus.find((n) => n._id === s.productId);
887
+ return t ? (t == null ? void 0 : t.category) !== null : !1;
888
+ }));
889
+ function k(s) {
890
+ l.bindings = [...H.value, ...s];
891
+ }
892
+ function w(s) {
893
+ l.bindings = [...S.value, ...s];
894
+ }
895
+ const g = P(), C = ie(o, "show");
896
+ function v() {
897
+ var s, t;
898
+ (t = (s = g.value) == null ? void 0 : s.validateInputs) == null || t.call(s);
899
+ }
900
+ function _() {
901
+ p("update:setting", z(l)), p("submit");
902
+ }
903
+ const { t: b } = R();
904
+ return (s, t) => {
905
+ const n = B("FmChip"), a = B("FmForm"), u = B("FmButton"), e = B("FmSideSheet");
906
+ return $(), U(e, {
907
+ modelValue: F(C),
908
+ "onUpdate:modelValue": t[4] || (t[4] = (i) => te(C) ? C.value = i : null),
909
+ header: F(b)("inventory.integration.apply.title"),
910
+ "dismiss-away": "",
911
+ "close-button": "",
912
+ "max-width": 500
913
+ }, {
914
+ default: N(() => [
915
+ m("div", ct, [
916
+ m("div", null, [
917
+ M(n, { label: "Menu v4" })
918
+ ]),
919
+ M(a, {
920
+ ref_key: "formRef",
921
+ ref: g,
922
+ onValidationSuccess: t[2] || (t[2] = (i) => _())
923
+ }, {
924
+ default: N(() => [
925
+ M(Y, {
926
+ categories: s.categories,
927
+ variants: s.variants,
928
+ bindings: S.value,
929
+ menus: V.value,
930
+ "onUpdate:bindings": t[0] || (t[0] = (i) => k(i))
931
+ }, null, 8, ["categories", "variants", "bindings", "menus"]),
932
+ M(Y, {
933
+ "is-addon": !0,
934
+ categories: [],
935
+ variants: s.variants,
936
+ bindings: H.value,
937
+ menus: c.value,
938
+ "onUpdate:bindings": t[1] || (t[1] = (i) => w(i))
939
+ }, null, 8, ["variants", "bindings", "menus"])
940
+ ]),
941
+ _: 1
942
+ }, 512)
943
+ ])
944
+ ]),
945
+ "side-sheet-footer": N(() => [
946
+ M(u, {
947
+ loading: s.loading,
948
+ type: "submit",
949
+ label: F(b)("common.confirm"),
950
+ onClick: t[3] || (t[3] = (i) => v())
951
+ }, null, 8, ["loading", "label"])
952
+ ]),
953
+ _: 1
954
+ }, 8, ["modelValue", "header"]);
955
+ };
956
+ }
957
+ }), G = P(0);
958
+ function le() {
959
+ G.value = window.innerWidth;
960
+ }
961
+ const Q = {
962
+ sm: 640,
963
+ md: 768,
964
+ lg: 1024,
965
+ xl: 1280,
966
+ "2xl": 1536
967
+ };
968
+ le();
969
+ window.addEventListener("resize", le);
970
+ function mt() {
971
+ const h = K(() => {
972
+ const o = G.value;
973
+ return Object.entries(Q).reduce(
974
+ (p, [l, c]) => (p[l] = o >= c, p),
975
+ {}
976
+ );
977
+ }), y = K(() => {
978
+ const o = G.value;
979
+ return Object.entries(Q).reduce(
980
+ (p, [l, c]) => (p[l] = o <= c, p),
981
+ {}
982
+ );
983
+ });
984
+ return {
985
+ get min() {
986
+ return F(h);
987
+ },
988
+ get max() {
989
+ return F(y);
990
+ },
991
+ get width() {
992
+ return F(G);
993
+ }
994
+ };
995
+ }
996
+ const pt = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, gt = { key: 0 }, vt = {
997
+ key: 1,
998
+ class: "flex flex-col items-center my-10 gap-5"
999
+ }, yt = ["src"], bt = /* @__PURE__ */ m("div", { class: "font-bold text-lg" }, "Integration", -1), ht = {
1000
+ class: "text-xs text-neutral-400 text-center",
1001
+ style: { "max-width": "25rem" }
1002
+ }, _t = { key: 2 }, Ct = { class: "flex justify-center" }, xt = ["src"], wt = { class: "flex flex-col items-center gap-2" }, Ht = { class: "text-lg font-bold" }, $t = { class: "text-fm-color-neutral-gray-300" }, kt = { key: 0 }, Lt = /* @__PURE__ */ q({
1003
+ __name: "IntegrationView",
1004
+ setup(h) {
1005
+ const y = xe(), o = Ce(), p = he(), l = P(!1), c = P(), H = P(), V = P(), S = P(), k = P(), w = K(() => {
1006
+ var u;
1007
+ return ((u = k.value) == null ? void 0 : u.enable) ?? !1;
1008
+ }), g = be(), C = K(() => {
1009
+ var u;
1010
+ return (u = y.currentBusiness.value) == null ? void 0 : u.menuVersion;
1011
+ });
1012
+ p.watchLocation(v);
1013
+ async function v(u) {
1014
+ var e, i, r, f;
1015
+ if (!u) {
1016
+ const d = {
1017
+ _id: "",
1018
+ enable: !1,
1019
+ bindings: [],
1020
+ uniqueCode: "",
1021
+ branchCode: "",
1022
+ server: {
1023
+ password: "",
1024
+ host: "",
1025
+ username: "",
1026
+ port: "",
1027
+ directory: ""
1028
+ },
1029
+ histories: [],
1030
+ modifiers: [],
1031
+ exportAsJson: !1
1032
+ };
1033
+ k.value = d;
1034
+ return;
1035
+ }
1036
+ l.value = !0;
1037
+ try {
1038
+ const d = await g.readMenu();
1039
+ c.value = ((e = d.modules) == null ? void 0 : e.item) ?? [], H.value = ((i = d.modules) == null ? void 0 : i.group) ?? [], V.value = ((r = d.modules) == null ? void 0 : r.variant) ?? [];
1040
+ const L = (((f = d.modules) == null ? void 0 : f.category) ?? []).map((D) => ({
1041
+ ...D,
1042
+ _id: D._id === void 0 ? null : D._id
1043
+ }));
1044
+ S.value = L, k.value = await g.readSetting();
1045
+ } catch (d) {
1046
+ o.open({
1047
+ title: "Something went wrong",
1048
+ message: "Cannot fetch integration info. Please try again.",
1049
+ type: "error"
1050
+ }), console.error("Error at fetching integration info", d);
1051
+ } finally {
1052
+ l.value = !1;
1053
+ }
1054
+ }
1055
+ const _ = P(!1);
1056
+ async function b() {
1057
+ _.value = !0;
1058
+ }
1059
+ const s = mt(), t = K(() => s.max.sm);
1060
+ async function n() {
1061
+ const u = k.value;
1062
+ if (u) {
1063
+ l.value = !0;
1064
+ try {
1065
+ await g.updateSetting(u), o.open({
1066
+ title: "Success",
1067
+ message: "Your changes has been saved",
1068
+ type: "success"
1069
+ }), _.value = !1, await v(p.currentLocation);
1070
+ return;
1071
+ } catch (e) {
1072
+ o.open({
1073
+ title: "Something went wrong",
1074
+ message: "Cannot update integration info. Please try again.",
1075
+ type: "error"
1076
+ }), console.error("Error at updating integration info", e);
1077
+ } finally {
1078
+ l.value = !1;
1079
+ }
1080
+ }
1081
+ }
1082
+ const { t: a } = R();
1083
+ return (u, e) => {
1084
+ const i = B("FmCircularProgress"), r = B("FmCardSection"), f = B("FmCard");
1085
+ return $(), U(we, {
1086
+ title: F(a)("inventory.integration.title")
1087
+ }, {
1088
+ default: N(() => [
1089
+ m("div", pt, [
1090
+ M(He, { "change-location": "" }),
1091
+ !F(p)._currentLocation || l.value ? ($(), A("div", gt, [
1092
+ M(i, { size: "lg" })
1093
+ ])) : w.value ? ($(), A("div", _t, [
1094
+ M(f, {
1095
+ class: T({
1096
+ "w-full": t.value,
1097
+ "w-1/2": !t.value,
1098
+ border: !0,
1099
+ "border-fm-color-neutral-gray-100": !0,
1100
+ "cursor-pointer": !0,
1101
+ "hover:border-fm-color-primary": !0
1102
+ }),
1103
+ onClick: e[0] || (e[0] = (d) => b())
1104
+ }, {
1105
+ default: N(() => [
1106
+ M(r, null, {
1107
+ default: N(() => [
1108
+ m("div", Ct, [
1109
+ m("img", {
1110
+ src: F($e),
1111
+ alt: "Food Market Hub"
1112
+ }, null, 8, xt)
1113
+ ]),
1114
+ m("div", wt, [
1115
+ m("div", Ht, I(F(a)("inventory.integration.fmh.title")), 1),
1116
+ m("div", $t, I(F(a)("inventory.integration.fmh.description")), 1)
1117
+ ])
1118
+ ]),
1119
+ _: 1
1120
+ })
1121
+ ]),
1122
+ _: 1
1123
+ }, 8, ["class"])
1124
+ ])) : ($(), A("div", vt, [
1125
+ m("div", null, [
1126
+ m("img", {
1127
+ src: F(ve),
1128
+ alt: "List is empty"
1129
+ }, null, 8, yt)
1130
+ ]),
1131
+ bt,
1132
+ m("div", ht, I(F(a)("inventory.integration.description")), 1)
1133
+ ]))
1134
+ ]),
1135
+ k.value ? ($(), A("div", kt, [
1136
+ ($(), U(ge, { to: "body" }, [
1137
+ C.value === "v3" ? ($(), U(ut, {
1138
+ key: 0,
1139
+ menus: c.value,
1140
+ variants: V.value,
1141
+ categories: S.value,
1142
+ setting: k.value,
1143
+ "onUpdate:setting": e[1] || (e[1] = (d) => k.value = d),
1144
+ show: _.value,
1145
+ "onUpdate:show": e[2] || (e[2] = (d) => _.value = d),
1146
+ groups: H.value,
1147
+ loading: l.value,
1148
+ onSubmit: e[3] || (e[3] = (d) => n())
1149
+ }, null, 8, ["menus", "variants", "categories", "setting", "show", "groups", "loading"])) : ($(), U(ft, {
1150
+ key: 1,
1151
+ menus: c.value,
1152
+ variants: V.value,
1153
+ categories: S.value,
1154
+ setting: k.value,
1155
+ "onUpdate:setting": e[4] || (e[4] = (d) => k.value = d),
1156
+ show: _.value,
1157
+ "onUpdate:show": e[5] || (e[5] = (d) => _.value = d),
1158
+ groups: H.value,
1159
+ loading: l.value,
1160
+ onSubmit: e[6] || (e[6] = (d) => n())
1161
+ }, null, 8, ["menus", "variants", "categories", "setting", "show", "groups", "loading"]))
1162
+ ]))
1163
+ ])) : E("", !0)
1164
+ ]),
1165
+ _: 1
1166
+ }, 8, ["title"]);
1167
+ };
1168
+ }
1169
+ });
1170
+ export {
1171
+ Lt as default
1172
+ };