import{az as le,ad as c,cU as ne,cV as m,a$ as y,e as z,cW as oe,d as se,f as W,r as j,A as ie,cX as ue,a as E,w as ce,by as de,bW as V,aW as ve,c3 as me,c5 as pe}from"./index-BP6bNRoi.js";var k=Number.isNaN||function(e){return typeof e=="number"&&e!=e};function fe(e,a){if(e.length!==a.length)return!1;for(var l=0;l{const e=le().proxy.$props;return c(()=>{const a=(l,n,r)=>({});return e.perfMode?ne(a):function(l,n){n===void 0&&(n=fe);var r=null;function p(){for(var u=[],d=0;doe([])},direction:Me,height:{type:[String,Number],required:!0},innerElement:{type:[String,Object],default:"div"},style:{type:y([Object,String,Array])},useIsScrolling:{type:Boolean,default:!1},width:{type:[Number,String],required:!1},perfMode:{type:Boolean,default:!0},scrollbarAlwaysOn:{type:Boolean,default:!1}}),Le=z({cache:$,estimatedItemSize:T,layout:Y,initScrollOffset:O,total:M,itemSize:R,..._}),q={type:Number,default:6},J={type:Number,default:0},Q={type:Number,default:2},Ce=z({columnCache:$,columnWidth:R,estimatedColumnWidth:T,estimatedRowHeight:T,initScrollLeft:O,initScrollTop:O,itemKey:{type:y(Function),default:({columnIndex:e,rowIndex:a})=>`${a}:${e}`},rowCache:$,rowHeight:R,totalColumn:M,totalRow:M,hScrollbarSize:q,vScrollbarSize:q,scrollbarStartGap:J,scrollbarEndGap:Q,role:String,..._}),Z=z({alwaysOn:Boolean,class:String,layout:Y,total:M,ratio:{type:Number,required:!0},clientSize:{type:Number,required:!0},scrollFrom:{type:Number,required:!0},scrollbarSize:q,startGap:J,endGap:Q,visible:Boolean}),Ie=(e,a)=>ee==="ltr"||e===B||e===b,Re=e=>e===B;let S=null;function Te(e=!1){if(S===null||e){const a=document.createElement("div"),l=a.style;l.width="50px",l.height="50px",l.overflow="scroll",l.direction="rtl";const n=document.createElement("div"),r=n.style;return r.width="100px",r.height="100px",a.appendChild(n),document.body.appendChild(a),a.scrollLeft>0?S=X:(a.scrollLeft=1,S=a.scrollLeft===0?K:U),document.body.removeChild(a),S}return S}const $e=se({name:"ElVirtualScrollBar",props:Z,emits:["scroll","start-move","stop-move"],setup(e,{emit:a}){const l=c(()=>e.startGap+e.endGap),n=W("virtual-scrollbar"),r=W("scrollbar"),p=j(),u=j();let d=null,f=null;const i=ie({isDragging:!1,traveled:0}),o=c(()=>ue[e.layout]),A=c(()=>e.clientSize-E(l)),ee=c(()=>({position:"absolute",width:`${b===e.layout?A.value:e.scrollbarSize}px`,height:`${b===e.layout?e.scrollbarSize:A.value}px`,[Ee[e.layout]]:"2px",right:"2px",bottom:"2px",borderRadius:"4px"})),L=c(()=>{const t=e.ratio,s=e.clientSize;if(t>=100)return Number.POSITIVE_INFINITY;if(t>=50)return t*s/100;const g=s/3;return Math.floor(Math.min(Math.max(t*s,20),g))}),te=c(()=>{if(!Number.isFinite(L.value))return{display:"none"};const t=`${L.value}px`;return function({move:g,size:N,bar:G},re){const v={},C=`translate${G.axis}(${g}px)`;return v[G.size]=N,v.transform=C,v.msTransform=C,v.webkitTransform=C,re==="horizontal"?v.height="100%":v.width="100%",v}({bar:o.value,size:t,move:i.traveled},e.layout)}),h=c(()=>Math.floor(e.clientSize-L.value-E(l))),D=()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w),document.onselectstart=f,f=null;const t=E(u);t&&(t.removeEventListener("touchmove",x),t.removeEventListener("touchend",w))},F=t=>{t.stopImmediatePropagation(),t.ctrlKey||[1,2].includes(t.button)||(i.isDragging=!0,i[o.value.axis]=t.currentTarget[o.value.offset]-(t[o.value.client]-t.currentTarget.getBoundingClientRect()[o.value.direction]),a("start-move"),(()=>{window.addEventListener("mousemove",x),window.addEventListener("mouseup",w);const s=E(u);s&&(f=document.onselectstart,document.onselectstart=()=>!1,s.addEventListener("touchmove",x),s.addEventListener("touchend",w))})())},w=()=>{i.isDragging=!1,i[o.value.axis]=0,a("stop-move"),D()},x=t=>{const{isDragging:s}=i;if(!s||!u.value||!p.value)return;const g=i[o.value.axis];if(!g)return;me(d);const N=-1*(p.value.getBoundingClientRect()[o.value.direction]-t[o.value.client])-(u.value[o.value.offset]-g);d=pe(()=>{i.traveled=Math.max(e.startGap,Math.min(N,h.value)),a("scroll",N,h.value)})},ae=t=>{const s=Math.abs(t.target.getBoundingClientRect()[o.value.direction]-t[o.value.client])-u.value[o.value.offset]/2;i.traveled=Math.max(0,Math.min(s,h.value)),a("scroll",s,h.value)};return ce(()=>e.scrollFrom,t=>{i.isDragging||(i.traveled=Math.ceil(t*h.value))}),de(()=>{D()}),()=>V("div",{role:"presentation",ref:p,class:[n.b(),e.class,(e.alwaysOn||i.isDragging)&&"always-on"],style:ee.value,onMousedown:ve(ae,["stop","prevent"]),onTouchstartPrevent:F},V("div",{ref:u,class:r.e("thumb"),style:te.value,onMousedown:F},[]))}});export{Se as A,P as B,Ne as C,he as D,ze as E,H as F,b as H,ye as I,B as R,be as S,I as V,U as a,K as b,$e as c,Ie as d,X as e,xe as f,Te as g,we as h,Be as i,Ce as j,Re as k,Z as l,ge as u,Le as v};