/* Copyright © 2024 Melbet - All Rights Reserved */ import{ref as z,computed as l,unref as n,watch as S,onMounted as W,onUnmounted as E,nextTick as d}from"../../../../shared-assets/__shared_vue_deps_SRT2KB67.js";import{useGlobalStore as I}from"./entry-Bl6dkD65.js";import{unrefElement as T}from"./_r9fP6sa7pPh.js";import{useWindowResize as g}from"./Bx0ZD5RTcnSu.js";import{debounce as V}from"./lWPnVB_-t_cI.js";const P=({target:y,items:i,minVisibleCount:b=0})=>{const s=z(0),v=I(),R=l(()=>v.isRtl),w=l(()=>n(i).length),x=l(()=>n(i).slice(0,n(s))),M=l(()=>n(i).slice(n(s))),r=t=>{s.value=t},a=()=>T(y),u=t=>{if(!t)return u(a());const{left:e,right:o}=t.getBoundingClientRect();return n(R)?0-Math.round(e*10)/10:Math.round(o*10)/10},m=()=>u(a()),p=()=>{const t=a(),{lastElementChild:e}=t!=null?t:{};return u(e)},O=async t=>{const e=a();if(e){const o=e.style.overflow;e.style.overflow="hidden",await t(),e.style.overflow=o}},h=async()=>{const t=m(),e=p(),o=n(s)+1;e<=t&&o<=n(w)&&(r(o),await d(),await h())},C=async()=>{const t=m(),e=p(),o=n(s)-1;e>t&&o>=n(b)&&(r(o),await d(),await C())},f=async()=>{await d(),await O(async()=>{await h(),await C()})},c=V(f,200,{leading:!0});return S(()=>n(i).length,()=>c()),W(async()=>{g().watchWindowResize(c),await f()}),E(()=>g().unwatchWindowResize(c)),{visibleCount:s,visibleItems:x,invisibleItems:M,maxItemsCount:w,setVisibleCount:r,updateCount:f,debounceUpdateCount:c}};export{P as useResizableList};