@cntrl-site/components 1.0.118 → 1.0.120-alpha.0

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,445 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),y=require("./scalingValue-CSHYgTZl.js"),jn=require("./buildColorVars-CE2D5cQV.js"),Cn=require("./useScopedStyles-Bf6yohVQ.js"),on=require("./useLazyVideos-CdCbc2j0.js"),It=require("./LinkWrapper-CTqM1ucO.js"),oe=require("./EmbedMediaFrame-DsOTKE4i.js"),s=require("react"),kn=require("react-dom"),Ze=require("./textStylesToCss-CNN3zZTV.js"),Mn=require("./SvgImage-DFlmxAoL.js"),ln=require("./LazyVideo-imbU18js.js");function Tn(e){return`calc(var(--cntrl-article-width, 100vw) * ${e/1440})`}function en(e){return((e==null?void 0:e.trim().length)??0)>0}function Ft(e,n,t,l){return n!==void 0&&n<(e??.01)?`${t} ${l}`:t}function Wt(e,n,t,l){const o=e??.01;return n===void 0||n>=o?{}:{[`--${t}-title-leading-gap`]:y.scalingValue((o-n)/2,l)}}const Et=400,Gt="cubic-bezier(0.25, 0.1, 0.25, 1)",Ln=1.1,an="--grid-media-radius";function Rn(e){return`
2
+ .${e}-wrapper {
3
+ display: grid;
4
+ align-items: start;
5
+ justify-content: center;
6
+ min-height: ${Tn(48)};
7
+ }
8
+ .${e}-item {
9
+ display: flex;
10
+ flex-direction: column;
11
+ justify-content: center;
12
+ align-items: center;
13
+ }
14
+ .${e}-item-inner {
15
+ display: flex;
16
+ flex-direction: column;
17
+ align-items: center;
18
+ outline: 1px solid #FF5C02;
19
+ }
20
+ .${e}-item-inner-hidden {
21
+ display: flex;
22
+ flex-direction: column;
23
+ align-items: center;
24
+ }
25
+ .${e}-item-image-wrapper {
26
+ display: flex;
27
+ justify-content: center;
28
+ align-items: center;
29
+ align-self: center;
30
+ }
31
+ .${e}-item-image-wrapper-fit-slider {
32
+ display: grid;
33
+ overflow: hidden;
34
+ position: relative;
35
+ }
36
+ .${e}-item-image-wrapper-fit-slider > .${e}-item-image-wrapper-sizer {
37
+ grid-area: 1 / 1;
38
+ width: 100%;
39
+ display: grid;
40
+ visibility: hidden;
41
+ pointer-events: none;
42
+ }
43
+ .${e}-item-image-wrapper-fit-slider > .${e}-item-image-wrapper-sizer img {
44
+ grid-area: 1 / 1;
45
+ width: auto;
46
+ height: auto;
47
+ max-width: 100%;
48
+ object-fit: contain;
49
+ }
50
+ .${e}-item-image-wrapper-fit-slider > .${e}-item-image-wrapper-sizer video {
51
+ grid-area: 1 / 1;
52
+ width: auto;
53
+ height: auto;
54
+ max-width: 100%;
55
+ object-fit: contain;
56
+ }
57
+ .${e}-item-image-wrapper-fit-slider > .${e}-item-image-wrapper-sizer div {
58
+ grid-area: 1 / 1;
59
+ width: 100%;
60
+ }
61
+ .${e}-item-image-wrapper-fit-slider > .${e}-item-slider {
62
+ position: absolute;
63
+ inset: 0;
64
+ width: 100%;
65
+ overflow: hidden;
66
+ }
67
+ .${e}-item-image-link {
68
+ width: 100%;
69
+ display: flex;
70
+ flex-direction: column;
71
+ align-items: center;
72
+ }
73
+ .${e}-custom-layout .${e}-item-image-link {
74
+ flex: 1 1 0%;
75
+ min-height: 0;
76
+ }
77
+ .${e}-custom-layout.${e}-text-outside .${e}-item-image-link,
78
+ .${e}-custom-layout.${e}-auto-height .${e}-item-image-link {
79
+ flex: none;
80
+ }
81
+ .${e}-auto-height .${e}-item-image-wrapper-fit-slider > .${e}-item-image-wrapper-sizer :is(img, video) {
82
+ width: 100%;
83
+ }
84
+ .${e}-item-text-link {
85
+ display: flex;
86
+ flex-direction: column;
87
+ align-items: center;
88
+ width: 100%;
89
+ color: inherit;
90
+ text-decoration: none;
91
+ }
92
+ .${e}-item-image {
93
+ width: 100%;
94
+ height: 100%;
95
+ display: block;
96
+ max-width: 100%;
97
+ }
98
+ .${e}-item-video {
99
+ width: 100%;
100
+ height: 100%;
101
+ display: block;
102
+ max-width: 100%;
103
+ }
104
+ .${e}-item-slider {
105
+ position: relative;
106
+ width: 100%;
107
+ height: 100%;
108
+ overflow: hidden;
109
+ }
110
+ .${e}-item-slider-list {
111
+ position: relative;
112
+ display: flex;
113
+ flex-direction: row;
114
+ width: 100%;
115
+ height: 100%;
116
+ will-change: transform;
117
+ }
118
+ .${e}-item-slider-list-vertical {
119
+ flex-direction: column;
120
+ }
121
+ .${e}-item-slider-list-fade {
122
+ display: block;
123
+ will-change: auto;
124
+ }
125
+ .${e}-item-slide {
126
+ position: relative;
127
+ flex: 0 0 100%;
128
+ width: 100%;
129
+ height: 100%;
130
+ display: flex;
131
+ justify-content: center;
132
+ align-items: center;
133
+ }
134
+ .${e}-item-slider-list-fade .${e}-item-slide {
135
+ position: absolute;
136
+ top: 0;
137
+ left: 0;
138
+ opacity: 0;
139
+ transition: opacity ${Ot}ms ${cn};
140
+ }
141
+ .${e}-item-slider-list-fade .${e}-item-slide-active {
142
+ opacity: 1;
143
+ z-index: 1;
144
+ }
145
+ .${e}-item-title {
146
+ white-space: normal;
147
+ overflow-wrap: anywhere;
148
+ word-break: break-word;
149
+ text-align: center;
150
+ margin-bottom: 0px;
151
+ margin-top: 0px;
152
+ color: var(--${e}-title-color);
153
+ }
154
+ .${e}-item-subtitle {
155
+ white-space: normal;
156
+ overflow-wrap: anywhere;
157
+ word-break: break-word;
158
+ text-align: center;
159
+ margin-bottom: 0px;
160
+ margin-top: 0px;
161
+ color: var(--${e}-subtitle-color);
162
+ }
163
+ .${e}-text-tight-leading {
164
+ display: block;
165
+ flex-shrink: 0;
166
+ padding-top: var(--${e}-title-leading-gap, 0);
167
+ padding-bottom: var(--${e}-title-leading-gap, 0);
168
+ }
169
+ .${e}-show-text-hover .${e}-item-title,
170
+ .${e}-show-text-hover .${e}-item-subtitle {
171
+ opacity: 0;
172
+ transition: opacity 250ms;
173
+ }
174
+ .${e}-show-text-hover .${e}-item-inner:hover .${e}-item-title,
175
+ .${e}-show-text-hover .${e}-item-inner:hover .${e}-item-subtitle,
176
+ .${e}-show-text-hover .${e}-item-inner-hidden:hover .${e}-item-title,
177
+ .${e}-show-text-hover .${e}-item-inner-hidden:hover .${e}-item-subtitle {
178
+ opacity: 1;
179
+ }
180
+ @property --${e}-hover-zoom {
181
+ syntax: '<number>';
182
+ inherits: false;
183
+ initial-value: 1;
184
+ }
185
+ .${e}-hover-zoom-in .${e}-item-image,
186
+ .${e}-hover-zoom-in .${e}-item-video {
187
+ transform: scale(var(--${e}-hover-zoom));
188
+ clip-path: inset(calc(50% - 50% / var(--${e}-hover-zoom)) round calc(var(${an}, 0px) / var(--${e}-hover-zoom)));
189
+ transition: --${e}-hover-zoom ${Et}ms ${Gt};
190
+ }
191
+ .${e}-hover-scale-down .${e}-item-image,
192
+ .${e}-hover-scale-down .${e}-item-video {
193
+ transition: transform ${Et}ms ${Gt};
194
+ }
195
+ .${e}-hover-greyscale .${e}-item-image-wrapper {
196
+ transition: filter ${Et}ms ${Gt};
197
+ }
198
+ @media (hover: hover) {
199
+ .${e}-hover-zoom-in .${e}-item-image-wrapper:has(.${e}-item-image:hover, .${e}-item-video:hover) :is(.${e}-item-image, .${e}-item-video) {
200
+ --${e}-hover-zoom: ${Ln};
201
+ }
202
+ .${e}-hover-scale-down .${e}-item-image-wrapper:hover .${e}-item-image,
203
+ .${e}-hover-scale-down .${e}-item-image-wrapper:hover .${e}-item-video {
204
+ transform: scale(0.9);
205
+ }
206
+ .${e}-hover-greyscale:has(.${e}-item-image:hover, .${e}-item-video:hover) .${e}-item-image-wrapper:not(:has(.${e}-item-image:hover, .${e}-item-video:hover)) {
207
+ filter: grayscale(1);
208
+ }
209
+ }
210
+ .${e}-type-a .${e}-item-inner,
211
+ .${e}-type-a .${e}-item-inner-hidden,
212
+ .${e}-type-d .${e}-item-inner,
213
+ .${e}-type-d .${e}-item-inner-hidden {
214
+ align-items: flex-start;
215
+ }
216
+ .${e}-type-b .${e}-item-inner,
217
+ .${e}-type-b .${e}-item-inner-hidden,
218
+ .${e}-type-e .${e}-item-inner,
219
+ .${e}-type-e .${e}-item-inner-hidden {
220
+ align-items: center;
221
+ }
222
+ .${e}-type-c .${e}-item-inner,
223
+ .${e}-type-c .${e}-item-inner-hidden,
224
+ .${e}-type-f .${e}-item-inner,
225
+ .${e}-type-f .${e}-item-inner-hidden {
226
+ align-items: flex-end;
227
+ }
228
+ .${e}-type-a .${e}-item-image-link,
229
+ .${e}-type-b .${e}-item-image-link,
230
+ .${e}-type-c .${e}-item-image-link,
231
+ .${e}-type-d .${e}-item-image-link,
232
+ .${e}-type-e .${e}-item-image-link,
233
+ .${e}-type-f .${e}-item-image-link {
234
+ align-items: center;
235
+ }
236
+ .${e}-type-a .${e}-item-title,
237
+ .${e}-type-a .${e}-item-subtitle,
238
+ .${e}-type-d .${e}-item-title,
239
+ .${e}-type-d .${e}-item-subtitle {
240
+ text-align: left;
241
+ }
242
+ .${e}-type-b .${e}-item-title,
243
+ .${e}-type-b .${e}-item-subtitle,
244
+ .${e}-type-e .${e}-item-title,
245
+ .${e}-type-e .${e}-item-subtitle {
246
+ text-align: center;
247
+ }
248
+ .${e}-type-c .${e}-item-title,
249
+ .${e}-type-c .${e}-item-subtitle,
250
+ .${e}-type-f .${e}-item-title,
251
+ .${e}-type-f .${e}-item-subtitle {
252
+ text-align: right;
253
+ }
254
+ .${e}-item-text-block {
255
+ display: flex;
256
+ flex-direction: column;
257
+ align-items: flex-start;
258
+ width: 100%;
259
+ flex-shrink: 0;
260
+ }
261
+ .${e}-type-d .${e}-item-text-block {
262
+ align-items: flex-start;
263
+ }
264
+ .${e}-type-e .${e}-item-text-block {
265
+ align-items: center;
266
+ }
267
+ .${e}-type-f .${e}-item-text-block {
268
+ align-items: flex-end;
269
+ }
270
+ .${e}-type-a .${e}-item-text-link,
271
+ .${e}-type-d .${e}-item-text-link {
272
+ align-items: flex-start;
273
+ }
274
+ .${e}-type-b .${e}-item-text-link,
275
+ .${e}-type-e .${e}-item-text-link {
276
+ align-items: center;
277
+ }
278
+ .${e}-type-c .${e}-item-text-link,
279
+ .${e}-type-f .${e}-item-text-link {
280
+ align-items: flex-end;
281
+ }
282
+ .${e}-image-align-top .${e}-item-image-wrapper:not(.${e}-item-image-wrapper-fit-slider) {
283
+ align-items: flex-start;
284
+ }
285
+ .${e}-image-align-center .${e}-item-image-wrapper:not(.${e}-item-image-wrapper-fit-slider) {
286
+ align-items: center;
287
+ }
288
+ .${e}-image-align-bottom .${e}-item-image-wrapper:not(.${e}-item-image-wrapper-fit-slider) {
289
+ align-items: flex-end;
290
+ }
291
+ .${e}-image-align-top .${e}-item-slider .${e}-item-slide {
292
+ align-items: flex-start;
293
+ }
294
+ .${e}-image-align-center .${e}-item-slider .${e}-item-slide {
295
+ align-items: center;
296
+ }
297
+ .${e}-image-align-bottom .${e}-item-slider .${e}-item-slide {
298
+ align-items: flex-end;
299
+ }
300
+ .${e}-align-entries .${e}-item {
301
+ display: contents;
302
+ }
303
+ .${e}-align-entries .${e}-item-inner,
304
+ .${e}-align-entries .${e}-item-inner-hidden {
305
+ display: grid;
306
+ grid-template-rows: subgrid;
307
+ grid-row: span 3;
308
+ justify-self: center;
309
+ margin-bottom: var(--${e}-align-entries-row-gap, 0);
310
+ }
311
+ .${e}-align-entries .${e}-item-inner-last-row {
312
+ margin-bottom: 0;
313
+ }
314
+ .${e}-align-entries .${e}-item-text-link {
315
+ display: contents;
316
+ }
317
+ .${e}-align-entries .${e}-item-title-row,
318
+ .${e}-align-entries .${e}-item-subtitle-row {
319
+ display: flex;
320
+ flex-direction: column;
321
+ align-items: flex-start;
322
+ width: 100%;
323
+ min-height: 100%;
324
+ }
325
+ .${e}-type-a.${e}-align-entries .${e}-item-title-row,
326
+ .${e}-type-a.${e}-align-entries .${e}-item-subtitle-row,
327
+ .${e}-type-d.${e}-align-entries .${e}-item-title-row,
328
+ .${e}-type-d.${e}-align-entries .${e}-item-subtitle-row {
329
+ align-items: flex-start;
330
+ }
331
+ .${e}-type-b.${e}-align-entries .${e}-item-title-row,
332
+ .${e}-type-b.${e}-align-entries .${e}-item-subtitle-row,
333
+ .${e}-type-e.${e}-align-entries .${e}-item-title-row,
334
+ .${e}-type-e.${e}-align-entries .${e}-item-subtitle-row {
335
+ align-items: center;
336
+ }
337
+ .${e}-type-c.${e}-align-entries .${e}-item-title-row,
338
+ .${e}-type-c.${e}-align-entries .${e}-item-subtitle-row,
339
+ .${e}-type-f.${e}-align-entries .${e}-item-title-row,
340
+ .${e}-type-f.${e}-align-entries .${e}-item-subtitle-row {
341
+ align-items: flex-end;
342
+ }
343
+ .${e}-align-entries .${e}-item-image-link {
344
+ width: 100%;
345
+ height: 100%;
346
+ min-height: 100%;
347
+ display: flex;
348
+ flex-direction: column;
349
+ align-items: center;
350
+ justify-content: flex-start;
351
+ }
352
+ .${e}-align-entries .${e}-item-image-link > .${e}-item-image-wrapper {
353
+ flex-shrink: 0;
354
+ height: auto;
355
+ align-self: auto;
356
+ }
357
+ .${e}-image-align-top.${e}-align-entries .${e}-item-image-link > .${e}-item-image-wrapper {
358
+ margin-top: 0;
359
+ margin-bottom: auto;
360
+ }
361
+ .${e}-image-align-center.${e}-align-entries .${e}-item-image-link > .${e}-item-image-wrapper {
362
+ margin-top: auto;
363
+ margin-bottom: auto;
364
+ }
365
+ .${e}-image-align-bottom.${e}-align-entries .${e}-item-image-link > .${e}-item-image-wrapper {
366
+ margin-top: auto;
367
+ margin-bottom: 0;
368
+ }
369
+ .${e}-image-align-top.${e}-align-entries .${e}-item-image-wrapper:not(.${e}-item-image-wrapper-fit-slider) {
370
+ align-items: flex-start;
371
+ }
372
+ .${e}-image-align-center.${e}-align-entries .${e}-item-image-wrapper:not(.${e}-item-image-wrapper-fit-slider) {
373
+ align-items: center;
374
+ }
375
+ .${e}-image-align-bottom.${e}-align-entries .${e}-item-image-wrapper:not(.${e}-item-image-wrapper-fit-slider) {
376
+ align-items: flex-end;
377
+ }
378
+ .${e}-image-align-top.${e}-align-entries .${e}-item-slider .${e}-item-slide {
379
+ align-items: flex-start;
380
+ }
381
+ .${e}-image-align-center.${e}-align-entries .${e}-item-slider .${e}-item-slide {
382
+ align-items: center;
383
+ }
384
+ .${e}-image-align-bottom.${e}-align-entries .${e}-item-slider .${e}-item-slide {
385
+ align-items: flex-end;
386
+ }
387
+ .${e}-image-align-top.${e}-align-entries .${e}-item-image-link {
388
+ justify-content: flex-start;
389
+ }
390
+ .${e}-image-align-center.${e}-align-entries .${e}-item-image-link {
391
+ justify-content: center;
392
+ }
393
+ .${e}-image-align-bottom.${e}-align-entries .${e}-item-image-link {
394
+ justify-content: flex-end;
395
+ }
396
+ .${e}-lightbox-counter {
397
+ margin: 0;
398
+ color: var(--${e}-lightbox-counter-color);
399
+ }
400
+ .${e}-lightbox {
401
+ position: fixed;
402
+ inset: 0;
403
+ z-index: 9997;
404
+ overscroll-behavior: none;
405
+ overflow: hidden;
406
+ }
407
+ .${e}-lightbox-editor {
408
+ inset: auto;
409
+ top: var(--cntrl-article-top, 0);
410
+ left: var(--cntrl-article-left, 0);
411
+ width: var(--cntrl-article-width, 100vw) !important;
412
+ height: var(--cntrl-viewport-height, 100vh) !important;
413
+ }
414
+ .${e}-control {
415
+ position: relative;
416
+ z-index: 2;
417
+ width: 100%;
418
+ }
419
+ .${e}-close-icon {
420
+ position: relative;
421
+ flex-shrink: 0;
422
+ pointer-events: auto;
423
+ z-index: 2;
424
+ display: flex;
425
+ align-items: center;
426
+ justify-content: center;
427
+ border: none;
428
+ background-color: transparent;
429
+ padding: 0;
430
+ }
431
+ .${e}-close-icon-inner {
432
+ all: unset;
433
+ position: relative;
434
+ cursor: pointer;
435
+ width: 100%;
436
+ height: 100%;
437
+ pointer-events: auto;
438
+ }
439
+ .${e}-close-icon-img {
440
+ position: absolute;
441
+ top: 50%;
442
+ left: 50%;
443
+ transform: translate(-50%, -50%);
444
+ }
445
+ `}function zn(){return Math.random()<.5?"ltr":"ttb"}function tn(e,n){return n<=0?0:(e%n+n)%n}const de=500,Ot=750,cn="cubic-bezier(0.25, 1, 0.5, 1)",An=5e3,Me="cubic-bezier(0.22, 1, 0.36, 1)",Nn=72,Vn=50;function Fn(e){if(!Array.isArray(e)||e.length===0)return!1;const n=e[0];return n!==null&&typeof n=="object"&&"media"in n&&Array.isArray(n.media)}function Wn(e){const[n,t]=e.media;return t!=null&&t.assetId?t:n!=null&&n.assetId?n:null}function En(e){const[n]=e.media;return n!=null&&n.assetId?n:null}function un(e){return!Array.isArray(e)||e.length===0?[]:Fn(e)?e.flatMap(n=>{const t=Wn(n);if(!t)return[];const l=En(n);return[{displayMedia:t,lightboxMedia:l!=null&&l.assetId?l:null}]}):e.filter(n=>n==null?void 0:n.assetId).map(n=>({displayMedia:n,lightboxMedia:n}))}function Fe(e){return!oe.isEmbedMedia(e)&&e.type==="video"}function Gn(e){const n=new Set,t=[];for(const l of e){const o=un(l.gallery);for(const m of o){const u=m.lightboxMedia;u!=null&&u.assetId&&!n.has(u.assetId)&&(n.add(u.assetId),t.push(u))}}return t}const On=s.memo(function({mediaList:n}){const[t,l]=s.useState(null);on.useLazyVideos(t,{preload:"metadata"});const o=n.filter(m=>!oe.isEmbedMedia(m));return o.length===0?null:i.jsx("div",{ref:l,"aria-hidden":!0,style:{position:"absolute",width:0,height:0,overflow:"hidden",opacity:0,pointerEvents:"none"},children:o.map(m=>Fe(m)?i.jsx("video",{src:m.assetId,preload:"none",muted:!0,playsInline:!0},m.assetId):i.jsx("img",{src:m.assetId,alt:""},m.assetId))})});function _n(e){e.pause(),e.removeAttribute("src"),e.load()}const mn="cntrl-grid-slide",dn="cntrl-grid-slide-playing",Dn=`.${mn} video`;function Hn(e){return e.closest(`.${dn}`)!==null}function Bn({prefix:e,slides:n,isFade:t,direction:l,intervalMs:o}){const m=n.length,u=!t&&m>1,w=!t&&l==="random",F=Number.isFinite(o)&&o>0?o:An,[r,f]=s.useState(u?1:0),[$,b]=s.useState(!t&&l==="vertical"?"ttb":"ltr"),[C,R]=s.useState(!1),[X,S]=s.useState(!1),[P,H]=s.useState(0),I=s.useRef(!1);s.useEffect(()=>{if(m<2)return;const M=window.setTimeout(()=>{if(I.current){H(j=>j+1);return}I.current=!0,R(!0),S(!1),f(j=>u?j+1:tn(j+1,m)),w||H(j=>j+1)},F);return()=>window.clearTimeout(M)},[m,P,F,u,w]),s.useEffect(()=>{if(!C)return;const M=window.setTimeout(()=>{const j=u&&r===m+1,N=w?zn():$;(j||N!==$)&&(S(!0),j&&f(1),b(N)),I.current=!1,R(!1),w&&H(B=>B+1)},Ot);return()=>window.clearTimeout(M)},[$,m,u,C,w,r]),s.useEffect(()=>{if(!X)return;let M=0;const j=requestAnimationFrame(()=>{M=requestAnimationFrame(()=>S(!1))});return()=>{cancelAnimationFrame(j),cancelAnimationFrame(M)}},[X]);const Z=u?m+2:m,h=M=>u?tn(M-1,m):M,p=M=>u&&(M===0||M===m+1),k=h(r),E=r+1<Z?r+1:-1,W=M=>t||M===r&&!p(M)||M===E||E>=0&&!p(M)&&h(M)===h(E),G=!t&&$==="ttb",ee=t?void 0:{transform:G?`translate3d(0, ${-r*100}%, 0)`:`translate3d(${-r*100}%, 0, 0)`,transition:X?"none":`transform ${Ot}ms ${cn}`};return i.jsx("div",{className:`${e}-item-slider`,children:i.jsx("div",{className:`${e}-item-slider-list${t?` ${e}-item-slider-list-fade`:""}${G?` ${e}-item-slider-list-vertical`:""}`,style:ee,children:Array.from({length:Z},(M,j)=>{const N=h(j),B=p(j),Q=t?N===k:j===r;return i.jsx("div",{className:`${e}-item-slide ${mn}${t&&Q?` ${e}-item-slide-active`:""}${W(j)?` ${dn}`:""}`,"aria-hidden":Q?void 0:!0,children:n[N]},B?`clone-${j===0?"start":"end"}`:`slide-${N}`)})})})}function nn({media:e,className:n,style:t,hasLightbox:l,isSliderSlide:o=!1,onMediaClick:m}){if(oe.isEmbedMedia(e))return i.jsx(oe.EmbedMediaFrame,{media:e,fit:t.objectFit==="contain"?"contain":"cover",silentLoop:l,className:n,style:{...t,cursor:m?"pointer":"default"},onClick:m});if(Fe(e)){const u={src:e.assetId,className:n,style:{...t,cursor:m?"pointer":"default"},muted:!0,loop:!0,playsInline:!0,onClick:m};return o?i.jsx("video",{...u,preload:"none"}):i.jsx(ln.LazyVideo,{...u,autoPlay:!0})}return i.jsx("img",{src:e.assetId,alt:e.name,className:n,style:{...t,cursor:m?"pointer":"default"},onClick:m})}function qn({className:e,style:n,children:t}){const[l,o]=s.useState(null);return on.useLazyVideos(l,{autoPlay:!0,selector:Dn,shouldPlay:Hn}),i.jsx("div",{ref:o,className:e,style:n,children:t})}function rn(e){const n=e.getBoundingClientRect();return{width:n.width,height:n.height,left:n.left,top:n.top}}function Un(e,n){if(!n||!n.width||!n.height||!e.width||!e.height)return e;const t=n.width/n.height,l=e.width/e.height;if(t>l){const m=e.width/t;return{width:e.width,height:m,left:e.left,top:e.top+(e.height-m)/2}}const o=e.height*t;return{width:o,height:e.height,left:e.left+(e.width-o)/2,top:e.top}}function Xn({src:e,mediaRef:n,mediaStyle:t,onLoadedMetadata:l}){return s.useEffect(()=>{const o=n.current;if(o)return()=>{_n(o)}},[e,n]),i.jsx("video",{ref:n,src:e,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,preload:"auto",onLoadedMetadata:l,style:t})}const Yn="https://cdn.cntrl.site/component-assets/defaultCloseIcon.svg",Kn=.004;function Zn({prefix:e,closeIcon:n=Yn,closeIconMaxWidth:t=.0125,closeIconColor:l="#FFFFFF",closeIconHoverColor:o="#999999",iconMarginRight:m=.01,contentMarginTop:u=.01,isEditor:w,isPreviewMode:F,isEditMode:r,visible:f,onClose:$}){if(!n)return null;const b=y.scalingValue(t,w),C=y.scalingValue(m,w),R=y.scalingValue(u,w),X=y.scalingValue(Math.max(u,Kn),w);return i.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,zIndex:1e4,display:"flex",flexDirection:"column",alignItems:"flex-end",pointerEvents:"none",opacity:f?1:0,transition:"opacity 500ms cubic-bezier(0.22, 1, 0.36, 1)"},children:[i.jsx("div",{style:{position:"relative",width:"100%",height:R,flexShrink:0},children:r&&i.jsx("div",{"data-controls":"contentMarginTop","data-controls-axis":"y","data-controls-min":"0",className:`${e}-control`,style:{position:"absolute",top:0,left:0,width:"100%",height:X,pointerEvents:f?"auto":"none"}})}),i.jsxs("div",{className:`${e}-close-icon`,style:{width:b,height:b,marginRight:C,pointerEvents:f?"auto":"none"},onClick:S=>S.stopPropagation(),children:[i.jsx("button",{type:"button",className:`${e}-close-icon-inner`,"aria-label":"Close",onClick:S=>{S.stopPropagation(),$()},children:i.jsx(Mn.SvgImage,{url:n,fill:l,hoverFill:w&&!F?l:o,className:`${e}-close-icon-img`})}),r&&i.jsx("div",{"data-controls":"iconMarginRight","data-controls-axis":"x","data-controls-reverse":"",className:`${e}-control`,style:{position:"absolute",top:0,left:"100%",width:C,height:"100%",pointerEvents:f?"auto":"none"}})]})]})}function Jn({prefix:e,items:n,index:t,imageDisplay:l,isEditor:o,isPreviewMode:m,isEditMode:u,onClose:w,onPrev:F,onNext:r,counterClassName:f,counterStyle:$,closeIcon:b,closeIconMaxWidth:C,closeIconColor:R,closeIconHoverColor:X,iconMarginRight:S,contentMarginTop:P}){const H=l==="cover",I=s.useRef(null),Z=s.useRef(null),h=s.useRef(null),p=s.useRef(null),k=s.useRef(0),E=s.useRef(0),W=s.useRef("none"),G=s.useRef(!1),ee=s.useRef(!1),M=s.useRef(null),j=s.useRef(0),N=s.useRef(null),B=s.useRef(!1),Q=s.useRef(null),ae=s.useRef(null),We=s.useRef(null),Qe=s.useRef(()=>{}),[V,ye]=s.useState(null),[x,Ee]=s.useState(null),[U,Te]=s.useState("opening"),[he,Le]=s.useState(0),[ce,le]=s.useState(0),[be,ve]=s.useState(null),[Ge,Se]=s.useState(!1),[Oe,Re]=s.useState(!1),[jt,ut]=s.useState(!1),[Ct,mt]=s.useState(null),dt=s.useRef(t),Pe=s.useRef(void 0),v=n[t],kt=v?Fe(v):!1,et=v?oe.isEmbedMedia(v):!1,_e=be!==null,De=s.useCallback(c=>{const T=c.currentTarget,O=T instanceof HTMLVideoElement?{width:T.videoWidth,height:T.videoHeight}:{width:T.naturalWidth,height:T.naturalHeight};!O.width||!O.height||mt(O)},[]);s.useEffect(()=>{M.current=x},[x]),s.useEffect(()=>{const c=I.current;if(!c)return;const T=()=>Ee(rn(c));T();const O=new ResizeObserver(T);return O.observe(c),()=>O.disconnect()},[]);const Y=s.useCallback(()=>{Q.current!==null&&(window.clearTimeout(Q.current),Q.current=null)},[]),ge=s.useCallback(()=>{const c=ae.current;ae.current=null,Y(),N.current=null,B.current=!1,ve(null),Se(!1),le(0),j.current=0,Re(!1),G.current=!1,E.current=0,W.current="none",c===1?r():c===-1&&F()},[Y,r,F]),Ie=s.useCallback(()=>{Y(),ae.current=null,N.current=null,B.current=!1,ve(null),Se(!1),le(0),j.current=0},[Y]),ht=s.useCallback(()=>{Y(),Q.current=window.setTimeout(()=>{ae.current!==null&&ge()},de+32)},[Y,ge]),je=s.useCallback((c,T)=>{var Ae;const O=((Ae=M.current)==null?void 0:Ae.width)??0;if(Y(),N.current=c,ve(c),B.current=!0,Se(!0),T){ae.current=c;const fe=-c*O;j.current=fe,le(fe),ht();return}j.current=0,le(0),Q.current=window.setTimeout(()=>{Q.current=null,Ie()},de+32)},[Y,Ie,ht]),tt=s.useCallback(c=>{if(!(n.length<=1)){if(B.current){if(ae.current===c){We.current=c,ge();return}Ie()}Y(),N.current=c,ve(c),B.current=!1,Se(!1),j.current=0,le(0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{je(c,!0)})})}},[n.length,je,ge,Ie,Y]);Qe.current=tt;const gt=s.useCallback(c=>{c.propertyName!=="transform"||!B.current||ae.current!==null&&ge()},[ge]),nt=s.useCallback(()=>{const c=Z.current;if(!c)return;const T=rn(c);!T.width||!T.height||ye(T)},[]);s.useEffect(()=>{nt();const c=Z.current;if(!c)return;const T=new ResizeObserver(()=>nt());return T.observe(c),()=>T.disconnect()},[nt]),s.useEffect(()=>{U==="opening"&&V&&Te("open")},[U,V]),s.useEffect(()=>{if(U!=="closing")return;const c=setTimeout(()=>w(),de);return()=>clearTimeout(c)},[U,w]),s.useEffect(()=>()=>{Y()},[Y]),s.useLayoutEffect(()=>{dt.current===t&&Pe.current===(v==null?void 0:v.assetId)||(Y(),ae.current=null,ve(null),Le(0),le(0),Se(!1),ut(!1),Re(!1),mt(null),k.current=0,E.current=0,W.current="none",G.current=!1,B.current=!1,j.current=0,N.current=null,p.current=null,ee.current=!1,dt.current=t,Pe.current=v==null?void 0:v.assetId)},[t,v==null?void 0:v.assetId,Y]),s.useLayoutEffect(()=>{const c=We.current;c!==null&&(We.current=null,requestAnimationFrame(()=>{Qe.current(c)}))},[t,v==null?void 0:v.assetId]),s.useEffect(()=>{if(U!=="open")return;let c=null;const T=()=>{c&&(document.removeEventListener("click",c,!0),c=null)},O=()=>{T(),c=_=>{_.stopPropagation(),_.preventDefault(),T()},document.addEventListener("click",c,!0)},Ae=_=>{const ie=_<0?1:-1;if(Math.abs(_)>Vn&&n.length>1){je(ie,!0);return}je(ie,!1)},fe=_=>{if(_.touches.length!==1||B.current)return;const ie=_.touches[0];ee.current=!0,p.current={x:ie.clientX,y:ie.clientY},W.current="none",E.current=0,G.current=!1},qe=_=>{if(!p.current||_.touches.length!==1||B.current)return;const ie=_.touches[0],re=ie.clientX-p.current.x,$e=ie.clientY-p.current.y;if(W.current==="none"){if(Math.abs(re)<10&&Math.abs($e)<10)return;if(Math.abs(re)>Math.abs($e)){if(n.length<=1)return;W.current="horizontal"}else if($e>0)W.current="vertical";else return}if(W.current==="horizontal"){G.current=!0,Re(!0),E.current=re;const at=re<0?1:-1;N.current!==at&&(N.current=at,ve(at)),j.current=re,le(re),_.preventDefault();return}W.current==="vertical"&&(G.current=!0,Re(!0),k.current=$e,Le($e),_.preventDefault())},Ne=()=>{if(!p.current)return;const _=W.current,ie=G.current;if(ie&&_==="horizontal")Ae(E.current),O();else if(ie&&_==="vertical")if(k.current>Nn){const $e=window.innerHeight;k.current=$e,ut(!0),Le($e),Te("closing")}else k.current=0,Le(0),O();else _==="horizontal"&&Math.abs(E.current)>0&&(Ae(E.current),O());p.current=null,W.current="none",E.current=0,G.current=!1,Re(!1)};return document.addEventListener("touchstart",fe,{passive:!0}),document.addEventListener("touchmove",qe,{passive:!1}),document.addEventListener("touchend",Ne),document.addEventListener("touchcancel",Ne),()=>{document.removeEventListener("touchstart",fe),document.removeEventListener("touchmove",qe),document.removeEventListener("touchend",Ne),document.removeEventListener("touchcancel",Ne),T()}},[U,n.length,je]),s.useEffect(()=>{const c=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),U!=="closing"&&Te("closing"))};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[U]);const pt=()=>{U!=="closing"&&Te("closing")},a=U==="open",it=U==="closing",rt=he>0?Math.max(0,1-he/500):1,te=he>0?Math.max(.35,1-he/500):1,st=et&&v?{width:oe.getEmbedAspect(v),height:1}:Ct,z=V?H?V:Un(V,st):null,ot={position:"fixed",top:x==null?void 0:x.top,left:x==null?void 0:x.left,width:x==null?void 0:x.width,height:x==null?void 0:x.height,zIndex:9998},lt=H?"cover":"contain",q=ce!==0||he>0?`translate(${ce}px, ${he}px)`:void 0,Mt=Oe&&!Ge?"none":Ge?`transform ${de}ms ${Me}`:jt?`transform ${de}ms ${Me}, opacity ${de}ms ${Me}`:U==="opening"||it?`opacity ${de}ms ${Me}`:"none",ze={...ot,transform:q,opacity:he>0?te:U==="opening"||it?0:1,transition:Mt,pointerEvents:"none"},He={position:"absolute",top:((z==null?void 0:z.top)??0)-((x==null?void 0:x.top)??0),left:((z==null?void 0:z.left)??0)-((x==null?void 0:x.left)??0),width:z==null?void 0:z.width,height:z==null?void 0:z.height,objectFit:lt,pointerEvents:"none"},ue=(x==null?void 0:x.width)??0,pe=_e?(t+be+n.length)%n.length:null,ne=pe!==null?n[pe]:null,ft={...ot,transform:_e?`translateX(${be*ue+ce}px)`:void 0,opacity:1,transition:Ge?`transform ${de}ms ${Me}`:"none",pointerEvents:"none"},Be={position:"absolute",top:((V==null?void 0:V.top)??0)-((x==null?void 0:x.top)??0),left:((V==null?void 0:V.left)??0)-((x==null?void 0:x.left)??0),width:V==null?void 0:V.width,height:V==null?void 0:V.height,objectFit:lt,pointerEvents:"none"},$t=et&&v&&oe.getEmbedPlayback(v).controls&&z?Math.min(52,z.height*.2):0,xt=z?{position:"fixed",top:z.top,height:z.height-$t,width:z.width/2,zIndex:9999}:null;return i.jsxs("div",{ref:I,className:[`${e}-lightbox`,o?`${e}-lightbox-editor`:""].filter(Boolean).join(" "),style:{touchAction:U==="open"?"none":void 0},onClick:pt,children:[i.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(28,31,34,0.9)",opacity:a?rt:0,transition:Oe?"none":`opacity ${de}ms ${Me}`,pointerEvents:"none"}}),i.jsx("div",{style:{position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:H?i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:Z,style:{position:"absolute",inset:0}}),i.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"10%",opacity:a?1:0,transition:`opacity ${de}ms ${Me}`,pointerEvents:"none",zIndex:9999},children:n.length>1&&i.jsxs("p",{className:f,style:$,children:[t+1," / ",n.length]})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{height:"10%"}}),i.jsx("div",{style:{width:"70%",height:"80%",display:"flex",justifyContent:"center",alignItems:"center"},children:i.jsx("div",{ref:Z,style:{width:"100%",height:"100%"}})}),i.jsx("div",{style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"10%",opacity:a?1:0,transition:`opacity ${de}ms ${Me}`},children:n.length>1&&i.jsxs("p",{className:f,style:$,children:[t+1," / ",n.length]})})]})}),V&&x&&ne&&i.jsx("div",{style:ft,onTransitionEnd:gt,children:oe.isEmbedMedia(ne)?i.jsx("img",{src:ne.thumbnail,alt:ne.name,style:Be},`neighbor-${pe}-${ne.assetId}`):Fe(ne)?i.jsx("video",{src:ne.assetId,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,preload:"auto",style:Be},`neighbor-${pe}-${ne.assetId}`):i.jsx("img",{src:ne.assetId,alt:ne.name,style:Be},`neighbor-${pe}-${ne.assetId}`)}),V&&x&&v&&i.jsx("div",{style:ze,onTransitionEnd:gt,children:et?i.jsx(oe.EmbedMediaFrame,{media:v,fit:H?"cover":"contain",lazy:!1,startsAtOnce:!0,style:He},`${t}-${v.assetId}`):kt?i.jsx(Xn,{src:v.assetId,mediaRef:h,mediaStyle:He,onLoadedMetadata:De},`${t}-${v.assetId}`):i.jsx("img",{ref:h,src:v.assetId,alt:v.name,onLoad:De,style:He},`${t}-${v.assetId}`)}),a&&xt&&n.length>1&&i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{...xt,left:z.left,cursor:"w-resize",pointerEvents:Oe?"none":"auto"},onClick:c=>{if(ee.current){ee.current=!1;return}c.stopPropagation(),tt(-1)}}),i.jsx("div",{style:{...xt,left:z.left+z.width/2,cursor:"e-resize",pointerEvents:Oe?"none":"auto"},onClick:c=>{if(ee.current){ee.current=!1;return}c.stopPropagation(),tt(1)}})]}),i.jsx(Zn,{prefix:e,closeIcon:b,closeIconMaxWidth:C,closeIconColor:R,closeIconHoverColor:X,iconMarginRight:S,contentMarginTop:P,isEditor:o,isPreviewMode:m,isEditMode:u,visible:a,onClose:pt})]})}function Qn(e){return typeof e=="string"?e==="cover"?"cover":"fit":(e==null?void 0:e.display)==="cover"?"cover":"fit"}function _t(e,n){return e.columnWidth*n+e.gutterWidth*Math.max(0,n-1)}function Pn(e){return e.blocks.reduce((n,t)=>Math.max(n,Math.max(0,t.top)+Math.max(0,t.height)),0)}function Dt(e){return typeof e.verticalGap=="number"?Math.max(0,e.verticalGap):Math.max(0,(e.repeatHeight??0)-Pn(e))}function hn(e,n){const t=e.blocks[n%e.blocks.length],l=Math.min(Math.max(1,Math.round(t.span)),e.columnsCount),o=Math.min(Math.max(0,Math.round(t.column)),e.columnsCount-l);return{column:o,span:l,width:_t(e,l),top:Math.max(0,t.top),height:Math.max(0,t.height),gridColumn:`${o+1} / span ${l}`}}const Je=1e-6;function ei(e,n,t){const l=e.beat??0,o=l>0&&!!t,m=r=>Math.ceil(r/l-.001)*l,u=[],w=[],F=Dt(e);for(let r=0;r<n;r+=e.blocks.length){r>0&&F>0&&u.push(F);const f=Array.from({length:Math.min(e.blocks.length,n-r)},(h,p)=>hn(e,r+p)),$=f.map(h=>{const p=f.filter(k=>k.column<h.column+h.span&&h.column<k.column+k.span&&k.top>=h.top+h.height-Je);return p.length>0?Math.min(...p.map(k=>k.top)):void 0}),b=[0,...f.map(h=>h.top)].sort((h,p)=>h-p).filter((h,p,k)=>p===0||h-k[p-1]>Je),C=(h,p)=>Math.abs(h-p)<=Je,R=h=>b.findIndex(p=>C(p,h)),X=[];let S=0;const P=h=>{const p=f.flatMap((W,G)=>h($[G])?[{slot:W,entry:r+G}]:[]);if(p.length===0)return;if(!o){u.push("auto");return}const k=Math.max(...p.map(({slot:W,entry:G})=>X[R(W.top)]+(t[G]??0))),E=Math.max(0,m(k)-S);u.push(E),S+=E},H=b.map((h,p)=>(p>0&&(u.push(h-b[p-1]),S+=h-b[p-1]),P(k=>k!==void 0&&C(k,h)),X.push(S),u.length+1));P(h=>h===void 0);const I=u.length+1,Z=h=>H[R(h)];f.forEach((h,p)=>{const k=$[p];w.push(`${Z(h.top)} / ${k===void 0?I:Z(k)}`)})}return{tracks:u,gridRows:w}}function sn(e){return oe.isEmbedMedia(e)?oe.getEmbedAspect(e):e.width&&e.height&&e.width>0&&e.height>0?e.width/e.height:void 0}function ti(e,n,t){const l=e.blocks.length,o=Dt(e),m=n.slice(0,l).map(r=>r.top).sort((r,f)=>r-f).filter((r,f,$)=>f===0||r-$[f-1]>Je),u=[];let w=0,F=0;for(let r=0;r<n.length;r+=l)for(const f of m){const $=Array.from({length:Math.min(l,n.length-r)},(b,C)=>r+C).filter(b=>Math.abs(n[b].top-f)<=Je);$.length!==0&&($.forEach(b=>{u[b]=w}),F=Math.max(...$.map(b=>w+t[b])),w=F+o)}return{tops:u,bottom:F}}function ni(e,n,t){if(e.gridType==="rows")return ti(e,n,t);const l=e.blocks.length,o=Dt(e),m=e.masonry==="on",u=[],w=[],F=f=>f.reduce(($,b)=>Math.max($,b.bottom),0);let r=0;for(let f=0;f<n.length;f+=l){const $=f/l,b=Array.from({length:Math.min(l,n.length-f)},(C,R)=>f+R).sort((C,R)=>n[C].top-n[R].top||C-R);for(const C of b){const R=n[C],X=I=>I.column<R.column+R.span&&R.column<I.column+I.span,S=b.filter(I=>I!==C&&u[I]!==void 0&&X(n[I])&&n[I].top+n[I].height<=R.top+Je),P=m?w.filter(I=>I.group<$&&X(I)):[],H=S.map(I=>u[I]+t[I]+R.top-(n[I].top+n[I].height));P.length>0&&H.push(F(P)+o),H.length===0&&H.push(r+R.top),u[C]=Math.max(...H),w.push({column:R.column,span:R.span,bottom:u[C]+t[C],group:$})}r=F(w)+o}return{tops:u,bottom:F(w)}}function ii({settings:e,content:n,isEditor:t,isPreviewMode:l,isEditMode:o,metadata:m,activeEvent:u,layoutId:w,portalId:F}){const{prefix:r}=Cn.useScopedStyles(),{type:f="a",gridLayout:$,customGrid:b,textBoxWidth:C=100,verticalGap:R,entriesCount:X,lightbox:S,imageDisplay:P,imageCorners:H,lightboxImageDisplay:I,slider:Z,sliderTiming:h,direction:p,transition:k,titleMarginTop:E,subtitleMarginTop:W,titleColor:G,subtitleColor:ee,lightboxCounterColor:M,titleFontFamily:j,titleFontSettings:N,titleFontSize:B,titleLineHeight:Q,titleLetterSpacing:ae,titleWordSpacing:We,titleTextAppearance:Qe,subtitleFontFamily:V,subtitleFontSettings:ye,subtitleFontSize:x,subtitleLineHeight:Ee,subtitleLetterSpacing:U,subtitleWordSpacing:Te,subtitleTextAppearance:he,lightboxCounterFontFamily:Le,lightboxCounterFontSettings:ce,lightboxCounterFontSize:le,lightboxCounterLineHeight:be,lightboxCounterLetterSpacing:ve,lightboxCounterWordSpacing:Ge,lightboxCounterTextAppearance:Se,closeIcon:Oe,closeIconMaxWidth:Re,closeIconColor:jt,closeIconHoverColor:ut,iconMarginRight:Ct,contentMarginTop:mt,showText:dt="always",hover:Pe="none",alignEntries:v="off",align:kt="top",textGrowth:et="inside"}=e,_e=s.useMemo(()=>({...Ze.omitTextColors(Ze.textStylesToCss({fontSettings:{fontFamily:j,fontWeight:(N==null?void 0:N.fontWeight)??400,fontStyle:(N==null?void 0:N.fontStyle)??"normal"},fontSize:B??.01,lineHeight:Q,letterSpacing:ae??0,wordSpacing:We??0,textAppearance:Qe,color:G},t)),...Wt(B,Q,r,t)}),[j,N,B,Q,ae,We,Qe,G,t,r]),De=s.useMemo(()=>({...Ze.omitTextColors(Ze.textStylesToCss({fontSettings:{fontFamily:V,fontWeight:(ye==null?void 0:ye.fontWeight)??400,fontStyle:(ye==null?void 0:ye.fontStyle)??"normal"},fontSize:x??.01,lineHeight:Ee,letterSpacing:U??0,wordSpacing:Te??0,textAppearance:he,color:ee},t)),...Wt(x,Ee,r,t)}),[V,ye,x,Ee,U,Te,he,ee,t,r]),Y=s.useMemo(()=>({...Ze.omitTextColors(Ze.textStylesToCss({fontSettings:{fontFamily:Le,fontWeight:(ce==null?void 0:ce.fontWeight)??400,fontStyle:(ce==null?void 0:ce.fontStyle)??"normal"},fontSize:le??.01,lineHeight:be,letterSpacing:ve??0,wordSpacing:Ge??0,textAppearance:Se,color:M},t)),...Wt(le,be,r,t)}),[Le,ce,le,be,ve,Ge,Se,M,t,r]),ge=Ft(B,Q,`${r}-item-title`,`${r}-text-tight-leading`),Ie=Ft(x,Ee,`${r}-item-subtitle`,`${r}-text-tight-leading`),ht=Ft(le,be,`${r}-lightbox-counter`,`${r}-text-tight-leading`),je=s.useMemo(()=>jn.buildColorVars(r,{titleColor:G,subtitleColor:ee,lightboxCounterColor:M},ri,si),[r,G,ee,M]),tt=u&&u!=="default"?`${r}-state-${u}`:"",gt=dt==="on hover"&&(!t||l),nt=Pe!=="none"&&(!t||l)?` ${r}-hover-${Pe}`:"",pt=`${tt}${gt?` ${r}-show-text-hover`:""}${nt}`.trim(),a=b&&Array.isArray(b.blocks)&&b.blocks.length>0?b:void 0,it=a||X===0?1/0:X,rt=!!a&&(a.textGrowth??et)==="outside",te=(a==null?void 0:a.cellHeight)==="auto",st=te||(a==null?void 0:a.masonry)==="on",z=s.useRef([]),[ot,lt]=s.useState([]),q=s.useMemo(()=>(n??[]).slice(0,it),[n,it]),Mt=s.useMemo(()=>S==="on"?Gn(q):[],[q,S]),ze=s.useMemo(()=>q.map(d=>{const g=un(d.gallery),L=g.filter(A=>A.lightboxMedia).map(A=>A.lightboxMedia),D=g.map(({lightboxMedia:A})=>A?L.findIndex(xe=>xe.assetId===A.assetId):-1);return{displayItems:g,lightboxItemsForEntry:L,lightboxIndexes:D}}),[q]),He=($==null?void 0:$.entryWidth)??.2,ue=typeof P=="string"?{display:P}:P,pe=((a==null?void 0:a.mediaDisplay)??(ue==null?void 0:ue.display))==="cover",ne=(ue==null?void 0:ue.ratioValue)??"1:1",ft=(ue==null?void 0:ue.reversed)??!1,[Be,$t]=ne.split(":").map(Number),T=`${ft?$t:Be} / ${ft?Be:$t}`,O=($==null?void 0:$.columnsCount)??1,Ae=y.scalingValue(He??0,t),fe=Z!=="off"&&(a?te:!pe),qe=q.length%O||O,Ne=!a&&qe<O&&q.length>0,_=q.length-qe,ie=Ne?Math.floor((O-qe)/2)+1:1,re=H?y.scalingValue(H,t):void 0,$e=(d,g,L)=>({width:d,...g&&te?{height:L!=null&&L.isEmpty?y.scalingValue(g.height,t):"auto",flexShrink:0,overflow:"hidden",...L!=null&&L.aspect&&!fe?{aspectRatio:`${L.aspect}`}:{}}:g?rt?{height:y.scalingValue(g.height,t),flexShrink:0,overflow:"hidden"}:{flex:"1 1 0%",minHeight:0,overflow:"hidden"}:pe?{aspectRatio:T,height:"auto",overflow:"hidden"}:{height:"auto"},...re?{borderRadius:re,overflow:"hidden"}:{}}),at=`${r}-item-image-wrapper${fe?` ${r}-item-image-wrapper-fit-slider`:""}`.trim(),Ce=f==="d"||f==="e"||f==="f",we=!a&&v==="on",Tt=re?{borderRadius:re,[an]:re}:{},Lt=te?{objectFit:fe&&!pe?"contain":"cover",pointerEvents:"auto",width:"100%",height:"100%",maxWidth:"100%",...Tt}:pe?{objectFit:"cover",pointerEvents:"auto",width:"100%",height:"100%",maxWidth:"100%",...Tt}:{objectFit:"contain",pointerEvents:"auto",width:"auto",height:"auto",maxWidth:"100%",...a?{maxHeight:"100%"}:{},...Tt},Rt=((a==null?void 0:a.beat)??0)>0||st,zt=a?_t(a,a.columnsCount):0;s.useLayoutEffect(()=>{if(!Rt){lt(A=>A.length>0?[]:A);return}const d=vt.current,g=z.current.slice(0,q.length),L=()=>{const A=d&&zt>0?d.offsetWidth/zt:0;if(A<=0)return;const xe=g.map(se=>se?se.offsetHeight/A:0);lt(se=>se.length===xe.length&&se.every((J,me)=>Math.abs(J-xe[me])<1e-5)?se:xe)};L();const D=new ResizeObserver(L);return d&&D.observe(d),g.forEach(A=>A&&D.observe(A)),()=>D.disconnect()},[Rt,q.length,zt,r]);const Ue=Rt&&ot.length===q.length?ot:void 0,Xe=s.useMemo(()=>{if(!a)return;const d=ei(a,q.length,Ue);return{gridRows:d.gridRows,gridTemplateRows:d.tracks.length?d.tracks.map(g=>g==="auto"?"auto":y.scalingValue(g,t)).join(" "):"auto"}},[a,q.length,Ue,t]),Ve=s.useMemo(()=>a?q.map((d,g)=>hn(a,g)):void 0,[a,q.length]),gn=s.useMemo(()=>ze.map(({displayItems:d})=>te&&d.length>0?sn(d[0].displayMedia):void 0),[ze,te]),yt=s.useMemo(()=>{if(!a||!Ve||!st)return;const d=a.beat??0,g=Ve.map((L,D)=>{const xe=ze[D].displayItems.map(({displayMedia:me})=>sn(me)).filter(me=>me!==void 0),se=te&&xe.length>0?Math.max(...xe.map(me=>L.width/me)):L.height,J=(Ue==null?void 0:Ue[D])??se;return d>0?Math.ceil(J/d-.001)*d:J});return ni(a,Ve,g)},[a,Ve,st,te,ze,Ue]),pn=a?{gridTemplateColumns:`repeat(${a.columnsCount}, ${y.scalingValue(a.columnWidth,t)})`,gridTemplateRows:(Xe==null?void 0:Xe.gridTemplateRows)??"auto",rowGap:0,columnGap:y.scalingValue(a.gutterWidth,t),width:y.scalingValue(_t(a,a.columnsCount),t),...yt?{position:"relative",height:y.scalingValue(yt.bottom,t)}:{}}:{gridTemplateColumns:`repeat(${O}, ${Ae})`,rowGap:we?0:y.scalingValue(R??0,t),columnGap:y.scalingValue(($==null?void 0:$.horizontalGap)??0,t),width:y.scalingValue(($==null?void 0:$.wrapperWidth)??0,t),...we?{[`--${r}-align-entries-row-gap`]:y.scalingValue(R??0,t)}:{}},vt=s.useRef(null),fn=()=>{const d={...je},g=vt.current?getComputedStyle(vt.current).getPropertyValue("--cntrl-article-width").trim():"";return g&&(d["--cntrl-article-width"]=g),d},[At,Nt]=s.useState(!1),[wt,$n]=s.useState([]),[xn,Vt]=s.useState(0),Ht=S==="on"&&(!t||l),Bt=(d,g)=>{t&&!l||S!=="off"&&($n(d),Vt(g),Nt(!0))};s.useEffect(()=>{if(!At||S!=="on"||typeof document>"u")return;const d=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=d}},[At,S]),s.useEffect(()=>{!t||l||Nt(!1)},[t,l]);const yn=s.useMemo(()=>Rn(r),[r]);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:yn}}),S==="on"&&i.jsx(On,{mediaList:Mt}),i.jsx("div",{style:je,children:i.jsx("div",{ref:vt,className:`${r}-wrapper ${r}-type-${f}${we?` ${r}-align-entries`:""}${a?` ${r}-custom-layout`:""}${rt?` ${r}-text-outside`:""}${te?` ${r}-auto-height`:""} ${r}-image-align-${a?"top":kt} ${pt}`.trim(),style:pn,children:q.map((d,g)=>{var Qt;const L=en(d.title),D=en(d.subtitle),A=S==="off"&&((Qt=d.link)!=null&&Qt.value)?d.link:void 0,xe=Math.floor(g/O)===Math.ceil(q.length/O)-1,se=Ne&&g>=_?`${ie+(g-_)}`:void 0,J=Ve==null?void 0:Ve[g],me=(J==null?void 0:J.width)??He,ct=y.scalingValue(me,t),Ye=`calc(${ct} * (${C} / 100))`,ke=y.scalingValue(me*C/100,t),{displayItems:Ke,lightboxItemsForEntry:qt,lightboxIndexes:Ut}=ze[g],Xt=Z==="off"?gn[g]:void 0,vn=$e(ct,J,{aspect:Xt,isEmpty:Ke.length===0}),wn=te&&Z==="off"&&!Xt?{...Lt,height:"auto"}:Lt,bn=J&&a&&yt?{position:"absolute",left:y.scalingValue(J.column*(a.columnWidth+a.gutterWidth),t),top:y.scalingValue(yt.tops[g],t),width:ct}:J?{gridColumn:J.gridColumn,gridRow:Xe==null?void 0:Xe.gridRows[g],alignSelf:"start"}:se&&!we?{gridColumn:se}:void 0,Yt=Ce?i.jsxs("div",{className:`${r}-item-text-block`,children:[L&&i.jsx("p",{className:ge,style:{width:Ye,..._e},children:d.title}),L&&i.jsx("div",{"data-controls":o?"titleMarginTop":void 0,className:o?`${r}-control`:void 0,style:{height:y.scalingValue(E??0,t),width:ke}}),D&&i.jsx("p",{className:Ie,style:{width:Ye,...De},children:d.subtitle}),D&&i.jsx("div",{"data-controls":o?"subtitleMarginTop":void 0,className:o?`${r}-control`:void 0,style:{height:y.scalingValue(W??0,t),width:ke}})]}):null,Sn=we?i.jsxs("div",{className:`${r}-item-title-row`,children:[!Ce&&i.jsx("div",{"data-controls":o&&L?"titleMarginTop":void 0,className:o&&L?`${r}-control`:void 0,style:{height:L?y.scalingValue(E??0,t):0,width:ke}}),L&&i.jsx("p",{className:ge,style:{width:Ye,..._e},children:d.title}),Ce&&L&&i.jsx("div",{"data-controls":o?"titleMarginTop":void 0,className:o?`${r}-control`:void 0,style:{height:y.scalingValue(E??0,t),width:ke}})]}):null,In=we?i.jsxs("div",{className:`${r}-item-subtitle-row`,children:[!Ce&&i.jsx("div",{"data-controls":o&&D?"subtitleMarginTop":void 0,className:o&&D?`${r}-control`:void 0,style:{height:D?y.scalingValue(W??0,t):0,width:ke}}),D&&i.jsx("p",{className:Ie,style:{width:Ye,...De},children:d.subtitle}),Ce&&D&&i.jsx("div",{"data-controls":o?"subtitleMarginTop":void 0,className:o?`${r}-control`:void 0,style:{height:y.scalingValue(W??0,t),width:ke}})]}):null,Kt=i.jsxs(It.LinkWrapper,{link:A,className:`${r}-item-text-link`,children:[Sn,In]}),bt=i.jsx(qn,{className:at,style:vn,children:Ke.length===0?null:Z==="off"?(()=>{const{displayMedia:K}=Ke[0],St=Ut[0];return i.jsx(nn,{media:K,className:`${r}-item-${Fe(K)?"video":"image"}`.trim(),style:wn,hasLightbox:S==="on",onMediaClick:Ht&&St>=0?()=>Bt(qt,St):void 0})})():i.jsxs(i.Fragment,{children:[fe&&i.jsx("div",{className:`${r}-item-image-wrapper-sizer`,"aria-hidden":"true",children:Ke.map(({displayMedia:K})=>oe.isEmbedMedia(K)?i.jsx("div",{style:{aspectRatio:`${oe.getEmbedAspect(K)}`}},`sizer-${K.assetId}`):Fe(K)?i.jsx(ln.LazyVideo,{src:K.assetId,nearPreload:"metadata",muted:!0,playsInline:!0},`sizer-${K.assetId}`):i.jsx("img",{src:K.assetId,alt:""},`sizer-${K.assetId}`))}),i.jsx(Bn,{prefix:r,isFade:k==="fade",direction:p,intervalMs:h*1e3,slides:Ke.map(({displayMedia:K},St)=>{const Pt=Ut[St];return i.jsx(nn,{media:K,className:`${r}-item-${Fe(K)?"video":"image"}`.trim(),style:Lt,hasLightbox:S==="on",isSliderSlide:!0,onMediaClick:Ht&&Pt>=0?()=>Bt(qt,Pt):void 0})})},`${k}-${me}-${p}-${h}-${w}-${Ke.length}`)]})}),Zt=Ce?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{"data-controls":o&&L?"titleMarginTop":void 0,className:o&&L?`${r}-control`:void 0,style:{height:L?y.scalingValue(E??0,t):0,width:ke}}),i.jsx("p",{className:ge,style:{width:Ye,..._e},children:d.title}),i.jsx("div",{"data-controls":o&&D?"subtitleMarginTop":void 0,className:o&&D?`${r}-control`:void 0,style:{height:D?y.scalingValue(W??0,t):0,width:ke}}),i.jsx("p",{className:Ie,style:{width:Ye,...De},children:d.subtitle})]}),Jt=A?i.jsx(It.LinkWrapper,{link:A,className:`${r}-item-image-link`,children:bt}):i.jsx("a",{className:`${r}-item-image-link`,children:bt});return i.jsx("div",{className:`${r}-item`.trim(),style:bn,children:i.jsx("div",{ref:K=>{z.current[g]=K},className:`${o?`${r}-item-inner`:`${r}-item-inner-hidden`}${we&&xe?` ${r}-item-inner-last-row`:""}`.trim(),style:{width:(C??0)>100?`calc(${ct} * (${C} / 100))`:ct,...J&&!rt&&!te?{height:y.scalingValue(J.height,t)}:{},...se&&we?{gridColumn:se}:{}},children:we?i.jsx(i.Fragment,{children:Ce?i.jsxs(i.Fragment,{children:[Kt,Jt]}):i.jsxs(i.Fragment,{children:[Jt,Kt]})}):A?i.jsxs(i.Fragment,{children:[i.jsxs(It.LinkWrapper,{link:A,className:`${r}-item-image-link`,children:[Yt,bt]}),!Ce&&i.jsx(It.LinkWrapper,{link:A,className:`${r}-item-text-link`,children:Zt})]}):i.jsxs(i.Fragment,{children:[Yt,bt,Zt]})})},g)})})}),(!t||l)&&At&&typeof document<"u"&&S==="on"&&(()=>{const d=(F?document.getElementById(F):null)??document.body;return kn.createPortal(i.jsx("div",{style:fn(),"data-selection":"none",children:i.jsx(Jn,{prefix:r,items:wt,index:xn,imageDisplay:Qn(I),isEditor:t,isPreviewMode:l,isEditMode:o,closeIcon:Oe,closeIconMaxWidth:Re,closeIconColor:jt,closeIconHoverColor:ut,iconMarginRight:Ct,contentMarginTop:mt,onClose:()=>Nt(!1),onPrev:()=>Vt(g=>(g-1+wt.length)%wt.length),onNext:()=>Vt(g=>(g+1)%wt.length),counterClassName:ht,counterStyle:Y})}),d)})()]})}const ri={titleColor:"title-color",subtitleColor:"subtitle-color",lightboxCounterColor:"lightbox-counter-color"},si=["hover","focus","filled","success","error"];exports.Grid=ii;