@feedmepos/mf-miniprogram-v2 0.2.10 → 0.2.11-dev.2

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