@feedmepos/mf-hrm-portal 2.0.15-dev.2 → 2.0.15-dev.4

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 (25) hide show
  1. package/dist/{AuditLogList-_iGkRjav.js → AuditLogList-DnmeTc37.js} +4 -4
  2. package/dist/{EmployeeList-BsauFDHA.js → EmployeeList-DxlllTty.js} +43 -43
  3. package/dist/{Main-CWSLq8gH.js → Main-COZvNyhk.js} +4 -4
  4. package/dist/{Main-DWBJw_Ta.js → Main-CeFkxIhA.js} +765 -770
  5. package/dist/{Main-D0eoxqEG.js → Main-D1yqf9Yq.js} +13 -14
  6. package/dist/{PermissionSetList-CzFf90Bv.js → PermissionSetList-Ckc-VGme.js} +5 -5
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CBcnIfck.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-n4_wNZbg.js} +747 -750
  8. package/dist/{RoleList-CsdcFHQK.js → RoleList-BDbQX9of.js} +7 -7
  9. package/dist/{TeamMemberList-CI24SCZz.js → TeamMemberList-DJYxuPyN.js} +324 -323
  10. package/dist/{TimesheetList-eD8-rA_L.js → TimesheetList-CxehedOx.js} +6 -6
  11. package/dist/{app-DnT6yzx7.js → app-DEA0Bhzy.js} +2222 -1394
  12. package/dist/app.js +1 -1
  13. package/dist/{dayjs.min-L-465Ow8.js → dayjs.min-D-rfdWhu.js} +1 -1
  14. package/dist/{employee-DGjXlPn1.js → employee-CFnP1VvM.js} +3 -3
  15. package/dist/{iteration-CAxWl04o.js → iteration-S7YxnyNB.js} +1 -1
  16. package/dist/{lodash-VfbpRiGW.js → lodash-BdeQh1LM.js} +1 -1
  17. package/dist/{rule-D6eh6FDn.js → rule-DbvJ1q_w.js} +284 -285
  18. package/dist/style.css +1 -1
  19. package/dist/{timesheet-B11NLk-Z.js → timesheet-CPZSm4Qs.js} +2 -2
  20. package/dist/tsconfig.app.tsbuildinfo +1 -1
  21. package/dist/{useAppStore-BaDI6IZu.js → useAppStore-CJ6tnELc.js} +1 -1
  22. package/dist/{useLoading-B2CoUwmJ.js → useLoading-BuN7YL-v.js} +1 -1
  23. package/dist/{useReportPermissions-BfjLdcAd.js → useReportPermissions-D-GJuNg3.js} +3 -3
  24. package/package.json +1 -1
  25. package/dist/index-DOpSY75_.js +0 -827
@@ -1,827 +0,0 @@
1
- var oe = Object.defineProperty;
2
- var se = (_, h, y) => h in _ ? oe(_, h, { enumerable: !0, configurable: !0, writable: !0, value: y }) : _[h] = y;
3
- var ot = (_, h, y) => se(_, typeof h != "symbol" ? h + "" : h, y);
4
- import { readonly as Nt, ref as Rt } from "vue";
5
- import { c as st } from "./app-DnT6yzx7.js";
6
- var Pt = { exports: {} };
7
- (function(_, h) {
8
- (function(y, p) {
9
- p(h);
10
- })(st, function(y) {
11
- var p = { getItemSync: function(a) {
12
- try {
13
- return localStorage.getItem(a) || null;
14
- } catch {
15
- return null;
16
- }
17
- }, getItem: function(a, e) {
18
- var t = this;
19
- return new Promise(function(i, n) {
20
- try {
21
- var r = t.getItemSync(a);
22
- e == null || e(null, r), i(r);
23
- } catch (o) {
24
- e && e(o, null), n(o);
25
- }
26
- });
27
- }, setItem: function(a, e, t) {
28
- return new Promise(function(i, n) {
29
- try {
30
- localStorage.setItem(a, e), t && t(null, e), i(e);
31
- } catch (r) {
32
- t && t(r, null), n(r);
33
- }
34
- });
35
- } }, s = function() {
36
- return s = Object.assign || function(a) {
37
- for (var e, t = 1, i = arguments.length; t < i; t++) for (var n in e = arguments[t]) Object.prototype.hasOwnProperty.call(e, n) && (a[n] = e[n]);
38
- return a;
39
- }, s.apply(this, arguments);
40
- };
41
- function k(a, e, t, i) {
42
- return new (t || (t = Promise))(function(n, r) {
43
- function o(d) {
44
- try {
45
- c(i.next(d));
46
- } catch (l) {
47
- r(l);
48
- }
49
- }
50
- function u(d) {
51
- try {
52
- c(i.throw(d));
53
- } catch (l) {
54
- r(l);
55
- }
56
- }
57
- function c(d) {
58
- var l;
59
- d.done ? n(d.value) : (l = d.value, l instanceof t ? l : new t(function(g) {
60
- g(l);
61
- })).then(o, u);
62
- }
63
- c((i = i.apply(a, [])).next());
64
- });
65
- }
66
- function M(a, e) {
67
- var t, i, n, r, o = { label: 0, sent: function() {
68
- if (1 & n[0]) throw n[1];
69
- return n[1];
70
- }, trys: [], ops: [] };
71
- return r = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (r[Symbol.iterator] = function() {
72
- return this;
73
- }), r;
74
- function u(c) {
75
- return function(d) {
76
- return function(l) {
77
- if (t) throw new TypeError("Generator is already executing.");
78
- for (; o; ) try {
79
- if (t = 1, i && (n = 2 & l[0] ? i.return : l[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, l[1])).done) return n;
80
- switch (i = 0, n && (l = [2 & l[0], n.value]), l[0]) {
81
- case 0:
82
- case 1:
83
- n = l;
84
- break;
85
- case 4:
86
- return o.label++, { value: l[1], done: !1 };
87
- case 5:
88
- o.label++, i = l[1], l = [0];
89
- continue;
90
- case 7:
91
- l = o.ops.pop(), o.trys.pop();
92
- continue;
93
- default:
94
- if (n = o.trys, !((n = n.length > 0 && n[n.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
95
- o = 0;
96
- continue;
97
- }
98
- if (l[0] === 3 && (!n || l[1] > n[0] && l[1] < n[3])) {
99
- o.label = l[1];
100
- break;
101
- }
102
- if (l[0] === 6 && o.label < n[1]) {
103
- o.label = n[1], n = l;
104
- break;
105
- }
106
- if (n && o.label < n[2]) {
107
- o.label = n[2], o.ops.push(l);
108
- break;
109
- }
110
- n[2] && o.ops.pop(), o.trys.pop();
111
- continue;
112
- }
113
- l = e.call(a, o);
114
- } catch (g) {
115
- l = [6, g], i = 0;
116
- } finally {
117
- t = n = 0;
118
- }
119
- if (5 & l[0]) throw l[1];
120
- return { value: l[0] ? l[1] : void 0, done: !0 };
121
- }([c, d]);
122
- };
123
- }
124
- }
125
- function D(a, e, t) {
126
- for (var i, n = 0, r = e.length; n < r; n++) !i && n in e || (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
127
- return a.concat(i || Array.prototype.slice.call(e));
128
- }
129
- var nt = function a(e, t) {
130
- if (e === t) return !0;
131
- if (e && t && typeof e == "object" && typeof t == "object") {
132
- if (e.constructor !== t.constructor) return !1;
133
- var i, n, r;
134
- if (Array.isArray(e)) {
135
- if ((i = e.length) != t.length) return !1;
136
- for (n = i; n-- != 0; ) if (!a(e[n], t[n])) return !1;
137
- return !0;
138
- }
139
- if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
140
- if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
141
- if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
142
- if ((i = (r = Object.keys(e)).length) !== Object.keys(t).length) return !1;
143
- for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(t, r[n])) return !1;
144
- for (n = i; n-- != 0; ) {
145
- var o = r[n];
146
- if (!a(e[o], t[o])) return !1;
147
- }
148
- return !0;
149
- }
150
- return e != e && t != t;
151
- };
152
- function b(a, e) {
153
- var t = Object.keys(e || {}).filter(function(i) {
154
- var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
155
- return !nt(n, r);
156
- });
157
- return Object.keys(a || {}).filter(function(i) {
158
- Object.keys(e || {}).includes(i) || t.push(i);
159
- }), Object.keys(t).length ? t : null;
160
- }
161
- var v, S;
162
- function C(a, e, t) {
163
- var i = "shortString", n = !0;
164
- typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
165
- }
166
- function G(a) {
167
- return !!a && typeof a == "object" && a.value !== void 0;
168
- }
169
- function it(a) {
170
- return Object.fromEntries(Object.entries(a).map(function(e) {
171
- var t = e[0], i = e[1];
172
- return [t, G(i) ? i : { value: i }];
173
- }));
174
- }
175
- function ut(a) {
176
- return s(s({}, a), { identity: a.identity ? s(s({}, a.identity), { traits: it(a.identity.traits || {}) }) : void 0 });
177
- }
178
- (function(a) {
179
- a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
180
- })(v || (v = {}));
181
- var ct, O = null, ee = "FLAGSMITH_EVENT", at = ee, Ut = "https://edge.api.flagsmith.com/api/v1/", Kt = "flagsmith_value_", Dt = "flagsmith_enabled_", Gt = "flagsmith_trait_", ne = function() {
182
- function a(e) {
183
- var t = this;
184
- this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
185
- var i = t, n = i.api, r = i.evaluationContext;
186
- t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(s(s({}, t.loadingState), { isFetching: !0 }));
187
- var o = "".concat(t.getContext().identity), u = function(c) {
188
- var d, l, g, x;
189
- if (c && o === "".concat(t.getContext().identity)) {
190
- var N = c.flags, w = c.traits, j = c.identifier;
191
- t.isLoading = !1;
192
- var I = {}, L = {};
193
- w = w || [], (N = N || []).forEach(function(f) {
194
- I[f.feature.name.toLowerCase().replace(/ /g, "_")] = { id: f.feature.id, enabled: f.enabled, value: f.feature_state_value };
195
- }), w.forEach(function(f) {
196
- L[f.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: f.transient, value: f.trait_value };
197
- }), t.oldFlags = s({}, t.flags);
198
- var P = b(t.oldFlags, I), Z = b((d = t.evaluationContext.identity) === null || d === void 0 ? void 0 : d.traits, L);
199
- if ((j || Object.keys(L).length) && (t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: L }), j && (t.evaluationContext.identity.identifier = j)), t.flags = I, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: P, traitsChanged: Z }, t._loadedState(null, v.SERVER)), t.datadogRum) try {
200
- if (t.datadogRum.trackTraits) {
201
- var Q = {};
202
- Object.keys(((l = t.evaluationContext.identity) === null || l === void 0 ? void 0 : l.traits) || {}).map(function(f) {
203
- Q[Gt + f] = t.getTrait(f);
204
- });
205
- var $ = s(s(s({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((g = t.evaluationContext.identity) === null || g === void 0 ? void 0 : g.identifier) }), Q);
206
- t.log("Setting Datadog user", $), t.datadogRum.client.setUser($);
207
- }
208
- } catch (f) {
209
- console.error(f);
210
- }
211
- if (t.dtrum) try {
212
- var E = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
213
- Object.keys(t.flags).map(function(f) {
214
- C(E, Kt + f, t.getValue(f, { skipAnalytics: !0 })), C(E, Dt + f, t.hasFeature(f, { skipAnalytics: !0 }));
215
- }), Object.keys(((x = t.evaluationContext.identity) === null || x === void 0 ? void 0 : x.traits) || {}).map(function(f) {
216
- C(E, Gt + f, t.getTrait(f));
217
- }), t.log("Sending javaLongOrObject traits to dynatrace", E.javaLongOrObject), t.log("Sending date traits to dynatrace", E.date), t.log("Sending shortString traits to dynatrace", E.shortString), t.log("Sending javaDouble to dynatrace", E.javaDouble), t.dtrum.sendSessionProperties(E.javaLongOrObject, E.date, E.shortString, E.javaDouble);
218
- } catch (f) {
219
- console.error(f);
220
- }
221
- }
222
- };
223
- return r.identity ? Promise.all([r.identity.traits && Object.keys(r.identity.traits).length || !r.identity.identifier ? t.getJSON(n + "identities/", "POST", JSON.stringify({ identifier: r.identity.identifier, transient: r.identity.transient, traits: Object.entries(r.identity.traits).map(function(c) {
224
- var d = c[0], l = c[1];
225
- return { trait_key: d, trait_value: l == null ? void 0 : l.value, transient: l == null ? void 0 : l.transient };
226
- }).filter(function(c) {
227
- return c.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", c.trait_key), !1);
228
- }) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(c) {
229
- return t.evaluationContext.identity = s(s({}, t.evaluationContext.identity), { traits: {} }), u(c == null ? void 0 : c[0]);
230
- }).catch(function(c) {
231
- var d = c.message, l = new Error(d);
232
- return Promise.reject(l);
233
- }) : t.getJSON(n + "flags/").then(function(c) {
234
- return u({ flags: c, traits: void 0 });
235
- });
236
- }, this.analyticsFlags = function() {
237
- var i = t.api;
238
- if (t.evaluationEvent && t.evaluationContext.environment && t.evaluationEvent[t.evaluationContext.environment.apiKey]) return t.evaluationEvent && Object.getOwnPropertyNames(t.evaluationEvent).length !== 0 && Object.getOwnPropertyNames(t.evaluationEvent[t.evaluationContext.environment.apiKey]).length !== 0 ? t.getJSON(i + "analytics/flags/", "POST", JSON.stringify(t.evaluationEvent[t.evaluationContext.environment.apiKey])).then(function(n) {
239
- if (t.evaluationContext.environment) {
240
- var r = t.getState();
241
- t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(s(s({}, r), { evaluationEvent: t.evaluationEvent })), t.updateEventStorage();
242
- }
243
- }).catch(function(n) {
244
- t.log("Exception fetching evaluationEvent", n);
245
- }) : void 0;
246
- }, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: v.NONE }, this.canUseStorage = !1, this.analyticsInterval = null, this.api = null, this.cacheFlags = !1, this.ts = null, this.enableAnalytics = !1, this.enableLogs = !1, this.evaluationContext = {}, this.evaluationEvent = null, this.flags = null, this.getFlagInterval = null, this.headers = null, this.initialised = !1, this.oldFlags = null, this.onChange = null, this.onError = null, this.ticks = null, this.timer = null, this.dtrum = null, this.withTraits = null, this.cacheOptions = { ttl: 0, skipAPI: !1, loadStale: !1, storageKey: void 0 }, this.getValue = function(i, n, r) {
247
- var o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], u = null;
248
- if (o && (u = o.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), u === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
249
- if (n != null && n.json) try {
250
- return u === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(u);
251
- } catch {
252
- return n.fallback;
253
- }
254
- return u;
255
- }, this.getTrait = function(i) {
256
- var n, r;
257
- return ((n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits) && ((r = t.evaluationContext.identity.traits[i.toLowerCase().replace(/ /g, "_")]) === null || r === void 0 ? void 0 : r.value);
258
- }, this.getAllTraits = function() {
259
- var i;
260
- return Object.fromEntries(Object.entries(((i = t.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
261
- var r = n[0], o = n[1];
262
- return [r, o == null ? void 0 : o.value];
263
- }));
264
- }, this.setContext = function(i) {
265
- var n = ut(i);
266
- return t.evaluationContext = s(s({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
267
- }, this.getContext = function() {
268
- return t.evaluationContext;
269
- }, this.updateContext = function(i) {
270
- return t.setContext(s(s({}, t.getContext()), i));
271
- }, this.setTrait = function(i, n) {
272
- var r;
273
- if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (r = t.evaluationContext.identity) === null || r === void 0 ? void 0 : r.traits), it(Object.fromEntries([[i, n]]))) }) }));
274
- }, this.setTraits = function(i) {
275
- var n;
276
- if (t.api) return t.setContext(s(s({}, t.evaluationContext), { identity: s(s({}, t.evaluationContext.identity), { traits: s(s({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
277
- var o = r[0], u = r[1];
278
- return [o, G(u) ? u : { value: u }];
279
- }))) }) }));
280
- 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.");
281
- }, this.hasFeature = function(i, n) {
282
- var r = typeof n == "object", o = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], u = !1;
283
- return !o && r && n.fallback !== void 0 ? u = n == null ? void 0 : n.fallback : o && o.enabled && (u = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), u;
284
- }, this.getStorageKey = function() {
285
- var i, n;
286
- return ((i = t.cacheOptions) === null || i === void 0 ? void 0 : i.storageKey) || "FLAGSMITH_DB_" + ((n = t.evaluationContext.environment) === null || n === void 0 ? void 0 : n.apiKey);
287
- }, this.getJSON = function(i, n, r) {
288
- var o, u = t;
289
- u.evaluationContext;
290
- var c = u.headers, d = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
291
- t.evaluationContext.environment && (d.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (d.headers["Content-Type"] = "application/json; charset=utf-8"), c && Object.assign(d.headers, c), S || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
292
- var l = "".concat((o = t.evaluationContext.identity) === null || o === void 0 ? void 0 : o.identifier);
293
- return S(i, d).then(function(g) {
294
- var x, N, w = "".concat((x = t.evaluationContext.identity) === null || x === void 0 ? void 0 : x.identifier);
295
- if (l === w) {
296
- var j = (N = g.headers) === null || N === void 0 ? void 0 : N.get("x-flagsmith-document-updated-at");
297
- if (j) try {
298
- var I = parseFloat(j);
299
- if (isNaN(I)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
300
- t.timestamp = I;
301
- } catch (L) {
302
- t.log(L, "Failed to parse x-flagsmith-document-updated-at", j);
303
- }
304
- return t.log("Fetch response: " + g.status + " " + (n || "GET") + 0 + i), g.text().then(function(L) {
305
- var P = L;
306
- try {
307
- P = JSON.parse(L);
308
- } catch {
309
- }
310
- return !P && g.status && (P = "API Response: ".concat(g.status)), g.status && g.status >= 200 && g.status < 300 ? P : Promise.reject(new Error(P));
311
- });
312
- }
313
- t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(l, ", Current: ").concat(w));
314
- });
315
- }, this.evaluateFlag = function(i, n) {
316
- if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Kt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Dt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
317
- if (!t.evaluationEvent || !t.evaluationContext.environment) return;
318
- t.evaluationEvent[t.evaluationContext.environment.apiKey] || (t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] === void 0 && (t.evaluationEvent[t.evaluationContext.environment.apiKey][i] = 0), t.evaluationEvent[t.evaluationContext.environment.apiKey][i] += 1;
319
- }
320
- t.updateEventStorage();
321
- }, this._onChange = function(i, n, r) {
322
- var o, u;
323
- t.setLoadingState(r), (o = t.onChange) === null || o === void 0 || o.call(t, i, n, t.loadingState), (u = t._trigger) === null || u === void 0 || u.call(t);
324
- }, S = e.fetch ? e.fetch : typeof fetch < "u" ? fetch : st === null || st === void 0 ? void 0 : st.fetch, this.canUseStorage = typeof window < "u" || !!e.browserlessStorage, this.log("Constructing flagsmith instance " + e), e.eventSource && (ct = e.eventSource), e.AsyncStorage && (O = e.AsyncStorage);
325
- }
326
- return a.prototype.init = function(e) {
327
- var t, i, n;
328
- return k(this, void 0, void 0, function() {
329
- var r, o, u, c, d, l, g, x, N, w, j, I, L, P, Z, Q, $, E, f, vt, W, Bt, B, dt, qt, Xt, gt, Yt, ft, tt, q, Zt, F = this;
330
- return M(this, function(T) {
331
- switch (T.label) {
332
- case 0:
333
- r = ut(e.evaluationContext || this.evaluationContext), T.label = 1;
334
- case 1:
335
- if (T.trys.push([1, 13, , 14]), o = e.environmentID, u = e.api, c = u === void 0 ? Ut : u, d = e.headers, l = e.onChange, g = e.cacheFlags, x = e.datadogRum, N = e.onError, w = e.defaultFlags, j = e.fetch, I = e.preventFetch, L = e.enableLogs, P = e.enableDynatrace, Z = e.enableAnalytics, Q = e.realtime, $ = e.eventSourceUrl, E = $ === void 0 ? "https://realtime.flagsmith.com/" : $, f = e.AsyncStorage, vt = e.identity, W = e.traits, Bt = e.state, B = e.cacheOptions, dt = e.angularHttpClient, qt = e._trigger, Xt = e._triggerLoadingState, r.environment = o ? { apiKey: o } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
336
- if (r.identity = vt || W ? { identifier: vt, traits: W ? Object.fromEntries(Object.entries(W).map(function(A) {
337
- return [A[0], { value: A[1] }];
338
- })) : {} } : r.identity, this.evaluationContext = r, this.api = c, this.headers = d, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = l, gt = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = qt || this._trigger, this._triggerLoadingState = Xt || this._triggerLoadingState, this.onError = function(A) {
339
- F.setLoadingState(s(s({}, F.loadingState), { isFetching: !1, isLoading: !1, error: A })), N == null || N(A);
340
- }, this.enableLogs = L || !1, this.cacheOptions = B ? { skipAPI: !!B.skipAPI, ttl: B.ttl || 0, storageKey: B.storageKey, loadStale: !!B.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."), j && (S = j), this.enableAnalytics = Z || !1, this.flags = Object.assign({}, w) || {}, this.datadogRum = x || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = O !== void 0 && !!g, at = "FLAGSMITH_EVENT_" + r.environment.apiKey, f && (O = f), Q && typeof window < "u" && this.setupRealtime(E, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = s(s({}, this.loadingState), { isLoading: !1, source: v.DEFAULT_FLAGS })), this.setState(Bt), this.log("Initialising with properties", e, this), P && (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), dt && (S = /* @__PURE__ */ function(A) {
341
- return function(R, U) {
342
- var V = U.headers, m = U.method, X = U.body;
343
- return new Promise(function(H) {
344
- switch (m) {
345
- case "GET":
346
- return A.get(R, { headers: V }).subscribe(function(J) {
347
- H({ ok: !0, text: function() {
348
- return Promise.resolve(J);
349
- } });
350
- });
351
- case "POST":
352
- case "PUT":
353
- return A.post(R, X, { headers: V }).subscribe(function(J) {
354
- H({ ok: !0, text: function() {
355
- return Promise.resolve(J);
356
- } });
357
- });
358
- }
359
- });
360
- };
361
- }(dt)), O && this.canUseStorage && O.getItem(at).then(function(A) {
362
- try {
363
- F.evaluationEvent = JSON.parse(A) || {};
364
- } catch {
365
- F.evaluationEvent = {};
366
- }
367
- F.analyticsInterval = setInterval(F.analyticsFlags, F.ticks);
368
- }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), O && this.canUseStorage && O.getItem(at, function(A, R) {
369
- if (R && F.evaluationContext.environment) {
370
- var U = JSON.parse(R);
371
- if (U[F.evaluationContext.environment.apiKey]) {
372
- var V = F.getState();
373
- F.log("Retrieved events from cache", R), F.setState(s(s({}, V), { evaluationEvent: U[F.evaluationContext.environment.apiKey] }));
374
- }
375
- }
376
- })), !g) return [3, 9];
377
- if (!O || !this.canUseStorage) return [3, 8];
378
- Yt = function(A, R) {
379
- return k(F, void 0, void 0, function() {
380
- var U, V, m, X, H, J, pt, Qt, yt, mt, St, Ct, _t, bt, xt, Et, Ft, Ot, wt, It, Lt, At, jt, Tt, Wt = this;
381
- return M(this, function(z) {
382
- switch (z.label) {
383
- case 0:
384
- if (!R) return [3, 7];
385
- U = null, V = null, z.label = 1;
386
- case 1:
387
- return z.trys.push([1, 5, , 6]), m = JSON.parse(R), X = !1, H = !1, m && m.api === this.api && ((mt = (yt = m.evaluationContext) === null || yt === void 0 ? void 0 : yt.environment) === null || mt === void 0 ? void 0 : mt.apiKey) === ((St = this.evaluationContext.environment) === null || St === void 0 ? void 0 : St.apiKey) && (J = !0, this.evaluationContext.identity && ((_t = (Ct = m.evaluationContext) === null || Ct === void 0 ? void 0 : Ct.identity) === null || _t === void 0 ? void 0 : _t.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((xt = (bt = m.evaluationContext) === null || bt === void 0 ? void 0 : bt.identity) === null || xt === void 0 ? void 0 : xt.identifier) + " to " + this.evaluationContext.identity.identifier), J = !1), this.cacheOptions.ttl && (!m.ts || (/* @__PURE__ */ new Date()).valueOf() - m.ts > this.cacheOptions.ttl) && (m.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + m.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - m.ts) + "ms"), J = !1) : m.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + m.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - m.ts) + "ms"), H = !0, J = !0)), J && (X = !0, V = b((Et = this.evaluationContext.identity) === null || Et === void 0 ? void 0 : Et.traits, (Ot = (Ft = m.evaluationContext) === null || Ft === void 0 ? void 0 : Ft.identity) === null || Ot === void 0 ? void 0 : Ot.traits), U = b(this.flags, m.flags), this.setState(s(s({}, m), { evaluationContext: ut(s(s({}, m.evaluationContext), { identity: !((wt = m.evaluationContext) === null || wt === void 0) && wt.identity ? s(s({}, (It = m.evaluationContext) === null || It === void 0 ? void 0 : It.identity), { traits: s(s({}, ((At = (Lt = m.evaluationContext) === null || Lt === void 0 ? void 0 : Lt.identity) === null || At === void 0 ? void 0 : At.traits) || {}), W || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", m))), X ? (pt = !I && (!this.cacheOptions.skipAPI || H), this._onChange(null, { isFromServer: !1, flagsChanged: U, traitsChanged: V }, this._loadedState(null, v.CACHE, pt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && X && !H && this.log("Skipping API, using cache"), pt && this.getFlags().catch(function(re) {
388
- var kt;
389
- (kt = Wt.onError) === null || kt === void 0 || kt.call(Wt, re);
390
- }), [3, 4]) : [3, 2];
391
- case 2:
392
- return I ? [3, 4] : [4, this.getFlags()];
393
- case 3:
394
- z.sent(), z.label = 4;
395
- case 4:
396
- return [3, 6];
397
- case 5:
398
- return Qt = z.sent(), this.log("Exception fetching cached logs", Qt), [3, 6];
399
- case 6:
400
- return [3, 10];
401
- case 7:
402
- return I ? [3, 9] : [4, this.getFlags()];
403
- case 8:
404
- return z.sent(), [3, 10];
405
- case 9:
406
- if (w) this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (jt = this.evaluationContext.identity) === null || jt === void 0 ? void 0 : jt.traits) }, this._loadedState(null, v.DEFAULT_FLAGS));
407
- else {
408
- if (!this.flags) throw new Error(gt);
409
- this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (Tt = this.evaluationContext.identity) === null || Tt === void 0 ? void 0 : Tt.traits) }, this._loadedState(null, v.DEFAULT_FLAGS));
410
- }
411
- z.label = 10;
412
- case 10:
413
- return [2];
414
- }
415
- });
416
- });
417
- }, T.label = 2;
418
- case 2:
419
- return T.trys.push([2, 7, , 8]), O.getItemSync ? (ft = O.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
420
- case 3:
421
- return [4, O.getItem(this.getStorageKey())];
422
- case 4:
423
- ft = T.sent(), T.label = 5;
424
- case 5:
425
- return [4, Yt(null, ft)];
426
- case 6:
427
- case 7:
428
- return T.sent(), [3, 8];
429
- case 8:
430
- return [3, 12];
431
- case 9:
432
- return I ? [3, 11] : [4, this.getFlags()];
433
- case 10:
434
- return T.sent(), [3, 12];
435
- case 11:
436
- if (w) this._onChange(null, { isFromServer: !1, flagsChanged: b({}, w), traitsChanged: b({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, v.DEFAULT_FLAGS));
437
- else if (this.flags && (tt = null, Object.keys(this.flags).length === 0 && (tt = gt), this._onChange(null, { isFromServer: !1, flagsChanged: b({}, this.flags), traitsChanged: b({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(tt, v.DEFAULT_FLAGS)), tt)) throw new Error(tt);
438
- T.label = 12;
439
- case 12:
440
- return [3, 14];
441
- case 13:
442
- throw q = T.sent(), this.log("Error during initialisation ", q), Zt = q instanceof Error ? q : new Error("".concat(q)), (n = this.onError) === null || n === void 0 || n.call(this, Zt), q;
443
- case 14:
444
- return [2];
445
- }
446
- });
447
- });
448
- }, a.prototype.getAllFlags = function() {
449
- return this.flags;
450
- }, a.prototype.identify = function(e, t, i) {
451
- return this.evaluationContext.identity = { identifier: e, transient: i, traits: this.evaluationContext.identity && this.evaluationContext.identity.identifier == e ? this.evaluationContext.identity.traits : {} }, this.evaluationContext.identity.identifier = e, this.log("Identify: " + this.evaluationContext.identity.identifier), t && (this.evaluationContext.identity.traits = Object.fromEntries(Object.entries(t).map(function(n) {
452
- var r = n[0], o = n[1];
453
- return [r, G(o) ? o : { value: o }];
454
- }))), this.initialised ? this.getFlags() : Promise.resolve();
455
- }, a.prototype.getState = function() {
456
- return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
457
- }, a.prototype.setState = function(e) {
458
- e && (this.initialised = !0, this.api = e.api || this.api || Ut, this.flags = e.flags || this.flags, this.evaluationContext = e.evaluationContext || this.evaluationContext, this.evaluationEvent = e.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
459
- }, a.prototype.logout = function() {
460
- return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
461
- }, a.prototype.startListening = function(e) {
462
- e === void 0 && (e = 1e3), this.getFlagInterval && clearInterval(this.getFlagInterval), this.getFlagInterval = setInterval(this.getFlags, e);
463
- }, a.prototype.stopListening = function() {
464
- this.getFlagInterval && (clearInterval(this.getFlagInterval), this.getFlagInterval = null);
465
- }, a.prototype._loadedState = function(e, t, i) {
466
- return e === void 0 && (e = null), i === void 0 && (i = !1), { error: e, isFetching: i, isLoading: !1, source: t };
467
- }, a.prototype.log = function() {
468
- for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
469
- this.enableLogs && console.log.apply(this, D(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], e));
470
- }, a.prototype.updateStorage = function() {
471
- if (this.cacheFlags) {
472
- this.ts = (/* @__PURE__ */ new Date()).valueOf();
473
- var e = JSON.stringify(this.getState());
474
- this.log("Setting storage", e), O.setItem(this.getStorageKey(), e);
475
- }
476
- }, a.prototype.updateEventStorage = function() {
477
- if (this.enableAnalytics) {
478
- var e = JSON.stringify(this.getState().evaluationEvent);
479
- O.setItem(at, e).catch(function(t) {
480
- return console.error("Flagsmith: Error setting item in async storage", t);
481
- });
482
- }
483
- }, a.prototype.setLoadingState = function(e) {
484
- var t;
485
- nt(e, this.loadingState) || (this.loadingState = s({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
486
- }, a.prototype.setupRealtime = function(e, t) {
487
- var i = this, n = e + "sse/environments/" + t + "/stream";
488
- ct ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new ct(n), this.eventSource.addEventListener("environment_updated", function(r) {
489
- var o;
490
- try {
491
- o = JSON.parse(r.data).updated_at;
492
- } catch (u) {
493
- i.log("Could not parse sse event", u);
494
- }
495
- o ? !i.timestamp || o > i.timestamp ? i.isLoading ? i.log("updated_at is new, but flags are loading", r.data, i.timestamp) : (i.log("updated_at is new, fetching flags", r.data, i.timestamp), i.getFlags()) : i.log("updated_at is outdated, skipping get flags", r.data, i.timestamp) : i.log("No updated_at received, fetching flags", r);
496
- })) : this.log("Error, EventSource is undefined");
497
- }, a;
498
- }();
499
- function Jt(a) {
500
- var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
501
- return new ne({ fetch: e, AsyncStorage: t, eventSource: i });
502
- }
503
- var rt, ie = (rt = function(a, e) {
504
- return rt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
505
- t.__proto__ = i;
506
- } || function(t, i) {
507
- for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]);
508
- }, rt(a, e);
509
- }, function(a, e) {
510
- if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
511
- function t() {
512
- this.constructor = a;
513
- }
514
- rt(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
515
- }), Vt = function(a) {
516
- var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
517
- if (t) return t.call(a);
518
- if (a && typeof a.length == "number") return { next: function() {
519
- return a && i >= a.length && (a = void 0), { value: a && a[i++], done: !a };
520
- } };
521
- throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
522
- }, zt = function(a, e) {
523
- var t = typeof Symbol == "function" && a[Symbol.iterator];
524
- if (!t) return a;
525
- var i, n, r = t.call(a), o = [];
526
- try {
527
- for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
528
- } catch (u) {
529
- n = { error: u };
530
- } finally {
531
- try {
532
- i && !i.done && (t = r.return) && t.call(r);
533
- } finally {
534
- if (n) throw n.error;
535
- }
536
- }
537
- return o;
538
- }, ht = function(a, e, t) {
539
- if (arguments.length === 2) for (var i, n = 0, r = e.length; n < r; n++) !i && n in e || (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
540
- return a.concat(i || Array.prototype.slice.call(e));
541
- }, ae = function(a) {
542
- function e() {
543
- return a.call(this, `EventSource not available.
544
- Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
545
- }
546
- return ie(e, a), e;
547
- }(Error), Mt = function() {
548
- function a(e, t) {
549
- var i = this;
550
- if (this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, this._configuration = t != null ? Object.assign({}, t) : void 0, this.withCredentials = !1, this._eventSource = null, this._lastEventId = null, this._timer = null, this._listeners = { open: [], error: [], message: [] }, this.url = e.toString(), this.readyState = this.CONNECTING, this.max_retry_time = 3e3, this.eventSourceClass = globalThis.FlagsmithEventSource, this._configuration != null && (this._configuration.lastEventId && (this._lastEventId = this._configuration.lastEventId, delete this._configuration.lastEventId), this._configuration.max_retry_time && (this.max_retry_time = this._configuration.max_retry_time, delete this._configuration.max_retry_time), this._configuration.eventSourceClass && (this.eventSourceClass = this._configuration.eventSourceClass, delete this._configuration.eventSourceClass)), this.eventSourceClass == null || typeof this.eventSourceClass != "function") throw new ae();
551
- this._onevent_wrapped = function(n) {
552
- i._onevent(n);
553
- }, this._start();
554
- }
555
- return a.prototype.dispatchEvent = function(e) {
556
- throw new Error("Method not implemented.");
557
- }, a.prototype._start = function() {
558
- var e, t, i = this, n = this.url;
559
- this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(c) {
560
- i._onopen(c);
561
- }, this._eventSource.onerror = function(c) {
562
- i._onerror(c);
563
- }, this._eventSource.onmessage = function(c) {
564
- i.onmessage(c);
565
- };
566
- try {
567
- for (var r = Vt(Object.keys(this._listeners)), o = r.next(); !o.done; o = r.next()) {
568
- var u = o.value;
569
- this._eventSource.addEventListener(u, this._onevent_wrapped);
570
- }
571
- } catch (c) {
572
- e = { error: c };
573
- } finally {
574
- try {
575
- o && !o.done && (t = r.return) && t.call(r);
576
- } finally {
577
- if (e) throw e.error;
578
- }
579
- }
580
- }, a.prototype._onopen = function(e) {
581
- this.readyState === 0 && (this.readyState = 1, this.onopen(e));
582
- }, a.prototype._onerror = function(e) {
583
- var t = this;
584
- if (this.readyState === 1 && (this.readyState = 0, this.onerror(e)), this._eventSource) {
585
- this._eventSource.close(), this._eventSource = null;
586
- var i = Math.round(this.max_retry_time * Math.random());
587
- this._timer = setTimeout(function() {
588
- return t._start();
589
- }, i);
590
- }
591
- }, a.prototype._onevent = function(e) {
592
- var t, i;
593
- e && e.lastEventId && (this._lastEventId = e.lastEventId);
594
- var n = this._listeners[e.type];
595
- if (n != null) try {
596
- for (var r = Vt(ht([], zt(n), !1)), o = r.next(); !o.done; o = r.next())
597
- o.value.call(this, e);
598
- } catch (u) {
599
- t = { error: u };
600
- } finally {
601
- try {
602
- o && !o.done && (i = r.return) && i.call(r);
603
- } finally {
604
- if (t) throw t.error;
605
- }
606
- }
607
- e.type === "message" && this.onmessage(e);
608
- }, a.prototype.onopen = function(e) {
609
- }, a.prototype.onerror = function(e) {
610
- }, a.prototype.onmessage = function(e) {
611
- }, a.prototype.close = function() {
612
- this._timer && (clearTimeout(this._timer), this._timer = null), this._eventSource && (this._eventSource.close(), this._eventSource = null), this.readyState = 2;
613
- }, a.prototype.addEventListener = function(e, t, i) {
614
- this._listeners[e] == null && (this._listeners[e] = [], this._eventSource != null && this._eventSource.addEventListener(e, this._onevent_wrapped));
615
- var n = this._listeners[e];
616
- n.includes(t) || (this._listeners[e] = ht(ht([], zt(n), !1), [t], !1));
617
- }, a.prototype.removeEventListener = function(e, t, i) {
618
- var n = this._listeners[e];
619
- this._listeners[e] = n.filter(function(r) {
620
- return r !== t;
621
- });
622
- }, a;
623
- }();
624
- globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
625
- var Ht = function(a, e) {
626
- return e = e || {}, new Promise(function(t, i) {
627
- var n = new XMLHttpRequest(), r = [], o = [], u = {}, c = function() {
628
- return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
629
- return Promise.resolve(n.responseText);
630
- }, json: function() {
631
- return Promise.resolve(n.responseText).then(JSON.parse);
632
- }, blob: function() {
633
- return Promise.resolve(new Blob([n.response]));
634
- }, clone: c, headers: { keys: function() {
635
- return r;
636
- }, entries: function() {
637
- return o;
638
- }, get: function(l) {
639
- return u[l.toLowerCase()];
640
- }, has: function(l) {
641
- return l.toLowerCase() in u;
642
- } } };
643
- };
644
- for (var d in n.open(e.method || "get", a, !0), n.onload = function() {
645
- n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(l, g, x) {
646
- r.push(g = g.toLowerCase()), o.push([g, x]), u[g] = u[g] ? u[g] + "," + x : x;
647
- }), t(c());
648
- }, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(d, e.headers[d]);
649
- n.send(e.body || null);
650
- });
651
- }, $t = Jt({ AsyncStorage: p, fetch: Ht, eventSource: Mt });
652
- typeof window < "u" && (window.flagsmith = $t), y.createFlagsmithInstance = function() {
653
- return Jt({ AsyncStorage: p, fetch: Ht, eventSource: Mt });
654
- }, y.default = $t, Object.defineProperty(y, "__esModule", { value: !0 });
655
- });
656
- })(Pt, Pt.exports);
657
- var le = Pt.exports, ue = {
658
- NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first."
659
- }, te = "business", K, ce = (K = class {
660
- constructor() {
661
- ot(this, "flagsmithClient", null);
662
- ot(this, "userContext", null);
663
- }
664
- static getInstance() {
665
- return K.instance || (K.instance = new K()), K.instance;
666
- }
667
- ensureInitialized() {
668
- if (!this.flagsmithClient)
669
- throw new Error(ue.NOT_INITIALIZED);
670
- }
671
- async init(h, y = []) {
672
- if (!this.flagsmithClient)
673
- try {
674
- this.flagsmithClient = le.createFlagsmithInstance();
675
- const p = y.reduce((s, k) => (s[k.feature.name] = k, s), {});
676
- await this.flagsmithClient.init({
677
- environmentID: h.apiKey,
678
- api: (h == null ? void 0 : h.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
679
- enableAnalytics: (h == null ? void 0 : h.enableAnalytics) ?? !0,
680
- defaultFlags: p,
681
- cacheFlags: (h == null ? void 0 : h.cacheFlags) ?? !0
682
- });
683
- } catch (p) {
684
- throw console.error("Failed to initialize FeatureFlag:", p), p;
685
- }
686
- }
687
- async setUser(h) {
688
- this.ensureInitialized(), this.userContext = { identifier: h }, await this.updateContext();
689
- }
690
- async updateContext() {
691
- try {
692
- if (!this.userContext) return;
693
- await this.flagsmithClient.setContext({
694
- identity: {
695
- identifier: this.userContext.identifier
696
- }
697
- });
698
- } catch (h) {
699
- throw console.error("Failed to update user context:", h), h;
700
- }
701
- }
702
- async getFlags() {
703
- this.ensureInitialized();
704
- const h = this.flagsmithClient.getAllFlags();
705
- return Object.entries(h).map(([y, p]) => {
706
- var s;
707
- return {
708
- feature: {
709
- name: y,
710
- id: (p == null ? void 0 : p.id) ?? 0
711
- },
712
- enabled: p.enabled,
713
- value: ((s = p.value) == null ? void 0 : s.toString()) ?? null
714
- };
715
- });
716
- }
717
- getFlagValue(h, y) {
718
- this.ensureInitialized();
719
- const p = this.flagsmithClient.getValue(h);
720
- if (p == null)
721
- return null;
722
- try {
723
- const s = p.toString();
724
- return y ? y(s) : typeof {} == "number" ? isNaN(Number(s)) ? null : Number(s) : typeof {} == "boolean" ? s.toLowerCase() === "true" : s;
725
- } catch (s) {
726
- return console.error("Error transforming flag value:", s), null;
727
- }
728
- }
729
- getFlag(h) {
730
- this.ensureInitialized();
731
- const y = this.flagsmithClient.getValue(h);
732
- if (y == null) return null;
733
- const p = this.flagsmithClient.hasFeature(h);
734
- return {
735
- feature: {
736
- name: h,
737
- id: 0
738
- },
739
- enabled: p,
740
- value: y.toString()
741
- };
742
- }
743
- async getUserFlagValue(h, y, p = null, s) {
744
- var M;
745
- const k = this.userContext;
746
- try {
747
- return await this.setUser(h), this.getFlagValue(y, s) ?? p;
748
- } catch (D) {
749
- return console.error(`Error getting user flag value for ${y}:`, D), p;
750
- } finally {
751
- try {
752
- await ((M = this.flagsmithClient) == null ? void 0 : M.logout()), this.userContext = null, k && await this.setUser(k.identifier);
753
- } catch (D) {
754
- console.error("Error during cleanup:", D);
755
- }
756
- }
757
- }
758
- reset() {
759
- this.flagsmithClient = null, this.userContext = null;
760
- }
761
- }, ot(K, "instance"), K), he = ce.getInstance(), et = Rt(!1), lt = Rt([]), Y = Rt(null);
762
- function ve(_ = he) {
763
- const h = () => et.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), y = async (v, S = []) => {
764
- if (et.value) {
765
- console.warn("FeatureFlag is already initialized.");
766
- return;
767
- }
768
- try {
769
- await _.init(v, S), lt.value = await _.getFlags(), et.value = !0, Y.value = null;
770
- } catch (C) {
771
- console.error("Failed to initialize feature flags:", C), Y.value = C;
772
- }
773
- }, p = async (v) => {
774
- if (h())
775
- try {
776
- await _.setUser(v), lt.value = await _.getFlags(), Y.value = null;
777
- } catch (S) {
778
- console.error("Failed to set user:", S), Y.value = S;
779
- }
780
- }, s = async (v) => p(`${te}-${v}`), k = (v, S, C = null) => {
781
- if (!h()) return C;
782
- try {
783
- return _.getFlagValue(v, S) ?? C;
784
- } catch (G) {
785
- return console.error(`Error getting flag value for ${v}:`, G), C;
786
- }
787
- }, M = (v, S) => {
788
- if (!h()) return S ?? null;
789
- try {
790
- return _.getFlag(v) ?? S ?? null;
791
- } catch (C) {
792
- return console.error(`Error getting flag for ${v}:`, C), S ?? null;
793
- }
794
- }, D = async (v, S, C = null, G) => {
795
- if (!h()) return C;
796
- try {
797
- return await _.getUserFlagValue(v, S, C, G);
798
- } catch (it) {
799
- return console.error(`Error getting user flag value for ${S}:`, it), C;
800
- }
801
- }, nt = async (v, S, C = null, G) => D(`${te}-${v}`, S, C, G), b = () => {
802
- try {
803
- _.reset();
804
- } catch (v) {
805
- console.error("Error resetting feature flags:", v);
806
- } finally {
807
- lt.value = [], et.value = !1, Y.value = null;
808
- }
809
- };
810
- return {
811
- flags: Nt(lt),
812
- isInitialized: Nt(et),
813
- error: Nt(Y),
814
- init: y,
815
- setUser: p,
816
- setBusiness: s,
817
- getFlagValue: k,
818
- getFlag: M,
819
- getUserFlagValue: D,
820
- getBusinessFlagValue: nt,
821
- reset: b
822
- };
823
- }
824
- var pe = () => ve();
825
- export {
826
- pe as u
827
- };