@cntrl-site/components 1.0.115-alpha.0 → 1.0.115-alpha.1

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.
@@ -1,11 +1,13 @@
1
1
  import { CommonComponentProps } from '../props';
2
+ import { EmbedMediaLike } from '../utils/embedMedia';
2
3
  import { PopupMenuAlign, PopupMenuBlockType, PopupMenuGridSettings, PopupMenuSidesSetting, PopupMenuLayout } from './popupMenuLayout';
3
4
  /** How the popup comes in as it opens and goes as it closes; the overlay behind it fades with it, but for 'none'. */
4
5
  export declare const POPUP_MENU_TRANSITIONS: readonly ["slide down", "slide up", "fade", "scale", "none"];
5
6
  export type PopupMenuTransition = (typeof POPUP_MENU_TRANSITIONS)[number];
6
7
  export declare const POPUP_MENU_TRIGGER_TYPES: readonly ["burger", "plus", "icon", "text"];
7
8
  export type PopupMenuTriggerType = (typeof POPUP_MENU_TRIGGER_TYPES)[number];
8
- type PopupMenuImage = {
9
+ /** An image, an uploaded video, or a Vimeo or YouTube one, as a media item holds it. */
10
+ type PopupMenuImage = EmbedMediaLike & {
9
11
  assetId: string;
10
12
  name?: string;
11
13
  };
@@ -28,6 +28,7 @@ export declare const PopupMenuComponent: {
28
28
  type: "array";
29
29
  settings: {
30
30
  addItemWithoutImage: true;
31
+ allowsVideo: true;
31
32
  };
32
33
  display: {
33
34
  type: string;
@@ -0,0 +1,369 @@
1
+ "use strict";const v=require("react/jsx-runtime"),f=require("react"),Re=require("react-dom"),qt=require("./scalingValue-CSHYgTZl.js"),Ie=require("./useScopedStyles-Bf6yohVQ.js"),Wt=require("./EmbedMediaFrame-DsOTKE4i.js"),Te=require("./useLightboxScrollLock-Hf16Eq4g.js"),Ee=require("./textStylesToCss-CNN3zZTV.js"),Le=require("./RichTextRenderer-DEFXh5o6.js"),Ne=require("./SvgImage-_QN8ngad.js"),Xt=60,Zt=900/1440,Kt=["left","center","right"],bt={columns:12,columnWidth:99/1440,gutter:20/1440};function Jt(t,e=bt){const o=c=>typeof c=="number"&&Number.isFinite(c),n=(c,...s)=>s.find(o)??c,r=t.gridLayout??{},u=Math.max(0,n(e.gutter,r.horizontalGap,t.gridGutter));return{columns:Math.max(1,Math.round(n(e.columns,r.columnsCount,t.gridColumns))),columnWidth:Math.max(0,n(e.columnWidth,r.entryWidth,t.gridColumnWidth)),gutter:u,rowGap:Math.max(0,n(u,t.verticalGap))}}function J(t){return t.rowGap??t.gutter}function vt(t){const e=t.popupHeight;return Math.min(100,Math.max(0,typeof e=="number"&&Number.isFinite(e)?e:Xt))}function Qt(t,e=Zt){return vt(t)/100*e}function Ae(t){return Kt.includes(t.popupAlign)?t.popupAlign:"center"}function Pt(t,e){var r;const o=(r=t.gridLayout)==null?void 0:r.wrapperWidth,n=e.columns*e.columnWidth+(e.columns-1)*e.gutter;return typeof o=="number"&&Number.isFinite(o)&&o>0?Math.max(o,n):n>0?n:1}function te(t){if(typeof t=="number")return{top:t,right:t,bottom:t,left:t};const e=o=>typeof o=="number"&&Number.isFinite(o)?Math.max(0,o):0;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)}}const ee={span:{text:{min:1/4,max:5/12},image:{min:1/6,max:1/3},listA:{min:1/6,max:1/4},listB:{min:1/6,max:1/4}},breakChance:.25};function oe(t,e,o,n,r=ee){const u=je(o),c=Math.max(1,Math.floor(e.columns)),s=[];let h=0,d=new Array(c).fill(!1);const g={};for(const T of t){const $=g[T]??(g[T]=Be(r.span[T]??r.span.text,c,u));let m=Ht(d,$);const y=d.some(Boolean);(m.length===0||y&&u()<r.breakChance)&&(h+=1,d=new Array(c).fill(!1),m=Ht(d,$));const N=m[Math.floor(u()*m.length)];for(let L=Math.max(0,N-1);L<Math.min(c,N+$+1);L++)d[L]=!0;s.push({column:N,span:$,row:h})}const a=h+1;return{seed:o,grid:{...e,columns:c},placements:s.map(({column:T,span:$,row:m})=>({column:T,span:$,top:H(e,m*n/a,n)}))}}function ze(){return Math.floor(Math.random()*2147483647)}function H(t,e,o=1/0){const n=t.beat??0,r=Math.max(0,o),u=n>0?Math.round(e/n)*n:e,c=u<=r?u:n>0?Math.floor(r/n+1e-9)*n:r;return Math.round(Math.max(0,c)*1e6)/1e6}function xt(t){return t.beat&&t.beat>0?t.beat:8/1440}function Q(t,e,o=1/0){const n=t.beat??0,r=xt(t),u=n>0?Math.round(e/n)*n:e,c=u<=o?u:n>0?Math.floor(o/n+1e-9)*n:o;return ie(Math.max(r,c))}function ne(t,e){const o=(n,r)=>Math.abs(n-r)<1e-9;return Math.floor(t.columns)===Math.floor(e.columns)&&o(t.columnWidth,e.columnWidth)&&o(t.gutter,e.gutter)&&o(J(t),J(e))&&o(t.beat??0,e.beat??0)}function re(t,e){const o={...e,columns:Math.max(1,Math.floor(e.columns))};if(ne(t.grid,o))return t;const n=Math.max(1,Math.floor(t.grid.columns)),r=o.columns,u=s=>n===r?s:Math.round(s*r/n),c=t.placements.map(s=>{const h=Math.min(r,Math.max(1,u(s.span))),d=Math.min(Math.max(0,u(s.column)),r-h),g=H(o,s.top);return s.height===void 0?{column:d,span:h,top:g}:{column:d,span:h,top:g,height:Q(o,s.height)}});return{...t,grid:o,placements:c}}function ie(t){return Math.round(t*1e6)/1e6}function ae(t,e,o,n,r){return t.column<o.column+o.span&&o.column<t.column+t.span&&t.top<o.top+n+r-1e-9&&o.top<t.top+e+r-1e-9}function le(t,e,o,n,r){const u=t.placements[e];return u?ce(t,e,{...u,column:o,top:n},r):null}function se(t,e,o,n){if(!t.placements[e])return null;const{columns:r}=t.grid,u=Math.min(Math.max(0,o.column),r-1),c=Math.min(Math.max(1,o.span),r-u),s=H(t.grid,o.top,n?n.height-xt(t.grid):1/0),h=o.height===void 0?void 0:Q(t.grid,o.height,n?n.height-s:1/0);return ce(t,e,h===void 0?{column:u,span:c,top:s}:{column:u,span:c,top:s,height:h},n)}function ce(t,e,o,n){const{columns:r}=t.grid,u=J(t.grid),c=Math.min(o.span,r);if(c<1||o.column<0||o.column+c>r)return null;const s=o.height??(n==null?void 0:n.heights[e])??0,h={column:o.column,span:c,top:H(t.grid,o.top,n?n.height-s:1/0),...o.height===void 0?{}:{height:o.height}};return n&&t.placements.some((d,g)=>g!==e&&ae(h,s,d,n.heights[g]??0,u))?null:{...t,edited:!0,placements:t.placements.map((d,g)=>g===e?h:d)}}function ue(t,e){const{columns:o}=t.grid,n=J(t.grid),r=t.grid.beat??0,u=e.height,c=t.placements.map(($,m)=>e.heights[m]??0),s=[...t.placements],h=s.map(($,m)=>m).sort(($,m)=>s[$].top-s[m].top||$-m),d=[],g=($,m)=>{let{top:y}=$;for(let N=!0,L=0;N&&L<=d.length;L++){N=!1;for(const A of d){const S=s[A];if(!ae({...$,top:y},m,S,c[A],n))continue;const E=S.top+c[A]+n,R=r>0?ie(Math.ceil(E/r-1e-9)*r):Math.ceil(E*1e6-1e-6)/1e6;R<=y||(y=R,N=!0)}}return y},a=($,m)=>$+m>u+1e-9;let T=!1;for(const $ of h){const m=s[$];let y={column:m.column,top:g(m,c[$])};if(y.top!==m.top&&a(y.top,c[$])){const N=Math.min(m.span,o),L=Array.from({length:Math.max(0,o-N+1)},(S,E)=>E).sort((S,E)=>Math.abs(S-m.column)-Math.abs(E-m.column)||S-E);let A=null;for(const S of L){const E=g({...m,column:S},c[$]);!a(E,c[$])&&(!A||E<A.top-1e-9)&&(A={column:S,top:E})}A&&(y=A)}(y.column!==m.column||y.top!==m.top)&&(s[$]={...s[$],...y},T=!0),d.push($)}return T?{...t,placements:s}:t}function Be(t,e,o){const n=Math.max(1,Math.round(t.min*e)),r=Math.max(n,Math.round(t.max*e));return Math.min(e,n+Math.floor(o()*(r-n+1)))}function Ht(t,e){const o=[];for(let n=0;n+e<=t.length;n++){let r=!0;for(let u=n;u<n+e;u++)if(t[u]){r=!1;break}r&&o.push(n)}return o}function je(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let o=e;return o=Math.imul(o^o>>>15,o|1),o^=o+Math.imul(o^o>>>7,o|61),((o^o>>>14)>>>0)/4294967296}}const W=300,Ge=3e3,Mt=["slide down","slide up","fade","scale","none"],Fe="slide down";function Oe(t){const e=t.popupTransition;return Mt.includes(e)?e:Fe}const he=["burger","plus","icon","text"],De=24/1440,Ue=["--cntrl-article-top","--cntrl-article-left","--cntrl-article-width","--cntrl-viewport-height"],We=["top","right","bottom","left","top-left","top-right","bottom-right","bottom-left"],He=["right","left"];function Vt(t,e){return{...e,heights:e.heights.map((o,n)=>{var r;return((r=t.placements[n])==null?void 0:r.height)??o})}}function Ve(t,e){return t.column===e.column&&t.span===e.span&&t.top===e.top&&t.height===e.height}function Yt(t,e){return e.handle?se(t,e.index,e.placement,e.measure):le(t,e.index,e.placement.column,e.placement.top,e.measure)}function Ye(t){return`
2
+ /* the element is the trigger alone, placed and sized on the page as any other element; the popup opens over the page */
3
+ .${t}-root {
4
+ position: relative;
5
+ width: 100%;
6
+ height: 100%;
7
+ box-sizing: border-box;
8
+ }
9
+ /* fills the element's box, its icon or text centred in it inside its padding */
10
+ .${t}-button {
11
+ all: unset;
12
+ box-sizing: border-box;
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ width: 100%;
17
+ height: 100%;
18
+ cursor: pointer;
19
+ white-space: nowrap;
20
+ color: var(--${t}-trigger-color);
21
+ background-color: var(--${t}-trigger-bg);
22
+ }
23
+ /* an icon trigger's lines, as thick as a twelfth of it and a pixel at least, drawn in the trigger's colour */
24
+ .${t}-icon {
25
+ position: relative;
26
+ display: block;
27
+ flex: none;
28
+ width: var(--${t}-icon-size);
29
+ height: var(--${t}-icon-size);
30
+ --${t}-icon-stroke: max(1px, calc(var(--${t}-icon-size) / 12));
31
+ transition: transform ${W}ms ease;
32
+ }
33
+ .${t}-icon-line {
34
+ position: absolute;
35
+ left: 0;
36
+ width: 100%;
37
+ height: var(--${t}-icon-stroke);
38
+ top: calc(50% - var(--${t}-icon-stroke) / 2);
39
+ background-color: currentColor;
40
+ transition: transform ${W}ms ease, opacity ${W}ms ease;
41
+ }
42
+ /* three lines, the outer two meeting in the middle and crossing as the popup opens, the middle one fading */
43
+ .${t}-icon-burger .${t}-icon-line:nth-child(1) { transform: translateY(calc(var(--${t}-icon-size) * -0.3)) rotate(0deg) scaleX(1); }
44
+ .${t}-icon-burger .${t}-icon-line:nth-child(3) { transform: translateY(calc(var(--${t}-icon-size) * 0.3)) rotate(0deg) scaleX(1); }
45
+ .${t}-button-open .${t}-icon-burger .${t}-icon-line:nth-child(1) { transform: translateY(0) rotate(45deg) scaleX(1); }
46
+ .${t}-button-open .${t}-icon-burger .${t}-icon-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
47
+ .${t}-button-open .${t}-icon-burger .${t}-icon-line:nth-child(3) { transform: translateY(0) rotate(-45deg) scaleX(1); }
48
+ /* a plus, turned an eighth as the popup opens, into a cross */
49
+ .${t}-icon-plus .${t}-icon-line:nth-child(2) { transform: rotate(90deg); }
50
+ .${t}-button-open .${t}-icon-plus { transform: rotate(45deg); }
51
+ /* the user's image, fitted to the icon's size: an SVG tinted with the trigger's colour, anything else as it is */
52
+ .${t}-icon-picture {
53
+ display: block;
54
+ width: 100%;
55
+ height: 100%;
56
+ }
57
+ @media (prefers-reduced-motion: reduce) {
58
+ .${t}-icon,
59
+ .${t}-icon-line {
60
+ transition: none;
61
+ }
62
+ }
63
+ .${t}-button:focus-visible {
64
+ outline: 1px solid currentColor;
65
+ outline-offset: 2px;
66
+ }
67
+ /* the popup opens over the whole screen, out of the element's box (it is portalled out of it); in the editor, over
68
+ the whole article as it is drawn on the canvas */
69
+ .${t}-overlay {
70
+ position: fixed;
71
+ inset: 0;
72
+ z-index: 9997;
73
+ pointer-events: none;
74
+ overflow: hidden;
75
+ }
76
+ .${t}-overlay-editor {
77
+ inset: auto;
78
+ top: var(--cntrl-article-top, 0);
79
+ left: var(--cntrl-article-left, 0);
80
+ width: var(--cntrl-article-width, 100vw);
81
+ height: var(--cntrl-viewport-height, 100vh);
82
+ }
83
+ .${t}-overlay-active {
84
+ pointer-events: auto;
85
+ }
86
+ /* the trigger drawn again over the popup, where it is on the page, so that its cross shows above the popup and closes
87
+ it; the page's own trigger, under the overlay, is hidden meanwhile */
88
+ .${t}-overlay .${t}-close {
89
+ position: absolute;
90
+ z-index: 1;
91
+ }
92
+ /* on the canvas, where the popup is pinned open, it lets the blocks under it be taken */
93
+ .${t}-overlay .${t}-close-inert {
94
+ pointer-events: none;
95
+ }
96
+ .${t}-button-hidden {
97
+ opacity: 0;
98
+ }
99
+ .${t}-backdrop {
100
+ all: unset;
101
+ position: absolute;
102
+ inset: 0;
103
+ background-color: var(--${t}-overlay-color);
104
+ /* the page behind blurred, the blur fading in and out with the overlay's colour */
105
+ -webkit-backdrop-filter: var(--${t}-overlay-blur, none);
106
+ backdrop-filter: var(--${t}-overlay-blur, none);
107
+ opacity: 0;
108
+ transition: opacity ${W}ms ease;
109
+ }
110
+ .${t}-card {
111
+ position: absolute;
112
+ box-sizing: border-box;
113
+ /* content reaching below the popup's bottom scrolls, within the popup alone */
114
+ overflow-x: hidden;
115
+ overflow-y: auto;
116
+ overscroll-behavior: contain;
117
+ background-color: var(--${t}-popup-bg);
118
+ opacity: 0;
119
+ transition: opacity ${W}ms ease, transform ${W}ms ease;
120
+ }
121
+ /* where the popup comes in from and goes back to, by its transition; it fades in and out with each, and 'none'
122
+ shows and hides the popup and its overlay at once */
123
+ .${t}-transition-slide-down .${t}-card {
124
+ transform: translateY(24px);
125
+ }
126
+ .${t}-transition-slide-up .${t}-card {
127
+ transform: translateY(-24px);
128
+ }
129
+ .${t}-transition-scale .${t}-card {
130
+ transform: scale(0.95);
131
+ }
132
+ .${t}-transition-none .${t}-backdrop,
133
+ .${t}-transition-none .${t}-card {
134
+ transition: none;
135
+ }
136
+ @media (prefers-reduced-motion: reduce) {
137
+ .${t}-overlay .${t}-card {
138
+ transform: none;
139
+ }
140
+ }
141
+ .${t}-overlay-active .${t}-backdrop,
142
+ .${t}-overlay-active .${t}-card {
143
+ opacity: 1;
144
+ transform: none;
145
+ }
146
+ /* one row, which every block shares: its column from the grid, its height from a spacer above it. The row is
147
+ as tall as the popup at least, and as tall as the lowest block reaches where that is further, the popup
148
+ scrolling down to it */
149
+ .${t}-grid {
150
+ position: relative;
151
+ display: grid;
152
+ grid-template-rows: auto;
153
+ min-height: 100%;
154
+ }
155
+ /* the grid the blocks snap to, drawn as the article's is while a block is moved or resized: a hairline at both
156
+ edges of every column, and one across every beat from the popup's top, or, with no beat, every vertical gap */
157
+ .${t}-guides {
158
+ position: absolute;
159
+ inset: 0;
160
+ z-index: 2;
161
+ display: grid;
162
+ grid-template-rows: minmax(0, 1fr);
163
+ pointer-events: none;
164
+ opacity: 0;
165
+ transition: opacity 200ms ease;
166
+ --${t}-guide-color: var(--cntrl-grid-color, rgba(255, 92, 2, 0.45));
167
+ }
168
+ .${t}-guides-shown {
169
+ opacity: 1;
170
+ }
171
+ .${t}-guides-beats {
172
+ background-image: repeating-linear-gradient(
173
+ to bottom,
174
+ var(--${t}-guide-color) 0 1px,
175
+ transparent 1px var(--${t}-beat)
176
+ );
177
+ }
178
+ .${t}-guide {
179
+ grid-row: 1;
180
+ box-shadow: inset 1px 0 var(--${t}-guide-color), inset -1px 0 var(--${t}-guide-color);
181
+ }
182
+ /* the block and, on the canvas, the handles it is resized by, which sit on its edges outside any scroller */
183
+ .${t}-frame {
184
+ position: relative;
185
+ display: flex;
186
+ flex-direction: column;
187
+ flex: none;
188
+ min-width: 0;
189
+ min-height: 0;
190
+ }
191
+ .${t}-slot {
192
+ display: flex;
193
+ flex-direction: column;
194
+ grid-row: 1;
195
+ min-width: 0;
196
+ min-height: 0;
197
+ pointer-events: none;
198
+ }
199
+ .${t}-spacer {
200
+ flex: none;
201
+ }
202
+ .${t}-block {
203
+ flex: none;
204
+ min-width: 0;
205
+ pointer-events: auto;
206
+ }
207
+ /* the text's box runs from the first line's cap height to the last line's baseline, where the browser can
208
+ trim it: a title lines up with the top of an image beside it, and the block is no taller than its text */
209
+ .${t}-block.${t}-block-text,
210
+ .${t}-block.${t}-block-listA,
211
+ .${t}-block.${t}-block-listB {
212
+ text-box: trim-both cap alphabetic;
213
+ }
214
+ .${t}-block-title {
215
+ color: var(--${t}-title-color);
216
+ }
217
+ .${t}-block-text {
218
+ color: var(--${t}-text-color);
219
+ }
220
+ .${t}-block-text a {
221
+ color: inherit;
222
+ }
223
+ .${t}-block-listA .${t}-block-text {
224
+ color: var(--${t}-list-a-color, var(--${t}-text-color));
225
+ }
226
+ .${t}-block-listB .${t}-block-text {
227
+ color: var(--${t}-list-b-color, var(--${t}-text-color));
228
+ }
229
+ .${t}-block-listA .${t}-block-text a,
230
+ .${t}-block-listB .${t}-block-text a {
231
+ text-decoration: none;
232
+ }
233
+ .${t}-block-listA .${t}-block-text a:hover,
234
+ .${t}-block-listB .${t}-block-text a:hover {
235
+ text-decoration: underline;
236
+ }
237
+ .${t}-images {
238
+ display: grid;
239
+ }
240
+ /* every image takes the same cell, so the block is as tall as its tallest image and keeps still as they change */
241
+ .${t}-image {
242
+ display: block;
243
+ grid-area: 1 / 1;
244
+ width: 100%;
245
+ height: auto;
246
+ object-fit: cover;
247
+ }
248
+ /* a block resized to a height: its images fill it, cut to it */
249
+ .${t}-block-sized .${t}-images {
250
+ height: 100%;
251
+ grid-template-rows: minmax(0, 100%);
252
+ }
253
+ .${t}-block-sized .${t}-image {
254
+ height: 100%;
255
+ }
256
+ .${t}-image {
257
+ transition: opacity 800ms ease-in-out;
258
+ }
259
+ .${t}-image-hidden {
260
+ opacity: 0;
261
+ }
262
+ @media (prefers-reduced-motion: reduce) {
263
+ .${t}-image {
264
+ transition: none;
265
+ }
266
+ }
267
+ .${t}-grid-editable .${t}-block {
268
+ cursor: grab;
269
+ touch-action: none;
270
+ user-select: none;
271
+ }
272
+ .${t}-grid-editable .${t}-block * {
273
+ pointer-events: none;
274
+ }
275
+ .${t}-slot-dragged {
276
+ z-index: 1;
277
+ }
278
+ .${t}-grid-editable .${t}-block-dragged {
279
+ cursor: grabbing;
280
+ outline: 1px solid #FF5C02;
281
+ outline-offset: 2px;
282
+ }
283
+ .${t}-grid-editable .${t}-frame:hover > .${t}-block:not(.${t}-block-dragged) {
284
+ outline: 1px solid rgba(255, 92, 2, 0.4);
285
+ outline-offset: 2px;
286
+ }
287
+ .${t}-grid-editable .${t}-block-invalid {
288
+ opacity: 0.5;
289
+ outline-style: dashed;
290
+ }
291
+ /* edges are a bar that grows from the block's edge as the pointer comes to it, as a structured block's do;
292
+ corners a small square */
293
+ .${t}-handle {
294
+ position: absolute;
295
+ z-index: 3;
296
+ pointer-events: auto;
297
+ touch-action: none;
298
+ }
299
+ .${t}-handle::after {
300
+ content: '';
301
+ position: absolute;
302
+ box-sizing: border-box;
303
+ opacity: 0;
304
+ transition: opacity 150ms ease, transform 150ms ease;
305
+ }
306
+ .${t}-handle-left,
307
+ .${t}-handle-right {
308
+ top: 0;
309
+ bottom: 0;
310
+ width: 10px;
311
+ cursor: ew-resize;
312
+ }
313
+ .${t}-handle-left { left: -5px; }
314
+ .${t}-handle-right { right: -5px; }
315
+ .${t}-handle-top,
316
+ .${t}-handle-bottom {
317
+ left: 0;
318
+ right: 0;
319
+ height: 10px;
320
+ cursor: ns-resize;
321
+ }
322
+ .${t}-handle-top { top: -5px; }
323
+ .${t}-handle-bottom { bottom: -5px; }
324
+ .${t}-handle-left::after,
325
+ .${t}-handle-right::after {
326
+ top: 0;
327
+ bottom: 0;
328
+ left: 3px;
329
+ width: 4px;
330
+ background-color: #FF5C02;
331
+ transform: scaleX(0.25);
332
+ }
333
+ .${t}-handle-top::after,
334
+ .${t}-handle-bottom::after {
335
+ left: 0;
336
+ right: 0;
337
+ top: 3px;
338
+ height: 4px;
339
+ background-color: #FF5C02;
340
+ transform: scaleY(0.25);
341
+ }
342
+ .${t}-handle-top-left,
343
+ .${t}-handle-top-right,
344
+ .${t}-handle-bottom-right,
345
+ .${t}-handle-bottom-left {
346
+ width: 12px;
347
+ height: 12px;
348
+ }
349
+ .${t}-handle-top-left { top: -6px; left: -6px; cursor: nwse-resize; }
350
+ .${t}-handle-bottom-right { bottom: -6px; right: -6px; cursor: nwse-resize; }
351
+ .${t}-handle-top-right { top: -6px; right: -6px; cursor: nesw-resize; }
352
+ .${t}-handle-bottom-left { bottom: -6px; left: -6px; cursor: nesw-resize; }
353
+ .${t}-handle-top-left::after,
354
+ .${t}-handle-top-right::after,
355
+ .${t}-handle-bottom-right::after,
356
+ .${t}-handle-bottom-left::after {
357
+ inset: 3px;
358
+ background-color: #ffffff;
359
+ border: 1px solid #FF5C02;
360
+ }
361
+ .${t}-frame:hover > .${t}-handle::after {
362
+ opacity: 0.6;
363
+ }
364
+ .${t}-handle:hover::after,
365
+ .${t}-handle-active::after {
366
+ opacity: 1;
367
+ transform: none;
368
+ }
369
+ `}function K(t,e,o,n){const r=h=>t[`${e}${h}`]??(n?t[`${n}${h}`]:void 0),u=h=>{const d=r(h);return d===void 0?void 0:qt.scalingValue(d,o)},c=r("FontSettings"),s=r("TextAppearance");return{fontFamily:Ee.normalizeFontFamilyCssValue(r("FontFamily")),fontWeight:c==null?void 0:c.fontWeight,fontStyle:c==null?void 0:c.fontStyle,fontSize:u("FontSize"),lineHeight:u("LineHeight"),letterSpacing:u("LetterSpacing"),wordSpacing:u("WordSpacing"),textTransform:s==null?void 0:s.textTransform,textDecoration:s==null?void 0:s.textDecoration,fontVariant:s==null?void 0:s.fontVariant}}function yt(t){const e=t.type??"text";return e==="list"?"listA":e}function qe(t,e,o,n){return t!=null&&t.grid&&Array.isArray(t.placements)&&t.placements.every(r=>typeof(r==null?void 0:r.top)=="number")?Xe(re(t,n),e):oe(e.map(yt),n,1,o)}function Xe(t,e){const o=(n,r)=>n.height!==void 0&&e[r]&&yt(e[r])!=="image";return t.placements.some(o)?{...t,placements:t.placements.map((n,r)=>{if(!o(n,r))return n;const{height:u,...c}=n;return c})}:t}function Ze(t,e){const o=(n,r)=>Math.abs(n-r)<1e-4;return o(t.height,e.height)&&t.heights.length===e.heights.length&&t.heights.every((n,r)=>o(n,e.heights[r]))}function $t(t,e){const{columns:o}=t.grid,n=t.placements[e];if(!n)return{column:0,span:Math.min(o,Math.max(1,Math.round(o/4))),top:0};const r=Math.min(n.span,o),u={column:Math.min(n.column,o-r),span:r,top:n.top};return typeof n.height=="number"?{...u,height:n.height}:u}function pe({settings:t,content:e=[],isEditor:o,isEditMode:n,isPreviewMode:r,layoutId:u,portalId:c,currentState:s,unavailableStates:h=[],onOpenChange:d,onUpdateSettings:g}){var Ot,Dt;const{prefix:a}=Ie.useScopedStyles(),T=f.useMemo(()=>Ye(a),[a]),[$,m]=f.useState(!1),[y,N]=f.useState(!1),[L,A]=f.useState(!1),S=!!(o&&!r),E=S&&s==="open"&&!h.includes("open"),R=E||!S&&$,rt=Oe(t);Te.useLightboxScrollLock(R&&!S),f.useEffect(()=>{d==null||d(R)},[R,d]),f.useEffect(()=>{m(!1)},[u]),f.useEffect(()=>{if(R){N(!0);return}A(!1);const i=window.setTimeout(()=>N(!1),rt==="none"?0:W);return()=>window.clearTimeout(i)},[R,rt]),f.useEffect(()=>{if(!R||!y)return;const i=X.current;i&&getComputedStyle(i.querySelector("[role=dialog]")??i).opacity;const l=requestAnimationFrame(()=>A(!0));return()=>cancelAnimationFrame(l)},[R,y]),f.useEffect(()=>{if(!R||S)return;const i=l=>{l.key==="Escape"&&m(!1)};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[R,S]);const I=i=>qt.scalingValue(i??0,o),wt=Qt(t),P=(Ot=t.menuLayout)==null?void 0:Ot.grid,kt=Jt(t,P!=null&&P.columnWidth?P:bt),it=`min(100%, ${I(Pt(t,kt))})`,at=I(t.popupOffset),de={left:`calc(0px + ${at})`,center:`calc((100% - ${it}) / 2 + ${at})`,right:`calc(100% - ${it} + ${at})`}[Ae(t)],{columns:Ct,columnWidth:St,gutter:_t,rowGap:Rt}=kt,It=f.useMemo(()=>({columns:Ct,columnWidth:St,gutter:_t,rowGap:Rt}),[Ct,St,_t,Rt]),q=f.useMemo(()=>qe(t.menuLayout,e,wt,It),[t.menuLayout,e,wt,It]),[lt,me]=f.useState(null),st=f.useMemo(()=>lt?Vt(q,lt):null,[q,lt]),_=f.useMemo(()=>st?ue(q,st):q,[q,st]),{columns:G,gutter:ct,columnWidth:ut}=_.grid,ge=G*ut+(G-1)*ct,ht=ut>0?{gridTemplateColumns:`repeat(${G}, minmax(0, ${I(ut)}))`,columnGap:I(ct),width:`min(100%, ${I(ge)})`,marginInline:"auto"}:{gridTemplateColumns:`repeat(${G}, minmax(0, 1fr))`,columnGap:I(ct)},Tt=t.triggerLabel||"Menu",tt=te(t.triggerPadding),V=t.triggerType==="icon"&&!t.triggerIcon?"burger":t.triggerType??"text",fe=K(t,"trigger",o),$e=K(t,"title",o),be={text:K(t,"text",o),listA:K(t,"listA",o,"text"),listB:K(t,"listB",o,"text")},O=((Dt=t.stateOverrides)==null?void 0:Dt.open)??{},Et={[`--${a}-trigger-bg`]:t.barBackgroundColor,[`--${a}-trigger-color`]:(R?O.triggerColor:void 0)??t.triggerColor,[`--${a}-overlay-color`]:O.overlayColor??t.overlayColor,[`--${a}-overlay-blur`]:t.overlayBlur?`blur(${I(t.overlayBlur)})`:void 0,[`--${a}-popup-bg`]:O.popupBackgroundColor??t.popupBackgroundColor,[`--${a}-title-color`]:O.titleColor??t.titleColor,[`--${a}-text-color`]:O.textColor??t.textColor,[`--${a}-list-a-color`]:O.listAColor??t.listAColor,[`--${a}-list-b-color`]:O.listBColor??t.listBColor},Lt=f.useRef(null),ve=f.useMemo(()=>{const i=Lt.current;if(!y||!o||!i)return;const l=getComputedStyle(i);return Object.fromEntries(Ue.map(p=>[p,l.getPropertyValue(p).trim()]).filter(([,p])=>p))},[y,o]),X=f.useRef(null),Nt=f.useRef(null),At=f.useRef(null),pt=f.useRef(null),Z=f.useRef([]),[B,xe]=f.useState(null),dt=f.useRef(null),Y=i=>{dt.current=i,xe(i)},F=!!(E&&n&&g),Me=B?Yt(_,B):null;f.useEffect(()=>{F||Y(null)},[F]);const[mt,zt]=f.useState(null);f.useLayoutEffect(()=>{const i=Nt.current;if(!y||!i){zt(null);return}const l=()=>{const k=X.current;if(!k)return;const x=k.getBoundingClientRect(),b=i.getBoundingClientRect(),C={top:b.top-x.top,left:b.left-x.left,width:b.width,height:b.height};zt(M=>M&&M.top===C.top&&M.left===C.left&&M.width===C.width&&M.height===C.height?M:C)};l();const p=new ResizeObserver(l);return p.observe(i),window.addEventListener("resize",l),window.addEventListener("scroll",l,{capture:!0,passive:!0}),()=>{p.disconnect(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,{capture:!0})}},[y]),f.useLayoutEffect(()=>{const i=At.current,l=pt.current;if(!y||!i||!l)return;const p=()=>{var C;const x=(C=X.current)==null?void 0:C.getBoundingClientRect().width;if(!x)return;const b={height:i.getBoundingClientRect().height/x,heights:e.map((M,z)=>{var w;return(((w=Z.current[z])==null?void 0:w.getBoundingClientRect().height)??0)/x})};me(M=>M&&Ze(M,b)?M:b)};p();const k=new ResizeObserver(p);return k.observe(i),k.observe(l),Z.current.slice(0,e.length).forEach(x=>x&&k.observe(x)),()=>k.disconnect()},[y,e]);const Bt=()=>{const i=pt.current,l=i.getBoundingClientRect(),p=i.offsetWidth?l.width/i.offsetWidth:1,k=(parseFloat(getComputedStyle(i).columnGap)||0)*p;return{area:l,gap:k,pitch:(l.width+k)/G}},ye=(i,l,p)=>{var z,w;if(!F||!_.placements[l]||i.button!==0)return;i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);const{area:k,pitch:x}=Bt(),b=((z=Z.current[l])==null?void 0:z.getBoundingClientRect())??i.currentTarget.getBoundingClientRect(),C=((w=X.current)==null?void 0:w.getBoundingClientRect().width)||1,M=$t(_,l);Y({index:l,pointerId:i.pointerId,handle:p,grabColumn:Math.min(Math.max(Math.floor((i.clientX-k.left)/x)-M.column,0),M.span-1),grabY:i.clientY-b.top,unit:C,start:M,placement:M,measure:Vt(_,{height:k.height/C,heights:e.map((D,et)=>{var j;return(((j=Z.current[et])==null?void 0:j.getBoundingClientRect().height)??0)/C})})})},we=i=>{const l=dt.current;if(!l||i.pointerId!==l.pointerId)return;i.stopPropagation();const{area:p,gap:k,pitch:x}=Bt(),{start:b,measure:C,handle:M}=l,z=C.height;if(!M){Y({...l,placement:{...b,column:Math.min(Math.max(Math.floor((i.clientX-p.left)/x)-l.grabColumn,0),G-b.span),top:H(_.grid,(i.clientY-l.grabY-p.top)/l.unit,z-C.heights[l.index])}});return}const w=i.clientX-p.left,D=(i.clientY-p.top)/l.unit,et=b.column+b.span;let{column:j,span:ot,top:U}=b,nt=b.height;if(M.includes("left")&&(j=Math.min(Math.max(Math.round(w/x),0),et-1),ot=et-j),M.includes("right")&&(ot=Math.min(Math.max(Math.round((w+k)/x),j+1),G)-j),M.includes("top")){const Ut=b.top+(b.height??C.heights[l.index]??0);U=H(_.grid,D,Ut-xt(_.grid)),nt=Q(_.grid,Ut-U,z-U)}M.includes("bottom")&&(nt=Q(_.grid,D-U,z-U)),Y({...l,placement:nt===void 0?{column:j,span:ot,top:U}:{column:j,span:ot,top:U,height:nt}})},ke=i=>{const l=dt.current;if(!l||i.pointerId!==l.pointerId)return;i.stopPropagation();const p=Yt(_,l),k=p==null?void 0:p.placements[l.index];p&&k&&!Ve(k,$t(_,l.index))&&(g==null||g({...t,menuLayout:p})),Y(null)},Ce=(i,l)=>{i.stopPropagation();const p=_.placements[l];if(!F||!p||p.height===void 0)return;const{height:k,...x}=p;g==null||g({...t,menuLayout:{..._,edited:!0,placements:_.placements.map((b,C)=>C===l?x:b)}})},gt=()=>m(!1),Se=i=>{!S&&i.target.closest("a")&&gt()},_e=(i,l)=>{const p=yt(i),k=(i.images??[]).filter(w=>w==null?void 0:w.assetId),x=(B==null?void 0:B.index)===l,b=x?B.placement:$t(_,l),C=b.height!==void 0,M=F&&(!B||x),z=w=>({onPointerDown:D=>ye(D,l,w),onPointerMove:we,onPointerUp:ke,onPointerCancel:()=>Y(null)});return v.jsxs("div",{className:`${a}-slot${x?` ${a}-slot-dragged`:""}`,style:{gridColumn:`${b.column+1} / span ${b.span}`},children:[v.jsx("div",{className:`${a}-spacer`,style:{height:I(b.top)}}),v.jsxs("div",{className:`${a}-frame`,children:[v.jsxs("div",{ref:w=>{Z.current[l]=w},className:[`${a}-block ${a}-block-${p}`,C?`${a}-block-sized`:"",x?`${a}-block-dragged`:"",x&&!Me?`${a}-block-invalid`:""].filter(Boolean).join(" "),style:C?{height:I(b.height)}:void 0,...F?z(null):{},children:[i.title&&p!=="image"?v.jsx("div",{className:`${a}-block-title`,style:{...$e,marginBottom:I(t.titleGap)},children:i.title}):null,p==="image"?v.jsx(Je,{prefix:a,images:k,isRunning:R,radius:I(t.imageRadius)}):v.jsx("div",{className:`${a}-block-text`,style:be[p],children:v.jsx(Le.RichTextRenderer,{content:Array.isArray(i.text)?i.text:[]})})]}),M?(p==="image"?We:He).map(w=>v.jsx("div",{className:`${a}-handle ${a}-handle-${w}${x&&B.handle===w?` ${a}-handle-active`:""}`,"aria-hidden":!0,...z(w),onDoubleClick:w.includes("top")||w.includes("bottom")?D=>Ce(D,l):void 0},w)):null]})]},l)},jt={...V==="text"?fe:void 0,padding:[tt.top,tt.right,tt.bottom,tt.left].map(i=>I(i)).join(" "),[`--${a}-icon-size`]:I(t.triggerIconSize??De)},Gt=V==="text"?Tt:v.jsx("span",{className:`${a}-icon ${a}-icon-${V}`,"aria-hidden":!0,children:V==="icon"?v.jsx(Ne.SvgImage,{url:t.triggerIcon,fill:`var(--${a}-trigger-color)`,hoverFill:`var(--${a}-trigger-color)`,className:`${a}-icon-picture`}):Array.from({length:V==="burger"?3:2},(i,l)=>v.jsx("span",{className:`${a}-icon-line`},l))}),ft=_.grid.beat||J(_.grid),Ft=y?v.jsxs("div",{ref:X,"data-selection":"none",className:[`${a}-overlay`,`${a}-transition-${rt.replace(" ","-")}`,o?`${a}-overlay-editor`:"",L?`${a}-overlay-active`:""].filter(Boolean).join(" "),style:{...ve,...Et},"aria-hidden":!L,children:[v.jsx("button",{type:"button",className:`${a}-backdrop`,"aria-label":"Close menu",tabIndex:-1,onClick:S?void 0:gt}),v.jsx("div",{ref:At,className:`${a}-card`,role:"dialog","aria-modal":"true","aria-label":t.triggerLabel||"Menu",onClick:Se,style:{top:I(t.popupOffsetTop),height:`${vt(t)}%`,left:de,width:it,borderRadius:I(t.popupRadius)},children:v.jsxs("div",{ref:pt,className:`${a}-grid${F?` ${a}-grid-editable`:""}`,style:ht,children:[e.map(_e),F?v.jsx("div",{className:`${a}-guides${ft>0?` ${a}-guides-beats`:""}${B?` ${a}-guides-shown`:""}`,style:{gridTemplateColumns:ht.gridTemplateColumns,columnGap:ht.columnGap,[`--${a}-beat`]:ft>0?I(ft):void 0},"aria-hidden":!0,children:Array.from({length:G},(i,l)=>v.jsx("div",{className:`${a}-guide`},l))}):null]})}),mt?v.jsx("button",{type:"button",className:[`${a}-button ${a}-close`,L?`${a}-button-open`:"",S?`${a}-close-inert`:""].filter(Boolean).join(" "),style:{...jt,...mt},"aria-label":"Close menu","aria-expanded":R,tabIndex:L?void 0:-1,onClick:S?void 0:gt,children:Gt}):null]}):null;return v.jsxs("div",{ref:Lt,className:`${a}-root`,style:Et,"data-edit-mode":n?"":void 0,children:[v.jsx("style",{dangerouslySetInnerHTML:{__html:T}}),v.jsx("button",{ref:Nt,type:"button",className:[`${a}-button`,R?`${a}-button-open`:"",mt?`${a}-button-hidden`:""].filter(Boolean).join(" "),style:jt,"aria-expanded":R,"aria-label":V==="text"?void 0:Tt,onClick:S?void 0:()=>m(i=>!i),children:Gt}),Ft&&typeof document<"u"?Re.createPortal(Ft,(c?document.getElementById(c):null)??document.body):null]})}function Ke(t){return t.type==="video"?!0:t.type?!1:/\.(mp4|webm|ogg|mov)(\?|$)/i.test(t.name||t.assetId)}function Je({prefix:t,images:e,isRunning:o,radius:n}){const[r,u]=f.useState(0),c=f.useRef([]),s=e.length;return f.useEffect(()=>{if(!o||s<2){u(0);return}const h=window.setInterval(()=>u(d=>(d+1)%s),Ge);return()=>window.clearInterval(h)},[o,s]),f.useEffect(()=>{c.current.slice(0,s).forEach((h,d)=>{var g;h&&(o&&d===r%s?(g=h.play())==null||g.catch(()=>{}):h.pause())})},[o,r,s,e]),v.jsx("div",{className:`${t}-images`,children:e.map((h,d)=>{const g=d===r%s,a=`${t}-image${g?"":` ${t}-image-hidden`}`,T={borderRadius:n};return Wt.isEmbedMedia(h)?v.jsx(Wt.EmbedMediaFrame,{className:a,media:h,fit:"cover",lazy:!1,silentLoop:!0,"aria-hidden":!g,style:T},d):Ke(h)?v.jsx("video",{ref:$=>{c.current[d]=$},className:a,src:h.assetId,autoPlay:o&&g,muted:!0,loop:!0,playsInline:!0,"aria-hidden":!g,style:T},d):v.jsx("img",{className:a,src:h.assetId,alt:h.name??"","aria-hidden":!g,style:T},d)})})}const Qe=Object.freeze(Object.defineProperty({__proto__:null,POPUP_MENU_TRANSITIONS:Mt,POPUP_MENU_TRIGGER_TYPES:he,PopupMenu:pe},Symbol.toStringTag,{value:"Module"}));exports.DEFAULT_POPUP_MENU_GRID=bt;exports.DEFAULT_POPUP_MENU_HEIGHT=Xt;exports.DEFAULT_POPUP_MENU_VIEWPORT_RATIO=Zt;exports.POPUP_MENU_ALIGNS=Kt;exports.POPUP_MENU_TRANSITIONS=Mt;exports.POPUP_MENU_TRIGGER_TYPES=he;exports.PopupMenu=pe;exports.PopupMenu$1=Qe;exports.defaultPopupMenuLayoutRules=ee;exports.fitPopupMenuLayoutToGrid=re;exports.generatePopupMenuLayout=oe;exports.getPopupMenuGrid=Jt;exports.getPopupMenuHeight=Qt;exports.getPopupMenuHeightPercent=vt;exports.getPopupMenuSides=te;exports.getPopupMenuWidth=Pt;exports.isSamePopupMenuGrid=ne;exports.movePopupMenuBlock=le;exports.randomPopupMenuSeed=ze;exports.resizePopupMenuBlock=se;exports.settlePopupMenuLayout=ue;exports.snapPopupMenuHeight=Q;exports.snapPopupMenuTop=H;