var t,L,c,f,p,O,u,w,C=function(){return typeof window<"u"},B=function(){return t||C()&&(t=window.gsap)&&t.registerPlugin&&t},G=function(o){return typeof o=="string"},S=function(o){return typeof o=="function"},h=function(o,i){var s=i==="x"?"Width":"Height",r="scroll"+s,l="client"+s;return o===c||o===f||o===p?Math.max(f[r],p[r])-(c["inner"+s]||f[l]||p[l]):o[r]-o["offset"+s]},T=function(o,i){var s="scroll"+(i==="x"?"Left":"Top");return o===c&&(o.pageXOffset!=null?s="page"+i.toUpperCase()+"Offset":o=f[s]!=null?f:p),function(){return o[s]}},E=function(o,i,s,r){if(S(o)&&(o=o(i,s,r)),typeof o!="object")return G(o)&&o!=="max"&&o.charAt(1)!=="="?{x:o,y:o}:{y:o};if(o.nodeType)return{y:o,x:o};var l={},n;for(n in o)l[n]=n!=="onAutoKill"&&S(o[n])?o[n](i,s,r):o[n];return l},R=function(o,i){if(o=O(o)[0],!o||!o.getBoundingClientRect)return console.warn("scrollTo target doesn't exist. Using 0")||{x:0,y:0};var s=o.getBoundingClientRect(),r=!i||i===c||i===p,l=r?{top:f.clientTop-(c.pageYOffset||f.scrollTop||p.scrollTop||0),left:f.clientLeft-(c.pageXOffset||f.scrollLeft||p.scrollLeft||0)}:i.getBoundingClientRect(),n={x:s.left-l.left,y:s.top-l.top};return!r&&i&&(n.x+=T(i,"x")(),n.y+=T(i,"y")()),n},m=function(o,i,s,r,l){return!isNaN(o)&&typeof o!="object"?parseFloat(o)-l:G(o)&&o.charAt(1)==="="?parseFloat(o.substr(2))*(o.charAt(0)==="-"?-1:1)+r-l:o==="max"?h(i,s)-l:Math.min(h(i,s),R(o,i)[s]-l)},b=function(){t=B(),C()&&t&&typeof document<"u"&&document.body&&(c=window,p=document.body,f=document.documentElement,O=t.utils.toArray,t.config({autoKillThreshold:7}),u=t.config(),L=1)},k={version:"3.15.0",name:"scrollTo",rawVars:1,register:function(o){t=o,b()},init:function(o,i,s,r,l){L||b();var n=this,x=t.getProperty(o,"scrollSnapType");n.isWin=o===c,n.target=o,n.tween=s,i=E(i,r,o,l),n.vars=i,n.autoKill=!!("autoKill"in i?i:u).autoKill,n.getX=T(o,"x"),n.getY=T(o,"y"),n.x=n.xPrev=n.getX(),n.y=n.yPrev=n.getY(),w||(w=t.core.globals().ScrollTrigger),t.getProperty(o,"scrollBehavior")==="smooth"&&t.set(o,{scrollBehavior:"auto"}),x&&x!=="none"&&(n.snap=1,n.snapInline=o.style.scrollSnapType,o.style.scrollSnapType="none"),i.x!=null?(n.add(n,"x",n.x,m(i.x,o,"x",n.x,i.offsetX||0),r,l),n._props.push("scrollTo_x")):n.skipX=1,i.y!=null?(n.add(n,"y",n.y,m(i.y,o,"y",n.y,i.offsetY||0),r,l),n._props.push("scrollTo_y")):n.skipY=1},render:function(o,i){for(var s=i._pt,r=i.target,l=i.tween,n=i.autoKill,x=i.xPrev,A=i.yPrev,P=i.isWin,d=i.snap,K=i.snapInline,y,_,X,Y,g;s;)s.r(o,s.d),s=s._next;y=P||!i.skipX?i.getX():x,_=P||!i.skipY?i.getY():A,X=_-A,Y=y-x,g=u.autoKillThreshold,i.x<0&&(i.x=0),i.y<0&&(i.y=0),n&&(!i.skipX&&(Y>g||Y<-g)&&y<h(r,"x")&&(i.skipX=1),!i.skipY&&(X>g||X<-g)&&_<h(r,"y")&&(i.skipY=1),i.skipX&&i.skipY&&(l.kill(),i.vars.onAutoKill&&i.vars.onAutoKill.apply(l,i.vars.onAutoKillParams||[]))),P?c.scrollTo(i.skipX?y:i.x,i.skipY?_:i.y):(i.skipY||(r.scrollTop=i.y),i.skipX||(r.scrollLeft=i.x)),d&&(o===1||o===0)&&(_=r.scrollTop,y=r.scrollLeft,K?r.style.scrollSnapType=K:r.style.removeProperty("scroll-snap-type"),r.scrollTop=_+1,r.scrollLeft=y+1,r.scrollTop=_,r.scrollLeft=y),i.xPrev=i.x,i.yPrev=i.y,w&&w.update()},kill:function(o){var i=o==="scrollTo",s=this._props.indexOf(o);return(i||o==="scrollTo_x")&&(this.skipX=1),(i||o==="scrollTo_y")&&(this.skipY=1),s>-1&&this._props.splice(s,1),!this._props.length}};k.max=h;k.getOffset=R;k.buildGetter=T;k.config=function(e){u||b()||(u=t.config());for(var o in e)u[o]=e[o]};B()&&t.registerPlugin(k);export{k as ScrollToPlugin,k as default};
