import{J as D,bm as j,K as E,bn as M,r as R,c as C,bY as T,ah as _,O as g,aE as z,j as B,cK as F,cd as I}from"./index-CS0Lg7FU.js";const x=[["left","center","start","width"],["right","center","end","width"],["top","start","center","height"],["bottom","end","center","height"]],O=D({name:"QSlideItem",props:{...j,leftColor:String,rightColor:String,topColor:String,bottomColor:String,onSlide:Function},emits:["action","top","right","bottom","left"],setup(f,{slots:o,emit:m}){const{proxy:v}=E(),{$q:y}=v,$=M(f,y),{getCache:S}=F(),p=R(null);let l=null,e={},u={},h={};const d=C(()=>y.lang.rtl===!0?{left:"right",right:"left"}:{left:"left",right:"right"}),k=C(()=>"q-slide-item q-item-type overflow-hidden"+($.value===!0?" q-slide-item--dark q-dark":""));function b(){p.value.style.transform="translate(0,0)"}function w(t,a,n){f.onSlide!==void 0&&m("slide",{side:t,ratio:a,isReset:n})}function q(t){const a=p.value;if(t.isFirst)e={dir:null,size:{left:0,right:0,top:0,bottom:0},scale:0},a.classList.add("no-transition"),x.forEach(i=>{if(o[i[0]]!==void 0){const c=h[i[0]];c.style.transform="scale(1)",e.size[i[0]]=c.getBoundingClientRect()[i[3]]}}),e.axis=t.direction==="up"||t.direction==="down"?"Y":"X";else if(t.isFinal){a.classList.remove("no-transition"),e.scale===1?(a.style.transform=`translate${e.axis}(${e.dir*100}%)`,l!==null&&clearTimeout(l),l=setTimeout(()=>{l=null,m(e.showing,{reset:b}),m("action",{side:e.showing,reset:b})},230)):(a.style.transform="translate(0,0)",w(e.showing,0,!0));return}else t.direction=e.axis==="X"?t.offset.x<0?"left":"right":t.offset.y<0?"up":"down";if(o.left===void 0&&t.direction===d.value.right||o.right===void 0&&t.direction===d.value.left||o.top===void 0&&t.direction==="down"||o.bottom===void 0&&t.direction==="up"){a.style.transform="translate(0,0)";return}let n,s,r;e.axis==="X"?(s=t.direction==="left"?-1:1,n=s===1?d.value.left:d.value.right,r=t.distance.x):(s=t.direction==="up"?-2:2,n=s===2?"top":"bottom",r=t.distance.y),!(e.dir!==null&&Math.abs(s)!==Math.abs(e.dir))&&(e.dir!==s&&(["left","right","top","bottom"].forEach(i=>{u[i]&&(u[i].style.visibility=n===i?"visible":"hidden")}),e.showing=n,e.dir=s),e.scale=Math.max(0,Math.min(1,(r-40)/e.size[n])),a.style.transform=`translate${e.axis}(${r*s/Math.abs(s)}px)`,h[n].style.transform=`scale(${e.scale})`,w(n,e.scale,!1))}return T(()=>{u={},h={}}),_(()=>{l!==null&&clearTimeout(l)}),Object.assign(v,{reset:b}),()=>{const t=[],a={left:o[d.value.right]!==void 0,right:o[d.value.left]!==void 0,up:o.bottom!==void 0,down:o.top!==void 0},n=Object.keys(a).filter(r=>a[r]===!0);x.forEach(r=>{const i=r[0];o[i]!==void 0&&t.push(g("div",{key:i,ref:c=>{u[i]=c},class:`q-slide-item__${i} absolute-full row no-wrap items-${r[1]} justify-${r[2]}`+(f[i+"Color"]!==void 0?` bg-${f[i+"Color"]}`:"")},[g("div",{ref:c=>{h[i]=c}},o[i]())]))});const s=g("div",{key:`${n.length===0?"only-":""} content`,ref:p,class:"q-slide-item__content"},z(o.default));return n.length===0?t.push(s):t.push(B(s,S("dir#"+n.join(""),()=>{const r={prevent:!0,stop:!0,mouse:!0};return n.forEach(i=>{r[i]=!0}),[[I,q,void 0,r]]}))),g("div",{class:k.value},t)}}});export{O as Q};
