@feedmepos/mf-miniprogram-v2 0.2.2-dev.9 → 0.2.3
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.
- package/dist/App-qAELeU_7.js +1120 -0
- package/dist/AppTemplatePicker.vue_vue_type_script_setup_true_lang-CDvGnq6F.js +184 -0
- package/dist/BrandFontPicker-BZyGrK3D.js +241 -0
- package/dist/BrandKitView-CzefaEEN.js +249 -0
- package/dist/{ControlPlaneView-DGDA8EFh.js → ControlPlaneView-CqUxRaS2.js} +7717 -7289
- package/dist/{EcosystemView-Cx-3k7lB.js → EcosystemView-C-y5cPOp.js} +7 -7
- package/dist/{LegacyWorkspaceEntry-opz_kWz9.js → LegacyWorkspaceEntry-CADRpDkg.js} +2 -2
- package/dist/MobileProjectsView-obtkXdEv.js +331 -0
- package/dist/{ModuleCenterView-DEShxy_e.js → ModuleCenterView-B08oZqQw.js} +34 -34
- package/dist/{ModuleDetailView-BSndm4ov.js → ModuleDetailView-lROTkaR7.js} +49 -49
- package/dist/{PagesView-CegMd6GC.js → PagesView-DOG8RSen.js} +2 -2
- package/dist/{PlatformUnavailableView-j0_2YBKm.js → PlatformUnavailableView-C1RltAIw.js} +1 -1
- package/dist/{PortalSettingsView-DFz6FUd9.js → PortalSettingsView-BK6kRgtf.js} +7 -7
- package/dist/StatusBadge.vue_vue_type_script_setup_true_lang-CMgQ0bd_.js +30 -0
- package/dist/TemplateCenterView-niXTXw9y.js +426 -0
- package/dist/WorkspaceEntryView-DzR8DQC5.js +21 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/adminAccess-CDxAuQ-M.js +48 -0
- package/dist/app.js +22 -11
- package/dist/{controlPlane-CoEgf9BA.js → controlPlane-DT3t_ftg.js} +11 -11
- package/dist/{index-D5qXvcfE.js → index-CIJWcl_6.js} +10 -9
- package/dist/package.json +3 -1
- package/dist/{portalContext-C4HL_0kl.js → portalContext-B2pXdNtB.js} +2 -2
- package/dist/portalNavigation-DKCfwTH8.js +28 -0
- package/dist/routes-CeuodIgg.js +95 -0
- package/dist/style.css +1 -1
- package/dist/{useBrandKit-BlKlqpo2.js → useBrandKit-CQv08nyY.js} +166 -170
- package/dist/{useModuleCatalog-CkNuZzNM.js → useModuleCatalog-B9HXHA-e.js} +3 -3
- package/package.json +3 -1
- package/dist/App-BtDqnBq4.js +0 -193
- package/dist/AppTemplatePicker-eKlQ0c54.js +0 -184
- package/dist/BrandFontPicker-CyLbp5nr.js +0 -240
- package/dist/BrandKitView-CaxS1T-W.js +0 -217
- package/dist/MobileProjectsView-DEQ6q6Si.js +0 -279
- package/dist/StatusBadge.vue_vue_type_script_setup_true_lang-Bh9Eoe_H.js +0 -26
- package/dist/WorkspaceEntryView-e2EUnq9A.js +0 -21
- package/dist/localPreference-DneUpUrQ.js +0 -34
- package/dist/portalNavigation-DOF4Ah49.js +0 -28
- package/dist/routes-Boz_WlNM.js +0 -54
|
@@ -0,0 +1,1120 @@
|
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var ke = (f, s, g) => s in f ? Ae(f, s, { enumerable: !0, configurable: !0, writable: !0, value: g }) : f[s] = g;
|
|
3
|
+
var Et = (f, s, g) => ke(f, typeof s != "symbol" ? s + "" : s, g);
|
|
4
|
+
import { readonly as Wt, ref as tt, watch as je, defineComponent as Pe, computed as yt, onMounted as Te, onBeforeUnmount as Ne, resolveComponent as wt, openBlock as B, createElementBlock as Q, Fragment as te, createElementVNode as S, normalizeClass as ee, createVNode as T, renderList as me, unref as C, withCtx as st, toDisplayString as ut, createBlock as ye, createCommentVNode as ne } from "vue";
|
|
5
|
+
import { useCoreStore as xe } from "@feedmepos/mf-common";
|
|
6
|
+
import { useRoute as Re, RouterView as Ue } from "vue-router";
|
|
7
|
+
import { P as bt } from "./PortalIcon-DO0VrIoY.js";
|
|
8
|
+
import { r as be, u as Ke, w as Se } from "./adminAccess-CDxAuQ-M.js";
|
|
9
|
+
import { c as Ot } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
10
|
+
import { p as Me } from "./portalContext-B2pXdNtB.js";
|
|
11
|
+
import { p as ct } from "./portalNavigation-DKCfwTH8.js";
|
|
12
|
+
import { _ as De } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
13
|
+
var ie = { exports: {} };
|
|
14
|
+
(function(f, s) {
|
|
15
|
+
(function(g, d) {
|
|
16
|
+
d(s);
|
|
17
|
+
})(Ot, function(g) {
|
|
18
|
+
var d = { getItemSync: function(a) {
|
|
19
|
+
try {
|
|
20
|
+
return localStorage.getItem(a) || null;
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}, getItem: function(a, e) {
|
|
25
|
+
var t = this;
|
|
26
|
+
return new Promise(function(i, n) {
|
|
27
|
+
try {
|
|
28
|
+
var r = t.getItemSync(a);
|
|
29
|
+
e == null || e(null, r), i(r);
|
|
30
|
+
} catch (l) {
|
|
31
|
+
e && e(l, null), n(l);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}, setItem: function(a, e, t) {
|
|
35
|
+
return new Promise(function(i, n) {
|
|
36
|
+
try {
|
|
37
|
+
localStorage.setItem(a, e), t && t(null, e), i(e);
|
|
38
|
+
} catch (r) {
|
|
39
|
+
t && t(r, null), n(r);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
} }, o = function() {
|
|
43
|
+
return o = Object.assign || function(a) {
|
|
44
|
+
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]);
|
|
45
|
+
return a;
|
|
46
|
+
}, o.apply(this, arguments);
|
|
47
|
+
};
|
|
48
|
+
function x(a, e, t, i) {
|
|
49
|
+
return new (t || (t = Promise))(function(n, r) {
|
|
50
|
+
function l(m) {
|
|
51
|
+
try {
|
|
52
|
+
v(i.next(m));
|
|
53
|
+
} catch (u) {
|
|
54
|
+
r(u);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function c(m) {
|
|
58
|
+
try {
|
|
59
|
+
v(i.throw(m));
|
|
60
|
+
} catch (u) {
|
|
61
|
+
r(u);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function v(m) {
|
|
65
|
+
var u;
|
|
66
|
+
m.done ? n(m.value) : (u = m.value, u instanceof t ? u : new t(function(y) {
|
|
67
|
+
y(u);
|
|
68
|
+
})).then(l, c);
|
|
69
|
+
}
|
|
70
|
+
v((i = i.apply(a, [])).next());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function A(a, e) {
|
|
74
|
+
var t, i, n, r, l = { label: 0, sent: function() {
|
|
75
|
+
if (1 & n[0]) throw n[1];
|
|
76
|
+
return n[1];
|
|
77
|
+
}, trys: [], ops: [] };
|
|
78
|
+
return r = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (r[Symbol.iterator] = function() {
|
|
79
|
+
return this;
|
|
80
|
+
}), r;
|
|
81
|
+
function c(v) {
|
|
82
|
+
return function(m) {
|
|
83
|
+
return function(u) {
|
|
84
|
+
if (t) throw new TypeError("Generator is already executing.");
|
|
85
|
+
for (; l; ) try {
|
|
86
|
+
if (t = 1, i && (n = 2 & u[0] ? i.return : u[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, u[1])).done) return n;
|
|
87
|
+
switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) {
|
|
88
|
+
case 0:
|
|
89
|
+
case 1:
|
|
90
|
+
n = u;
|
|
91
|
+
break;
|
|
92
|
+
case 4:
|
|
93
|
+
return l.label++, { value: u[1], done: !1 };
|
|
94
|
+
case 5:
|
|
95
|
+
l.label++, i = u[1], u = [0];
|
|
96
|
+
continue;
|
|
97
|
+
case 7:
|
|
98
|
+
u = l.ops.pop(), l.trys.pop();
|
|
99
|
+
continue;
|
|
100
|
+
default:
|
|
101
|
+
if (n = l.trys, !((n = n.length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) {
|
|
102
|
+
l = 0;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) {
|
|
106
|
+
l.label = u[1];
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (u[0] === 6 && l.label < n[1]) {
|
|
110
|
+
l.label = n[1], n = u;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
if (n && l.label < n[2]) {
|
|
114
|
+
l.label = n[2], l.ops.push(u);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
n[2] && l.ops.pop(), l.trys.pop();
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
u = e.call(a, l);
|
|
121
|
+
} catch (y) {
|
|
122
|
+
u = [6, y], i = 0;
|
|
123
|
+
} finally {
|
|
124
|
+
t = n = 0;
|
|
125
|
+
}
|
|
126
|
+
if (5 & u[0]) throw u[1];
|
|
127
|
+
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
128
|
+
}([v, m]);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function O(a, e, t) {
|
|
133
|
+
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]);
|
|
134
|
+
return a.concat(i || Array.prototype.slice.call(e));
|
|
135
|
+
}
|
|
136
|
+
var M = function a(e, t) {
|
|
137
|
+
if (e === t) return !0;
|
|
138
|
+
if (e && t && typeof e == "object" && typeof t == "object") {
|
|
139
|
+
if (e.constructor !== t.constructor) return !1;
|
|
140
|
+
var i, n, r;
|
|
141
|
+
if (Array.isArray(e)) {
|
|
142
|
+
if ((i = e.length) != t.length) return !1;
|
|
143
|
+
for (n = i; n-- != 0; ) if (!a(e[n], t[n])) return !1;
|
|
144
|
+
return !0;
|
|
145
|
+
}
|
|
146
|
+
if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
|
|
147
|
+
if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
|
|
148
|
+
if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
|
|
149
|
+
if ((i = (r = Object.keys(e)).length) !== Object.keys(t).length) return !1;
|
|
150
|
+
for (n = i; n-- != 0; ) if (!Object.prototype.hasOwnProperty.call(t, r[n])) return !1;
|
|
151
|
+
for (n = i; n-- != 0; ) {
|
|
152
|
+
var l = r[n];
|
|
153
|
+
if (!a(e[l], t[l])) return !1;
|
|
154
|
+
}
|
|
155
|
+
return !0;
|
|
156
|
+
}
|
|
157
|
+
return e != e && t != t;
|
|
158
|
+
};
|
|
159
|
+
function F(a, e) {
|
|
160
|
+
var t = Object.keys(e || {}).filter(function(i) {
|
|
161
|
+
var n = a == null ? void 0 : a[i], r = e == null ? void 0 : e[i];
|
|
162
|
+
return !M(n, r);
|
|
163
|
+
});
|
|
164
|
+
return Object.keys(a || {}).filter(function(i) {
|
|
165
|
+
Object.keys(e || {}).includes(i) || t.push(i);
|
|
166
|
+
}), Object.keys(t).length ? t : null;
|
|
167
|
+
}
|
|
168
|
+
var h, _;
|
|
169
|
+
function w(a, e, t) {
|
|
170
|
+
var i = "shortString", n = !0;
|
|
171
|
+
typeof t == "number" && (i = "javaDouble", n = !1), a[i] = a[i] || {}, a[i][e] = n ? t + "" : t;
|
|
172
|
+
}
|
|
173
|
+
function D(a) {
|
|
174
|
+
return !!a && typeof a == "object" && a.value !== void 0;
|
|
175
|
+
}
|
|
176
|
+
function nt(a) {
|
|
177
|
+
return Object.fromEntries(Object.entries(a).map(function(e) {
|
|
178
|
+
var t = e[0], i = e[1];
|
|
179
|
+
return [t, D(i) ? i : { value: i }];
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
function it(a) {
|
|
183
|
+
return o(o({}, a), { identity: a.identity ? o(o({}, a.identity), { traits: nt(a.identity.traits || {}) }) : void 0 });
|
|
184
|
+
}
|
|
185
|
+
(function(a) {
|
|
186
|
+
a.NONE = "NONE", a.DEFAULT_FLAGS = "DEFAULT_FLAGS", a.CACHE = "CACHE", a.SERVER = "SERVER";
|
|
187
|
+
})(h || (h = {}));
|
|
188
|
+
var vt, I = null, p = "FLAGSMITH_EVENT", G = p, gt = "https://edge.api.flagsmith.com/api/v1/", _t = "flagsmith_value_", Ft = "flagsmith_enabled_", L = "flagsmith_trait_", we = function() {
|
|
189
|
+
function a(e) {
|
|
190
|
+
var t = this;
|
|
191
|
+
this._trigger = null, this._triggerLoadingState = null, this.timestamp = null, this.isLoading = !1, this.eventSource = null, this.getFlags = function() {
|
|
192
|
+
var i = t, n = i.api, r = i.evaluationContext;
|
|
193
|
+
t.log("Get Flags"), t.isLoading = !0, t.loadingState.isFetching || t.setLoadingState(o(o({}, t.loadingState), { isFetching: !0 }));
|
|
194
|
+
var l = "".concat(t.getContext().identity), c = function(v) {
|
|
195
|
+
var m, u, y, k;
|
|
196
|
+
if (v && l === "".concat(t.getContext().identity)) {
|
|
197
|
+
var z = v.flags, N = v.traits, J = v.identifier;
|
|
198
|
+
t.isLoading = !1;
|
|
199
|
+
var R = {}, U = {};
|
|
200
|
+
N = N || [], (z = z || []).forEach(function(b) {
|
|
201
|
+
R[b.feature.name.toLowerCase().replace(/ /g, "_")] = { id: b.feature.id, enabled: b.enabled, value: b.feature_state_value };
|
|
202
|
+
}), N.forEach(function(b) {
|
|
203
|
+
U[b.trait_key.toLowerCase().replace(/ /g, "_")] = { transient: b.transient, value: b.trait_value };
|
|
204
|
+
}), t.oldFlags = o({}, t.flags);
|
|
205
|
+
var q = F(t.oldFlags, R), ht = F((m = t.evaluationContext.identity) === null || m === void 0 ? void 0 : m.traits, U);
|
|
206
|
+
if ((J || Object.keys(U).length) && (t.evaluationContext.identity = o(o({}, t.evaluationContext.identity), { traits: U }), J && (t.evaluationContext.identity.identifier = J)), t.flags = R, t.updateStorage(), t._onChange(t.oldFlags, { isFromServer: !0, flagsChanged: q, traitsChanged: ht }, t._loadedState(null, h.SERVER)), t.datadogRum) try {
|
|
207
|
+
if (t.datadogRum.trackTraits) {
|
|
208
|
+
var ft = {};
|
|
209
|
+
Object.keys(((u = t.evaluationContext.identity) === null || u === void 0 ? void 0 : u.traits) || {}).map(function(b) {
|
|
210
|
+
ft[L + b] = t.getTrait(b);
|
|
211
|
+
});
|
|
212
|
+
var at = o(o(o({}, t.datadogRum.client.getUser()), { id: t.datadogRum.client.getUser().id || ((y = t.evaluationContext.identity) === null || y === void 0 ? void 0 : y.identifier) }), ft);
|
|
213
|
+
t.log("Setting Datadog user", at), t.datadogRum.client.setUser(at);
|
|
214
|
+
}
|
|
215
|
+
} catch (b) {
|
|
216
|
+
console.error(b);
|
|
217
|
+
}
|
|
218
|
+
if (t.dtrum) try {
|
|
219
|
+
var j = { javaDouble: {}, date: {}, shortString: {}, javaLongOrObject: {} };
|
|
220
|
+
Object.keys(t.flags).map(function(b) {
|
|
221
|
+
w(j, _t + b, t.getValue(b, { skipAnalytics: !0 })), w(j, Ft + b, t.hasFeature(b, { skipAnalytics: !0 }));
|
|
222
|
+
}), Object.keys(((k = t.evaluationContext.identity) === null || k === void 0 ? void 0 : k.traits) || {}).map(function(b) {
|
|
223
|
+
w(j, L + b, t.getTrait(b));
|
|
224
|
+
}), t.log("Sending javaLongOrObject traits to dynatrace", j.javaLongOrObject), t.log("Sending date traits to dynatrace", j.date), t.log("Sending shortString traits to dynatrace", j.shortString), t.log("Sending javaDouble to dynatrace", j.javaDouble), t.dtrum.sendSessionProperties(j.javaLongOrObject, j.date, j.shortString, j.javaDouble);
|
|
225
|
+
} catch (b) {
|
|
226
|
+
console.error(b);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
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(v) {
|
|
231
|
+
var m = v[0], u = v[1];
|
|
232
|
+
return { trait_key: m, trait_value: u == null ? void 0 : u.value, transient: u == null ? void 0 : u.transient };
|
|
233
|
+
}).filter(function(v) {
|
|
234
|
+
return v.trait_value !== void 0 || (t.log("Warning - attempted to set an undefined trait value for key", v.trait_key), !1);
|
|
235
|
+
}) })) : t.getJSON(n + "identities/?identifier=" + encodeURIComponent(r.identity.identifier) + (r.identity.transient ? "&transient=true" : ""))]).then(function(v) {
|
|
236
|
+
return t.evaluationContext.identity = o(o({}, t.evaluationContext.identity), { traits: {} }), c(v == null ? void 0 : v[0]);
|
|
237
|
+
}).catch(function(v) {
|
|
238
|
+
var m = v.message, u = new Error(m);
|
|
239
|
+
return Promise.reject(u);
|
|
240
|
+
}) : t.getJSON(n + "flags/").then(function(v) {
|
|
241
|
+
return c({ flags: v, traits: void 0 });
|
|
242
|
+
});
|
|
243
|
+
}, this.analyticsFlags = function() {
|
|
244
|
+
var i = t.api;
|
|
245
|
+
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) {
|
|
246
|
+
if (t.evaluationContext.environment) {
|
|
247
|
+
var r = t.getState();
|
|
248
|
+
t.evaluationEvent || (t.evaluationEvent = {}), t.evaluationEvent[t.evaluationContext.environment.apiKey] = {}, t.setState(o(o({}, r), { evaluationEvent: t.evaluationEvent })), t.updateEventStorage();
|
|
249
|
+
}
|
|
250
|
+
}).catch(function(n) {
|
|
251
|
+
t.log("Exception fetching evaluationEvent", n);
|
|
252
|
+
}) : void 0;
|
|
253
|
+
}, this.datadogRum = null, this.loadingState = { isLoading: !0, isFetching: !0, error: null, source: h.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) {
|
|
254
|
+
var l = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = null;
|
|
255
|
+
if (l && (c = l.value), n != null && n.skipAnalytics || r || t.evaluateFlag(i, "VALUE"), c === null && (n == null ? void 0 : n.fallback) !== void 0) return n.fallback;
|
|
256
|
+
if (n != null && n.json) try {
|
|
257
|
+
return c === null ? (t.log("Tried to parse null flag as JSON: " + i), null) : JSON.parse(c);
|
|
258
|
+
} catch {
|
|
259
|
+
return n.fallback;
|
|
260
|
+
}
|
|
261
|
+
return c;
|
|
262
|
+
}, this.getTrait = function(i) {
|
|
263
|
+
var n, r;
|
|
264
|
+
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);
|
|
265
|
+
}, this.getAllTraits = function() {
|
|
266
|
+
var i;
|
|
267
|
+
return Object.fromEntries(Object.entries(((i = t.evaluationContext.identity) === null || i === void 0 ? void 0 : i.traits) || {}).map(function(n) {
|
|
268
|
+
var r = n[0], l = n[1];
|
|
269
|
+
return [r, l == null ? void 0 : l.value];
|
|
270
|
+
}));
|
|
271
|
+
}, this.setContext = function(i) {
|
|
272
|
+
var n = it(i);
|
|
273
|
+
return t.evaluationContext = o(o({}, n), { environment: n.environment || t.evaluationContext.environment }), t.initialised ? t.getFlags() : Promise.resolve();
|
|
274
|
+
}, this.getContext = function() {
|
|
275
|
+
return t.evaluationContext;
|
|
276
|
+
}, this.updateContext = function(i) {
|
|
277
|
+
return t.setContext(o(o({}, t.getContext()), i));
|
|
278
|
+
}, this.setTrait = function(i, n) {
|
|
279
|
+
var r;
|
|
280
|
+
if (t.api) return t.setContext(o(o({}, t.evaluationContext), { identity: o(o({}, t.evaluationContext.identity), { traits: o(o({}, (r = t.evaluationContext.identity) === null || r === void 0 ? void 0 : r.traits), nt(Object.fromEntries([[i, n]]))) }) }));
|
|
281
|
+
}, this.setTraits = function(i) {
|
|
282
|
+
var n;
|
|
283
|
+
if (t.api) return t.setContext(o(o({}, t.evaluationContext), { identity: o(o({}, t.evaluationContext.identity), { traits: o(o({}, (n = t.evaluationContext.identity) === null || n === void 0 ? void 0 : n.traits), Object.fromEntries(Object.entries(i).map(function(r) {
|
|
284
|
+
var l = r[0], c = r[1];
|
|
285
|
+
return [l, D(c) ? c : { value: c }];
|
|
286
|
+
}))) }) }));
|
|
287
|
+
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.");
|
|
288
|
+
}, this.hasFeature = function(i, n) {
|
|
289
|
+
var r = typeof n == "object", l = t.flags && t.flags[i.toLowerCase().replace(/ /g, "_")], c = !1;
|
|
290
|
+
return !l && r && n.fallback !== void 0 ? c = n == null ? void 0 : n.fallback : l && l.enabled && (c = !0), (r && !n.skipAnalytics || !n) && t.evaluateFlag(i, "ENABLED"), c;
|
|
291
|
+
}, this.getStorageKey = function() {
|
|
292
|
+
var i, n;
|
|
293
|
+
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);
|
|
294
|
+
}, this.getJSON = function(i, n, r) {
|
|
295
|
+
var l, c = t;
|
|
296
|
+
c.evaluationContext;
|
|
297
|
+
var v = c.headers, m = { method: n || "GET", body: r, cache: "no-cache", headers: {} };
|
|
298
|
+
t.evaluationContext.environment && (m.headers["X-Environment-Key"] = t.evaluationContext.environment.apiKey), n && n !== "GET" && (m.headers["Content-Type"] = "application/json; charset=utf-8"), v && Object.assign(m.headers, v), _ || console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");
|
|
299
|
+
var u = "".concat((l = t.evaluationContext.identity) === null || l === void 0 ? void 0 : l.identifier);
|
|
300
|
+
return _(i, m).then(function(y) {
|
|
301
|
+
var k, z, N = "".concat((k = t.evaluationContext.identity) === null || k === void 0 ? void 0 : k.identifier);
|
|
302
|
+
if (u === N) {
|
|
303
|
+
var J = (z = y.headers) === null || z === void 0 ? void 0 : z.get("x-flagsmith-document-updated-at");
|
|
304
|
+
if (J) try {
|
|
305
|
+
var R = parseFloat(J);
|
|
306
|
+
if (isNaN(R)) return Promise.reject("Failed to parse x-flagsmith-document-updated-at");
|
|
307
|
+
t.timestamp = R;
|
|
308
|
+
} catch (U) {
|
|
309
|
+
t.log(U, "Failed to parse x-flagsmith-document-updated-at", J);
|
|
310
|
+
}
|
|
311
|
+
return t.log("Fetch response: " + y.status + " " + (n || "GET") + 0 + i), y.text().then(function(U) {
|
|
312
|
+
var q = U;
|
|
313
|
+
try {
|
|
314
|
+
q = JSON.parse(U);
|
|
315
|
+
} catch {
|
|
316
|
+
}
|
|
317
|
+
return !q && y.status && (q = "API Response: ".concat(y.status)), y.status && y.status >= 200 && y.status < 300 ? q : Promise.reject(new Error(q));
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
t.log("Received response with identity mismatch, ignoring response. Requested: ".concat(u, ", Current: ").concat(N));
|
|
321
|
+
});
|
|
322
|
+
}, this.evaluateFlag = function(i, n) {
|
|
323
|
+
if (t.datadogRum && (t.datadogRum.client.addFeatureFlagEvaluation ? n === "VALUE" ? t.datadogRum.client.addFeatureFlagEvaluation(_t + i, t.getValue(i, {}, !0)) : t.datadogRum.client.addFeatureFlagEvaluation(Ft + i, t.hasFeature(i, !0)) : console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")), t.enableAnalytics) {
|
|
324
|
+
if (!t.evaluationEvent || !t.evaluationContext.environment) return;
|
|
325
|
+
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;
|
|
326
|
+
}
|
|
327
|
+
t.updateEventStorage();
|
|
328
|
+
}, this._onChange = function(i, n, r) {
|
|
329
|
+
var l, c;
|
|
330
|
+
t.setLoadingState(r), (l = t.onChange) === null || l === void 0 || l.call(t, i, n, t.loadingState), (c = t._trigger) === null || c === void 0 || c.call(t);
|
|
331
|
+
}, _ = e.fetch ? e.fetch : typeof fetch < "u" ? fetch : Ot === null || Ot === void 0 ? void 0 : Ot.fetch, this.canUseStorage = typeof window < "u" || !!e.browserlessStorage, this.log("Constructing flagsmith instance " + e), e.eventSource && (vt = e.eventSource), e.AsyncStorage && (I = e.AsyncStorage);
|
|
332
|
+
}
|
|
333
|
+
return a.prototype.init = function(e) {
|
|
334
|
+
var t, i, n;
|
|
335
|
+
return x(this, void 0, void 0, function() {
|
|
336
|
+
var r, l, c, v, m, u, y, k, z, N, J, R, U, q, ht, ft, at, j, b, kt, pt, ce, rt, jt, de, ve, Pt, ge, Tt, mt, ot, he, P = this;
|
|
337
|
+
return A(this, function(V) {
|
|
338
|
+
switch (V.label) {
|
|
339
|
+
case 0:
|
|
340
|
+
r = it(e.evaluationContext || this.evaluationContext), V.label = 1;
|
|
341
|
+
case 1:
|
|
342
|
+
if (V.trys.push([1, 13, , 14]), l = e.environmentID, c = e.api, v = c === void 0 ? gt : c, m = e.headers, u = e.onChange, y = e.cacheFlags, k = e.datadogRum, z = e.onError, N = e.defaultFlags, J = e.fetch, R = e.preventFetch, U = e.enableLogs, q = e.enableDynatrace, ht = e.enableAnalytics, ft = e.realtime, at = e.eventSourceUrl, j = at === void 0 ? "https://realtime.flagsmith.com/" : at, b = e.AsyncStorage, kt = e.identity, pt = e.traits, ce = e.state, rt = e.cacheOptions, jt = e.angularHttpClient, de = e._trigger, ve = e._triggerLoadingState, r.environment = l ? { apiKey: l } : r.environment, !r.environment || !r.environment.apiKey) throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");
|
|
343
|
+
if (r.identity = kt || pt ? { identifier: kt, traits: pt ? Object.fromEntries(Object.entries(pt).map(function(K) {
|
|
344
|
+
return [K[0], { value: K[1] }];
|
|
345
|
+
})) : {} } : r.identity, this.evaluationContext = r, this.api = v, this.headers = m, this.getFlagInterval = null, this.analyticsInterval = null, this.onChange = u, Pt = "Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided", this._trigger = de || this._trigger, this._triggerLoadingState = ve || this._triggerLoadingState, this.onError = function(K) {
|
|
346
|
+
P.setLoadingState(o(o({}, P.loadingState), { isFetching: !1, isLoading: !1, error: K })), z == null || z(K);
|
|
347
|
+
}, this.enableLogs = U || !1, this.cacheOptions = rt ? { skipAPI: !!rt.skipAPI, ttl: rt.ttl || 0, storageKey: rt.storageKey, loadStale: !!rt.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 && (_ = J), this.enableAnalytics = ht || !1, this.flags = Object.assign({}, N) || {}, this.datadogRum = k || null, this.initialised = !0, this.ticks = 1e4, this.timer = this.enableLogs ? (/* @__PURE__ */ new Date()).valueOf() : null, this.cacheFlags = I !== void 0 && !!y, G = "FLAGSMITH_EVENT_" + r.environment.apiKey, b && (I = b), ft && typeof window < "u" && this.setupRealtime(j, r.environment.apiKey), Object.keys(this.flags).length && (this.loadingState = o(o({}, this.loadingState), { isLoading: !1, source: h.DEFAULT_FLAGS })), this.setState(ce), this.log("Initialising with properties", e, this), q && (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), jt && (_ = /* @__PURE__ */ function(K) {
|
|
348
|
+
return function($, H) {
|
|
349
|
+
var Z = H.headers, E = H.method, lt = H.body;
|
|
350
|
+
return new Promise(function(et) {
|
|
351
|
+
switch (E) {
|
|
352
|
+
case "GET":
|
|
353
|
+
return K.get($, { headers: Z }).subscribe(function(X) {
|
|
354
|
+
et({ ok: !0, text: function() {
|
|
355
|
+
return Promise.resolve(X);
|
|
356
|
+
} });
|
|
357
|
+
});
|
|
358
|
+
case "POST":
|
|
359
|
+
case "PUT":
|
|
360
|
+
return K.post($, lt, { headers: Z }).subscribe(function(X) {
|
|
361
|
+
et({ ok: !0, text: function() {
|
|
362
|
+
return Promise.resolve(X);
|
|
363
|
+
} });
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
}(jt)), I && this.canUseStorage && I.getItem(G).then(function(K) {
|
|
369
|
+
try {
|
|
370
|
+
P.evaluationEvent = JSON.parse(K) || {};
|
|
371
|
+
} catch {
|
|
372
|
+
P.evaluationEvent = {};
|
|
373
|
+
}
|
|
374
|
+
P.analyticsInterval = setInterval(P.analyticsFlags, P.ticks);
|
|
375
|
+
}), this.enableAnalytics && (this.analyticsInterval && clearInterval(this.analyticsInterval), I && this.canUseStorage && I.getItem(G, function(K, $) {
|
|
376
|
+
if ($ && P.evaluationContext.environment) {
|
|
377
|
+
var H = JSON.parse($);
|
|
378
|
+
if (H[P.evaluationContext.environment.apiKey]) {
|
|
379
|
+
var Z = P.getState();
|
|
380
|
+
P.log("Retrieved events from cache", $), P.setState(o(o({}, Z), { evaluationEvent: H[P.evaluationContext.environment.apiKey] }));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
})), !y) return [3, 9];
|
|
384
|
+
if (!I || !this.canUseStorage) return [3, 8];
|
|
385
|
+
ge = function(K, $) {
|
|
386
|
+
return x(P, void 0, void 0, function() {
|
|
387
|
+
var H, Z, E, lt, et, X, Nt, fe, Rt, Ut, Kt, Mt, Dt, Gt, Jt, Vt, Bt, zt, qt, $t, Ht, Yt, Xt, Qt, pe = this;
|
|
388
|
+
return A(this, function(W) {
|
|
389
|
+
switch (W.label) {
|
|
390
|
+
case 0:
|
|
391
|
+
if (!$) return [3, 7];
|
|
392
|
+
H = null, Z = null, W.label = 1;
|
|
393
|
+
case 1:
|
|
394
|
+
return W.trys.push([1, 5, , 6]), E = JSON.parse($), lt = !1, et = !1, E && E.api === this.api && ((Ut = (Rt = E.evaluationContext) === null || Rt === void 0 ? void 0 : Rt.environment) === null || Ut === void 0 ? void 0 : Ut.apiKey) === ((Kt = this.evaluationContext.environment) === null || Kt === void 0 ? void 0 : Kt.apiKey) && (X = !0, this.evaluationContext.identity && ((Dt = (Mt = E.evaluationContext) === null || Mt === void 0 ? void 0 : Mt.identity) === null || Dt === void 0 ? void 0 : Dt.identifier) !== this.evaluationContext.identity.identifier && (this.log("Ignoring cache, identity has changed from " + ((Jt = (Gt = E.evaluationContext) === null || Gt === void 0 ? void 0 : Gt.identity) === null || Jt === void 0 ? void 0 : Jt.identifier) + " to " + this.evaluationContext.identity.identifier), X = !1), this.cacheOptions.ttl && (!E.ts || (/* @__PURE__ */ new Date()).valueOf() - E.ts > this.cacheOptions.ttl) && (E.ts && !this.cacheOptions.loadStale ? (this.log("Ignoring cache, timestamp is too old ts:" + E.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - E.ts) + "ms"), X = !1) : E.ts && this.cacheOptions.loadStale && (this.log("Loading stale cache, timestamp ts:" + E.ts + " ttl: " + this.cacheOptions.ttl + " time elapsed since cache: " + ((/* @__PURE__ */ new Date()).valueOf() - E.ts) + "ms"), et = !0, X = !0)), X && (lt = !0, Z = F((Vt = this.evaluationContext.identity) === null || Vt === void 0 ? void 0 : Vt.traits, (zt = (Bt = E.evaluationContext) === null || Bt === void 0 ? void 0 : Bt.identity) === null || zt === void 0 ? void 0 : zt.traits), H = F(this.flags, E.flags), this.setState(o(o({}, E), { evaluationContext: it(o(o({}, E.evaluationContext), { identity: !((qt = E.evaluationContext) === null || qt === void 0) && qt.identity ? o(o({}, ($t = E.evaluationContext) === null || $t === void 0 ? void 0 : $t.identity), { traits: o(o({}, ((Yt = (Ht = E.evaluationContext) === null || Ht === void 0 ? void 0 : Ht.identity) === null || Yt === void 0 ? void 0 : Yt.traits) || {}), pt || {}) }) : void 0 })) })), this.log("Retrieved flags from cache", E))), lt ? (Nt = !R && (!this.cacheOptions.skipAPI || et), this._onChange(null, { isFromServer: !1, flagsChanged: H, traitsChanged: Z }, this._loadedState(null, h.CACHE, Nt)), this.oldFlags = this.flags, this.cacheOptions.skipAPI && lt && !et && this.log("Skipping API, using cache"), Nt && this.getFlags().catch(function(Le) {
|
|
395
|
+
var Zt;
|
|
396
|
+
(Zt = pe.onError) === null || Zt === void 0 || Zt.call(pe, Le);
|
|
397
|
+
}), [3, 4]) : [3, 2];
|
|
398
|
+
case 2:
|
|
399
|
+
return R ? [3, 4] : [4, this.getFlags()];
|
|
400
|
+
case 3:
|
|
401
|
+
W.sent(), W.label = 4;
|
|
402
|
+
case 4:
|
|
403
|
+
return [3, 6];
|
|
404
|
+
case 5:
|
|
405
|
+
return fe = W.sent(), this.log("Exception fetching cached logs", fe), [3, 6];
|
|
406
|
+
case 6:
|
|
407
|
+
return [3, 10];
|
|
408
|
+
case 7:
|
|
409
|
+
return R ? [3, 9] : [4, this.getFlags()];
|
|
410
|
+
case 8:
|
|
411
|
+
return W.sent(), [3, 10];
|
|
412
|
+
case 9:
|
|
413
|
+
if (N) this._onChange(null, { isFromServer: !1, flagsChanged: F({}, this.flags), traitsChanged: F({}, (Xt = this.evaluationContext.identity) === null || Xt === void 0 ? void 0 : Xt.traits) }, this._loadedState(null, h.DEFAULT_FLAGS));
|
|
414
|
+
else {
|
|
415
|
+
if (!this.flags) throw new Error(Pt);
|
|
416
|
+
this._onChange(null, { isFromServer: !1, flagsChanged: F({}, this.flags), traitsChanged: F({}, (Qt = this.evaluationContext.identity) === null || Qt === void 0 ? void 0 : Qt.traits) }, this._loadedState(null, h.DEFAULT_FLAGS));
|
|
417
|
+
}
|
|
418
|
+
W.label = 10;
|
|
419
|
+
case 10:
|
|
420
|
+
return [2];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
}, V.label = 2;
|
|
425
|
+
case 2:
|
|
426
|
+
return V.trys.push([2, 7, , 8]), I.getItemSync ? (Tt = I.getItemSync(this.getStorageKey()), [3, 5]) : [3, 3];
|
|
427
|
+
case 3:
|
|
428
|
+
return [4, I.getItem(this.getStorageKey())];
|
|
429
|
+
case 4:
|
|
430
|
+
Tt = V.sent(), V.label = 5;
|
|
431
|
+
case 5:
|
|
432
|
+
return [4, ge(null, Tt)];
|
|
433
|
+
case 6:
|
|
434
|
+
case 7:
|
|
435
|
+
return V.sent(), [3, 8];
|
|
436
|
+
case 8:
|
|
437
|
+
return [3, 12];
|
|
438
|
+
case 9:
|
|
439
|
+
return R ? [3, 11] : [4, this.getFlags()];
|
|
440
|
+
case 10:
|
|
441
|
+
return V.sent(), [3, 12];
|
|
442
|
+
case 11:
|
|
443
|
+
if (N) this._onChange(null, { isFromServer: !1, flagsChanged: F({}, N), traitsChanged: F({}, (t = r.identity) === null || t === void 0 ? void 0 : t.traits) }, this._loadedState(null, h.DEFAULT_FLAGS));
|
|
444
|
+
else if (this.flags && (mt = null, Object.keys(this.flags).length === 0 && (mt = Pt), this._onChange(null, { isFromServer: !1, flagsChanged: F({}, this.flags), traitsChanged: F({}, (i = r.identity) === null || i === void 0 ? void 0 : i.traits) }, this._loadedState(mt, h.DEFAULT_FLAGS)), mt)) throw new Error(mt);
|
|
445
|
+
V.label = 12;
|
|
446
|
+
case 12:
|
|
447
|
+
return [3, 14];
|
|
448
|
+
case 13:
|
|
449
|
+
throw ot = V.sent(), this.log("Error during initialisation ", ot), he = ot instanceof Error ? ot : new Error("".concat(ot)), (n = this.onError) === null || n === void 0 || n.call(this, he), ot;
|
|
450
|
+
case 14:
|
|
451
|
+
return [2];
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
}, a.prototype.getAllFlags = function() {
|
|
456
|
+
return this.flags;
|
|
457
|
+
}, a.prototype.identify = function(e, t, i) {
|
|
458
|
+
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) {
|
|
459
|
+
var r = n[0], l = n[1];
|
|
460
|
+
return [r, D(l) ? l : { value: l }];
|
|
461
|
+
}))), this.initialised ? this.getFlags() : Promise.resolve();
|
|
462
|
+
}, a.prototype.getState = function() {
|
|
463
|
+
return { api: this.api, flags: this.flags, ts: this.ts, evaluationContext: this.evaluationContext, evaluationEvent: this.evaluationEvent };
|
|
464
|
+
}, a.prototype.setState = function(e) {
|
|
465
|
+
e && (this.initialised = !0, this.api = e.api || this.api || gt, this.flags = e.flags || this.flags, this.evaluationContext = e.evaluationContext || this.evaluationContext, this.evaluationEvent = e.evaluationEvent || this.evaluationEvent, this.log("setState called", this));
|
|
466
|
+
}, a.prototype.logout = function() {
|
|
467
|
+
return this.evaluationContext.identity = null, this.initialised ? this.getFlags() : Promise.resolve();
|
|
468
|
+
}, a.prototype.startListening = function(e) {
|
|
469
|
+
e === void 0 && (e = 1e3), this.getFlagInterval && clearInterval(this.getFlagInterval), this.getFlagInterval = setInterval(this.getFlags, e);
|
|
470
|
+
}, a.prototype.stopListening = function() {
|
|
471
|
+
this.getFlagInterval && (clearInterval(this.getFlagInterval), this.getFlagInterval = null);
|
|
472
|
+
}, a.prototype._loadedState = function(e, t, i) {
|
|
473
|
+
return e === void 0 && (e = null), i === void 0 && (i = !1), { error: e, isFetching: i, isLoading: !1, source: t };
|
|
474
|
+
}, a.prototype.log = function() {
|
|
475
|
+
for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
|
|
476
|
+
this.enableLogs && console.log.apply(this, O(["FLAGSMITH:", (/* @__PURE__ */ new Date()).valueOf() - (this.timer || 0), "ms"], e));
|
|
477
|
+
}, a.prototype.updateStorage = function() {
|
|
478
|
+
if (this.cacheFlags) {
|
|
479
|
+
this.ts = (/* @__PURE__ */ new Date()).valueOf();
|
|
480
|
+
var e = JSON.stringify(this.getState());
|
|
481
|
+
this.log("Setting storage", e), I.setItem(this.getStorageKey(), e);
|
|
482
|
+
}
|
|
483
|
+
}, a.prototype.updateEventStorage = function() {
|
|
484
|
+
if (this.enableAnalytics) {
|
|
485
|
+
var e = JSON.stringify(this.getState().evaluationEvent);
|
|
486
|
+
I.setItem(G, e).catch(function(t) {
|
|
487
|
+
return console.error("Flagsmith: Error setting item in async storage", t);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}, a.prototype.setLoadingState = function(e) {
|
|
491
|
+
var t;
|
|
492
|
+
M(e, this.loadingState) || (this.loadingState = o({}, e), this.log("Loading state changed", e), (t = this._triggerLoadingState) === null || t === void 0 || t.call(this));
|
|
493
|
+
}, a.prototype.setupRealtime = function(e, t) {
|
|
494
|
+
var i = this, n = e + "sse/environments/" + t + "/stream";
|
|
495
|
+
vt ? this.eventSource || (this.log("Creating event source with url " + n), this.eventSource = new vt(n), this.eventSource.addEventListener("environment_updated", function(r) {
|
|
496
|
+
var l;
|
|
497
|
+
try {
|
|
498
|
+
l = JSON.parse(r.data).updated_at;
|
|
499
|
+
} catch (c) {
|
|
500
|
+
i.log("Could not parse sse event", c);
|
|
501
|
+
}
|
|
502
|
+
l ? !i.timestamp || l > 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);
|
|
503
|
+
})) : this.log("Error, EventSource is undefined");
|
|
504
|
+
}, a;
|
|
505
|
+
}();
|
|
506
|
+
function ae(a) {
|
|
507
|
+
var e = a.fetch, t = a.AsyncStorage, i = a.eventSource;
|
|
508
|
+
return new we({ fetch: e, AsyncStorage: t, eventSource: i });
|
|
509
|
+
}
|
|
510
|
+
var xt, Oe = (xt = function(a, e) {
|
|
511
|
+
return xt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, i) {
|
|
512
|
+
t.__proto__ = i;
|
|
513
|
+
} || function(t, i) {
|
|
514
|
+
for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]);
|
|
515
|
+
}, xt(a, e);
|
|
516
|
+
}, function(a, e) {
|
|
517
|
+
if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
|
518
|
+
function t() {
|
|
519
|
+
this.constructor = a;
|
|
520
|
+
}
|
|
521
|
+
xt(a, e), a.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
522
|
+
}), re = function(a) {
|
|
523
|
+
var e = typeof Symbol == "function" && Symbol.iterator, t = e && a[e], i = 0;
|
|
524
|
+
if (t) return t.call(a);
|
|
525
|
+
if (a && typeof a.length == "number") return { next: function() {
|
|
526
|
+
return a && i >= a.length && (a = void 0), { value: a && a[i++], done: !a };
|
|
527
|
+
} };
|
|
528
|
+
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
529
|
+
}, oe = function(a, e) {
|
|
530
|
+
var t = typeof Symbol == "function" && a[Symbol.iterator];
|
|
531
|
+
if (!t) return a;
|
|
532
|
+
var i, n, r = t.call(a), l = [];
|
|
533
|
+
try {
|
|
534
|
+
for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) l.push(i.value);
|
|
535
|
+
} catch (c) {
|
|
536
|
+
n = { error: c };
|
|
537
|
+
} finally {
|
|
538
|
+
try {
|
|
539
|
+
i && !i.done && (t = r.return) && t.call(r);
|
|
540
|
+
} finally {
|
|
541
|
+
if (n) throw n.error;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return l;
|
|
545
|
+
}, At = function(a, e, t) {
|
|
546
|
+
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]);
|
|
547
|
+
return a.concat(i || Array.prototype.slice.call(e));
|
|
548
|
+
}, Ie = function(a) {
|
|
549
|
+
function e() {
|
|
550
|
+
return a.call(this, `EventSource not available.
|
|
551
|
+
Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`) || this;
|
|
552
|
+
}
|
|
553
|
+
return Oe(e, a), e;
|
|
554
|
+
}(Error), le = function() {
|
|
555
|
+
function a(e, t) {
|
|
556
|
+
var i = this;
|
|
557
|
+
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 Ie();
|
|
558
|
+
this._onevent_wrapped = function(n) {
|
|
559
|
+
i._onevent(n);
|
|
560
|
+
}, this._start();
|
|
561
|
+
}
|
|
562
|
+
return a.prototype.dispatchEvent = function(e) {
|
|
563
|
+
throw new Error("Method not implemented.");
|
|
564
|
+
}, a.prototype._start = function() {
|
|
565
|
+
var e, t, i = this, n = this.url;
|
|
566
|
+
this._lastEventId && (n.indexOf("?") === -1 ? n += "?" : n += "&", n += "lastEventId=" + encodeURIComponent(this._lastEventId)), this._eventSource = new this.eventSourceClass(n, this._configuration), this._eventSource.onopen = function(v) {
|
|
567
|
+
i._onopen(v);
|
|
568
|
+
}, this._eventSource.onerror = function(v) {
|
|
569
|
+
i._onerror(v);
|
|
570
|
+
}, this._eventSource.onmessage = function(v) {
|
|
571
|
+
i.onmessage(v);
|
|
572
|
+
};
|
|
573
|
+
try {
|
|
574
|
+
for (var r = re(Object.keys(this._listeners)), l = r.next(); !l.done; l = r.next()) {
|
|
575
|
+
var c = l.value;
|
|
576
|
+
this._eventSource.addEventListener(c, this._onevent_wrapped);
|
|
577
|
+
}
|
|
578
|
+
} catch (v) {
|
|
579
|
+
e = { error: v };
|
|
580
|
+
} finally {
|
|
581
|
+
try {
|
|
582
|
+
l && !l.done && (t = r.return) && t.call(r);
|
|
583
|
+
} finally {
|
|
584
|
+
if (e) throw e.error;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}, a.prototype._onopen = function(e) {
|
|
588
|
+
this.readyState === 0 && (this.readyState = 1, this.onopen(e));
|
|
589
|
+
}, a.prototype._onerror = function(e) {
|
|
590
|
+
var t = this;
|
|
591
|
+
if (this.readyState === 1 && (this.readyState = 0, this.onerror(e)), this._eventSource) {
|
|
592
|
+
this._eventSource.close(), this._eventSource = null;
|
|
593
|
+
var i = Math.round(this.max_retry_time * Math.random());
|
|
594
|
+
this._timer = setTimeout(function() {
|
|
595
|
+
return t._start();
|
|
596
|
+
}, i);
|
|
597
|
+
}
|
|
598
|
+
}, a.prototype._onevent = function(e) {
|
|
599
|
+
var t, i;
|
|
600
|
+
e && e.lastEventId && (this._lastEventId = e.lastEventId);
|
|
601
|
+
var n = this._listeners[e.type];
|
|
602
|
+
if (n != null) try {
|
|
603
|
+
for (var r = re(At([], oe(n), !1)), l = r.next(); !l.done; l = r.next())
|
|
604
|
+
l.value.call(this, e);
|
|
605
|
+
} catch (c) {
|
|
606
|
+
t = { error: c };
|
|
607
|
+
} finally {
|
|
608
|
+
try {
|
|
609
|
+
l && !l.done && (i = r.return) && i.call(r);
|
|
610
|
+
} finally {
|
|
611
|
+
if (t) throw t.error;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
e.type === "message" && this.onmessage(e);
|
|
615
|
+
}, a.prototype.onopen = function(e) {
|
|
616
|
+
}, a.prototype.onerror = function(e) {
|
|
617
|
+
}, a.prototype.onmessage = function(e) {
|
|
618
|
+
}, a.prototype.close = function() {
|
|
619
|
+
this._timer && (clearTimeout(this._timer), this._timer = null), this._eventSource && (this._eventSource.close(), this._eventSource = null), this.readyState = 2;
|
|
620
|
+
}, a.prototype.addEventListener = function(e, t, i) {
|
|
621
|
+
this._listeners[e] == null && (this._listeners[e] = [], this._eventSource != null && this._eventSource.addEventListener(e, this._onevent_wrapped));
|
|
622
|
+
var n = this._listeners[e];
|
|
623
|
+
n.includes(t) || (this._listeners[e] = At(At([], oe(n), !1), [t], !1));
|
|
624
|
+
}, a.prototype.removeEventListener = function(e, t, i) {
|
|
625
|
+
var n = this._listeners[e];
|
|
626
|
+
this._listeners[e] = n.filter(function(r) {
|
|
627
|
+
return r !== t;
|
|
628
|
+
});
|
|
629
|
+
}, a;
|
|
630
|
+
}();
|
|
631
|
+
globalThis.FlagsmithEventSource = typeof EventSource < "u" ? EventSource : null;
|
|
632
|
+
var se = function(a, e) {
|
|
633
|
+
return e = e || {}, new Promise(function(t, i) {
|
|
634
|
+
var n = new XMLHttpRequest(), r = [], l = [], c = {}, v = function() {
|
|
635
|
+
return { ok: (n.status / 100 | 0) == 2, statusText: n.statusText, status: n.status, url: n.responseURL, text: function() {
|
|
636
|
+
return Promise.resolve(n.responseText);
|
|
637
|
+
}, json: function() {
|
|
638
|
+
return Promise.resolve(n.responseText).then(JSON.parse);
|
|
639
|
+
}, blob: function() {
|
|
640
|
+
return Promise.resolve(new Blob([n.response]));
|
|
641
|
+
}, clone: v, headers: { keys: function() {
|
|
642
|
+
return r;
|
|
643
|
+
}, entries: function() {
|
|
644
|
+
return l;
|
|
645
|
+
}, get: function(u) {
|
|
646
|
+
return c[u.toLowerCase()];
|
|
647
|
+
}, has: function(u) {
|
|
648
|
+
return u.toLowerCase() in c;
|
|
649
|
+
} } };
|
|
650
|
+
};
|
|
651
|
+
for (var m in n.open(e.method || "get", a, !0), n.onload = function() {
|
|
652
|
+
n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function(u, y, k) {
|
|
653
|
+
r.push(y = y.toLowerCase()), l.push([y, k]), c[y] = c[y] ? c[y] + "," + k : k;
|
|
654
|
+
}), t(v());
|
|
655
|
+
}, n.onerror = i, n.withCredentials = e.credentials == "include", e.headers) n.setRequestHeader(m, e.headers[m]);
|
|
656
|
+
n.send(e.body || null);
|
|
657
|
+
});
|
|
658
|
+
}, ue = ae({ AsyncStorage: d, fetch: se, eventSource: le });
|
|
659
|
+
typeof window < "u" && (window.flagsmith = ue), g.createFlagsmithInstance = function() {
|
|
660
|
+
return ae({ AsyncStorage: d, fetch: se, eventSource: le });
|
|
661
|
+
}, g.default = ue, Object.defineProperty(g, "__esModule", { value: !0 });
|
|
662
|
+
});
|
|
663
|
+
})(ie, ie.exports);
|
|
664
|
+
var Ge = ie.exports, Je = {
|
|
665
|
+
NOT_INITIALIZED: "FeatureFlag not initialized. Call init() first."
|
|
666
|
+
}, Ce = "business", Y, Ve = (Y = class {
|
|
667
|
+
constructor() {
|
|
668
|
+
Et(this, "flagsmithClient", null);
|
|
669
|
+
Et(this, "userContext", null);
|
|
670
|
+
}
|
|
671
|
+
static getInstance() {
|
|
672
|
+
return Y.instance || (Y.instance = new Y()), Y.instance;
|
|
673
|
+
}
|
|
674
|
+
ensureInitialized() {
|
|
675
|
+
if (!this.flagsmithClient)
|
|
676
|
+
throw new Error(Je.NOT_INITIALIZED);
|
|
677
|
+
}
|
|
678
|
+
async init(s, g = []) {
|
|
679
|
+
if (!this.flagsmithClient)
|
|
680
|
+
try {
|
|
681
|
+
this.flagsmithClient = Ge.createFlagsmithInstance();
|
|
682
|
+
const d = g.reduce((o, x) => (o[x.feature.name] = x, o), {});
|
|
683
|
+
await this.flagsmithClient.init({
|
|
684
|
+
environmentID: s.apiKey,
|
|
685
|
+
api: (s == null ? void 0 : s.url) ?? "https://feature-flag-proxy.feedme.farm/api/v1/",
|
|
686
|
+
enableAnalytics: (s == null ? void 0 : s.enableAnalytics) ?? !0,
|
|
687
|
+
defaultFlags: d,
|
|
688
|
+
cacheFlags: (s == null ? void 0 : s.cacheFlags) ?? !0
|
|
689
|
+
});
|
|
690
|
+
} catch (d) {
|
|
691
|
+
throw console.error("Failed to initialize FeatureFlag:", d), d;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
async setUser(s) {
|
|
695
|
+
this.ensureInitialized(), this.userContext = { identifier: s }, await this.updateContext();
|
|
696
|
+
}
|
|
697
|
+
async updateContext() {
|
|
698
|
+
try {
|
|
699
|
+
if (!this.userContext) return;
|
|
700
|
+
await this.flagsmithClient.setContext({
|
|
701
|
+
identity: {
|
|
702
|
+
identifier: this.userContext.identifier
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
} catch (s) {
|
|
706
|
+
throw console.error("Failed to update user context:", s), s;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
async getFlags() {
|
|
710
|
+
this.ensureInitialized();
|
|
711
|
+
const s = this.flagsmithClient.getAllFlags();
|
|
712
|
+
return Object.entries(s).map(([g, d]) => {
|
|
713
|
+
var o;
|
|
714
|
+
return {
|
|
715
|
+
feature: {
|
|
716
|
+
name: g,
|
|
717
|
+
id: (d == null ? void 0 : d.id) ?? 0
|
|
718
|
+
},
|
|
719
|
+
enabled: d.enabled,
|
|
720
|
+
value: ((o = d.value) == null ? void 0 : o.toString()) ?? null
|
|
721
|
+
};
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
getFlagValue(s, g) {
|
|
725
|
+
this.ensureInitialized();
|
|
726
|
+
const d = this.flagsmithClient.getValue(s);
|
|
727
|
+
if (d == null)
|
|
728
|
+
return null;
|
|
729
|
+
try {
|
|
730
|
+
const o = d.toString();
|
|
731
|
+
return g ? g(o) : typeof {} == "number" ? isNaN(Number(o)) ? null : Number(o) : typeof {} == "boolean" ? o.toLowerCase() === "true" : o;
|
|
732
|
+
} catch (o) {
|
|
733
|
+
return console.error("Error transforming flag value:", o), null;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
getFlag(s) {
|
|
737
|
+
this.ensureInitialized();
|
|
738
|
+
const g = this.flagsmithClient.getValue(s);
|
|
739
|
+
if (g == null) return null;
|
|
740
|
+
const d = this.flagsmithClient.hasFeature(s);
|
|
741
|
+
return {
|
|
742
|
+
feature: {
|
|
743
|
+
name: s,
|
|
744
|
+
id: 0
|
|
745
|
+
},
|
|
746
|
+
enabled: d,
|
|
747
|
+
value: g.toString()
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
async getUserFlagValue(s, g, d = null, o) {
|
|
751
|
+
var A;
|
|
752
|
+
const x = this.userContext;
|
|
753
|
+
try {
|
|
754
|
+
return await this.setUser(s), this.getFlagValue(g, o) ?? d;
|
|
755
|
+
} catch (O) {
|
|
756
|
+
return console.error(`Error getting user flag value for ${g}:`, O), d;
|
|
757
|
+
} finally {
|
|
758
|
+
try {
|
|
759
|
+
await ((A = this.flagsmithClient) == null ? void 0 : A.logout()), this.userContext = null, x && await this.setUser(x.identifier);
|
|
760
|
+
} catch (O) {
|
|
761
|
+
console.error("Error during cleanup:", O);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
reset() {
|
|
766
|
+
this.flagsmithClient = null, this.userContext = null;
|
|
767
|
+
}
|
|
768
|
+
}, Et(Y, "instance"), Y), Be = Ve.getInstance(), St = tt(!1), It = tt([]), dt = tt(null);
|
|
769
|
+
function ze(f = Be) {
|
|
770
|
+
const s = () => St.value ? !0 : (console.warn("FeatureFlag is not initialized. Using default values."), !1), g = async (h, _ = []) => {
|
|
771
|
+
if (St.value) {
|
|
772
|
+
console.warn("FeatureFlag is already initialized.");
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
try {
|
|
776
|
+
await f.init(h, _), It.value = await f.getFlags(), St.value = !0, dt.value = null;
|
|
777
|
+
} catch (w) {
|
|
778
|
+
console.error("Failed to initialize feature flags:", w), dt.value = w;
|
|
779
|
+
}
|
|
780
|
+
}, d = async (h) => {
|
|
781
|
+
if (s())
|
|
782
|
+
try {
|
|
783
|
+
await f.setUser(h), It.value = await f.getFlags(), dt.value = null;
|
|
784
|
+
} catch (_) {
|
|
785
|
+
console.error("Failed to set user:", _), dt.value = _;
|
|
786
|
+
}
|
|
787
|
+
}, o = async (h) => d(`${Ce}-${h}`), x = (h, _, w = null) => {
|
|
788
|
+
if (!s()) return w;
|
|
789
|
+
try {
|
|
790
|
+
return f.getFlagValue(h, _) ?? w;
|
|
791
|
+
} catch (D) {
|
|
792
|
+
return console.error(`Error getting flag value for ${h}:`, D), w;
|
|
793
|
+
}
|
|
794
|
+
}, A = (h, _) => {
|
|
795
|
+
if (!s()) return _ ?? null;
|
|
796
|
+
try {
|
|
797
|
+
return f.getFlag(h) ?? _ ?? null;
|
|
798
|
+
} catch (w) {
|
|
799
|
+
return console.error(`Error getting flag for ${h}:`, w), _ ?? null;
|
|
800
|
+
}
|
|
801
|
+
}, O = async (h, _, w = null, D) => {
|
|
802
|
+
if (!s()) return w;
|
|
803
|
+
try {
|
|
804
|
+
return await f.getUserFlagValue(h, _, w, D);
|
|
805
|
+
} catch (nt) {
|
|
806
|
+
return console.error(`Error getting user flag value for ${_}:`, nt), w;
|
|
807
|
+
}
|
|
808
|
+
}, M = async (h, _, w = null, D) => O(`${Ce}-${h}`, _, w, D), F = () => {
|
|
809
|
+
try {
|
|
810
|
+
f.reset();
|
|
811
|
+
} catch (h) {
|
|
812
|
+
console.error("Error resetting feature flags:", h);
|
|
813
|
+
} finally {
|
|
814
|
+
It.value = [], St.value = !1, dt.value = null;
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
return {
|
|
818
|
+
flags: Wt(It),
|
|
819
|
+
isInitialized: Wt(St),
|
|
820
|
+
error: Wt(dt),
|
|
821
|
+
init: g,
|
|
822
|
+
setUser: d,
|
|
823
|
+
setBusiness: o,
|
|
824
|
+
getFlagValue: x,
|
|
825
|
+
getFlag: A,
|
|
826
|
+
getUserFlagValue: O,
|
|
827
|
+
getBusinessFlagValue: M,
|
|
828
|
+
reset: F
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
var Ee = () => ze();
|
|
832
|
+
const _e = {
|
|
833
|
+
dev: "MaGoXrEWuEJNpWgKTqseee",
|
|
834
|
+
prod: "6GhcttsJ9Rj9cTevcdrpin"
|
|
835
|
+
}, qe = "order_miniprogram_v2", Fe = 1e4, Ct = tt("pending");
|
|
836
|
+
let Lt = null;
|
|
837
|
+
function $e(f) {
|
|
838
|
+
if (Lt) return Lt;
|
|
839
|
+
const { init: s } = Ee(), g = f === "prod" ? _e.prod : _e.dev;
|
|
840
|
+
let d;
|
|
841
|
+
return Lt = Promise.race([
|
|
842
|
+
s({ apiKey: g }),
|
|
843
|
+
new Promise((o, x) => {
|
|
844
|
+
d = setTimeout(() => x(new Error(`Flagsmith init exceeded ${Fe}ms`)), Fe);
|
|
845
|
+
})
|
|
846
|
+
]).then(() => {
|
|
847
|
+
Ct.value = "ready";
|
|
848
|
+
}).catch((o) => {
|
|
849
|
+
Ct.value = "failed", console.warn("[FeatureFlag] init failed:", o);
|
|
850
|
+
}).finally(() => {
|
|
851
|
+
clearTimeout(d);
|
|
852
|
+
}), Lt;
|
|
853
|
+
}
|
|
854
|
+
function He(f) {
|
|
855
|
+
try {
|
|
856
|
+
const s = typeof f == "string" ? JSON.parse(f) : f;
|
|
857
|
+
return s === !0 || s === "true" || (s == null ? void 0 : s.enabled) === !0 || (s == null ? void 0 : s.enabled) === "true";
|
|
858
|
+
} catch {
|
|
859
|
+
return f === !0 || f === "true";
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function Ye(f, s, g) {
|
|
863
|
+
const d = xe(), { getBusinessFlagValue: o } = Ee(), x = tt(s), A = tt(!0);
|
|
864
|
+
let O = 0;
|
|
865
|
+
async function M() {
|
|
866
|
+
var _;
|
|
867
|
+
const F = ++O, h = (_ = d.currentBusiness.value) == null ? void 0 : _._id;
|
|
868
|
+
if (!h || Ct.value === "failed") {
|
|
869
|
+
x.value = s, A.value = !1;
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (Ct.value === "pending") {
|
|
873
|
+
A.value = !0;
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
A.value = !0;
|
|
877
|
+
try {
|
|
878
|
+
const w = await o(h, f, s);
|
|
879
|
+
if (F !== O) return;
|
|
880
|
+
x.value = g ? g(w) : w;
|
|
881
|
+
} catch {
|
|
882
|
+
if (F !== O) return;
|
|
883
|
+
x.value = s;
|
|
884
|
+
} finally {
|
|
885
|
+
F === O && (A.value = !1);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return je([() => {
|
|
889
|
+
var F;
|
|
890
|
+
return (F = d.currentBusiness.value) == null ? void 0 : F._id;
|
|
891
|
+
}, Ct], M, { immediate: !0 }), { value: x, loading: A };
|
|
892
|
+
}
|
|
893
|
+
function Xe() {
|
|
894
|
+
const { value: f, loading: s } = Ye(qe, !1, He);
|
|
895
|
+
return { enabled: f, loading: s };
|
|
896
|
+
}
|
|
897
|
+
const Qe = "templatePicker";
|
|
898
|
+
function Ze() {
|
|
899
|
+
if (typeof window > "u") return !1;
|
|
900
|
+
try {
|
|
901
|
+
const f = new URLSearchParams(window.location.search).get(Qe);
|
|
902
|
+
return f !== null && f !== "0" && f !== "false";
|
|
903
|
+
} catch {
|
|
904
|
+
return !1;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
const We = {
|
|
908
|
+
key: 0,
|
|
909
|
+
class: "portal-sidebar",
|
|
910
|
+
"aria-label": "Mini Program navigation"
|
|
911
|
+
}, tn = ["aria-expanded", "aria-label"], en = {
|
|
912
|
+
id: "miniprogram-navigation",
|
|
913
|
+
class: "portal-nav"
|
|
914
|
+
}, nn = { class: "portal-nav-label" }, an = { class: "portal-nav-label" }, rn = { class: "portal-main" }, on = {
|
|
915
|
+
key: 0,
|
|
916
|
+
class: "portal-breadcrumb",
|
|
917
|
+
"aria-label": "Breadcrumb"
|
|
918
|
+
}, ln = {
|
|
919
|
+
id: "miniprogram-content",
|
|
920
|
+
class: "portal-content",
|
|
921
|
+
tabindex: "-1"
|
|
922
|
+
}, sn = {
|
|
923
|
+
key: 0,
|
|
924
|
+
class: "portal-empty"
|
|
925
|
+
}, un = {
|
|
926
|
+
key: 1,
|
|
927
|
+
class: "portal-loading",
|
|
928
|
+
role: "status"
|
|
929
|
+
}, cn = {
|
|
930
|
+
key: 2,
|
|
931
|
+
class: "portal-empty"
|
|
932
|
+
}, dn = {
|
|
933
|
+
key: 3,
|
|
934
|
+
class: "portal-empty",
|
|
935
|
+
role: "alert"
|
|
936
|
+
}, vn = /* @__PURE__ */ Pe({
|
|
937
|
+
__name: "App",
|
|
938
|
+
setup(f) {
|
|
939
|
+
const s = Re(), g = xe(), d = Me();
|
|
940
|
+
$e(g.namespace.value);
|
|
941
|
+
const o = Xe(), x = yt(() => s.name === "miniprogram-v2-project"), A = yt(() => o.loading.value || o.enabled.value), O = tt(
|
|
942
|
+
be(
|
|
943
|
+
"mpv2:portal-collapsed",
|
|
944
|
+
typeof window < "u" && window.matchMedia("(max-width: 1000px)").matches
|
|
945
|
+
)
|
|
946
|
+
), M = tt(be("mpv2:editor-collapsed", !0)), F = yt(() => x.value ? M.value : O.value), h = yt(
|
|
947
|
+
() => {
|
|
948
|
+
var I;
|
|
949
|
+
return x.value ? (I = d.context.value) == null ? void 0 : I.project.name : String(s.meta.title ?? "Ecosystem");
|
|
950
|
+
}
|
|
951
|
+
), _ = [
|
|
952
|
+
{ name: "miniprogram-v2-ecosystem", label: "Ecosystem", icon: "ecosystem" },
|
|
953
|
+
{ name: "miniprogram-v2-brand-kit", label: "Brand Kit", icon: "brand" },
|
|
954
|
+
{ name: "miniprogram-v2-pages", label: "Pages", icon: "pages" }
|
|
955
|
+
], w = yt(() => ({ name: "miniprogram-v2-mobile-projects", query: ct(s.query) })), D = Ke(), nt = Ze();
|
|
956
|
+
let it = !1;
|
|
957
|
+
Te(() => {
|
|
958
|
+
it = g.hideSidebar.value, g.hideSidebar.value = !0;
|
|
959
|
+
}), Ne(() => {
|
|
960
|
+
g.hideSidebar.value = it;
|
|
961
|
+
});
|
|
962
|
+
function vt() {
|
|
963
|
+
x.value ? (M.value = !M.value, Se("mpv2:editor-collapsed", M.value)) : (O.value = !O.value, Se("mpv2:portal-collapsed", O.value));
|
|
964
|
+
}
|
|
965
|
+
return (I, p) => {
|
|
966
|
+
const G = wt("RouterLink"), gt = wt("FmIcon"), _t = wt("FmCircularProgress"), Ft = wt("FmButton");
|
|
967
|
+
return B(), Q(te, null, [
|
|
968
|
+
p[14] || (p[14] = S("link", {
|
|
969
|
+
href: "https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0..1,0",
|
|
970
|
+
rel: "stylesheet"
|
|
971
|
+
}, null, -1)),
|
|
972
|
+
S("div", {
|
|
973
|
+
class: ee(["mpv2-app portal-shell", { "portal-shell--collapsed": F.value }])
|
|
974
|
+
}, [
|
|
975
|
+
p[13] || (p[13] = S("a", {
|
|
976
|
+
class: "portal-skip",
|
|
977
|
+
href: "#miniprogram-content"
|
|
978
|
+
}, "Skip to content", -1)),
|
|
979
|
+
A.value ? (B(), Q("aside", We, [
|
|
980
|
+
S("button", {
|
|
981
|
+
class: "portal-sidebar-toggle",
|
|
982
|
+
type: "button",
|
|
983
|
+
"aria-expanded": !F.value,
|
|
984
|
+
"aria-controls": "miniprogram-navigation",
|
|
985
|
+
"aria-label": F.value ? "Expand navigation" : "Collapse navigation",
|
|
986
|
+
onClick: vt
|
|
987
|
+
}, [
|
|
988
|
+
T(bt, { name: "collapse" }),
|
|
989
|
+
p[0] || (p[0] = S("span", { class: "portal-nav-label" }, "Mini Program", -1))
|
|
990
|
+
], 8, tn),
|
|
991
|
+
S("nav", en, [
|
|
992
|
+
(B(), Q(te, null, me(_, (L) => T(G, {
|
|
993
|
+
key: L.name,
|
|
994
|
+
to: { name: L.name, query: C(ct)(C(s).query) },
|
|
995
|
+
class: "portal-nav-item",
|
|
996
|
+
title: L.label,
|
|
997
|
+
"aria-label": L.label,
|
|
998
|
+
"aria-current": C(s).name === L.name ? "page" : void 0
|
|
999
|
+
}, {
|
|
1000
|
+
default: st(() => [
|
|
1001
|
+
T(bt, {
|
|
1002
|
+
name: L.icon
|
|
1003
|
+
}, null, 8, ["name"]),
|
|
1004
|
+
S("span", nn, ut(L.label), 1)
|
|
1005
|
+
]),
|
|
1006
|
+
_: 2
|
|
1007
|
+
}, 1032, ["to", "title", "aria-label", "aria-current"])), 64)),
|
|
1008
|
+
p[4] || (p[4] = S("p", { class: "portal-nav-caption" }, "Platforms", -1)),
|
|
1009
|
+
T(G, {
|
|
1010
|
+
to: w.value,
|
|
1011
|
+
class: ee(["portal-nav-item", { "router-link-active": x.value }]),
|
|
1012
|
+
title: "Mobile Ordering",
|
|
1013
|
+
"aria-label": "Mobile Ordering",
|
|
1014
|
+
"aria-current": x.value ? "page" : void 0
|
|
1015
|
+
}, {
|
|
1016
|
+
default: st(() => [
|
|
1017
|
+
T(bt, { name: "mobile" }),
|
|
1018
|
+
p[1] || (p[1] = S("span", { class: "portal-nav-label" }, "Mobile Ordering", -1))
|
|
1019
|
+
]),
|
|
1020
|
+
_: 1
|
|
1021
|
+
}, 8, ["to", "class", "aria-current"]),
|
|
1022
|
+
(B(), Q(te, null, me(["tablet", "kiosk"], (L) => T(G, {
|
|
1023
|
+
key: L,
|
|
1024
|
+
to: { name: `miniprogram-v2-${L}`, query: C(ct)(C(s).query) },
|
|
1025
|
+
class: "portal-nav-item",
|
|
1026
|
+
title: L === "tablet" ? "Tablet" : "Kiosk",
|
|
1027
|
+
"aria-label": L === "tablet" ? "Tablet" : "Kiosk"
|
|
1028
|
+
}, {
|
|
1029
|
+
default: st(() => [
|
|
1030
|
+
T(bt, { name: L }, null, 8, ["name"]),
|
|
1031
|
+
S("span", an, ut(L === "tablet" ? "Tablet" : "Kiosk"), 1)
|
|
1032
|
+
]),
|
|
1033
|
+
_: 2
|
|
1034
|
+
}, 1032, ["to", "title", "aria-label"])), 64)),
|
|
1035
|
+
p[5] || (p[5] = S("div", { class: "portal-nav-divider" }, null, -1)),
|
|
1036
|
+
T(G, {
|
|
1037
|
+
to: { name: "miniprogram-v2-module-center", query: C(ct)(C(s).query) },
|
|
1038
|
+
class: ee(["portal-nav-item", { "router-link-active": C(s).name === "miniprogram-v2-module-detail" }]),
|
|
1039
|
+
title: "Module library",
|
|
1040
|
+
"aria-label": "Module library"
|
|
1041
|
+
}, {
|
|
1042
|
+
default: st(() => [
|
|
1043
|
+
T(gt, {
|
|
1044
|
+
name: "widgets",
|
|
1045
|
+
size: "md"
|
|
1046
|
+
}),
|
|
1047
|
+
p[2] || (p[2] = S("span", { class: "portal-nav-label" }, "Module library", -1))
|
|
1048
|
+
]),
|
|
1049
|
+
_: 1
|
|
1050
|
+
}, 8, ["to", "class"]),
|
|
1051
|
+
C(D) && C(nt) ? (B(), ye(G, {
|
|
1052
|
+
key: 0,
|
|
1053
|
+
to: { name: "miniprogram-v2-template-center", query: C(ct)(C(s).query) },
|
|
1054
|
+
class: "portal-nav-item",
|
|
1055
|
+
title: "Template library",
|
|
1056
|
+
"aria-label": "Template library"
|
|
1057
|
+
}, {
|
|
1058
|
+
default: st(() => [
|
|
1059
|
+
T(gt, {
|
|
1060
|
+
name: "dashboard_customize",
|
|
1061
|
+
size: "md"
|
|
1062
|
+
}),
|
|
1063
|
+
p[3] || (p[3] = S("span", { class: "portal-nav-label" }, "Template library", -1))
|
|
1064
|
+
]),
|
|
1065
|
+
_: 1
|
|
1066
|
+
}, 8, ["to"])) : ne("", !0)
|
|
1067
|
+
]),
|
|
1068
|
+
T(G, {
|
|
1069
|
+
to: { name: "miniprogram-v2-settings", query: C(ct)(C(s).query) },
|
|
1070
|
+
class: "portal-nav-item portal-settings-link",
|
|
1071
|
+
title: "Settings",
|
|
1072
|
+
"aria-label": "Settings"
|
|
1073
|
+
}, {
|
|
1074
|
+
default: st(() => [
|
|
1075
|
+
T(bt, { name: "settings" }),
|
|
1076
|
+
p[6] || (p[6] = S("span", { class: "portal-nav-label" }, "Settings", -1))
|
|
1077
|
+
]),
|
|
1078
|
+
_: 1
|
|
1079
|
+
}, 8, ["to"])
|
|
1080
|
+
])) : ne("", !0),
|
|
1081
|
+
S("div", rn, [
|
|
1082
|
+
x.value ? ne("", !0) : (B(), Q("header", on, [
|
|
1083
|
+
S("span", null, ut(C(d).businessName.value), 1),
|
|
1084
|
+
p[7] || (p[7] = S("span", { "aria-hidden": "true" }, "/", -1)),
|
|
1085
|
+
S("span", null, ut(h.value), 1),
|
|
1086
|
+
p[8] || (p[8] = S("div", {
|
|
1087
|
+
id: "portal-page-actions",
|
|
1088
|
+
class: "portal-page-actions"
|
|
1089
|
+
}, null, -1))
|
|
1090
|
+
])),
|
|
1091
|
+
S("div", ln, [
|
|
1092
|
+
C(d).businessId.value ? C(d).loading.value || C(o).loading.value ? (B(), Q("div", un, [
|
|
1093
|
+
T(_t, { size: "xl" }),
|
|
1094
|
+
p[10] || (p[10] = S("span", null, "Loading your Mini Program…", -1))
|
|
1095
|
+
])) : C(o).enabled.value ? C(d).error.value ? (B(), Q("section", dn, [
|
|
1096
|
+
p[12] || (p[12] = S("h1", null, "Could not open this Mini Program", -1)),
|
|
1097
|
+
S("p", null, ut(C(d).error.value), 1),
|
|
1098
|
+
T(Ft, {
|
|
1099
|
+
label: "Try again",
|
|
1100
|
+
onClick: C(d).refresh
|
|
1101
|
+
}, null, 8, ["onClick"])
|
|
1102
|
+
])) : (B(), ye(C(Ue), {
|
|
1103
|
+
key: `${C(d).businessId.value}:${C(s).params.projectId ?? String(C(s).name)}`
|
|
1104
|
+
})) : (B(), Q("section", cn, [
|
|
1105
|
+
p[11] || (p[11] = S("h1", null, "Mini Program is not available for this business", -1)),
|
|
1106
|
+
S("p", null, " It is still rolling out. Your FeedMe contact can enable it for " + ut(C(d).businessName.value) + ". ", 1)
|
|
1107
|
+
])) : (B(), Q("section", sn, [...p[9] || (p[9] = [
|
|
1108
|
+
S("h1", null, "Select a business", -1),
|
|
1109
|
+
S("p", null, "Choose a business in the Portal header to open its Mini Program.", -1)
|
|
1110
|
+
])]))
|
|
1111
|
+
])
|
|
1112
|
+
])
|
|
1113
|
+
], 2)
|
|
1114
|
+
], 64);
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
}), Fn = /* @__PURE__ */ De(vn, [["__scopeId", "data-v-5f3118b7"]]);
|
|
1118
|
+
export {
|
|
1119
|
+
Fn as default
|
|
1120
|
+
};
|