2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{d as le,u as Ie,o as xe,a as Re,b as we,w as ce,c as Ae,e as n,f as r,g as d,F as j,r as U,n as N,h as $,i as te,j as O,k as E,s as Me,_ as ie,t as ee,l as Fe,m as De,p as Ee,q as s,v as Le,x as v,I as G,y as Be,z as Ve,A as Ne,B as ne,C as $e,D as Oe,E as Xe,G as qe,K as he,H as V,J as Te,L as ge,M as We,N as Z,O as ue}from"./index-Cu2VAQBj.js";import{R as He}from"./RateStrip-BlWw2lSm.js";import{P as ye}from"./ProductCard-w77j8EA9.js";import{S as be}from"./SectionHead-CpGrRHt8.js";import{u as je}from"./filtersStore-DKlUqmc5.js";import{u as Ue}from"./useReveal-C6_zxE5K.js";import{u as Ge}from"./catalogStore-DU2bF1aY.js";import{P as Ke}from"./index-zS7lUV1L.js";import"./filters-DYLoih7M.js";const Je={key:0,class:"carousel"},Ye=["data-index"],Qe=["src"],Ze={key:0,class:"carousel__dots",dir:"ltr"},et=["aria-label","onClick"],ke=.92,tt=le({__name:"Carousel",props:{slides:{},sideScale:{default:.72},gap:{default:3},borderRadius:{default:22},stiffness:{default:70},damping:{default:28},autoplay:{type:Boolean,default:!0},autoplayInterval:{default:7500}},setup(y){const a=y,h=Ie(),z=O(()=>{const e=a.slides.filter(t=>t.image);if(!e.length)return[];const o=[];let i=0;for(;o.length<Math.max(6,e.length*2);)for(const t of e)o.push({key:`${t.key}#${i++}`,image:t.image});return o}),x=E(null),_=E(null),g=E(!1),A=E(0),M=Me([]);let f=0,p=0,m=0,P=!1,C=0,I=0,S=0,L=0,X=0,q=0,R=null,b=null,K=0,T,B=null;function se(e,o,i){let t=(e-o)%i;return t<-i/2&&(t+=i),t>=i/2&&(t-=i),t}function J(){const e=a.slides.filter(o=>o.image).length||1;return(Math.round(p)%e+e)%e}function l(){A.value=J()}function c(){var pe;const o=z.value.length;if(!o){M.value=[];return}const t=(((pe=_.value)==null?void 0:pe.clientWidth)||380)*ke,w=a.sideScale,D=a.gap,H=t*.5+t*w*.5+D,fe=new Array(o);for(let oe=0;oe<o;oe++){const me=se(oe,f,o),re=Math.abs(me),Se=1-Math.min(re,1)*(1-w),Pe=me*H,ve=re<2.1;fe[oe]={opacity:ve?"1":"0",pointerEvents:ve?"auto":"none",zIndex:String(100-Math.round(re*20)),transform:`translate3d(calc(-50% + ${Pe.toFixed(2)}px), 0, 0) scale(${Se.toFixed(4)})`}}M.value=fe}function k(){if(h.isReducedMotion){f=p,m=0,c(),b=null;return}b!=null&&cancelAnimationFrame(b),K=performance.now();const e=o=>{const i=Math.min((o-K)/1e3,.064);K=o;const t=f-p,w=-a.stiffness*t,D=-a.damping*m,H=w+D;if(m+=H*i,f+=m*i,c(),Math.abs(m)<.002&&Math.abs(p-f)<.001){f=p,m=0,c(),b=null;return}b=requestAnimationFrame(e)};b=requestAnimationFrame(e)}function F(e){var i;if(z.value.length<2||R!==null||e.button!==void 0&&e.button!==0)return;const o=x.value;o&&(R=e.pointerId,P=!0,g.value=!0,ae(),b!=null&&(cancelAnimationFrame(b),b=null),C=e.clientX,S=e.clientX,I=f,m=0,X=0,q=0,L=performance.now(),(i=o.setPointerCapture)==null||i.call(o,e.pointerId))}function u(e){var H;if(!P||e.pointerId!==R)return;const o=performance.now(),i=Math.max(1,o-L),t=e.clientX-C,w=e.clientX-S;q=Math.abs(t);const D=(((H=_.value)==null?void 0:H.clientWidth)??0)*ke||320;f=I-t/D,X=-(w/D)/(i/1e3),S=e.clientX,L=o,c()}function W(e){if(!P||e.pointerId!==R)return;P=!1,g.value=!1,R=null;const o=z.value.length;if(q<6&&e.target instanceof Element){const t=e.target.closest(".carousel__card");if(t){const w=Number(t.dataset.index);if(!Number.isNaN(w)){const D=se(w,f,o);if(Math.abs(D)>.25){p=Math.round(f+D),k(),l(),a.autoplay&&Q();return}}}}m=X;const i=f+m*.16;p=Math.round(i),k(),l(),a.autoplay&&Q()}function ze(e){const o=a.slides.filter(w=>w.image).length;if(o<2)return;const i=J();let t=e-i;t>o/2&&(t-=o),t<-o/2&&(t+=o),p=Math.round(p)+t,k(),l()}let Y=!0;function Q(){ae(),Y&&(!a.autoplay||h.isReducedMotion||a.slides.length<2||(T=setInterval(()=>{!P&&Y&&(p=Math.round(p)+1,k(),l())},a.autoplayInterval)))}function ae(){T&&(clearInterval(T),T=void 0)}function de(){Y=!1,ae(),b!=null&&(cancelAnimationFrame(b),b=null),f=p,m=0,P=!1,g.value=!1,c(),l()}function Ce(){Y=!0,c(),a.autoplay&&Q()}function _e(){f=0,p=0,m=0,l(),c()}return xe(()=>{Y=!0,_e(),_.value&&typeof ResizeObserver<"u"&&(B=new ResizeObserver(()=>c()),B.observe(_.value)),a.autoplay&&Q()}),Re(de),we(Ce),ce(()=>a.slides,()=>{_e()}),ce(()=>[a.sideScale,a.gap,a.stiffness,a.damping]
|