@cntrl-site/components 1.0.115-alpha.1 → 1.0.115-alpha.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.
@@ -0,0 +1,1372 @@
1
+ import { jsx as I, jsxs as et } from "react/jsx-runtime";
2
+ import { useMemo as bt, useState as H, useEffect as Y, useRef as X, useLayoutEffect as Ot } from "react";
3
+ import { createPortal as Xe } from "react-dom";
4
+ import { s as me } from "./scalingValue-C9JH5L6O.mjs";
5
+ import { u as je } from "./useScopedStyles-DhBG3557.mjs";
6
+ import { i as Ye, E as Ve } from "./EmbedMediaFrame-DwHeOAy5.mjs";
7
+ import { u as Ke } from "./useLightboxScrollLock-VQ07s7EJ.mjs";
8
+ import { n as qe } from "./textStylesToCss-05Mn6I_2.mjs";
9
+ import { R as Ze } from "./RichTextRenderer-D52Xto59.mjs";
10
+ import { S as Je } from "./SvgImage-CwRq9-ec.mjs";
11
+ const Qe = 60, Pe = 900 / 1440, to = ["left", "center", "right"], ge = {
12
+ columns: 12,
13
+ columnWidth: 99 / 1440,
14
+ gutter: 20 / 1440
15
+ };
16
+ function eo(t, e = ge) {
17
+ const o = (l) => typeof l == "number" && Number.isFinite(l), r = (l, ...u) => u.find(o) ?? l, i = t.gridLayout ?? {}, s = Math.max(0, r(e.gutter, i.horizontalGap, t.gridGutter));
18
+ return {
19
+ columns: Math.max(1, Math.round(r(e.columns, i.columnsCount, t.gridColumns))),
20
+ columnWidth: Math.max(0, r(e.columnWidth, i.entryWidth, t.gridColumnWidth)),
21
+ gutter: s,
22
+ rowGap: Math.max(0, r(s, t.verticalGap))
23
+ };
24
+ }
25
+ function nt(t) {
26
+ return t.rowGap ?? t.gutter;
27
+ }
28
+ function $e(t) {
29
+ const e = t.popupHeight;
30
+ return Math.min(100, Math.max(0, typeof e == "number" && Number.isFinite(e) ? e : Qe));
31
+ }
32
+ function oo(t, e = Pe) {
33
+ return $e(t) / 100 * e;
34
+ }
35
+ function no(t) {
36
+ return to.includes(t.popupAlign) ? t.popupAlign : "center";
37
+ }
38
+ function ro(t, e) {
39
+ var i;
40
+ const o = (i = t.gridLayout) == null ? void 0 : i.wrapperWidth, r = e.columns * e.columnWidth + (e.columns - 1) * e.gutter;
41
+ return typeof o == "number" && Number.isFinite(o) && o > 0 ? Math.max(o, r) : r > 0 ? r : 1;
42
+ }
43
+ function io(t) {
44
+ if (typeof t == "number") return { top: t, right: t, bottom: t, left: t };
45
+ const e = (o) => typeof o == "number" && Number.isFinite(o) ? Math.max(0, o) : 0;
46
+ return { top: e(t == null ? void 0 : t.top), right: e(t == null ? void 0 : t.right), bottom: e(t == null ? void 0 : t.bottom), left: e(t == null ? void 0 : t.left) };
47
+ }
48
+ function Ht(t) {
49
+ const e = Math.max(1, Math.floor(t.columns));
50
+ return t.columnWidth > 0 ? t.columnWidth : Math.max(0, (1 - (e - 1) * t.gutter) / e);
51
+ }
52
+ function V(t) {
53
+ const e = Math.max(1, Math.floor(t.columns));
54
+ return e * Ht(t) + (e - 1) * t.gutter;
55
+ }
56
+ function be(t) {
57
+ const e = Math.max(1, Math.floor(t.columns)), o = Ht(t), r = o + t.gutter;
58
+ return Array.from({ length: e }, (i, s) => [U(s * r), U(s * r + o)]).flat();
59
+ }
60
+ function Xt(t, e, o, r, i) {
61
+ const s = Ht(t), l = {
62
+ left: U(e * (s + t.gutter)),
63
+ width: U(o * s + Math.max(0, o - 1) * t.gutter),
64
+ top: r
65
+ };
66
+ return i === void 0 ? l : { ...l, height: i };
67
+ }
68
+ function It() {
69
+ return 8 / 1440;
70
+ }
71
+ function ao(t) {
72
+ const e = Math.max(1, Math.floor(t.columns));
73
+ return Xt(t, 0, Math.min(e, Math.max(1, Math.round(e / 4))), 0);
74
+ }
75
+ function ve(t) {
76
+ const e = t;
77
+ return typeof e.left == "number" && Number.isFinite(e.left) && typeof e.width == "number" && Number.isFinite(e.width);
78
+ }
79
+ function so(t, e) {
80
+ if (ve(t)) return t;
81
+ const o = Math.max(1, Math.floor(e.columns)), r = Math.min(o, Math.max(1, Math.round(t.span ?? 1))), i = Math.min(Math.max(0, Math.round(t.column ?? 0)), o - r);
82
+ return Xt(e, i, r, t.top, typeof t.height == "number" ? t.height : void 0);
83
+ }
84
+ function lo(t) {
85
+ return t.placements.every(ve) ? t : { ...t, placements: t.placements.map((e) => so(e, t.grid)) };
86
+ }
87
+ const co = {
88
+ span: {
89
+ text: { min: 1 / 4, max: 5 / 12 },
90
+ image: { min: 1 / 6, max: 1 / 3 },
91
+ listA: { min: 1 / 6, max: 1 / 4 },
92
+ listB: { min: 1 / 6, max: 1 / 4 }
93
+ },
94
+ breakChance: 0.25
95
+ };
96
+ function ho(t, e, o, r, i = co) {
97
+ const s = vo(o), l = Math.max(1, Math.floor(e.columns)), u = [];
98
+ let h = 0, d = new Array(l).fill(!1);
99
+ const n = {};
100
+ for (const y of t) {
101
+ const p = n[y] ?? (n[y] = bo(i.span[y] ?? i.span.text, l, s));
102
+ let g = he(d, p);
103
+ const L = d.some(Boolean);
104
+ (g.length === 0 || L && s() < i.breakChance) && (h += 1, d = new Array(l).fill(!1), g = he(d, p));
105
+ const T = g[Math.floor(s() * g.length)];
106
+ for (let x = Math.max(0, T - 1); x < Math.min(l, T + p + 1); x++) d[x] = !0;
107
+ u.push({ column: T, span: p, row: h });
108
+ }
109
+ const m = h + 1, k = { ...e, columns: l };
110
+ return {
111
+ seed: o,
112
+ grid: k,
113
+ placements: u.map(({ column: y, span: p, row: g }) => Xt(k, y, p, uo(e, g * r / m, r)))
114
+ };
115
+ }
116
+ function uo(t, e, o = 1 / 0) {
117
+ const r = t.beat ?? 0, i = Math.max(0, o), s = r > 0 ? Math.round(e / r) * r : e, l = s <= i ? s : r > 0 ? Math.floor(i / r + 1e-9) * r : i;
118
+ return Math.round(Math.max(0, l) * 1e6) / 1e6;
119
+ }
120
+ function jt(t) {
121
+ return t.beat && t.beat > 0 ? t.beat : 8 / 1440;
122
+ }
123
+ function rn(t, e, o = 1 / 0) {
124
+ const r = t.beat ?? 0, i = jt(t), s = r > 0 ? Math.round(e / r) * r : e, l = s <= o ? s : r > 0 ? Math.floor(o / r + 1e-9) * r : o;
125
+ return U(Math.max(i, l));
126
+ }
127
+ function po(t, e) {
128
+ const o = (r, i) => Math.abs(r - i) < 1e-9;
129
+ return Math.floor(t.columns) === Math.floor(e.columns) && o(t.columnWidth, e.columnWidth) && o(t.gutter, e.gutter) && o(nt(t), nt(e)) && o(t.beat ?? 0, e.beat ?? 0);
130
+ }
131
+ function fo(t, e) {
132
+ const o = { ...e, columns: Math.max(1, Math.floor(e.columns)) };
133
+ if (po(t.grid, o)) return t;
134
+ const r = V(t.grid), i = V(o), s = r > 0 ? i / r : 1, l = t.placements.map((u) => {
135
+ const h = U(Math.min(i, Math.max(It(), u.width * s))), d = U(Math.min(Math.max(0, u.left * s), i - h));
136
+ return u.height === void 0 ? { left: d, width: h, top: u.top } : { left: d, width: h, top: u.top, height: u.height };
137
+ });
138
+ return { ...t, grid: o, placements: l };
139
+ }
140
+ function U(t) {
141
+ return Math.round(t * 1e6) / 1e6;
142
+ }
143
+ function xe(t, e, o, r, i) {
144
+ return t.left < o.left + o.width - 1e-9 && o.left < t.left + t.width - 1e-9 && t.top < o.top + r + i - 1e-9 && o.top < t.top + e + i - 1e-9;
145
+ }
146
+ function mo(t, e, o, r, i) {
147
+ const s = t.placements[e];
148
+ return s ? ye(t, e, { ...s, left: o, top: r }, i) : null;
149
+ }
150
+ function go(t, e, o, r) {
151
+ if (!t.placements[e]) return null;
152
+ const i = V(t.grid), s = Math.min(It(), i), l = jt(t.grid), u = Math.min(Math.max(0, o.left), i - s), h = Math.min(Math.max(s, o.width), i - u), d = Math.min(Math.max(0, o.top), r ? Math.max(0, r.height - l) : 1 / 0), n = o.height === void 0 ? void 0 : Math.min(Math.max(l, o.height), r ? Math.max(l, r.height - d) : 1 / 0);
153
+ return ye(t, e, n === void 0 ? { left: u, width: h, top: d } : { left: u, width: h, top: d, height: n }, r);
154
+ }
155
+ function ye(t, e, o, r) {
156
+ const i = nt(t.grid), s = V(t.grid), l = U(Math.min(Math.max(o.width, Math.min(It(), s)), s)), u = o.height ?? (r == null ? void 0 : r.heights[e]) ?? 0, h = {
157
+ left: U(Math.min(Math.max(0, o.left), s - l)),
158
+ width: l,
159
+ top: U(Math.min(Math.max(0, o.top), r ? Math.max(0, r.height - u) : 1 / 0)),
160
+ ...o.height === void 0 ? {} : { height: U(o.height) }
161
+ };
162
+ return r && t.placements.some((d, n) => n !== e && xe(h, u, d, r.heights[n] ?? 0, i)) ? null : {
163
+ ...t,
164
+ edited: !0,
165
+ placements: t.placements.map((d, n) => n === e ? h : d)
166
+ };
167
+ }
168
+ function $o(t, e) {
169
+ const o = V(t.grid), r = be(t.grid).filter((p, g) => g % 2 === 0), i = nt(t.grid), s = t.grid.beat ?? 0, l = e.height, u = t.placements.map((p, g) => e.heights[g] ?? 0), h = [...t.placements], d = h.map((p, g) => g).sort((p, g) => h[p].top - h[g].top || p - g), n = [], m = (p, g) => {
170
+ let { top: L } = p;
171
+ for (let T = !0, x = 0; T && x <= n.length; x++) {
172
+ T = !1;
173
+ for (const E of n) {
174
+ const v = h[E];
175
+ if (!xe({ ...p, top: L }, g, v, u[E], i)) continue;
176
+ const S = v.top + u[E] + i, $ = s > 0 ? U(Math.ceil(S / s - 1e-9) * s) : Math.ceil(S * 1e6 - 1e-6) / 1e6;
177
+ $ <= L || (L = $, T = !0);
178
+ }
179
+ }
180
+ return L;
181
+ }, k = (p, g) => p + g > l + 1e-9;
182
+ let y = !1;
183
+ for (const p of d) {
184
+ const g = h[p];
185
+ let L = { left: g.left, top: m(g, u[p]) };
186
+ if (L.top !== g.top && k(L.top, u[p])) {
187
+ const T = r.filter((E) => E + g.width <= o + 1e-9).sort((E, v) => Math.abs(E - g.left) - Math.abs(v - g.left) || E - v);
188
+ let x = null;
189
+ for (const E of T) {
190
+ const v = m({ ...g, left: E }, u[p]);
191
+ !k(v, u[p]) && (!x || v < x.top - 1e-9) && (x = { left: E, top: v });
192
+ }
193
+ x && (L = x);
194
+ }
195
+ (L.left !== g.left || L.top !== g.top) && (h[p] = { ...h[p], ...L }, y = !0), n.push(p);
196
+ }
197
+ return y ? { ...t, placements: h } : t;
198
+ }
199
+ function bo(t, e, o) {
200
+ const r = Math.max(1, Math.round(t.min * e)), i = Math.max(r, Math.round(t.max * e));
201
+ return Math.min(e, r + Math.floor(o() * (i - r + 1)));
202
+ }
203
+ function he(t, e) {
204
+ const o = [];
205
+ for (let r = 0; r + e <= t.length; r++) {
206
+ let i = !0;
207
+ for (let s = r; s < r + e; s++)
208
+ if (t[s]) {
209
+ i = !1;
210
+ break;
211
+ }
212
+ i && o.push(r);
213
+ }
214
+ return o;
215
+ }
216
+ function vo(t) {
217
+ let e = t >>> 0;
218
+ return () => {
219
+ e = e + 1831565813 >>> 0;
220
+ let o = e;
221
+ return o = Math.imul(o ^ o >>> 15, o | 1), o ^= o + Math.imul(o ^ o >>> 7, o | 61), ((o ^ o >>> 14) >>> 0) / 4294967296;
222
+ };
223
+ }
224
+ const ue = 5, xt = (t) => Array.from(new Set(t.map((e) => Math.round(e * 1e6) / 1e6)));
225
+ function xo(t, e) {
226
+ const o = t.beat || nt(t);
227
+ if (!(o > 0)) return [];
228
+ const r = [];
229
+ for (let i = 1; i * o <= e + 1e-9; i++) r.push(i * o);
230
+ return r;
231
+ }
232
+ function yo(t, e, o, r = []) {
233
+ const i = V(t.grid), s = nt(t.grid), l = t.grid.beat ?? 0, u = [0, i / 2, i, ...be(t.grid)], h = [0, o.height];
234
+ if (l > 0) for (let n = l; n < o.height; n += l) h.push(n);
235
+ const d = xo(t.grid, o.height);
236
+ return t.placements.forEach((n, m) => {
237
+ if (m === e) return;
238
+ const k = n.height ?? o.heights[m] ?? 0;
239
+ u.push(n.left, n.left + n.width / 2, n.left + n.width), h.push(n.top, n.top + k / 2, n.top + k), s > 0 && h.push(n.top - s, n.top + k + s);
240
+ const y = r[m];
241
+ typeof y == "number" && d.push(n.top + y);
242
+ }), { xs: xt(u), ys: xt(h.filter((n) => n >= 0)), baselines: xt(d) };
243
+ }
244
+ function Ct(t, e, o) {
245
+ let r = null;
246
+ for (const i of t)
247
+ for (const s of e) {
248
+ const l = s - i;
249
+ Math.abs(l) <= o && (r === null || Math.abs(l) < Math.abs(r)) && (r = l);
250
+ }
251
+ return r;
252
+ }
253
+ function wo(t, e) {
254
+ return t === null ? e : e === null ? t : Math.abs(e) < Math.abs(t) ? e : t;
255
+ }
256
+ function we(t, e) {
257
+ const o = (r, i) => i.filter((s) => r.some((l) => Math.abs(l - s) < 1e-5));
258
+ return {
259
+ xs: xt(o(t.xs, e.xs)),
260
+ ys: xt([...o(t.ys, e.ys), ...o(t.baselines ?? [], e.baselines ?? [])])
261
+ };
262
+ }
263
+ function Mo(t, e, o, r, i, s, l, u, h) {
264
+ const { width: d } = t;
265
+ let n = t.left + o, m = t.top + r;
266
+ const k = typeof h == "number";
267
+ return n += Ct([n, n + d / 2, n + d], i.xs, s.x) ?? 0, m += wo(
268
+ Ct([m, m + e / 2, m + e], i.ys, s.y),
269
+ k ? Ct([m + h], i.baselines ?? [], s.y) : null
270
+ ) ?? 0, n = Math.min(Math.max(0, n), Math.max(0, l - d)), m = Math.min(Math.max(0, m), Math.max(0, u - e)), {
271
+ placement: { ...t, left: n, top: m },
272
+ guides: we(
273
+ {
274
+ xs: [n, n + d / 2, n + d],
275
+ ys: [m, m + e / 2, m + e],
276
+ baselines: k ? [m + h] : []
277
+ },
278
+ i
279
+ )
280
+ };
281
+ }
282
+ function ko(t, e, o, r, i, s, l, u, h, d, { keepRatio: n = !1, fromCenter: m = !1 } = {}) {
283
+ const k = Math.min(It(), u), y = o.includes("left"), p = o.includes("right"), g = o.includes("top"), L = o.includes("bottom"), T = y || p, x = g || L, E = t.left + t.width / 2, v = t.top + e / 2;
284
+ let S = t.left, $ = t.left + t.width, _ = t.top, z = t.top + e;
285
+ const J = (M, O, D) => M + (Ct([M], O, D) ?? 0);
286
+ let K = !1, Q = !1;
287
+ if (y) {
288
+ const M = t.left + r;
289
+ S = J(M, s.xs, l.x), K = S !== M, m && ($ = 2 * E - S);
290
+ } else if (p) {
291
+ const M = t.left + t.width + r;
292
+ $ = J(M, s.xs, l.x), K = $ !== M, m && (S = 2 * E - $);
293
+ }
294
+ if (g) {
295
+ const M = t.top + i;
296
+ _ = J(M, s.ys, l.y), Q = _ !== M, m && (z = 2 * v - _);
297
+ } else if (L) {
298
+ const M = t.top + e + i;
299
+ z = J(M, s.ys, l.y), Q = z !== M, m && (_ = 2 * v - z);
300
+ }
301
+ if (n && T && x && t.width > 0 && e > 0) {
302
+ const M = t.width / e, O = Math.abs($ - S), D = Math.abs(z - _);
303
+ if (K !== Q ? K : Math.abs(O / t.width - 1) >= Math.abs(D / e - 1)) {
304
+ const W = O / M;
305
+ m ? [_, z] = [v - W / 2, v + W / 2] : g ? _ = z - W : z = _ + W;
306
+ } else {
307
+ const W = D * M;
308
+ m ? [S, $] = [E - W / 2, E + W / 2] : y ? S = $ - W : $ = S + W;
309
+ }
310
+ }
311
+ const yt = (M, O, D, rt, W) => O - M >= D ? [M, O] : m ? [W - D / 2, W + D / 2] : rt ? [O - D, O] : [M, M + D];
312
+ T && ([S, $] = yt(S, $, k, y, E)), x && ([_, z] = yt(_, z, d, g, v)), S = Math.max(0, S), $ = Math.min(u, Math.max(S + k, $)), _ = Math.max(0, _), x && (z = Math.min(Math.max(h, _ + d), Math.max(_ + d, z)));
313
+ const ct = { left: S, width: $ - S, top: _ }, ht = x ? z - _ : t.height;
314
+ return ht !== void 0 && (ct.height = ht), {
315
+ placement: ct,
316
+ guides: we(
317
+ {
318
+ xs: T ? m || n ? [S, $] : [y ? S : $] : [],
319
+ ys: x ? m || n ? [_, z] : [g ? _ : z] : []
320
+ },
321
+ s
322
+ )
323
+ };
324
+ }
325
+ const ot = 300, So = 3e3, Me = ["slide down", "slide up", "fade", "scale", "none"], Co = "slide down";
326
+ function Ro(t) {
327
+ const e = t.popupTransition;
328
+ return Me.includes(e) ? e : Co;
329
+ }
330
+ const Io = ["burger", "plus", "icon", "text"], Lo = 24 / 1440, ke = ["--cntrl-article-top", "--cntrl-article-left", "--cntrl-article-width", "--cntrl-viewport-height"];
331
+ function _o(t) {
332
+ const e = getComputedStyle(t);
333
+ return Object.fromEntries(
334
+ ke.map((o) => [o, e.getPropertyValue(o).trim()]).filter(([, o]) => o)
335
+ );
336
+ }
337
+ function Ao(t) {
338
+ const e = getComputedStyle(t).getPropertyValue("--cntrl-article-width").trim();
339
+ if (!e) return t;
340
+ let o = t;
341
+ for (let r = o.parentElement; r && getComputedStyle(r).getPropertyValue("--cntrl-article-width").trim() === e; r = r.parentElement)
342
+ o = r;
343
+ return o;
344
+ }
345
+ const Eo = ["top", "right", "bottom", "left", "top-left", "top-right", "bottom-right", "bottom-left"], zo = ["right", "left"], No = ["top", "right", "bottom", "left"], Bo = ["right", "left"], To = 3;
346
+ function Gt(t, e, o) {
347
+ const { start: r, startHeight: i, handle: s, lines: l, measure: u, unitX: h, unitY: d } = e, n = (o.x - e.origin.x) / h, m = (o.y - e.origin.y) / d, k = { x: ue / h, y: ue / d }, y = V(t.grid), p = s ? ko(
348
+ r,
349
+ i,
350
+ s,
351
+ n,
352
+ m,
353
+ l,
354
+ k,
355
+ y,
356
+ u.height,
357
+ jt(t.grid),
358
+ { keepRatio: o.shiftKey, fromCenter: o.altKey }
359
+ ) : Mo(r, i, n, m, l, k, y, u.height, e.baseline);
360
+ return { ...e, pointer: o, placement: p.placement, guides: p.guides };
361
+ }
362
+ function de(t, e) {
363
+ return { ...e, heights: e.heights.map((o, r) => {
364
+ var i;
365
+ return ((i = t.placements[r]) == null ? void 0 : i.height) ?? o;
366
+ }) };
367
+ }
368
+ function Wo(t, e) {
369
+ return t.left === e.left && t.width === e.width && t.top === e.top && t.height === e.height;
370
+ }
371
+ function Fo(t) {
372
+ const o = document.createTreeWalker(t, NodeFilter.SHOW_TEXT, {
373
+ acceptNode: (s) => {
374
+ var l;
375
+ return (l = s.textContent) != null && l.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
376
+ }
377
+ }).nextNode();
378
+ if (!(o != null && o.parentNode)) return null;
379
+ const r = document.createElement("span");
380
+ r.style.cssText = "display:inline-block;width:0;height:0;margin:0;padding:0;border:0;vertical-align:baseline", o.parentNode.insertBefore(r, o);
381
+ const i = r.getBoundingClientRect().bottom;
382
+ return r.remove(), i - t.getBoundingClientRect().top;
383
+ }
384
+ const Do = {
385
+ leftRight: '<g fill="none" transform="translate(7 8)"><path fill-rule="evenodd" clip-rule="evenodd" d="m7 0v6.006h-1.021v-3.466l-5.979 5.472 5.979 5.461v-3.478h1.021v6.005h.02 3.961v-6.006h1.058v3.467l5.961-5.473-5.961-5.461v3.478h-1.058v-6.005z" fill="#fff"/><path d="m16.34 7.989-3.32-3.223v2.254h-3.02v-5.96h-.019v-.02h-1.941v6h-3.06v-2.28l-3.32 3.251 3.32 3.224v-2.254h3.06v6h.02 1.921.019v-6h3.02v2.259z" fill="#000"/></g>',
386
+ topBottom: '<g fill="none" transform="translate(8 7)"><path fill-rule="evenodd" clip-rule="evenodd" d="m7.988 0-5.461 5.962h3.478v1.038h-6.005v.019 3.942.02h6.005v1.058h-3.466l5.472 5.961 5.462-5.961h-3.478v-1.058h6.005v-3.981h-6.006v-1.038h3.467z" fill="#fff"/><path d="m14.961 8.02h-5.981v-3.039h2.26l-3.251-3.32-3.223 3.32h2.254v3.039h-5.98-.02v1.96h.02 6v3.04h-2.28l3.251 3.32 3.223-3.32h-2.253v-3.04h5.98.02v-1.96z" fill="#000"/></g>',
387
+ diagonalRight: '<g fill="none" transform="translate(9 9)"><path fill-rule="evenodd" clip-rule="evenodd" d="m9.743 7.087-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z" fill="#fff"/><path d="m8.683 6.733-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z" fill="#000"/></g>',
388
+ diagonalLeft: '<g fill="none" transform="translate(9 9)"><path fill-rule="evenodd" clip-rule="evenodd" d="m4.257 7.087 4.072 4.068-2.829 2.828 8.473-.013.013-8.47-2.841 2.842-4.075-4.068-1.414-1.415 2.844-2.842h-8.486v8.484l2.829-2.827z" fill="#fff"/><path d="m5.317 6.733 4.427 4.424-1.828 1.828 5.056-.016.014-5.054-1.842 1.841-4.428-4.422-2.474-2.475 1.844-1.843h-5.073v5.071l1.83-1.828z" fill="#000"/></g>'
389
+ }, Oo = { leftRight: "ew-resize", topBottom: "ns-resize", diagonalRight: "nesw-resize", diagonalLeft: "nwse-resize" }, Z = Object.fromEntries(Object.entries(Do).map(([t, e]) => {
390
+ const o = `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">${e}</svg>`;
391
+ return [t, `url("data:image/svg+xml,${encodeURIComponent(o)}") 16 16, ${Oo[t]}`];
392
+ })), pe = 40;
393
+ function fe(t, e) {
394
+ return e.handle ? go(t, e.index, e.placement, e.measure) : mo(t, e.index, e.placement.left, e.placement.top, e.measure);
395
+ }
396
+ function Go(t) {
397
+ return `
398
+ /* the element is the trigger alone, placed and sized on the page as any other element; the popup opens over the page */
399
+ .${t}-root {
400
+ position: relative;
401
+ width: 100%;
402
+ height: 100%;
403
+ box-sizing: border-box;
404
+ }
405
+ /* fills the element's box, its icon or text centred in it inside its padding */
406
+ .${t}-button {
407
+ all: unset;
408
+ box-sizing: border-box;
409
+ display: flex;
410
+ align-items: center;
411
+ justify-content: center;
412
+ width: 100%;
413
+ height: 100%;
414
+ cursor: pointer;
415
+ white-space: nowrap;
416
+ color: var(--${t}-trigger-color);
417
+ background-color: var(--${t}-trigger-bg);
418
+ }
419
+ /* an icon trigger's lines, as thick as a twelfth of it and a pixel at least, drawn in the trigger's colour */
420
+ .${t}-icon {
421
+ position: relative;
422
+ display: block;
423
+ flex: none;
424
+ width: var(--${t}-icon-size);
425
+ height: var(--${t}-icon-size);
426
+ --${t}-icon-stroke: max(1px, calc(var(--${t}-icon-size) / 12));
427
+ transition: transform ${ot}ms ease;
428
+ }
429
+ .${t}-icon-line {
430
+ position: absolute;
431
+ left: 0;
432
+ width: 100%;
433
+ height: var(--${t}-icon-stroke);
434
+ top: calc(50% - var(--${t}-icon-stroke) / 2);
435
+ background-color: currentColor;
436
+ transition: transform ${ot}ms ease, opacity ${ot}ms ease;
437
+ }
438
+ /* three lines, the outer two meeting in the middle and crossing as the popup opens, the middle one fading */
439
+ .${t}-icon-burger .${t}-icon-line:nth-child(1) { transform: translateY(calc(var(--${t}-icon-size) * -0.3)) rotate(0deg) scaleX(1); }
440
+ .${t}-icon-burger .${t}-icon-line:nth-child(3) { transform: translateY(calc(var(--${t}-icon-size) * 0.3)) rotate(0deg) scaleX(1); }
441
+ .${t}-button-open .${t}-icon-burger .${t}-icon-line:nth-child(1) { transform: translateY(0) rotate(45deg) scaleX(1); }
442
+ .${t}-button-open .${t}-icon-burger .${t}-icon-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
443
+ .${t}-button-open .${t}-icon-burger .${t}-icon-line:nth-child(3) { transform: translateY(0) rotate(-45deg) scaleX(1); }
444
+ /* a plus, turned an eighth as the popup opens, into a cross */
445
+ .${t}-icon-plus .${t}-icon-line:nth-child(2) { transform: rotate(90deg); }
446
+ .${t}-button-open .${t}-icon-plus { transform: rotate(45deg); }
447
+ /* the user's image, fitted to the icon's size: an SVG tinted with the trigger's colour, anything else as it is */
448
+ .${t}-icon-picture {
449
+ display: block;
450
+ width: 100%;
451
+ height: 100%;
452
+ }
453
+ @media (prefers-reduced-motion: reduce) {
454
+ .${t}-icon,
455
+ .${t}-icon-line {
456
+ transition: none;
457
+ }
458
+ }
459
+ .${t}-button:focus-visible {
460
+ outline: 1px solid currentColor;
461
+ outline-offset: 2px;
462
+ }
463
+ /* the popup opens over the whole screen, out of the element's box (it is portalled out of it); in the editor, over
464
+ the whole article as it is drawn on the canvas */
465
+ .${t}-overlay {
466
+ position: fixed;
467
+ inset: 0;
468
+ z-index: 9997;
469
+ pointer-events: none;
470
+ overflow: hidden;
471
+ }
472
+ .${t}-overlay-editor {
473
+ inset: auto;
474
+ top: var(--cntrl-article-top, 0);
475
+ left: var(--cntrl-article-left, 0);
476
+ width: var(--cntrl-article-width, 100vw);
477
+ height: var(--cntrl-viewport-height, 100vh);
478
+ }
479
+ .${t}-overlay-active {
480
+ pointer-events: auto;
481
+ }
482
+ /* the trigger drawn again over the popup, where it is on the page, so that its cross shows above the popup and closes
483
+ it; the page's own trigger, under the overlay, is hidden meanwhile */
484
+ .${t}-overlay .${t}-close {
485
+ position: absolute;
486
+ z-index: 1;
487
+ }
488
+ /* on the canvas, where the popup is pinned open, it lets the blocks under it be taken */
489
+ .${t}-overlay .${t}-close-inert {
490
+ pointer-events: none;
491
+ }
492
+ .${t}-button-hidden {
493
+ opacity: 0;
494
+ }
495
+ .${t}-backdrop {
496
+ all: unset;
497
+ position: absolute;
498
+ inset: 0;
499
+ background-color: var(--${t}-overlay-color);
500
+ /* the page behind blurred, the blur fading in and out with the overlay's colour */
501
+ -webkit-backdrop-filter: var(--${t}-overlay-blur, none);
502
+ backdrop-filter: var(--${t}-overlay-blur, none);
503
+ opacity: 0;
504
+ transition: opacity ${ot}ms ease;
505
+ }
506
+ .${t}-card {
507
+ position: absolute;
508
+ box-sizing: border-box;
509
+ /* content reaching below the popup's bottom scrolls, within the popup alone */
510
+ overflow-x: hidden;
511
+ overflow-y: auto;
512
+ overscroll-behavior: contain;
513
+ background-color: var(--${t}-popup-bg);
514
+ opacity: 0;
515
+ transition: opacity ${ot}ms ease, transform ${ot}ms ease;
516
+ }
517
+ /* where the popup comes in from and goes back to, by its transition; it fades in and out with each, and 'none'
518
+ shows and hides the popup and its overlay at once */
519
+ .${t}-transition-slide-down .${t}-card {
520
+ transform: translateY(24px);
521
+ }
522
+ .${t}-transition-slide-up .${t}-card {
523
+ transform: translateY(-24px);
524
+ }
525
+ .${t}-transition-scale .${t}-card {
526
+ transform: scale(0.95);
527
+ }
528
+ .${t}-transition-none .${t}-backdrop,
529
+ .${t}-transition-none .${t}-card {
530
+ transition: none;
531
+ }
532
+ @media (prefers-reduced-motion: reduce) {
533
+ .${t}-overlay .${t}-card {
534
+ transform: none;
535
+ }
536
+ }
537
+ .${t}-overlay-active .${t}-backdrop,
538
+ .${t}-overlay-active .${t}-card {
539
+ opacity: 1;
540
+ transform: none;
541
+ }
542
+ /* one cell, which every block shares: its left and width a share of the grid's width, its top from a spacer above
543
+ it. The cell is as tall as the popup at least, and as tall as the lowest block reaches where that is further,
544
+ the popup scrolling down to it */
545
+ .${t}-grid {
546
+ position: relative;
547
+ display: grid;
548
+ grid-template-columns: minmax(0, 1fr);
549
+ grid-template-rows: auto;
550
+ min-height: 100%;
551
+ }
552
+ /* the lines a block being moved or resized has snapped to, as the article draws them */
553
+ .${t}-snaps {
554
+ position: absolute;
555
+ inset: 0;
556
+ z-index: 4;
557
+ pointer-events: none;
558
+ }
559
+ .${t}-snap {
560
+ position: absolute;
561
+ background-color: rgba(255, 48, 0, 0.7);
562
+ }
563
+ .${t}-snap-x {
564
+ top: 0;
565
+ bottom: 0;
566
+ width: 1px;
567
+ transform: translateX(-0.5px);
568
+ }
569
+ .${t}-snap-y {
570
+ left: 0;
571
+ right: 0;
572
+ height: 1px;
573
+ transform: translateY(-0.5px);
574
+ }
575
+ /* the grid the blocks snap to, drawn as the article's is while a block is moved or resized: a hairline at both
576
+ edges of every column, and one across every beat from the popup's top, or, with no beat, every vertical gap */
577
+ .${t}-guides {
578
+ position: absolute;
579
+ inset: 0;
580
+ z-index: 2;
581
+ display: grid;
582
+ grid-template-rows: minmax(0, 1fr);
583
+ pointer-events: none;
584
+ opacity: 0;
585
+ transition: opacity 200ms ease;
586
+ --${t}-guide-color: var(--cntrl-grid-color, rgba(255, 92, 2, 0.45));
587
+ }
588
+ .${t}-guides-shown {
589
+ opacity: 1;
590
+ }
591
+ .${t}-guides-beats {
592
+ background-image: repeating-linear-gradient(
593
+ to bottom,
594
+ var(--${t}-guide-color) 0 1px,
595
+ transparent 1px var(--${t}-beat)
596
+ );
597
+ }
598
+ .${t}-guide {
599
+ grid-row: 1;
600
+ box-shadow: inset 1px 0 var(--${t}-guide-color), inset -1px 0 var(--${t}-guide-color);
601
+ }
602
+ /* the block and, on the canvas, the handles it is resized by, which sit on its edges outside any scroller */
603
+ .${t}-frame {
604
+ position: relative;
605
+ display: flex;
606
+ flex-direction: column;
607
+ flex: none;
608
+ min-width: 0;
609
+ min-height: 0;
610
+ }
611
+ .${t}-slot {
612
+ display: flex;
613
+ flex-direction: column;
614
+ grid-area: 1 / 1;
615
+ min-width: 0;
616
+ min-height: 0;
617
+ pointer-events: none;
618
+ }
619
+ .${t}-spacer {
620
+ flex: none;
621
+ }
622
+ .${t}-block {
623
+ flex: none;
624
+ min-width: 0;
625
+ pointer-events: auto;
626
+ }
627
+ /* the text's box runs from the first line's cap height to the last line's baseline, where the browser can
628
+ trim it: a title lines up with the top of an image beside it, and the block is no taller than its text */
629
+ .${t}-block.${t}-block-text,
630
+ .${t}-block.${t}-block-listA,
631
+ .${t}-block.${t}-block-listB {
632
+ text-box: trim-both cap alphabetic;
633
+ }
634
+ .${t}-block-title {
635
+ color: var(--${t}-title-color);
636
+ }
637
+ .${t}-block-text {
638
+ color: var(--${t}-text-color);
639
+ }
640
+ .${t}-block-text a {
641
+ color: inherit;
642
+ }
643
+ .${t}-block-listA .${t}-block-text {
644
+ color: var(--${t}-list-a-color, var(--${t}-text-color));
645
+ }
646
+ .${t}-block-listB .${t}-block-text {
647
+ color: var(--${t}-list-b-color, var(--${t}-text-color));
648
+ }
649
+ .${t}-block-listA .${t}-block-text a,
650
+ .${t}-block-listB .${t}-block-text a {
651
+ text-decoration: none;
652
+ }
653
+ .${t}-block-listA .${t}-block-text a:hover,
654
+ .${t}-block-listB .${t}-block-text a:hover {
655
+ text-decoration: underline;
656
+ }
657
+ .${t}-images {
658
+ display: grid;
659
+ }
660
+ /* every image takes the same cell, so the block is as tall as its tallest image and keeps still as they change */
661
+ .${t}-image {
662
+ display: block;
663
+ grid-area: 1 / 1;
664
+ width: 100%;
665
+ height: auto;
666
+ object-fit: cover;
667
+ }
668
+ /* a block resized to a height: its images fill it, cut to it */
669
+ .${t}-block-sized .${t}-images {
670
+ height: 100%;
671
+ grid-template-rows: minmax(0, 100%);
672
+ }
673
+ .${t}-block-sized .${t}-image {
674
+ height: 100%;
675
+ }
676
+ .${t}-image {
677
+ transition: opacity 800ms ease-in-out;
678
+ }
679
+ .${t}-image-hidden {
680
+ opacity: 0;
681
+ }
682
+ @media (prefers-reduced-motion: reduce) {
683
+ .${t}-image {
684
+ transition: none;
685
+ }
686
+ }
687
+ .${t}-grid-editable .${t}-block {
688
+ cursor: default;
689
+ touch-action: none;
690
+ user-select: none;
691
+ }
692
+ .${t}-grid-editable .${t}-block * {
693
+ pointer-events: none;
694
+ }
695
+ .${t}-slot-dragged {
696
+ z-index: 1;
697
+ }
698
+ /* the editor's chrome, as an article's items have it: a 2px outline on the block the pointer is over, a hairline
699
+ border round the one selected, vermilion for text and grey for images, and the handles it is resized by */
700
+ .${t}-frame::before,
701
+ .${t}-box {
702
+ content: '';
703
+ position: absolute;
704
+ inset: 0;
705
+ z-index: 2;
706
+ box-sizing: border-box;
707
+ pointer-events: none;
708
+ }
709
+ .${t}-grid-editable:not(.${t}-grid-busy) .${t}-frame:not(.${t}-frame-selected):hover::before {
710
+ box-shadow: inset 0 0 0 1px #FF4400, 0 0 0 1px #FF4400;
711
+ }
712
+ .${t}-box {
713
+ border: 0.5px solid var(--${t}-box-color, #ACACAC);
714
+ }
715
+ .${t}-grid-editable .${t}-block-invalid {
716
+ opacity: 0.5;
717
+ }
718
+ .${t}-box-invalid {
719
+ border-style: dashed;
720
+ }
721
+ /* the side a handle reshapes the block by, as a structured block's: while its handle is pointed at or dragged, the
722
+ block's edge thickens to 5px out of a 1px line, and thins back after. A corner thickens both sides it moves */
723
+ .${t}-edge {
724
+ position: absolute;
725
+ z-index: 3;
726
+ background-color: #FF5C02;
727
+ pointer-events: none;
728
+ opacity: 0;
729
+ transition: opacity 0.15s ease, transform 0.15s ease;
730
+ }
731
+ .${t}-edge-left,
732
+ .${t}-edge-right {
733
+ top: 0;
734
+ bottom: 0;
735
+ width: 5px;
736
+ transform: scaleX(0.2);
737
+ }
738
+ .${t}-edge-left { left: -2.5px; }
739
+ .${t}-edge-right { right: -2.5px; }
740
+ .${t}-edge-top,
741
+ .${t}-edge-bottom {
742
+ left: 0;
743
+ right: 0;
744
+ height: 5px;
745
+ transform: scaleY(0.2);
746
+ }
747
+ .${t}-edge-top { top: -2.5px; }
748
+ .${t}-edge-bottom { bottom: -2.5px; }
749
+ .${t}-frame:has(> .${t}-handle-left:hover, > .${t}-handle-top-left:hover, > .${t}-handle-bottom-left:hover) > .${t}-edge-left,
750
+ .${t}-frame:has(> .${t}-handle-right:hover, > .${t}-handle-top-right:hover, > .${t}-handle-bottom-right:hover) > .${t}-edge-right,
751
+ .${t}-frame:has(> .${t}-handle-top:hover, > .${t}-handle-top-left:hover, > .${t}-handle-top-right:hover) > .${t}-edge-top,
752
+ .${t}-frame:has(> .${t}-handle-bottom:hover, > .${t}-handle-bottom-left:hover, > .${t}-handle-bottom-right:hover) > .${t}-edge-bottom,
753
+ .${t}-edge-shown {
754
+ opacity: 1;
755
+ transform: none;
756
+ }
757
+ @media (prefers-reduced-motion: reduce) {
758
+ .${t}-edge {
759
+ transition: none;
760
+ }
761
+ }
762
+ /* a handle is an 11px strip along an edge, or a 22px square on a corner, centred on it and drawn by the edge it
763
+ thickens alone; on a block under 40px, outside it, so that the block is still there to be taken */
764
+ .${t}-handle {
765
+ position: absolute;
766
+ z-index: 3;
767
+ pointer-events: auto;
768
+ touch-action: none;
769
+ }
770
+ .${t}-handle-left,
771
+ .${t}-handle-right {
772
+ top: 50%;
773
+ width: 11px;
774
+ height: max(0px, calc(100% - 22px));
775
+ }
776
+ .${t}-handle-top,
777
+ .${t}-handle-bottom {
778
+ left: 50%;
779
+ width: max(0px, calc(100% - 22px));
780
+ height: 11px;
781
+ }
782
+ .${t}-handle-top-left,
783
+ .${t}-handle-top-right,
784
+ .${t}-handle-bottom-right,
785
+ .${t}-handle-bottom-left {
786
+ width: 22px;
787
+ height: 22px;
788
+ }
789
+ .${t}-handle-right { right: 0; transform: translate(50%, -50%); cursor: ${Z.leftRight}; }
790
+ .${t}-handle-left { left: 0; transform: translate(-50%, -50%); cursor: ${Z.leftRight}; }
791
+ .${t}-handle-top { top: 0; transform: translate(-50%, -50%); cursor: ${Z.topBottom}; }
792
+ .${t}-handle-bottom { bottom: 0; transform: translate(-50%, 50%); cursor: ${Z.topBottom}; }
793
+ .${t}-handle-top-left { top: 0; left: 0; transform: translate(-50%, -50%); cursor: ${Z.diagonalLeft}; }
794
+ .${t}-handle-top-right { top: 0; right: 0; transform: translate(50%, -50%); cursor: ${Z.diagonalRight}; }
795
+ .${t}-handle-bottom-right { bottom: 0; right: 0; transform: translate(50%, 50%); cursor: ${Z.diagonalLeft}; }
796
+ .${t}-handle-bottom-left { bottom: 0; left: 0; transform: translate(-50%, 50%); cursor: ${Z.diagonalRight}; }
797
+ .${t}-handles-outer .${t}-handle-right { transform: translate(100%, -50%); }
798
+ .${t}-handles-outer .${t}-handle-left { transform: translate(-100%, -50%); }
799
+ .${t}-handles-outer .${t}-handle-top { transform: translate(-50%, -100%); }
800
+ .${t}-handles-outer .${t}-handle-bottom { transform: translate(-50%, 100%); }
801
+ .${t}-handles-outer .${t}-handle-top-left { transform: translate(-100%, -100%); }
802
+ .${t}-handles-outer .${t}-handle-top-right { transform: translate(100%, -100%); }
803
+ .${t}-handles-outer .${t}-handle-bottom-right { transform: translate(100%, 100%); }
804
+ .${t}-handles-outer .${t}-handle-bottom-left { transform: translate(-100%, 100%); }
805
+ `;
806
+ }
807
+ function vt(t, e, o, r) {
808
+ const i = (h) => t[`${e}${h}`] ?? (r ? t[`${r}${h}`] : void 0), s = (h) => {
809
+ const d = i(h);
810
+ return d === void 0 ? void 0 : me(d, o);
811
+ }, l = i("FontSettings"), u = i("TextAppearance");
812
+ return {
813
+ fontFamily: qe(i("FontFamily")),
814
+ fontWeight: l == null ? void 0 : l.fontWeight,
815
+ fontStyle: l == null ? void 0 : l.fontStyle,
816
+ fontSize: s("FontSize"),
817
+ lineHeight: s("LineHeight"),
818
+ letterSpacing: s("LetterSpacing"),
819
+ wordSpacing: s("WordSpacing"),
820
+ textTransform: u == null ? void 0 : u.textTransform,
821
+ textDecoration: u == null ? void 0 : u.textDecoration,
822
+ fontVariant: u == null ? void 0 : u.fontVariant
823
+ };
824
+ }
825
+ function Rt(t) {
826
+ const e = t.type ?? "text";
827
+ return e === "list" ? "listA" : e;
828
+ }
829
+ function Uo(t, e, o, r) {
830
+ return t != null && t.grid && Array.isArray(t.placements) && t.placements.every((i) => typeof (i == null ? void 0 : i.top) == "number") ? Ho(fo(lo(t), r), e) : ho(e.map(Rt), r, 1, o);
831
+ }
832
+ function Ho(t, e) {
833
+ const o = (r, i) => r.height !== void 0 && e[i] && Rt(e[i]) !== "image";
834
+ return t.placements.some(o) ? {
835
+ ...t,
836
+ placements: t.placements.map((r, i) => {
837
+ if (!o(r, i)) return r;
838
+ const { height: s, ...l } = r;
839
+ return l;
840
+ })
841
+ } : t;
842
+ }
843
+ function Xo(t, e) {
844
+ const o = (r, i) => Math.abs(r - i) < 1e-4;
845
+ return o(t.height, e.height) && t.heights.length === e.heights.length && t.heights.every((r, i) => o(r, e.heights[i]));
846
+ }
847
+ function Ut(t, e) {
848
+ const o = t.placements[e];
849
+ if (!o) return ao(t.grid);
850
+ const r = V(t.grid), i = Math.min(o.width, r), s = { left: Math.min(Math.max(0, o.left), r - i), width: i, top: o.top };
851
+ return typeof o.height == "number" ? { ...s, height: o.height } : s;
852
+ }
853
+ function jo({
854
+ settings: t,
855
+ content: e = [],
856
+ isEditor: o,
857
+ isEditMode: r,
858
+ isPreviewMode: i,
859
+ portalId: s,
860
+ currentState: l,
861
+ unavailableStates: u = [],
862
+ onOpenChange: h,
863
+ onUpdateSettings: d
864
+ }) {
865
+ var se, le;
866
+ const { prefix: n } = je(), m = bt(() => Go(n), [n]), [k, y] = H(!1), [p, g] = H(!1), [L, T] = H(!1), x = !!(o && !i), E = x && l === "open" && !u.includes("open"), v = E || !x && k, S = Ro(t);
867
+ Ke(v && !x), Y(() => {
868
+ h == null || h(v);
869
+ }, [v, h]), Y(() => {
870
+ if (v) {
871
+ g(!0);
872
+ return;
873
+ }
874
+ T(!1);
875
+ const a = window.setTimeout(() => g(!1), S === "none" ? 0 : ot);
876
+ return () => window.clearTimeout(a);
877
+ }, [v, S]), Y(() => {
878
+ if (!v || !p) return;
879
+ const a = pt.current;
880
+ a && getComputedStyle(a.querySelector("[role=dialog]") ?? a).opacity;
881
+ const c = requestAnimationFrame(() => T(!0));
882
+ return () => cancelAnimationFrame(c);
883
+ }, [v, p]), Y(() => {
884
+ if (!v || x) return;
885
+ const a = (c) => {
886
+ c.key === "Escape" && y(!1);
887
+ };
888
+ return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
889
+ }, [v, x]);
890
+ const $ = (a) => me(a ?? 0, o), _ = oo(t), z = (se = t.menuLayout) == null ? void 0 : se.grid, J = eo(t, z != null && z.columnWidth ? z : ge), K = `min(100%, ${$(ro(t, J))})`, Q = $(t.popupOffset), yt = {
891
+ left: `calc(0px + ${Q})`,
892
+ center: `calc((100% - ${K}) / 2 + ${Q})`,
893
+ right: `calc(100% - ${K} + ${Q})`
894
+ }[no(t)], { columns: ct, columnWidth: ht, gutter: M, rowGap: O } = J, D = bt(
895
+ () => ({ columns: ct, columnWidth: ht, gutter: M, rowGap: O }),
896
+ [ct, ht, M, O]
897
+ ), [rt, W] = H(null), Yt = rt && rt.from === t.menuLayout ? rt.layout : t.menuLayout;
898
+ Y(() => {
899
+ W((a) => a && a.from !== t.menuLayout ? null : a);
900
+ }, [t.menuLayout]);
901
+ const ut = bt(
902
+ () => Uo(Yt, e, _, D),
903
+ [Yt, e, _, D]
904
+ ), [Lt, Se] = H(null), it = bt(() => Lt ? de(ut, Lt) : null, [ut, Lt]), N = bt(() => it ? $o(ut, it) : ut, [ut, it]), { columns: dt, gutter: _t, columnWidth: At } = N.grid, Ce = dt * At + (dt - 1) * _t, wt = At > 0 ? {
905
+ gridTemplateColumns: `repeat(${dt}, minmax(0, ${$(At)}))`,
906
+ columnGap: $(_t),
907
+ width: `min(100%, ${$(Ce)})`,
908
+ marginInline: "auto"
909
+ } : { gridTemplateColumns: `repeat(${dt}, minmax(0, 1fr))`, columnGap: $(_t) }, Re = { width: wt.width, marginInline: wt.marginInline }, Vt = V(N.grid), Et = (a) => `${a / (Vt || 1) * 100}%`, Kt = t.triggerLabel || "Menu", Mt = io(t.triggerPadding), at = t.triggerType === "icon" && !t.triggerIcon ? "burger" : t.triggerType ?? "text", Ie = vt(t, "trigger", o), Le = vt(t, "title", o), _e = {
910
+ text: vt(t, "text", o),
911
+ listA: vt(t, "listA", o, "text"),
912
+ listB: vt(t, "listB", o, "text")
913
+ }, P = ((le = t.stateOverrides) == null ? void 0 : le.open) ?? {}, qt = {
914
+ [`--${n}-trigger-bg`]: t.barBackgroundColor,
915
+ [`--${n}-trigger-color`]: (v ? P.triggerColor : void 0) ?? t.triggerColor,
916
+ [`--${n}-overlay-color`]: P.overlayColor ?? t.overlayColor,
917
+ [`--${n}-overlay-blur`]: t.overlayBlur ? `blur(${$(t.overlayBlur)})` : void 0,
918
+ [`--${n}-popup-bg`]: P.popupBackgroundColor ?? t.popupBackgroundColor,
919
+ [`--${n}-title-color`]: P.titleColor ?? t.titleColor,
920
+ [`--${n}-text-color`]: P.textColor ?? t.textColor,
921
+ [`--${n}-list-a-color`]: P.listAColor ?? t.listAColor,
922
+ [`--${n}-list-b-color`]: P.listBColor ?? t.listBColor
923
+ }, Zt = X(null), [Ae, Jt] = H(void 0);
924
+ Ot(() => {
925
+ const a = Zt.current;
926
+ if (!p || !o || !a) {
927
+ Jt(void 0);
928
+ return;
929
+ }
930
+ const c = () => Jt((R) => {
931
+ const B = _o(a);
932
+ return R && ke.every((w) => R[w] === B[w]) ? R : B;
933
+ });
934
+ if (c(), typeof ResizeObserver > "u") return;
935
+ const f = new ResizeObserver(c);
936
+ f.observe(a);
937
+ const C = new MutationObserver(c), b = Ao(a);
938
+ return b !== a && (f.observe(b), C.observe(b, { attributes: !0, attributeFilter: ["style"] })), () => {
939
+ f.disconnect(), C.disconnect();
940
+ };
941
+ }, [p, o]);
942
+ const pt = X(null), Qt = X(null), Pt = X(null), zt = X(null), ft = X([]), [F, Ee] = H(null), mt = X(null), st = (a) => {
943
+ mt.current = a, Ee(a);
944
+ }, tt = X(null), j = !!(E && r && d), ze = F ? fe(N, F) : null, [Nt, Bt] = H(null), Ne = j && Nt !== null && Nt < e.length ? Nt : null, [Tt, Be] = H(0);
945
+ Y(() => {
946
+ j || (tt.current = null, st(null), Bt(null), W(null));
947
+ }, [j]);
948
+ const [Wt, te] = H(null);
949
+ Ot(() => {
950
+ const a = Qt.current;
951
+ if (!p || !a) {
952
+ te(null);
953
+ return;
954
+ }
955
+ const c = () => {
956
+ const C = pt.current;
957
+ if (!C) return;
958
+ const b = C.getBoundingClientRect(), R = a.getBoundingClientRect(), B = { top: R.top - b.top, left: R.left - b.left, width: R.width, height: R.height };
959
+ te((w) => w && w.top === B.top && w.left === B.left && w.width === B.width && w.height === B.height ? w : B);
960
+ };
961
+ c();
962
+ const f = new ResizeObserver(c);
963
+ return f.observe(a), window.addEventListener("resize", c), window.addEventListener("scroll", c, { capture: !0, passive: !0 }), () => {
964
+ f.disconnect(), window.removeEventListener("resize", c), window.removeEventListener("scroll", c, { capture: !0 });
965
+ };
966
+ }, [p]), Ot(() => {
967
+ const a = Pt.current, c = zt.current;
968
+ if (!p || !a || !c) return;
969
+ const f = () => {
970
+ var B;
971
+ const b = (B = pt.current) == null ? void 0 : B.getBoundingClientRect().width;
972
+ if (!b) return;
973
+ const R = {
974
+ height: a.getBoundingClientRect().height / b,
975
+ heights: e.map((w, lt) => {
976
+ var q;
977
+ return (((q = ft.current[lt]) == null ? void 0 : q.getBoundingClientRect().height) ?? 0) / b;
978
+ })
979
+ };
980
+ Se((w) => w && Xo(w, R) ? w : R), Be(b);
981
+ };
982
+ f();
983
+ const C = new ResizeObserver(f);
984
+ return C.observe(a), C.observe(c), ft.current.slice(0, e.length).forEach((b) => b && C.observe(b)), () => C.disconnect();
985
+ }, [p, e]);
986
+ const Te = (a, c, f) => {
987
+ !j || !N.placements[c] || a.button !== 0 || (a.preventDefault(), a.stopPropagation(), a.currentTarget.setPointerCapture(a.pointerId), tt.current = { index: c, handle: f, pointerId: a.pointerId, origin: { x: a.clientX, y: a.clientY } }, Bt(c));
988
+ }, We = ({ index: a, handle: c, pointerId: f, origin: C }, b) => {
989
+ var St;
990
+ const R = zt.current;
991
+ if (!R || !N.placements[a]) return null;
992
+ const B = R.getBoundingClientRect(), w = ((St = pt.current) == null ? void 0 : St.getBoundingClientRect().width) || 1, lt = B.width / (Vt || 1) || w, q = Ut(N, a), gt = de(N, {
993
+ height: B.height / w,
994
+ heights: e.map(($t, A) => {
995
+ var G;
996
+ return (((G = ft.current[A]) == null ? void 0 : G.getBoundingClientRect().height) ?? 0) / w;
997
+ })
998
+ }), kt = e.map(($t, A) => {
999
+ const G = ft.current[A];
1000
+ if (!G || Rt($t) === "image") return null;
1001
+ const ce = Fo(G);
1002
+ return ce === null ? null : ce / w;
1003
+ });
1004
+ return Gt(N, {
1005
+ index: a,
1006
+ pointerId: f,
1007
+ handle: c,
1008
+ origin: C,
1009
+ unitX: lt,
1010
+ unitY: w,
1011
+ start: q,
1012
+ startHeight: q.height ?? gt.heights[a] ?? 0,
1013
+ placement: q,
1014
+ measure: gt,
1015
+ baseline: kt[a] ?? null,
1016
+ lines: yo(N, a, gt, kt),
1017
+ guides: { xs: [], ys: [] },
1018
+ pointer: b
1019
+ }, b);
1020
+ }, Fe = (a) => {
1021
+ const c = { x: a.clientX, y: a.clientY, shiftKey: a.shiftKey, altKey: a.altKey }, f = mt.current;
1022
+ if (f) {
1023
+ if (a.pointerId !== f.pointerId) return;
1024
+ a.stopPropagation(), st(Gt(N, f, c));
1025
+ return;
1026
+ }
1027
+ const C = tt.current;
1028
+ if (!C || a.pointerId !== C.pointerId || (a.stopPropagation(), Math.hypot(c.x - C.origin.x, c.y - C.origin.y) < To)) return;
1029
+ tt.current = null;
1030
+ const b = We(C, c);
1031
+ b && st(b);
1032
+ }, De = () => {
1033
+ tt.current = null, st(null);
1034
+ }, ee = X(() => {
1035
+ });
1036
+ ee.current = (a) => {
1037
+ const c = mt.current;
1038
+ c != null && c.handle && st(Gt(N, c, a));
1039
+ };
1040
+ const oe = !!F;
1041
+ Y(() => {
1042
+ if (!oe) return;
1043
+ const a = (c) => {
1044
+ if (c.key !== "Shift" && c.key !== "Alt") return;
1045
+ const f = mt.current;
1046
+ f != null && f.handle && (c.preventDefault(), ee.current({ ...f.pointer, shiftKey: c.shiftKey, altKey: c.altKey }));
1047
+ };
1048
+ return window.addEventListener("keydown", a), window.addEventListener("keyup", a), () => {
1049
+ window.removeEventListener("keydown", a), window.removeEventListener("keyup", a);
1050
+ };
1051
+ }, [oe]);
1052
+ const Oe = (a) => {
1053
+ var b;
1054
+ if (((b = tt.current) == null ? void 0 : b.pointerId) === a.pointerId) {
1055
+ a.stopPropagation(), tt.current = null;
1056
+ return;
1057
+ }
1058
+ const c = mt.current;
1059
+ if (!c || a.pointerId !== c.pointerId) return;
1060
+ a.stopPropagation();
1061
+ const f = fe(N, c), C = f == null ? void 0 : f.placements[c.index];
1062
+ f && C && !Wo(C, Ut(N, c.index)) && ne(f), st(null);
1063
+ }, ne = (a) => {
1064
+ W({ layout: a, from: t.menuLayout }), d == null || d({ ...t, menuLayout: a });
1065
+ }, Ge = (a, c) => {
1066
+ a.stopPropagation();
1067
+ const f = N.placements[c];
1068
+ if (!j || !f || f.height === void 0) return;
1069
+ const { height: C, ...b } = f;
1070
+ ne({ ...N, edited: !0, placements: N.placements.map((R, B) => B === c ? b : R) });
1071
+ }, Ft = () => y(!1), Ue = (a) => {
1072
+ !x && a.target.closest("a") && Ft();
1073
+ }, He = (a, c) => {
1074
+ const f = Rt(a), C = (a.images ?? []).filter((A) => A == null ? void 0 : A.assetId), b = (F == null ? void 0 : F.index) === c, R = b ? F.placement : Ut(N, c), B = R.height !== void 0, w = Ne === c, lt = b && !ze, q = f === "image" ? Eo : zo, gt = (R.height ?? (it == null ? void 0 : it.heights[c]) ?? 0) * Tt, kt = R.width * Tt, St = Tt > 0 && (kt < pe || f === "image" && gt < pe), $t = (A) => ({
1075
+ onPointerDown: (G) => Te(G, c, A),
1076
+ onPointerMove: Fe,
1077
+ onPointerUp: Oe,
1078
+ onPointerCancel: De
1079
+ });
1080
+ return /* @__PURE__ */ et(
1081
+ "div",
1082
+ {
1083
+ className: `${n}-slot${b ? ` ${n}-slot-dragged` : ""}`,
1084
+ style: { marginLeft: Et(R.left), width: Et(R.width) },
1085
+ children: [
1086
+ /* @__PURE__ */ I("div", { className: `${n}-spacer`, style: { height: $(R.top) } }),
1087
+ /* @__PURE__ */ et(
1088
+ "div",
1089
+ {
1090
+ className: [
1091
+ `${n}-frame`,
1092
+ w ? `${n}-frame-selected` : "",
1093
+ w && St ? `${n}-handles-outer` : ""
1094
+ ].filter(Boolean).join(" "),
1095
+ children: [
1096
+ /* @__PURE__ */ et(
1097
+ "div",
1098
+ {
1099
+ ref: (A) => {
1100
+ ft.current[c] = A;
1101
+ },
1102
+ className: [
1103
+ `${n}-block ${n}-block-${f}`,
1104
+ B ? `${n}-block-sized` : "",
1105
+ b ? `${n}-block-dragged` : "",
1106
+ lt ? `${n}-block-invalid` : ""
1107
+ ].filter(Boolean).join(" "),
1108
+ style: B ? { height: $(R.height) } : void 0,
1109
+ ...j ? $t(null) : {},
1110
+ children: [
1111
+ a.title && f !== "image" ? /* @__PURE__ */ I("div", { className: `${n}-block-title`, style: { ...Le, marginBottom: $(t.titleGap) }, children: a.title }) : null,
1112
+ f === "image" ? /* @__PURE__ */ I(Vo, { prefix: n, images: C, isRunning: v, radius: $(t.imageRadius) }) : /* @__PURE__ */ I("div", { className: `${n}-block-text`, style: _e[f], children: /* @__PURE__ */ I(Ze, { content: Array.isArray(a.text) ? a.text : [] }) })
1113
+ ]
1114
+ }
1115
+ ),
1116
+ w ? /* @__PURE__ */ I(
1117
+ "div",
1118
+ {
1119
+ className: `${n}-box${lt ? ` ${n}-box-invalid` : ""}`,
1120
+ style: { [`--${n}-box-color`]: f === "image" ? "#ACACAC" : "#FF4400" },
1121
+ "aria-hidden": !0
1122
+ }
1123
+ ) : null,
1124
+ w ? (f === "image" ? No : Bo).map((A) => {
1125
+ var G;
1126
+ return /* @__PURE__ */ I(
1127
+ "div",
1128
+ {
1129
+ className: `${n}-edge ${n}-edge-${A}${b && ((G = F.handle) != null && G.includes(A)) ? ` ${n}-edge-shown` : ""}`,
1130
+ "aria-hidden": !0
1131
+ },
1132
+ A
1133
+ );
1134
+ }) : null,
1135
+ w ? q.map((A) => /* @__PURE__ */ I(
1136
+ "div",
1137
+ {
1138
+ className: `${n}-handle ${n}-handle-${A}`,
1139
+ "aria-hidden": !0,
1140
+ ...$t(A),
1141
+ onDoubleClick: A.includes("top") || A.includes("bottom") ? (G) => Ge(G, c) : void 0
1142
+ },
1143
+ A
1144
+ )) : null
1145
+ ]
1146
+ }
1147
+ )
1148
+ ]
1149
+ },
1150
+ c
1151
+ );
1152
+ }, re = {
1153
+ ...at === "text" ? Ie : void 0,
1154
+ padding: [Mt.top, Mt.right, Mt.bottom, Mt.left].map((a) => $(a)).join(" "),
1155
+ [`--${n}-icon-size`]: $(t.triggerIconSize ?? Lo)
1156
+ }, ie = at === "text" ? Kt : /* @__PURE__ */ I("span", { className: `${n}-icon ${n}-icon-${at}`, "aria-hidden": !0, children: at === "icon" ? /* @__PURE__ */ I(
1157
+ Je,
1158
+ {
1159
+ url: t.triggerIcon,
1160
+ fill: `var(--${n}-trigger-color)`,
1161
+ hoverFill: `var(--${n}-trigger-color)`,
1162
+ className: `${n}-icon-picture`
1163
+ }
1164
+ ) : Array.from({ length: at === "burger" ? 3 : 2 }, (a, c) => /* @__PURE__ */ I("span", { className: `${n}-icon-line` }, c)) }), Dt = N.grid.beat || nt(N.grid), ae = p ? /* @__PURE__ */ et(
1165
+ "div",
1166
+ {
1167
+ ref: pt,
1168
+ "data-selection": "none",
1169
+ className: [`${n}-overlay`, `${n}-transition-${S.replace(" ", "-")}`, o ? `${n}-overlay-editor` : "", L ? `${n}-overlay-active` : ""].filter(Boolean).join(" "),
1170
+ style: { ...Ae, ...qt },
1171
+ "aria-hidden": !L,
1172
+ onPointerDown: j ? (a) => {
1173
+ a.target.closest(`.${n}-frame`) || Bt(null);
1174
+ } : void 0,
1175
+ children: [
1176
+ /* @__PURE__ */ I(
1177
+ "button",
1178
+ {
1179
+ type: "button",
1180
+ className: `${n}-backdrop`,
1181
+ "aria-label": "Close menu",
1182
+ tabIndex: -1,
1183
+ onClick: x ? void 0 : Ft
1184
+ }
1185
+ ),
1186
+ /* @__PURE__ */ I(
1187
+ "div",
1188
+ {
1189
+ ref: Pt,
1190
+ className: `${n}-card`,
1191
+ role: "dialog",
1192
+ "aria-modal": "true",
1193
+ "aria-label": t.triggerLabel || "Menu",
1194
+ onClick: Ue,
1195
+ style: {
1196
+ top: $(t.popupOffsetTop),
1197
+ height: `${$e(t)}%`,
1198
+ left: yt,
1199
+ width: K,
1200
+ borderRadius: $(t.popupRadius)
1201
+ },
1202
+ children: /* @__PURE__ */ et(
1203
+ "div",
1204
+ {
1205
+ ref: zt,
1206
+ className: `${n}-grid${j ? ` ${n}-grid-editable` : ""}${F ? ` ${n}-grid-busy` : ""}`,
1207
+ style: Re,
1208
+ children: [
1209
+ e.map(He),
1210
+ F && (F.guides.xs.length > 0 || F.guides.ys.length > 0) ? /* @__PURE__ */ et("div", { className: `${n}-snaps`, "aria-hidden": !0, children: [
1211
+ F.guides.xs.map((a) => /* @__PURE__ */ I("div", { className: `${n}-snap ${n}-snap-x`, style: { left: Et(a) } }, `x${a}`)),
1212
+ F.guides.ys.map((a) => /* @__PURE__ */ I("div", { className: `${n}-snap ${n}-snap-y`, style: { top: $(a) } }, `y${a}`))
1213
+ ] }) : null,
1214
+ j ? /* @__PURE__ */ I(
1215
+ "div",
1216
+ {
1217
+ className: `${n}-guides${Dt > 0 ? ` ${n}-guides-beats` : ""}${F ? ` ${n}-guides-shown` : ""}`,
1218
+ style: {
1219
+ gridTemplateColumns: wt.gridTemplateColumns,
1220
+ columnGap: wt.columnGap,
1221
+ [`--${n}-beat`]: Dt > 0 ? $(Dt) : void 0
1222
+ },
1223
+ "aria-hidden": !0,
1224
+ children: Array.from({ length: dt }, (a, c) => /* @__PURE__ */ I("div", { className: `${n}-guide` }, c))
1225
+ }
1226
+ ) : null
1227
+ ]
1228
+ }
1229
+ )
1230
+ }
1231
+ ),
1232
+ Wt ? /* @__PURE__ */ I(
1233
+ "button",
1234
+ {
1235
+ type: "button",
1236
+ className: [
1237
+ `${n}-button ${n}-close`,
1238
+ L ? `${n}-button-open` : "",
1239
+ x ? `${n}-close-inert` : ""
1240
+ ].filter(Boolean).join(" "),
1241
+ style: { ...re, ...Wt },
1242
+ "aria-label": "Close menu",
1243
+ "aria-expanded": v,
1244
+ tabIndex: L ? void 0 : -1,
1245
+ onClick: x ? void 0 : Ft,
1246
+ children: ie
1247
+ }
1248
+ ) : null
1249
+ ]
1250
+ }
1251
+ ) : null;
1252
+ return /* @__PURE__ */ et("div", { ref: Zt, className: `${n}-root`, style: qt, "data-edit-mode": r ? "" : void 0, children: [
1253
+ /* @__PURE__ */ I("style", { dangerouslySetInnerHTML: { __html: m } }),
1254
+ /* @__PURE__ */ I(
1255
+ "button",
1256
+ {
1257
+ ref: Qt,
1258
+ type: "button",
1259
+ className: [
1260
+ `${n}-button`,
1261
+ v ? `${n}-button-open` : "",
1262
+ // the close button over the popup stands in for it while the popup shows
1263
+ Wt ? `${n}-button-hidden` : ""
1264
+ ].filter(Boolean).join(" "),
1265
+ style: re,
1266
+ "aria-expanded": v,
1267
+ "aria-label": at === "text" ? void 0 : Kt,
1268
+ onClick: x ? void 0 : () => y((a) => !a),
1269
+ children: ie
1270
+ }
1271
+ ),
1272
+ ae && typeof document < "u" ? Xe(ae, (s ? document.getElementById(s) : null) ?? document.body) : null
1273
+ ] });
1274
+ }
1275
+ function Yo(t) {
1276
+ return t.type === "video" ? !0 : t.type ? !1 : /\.(mp4|webm|ogg|mov)(\?|$)/i.test(t.name || t.assetId);
1277
+ }
1278
+ function Vo({ prefix: t, images: e, isRunning: o, radius: r }) {
1279
+ const [i, s] = H(0), l = X([]), u = e.length;
1280
+ return Y(() => {
1281
+ if (!o || u < 2) {
1282
+ s(0);
1283
+ return;
1284
+ }
1285
+ const h = window.setInterval(() => s((d) => (d + 1) % u), So);
1286
+ return () => window.clearInterval(h);
1287
+ }, [o, u]), Y(() => {
1288
+ l.current.slice(0, u).forEach((h, d) => {
1289
+ var n;
1290
+ h && (o && d === i % u ? (n = h.play()) == null || n.catch(() => {
1291
+ }) : h.pause());
1292
+ });
1293
+ }, [o, i, u, e]), /* @__PURE__ */ I("div", { className: `${t}-images`, children: e.map((h, d) => {
1294
+ const n = d === i % u, m = `${t}-image${n ? "" : ` ${t}-image-hidden`}`, k = { borderRadius: r };
1295
+ return Ye(h) ? /* @__PURE__ */ I(
1296
+ Ve,
1297
+ {
1298
+ className: m,
1299
+ media: h,
1300
+ fit: "cover",
1301
+ lazy: !1,
1302
+ silentLoop: !0,
1303
+ "aria-hidden": !n,
1304
+ style: k
1305
+ },
1306
+ d
1307
+ ) : Yo(h) ? /* @__PURE__ */ I(
1308
+ "video",
1309
+ {
1310
+ ref: (y) => {
1311
+ l.current[d] = y;
1312
+ },
1313
+ className: m,
1314
+ src: h.assetId,
1315
+ autoPlay: o && n,
1316
+ muted: !0,
1317
+ loop: !0,
1318
+ playsInline: !0,
1319
+ "aria-hidden": !n,
1320
+ style: k
1321
+ },
1322
+ d
1323
+ ) : /* @__PURE__ */ I(
1324
+ "img",
1325
+ {
1326
+ className: m,
1327
+ src: h.assetId,
1328
+ alt: h.name ?? "",
1329
+ "aria-hidden": !n,
1330
+ style: k
1331
+ },
1332
+ d
1333
+ );
1334
+ }) });
1335
+ }
1336
+ const an = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1337
+ __proto__: null,
1338
+ POPUP_MENU_TRANSITIONS: Me,
1339
+ POPUP_MENU_TRIGGER_TYPES: Io,
1340
+ PopupMenu: jo
1341
+ }, Symbol.toStringTag, { value: "Module" }));
1342
+ export {
1343
+ an as A,
1344
+ Pe as D,
1345
+ to as P,
1346
+ uo as a,
1347
+ rn as b,
1348
+ oo as c,
1349
+ $e as d,
1350
+ ro as e,
1351
+ fo as f,
1352
+ ho as g,
1353
+ io as h,
1354
+ po as i,
1355
+ eo as j,
1356
+ ge as k,
1357
+ co as l,
1358
+ mo as m,
1359
+ Qe as n,
1360
+ ao as o,
1361
+ be as p,
1362
+ Ht as q,
1363
+ go as r,
1364
+ $o as s,
1365
+ Xt as t,
1366
+ V as u,
1367
+ lo as v,
1368
+ so as w,
1369
+ Me as x,
1370
+ Io as y,
1371
+ jo as z
1372
+ };