import{s as st}from"./main.js";import{g as s,D as W,S as it}from"./gsap.js";import"./lenis.js";import"./barba.js";s.registerPlugin(W);function ut(_){const z=st(_),b=[];if(z.querySelectorAll("[data-orbit-tiles-init]").forEach(o=>{var I,L;if(o.hasAttribute("data-orbit-ready"))return;o.setAttribute("data-orbit-ready","true");const q=o.querySelector("[data-orbit-tiles-list]"),n=Array.from(o.querySelectorAll("[data-orbit-tiles-item]")),M=o.querySelector("[data-orbit-tiles-caption-name]"),v=o.querySelector("[data-orbit-tiles-caption-text]"),A=o.querySelector("[data-orbit-tiles-counter-current]"),E=o.querySelector("[data-orbit-tiles-counter-total]"),a=n.length;if(!q||a<2)return;const P="polygon(46% 46%, 54% 46%, 54% 54%, 46% 54%)",C="polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",c=n.map(t=>t.querySelector(".demo-card__media")),D=n.map(t=>t.getAttribute("data-orbit-tiles-name")||""),F=n.map(t=>t.getAttribute("data-orbit-tiles-text")||""),X=n.map(t=>s.quickSetter(t,"x","px")),Y=n.map(t=>s.quickSetter(t,"y","px")),$=n.map(t=>s.quickSetter(t,"scale")),U=n.map(t=>s.quickSetter(t,"zIndex")),V=c.map(t=>t?s.quickSetter(t,"filter"):null),Z=2.15,j=0,G=.04,B=.2,w=.3,H=1.3,i={progress:0};let u=0,f=!1,e,T=-1,h=n[0].offsetWidth||1;const J=Math.PI*2,K=1/a;c.some(Boolean)&&s.set(c.filter(Boolean),{clipPath:C}),E&&(E.textContent=String(a));function N(t){return(t%a+a)%a}function g(){const t=h,y=t*Z,et=t*j,ot=t*G,p=N(Math.round(i.progress)),rt=i.progress;for(let r=0;r<a;r++){const k=(r-rt)*K*J,m=((Math.cos(k)+1)*.5)**H;X[r](Math.sin(k)*y),Y[r](Math.cos(k)*et),$[r](B+(1-B)*m),U[r](m*1e3+.5|0);const R=V[r];R&&R(`blur(${(1-m)*ot}px) brightness(${w+(1-w)*m})`)}if(p!==T){T=p;for(let r=0;r<a;r++)n[r].setAttribute("data-orbit-tiles-item-status",r===p?"active":"not-active");M&&(M.textContent=D[p]),v&&(v.textContent=F[p]),A&&(A.textContent=String(p+1))}}function d(t,y=.55){u=t,e==null||e.kill(),s.to(i,{progress:t,duration:y,ease:"osmo",overwrite:!0,onUpdate:g,onComplete(){i.progress=t,g(),f&&(e=s.delayedCall(1.8,()=>d(u+1,2.5)))}})}(I=o.querySelector("[data-orbit-tiles-prev]"))==null||I.addEventListener("click",()=>{d(u-1)}),(L=o.querySelector("[data-orbit-tiles-next]"))==null||L.addEventListener("click",()=>{d(u+1)});const Q=document.createElement("div");let x=0;const tt=W.create(Q,{trigger:q,type:"x",zIndexBoost:!1,onPress(){s.killTweensOf(i),e==null||e.kill(),u=i.progress,x=this.x},onDrag(){i.progress-=(this.x-x)/h,u=i.progress,x=this.x,g()},onRelease(){d(Math.round(i.progress),.7)}});g();let S=0;const O=new ResizeObserver(()=>{S||(S=requestAnimationFrame(()=>{S=0,h=n[0].offsetWidth||1,g()}))});O.observe(o);const l=c.some(Boolean)?s.fromTo(c.filter(Boolean),{clipPath:P},{clipPath:C,duration:1.25,ease:"expo.out",paused:!0,immediateRender:!1}):null;it.create({trigger:o,start:"top bottom",end:"bottom top",onEnter(){f=!0,l==null||l.restart(!0),d(Math.round(i.progress),0)},onEnterBack(){f=!0,d(Math.round(i.progress),0)},onLeave(){f=!1,e==null||e.kill()},onLeaveBack(){f=!1,e==null||e.kill(),l==null||l.pause(0);const t=c.filter(Boolean);t.length&&s.set(t,{clipPath:P})}}),b.push(()=>{var t;e==null||e.kill(),s.killTweensOf(i),l==null||l.kill(),(t=tt[0])==null||t.kill(),O.disconnect(),o.removeAttribute("data-orbit-ready")})}),!!b.length)return()=>b.forEach(o=>o())}export{ut as default};
