@feedmepos/mf-miniprogram-v2 0.2.9-dev.9 → 0.2.9

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