@feedmepos/mf-inventory-portal 0.0.23-dev.4 → 0.0.23-dev.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/{App-DReDvY0M.js → App-D8DXxTIq.js} +84 -72
  2. package/dist/{ApprovalView-BMZlYmRk.js → ApprovalView-BWGXkHV6.js} +25 -28
  3. package/dist/{BindingsDialog-Y2K4I7H7.js → BindingsDialog-D7WypDot.js} +6 -6
  4. package/dist/{BindingsPicker-DKBq9c37.js → BindingsPicker-DUlGwkwM.js} +8 -9
  5. package/dist/{BindingsTable-45v4SDfp.js → BindingsTable-BjeZYCaJ.js} +18 -22
  6. package/dist/ClosingDraftView-o2LEUfo8.js +1190 -0
  7. package/dist/{ClosingTemplateView-CKJVYSbj.js → ClosingTemplateView-Dt983Cg4.js} +271 -285
  8. package/dist/FmCustomAttribute.vue_vue_type_script_setup_true_lang-Dc_7IyBG.js +142 -0
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CMEOp-0r.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-wocPyZls.js} +18 -19
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-C1DjyjyH.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DzoEp-Pg.js} +25 -26
  11. package/dist/{IngredientGroupView-BuP-HGeg.js → IngredientGroupView-CIPpIpv1.js} +63 -69
  12. package/dist/IngredientsView-CFV3kX7Q.js +1707 -0
  13. package/dist/{IntegrationView-kYCaKG0o.js → IntegrationView-DkW32m-t.js} +89 -92
  14. package/dist/{InventoryBindingForm-BXHq4h-n.js → InventoryBindingForm-B4CBet9W.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CVxJ_bV3.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DpdDVf6O.js} +112 -104
  16. package/dist/{InventoryBindingSummary-Bjasfc_v.js → InventoryBindingSummary-75ImZtqK.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DM0C4raP.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DfpG3Fy8.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-C3O3JebE.js → PremiumBadge.vue_vue_type_script_setup_true_lang-B4d0c3nk.js} +19 -20
  19. package/dist/{PurchaseOrderPrintPreview-CmjkfTTS.js → PurchaseOrderPrintPreview-BYO0JcQW.js} +17 -18
  20. package/dist/ReceiveRequestView-cFLNExw9.js +4194 -0
  21. package/dist/RecipeView-CjfpaHaT.js +609 -0
  22. package/dist/StockView-HMtD9qar.js +1818 -0
  23. package/dist/{SupplierView-DAx7E7sR.js → SupplierView-Cidfe-Xm.js} +2325 -787
  24. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CdU3HPBC.js +1275 -0
  25. package/dist/TransferTemplateView-Doxr1fXP.js +1264 -0
  26. package/dist/{UnitView-CQPGZ8-r.js → UnitView-C1af71aM.js} +228 -227
  27. package/dist/{WarehouseView-jy-RNCgy.js → WarehouseView-CviOLXfX.js} +100 -106
  28. package/dist/api/adjustment-template.d.ts +25 -0
  29. package/dist/api/bill.d.ts +240 -84
  30. package/dist/api/closing-draft.d.ts +6 -0
  31. package/dist/api/closing.d.ts +1 -0
  32. package/dist/api/inventory.d.ts +15 -6
  33. package/dist/api/netsuite.d.ts +3 -3
  34. package/dist/app-BE8SgDqI.js +84466 -0
  35. package/dist/app.d.ts +64 -0
  36. package/dist/app.js +2 -2
  37. package/dist/components/FmCustomAttribute.vue.d.ts +23 -0
  38. package/dist/components/FmLockableField.vue.d.ts +37 -0
  39. package/dist/components/FmMultiselectDialogProps.d.ts +1 -0
  40. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +3 -1
  41. package/dist/components/row-action.enum.d.ts +1 -0
  42. package/dist/components/shell/inventory/binding-ui.vue.d.ts +3 -1
  43. package/dist/composable/defineDeepModel.d.ts +1 -1
  44. package/dist/{decimal-BAc9M88Q.js → decimal-xj3kVOP6.js} +1 -1
  45. package/dist/feature-CWpNYcWJ.js +946 -0
  46. package/dist/format-unit-display-CZ835oaL.js +1215 -0
  47. package/dist/index-B8IWDKYv.js +29202 -0
  48. package/dist/{StockView-D9no-mrA.js → index-C6SzYqK7.js} +2242 -3986
  49. package/dist/router/name.d.ts +2 -0
  50. package/dist/stock-C2xyYnS7.js +125 -0
  51. package/dist/stores/feature.d.ts +6 -0
  52. package/dist/stores/integration/netsuite.d.ts +70 -2
  53. package/dist/stores/inventory.d.ts +21 -12
  54. package/dist/stores/supplier.d.ts +1 -1
  55. package/dist/style.css +1 -1
  56. package/dist/{supplier-DJC0UZWv.js → supplier-B-7o9hg1.js} +15 -15
  57. package/dist/tsconfig.app.tsbuildinfo +1 -1
  58. package/dist/{use-inventory-binding-dialog-PEQbFRvO.js → use-inventory-binding-dialog-Dm8Ky1MH.js} +10 -11
  59. package/dist/views/adjustment-template/import/AdjustmentTemplateImport.vue.d.ts +2 -0
  60. package/dist/views/adjustment-template/import/AdjustmentTemplateImportItem.vue.d.ts +18 -0
  61. package/dist/views/adjustment-template/import/export.d.ts +60 -0
  62. package/dist/views/adjustment-template/wastage-template/WastageTemplateDetails.vue.d.ts +2 -0
  63. package/dist/views/adjustment-template/wastage-template/WastageTemplateDialog.vue.d.ts +22 -0
  64. package/dist/views/adjustment-template/wastage-template/WastageTemplatePublish.vue.d.ts +6 -0
  65. package/dist/views/adjustment-template/wastage-template/WastageTemplateReason.vue.d.ts +18 -0
  66. package/dist/views/adjustment-template/wastage-template/WastageTemplateView.vue.d.ts +2 -0
  67. package/dist/views/adjustment-template/wastage-template/actions.d.ts +1329 -0
  68. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateForm.vue.d.ts +16 -0
  69. package/dist/views/adjustment-template/wastage-template/form/WastageTemplateItemTable.vue.d.ts +35 -0
  70. package/dist/views/adjustment-template/wastage-template/form/useAdjustmentTemplateItems.d.ts +20 -0
  71. package/dist/views/adjustment-template/wastage-template/props.d.ts +36 -0
  72. package/dist/views/adjustment-template/wastage-template/table.d.ts +1303 -0
  73. package/dist/views/closing-draft/ClosingDraftView.vue.d.ts +2 -0
  74. package/dist/views/closing-draft/components/closing-draft-action/ClosingDraftAction.vue.d.ts +22 -0
  75. package/dist/views/closing-draft/components/closing-draft-dialog/ClosingDraftDialog.vue.d.ts +625 -0
  76. package/dist/views/closing-draft/composables/use-closing-draft-actions.d.ts +25 -0
  77. package/dist/views/closing-draft/composables/use-closing-draft-table.d.ts +3645 -0
  78. package/dist/views/closing-draft/helpers/draft-status-to-class-name.helper.d.ts +1 -0
  79. package/dist/views/closing-draft/helpers/export-draft.helper.d.ts +19 -0
  80. package/dist/views/closing-draft/helpers/get-calculated-total.helper.d.ts +4 -0
  81. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +2 -1
  82. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +48 -204
  83. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +49 -205
  84. package/dist/views/ingredient-group/composables/use-ingredient-group-table.d.ts +6 -3
  85. package/dist/views/ingredients/components/convert/ConvertFormProps.d.ts +1 -0
  86. package/dist/views/ingredients/components/ingredient-form/IngredientForm.vue.d.ts +4 -2
  87. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +1 -0
  88. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +2 -1
  89. package/dist/views/receive-request/components/netsuite/NetSuiteInfo.vue.d.ts +12 -0
  90. package/dist/views/receive-request/components/netsuite/NetSuiteProps.d.ts +13 -0
  91. package/dist/views/receive-request/components/netsuite/NetSuiteSync.vue.d.ts +12 -0
  92. package/dist/views/receive-request/components/transfer-form/NetSuiteField.vue.d.ts +2 -0
  93. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +1 -1
  94. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +40 -17
  95. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +4 -2
  96. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +2 -1
  97. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +57 -24
  98. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +57 -24
  99. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +2 -0
  100. package/dist/views/stock/components/StockRecordCard.vue.d.ts +120 -42
  101. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +6 -4
  102. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  103. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +2 -1
  104. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +24 -12
  105. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +24 -12
  106. package/dist/views/transfer-template/helpers/import-export.helper.d.ts +2 -1
  107. package/package.json +5 -4
  108. package/dist/FmDroppableField-8RzKjEdL.js +0 -154
  109. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BhdcqRh-.js +0 -436
  110. package/dist/FmMultiselectDialog-D7YtdoyJ.js +0 -415
  111. package/dist/IngredientBindedItem.vue_vue_type_script_setup_true_lang-zjvFEF5C.js +0 -51
  112. package/dist/IngredientsView-DMRN-odY.js +0 -1613
  113. package/dist/ReceiveRequestView-aQZJO8sq.js +0 -4165
  114. package/dist/RecipeView-DXO43tFi.js +0 -597
  115. package/dist/TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js +0 -135
  116. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DCA0RUfu.js +0 -1209
  117. package/dist/TransferTemplateView-CfxdQF1t.js +0 -1261
  118. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +0 -9
  119. package/dist/app-KnSMkJBV.js +0 -33496
  120. package/dist/date2-CIeUqUIc.js +0 -117
  121. package/dist/dayjs.min-Df5jSnDJ.js +0 -282
  122. package/dist/defineDeepModel-BfuQAIoM.js +0 -13
  123. package/dist/feature-dwB4OxRQ.js +0 -86
  124. package/dist/format-time-from-id-BbvzyIN6.js +0 -15
  125. package/dist/format-unit-display-BBWblJEt.js +0 -1216
  126. package/dist/fuzzy-B9ryZ9VZ.js +0 -41
  127. package/dist/index-BN0CY3sZ.js +0 -22277
  128. package/dist/index-Bj1fJum-.js +0 -45
  129. package/dist/index-C4yL_7rR.js +0 -10545
  130. package/dist/netsuite-ByWOS6tI.js +0 -194
  131. package/dist/normalizeArguments-DP7Hrren.js +0 -1552
  132. package/dist/row-action.enum-PMKMRrZR.js +0 -50
  133. package/dist/rules-C12nWDD1.js +0 -198
  134. package/dist/use-template-enabled-locations-2-k9g5t8tt.js +0 -86
  135. package/dist/xlsx-B4XHad7S.js +0 -24004
  136. package/dist/xlsx.util-BSO4SHJi.js +0 -78
@@ -0,0 +1,946 @@
1
+ var ue = Object.defineProperty;
2
+ var ce = (v, l, d) => l in v ? ue(v, l, { enumerable: !0, configurable: !0, writable: !0, value: d }) : v[l] = d;
3
+ var ut = (v, l, d) => ce(v, typeof l != "symbol" ? l + "" : l, d);
4
+ import { useCoreStore as B } from "@feedmepos/mf-common";
5
+ import { aI as ct, u as ee, aB as he, a as ve } from "./app-BE8SgDqI.js";
6
+ import { ref as Ut, readonly as kt } from "vue";
7
+ var Rt = { exports: {} };
8
+ (function(v, l) {
9
+ (function(d, g) {
10
+ g(l);
11
+ })(ct, function(d) {
12
+ var g = { getItemSync: function(a) {
13
+ try {
14
+ return localStorage.getItem(a) || null;
15
+ } catch {
16
+ return null;
17
+ }
18
+ }, getItem: function(a, e) {
19
+ var t = this;
20
+ return new Promise(function(i, n) {
21
+ try {
22
+ var r = t.getItemSync(a);
23
+ e == null || e(null, r), i(r);
24
+ } catch (o) {
25
+ e && e(o, null), n(o);
26
+ }
27
+ });
28
+ }, setItem: function(a, e, t) {
29
+ return new Promise(function(i, n) {
30
+ try {
31
+ localStorage.setItem(a, e), t && t(null, e), i(e);
32
+ } catch (r) {
33
+ t && t(r, null), n(r);
34
+ }
35
+ });
36
+ } }, s = function() {
37
+ return s = Object.assign || function(a) {
38
+ for (var e, t = 1, i = arguments.length; t < i; t++) for (var n in e = arguments[t]) Object.prototype.hasOwnProperty.call(e, n) && (a[n] = e[n]);
39
+ return a;
40
+ }, s.apply(this, arguments);
41
+ };
42
+ function T(a, e, t, i) {
43
+ return new (t || (t = Promise))(function(n, r) {
44
+ function o(f) {
45
+ try {
46
+ h(i.next(f));
47
+ } catch (u) {
48
+ r(u);
49
+ }
50
+ }
51
+ function c(f) {
52
+ try {
53
+ h(i.throw(f));
54
+ } catch (u) {
55
+ r(u);
56
+ }
57
+ }
58
+ function h(f) {
59
+ var u;
60
+ f.done ? n(f.value) : (u = f.value, u instanceof t ? u : new t(function(p) {
61
+ p(u);
62
+ })).then(o, c);
63
+ }
64
+ h((i = i.apply(a, [])).next());
65
+ });
66
+ }
67
+ function $(a, e) {
68
+ var t, i, n, r, o = { label: 0, sent: function() {
69
+ if (1 & n[0]) throw n[1];
70
+ return n[1];
71
+ }, trys: [], ops: [] };
72
+ return r = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (r[Symbol.iterator] = function() {
73
+ return this;
74
+ }), r;
75
+ function c(h) {
76
+ return function(f) {
77
+ return function(u) {
78
+ if (t) throw new TypeError("Generator is already executing.");
79
+ for (; o; ) try {
80
+ if (t = 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;
81
+ switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) {
82
+ case 0:
83
+ case 1:
84
+ n = u;
85
+ break;
86
+ case 4:
87
+ return o.label++, { value: u[1], done: !1 };
88
+ case 5:
89
+ o.label++, i = u[1], u = [0];
90
+ continue;
91
+ case 7:
92
+ u = o.ops.pop(), o.trys.pop();
93
+ continue;
94
+ default:
95
+ if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
96
+ o = 0;
97
+ continue;
98
+ }
99
+ if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) {
100
+ o.label = u[1];
101
+ break;
102
+ }
103
+ if (u[0] === 6 && o.label < n[1]) {
104
+ o.label = n[1], n = u;
105
+ break;
106
+ }
107
+ if (n && o.label < n[2]) {
108
+ o.label = n[2], o.ops.push(u);
109
+ break;
110
+ }
111
+ n[2] && o.ops.pop(), o.trys.pop();
112
+ continue;
113
+ }
114
+ u = e.call(a, o);
115
+ } catch (p) {
116
+ u = [6, p], i = 0;
117
+ } finally {
118
+ t = n = 0;
119
+ }
120
+ if (5 & u[0]) throw u[1];
121
+ return { value: u[0] ? u[1] : void 0, done: !0 };
122
+ }([h, f]);
123
+ };
124
+ }
125
+ }
126
+ function V(a, e, t) {
127
+ for (var i, n = 0, r = e.length; n < r; n++) !i && n in e || (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
128
+ return a.concat(i || Array.prototype.slice.call(e));
129
+ }
130
+ var W = function a(e, t) {
131
+ if (e === t) return !0;
132
+ if (e && t && typeof e == "object" && typeof t == "object") {
133
+ if (e.constructor !== t.constructor) return !1;
134
+ var i, n, r;
135
+ if (Array.isArray(e)) {
136
+ if ((i = e.length) != t.length) return !1;
137
+ for (n = i; n-- != 0; ) if (!a(e[n], t[n])) return !1;
138
+ return !0;
139
+ }
140
+ if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
141
+ if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
142
+ if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
143
+ if ((i = (r = Object.keys(e)).length) !== Object.keys(t).length) return !1;
144
+ for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(t, r[n])) return !1;
145
+ for (n = i; n-- != 0; ) {
146
+ var o = r[n];
147
+ if (!a(e[o], t[o])) return !1;
148
+ }
149
+ return !0;
150
+ }
151
+ return e != e && t != t;
152
+ };
153
+ function _(a, e) {
154
+ var t = Object.keys(e || {}).filter(function(i) {
155
+ var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
156
+ return !W(n, r);
157
+ });
158
+ return Object.keys(a || {}).filter(function(i) {
159
+ Object.keys(e || {}).includes(i) || t.push(i);
160
+ }), Object.keys(t).length ? t : null;
161
+ }
162
+ var O, m;
163
+ function b(a, e, t) {
164
+ var i = "shortString", n = !0;
165
+ typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
166
+ }
167
+ function C(a) {
168
+ return !!a && typeof a == "object" && a.value !== void 0;
169
+ }
170
+ function J(a) {
171
+ return Object.fromEntries(Object.entries(a).map(function(e) {
172
+ var t = e[0], i = e[1];
173
+ return [t, C(i) ? i : { value: i }];
174
+ }));
175
+ }
176
+ function tt(a) {
177
+ return s(s({}, a), { identity: a.identity ? s(s({}, a.identity), { traits: J(a.identity.traits || {}) }) : void 0 });
178
+ }
179
+ (function(a) {
180
+ a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
181
+ })(O || (O = {}));
182
+ var ht, w = null, ae = "FLAGSMITH_EVENT", st = ae, Dt = "https://edge.api.flagsmith.com/api/v1/", Kt = "flagsmith_value_", Gt = "flagsmith_enabled_", Vt = "flagsmith_trait_", re = function() {
183
+ function a(e) {
184
+ var t = this;
185
+ this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
186
+ var i = t, n = i.api, r = i.evaluationContext;
187
+ t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(s(s({}, t.loadingState), { isFetching: !0 }));
188
+ var o = "".concat(t.getContext().identity), c = function(h) {
189
+ var f, u, p, E;
190
+ if (h && o === "".concat(t.getContext().identity)) {
191
+ var k = h.flags, I = h.traits, N = h.identifier;
192
+ t.isLoading = !1;
193
+ var L = {}, A = {};
194
+ I = I || [], (k = k || []).forEach(function(y) {
195
+ L[y.feature.name.toLowerCase().replace(/ /g, "_")] = { id: y.feature.id, enabled: y.enabled, value: y.feature_state_value };
196
+ }), I.forEach(function(y) {
197
+ A[y.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: y.transient, value: y.trait_value };
198
+ }), t.oldFlags = s({}, t.flags);
199
+ var R = _(t.oldFlags, L), et = _((f = t.evaluationContext.identity) === null || f === void 0 ? void 0 : f.traits, A);
200
+ if ((N || Object.keys(A).length) && (t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: A }), N && (t.evaluationContext.identity.identifier = N)), t.flags = L, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: R, traitsChanged: et }, t._loadedState(null, O.SERVER)), t.datadogRum) try {
201
+ if (t.datadogRum.trackTraits) {
202
+ var nt = {};
203
+ Object.keys(((u = t.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(y) {
204
+ nt[Vt + y] = t.getTrait(y);
205
+ });
206
+ var X = s(s(s({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((p = t.evaluationContext.identity) === null || p === void 0 ? void 0 : p.identifier) }), nt);
207
+ t.log("Setting Datadog user", X), t.datadogRum.client.setUser(X);
208
+ }
209
+ } catch (y) {
210
+ console.error(y);
211
+ }
212
+ if (t.dtrum) try {
213
+ var F = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
214
+ Object.keys(t.flags).map(function(y) {
215
+ b(F, Kt + y, t.getValue(y, { skipAnalytics: !0 })), b(F, Gt + y, t.hasFeature(y, { skipAnalytics: !0 }));
216
+ }), Object.keys(((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.traits) || {}).map(function(y) {
217
+ b(F, Vt + y, t.getTrait(y));
218
+ }), t.log("Sending javaLongOrObject traits to dynatrace", F.javaLongOrObject), t.log("Sending date traits to dynatrace", F.date), t.log("Sending shortString traits to dynatrace", F.shortString), t.log("Sending javaDouble to dynatrace", F.javaDouble), t.dtrum.sendSessionProperties(F.javaLongOrObject, F.date, F.shortString, F.javaDouble);
219
+ } catch (y) {
220
+ console.error(y);
221
+ }
222
+ }
223
+ };
224
+ return r.identity ? Promise.all([r.identity.traits && Object.keys(r.identity.traits).length || !r.identity.identifier ? t.getJSON(n + "identities/", "POST", JSON.stringify({ identifier: r.identity.identifier, transient: r.identity.transient, traits: Object.entries(r.identity.traits).map(function(h) {
225
+ var f = h[0], u = h[1];
226
+ return { trait_key: f, trait_value: u == null ? void 0 : u.value, transient: u == null ? void 0 : u.transient };
227
+ }).filter(function(h) {
228
+ return h.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", h.trait_key), !1);
229
+ }) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(h) {
230
+ return t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: {} }), c(h == null ? void 0 : h[0]);
231
+ }).catch(function(h) {
232
+ var f = h.message, u = new Error(f);
233
+ return Promise.reject(u);
234
+ }) : t.getJSON(n + "flags/").then(function(h) {
235
+ return c({ flags: h, traits: void 0 });
236
+ });
237
+ }, this.analyticsFlags = function() {
238
+ var i = t.api;
239
+ if (t.evaluationEvent && t.evaluationContext.environment && t.evaluationEvent[t.evaluationContext.environment.apiKey]) return t.evaluationEvent && Object.getOwnPropertyNames(t.evaluationEvent).length !== 0 && Object.getOwnPropertyNames(t.evaluationEvent[t.evaluationContext.environment.apiKey]).length !== 0 ? t.getJSON(i + "analytics/flags/", "POST", JSON.stringify(t.evaluationEvent[t.evaluationContext.environment.apiKey])).then(function(n) {
240
+ if (t.evaluationContext.environment) {
241
+ var r = t.getState();
242
+ t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(s(s({}, r), { evaluationEvent: t.evaluationEvent })), t.updateEventStorage();
243
+ }
244
+ }).catch(function(n) {
245
+ t.log("Exception fetching evaluationEvent", n);
246
+ }) : void 0;
247
+ }, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: O.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, r) {
248
+ var o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = null;
249
+ if (o && (c = o.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), c === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
250
+ if (n != null && n.json) try {
251
+ return c === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(c);
252
+ } catch {
253
+ return n.fallback;
254
+ }
255
+ return c;
256
+ }, this.getTrait = function(i) {
257
+ var n, r;
258
+ return ((n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((r = t.evaluationContext.identity.traits[i.toLowerCase().replace(/ /g, "_")]) === null || r === void 0 ? void 0 : r.value);
259
+ }, this.getAllTraits = function() {
260
+ var i;
261
+ return Object.fromEntries(Object.entries(((i = t.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
262
+ var r = n[0], o = n[1];
263
+ return [r, o == null ? void 0 : o.value];
264
+ }));
265
+ }, this.setContext = function(i) {
266
+ var n = tt(i);
267
+ return t.evaluationContext = s(s({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
268
+ }, this.getContext = function() {
269
+ return t.evaluationContext;
270
+ }, this.updateContext = function(i) {
271
+ return t.setContext(s(s({}, t.getContext()), i));
272
+ }, this.setTrait = function(i, n) {
273
+ var r;
274
+ if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (r = t.evaluationContext.identity) === null || r === void 0 ? void 0 : r.traits), J(Object.fromEntries([[i, n]]))) }) }));
275
+ }, this.setTraits = function(i) {
276
+ var n;
277
+ if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
278
+ var o = r[0], c = r[1];
279
+ return [o, C(c) ? c : { value: c }];
280
+ }))) }) }));
281
+ 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.");
282
+ }, this.hasFeature = function(i, n) {
283
+ var r = typeof n == "object", o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = !1;
284
+ return !o && r && n.fallback !== void 0 ? c = n == null ? void 0 : n.fallback : o && o.enabled && (c = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), c;
285
+ }, this.getStorageKey = function() {
286
+ var i, n;
287
+ return ((i = t.cacheOptions) === null || i === void 0 ? void 0 : i.storageKey) || "FLAGSMITH_DB_" + ((n = t.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
288
+ }, this.getJSON = function(i, n, r) {
289
+ var o, c = t;
290
+ c.evaluationContext;
291
+ var h = c.headers, f = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
292
+ t.evaluationContext.environment && (f.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (f.headers["Content-Type"] = "application/json; charset=utf-8"), h && Object.assign(f.headers, h), m || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
293
+ var u = "".concat((o = t.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
294
+ return m(i, f).then(function(p) {
295
+ var E, k, I = "".concat((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.identifier);
296
+ if (u === I) {
297
+ var N = (k = p.headers) === null || k === void 0 ? void 0 : k.get("x-flagsmith-document-updated-at");
298
+ if (N) try {
299
+ var L = parseFloat(N);
300
+ if (isNaN(L)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
301
+ t.timestamp = L;
302
+ } catch (A) {
303
+ t.log(A, "Failed to parse x-flagsmith-document-updated-at", N);
304
+ }
305
+ return t.log("Fetch response: " + p.status + " " + (n || "GET") + 0 + i), p.text().then(function(A) {
306
+ var R = A;
307
+ try {
308
+ R = JSON.parse(A);
309
+ } catch {
310
+ }
311
+ return !R && p.status && (R = "API Response: ".concat(p.status)), p.status && p.status >= 200 && p.status < 300 ? R : Promise.reject(new Error(R));
312
+ });
313
+ }
314
+ t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(u, ", Current: ").concat(I));
315
+ });
316
+ }, this.evaluateFlag = function(i, n) {
317
+ if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Kt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Gt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
318
+ if (!t.evaluationEvent || !t.evaluationContext.environment) return;
319
+ t.evaluationEvent[t.evaluationContext.environment.apiKey] || (t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] === void 0 && (t.evaluationEvent[t.evaluationContext.environment.apiKey][i] = 0), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] += 1;
320
+ }
321
+ t.updateEventStorage();
322
+ }, this._onChange = function(i, n, r) {
323
+ var o, c;
324
+ t.setLoadingState(r), (o = t.onChange) === null || o === void 0 || o.call(t, i, n, t.loadingState), (c = t._trigger) === null || c === void 0 || c.call(t);
325
+ }, m = e.fetch ? e.fetch : typeof fetch < "u" ? fetch : ct === null || ct === void 0 ? void 0 : ct.fetch, this.canUseStorage = typeof window < "u" || !!e.browserlessStorage, this.log("Constructing flagsmith instance " + e), e.eventSource && (ht = e.eventSource), e.AsyncStorage && (w = e.AsyncStorage);
326
+ }
327
+ return a.prototype.init = function(e) {
328
+ var t, i, n;
329
+ return T(this, void 0, void 0, function() {
330
+ var r, o, c, h, f, u, p, E, k, I, N, L, A, R, et, nt, X, F, y, dt, it, qt, Y, gt, Xt, Yt, ft, Zt, pt, at, Z, Qt, x = this;
331
+ return $(this, function(P) {
332
+ switch (P.label) {
333
+ case 0:
334
+ r = tt(e.evaluationContext || this.evaluationContext), P.label = 1;
335
+ case 1:
336
+ if (P.trys.push([1, 13, , 14]), o = e.environmentID, c = e.api, h = c === void 0 ? Dt : c, f = e.headers, u = e.onChange, p = e.cacheFlags, E = e.datadogRum, k = e.onError, I = e.defaultFlags, N = e.fetch, L = e.preventFetch, A = e.enableLogs, R = e.enableDynatrace, et = e.enableAnalytics, nt = e.realtime, X = e.eventSourceUrl, F = X === void 0 ? "https://realtime.flagsmith.com/" : X, y = e.AsyncStorage, dt = e.identity, it = e.traits, qt = e.state, Y = e.cacheOptions, gt = e.angularHttpClient, Xt = e._trigger, Yt = e._triggerLoadingState, r.environment = o ? { apiKey: o } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
337
+ if (r.identity = dt || it ? { identifier: dt, traits: it ? Object.fromEntries(Object.entries(it).map(function(j) {
338
+ return [j[0], { value: j[1] }];
339
+ })) : {} } : r.identity, this.evaluationContext = r, this.api = h, this.headers = f, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, ft = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Xt || this._trigger, this._triggerLoadingState = Yt || this._triggerLoadingState, this.onError = function(j) {
340
+ x.setLoadingState(s(s({}, x.loadingState), { isFetching: !1, isLoading: !1, error: j })), k == null || k(j);
341
+ }, this.enableLogs = A || !1, this.cacheOptions = Y ? { skipAPI: !!Y.skipAPI, ttl: Y.ttl || 0, storageKey: Y.storageKey, loadStale: !!Y.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."), N && (m = N), this.enableAnalytics = et || !1, this.flags = Object.assign({}, I) || {}, this.datadogRum = E || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = w !== void 0 && !!p, st = "FLAGSMITH_EVENT_" + r.environment.apiKey, y && (w = y), nt && typeof window < "u" && this.setupRealtime(F, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: O.DEFAULT_FLAGS })), this.setState(qt), this.log("Initialising with properties", e, this), R && (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), gt && (m = /* @__PURE__ */ function(j) {
342
+ return function(U, D) {
343
+ var z = D.headers, S = D.method, Q = D.body;
344
+ return new Promise(function(q) {
345
+ switch (S) {
346
+ case "GET":
347
+ return j.get(U, { headers: z }).subscribe(function(G) {
348
+ q({ ok: !0, text: function() {
349
+ return Promise.resolve(G);
350
+ } });
351
+ });
352
+ case "POST":
353
+ case "PUT":
354
+ return j.post(U, Q, { headers: z }).subscribe(function(G) {
355
+ q({ ok: !0, text: function() {
356
+ return Promise.resolve(G);
357
+ } });
358
+ });
359
+ }
360
+ });
361
+ };
362
+ }(gt)), w && this.canUseStorage && w.getItem(st).then(function(j) {
363
+ try {
364
+ x.evaluationEvent = JSON.parse(j) || {};
365
+ } catch {
366
+ x.evaluationEvent = {};
367
+ }
368
+ x.analyticsInterval = setInterval(x.analyticsFlags, x.ticks);
369
+ }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), w && this.canUseStorage && w.getItem(st, function(j, U) {
370
+ if (U && x.evaluationContext.environment) {
371
+ var D = JSON.parse(U);
372
+ if (D[x.evaluationContext.environment.apiKey]) {
373
+ var z = x.getState();
374
+ x.log("Retrieved events from cache", U), x.setState(s(s({}, z), { evaluationEvent: D[x.evaluationContext.environment.apiKey] }));
375
+ }
376
+ }
377
+ })), !p) return [3, 9];
378
+ if (!w || !this.canUseStorage) return [3, 8];
379
+ Zt = function(j, U) {
380
+ return T(x, void 0, void 0, function() {
381
+ var D, z, S, Q, q, G, yt, Wt, mt, St, bt, Ct, _t, Et, Ft, xt, wt, Ot, It, Lt, At, jt, Tt, Nt, te = this;
382
+ return $(this, function(M) {
383
+ switch (M.label) {
384
+ case 0:
385
+ if (!U) return [3, 7];
386
+ D = null, z = null, M.label = 1;
387
+ case 1:
388
+ return M.trys.push([1, 5, , 6]), S = JSON.parse(U), Q = !1, q = !1, S && S.api === this.api && ((St = (mt = S.evaluationContext) === null || mt === void 0 ? void 0 : mt.environment) === null || St === void 0 ? void 0 : St.apiKey) === ((bt = this.evaluationContext.environment) === null || bt === void 0 ? void 0 : bt.apiKey) && (G = !0, this.evaluationContext.identity && ((_t = (Ct = S.evaluationContext) === null || Ct === void 0 ? void 0 : Ct.identity) === null || _t === void 0 ? void 0 : _t.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((Ft = (Et = S.evaluationContext) === null || Et === void 0 ? void 0 : Et.identity) === null || Ft === void 0 ? void 0 : Ft.identifier) + " to " + this.evaluationContext.identity.identifier), G = !1), this.cacheOptions.ttl && (!S.ts || (/* @__PURE__ */ new Date()).valueOf() - S.ts > this.cacheOptions.ttl) && (S.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + S.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - S.ts) + "ms"), G = !1) : S.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + S.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - S.ts) + "ms"), q = !0, G = !0)), G && (Q = !0, z = _((xt = this.evaluationContext.identity) === null || xt === void 0 ? void 0 : xt.traits, (Ot = (wt = S.evaluationContext) === null || wt === void 0 ? void 0 : wt.identity) === null || Ot === void 0 ? void 0 : Ot.traits), D = _(this.flags, S.flags), this.setState(s(s({}, S), { evaluationContext: tt(s(s({}, S.evaluationContext), { identity: !((It = S.evaluationContext) === null || It === void 0) && It.identity ? s(s({}, (Lt = S.evaluationContext) === null || Lt === void 0 ? void 0 : Lt.identity), { traits: s(s({}, ((jt = (At = S.evaluationContext) === null || At === void 0 ? void 0 : At.identity) === null || jt === void 0 ? void 0 : jt.traits) || {}), it || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", S))), Q ? (yt = !L && (!this.cacheOptions.skipAPI || q), this._onChange(null, { isFromServer: !1, flagsChanged: D, traitsChanged: z }, this._loadedState(null, O.CACHE, yt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && Q && !q && this.log("Skipping API, using cache"), yt && this.getFlags().catch(function(le) {
389
+ var Pt;
390
+ (Pt = te.onError) === null || Pt === void 0 || Pt.call(te, le);
391
+ }), [3, 4]) : [3, 2];
392
+ case 2:
393
+ return L ? [3, 4] : [4, this.getFlags()];
394
+ case 3:
395
+ M.sent(), M.label = 4;
396
+ case 4:
397
+ return [3, 6];
398
+ case 5:
399
+ return Wt = M.sent(), this.log("Exception fetching cached logs", Wt), [3, 6];
400
+ case 6:
401
+ return [3, 10];
402
+ case 7:
403
+ return L ? [3, 9] : [4, this.getFlags()];
404
+ case 8:
405
+ return M.sent(), [3, 10];
406
+ case 9:
407
+ if (I) this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (Tt = this.evaluationContext.identity) === null || Tt === void 0 ? void 0 : Tt.traits) }, this._loadedState(null, O.DEFAULT_FLAGS));
408
+ else {
409
+ if (!this.flags) throw new Error(ft);
410
+ this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (Nt = this.evaluationContext.identity) === null || Nt === void 0 ? void 0 : Nt.traits) }, this._loadedState(null, O.DEFAULT_FLAGS));
411
+ }
412
+ M.label = 10;
413
+ case 10:
414
+ return [2];
415
+ }
416
+ });
417
+ });
418
+ }, P.label = 2;
419
+ case 2:
420
+ return P.trys.push([2, 7, , 8]), w.getItemSync ? (pt = w.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
421
+ case 3:
422
+ return [4, w.getItem(this.getStorageKey())];
423
+ case 4:
424
+ pt = P.sent(), P.label = 5;
425
+ case 5:
426
+ return [4, Zt(null, pt)];
427
+ case 6:
428
+ case 7:
429
+ return P.sent(), [3, 8];
430
+ case 8:
431
+ return [3, 12];
432
+ case 9:
433
+ return L ? [3, 11] : [4, this.getFlags()];
434
+ case 10:
435
+ return P.sent(), [3, 12];
436
+ case 11:
437
+ if (I) this._onChange(null, { isFromServer: !1, flagsChanged: _({}, I), traitsChanged: _({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, O.DEFAULT_FLAGS));
438
+ else if (this.flags && (at = null, Object.keys(this.flags).length === 0 && (at = ft), this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(at, O.DEFAULT_FLAGS)), at)) throw new Error(at);
439
+ P.label = 12;
440
+ case 12:
441
+ return [3, 14];
442
+ case 13:
443
+ throw Z = P.sent(), this.log("Error during initialisation ", Z), Qt = Z instanceof Error ? Z : new Error("".concat(Z)), (n = this.onError) === null || n === void 0 || n.call(this, Qt), Z;
444
+ case 14:
445
+ return [2];
446
+ }
447
+ });
448
+ });
449
+ }, a.prototype.getAllFlags = function() {
450
+ return this.flags;
451
+ }, a.prototype.identify = function(e, t, i) {
452
+ return this.evaluationContext.identity = { identifier: e, transient: i, traits: this.evaluationContext.identity && this.evaluationContext.identity.identifier == e ? this.evaluationContext.identity.traits : {} }, this.evaluationContext.identity.identifier = e, this.log("Identify: " + this.evaluationContext.identity.identifier), t && (this.evaluationContext.identity.traits = Object.fromEntries(Object.entries(t).map(function(n) {
453
+ var r = n[0], o = n[1];
454
+ return [r, C(o) ? o : { value: o }];
455
+ }))), this.initialised ? this.getFlags() : Promise.resolve();
456
+ }, a.prototype.getState = function() {
457
+ return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
458
+ }, a.prototype.setState = function(e) {
459
+ e && (this.initialised = !0, this.api = e.api || this.api || Dt, this.flags = e.flags || this.flags, this.evaluationContext = e.evaluationContext || this.evaluationContext, this.evaluationEvent = e.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
460
+ }, a.prototype.logout = function() {
461
+ return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
462
+ }, a.prototype.startListening = function(e) {
463
+ e === void 0 && (e = 1e3), this.getFlagInterval && clearInterval(this.getFlagInterval), this.getFlagInterval = setInterval(this.getFlags, e);
464
+ }, a.prototype.stopListening = function() {
465
+ this.getFlagInterval && (clearInterval(this.getFlagInterval), this.getFlagInterval = null);
466
+ }, a.prototype._loadedState = function(e, t, i) {
467
+ return e === void 0 && (e = null), i === void 0 && (i = !1), { error: e, isFetching: i, isLoading: !1, source: t };
468
+ }, a.prototype.log = function() {
469
+ for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
470
+ this.enableLogs && console.log.apply(this, V(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], e));
471
+ }, a.prototype.updateStorage = function() {
472
+ if (this.cacheFlags) {
473
+ this.ts = (/* @__PURE__ */ new Date()).valueOf();
474
+ var e = JSON.stringify(this.getState());
475
+ this.log("Setting storage", e), w.setItem(this.getStorageKey(), e);
476
+ }
477
+ }, a.prototype.updateEventStorage = function() {
478
+ if (this.enableAnalytics) {
479
+ var e = JSON.stringify(this.getState().evaluationEvent);
480
+ w.setItem(st, e).catch(function(t) {
481
+ return console.error("Flagsmith: Error setting item in async storage", t);
482
+ });
483
+ }
484
+ }, a.prototype.setLoadingState = function(e) {
485
+ var t;
486
+ W(e, this.loadingState) || (this.loadingState = s({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
487
+ }, a.prototype.setupRealtime = function(e, t) {
488
+ var i = this, n = e + "sse/environments/" + t + "/stream";
489
+ ht ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new ht(n), this.eventSource.addEventListener("environment_updated", function(r) {
490
+ var o;
491
+ try {
492
+ o = JSON.parse(r.data).updated_at;
493
+ } catch (c) {
494
+ i.log("Could not parse sse event", c);
495
+ }
496
+ o ? !i.timestamp || o > i.timestamp ? i.isLoading ? i.log("updated_at is new, but flags are loading", r.data, i.timestamp) : (i.log("updated_at is new, fetching flags", r.data, i.timestamp), i.getFlags()) : i.log("updated_at is outdated, skipping get flags", r.data, i.timestamp) : i.log("No updated_at received, fetching flags", r);
497
+ })) : this.log("Error, EventSource is undefined");
498
+ }, a;
499
+ }();
500
+ function Jt(a) {
501
+ var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
502
+ return new re({ fetch: e, AsyncStorage: t, eventSource: i });
503
+ }
504
+ var lt, oe = (lt = function(a, e) {
505
+ return lt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
506
+ t.__proto__ = i;
507
+ } || function(t, i) {
508
+ for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]);
509
+ }, lt(a, e);
510
+ }, function(a, e) {
511
+ if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
512
+ function t() {
513
+ this.constructor = a;
514
+ }
515
+ lt(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
516
+ }), zt = function(a) {
517
+ var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
518
+ if (t) return t.call(a);
519
+ if (a && typeof a.length == "number") return { next: function() {
520
+ return a && i >= a.length && (a = void 0), { value: a && a[i++], done: !a };
521
+ } };
522
+ throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
523
+ }, Mt = function(a, e) {
524
+ var t = typeof Symbol == "function" && a[Symbol.iterator];
525
+ if (!t) return a;
526
+ var i, n, r = t.call(a), o = [];
527
+ try {
528
+ for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
529
+ } catch (c) {
530
+ n = { error: c };
531
+ } finally {
532
+ try {
533
+ i && !i.done && (t = r.return) && t.call(r);
534
+ } finally {
535
+ if (n) throw n.error;
536
+ }
537
+ }
538
+ return o;
539
+ }, vt = function(a, e, t) {
540
+ if (arguments.length === 2) for (var i, n = 0, r = e.length; n < r; n++) !i && n in e || (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
541
+ return a.concat(i || Array.prototype.slice.call(e));
542
+ }, se = function(a) {
543
+ function e() {
544
+ return a.call(this, `EventSource not available.
545
+ Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
546
+ }
547
+ return oe(e, a), e;
548
+ }(Error), Bt = function() {
549
+ function a(e, t) {
550
+ var i = this;
551
+ if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = t != null ? Object.assign({}, t) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = e.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 se();
552
+ this._onevent_wrapped = function(n) {
553
+ i._onevent(n);
554
+ }, this._start();
555
+ }
556
+ return a.prototype.dispatchEvent = function(e) {
557
+ throw new Error("Method not implemented.");
558
+ }, a.prototype._start = function() {
559
+ var e, t, i = this, n = this.url;
560
+ this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(h) {
561
+ i._onopen(h);
562
+ }, this._eventSource.onerror = function(h) {
563
+ i._onerror(h);
564
+ }, this._eventSource.onmessage = function(h) {
565
+ i.onmessage(h);
566
+ };
567
+ try {
568
+ for (var r = zt(Object.keys(this._listeners)), o = r.next(); !o.done; o = r.next()) {
569
+ var c = o.value;
570
+ this._eventSource.addEventListener(c, this._onevent_wrapped);
571
+ }
572
+ } catch (h) {
573
+ e = { error: h };
574
+ } finally {
575
+ try {
576
+ o && !o.done && (t = r.return) && t.call(r);
577
+ } finally {
578
+ if (e) throw e.error;
579
+ }
580
+ }
581
+ }, a.prototype._onopen = function(e) {
582
+ this.readyState === 0 && (this.readyState = 1, this.onopen(e));
583
+ }, a.prototype._onerror = function(e) {
584
+ var t = this;
585
+ if (this.readyState === 1 && (this.readyState = 0, this.onerror(e)), this._eventSource) {
586
+ this._eventSource.close(), this._eventSource = null;
587
+ var i = Math.round(this.max_retry_time * Math.random());
588
+ this._timer = setTimeout(function() {
589
+ return t._start();
590
+ }, i);
591
+ }
592
+ }, a.prototype._onevent = function(e) {
593
+ var t, i;
594
+ e && e.lastEventId && (this._lastEventId = e.lastEventId);
595
+ var n = this._listeners[e.type];
596
+ if (n != null) try {
597
+ for (var r = zt(vt([], Mt(n), !1)), o = r.next(); !o.done; o = r.next())
598
+ o.value.call(this, e);
599
+ } catch (c) {
600
+ t = { error: c };
601
+ } finally {
602
+ try {
603
+ o && !o.done && (i = r.return) && i.call(r);
604
+ } finally {
605
+ if (t) throw t.error;
606
+ }
607
+ }
608
+ e.type === "message" && this.onmessage(e);
609
+ }, a.prototype.onopen = function(e) {
610
+ }, a.prototype.onerror = function(e) {
611
+ }, a.prototype.onmessage = function(e) {
612
+ }, a.prototype.close = function() {
613
+ this._timer && (clearTimeout(this._timer), this._timer = null), this._eventSource && (this._eventSource.close(), this._eventSource = null), this.readyState = 2;
614
+ }, a.prototype.addEventListener = function(e, t, i) {
615
+ this._listeners[e] == null && (this._listeners[e] = [], this._eventSource != null && this._eventSource.addEventListener(e, this._onevent_wrapped));
616
+ var n = this._listeners[e];
617
+ n.includes(t) || (this._listeners[e] = vt(vt([], Mt(n), !1), [t], !1));
618
+ }, a.prototype.removeEventListener = function(e, t, i) {
619
+ var n = this._listeners[e];
620
+ this._listeners[e] = n.filter(function(r) {
621
+ return r !== t;
622
+ });
623
+ }, a;
624
+ }();
625
+ globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
626
+ var Ht = function(a, e) {
627
+ return e = e || {}, new Promise(function(t, i) {
628
+ var n = new XMLHttpRequest(), r = [], o = [], c = {}, h = function() {
629
+ return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
630
+ return Promise.resolve(n.responseText);
631
+ }, json: function() {
632
+ return Promise.resolve(n.responseText).then(JSON.parse);
633
+ }, blob: function() {
634
+ return Promise.resolve(new Blob([n.response]));
635
+ }, clone: h, headers: { keys: function() {
636
+ return r;
637
+ }, entries: function() {
638
+ return o;
639
+ }, get: function(u) {
640
+ return c[u.toLowerCase()];
641
+ }, has: function(u) {
642
+ return u.toLowerCase() in c;
643
+ } } };
644
+ };
645
+ for (var f in n.open(e.method || "get", a, !0), n.onload = function() {
646
+ n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(u, p, E) {
647
+ r.push(p = p.toLowerCase()), o.push([p, E]), c[p] = c[p] ? c[p] + "," + E : E;
648
+ }), t(h());
649
+ }, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(f, e.headers[f]);
650
+ n.send(e.body || null);
651
+ });
652
+ }, $t = Jt({ AsyncStorage: g, fetch: Ht, eventSource: Bt });
653
+ typeof window < "u" && (window.flagsmith = $t), d.createFlagsmithInstance = function() {
654
+ return Jt({ AsyncStorage: g, fetch: Ht, eventSource: Bt });
655
+ }, d.default = $t, Object.defineProperty(d, "__esModule", { value: !0 });
656
+ });
657
+ })(Rt, Rt.exports);
658
+ var de = Rt.exports, ne = {
659
+ NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first.",
660
+ INVALID_CONFIG: "Invalid Flagsmith configuration",
661
+ FETCH_FAILED: "Failed to fetch Flagsmith configuration",
662
+ NO_USER_CONTEXT: "User context not set. Call setUser() first.",
663
+ ALREADY_INITIALIZED: "FeatureFlag is already initialized."
664
+ }, ie = "business", K, ge = (K = class {
665
+ constructor() {
666
+ ut(this, "flagsmithClient", null);
667
+ ut(this, "userContext", null);
668
+ }
669
+ static getInstance() {
670
+ return K.instance || (K.instance = new K()), K.instance;
671
+ }
672
+ ensureInitialized() {
673
+ if (!this.flagsmithClient)
674
+ throw new Error(ne.NOT_INITIALIZED);
675
+ }
676
+ async init(l, d = []) {
677
+ if (!this.flagsmithClient)
678
+ try {
679
+ this.flagsmithClient = de.createFlagsmithInstance();
680
+ const g = d.reduce((s, T) => (s[T.feature.name] = T, s), {});
681
+ await this.flagsmithClient.init({
682
+ environmentID: l.apiKey,
683
+ api: (l == null ? void 0 : l.url) ?? "https://flag.feedme.farm/api/v1/",
684
+ enableAnalytics: (l == null ? void 0 : l.enableAnalytics) ?? !0,
685
+ defaultFlags: g,
686
+ cacheFlags: (l == null ? void 0 : l.cacheFlags) ?? !0
687
+ });
688
+ } catch (g) {
689
+ throw console.error("Failed to initialize FeatureFlag:", g), g;
690
+ }
691
+ }
692
+ async setUser(l, d) {
693
+ this.ensureInitialized(), this.userContext = { identifier: l, traits: d }, await this.updateContext();
694
+ }
695
+ async addTraits(l) {
696
+ if (this.ensureInitialized(), !this.userContext)
697
+ throw new Error(ne.NO_USER_CONTEXT);
698
+ this.userContext.traits = { ...this.userContext.traits, ...l }, await this.updateContext();
699
+ }
700
+ async updateContext() {
701
+ try {
702
+ if (!this.userContext) return;
703
+ await this.flagsmithClient.setContext({
704
+ identity: {
705
+ identifier: this.userContext.identifier,
706
+ traits: this.userContext.traits || {}
707
+ }
708
+ });
709
+ } catch (l) {
710
+ throw console.error("Failed to update user context:", l), l;
711
+ }
712
+ }
713
+ async getFlags() {
714
+ this.ensureInitialized();
715
+ const l = this.flagsmithClient.getAllFlags();
716
+ return Object.entries(l).map(([d, g]) => {
717
+ var s;
718
+ return {
719
+ feature: {
720
+ name: d,
721
+ id: (g == null ? void 0 : g.id) ?? 0
722
+ },
723
+ enabled: g.enabled,
724
+ value: ((s = g.value) == null ? void 0 : s.toString()) ?? null
725
+ };
726
+ });
727
+ }
728
+ getFlagValue(l, d) {
729
+ this.ensureInitialized();
730
+ const g = this.flagsmithClient.getValue(l);
731
+ if (g == null)
732
+ return null;
733
+ try {
734
+ const s = g.toString();
735
+ return d ? d(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
736
+ } catch (s) {
737
+ return console.error("Error transforming flag value:", s), null;
738
+ }
739
+ }
740
+ getFlag(l) {
741
+ this.ensureInitialized();
742
+ const d = this.flagsmithClient.getValue(l);
743
+ if (d == null) return null;
744
+ const g = this.flagsmithClient.hasFeature(l);
745
+ return {
746
+ feature: {
747
+ name: l,
748
+ id: 0
749
+ },
750
+ enabled: g,
751
+ value: d.toString()
752
+ };
753
+ }
754
+ async getUserFlagValue(l, d, g = null, s) {
755
+ var $;
756
+ const T = this.userContext;
757
+ try {
758
+ return await this.setUser(l), this.getFlagValue(d, s) ?? g;
759
+ } catch (V) {
760
+ return console.error(`Error getting user flag value for ${d}:`, V), g;
761
+ } finally {
762
+ try {
763
+ await (($ = this.flagsmithClient) == null ? void 0 : $.logout()), this.userContext = null, T && await this.setUser(T.identifier, T.traits);
764
+ } catch (V) {
765
+ console.error("Error during cleanup:", V);
766
+ }
767
+ }
768
+ }
769
+ reset() {
770
+ this.flagsmithClient = null, this.userContext = null;
771
+ }
772
+ }, ut(K, "instance"), K), fe = ge.getInstance(), rt = Ut(!1), ot = Ut([]), H = Ut(null);
773
+ function pe(v = fe) {
774
+ const l = () => rt.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), d = async (m, b = []) => {
775
+ if (rt.value) {
776
+ console.warn("FeatureFlag is already initialized.");
777
+ return;
778
+ }
779
+ try {
780
+ await v.init(m, b), ot.value = await v.getFlags(), rt.value = !0, H.value = null;
781
+ } catch (C) {
782
+ console.error("Failed to initialize feature flags:", C), H.value = C;
783
+ }
784
+ }, g = async (m, b) => {
785
+ if (l())
786
+ try {
787
+ await v.setUser(m, b), ot.value = await v.getFlags(), H.value = null;
788
+ } catch (C) {
789
+ console.error("Failed to set user:", C), H.value = C;
790
+ }
791
+ }, s = async (m, b) => g(`${ie}-${m}`, b), T = async (m) => {
792
+ if (l())
793
+ try {
794
+ await v.addTraits(m), ot.value = await v.getFlags(), H.value = null;
795
+ } catch (b) {
796
+ console.error("Failed to add traits:", b), H.value = b;
797
+ }
798
+ }, $ = (m, b, C = null) => {
799
+ if (!l()) return C;
800
+ try {
801
+ return v.getFlagValue(m, b) ?? C;
802
+ } catch (J) {
803
+ return console.error(`Error getting flag value for ${m}:`, J), C;
804
+ }
805
+ }, V = (m, b) => {
806
+ if (!l()) return b ?? null;
807
+ try {
808
+ return v.getFlag(m) ?? b ?? null;
809
+ } catch (C) {
810
+ return console.error(`Error getting flag for ${m}:`, C), b ?? null;
811
+ }
812
+ }, W = async (m, b, C = null, J) => {
813
+ if (!l()) return C;
814
+ try {
815
+ return await v.getUserFlagValue(m, b, C, J);
816
+ } catch (tt) {
817
+ return console.error(`Error getting user flag value for ${b}:`, tt), C;
818
+ }
819
+ }, _ = async (m, b, C = null, J) => W(`${ie}-${m}`, b, C, J), O = () => {
820
+ try {
821
+ v.reset();
822
+ } catch (m) {
823
+ console.error("Error resetting feature flags:", m);
824
+ } finally {
825
+ ot.value = [], rt.value = !1, H.value = null;
826
+ }
827
+ };
828
+ return {
829
+ flags: kt(ot),
830
+ isInitialized: kt(rt),
831
+ error: kt(H),
832
+ init: d,
833
+ setUser: g,
834
+ setBusiness: s,
835
+ addTraits: T,
836
+ getFlagValue: $,
837
+ getFlag: V,
838
+ getUserFlagValue: W,
839
+ getBusinessFlagValue: _,
840
+ reset: O
841
+ };
842
+ }
843
+ var ye = () => pe();
844
+ const me = /* @__PURE__ */ new Set([
845
+ // vivo pizza prod
846
+ "business_6687e91fa7240b001ba3f4c2",
847
+ // vivo dev
848
+ "business_669a1d2efc050a001cfbb5a2"
849
+ ]), Se = /* @__PURE__ */ new Set([
850
+ // vivo pizza prod
851
+ "business_6687e91fa7240b001ba3f4c2",
852
+ // vivo dev
853
+ "business_669a1d2efc050a001cfbb5a2",
854
+ // kfc dev
855
+ "business_655b25254fe3be001b123f0b",
856
+ // King Menu V4
857
+ "business_646ee00ebffa92001b84c4c7"
858
+ ]), be = /* @__PURE__ */ new Set([
859
+ // kfc dev
860
+ "business_655b25254fe3be001b123f0b",
861
+ // zus dev
862
+ "business_671005de24a7f4001c87e25e"
863
+ ]), Ce = /* @__PURE__ */ new Set([
864
+ // kfc dev
865
+ "business_655b25254fe3be001b123f0b",
866
+ // zus dev
867
+ "business_671005de24a7f4001c87e25e"
868
+ ]), _e = /* @__PURE__ */ new Set([
869
+ // zus dev
870
+ "business_671005de24a7f4001c87e25e"
871
+ ]), Oe = () => ({
872
+ get businessDbName() {
873
+ var d;
874
+ return `business_${((d = B().currentBusiness.value) == null ? void 0 : d._id) ?? ""}`;
875
+ },
876
+ get isWarehouse() {
877
+ var l;
878
+ return ((l = ee()._currentLocation) == null ? void 0 : l.type) === he.enum.warehouse;
879
+ },
880
+ get restaurantPosVersion() {
881
+ var d;
882
+ const v = ee();
883
+ return (d = B().restaurants.value.find(
884
+ (g) => {
885
+ var s;
886
+ return g._id === ((s = v._currentLocation) == null ? void 0 : s.doc._id);
887
+ }
888
+ )) == null ? void 0 : d.posVersion;
889
+ },
890
+ get enableTotalCost() {
891
+ var l;
892
+ return ((l = B().currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4";
893
+ },
894
+ /** @deprecated TODO: remove */
895
+ get enableBackdatePo() {
896
+ const v = ve();
897
+ return Se.has(this.businessDbName) && (this.isWarehouse || v.state.closing !== null);
898
+ },
899
+ /** @deprecated TODO: remove */
900
+ get autoReceiveWarehouse() {
901
+ return this.isWarehouse ? !this.manualReceive : !1;
902
+ },
903
+ /** @deprecated TODO: remove */
904
+ get manualReceive() {
905
+ var l;
906
+ return (
907
+ // if menu v4, must manual receive && must use outlet app
908
+ ((l = B().currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4" && // more guard for businesses using menu v4, only those listed for manual receive will be included
909
+ // TODO: may be removed to use menu version only
910
+ me.has(this.businessDbName)
911
+ );
912
+ },
913
+ get enablePoTemplate() {
914
+ var l;
915
+ const v = B();
916
+ return ((l = v.currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4" && v.namespace.value === "dev";
917
+ },
918
+ get enableSupplierMasterList() {
919
+ var l;
920
+ const v = B();
921
+ return ((l = v.currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4" && v.namespace.value === "dev";
922
+ },
923
+ get mustUsePoTemplate() {
924
+ const v = B();
925
+ return be.has(this.businessDbName) && v.namespace.value === "dev";
926
+ },
927
+ /** @deprecated TODO: remove */
928
+ get mustUseDefaultCost() {
929
+ return Ce.has(this.businessDbName);
930
+ },
931
+ get businessSupplierOnly() {
932
+ return _e.has(this.businessDbName);
933
+ },
934
+ async init() {
935
+ const v = B(), { init: l } = ye(), d = v.namespace.value === "prod";
936
+ await l({
937
+ apiKey: d ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee"
938
+ // url: 'https://flag.feedme.farm/api/v1/', // optional -> this is a default URL value
939
+ // enableAnalytics: true, // optional, defaults to true
940
+ // cacheFlags: true // optional, defaults to true
941
+ });
942
+ }
943
+ });
944
+ export {
945
+ Oe as u
946
+ };