@feedmepos/mf-inventory-portal 0.0.23-dev.41 → 0.0.23-dev.42

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 (41) hide show
  1. package/dist/{App-DW2K97Bb.js → App-Cr-n7HVf.js} +104 -98
  2. package/dist/{ApprovalView-BgSxdrwt.js → ApprovalView-BYHDmt9W.js} +5 -5
  3. package/dist/{BindingsDialog-CQtusdvp.js → BindingsDialog-CI0nYM1_.js} +2 -2
  4. package/dist/{BindingsPicker-BnEjRAah.js → BindingsPicker-BVzF3C8O.js} +3 -3
  5. package/dist/{BindingsTable-DpTPAef_.js → BindingsTable-B21_9L2o.js} +1 -1
  6. package/dist/ClosingDraftView-k2Vsz8-W.js +1225 -0
  7. package/dist/{ClosingTemplateView-CMTJHywt.js → ClosingTemplateView-BLda7tYC.js} +21 -21
  8. package/dist/{FmCustomAttribute.vue_vue_type_script_setup_true_lang-zOmcCdDR.js → FmCustomAttribute.vue_vue_type_script_setup_true_lang-DUDOaU6F.js} +8 -8
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-mAPA5_sB.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CXuer_x5.js} +3 -3
  10. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BjNpfucZ.js → FmUnitInput.vue_vue_type_script_setup_true_lang-Ds3yBf9U.js} +12 -12
  11. package/dist/{IngredientGroupView-CrEfiZvn.js → IngredientGroupView-CgZ4YT3i.js} +1 -1
  12. package/dist/{IngredientsView-BB8LQlU9.js → IngredientsView-tPERrF9O.js} +4 -4
  13. package/dist/{IntegrationView-D2wTkDyX.js → IntegrationView-CoF_rdWv.js} +1 -1
  14. package/dist/{InventoryBindingForm-DW7rJDc1.js → InventoryBindingForm-BSnofTIL.js} +1 -1
  15. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-Ci8UI1eQ.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-4d9oz7Xh.js} +18 -18
  16. package/dist/{InventoryBindingSummary-B40KofiI.js → InventoryBindingSummary-qm9ZUFny.js} +1 -1
  17. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DD7VT9MS.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CQY98Hj6.js} +1 -1
  18. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BGuXTfn6.js → PremiumBadge.vue_vue_type_script_setup_true_lang-NUkiVop4.js} +1 -1
  19. package/dist/{PurchaseOrderPrintPreview-DQmx28Be.js → PurchaseOrderPrintPreview-CIWiq2NB.js} +1 -1
  20. package/dist/{ReceiveRequestView-CJknzKfd.js → ReceiveRequestView-Dgt3FeGb.js} +10 -10
  21. package/dist/{RecipeView-D5oWQ9Yd.js → RecipeView-CzWlx1Xv.js} +3 -3
  22. package/dist/{StockView-U59PHCy2.js → StockView-IPXGJNN8.js} +103 -103
  23. package/dist/{SupplierView-CLjjpTNZ.js → SupplierView-DuL3NXc0.js} +4 -4
  24. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-DLDDXnyG.js → TransferDetails.vue_vue_type_script_setup_true_lang-82Bu89OE.js} +43 -43
  25. package/dist/{TransferTemplateView-CFoVrPIX.js → TransferTemplateView-BEaRafuO.js} +25 -25
  26. package/dist/{UnitView-CAopphN_.js → UnitView-Cwo0mthQ.js} +14 -14
  27. package/dist/{WarehouseView-DUZku5U6.js → WarehouseView-DzjQrpyv.js} +140 -140
  28. package/dist/{app-0klJzLit.js → app-CpuFfqWF.js} +226 -226
  29. package/dist/app.js +1 -1
  30. package/dist/{decimal-Cu4rlnvU.js → decimal-bSGrDlvd.js} +1 -1
  31. package/dist/{feature-C1wCaXKQ.js → feature-D8aRYGen.js} +199 -183
  32. package/dist/{format-unit-display-CMa5UhY1.js → format-unit-display-D4gi2D-O.js} +58 -58
  33. package/dist/{index-HTBqkVVr.js → index-COeURijn.js} +3 -3
  34. package/dist/{index-BJaMpEVJ.js → index-Cn1ato-l.js} +1 -1
  35. package/dist/{stock-CB4yNRMO.js → stock-B1Rchi6n.js} +1 -1
  36. package/dist/stores/feature.d.ts +3 -0
  37. package/dist/style.css +1 -1
  38. package/dist/{supplier-biIIXGyr.js → supplier-CeY_Gro-.js} +1 -1
  39. package/dist/{use-inventory-binding-dialog-BopoOOxB.js → use-inventory-binding-dialog-BXqY40wn.js} +1 -1
  40. package/package.json +1 -1
  41. package/dist/ClosingDraftView-CXKYLCZS.js +0 -1190
@@ -1,14 +1,14 @@
1
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-0klJzLit.js";
6
- import { ref as Ut, readonly as kt } from "vue";
2
+ var ce = (d, l, v) => l in d ? ue(d, l, { enumerable: !0, configurable: !0, writable: !0, value: v }) : d[l] = v;
3
+ var ut = (d, l, v) => ce(d, typeof l != "symbol" ? l + "" : l, v);
4
+ import { useCoreStore as q } from "@feedmepos/mf-common";
5
+ import { aI as ct, u as ee, aB as he, a as ve } from "./app-CpuFfqWF.js";
6
+ import { ref as Dt, readonly as kt } from "vue";
7
7
  var Rt = { exports: {} };
8
- (function(v, l) {
9
- (function(d, g) {
8
+ (function(d, l) {
9
+ (function(v, g) {
10
10
  g(l);
11
- })(ct, function(d) {
11
+ })(ct, function(v) {
12
12
  var g = { getItemSync: function(a) {
13
13
  try {
14
14
  return localStorage.getItem(a) || null;
@@ -21,8 +21,8 @@ var Rt = { exports: {} };
21
21
  try {
22
22
  var r = t.getItemSync(a);
23
23
  e == null || e(null, r), i(r);
24
- } catch (o) {
25
- e && e(o, null), n(o);
24
+ } catch (s) {
25
+ e && e(s, null), n(s);
26
26
  }
27
27
  });
28
28
  }, setItem: function(a, e, t) {
@@ -33,15 +33,15 @@ var Rt = { exports: {} };
33
33
  t && t(r, null), n(r);
34
34
  }
35
35
  });
36
- } }, s = function() {
37
- return s = Object.assign || function(a) {
36
+ } }, o = function() {
37
+ return o = Object.assign || function(a) {
38
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
39
  return a;
40
- }, s.apply(this, arguments);
40
+ }, o.apply(this, arguments);
41
41
  };
42
- function T(a, e, t, i) {
42
+ function j(a, e, t, i) {
43
43
  return new (t || (t = Promise))(function(n, r) {
44
- function o(f) {
44
+ function s(f) {
45
45
  try {
46
46
  h(i.next(f));
47
47
  } catch (u) {
@@ -59,13 +59,13 @@ var Rt = { exports: {} };
59
59
  var u;
60
60
  f.done ? n(f.value) : (u = f.value, u instanceof t ? u : new t(function(p) {
61
61
  p(u);
62
- })).then(o, c);
62
+ })).then(s, c);
63
63
  }
64
64
  h((i = i.apply(a, [])).next());
65
65
  });
66
66
  }
67
- function $(a, e) {
68
- var t, i, n, r, o = { label: 0, sent: function() {
67
+ function H(a, e) {
68
+ var t, i, n, r, s = { label: 0, sent: function() {
69
69
  if (1 & n[0]) throw n[1];
70
70
  return n[1];
71
71
  }, trys: [], ops: [] };
@@ -76,7 +76,7 @@ var Rt = { exports: {} };
76
76
  return function(f) {
77
77
  return function(u) {
78
78
  if (t) throw new TypeError("Generator is already executing.");
79
- for (; o; ) try {
79
+ for (; s; ) try {
80
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
81
  switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) {
82
82
  case 0:
@@ -84,34 +84,34 @@ var Rt = { exports: {} };
84
84
  n = u;
85
85
  break;
86
86
  case 4:
87
- return o.label++, { value: u[1], done: !1 };
87
+ return s.label++, { value: u[1], done: !1 };
88
88
  case 5:
89
- o.label++, i = u[1], u = [0];
89
+ s.label++, i = u[1], u = [0];
90
90
  continue;
91
91
  case 7:
92
- u = o.ops.pop(), o.trys.pop();
92
+ u = s.ops.pop(), s.trys.pop();
93
93
  continue;
94
94
  default:
95
- if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
96
- o = 0;
95
+ if (n = s.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
96
+ s = 0;
97
97
  continue;
98
98
  }
99
99
  if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) {
100
- o.label = u[1];
100
+ s.label = u[1];
101
101
  break;
102
102
  }
103
- if (u[0] === 6 && o.label < n[1]) {
104
- o.label = n[1], n = u;
103
+ if (u[0] === 6 && s.label < n[1]) {
104
+ s.label = n[1], n = u;
105
105
  break;
106
106
  }
107
- if (n && o.label < n[2]) {
108
- o.label = n[2], o.ops.push(u);
107
+ if (n && s.label < n[2]) {
108
+ s.label = n[2], s.ops.push(u);
109
109
  break;
110
110
  }
111
- n[2] && o.ops.pop(), o.trys.pop();
111
+ n[2] && s.ops.pop(), s.trys.pop();
112
112
  continue;
113
113
  }
114
- u = e.call(a, o);
114
+ u = e.call(a, s);
115
115
  } catch (p) {
116
116
  u = [6, p], i = 0;
117
117
  } finally {
@@ -143,8 +143,8 @@ var Rt = { exports: {} };
143
143
  if ((i = (r = Object.keys(e)).length) !== Object.keys(t).length) return !1;
144
144
  for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(t, r[n])) return !1;
145
145
  for (n = i; n-- != 0; ) {
146
- var o = r[n];
147
- if (!a(e[o], t[o])) return !1;
146
+ var s = r[n];
147
+ if (!a(e[s], t[s])) return !1;
148
148
  }
149
149
  return !0;
150
150
  }
@@ -174,20 +174,20 @@ var Rt = { exports: {} };
174
174
  }));
175
175
  }
176
176
  function tt(a) {
177
- return s(s({}, a), { identity: a.identity ? s(s({}, a.identity), { traits: J(a.identity.traits || {}) }) : void 0 });
177
+ return o(o({}, a), { identity: a.identity ? o(o({}, a.identity), { traits: J(a.identity.traits || {}) }) : void 0 });
178
178
  }
179
179
  (function(a) {
180
180
  a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
181
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() {
182
+ var ht, w = null, ae = "FLAGSMITH_EVENT", ot = ae, Ut = "https://edge.api.flagsmith.com/api/v1/", Kt = "flagsmith_value_", Gt = "flagsmith_enabled_", Vt = "flagsmith_trait_", re = function() {
183
183
  function a(e) {
184
184
  var t = this;
185
185
  this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
186
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) {
187
+ t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(o(o({}, t.loadingState), { isFetching: !0 }));
188
+ var s = "".concat(t.getContext().identity), c = function(h) {
189
189
  var f, u, p, E;
190
- if (h && o === "".concat(t.getContext().identity)) {
190
+ if (h && s === "".concat(t.getContext().identity)) {
191
191
  var k = h.flags, I = h.traits, N = h.identifier;
192
192
  t.isLoading = !1;
193
193
  var L = {}, A = {};
@@ -195,15 +195,15 @@ var Rt = { exports: {} };
195
195
  L[y.feature.name.toLowerCase().replace(/ /g, "_")] = { id: y.feature.id, enabled: y.enabled, value: y.feature_state_value };
196
196
  }), I.forEach(function(y) {
197
197
  A[y.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: y.transient, value: y.trait_value };
198
- }), t.oldFlags = s({}, t.flags);
198
+ }), t.oldFlags = o({}, t.flags);
199
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 {
200
+ if ((N || Object.keys(A).length) && (t.evaluationContext.identity = o(o({}, 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
201
  if (t.datadogRum.trackTraits) {
202
202
  var nt = {};
203
203
  Object.keys(((u = t.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(y) {
204
204
  nt[Vt + y] = t.getTrait(y);
205
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);
206
+ var X = o(o(o({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((p = t.evaluationContext.identity) === null || p === void 0 ? void 0 : p.identifier) }), nt);
207
207
  t.log("Setting Datadog user", X), t.datadogRum.client.setUser(X);
208
208
  }
209
209
  } catch (y) {
@@ -227,7 +227,7 @@ var Rt = { exports: {} };
227
227
  }).filter(function(h) {
228
228
  return h.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", h.trait_key), !1);
229
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]);
230
+ return t.evaluationContext.identity = o(o({}, t.evaluationContext.identity), { traits: {} }), c(h == null ? void 0 : h[0]);
231
231
  }).catch(function(h) {
232
232
  var f = h.message, u = new Error(f);
233
233
  return Promise.reject(u);
@@ -239,14 +239,14 @@ var Rt = { exports: {} };
239
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
240
  if (t.evaluationContext.environment) {
241
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();
242
+ t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(o(o({}, r), { evaluationEvent: t.evaluationEvent })), t.updateEventStorage();
243
243
  }
244
244
  }).catch(function(n) {
245
245
  t.log("Exception fetching evaluationEvent", n);
246
246
  }) : void 0;
247
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;
248
+ var s = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = null;
249
+ if (s && (c = s.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), c === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
250
250
  if (n != null && n.json) try {
251
251
  return c === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(c);
252
252
  } catch {
@@ -259,38 +259,38 @@ var Rt = { exports: {} };
259
259
  }, this.getAllTraits = function() {
260
260
  var i;
261
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];
262
+ var r = n[0], s = n[1];
263
+ return [r, s == null ? void 0 : s.value];
264
264
  }));
265
265
  }, this.setContext = function(i) {
266
266
  var n = tt(i);
267
- return t.evaluationContext = s(s({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
267
+ return t.evaluationContext = o(o({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
268
268
  }, this.getContext = function() {
269
269
  return t.evaluationContext;
270
270
  }, this.updateContext = function(i) {
271
- return t.setContext(s(s({}, t.getContext()), i));
271
+ return t.setContext(o(o({}, t.getContext()), i));
272
272
  }, this.setTrait = function(i, n) {
273
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]]))) }) }));
274
+ if (t.api) return t.setContext(o(o({}, t.evaluationContext), { identity: o(o({}, t.evaluationContext.identity), { traits: o(o({}, (r = t.evaluationContext.identity) === null || r === void 0 ? void 0 : r.traits), J(Object.fromEntries([[i, n]]))) }) }));
275
275
  }, this.setTraits = function(i) {
276
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 }];
277
+ if (t.api) return t.setContext(o(o({}, t.evaluationContext), { identity: o(o({}, t.evaluationContext.identity), { traits: o(o({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
278
+ var s = r[0], c = r[1];
279
+ return [s, C(c) ? c : { value: c }];
280
280
  }))) }) }));
281
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
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;
283
+ var r = typeof n == "object", s = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = !1;
284
+ return !s && r && n.fallback !== void 0 ? c = n == null ? void 0 : n.fallback : s && s.enabled && (c = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), c;
285
285
  }, this.getStorageKey = function() {
286
286
  var i, n;
287
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
288
  }, this.getJSON = function(i, n, r) {
289
- var o, c = t;
289
+ var s, c = t;
290
290
  c.evaluationContext;
291
291
  var h = c.headers, f = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
292
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);
293
+ var u = "".concat((s = t.evaluationContext.identity) === null || s === void 0 ? void 0 : s.identifier);
294
294
  return m(i, f).then(function(p) {
295
295
  var E, k, I = "".concat((E = t.evaluationContext.identity) === null || E === void 0 ? void 0 : E.identifier);
296
296
  if (u === I) {
@@ -320,72 +320,72 @@ var Rt = { exports: {} };
320
320
  }
321
321
  t.updateEventStorage();
322
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);
323
+ var s, c;
324
+ t.setLoadingState(r), (s = t.onChange) === null || s === void 0 || s.call(t, i, n, t.loadingState), (c = t._trigger) === null || c === void 0 || c.call(t);
325
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
326
  }
327
327
  return a.prototype.init = function(e) {
328
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) {
329
+ return j(this, void 0, void 0, function() {
330
+ var r, s, 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 H(this, function(P) {
332
332
  switch (P.label) {
333
333
  case 0:
334
334
  r = tt(e.evaluationContext || this.evaluationContext), P.label = 1;
335
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) {
336
+ if (P.trys.push([1, 13, , 14]), s = e.environmentID, c = e.api, h = c === void 0 ? Ut : 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 = s ? { apiKey: s } : 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(T) {
338
+ return [T[0], { value: T[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(T) {
340
+ x.setLoadingState(o(o({}, x.loadingState), { isFetching: !1, isLoading: !1, error: T })), k == null || k(T);
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, ot = "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 = o(o({}, 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(T) {
342
+ return function(D, U) {
343
+ var z = U.headers, S = U.method, Q = U.body;
344
+ return new Promise(function($) {
345
345
  switch (S) {
346
346
  case "GET":
347
- return j.get(U, { headers: z }).subscribe(function(G) {
348
- q({ ok: !0, text: function() {
347
+ return T.get(D, { headers: z }).subscribe(function(G) {
348
+ $({ ok: !0, text: function() {
349
349
  return Promise.resolve(G);
350
350
  } });
351
351
  });
352
352
  case "POST":
353
353
  case "PUT":
354
- return j.post(U, Q, { headers: z }).subscribe(function(G) {
355
- q({ ok: !0, text: function() {
354
+ return T.post(D, Q, { headers: z }).subscribe(function(G) {
355
+ $({ ok: !0, text: function() {
356
356
  return Promise.resolve(G);
357
357
  } });
358
358
  });
359
359
  }
360
360
  });
361
361
  };
362
- }(gt)), w && this.canUseStorage && w.getItem(st).then(function(j) {
362
+ }(gt)), w && this.canUseStorage && w.getItem(ot).then(function(T) {
363
363
  try {
364
- x.evaluationEvent = JSON.parse(j) || {};
364
+ x.evaluationEvent = JSON.parse(T) || {};
365
365
  } catch {
366
366
  x.evaluationEvent = {};
367
367
  }
368
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]) {
369
+ }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), w && this.canUseStorage && w.getItem(ot, function(T, D) {
370
+ if (D && x.evaluationContext.environment) {
371
+ var U = JSON.parse(D);
372
+ if (U[x.evaluationContext.environment.apiKey]) {
373
373
  var z = x.getState();
374
- x.log("Retrieved events from cache", U), x.setState(s(s({}, z), { evaluationEvent: D[x.evaluationContext.environment.apiKey] }));
374
+ x.log("Retrieved events from cache", D), x.setState(o(o({}, z), { evaluationEvent: U[x.evaluationContext.environment.apiKey] }));
375
375
  }
376
376
  }
377
377
  })), !p) return [3, 9];
378
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) {
379
+ Zt = function(T, D) {
380
+ return j(x, void 0, void 0, function() {
381
+ var U, z, S, Q, $, G, yt, Wt, mt, St, bt, Ct, _t, Et, Ft, xt, wt, Ot, It, Lt, At, Tt, jt, Nt, te = this;
382
+ return H(this, function(M) {
383
383
  switch (M.label) {
384
384
  case 0:
385
- if (!U) return [3, 7];
386
- D = null, z = null, M.label = 1;
385
+ if (!D) return [3, 7];
386
+ U = null, z = null, M.label = 1;
387
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) {
388
+ return M.trys.push([1, 5, , 6]), S = JSON.parse(D), Q = !1, $ = !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"), $ = !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), U = _(this.flags, S.flags), this.setState(o(o({}, S), { evaluationContext: tt(o(o({}, S.evaluationContext), { identity: !((It = S.evaluationContext) === null || It === void 0) && It.identity ? o(o({}, (Lt = S.evaluationContext) === null || Lt === void 0 ? void 0 : Lt.identity), { traits: o(o({}, ((Tt = (At = S.evaluationContext) === null || At === void 0 ? void 0 : At.identity) === null || Tt === void 0 ? void 0 : Tt.traits) || {}), it || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", S))), Q ? (yt = !L && (!this.cacheOptions.skipAPI || $), this._onChange(null, { isFromServer: !1, flagsChanged: U, traitsChanged: z }, this._loadedState(null, O.CACHE, yt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && Q && !$ && this.log("Skipping API, using cache"), yt && this.getFlags().catch(function(le) {
389
389
  var Pt;
390
390
  (Pt = te.onError) === null || Pt === void 0 || Pt.call(te, le);
391
391
  }), [3, 4]) : [3, 2];
@@ -404,7 +404,7 @@ var Rt = { exports: {} };
404
404
  case 8:
405
405
  return M.sent(), [3, 10];
406
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));
407
+ if (I) this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (jt = this.evaluationContext.identity) === null || jt === void 0 ? void 0 : jt.traits) }, this._loadedState(null, O.DEFAULT_FLAGS));
408
408
  else {
409
409
  if (!this.flags) throw new Error(ft);
410
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));
@@ -450,13 +450,13 @@ var Rt = { exports: {} };
450
450
  return this.flags;
451
451
  }, a.prototype.identify = function(e, t, i) {
452
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 }];
453
+ var r = n[0], s = n[1];
454
+ return [r, C(s) ? s : { value: s }];
455
455
  }))), this.initialised ? this.getFlags() : Promise.resolve();
456
456
  }, a.prototype.getState = function() {
457
457
  return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
458
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));
459
+ e && (this.initialised = !0, this.api = e.api || this.api || Ut, this.flags = e.flags || this.flags, this.evaluationContext = e.evaluationContext || this.evaluationContext, this.evaluationEvent = e.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
460
460
  }, a.prototype.logout = function() {
461
461
  return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
462
462
  }, a.prototype.startListening = function(e) {
@@ -477,23 +477,23 @@ var Rt = { exports: {} };
477
477
  }, a.prototype.updateEventStorage = function() {
478
478
  if (this.enableAnalytics) {
479
479
  var e = JSON.stringify(this.getState().evaluationEvent);
480
- w.setItem(st, e).catch(function(t) {
480
+ w.setItem(ot, e).catch(function(t) {
481
481
  return console.error("Flagsmith: Error setting item in async storage", t);
482
482
  });
483
483
  }
484
484
  }, a.prototype.setLoadingState = function(e) {
485
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));
486
+ W(e, this.loadingState) || (this.loadingState = o({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
487
487
  }, a.prototype.setupRealtime = function(e, t) {
488
488
  var i = this, n = e + "sse/environments/" + t + "/stream";
489
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;
490
+ var s;
491
491
  try {
492
- o = JSON.parse(r.data).updated_at;
492
+ s = JSON.parse(r.data).updated_at;
493
493
  } catch (c) {
494
494
  i.log("Could not parse sse event", c);
495
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);
496
+ s ? !i.timestamp || s > 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
497
  })) : this.log("Error, EventSource is undefined");
498
498
  }, a;
499
499
  }();
@@ -501,7 +501,7 @@ var Rt = { exports: {} };
501
501
  var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
502
502
  return new re({ fetch: e, AsyncStorage: t, eventSource: i });
503
503
  }
504
- var lt, oe = (lt = function(a, e) {
504
+ var lt, se = (lt = function(a, e) {
505
505
  return lt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
506
506
  t.__proto__ = i;
507
507
  } || function(t, i) {
@@ -523,9 +523,9 @@ var Rt = { exports: {} };
523
523
  }, Mt = function(a, e) {
524
524
  var t = typeof Symbol == "function" && a[Symbol.iterator];
525
525
  if (!t) return a;
526
- var i, n, r = t.call(a), o = [];
526
+ var i, n, r = t.call(a), s = [];
527
527
  try {
528
- for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
528
+ for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) s.push(i.value);
529
529
  } catch (c) {
530
530
  n = { error: c };
531
531
  } finally {
@@ -535,20 +535,20 @@ var Rt = { exports: {} };
535
535
  if (n) throw n.error;
536
536
  }
537
537
  }
538
- return o;
538
+ return s;
539
539
  }, vt = function(a, e, t) {
540
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
541
  return a.concat(i || Array.prototype.slice.call(e));
542
- }, se = function(a) {
542
+ }, oe = function(a) {
543
543
  function e() {
544
544
  return a.call(this, `EventSource not available.
545
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
546
  }
547
- return oe(e, a), e;
547
+ return se(e, a), e;
548
548
  }(Error), Bt = function() {
549
549
  function a(e, t) {
550
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();
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 oe();
552
552
  this._onevent_wrapped = function(n) {
553
553
  i._onevent(n);
554
554
  }, this._start();
@@ -565,15 +565,15 @@ Consider loading an EventSource polyfill and making it available globally as Eve
565
565
  i.onmessage(h);
566
566
  };
567
567
  try {
568
- for (var r = zt(Object.keys(this._listeners)), o = r.next(); !o.done; o = r.next()) {
569
- var c = o.value;
568
+ for (var r = zt(Object.keys(this._listeners)), s = r.next(); !s.done; s = r.next()) {
569
+ var c = s.value;
570
570
  this._eventSource.addEventListener(c, this._onevent_wrapped);
571
571
  }
572
572
  } catch (h) {
573
573
  e = { error: h };
574
574
  } finally {
575
575
  try {
576
- o && !o.done && (t = r.return) && t.call(r);
576
+ s && !s.done && (t = r.return) && t.call(r);
577
577
  } finally {
578
578
  if (e) throw e.error;
579
579
  }
@@ -594,13 +594,13 @@ Consider loading an EventSource polyfill and making it available globally as Eve
594
594
  e && e.lastEventId && (this._lastEventId = e.lastEventId);
595
595
  var n = this._listeners[e.type];
596
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);
597
+ for (var r = zt(vt([], Mt(n), !1)), s = r.next(); !s.done; s = r.next())
598
+ s.value.call(this, e);
599
599
  } catch (c) {
600
600
  t = { error: c };
601
601
  } finally {
602
602
  try {
603
- o && !o.done && (i = r.return) && i.call(r);
603
+ s && !s.done && (i = r.return) && i.call(r);
604
604
  } finally {
605
605
  if (t) throw t.error;
606
606
  }
@@ -625,7 +625,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
625
625
  globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
626
626
  var Ht = function(a, e) {
627
627
  return e = e || {}, new Promise(function(t, i) {
628
- var n = new XMLHttpRequest(), r = [], o = [], c = {}, h = function() {
628
+ var n = new XMLHttpRequest(), r = [], s = [], c = {}, h = function() {
629
629
  return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
630
630
  return Promise.resolve(n.responseText);
631
631
  }, json: function() {
@@ -635,7 +635,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
635
635
  }, clone: h, headers: { keys: function() {
636
636
  return r;
637
637
  }, entries: function() {
638
- return o;
638
+ return s;
639
639
  }, get: function(u) {
640
640
  return c[u.toLowerCase()];
641
641
  }, has: function(u) {
@@ -644,15 +644,15 @@ Consider loading an EventSource polyfill and making it available globally as Eve
644
644
  };
645
645
  for (var f in n.open(e.method || "get", a, !0), n.onload = function() {
646
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;
647
+ r.push(p = p.toLowerCase()), s.push([p, E]), c[p] = c[p] ? c[p] + "," + E : E;
648
648
  }), t(h());
649
649
  }, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(f, e.headers[f]);
650
650
  n.send(e.body || null);
651
651
  });
652
652
  }, $t = Jt({ AsyncStorage: g, fetch: Ht, eventSource: Bt });
653
- typeof window < "u" && (window.flagsmith = $t), d.createFlagsmithInstance = function() {
653
+ typeof window < "u" && (window.flagsmith = $t), v.createFlagsmithInstance = function() {
654
654
  return Jt({ AsyncStorage: g, fetch: Ht, eventSource: Bt });
655
- }, d.default = $t, Object.defineProperty(d, "__esModule", { value: !0 });
655
+ }, v.default = $t, Object.defineProperty(v, "__esModule", { value: !0 });
656
656
  });
657
657
  })(Rt, Rt.exports);
658
658
  var de = Rt.exports, ne = {
@@ -673,11 +673,11 @@ var de = Rt.exports, ne = {
673
673
  if (!this.flagsmithClient)
674
674
  throw new Error(ne.NOT_INITIALIZED);
675
675
  }
676
- async init(l, d = []) {
676
+ async init(l, v = []) {
677
677
  if (!this.flagsmithClient)
678
678
  try {
679
679
  this.flagsmithClient = de.createFlagsmithInstance();
680
- const g = d.reduce((s, T) => (s[T.feature.name] = T, s), {});
680
+ const g = v.reduce((o, j) => (o[j.feature.name] = j, o), {});
681
681
  await this.flagsmithClient.init({
682
682
  environmentID: l.apiKey,
683
683
  api: (l == null ? void 0 : l.url) ?? "https://flag.feedme.farm/api/v1/",
@@ -689,8 +689,8 @@ var de = Rt.exports, ne = {
689
689
  throw console.error("Failed to initialize FeatureFlag:", g), g;
690
690
  }
691
691
  }
692
- async setUser(l, d) {
693
- this.ensureInitialized(), this.userContext = { identifier: l, traits: d }, await this.updateContext();
692
+ async setUser(l, v) {
693
+ this.ensureInitialized(), this.userContext = { identifier: l, traits: v }, await this.updateContext();
694
694
  }
695
695
  async addTraits(l) {
696
696
  if (this.ensureInitialized(), !this.userContext)
@@ -713,34 +713,34 @@ var de = Rt.exports, ne = {
713
713
  async getFlags() {
714
714
  this.ensureInitialized();
715
715
  const l = this.flagsmithClient.getAllFlags();
716
- return Object.entries(l).map(([d, g]) => {
717
- var s;
716
+ return Object.entries(l).map(([v, g]) => {
717
+ var o;
718
718
  return {
719
719
  feature: {
720
- name: d,
720
+ name: v,
721
721
  id: (g == null ? void 0 : g.id) ?? 0
722
722
  },
723
723
  enabled: g.enabled,
724
- value: ((s = g.value) == null ? void 0 : s.toString()) ?? null
724
+ value: ((o = g.value) == null ? void 0 : o.toString()) ?? null
725
725
  };
726
726
  });
727
727
  }
728
- getFlagValue(l, d) {
728
+ getFlagValue(l, v) {
729
729
  this.ensureInitialized();
730
730
  const g = this.flagsmithClient.getValue(l);
731
731
  if (g == null)
732
732
  return null;
733
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;
734
+ const o = g.toString();
735
+ return v ? v(o) : typeof {} == "number" ? isNaN(Number(o)) ? null : Number(o) : typeof {} == "boolean" ? o.toLowerCase() === "true" : o;
736
+ } catch (o) {
737
+ return console.error("Error transforming flag value:", o), null;
738
738
  }
739
739
  }
740
740
  getFlag(l) {
741
741
  this.ensureInitialized();
742
- const d = this.flagsmithClient.getValue(l);
743
- if (d == null) return null;
742
+ const v = this.flagsmithClient.getValue(l);
743
+ if (v == null) return null;
744
744
  const g = this.flagsmithClient.hasFeature(l);
745
745
  return {
746
746
  feature: {
@@ -748,19 +748,19 @@ var de = Rt.exports, ne = {
748
748
  id: 0
749
749
  },
750
750
  enabled: g,
751
- value: d.toString()
751
+ value: v.toString()
752
752
  };
753
753
  }
754
- async getUserFlagValue(l, d, g = null, s) {
755
- var $;
756
- const T = this.userContext;
754
+ async getUserFlagValue(l, v, g = null, o) {
755
+ var H;
756
+ const j = this.userContext;
757
757
  try {
758
- return await this.setUser(l), this.getFlagValue(d, s) ?? g;
758
+ return await this.setUser(l), this.getFlagValue(v, o) ?? g;
759
759
  } catch (V) {
760
- return console.error(`Error getting user flag value for ${d}:`, V), g;
760
+ return console.error(`Error getting user flag value for ${v}:`, V), g;
761
761
  } finally {
762
762
  try {
763
- await (($ = this.flagsmithClient) == null ? void 0 : $.logout()), this.userContext = null, T && await this.setUser(T.identifier, T.traits);
763
+ await ((H = this.flagsmithClient) == null ? void 0 : H.logout()), this.userContext = null, j && await this.setUser(j.identifier, j.traits);
764
764
  } catch (V) {
765
765
  console.error("Error during cleanup:", V);
766
766
  }
@@ -769,71 +769,71 @@ var de = Rt.exports, ne = {
769
769
  reset() {
770
770
  this.flagsmithClient = null, this.userContext = null;
771
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 = []) => {
772
+ }, ut(K, "instance"), K), fe = ge.getInstance(), rt = Dt(!1), st = Dt([]), B = Dt(null);
773
+ function pe(d = fe) {
774
+ const l = () => rt.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), v = async (m, b = []) => {
775
775
  if (rt.value) {
776
776
  console.warn("FeatureFlag is already initialized.");
777
777
  return;
778
778
  }
779
779
  try {
780
- await v.init(m, b), ot.value = await v.getFlags(), rt.value = !0, H.value = null;
780
+ await d.init(m, b), st.value = await d.getFlags(), rt.value = !0, B.value = null;
781
781
  } catch (C) {
782
- console.error("Failed to initialize feature flags:", C), H.value = C;
782
+ console.error("Failed to initialize feature flags:", C), B.value = C;
783
783
  }
784
784
  }, g = async (m, b) => {
785
785
  if (l())
786
786
  try {
787
- await v.setUser(m, b), ot.value = await v.getFlags(), H.value = null;
787
+ await d.setUser(m, b), st.value = await d.getFlags(), B.value = null;
788
788
  } catch (C) {
789
- console.error("Failed to set user:", C), H.value = C;
789
+ console.error("Failed to set user:", C), B.value = C;
790
790
  }
791
- }, s = async (m, b) => g(`${ie}-${m}`, b), T = async (m) => {
791
+ }, o = async (m, b) => g(`${ie}-${m}`, b), j = async (m) => {
792
792
  if (l())
793
793
  try {
794
- await v.addTraits(m), ot.value = await v.getFlags(), H.value = null;
794
+ await d.addTraits(m), st.value = await d.getFlags(), B.value = null;
795
795
  } catch (b) {
796
- console.error("Failed to add traits:", b), H.value = b;
796
+ console.error("Failed to add traits:", b), B.value = b;
797
797
  }
798
- }, $ = (m, b, C = null) => {
798
+ }, H = (m, b, C = null) => {
799
799
  if (!l()) return C;
800
800
  try {
801
- return v.getFlagValue(m, b) ?? C;
801
+ return d.getFlagValue(m, b) ?? C;
802
802
  } catch (J) {
803
803
  return console.error(`Error getting flag value for ${m}:`, J), C;
804
804
  }
805
805
  }, V = (m, b) => {
806
806
  if (!l()) return b ?? null;
807
807
  try {
808
- return v.getFlag(m) ?? b ?? null;
808
+ return d.getFlag(m) ?? b ?? null;
809
809
  } catch (C) {
810
810
  return console.error(`Error getting flag for ${m}:`, C), b ?? null;
811
811
  }
812
812
  }, W = async (m, b, C = null, J) => {
813
813
  if (!l()) return C;
814
814
  try {
815
- return await v.getUserFlagValue(m, b, C, J);
815
+ return await d.getUserFlagValue(m, b, C, J);
816
816
  } catch (tt) {
817
817
  return console.error(`Error getting user flag value for ${b}:`, tt), C;
818
818
  }
819
819
  }, _ = async (m, b, C = null, J) => W(`${ie}-${m}`, b, C, J), O = () => {
820
820
  try {
821
- v.reset();
821
+ d.reset();
822
822
  } catch (m) {
823
823
  console.error("Error resetting feature flags:", m);
824
824
  } finally {
825
- ot.value = [], rt.value = !1, H.value = null;
825
+ st.value = [], rt.value = !1, B.value = null;
826
826
  }
827
827
  };
828
828
  return {
829
- flags: kt(ot),
829
+ flags: kt(st),
830
830
  isInitialized: kt(rt),
831
- error: kt(H),
832
- init: d,
831
+ error: kt(B),
832
+ init: v,
833
833
  setUser: g,
834
- setBusiness: s,
835
- addTraits: T,
836
- getFlagValue: $,
834
+ setBusiness: o,
835
+ addTraits: j,
836
+ getFlagValue: H,
837
837
  getFlag: V,
838
838
  getUserFlagValue: W,
839
839
  getBusinessFlagValue: _,
@@ -868,33 +868,42 @@ const me = /* @__PURE__ */ new Set([
868
868
  ]), _e = /* @__PURE__ */ new Set([
869
869
  // zus dev
870
870
  "business_671005de24a7f4001c87e25e"
871
- ]), Oe = () => ({
871
+ ]), Ee = /* @__PURE__ */ new Set([
872
+ // zus dev
873
+ "business_671005de24a7f4001c87e25e"
874
+ ]), Fe = /* @__PURE__ */ new Set([
875
+ // zus dev
876
+ "business_671005de24a7f4001c87e25e"
877
+ ]), xe = /* @__PURE__ */ new Set([
878
+ // zus dev
879
+ "business_671005de24a7f4001c87e25e"
880
+ ]), Ae = () => ({
872
881
  get businessDbName() {
873
- var d;
874
- return `business_${((d = B().currentBusiness.value) == null ? void 0 : d._id) ?? ""}`;
882
+ var v;
883
+ return `business_${((v = q().currentBusiness.value) == null ? void 0 : v._id) ?? ""}`;
875
884
  },
876
885
  get isWarehouse() {
877
886
  var l;
878
887
  return ((l = ee()._currentLocation) == null ? void 0 : l.type) === he.enum.warehouse;
879
888
  },
880
889
  get restaurantPosVersion() {
881
- var d;
882
- const v = ee();
883
- return (d = B().restaurants.value.find(
890
+ var v;
891
+ const d = ee();
892
+ return (v = q().restaurants.value.find(
884
893
  (g) => {
885
- var s;
886
- return g._id === ((s = v._currentLocation) == null ? void 0 : s.doc._id);
894
+ var o;
895
+ return g._id === ((o = d._currentLocation) == null ? void 0 : o.doc._id);
887
896
  }
888
- )) == null ? void 0 : d.posVersion;
897
+ )) == null ? void 0 : v.posVersion;
889
898
  },
890
899
  get enableTotalCost() {
891
900
  var l;
892
- return ((l = B().currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4";
901
+ return ((l = q().currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4";
893
902
  },
894
903
  /** @deprecated TODO: remove */
895
904
  get enableBackdatePo() {
896
- const v = ve();
897
- return Se.has(this.businessDbName) && (this.isWarehouse || v.state.closing !== null);
905
+ const d = ve();
906
+ return Se.has(this.businessDbName) && (this.isWarehouse || d.state.closing !== null);
898
907
  },
899
908
  /** @deprecated TODO: remove */
900
909
  get autoReceiveWarehouse() {
@@ -905,24 +914,31 @@ const me = /* @__PURE__ */ new Set([
905
914
  var l;
906
915
  return (
907
916
  // 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
917
+ ((l = q().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
918
  // TODO: may be removed to use menu version only
910
919
  me.has(this.businessDbName)
911
920
  );
912
921
  },
913
922
  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";
923
+ return Ee.has(this.businessDbName);
924
+ },
925
+ get enableClosingTemplate() {
926
+ return Fe.has(this.businessDbName);
927
+ },
928
+ get enableWastageTemplate() {
929
+ return xe.has(this.businessDbName);
930
+ },
931
+ get enableIngredientGroup() {
932
+ return !1;
917
933
  },
918
934
  get enableSupplierMasterList() {
919
935
  var l;
920
- const v = B();
921
- return ((l = v.currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4" && v.namespace.value === "dev";
936
+ const d = q();
937
+ return ((l = d.currentBusiness.value) == null ? void 0 : l.menuVersion) === "v4" && d.namespace.value === "dev";
922
938
  },
923
939
  get mustUsePoTemplate() {
924
- const v = B();
925
- return be.has(this.businessDbName) && v.namespace.value === "dev";
940
+ const d = q();
941
+ return be.has(this.businessDbName) && d.namespace.value === "dev";
926
942
  },
927
943
  /** @deprecated TODO: remove */
928
944
  get mustUseDefaultCost() {
@@ -932,9 +948,9 @@ const me = /* @__PURE__ */ new Set([
932
948
  return _e.has(this.businessDbName);
933
949
  },
934
950
  async init() {
935
- const v = B(), { init: l } = ye(), d = v.namespace.value === "prod";
951
+ const d = q(), { init: l } = ye(), v = d.namespace.value === "prod";
936
952
  await l({
937
- apiKey: d ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee"
953
+ apiKey: v ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee"
938
954
  // url: 'https://flag.feedme.farm/api/v1/', // optional -> this is a default URL value
939
955
  // enableAnalytics: true, // optional, defaults to true
940
956
  // cacheFlags: true // optional, defaults to true
@@ -942,5 +958,5 @@ const me = /* @__PURE__ */ new Set([
942
958
  }
943
959
  });
944
960
  export {
945
- Oe as u
961
+ Ae as u
946
962
  };