"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),h=require("@vueuse/core"),_=require("lodash-unified");require("./internal.vue2.js");const u=require("./utils/index.js"),g=require("./internal.vue.js"),m=e.defineComponent({name:"ScrollBar",__name:"index",props:{scrollContainer:{},extraSize:{default:0},direction:{default:"vertical"},scroll:{},barLength:{default:30},width:{},barColor:{},trackColor:{},trackWidth:{},disabled:{type:Boolean,default:!1},showTrack:{type:Boolean,default:!0},trackSpeed:{default:2},onScrollStart:{},onScroll:{},onScrollEnd:{}},setup(d,{expose:S}){const t=d,o=e.toRef(t,"scrollContainer"),n=e.shallowRef(),a=e.ref(t.barLength);function p(){if(!o.value||!n.value)return;const{totalSize:r,visibleSize:l,distance:c}=u.getScrollable(o.value,t.direction),i=c/(r+t.extraSize-l||1)*100;n.value.scroll(i)}function s(){const{visibleSize:r,totalSize:l}=u.getScrollable(o.value,t.direction);a.value=u.ensureRangeValue(r/(l+t.extraSize||1)*100)}h.useResizeObserver(o,()=>{s()}),e.watchEffect(()=>{const r=e.unref(o.value);r&&(s(),r.addEventListener("scroll",p))},{flush:"post"}),e.watch(()=>t.barLength,r=>{a.value=r});function f(r){const l=e.unref(o);if(!l)return;const{totalSize:c,visibleSize:i,topOrLeft:v}=u.getScrollable(l,t.direction);if(c<=i)return;const b=`scroll${v}`;l[b]=r*(c+t.extraSize-i)/100}return S({currentScroll:e.computed(()=>e.unref(n.value?.currentScroll)),scroll:f,visible:e.computed(()=>a.value<100),rootElement:e.computed(()=>e.unref(n.value?.container))}),(r,l)=>a.value!==100?(e.openBlock(),e.createBlock(g.default,e.mergeProps({key:0,ref_key:"barRef",ref:n},e.unref(_.omit)(t,["onScroll","extraSize","scrollContainer"]),{"bar-length":a.value,onScroll:f}),null,16,["bar-length"])):e.createCommentVNode("",!0)}});exports.default=m;
