function A(p,O,x){return Math.min(Math.max(p,O),x)}function m(p){return typeof p=="number"&&!isNaN(p)}function k(p={}){let n,f=[],F,S=0,u=0,v=0,y=!1,b,P;function I(t){n=t;const o=n.selectedScrollSnap(),{scrollBody:e,containerRect:c,axis:s}=n.internalEngine(),r=s.measureSize(c);F=A(r*.75,200,500),y=!1,f=n.scrollSnapList().map((i,l)=>l===o?1:0),b=e.settled,P=n.scrollProgress,e.settled=_,n.scrollProgress=$,n.on("select",B).on("slideFocus",h).on("pointerDown",D).on("pointerUp",w),U(),h()}function N(){const{scrollBody:t}=n.internalEngine();t.settled=b,n.scrollProgress=P,n.off("select",B).off("slideFocus",h).off("pointerDown",D).off("pointerUp",w),n.slideNodes().forEach(o=>{const e=o.style;e.opacity="",e.transform="",e.pointerEvents="",o.getAttribute("style")||o.removeAttribute("style")})}function h(){const t=n.selectedScrollSnap();M(t,1)}function w(){y=!1}function D(){y=!1,S=0,u=0}function B(){const t=n.internalEngine().scrollBody.duration();u=t?0:1,y=!0,t||h()}function R(t){const{axis:o}=n.internalEngine();return`translate${o.scroll.toUpperCase()}(${o.direction(t)}px)`}function U(){const{translate:t,slideLooper:o}=n.internalEngine();t.clear(),t.toggleActive(!1),o.loopPoints.forEach(({translate:e})=>{e.clear(),e.toggleActive(!1)})}function H(t){const{scrollSnaps:o,location:e,target:c}=n.internalEngine();!m(t)||f[t]<.5||(e.set(o[t]),c.set(e))}function M(t,o){n.scrollSnapList().forEach((c,s)=>{const r=Math.abs(o),i=f[s],l=s===t,a=l?i+r:i-r,d=A(a,0,1);f[s]=d;const g=l&&y,E=n.previousScrollSnap();g&&(f[E]=1-d),l&&z(t,d),L(s)})}function L(t){const o=n.internalEngine().slideRegistry[t],{scrollSnaps:e,containerRect:c}=n.internalEngine(),s=f[t];o.forEach(r=>{const i=n.slideNodes()[r].style,l=parseFloat(s.toFixed(2)),a=l>0,d=a?e[t]:c.width+2,g=R(d);a&&(i.transform=g),i.opacity=l.toString(),i.pointerEvents=s>.5?"auto":"none",a||(i.transform=g)})}function z(t,o){const{index:e,dragHandler:c,scrollSnaps:s}=n.internalEngine(),r=c.pointerDown(),i=1/(s.length-1);let l=t,a=r?n.selectedScrollSnap():n.previousScrollSnap();if(r&&l===a){const E=Math.sign(S)*-1;l=a,a=e.clone().set(a).add(E).get()}const d=a*i,g=(l-a)*i;v=d+g*o}function T(){const{dragHandler:t,index:o,scrollBody:e}=n.internalEngine(),c=n.selectedScrollSnap();if(!t.pointerDown())return c;const s=Math.sign(e.velocity()),r=Math.sign(S),i=o.clone().set(c).add(s*-1).get();return!s||!r?null:r===s?i:c}function V(t){const{dragHandler:o,scrollBody:e}=t.internalEngine(),c=o.pointerDown(),s=e.velocity(),r=e.duration(),i=T(),l=!m(i);if(c){if(!s)return;S+=s,u=Math.abs(s/F),H(i)}if(!c){if(!r||l)return;u+=(1-f[i])/r,u*=.68}l||M(i,u)}function _(){const{target:t,location:o}=n.internalEngine(),e=t.get()-o.get(),c=Math.abs(e)>=1,s=T(),r=!m(s);return V(n),r||c?!1:f[s]>.999}function $(){return v}return{name:"fade",options:p,init:I,destroy:N}}k.globalOptions=void 0;export{k as default};
//# sourceMappingURL=embla-carousel-fade.esm-wrqBHFeW.js.map
