import{j as F,D as O,H as R,I as H,g as I,ab as L,z as q,d as W,A as N,N as c,b as z}from"./C43PsxSN.js";import{_ as $}from"./DlAUqK2U.js";const j=F({__name:"HorizontalScrollbar",props:{threshold:{default:1400}},setup(D){const y=D,n=c(0),u=c(0),o=c(0),a=c(0),f=c(!1),w=c();let r=0,i=!1,_=0,x=0;const h=z(()=>a.value>o.value),S=z(()=>{if(!h.value)return{display:"none"};const e=Math.max(o.value/a.value*o.value,60),s=a.value-o.value,v=o.value-e,d=s>0?n.value/s*v:0;return{width:`${e}px`,transform:`translateX(${d}px)`}});function p(){u.value=window.scrollX,o.value=window.innerWidth,a.value=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth)}function A(){if(r)return;function t(){const e=u.value-n.value;if(Math.abs(e)<.5){n.value=u.value,r=0;return}n.value+=e*.12,r=requestAnimationFrame(t)}r=requestAnimationFrame(t)}function X(){document.documentElement.style.overflowX="auto",document.body.style.overflow="visible"}function T(){document.documentElement.style.overflowX="",document.body.style.overflow=""}function m(){o.value<y.threshold?(X(),f.value=h.value):(f.value=!1,T())}function g(){p(),A(),i||m()}function M(){p(),i||m()}function B(t){if(!w.value)return;const e=w.value.getBoundingClientRect(),s=t.clientX-e.left,v=e.width,d=a.value-o.value,l=Math.max(0,Math.min(1,s/v))*d;u.value=l,n.value=l,window.scrollTo({left:l,behavior:"instant"}),m()}function C(t){t.preventDefault(),i=!0,_=t.clientX,x=n.value,document.addEventListener("mousemove",b),document.addEventListener("mouseup",E)}function b(t){if(!i)return;const e=a.value-o.value;if(e<=0)return;const s=parseFloat(S.value.width||"60"),v=o.value-s,k=(t.clientX-_)/v*e,l=Math.max(0,Math.min(x+k,e));window.scrollTo({left:l,behavior:"instant"}),u.value=l,n.value=l}function E(){i=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E)}return O(()=>{window.innerWidth<y.threshold&&(X(),document.documentElement.offsetHeight),p(),m(),window.addEventListener("scroll",g,{passive:!0}),window.addEventListener("resize",M)}),R(()=>{window.removeEventListener("scroll",g),window.removeEventListener("resize",M),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",E),r&&cancelAnimationFrame(r),document.documentElement.style.overflowX="",document.body.style.overflow=""}),(t,e)=>(H(),I("div",{class:q(["h-scrollbar",{"is-visible":f.value&&h.value}]),onMousedown:e[0]||(e[0]=L(()=>{},["stop"]))},[W("div",{class:"h-scrollbar-track",ref_key:"trackRef",ref:w,onMousedown:B},[W("div",{class:"h-scrollbar-thumb",style:N(S.value),onMousedown:L(C,["stop"])},null,36)],544)],34))}}),G=$(j,[["__scopeId","data-v-13d08a82"]]);export{G as _};
