@feedmepos/mf-miniprogram-v2 0.2.12-dev.1 → 0.2.12-dev.2

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.
@@ -1,31 +1,31 @@
1
- var pe = Object.defineProperty;
2
- var ye = (c, o, d) => o in c ? pe(c, o, { enumerable: !0, configurable: !0, writable: !0, value: d }) : c[o] = d;
3
- var lt = (c, o, d) => ye(c, typeof o != "symbol" ? o + "" : o, d);
1
+ var ye = Object.defineProperty;
2
+ var me = (c, o, d) => o in c ? ye(c, o, { enumerable: !0, configurable: !0, writable: !0, value: d }) : c[o] = d;
3
+ var lt = (c, o, d) => me(c, typeof o != "symbol" ? o + "" : o, d);
4
4
  import "./index-DB33ug2V.js";
5
- import { a as me } from "./routes-W8KfuhWL.js";
6
- import { ref as J, readonly as Ut, watch as Se } from "vue";
7
- import { c as Ce } from "./controlPlane-Bn-uDXG_.js";
5
+ import { a as Se } from "./routes-W8KfuhWL.js";
6
+ import { ref as M, readonly as Ut, watch as Ce } from "vue";
7
+ import { c as _e } from "./controlPlane-Bn-uDXG_.js";
8
8
  import { c as ut } from "./_commonjsHelpers-DaMA6jEr.js";
9
- import { useCoreStore as oe } from "@feedmepos/mf-common";
9
+ import { useCoreStore as re } from "@feedmepos/mf-common";
10
10
  let Kt = null;
11
- function se() {
12
- return Kt || (Kt = Ce(me.adminWhoami()).catch(() => ({
11
+ function oe() {
12
+ return Kt || (Kt = _e(Se.adminWhoami()).catch(() => ({
13
13
  isAdmin: !1,
14
14
  isFeedMeStaff: !1
15
15
  }))), Kt;
16
16
  }
17
- function _e() {
18
- return se().then((c) => c.isAdmin);
17
+ function Fe() {
18
+ return oe().then((c) => c.isAdmin);
19
19
  }
20
- function Ke() {
21
- const c = J(!1);
22
- return _e().then((o) => {
20
+ function Ge() {
21
+ const c = M(!1);
22
+ return Fe().then((o) => {
23
23
  c.value = o;
24
24
  }), c;
25
25
  }
26
- function De() {
27
- const c = J(!1);
28
- return se().then((o) => {
26
+ function Me() {
27
+ const c = M(!1);
28
+ return oe().then((o) => {
29
29
  c.value = o.isFeedMeStaff === !0;
30
30
  }), c;
31
31
  }
@@ -64,7 +64,7 @@ var Dt = { exports: {} };
64
64
  return a;
65
65
  }, l.apply(this, arguments);
66
66
  };
67
- function F(a, e, t, i) {
67
+ function b(a, e, t, i) {
68
68
  return new (t || (t = Promise))(function(n, r) {
69
69
  function s(p) {
70
70
  try {
@@ -152,7 +152,7 @@ var Dt = { exports: {} };
152
152
  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]);
153
153
  return a.concat(i || Array.prototype.slice.call(e));
154
154
  }
155
- var q = function a(e, t) {
155
+ var $ = function a(e, t) {
156
156
  if (e === t) return !0;
157
157
  if (e && t && typeof e == "object" && typeof t == "object") {
158
158
  if (e.constructor !== t.constructor) return !1;
@@ -175,27 +175,27 @@ var Dt = { exports: {} };
175
175
  }
176
176
  return e != e && t != t;
177
177
  };
178
- function _(a, e) {
178
+ function F(a, e) {
179
179
  var t = Object.keys(e || {}).filter(function(i) {
180
180
  var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
181
- return !q(n, r);
181
+ return !$(n, r);
182
182
  });
183
183
  return Object.keys(a || {}).filter(function(i) {
184
184
  Object.keys(e || {}).includes(i) || t.push(i);
185
185
  }), Object.keys(t).length ? t : null;
186
186
  }
187
187
  var g, S;
188
- function b(a, e, t) {
188
+ function _(a, e, t) {
189
189
  var i = "shortString", n = !0;
190
190
  typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
191
191
  }
192
- function M(a) {
192
+ function J(a) {
193
193
  return !!a && typeof a == "object" && a.value !== void 0;
194
194
  }
195
195
  function rt(a) {
196
196
  return Object.fromEntries(Object.entries(a).map(function(e) {
197
197
  var t = e[0], i = e[1];
198
- return [t, M(i) ? i : { value: i }];
198
+ return [t, J(i) ? i : { value: i }];
199
199
  }));
200
200
  }
201
201
  function dt(a) {
@@ -204,7 +204,7 @@ var Dt = { exports: {} };
204
204
  (function(a) {
205
205
  a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
206
206
  })(g || (g = {}));
207
- var vt, A = null, he = "FLAGSMITH_EVENT", ot = he, Gt = "https://edge.api.flagsmith.com/api/v1/", Jt = "flagsmith_value_", Mt = "flagsmith_enabled_", Vt = "flagsmith_trait_", de = function() {
207
+ var vt, A = null, de = "FLAGSMITH_EVENT", ot = de, Gt = "https://edge.api.flagsmith.com/api/v1/", Mt = "flagsmith_value_", Jt = "flagsmith_enabled_", Vt = "flagsmith_trait_", ve = function() {
208
208
  function a(e) {
209
209
  var t = this;
210
210
  this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
@@ -215,21 +215,21 @@ var Dt = { exports: {} };
215
215
  if (v && s === "".concat(t.getContext().identity)) {
216
216
  var k = v.flags, L = v.traits, P = v.identifier;
217
217
  t.isLoading = !1;
218
- var j = {}, N = {};
218
+ var j = {}, T = {};
219
219
  L = L || [], (k = k || []).forEach(function(m) {
220
220
  j[m.feature.name.toLowerCase().replace(/ /g, "_")] = { id: m.feature.id, enabled: m.enabled, value: m.feature_state_value };
221
221
  }), L.forEach(function(m) {
222
- N[m.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: m.transient, value: m.trait_value };
222
+ T[m.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: m.transient, value: m.trait_value };
223
223
  }), t.oldFlags = l({}, t.flags);
224
- var U = _(t.oldFlags, j), W = _((p = t.evaluationContext.identity) === null || p === void 0 ? void 0 : p.traits, N);
225
- if ((P || Object.keys(N).length) && (t.evaluationContext.identity = l(l({}, t.evaluationContext.identity), { traits: N }), P && (t.evaluationContext.identity.identifier = P)), t.flags = j, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: U, traitsChanged: W }, t._loadedState(null, g.SERVER)), t.datadogRum) try {
224
+ var U = F(t.oldFlags, j), W = F((p = t.evaluationContext.identity) === null || p === void 0 ? void 0 : p.traits, T);
225
+ if ((P || Object.keys(T).length) && (t.evaluationContext.identity = l(l({}, t.evaluationContext.identity), { traits: T }), P && (t.evaluationContext.identity.identifier = P)), t.flags = j, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: U, traitsChanged: W }, t._loadedState(null, g.SERVER)), t.datadogRum) try {
226
226
  if (t.datadogRum.trackTraits) {
227
227
  var tt = {};
228
228
  Object.keys(((u = t.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(m) {
229
229
  tt[Vt + m] = t.getTrait(m);
230
230
  });
231
- var $ = l(l(l({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((y = t.evaluationContext.identity) === null || y === void 0 ? void 0 : y.identifier) }), tt);
232
- t.log("Setting Datadog user", $), t.datadogRum.client.setUser($);
231
+ var q = l(l(l({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((y = t.evaluationContext.identity) === null || y === void 0 ? void 0 : y.identifier) }), tt);
232
+ t.log("Setting Datadog user", q), t.datadogRum.client.setUser(q);
233
233
  }
234
234
  } catch (m) {
235
235
  console.error(m);
@@ -237,9 +237,9 @@ var Dt = { exports: {} };
237
237
  if (t.dtrum) try {
238
238
  var w = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
239
239
  Object.keys(t.flags).map(function(m) {
240
- b(w, Jt + m, t.getValue(m, { skipAnalytics: !0 })), b(w, Mt + m, t.hasFeature(m, { skipAnalytics: !0 }));
240
+ _(w, Mt + m, t.getValue(m, { skipAnalytics: !0 })), _(w, Jt + m, t.hasFeature(m, { skipAnalytics: !0 }));
241
241
  }), Object.keys(((x = t.evaluationContext.identity) === null || x === void 0 ? void 0 : x.traits) || {}).map(function(m) {
242
- b(w, Vt + m, t.getTrait(m));
242
+ _(w, Vt + m, t.getTrait(m));
243
243
  }), t.log("Sending javaLongOrObject traits to dynatrace", w.javaLongOrObject), t.log("Sending date traits to dynatrace", w.date), t.log("Sending shortString traits to dynatrace", w.shortString), t.log("Sending javaDouble to dynatrace", w.javaDouble), t.dtrum.sendSessionProperties(w.javaLongOrObject, w.date, w.shortString, w.javaDouble);
244
244
  } catch (m) {
245
245
  console.error(m);
@@ -301,7 +301,7 @@ var Dt = { exports: {} };
301
301
  var n;
302
302
  if (t.api) return t.setContext(l(l({}, t.evaluationContext), { identity: l(l({}, t.evaluationContext.identity), { traits: l(l({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
303
303
  var s = r[0], h = r[1];
304
- return [s, M(h) ? h : { value: h }];
304
+ return [s, J(h) ? h : { value: h }];
305
305
  }))) }) }));
306
306
  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.");
307
307
  }, this.hasFeature = function(i, n) {
@@ -324,13 +324,13 @@ var Dt = { exports: {} };
324
324
  var j = parseFloat(P);
325
325
  if (isNaN(j)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
326
326
  t.timestamp = j;
327
- } catch (N) {
328
- t.log(N, "Failed to parse x-flagsmith-document-updated-at", P);
327
+ } catch (T) {
328
+ t.log(T, "Failed to parse x-flagsmith-document-updated-at", P);
329
329
  }
330
- return t.log("Fetch response: " + y.status + " " + (n || "GET") + 0 + i), y.text().then(function(N) {
331
- var U = N;
330
+ return t.log("Fetch response: " + y.status + " " + (n || "GET") + 0 + i), y.text().then(function(T) {
331
+ var U = T;
332
332
  try {
333
- U = JSON.parse(N);
333
+ U = JSON.parse(T);
334
334
  } catch {
335
335
  }
336
336
  return !U && y.status && (U = "API Response: ".concat(y.status)), y.status && y.status >= 200 && y.status < 300 ? U : Promise.reject(new Error(U));
@@ -339,7 +339,7 @@ var Dt = { exports: {} };
339
339
  t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(u, ", Current: ").concat(L));
340
340
  });
341
341
  }, this.evaluateFlag = function(i, n) {
342
- if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Jt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Mt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
342
+ if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(Mt + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Jt + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
343
343
  if (!t.evaluationEvent || !t.evaluationContext.environment) return;
344
344
  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;
345
345
  }
@@ -351,90 +351,90 @@ var Dt = { exports: {} };
351
351
  }
352
352
  return a.prototype.init = function(e) {
353
353
  var t, i, n;
354
- return F(this, void 0, void 0, function() {
355
- var r, s, h, v, p, u, y, x, k, L, P, j, N, U, W, tt, $, w, m, gt, et, Yt, X, pt, Zt, Qt, yt, Wt, mt, nt, Y, te, O = this;
354
+ return b(this, void 0, void 0, function() {
355
+ var r, s, h, v, p, u, y, x, k, L, P, j, T, U, W, tt, q, w, m, gt, et, Yt, X, pt, Zt, Qt, yt, Wt, mt, nt, Y, te, O = this;
356
356
  return I(this, function(R) {
357
357
  switch (R.label) {
358
358
  case 0:
359
359
  r = dt(e.evaluationContext || this.evaluationContext), R.label = 1;
360
360
  case 1:
361
- if (R.trys.push([1, 13, , 14]), s = e.environmentID, h = e.api, v = h === void 0 ? Gt : h, p = e.headers, u = e.onChange, y = e.cacheFlags, x = e.datadogRum, k = e.onError, L = e.defaultFlags, P = e.fetch, j = e.preventFetch, N = e.enableLogs, U = e.enableDynatrace, W = e.enableAnalytics, tt = e.realtime, $ = e.eventSourceUrl, w = $ === void 0 ? "https://realtime.flagsmith.com/" : $, m = e.AsyncStorage, gt = e.identity, et = e.traits, Yt = e.state, X = e.cacheOptions, pt = e.angularHttpClient, Zt = e._trigger, Qt = e._triggerLoadingState, r.environment = s ? { apiKey: s } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
362
- if (r.identity = gt || et ? { identifier: gt, traits: et ? Object.fromEntries(Object.entries(et).map(function(T) {
363
- return [T[0], { value: T[1] }];
364
- })) : {} } : r.identity, this.evaluationContext = r, this.api = v, this.headers = p, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, yt = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Zt || this._trigger, this._triggerLoadingState = Qt || this._triggerLoadingState, this.onError = function(T) {
365
- O.setLoadingState(l(l({}, O.loadingState), { isFetching: !1, isLoading: !1, error: T })), k == null || k(T);
366
- }, this.enableLogs = N || !1, this.cacheOptions = X ? { skipAPI: !!X.skipAPI, ttl: X.ttl || 0, storageKey: X.storageKey, loadStale: !!X.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."), P && (S = P), this.enableAnalytics = W || !1, this.flags = Object.assign({}, L) || {}, this.datadogRum = x || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = A !== void 0 && !!y, ot = "FLAGSMITH_EVENT_" + r.environment.apiKey, m && (A = m), tt && typeof window < "u" && this.setupRealtime(w, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = l(l({}, this.loadingState), { isLoading: !1, source: g.DEFAULT_FLAGS })), this.setState(Yt), this.log("Initialising with properties", e, this), U && (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), pt && (S = /* @__PURE__ */ function(T) {
361
+ if (R.trys.push([1, 13, , 14]), s = e.environmentID, h = e.api, v = h === void 0 ? Gt : h, p = e.headers, u = e.onChange, y = e.cacheFlags, x = e.datadogRum, k = e.onError, L = e.defaultFlags, P = e.fetch, j = e.preventFetch, T = e.enableLogs, U = e.enableDynatrace, W = e.enableAnalytics, tt = e.realtime, q = e.eventSourceUrl, w = q === void 0 ? "https://realtime.flagsmith.com/" : q, m = e.AsyncStorage, gt = e.identity, et = e.traits, Yt = e.state, X = e.cacheOptions, pt = e.angularHttpClient, Zt = e._trigger, Qt = e._triggerLoadingState, r.environment = s ? { apiKey: s } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
362
+ if (r.identity = gt || et ? { identifier: gt, traits: et ? Object.fromEntries(Object.entries(et).map(function(N) {
363
+ return [N[0], { value: N[1] }];
364
+ })) : {} } : r.identity, this.evaluationContext = r, this.api = v, this.headers = p, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, yt = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = Zt || this._trigger, this._triggerLoadingState = Qt || this._triggerLoadingState, this.onError = function(N) {
365
+ O.setLoadingState(l(l({}, O.loadingState), { isFetching: !1, isLoading: !1, error: N })), k == null || k(N);
366
+ }, this.enableLogs = T || !1, this.cacheOptions = X ? { skipAPI: !!X.skipAPI, ttl: X.ttl || 0, storageKey: X.storageKey, loadStale: !!X.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."), P && (S = P), this.enableAnalytics = W || !1, this.flags = Object.assign({}, L) || {}, this.datadogRum = x || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = A !== void 0 && !!y, ot = "FLAGSMITH_EVENT_" + r.environment.apiKey, m && (A = m), tt && typeof window < "u" && this.setupRealtime(w, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = l(l({}, this.loadingState), { isLoading: !1, source: g.DEFAULT_FLAGS })), this.setState(Yt), this.log("Initialising with properties", e, this), U && (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), pt && (S = /* @__PURE__ */ function(N) {
367
367
  return function(K, D) {
368
- var z = D.headers, C = D.method, Z = D.body;
369
- return new Promise(function(H) {
368
+ var H = D.headers, C = D.method, Z = D.body;
369
+ return new Promise(function(B) {
370
370
  switch (C) {
371
371
  case "GET":
372
- return T.get(K, { headers: z }).subscribe(function(V) {
373
- H({ ok: !0, text: function() {
372
+ return N.get(K, { headers: H }).subscribe(function(V) {
373
+ B({ ok: !0, text: function() {
374
374
  return Promise.resolve(V);
375
375
  } });
376
376
  });
377
377
  case "POST":
378
378
  case "PUT":
379
- return T.post(K, Z, { headers: z }).subscribe(function(V) {
380
- H({ ok: !0, text: function() {
379
+ return N.post(K, Z, { headers: H }).subscribe(function(V) {
380
+ B({ ok: !0, text: function() {
381
381
  return Promise.resolve(V);
382
382
  } });
383
383
  });
384
384
  }
385
385
  });
386
386
  };
387
- }(pt)), A && this.canUseStorage && A.getItem(ot).then(function(T) {
387
+ }(pt)), A && this.canUseStorage && A.getItem(ot).then(function(N) {
388
388
  try {
389
- O.evaluationEvent = JSON.parse(T) || {};
389
+ O.evaluationEvent = JSON.parse(N) || {};
390
390
  } catch {
391
391
  O.evaluationEvent = {};
392
392
  }
393
393
  O.analyticsInterval = setInterval(O.analyticsFlags, O.ticks);
394
- }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), A && this.canUseStorage && A.getItem(ot, function(T, K) {
394
+ }), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), A && this.canUseStorage && A.getItem(ot, function(N, K) {
395
395
  if (K && O.evaluationContext.environment) {
396
396
  var D = JSON.parse(K);
397
397
  if (D[O.evaluationContext.environment.apiKey]) {
398
- var z = O.getState();
399
- O.log("Retrieved events from cache", K), O.setState(l(l({}, z), { evaluationEvent: D[O.evaluationContext.environment.apiKey] }));
398
+ var H = O.getState();
399
+ O.log("Retrieved events from cache", K), O.setState(l(l({}, H), { evaluationEvent: D[O.evaluationContext.environment.apiKey] }));
400
400
  }
401
401
  }
402
402
  })), !y) return [3, 9];
403
403
  if (!A || !this.canUseStorage) return [3, 8];
404
- Wt = function(T, K) {
405
- return F(O, void 0, void 0, function() {
406
- var D, z, C, Z, H, V, St, ee, Ct, _t, bt, Ft, Et, xt, wt, Ot, It, At, Lt, jt, Nt, Tt, Pt, Rt, ne = this;
407
- return I(this, function(B) {
408
- switch (B.label) {
404
+ Wt = function(N, K) {
405
+ return b(O, void 0, void 0, function() {
406
+ var D, H, C, Z, B, V, St, ee, Ct, _t, Ft, bt, Et, xt, wt, Ot, It, At, Lt, jt, Tt, Nt, Pt, Rt, ne = this;
407
+ return I(this, function(z) {
408
+ switch (z.label) {
409
409
  case 0:
410
410
  if (!K) return [3, 7];
411
- D = null, z = null, B.label = 1;
411
+ D = null, H = null, z.label = 1;
412
412
  case 1:
413
- return B.trys.push([1, 5, , 6]), C = JSON.parse(K), Z = !1, H = !1, C && C.api === this.api && ((_t = (Ct = C.evaluationContext) === null || Ct === void 0 ? void 0 : Ct.environment) === null || _t === void 0 ? void 0 : _t.apiKey) === ((bt = this.evaluationContext.environment) === null || bt === void 0 ? void 0 : bt.apiKey) && (V = !0, this.evaluationContext.identity && ((Et = (Ft = C.evaluationContext) === null || Ft === void 0 ? void 0 : Ft.identity) === null || Et === void 0 ? void 0 : Et.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((wt = (xt = C.evaluationContext) === null || xt === void 0 ? void 0 : xt.identity) === null || wt === void 0 ? void 0 : wt.identifier) + " to " + this.evaluationContext.identity.identifier), V = !1), this.cacheOptions.ttl && (!C.ts || (/* @__PURE__ */ new Date()).valueOf() - C.ts > this.cacheOptions.ttl) && (C.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), V = !1) : C.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), H = !0, V = !0)), V && (Z = !0, z = _((Ot = this.evaluationContext.identity) === null || Ot === void 0 ? void 0 : Ot.traits, (At = (It = C.evaluationContext) === null || It === void 0 ? void 0 : It.identity) === null || At === void 0 ? void 0 : At.traits), D = _(this.flags, C.flags), this.setState(l(l({}, C), { evaluationContext: dt(l(l({}, C.evaluationContext), { identity: !((Lt = C.evaluationContext) === null || Lt === void 0) && Lt.identity ? l(l({}, (jt = C.evaluationContext) === null || jt === void 0 ? void 0 : jt.identity), { traits: l(l({}, ((Tt = (Nt = C.evaluationContext) === null || Nt === void 0 ? void 0 : Nt.identity) === null || Tt === void 0 ? void 0 : Tt.traits) || {}), et || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", C))), Z ? (St = !j && (!this.cacheOptions.skipAPI || H), this._onChange(null, { isFromServer: !1, flagsChanged: D, traitsChanged: z }, this._loadedState(null, g.CACHE, St)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && Z && !H && this.log("Skipping API, using cache"), St && this.getFlags().catch(function(ge) {
413
+ return z.trys.push([1, 5, , 6]), C = JSON.parse(K), Z = !1, B = !1, C && C.api === this.api && ((_t = (Ct = C.evaluationContext) === null || Ct === void 0 ? void 0 : Ct.environment) === null || _t === void 0 ? void 0 : _t.apiKey) === ((Ft = this.evaluationContext.environment) === null || Ft === void 0 ? void 0 : Ft.apiKey) && (V = !0, this.evaluationContext.identity && ((Et = (bt = C.evaluationContext) === null || bt === void 0 ? void 0 : bt.identity) === null || Et === void 0 ? void 0 : Et.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((wt = (xt = C.evaluationContext) === null || xt === void 0 ? void 0 : xt.identity) === null || wt === void 0 ? void 0 : wt.identifier) + " to " + this.evaluationContext.identity.identifier), V = !1), this.cacheOptions.ttl && (!C.ts || (/* @__PURE__ */ new Date()).valueOf() - C.ts > this.cacheOptions.ttl) && (C.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), V = !1) : C.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + C.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - C.ts) + "ms"), B = !0, V = !0)), V && (Z = !0, H = F((Ot = this.evaluationContext.identity) === null || Ot === void 0 ? void 0 : Ot.traits, (At = (It = C.evaluationContext) === null || It === void 0 ? void 0 : It.identity) === null || At === void 0 ? void 0 : At.traits), D = F(this.flags, C.flags), this.setState(l(l({}, C), { evaluationContext: dt(l(l({}, C.evaluationContext), { identity: !((Lt = C.evaluationContext) === null || Lt === void 0) && Lt.identity ? l(l({}, (jt = C.evaluationContext) === null || jt === void 0 ? void 0 : jt.identity), { traits: l(l({}, ((Nt = (Tt = C.evaluationContext) === null || Tt === void 0 ? void 0 : Tt.identity) === null || Nt === void 0 ? void 0 : Nt.traits) || {}), et || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", C))), Z ? (St = !j && (!this.cacheOptions.skipAPI || B), this._onChange(null, { isFromServer: !1, flagsChanged: D, traitsChanged: H }, this._loadedState(null, g.CACHE, St)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && Z && !B && this.log("Skipping API, using cache"), St && this.getFlags().catch(function(pe) {
414
414
  var kt;
415
- (kt = ne.onError) === null || kt === void 0 || kt.call(ne, ge);
415
+ (kt = ne.onError) === null || kt === void 0 || kt.call(ne, pe);
416
416
  }), [3, 4]) : [3, 2];
417
417
  case 2:
418
418
  return j ? [3, 4] : [4, this.getFlags()];
419
419
  case 3:
420
- B.sent(), B.label = 4;
420
+ z.sent(), z.label = 4;
421
421
  case 4:
422
422
  return [3, 6];
423
423
  case 5:
424
- return ee = B.sent(), this.log("Exception fetching cached logs", ee), [3, 6];
424
+ return ee = z.sent(), this.log("Exception fetching cached logs", ee), [3, 6];
425
425
  case 6:
426
426
  return [3, 10];
427
427
  case 7:
428
428
  return j ? [3, 9] : [4, this.getFlags()];
429
429
  case 8:
430
- return B.sent(), [3, 10];
430
+ return z.sent(), [3, 10];
431
431
  case 9:
432
- if (L) this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (Pt = this.evaluationContext.identity) === null || Pt === void 0 ? void 0 : Pt.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
432
+ if (L) this._onChange(null, { isFromServer: !1, flagsChanged: F({}, this.flags), traitsChanged: F({}, (Pt = this.evaluationContext.identity) === null || Pt === void 0 ? void 0 : Pt.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
433
433
  else {
434
434
  if (!this.flags) throw new Error(yt);
435
- this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (Rt = this.evaluationContext.identity) === null || Rt === void 0 ? void 0 : Rt.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
435
+ this._onChange(null, { isFromServer: !1, flagsChanged: F({}, this.flags), traitsChanged: F({}, (Rt = this.evaluationContext.identity) === null || Rt === void 0 ? void 0 : Rt.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
436
436
  }
437
- B.label = 10;
437
+ z.label = 10;
438
438
  case 10:
439
439
  return [2];
440
440
  }
@@ -459,8 +459,8 @@ var Dt = { exports: {} };
459
459
  case 10:
460
460
  return R.sent(), [3, 12];
461
461
  case 11:
462
- if (L) this._onChange(null, { isFromServer: !1, flagsChanged: _({}, L), traitsChanged: _({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
463
- else if (this.flags && (nt = null, Object.keys(this.flags).length === 0 && (nt = yt), this._onChange(null, { isFromServer: !1, flagsChanged: _({}, this.flags), traitsChanged: _({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(nt, g.DEFAULT_FLAGS)), nt)) throw new Error(nt);
462
+ if (L) this._onChange(null, { isFromServer: !1, flagsChanged: F({}, L), traitsChanged: F({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, g.DEFAULT_FLAGS));
463
+ else if (this.flags && (nt = null, Object.keys(this.flags).length === 0 && (nt = yt), this._onChange(null, { isFromServer: !1, flagsChanged: F({}, this.flags), traitsChanged: F({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(nt, g.DEFAULT_FLAGS)), nt)) throw new Error(nt);
464
464
  R.label = 12;
465
465
  case 12:
466
466
  return [3, 14];
@@ -476,7 +476,7 @@ var Dt = { exports: {} };
476
476
  }, a.prototype.identify = function(e, t, i) {
477
477
  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) {
478
478
  var r = n[0], s = n[1];
479
- return [r, M(s) ? s : { value: s }];
479
+ return [r, J(s) ? s : { value: s }];
480
480
  }))), this.initialised ? this.getFlags() : Promise.resolve();
481
481
  }, a.prototype.getState = function() {
482
482
  return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
@@ -508,7 +508,7 @@ var Dt = { exports: {} };
508
508
  }
509
509
  }, a.prototype.setLoadingState = function(e) {
510
510
  var t;
511
- q(e, this.loadingState) || (this.loadingState = l({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
511
+ $(e, this.loadingState) || (this.loadingState = l({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
512
512
  }, a.prototype.setupRealtime = function(e, t) {
513
513
  var i = this, n = e + "sse/environments/" + t + "/stream";
514
514
  vt ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new vt(n), this.eventSource.addEventListener("environment_updated", function(r) {
@@ -522,11 +522,11 @@ var Dt = { exports: {} };
522
522
  })) : this.log("Error, EventSource is undefined");
523
523
  }, a;
524
524
  }();
525
- function zt(a) {
525
+ function Ht(a) {
526
526
  var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
527
- return new de({ fetch: e, AsyncStorage: t, eventSource: i });
527
+ return new ve({ fetch: e, AsyncStorage: t, eventSource: i });
528
528
  }
529
- var st, ve = (st = function(a, e) {
529
+ var st, fe = (st = function(a, e) {
530
530
  return st = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
531
531
  t.__proto__ = i;
532
532
  } || function(t, i) {
@@ -538,14 +538,14 @@ var Dt = { exports: {} };
538
538
  this.constructor = a;
539
539
  }
540
540
  st(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
541
- }), Bt = function(a) {
541
+ }), zt = function(a) {
542
542
  var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
543
543
  if (t) return t.call(a);
544
544
  if (a && typeof a.length == "number") return { next: function() {
545
545
  return a && i >= a.length && (a = void 0), { value: a && a[i++], done: !a };
546
546
  } };
547
547
  throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
548
- }, Ht = function(a, e) {
548
+ }, Bt = function(a, e) {
549
549
  var t = typeof Symbol == "function" && a[Symbol.iterator];
550
550
  if (!t) return a;
551
551
  var i, n, r = t.call(a), s = [];
@@ -564,16 +564,16 @@ var Dt = { exports: {} };
564
564
  }, ft = function(a, e, t) {
565
565
  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]);
566
566
  return a.concat(i || Array.prototype.slice.call(e));
567
- }, fe = function(a) {
567
+ }, ge = function(a) {
568
568
  function e() {
569
569
  return a.call(this, `EventSource not available.
570
570
  Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
571
571
  }
572
- return ve(e, a), e;
573
- }(Error), qt = function() {
572
+ return fe(e, a), e;
573
+ }(Error), $t = function() {
574
574
  function a(e, t) {
575
575
  var i = this;
576
- 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 fe();
576
+ 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 ge();
577
577
  this._onevent_wrapped = function(n) {
578
578
  i._onevent(n);
579
579
  }, this._start();
@@ -590,7 +590,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
590
590
  i.onmessage(v);
591
591
  };
592
592
  try {
593
- for (var r = Bt(Object.keys(this._listeners)), s = r.next(); !s.done; s = r.next()) {
593
+ for (var r = zt(Object.keys(this._listeners)), s = r.next(); !s.done; s = r.next()) {
594
594
  var h = s.value;
595
595
  this._eventSource.addEventListener(h, this._onevent_wrapped);
596
596
  }
@@ -619,7 +619,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
619
619
  e && e.lastEventId && (this._lastEventId = e.lastEventId);
620
620
  var n = this._listeners[e.type];
621
621
  if (n != null) try {
622
- for (var r = Bt(ft([], Ht(n), !1)), s = r.next(); !s.done; s = r.next())
622
+ for (var r = zt(ft([], Bt(n), !1)), s = r.next(); !s.done; s = r.next())
623
623
  s.value.call(this, e);
624
624
  } catch (h) {
625
625
  t = { error: h };
@@ -639,7 +639,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
639
639
  }, a.prototype.addEventListener = function(e, t, i) {
640
640
  this._listeners[e] == null && (this._listeners[e] = [], this._eventSource != null && this._eventSource.addEventListener(e, this._onevent_wrapped));
641
641
  var n = this._listeners[e];
642
- n.includes(t) || (this._listeners[e] = ft(ft([], Ht(n), !1), [t], !1));
642
+ n.includes(t) || (this._listeners[e] = ft(ft([], Bt(n), !1), [t], !1));
643
643
  }, a.prototype.removeEventListener = function(e, t, i) {
644
644
  var n = this._listeners[e];
645
645
  this._listeners[e] = n.filter(function(r) {
@@ -648,7 +648,7 @@ Consider loading an EventSource polyfill and making it available globally as Eve
648
648
  }, a;
649
649
  }();
650
650
  globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
651
- var $t = function(a, e) {
651
+ var qt = function(a, e) {
652
652
  return e = e || {}, new Promise(function(t, i) {
653
653
  var n = new XMLHttpRequest(), r = [], s = [], h = {}, v = function() {
654
654
  return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
@@ -674,15 +674,15 @@ Consider loading an EventSource polyfill and making it available globally as Eve
674
674
  }, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(p, e.headers[p]);
675
675
  n.send(e.body || null);
676
676
  });
677
- }, Xt = zt({ AsyncStorage: f, fetch: $t, eventSource: qt });
677
+ }, Xt = Ht({ AsyncStorage: f, fetch: qt, eventSource: $t });
678
678
  typeof window < "u" && (window.flagsmith = Xt), d.createFlagsmithInstance = function() {
679
- return zt({ AsyncStorage: f, fetch: $t, eventSource: qt });
679
+ return Ht({ AsyncStorage: f, fetch: qt, eventSource: $t });
680
680
  }, d.default = Xt, Object.defineProperty(d, "__esModule", { value: !0 });
681
681
  });
682
682
  })(Dt, Dt.exports);
683
- var be = Dt.exports, Fe = {
683
+ var be = Dt.exports, Ee = {
684
684
  NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first."
685
- }, ie = "business", G, Ee = (G = class {
685
+ }, ie = "business", G, xe = (G = class {
686
686
  constructor() {
687
687
  lt(this, "flagsmithClient", null);
688
688
  lt(this, "userContext", null);
@@ -692,13 +692,13 @@ var be = Dt.exports, Fe = {
692
692
  }
693
693
  ensureInitialized() {
694
694
  if (!this.flagsmithClient)
695
- throw new Error(Fe.NOT_INITIALIZED);
695
+ throw new Error(Ee.NOT_INITIALIZED);
696
696
  }
697
697
  async init(o, d = []) {
698
698
  if (!this.flagsmithClient)
699
699
  try {
700
700
  this.flagsmithClient = be.createFlagsmithInstance();
701
- const f = d.reduce((l, F) => (l[F.feature.name] = F, l), {});
701
+ const f = d.reduce((l, b) => (l[b.feature.name] = b, l), {});
702
702
  await this.flagsmithClient.init({
703
703
  environmentID: o.apiKey,
704
704
  api: (o == null ? void 0 : o.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
@@ -768,14 +768,14 @@ var be = Dt.exports, Fe = {
768
768
  }
769
769
  async getUserFlagValue(o, d, f = null, l) {
770
770
  var I;
771
- const F = this.userContext;
771
+ const b = this.userContext;
772
772
  try {
773
773
  return await this.setUser(o), this.getFlagValue(d, l) ?? f;
774
774
  } catch (E) {
775
775
  return console.error(`Error getting user flag value for ${d}:`, E), f;
776
776
  } finally {
777
777
  try {
778
- await ((I = this.flagsmithClient) == null ? void 0 : I.logout()), this.userContext = null, F && await this.setUser(F.identifier);
778
+ await ((I = this.flagsmithClient) == null ? void 0 : I.logout()), this.userContext = null, b && await this.setUser(b.identifier);
779
779
  } catch (E) {
780
780
  console.error("Error during cleanup:", E);
781
781
  }
@@ -784,8 +784,8 @@ var be = Dt.exports, Fe = {
784
784
  reset() {
785
785
  this.flagsmithClient = null, this.userContext = null;
786
786
  }
787
- }, lt(G, "instance"), G), xe = Ee.getInstance(), it = J(!1), ct = J([]), Q = J(null);
788
- function we(c = xe) {
787
+ }, lt(G, "instance"), G), we = xe.getInstance(), it = M(!1), ct = M([]), Q = M(null);
788
+ function Oe(c = we) {
789
789
  const o = () => it.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), d = async (g, S = []) => {
790
790
  if (it.value) {
791
791
  console.warn("FeatureFlag is already initialized.");
@@ -793,8 +793,8 @@ function we(c = xe) {
793
793
  }
794
794
  try {
795
795
  await c.init(g, S), ct.value = await c.getFlags(), it.value = !0, Q.value = null;
796
- } catch (b) {
797
- console.error("Failed to initialize feature flags:", b), Q.value = b;
796
+ } catch (_) {
797
+ console.error("Failed to initialize feature flags:", _), Q.value = _;
798
798
  }
799
799
  }, f = async (g) => {
800
800
  if (o())
@@ -803,28 +803,28 @@ function we(c = xe) {
803
803
  } catch (S) {
804
804
  console.error("Failed to set user:", S), Q.value = S;
805
805
  }
806
- }, l = async (g) => f(`${ie}-${g}`), F = (g, S, b = null) => {
807
- if (!o()) return b;
806
+ }, l = async (g) => f(`${ie}-${g}`), b = (g, S, _ = null) => {
807
+ if (!o()) return _;
808
808
  try {
809
- return c.getFlagValue(g, S) ?? b;
810
- } catch (M) {
811
- return console.error(`Error getting flag value for ${g}:`, M), b;
809
+ return c.getFlagValue(g, S) ?? _;
810
+ } catch (J) {
811
+ return console.error(`Error getting flag value for ${g}:`, J), _;
812
812
  }
813
813
  }, I = (g, S) => {
814
814
  if (!o()) return S ?? null;
815
815
  try {
816
816
  return c.getFlag(g) ?? S ?? null;
817
- } catch (b) {
818
- return console.error(`Error getting flag for ${g}:`, b), S ?? null;
817
+ } catch (_) {
818
+ return console.error(`Error getting flag for ${g}:`, _), S ?? null;
819
819
  }
820
- }, E = async (g, S, b = null, M) => {
821
- if (!o()) return b;
820
+ }, E = async (g, S, _ = null, J) => {
821
+ if (!o()) return _;
822
822
  try {
823
- return await c.getUserFlagValue(g, S, b, M);
823
+ return await c.getUserFlagValue(g, S, _, J);
824
824
  } catch (rt) {
825
- return console.error(`Error getting user flag value for ${S}:`, rt), b;
825
+ return console.error(`Error getting user flag value for ${S}:`, rt), _;
826
826
  }
827
- }, q = async (g, S, b = null, M) => E(`${ie}-${g}`, S, b, M), _ = () => {
827
+ }, $ = async (g, S, _ = null, J) => E(`${ie}-${g}`, S, _, J), F = () => {
828
828
  try {
829
829
  c.reset();
830
830
  } catch (g) {
@@ -840,37 +840,39 @@ function we(c = xe) {
840
840
  init: d,
841
841
  setUser: f,
842
842
  setBusiness: l,
843
- getFlagValue: F,
843
+ getFlagValue: b,
844
844
  getFlag: I,
845
845
  getUserFlagValue: E,
846
- getBusinessFlagValue: q,
847
- reset: _
846
+ getBusinessFlagValue: $,
847
+ reset: F
848
848
  };
849
849
  }
850
- var le = () => we();
850
+ var se = () => Oe();
851
851
  const ae = {
852
852
  dev: "MaGoXrEWuEJNpWgKTqseee",
853
853
  prod: "6GhcttsJ9Rj9cTevcdrpin"
854
- }, ue = "order_miniprogram_v2", re = 1e4, at = J("pending");
855
- let ht = null;
856
- function Ge(c) {
857
- if (ht) return ht;
858
- const { init: o } = le(), d = c === "prod" ? ae.prod : ae.dev;
854
+ }, le = "order_miniprogram_v2", Ie = "https://flag.feedmeapi.com/api/v1/", ue = 1e4;
855
+ function ce(c, o, d) {
859
856
  let f;
860
- return ht = Promise.race([
861
- o({ apiKey: d }),
862
- new Promise((l, F) => {
863
- f = setTimeout(() => F(new Error(`Flagsmith init exceeded ${re}ms`)), re);
857
+ return Promise.race([
858
+ c,
859
+ new Promise((l, b) => {
860
+ f = setTimeout(() => b(new Error(`${d} exceeded ${o}ms`)), o);
864
861
  })
865
- ]).then(() => {
862
+ ]).finally(() => clearTimeout(f));
863
+ }
864
+ const at = M("pending");
865
+ let ht = null;
866
+ function Je(c) {
867
+ if (ht) return ht;
868
+ const { init: o } = se(), d = c === "prod" ? ae.prod : ae.dev;
869
+ return ht = ce(o({ apiKey: d, url: Ie }), ue, "Flagsmith init").then(() => {
866
870
  at.value = "ready";
867
- }).catch((l) => {
868
- at.value = "failed", console.warn("[FeatureFlag] init failed:", l);
869
- }).finally(() => {
870
- clearTimeout(f);
871
+ }).catch((f) => {
872
+ at.value = "failed", console.warn("[FeatureFlag] init failed:", f);
871
873
  }), ht;
872
874
  }
873
- function Oe(c) {
875
+ function Ae(c) {
874
876
  try {
875
877
  const o = typeof c == "string" ? JSON.parse(c) : c;
876
878
  return o === !0 || o === "true" || (o == null ? void 0 : o.enabled) === !0 || (o == null ? void 0 : o.enabled) === "true";
@@ -878,7 +880,7 @@ function Oe(c) {
878
880
  return c === !0 || c === "true";
879
881
  }
880
882
  }
881
- function Ie(c) {
883
+ function Le(c) {
882
884
  try {
883
885
  const o = typeof c == "string" ? JSON.parse(c) : c, d = o == null ? void 0 : o.edit_require_license;
884
886
  return d === !0 || d === "true";
@@ -886,14 +888,14 @@ function Ie(c) {
886
888
  return !1;
887
889
  }
888
890
  }
889
- function ce(c, o, d) {
890
- const f = oe(), { getBusinessFlagValue: l } = le(), F = J(o), I = J(!0);
891
+ function he(c, o, d) {
892
+ const f = re(), { getBusinessFlagValue: l } = se(), b = M(o), I = M(!0);
891
893
  let E = 0;
892
- async function q() {
894
+ async function $() {
893
895
  var S;
894
- const _ = ++E, g = (S = f.currentBusiness.value) == null ? void 0 : S._id;
896
+ const F = ++E, g = (S = f.currentBusiness.value) == null ? void 0 : S._id;
895
897
  if (!g || at.value === "failed") {
896
- F.value = o, I.value = !1;
898
+ b.value = o, I.value = !1;
897
899
  return;
898
900
  }
899
901
  if (at.value === "pending") {
@@ -902,36 +904,40 @@ function ce(c, o, d) {
902
904
  }
903
905
  I.value = !0;
904
906
  try {
905
- const b = await l(g, c, o);
906
- if (_ !== E) return;
907
- F.value = d ? d(b) : b;
908
- } catch {
909
- if (_ !== E) return;
910
- F.value = o;
907
+ const _ = await ce(
908
+ l(g, c, o),
909
+ ue,
910
+ `Flagsmith ${c} read`
911
+ );
912
+ if (F !== E) return;
913
+ b.value = d ? d(_) : _;
914
+ } catch (_) {
915
+ if (F !== E) return;
916
+ console.warn(`[FeatureFlag] ${c} read failed:`, _), b.value = o;
911
917
  } finally {
912
- _ === E && (I.value = !1);
918
+ F === E && (I.value = !1);
913
919
  }
914
920
  }
915
- return Se([() => {
916
- var _;
917
- return (_ = f.currentBusiness.value) == null ? void 0 : _._id;
918
- }, at], q, { immediate: !0 }), { value: F, loading: I };
921
+ return Ce([() => {
922
+ var F;
923
+ return (F = f.currentBusiness.value) == null ? void 0 : F._id;
924
+ }, at], $, { immediate: !0 }), { value: b, loading: I };
919
925
  }
920
- function Je(c) {
921
- const o = oe();
922
- if (Ae(c, o.namespace.value))
923
- return { enabled: J(!0), loading: J(!1) };
924
- const { value: d, loading: f } = ce(ue, !1, Oe);
926
+ function Ve(c) {
927
+ const o = re();
928
+ if (je(c, o.namespace.value))
929
+ return { enabled: M(!0), loading: M(!1) };
930
+ const { value: d, loading: f } = he(le, !1, Ae);
925
931
  return { enabled: d, loading: f };
926
932
  }
927
- function Me() {
928
- const { value: c, loading: o } = ce(ue, !1, Ie);
933
+ function He() {
934
+ const { value: c, loading: o } = he(le, !1, Le);
929
935
  return { required: c, loading: o };
930
936
  }
931
- function Ae(c, o) {
937
+ function je(c, o) {
932
938
  return c.toLowerCase().includes("dev") && o === "dev";
933
939
  }
934
- function Ve(c, o) {
940
+ function ze(c, o) {
935
941
  if (typeof window > "u") return o;
936
942
  try {
937
943
  const d = window.localStorage.getItem(c);
@@ -940,7 +946,7 @@ function Ve(c, o) {
940
946
  return o;
941
947
  }
942
948
  }
943
- function ze(c, o) {
949
+ function Be(c, o) {
944
950
  if (typeof window > "u") return o;
945
951
  try {
946
952
  const d = Number(window.localStorage.getItem(c));
@@ -949,24 +955,24 @@ function ze(c, o) {
949
955
  return o;
950
956
  }
951
957
  }
952
- function Le(c, o) {
958
+ function Te(c, o) {
953
959
  if (!(typeof window > "u"))
954
960
  try {
955
961
  window.localStorage.setItem(c, o);
956
962
  } catch {
957
963
  }
958
964
  }
959
- function Be(c, o) {
960
- Le(c, o ? "1" : "0");
965
+ function $e(c, o) {
966
+ Te(c, o ? "1" : "0");
961
967
  }
962
968
  export {
963
- Ke as a,
964
- De as b,
965
- Me as c,
966
- ze as d,
967
- Le as e,
968
- Ge as i,
969
- Ve as r,
970
- Je as u,
971
- Be as w
969
+ Ge as a,
970
+ Me as b,
971
+ He as c,
972
+ Be as d,
973
+ Te as e,
974
+ Je as i,
975
+ ze as r,
976
+ Ve as u,
977
+ $e as w
972
978
  };