@cntrl-site/components 1.0.104 → 1.0.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/Components/utils/observeIntersection.d.ts +4 -0
  2. package/dist/Components/utils/useLazyVideos.d.ts +0 -3
  3. package/dist/{Grid-Bq6bk2AQ.js → Grid-BBpdl60K.js} +1 -1
  4. package/dist/{Grid-B2_o1dvz.mjs → Grid-DS53S_gA.mjs} +2 -2
  5. package/dist/{Helix-BrKQzGX5.mjs → Helix-BPn9V1sg.mjs} +1 -1
  6. package/dist/{Helix-B7rxlvKq.js → Helix-DcgsCc4D.js} +1 -1
  7. package/dist/{Hive-BusARSOi.mjs → Hive-D6-R6TwM.mjs} +2 -2
  8. package/dist/{Hive-Dh5nKPGm.js → Hive-n8Fz-j3o.js} +1 -1
  9. package/dist/{LazyVideo-D8eVYFyw.mjs → LazyVideo-CdAWymKO.mjs} +1 -1
  10. package/dist/{LazyVideo-Cn_vmMq8.js → LazyVideo-imbU18js.js} +1 -1
  11. package/dist/Marquee-DOIRRCu4.js +133 -0
  12. package/dist/{Marquee-CdtAqhQE.mjs → Marquee-O_PDwlIb.mjs} +55 -54
  13. package/dist/MarqueeText-DkaO2lQ5.js +132 -0
  14. package/dist/MarqueeText-Rzt2fJYt.mjs +517 -0
  15. package/dist/{Mercury-BRqlbk4i.mjs → Mercury-C9D10TTT.mjs} +1 -1
  16. package/dist/{Mercury-C-O2VGkK.js → Mercury-DynO-NxY.js} +1 -1
  17. package/dist/{PretextComponent-D5P0AjnL.js → PretextComponent-BnsS2zJ6.js} +1 -1
  18. package/dist/{PretextComponent-s4DDfmzY.mjs → PretextComponent-j-OsRZTx.mjs} +7 -7
  19. package/dist/{Waterfall-fdiHR0Rc.js → Waterfall-DC2WQ3GT.js} +1 -1
  20. package/dist/{Waterfall-DKuh4bnv.mjs → Waterfall-Yud2VR62.mjs} +2 -2
  21. package/dist/{components-DzNixU7Q.js → components-B9Vdjf0w.js} +1 -1
  22. package/dist/{components-Yf9Zjska.mjs → components-D2LyuDm-.mjs} +1 -1
  23. package/dist/elements.js +1 -1
  24. package/dist/elements.mjs +7 -7
  25. package/dist/elements.node.js +1 -1
  26. package/dist/elements.node.mjs +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.mjs +2 -2
  29. package/dist/observeIntersection-B0f3L2iK.mjs +23 -0
  30. package/dist/observeIntersection-DxGj9Ctt.js +1 -0
  31. package/dist/sources.js +24 -12
  32. package/dist/sources.mjs +28 -16
  33. package/dist/useLazyVideos-CdCbc2j0.js +1 -0
  34. package/dist/useLazyVideos-CxXyEjRQ.mjs +52 -0
  35. package/dist/utils.js +1 -1
  36. package/dist/utils.mjs +1 -1
  37. package/package.json +1 -1
  38. package/dist/Marquee-DUN8wUax.js +0 -133
  39. package/dist/MarqueeText-4Rip_sQX.mjs +0 -515
  40. package/dist/MarqueeText-E6OubMOG.js +0 -132
  41. package/dist/useLazyVideos-BbgdvELi.js +0 -1
  42. package/dist/useLazyVideos-CZLyNolX.mjs +0 -72
@@ -1,132 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),a=require("react"),wt=require("classnames"),$t=require("./scalingValue-CSHYgTZl.js"),St=require("./useScopedStyles-Bf6yohVQ.js"),At=require("./textStylesToCss-CNN3zZTV.js");function Et(e,r,o){const s=r>0?`${r}px`:"0px",i=o?`
2
- .${e}-item-image-wrap {
3
- display: flex;
4
- flex: 0 0 auto;
5
- align-items: center;
6
- }
7
- .${e}-glyph {
8
- display: inline-block;
9
- }
10
- .${e}-glyph-inner {
11
- display: inline-block;
12
- transform-origin: 50% 50%;
13
- backface-visibility: hidden;
14
- -webkit-backface-visibility: hidden;
15
- }
16
- .${e}-item-image {
17
- transform-origin: 50% 50%;
18
- backface-visibility: hidden;
19
- -webkit-backface-visibility: hidden;
20
- }
21
- `:"";return`
22
- .${e}-wrapper {
23
- position: relative;
24
- width: 100%;
25
- height: auto;
26
- }
27
- .${e}-marquee-wrapper {
28
- position: relative;
29
- overflow: hidden;
30
- overflow-x: clip;
31
- overflow-y: visible;
32
- width: 100%;
33
- height: auto;
34
- }
35
- .${e}-curve-bg {
36
- position: absolute;
37
- left: 0;
38
- top: 0;
39
- width: 100%;
40
- height: 100%;
41
- overflow: visible;
42
- pointer-events: none;
43
- z-index: 0;
44
- }
45
- .${e}-ribbon {
46
- position: absolute;
47
- left: 0;
48
- top: 50%;
49
- width: 100%;
50
- transform: translateY(-50%);
51
- pointer-events: none;
52
- z-index: 0;
53
- }
54
-
55
- @keyframes ${e}-marquee-left {
56
- from { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }
57
- to { -webkit-transform: translate3d(-${s}, 0, 0); transform: translate3d(-${s}, 0, 0); }
58
- }
59
-
60
- @keyframes ${e}-marquee-right {
61
- from { -webkit-transform: translate3d(-${s}, 0, 0); transform: translate3d(-${s}, 0, 0); }
62
- to { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }
63
- }
64
-
65
- .${e}-marquee-track {
66
- display: flex;
67
- flex-direction: row;
68
- width: max-content;
69
- backface-visibility: hidden;
70
- -webkit-backface-visibility: hidden;
71
- flex-wrap: nowrap;
72
- -webkit-animation-timing-function: linear;
73
- animation-timing-function: linear;
74
- -webkit-animation-iteration-count: infinite;
75
- animation-iteration-count: infinite;
76
- position: relative;
77
- z-index: 1;
78
- }
79
- .${e}-marquee-track[data-direction="left"] {
80
- -webkit-animation-name: ${e}-marquee-left;
81
- animation-name: ${e}-marquee-left;
82
- }
83
- .${e}-marquee-track[data-direction="right"] {
84
- -webkit-animation-name: ${e}-marquee-right;
85
- animation-name: ${e}-marquee-right;
86
- }
87
- .${e}-marquee-set {
88
- display: flex;
89
- flex-direction: row;
90
- align-items: center;
91
- flex: 0 0 auto;
92
- position: relative;
93
- z-index: 1;
94
- }
95
- .${e}-marquee-static {
96
- justify-content: center;
97
- overflow-x: auto;
98
- }
99
- .${e}-item {
100
- position: relative;
101
- display: flex;
102
- flex-direction: row;
103
- align-items: center;
104
- flex: 0 0 auto;
105
- white-space: nowrap;
106
- }
107
- .${e}-item-link {
108
- display: flex;
109
- flex-direction: row;
110
- align-items: center;
111
- text-decoration: none;
112
- color: inherit;
113
- }
114
- .${e}-item-image {
115
- display: block;
116
- width: auto;
117
- flex: 0 0 auto;
118
- object-fit: contain;
119
- }
120
- .${e}-text {
121
- display: inline-block;
122
- }
123
- ${i}
124
- .${e}-cap-ref {
125
- position: absolute;
126
- visibility: hidden;
127
- pointer-events: none;
128
- white-space: nowrap;
129
- left: -9999px;
130
- top: 0;
131
- }
132
- `}const Mt=30,we=3,Ct=12,Rt=96,Ue=3,se=.72,kt=100,qt=10,Lt=e=>e/kt,Ft=e=>Math.max(0,e)/qt,Tt=e=>{e.style.setProperty("animation-name","none"),e.style.setProperty("-webkit-animation-name","none"),e.offsetHeight,e.style.removeProperty("animation-name"),e.style.removeProperty("-webkit-animation-name")},_t=(e,r)=>Array.from({length:r*e.length},(o,s)=>e[s%e.length]),D={ctx:void 0},Wt=()=>D.ctx!==void 0?D.ctx:typeof document>"u"?(D.ctx=null,D.ctx):(D.ctx=document.createElement("canvas").getContext("2d"),D.ctx),Nt=(e,r,o,s)=>{e.style.transform=`translate3d(${r}px, ${o}px, 0) rotate(${s}deg)`},Xe=e=>{e.style.transform=""},jt=e=>{if(!e||e==="none")return 0;try{return new DOMMatrixReadOnly(e).m41}catch{return 0}},Bt=(e,r)=>{const o=(s,i)=>{if(!s||s===r)return i;const m=i+s.offsetLeft,u=s.offsetParent;return!u||u===s?m:o(u,m)};return o(e,e.offsetWidth/2)},Ve=96,Ye=(e,r,o)=>{if(r<=0||Math.abs(e)<=0||o<2)return null;const s=2*Math.PI/r,i=new Float64Array(o+1),m=new Float64Array(o+1),u=e*r,l=d=>Math.sqrt(1+(u*Math.cos(r*d))**2),w=s/o;return Array.from({length:o},(d,R)=>{const v=R*w,M=v+w;i[R+1]=M,m[R+1]=m[R]+(l(v)+l(M))*.5*w}),{wavelength:s,periodArc:m[o],x:i,s:m}},Ht=(e,r)=>{const o=Ye(e,r,Ve);return!o||o.wavelength<=0?1:o.periodArc/o.wavelength},Pt=(e,r)=>{if(e.periodArc<=0)return r;const o=r<0?-1:1,s=Math.abs(r),i=Math.floor(s/e.periodArc),m=s-i*e.periodArc,{s:u,x:l}=e,w=(k,$)=>{if($-k<=1)return[k,$];const q=k+$>>1;return u[q]<=m?w(q,$):w(k,q)},[d,R]=w(0,u.length-1),v=u[R]-u[d],M=v>0?(m-u[d])/v:0;return o*(i*e.wavelength+l[d]+(l[R]-l[d])*M)},zt=(e,r,o,s,i=0)=>{const m=Math.max(0,o),u=e>0?2*Math.PI*m/e:0,l=$=>s+r*Math.sin(u*$),w=$=>r*u*Math.cos(u*$),d=-i,v=e+i-d,M=Math.max(4,Math.ceil(m*4*(v/Math.max(e,1)))),k=Array.from({length:M},($,q)=>{const W=d+q/M*v,L=d+(q+1)/M*v,N=L-W,Q=l(W),I=l(L),G=W+N/3,J=Q+w(W)*N/3,ce=L-N/3,Z=I-w(L)*N/3;return`C${G.toFixed(2)} ${J.toFixed(2)} ${ce.toFixed(2)} ${Z.toFixed(2)} ${L.toFixed(2)} ${I.toFixed(2)}`});return[`M${d.toFixed(2)} ${l(d).toFixed(2)}`,...k].join(" ")},Ot=({item:e,prefix:r,textCss:o,capHeightPx:s,opticalOffsetY:i,imageGapPx:m,isCurve:u})=>{var k;const l=i!==0?{...o,transform:`translateY(${i}px)`}:o,w=s>0?{height:`${s}px`}:{fontSize:o.fontSize,height:`${se}em`},d=((k=e.image)==null?void 0:k.assetId)&&f.jsx("img",{src:e.image.assetId,alt:e.image.name??"",className:`${r}-item-image`,style:w}),R=d&&(u?f.jsx("span",{className:`${r}-item-image-wrap`,"data-marquee-wave-node":!0,children:d}):d),v=u?f.jsx("span",{className:`${r}-text`,style:l,children:Array.from(e.text).map(($,q)=>f.jsx("span",{className:`${r}-glyph`,"data-marquee-wave-node":!0,children:f.jsx("span",{className:`${r}-glyph-inner`,children:$===" "?" ":$})},q))}):f.jsx("span",{className:`${r}-text`,style:l,children:e.text}),M=f.jsxs(f.Fragment,{children:[R,v]});return f.jsx("div",{className:`${r}-item`,"data-marquee-text-item":!0,style:{gap:m},children:e.link?f.jsx("a",{href:e.link,className:`${r}-item-link`,style:{gap:m},children:M}):M})},Dt=({settings:e,content:r,isEditor:o,isPreviewMode:s})=>{const{prefix:i}=St.useScopedStyles(),[m,u]=a.useState(0),l=m>0?Math.round(m):0,{speed:w,direction:d,pauseOnHover:R,gap:v,layoutType:M,curveAmplitude:k,curveFrequency:$,textFontFamily:q,textFontSettings:W,textFontSize:L,textLetterSpacing:N,textWordSpacing:Q,textTextAppearance:I,textColor:G,backgroundColor:J,ribbonWidth:ce}=e,Z=ce??L,b=M==="curve",P=Lt(k),U=Ft($),Ke=a.useMemo(()=>Et(i,l,b),[i,l,b]),j=a.useMemo(()=>At.textStylesToCss({fontSettings:{fontFamily:q,fontWeight:W.fontWeight,fontStyle:W.fontStyle},letterSpacing:N,wordSpacing:Q,fontSize:L,lineHeight:L,textAppearance:I,color:G},o),[q,W,N,Q,L,I,G,o]),ee=n=>$t.scalingValue(n,o??!1),B=((r==null?void 0:r.length)??0)>0,X=o?!!s:!0,H=B&&(X||!!o),te=Math.max(0,w)*Mt,ue=X&&R==="on",[Qe,$e]=a.useState(!1),le=X?ue&&Qe?"paused":"running":"paused",de=le==="running"&&te>0&&l>0,Ge=l>0&&te>0?l/te*1e3:0,ne=a.useRef(null),fe=a.useRef(null),me=a.useRef(null),re=a.useRef(null),Se=a.useRef(null),Ae=a.useRef(null),Ee=a.useRef(de),V=a.useRef(null),Y=a.useRef(null),he=a.useRef(P),pe=a.useRef(U);Ee.current=de,he.current=P,pe.current=U;const[z,Me]=a.useState(0),[Je,Ce]=a.useState(0),[Re,ke]=a.useState(0),[K,qe]=a.useState(0),[Le,Ze]=a.useState(0),oe=a.useMemo(()=>(r??[]).map(n=>{var t;return`${n.text}\0${((t=n.image)==null?void 0:t.assetId)??""}\0${n.link??""}`}).join("\0"),[r]),[O,Fe]=a.useState(we),et=a.useMemo(()=>{const n=r??[];return n.length===0||!(X||o)?n:_t(n,O)},[r,X,O,o]),tt=H?Ue:1;a.useLayoutEffect(()=>{Fe(we),u(0)},[oe]),a.useLayoutEffect(()=>{var g;const n=Ae.current;if(!n)return;const t=()=>{const x=getComputedStyle(n),h=parseFloat(x.fontSize)||0;if(h<=0)return;const p=Wt();if(!p){Me(h*se),Ce(0);return}p.font=`${x.fontStyle} ${x.fontWeight} ${h}px ${x.fontFamily}`;const y=p.measureText("H"),F=y.actualBoundingBoxAscent>0?y.actualBoundingBoxAscent:h*se,A=Math.max(0,y.actualBoundingBoxDescent||0),E=y.fontBoundingBoxAscent||0,_=y.fontBoundingBoxDescent||0;Me(T=>Math.abs(T-F)>.5?F:T);const C=E>0||_>0?(_-A-(E-F))/2:0;Ce(T=>Math.abs(T-C)>.25?C:T)};t();const c=typeof document<"u"?document.fonts:void 0;(g=c==null?void 0:c.ready)==null||g.then(t).catch(()=>{});const S=new ResizeObserver(t);return S.observe(n),()=>S.disconnect()},[j.fontFamily,j.fontWeight,j.fontStyle,j.fontSize,j.lineHeight]),a.useLayoutEffect(()=>{if(!H)return;const n=ne.current,t=re.current;if(!n||!t)return;const c={id:0},S=()=>{const p=n.offsetWidth||n.getBoundingClientRect().width,y=t.offsetWidth||t.getBoundingClientRect().width;if(B&&p>0&&y>0){const F=y/O;if(F>0){let A=p,E=Ct;if(b){const C=p*he.current,T=pe.current,ae=T>0?2*Math.PI*T/p:0,ve=Ht(C,ae);A=Math.max(p,ve*p/(Ue-1)),E=Rt}const _=Math.min(E,Math.max(we,Math.ceil(A/F)+1));if(_!==O){Fe(_);return}}}y>0&&u(y)},g=()=>{cancelAnimationFrame(c.id),c.id=requestAnimationFrame(S)};g();const x=new ResizeObserver(g);x.observe(n),x.observe(t);const h=()=>{document.hidden||g()};return document.addEventListener("visibilitychange",h),window.addEventListener("pageshow",h),window.addEventListener("focus",h),()=>{cancelAnimationFrame(c.id),x.disconnect(),document.removeEventListener("visibilitychange",h),window.removeEventListener("pageshow",h),window.removeEventListener("focus",h)}},[H,oe,O,B,z,b,P,U]),a.useLayoutEffect(()=>{const n=Se.current;if(!n)return;const t={id:0},c=()=>{const g=n.offsetHeight;g>0&&Ze(x=>Math.abs(x-g)>.5?g:x)};t.id=requestAnimationFrame(c);const S=new ResizeObserver(()=>{cancelAnimationFrame(t.id),t.id=requestAnimationFrame(c)});return S.observe(n),()=>{cancelAnimationFrame(t.id),S.disconnect()}},[Z,o]),a.useLayoutEffect(()=>{if(!b){ke(0),qe(0);return}const n=ne.current,t=re.current;if(!n||!t)return;const c={id:0},S=()=>{const x=n.offsetWidth,h=t.offsetHeight;x>0&&qe(p=>Math.abs(p-x)>.5?x:p),h>0&&ke(p=>Math.abs(p-h)>.5?h:p)};c.id=requestAnimationFrame(S);const g=new ResizeObserver(()=>{cancelAnimationFrame(c.id),c.id=requestAnimationFrame(S)});return g.observe(n),g.observe(t),()=>{cancelAnimationFrame(c.id),g.disconnect()}},[b,oe,z,L,H]),a.useLayoutEffect(()=>{if(!H||l<=0)return;const n=me.current;n&&Tt(n)},[H,l,d,te]),a.useLayoutEffect(()=>{if(!b||!B)return;const n=ne.current;if(!n)return;const t={raf:0,cancelled:!1,lut:null,lutKey:"",itemsCache:[],cacheDirty:!0},c=()=>{for(const F of t.itemsCache)for(const A of F.glyphs)Xe(A.inner)},S=()=>{const F=fe.current??n;t.itemsCache=Array.from(n.querySelectorAll("[data-marquee-text-item]"),A=>{const E=[];return A.querySelectorAll("[data-marquee-wave-node]").forEach(_=>{const C=_.firstElementChild;C&&E.push({inner:C,layoutLocalX:Bt(_,F)})}),{item:A,glyphs:E}}),t.cacheDirty=!1},g=()=>{t.cacheDirty&&S();const A=(fe.current??n).offsetWidth||1,E=A*he.current,_=pe.current,C=2*Math.PI*_/A,T=`${A}|${E}|${C}`;if(T!==t.lutKey&&(t.lutKey=T,t.lut=Ye(E,C,Ve)),Math.abs(E)<=0||C<=0){c();return}const ae=me.current,ve=ae?jt(getComputedStyle(ae).transform):0,Pe=n.getBoundingClientRect(),ht=Pe.left,pt=Pe.right,gt=t.lut&&t.lut.wavelength>0?Math.max(0,(t.lut.periodArc/t.lut.wavelength-1)*A):0;for(const{item:xt,glyphs:ze}of t.itemsCache){const Oe=xt.getBoundingClientRect();if(Oe.right<ht||Oe.left>pt+gt){for(const ie of ze)Xe(ie.inner);continue}for(const ie of ze){const be=ie.layoutLocalX+ve,De=t.lut?Pt(t.lut,be):be,Ie=C*De,yt=E*Math.sin(Ie),vt=E*C*Math.cos(Ie),bt=Math.atan(vt)*(180/Math.PI);Nt(ie.inner,De-be,yt,bt)}}},x=()=>{t.cancelled||(t.raf=0,g(),Ee.current&&!document.hidden&&(t.raf=requestAnimationFrame(x)))},h=()=>{t.cancelled||t.raf||(t.raf=requestAnimationFrame(x))},p=()=>{t.cacheDirty=!0,g(),h()};V.current=h,Y.current=p,g(),h();const y=()=>{if(document.hidden){cancelAnimationFrame(t.raf),t.raf=0;return}cancelAnimationFrame(t.raf),t.raf=0,p()};return document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),window.addEventListener("focus",y),()=>{t.cancelled=!0,V.current=null,Y.current=null,cancelAnimationFrame(t.raf),document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y),window.removeEventListener("focus",y),c()}},[b,B]),a.useLayoutEffect(()=>{var n;!b||!B||(n=Y.current)==null||n.call(Y)},[b,B,m,oe,O,z,P,U,K]),a.useLayoutEffect(()=>{var n;(n=V.current)==null||n.call(V)},[de,d]);const nt=n=>{ue&&n.pointerType==="mouse"&&$e(!0)},rt=()=>{ue&&$e(!1)},Te=b?Math.abs(P)*100:0,ge=ee(Z),ot={minHeight:ge,...b?{paddingTop:`${Te}%`,paddingBottom:`${Te}%`}:{}},at={height:ge,...b?{visibility:"hidden"}:{backgroundColor:J}},_e={gap:ee(v),minHeight:ge},We=K*P,Ne=Math.abs(We),xe=Le>0?Le:Re,ye=Math.max(Re,xe),it=Ne+ye/2,st=Math.max(xe,1),je=b&&K>0&&ye>0?zt(K,We,U,it,st):"",ct=Ne*2+ye,ut=je?f.jsx("svg",{className:`${i}-curve-bg`,viewBox:`0 0 ${K} ${ct}`,preserveAspectRatio:"none","aria-hidden":!0,children:f.jsx("path",{d:je,fill:"none",stroke:J,strokeWidth:xe,strokeLinecap:"butt",strokeLinejoin:"round"})}):null,lt=f.jsx("div",{ref:Se,className:`${i}-ribbon`,style:at,"aria-hidden":!0}),dt={...j,lineHeight:z>0?`${z}px`:`${se}em`},Be=(n,t,c)=>f.jsx(Ot,{item:n,prefix:i,textCss:dt,capHeightPx:z,opticalOffsetY:Je,imageGapPx:ee(v),isCurve:b},`${t}-${c}`),ft=f.jsx("span",{ref:Ae,"aria-hidden":!0,className:`${i}-cap-ref`,style:j,children:"H"}),He=`${Math.max(0,Ge)/1e3}s`,mt=H?f.jsx("div",{ref:me,className:`${i}-marquee-track`,"data-direction":d,onPointerEnter:nt,onPointerLeave:rt,style:{WebkitAnimationDuration:He,animationDuration:He,WebkitAnimationPlayState:le,animationPlayState:le},children:Array.from({length:tt},(n,t)=>f.jsx("div",{ref:t===0?re:void 0,className:`${i}-marquee-set`,style:{..._e,paddingRight:ee(v)},"aria-hidden":t>0,children:et.map((c,S)=>Be(c,t,S))},`set-${t}`))}):f.jsx("div",{ref:re,className:wt(`${i}-marquee-set`,`${i}-marquee-static`),style:_e,children:r==null?void 0:r.map((n,t)=>Be(n,0,t))});return f.jsxs("div",{ref:ne,className:`${i}-wrapper`,"aria-label":"Marquee text",children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:Ke}}),ft,f.jsxs("div",{ref:fe,className:`${i}-marquee-wrapper`,style:ot,children:[lt,ut,mt]})]})};exports.MarqueeText=Dt;
@@ -1 +0,0 @@
1
- "use strict";const w=require("react"),I="100% 0px",V=new Map;function A(e){const t=V.get(e);if(t)return t;const r=new Map,o=new Map,c={observer:new IntersectionObserver(n=>{var a;for(const f of n)o.set(f.target,f.isIntersecting),(a=r.get(f.target))==null||a.forEach(d=>d(f.isIntersecting))},{rootMargin:e}),listeners:r,states:o};return V.set(e,c),c}function b(e,t,r){const{observer:o,listeners:i,states:c}=A(t),n=i.get(e)??new Set;n.size===0&&(i.set(e,n),o.observe(e)),n.add(r);const a=c.get(e);return a!==void 0&&r(a),()=>{n.delete(r),!(n.size>0)&&(i.delete(e),c.delete(e),o.unobserve(e))}}const g=["none","metadata","auto"];function E(e,t){g.indexOf(e.preload)<g.indexOf(t)&&(e.preload=t)}function R(e){const t=e.play();t&&t.catch(()=>{})}function l(e){e.paused||e.pause()}function N(e){return e.localName==="video"}function y(e,{autoPlay:t=!1,preload:r="auto",selector:o="video",shouldPlay:i}={}){w.useEffect(()=>{if(!e)return;const c=N(e),n=()=>c?[e]:Array.from(e.querySelectorAll(o));if(typeof IntersectionObserver>"u"){n().forEach(s=>{E(s,r),s.autoplay=t});return}let a=!1,f=!1;const d=()=>{n().forEach(s=>{a&&E(s,r),t&&(f&&(!i||i(s))?(s.muted=!0,s.paused&&R(s)):l(s))})},O=b(e,I,s=>{a=s,d()}),p=t?b(e,"0px",s=>{f=s,d()}):null,u=c?null:new MutationObserver(d);return u==null||u.observe(e,{childList:!0,subtree:!0,...i?{attributes:!0,attributeFilter:["class"]}:{}}),()=>{O(),p==null||p(),u==null||u.disconnect()}},[e,t,r,o,i])}exports.NEAR_VIEWPORT_MARGIN=I;exports.observeIntersection=b;exports.pauseVideo=l;exports.playVideo=R;exports.raisePreload=E;exports.useLazyVideos=y;
@@ -1,72 +0,0 @@
1
- import { useEffect as O } from "react";
2
- const V = "100% 0px", b = /* @__PURE__ */ new Map();
3
- function l(e) {
4
- const s = b.get(e);
5
- if (s) return s;
6
- const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = { observer: new IntersectionObserver((n) => {
7
- var a;
8
- for (const f of n)
9
- o.set(f.target, f.isIntersecting), (a = r.get(f.target)) == null || a.forEach((p) => p(f.isIntersecting));
10
- }, { rootMargin: e }), listeners: r, states: o };
11
- return b.set(e, c), c;
12
- }
13
- function g(e, s, r) {
14
- const { observer: o, listeners: i, states: c } = l(s), n = i.get(e) ?? /* @__PURE__ */ new Set();
15
- n.size === 0 && (i.set(e, n), o.observe(e)), n.add(r);
16
- const a = c.get(e);
17
- return a !== void 0 && r(a), () => {
18
- n.delete(r), !(n.size > 0) && (i.delete(e), c.delete(e), o.unobserve(e));
19
- };
20
- }
21
- const E = ["none", "metadata", "auto"];
22
- function w(e, s) {
23
- E.indexOf(e.preload) < E.indexOf(s) && (e.preload = s);
24
- }
25
- function x(e) {
26
- const s = e.play();
27
- s && s.catch(() => {
28
- });
29
- }
30
- function N(e) {
31
- e.paused || e.pause();
32
- }
33
- function R(e) {
34
- return e.localName === "video";
35
- }
36
- function A(e, { autoPlay: s = !1, preload: r = "auto", selector: o = "video", shouldPlay: i } = {}) {
37
- O(() => {
38
- if (!e) return;
39
- const c = R(e), n = () => c ? [e] : Array.from(e.querySelectorAll(o));
40
- if (typeof IntersectionObserver > "u") {
41
- n().forEach((t) => {
42
- w(t, r), t.autoplay = s;
43
- });
44
- return;
45
- }
46
- let a = !1, f = !1;
47
- const p = () => {
48
- n().forEach((t) => {
49
- a && w(t, r), s && (f && (!i || i(t)) ? (t.muted = !0, t.paused && x(t)) : N(t));
50
- });
51
- }, I = g(e, V, (t) => {
52
- a = t, p();
53
- }), d = s ? g(e, "0px", (t) => {
54
- f = t, p();
55
- }) : null, u = c ? null : new MutationObserver(p);
56
- return u == null || u.observe(e, {
57
- childList: !0,
58
- subtree: !0,
59
- ...i ? { attributes: !0, attributeFilter: ["class"] } : {}
60
- }), () => {
61
- I(), d == null || d(), u == null || u.disconnect();
62
- };
63
- }, [e, s, r, o, i]);
64
- }
65
- export {
66
- V as N,
67
- x as a,
68
- g as o,
69
- N as p,
70
- w as r,
71
- A as u
72
- };