@feedmepos/mf-inventory-portal 1.3.7 → 1.3.8-dev.1

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 (132) hide show
  1. package/dist/{App-D1-fT3jF.js → App-Dl97lAmD.js} +3 -3
  2. package/dist/ApprovalView-RePEhbhl.js +241 -0
  3. package/dist/{BindingsDialog-DeavyPY-.js → BindingsDialog-8QVbtnnq.js} +5 -5
  4. package/dist/{BindingsPicker-BGzhKq8G.js → BindingsPicker-D9yuDGcq.js} +3 -3
  5. package/dist/{BindingsTable-Dr9hWkE1.js → BindingsTable-DAYhI-6V.js} +5 -5
  6. package/dist/{ClosingDraftView-6gwWEWWB.js → ClosingDraftView-D_VtBfFG.js} +57 -57
  7. package/dist/{ClosingHistoryView-D4rNnlsq.js → ClosingHistoryView-ClUnxQS2.js} +4 -4
  8. package/dist/{ClosingTemplateView-DxCLH1GH.js → ClosingTemplateView-0a_isyyx.js} +16 -16
  9. package/dist/{DeliveryOrderPrintPreview-D-XeZX-z.js → DeliveryOrderPrintPreview-DovAi6j-.js} +17 -17
  10. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DeoaPLQm.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DjNZ0m13.js} +14 -14
  11. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BMhSHZ3Z.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-4vZH2hLF.js} +2 -2
  12. package/dist/{FmMultiselectDialog-DJFi54mG.js → FmMultiselectDialog-B5-aK-b2.js} +1 -1
  13. package/dist/{FmMultiselectDialog-BQZmTWDb.js → FmMultiselectDialog-Z49kK96R.js} +2 -2
  14. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DAivpdPp.js → FmUnitInput.vue_vue_type_script_setup_true_lang-zP1nS7bp.js} +4 -4
  15. package/dist/{ImportView-DPQY0ELT.js → ImportView-Dba8fJry.js} +6 -6
  16. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-DeVYXEzb.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DHITBIhp.js} +1 -1
  17. package/dist/{IngredientGroupView-5AuPbMDz.js → IngredientGroupView-CHi5_A4T.js} +7 -7
  18. package/dist/{IngredientsView-qMotWYnL.js → IngredientsView-DWk27PJg.js} +17 -17
  19. package/dist/IntegrationExplorerView-CixgHWVb.js +22254 -0
  20. package/dist/{IntegrationView-CVdwhNTA.js → IntegrationView-fttszvyC.js} +13 -13
  21. package/dist/{InventoryBindingForm-B5KUYKIu.js → InventoryBindingForm-DDcM2paa.js} +1 -1
  22. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-pbyMU879.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DOHrtdbl.js} +5 -5
  23. package/dist/{InventoryBindingSummary-Bm3A2kmC.js → InventoryBindingSummary-BERshnpd.js} +1 -1
  24. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-NnoVkA8W.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D4u0MM_k.js} +1 -1
  25. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Dp4gFbs5.js → PremiumBadge.vue_vue_type_script_setup_true_lang-eFb-84g2.js} +1 -1
  26. package/dist/{PublishView-DOIiAeDK.js → PublishView-COGdnDHP.js} +3 -3
  27. package/dist/{PurchaseOrderPrintPreview-BE-8EJFv.js → PurchaseOrderPrintPreview-COJVgeTm.js} +12 -12
  28. package/dist/ReceiveRequestView-DvC12_QK.js +2817 -0
  29. package/dist/{RecipeView-CM-BrVSe.js → RecipeView-BKlVCFPR.js} +22 -21
  30. package/dist/SettingsView-DbXva8_D.js +695 -0
  31. package/dist/{StockView-DDqlms0m.js → StockView-Hri6SSjn.js} +21 -20
  32. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-CcQ6bBWG.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DiRfjFmz.js} +1 -1
  33. package/dist/{SupplierView-CM2PrtHi.js → SupplierView-DCMW5muk.js} +14 -14
  34. package/dist/{SurchargeView-q2NfASMH.js → SurchargeView-DRh5EAi8.js} +8 -8
  35. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-BbZQZQTQ.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-BHNIS7Pp.js} +2 -2
  36. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Bp3joqMK.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-BVyoZ2a4.js} +1 -1
  37. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CMSKhz6_.js +3790 -0
  38. package/dist/{TransferTemplateView-B26H_T9Q.js → TransferTemplateView-71XY525Q.js} +20 -19
  39. package/dist/{UnitCostHistoryView-BzumRVdx.js → UnitCostHistoryView-CjEaekfJ.js} +4 -4
  40. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CfWpv2Mv.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-B8dRQhZi.js} +4 -4
  41. package/dist/{UnitView-Cxfg--TU.js → UnitView-D06txpBT.js} +9 -9
  42. package/dist/{WarehouseView-CvoafTrd.js → WarehouseView-DQluGq0D.js} +7 -7
  43. package/dist/{WastageTemplateView-Bqd4Wp3d.js → WastageTemplateView-Bqmd_r_Y.js} +16 -16
  44. package/dist/api/integration-sync-log.d.ts +47 -0
  45. package/dist/api/netsuite-explorer.d.ts +51 -0
  46. package/dist/{app-CrrDFeMj.js → app-B5-QVzib.js} +4711 -4557
  47. package/dist/app.d.ts +32 -0
  48. package/dist/app.js +2 -2
  49. package/dist/{closing-template-Ew74NLQj.js → closing-template-C3ClR8Pj.js} +1 -1
  50. package/dist/{component-DpCUABT3.js → component-kqxARxvM.js} +30 -21
  51. package/dist/components/row-action.enum.d.ts +3 -0
  52. package/dist/{date2-Bklbk2g-.js → date2-CQCX7jCE.js} +4 -4
  53. package/dist/{dayjs.min-B463GIlc.js → dayjs.min-Dhp0BWSV.js} +1 -1
  54. package/dist/{decimal-Dm2vbfDq.js → decimal-98G--u_X.js} +2 -2
  55. package/dist/defineDeepModel-BmHs4vdS.js +19 -0
  56. package/dist/{duplicate-template-CR79OmLy.js → duplicate-template-UzmArmcM.js} +1 -1
  57. package/dist/{export-CQJcxfPC.js → export-Bdxro0GT.js} +1 -1
  58. package/dist/feature-DyfUPR3b.js +1081 -0
  59. package/dist/{format-time-from-id-61ydd8RS.js → format-time-from-id-uRCD3JxF.js} +1 -1
  60. package/dist/{format-unit-display-BLtW28yU.js → format-unit-display-C-_85vuL.js} +13 -13
  61. package/dist/{import-export.helper-uhFwjH6X.js → import-export.helper-N1BqiTub.js} +6 -6
  62. package/dist/{index-Dx5HvWR_.js → index-B1RZtqz-.js} +1 -1
  63. package/dist/{index-uA6bkf1x.js → index-CaREZ_vQ.js} +3 -3
  64. package/dist/{index-CouegIcG.js → index-CwqHa5AY.js} +1 -1
  65. package/dist/{feature-CZHvliez.js → inventory-core-dart.default-BK8f9n8e.js} +322 -1395
  66. package/dist/{lodash-CjyamSgJ.js → lodash-B9tHF9A4.js} +1 -1
  67. package/dist/{lz-string-BbZdMrTL.js → lz-string-BSMjlcH9.js} +1 -1
  68. package/dist/modules/print-template/api/print-template.d.ts +29 -0
  69. package/dist/modules/print-template/components/BlockConfigPanel.vue.d.ts +19 -0
  70. package/dist/modules/print-template/components/CustomPrintTemplatePreview.vue.d.ts +25 -0
  71. package/dist/modules/print-template/components/PrintTemplateEditorDialog.vue.d.ts +45 -0
  72. package/dist/modules/print-template/components/TemplatePreview.vue.d.ts +22 -0
  73. package/dist/modules/print-template/composables/print-po-with-template.d.ts +25 -0
  74. package/dist/modules/print-template/definitions/block-definitions.d.ts +88 -0
  75. package/dist/modules/print-template/definitions/predefined-templates.d.ts +22 -0
  76. package/dist/modules/print-template/definitions/template-renderer.d.ts +17 -0
  77. package/dist/modules/print-template/index.d.ts +11 -0
  78. package/dist/modules/print-template/store/print-template.d.ts +170 -0
  79. package/dist/modules/print-template/types/print-data.d.ts +52 -0
  80. package/dist/modules/print-template/utils/sanitize-html.d.ts +32 -0
  81. package/dist/{netsuite-2v3F8ILe.js → netsuite-D4KHhWWu.js} +60 -9
  82. package/dist/{number-BYbxsJHr.js → number-DmqVo28f.js} +3 -3
  83. package/dist/predefined-templates-Dy5hYXMM.js +4542 -0
  84. package/dist/{purchase-order-template-s1AiueV_.js → purchase-order-template-BT3tF_gn.js} +1 -1
  85. package/dist/router/name.d.ts +2 -0
  86. package/dist/{row-action.enum-BcW_L_nE.js → row-action.enum-Co_O4qD9.js} +11 -3
  87. package/dist/{rules-C7L-LFOd.js → rules-CbJ7idQa.js} +2 -2
  88. package/dist/{stock-D2s88pz1.js → stock-C9RXv-3_.js} +1 -1
  89. package/dist/{stock-CvYOcgWb.js → stock-YXoLCE8o.js} +3 -3
  90. package/dist/stores/feature.d.ts +2 -0
  91. package/dist/stores/integration/netsuite.d.ts +1 -1
  92. package/dist/style.css +1 -1
  93. package/dist/{supplier-DmobM7mD.js → supplier-Duiacdig.js} +2 -2
  94. package/dist/{surcharge-BdZOVfi0.js → surcharge-CkDK4P_6.js} +1 -1
  95. package/dist/tsconfig.app.tsbuildinfo +1 -1
  96. package/dist/{use-ingredient-select-dialog-BUCJBHjV.js → use-ingredient-select-dialog-C7uVeT1M.js} +2 -2
  97. package/dist/{use-inventory-binding-dialog-DiN1hBIm.js → use-inventory-binding-dialog-BIo9Fi-9.js} +2 -2
  98. package/dist/{use-template-enabled-locations-CmH6I2cy.js → use-template-enabled-locations-BtbfLc0y.js} +2 -2
  99. package/dist/views/integration/components/IntegrationSyncLogTab.vue.d.ts +15 -0
  100. package/dist/views/integration/composables/use-integration-sync-log.d.ts +45 -0
  101. package/dist/views/integration-explorer/IntegrationExplorerView.vue.d.ts +2 -0
  102. package/dist/views/integration-explorer/composables/use-explorer-tab.d.ts +126 -0
  103. package/dist/views/integration-explorer/netsuite/ExplorerRecordSyncLog.vue.d.ts +17 -0
  104. package/dist/views/integration-explorer/netsuite/ExplorerRecordToolbar.vue.d.ts +201 -0
  105. package/dist/views/integration-explorer/netsuite/ExplorerSystemNote.vue.d.ts +15 -0
  106. package/dist/views/integration-explorer/netsuite/JsonViewer.vue.d.ts +15 -0
  107. package/dist/views/integration-explorer/netsuite/NetSuiteExplorerView.vue.d.ts +2 -0
  108. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferSideSheet.vue.d.ts +7 -0
  109. package/dist/views/integration-explorer/netsuite/inventoryTransfer/InventoryTransferView.vue.d.ts +39 -0
  110. package/dist/views/integration-explorer/netsuite/items/AssemblyItemSideSheet.vue.d.ts +7 -0
  111. package/dist/views/integration-explorer/netsuite/items/InventoryItemSideSheet.vue.d.ts +7 -0
  112. package/dist/views/integration-explorer/netsuite/items/ItemsView.vue.d.ts +2 -0
  113. package/dist/views/integration-explorer/netsuite/items/ServiceItemSideSheet.vue.d.ts +7 -0
  114. package/dist/views/integration-explorer/netsuite/orders/ExplorerOrderDetailSideSheet.vue.d.ts +7 -0
  115. package/dist/views/integration-explorer/netsuite/orders/OrdersView.vue.d.ts +39 -0
  116. package/dist/views/integration-explorer/netsuite/orders/PurchaseOrderSideSheet.vue.d.ts +7 -0
  117. package/dist/views/integration-explorer/netsuite/orders/SyncNetsuiteButton.vue.d.ts +29 -0
  118. package/dist/views/integration-explorer/netsuite/orders/TransferOrderSideSheet.vue.d.ts +7 -0
  119. package/dist/views/receive-request/components/transfer-form/TransferFormWithController.vue.d.ts +21 -21
  120. package/dist/views/receive-request/composables/use-process-purchase-order.d.ts +21 -21
  121. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +129 -129
  122. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +154 -150
  123. package/dist/views/settings/SettingsView.vue.d.ts +2 -0
  124. package/dist/vue-i18n-D1JHIbLE.js +2365 -0
  125. package/dist/{xlsx-D4PML26z.js → xlsx-BEbkruI_.js} +398 -398
  126. package/dist/{xlsx.util-BWLcCmO_.js → xlsx.util-BMTXqfxw.js} +1 -1
  127. package/package.json +9 -4
  128. package/dist/ApprovalView-0FbsslVD.js +0 -226
  129. package/dist/ReceiveRequestView-ur3OeHuv.js +0 -2802
  130. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-GhRFdMoW.js +0 -3521
  131. package/dist/defineDeepModel-SD5OUepJ.js +0 -19
  132. package/dist/vue-i18n-D0Q6LFcu.js +0 -2365
@@ -0,0 +1,1081 @@
1
+ var _t = Object.defineProperty;
2
+ var ft = (l, c, h) => c in l ? _t(l, c, { enumerable: !0, configurable: !0, writable: !0, value: h }) : l[c] = h;
3
+ var ce = (l, c, h) => ft(l, typeof c != "symbol" ? c + "" : c, h);
4
+ import { useCoreStore as De } from "@feedmepos/mf-common";
5
+ import { ak as ve, u as Ke, k as at, a as gt } from "./app-B5-QVzib.js";
6
+ import { ref as he, readonly as Ge } from "vue";
7
+ import "./inventory-core-dart.default-BK8f9n8e.js";
8
+ var Ve = { exports: {} };
9
+ (function(l, c) {
10
+ (function(h, f) {
11
+ f(c);
12
+ })(ve, function(h) {
13
+ var f = { getItemSync: function(r) {
14
+ try {
15
+ return localStorage.getItem(r) || null;
16
+ } catch {
17
+ return null;
18
+ }
19
+ }, getItem: function(r, t) {
20
+ var e = this;
21
+ return new Promise(function(i, n) {
22
+ try {
23
+ var a = e.getItemSync(r);
24
+ t == null || t(null, a), i(a);
25
+ } catch (o) {
26
+ t && t(o, null), n(o);
27
+ }
28
+ });
29
+ }, setItem: function(r, t, e) {
30
+ return new Promise(function(i, n) {
31
+ try {
32
+ localStorage.setItem(r, t), e && e(null, t), i(t);
33
+ } catch (a) {
34
+ e && e(a, null), n(a);
35
+ }
36
+ });
37
+ } }, s = function() {
38
+ return s = Object.assign || function(r) {
39
+ for (var t, e = 1, i = arguments.length; e < i; e++) for (var n in t = arguments[e]) Object.prototype.hasOwnProperty.call(t, n) && (r[n] = t[n]);
40
+ return r;
41
+ }, s.apply(this, arguments);
42
+ };
43
+ function R(r, t, e, i) {
44
+ return new (e || (e = Promise))(function(n, a) {
45
+ function o(p) {
46
+ try {
47
+ d(i.next(p));
48
+ } catch (u) {
49
+ a(u);
50
+ }
51
+ }
52
+ function v(p) {
53
+ try {
54
+ d(i.throw(p));
55
+ } catch (u) {
56
+ a(u);
57
+ }
58
+ }
59
+ function d(p) {
60
+ var u;
61
+ p.done ? n(p.value) : (u = p.value, u instanceof e ? u : new e(function(y) {
62
+ y(u);
63
+ })).then(o, v);
64
+ }
65
+ d((i = i.apply(r, [])).next());
66
+ });
67
+ }
68
+ function K(r, t) {
69
+ var e, i, n, a, o = { label: 0, sent: function() {
70
+ if (1 & n[0]) throw n[1];
71
+ return n[1];
72
+ }, trys: [], ops: [] };
73
+ return a = { next: v(0), throw: v(1), return: v(2) }, typeof Symbol == "function" && (a[Symbol.iterator] = function() {
74
+ return this;
75
+ }), a;
76
+ function v(d) {
77
+ return function(p) {
78
+ return function(u) {
79
+ if (e) throw new TypeError("Generator is already executing.");
80
+ for (; o; ) try {
81
+ if (e = 1, i && (n = 2 & u[0] ? i.return : u[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, u[1])).done) return n;
82
+ switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) {
83
+ case 0:
84
+ case 1:
85
+ n = u;
86
+ break;
87
+ case 4:
88
+ return o.label++, { value: u[1], done: !1 };
89
+ case 5:
90
+ o.label++, i = u[1], u = [0];
91
+ continue;
92
+ case 7:
93
+ u = o.ops.pop(), o.trys.pop();
94
+ continue;
95
+ default:
96
+ if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
97
+ o = 0;
98
+ continue;
99
+ }
100
+ if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) {
101
+ o.label = u[1];
102
+ break;
103
+ }
104
+ if (u[0] === 6 && o.label < n[1]) {
105
+ o.label = n[1], n = u;
106
+ break;
107
+ }
108
+ if (n && o.label < n[2]) {
109
+ o.label = n[2], o.ops.push(u);
110
+ break;
111
+ }
112
+ n[2] && o.ops.pop(), o.trys.pop();
113
+ continue;
114
+ }
115
+ u = t.call(r, o);
116
+ } catch (y) {
117
+ u = [6, y], i = 0;
118
+ } finally {
119
+ e = n = 0;
120
+ }
121
+ if (5 & u[0]) throw u[1];
122
+ return { value: u[0] ? u[1] : void 0, done: !0 };
123
+ }([d, p]);
124
+ };
125
+ }
126
+ }
127
+ function F(r, t, e) {
128
+ for (var i, n = 0, a = t.length; n < a; n++) !i && n in t || (i || (i = Array.prototype.slice.call(t, 0, n)), i[n] = t[n]);
129
+ return r.concat(i || Array.prototype.slice.call(t));
130
+ }
131
+ var W = function r(t, e) {
132
+ if (t === e) return !0;
133
+ if (t && e && typeof t == "object" && typeof e == "object") {
134
+ if (t.constructor !== e.constructor) return !1;
135
+ var i, n, a;
136
+ if (Array.isArray(t)) {
137
+ if ((i = t.length) != e.length) return !1;
138
+ for (n = i; n-- != 0; ) if (!r(t[n], e[n])) return !1;
139
+ return !0;
140
+ }
141
+ if (t.constructor === RegExp) return t.source === e.source && t.flags === e.flags;
142
+ if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === e.valueOf();
143
+ if (t.toString !== Object.prototype.toString) return t.toString() === e.toString();
144
+ if ((i = (a = Object.keys(t)).length) !== Object.keys(e).length) return !1;
145
+ for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(e, a[n])) return !1;
146
+ for (n = i; n-- != 0; ) {
147
+ var o = a[n];
148
+ if (!r(t[o], e[o])) return !1;
149
+ }
150
+ return !0;
151
+ }
152
+ return t != t && e != e;
153
+ };
154
+ function E(r, t) {
155
+ var e = Object.keys(t || {}).filter(function(i) {
156
+ var n = r == null ? void 0 : r[i], a = t == null ? void 0 : t[i];
157
+ return !W(n, a);
158
+ });
159
+ return Object.keys(r || {}).filter(function(i) {
160
+ Object.keys(t || {}).includes(i) || e.push(i);
161
+ }), Object.keys(e).length ? e : null;
162
+ }
163
+ var g, b;
164
+ function w(r, t, e) {
165
+ var i = "shortString", n = !0;
166
+ typeof e == "number" && (i = "javaDouble", n = !1), r[i] = r[i] || {}, r[i][t] = n ? e + "" : e;
167
+ }
168
+ function I(r) {
169
+ return !!r && typeof r == "object" && r.value !== void 0;
170
+ }
171
+ function $(r) {
172
+ return Object.fromEntries(Object.entries(r).map(function(t) {
173
+ var e = t[0], i = t[1];
174
+ return [e, I(i) ? i : { value: i }];
175
+ }));
176
+ }
177
+ function Y(r) {
178
+ return s(s({}, r), { identity: r.identity ? s(s({}, r.identity), { traits: $(r.identity.traits || {}) }) : void 0 });
179
+ }
180
+ (function(r) {
181
+ r.NONE = "NONE", r.DEFAULT_FLAGS = "DEFAULT_FLAGS", r.CACHE = "CACHE", r.SERVER = "SERVER";
182
+ })(g || (g = {}));
183
+ var _e, k = null, ut = "FLAGSMITH_EVENT", le = ut, Je = "https://edge.api.flagsmith.com/api/v1/", qe = "flagsmith_value_", Be = "flagsmith_enabled_", Me = "flagsmith_trait_", ct = function() {
184
+ function r(t) {
185
+ var e = this;
186
+ this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
187
+ var i = e, n = i.api, a = i.evaluationContext;
188
+ e.log("Get Flags"), e.isLoading = !0, e.loadingState.isFetching || e.setLoadingState(s(s({}, e.loadingState), { isFetching: !0 }));
189
+ var o = "".concat(e.getContext().identity), v = function(d) {
190
+ var p, u, y, O;
191
+ if (d && o === "".concat(e.getContext().identity)) {
192
+ var G = d.flags, A = d.traits, U = d.identifier;
193
+ e.isLoading = !1;
194
+ var P = {}, j = {};
195
+ A = A || [], (G = G || []).forEach(function(m) {
196
+ P[m.feature.name.toLowerCase().replace(/ /g, "_")] = { id: m.feature.id, enabled: m.enabled, value: m.feature_state_value };
197
+ }), A.forEach(function(m) {
198
+ j[m.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: m.transient, value: m.trait_value };
199
+ }), e.oldFlags = s({}, e.flags);
200
+ var V = E(e.oldFlags, P), ie = E((p = e.evaluationContext.identity) === null || p === void 0 ? void 0 : p.traits, j);
201
+ if ((U || Object.keys(j).length) && (e.evaluationContext.identity = s(s({}, e.evaluationContext.identity), { traits: j }), U && (e.evaluationContext.identity.identifier = U)), e.flags = P, e.updateStorage(), e._onChange(e.oldFlags, { isFromServer: !0, flagsChanged: V, traitsChanged: ie }, e._loadedState(null, g.SERVER)), e.datadogRum) try {
202
+ if (e.datadogRum.trackTraits) {
203
+ var re = {};
204
+ Object.keys(((u = e.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(m) {
205
+ re[Me + m] = e.getTrait(m);
206
+ });
207
+ var Z = s(s(s({}, e.datadogRum.client.getUser()), { id: e.datadogRum.client.getUser().id || ((y = e.evaluationContext.identity) === null || y === void 0 ? void 0 : y.identifier) }), re);
208
+ e.log("Setting Datadog user", Z), e.datadogRum.client.setUser(Z);
209
+ }
210
+ } catch (m) {
211
+ console.error(m);
212
+ }
213
+ if (e.dtrum) try {
214
+ var T = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
215
+ Object.keys(e.flags).map(function(m) {
216
+ w(T, qe + m, e.getValue(m, { skipAnalytics: !0 })), w(T, Be + m, e.hasFeature(m, { skipAnalytics: !0 }));
217
+ }), Object.keys(((O = e.evaluationContext.identity) === null || O === void 0 ? void 0 : O.traits) || {}).map(function(m) {
218
+ w(T, Me + m, e.getTrait(m));
219
+ }), e.log("Sending javaLongOrObject traits to dynatrace", T.javaLongOrObject), e.log("Sending date traits to dynatrace", T.date), e.log("Sending shortString traits to dynatrace", T.shortString), e.log("Sending javaDouble to dynatrace", T.javaDouble), e.dtrum.sendSessionProperties(T.javaLongOrObject, T.date, T.shortString, T.javaDouble);
220
+ } catch (m) {
221
+ console.error(m);
222
+ }
223
+ }
224
+ };
225
+ return a.identity ? Promise.all([a.identity.traits && Object.keys(a.identity.traits).length || !a.identity.identifier ? e.getJSON(n + "identities/", "POST", JSON.stringify({ identifier: a.identity.identifier, transient: a.identity.transient, traits: Object.entries(a.identity.traits).map(function(d) {
226
+ var p = d[0], u = d[1];
227
+ return { trait_key: p, trait_value: u == null ? void 0 : u.value, transient: u == null ? void 0 : u.transient };
228
+ }).filter(function(d) {
229
+ return d.trait_value !== void 0 || (e.log("Warning - attempted to set an undefined trait value for key", d.trait_key), !1);
230
+ }) })) : e.getJSON(n + "identities/?identifier=" + encodeURIComponent(a.identity.identifier) + (a.identity.transient ? "&transient=true" : ""))]).then(function(d) {
231
+ return e.evaluationContext.identity = s(s({}, e.evaluationContext.identity), { traits: {} }), v(d == null ? void 0 : d[0]);
232
+ }).catch(function(d) {
233
+ var p = d.message, u = new Error(p);
234
+ return Promise.reject(u);
235
+ }) : e.getJSON(n + "flags/").then(function(d) {
236
+ return v({ flags: d, traits: void 0 });
237
+ });
238
+ }, this.analyticsFlags = function() {
239
+ var i = e.api;
240
+ if (e.evaluationEvent && e.evaluationContext.environment && e.evaluationEvent[e.evaluationContext.environment.apiKey]) return e.evaluationEvent && Object.getOwnPropertyNames(e.evaluationEvent).length !== 0 && Object.getOwnPropertyNames(e.evaluationEvent[e.evaluationContext.environment.apiKey]).length !== 0 ? e.getJSON(i + "analytics/flags/", "POST", JSON.stringify(e.evaluationEvent[e.evaluationContext.environment.apiKey])).then(function(n) {
241
+ if (e.evaluationContext.environment) {
242
+ var a = e.getState();
243
+ e.evaluationEvent || (e.evaluationEvent = {}), e.evaluationEvent[e.evaluationContext.environment.apiKey] = {}, e.setState(s(s({}, a), { evaluationEvent: e.evaluationEvent })), e.updateEventStorage();
244
+ }
245
+ }).catch(function(n) {
246
+ e.log("Exception fetching evaluationEvent", n);
247
+ }) : void 0;
248
+ }, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: g.NONE }, this.canUseStorage = !1, this.analyticsInterval = null, this.api = null, this.cacheFlags = !1, this.ts = null, this.enableAnalytics = !1, this.enableLogs = !1, this.evaluationContext = {}, this.evaluationEvent = null, this.flags = null, this.getFlagInterval = null, this.headers = null, this.initialised = !1, this.oldFlags = null, this.onChange = null, this.onError = null, this.ticks = null, this.timer = null, this.dtrum = null, this.withTraits = null, this.cacheOptions = { ttl: 0, skipAPI: !1, loadStale: !1, storageKey: void 0 }, this.getValue = function(i, n, a) {
249
+ var o = e.flags && e.flags[i.toLowerCase().replace(/ /g, "_")], v = null;
250
+ if (o && (v = o.value), n != null && n.skipAnalytics || a || e.evaluateFlag(i, "VALUE"), v === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
251
+ if (n != null && n.json) try {
252
+ return v === null ? (e.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(v);
253
+ } catch {
254
+ return n.fallback;
255
+ }
256
+ return v;
257
+ }, this.getTrait = function(i) {
258
+ var n, a;
259
+ return ((n = e.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((a = e.evaluationContext.identity.traits[i.toLowerCase().replace(/ /g, "_")]) === null || a === void 0 ? void 0 : a.value);
260
+ }, this.getAllTraits = function() {
261
+ var i;
262
+ return Object.fromEntries(Object.entries(((i = e.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
263
+ var a = n[0], o = n[1];
264
+ return [a, o == null ? void 0 : o.value];
265
+ }));
266
+ }, this.setContext = function(i) {
267
+ var n = Y(i);
268
+ return e.evaluationContext = s(s({}, n), { environment: n.environment || e.evaluationContext.environment }), e.initialised ? e.getFlags() : Promise.resolve();
269
+ }, this.getContext = function() {
270
+ return e.evaluationContext;
271
+ }, this.updateContext = function(i) {
272
+ return e.setContext(s(s({}, e.getContext()), i));
273
+ }, this.setTrait = function(i, n) {
274
+ var a;
275
+ if (e.api) return e.setContext(s(s({}, e.evaluationContext), { identity: s(s({}, e.evaluationContext.identity), { traits: s(s({}, (a = e.evaluationContext.identity) === null || a === void 0 ? void 0 : a.traits), $(Object.fromEntries([[i, n]]))) }) }));
276
+ }, this.setTraits = function(i) {
277
+ var n;
278
+ if (e.api) return e.setContext(s(s({}, e.evaluationContext), { identity: s(s({}, e.evaluationContext.identity), { traits: s(s({}, (n = e.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(a) {
279
+ var o = a[0], v = a[1];
280
+ return [o, I(v) ? v : { value: v }];
281
+ }))) }) }));
282
+ console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.");
283
+ }, this.hasFeature = function(i, n) {
284
+ var a = typeof n == "object", o = e.flags && e.flags[i.toLowerCase().replace(/ /g, "_")], v = !1;
285
+ return !o && a && n.fallback !== void 0 ? v = n == null ? void 0 : n.fallback : o && o.enabled && (v = !0), (a && !n.skipAnalytics || !n) && e.evaluateFlag(i, "ENABLED"), v;
286
+ }, this.getStorageKey = function() {
287
+ var i, n;
288
+ return ((i = e.cacheOptions) === null || i === void 0 ? void 0 : i.storageKey) || "FLAGSMITH_DB_" + ((n = e.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
289
+ }, this.getJSON = function(i, n, a) {
290
+ var o, v = e;
291
+ v.evaluationContext;
292
+ var d = v.headers, p = { method: n || "GET", body: a, cache: "no-cache", headers: {} };
293
+ e.evaluationContext.environment && (p.headers["X-Environment-Key"] = e.evaluationContext.environment.apiKey), n && n !== "GET" && (p.headers["Content-Type"] = "application/json; charset=utf-8"), d && Object.assign(p.headers, d), b || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
294
+ var u = "".concat((o = e.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
295
+ return b(i, p).then(function(y) {
296
+ var O, G, A = "".concat((O = e.evaluationContext.identity) === null || O === void 0 ? void 0 : O.identifier);
297
+ if (u === A) {
298
+ var U = (G = y.headers) === null || G === void 0 ? void 0 : G.get("x-flagsmith-document-updated-at");
299
+ if (U) try {
300
+ var P = parseFloat(U);
301
+ if (isNaN(P)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
302
+ e.timestamp = P;
303
+ } catch (j) {
304
+ e.log(j, "Failed to parse x-flagsmith-document-updated-at", U);
305
+ }
306
+ return e.log("Fetch response: " + y.status + " " + (n || "GET") + 0 + i), y.text().then(function(j) {
307
+ var V = j;
308
+ try {
309
+ V = JSON.parse(j);
310
+ } catch {
311
+ }
312
+ return !V && y.status && (V = "API Response: ".concat(y.status)), y.status && y.status >= 200 && y.status < 300 ? V : Promise.reject(new Error(V));
313
+ });
314
+ }
315
+ e.log("Received response with identity mismatch, ignoring response. Requested: ".concat(u, ", Current: ").concat(A));
316
+ });
317
+ }, this.evaluateFlag = function(i, n) {
318
+ if (e.datadogRum && (e.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? e.datadogRum.client.addFeatureFlagEvaluation(qe + i, e.getValue(i, {}, !0)) : e.datadogRum.client.addFeatureFlagEvaluation(Be + i, e.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), e.enableAnalytics) {
319
+ if (!e.evaluationEvent || !e.evaluationContext.environment) return;
320
+ e.evaluationEvent[e.evaluationContext.environment.apiKey] || (e.evaluationEvent[e.evaluationContext.environment.apiKey] = {}), e.evaluationEvent[e.evaluationContext.environment.apiKey][i] === void 0 && (e.evaluationEvent[e.evaluationContext.environment.apiKey][i] = 0), e.evaluationEvent[e.evaluationContext.environment.apiKey][i] += 1;
321
+ }
322
+ e.updateEventStorage();
323
+ }, this._onChange = function(i, n, a) {
324
+ var o, v;
325
+ e.setLoadingState(a), (o = e.onChange) === null || o === void 0 || o.call(e, i, n, e.loadingState), (v = e._trigger) === null || v === void 0 || v.call(e);
326
+ }, b = t.fetch ? t.fetch : typeof fetch < "u" ? fetch : ve === null || ve === void 0 ? void 0 : ve.fetch, this.canUseStorage = typeof window < "u" || !!t.browserlessStorage, this.log("Constructing flagsmith instance " + t), t.eventSource && (_e = t.eventSource), t.AsyncStorage && (k = t.AsyncStorage);
327
+ }
328
+ return r.prototype.init = function(t) {
329
+ var e, i, n;
330
+ return R(this, void 0, void 0, function() {
331
+ var a, o, v, d, p, u, y, O, G, A, U, P, j, V, ie, re, Z, T, m, ge, ae, Ze, Q, pe, Qe, et, ye, tt, me, oe, ee, nt, L = this;
332
+ return K(this, function(D) {
333
+ switch (D.label) {
334
+ case 0:
335
+ a = Y(t.evaluationContext || this.evaluationContext), D.label = 1;
336
+ case 1:
337
+ if (D.trys.push([1, 13, , 14]), o = t.environmentID, v = t.api, d = v === void 0 ? Je : v, p = t.headers, u = t.onChange, y = t.cacheFlags, O = t.datadogRum, G = t.onError, A = t.defaultFlags, U = t.fetch, P = t.preventFetch, j = t.enableLogs, V = t.enableDynatrace, ie = t.enableAnalytics, re = t.realtime, Z = t.eventSourceUrl, T = Z === void 0 ? "https://realtime.flagsmith.com/" : Z, m = t.AsyncStorage, ge = t.identity, ae = t.traits, Ze = t.state, Q = t.cacheOptions, pe = t.angularHttpClient, Qe = t._trigger, et = t._triggerLoadingState, a.environment = o ? { apiKey: o } : a.environment, !a.environment || !a.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
338
+ if (a.identity = ge || ae ? { identifier: ge, traits: ae ? Object.fromEntries(Object.entries(ae).map(function(N) {
339
+ return [N[0], { value: N[1] }];
340
+ })) : {} } : a.identity, this.evaluationContext = a, this.api = d, this.headers = p, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, ye = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Qe || this._trigger, this._triggerLoadingState = et || this._triggerLoadingState, this.onError = function(N) {
341
+ L.setLoadingState(s(s({}, L.loadingState), { isFetching: !1, isLoading: !1, error: N })), G == null || G(N);
342
+ }, this.enableLogs = j || !1, this.cacheOptions = Q ? { skipAPI: !!Q.skipAPI, ttl: Q.ttl || 0, storageKey: Q.storageKey, loadStale: !!Q.loadStale } : this.cacheOptions, !this.cacheOptions.ttl && this.cacheOptions.skipAPI && console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."), U && (b = U), this.enableAnalytics = ie || !1, this.flags = Object.assign({}, A) || {}, this.datadogRum = O || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = k !== void 0 && !!y, le = "FLAGSMITH_EVENT_" + a.environment.apiKey, m && (k = m), re && typeof window < "u" && this.setupRealtime(T, a.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: g.DEFAULT_FLAGS })), this.setState(Ze), this.log("Initialising with properties", t, this), V && (typeof dtrum > "u" ? console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed.") : this.dtrum = dtrum), pe && (b = /* @__PURE__ */ function(N) {
343
+ return function(J, q) {
344
+ var z = q.headers, C = q.method, te = q.body;
345
+ return new Promise(function(X) {
346
+ switch (C) {
347
+ case "GET":
348
+ return N.get(J, { headers: z }).subscribe(function(M) {
349
+ X({ ok: !0, text: function() {
350
+ return Promise.resolve(M);
351
+ } });
352
+ });
353
+ case "POST":
354
+ case "PUT":
355
+ return N.post(J, te, { headers: z }).subscribe(function(M) {
356
+ X({ ok: !0, text: function() {
357
+ return Promise.resolve(M);
358
+ } });
359
+ });
360
+ }
361
+ });
362
+ };
363
+ }(pe)), k && this.canUseStorage && k.getItem(le).then(function(N) {
364
+ try {
365
+ L.evaluationEvent = JSON.parse(N) || {};
366
+ } catch {
367
+ L.evaluationEvent = {};
368
+ }
369
+ L.analyticsInterval = setInterval(L.analyticsFlags, L.ticks);
370
+ }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), k && this.canUseStorage && k.getItem(le, function(N, J) {
371
+ if (J && L.evaluationContext.environment) {
372
+ var q = JSON.parse(J);
373
+ if (q[L.evaluationContext.environment.apiKey]) {
374
+ var z = L.getState();
375
+ L.log("Retrieved events from cache", J), L.setState(s(s({}, z), { evaluationEvent: q[L.evaluationContext.environment.apiKey] }));
376
+ }
377
+ }
378
+ })), !y) return [3, 9];
379
+ if (!k || !this.canUseStorage) return [3, 8];
380
+ tt = function(N, J) {
381
+ return R(L, void 0, void 0, function() {
382
+ var q, z, C, te, X, M, be, it, Se, Ce, xe, we, Ee, Oe, Te, Le, ke, Fe, Ie, Ae, Pe, je, Ne, Re, rt = this;
383
+ return K(this, function(H) {
384
+ switch (H.label) {
385
+ case 0:
386
+ if (!J) return [3, 7];
387
+ q = null, z = null, H.label = 1;
388
+ case 1:
389
+ return H.trys.push([1, 5, , 6]), C = JSON.parse(J), te = !1, X = !1, C && C.api === this.api && ((Ce = (Se = C.evaluationContext) === null || Se === void 0 ? void 0 : Se.environment) === null || Ce === void 0 ? void 0 : Ce.apiKey) === ((xe = this.evaluationContext.environment) === null || xe === void 0 ? void 0 : xe.apiKey) && (M = !0, this.evaluationContext.identity && ((Ee = (we = C.evaluationContext) === null || we === void 0 ? void 0 : we.identity) === null || Ee === void 0 ? void 0 : Ee.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((Te = (Oe = C.evaluationContext) === null || Oe === void 0 ? void 0 : Oe.identity) === null || Te === void 0 ? void 0 : Te.identifier) + " to " + this.evaluationContext.identity.identifier), M = !1), this.cacheOptions.ttl && (!C.ts || (/* @__PURE__ */ new Date()).valueOf() - C.ts > this.cacheOptions.ttl) && (C.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), M = !1) : C.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), X = !0, M = !0)), M && (te = !0, z = E((Le = this.evaluationContext.identity) === null || Le === void 0 ? void 0 : Le.traits, (Fe = (ke = C.evaluationContext) === null || ke === void 0 ? void 0 : ke.identity) === null || Fe === void 0 ? void 0 : Fe.traits), q = E(this.flags, C.flags), this.setState(s(s({}, C), { evaluationContext: Y(s(s({}, C.evaluationContext), { identity: !((Ie = C.evaluationContext) === null || Ie === void 0) && Ie.identity ? s(s({}, (Ae = C.evaluationContext) === null || Ae === void 0 ? void 0 : Ae.identity), { traits: s(s({}, ((je = (Pe = C.evaluationContext) === null || Pe === void 0 ? void 0 : Pe.identity) === null || je === void 0 ? void 0 : je.traits) || {}), ae || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", C))), te ? (be = !P && (!this.cacheOptions.skipAPI || X), this._onChange(null, { isFromServer: !1, flagsChanged: q, traitsChanged: z }, this._loadedState(null, g.CACHE, be)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && te && !X && this.log("Skipping API, using cache"), be && this.getFlags().catch(function(ht) {
390
+ var Ue;
391
+ (Ue = rt.onError) === null || Ue === void 0 || Ue.call(rt, ht);
392
+ }), [3, 4]) : [3, 2];
393
+ case 2:
394
+ return P ? [3, 4] : [4, this.getFlags()];
395
+ case 3:
396
+ H.sent(), H.label = 4;
397
+ case 4:
398
+ return [3, 6];
399
+ case 5:
400
+ return it = H.sent(), this.log("Exception fetching cached logs", it), [3, 6];
401
+ case 6:
402
+ return [3, 10];
403
+ case 7:
404
+ return P ? [3, 9] : [4, this.getFlags()];
405
+ case 8:
406
+ return H.sent(), [3, 10];
407
+ case 9:
408
+ if (A) this._onChange(null, { isFromServer: !1, flagsChanged: E({}, this.flags), traitsChanged: E({}, (Ne = this.evaluationContext.identity) === null || Ne === void 0 ? void 0 : Ne.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
409
+ else {
410
+ if (!this.flags) throw new Error(ye);
411
+ this._onChange(null, { isFromServer: !1, flagsChanged: E({}, this.flags), traitsChanged: E({}, (Re = this.evaluationContext.identity) === null || Re === void 0 ? void 0 : Re.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
412
+ }
413
+ H.label = 10;
414
+ case 10:
415
+ return [2];
416
+ }
417
+ });
418
+ });
419
+ }, D.label = 2;
420
+ case 2:
421
+ return D.trys.push([2, 7, , 8]), k.getItemSync ? (me = k.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
422
+ case 3:
423
+ return [4, k.getItem(this.getStorageKey())];
424
+ case 4:
425
+ me = D.sent(), D.label = 5;
426
+ case 5:
427
+ return [4, tt(null, me)];
428
+ case 6:
429
+ case 7:
430
+ return D.sent(), [3, 8];
431
+ case 8:
432
+ return [3, 12];
433
+ case 9:
434
+ return P ? [3, 11] : [4, this.getFlags()];
435
+ case 10:
436
+ return D.sent(), [3, 12];
437
+ case 11:
438
+ if (A) this._onChange(null, { isFromServer: !1, flagsChanged: E({}, A), traitsChanged: E({}, (e = a.identity) === null || e === void 0 ? void 0 : e.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
439
+ else if (this.flags && (oe = null, Object.keys(this.flags).length === 0 && (oe = ye), this._onChange(null, { isFromServer: !1, flagsChanged: E({}, this.flags), traitsChanged: E({}, (i = a.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(oe, g.DEFAULT_FLAGS)), oe)) throw new Error(oe);
440
+ D.label = 12;
441
+ case 12:
442
+ return [3, 14];
443
+ case 13:
444
+ throw ee = D.sent(), this.log("Error during initialisation ", ee), nt = ee instanceof Error ? ee : new Error("".concat(ee)), (n = this.onError) === null || n === void 0 || n.call(this, nt), ee;
445
+ case 14:
446
+ return [2];
447
+ }
448
+ });
449
+ });
450
+ }, r.prototype.getAllFlags = function() {
451
+ return this.flags;
452
+ }, r.prototype.identify = function(t, e, i) {
453
+ return this.evaluationContext.identity = { identifier: t, transient: i, traits: this.evaluationContext.identity && this.evaluationContext.identity.identifier == t ? this.evaluationContext.identity.traits : {} }, this.evaluationContext.identity.identifier = t, this.log("Identify: " + this.evaluationContext.identity.identifier), e && (this.evaluationContext.identity.traits = Object.fromEntries(Object.entries(e).map(function(n) {
454
+ var a = n[0], o = n[1];
455
+ return [a, I(o) ? o : { value: o }];
456
+ }))), this.initialised ? this.getFlags() : Promise.resolve();
457
+ }, r.prototype.getState = function() {
458
+ return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
459
+ }, r.prototype.setState = function(t) {
460
+ t && (this.initialised = !0, this.api = t.api || this.api || Je, this.flags = t.flags || this.flags, this.evaluationContext = t.evaluationContext || this.evaluationContext, this.evaluationEvent = t.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
461
+ }, r.prototype.logout = function() {
462
+ return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
463
+ }, r.prototype.startListening = function(t) {
464
+ t === void 0 && (t = 1e3), this.getFlagInterval && clearInterval(this.getFlagInterval), this.getFlagInterval = setInterval(this.getFlags, t);
465
+ }, r.prototype.stopListening = function() {
466
+ this.getFlagInterval && (clearInterval(this.getFlagInterval), this.getFlagInterval = null);
467
+ }, r.prototype._loadedState = function(t, e, i) {
468
+ return t === void 0 && (t = null), i === void 0 && (i = !1), { error: t, isFetching: i, isLoading: !1, source: e };
469
+ }, r.prototype.log = function() {
470
+ for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
471
+ this.enableLogs && console.log.apply(this, F(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], t));
472
+ }, r.prototype.updateStorage = function() {
473
+ if (this.cacheFlags) {
474
+ this.ts = (/* @__PURE__ */ new Date()).valueOf();
475
+ var t = JSON.stringify(this.getState());
476
+ this.log("Setting storage", t), k.setItem(this.getStorageKey(), t);
477
+ }
478
+ }, r.prototype.updateEventStorage = function() {
479
+ if (this.enableAnalytics) {
480
+ var t = JSON.stringify(this.getState().evaluationEvent);
481
+ k.setItem(le, t).catch(function(e) {
482
+ return console.error("Flagsmith: Error setting item in async storage", e);
483
+ });
484
+ }
485
+ }, r.prototype.setLoadingState = function(t) {
486
+ var e;
487
+ W(t, this.loadingState) || (this.loadingState = s({}, t), this.log("Loading state changed", t), (e = this._triggerLoadingState) === null || e === void 0 || e.call(this));
488
+ }, r.prototype.setupRealtime = function(t, e) {
489
+ var i = this, n = t + "sse/environments/" + e + "/stream";
490
+ _e ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new _e(n), this.eventSource.addEventListener("environment_updated", function(a) {
491
+ var o;
492
+ try {
493
+ o = JSON.parse(a.data).updated_at;
494
+ } catch (v) {
495
+ i.log("Could not parse sse event", v);
496
+ }
497
+ o ? !i.timestamp || o > i.timestamp ? i.isLoading ? i.log("updated_at is new, but flags are loading", a.data, i.timestamp) : (i.log("updated_at is new, fetching flags", a.data, i.timestamp), i.getFlags()) : i.log("updated_at is outdated, skipping get flags", a.data, i.timestamp) : i.log("No updated_at received, fetching flags", a);
498
+ })) : this.log("Error, EventSource is undefined");
499
+ }, r;
500
+ }();
501
+ function ze(r) {
502
+ var t = r.fetch, e = r.AsyncStorage, i = r.eventSource;
503
+ return new ct({ fetch: t, AsyncStorage: e, eventSource: i });
504
+ }
505
+ var ue, vt = (ue = function(r, t) {
506
+ return ue = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, i) {
507
+ e.__proto__ = i;
508
+ } || function(e, i) {
509
+ for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (e[n] = i[n]);
510
+ }, ue(r, t);
511
+ }, function(r, t) {
512
+ if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
513
+ function e() {
514
+ this.constructor = r;
515
+ }
516
+ ue(r, t), r.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
517
+ }), He = function(r) {
518
+ var t = typeof Symbol == "function" && Symbol.iterator, e = t && r[t], i = 0;
519
+ if (e) return e.call(r);
520
+ if (r && typeof r.length == "number") return { next: function() {
521
+ return r && i >= r.length && (r = void 0), { value: r && r[i++], done: !r };
522
+ } };
523
+ throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
524
+ }, $e = function(r, t) {
525
+ var e = typeof Symbol == "function" && r[Symbol.iterator];
526
+ if (!e) return r;
527
+ var i, n, a = e.call(r), o = [];
528
+ try {
529
+ for (; (t === void 0 || t-- > 0) && !(i = a.next()).done; ) o.push(i.value);
530
+ } catch (v) {
531
+ n = { error: v };
532
+ } finally {
533
+ try {
534
+ i && !i.done && (e = a.return) && e.call(a);
535
+ } finally {
536
+ if (n) throw n.error;
537
+ }
538
+ }
539
+ return o;
540
+ }, fe = function(r, t, e) {
541
+ if (arguments.length === 2) for (var i, n = 0, a = t.length; n < a; n++) !i && n in t || (i || (i = Array.prototype.slice.call(t, 0, n)), i[n] = t[n]);
542
+ return r.concat(i || Array.prototype.slice.call(t));
543
+ }, dt = function(r) {
544
+ function t() {
545
+ return r.call(this, `EventSource not available.
546
+ Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
547
+ }
548
+ return vt(t, r), t;
549
+ }(Error), Xe = function() {
550
+ function r(t, e) {
551
+ var i = this;
552
+ if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = e != null ? Object.assign({}, e) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = t.toString(), this.readyState = this.CONNECTING, this.max_retry_time = 3e3, this.eventSourceClass = globalThis.FlagsmithEventSource, this._configuration != null && (this._configuration.lastEventId && (this._lastEventId = this._configuration.lastEventId, delete this._configuration.lastEventId), this._configuration.max_retry_time && (this.max_retry_time = this._configuration.max_retry_time, delete this._configuration.max_retry_time), this._configuration.eventSourceClass && (this.eventSourceClass = this._configuration.eventSourceClass, delete this._configuration.eventSourceClass)), this.eventSourceClass == null || typeof this.eventSourceClass != "function") throw new dt();
553
+ this._onevent_wrapped = function(n) {
554
+ i._onevent(n);
555
+ }, this._start();
556
+ }
557
+ return r.prototype.dispatchEvent = function(t) {
558
+ throw new Error("Method not implemented.");
559
+ }, r.prototype._start = function() {
560
+ var t, e, i = this, n = this.url;
561
+ this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(d) {
562
+ i._onopen(d);
563
+ }, this._eventSource.onerror = function(d) {
564
+ i._onerror(d);
565
+ }, this._eventSource.onmessage = function(d) {
566
+ i.onmessage(d);
567
+ };
568
+ try {
569
+ for (var a = He(Object.keys(this._listeners)), o = a.next(); !o.done; o = a.next()) {
570
+ var v = o.value;
571
+ this._eventSource.addEventListener(v, this._onevent_wrapped);
572
+ }
573
+ } catch (d) {
574
+ t = { error: d };
575
+ } finally {
576
+ try {
577
+ o && !o.done && (e = a.return) && e.call(a);
578
+ } finally {
579
+ if (t) throw t.error;
580
+ }
581
+ }
582
+ }, r.prototype._onopen = function(t) {
583
+ this.readyState === 0 && (this.readyState = 1, this.onopen(t));
584
+ }, r.prototype._onerror = function(t) {
585
+ var e = this;
586
+ if (this.readyState === 1 && (this.readyState = 0, this.onerror(t)), this._eventSource) {
587
+ this._eventSource.close(), this._eventSource = null;
588
+ var i = Math.round(this.max_retry_time * Math.random());
589
+ this._timer = setTimeout(function() {
590
+ return e._start();
591
+ }, i);
592
+ }
593
+ }, r.prototype._onevent = function(t) {
594
+ var e, i;
595
+ t && t.lastEventId && (this._lastEventId = t.lastEventId);
596
+ var n = this._listeners[t.type];
597
+ if (n != null) try {
598
+ for (var a = He(fe([], $e(n), !1)), o = a.next(); !o.done; o = a.next())
599
+ o.value.call(this, t);
600
+ } catch (v) {
601
+ e = { error: v };
602
+ } finally {
603
+ try {
604
+ o && !o.done && (i = a.return) && i.call(a);
605
+ } finally {
606
+ if (e) throw e.error;
607
+ }
608
+ }
609
+ t.type === "message" && this.onmessage(t);
610
+ }, r.prototype.onopen = function(t) {
611
+ }, r.prototype.onerror = function(t) {
612
+ }, r.prototype.onmessage = function(t) {
613
+ }, r.prototype.close = function() {
614
+ this._timer && (clearTimeout(this._timer), this._timer = null), this._eventSource && (this._eventSource.close(), this._eventSource = null), this.readyState = 2;
615
+ }, r.prototype.addEventListener = function(t, e, i) {
616
+ this._listeners[t] == null && (this._listeners[t] = [], this._eventSource != null && this._eventSource.addEventListener(t, this._onevent_wrapped));
617
+ var n = this._listeners[t];
618
+ n.includes(e) || (this._listeners[t] = fe(fe([], $e(n), !1), [e], !1));
619
+ }, r.prototype.removeEventListener = function(t, e, i) {
620
+ var n = this._listeners[t];
621
+ this._listeners[t] = n.filter(function(a) {
622
+ return a !== e;
623
+ });
624
+ }, r;
625
+ }();
626
+ globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
627
+ var We = function(r, t) {
628
+ return t = t || {}, new Promise(function(e, i) {
629
+ var n = new XMLHttpRequest(), a = [], o = [], v = {}, d = function() {
630
+ return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
631
+ return Promise.resolve(n.responseText);
632
+ }, json: function() {
633
+ return Promise.resolve(n.responseText).then(JSON.parse);
634
+ }, blob: function() {
635
+ return Promise.resolve(new Blob([n.response]));
636
+ }, clone: d, headers: { keys: function() {
637
+ return a;
638
+ }, entries: function() {
639
+ return o;
640
+ }, get: function(u) {
641
+ return v[u.toLowerCase()];
642
+ }, has: function(u) {
643
+ return u.toLowerCase() in v;
644
+ } } };
645
+ };
646
+ for (var p in n.open(t.method || "get", r, !0), n.onload = function() {
647
+ n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(u, y, O) {
648
+ a.push(y = y.toLowerCase()), o.push([y, O]), v[y] = v[y] ? v[y] + "," + O : O;
649
+ }), e(d());
650
+ }, n.onerror = i, n.withCredentials = t.credentials == "include", t.headers) n.setRequestHeader(p, t.headers[p]);
651
+ n.send(t.body || null);
652
+ });
653
+ }, Ye = ze({ AsyncStorage: f, fetch: We, eventSource: Xe });
654
+ typeof window < "u" && (window.flagsmith = Ye), h.createFlagsmithInstance = function() {
655
+ return ze({ AsyncStorage: f, fetch: We, eventSource: Xe });
656
+ }, h.default = Ye, Object.defineProperty(h, "__esModule", { value: !0 });
657
+ });
658
+ })(Ve, Ve.exports);
659
+ var pt = Ve.exports, yt = {
660
+ NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first.",
661
+ INVALID_CONFIG: "Invalid Flagsmith configuration",
662
+ FETCH_FAILED: "Failed to fetch Flagsmith configuration",
663
+ NO_USER_CONTEXT: "User context not set. Call setUser() first.",
664
+ ALREADY_INITIALIZED: "FeatureFlag is already initialized."
665
+ }, ot = "business", B, mt = (B = class {
666
+ constructor() {
667
+ ce(this, "flagsmithClient", null);
668
+ ce(this, "userContext", null);
669
+ }
670
+ static getInstance() {
671
+ return B.instance || (B.instance = new B()), B.instance;
672
+ }
673
+ ensureInitialized() {
674
+ if (!this.flagsmithClient)
675
+ throw new Error(yt.NOT_INITIALIZED);
676
+ }
677
+ async init(c, h = []) {
678
+ if (!this.flagsmithClient)
679
+ try {
680
+ this.flagsmithClient = pt.createFlagsmithInstance();
681
+ const f = h.reduce((s, R) => (s[R.feature.name] = R, s), {});
682
+ await this.flagsmithClient.init({
683
+ environmentID: c.apiKey,
684
+ api: (c == null ? void 0 : c.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
685
+ enableAnalytics: (c == null ? void 0 : c.enableAnalytics) ?? !0,
686
+ defaultFlags: f,
687
+ cacheFlags: (c == null ? void 0 : c.cacheFlags) ?? !0
688
+ });
689
+ } catch (f) {
690
+ throw console.error("Failed to initialize FeatureFlag:", f), f;
691
+ }
692
+ }
693
+ async setUser(c) {
694
+ this.ensureInitialized(), this.userContext = { identifier: c }, await this.updateContext();
695
+ }
696
+ async updateContext() {
697
+ try {
698
+ if (!this.userContext) return;
699
+ await this.flagsmithClient.setContext({
700
+ identity: {
701
+ identifier: this.userContext.identifier
702
+ }
703
+ });
704
+ } catch (c) {
705
+ throw console.error("Failed to update user context:", c), c;
706
+ }
707
+ }
708
+ async getFlags() {
709
+ this.ensureInitialized();
710
+ const c = this.flagsmithClient.getAllFlags();
711
+ return Object.entries(c).map(([h, f]) => {
712
+ var s;
713
+ return {
714
+ feature: {
715
+ name: h,
716
+ id: (f == null ? void 0 : f.id) ?? 0
717
+ },
718
+ enabled: f.enabled,
719
+ value: ((s = f.value) == null ? void 0 : s.toString()) ?? null
720
+ };
721
+ });
722
+ }
723
+ getFlagValue(c, h) {
724
+ this.ensureInitialized();
725
+ const f = this.flagsmithClient.getValue(c);
726
+ if (f == null)
727
+ return null;
728
+ try {
729
+ const s = f.toString();
730
+ return h ? h(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
731
+ } catch (s) {
732
+ return console.error("Error transforming flag value:", s), null;
733
+ }
734
+ }
735
+ getFlag(c) {
736
+ this.ensureInitialized();
737
+ const h = this.flagsmithClient.getValue(c);
738
+ if (h == null) return null;
739
+ const f = this.flagsmithClient.hasFeature(c);
740
+ return {
741
+ feature: {
742
+ name: c,
743
+ id: 0
744
+ },
745
+ enabled: f,
746
+ value: h.toString()
747
+ };
748
+ }
749
+ async getUserFlagValue(c, h, f = null, s) {
750
+ var K;
751
+ const R = this.userContext;
752
+ try {
753
+ return await this.setUser(c), this.getFlagValue(h, s) ?? f;
754
+ } catch (F) {
755
+ return console.error(`Error getting user flag value for ${h}:`, F), f;
756
+ } finally {
757
+ try {
758
+ await ((K = this.flagsmithClient) == null ? void 0 : K.logout()), this.userContext = null, R && await this.setUser(R.identifier);
759
+ } catch (F) {
760
+ console.error("Error during cleanup:", F);
761
+ }
762
+ }
763
+ }
764
+ reset() {
765
+ this.flagsmithClient = null, this.userContext = null;
766
+ }
767
+ }, ce(B, "instance"), B), bt = mt.getInstance(), se = he(!1), de = he([]), ne = he(null);
768
+ function St(l = bt) {
769
+ const c = () => se.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), h = async (g, b = []) => {
770
+ if (se.value) {
771
+ console.warn("FeatureFlag is already initialized.");
772
+ return;
773
+ }
774
+ try {
775
+ await l.init(g, b), de.value = await l.getFlags(), se.value = !0, ne.value = null;
776
+ } catch (w) {
777
+ console.error("Failed to initialize feature flags:", w), ne.value = w;
778
+ }
779
+ }, f = async (g) => {
780
+ if (c())
781
+ try {
782
+ await l.setUser(g), de.value = await l.getFlags(), ne.value = null;
783
+ } catch (b) {
784
+ console.error("Failed to set user:", b), ne.value = b;
785
+ }
786
+ }, s = async (g) => f(`${ot}-${g}`), R = (g, b, w = null) => {
787
+ if (!c()) return w;
788
+ try {
789
+ return l.getFlagValue(g, b) ?? w;
790
+ } catch (I) {
791
+ return console.error(`Error getting flag value for ${g}:`, I), w;
792
+ }
793
+ }, K = (g, b) => {
794
+ if (!c()) return b ?? null;
795
+ try {
796
+ return l.getFlag(g) ?? b ?? null;
797
+ } catch (w) {
798
+ return console.error(`Error getting flag for ${g}:`, w), b ?? null;
799
+ }
800
+ }, F = async (g, b, w = null, I) => {
801
+ if (!c()) return w;
802
+ try {
803
+ return await l.getUserFlagValue(g, b, w, I);
804
+ } catch ($) {
805
+ return console.error(`Error getting user flag value for ${b}:`, $), w;
806
+ }
807
+ }, W = async (g, b, w = null, I) => F(`${ot}-${g}`, b, w, I), E = () => {
808
+ try {
809
+ l.reset();
810
+ } catch (g) {
811
+ console.error("Error resetting feature flags:", g);
812
+ } finally {
813
+ de.value = [], se.value = !1, ne.value = null;
814
+ }
815
+ };
816
+ return {
817
+ flags: Ge(de),
818
+ isInitialized: Ge(se),
819
+ error: Ge(ne),
820
+ init: h,
821
+ setUser: f,
822
+ setBusiness: s,
823
+ getFlagValue: R,
824
+ getFlag: K,
825
+ getUserFlagValue: F,
826
+ getBusinessFlagValue: W,
827
+ reset: E
828
+ };
829
+ }
830
+ var st = () => St(), S = /* @__PURE__ */ ((l) => (l.inventory_portal_must_use_transfer_template = "inventory_portal_must_use_transfer_template", l.inventory_portal_use_iframe = "inventory_portal_use_iframe", l.inventory_pos_adjust_v1 = "inventory_pos_adjust_v1", l.inventory_pos_adjust_v2_wastage = "inventory_pos_adjust_v2_wastage", l.inventory_pos_closing_recalculation = "inventory_pos_closing_recalculation", l.inventory_pos_closing_v1 = "inventory_pos_closing_v1", l.inventory_pos_closing_v2 = "inventory_pos_closing_v2", l.inventory_pos_convert_v1 = "inventory_pos_convert_v1", l.inventory_pos_costing = "inventory_pos_costing", l.inventory_pos_stock_return = "inventory_pos_stock_return", l.inventory_pos_transfer_require_fulfillment = "inventory_pos_transfer_require_fulfillment", l.inventory_purchase_order_approval = "inventory_purchase_order_approval", l.inventory_portal_xilnex_transfer_note = "inventory_portal_xilnex_transfer_note", l.inventory_portal_custom_attribute = "inventory_portal_custom_attribute", l.inventory_portal_purchase_order_v2 = "inventory_portal_purchase_order_v2", l.inventory_portal_accept_require_fulfillment = "inventory_portal_accept_require_fulfillment", l.inventory_portal_po_operate_v2 = "inventory_portal_po_operate_v2", l.inventory_pos_allow_receive_order = "inventory_pos_allow_receive_order", l.inventory_xilnex_opening_migration = "inventory_xilnex_opening_migration", l.inventory_ingredient_group = "inventory_ingredient_group", l.inventory_purchase_order_backdate = "inventory_purchase_order_backdate", l.inventory_synergy_opening_migration = "inventory_synergy_opening_migration", l.inventory_netsuite_inventory_transfer_out = "inventory_netsuite_inventory_transfer_out", l.inventory_portal_supplier_preparation_time = "inventory_portal_supplier_preparation_time", l.inventory_backdate_receive = "inventory_backdate_receive", l.inventory_portal_delivery_order_write = "inventory_portal_delivery_order_write", l.inventory_purchase_order_custom_cost = "inventory_purchase_order_custom_cost", l.inventory_bulk_import = "inventory_bulk_import", l.inventory_portal_surcharge = "inventory_portal_surcharge", l.inventory_purchase_order_cost_edit = "inventory_purchase_order_cost_edit", l.inventory_purchase_order_workflow_allow_to_mark_completed = "inventory_purchase_order_workflow_allow_to_mark_completed", l.inventory_recipe_v2 = "inventory_recipe_v2", l.inventory_print_template = "inventory_print_template", l))(S || {});
831
+ const Ct = /* @__PURE__ */ new Set([
832
+ // vivo pizza prod
833
+ "business_6687e91fa7240b001ba3f4c2",
834
+ // vivo dev
835
+ "business_669a1d2efc050a001cfbb5a2"
836
+ ]), xt = /* @__PURE__ */ new Set([
837
+ // zus dev
838
+ "business_671005de24a7f4001c87e25e",
839
+ // zus prod
840
+ "business_6776a1fe205a52001c516efa"
841
+ ]);
842
+ function lt() {
843
+ return {
844
+ isLoaded: !1,
845
+ autoReceiveWarehouse: !1,
846
+ businessSupplierOnly: !1,
847
+ enableBackdatePo: !1,
848
+ enableClosingTemplate: !1,
849
+ enableIngredientGroup: !1,
850
+ enablePoTemplate: !1,
851
+ enableTotalCost: !1,
852
+ enableWastageTemplate: !1,
853
+ manualReceive: !1,
854
+ mustUseDefaultCost: !1,
855
+ mustUsePoTemplate: !1,
856
+ enableXilnexTransferNote: !1,
857
+ enableCustomAttribute: !1,
858
+ usePurchaseOrderV2: !1,
859
+ acceptRequireFulfillment: !1,
860
+ useOperatePurchaseOrderV2: !1,
861
+ inventory_xilnex_opening_migration: !1,
862
+ inventory_synergy_opening_migration: !1,
863
+ inventory_netsuite_inventory_transfer_out: !1,
864
+ inventory_portal_supplier_preparation_time: !1,
865
+ inventory_portal_delivery_order_write: !1,
866
+ inventory_pos_transfer_require_fulfillment: !1,
867
+ inventory_backdate_receive: !1,
868
+ inventory_purchase_order_custom_cost: !1,
869
+ inventory_bulk_import: !1,
870
+ inventory_portal_surcharge: !1,
871
+ inventory_purchase_order_cost_edit: !1,
872
+ inventory_purchase_order_workflow_allow_to_mark_completed: !1,
873
+ inventory_recipe_v2: !1,
874
+ inventory_print_template: !1
875
+ };
876
+ }
877
+ const _ = he(lt()), kt = () => ({
878
+ get businessDbName() {
879
+ var h;
880
+ return `business_${((h = De().currentBusiness.value) == null ? void 0 : h._id) ?? ""}`;
881
+ },
882
+ get isWarehouse() {
883
+ var c;
884
+ return ((c = Ke()._currentLocation) == null ? void 0 : c.type) === at.enum.warehouse;
885
+ },
886
+ get restaurantPosVersion() {
887
+ var h;
888
+ const l = Ke();
889
+ return (h = De().restaurants.value.find(
890
+ (f) => {
891
+ var s;
892
+ return f._id === ((s = l._currentLocation) == null ? void 0 : s.doc._id);
893
+ }
894
+ )) == null ? void 0 : h.posVersion;
895
+ },
896
+ get enableTotalCost() {
897
+ return _.value.enableTotalCost;
898
+ },
899
+ get enableBackdatePo() {
900
+ return _.value.enableBackdatePo;
901
+ },
902
+ /** @deprecated TODO: remove */
903
+ get autoReceiveWarehouse() {
904
+ return _.value.autoReceiveWarehouse;
905
+ },
906
+ /** @deprecated TODO: remove */
907
+ get manualReceive() {
908
+ return _.value.manualReceive;
909
+ },
910
+ get isLoaded() {
911
+ return _.value.isLoaded;
912
+ },
913
+ get enablePoTemplate() {
914
+ return _.value.enablePoTemplate;
915
+ },
916
+ get enableClosingTemplate() {
917
+ return _.value.enableClosingTemplate;
918
+ },
919
+ get enableWastageTemplate() {
920
+ return _.value.enableWastageTemplate;
921
+ },
922
+ get enableIngredientGroup() {
923
+ return _.value.enableIngredientGroup;
924
+ },
925
+ get mustUsePoTemplate() {
926
+ return _.value.mustUsePoTemplate;
927
+ },
928
+ get businessSupplierOnly() {
929
+ return _.value.businessSupplierOnly;
930
+ },
931
+ get enableXilnexTransferNote() {
932
+ return _.value.enableXilnexTransferNote;
933
+ },
934
+ get enabledXilnexOpeningMigration() {
935
+ return _.value.inventory_xilnex_opening_migration;
936
+ },
937
+ get enabledSynergyOpeningMigration() {
938
+ return _.value.inventory_synergy_opening_migration;
939
+ },
940
+ get enableCustomAttribute() {
941
+ return _.value.enableCustomAttribute;
942
+ },
943
+ get usePurchaseOrderV2() {
944
+ return _.value.usePurchaseOrderV2;
945
+ },
946
+ get acceptRequireFulfillment() {
947
+ return _.value.acceptRequireFulfillment;
948
+ },
949
+ get useOperatePurchaseOrderV2() {
950
+ return _.value.useOperatePurchaseOrderV2;
951
+ },
952
+ get isNetSuiteInventoryTransferOutEnabled() {
953
+ return _.value.inventory_netsuite_inventory_transfer_out;
954
+ },
955
+ get enableSupplierPreparationTime() {
956
+ return _.value.inventory_portal_supplier_preparation_time;
957
+ },
958
+ get enablePortalDeliveryOrderWrite() {
959
+ return _.value.inventory_portal_delivery_order_write ?? !0;
960
+ },
961
+ get enablePOSTransferRequireFulfillment() {
962
+ return _.value.inventory_pos_transfer_require_fulfillment;
963
+ },
964
+ get enableBackdateReceive() {
965
+ return _.value.inventory_backdate_receive;
966
+ },
967
+ get enablePurchaseOrderReceiveWithCustomCost() {
968
+ return _.value.inventory_purchase_order_custom_cost;
969
+ },
970
+ get enableBulkImport() {
971
+ return _.value.inventory_bulk_import;
972
+ },
973
+ get enableSurcharge() {
974
+ return _.value.inventory_portal_surcharge;
975
+ },
976
+ get enablePurchaseOrderCostEdit() {
977
+ return _.value.inventory_purchase_order_cost_edit;
978
+ },
979
+ get poWorkflowAllowToMarkCompleted() {
980
+ return _.value.inventory_purchase_order_workflow_allow_to_mark_completed;
981
+ },
982
+ get enableRecipeV2() {
983
+ return _.value.inventory_recipe_v2;
984
+ },
985
+ get enablePrintTemplate() {
986
+ return _.value.inventory_print_template;
987
+ },
988
+ async init() {
989
+ const l = De(), { init: c, setBusiness: h } = st(), f = gt(), s = l.namespace.value === "prod";
990
+ await c({
991
+ apiKey: s ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee"
992
+ // url: 'https://flag.feedme.farm/api/v1/', // optional -> this is a default URL value
993
+ // enableAnalytics: true, // optional, defaults to true
994
+ // cacheFlags: true // optional, defaults to true
995
+ }), Ke().watchLocation(async (K) => {
996
+ var I, $, Y;
997
+ if (!K) {
998
+ _.value = lt();
999
+ return;
1000
+ }
1001
+ const F = ((I = l.currentBusiness.value) == null ? void 0 : I._id) ?? "";
1002
+ await h(F);
1003
+ const W = `business_${F}`, E = K.type === at.enum.warehouse, g = (
1004
+ // if menu v4, must manual receive && must use outlet app
1005
+ (($ = l.currentBusiness.value) == null ? void 0 : $.menuVersion) === "v4" && // more guard for businesses using menu v4, only those listed for manual receive will be included
1006
+ // TODO: may be removed to use menu version only
1007
+ Ct.has(this.businessDbName)
1008
+ ), b = xt.has(W) || x(S.inventory_portal_must_use_transfer_template), w = x(S.inventory_purchase_order_backdate) && (this.isWarehouse || f.state.closing !== null);
1009
+ _.value = {
1010
+ isLoaded: !0,
1011
+ enableTotalCost: ((Y = l.currentBusiness.value) == null ? void 0 : Y.menuVersion) === "v4",
1012
+ enableBackdatePo: w,
1013
+ autoReceiveWarehouse: E && !g,
1014
+ manualReceive: g,
1015
+ enablePoTemplate: b,
1016
+ enableClosingTemplate: x(S.inventory_pos_closing_v2),
1017
+ enableWastageTemplate: x(S.inventory_pos_adjust_v2_wastage),
1018
+ enableIngredientGroup: x(S.inventory_ingredient_group),
1019
+ mustUsePoTemplate: b,
1020
+ businessSupplierOnly: b,
1021
+ enableXilnexTransferNote: x(S.inventory_portal_xilnex_transfer_note),
1022
+ enableCustomAttribute: x(S.inventory_portal_custom_attribute),
1023
+ usePurchaseOrderV2: x(S.inventory_portal_purchase_order_v2),
1024
+ acceptRequireFulfillment: x(
1025
+ S.inventory_portal_accept_require_fulfillment
1026
+ ),
1027
+ useOperatePurchaseOrderV2: x(S.inventory_portal_po_operate_v2),
1028
+ inventory_xilnex_opening_migration: x(
1029
+ S.inventory_xilnex_opening_migration
1030
+ ),
1031
+ inventory_synergy_opening_migration: x(
1032
+ S.inventory_synergy_opening_migration
1033
+ ),
1034
+ inventory_netsuite_inventory_transfer_out: x(
1035
+ S.inventory_netsuite_inventory_transfer_out
1036
+ ),
1037
+ inventory_portal_supplier_preparation_time: x(
1038
+ S.inventory_portal_supplier_preparation_time
1039
+ ),
1040
+ inventory_portal_delivery_order_write: x(
1041
+ S.inventory_portal_delivery_order_write
1042
+ ),
1043
+ inventory_pos_transfer_require_fulfillment: x(
1044
+ S.inventory_pos_transfer_require_fulfillment
1045
+ ),
1046
+ inventory_backdate_receive: x(S.inventory_backdate_receive),
1047
+ inventory_purchase_order_custom_cost: x(
1048
+ S.inventory_purchase_order_custom_cost
1049
+ ),
1050
+ inventory_bulk_import: x(S.inventory_bulk_import),
1051
+ inventory_portal_surcharge: x(S.inventory_portal_surcharge),
1052
+ inventory_purchase_order_cost_edit: x(
1053
+ S.inventory_purchase_order_cost_edit
1054
+ ),
1055
+ inventory_purchase_order_workflow_allow_to_mark_completed: x(
1056
+ S.inventory_purchase_order_workflow_allow_to_mark_completed
1057
+ ),
1058
+ inventory_recipe_v2: x(S.inventory_recipe_v2),
1059
+ inventory_print_template: x(S.inventory_print_template)
1060
+ };
1061
+ }, "feature");
1062
+ },
1063
+ async awaitFeatureLoaded(l) {
1064
+ return new Promise((c) => {
1065
+ const h = () => {
1066
+ _.value.isLoaded ? c(l()) : setTimeout(h, 100);
1067
+ };
1068
+ h();
1069
+ });
1070
+ }
1071
+ });
1072
+ function x(l, c) {
1073
+ c = c === void 0 ? null : c;
1074
+ const { getFlagValue: h } = st();
1075
+ return h(l, (f) => f === "true") ?? c;
1076
+ }
1077
+ export {
1078
+ S as I,
1079
+ st as a,
1080
+ kt as u
1081
+ };