@feedmepos/mf-inventory-portal 1.4.2 → 1.4.4-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/App-_rrlFpzI.js +309 -0
  2. package/dist/{ApprovalView-B6WmrP3R.js → ApprovalView-BA13wbQ-.js} +7 -7
  3. package/dist/{BindingsDialog-DAG2toHR.js → BindingsDialog-DMzMv881.js} +2 -2
  4. package/dist/{BindingsPicker-CPbNuwFq.js → BindingsPicker-BGxYZDn_.js} +2 -2
  5. package/dist/{BindingsTable-Hkkel0vq.js → BindingsTable-D7I6KyIQ.js} +3 -3
  6. package/dist/ClosingDraftView-osqh-QJ1.js +3649 -0
  7. package/dist/{ClosingHistoryView-D7GacAqj.js → ClosingHistoryView-DQoNfb5z.js} +5 -5
  8. package/dist/{ClosingTemplateView-DqpbjHK2.js → ClosingTemplateView-Ckq2Veyq.js} +14 -14
  9. package/dist/{DefaultView-BSm6fE5w.js → DefaultView-BYIk34PR.js} +2 -2
  10. package/dist/{DeliveryOrderPrintPreview-DFj56iJk.js → DeliveryOrderPrintPreview-BgHL-gvt.js} +2 -2
  11. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CaVUl6v3.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-yqA2fgtH.js} +2 -2
  12. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-FunJ5ZX5.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Bvma2A4K.js} +2 -2
  13. package/dist/{FmMultiselectDialog-DpekFj8a.js → FmMultiselectDialog-BmTCvmlw.js} +2 -2
  14. package/dist/{FmMultiselectDialog-BE2Tqm4H.js → FmMultiselectDialog-VPcV-FQV.js} +1 -1
  15. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-Bt_kCIFn.js → FmUnitInput.vue_vue_type_script_setup_true_lang-7dkCTYcT.js} +4 -4
  16. package/dist/{ImportView-CAcUO9Pv.js → ImportView-gzF9CWtM.js} +6 -6
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-0Abq7FDN.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BJKxFdjv.js} +1 -1
  18. package/dist/{IngredientGroupView-CeUfykez.js → IngredientGroupView-DkoVLdIi.js} +5 -5
  19. package/dist/{IngredientsView-Cdhgw3Tw.js → IngredientsView-NBpaVLDo.js} +15 -15
  20. package/dist/{IntegrationExplorerView-BioiObpU.js → IntegrationExplorerView-D4P5Sxcm.js} +5 -5
  21. package/dist/{IntegrationView-BHjOvMpX.js → IntegrationView-B5YN8TEE.js} +13 -13
  22. package/dist/{InventoryBindingForm-D892WEqV.js → InventoryBindingForm-B7VMypYy.js} +1 -1
  23. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BMfmKcz8.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DziCetjY.js} +5 -5
  24. package/dist/{InventoryBindingSummary-DOGWF0fo.js → InventoryBindingSummary-B9Vy49tr.js} +1 -1
  25. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B-dhMJ0F.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DXbiPSqB.js} +1 -1
  26. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CKuIWTXZ.js → PremiumBadge.vue_vue_type_script_setup_true_lang-7ikbnzXX.js} +1 -1
  27. package/dist/{PublishView-Dh6OiaG1.js → PublishView-BwmWveBB.js} +3 -3
  28. package/dist/{PurchaseOrderPrintPreview-Cpme08gm.js → PurchaseOrderPrintPreview-kajF_P0m.js} +2 -2
  29. package/dist/{ReceiveRequestView-Dldwu3-H.js → ReceiveRequestView-DHYEENEf.js} +10550 -10507
  30. package/dist/{RecipeView-gkZuFdCP.js → RecipeView-BHwVXfLJ.js} +17 -17
  31. package/dist/{SettingsView-wOy_OATI.js → SettingsView-AdpIDPVs.js} +4 -4
  32. package/dist/{StockView-DeLcyQrC.js → StockView-C5AtoijI.js} +19 -19
  33. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-C2Jax3tb.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B3az_NVO.js} +1 -1
  34. package/dist/{SupplierView-Bf2AW8JH.js → SupplierView-D7Nr2RxT.js} +12 -12
  35. package/dist/{SurchargeView-CJtg87ol.js → SurchargeView-vJimp1Cv.js} +6 -6
  36. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-Bfzqxalj.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CinFL3QM.js} +2 -2
  37. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CEz3Yc2Z.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-D2SvRBN6.js} +1 -1
  38. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DlEjTd8E.js +4353 -0
  39. package/dist/{TransferTemplateView-DpWFExzQ.js → TransferTemplateView-C6RmjS-v.js} +18 -18
  40. package/dist/{UnitCostHistoryView-PEexDaAO.js → UnitCostHistoryView-aC4aPr3L.js} +4 -4
  41. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-i8HZEphD.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CuP7FMd1.js} +4 -4
  42. package/dist/{UnitView-BPyyMHKE.js → UnitView-BCGMlHCV.js} +7 -7
  43. package/dist/{WarehouseView-BmCech19.js → WarehouseView-O3gc_PiU.js} +5 -5
  44. package/dist/{WastageTemplateView-DJOBAWKd.js → WastageTemplateView-H9PA6ryl.js} +14 -14
  45. package/dist/api/purchase-order.d.ts +1 -0
  46. package/dist/api/sse.d.ts +3 -15
  47. package/dist/{app-D4P-koOR.js → app-CItiJtFw.js} +13 -11
  48. package/dist/app.js +1 -1
  49. package/dist/{closing-template-CCvXzoLm.js → closing-template-Cwj3O7Lm.js} +1 -1
  50. package/dist/composable/useSseClient.d.ts +5 -4
  51. package/dist/{date2-XHYHbI0K.js → date2-D00juOhc.js} +1 -1
  52. package/dist/{dayjs.min-pkE_kmHZ.js → dayjs.min-DmEufB_X.js} +1 -1
  53. package/dist/{decimal-CQ7SlCe0.js → decimal-Cfx4iNIN.js} +2 -2
  54. package/dist/{defineDeepModel-CZDkmNol.js → defineDeepModel-Dn4pcA76.js} +1 -1
  55. package/dist/{duplicate-template-BQ0bF_MO.js → duplicate-template-3GCMrDdJ.js} +1 -1
  56. package/dist/{export-CDIp6ydU.js → export-Taxbki8U.js} +2 -2
  57. package/dist/{feature-C4zPjstX.js → feature-CWFT4m6D.js} +426 -400
  58. package/dist/{format-time-from-id-D_USijTz.js → format-time-from-id-DBU5YJL6.js} +1 -1
  59. package/dist/{format-unit-display-CF6-yU7v.js → format-unit-display-Bcg7Sa60.js} +11 -11
  60. package/dist/{import-export.helper-iVXMr9yw.js → import-export.helper-DDM-pvFO.js} +6 -6
  61. package/dist/{index-BIG8c4oA.js → index-BMhosF1x.js} +3 -3
  62. package/dist/{index-EoaZ_eFV.js → index-DHnHIq4-.js} +1 -1
  63. package/dist/{index-CTNLpvtM.js → index-DK0BNrfa.js} +1 -1
  64. package/dist/{inventory-core-dart.default-D6cCA8tk.js → inventory-core-dart.default-B8aW6vKZ.js} +1 -1
  65. package/dist/{lodash-DR7t9CsC.js → lodash-raCw-gUe.js} +1 -1
  66. package/dist/{lz-string-DgqLqrsO.js → lz-string-eBAqN_g9.js} +1 -1
  67. package/dist/{netsuite-ByBZj6uf.js → netsuite-uRj2P-EH.js} +5 -6
  68. package/dist/{number-f4J4YlZT.js → number-C9o5tPfP.js} +3 -3
  69. package/dist/{predefined-templates-BlmLhRsh.js → predefined-templates-YPJMW8GJ.js} +1 -1
  70. package/dist/{purchase-order-template-BS94QDpg.js → purchase-order-template-B6aV2vdS.js} +1 -1
  71. package/dist/{recalculationUtils-D0wl-tgM.js → recalculationUtils-BiZ-pU6y.js} +1 -1
  72. package/dist/{rules-Cpi5Vduo.js → rules-01UCJome.js} +2 -2
  73. package/dist/{stock-BynB5KIH.js → stock-DTp9AhdZ.js} +1 -1
  74. package/dist/{stock-GYUDrBUF.js → stock-SuApOj2U.js} +3 -3
  75. package/dist/stores/feature.d.ts +15 -0
  76. package/dist/{supplier-BDpzWHvm.js → supplier-D60bDAuZ.js} +2 -2
  77. package/dist/{surcharge-ztZ3mUE2.js → surcharge-BWwSWZ1U.js} +1 -1
  78. package/dist/tsconfig.app.tsbuildinfo +1 -1
  79. package/dist/{use-ingredient-select-dialog-xx_W7OyU.js → use-ingredient-select-dialog-B4zci6JI.js} +2 -2
  80. package/dist/{use-inventory-binding-dialog-B_OV8CCL.js → use-inventory-binding-dialog-CgSz72ZS.js} +2 -2
  81. package/dist/{use-template-enabled-locations-ByOi4t2R.js → use-template-enabled-locations-DVLHfYM9.js} +2 -2
  82. package/dist/{use-transfer-locations-BOR-wq8s.js → use-transfer-locations-POSn3UDi.js} +2 -2
  83. package/dist/{useHrmPermission-BtXw89bp.js → useHrmPermission-B9ffPr7i.js} +1 -1
  84. package/dist/{useNavigationMenu-Ds6IBfYX.js → useNavigationMenu-dJYOEiud.js} +2 -2
  85. package/dist/views/receive-request/components/delivery-order-form/CreateFormProps.d.ts +2 -0
  86. package/dist/views/receive-request/components/delivery-order-form/EditFormProps.d.ts +1 -0
  87. package/dist/views/receive-request/helper/extra-items.d.ts +10 -0
  88. package/dist/views/receive-request/helper/extra-items.spec.d.ts +1 -0
  89. package/dist/{vue-i18n-C35dl24s.js → vue-i18n-CqFS0F9S.js} +477 -477
  90. package/dist/{xlsx-CzLrFB_A.js → xlsx-BY0_-lpm.js} +1 -1
  91. package/dist/{xlsx.util-osyDkxYO.js → xlsx.util-DR3_mTtm.js} +3 -3
  92. package/package.json +4 -4
  93. package/dist/App-D8p5pMar.js +0 -310
  94. package/dist/ClosingDraftView-JCtS2MZa.js +0 -3183
  95. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CcpH12aM.js +0 -3874
  96. package/dist/useSseClient-q5d7Qjrq.js +0 -502
@@ -1,72 +1,72 @@
1
- var _t = Object.defineProperty;
2
- var ft = (l, c, h) => c in l ? _t(l, c, { enumerable: !0, configurable: !0, writable: !0, value: h }) : l[c] = h;
3
- var ce = (l, c, h) => ft(l, typeof c != "symbol" ? c + "" : c, h);
4
- import { useCoreStore as De } from "@feedmepos/mf-common";
5
- import { U as ve, u as Ke, j as at, a as gt } from "./app-D4P-koOR.js";
6
- import { ref as he, readonly as Ge } from "vue";
7
- import "./inventory-core-dart.default-D6cCA8tk.js";
8
- var Ve = { exports: {} };
9
- (function(l, c) {
10
- (function(h, f) {
11
- f(c);
12
- })(ve, function(h) {
13
- var f = { getItemSync: function(r) {
1
+ var ht = Object.defineProperty;
2
+ var ft = (l, u, _) => u in l ? ht(l, u, { enumerable: !0, configurable: !0, writable: !0, value: _ }) : l[u] = _;
3
+ var ce = (l, u, _) => ft(l, typeof u != "symbol" ? u + "" : u, _);
4
+ import { useCoreStore as Ke } from "@feedmepos/mf-common";
5
+ import { U as ve, u as Ve, j as ot, a as gt } from "./app-CItiJtFw.js";
6
+ import { ref as de, readonly as Ge } from "vue";
7
+ import "./inventory-core-dart.default-B8aW6vKZ.js";
8
+ var Je = { exports: {} };
9
+ (function(l, u) {
10
+ (function(_, f) {
11
+ f(u);
12
+ })(ve, function(_) {
13
+ var f = { getItemSync: function(i) {
14
14
  try {
15
- return localStorage.getItem(r) || null;
15
+ return localStorage.getItem(i) || null;
16
16
  } catch {
17
17
  return null;
18
18
  }
19
- }, getItem: function(r, t) {
19
+ }, getItem: function(i, t) {
20
20
  var e = this;
21
- return new Promise(function(i, n) {
21
+ return new Promise(function(r, n) {
22
22
  try {
23
- var a = e.getItemSync(r);
24
- t == null || t(null, a), i(a);
23
+ var a = e.getItemSync(i);
24
+ t == null || t(null, a), r(a);
25
25
  } catch (o) {
26
26
  t && t(o, null), n(o);
27
27
  }
28
28
  });
29
- }, setItem: function(r, t, e) {
30
- return new Promise(function(i, n) {
29
+ }, setItem: function(i, t, e) {
30
+ return new Promise(function(r, n) {
31
31
  try {
32
- localStorage.setItem(r, t), e && e(null, t), i(t);
32
+ localStorage.setItem(i, t), e && e(null, t), r(t);
33
33
  } catch (a) {
34
34
  e && e(a, null), n(a);
35
35
  }
36
36
  });
37
37
  } }, s = function() {
38
- return s = Object.assign || function(r) {
39
- for (var t, e = 1, i = arguments.length; e < i; e++) for (var n in t = arguments[e]) Object.prototype.hasOwnProperty.call(t, n) && (r[n] = t[n]);
40
- return r;
38
+ return s = Object.assign || function(i) {
39
+ for (var t, e = 1, r = arguments.length; e < r; e++) for (var n in t = arguments[e]) Object.prototype.hasOwnProperty.call(t, n) && (i[n] = t[n]);
40
+ return i;
41
41
  }, s.apply(this, arguments);
42
42
  };
43
- function R(r, t, e, i) {
43
+ function O(i, t, e, r) {
44
44
  return new (e || (e = Promise))(function(n, a) {
45
45
  function o(p) {
46
46
  try {
47
- d(i.next(p));
48
- } catch (u) {
49
- a(u);
47
+ d(r.next(p));
48
+ } catch (c) {
49
+ a(c);
50
50
  }
51
51
  }
52
52
  function v(p) {
53
53
  try {
54
- d(i.throw(p));
55
- } catch (u) {
56
- a(u);
54
+ d(r.throw(p));
55
+ } catch (c) {
56
+ a(c);
57
57
  }
58
58
  }
59
59
  function d(p) {
60
- var u;
61
- p.done ? n(p.value) : (u = p.value, u instanceof e ? u : new e(function(y) {
62
- y(u);
60
+ var c;
61
+ p.done ? n(p.value) : (c = p.value, c instanceof e ? c : new e(function(y) {
62
+ y(c);
63
63
  })).then(o, v);
64
64
  }
65
- d((i = i.apply(r, [])).next());
65
+ d((r = r.apply(i, [])).next());
66
66
  });
67
67
  }
68
- function K(r, t) {
69
- var e, i, n, a, o = { label: 0, sent: function() {
68
+ function K(i, t) {
69
+ var e, r, n, a, o = { label: 0, sent: function() {
70
70
  if (1 & n[0]) throw n[1];
71
71
  return n[1];
72
72
  }, trys: [], ops: [] };
@@ -75,169 +75,169 @@ var Ve = { exports: {} };
75
75
  }), a;
76
76
  function v(d) {
77
77
  return function(p) {
78
- return function(u) {
78
+ return function(c) {
79
79
  if (e) throw new TypeError("Generator is already executing.");
80
80
  for (; o; ) try {
81
- if (e = 1, i && (n = 2 & u[0] ? i.return : u[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, u[1])).done) return n;
82
- switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) {
81
+ if (e = 1, r && (n = 2 & c[0] ? r.return : c[0] ? r.throw || ((n = r.return) && n.call(r), 0) : r.next) && !(n = n.call(r, c[1])).done) return n;
82
+ switch (r = 0, n && (c = [2 & c[0], n.value]), c[0]) {
83
83
  case 0:
84
84
  case 1:
85
- n = u;
85
+ n = c;
86
86
  break;
87
87
  case 4:
88
- return o.label++, { value: u[1], done: !1 };
88
+ return o.label++, { value: c[1], done: !1 };
89
89
  case 5:
90
- o.label++, i = u[1], u = [0];
90
+ o.label++, r = c[1], c = [0];
91
91
  continue;
92
92
  case 7:
93
- u = o.ops.pop(), o.trys.pop();
93
+ c = o.ops.pop(), o.trys.pop();
94
94
  continue;
95
95
  default:
96
- if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
96
+ if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
97
97
  o = 0;
98
98
  continue;
99
99
  }
100
- if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) {
101
- o.label = u[1];
100
+ if (c[0] === 3 && (!n || c[1] > n[0] && c[1] < n[3])) {
101
+ o.label = c[1];
102
102
  break;
103
103
  }
104
- if (u[0] === 6 && o.label < n[1]) {
105
- o.label = n[1], n = u;
104
+ if (c[0] === 6 && o.label < n[1]) {
105
+ o.label = n[1], n = c;
106
106
  break;
107
107
  }
108
108
  if (n && o.label < n[2]) {
109
- o.label = n[2], o.ops.push(u);
109
+ o.label = n[2], o.ops.push(c);
110
110
  break;
111
111
  }
112
112
  n[2] && o.ops.pop(), o.trys.pop();
113
113
  continue;
114
114
  }
115
- u = t.call(r, o);
115
+ c = t.call(i, o);
116
116
  } catch (y) {
117
- u = [6, y], i = 0;
117
+ c = [6, y], r = 0;
118
118
  } finally {
119
119
  e = n = 0;
120
120
  }
121
- if (5 & u[0]) throw u[1];
122
- return { value: u[0] ? u[1] : void 0, done: !0 };
121
+ if (5 & c[0]) throw c[1];
122
+ return { value: c[0] ? c[1] : void 0, done: !0 };
123
123
  }([d, p]);
124
124
  };
125
125
  }
126
126
  }
127
- function F(r, t, e) {
128
- for (var i, n = 0, a = t.length; n < a; n++) !i && n in t || (i || (i = Array.prototype.slice.call(t, 0, n)), i[n] = t[n]);
129
- return r.concat(i || Array.prototype.slice.call(t));
127
+ function I(i, t, e) {
128
+ for (var r, n = 0, a = t.length; n < a; n++) !r && n in t || (r || (r = Array.prototype.slice.call(t, 0, n)), r[n] = t[n]);
129
+ return i.concat(r || Array.prototype.slice.call(t));
130
130
  }
131
- var W = function r(t, e) {
131
+ var W = function i(t, e) {
132
132
  if (t === e) return !0;
133
133
  if (t && e && typeof t == "object" && typeof e == "object") {
134
134
  if (t.constructor !== e.constructor) return !1;
135
- var i, n, a;
135
+ var r, n, a;
136
136
  if (Array.isArray(t)) {
137
- if ((i = t.length) != e.length) return !1;
138
- for (n = i; n-- != 0; ) if (!r(t[n], e[n])) return !1;
137
+ if ((r = t.length) != e.length) return !1;
138
+ for (n = r; n-- != 0; ) if (!i(t[n], e[n])) return !1;
139
139
  return !0;
140
140
  }
141
141
  if (t.constructor === RegExp) return t.source === e.source && t.flags === e.flags;
142
142
  if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === e.valueOf();
143
143
  if (t.toString !== Object.prototype.toString) return t.toString() === e.toString();
144
- if ((i = (a = Object.keys(t)).length) !== Object.keys(e).length) return !1;
145
- for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(e, a[n])) return !1;
146
- for (n = i; n-- != 0; ) {
144
+ if ((r = (a = Object.keys(t)).length) !== Object.keys(e).length) return !1;
145
+ for (n = r; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(e, a[n])) return !1;
146
+ for (n = r; n-- != 0; ) {
147
147
  var o = a[n];
148
- if (!r(t[o], e[o])) return !1;
148
+ if (!i(t[o], e[o])) return !1;
149
149
  }
150
150
  return !0;
151
151
  }
152
152
  return t != t && e != e;
153
153
  };
154
- function w(r, t) {
155
- var e = Object.keys(t || {}).filter(function(i) {
156
- var n = r == null ? void 0 : r[i], a = t == null ? void 0 : t[i];
154
+ function w(i, t) {
155
+ var e = Object.keys(t || {}).filter(function(r) {
156
+ var n = i == null ? void 0 : i[r], a = t == null ? void 0 : t[r];
157
157
  return !W(n, a);
158
158
  });
159
- return Object.keys(r || {}).filter(function(i) {
160
- Object.keys(t || {}).includes(i) || e.push(i);
159
+ return Object.keys(i || {}).filter(function(r) {
160
+ Object.keys(t || {}).includes(r) || e.push(r);
161
161
  }), Object.keys(e).length ? e : null;
162
162
  }
163
163
  var g, C;
164
- function E(r, t, e) {
165
- var i = "shortString", n = !0;
166
- typeof e == "number" && (i = "javaDouble", n = !1), r[i] = r[i] || {}, r[i][t] = n ? e + "" : e;
164
+ function E(i, t, e) {
165
+ var r = "shortString", n = !0;
166
+ typeof e == "number" && (r = "javaDouble", n = !1), i[r] = i[r] || {}, i[r][t] = n ? e + "" : e;
167
167
  }
168
- function A(r) {
169
- return !!r && typeof r == "object" && r.value !== void 0;
168
+ function A(i) {
169
+ return !!i && typeof i == "object" && i.value !== void 0;
170
170
  }
171
- function $(r) {
172
- return Object.fromEntries(Object.entries(r).map(function(t) {
173
- var e = t[0], i = t[1];
174
- return [e, A(i) ? i : { value: i }];
171
+ function $(i) {
172
+ return Object.fromEntries(Object.entries(i).map(function(t) {
173
+ var e = t[0], r = t[1];
174
+ return [e, A(r) ? r : { value: r }];
175
175
  }));
176
176
  }
177
- function Y(r) {
178
- return s(s({}, r), { identity: r.identity ? s(s({}, r.identity), { traits: $(r.identity.traits || {}) }) : void 0 });
177
+ function Y(i) {
178
+ return s(s({}, i), { identity: i.identity ? s(s({}, i.identity), { traits: $(i.identity.traits || {}) }) : void 0 });
179
179
  }
180
- (function(r) {
181
- r.NONE = "NONE", r.DEFAULT_FLAGS = "DEFAULT_FLAGS", r.CACHE = "CACHE", r.SERVER = "SERVER";
180
+ (function(i) {
181
+ i.NONE = "NONE", i.DEFAULT_FLAGS = "DEFAULT_FLAGS", i.CACHE = "CACHE", i.SERVER = "SERVER";
182
182
  })(g || (g = {}));
183
- var _e, L = null, ut = "FLAGSMITH_EVENT", le = ut, Je = "https://edge.api.flagsmith.com/api/v1/", qe = "flagsmith_value_", Be = "flagsmith_enabled_", Me = "flagsmith_trait_", ct = function() {
184
- function r(t) {
183
+ var fe, F = null, ut = "FLAGSMITH_EVENT", le = ut, qe = "https://edge.api.flagsmith.com/api/v1/", Be = "flagsmith_value_", Me = "flagsmith_enabled_", ze = "flagsmith_trait_", ct = function() {
184
+ function i(t) {
185
185
  var e = this;
186
186
  this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
187
- var i = e, n = i.api, a = i.evaluationContext;
187
+ var r = e, n = r.api, a = r.evaluationContext;
188
188
  e.log("Get Flags"), e.isLoading = !0, e.loadingState.isFetching || e.setLoadingState(s(s({}, e.loadingState), { isFetching: !0 }));
189
189
  var o = "".concat(e.getContext().identity), v = function(d) {
190
- var p, u, y, O;
190
+ var p, c, y, k;
191
191
  if (d && o === "".concat(e.getContext().identity)) {
192
- var G = d.flags, I = d.traits, U = d.identifier;
192
+ var V = d.flags, P = d.traits, U = d.identifier;
193
193
  e.isLoading = !1;
194
- var P = {}, j = {};
195
- I = I || [], (G = G || []).forEach(function(m) {
196
- P[m.feature.name.toLowerCase().replace(/ /g, "_")] = { id: m.feature.id, enabled: m.enabled, value: m.feature_state_value };
197
- }), I.forEach(function(m) {
198
- j[m.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: m.transient, value: m.trait_value };
194
+ var j = {}, N = {};
195
+ P = P || [], (V = V || []).forEach(function(m) {
196
+ j[m.feature.name.toLowerCase().replace(/ /g, "_")] = { id: m.feature.id, enabled: m.enabled, value: m.feature_state_value };
197
+ }), P.forEach(function(m) {
198
+ N[m.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: m.transient, value: m.trait_value };
199
199
  }), e.oldFlags = s({}, e.flags);
200
- var V = w(e.oldFlags, P), ie = w((p = e.evaluationContext.identity) === null || p === void 0 ? void 0 : p.traits, j);
201
- if ((U || Object.keys(j).length) && (e.evaluationContext.identity = s(s({}, e.evaluationContext.identity), { traits: j }), U && (e.evaluationContext.identity.identifier = U)), e.flags = P, e.updateStorage(), e._onChange(e.oldFlags, { isFromServer: !0, flagsChanged: V, traitsChanged: ie }, e._loadedState(null, g.SERVER)), e.datadogRum) try {
200
+ var G = w(e.oldFlags, j), re = w((p = e.evaluationContext.identity) === null || p === void 0 ? void 0 : p.traits, N);
201
+ if ((U || Object.keys(N).length) && (e.evaluationContext.identity = s(s({}, e.evaluationContext.identity), { traits: N }), U && (e.evaluationContext.identity.identifier = U)), e.flags = j, e.updateStorage(), e._onChange(e.oldFlags, { isFromServer: !0, flagsChanged: G, traitsChanged: re }, e._loadedState(null, g.SERVER)), e.datadogRum) try {
202
202
  if (e.datadogRum.trackTraits) {
203
- var re = {};
204
- Object.keys(((u = e.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(m) {
205
- re[Me + m] = e.getTrait(m);
203
+ var ie = {};
204
+ Object.keys(((c = e.evaluationContext.identity) === null || c === void 0 ? void 0 : c.traits) || {}).map(function(m) {
205
+ ie[ze + m] = e.getTrait(m);
206
206
  });
207
- var Z = s(s(s({}, e.datadogRum.client.getUser()), { id: e.datadogRum.client.getUser().id || ((y = e.evaluationContext.identity) === null || y === void 0 ? void 0 : y.identifier) }), re);
207
+ var Z = s(s(s({}, e.datadogRum.client.getUser()), { id: e.datadogRum.client.getUser().id || ((y = e.evaluationContext.identity) === null || y === void 0 ? void 0 : y.identifier) }), ie);
208
208
  e.log("Setting Datadog user", Z), e.datadogRum.client.setUser(Z);
209
209
  }
210
210
  } catch (m) {
211
211
  console.error(m);
212
212
  }
213
213
  if (e.dtrum) try {
214
- var k = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
214
+ var T = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
215
215
  Object.keys(e.flags).map(function(m) {
216
- E(k, qe + m, e.getValue(m, { skipAnalytics: !0 })), E(k, Be + m, e.hasFeature(m, { skipAnalytics: !0 }));
217
- }), Object.keys(((O = e.evaluationContext.identity) === null || O === void 0 ? void 0 : O.traits) || {}).map(function(m) {
218
- E(k, Me + m, e.getTrait(m));
219
- }), e.log("Sending javaLongOrObject traits to dynatrace", k.javaLongOrObject), e.log("Sending date traits to dynatrace", k.date), e.log("Sending shortString traits to dynatrace", k.shortString), e.log("Sending javaDouble to dynatrace", k.javaDouble), e.dtrum.sendSessionProperties(k.javaLongOrObject, k.date, k.shortString, k.javaDouble);
216
+ E(T, Be + m, e.getValue(m, { skipAnalytics: !0 })), E(T, Me + m, e.hasFeature(m, { skipAnalytics: !0 }));
217
+ }), Object.keys(((k = e.evaluationContext.identity) === null || k === void 0 ? void 0 : k.traits) || {}).map(function(m) {
218
+ E(T, ze + m, e.getTrait(m));
219
+ }), e.log("Sending javaLongOrObject traits to dynatrace", T.javaLongOrObject), e.log("Sending date traits to dynatrace", T.date), e.log("Sending shortString traits to dynatrace", T.shortString), e.log("Sending javaDouble to dynatrace", T.javaDouble), e.dtrum.sendSessionProperties(T.javaLongOrObject, T.date, T.shortString, T.javaDouble);
220
220
  } catch (m) {
221
221
  console.error(m);
222
222
  }
223
223
  }
224
224
  };
225
225
  return a.identity ? Promise.all([a.identity.traits && Object.keys(a.identity.traits).length || !a.identity.identifier ? e.getJSON(n + "identities/", "POST", JSON.stringify({ identifier: a.identity.identifier, transient: a.identity.transient, traits: Object.entries(a.identity.traits).map(function(d) {
226
- var p = d[0], u = d[1];
227
- return { trait_key: p, trait_value: u == null ? void 0 : u.value, transient: u == null ? void 0 : u.transient };
226
+ var p = d[0], c = d[1];
227
+ return { trait_key: p, trait_value: c == null ? void 0 : c.value, transient: c == null ? void 0 : c.transient };
228
228
  }).filter(function(d) {
229
229
  return d.trait_value !== void 0 || (e.log("Warning - attempted to set an undefined trait value for key", d.trait_key), !1);
230
230
  }) })) : e.getJSON(n + "identities/?identifier=" + encodeURIComponent(a.identity.identifier) + (a.identity.transient ? "&transient=true" : ""))]).then(function(d) {
231
231
  return e.evaluationContext.identity = s(s({}, e.evaluationContext.identity), { traits: {} }), v(d == null ? void 0 : d[0]);
232
232
  }).catch(function(d) {
233
- var p = d.message, u = new Error(p);
234
- return Promise.reject(u);
233
+ var p = d.message, c = new Error(p);
234
+ return Promise.reject(c);
235
235
  }) : e.getJSON(n + "flags/").then(function(d) {
236
236
  return v({ flags: d, traits: void 0 });
237
237
  });
238
238
  }, this.analyticsFlags = function() {
239
- var i = e.api;
240
- if (e.evaluationEvent && e.evaluationContext.environment && e.evaluationEvent[e.evaluationContext.environment.apiKey]) return e.evaluationEvent && Object.getOwnPropertyNames(e.evaluationEvent).length !== 0 && Object.getOwnPropertyNames(e.evaluationEvent[e.evaluationContext.environment.apiKey]).length !== 0 ? e.getJSON(i + "analytics/flags/", "POST", JSON.stringify(e.evaluationEvent[e.evaluationContext.environment.apiKey])).then(function(n) {
239
+ var r = e.api;
240
+ if (e.evaluationEvent && e.evaluationContext.environment && e.evaluationEvent[e.evaluationContext.environment.apiKey]) return e.evaluationEvent && Object.getOwnPropertyNames(e.evaluationEvent).length !== 0 && Object.getOwnPropertyNames(e.evaluationEvent[e.evaluationContext.environment.apiKey]).length !== 0 ? e.getJSON(r + "analytics/flags/", "POST", JSON.stringify(e.evaluationEvent[e.evaluationContext.environment.apiKey])).then(function(n) {
241
241
  if (e.evaluationContext.environment) {
242
242
  var a = e.getState();
243
243
  e.evaluationEvent || (e.evaluationEvent = {}), e.evaluationEvent[e.evaluationContext.environment.apiKey] = {}, e.setState(s(s({}, a), { evaluationEvent: e.evaluationEvent })), e.updateEventStorage();
@@ -245,114 +245,114 @@ var Ve = { exports: {} };
245
245
  }).catch(function(n) {
246
246
  e.log("Exception fetching evaluationEvent", n);
247
247
  }) : void 0;
248
- }, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: g.NONE }, this.canUseStorage = !1, this.analyticsInterval = null, this.api = null, this.cacheFlags = !1, this.ts = null, this.enableAnalytics = !1, this.enableLogs = !1, this.evaluationContext = {}, this.evaluationEvent = null, this.flags = null, this.getFlagInterval = null, this.headers = null, this.initialised = !1, this.oldFlags = null, this.onChange = null, this.onError = null, this.ticks = null, this.timer = null, this.dtrum = null, this.withTraits = null, this.cacheOptions = { ttl: 0, skipAPI: !1, loadStale: !1, storageKey: void 0 }, this.getValue = function(i, n, a) {
249
- var o = e.flags && e.flags[i.toLowerCase().replace(/ /g, "_")], v = null;
250
- if (o && (v = o.value), n != null && n.skipAnalytics || a || e.evaluateFlag(i, "VALUE"), v === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
248
+ }, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: g.NONE }, this.canUseStorage = !1, this.analyticsInterval = null, this.api = null, this.cacheFlags = !1, this.ts = null, this.enableAnalytics = !1, this.enableLogs = !1, this.evaluationContext = {}, this.evaluationEvent = null, this.flags = null, this.getFlagInterval = null, this.headers = null, this.initialised = !1, this.oldFlags = null, this.onChange = null, this.onError = null, this.ticks = null, this.timer = null, this.dtrum = null, this.withTraits = null, this.cacheOptions = { ttl: 0, skipAPI: !1, loadStale: !1, storageKey: void 0 }, this.getValue = function(r, n, a) {
249
+ var o = e.flags && e.flags[r.toLowerCase().replace(/ /g, "_")], v = null;
250
+ if (o && (v = o.value), n != null && n.skipAnalytics || a || e.evaluateFlag(r, "VALUE"), v === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
251
251
  if (n != null && n.json) try {
252
- return v === null ? (e.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(v);
252
+ return v === null ? (e.log("Tried to parse null flag as JSON: " + r), null) : JSON.parse(v);
253
253
  } catch {
254
254
  return n.fallback;
255
255
  }
256
256
  return v;
257
- }, this.getTrait = function(i) {
257
+ }, this.getTrait = function(r) {
258
258
  var n, a;
259
- return ((n = e.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((a = e.evaluationContext.identity.traits[i.toLowerCase().replace(/ /g, "_")]) === null || a === void 0 ? void 0 : a.value);
259
+ return ((n = e.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((a = e.evaluationContext.identity.traits[r.toLowerCase().replace(/ /g, "_")]) === null || a === void 0 ? void 0 : a.value);
260
260
  }, this.getAllTraits = function() {
261
- var i;
262
- return Object.fromEntries(Object.entries(((i = e.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
261
+ var r;
262
+ return Object.fromEntries(Object.entries(((r = e.evaluationContext.identity) === null || r === void 0 ? void 0 : r.traits) || {}).map(function(n) {
263
263
  var a = n[0], o = n[1];
264
264
  return [a, o == null ? void 0 : o.value];
265
265
  }));
266
- }, this.setContext = function(i) {
267
- var n = Y(i);
266
+ }, this.setContext = function(r) {
267
+ var n = Y(r);
268
268
  return e.evaluationContext = s(s({}, n), { environment: n.environment || e.evaluationContext.environment }), e.initialised ? e.getFlags() : Promise.resolve();
269
269
  }, this.getContext = function() {
270
270
  return e.evaluationContext;
271
- }, this.updateContext = function(i) {
272
- return e.setContext(s(s({}, e.getContext()), i));
273
- }, this.setTrait = function(i, n) {
271
+ }, this.updateContext = function(r) {
272
+ return e.setContext(s(s({}, e.getContext()), r));
273
+ }, this.setTrait = function(r, n) {
274
274
  var a;
275
- if (e.api) return e.setContext(s(s({}, e.evaluationContext), { identity: s(s({}, e.evaluationContext.identity), { traits: s(s({}, (a = e.evaluationContext.identity) === null || a === void 0 ? void 0 : a.traits), $(Object.fromEntries([[i, n]]))) }) }));
276
- }, this.setTraits = function(i) {
275
+ if (e.api) return e.setContext(s(s({}, e.evaluationContext), { identity: s(s({}, e.evaluationContext.identity), { traits: s(s({}, (a = e.evaluationContext.identity) === null || a === void 0 ? void 0 : a.traits), $(Object.fromEntries([[r, n]]))) }) }));
276
+ }, this.setTraits = function(r) {
277
277
  var n;
278
- if (e.api) return e.setContext(s(s({}, e.evaluationContext), { identity: s(s({}, e.evaluationContext.identity), { traits: s(s({}, (n = e.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(a) {
278
+ if (e.api) return e.setContext(s(s({}, e.evaluationContext), { identity: s(s({}, e.evaluationContext.identity), { traits: s(s({}, (n = e.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(r).map(function(a) {
279
279
  var o = a[0], v = a[1];
280
280
  return [o, A(v) ? v : { value: v }];
281
281
  }))) }) }));
282
282
  console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.");
283
- }, this.hasFeature = function(i, n) {
284
- var a = typeof n == "object", o = e.flags && e.flags[i.toLowerCase().replace(/ /g, "_")], v = !1;
285
- return !o && a && n.fallback !== void 0 ? v = n == null ? void 0 : n.fallback : o && o.enabled && (v = !0), (a && !n.skipAnalytics || !n) && e.evaluateFlag(i, "ENABLED"), v;
283
+ }, this.hasFeature = function(r, n) {
284
+ var a = typeof n == "object", o = e.flags && e.flags[r.toLowerCase().replace(/ /g, "_")], v = !1;
285
+ return !o && a && n.fallback !== void 0 ? v = n == null ? void 0 : n.fallback : o && o.enabled && (v = !0), (a && !n.skipAnalytics || !n) && e.evaluateFlag(r, "ENABLED"), v;
286
286
  }, this.getStorageKey = function() {
287
- var i, n;
288
- return ((i = e.cacheOptions) === null || i === void 0 ? void 0 : i.storageKey) || "FLAGSMITH_DB_" + ((n = e.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
289
- }, this.getJSON = function(i, n, a) {
287
+ var r, n;
288
+ return ((r = e.cacheOptions) === null || r === void 0 ? void 0 : r.storageKey) || "FLAGSMITH_DB_" + ((n = e.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
289
+ }, this.getJSON = function(r, n, a) {
290
290
  var o, v = e;
291
291
  v.evaluationContext;
292
292
  var d = v.headers, p = { method: n || "GET", body: a, cache: "no-cache", headers: {} };
293
293
  e.evaluationContext.environment && (p.headers["X-Environment-Key"] = e.evaluationContext.environment.apiKey), n && n !== "GET" && (p.headers["Content-Type"] = "application/json; charset=utf-8"), d && Object.assign(p.headers, d), C || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
294
- var u = "".concat((o = e.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
295
- return C(i, p).then(function(y) {
296
- var O, G, I = "".concat((O = e.evaluationContext.identity) === null || O === void 0 ? void 0 : O.identifier);
297
- if (u === I) {
298
- var U = (G = y.headers) === null || G === void 0 ? void 0 : G.get("x-flagsmith-document-updated-at");
294
+ var c = "".concat((o = e.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
295
+ return C(r, p).then(function(y) {
296
+ var k, V, P = "".concat((k = e.evaluationContext.identity) === null || k === void 0 ? void 0 : k.identifier);
297
+ if (c === P) {
298
+ var U = (V = y.headers) === null || V === void 0 ? void 0 : V.get("x-flagsmith-document-updated-at");
299
299
  if (U) try {
300
- var P = parseFloat(U);
301
- if (isNaN(P)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
302
- e.timestamp = P;
303
- } catch (j) {
304
- e.log(j, "Failed to parse x-flagsmith-document-updated-at", U);
300
+ var j = parseFloat(U);
301
+ if (isNaN(j)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
302
+ e.timestamp = j;
303
+ } catch (N) {
304
+ e.log(N, "Failed to parse x-flagsmith-document-updated-at", U);
305
305
  }
306
- return e.log("Fetch response: " + y.status + " " + (n || "GET") + 0 + i), y.text().then(function(j) {
307
- var V = j;
306
+ return e.log("Fetch response: " + y.status + " " + (n || "GET") + 0 + r), y.text().then(function(N) {
307
+ var G = N;
308
308
  try {
309
- V = JSON.parse(j);
309
+ G = JSON.parse(N);
310
310
  } catch {
311
311
  }
312
- return !V && y.status && (V = "API Response: ".concat(y.status)), y.status && y.status >= 200 && y.status < 300 ? V : Promise.reject(new Error(V));
312
+ return !G && y.status && (G = "API Response: ".concat(y.status)), y.status && y.status >= 200 && y.status < 300 ? G : Promise.reject(new Error(G));
313
313
  });
314
314
  }
315
- e.log("Received response with identity mismatch, ignoring response. Requested: ".concat(u, ", Current: ").concat(I));
315
+ e.log("Received response with identity mismatch, ignoring response. Requested: ".concat(c, ", Current: ").concat(P));
316
316
  });
317
- }, this.evaluateFlag = function(i, n) {
318
- if (e.datadogRum && (e.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? e.datadogRum.client.addFeatureFlagEvaluation(qe + i, e.getValue(i, {}, !0)) : e.datadogRum.client.addFeatureFlagEvaluation(Be + i, e.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), e.enableAnalytics) {
317
+ }, this.evaluateFlag = function(r, n) {
318
+ if (e.datadogRum && (e.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? e.datadogRum.client.addFeatureFlagEvaluation(Be + r, e.getValue(r, {}, !0)) : e.datadogRum.client.addFeatureFlagEvaluation(Me + r, e.hasFeature(r, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), e.enableAnalytics) {
319
319
  if (!e.evaluationEvent || !e.evaluationContext.environment) return;
320
- e.evaluationEvent[e.evaluationContext.environment.apiKey] || (e.evaluationEvent[e.evaluationContext.environment.apiKey] = {}), e.evaluationEvent[e.evaluationContext.environment.apiKey][i] === void 0 && (e.evaluationEvent[e.evaluationContext.environment.apiKey][i] = 0), e.evaluationEvent[e.evaluationContext.environment.apiKey][i] += 1;
320
+ e.evaluationEvent[e.evaluationContext.environment.apiKey] || (e.evaluationEvent[e.evaluationContext.environment.apiKey] = {}), e.evaluationEvent[e.evaluationContext.environment.apiKey][r] === void 0 && (e.evaluationEvent[e.evaluationContext.environment.apiKey][r] = 0), e.evaluationEvent[e.evaluationContext.environment.apiKey][r] += 1;
321
321
  }
322
322
  e.updateEventStorage();
323
- }, this._onChange = function(i, n, a) {
323
+ }, this._onChange = function(r, n, a) {
324
324
  var o, v;
325
- e.setLoadingState(a), (o = e.onChange) === null || o === void 0 || o.call(e, i, n, e.loadingState), (v = e._trigger) === null || v === void 0 || v.call(e);
326
- }, C = t.fetch ? t.fetch : typeof fetch < "u" ? fetch : ve === null || ve === void 0 ? void 0 : ve.fetch, this.canUseStorage = typeof window < "u" || !!t.browserlessStorage, this.log("Constructing flagsmith instance " + t), t.eventSource && (_e = t.eventSource), t.AsyncStorage && (L = t.AsyncStorage);
325
+ e.setLoadingState(a), (o = e.onChange) === null || o === void 0 || o.call(e, r, n, e.loadingState), (v = e._trigger) === null || v === void 0 || v.call(e);
326
+ }, C = t.fetch ? t.fetch : typeof fetch < "u" ? fetch : ve === null || ve === void 0 ? void 0 : ve.fetch, this.canUseStorage = typeof window < "u" || !!t.browserlessStorage, this.log("Constructing flagsmith instance " + t), t.eventSource && (fe = t.eventSource), t.AsyncStorage && (F = t.AsyncStorage);
327
327
  }
328
- return r.prototype.init = function(t) {
329
- var e, i, n;
330
- return R(this, void 0, void 0, function() {
331
- var a, o, v, d, p, u, y, O, G, I, U, P, j, V, ie, re, Z, k, m, ge, ae, Ze, Q, pe, Qe, et, ye, tt, me, oe, ee, nt, T = this;
328
+ return i.prototype.init = function(t) {
329
+ var e, r, n;
330
+ return O(this, void 0, void 0, function() {
331
+ var a, o, v, d, p, c, y, k, V, P, U, j, N, G, re, ie, Z, T, m, pe, ae, Qe, Q, ye, et, tt, me, nt, be, oe, ee, rt, L = this;
332
332
  return K(this, function(D) {
333
333
  switch (D.label) {
334
334
  case 0:
335
335
  a = Y(t.evaluationContext || this.evaluationContext), D.label = 1;
336
336
  case 1:
337
- if (D.trys.push([1, 13, , 14]), o = t.environmentID, v = t.api, d = v === void 0 ? Je : v, p = t.headers, u = t.onChange, y = t.cacheFlags, O = t.datadogRum, G = t.onError, I = t.defaultFlags, U = t.fetch, P = t.preventFetch, j = t.enableLogs, V = t.enableDynatrace, ie = t.enableAnalytics, re = t.realtime, Z = t.eventSourceUrl, k = Z === void 0 ? "https://realtime.flagsmith.com/" : Z, m = t.AsyncStorage, ge = t.identity, ae = t.traits, Ze = t.state, Q = t.cacheOptions, pe = t.angularHttpClient, Qe = t._trigger, et = t._triggerLoadingState, a.environment = o ? { apiKey: o } : a.environment, !a.environment || !a.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
338
- if (a.identity = ge || ae ? { identifier: ge, traits: ae ? Object.fromEntries(Object.entries(ae).map(function(N) {
339
- return [N[0], { value: N[1] }];
340
- })) : {} } : a.identity, this.evaluationContext = a, this.api = d, this.headers = p, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, ye = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Qe || this._trigger, this._triggerLoadingState = et || this._triggerLoadingState, this.onError = function(N) {
341
- T.setLoadingState(s(s({}, T.loadingState), { isFetching: !1, isLoading: !1, error: N })), G == null || G(N);
342
- }, this.enableLogs = j || !1, this.cacheOptions = Q ? { skipAPI: !!Q.skipAPI, ttl: Q.ttl || 0, storageKey: Q.storageKey, loadStale: !!Q.loadStale } : this.cacheOptions, !this.cacheOptions.ttl && this.cacheOptions.skipAPI && console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."), U && (C = U), this.enableAnalytics = ie || !1, this.flags = Object.assign({}, I) || {}, this.datadogRum = O || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = L !== void 0 && !!y, le = "FLAGSMITH_EVENT_" + a.environment.apiKey, m && (L = m), re && typeof window < "u" && this.setupRealtime(k, a.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: g.DEFAULT_FLAGS })), this.setState(Ze), this.log("Initialising with properties", t, this), V && (typeof dtrum > "u" ? console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed.") : this.dtrum = dtrum), pe && (C = /* @__PURE__ */ function(N) {
337
+ if (D.trys.push([1, 13, , 14]), o = t.environmentID, v = t.api, d = v === void 0 ? qe : v, p = t.headers, c = t.onChange, y = t.cacheFlags, k = t.datadogRum, V = t.onError, P = t.defaultFlags, U = t.fetch, j = t.preventFetch, N = t.enableLogs, G = t.enableDynatrace, re = t.enableAnalytics, ie = t.realtime, Z = t.eventSourceUrl, T = Z === void 0 ? "https://realtime.flagsmith.com/" : Z, m = t.AsyncStorage, pe = t.identity, ae = t.traits, Qe = t.state, Q = t.cacheOptions, ye = t.angularHttpClient, et = t._trigger, tt = t._triggerLoadingState, a.environment = o ? { apiKey: o } : a.environment, !a.environment || !a.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
338
+ if (a.identity = pe || ae ? { identifier: pe, traits: ae ? Object.fromEntries(Object.entries(ae).map(function(R) {
339
+ return [R[0], { value: R[1] }];
340
+ })) : {} } : a.identity, this.evaluationContext = a, this.api = d, this.headers = p, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = c, me = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = et || this._trigger, this._triggerLoadingState = tt || this._triggerLoadingState, this.onError = function(R) {
341
+ L.setLoadingState(s(s({}, L.loadingState), { isFetching: !1, isLoading: !1, error: R })), V == null || V(R);
342
+ }, this.enableLogs = N || !1, this.cacheOptions = Q ? { skipAPI: !!Q.skipAPI, ttl: Q.ttl || 0, storageKey: Q.storageKey, loadStale: !!Q.loadStale } : this.cacheOptions, !this.cacheOptions.ttl && this.cacheOptions.skipAPI && console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."), U && (C = U), this.enableAnalytics = re || !1, this.flags = Object.assign({}, P) || {}, this.datadogRum = k || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = F !== void 0 && !!y, le = "FLAGSMITH_EVENT_" + a.environment.apiKey, m && (F = m), ie && typeof window < "u" && this.setupRealtime(T, a.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: g.DEFAULT_FLAGS })), this.setState(Qe), this.log("Initialising with properties", t, this), G && (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), ye && (C = /* @__PURE__ */ function(R) {
343
343
  return function(J, q) {
344
344
  var z = q.headers, x = q.method, te = q.body;
345
345
  return new Promise(function(X) {
346
346
  switch (x) {
347
347
  case "GET":
348
- return N.get(J, { headers: z }).subscribe(function(M) {
348
+ return R.get(J, { headers: z }).subscribe(function(M) {
349
349
  X({ ok: !0, text: function() {
350
350
  return Promise.resolve(M);
351
351
  } });
352
352
  });
353
353
  case "POST":
354
354
  case "PUT":
355
- return N.post(J, te, { headers: z }).subscribe(function(M) {
355
+ return R.post(J, te, { headers: z }).subscribe(function(M) {
356
356
  X({ ok: !0, text: function() {
357
357
  return Promise.resolve(M);
358
358
  } });
@@ -360,38 +360,38 @@ var Ve = { exports: {} };
360
360
  }
361
361
  });
362
362
  };
363
- }(pe)), L && this.canUseStorage && L.getItem(le).then(function(N) {
363
+ }(ye)), F && this.canUseStorage && F.getItem(le).then(function(R) {
364
364
  try {
365
- T.evaluationEvent = JSON.parse(N) || {};
365
+ L.evaluationEvent = JSON.parse(R) || {};
366
366
  } catch {
367
- T.evaluationEvent = {};
367
+ L.evaluationEvent = {};
368
368
  }
369
- T.analyticsInterval = setInterval(T.analyticsFlags, T.ticks);
370
- }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), L && this.canUseStorage && L.getItem(le, function(N, J) {
371
- if (J && T.evaluationContext.environment) {
369
+ L.analyticsInterval = setInterval(L.analyticsFlags, L.ticks);
370
+ }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), F && this.canUseStorage && F.getItem(le, function(R, J) {
371
+ if (J && L.evaluationContext.environment) {
372
372
  var q = JSON.parse(J);
373
- if (q[T.evaluationContext.environment.apiKey]) {
374
- var z = T.getState();
375
- T.log("Retrieved events from cache", J), T.setState(s(s({}, z), { evaluationEvent: q[T.evaluationContext.environment.apiKey] }));
373
+ if (q[L.evaluationContext.environment.apiKey]) {
374
+ var z = L.getState();
375
+ L.log("Retrieved events from cache", J), L.setState(s(s({}, z), { evaluationEvent: q[L.evaluationContext.environment.apiKey] }));
376
376
  }
377
377
  }
378
378
  })), !y) return [3, 9];
379
- if (!L || !this.canUseStorage) return [3, 8];
380
- tt = function(N, J) {
381
- return R(T, void 0, void 0, function() {
382
- var q, z, x, te, X, M, be, it, Se, Ce, xe, Ee, we, Oe, ke, Te, Le, Fe, Ae, Ie, Pe, je, Ne, Re, rt = this;
379
+ if (!F || !this.canUseStorage) return [3, 8];
380
+ nt = function(R, J) {
381
+ return O(L, void 0, void 0, function() {
382
+ var q, z, x, te, X, M, Se, it, Ce, xe, Ee, we, Oe, ke, Te, Le, Fe, Ie, Ae, Pe, je, Ne, Re, Ue, at = this;
383
383
  return K(this, function(H) {
384
384
  switch (H.label) {
385
385
  case 0:
386
386
  if (!J) return [3, 7];
387
387
  q = null, z = null, H.label = 1;
388
388
  case 1:
389
- return H.trys.push([1, 5, , 6]), x = JSON.parse(J), te = !1, X = !1, x && x.api === this.api && ((Ce = (Se = x.evaluationContext) === null || Se === void 0 ? void 0 : Se.environment) === null || Ce === void 0 ? void 0 : Ce.apiKey) === ((xe = this.evaluationContext.environment) === null || xe === void 0 ? void 0 : xe.apiKey) && (M = !0, this.evaluationContext.identity && ((we = (Ee = x.evaluationContext) === null || Ee === void 0 ? void 0 : Ee.identity) === null || we === void 0 ? void 0 : we.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((ke = (Oe = x.evaluationContext) === null || Oe === void 0 ? void 0 : Oe.identity) === null || ke === void 0 ? void 0 : ke.identifier) + " to " + this.evaluationContext.identity.identifier), M = !1), this.cacheOptions.ttl && (!x.ts || (/* @__PURE__ */ new Date()).valueOf() - x.ts > this.cacheOptions.ttl) && (x.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + x.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - x.ts) + "ms"), M = !1) : x.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + x.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - x.ts) + "ms"), X = !0, M = !0)), M && (te = !0, z = w((Te = this.evaluationContext.identity) === null || Te === void 0 ? void 0 : Te.traits, (Fe = (Le = x.evaluationContext) === null || Le === void 0 ? void 0 : Le.identity) === null || Fe === void 0 ? void 0 : Fe.traits), q = w(this.flags, x.flags), this.setState(s(s({}, x), { evaluationContext: Y(s(s({}, x.evaluationContext), { identity: !((Ae = x.evaluationContext) === null || Ae === void 0) && Ae.identity ? s(s({}, (Ie = x.evaluationContext) === null || Ie === void 0 ? void 0 : Ie.identity), { traits: s(s({}, ((je = (Pe = x.evaluationContext) === null || Pe === void 0 ? void 0 : Pe.identity) === null || je === void 0 ? void 0 : je.traits) || {}), ae || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", x))), te ? (be = !P && (!this.cacheOptions.skipAPI || X), this._onChange(null, { isFromServer: !1, flagsChanged: q, traitsChanged: z }, this._loadedState(null, g.CACHE, be)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && te && !X && this.log("Skipping API, using cache"), be && this.getFlags().catch(function(ht) {
390
- var Ue;
391
- (Ue = rt.onError) === null || Ue === void 0 || Ue.call(rt, ht);
389
+ return H.trys.push([1, 5, , 6]), x = JSON.parse(J), te = !1, X = !1, x && x.api === this.api && ((xe = (Ce = x.evaluationContext) === null || Ce === void 0 ? void 0 : Ce.environment) === null || xe === void 0 ? void 0 : xe.apiKey) === ((Ee = this.evaluationContext.environment) === null || Ee === void 0 ? void 0 : Ee.apiKey) && (M = !0, this.evaluationContext.identity && ((Oe = (we = x.evaluationContext) === null || we === void 0 ? void 0 : we.identity) === null || Oe === void 0 ? void 0 : Oe.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((Te = (ke = x.evaluationContext) === null || ke === void 0 ? void 0 : ke.identity) === null || Te === void 0 ? void 0 : Te.identifier) + " to " + this.evaluationContext.identity.identifier), M = !1), this.cacheOptions.ttl && (!x.ts || (/* @__PURE__ */ new Date()).valueOf() - x.ts > this.cacheOptions.ttl) && (x.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + x.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - x.ts) + "ms"), M = !1) : x.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + x.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - x.ts) + "ms"), X = !0, M = !0)), M && (te = !0, z = w((Le = this.evaluationContext.identity) === null || Le === void 0 ? void 0 : Le.traits, (Ie = (Fe = x.evaluationContext) === null || Fe === void 0 ? void 0 : Fe.identity) === null || Ie === void 0 ? void 0 : Ie.traits), q = w(this.flags, x.flags), this.setState(s(s({}, x), { evaluationContext: Y(s(s({}, x.evaluationContext), { identity: !((Ae = x.evaluationContext) === null || Ae === void 0) && Ae.identity ? s(s({}, (Pe = x.evaluationContext) === null || Pe === void 0 ? void 0 : Pe.identity), { traits: s(s({}, ((Ne = (je = x.evaluationContext) === null || je === void 0 ? void 0 : je.identity) === null || Ne === void 0 ? void 0 : Ne.traits) || {}), ae || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", x))), te ? (Se = !j && (!this.cacheOptions.skipAPI || X), this._onChange(null, { isFromServer: !1, flagsChanged: q, traitsChanged: z }, this._loadedState(null, g.CACHE, Se)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && te && !X && this.log("Skipping API, using cache"), Se && this.getFlags().catch(function(dt) {
390
+ var De;
391
+ (De = at.onError) === null || De === void 0 || De.call(at, dt);
392
392
  }), [3, 4]) : [3, 2];
393
393
  case 2:
394
- return P ? [3, 4] : [4, this.getFlags()];
394
+ return j ? [3, 4] : [4, this.getFlags()];
395
395
  case 3:
396
396
  H.sent(), H.label = 4;
397
397
  case 4:
@@ -401,14 +401,14 @@ var Ve = { exports: {} };
401
401
  case 6:
402
402
  return [3, 10];
403
403
  case 7:
404
- return P ? [3, 9] : [4, this.getFlags()];
404
+ return j ? [3, 9] : [4, this.getFlags()];
405
405
  case 8:
406
406
  return H.sent(), [3, 10];
407
407
  case 9:
408
- if (I) this._onChange(null, { isFromServer: !1, flagsChanged: w({}, this.flags), traitsChanged: w({}, (Ne = this.evaluationContext.identity) === null || Ne === void 0 ? void 0 : Ne.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
408
+ if (P) this._onChange(null, { isFromServer: !1, flagsChanged: w({}, this.flags), traitsChanged: w({}, (Re = this.evaluationContext.identity) === null || Re === void 0 ? void 0 : Re.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
409
409
  else {
410
- if (!this.flags) throw new Error(ye);
411
- this._onChange(null, { isFromServer: !1, flagsChanged: w({}, this.flags), traitsChanged: w({}, (Re = this.evaluationContext.identity) === null || Re === void 0 ? void 0 : Re.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
410
+ if (!this.flags) throw new Error(me);
411
+ this._onChange(null, { isFromServer: !1, flagsChanged: w({}, this.flags), traitsChanged: w({}, (Ue = this.evaluationContext.identity) === null || Ue === void 0 ? void 0 : Ue.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
412
412
  }
413
413
  H.label = 10;
414
414
  case 10:
@@ -418,155 +418,155 @@ var Ve = { exports: {} };
418
418
  });
419
419
  }, D.label = 2;
420
420
  case 2:
421
- return D.trys.push([2, 7, , 8]), L.getItemSync ? (me = L.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
421
+ return D.trys.push([2, 7, , 8]), F.getItemSync ? (be = F.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
422
422
  case 3:
423
- return [4, L.getItem(this.getStorageKey())];
423
+ return [4, F.getItem(this.getStorageKey())];
424
424
  case 4:
425
- me = D.sent(), D.label = 5;
425
+ be = D.sent(), D.label = 5;
426
426
  case 5:
427
- return [4, tt(null, me)];
427
+ return [4, nt(null, be)];
428
428
  case 6:
429
429
  case 7:
430
430
  return D.sent(), [3, 8];
431
431
  case 8:
432
432
  return [3, 12];
433
433
  case 9:
434
- return P ? [3, 11] : [4, this.getFlags()];
434
+ return j ? [3, 11] : [4, this.getFlags()];
435
435
  case 10:
436
436
  return D.sent(), [3, 12];
437
437
  case 11:
438
- if (I) this._onChange(null, { isFromServer: !1, flagsChanged: w({}, I), traitsChanged: w({}, (e = a.identity) === null || e === void 0 ? void 0 : e.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
439
- else if (this.flags && (oe = null, Object.keys(this.flags).length === 0 && (oe = ye), this._onChange(null, { isFromServer: !1, flagsChanged: w({}, this.flags), traitsChanged: w({}, (i = a.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(oe, g.DEFAULT_FLAGS)), oe)) throw new Error(oe);
438
+ if (P) this._onChange(null, { isFromServer: !1, flagsChanged: w({}, P), traitsChanged: w({}, (e = a.identity) === null || e === void 0 ? void 0 : e.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
439
+ else if (this.flags && (oe = null, Object.keys(this.flags).length === 0 && (oe = me), this._onChange(null, { isFromServer: !1, flagsChanged: w({}, this.flags), traitsChanged: w({}, (r = a.identity) === null || r === void 0 ? void 0 : r.traits) }, this._loadedState(oe, g.DEFAULT_FLAGS)), oe)) throw new Error(oe);
440
440
  D.label = 12;
441
441
  case 12:
442
442
  return [3, 14];
443
443
  case 13:
444
- throw ee = D.sent(), this.log("Error during initialisation ", ee), nt = ee instanceof Error ? ee : new Error("".concat(ee)), (n = this.onError) === null || n === void 0 || n.call(this, nt), ee;
444
+ throw ee = D.sent(), this.log("Error during initialisation ", ee), rt = ee instanceof Error ? ee : new Error("".concat(ee)), (n = this.onError) === null || n === void 0 || n.call(this, rt), ee;
445
445
  case 14:
446
446
  return [2];
447
447
  }
448
448
  });
449
449
  });
450
- }, r.prototype.getAllFlags = function() {
450
+ }, i.prototype.getAllFlags = function() {
451
451
  return this.flags;
452
- }, r.prototype.identify = function(t, e, i) {
453
- return this.evaluationContext.identity = { identifier: t, transient: i, traits: this.evaluationContext.identity && this.evaluationContext.identity.identifier == t ? this.evaluationContext.identity.traits : {} }, this.evaluationContext.identity.identifier = t, this.log("Identify: " + this.evaluationContext.identity.identifier), e && (this.evaluationContext.identity.traits = Object.fromEntries(Object.entries(e).map(function(n) {
452
+ }, i.prototype.identify = function(t, e, r) {
453
+ return this.evaluationContext.identity = { identifier: t, transient: r, traits: this.evaluationContext.identity && this.evaluationContext.identity.identifier == t ? this.evaluationContext.identity.traits : {} }, this.evaluationContext.identity.identifier = t, this.log("Identify: " + this.evaluationContext.identity.identifier), e && (this.evaluationContext.identity.traits = Object.fromEntries(Object.entries(e).map(function(n) {
454
454
  var a = n[0], o = n[1];
455
455
  return [a, A(o) ? o : { value: o }];
456
456
  }))), this.initialised ? this.getFlags() : Promise.resolve();
457
- }, r.prototype.getState = function() {
457
+ }, i.prototype.getState = function() {
458
458
  return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
459
- }, r.prototype.setState = function(t) {
460
- t && (this.initialised = !0, this.api = t.api || this.api || Je, this.flags = t.flags || this.flags, this.evaluationContext = t.evaluationContext || this.evaluationContext, this.evaluationEvent = t.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
461
- }, r.prototype.logout = function() {
459
+ }, i.prototype.setState = function(t) {
460
+ t && (this.initialised = !0, this.api = t.api || this.api || qe, this.flags = t.flags || this.flags, this.evaluationContext = t.evaluationContext || this.evaluationContext, this.evaluationEvent = t.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
461
+ }, i.prototype.logout = function() {
462
462
  return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
463
- }, r.prototype.startListening = function(t) {
463
+ }, i.prototype.startListening = function(t) {
464
464
  t === void 0 && (t = 1e3), this.getFlagInterval && clearInterval(this.getFlagInterval), this.getFlagInterval = setInterval(this.getFlags, t);
465
- }, r.prototype.stopListening = function() {
465
+ }, i.prototype.stopListening = function() {
466
466
  this.getFlagInterval && (clearInterval(this.getFlagInterval), this.getFlagInterval = null);
467
- }, r.prototype._loadedState = function(t, e, i) {
468
- return t === void 0 && (t = null), i === void 0 && (i = !1), { error: t, isFetching: i, isLoading: !1, source: e };
469
- }, r.prototype.log = function() {
467
+ }, i.prototype._loadedState = function(t, e, r) {
468
+ return t === void 0 && (t = null), r === void 0 && (r = !1), { error: t, isFetching: r, isLoading: !1, source: e };
469
+ }, i.prototype.log = function() {
470
470
  for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
471
- this.enableLogs && console.log.apply(this, F(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], t));
472
- }, r.prototype.updateStorage = function() {
471
+ this.enableLogs && console.log.apply(this, I(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], t));
472
+ }, i.prototype.updateStorage = function() {
473
473
  if (this.cacheFlags) {
474
474
  this.ts = (/* @__PURE__ */ new Date()).valueOf();
475
475
  var t = JSON.stringify(this.getState());
476
- this.log("Setting storage", t), L.setItem(this.getStorageKey(), t);
476
+ this.log("Setting storage", t), F.setItem(this.getStorageKey(), t);
477
477
  }
478
- }, r.prototype.updateEventStorage = function() {
478
+ }, i.prototype.updateEventStorage = function() {
479
479
  if (this.enableAnalytics) {
480
480
  var t = JSON.stringify(this.getState().evaluationEvent);
481
- L.setItem(le, t).catch(function(e) {
481
+ F.setItem(le, t).catch(function(e) {
482
482
  return console.error("Flagsmith: Error setting item in async storage", e);
483
483
  });
484
484
  }
485
- }, r.prototype.setLoadingState = function(t) {
485
+ }, i.prototype.setLoadingState = function(t) {
486
486
  var e;
487
487
  W(t, this.loadingState) || (this.loadingState = s({}, t), this.log("Loading state changed", t), (e = this._triggerLoadingState) === null || e === void 0 || e.call(this));
488
- }, r.prototype.setupRealtime = function(t, e) {
489
- var i = this, n = t + "sse/environments/" + e + "/stream";
490
- _e ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new _e(n), this.eventSource.addEventListener("environment_updated", function(a) {
488
+ }, i.prototype.setupRealtime = function(t, e) {
489
+ var r = this, n = t + "sse/environments/" + e + "/stream";
490
+ fe ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new fe(n), this.eventSource.addEventListener("environment_updated", function(a) {
491
491
  var o;
492
492
  try {
493
493
  o = JSON.parse(a.data).updated_at;
494
494
  } catch (v) {
495
- i.log("Could not parse sse event", v);
495
+ r.log("Could not parse sse event", v);
496
496
  }
497
- o ? !i.timestamp || o > i.timestamp ? i.isLoading ? i.log("updated_at is new, but flags are loading", a.data, i.timestamp) : (i.log("updated_at is new, fetching flags", a.data, i.timestamp), i.getFlags()) : i.log("updated_at is outdated, skipping get flags", a.data, i.timestamp) : i.log("No updated_at received, fetching flags", a);
497
+ o ? !r.timestamp || o > r.timestamp ? r.isLoading ? r.log("updated_at is new, but flags are loading", a.data, r.timestamp) : (r.log("updated_at is new, fetching flags", a.data, r.timestamp), r.getFlags()) : r.log("updated_at is outdated, skipping get flags", a.data, r.timestamp) : r.log("No updated_at received, fetching flags", a);
498
498
  })) : this.log("Error, EventSource is undefined");
499
- }, r;
499
+ }, i;
500
500
  }();
501
- function ze(r) {
502
- var t = r.fetch, e = r.AsyncStorage, i = r.eventSource;
503
- return new ct({ fetch: t, AsyncStorage: e, eventSource: i });
501
+ function He(i) {
502
+ var t = i.fetch, e = i.AsyncStorage, r = i.eventSource;
503
+ return new ct({ fetch: t, AsyncStorage: e, eventSource: r });
504
504
  }
505
- var ue, vt = (ue = function(r, t) {
506
- return ue = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, i) {
507
- e.__proto__ = i;
508
- } || function(e, i) {
509
- for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (e[n] = i[n]);
510
- }, ue(r, t);
511
- }, function(r, t) {
505
+ var ue, vt = (ue = function(i, t) {
506
+ return ue = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
507
+ e.__proto__ = r;
508
+ } || function(e, r) {
509
+ for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
510
+ }, ue(i, t);
511
+ }, function(i, t) {
512
512
  if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
513
513
  function e() {
514
- this.constructor = r;
514
+ this.constructor = i;
515
515
  }
516
- ue(r, t), r.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
517
- }), He = function(r) {
518
- var t = typeof Symbol == "function" && Symbol.iterator, e = t && r[t], i = 0;
519
- if (e) return e.call(r);
520
- if (r && typeof r.length == "number") return { next: function() {
521
- return r && i >= r.length && (r = void 0), { value: r && r[i++], done: !r };
516
+ ue(i, t), i.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
517
+ }), $e = function(i) {
518
+ var t = typeof Symbol == "function" && Symbol.iterator, e = t && i[t], r = 0;
519
+ if (e) return e.call(i);
520
+ if (i && typeof i.length == "number") return { next: function() {
521
+ return i && r >= i.length && (i = void 0), { value: i && i[r++], done: !i };
522
522
  } };
523
523
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
524
- }, $e = function(r, t) {
525
- var e = typeof Symbol == "function" && r[Symbol.iterator];
526
- if (!e) return r;
527
- var i, n, a = e.call(r), o = [];
524
+ }, Xe = function(i, t) {
525
+ var e = typeof Symbol == "function" && i[Symbol.iterator];
526
+ if (!e) return i;
527
+ var r, n, a = e.call(i), o = [];
528
528
  try {
529
- for (; (t === void 0 || t-- > 0) && !(i = a.next()).done; ) o.push(i.value);
529
+ for (; (t === void 0 || t-- > 0) && !(r = a.next()).done; ) o.push(r.value);
530
530
  } catch (v) {
531
531
  n = { error: v };
532
532
  } finally {
533
533
  try {
534
- i && !i.done && (e = a.return) && e.call(a);
534
+ r && !r.done && (e = a.return) && e.call(a);
535
535
  } finally {
536
536
  if (n) throw n.error;
537
537
  }
538
538
  }
539
539
  return o;
540
- }, fe = function(r, t, e) {
541
- if (arguments.length === 2) for (var i, n = 0, a = t.length; n < a; n++) !i && n in t || (i || (i = Array.prototype.slice.call(t, 0, n)), i[n] = t[n]);
542
- return r.concat(i || Array.prototype.slice.call(t));
543
- }, dt = function(r) {
540
+ }, ge = function(i, t, e) {
541
+ if (arguments.length === 2) for (var r, n = 0, a = t.length; n < a; n++) !r && n in t || (r || (r = Array.prototype.slice.call(t, 0, n)), r[n] = t[n]);
542
+ return i.concat(r || Array.prototype.slice.call(t));
543
+ }, _t = function(i) {
544
544
  function t() {
545
- return r.call(this, `EventSource not available.
545
+ return i.call(this, `EventSource not available.
546
546
  Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
547
547
  }
548
- return vt(t, r), t;
549
- }(Error), Xe = function() {
550
- function r(t, e) {
551
- var i = this;
552
- if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = e != null ? Object.assign({}, e) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = t.toString(), this.readyState = this.CONNECTING, this.max_retry_time = 3e3, this.eventSourceClass = globalThis.FlagsmithEventSource, this._configuration != null && (this._configuration.lastEventId && (this._lastEventId = this._configuration.lastEventId, delete this._configuration.lastEventId), this._configuration.max_retry_time && (this.max_retry_time = this._configuration.max_retry_time, delete this._configuration.max_retry_time), this._configuration.eventSourceClass && (this.eventSourceClass = this._configuration.eventSourceClass, delete this._configuration.eventSourceClass)), this.eventSourceClass == null || typeof this.eventSourceClass != "function") throw new dt();
548
+ return vt(t, i), t;
549
+ }(Error), We = function() {
550
+ function i(t, e) {
551
+ var r = this;
552
+ if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = e != null ? Object.assign({}, e) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = t.toString(), this.readyState = this.CONNECTING, this.max_retry_time = 3e3, this.eventSourceClass = globalThis.FlagsmithEventSource, this._configuration != null && (this._configuration.lastEventId && (this._lastEventId = this._configuration.lastEventId, delete this._configuration.lastEventId), this._configuration.max_retry_time && (this.max_retry_time = this._configuration.max_retry_time, delete this._configuration.max_retry_time), this._configuration.eventSourceClass && (this.eventSourceClass = this._configuration.eventSourceClass, delete this._configuration.eventSourceClass)), this.eventSourceClass == null || typeof this.eventSourceClass != "function") throw new _t();
553
553
  this._onevent_wrapped = function(n) {
554
- i._onevent(n);
554
+ r._onevent(n);
555
555
  }, this._start();
556
556
  }
557
- return r.prototype.dispatchEvent = function(t) {
557
+ return i.prototype.dispatchEvent = function(t) {
558
558
  throw new Error("Method not implemented.");
559
- }, r.prototype._start = function() {
560
- var t, e, i = this, n = this.url;
559
+ }, i.prototype._start = function() {
560
+ var t, e, r = this, n = this.url;
561
561
  this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(d) {
562
- i._onopen(d);
562
+ r._onopen(d);
563
563
  }, this._eventSource.onerror = function(d) {
564
- i._onerror(d);
564
+ r._onerror(d);
565
565
  }, this._eventSource.onmessage = function(d) {
566
- i.onmessage(d);
566
+ r.onmessage(d);
567
567
  };
568
568
  try {
569
- for (var a = He(Object.keys(this._listeners)), o = a.next(); !o.done; o = a.next()) {
569
+ for (var a = $e(Object.keys(this._listeners)), o = a.next(); !o.done; o = a.next()) {
570
570
  var v = o.value;
571
571
  this._eventSource.addEventListener(v, this._onevent_wrapped);
572
572
  }
@@ -579,53 +579,53 @@ Consider loading an EventSource polyfill and making it available globally as Eve
579
579
  if (t) throw t.error;
580
580
  }
581
581
  }
582
- }, r.prototype._onopen = function(t) {
582
+ }, i.prototype._onopen = function(t) {
583
583
  this.readyState === 0 && (this.readyState = 1, this.onopen(t));
584
- }, r.prototype._onerror = function(t) {
584
+ }, i.prototype._onerror = function(t) {
585
585
  var e = this;
586
586
  if (this.readyState === 1 && (this.readyState = 0, this.onerror(t)), this._eventSource) {
587
587
  this._eventSource.close(), this._eventSource = null;
588
- var i = Math.round(this.max_retry_time * Math.random());
588
+ var r = Math.round(this.max_retry_time * Math.random());
589
589
  this._timer = setTimeout(function() {
590
590
  return e._start();
591
- }, i);
591
+ }, r);
592
592
  }
593
- }, r.prototype._onevent = function(t) {
594
- var e, i;
593
+ }, i.prototype._onevent = function(t) {
594
+ var e, r;
595
595
  t && t.lastEventId && (this._lastEventId = t.lastEventId);
596
596
  var n = this._listeners[t.type];
597
597
  if (n != null) try {
598
- for (var a = He(fe([], $e(n), !1)), o = a.next(); !o.done; o = a.next())
598
+ for (var a = $e(ge([], Xe(n), !1)), o = a.next(); !o.done; o = a.next())
599
599
  o.value.call(this, t);
600
600
  } catch (v) {
601
601
  e = { error: v };
602
602
  } finally {
603
603
  try {
604
- o && !o.done && (i = a.return) && i.call(a);
604
+ o && !o.done && (r = a.return) && r.call(a);
605
605
  } finally {
606
606
  if (e) throw e.error;
607
607
  }
608
608
  }
609
609
  t.type === "message" && this.onmessage(t);
610
- }, r.prototype.onopen = function(t) {
611
- }, r.prototype.onerror = function(t) {
612
- }, r.prototype.onmessage = function(t) {
613
- }, r.prototype.close = function() {
610
+ }, i.prototype.onopen = function(t) {
611
+ }, i.prototype.onerror = function(t) {
612
+ }, i.prototype.onmessage = function(t) {
613
+ }, i.prototype.close = function() {
614
614
  this._timer && (clearTimeout(this._timer), this._timer = null), this._eventSource && (this._eventSource.close(), this._eventSource = null), this.readyState = 2;
615
- }, r.prototype.addEventListener = function(t, e, i) {
615
+ }, i.prototype.addEventListener = function(t, e, r) {
616
616
  this._listeners[t] == null && (this._listeners[t] = [], this._eventSource != null && this._eventSource.addEventListener(t, this._onevent_wrapped));
617
617
  var n = this._listeners[t];
618
- n.includes(e) || (this._listeners[t] = fe(fe([], $e(n), !1), [e], !1));
619
- }, r.prototype.removeEventListener = function(t, e, i) {
618
+ n.includes(e) || (this._listeners[t] = ge(ge([], Xe(n), !1), [e], !1));
619
+ }, i.prototype.removeEventListener = function(t, e, r) {
620
620
  var n = this._listeners[t];
621
621
  this._listeners[t] = n.filter(function(a) {
622
622
  return a !== e;
623
623
  });
624
- }, r;
624
+ }, i;
625
625
  }();
626
626
  globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
627
- var We = function(r, t) {
628
- return t = t || {}, new Promise(function(e, i) {
627
+ var Ye = function(i, t) {
628
+ return t = t || {}, new Promise(function(e, r) {
629
629
  var n = new XMLHttpRequest(), a = [], o = [], v = {}, d = function() {
630
630
  return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
631
631
  return Promise.resolve(n.responseText);
@@ -637,32 +637,32 @@ Consider loading an EventSource polyfill and making it available globally as Eve
637
637
  return a;
638
638
  }, entries: function() {
639
639
  return o;
640
- }, get: function(u) {
641
- return v[u.toLowerCase()];
642
- }, has: function(u) {
643
- return u.toLowerCase() in v;
640
+ }, get: function(c) {
641
+ return v[c.toLowerCase()];
642
+ }, has: function(c) {
643
+ return c.toLowerCase() in v;
644
644
  } } };
645
645
  };
646
- for (var p in n.open(t.method || "get", r, !0), n.onload = function() {
647
- n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(u, y, O) {
648
- a.push(y = y.toLowerCase()), o.push([y, O]), v[y] = v[y] ? v[y] + "," + O : O;
646
+ for (var p in n.open(t.method || "get", i, !0), n.onload = function() {
647
+ n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(c, y, k) {
648
+ a.push(y = y.toLowerCase()), o.push([y, k]), v[y] = v[y] ? v[y] + "," + k : k;
649
649
  }), e(d());
650
- }, n.onerror = i, n.withCredentials = t.credentials == "include", t.headers) n.setRequestHeader(p, t.headers[p]);
650
+ }, n.onerror = r, n.withCredentials = t.credentials == "include", t.headers) n.setRequestHeader(p, t.headers[p]);
651
651
  n.send(t.body || null);
652
652
  });
653
- }, Ye = ze({ AsyncStorage: f, fetch: We, eventSource: Xe });
654
- typeof window < "u" && (window.flagsmith = Ye), h.createFlagsmithInstance = function() {
655
- return ze({ AsyncStorage: f, fetch: We, eventSource: Xe });
656
- }, h.default = Ye, Object.defineProperty(h, "__esModule", { value: !0 });
653
+ }, Ze = He({ AsyncStorage: f, fetch: Ye, eventSource: We });
654
+ typeof window < "u" && (window.flagsmith = Ze), _.createFlagsmithInstance = function() {
655
+ return He({ AsyncStorage: f, fetch: Ye, eventSource: We });
656
+ }, _.default = Ze, Object.defineProperty(_, "__esModule", { value: !0 });
657
657
  });
658
- })(Ve, Ve.exports);
659
- var pt = Ve.exports, yt = {
658
+ })(Je, Je.exports);
659
+ var pt = Je.exports, yt = {
660
660
  NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first.",
661
661
  INVALID_CONFIG: "Invalid Flagsmith configuration",
662
662
  FETCH_FAILED: "Failed to fetch Flagsmith configuration",
663
663
  NO_USER_CONTEXT: "User context not set. Call setUser() first.",
664
664
  ALREADY_INITIALIZED: "FeatureFlag is already initialized."
665
- }, ot = "business", B, mt = (B = class {
665
+ }, st = "business", B, mt = (B = class {
666
666
  constructor() {
667
667
  ce(this, "flagsmithClient", null);
668
668
  ce(this, "userContext", null);
@@ -674,24 +674,24 @@ var pt = Ve.exports, yt = {
674
674
  if (!this.flagsmithClient)
675
675
  throw new Error(yt.NOT_INITIALIZED);
676
676
  }
677
- async init(c, h = []) {
677
+ async init(u, _ = []) {
678
678
  if (!this.flagsmithClient)
679
679
  try {
680
680
  this.flagsmithClient = pt.createFlagsmithInstance();
681
- const f = h.reduce((s, R) => (s[R.feature.name] = R, s), {});
681
+ const f = _.reduce((s, O) => (s[O.feature.name] = O, s), {});
682
682
  await this.flagsmithClient.init({
683
- environmentID: c.apiKey,
684
- api: (c == null ? void 0 : c.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
685
- enableAnalytics: (c == null ? void 0 : c.enableAnalytics) ?? !0,
683
+ environmentID: u.apiKey,
684
+ api: (u == null ? void 0 : u.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
685
+ enableAnalytics: (u == null ? void 0 : u.enableAnalytics) ?? !0,
686
686
  defaultFlags: f,
687
- cacheFlags: (c == null ? void 0 : c.cacheFlags) ?? !0
687
+ cacheFlags: (u == null ? void 0 : u.cacheFlags) ?? !0
688
688
  });
689
689
  } catch (f) {
690
690
  throw console.error("Failed to initialize FeatureFlag:", f), f;
691
691
  }
692
692
  }
693
- async setUser(c) {
694
- this.ensureInitialized(), this.userContext = { identifier: c }, await this.updateContext();
693
+ async setUser(u) {
694
+ this.ensureInitialized(), this.userContext = { identifier: u }, await this.updateContext();
695
695
  }
696
696
  async updateContext() {
697
697
  try {
@@ -701,18 +701,18 @@ var pt = Ve.exports, yt = {
701
701
  identifier: this.userContext.identifier
702
702
  }
703
703
  });
704
- } catch (c) {
705
- throw console.error("Failed to update user context:", c), c;
704
+ } catch (u) {
705
+ throw console.error("Failed to update user context:", u), u;
706
706
  }
707
707
  }
708
708
  async getFlags() {
709
709
  this.ensureInitialized();
710
- const c = this.flagsmithClient.getAllFlags();
711
- return Object.entries(c).map(([h, f]) => {
710
+ const u = this.flagsmithClient.getAllFlags();
711
+ return Object.entries(u).map(([_, f]) => {
712
712
  var s;
713
713
  return {
714
714
  feature: {
715
- name: h,
715
+ name: _,
716
716
  id: (f == null ? void 0 : f.id) ?? 0
717
717
  },
718
718
  enabled: f.enabled,
@@ -720,114 +720,114 @@ var pt = Ve.exports, yt = {
720
720
  };
721
721
  });
722
722
  }
723
- getFlagValue(c, h) {
723
+ getFlagValue(u, _) {
724
724
  this.ensureInitialized();
725
- const f = this.flagsmithClient.getValue(c);
725
+ const f = this.flagsmithClient.getValue(u);
726
726
  if (f == null)
727
727
  return null;
728
728
  try {
729
729
  const s = f.toString();
730
- return h ? h(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
730
+ return _ ? _(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
731
731
  } catch (s) {
732
732
  return console.error("Error transforming flag value:", s), null;
733
733
  }
734
734
  }
735
- getFlag(c) {
735
+ getFlag(u) {
736
736
  this.ensureInitialized();
737
- const h = this.flagsmithClient.getValue(c);
738
- if (h == null) return null;
739
- const f = this.flagsmithClient.hasFeature(c);
737
+ const _ = this.flagsmithClient.getValue(u);
738
+ if (_ == null) return null;
739
+ const f = this.flagsmithClient.hasFeature(u);
740
740
  return {
741
741
  feature: {
742
- name: c,
742
+ name: u,
743
743
  id: 0
744
744
  },
745
745
  enabled: f,
746
- value: h.toString()
746
+ value: _.toString()
747
747
  };
748
748
  }
749
- async getUserFlagValue(c, h, f = null, s) {
749
+ async getUserFlagValue(u, _, f = null, s) {
750
750
  var K;
751
- const R = this.userContext;
751
+ const O = this.userContext;
752
752
  try {
753
- return await this.setUser(c), this.getFlagValue(h, s) ?? f;
754
- } catch (F) {
755
- return console.error(`Error getting user flag value for ${h}:`, F), f;
753
+ return await this.setUser(u), this.getFlagValue(_, s) ?? f;
754
+ } catch (I) {
755
+ return console.error(`Error getting user flag value for ${_}:`, I), f;
756
756
  } finally {
757
757
  try {
758
- await ((K = this.flagsmithClient) == null ? void 0 : K.logout()), this.userContext = null, R && await this.setUser(R.identifier);
759
- } catch (F) {
760
- console.error("Error during cleanup:", F);
758
+ await ((K = this.flagsmithClient) == null ? void 0 : K.logout()), this.userContext = null, O && await this.setUser(O.identifier);
759
+ } catch (I) {
760
+ console.error("Error during cleanup:", I);
761
761
  }
762
762
  }
763
763
  }
764
764
  reset() {
765
765
  this.flagsmithClient = null, this.userContext = null;
766
766
  }
767
- }, ce(B, "instance"), B), bt = mt.getInstance(), se = he(!1), de = he([]), ne = he(null);
767
+ }, ce(B, "instance"), B), bt = mt.getInstance(), se = de(!1), _e = de([]), ne = de(null);
768
768
  function St(l = bt) {
769
- const c = () => se.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), h = async (g, C = []) => {
769
+ const u = () => se.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), _ = async (g, C = []) => {
770
770
  if (se.value) {
771
771
  console.warn("FeatureFlag is already initialized.");
772
772
  return;
773
773
  }
774
774
  try {
775
- await l.init(g, C), de.value = await l.getFlags(), se.value = !0, ne.value = null;
775
+ await l.init(g, C), _e.value = await l.getFlags(), se.value = !0, ne.value = null;
776
776
  } catch (E) {
777
777
  console.error("Failed to initialize feature flags:", E), ne.value = E;
778
778
  }
779
779
  }, f = async (g) => {
780
- if (c())
780
+ if (u())
781
781
  try {
782
- await l.setUser(g), de.value = await l.getFlags(), ne.value = null;
782
+ await l.setUser(g), _e.value = await l.getFlags(), ne.value = null;
783
783
  } catch (C) {
784
784
  console.error("Failed to set user:", C), ne.value = C;
785
785
  }
786
- }, s = async (g) => f(`${ot}-${g}`), R = (g, C, E = null) => {
787
- if (!c()) return E;
786
+ }, s = async (g) => f(`${st}-${g}`), O = (g, C, E = null) => {
787
+ if (!u()) return E;
788
788
  try {
789
789
  return l.getFlagValue(g, C) ?? E;
790
790
  } catch (A) {
791
791
  return console.error(`Error getting flag value for ${g}:`, A), E;
792
792
  }
793
793
  }, K = (g, C) => {
794
- if (!c()) return C ?? null;
794
+ if (!u()) return C ?? null;
795
795
  try {
796
796
  return l.getFlag(g) ?? C ?? null;
797
797
  } catch (E) {
798
798
  return console.error(`Error getting flag for ${g}:`, E), C ?? null;
799
799
  }
800
- }, F = async (g, C, E = null, A) => {
801
- if (!c()) return E;
800
+ }, I = async (g, C, E = null, A) => {
801
+ if (!u()) return E;
802
802
  try {
803
803
  return await l.getUserFlagValue(g, C, E, A);
804
804
  } catch ($) {
805
805
  return console.error(`Error getting user flag value for ${C}:`, $), E;
806
806
  }
807
- }, W = async (g, C, E = null, A) => F(`${ot}-${g}`, C, E, A), w = () => {
807
+ }, W = async (g, C, E = null, A) => I(`${st}-${g}`, C, E, A), w = () => {
808
808
  try {
809
809
  l.reset();
810
810
  } catch (g) {
811
811
  console.error("Error resetting feature flags:", g);
812
812
  } finally {
813
- de.value = [], se.value = !1, ne.value = null;
813
+ _e.value = [], se.value = !1, ne.value = null;
814
814
  }
815
815
  };
816
816
  return {
817
- flags: Ge(de),
817
+ flags: Ge(_e),
818
818
  isInitialized: Ge(se),
819
819
  error: Ge(ne),
820
- init: h,
820
+ init: _,
821
821
  setUser: f,
822
822
  setBusiness: s,
823
- getFlagValue: R,
823
+ getFlagValue: O,
824
824
  getFlag: K,
825
- getUserFlagValue: F,
825
+ getUserFlagValue: I,
826
826
  getBusinessFlagValue: W,
827
827
  reset: w
828
828
  };
829
829
  }
830
- var st = () => St(), b = /* @__PURE__ */ ((l) => (l.inventory_portal_must_use_transfer_template = "inventory_portal_must_use_transfer_template", l.inventory_portal_use_iframe = "inventory_portal_use_iframe", l.inventory_pos_adjust_v1 = "inventory_pos_adjust_v1", l.inventory_pos_adjust_v2_wastage = "inventory_pos_adjust_v2_wastage", l.inventory_pos_closing_recalculation = "inventory_pos_closing_recalculation", l.inventory_pos_closing_v1 = "inventory_pos_closing_v1", l.inventory_pos_closing_v2 = "inventory_pos_closing_v2", l.inventory_pos_convert_v1 = "inventory_pos_convert_v1", l.inventory_pos_costing = "inventory_pos_costing", l.inventory_pos_stock_return = "inventory_pos_stock_return", l.inventory_pos_transfer_require_fulfillment = "inventory_pos_transfer_require_fulfillment", l.inventory_purchase_order_approval = "inventory_purchase_order_approval", l.inventory_portal_xilnex_transfer_note = "inventory_portal_xilnex_transfer_note", l.inventory_portal_custom_attribute = "inventory_portal_custom_attribute", l.inventory_portal_purchase_order_v2 = "inventory_portal_purchase_order_v2", l.inventory_portal_accept_require_fulfillment = "inventory_portal_accept_require_fulfillment", l.inventory_portal_po_operate_v2 = "inventory_portal_po_operate_v2", l.inventory_pos_allow_receive_order = "inventory_pos_allow_receive_order", l.inventory_xilnex_opening_migration = "inventory_xilnex_opening_migration", l.inventory_ingredient_group = "inventory_ingredient_group", l.inventory_purchase_order_backdate = "inventory_purchase_order_backdate", l.inventory_synergy_opening_migration = "inventory_synergy_opening_migration", l.inventory_netsuite_inventory_transfer_out = "inventory_netsuite_inventory_transfer_out", l.inventory_portal_supplier_preparation_time = "inventory_portal_supplier_preparation_time", l.inventory_backdate_receive = "inventory_backdate_receive", l.inventory_portal_delivery_order_write = "inventory_portal_delivery_order_write", l.inventory_purchase_order_custom_cost = "inventory_purchase_order_custom_cost", l.inventory_bulk_import = "inventory_bulk_import", l.inventory_portal_surcharge = "inventory_portal_surcharge", l.inventory_purchase_order_cost_edit = "inventory_purchase_order_cost_edit", l.inventory_purchase_order_workflow_allow_to_mark_completed = "inventory_purchase_order_workflow_allow_to_mark_completed", l.inventory_recipe_v2 = "inventory_recipe_v2", l.inventory_print_template = "inventory_print_template", l.inventory_purchase_order_email = "inventory_purchase_order_email", l.inventory_bulk_edit_recipes = "inventory_bulk_edit_recipes", l))(b || {});
830
+ var he = () => St(), b = /* @__PURE__ */ ((l) => (l.inventory_portal_must_use_transfer_template = "inventory_portal_must_use_transfer_template", l.inventory_portal_use_iframe = "inventory_portal_use_iframe", l.inventory_pos_adjust_v1 = "inventory_pos_adjust_v1", l.inventory_pos_adjust_v2_wastage = "inventory_pos_adjust_v2_wastage", l.inventory_pos_closing_recalculation = "inventory_pos_closing_recalculation", l.inventory_pos_closing_v1 = "inventory_pos_closing_v1", l.inventory_pos_closing_v2 = "inventory_pos_closing_v2", l.inventory_pos_convert_v1 = "inventory_pos_convert_v1", l.inventory_pos_costing = "inventory_pos_costing", l.inventory_pos_stock_return = "inventory_pos_stock_return", l.inventory_pos_transfer_require_fulfillment = "inventory_pos_transfer_require_fulfillment", l.inventory_purchase_order_approval = "inventory_purchase_order_approval", l.inventory_portal_xilnex_transfer_note = "inventory_portal_xilnex_transfer_note", l.inventory_portal_custom_attribute = "inventory_portal_custom_attribute", l.inventory_portal_purchase_order_v2 = "inventory_portal_purchase_order_v2", l.inventory_portal_accept_require_fulfillment = "inventory_portal_accept_require_fulfillment", l.inventory_portal_po_operate_v2 = "inventory_portal_po_operate_v2", l.inventory_pos_allow_receive_order = "inventory_pos_allow_receive_order", l.inventory_xilnex_opening_migration = "inventory_xilnex_opening_migration", l.inventory_ingredient_group = "inventory_ingredient_group", l.inventory_purchase_order_backdate = "inventory_purchase_order_backdate", l.inventory_synergy_opening_migration = "inventory_synergy_opening_migration", l.inventory_netsuite_inventory_transfer_out = "inventory_netsuite_inventory_transfer_out", l.inventory_portal_supplier_preparation_time = "inventory_portal_supplier_preparation_time", l.inventory_backdate_receive = "inventory_backdate_receive", l.inventory_portal_delivery_order_write = "inventory_portal_delivery_order_write", l.inventory_purchase_order_custom_cost = "inventory_purchase_order_custom_cost", l.inventory_bulk_import = "inventory_bulk_import", l.inventory_portal_surcharge = "inventory_portal_surcharge", l.inventory_purchase_order_cost_edit = "inventory_purchase_order_cost_edit", l.inventory_purchase_order_workflow_allow_to_mark_completed = "inventory_purchase_order_workflow_allow_to_mark_completed", l.inventory_recipe_v2 = "inventory_recipe_v2", l.inventory_print_template = "inventory_print_template", l.inventory_purchase_order_email = "inventory_purchase_order_email", l.inventory_bulk_edit_recipes = "inventory_bulk_edit_recipes", l))(b || {});
831
831
  const Ct = /* @__PURE__ */ new Set([
832
832
  // vivo pizza prod
833
833
  "business_6687e91fa7240b001ba3f4c2",
@@ -873,148 +873,156 @@ function lt() {
873
873
  inventory_recipe_v2: !1,
874
874
  inventory_print_template: !1,
875
875
  inventory_purchase_order_email: !1,
876
- inventory_bulk_edit_recipes: !1
876
+ inventory_bulk_edit_recipes: !1,
877
+ report_portal_po_forecast_days_constraint: null,
878
+ report_portal_po_forecast_days_default: 7
877
879
  };
878
880
  }
879
- const _ = he(lt()), Lt = () => ({
881
+ const h = de(lt()), It = () => ({
880
882
  get businessDbName() {
881
- var h;
882
- return `business_${((h = De().currentBusiness.value) == null ? void 0 : h._id) ?? ""}`;
883
+ var _;
884
+ return `business_${((_ = Ke().currentBusiness.value) == null ? void 0 : _._id) ?? ""}`;
883
885
  },
884
886
  get isWarehouse() {
885
- var c;
886
- return ((c = Ke()._currentLocation) == null ? void 0 : c.type) === at.enum.warehouse;
887
+ var u;
888
+ return ((u = Ve()._currentLocation) == null ? void 0 : u.type) === ot.enum.warehouse;
887
889
  },
888
890
  get restaurantPosVersion() {
889
- var h;
890
- const l = Ke();
891
- return (h = De().restaurants.value.find(
891
+ var _;
892
+ const l = Ve();
893
+ return (_ = Ke().restaurants.value.find(
892
894
  (f) => {
893
895
  var s;
894
896
  return f._id === ((s = l._currentLocation) == null ? void 0 : s.doc._id);
895
897
  }
896
- )) == null ? void 0 : h.posVersion;
898
+ )) == null ? void 0 : _.posVersion;
897
899
  },
898
900
  get enableTotalCost() {
899
- return _.value.enableTotalCost;
901
+ return h.value.enableTotalCost;
900
902
  },
901
903
  get enableBackdatePo() {
902
- return _.value.enableBackdatePo;
904
+ return h.value.enableBackdatePo;
903
905
  },
904
906
  /** @deprecated TODO: remove */
905
907
  get autoReceiveWarehouse() {
906
- return _.value.autoReceiveWarehouse;
908
+ return h.value.autoReceiveWarehouse;
907
909
  },
908
910
  /** @deprecated TODO: remove */
909
911
  get manualReceive() {
910
- return _.value.manualReceive;
912
+ return h.value.manualReceive;
911
913
  },
912
914
  get isLoaded() {
913
- return _.value.isLoaded;
915
+ return h.value.isLoaded;
914
916
  },
915
917
  get enablePoTemplate() {
916
- return _.value.enablePoTemplate;
918
+ return h.value.enablePoTemplate;
917
919
  },
918
920
  get enableClosingTemplate() {
919
- return _.value.enableClosingTemplate;
921
+ return h.value.enableClosingTemplate;
920
922
  },
921
923
  get enableWastageTemplate() {
922
- return _.value.enableWastageTemplate;
924
+ return h.value.enableWastageTemplate;
923
925
  },
924
926
  get enableIngredientGroup() {
925
- return _.value.enableIngredientGroup;
927
+ return h.value.enableIngredientGroup;
926
928
  },
927
929
  get mustUsePoTemplate() {
928
- return _.value.mustUsePoTemplate;
930
+ return h.value.mustUsePoTemplate;
929
931
  },
930
932
  get businessSupplierOnly() {
931
- return _.value.businessSupplierOnly;
933
+ return h.value.businessSupplierOnly;
932
934
  },
933
935
  get enableXilnexTransferNote() {
934
- return _.value.enableXilnexTransferNote;
936
+ return h.value.enableXilnexTransferNote;
935
937
  },
936
938
  get enabledXilnexOpeningMigration() {
937
- return _.value.inventory_xilnex_opening_migration;
939
+ return h.value.inventory_xilnex_opening_migration;
938
940
  },
939
941
  get enabledSynergyOpeningMigration() {
940
- return _.value.inventory_synergy_opening_migration;
942
+ return h.value.inventory_synergy_opening_migration;
941
943
  },
942
944
  get enableCustomAttribute() {
943
- return _.value.enableCustomAttribute;
945
+ return h.value.enableCustomAttribute;
944
946
  },
945
947
  get usePurchaseOrderV2() {
946
- return _.value.usePurchaseOrderV2;
948
+ return h.value.usePurchaseOrderV2;
947
949
  },
948
950
  get acceptRequireFulfillment() {
949
- return _.value.acceptRequireFulfillment;
951
+ return h.value.acceptRequireFulfillment;
950
952
  },
951
953
  get useOperatePurchaseOrderV2() {
952
- return _.value.useOperatePurchaseOrderV2;
954
+ return h.value.useOperatePurchaseOrderV2;
953
955
  },
954
956
  get isNetSuiteInventoryTransferOutEnabled() {
955
- return _.value.inventory_netsuite_inventory_transfer_out;
957
+ return h.value.inventory_netsuite_inventory_transfer_out;
956
958
  },
957
959
  get enableSupplierPreparationTime() {
958
- return _.value.inventory_portal_supplier_preparation_time;
960
+ return h.value.inventory_portal_supplier_preparation_time;
959
961
  },
960
962
  get enablePortalDeliveryOrderWrite() {
961
- return _.value.inventory_portal_delivery_order_write ?? !0;
963
+ return h.value.inventory_portal_delivery_order_write ?? !0;
962
964
  },
963
965
  get enablePOSTransferRequireFulfillment() {
964
- return _.value.inventory_pos_transfer_require_fulfillment;
966
+ return h.value.inventory_pos_transfer_require_fulfillment;
965
967
  },
966
968
  get enableBackdateReceive() {
967
- return _.value.inventory_backdate_receive;
969
+ return h.value.inventory_backdate_receive;
968
970
  },
969
971
  get enablePurchaseOrderReceiveWithCustomCost() {
970
- return _.value.inventory_purchase_order_custom_cost;
972
+ return h.value.inventory_purchase_order_custom_cost;
971
973
  },
972
974
  get enableBulkImport() {
973
- return _.value.inventory_bulk_import;
975
+ return h.value.inventory_bulk_import;
974
976
  },
975
977
  get enableSurcharge() {
976
- return _.value.inventory_portal_surcharge;
978
+ return h.value.inventory_portal_surcharge;
977
979
  },
978
980
  get enablePurchaseOrderCostEdit() {
979
- return _.value.inventory_purchase_order_cost_edit;
981
+ return h.value.inventory_purchase_order_cost_edit;
980
982
  },
981
983
  get poWorkflowAllowToMarkCompleted() {
982
- return _.value.inventory_purchase_order_workflow_allow_to_mark_completed;
984
+ return h.value.inventory_purchase_order_workflow_allow_to_mark_completed;
983
985
  },
984
986
  get enableRecipeV2() {
985
- return _.value.inventory_recipe_v2;
987
+ return h.value.inventory_recipe_v2;
986
988
  },
987
989
  get enablePrintTemplate() {
988
- return _.value.inventory_print_template;
990
+ return h.value.inventory_print_template;
989
991
  },
990
992
  get enablePurchaseOrderEmail() {
991
- return _.value.inventory_purchase_order_email;
993
+ return h.value.inventory_purchase_order_email;
992
994
  },
993
995
  get enableBulkEditRecipes() {
994
- return _.value.inventory_bulk_edit_recipes;
996
+ return h.value.inventory_bulk_edit_recipes;
997
+ },
998
+ get poForecastDaysConstraint() {
999
+ return h.value.report_portal_po_forecast_days_constraint;
1000
+ },
1001
+ get poForecastDaysDefault() {
1002
+ return h.value.report_portal_po_forecast_days_default;
995
1003
  },
996
1004
  async init() {
997
- const l = De(), { init: c, setBusiness: h } = st(), f = gt(), s = l.namespace.value === "prod";
998
- await c({
1005
+ const l = Ke(), { init: u, setBusiness: _ } = he(), f = gt(), s = l.namespace.value === "prod";
1006
+ await u({
999
1007
  apiKey: s ? "6GhcttsJ9Rj9cTevcdrpin" : "MaGoXrEWuEJNpWgKTqseee"
1000
1008
  // url: 'https://flag.feedme.farm/api/v1/', // optional -> this is a default URL value
1001
1009
  // enableAnalytics: true, // optional, defaults to true
1002
1010
  // cacheFlags: true // optional, defaults to true
1003
- }), Ke().watchLocation(async (K) => {
1011
+ }), Ve().watchLocation(async (K) => {
1004
1012
  var A, $, Y;
1005
1013
  if (!K) {
1006
- _.value = lt();
1014
+ h.value = lt();
1007
1015
  return;
1008
1016
  }
1009
- const F = ((A = l.currentBusiness.value) == null ? void 0 : A._id) ?? "";
1010
- await h(F);
1011
- const W = `business_${F}`, w = K.type === at.enum.warehouse, g = (
1017
+ const I = ((A = l.currentBusiness.value) == null ? void 0 : A._id) ?? "";
1018
+ await _(I);
1019
+ const W = `business_${I}`, w = K.type === ot.enum.warehouse, g = (
1012
1020
  // if menu v4, must manual receive && must use outlet app
1013
1021
  (($ = l.currentBusiness.value) == null ? void 0 : $.menuVersion) === "v4" && // more guard for businesses using menu v4, only those listed for manual receive will be included
1014
1022
  // TODO: may be removed to use menu version only
1015
1023
  Ct.has(this.businessDbName)
1016
1024
  ), C = xt.has(W) || S(b.inventory_portal_must_use_transfer_template), E = S(b.inventory_purchase_order_backdate) && (this.isWarehouse || f.state.closing !== null);
1017
- _.value = {
1025
+ h.value = {
1018
1026
  isLoaded: !0,
1019
1027
  enableTotalCost: ((Y = l.currentBusiness.value) == null ? void 0 : Y.menuVersion) === "v4",
1020
1028
  enableBackdatePo: E,
@@ -1066,26 +1074,44 @@ const _ = he(lt()), Lt = () => ({
1066
1074
  inventory_recipe_v2: S(b.inventory_recipe_v2),
1067
1075
  inventory_print_template: S(b.inventory_print_template),
1068
1076
  inventory_purchase_order_email: S(b.inventory_purchase_order_email),
1069
- inventory_bulk_edit_recipes: S(b.inventory_bulk_edit_recipes)
1077
+ inventory_bulk_edit_recipes: S(b.inventory_bulk_edit_recipes),
1078
+ report_portal_po_forecast_days_constraint: Et(
1079
+ "report_portal_po_forecast_days_constraint"
1080
+ ),
1081
+ report_portal_po_forecast_days_default: wt(
1082
+ "report_portal_po_forecast_days_default",
1083
+ 7
1084
+ )
1070
1085
  };
1071
1086
  }, "feature");
1072
1087
  },
1073
1088
  async awaitFeatureLoaded(l) {
1074
- return new Promise((c) => {
1075
- const h = () => {
1076
- _.value.isLoaded ? c(l()) : setTimeout(h, 100);
1089
+ return new Promise((u) => {
1090
+ const _ = () => {
1091
+ h.value.isLoaded ? u(l()) : setTimeout(_, 100);
1077
1092
  };
1078
- h();
1093
+ _();
1079
1094
  });
1080
1095
  }
1081
1096
  });
1082
- function S(l, c) {
1083
- c = c === void 0 ? null : c;
1084
- const { getFlagValue: h } = st();
1085
- return h(l, (f) => f === "true") ?? c;
1097
+ function S(l, u) {
1098
+ u = u === void 0 ? null : u;
1099
+ const { getFlagValue: _ } = he();
1100
+ return _(l, (f) => f === "true") ?? u;
1101
+ }
1102
+ function Et(l) {
1103
+ const { getFlagValue: u } = he();
1104
+ return u(l, (f) => f.trim() ? f.trim() : null) ?? null;
1105
+ }
1106
+ function wt(l, u) {
1107
+ const { getFlagValue: _ } = he();
1108
+ return _(l, (s) => {
1109
+ const O = parseInt(s, 10);
1110
+ return isNaN(O) ? null : O;
1111
+ }) ?? u;
1086
1112
  }
1087
1113
  export {
1088
1114
  b as I,
1089
- st as a,
1090
- Lt as u
1115
+ he as a,
1116
+ It as u
1091
1117
  };