import{a8 as j,ar as Y,d as x,x as Z,aj as G,a_ as ee,u as c,G as w,a3 as te,ab as A,ac as D,o as k,i as W,w as q,j as ae,f as $,n as H,X as m,M as X,v as le,T as se,O as oe,c as J,b as K,F as re,P as ne,a9 as E,a$ as U,E as I,am as ie,z as V,aa as ce,I as ue,y as ve,b0 as fe,a as me,C as de,h as he,as as pe,at as be}from"./app-84040815.js";const g=4,ye={vertical:{offset:"offsetHeight",scroll:"scrollTop",scrollSize:"scrollHeight",size:"height",key:"vertical",axis:"Y",client:"clientY",direction:"top"},horizontal:{offset:"offsetWidth",scroll:"scrollLeft",scrollSize:"scrollWidth",size:"width",key:"horizontal",axis:"X",client:"clientX",direction:"left"}},ge=({move:d,size:u,bar:r})=>({[r.size]:u,transform:`translate${r.axis}(${d}%)`}),Q=Symbol("scrollbarContextKey"),we=j({vertical:Boolean,size:String,move:Number,ratio:{type:Number,required:!0},always:Boolean}),Se="Thumb",ze=x({__name:"thumb",props:we,setup(d){const u=d,r=Z(Q),l=G("scrollbar");r||ee(Se,"can not inject scrollbar context");const i=c(),v=c(),o=c({}),f=c(!1);let a=!1,p=!1,b=oe?document.onselectstart:null;const t=w(()=>ye[u.vertical?"vertical":"horizontal"]),S=w(()=>ge({size:u.size,move:u.move,bar:t.value})),z=w(()=>i.value[t.value.offset]**2/r.wrapElement[t.value.scrollSize]/u.ratio/v.value[t.value.offset]),T=s=>{var e;if(s.stopPropagation(),s.ctrlKey||[1,2].includes(s.button))return;(e=window.getSelection())==null||e.removeAllRanges(),L(s);const n=s.currentTarget;n&&(o.value[t.value.axis]=n[t.value.offset]-(s[t.value.client]-n.getBoundingClientRect()[t.value.direction]))},B=s=>{if(!v.value||!i.value||!r.wrapElement)return;const e=Math.abs(s.target.getBoundingClientRect()[t.value.direction]-s[t.value.client]),n=v.value[t.value.offset]/2,h=(e-n)*100*z.value/i.value[t.value.offset];r.wrapElement[t.value.scroll]=h*r.wrapElement[t.value.scrollSize]/100},L=s=>{s.stopImmediatePropagation(),a=!0,document.addEventListener("mousemove",C),document.addEventListener("mouseup",y),b=document.onselectstart,document.onselectstart=()=>!1},C=s=>{if(!i.value||!v.value||a===!1)return;const e=o.value[t.value.axis];if(!e)return;const n=(i.value.getBoundingClientRect()[t.value.direction]-s[t.value.client])*-1,h=v.value[t.value.offset]-e,_=(n-h)*100*z.value/i.value[t.value.offset];r.wrapElement[t.value.scroll]=_*r.wrapElement[t.value.scrollSize]/100},y=()=>{a=!1,o.value[t.value.axis]=0,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",y),N(),p&&(f.value=!1)},M=()=>{p=!1,f.value=!!u.size},O=()=>{p=!0,f.value=a};te(()=>{N(),document.removeEventListener("mouseup",y)});const N=()=>{document.onselectstart!==b&&(document.onselectstart=b)};return A(D(r,"scrollbarElement"),"mousemove",M),A(D(r,"scrollbarElement"),"mouseleave",O),(s,e)=>(k(),W(se,{name:m(l).b("fade"),persisted:""},{default:q(()=>[ae($("div",{ref_key:"instance",ref:i,class:H([m(l).e("bar"),m(l).is(m(t).key)]),onMousedown:B},[$("div",{ref_key:"thumb",ref:v,class:H(m(l).e("thumb")),style:X(m(S)),onMousedown:T},null,38)],34),[[le,s.always||f.value]])]),_:1},8,["name"]))}});var F=Y(ze,[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/thumb.vue"]]);const _e=j({always:{type:Boolean,default:!0},width:String,height:String,ratioX:{type:Number,default:1},ratioY:{type:Number,default:1}}),Ee=x({__name:"bar",props:_e,setup(d,{expose:u}){const r=d,l=c(0),i=c(0);return u({handleScroll:o=>{if(o){const f=o.offsetHeight-g,a=o.offsetWidth-g;i.value=o.scrollTop*100/f*r.ratioY,l.value=o.scrollLeft*100/a*r.ratioX}}}),(o,f)=>(k(),J(re,null,[K(F,{move:l.value,ratio:o.ratioX,size:o.width,always:o.always},null,8,["move","ratio","size","always"]),K(F,{move:i.value,ratio:o.ratioY,size:o.height,vertical:"",always:o.always},null,8,["move","ratio","size","always"])],64))}});var ke=Y(Ee,[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/bar.vue"]]);const He=j({height:{type:[String,Number],default:""},maxHeight:{type:[String,Number],default:""},native:{type:Boolean,default:!1},wrapStyle:{type:ne([String,Object,Array]),default:""},wrapClass:{type:[String,Array],default:""},viewClass:{type:[String,Array],default:""},viewStyle:{type:[String,Array,Object],default:""},noresize:Boolean,tag:{type:String,default:"div"},always:Boolean,minSize:{type:Number,default:20}}),Te={scroll:({scrollTop:d,scrollLeft:u})=>[d,u].every(E)},Ce="ElScrollbar",Ne=x({name:Ce}),Pe=x({...Ne,props:He,emits:Te,setup(d,{expose:u,emit:r}){const l=d,i=G("scrollbar");let v,o;const f=c(),a=c(),p=c(),b=c("0"),t=c("0"),S=c(),z=c(1),T=c(1),B=w(()=>{const e={};return l.height&&(e.height=U(l.height)),l.maxHeight&&(e.maxHeight=U(l.maxHeight)),[l.wrapStyle,e]}),L=w(()=>[l.wrapClass,i.e("wrap"),{[i.em("wrap","hidden-default")]:!l.native}]),C=w(()=>[i.e("view"),l.viewClass]),y=()=>{var e;a.value&&((e=S.value)==null||e.handleScroll(a.value),r("scroll",{scrollTop:a.value.scrollTop,scrollLeft:a.value.scrollLeft}))};function M(e,n){pe(e)?a.value.scrollTo(e):E(e)&&E(n)&&a.value.scrollTo(e,n)}const O=e=>{E(e)&&(a.value.scrollTop=e)},N=e=>{E(e)&&(a.value.scrollLeft=e)},s=()=>{if(!a.value)return;const e=a.value.offsetHeight-g,n=a.value.offsetWidth-g,h=e**2/a.value.scrollHeight,_=n**2/a.value.scrollWidth,P=Math.max(h,l.minSize),R=Math.max(_,l.minSize);z.value=h/(e-h)/(P/(e-P)),T.value=_/(n-_)/(R/(n-R)),t.value=P+g<e?`${P}px`:"",b.value=R+g<n?`${R}px`:""};return I(()=>l.noresize,e=>{e?(v==null||v(),o==null||o()):({stop:v}=ie(p,s),o=A("resize",s))},{immediate:!0}),I(()=>[l.maxHeight,l.height],()=>{l.native||V(()=>{var e;s(),a.value&&((e=S.value)==null||e.handleScroll(a.value))})}),ce(Q,ue({scrollbarElement:f,wrapElement:a})),ve(()=>{l.native||V(()=>{s()})}),fe(()=>s()),u({wrapRef:a,update:s,scrollTo:M,setScrollTop:O,setScrollLeft:N,handleScroll:y}),(e,n)=>(k(),J("div",{ref_key:"scrollbarRef",ref:f,class:H(m(i).b())},[$("div",{ref_key:"wrapRef",ref:a,class:H(m(L)),style:X(m(B)),onScroll:y},[(k(),W(de(e.tag),{ref_key:"resizeRef",ref:p,class:H(m(C)),style:X(e.viewStyle)},{default:q(()=>[me(e.$slots,"default")]),_:3},8,["class","style"]))],38),e.native?he("v-if",!0):(k(),W(ke,{key:0,ref_key:"barRef",ref:S,height:t.value,width:b.value,always:e.always,"ratio-x":T.value,"ratio-y":z.value},null,8,["height","width","always","ratio-x","ratio-y"]))],2))}});var Re=Y(Pe,[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/scrollbar.vue"]]);const Be=be(Re);export{Be as E}; //# sourceMappingURL=index-1dc6c986.js.map