@feedmepos/mf-miniprogram-v2 0.2.2-dev.0 → 0.2.2-dev.10
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-agMiJ0tU.js +197 -0
- package/dist/AppTemplatePicker-C0lZyhK2.js +184 -0
- package/dist/BrandFontPicker-BFjp8k2W.js +241 -0
- package/dist/BrandKitView-DUbIT3c8.js +249 -0
- package/dist/{ControlPlaneView-krmwG-w_.js → ControlPlaneView-BJ6QP0bK.js} +8181 -7959
- package/dist/EcosystemView-BgjtBJy_.js +186 -0
- package/dist/LegacyWorkspaceEntry-opz_kWz9.js +36 -0
- package/dist/MobileProjectsView-DAWuOiCr.js +279 -0
- package/dist/ModuleCenterView-DyMr3iWV.js +147 -0
- package/dist/{ModuleDetailView-D5P-_5Ms.js → ModuleDetailView-BeXK89Cs.js} +71 -73
- package/dist/PagesView-CegMd6GC.js +43 -0
- package/dist/PlatformUnavailableView-j0_2YBKm.js +40 -0
- package/dist/PortalIcon-DO0VrIoY.js +28 -0
- package/dist/PortalSettingsView-Bqw8tMZb.js +123 -0
- package/dist/StatusBadge.vue_vue_type_script_setup_true_lang-Bh9Eoe_H.js +26 -0
- package/dist/WorkspaceEntryView-e2EUnq9A.js +21 -0
- package/dist/app.js +55 -11
- package/dist/controlPlane-CoEgf9BA.js +144 -0
- package/dist/index-D5qXvcfE.js +55 -0
- package/dist/localPreference-DneUpUrQ.js +34 -0
- package/dist/package.json +2 -1
- package/dist/portalContext-C4HL_0kl.js +47 -0
- package/dist/portalNavigation-DOF4Ah49.js +28 -0
- package/dist/routes-Boz_WlNM.js +54 -0
- package/dist/style.css +1 -1
- package/dist/useBrandKit-BlKlqpo2.js +1020 -0
- package/dist/{useModuleCatalog-CTgQG6Dx.js → useModuleCatalog-DqECds3F.js} +17 -16
- package/package.json +2 -1
- package/dist/App-CaNGbhK8.js +0 -20
- package/dist/AppTabs.vue_vue_type_script_setup_true_lang-BKOXPYIU.js +0 -284
- package/dist/ModuleCenterView-54GneqaO.js +0 -148
|
@@ -0,0 +1,1020 @@
|
|
|
1
|
+
import { a as jt, e as xt } from "./index-D5qXvcfE.js";
|
|
2
|
+
import { computed as nt, reactive as Et } from "vue";
|
|
3
|
+
import { h as x, e as ot } from "./controlPlane-CoEgf9BA.js";
|
|
4
|
+
import { useCoreStore as At } from "@feedmepos/mf-common";
|
|
5
|
+
const it = [
|
|
6
|
+
"Inter",
|
|
7
|
+
"Roboto",
|
|
8
|
+
"Open Sans",
|
|
9
|
+
"Lato",
|
|
10
|
+
"Montserrat",
|
|
11
|
+
"Noto Sans",
|
|
12
|
+
"Nunito",
|
|
13
|
+
"Nunito Sans",
|
|
14
|
+
"Poppins",
|
|
15
|
+
"Raleway",
|
|
16
|
+
"Source Sans 3",
|
|
17
|
+
"Ubuntu",
|
|
18
|
+
"DM Sans",
|
|
19
|
+
"Manrope",
|
|
20
|
+
"Work Sans",
|
|
21
|
+
"Oswald",
|
|
22
|
+
"Playfair Display",
|
|
23
|
+
"Merriweather",
|
|
24
|
+
"Lora",
|
|
25
|
+
"Noto Sans SC",
|
|
26
|
+
"Noto Sans TC"
|
|
27
|
+
];
|
|
28
|
+
function Nt(e) {
|
|
29
|
+
var i;
|
|
30
|
+
return ((i = e.split(",")[0]) == null ? void 0 : i.trim().replace(/^(['"])(.*)\1$/, "$2")) || "App default";
|
|
31
|
+
}
|
|
32
|
+
function he(e) {
|
|
33
|
+
const i = ["Playfair Display", "Merriweather", "Lora"].includes(e) ? "serif" : "sans-serif";
|
|
34
|
+
return `'${e}', ${i === "serif" ? "" : "system-ui, "}${i}`;
|
|
35
|
+
}
|
|
36
|
+
function vt(e) {
|
|
37
|
+
return `https://fonts.googleapis.com/css2?${[...new Set(e)].sort().map((s) => `family=${encodeURIComponent(s)}:wght@400;500;600;700`).join("&")}&display=swap`;
|
|
38
|
+
}
|
|
39
|
+
function Tt(e) {
|
|
40
|
+
if (!e || typeof e != "object" || !("stylesheet" in e) || typeof e.stylesheet != "string")
|
|
41
|
+
return !1;
|
|
42
|
+
try {
|
|
43
|
+
const i = new URL(e.stylesheet);
|
|
44
|
+
if (i.hostname !== "fonts.googleapis.com" || !["/css", "/css2"].includes(i.pathname)) return !1;
|
|
45
|
+
const s = i.searchParams.getAll("family").flatMap((r) => r.split("|"));
|
|
46
|
+
return s.length > 0 && s.every(
|
|
47
|
+
(r) => it.some((n) => {
|
|
48
|
+
var o;
|
|
49
|
+
return n.toLowerCase() === ((o = r.split(":")[0]) == null ? void 0 : o.trim().toLowerCase());
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
} catch {
|
|
53
|
+
return !1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function Mt(e, i) {
|
|
57
|
+
const s = ["brand", "heading", "body"].flatMap(
|
|
58
|
+
(n) => (i[n] || "").split(",").flatMap((o) => {
|
|
59
|
+
const u = it.find((d) => d.toLowerCase() === Nt(o).toLowerCase());
|
|
60
|
+
return u ? [u] : [];
|
|
61
|
+
})
|
|
62
|
+
), r = Array.isArray(e) ? e.filter((n) => !Tt(n)) : [];
|
|
63
|
+
return s.length ? [...r, { stylesheet: vt(s) }] : r;
|
|
64
|
+
}
|
|
65
|
+
const z = /* @__PURE__ */ new Map();
|
|
66
|
+
function ge(e) {
|
|
67
|
+
if (!it.some((r) => r === e)) return Promise.resolve();
|
|
68
|
+
const i = z.get(e);
|
|
69
|
+
if (i) return i;
|
|
70
|
+
const s = new Promise((r, n) => {
|
|
71
|
+
const o = document.createElement("link");
|
|
72
|
+
o.rel = "stylesheet", o.href = vt([e]);
|
|
73
|
+
let u = !1;
|
|
74
|
+
const d = window.setTimeout(() => v(), 15e3), v = () => {
|
|
75
|
+
u || (u = !0, window.clearTimeout(d), o.remove(), z.delete(e), n(new Error(`Could not load ${e}`)));
|
|
76
|
+
};
|
|
77
|
+
o.onerror = v, o.onload = () => {
|
|
78
|
+
document.fonts.load(`400 16px "${e}"`).then((m) => {
|
|
79
|
+
if (!u) {
|
|
80
|
+
if (!m.length) return v();
|
|
81
|
+
u = !0, window.clearTimeout(d), r();
|
|
82
|
+
}
|
|
83
|
+
}, v);
|
|
84
|
+
}, document.head.append(o);
|
|
85
|
+
});
|
|
86
|
+
return z.set(e, s), s;
|
|
87
|
+
}
|
|
88
|
+
var kt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
89
|
+
function Ct(e) {
|
|
90
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
91
|
+
}
|
|
92
|
+
var yt = { exports: {} };
|
|
93
|
+
(function(e, i) {
|
|
94
|
+
(function(s, r) {
|
|
95
|
+
e.exports = r();
|
|
96
|
+
})(kt, function() {
|
|
97
|
+
return function(s) {
|
|
98
|
+
var r = {};
|
|
99
|
+
function n(o) {
|
|
100
|
+
if (r[o]) return r[o].exports;
|
|
101
|
+
var u = r[o] = { i: o, l: !1, exports: {} };
|
|
102
|
+
return s[o].call(u.exports, u, u.exports, n), u.l = !0, u.exports;
|
|
103
|
+
}
|
|
104
|
+
return n.m = s, n.c = r, n.d = function(o, u, d) {
|
|
105
|
+
n.o(o, u) || Object.defineProperty(o, u, { enumerable: !0, get: d });
|
|
106
|
+
}, n.r = function(o) {
|
|
107
|
+
typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(o, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(o, "__esModule", { value: !0 });
|
|
108
|
+
}, n.t = function(o, u) {
|
|
109
|
+
if (1 & u && (o = n(o)), 8 & u || 4 & u && typeof o == "object" && o && o.__esModule) return o;
|
|
110
|
+
var d = /* @__PURE__ */ Object.create(null);
|
|
111
|
+
if (n.r(d), Object.defineProperty(d, "default", { enumerable: !0, value: o }), 2 & u && typeof o != "string")
|
|
112
|
+
for (var v in o)
|
|
113
|
+
n.d(
|
|
114
|
+
d,
|
|
115
|
+
v,
|
|
116
|
+
(function(m) {
|
|
117
|
+
return o[m];
|
|
118
|
+
}).bind(null, v)
|
|
119
|
+
);
|
|
120
|
+
return d;
|
|
121
|
+
}, n.n = function(o) {
|
|
122
|
+
var u = o && o.__esModule ? function() {
|
|
123
|
+
return o.default;
|
|
124
|
+
} : function() {
|
|
125
|
+
return o;
|
|
126
|
+
};
|
|
127
|
+
return n.d(u, "a", u), u;
|
|
128
|
+
}, n.o = function(o, u) {
|
|
129
|
+
return Object.prototype.hasOwnProperty.call(o, u);
|
|
130
|
+
}, n.p = "", n(n.s = 0);
|
|
131
|
+
}([
|
|
132
|
+
function(s, r, n) {
|
|
133
|
+
s.exports = n(1);
|
|
134
|
+
},
|
|
135
|
+
function(s, r, n) {
|
|
136
|
+
function o(t) {
|
|
137
|
+
return (o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(a) {
|
|
138
|
+
return typeof a;
|
|
139
|
+
} : function(a) {
|
|
140
|
+
return a && typeof Symbol == "function" && a.constructor === Symbol && a !== Symbol.prototype ? "symbol" : typeof a;
|
|
141
|
+
})(t);
|
|
142
|
+
}
|
|
143
|
+
function u(t) {
|
|
144
|
+
var a = "[object " + t + "]";
|
|
145
|
+
return function(l) {
|
|
146
|
+
return Object.prototype.toString.call(l) === a;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
n.r(r), n.d(r, "default", function() {
|
|
150
|
+
return _t;
|
|
151
|
+
}), n.d(r, "compare", function() {
|
|
152
|
+
return ft;
|
|
153
|
+
}), n.d(r, "comparable", function() {
|
|
154
|
+
return X;
|
|
155
|
+
});
|
|
156
|
+
var d = u("Array"), v = u("Object"), m = u("Function");
|
|
157
|
+
function b(t, a) {
|
|
158
|
+
return m(t.get) ? t.get(a) : t[a];
|
|
159
|
+
}
|
|
160
|
+
function w(t) {
|
|
161
|
+
return function(a, l) {
|
|
162
|
+
if (!d(l) || !l.length) return t(a, l);
|
|
163
|
+
for (var c = 0, p = l.length; c < p; c++)
|
|
164
|
+
if (t(a, b(l, c))) return !0;
|
|
165
|
+
return !1;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function N(t) {
|
|
169
|
+
return function(a, l) {
|
|
170
|
+
if (!d(l) || !l.length) return t(a, l);
|
|
171
|
+
for (var c = 0, p = l.length; c < p; c++)
|
|
172
|
+
if (!t(a, b(l, c))) return !1;
|
|
173
|
+
return !0;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function O(t, a, l, c) {
|
|
177
|
+
return t.validate(t.options, a, l, c);
|
|
178
|
+
}
|
|
179
|
+
var F = {
|
|
180
|
+
$eq: w(function(t, a) {
|
|
181
|
+
return t(a);
|
|
182
|
+
}),
|
|
183
|
+
$ne: N(function(t, a) {
|
|
184
|
+
return t(a);
|
|
185
|
+
}),
|
|
186
|
+
$gt: w(function(t, a) {
|
|
187
|
+
return t(a);
|
|
188
|
+
}),
|
|
189
|
+
$gte: w(function(t, a) {
|
|
190
|
+
return t(a);
|
|
191
|
+
}),
|
|
192
|
+
$lt: w(function(t, a) {
|
|
193
|
+
return t(a);
|
|
194
|
+
}),
|
|
195
|
+
$lte: w(function(t, a) {
|
|
196
|
+
return t(a);
|
|
197
|
+
}),
|
|
198
|
+
$mod: w(function(t, a) {
|
|
199
|
+
return t(a);
|
|
200
|
+
}),
|
|
201
|
+
$in: function(t, a) {
|
|
202
|
+
return t(a);
|
|
203
|
+
},
|
|
204
|
+
$nin: function(t, a) {
|
|
205
|
+
return t(a);
|
|
206
|
+
},
|
|
207
|
+
$not: function(t, a, l, c) {
|
|
208
|
+
return t(a, l, c);
|
|
209
|
+
},
|
|
210
|
+
$type: function(t, a) {
|
|
211
|
+
return t(a);
|
|
212
|
+
},
|
|
213
|
+
$all: function(t, a, l, c) {
|
|
214
|
+
return F.$and(t, a, l, c);
|
|
215
|
+
},
|
|
216
|
+
$size: function(t, a) {
|
|
217
|
+
return !!a && t === a.length;
|
|
218
|
+
},
|
|
219
|
+
$or: function(t, a, l, c) {
|
|
220
|
+
for (var p = 0, h = t.length; p < h; p++)
|
|
221
|
+
if (O(b(t, p), a, l, c)) return !0;
|
|
222
|
+
return !1;
|
|
223
|
+
},
|
|
224
|
+
$nor: function(t, a, l, c) {
|
|
225
|
+
return !F.$or(t, a, l, c);
|
|
226
|
+
},
|
|
227
|
+
$and: function(t, a, l, c) {
|
|
228
|
+
for (var p = 0, h = t.length; p < h; p++)
|
|
229
|
+
if (!O(b(t, p), a, l, c)) return !1;
|
|
230
|
+
return !0;
|
|
231
|
+
},
|
|
232
|
+
$regex: w(function(t, a) {
|
|
233
|
+
return typeof a == "string" && t.test(a);
|
|
234
|
+
}),
|
|
235
|
+
$where: function(t, a, l, c) {
|
|
236
|
+
return t.call(a, a, l, c);
|
|
237
|
+
},
|
|
238
|
+
$elemMatch: function(t, a, l, c) {
|
|
239
|
+
return d(a) ? !!~function(p, h) {
|
|
240
|
+
for (var g = 0; g < p.length; g++)
|
|
241
|
+
if (b(p, g), O(h, b(p, g))) return g;
|
|
242
|
+
return -1;
|
|
243
|
+
}(a, t) : O(t, a, l, c);
|
|
244
|
+
},
|
|
245
|
+
$exists: function(t, a, l, c) {
|
|
246
|
+
return c.hasOwnProperty(l) === t;
|
|
247
|
+
}
|
|
248
|
+
}, R = {
|
|
249
|
+
$eq: function(t, a, l) {
|
|
250
|
+
var c = l.comparable, p = l.compare;
|
|
251
|
+
return t instanceof RegExp ? w(function(h) {
|
|
252
|
+
return typeof h == "string" && t.test(h);
|
|
253
|
+
}) : t instanceof Function ? w(t) : d(t) && !t.length ? w(function(h) {
|
|
254
|
+
return d(h) && !h.length;
|
|
255
|
+
}) : w(
|
|
256
|
+
t === null ? function(h) {
|
|
257
|
+
return h == null;
|
|
258
|
+
} : function(h) {
|
|
259
|
+
return p(c(h), c(t)) === 0;
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
},
|
|
263
|
+
$gt: function(t, a, l) {
|
|
264
|
+
var c = l.comparable, p = l.compare;
|
|
265
|
+
return function(h) {
|
|
266
|
+
return p(c(h), c(t)) > 0;
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
$gte: function(t, a, l) {
|
|
270
|
+
var c = l.comparable, p = l.compare;
|
|
271
|
+
return function(h) {
|
|
272
|
+
return p(c(h), c(t)) >= 0;
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
$lt: function(t, a, l) {
|
|
276
|
+
var c = l.comparable, p = l.compare;
|
|
277
|
+
return function(h) {
|
|
278
|
+
return p(c(h), c(t)) < 0;
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
$lte: function(t, a, l) {
|
|
282
|
+
var c = l.comparable, p = l.compare;
|
|
283
|
+
return function(h) {
|
|
284
|
+
return p(c(h), c(t)) <= 0;
|
|
285
|
+
};
|
|
286
|
+
},
|
|
287
|
+
$in: function(t, a, l) {
|
|
288
|
+
var c = l.comparable;
|
|
289
|
+
return function(p) {
|
|
290
|
+
if (!(p instanceof Array)) {
|
|
291
|
+
var h = c(p);
|
|
292
|
+
if (h === p && o(p) === "object") {
|
|
293
|
+
for (y = t.length; y--; )
|
|
294
|
+
if (String(t[y]) === String(p) && String(p) !== "[object Object]")
|
|
295
|
+
return !0;
|
|
296
|
+
}
|
|
297
|
+
if (h === void 0) {
|
|
298
|
+
for (y = t.length; y--; ) if (t[y] == null) return !0;
|
|
299
|
+
}
|
|
300
|
+
for (y = t.length; y--; ) {
|
|
301
|
+
var g = O(lt(b(t, y), l), h, y, t);
|
|
302
|
+
if (g && String(g) !== "[object Object]" && String(h) !== "[object Object]")
|
|
303
|
+
return !0;
|
|
304
|
+
}
|
|
305
|
+
return !!~t.indexOf(h);
|
|
306
|
+
}
|
|
307
|
+
for (var y = p.length; y--; )
|
|
308
|
+
if (~t.indexOf(c(b(p, y)))) return !0;
|
|
309
|
+
return !1;
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
$nin: function(t, a, l) {
|
|
313
|
+
var c = R.$in(t, a, l);
|
|
314
|
+
return function(p, h, g, y) {
|
|
315
|
+
return !c(p, h, g, y);
|
|
316
|
+
};
|
|
317
|
+
},
|
|
318
|
+
$mod: function(t) {
|
|
319
|
+
return function(a) {
|
|
320
|
+
return a % t[0] == t[1];
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
$ne: function(t, a, l) {
|
|
324
|
+
var c = R.$eq(t, a, l);
|
|
325
|
+
return N(function(p, h, g, y) {
|
|
326
|
+
return !c(p, h, g, y);
|
|
327
|
+
});
|
|
328
|
+
},
|
|
329
|
+
$and: function(t, a, l) {
|
|
330
|
+
return t.map(T(l));
|
|
331
|
+
},
|
|
332
|
+
$all: function(t, a, l) {
|
|
333
|
+
return R.$and(t, a, l);
|
|
334
|
+
},
|
|
335
|
+
$or: function(t, a, l) {
|
|
336
|
+
return t.map(T(l));
|
|
337
|
+
},
|
|
338
|
+
$nor: function(t, a, l) {
|
|
339
|
+
return t.map(T(l));
|
|
340
|
+
},
|
|
341
|
+
$not: function(t, a, l) {
|
|
342
|
+
var c = T(l)(t);
|
|
343
|
+
return function(p, h, g) {
|
|
344
|
+
return !O(c, p, h, g);
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
$type: function(t) {
|
|
348
|
+
return function(a, l, c) {
|
|
349
|
+
return a != null && (a instanceof t || a.constructor == t);
|
|
350
|
+
};
|
|
351
|
+
},
|
|
352
|
+
$regex: function(t, a) {
|
|
353
|
+
return new RegExp(t, a.$options);
|
|
354
|
+
},
|
|
355
|
+
$where: function(t) {
|
|
356
|
+
if (typeof t == "function") return t;
|
|
357
|
+
throw new Error(
|
|
358
|
+
'In CSP mode, sift does not support strings in "$where" condition'
|
|
359
|
+
);
|
|
360
|
+
},
|
|
361
|
+
$elemMatch: function(t, a, l) {
|
|
362
|
+
return T(l)(t);
|
|
363
|
+
},
|
|
364
|
+
$exists: function(t) {
|
|
365
|
+
return !!t;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
function E(t, a) {
|
|
369
|
+
return { options: t, validate: a };
|
|
370
|
+
}
|
|
371
|
+
function St(t, a) {
|
|
372
|
+
var l = t.keyPath, c = t.child, p = t.query, h = [];
|
|
373
|
+
if (function ct(A, k, C, Ft, W) {
|
|
374
|
+
if (C === k.length || A == null)
|
|
375
|
+
return void W.push([A, k[C - 1], Ft]);
|
|
376
|
+
var dt = b(k, C);
|
|
377
|
+
if (d(A) && isNaN(Number(dt)))
|
|
378
|
+
for (var Y = 0, Rt = A.length; Y < Rt; Y++) ct(b(A, Y), k, C, A, W);
|
|
379
|
+
else ct(b(A, dt), k, C + 1, A, W);
|
|
380
|
+
}(a, l, 0, a, h), h.length === 1) {
|
|
381
|
+
var g = h[0];
|
|
382
|
+
return O(c, g[0], g[1], g[2]);
|
|
383
|
+
}
|
|
384
|
+
for (var y = p && p.$ne !== void 0, P = y, S = 0; S < h.length; S++) {
|
|
385
|
+
var j = h[S], K = O(c, j[0], j[1], j[2]);
|
|
386
|
+
y ? P &= K : P |= K;
|
|
387
|
+
}
|
|
388
|
+
return P;
|
|
389
|
+
}
|
|
390
|
+
function $t(t, a, l) {
|
|
391
|
+
return E({ keyPath: t, child: a, query: l }, St);
|
|
392
|
+
}
|
|
393
|
+
function T(t) {
|
|
394
|
+
var a = t.comparable, l = t.expressions, c = function(g) {
|
|
395
|
+
var y;
|
|
396
|
+
return (!g || !(y = g) || y.constructor !== Object && y.constructor !== Array && y.constructor.toString() !== "function Object() { [native code] }" && y.constructor.toString() !== "function Array() { [native code] }" || y.toJSON) && (g = { $eq: g }), g;
|
|
397
|
+
}, p = function(g) {
|
|
398
|
+
g = a(g);
|
|
399
|
+
var y = [];
|
|
400
|
+
for (var P in g) {
|
|
401
|
+
var S = g[P];
|
|
402
|
+
if (P !== "$options") {
|
|
403
|
+
var j = F[P] || t && l && l[P];
|
|
404
|
+
if (j) R[P] && (S = R[P](S, g, t)), y.push(E(a(S), j));
|
|
405
|
+
else {
|
|
406
|
+
if (P.charCodeAt(0) === 36)
|
|
407
|
+
throw new Error("Unknown operation " + P);
|
|
408
|
+
var K = P.split(".");
|
|
409
|
+
y.push($t(K, h(S), S));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return y.length === 1 ? y[0] : E(y, F.$and);
|
|
414
|
+
}, h = function(g) {
|
|
415
|
+
return g = c(g), function y(P, S) {
|
|
416
|
+
if (!v(P)) return S;
|
|
417
|
+
for (var j in P) S.push(j), y(P[j], S);
|
|
418
|
+
return S;
|
|
419
|
+
}(g, []).join(",").search(/[$.]/) === -1 ? E(g, D) : p(g);
|
|
420
|
+
};
|
|
421
|
+
return function(g) {
|
|
422
|
+
return p(c(g));
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function D(t, a) {
|
|
426
|
+
if (Object.prototype.toString.call(t) !== Object.prototype.toString.call(a))
|
|
427
|
+
return !1;
|
|
428
|
+
if (v(t)) {
|
|
429
|
+
if (Object.keys(t).length !== Object.keys(a).length) return !1;
|
|
430
|
+
for (var l in t) if (!D(t[l], a[l])) return !1;
|
|
431
|
+
return !0;
|
|
432
|
+
}
|
|
433
|
+
if (d(t)) {
|
|
434
|
+
if (t.length !== a.length) return !1;
|
|
435
|
+
for (var c = 0, p = t.length; c < p; c++)
|
|
436
|
+
if (!D(t[c], a[c])) return !1;
|
|
437
|
+
return !0;
|
|
438
|
+
}
|
|
439
|
+
return t === a;
|
|
440
|
+
}
|
|
441
|
+
function lt(t, a) {
|
|
442
|
+
var l = T(a)(t);
|
|
443
|
+
return a && a.select && (l = {
|
|
444
|
+
options: l,
|
|
445
|
+
validate: function(c, p, h, g) {
|
|
446
|
+
return O(c, p && a.select(p), h, g);
|
|
447
|
+
}
|
|
448
|
+
}), l;
|
|
449
|
+
}
|
|
450
|
+
function _t(t, a) {
|
|
451
|
+
var l = lt(t, a = Object.assign({ compare: ft, comparable: X }, a));
|
|
452
|
+
return function(c, p, h) {
|
|
453
|
+
return O(l, c, p, h);
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function ft(t, a) {
|
|
457
|
+
if (D(t, a)) return 0;
|
|
458
|
+
if (o(t) === o(a)) {
|
|
459
|
+
if (t > a) return 1;
|
|
460
|
+
if (t < a) return -1;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function X(t) {
|
|
464
|
+
return t instanceof Date ? t.getTime() : d(t) ? t.map(X) : t && typeof t.toJSON == "function" ? t.toJSON() : t;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
]);
|
|
468
|
+
});
|
|
469
|
+
})(yt);
|
|
470
|
+
var It = yt.exports;
|
|
471
|
+
const Bt = /* @__PURE__ */ Ct(It);
|
|
472
|
+
function Lt(e, i) {
|
|
473
|
+
for (var s = 0; s < i.length; s++) {
|
|
474
|
+
var r = i[s];
|
|
475
|
+
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function Dt(e, i, s) {
|
|
479
|
+
return i && Lt(e.prototype, i), e;
|
|
480
|
+
}
|
|
481
|
+
function Kt(e, i) {
|
|
482
|
+
e.prototype = Object.create(i.prototype), e.prototype.constructor = e, e.__proto__ = i;
|
|
483
|
+
}
|
|
484
|
+
function V(e) {
|
|
485
|
+
return V = Object.setPrototypeOf ? Object.getPrototypeOf : function(s) {
|
|
486
|
+
return s.__proto__ || Object.getPrototypeOf(s);
|
|
487
|
+
}, V(e);
|
|
488
|
+
}
|
|
489
|
+
function G(e, i) {
|
|
490
|
+
return G = Object.setPrototypeOf || function(r, n) {
|
|
491
|
+
return r.__proto__ = n, r;
|
|
492
|
+
}, G(e, i);
|
|
493
|
+
}
|
|
494
|
+
function Ut() {
|
|
495
|
+
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
|
|
496
|
+
if (typeof Proxy == "function") return !0;
|
|
497
|
+
try {
|
|
498
|
+
return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
|
|
499
|
+
})), !0;
|
|
500
|
+
} catch {
|
|
501
|
+
return !1;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function J(e, i, s) {
|
|
505
|
+
return Ut() ? J = Reflect.construct : J = function(n, o, u) {
|
|
506
|
+
var d = [null];
|
|
507
|
+
d.push.apply(d, o);
|
|
508
|
+
var v = Function.bind.apply(n, d), m = new v();
|
|
509
|
+
return u && G(m, u.prototype), m;
|
|
510
|
+
}, J.apply(null, arguments);
|
|
511
|
+
}
|
|
512
|
+
function Jt(e) {
|
|
513
|
+
return Function.toString.call(e).indexOf("[native code]") !== -1;
|
|
514
|
+
}
|
|
515
|
+
function Q(e) {
|
|
516
|
+
var i = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
517
|
+
return Q = function(r) {
|
|
518
|
+
if (r === null || !Jt(r)) return r;
|
|
519
|
+
if (typeof r != "function")
|
|
520
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
521
|
+
if (typeof i < "u") {
|
|
522
|
+
if (i.has(r)) return i.get(r);
|
|
523
|
+
i.set(r, n);
|
|
524
|
+
}
|
|
525
|
+
function n() {
|
|
526
|
+
return J(r, arguments, V(this).constructor);
|
|
527
|
+
}
|
|
528
|
+
return n.prototype = Object.create(r.prototype, {
|
|
529
|
+
constructor: {
|
|
530
|
+
value: n,
|
|
531
|
+
enumerable: !1,
|
|
532
|
+
writable: !0,
|
|
533
|
+
configurable: !0
|
|
534
|
+
}
|
|
535
|
+
}), G(n, r);
|
|
536
|
+
}, Q(e);
|
|
537
|
+
}
|
|
538
|
+
function pt(e) {
|
|
539
|
+
if (e === void 0)
|
|
540
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
541
|
+
return e;
|
|
542
|
+
}
|
|
543
|
+
var mt = function(i) {
|
|
544
|
+
return 'Cannot execute "' + i.action + '" on "' + i.subjectName + '"';
|
|
545
|
+
}, U = mt, Gt = /* @__PURE__ */ function(e) {
|
|
546
|
+
Kt(i, e), i.setDefaultMessage = function(n) {
|
|
547
|
+
n === null ? U = mt : U = typeof n == "string" ? function() {
|
|
548
|
+
return n;
|
|
549
|
+
} : n;
|
|
550
|
+
}, i.from = function(n) {
|
|
551
|
+
var o = new this("");
|
|
552
|
+
return Object.defineProperty(o, "ability", {
|
|
553
|
+
value: n
|
|
554
|
+
}), o;
|
|
555
|
+
};
|
|
556
|
+
function i(r, n) {
|
|
557
|
+
var o;
|
|
558
|
+
return n === void 0 && (n = {}), o = e.call(this, r) || this, o._setMetadata(n), o.message = r || U(pt(o)), o._customMessage = null, typeof Error.captureStackTrace == "function" && (o.name = o.constructor.name, Error.captureStackTrace(pt(o), o.constructor)), o;
|
|
559
|
+
}
|
|
560
|
+
var s = i.prototype;
|
|
561
|
+
return s.setMessage = function(n) {
|
|
562
|
+
return this._customMessage = n, this;
|
|
563
|
+
}, s.throwUnlessCan = function(n, o, u) {
|
|
564
|
+
if (!this.ability)
|
|
565
|
+
throw new ReferenceError("Cannot throw FordiddenError without respective ability instance");
|
|
566
|
+
var d = this.ability.relevantRuleFor(n, o, u);
|
|
567
|
+
if (!(d && !d.inverted)) {
|
|
568
|
+
this._setMetadata({
|
|
569
|
+
action: n,
|
|
570
|
+
subject: o,
|
|
571
|
+
field: u,
|
|
572
|
+
subjectName: this.ability.subjectName(o)
|
|
573
|
+
});
|
|
574
|
+
var v = d ? d.reason : "";
|
|
575
|
+
throw this.message = this._customMessage || v || U(this), this;
|
|
576
|
+
}
|
|
577
|
+
}, s._setMetadata = function(n) {
|
|
578
|
+
this.subject = n.subject, this.subjectName = n.subjectName, this.action = n.action, this.field = n.field;
|
|
579
|
+
}, i;
|
|
580
|
+
}(Q(Error));
|
|
581
|
+
function Z(e) {
|
|
582
|
+
return Array.isArray(e) ? e : [e];
|
|
583
|
+
}
|
|
584
|
+
function qt(e) {
|
|
585
|
+
if (!e || typeof e == "string")
|
|
586
|
+
return e;
|
|
587
|
+
var i = typeof e == "object" ? e.constructor : e;
|
|
588
|
+
return i.modelName || i.name;
|
|
589
|
+
}
|
|
590
|
+
function Ht(e) {
|
|
591
|
+
return JSON.parse(JSON.stringify(e));
|
|
592
|
+
}
|
|
593
|
+
var Xt = /[-/\\^$+?.()|[\]{}]/g, Wt = /\.?\*+\.?/g, Yt = /\*+/, zt = /\./g;
|
|
594
|
+
function Vt(e, i, s) {
|
|
595
|
+
var r = s[0] === "*" || e[0] === "." && e[e.length - 1] === "." ? "+" : "*", n = e.indexOf("**") === -1 ? "[^.]" : ".", o = e.replace(zt, "\\$&").replace(Yt, n + r);
|
|
596
|
+
return i + e.length === s.length ? "(?:" + o + ")?" : o;
|
|
597
|
+
}
|
|
598
|
+
function Qt(e, i, s) {
|
|
599
|
+
return e === "." && (s[i - 1] === "*" || s[i + 1] === "*") ? e : "\\" + e;
|
|
600
|
+
}
|
|
601
|
+
function Zt(e) {
|
|
602
|
+
var i = e.map(function(r) {
|
|
603
|
+
return r.replace(Xt, Qt).replace(Wt, Vt);
|
|
604
|
+
}), s = i.length > 1 ? "(?:" + i.join("|") + ")" : i[0];
|
|
605
|
+
return new RegExp("^" + s + "$");
|
|
606
|
+
}
|
|
607
|
+
var te = /* @__PURE__ */ function() {
|
|
608
|
+
function e(s) {
|
|
609
|
+
this.actions = s.actions || s.action, this.subject = s.subject, this.fields = !s.fields || s.fields.length === 0 ? void 0 : Z(s.fields), Object.defineProperty(this, "_fieldsPattern", {
|
|
610
|
+
writable: !0
|
|
611
|
+
}), this.inverted = !!s.inverted, this.conditions = s.conditions, Object.defineProperty(this, "_matches", {
|
|
612
|
+
writable: !0,
|
|
613
|
+
value: this.conditions ? Bt(this.conditions) : void 0
|
|
614
|
+
}), this.reason = s.reason;
|
|
615
|
+
}
|
|
616
|
+
var i = e.prototype;
|
|
617
|
+
return i.matches = function(r) {
|
|
618
|
+
return this._matches ? typeof r == "string" ? !this.inverted : this._matches(r) : !0;
|
|
619
|
+
}, i.isRelevantFor = function(r, n) {
|
|
620
|
+
return this.fields ? n ? this.matchesField(n) : !this.inverted : !0;
|
|
621
|
+
}, i.matchesField = function(r) {
|
|
622
|
+
return typeof this._fieldsPattern > "u" && (this._fieldsPattern = this.fields.join("").indexOf("*") === -1 ? null : Zt(this.fields)), this._fieldsPattern === null || r.indexOf("*") !== -1 ? this.fields.indexOf(r) !== -1 : this._fieldsPattern.test(r);
|
|
623
|
+
}, e;
|
|
624
|
+
}(), $ = typeof Symbol < "u" ? Symbol("private") : "__" + Date.now(), ht = {
|
|
625
|
+
crud: ["create", "read", "update", "delete"]
|
|
626
|
+
};
|
|
627
|
+
function gt(e, i) {
|
|
628
|
+
return e === i || Array.isArray(i) && i.indexOf(e) !== -1;
|
|
629
|
+
}
|
|
630
|
+
var ee = /* @__PURE__ */ function() {
|
|
631
|
+
e.addAlias = function(r, n) {
|
|
632
|
+
if (r === "manage" || gt("manage", n))
|
|
633
|
+
throw new Error('Cannot add alias for "manage" action because it represents any action');
|
|
634
|
+
if (gt(r, n))
|
|
635
|
+
throw new Error("Attempt to alias action to itself: " + r + " -> " + n.toString());
|
|
636
|
+
return ht[r] = n, this;
|
|
637
|
+
};
|
|
638
|
+
function e(s, r) {
|
|
639
|
+
r === void 0 && (r = {}), Object.defineProperty(this, "subjectName", {
|
|
640
|
+
value: r.subjectName || qt
|
|
641
|
+
}), this[$] = {
|
|
642
|
+
RuleType: r.RuleType || te,
|
|
643
|
+
originalRules: s || [],
|
|
644
|
+
hasPerFieldRules: !1,
|
|
645
|
+
indexedRules: /* @__PURE__ */ Object.create(null),
|
|
646
|
+
mergedRules: /* @__PURE__ */ Object.create(null),
|
|
647
|
+
events: {},
|
|
648
|
+
aliases: Ht(ht)
|
|
649
|
+
}, this.update(s);
|
|
650
|
+
}
|
|
651
|
+
var i = e.prototype;
|
|
652
|
+
return i.update = function(r) {
|
|
653
|
+
if (!Array.isArray(r))
|
|
654
|
+
return this;
|
|
655
|
+
var n = {
|
|
656
|
+
rules: r,
|
|
657
|
+
ability: this
|
|
658
|
+
};
|
|
659
|
+
this.emit("update", n), this[$].originalRules = r.slice(0), this[$].mergedRules = /* @__PURE__ */ Object.create(null);
|
|
660
|
+
var o = this.buildIndexFor(r);
|
|
661
|
+
return this[$].indexedRules = o.rules, this[$].hasPerFieldRules = o.hasPerFieldRules, this.emit("updated", n), this;
|
|
662
|
+
}, i.buildIndexFor = function(r) {
|
|
663
|
+
for (var n = /* @__PURE__ */ Object.create(null), o = this[$].RuleType, u = !0, d = !1, v = 0; v < r.length; v++) {
|
|
664
|
+
var m = new o(r[v]), b = this.expandActions(m.actions), w = Z(m.subject), N = r.length - v - 1;
|
|
665
|
+
u = !!(u && m.inverted), !d && m.fields && (d = !0);
|
|
666
|
+
for (var O = 0; O < w.length; O++) {
|
|
667
|
+
var F = w[O];
|
|
668
|
+
n[F] = n[F] || /* @__PURE__ */ Object.create(null);
|
|
669
|
+
for (var R = 0; R < b.length; R++) {
|
|
670
|
+
var E = b[R];
|
|
671
|
+
n[F][E] = n[F][E] || /* @__PURE__ */ Object.create(null), n[F][E][N] = m;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
isAllInverted: u,
|
|
677
|
+
hasPerFieldRules: d,
|
|
678
|
+
rules: n
|
|
679
|
+
};
|
|
680
|
+
}, i.expandActions = function(r) {
|
|
681
|
+
for (var n = this[$].aliases, o = Z(r), u = 0; u < o.length; ) {
|
|
682
|
+
var d = o[u++];
|
|
683
|
+
n.hasOwnProperty(d) && (o = o.concat(n[d]));
|
|
684
|
+
}
|
|
685
|
+
return o;
|
|
686
|
+
}, i.can = function(r, n, o) {
|
|
687
|
+
if (o && typeof o != "string")
|
|
688
|
+
throw new Error("Ability.can expects 3rd parameter to be a string. See https://stalniy.github.io/casl/abilities/2017/07/21/check-abilities.html#checking-fields for details");
|
|
689
|
+
var u = this.relevantRuleFor(r, n, o);
|
|
690
|
+
return !!u && !u.inverted;
|
|
691
|
+
}, i.relevantRuleFor = function(r, n, o) {
|
|
692
|
+
for (var u = this.rulesFor(r, n, o), d = 0; d < u.length; d++)
|
|
693
|
+
if (u[d].matches(n))
|
|
694
|
+
return u[d];
|
|
695
|
+
return null;
|
|
696
|
+
}, i.possibleRulesFor = function(r, n) {
|
|
697
|
+
var o = this.subjectName(n), u = this[$].mergedRules, d = o + "_" + r;
|
|
698
|
+
return u[d] || (u[d] = this.mergeRulesFor(r, o)), u[d];
|
|
699
|
+
}, i.mergeRulesFor = function(r, n) {
|
|
700
|
+
var o = this[$].indexedRules, u = [n, "all"].reduce(function(d, v) {
|
|
701
|
+
var m = o[v];
|
|
702
|
+
return m ? Object.assign(d, m[r], m.manage) : d;
|
|
703
|
+
}, []);
|
|
704
|
+
return u.filter(Boolean);
|
|
705
|
+
}, i.rulesFor = function(r, n, o) {
|
|
706
|
+
var u = this.possibleRulesFor(r, n);
|
|
707
|
+
return this[$].hasPerFieldRules ? u.filter(function(d) {
|
|
708
|
+
return d.isRelevantFor(n, o);
|
|
709
|
+
}) : u;
|
|
710
|
+
}, i.cannot = function() {
|
|
711
|
+
return !this.can.apply(this, arguments);
|
|
712
|
+
}, i.throwUnlessCan = function() {
|
|
713
|
+
var r;
|
|
714
|
+
console.warn(`
|
|
715
|
+
Ability.throwUnlessCan is deprecated and will be removed in 4.x version.
|
|
716
|
+
Please use "ForbiddenError.from(ability).throwUnlessCan(...)" instead.
|
|
717
|
+
`.trim()), (r = Gt.from(this)).throwUnlessCan.apply(r, arguments);
|
|
718
|
+
}, i.on = function(r, n) {
|
|
719
|
+
var o = this[$].events, u = !0;
|
|
720
|
+
return o[r] || (o[r] = []), o[r].push(n), function() {
|
|
721
|
+
if (u) {
|
|
722
|
+
var d = o[r].indexOf(n);
|
|
723
|
+
o[r].splice(d, 1), u = !1;
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
}, i.emit = function(r, n) {
|
|
727
|
+
var o = this[$].events[r];
|
|
728
|
+
o && o.slice(0).forEach(function(u) {
|
|
729
|
+
return u(n);
|
|
730
|
+
});
|
|
731
|
+
}, Dt(e, [{
|
|
732
|
+
key: "rules",
|
|
733
|
+
get: function() {
|
|
734
|
+
return this[$].originalRules;
|
|
735
|
+
}
|
|
736
|
+
}]), e;
|
|
737
|
+
}();
|
|
738
|
+
function re(e) {
|
|
739
|
+
return new ee(e).can("manage", "business::miniProgram::brandkit");
|
|
740
|
+
}
|
|
741
|
+
function at() {
|
|
742
|
+
var i;
|
|
743
|
+
const e = ((i = At().sessionUser.value) == null ? void 0 : i.permissions) ?? [];
|
|
744
|
+
return re(
|
|
745
|
+
e.map(({ fields: s, inverted: r, reason: n, ...o }) => ({
|
|
746
|
+
...o,
|
|
747
|
+
fields: s ?? void 0,
|
|
748
|
+
inverted: r ?? void 0,
|
|
749
|
+
reason: n ?? void 0
|
|
750
|
+
}))
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
function ve() {
|
|
754
|
+
return nt(at);
|
|
755
|
+
}
|
|
756
|
+
const H = [
|
|
757
|
+
{ path: "primary", label: "Primary", group: "Brand", hint: "Dominant brand color" },
|
|
758
|
+
{
|
|
759
|
+
path: "secondary",
|
|
760
|
+
label: "Secondary",
|
|
761
|
+
group: "Brand",
|
|
762
|
+
hint: "Light supporting fill — primary-colored text renders on top, keep it a light tint"
|
|
763
|
+
},
|
|
764
|
+
{ path: "accent", label: "Accent", group: "Brand", hint: "Highlight / CTA pop" },
|
|
765
|
+
{ path: "background.base", label: "Base", group: "Background", hint: "Page background" },
|
|
766
|
+
{ path: "background.elevated", label: "Elevated", group: "Background", hint: "Cards / sheets" },
|
|
767
|
+
{ path: "neutral.light", label: "Light", group: "Neutral", hint: "Borders / dividers" },
|
|
768
|
+
{ path: "neutral.mid", label: "Mid", group: "Neutral" },
|
|
769
|
+
{
|
|
770
|
+
path: "neutral.dark",
|
|
771
|
+
label: "Dark",
|
|
772
|
+
group: "Neutral",
|
|
773
|
+
hint: "Doubles as the modal scrim — keep near-black"
|
|
774
|
+
},
|
|
775
|
+
{ path: "text.onPrimary", label: "On primary", group: "Text", hint: "Text on a brand fill" },
|
|
776
|
+
{ path: "text.primary", label: "Primary", group: "Text" },
|
|
777
|
+
{ path: "text.secondary", label: "Secondary", group: "Text" },
|
|
778
|
+
{ path: "text.tertiary", label: "Tertiary", group: "Text" },
|
|
779
|
+
{ path: "status.success", label: "Success", group: "Status" },
|
|
780
|
+
{ path: "status.warning", label: "Warning", group: "Status" },
|
|
781
|
+
{ path: "status.error", label: "Error", group: "Status" },
|
|
782
|
+
{ path: "status.info", label: "Info", group: "Status" }
|
|
783
|
+
], L = [
|
|
784
|
+
{ path: "brand", label: "Brand", group: "Fonts", hint: "Logo / wordmark contexts" },
|
|
785
|
+
{ path: "heading", label: "Heading", group: "Fonts" },
|
|
786
|
+
{ path: "body", label: "Body", group: "Fonts" }
|
|
787
|
+
], bt = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
788
|
+
function ne(e) {
|
|
789
|
+
return bt.test(e.trim());
|
|
790
|
+
}
|
|
791
|
+
function ye(e) {
|
|
792
|
+
const i = e.trim().toLowerCase();
|
|
793
|
+
if (!bt.test(i)) return "#000000";
|
|
794
|
+
if (i.length === 7) return i;
|
|
795
|
+
const [s, r, n] = i.slice(1);
|
|
796
|
+
return `#${s}${s}${r}${r}${n}${n}`;
|
|
797
|
+
}
|
|
798
|
+
function oe() {
|
|
799
|
+
return jt(xt("fmmf:dev")).apiOrigin;
|
|
800
|
+
}
|
|
801
|
+
function st(e) {
|
|
802
|
+
return `${oe()}/metadata/${e}/brandkit`;
|
|
803
|
+
}
|
|
804
|
+
function I(e, i) {
|
|
805
|
+
let s = e;
|
|
806
|
+
for (const r of i.split(".")) {
|
|
807
|
+
if (!s || typeof s != "object") return;
|
|
808
|
+
s = s[r];
|
|
809
|
+
}
|
|
810
|
+
return s;
|
|
811
|
+
}
|
|
812
|
+
function tt(e, i, s) {
|
|
813
|
+
const r = i.split("."), n = r.pop();
|
|
814
|
+
if (!n) return;
|
|
815
|
+
let o = e;
|
|
816
|
+
for (const u of r) {
|
|
817
|
+
const d = o[u];
|
|
818
|
+
(!d || typeof d != "object") && (o[u] = {}), o = o[u];
|
|
819
|
+
}
|
|
820
|
+
o[n] = s;
|
|
821
|
+
}
|
|
822
|
+
function et(e, i, s) {
|
|
823
|
+
const r = {};
|
|
824
|
+
for (const n of s) {
|
|
825
|
+
const o = I(e == null ? void 0 : e[i], n.path);
|
|
826
|
+
r[n.path] = typeof o == "string" ? o : "";
|
|
827
|
+
}
|
|
828
|
+
return r;
|
|
829
|
+
}
|
|
830
|
+
function rt(e) {
|
|
831
|
+
return JSON.parse(JSON.stringify(e));
|
|
832
|
+
}
|
|
833
|
+
const f = Et({
|
|
834
|
+
panelOpen: !1,
|
|
835
|
+
loading: !1,
|
|
836
|
+
saving: !1,
|
|
837
|
+
loaded: !1,
|
|
838
|
+
error: null,
|
|
839
|
+
businessId: null,
|
|
840
|
+
colors: {},
|
|
841
|
+
fonts: {},
|
|
842
|
+
savedColors: {},
|
|
843
|
+
savedFonts: {},
|
|
844
|
+
// Full kit as it was before our last save — the only undo colors get.
|
|
845
|
+
revertKit: null,
|
|
846
|
+
appliedProposal: null
|
|
847
|
+
});
|
|
848
|
+
async function ut(e) {
|
|
849
|
+
const i = await fetch(st(e), { signal: AbortSignal.timeout(15e3) });
|
|
850
|
+
if (i.status === 404) return null;
|
|
851
|
+
if (!i.ok) throw new Error(`GET brandkit failed: HTTP ${i.status}`);
|
|
852
|
+
return await i.json();
|
|
853
|
+
}
|
|
854
|
+
function q(e) {
|
|
855
|
+
f.colors = et(e, "colors", H), f.fonts = et(e, "fonts", L), f.savedColors = { ...f.colors }, f.savedFonts = { ...f.fonts }, f.loaded = !0;
|
|
856
|
+
}
|
|
857
|
+
let M = null, _ = 0, B = null;
|
|
858
|
+
function wt(e = !1) {
|
|
859
|
+
const i = x();
|
|
860
|
+
if (f.loaded && !e && f.businessId === i) return Promise.resolve();
|
|
861
|
+
if ((M == null ? void 0 : M.businessId) === i) return M.promise;
|
|
862
|
+
const s = ++_;
|
|
863
|
+
f.businessId !== i && (f.businessId = i, f.loaded = !1, f.revertKit = null, B = null, f.appliedProposal = null, q(null), f.loaded = !1);
|
|
864
|
+
const r = (async () => {
|
|
865
|
+
f.loading = !0, f.error = null;
|
|
866
|
+
try {
|
|
867
|
+
const n = await ut(i);
|
|
868
|
+
s === _ && q(n);
|
|
869
|
+
} catch (n) {
|
|
870
|
+
s === _ && (f.error = ot(n));
|
|
871
|
+
} finally {
|
|
872
|
+
s === _ && (f.loading = !1, M = null);
|
|
873
|
+
}
|
|
874
|
+
})();
|
|
875
|
+
return M = { businessId: i, promise: r }, r;
|
|
876
|
+
}
|
|
877
|
+
function Ot() {
|
|
878
|
+
const e = H.filter((s) => f.colors[s.path] !== f.savedColors[s.path]).map(
|
|
879
|
+
(s) => s.path
|
|
880
|
+
), i = L.filter((s) => f.fonts[s.path] !== f.savedFonts[s.path]).map(
|
|
881
|
+
(s) => s.path
|
|
882
|
+
);
|
|
883
|
+
return { colorPaths: e, fontPaths: i };
|
|
884
|
+
}
|
|
885
|
+
const ie = nt(() => {
|
|
886
|
+
const { colorPaths: e, fontPaths: i } = Ot();
|
|
887
|
+
return e.length + i.length;
|
|
888
|
+
}), Pt = nt(
|
|
889
|
+
() => H.some((e) => {
|
|
890
|
+
const i = f.colors[e.path] ?? "";
|
|
891
|
+
return i !== "" && !ne(i);
|
|
892
|
+
})
|
|
893
|
+
);
|
|
894
|
+
async function ae() {
|
|
895
|
+
const e = x();
|
|
896
|
+
if (!at())
|
|
897
|
+
throw f.error = "You do not have permission to manage this Brand Kit. Contact an administrator.", new Error(f.error);
|
|
898
|
+
if (f.saving || f.loading || !f.loaded || f.businessId !== e)
|
|
899
|
+
throw new Error("Wait for the current Brand Kit to finish loading or saving.");
|
|
900
|
+
if (Pt.value) throw new Error("Enter valid hex colors before saving.");
|
|
901
|
+
const { colorPaths: i, fontPaths: s } = Ot();
|
|
902
|
+
if (!i.length && !s.length) return;
|
|
903
|
+
const r = { ...f.colors }, n = { ...f.fonts }, o = _;
|
|
904
|
+
f.saving = !0, f.error = null;
|
|
905
|
+
try {
|
|
906
|
+
const u = await ut(e) ?? {}, d = rt(u), v = rt(u);
|
|
907
|
+
(!v.colors || typeof v.colors != "object") && (v.colors = {}), (!v.fonts || typeof v.fonts != "object") && (v.fonts = {});
|
|
908
|
+
for (const b of i) tt(v.colors, b, (r[b] ?? "").trim());
|
|
909
|
+
for (const b of s) tt(v.fonts, b, (n[b] ?? "").trim());
|
|
910
|
+
if (s.length && (v.fontFamilies = Mt(u.fontFamilies, et(v, "fonts", L))), o !== _ || e !== x())
|
|
911
|
+
throw new Error("Business changed. No Brand Kit was saved.");
|
|
912
|
+
const m = await fetch(st(e), {
|
|
913
|
+
method: "POST",
|
|
914
|
+
headers: { "Content-Type": "application/json" },
|
|
915
|
+
body: JSON.stringify(v),
|
|
916
|
+
signal: AbortSignal.timeout(2e4)
|
|
917
|
+
});
|
|
918
|
+
if (!m.ok) throw new Error(`Save failed: HTTP ${m.status}`);
|
|
919
|
+
o === _ && e === x() && (f.revertKit = d, B = {
|
|
920
|
+
colorPaths: i,
|
|
921
|
+
fontPaths: s,
|
|
922
|
+
savedFontFamilies: s.length ? JSON.stringify(v.fontFamilies) : void 0
|
|
923
|
+
}, f.appliedProposal = null, q(v));
|
|
924
|
+
} catch (u) {
|
|
925
|
+
throw o === _ && (f.error = ot(u)), u;
|
|
926
|
+
} finally {
|
|
927
|
+
f.saving = !1;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
async function se() {
|
|
931
|
+
if (!f.revertKit || !B || f.saving || f.loading) return;
|
|
932
|
+
const e = x();
|
|
933
|
+
if (!at())
|
|
934
|
+
throw f.error = "You do not have permission to manage this Brand Kit. Contact an administrator.", new Error(f.error);
|
|
935
|
+
if (f.businessId !== e) throw new Error("Load the current business before reverting.");
|
|
936
|
+
const i = _, s = rt(f.revertKit), r = B;
|
|
937
|
+
f.saving = !0, f.error = null;
|
|
938
|
+
try {
|
|
939
|
+
const n = await ut(e) ?? {};
|
|
940
|
+
if (r.fontPaths.length) {
|
|
941
|
+
if (L.some((u) => (I(n.fonts, u.path) ?? "") !== f.savedFonts[u.path]) || JSON.stringify(n.fontFamilies) !== r.savedFontFamilies)
|
|
942
|
+
throw new Error("Brand Kit changed since your save. Reload it before editing again.");
|
|
943
|
+
Object.hasOwn(s, "fontFamilies") ? n.fontFamilies = s.fontFamilies : delete n.fontFamilies;
|
|
944
|
+
}
|
|
945
|
+
for (const [u, d] of [
|
|
946
|
+
["colors", r.colorPaths],
|
|
947
|
+
["fonts", r.fontPaths]
|
|
948
|
+
]) {
|
|
949
|
+
const v = u === "colors" ? f.savedColors : f.savedFonts;
|
|
950
|
+
for (const m of d) {
|
|
951
|
+
if ((I(n[u], m) ?? "") !== v[m])
|
|
952
|
+
throw new Error("Brand Kit changed since your save. Reload it before editing again.");
|
|
953
|
+
(!n[u] || typeof n[u] != "object") && (n[u] = {});
|
|
954
|
+
const b = I(s[u], m);
|
|
955
|
+
if (typeof b == "string") tt(n[u], m, b);
|
|
956
|
+
else {
|
|
957
|
+
const w = m.split("."), N = w.pop(), O = w.length ? I(n[u], w.join(".")) : n[u];
|
|
958
|
+
O && typeof O == "object" && delete O[N];
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
if (i !== _ || e !== x())
|
|
963
|
+
throw new Error("Business changed. No Brand Kit was reverted.");
|
|
964
|
+
const o = await fetch(st(e), {
|
|
965
|
+
method: "POST",
|
|
966
|
+
headers: { "Content-Type": "application/json" },
|
|
967
|
+
body: JSON.stringify(n),
|
|
968
|
+
signal: AbortSignal.timeout(2e4)
|
|
969
|
+
});
|
|
970
|
+
if (!o.ok) throw new Error(`Revert failed: HTTP ${o.status}`);
|
|
971
|
+
i === _ && e === x() && (f.revertKit = null, B = null, q(n));
|
|
972
|
+
} catch (n) {
|
|
973
|
+
throw i === _ && (f.error = ot(n)), n;
|
|
974
|
+
} finally {
|
|
975
|
+
f.saving = !1;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
async function ue(e) {
|
|
979
|
+
f.panelOpen = !0;
|
|
980
|
+
const i = x();
|
|
981
|
+
if (await wt(), !(!f.loaded || f.loading || f.saving || f.businessId !== i || x() !== i)) {
|
|
982
|
+
for (const s of H) {
|
|
983
|
+
const r = e.colors[s.path];
|
|
984
|
+
r && (f.colors[s.path] = r);
|
|
985
|
+
}
|
|
986
|
+
for (const s of L) {
|
|
987
|
+
const r = e.fonts[s.path];
|
|
988
|
+
r && (f.fonts[s.path] = r);
|
|
989
|
+
}
|
|
990
|
+
f.appliedProposal = e.name ?? "Untitled proposal";
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function le() {
|
|
994
|
+
f.colors = { ...f.savedColors }, f.fonts = { ...f.savedFonts }, f.appliedProposal = null;
|
|
995
|
+
}
|
|
996
|
+
function me() {
|
|
997
|
+
return {
|
|
998
|
+
state: f,
|
|
999
|
+
dirtyCount: ie,
|
|
1000
|
+
hasInvalidColor: Pt,
|
|
1001
|
+
load: wt,
|
|
1002
|
+
save: ae,
|
|
1003
|
+
revertLastSave: se,
|
|
1004
|
+
applyProposal: ue,
|
|
1005
|
+
discardEdits: le
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
export {
|
|
1009
|
+
H as C,
|
|
1010
|
+
L as F,
|
|
1011
|
+
it as G,
|
|
1012
|
+
ve as a,
|
|
1013
|
+
Nt as b,
|
|
1014
|
+
he as f,
|
|
1015
|
+
Ct as g,
|
|
1016
|
+
ne as i,
|
|
1017
|
+
ge as l,
|
|
1018
|
+
ye as t,
|
|
1019
|
+
me as u
|
|
1020
|
+
};
|