vue-virtual-flow 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -629,6 +629,10 @@ five slides are normally mounted in the middle of the collection.
629
629
  | `hasMore` | `boolean` | `false` | Indicates that another page can be loaded. |
630
630
  | `loading` | `boolean` | `false` | Prevents duplicate `load-more` requests. |
631
631
  | `loadMoreThreshold` | `number` | `2` | Remaining slides after the visible group that trigger `load-more`. |
632
+ | `autoplay` | `boolean` | `false` | Enables automatic slide progression. |
633
+ | `autoplayDelay` | `number` | `3000` | Delay in milliseconds between automatic transitions; values below `1` are clamped and non-finite values use the default. |
634
+ | `autoplayLoop` | `boolean` | `true` | Returns to the first slide when reaching the end. |
635
+ | `pauseOnHover` | `boolean` | `true` | Pauses autoplay when the carousel is hovered. |
632
636
 
633
637
  #### Slots and events
634
638
 
@@ -649,10 +653,48 @@ five slides are normally mounted in the middle of the collection.
649
653
  | `next(behavior?)` | Advances by `slidesToScroll`; defaults to smooth scrolling. |
650
654
  | `previous(behavior?)` | Moves back by `slidesToScroll`. |
651
655
  | `scrollToIndex(index, options?)` | Makes the index the first visible slide. |
656
+ | `startAutoplay()` | Starts or restarts automatic slide progression. |
657
+ | `stopAutoplay()` | Stops automatic slide progression. |
652
658
 
653
659
  The viewport supports Arrow Left/Right, Page Up/Down, Home, and End. A
654
660
  long-distance smooth jump becomes immediate so virtualized gaps are not shown.
655
661
 
662
+ #### Autoplay example
663
+
664
+ ```vue
665
+ <script setup lang="ts">
666
+ import { ref } from 'vue'
667
+ import { VirtualCarousel, type VirtualCarouselExpose } from 'vue-virtual-flow'
668
+
669
+ const carousel = ref<VirtualCarouselExpose>()
670
+ const products = ref(loadProducts())
671
+ </script>
672
+
673
+ <template>
674
+ <VirtualCarousel
675
+ ref="carousel"
676
+ :items="products"
677
+ :slides-per-view="3"
678
+ :autoplay="true"
679
+ :autoplay-delay="3000"
680
+ :autoplay-loop="true"
681
+ :pause-on-hover="true"
682
+ >
683
+ <template #default="{ item }">
684
+ <ProductCard :product="item" />
685
+ </template>
686
+ </VirtualCarousel>
687
+
688
+ <button @click="carousel?.stopAutoplay()">Pause</button>
689
+ <button @click="carousel?.startAutoplay()">Resume</button>
690
+ </template>
691
+ ```
692
+
693
+ Autoplay also starts when an initially empty `items` collection receives data.
694
+ `stopAutoplay()` pauses the timer and `startAutoplay()` resumes it while the
695
+ `autoplay` prop remains enabled. Changes to `autoplayDelay`, `autoplayLoop`, and
696
+ `pauseOnHover` take effect at runtime.
697
+
656
698
  ## Shared recipes
657
699
 
658
700
  ### Viewport height
package/README.vi.md CHANGED
@@ -626,6 +626,10 @@ thường tối đa năm slide được mount ở giữa collection.
626
626
  | `hasMore` | `boolean` | `false` | Cho biết vẫn còn trang dữ liệu tiếp theo. |
627
627
  | `loading` | `boolean` | `false` | Ngăn request `load-more` bị lặp. |
628
628
  | `loadMoreThreshold` | `number` | `2` | Số slide còn lại sau vùng nhìn để kích hoạt `load-more`. |
629
+ | `autoplay` | `boolean` | `false` | Bật chế độ tự động chuyển slide. |
630
+ | `autoplayDelay` | `number` | `3000` | Thời gian chờ giữa các lần tự động chuyển, tính bằng mili giây; giá trị dưới `1` được giới hạn và giá trị không hữu hạn dùng mặc định. |
631
+ | `autoplayLoop` | `boolean` | `true` | Quay lại slide đầu tiên khi đến cuối. |
632
+ | `pauseOnHover` | `boolean` | `true` | Tạm dừng autoplay khi con trỏ nằm trên carousel. |
629
633
 
630
634
  #### Slots và events
631
635
 
@@ -646,10 +650,48 @@ thường tối đa năm slide được mount ở giữa collection.
646
650
  | `next(behavior?)` | Tiến thêm `slidesToScroll` slide; mặc định cuộn mượt. |
647
651
  | `previous(behavior?)` | Lùi lại `slidesToScroll` slide. |
648
652
  | `scrollToIndex(index, options?)` | Đưa index thành slide đầu tiên trong vùng nhìn. |
653
+ | `startAutoplay()` | Bắt đầu hoặc khởi động lại quá trình tự động chuyển slide. |
654
+ | `stopAutoplay()` | Dừng quá trình tự động chuyển slide. |
649
655
 
650
656
  Viewport hỗ trợ Arrow Left/Right, Page Up/Down, Home và End. Smooth scroll ở
651
657
  khoảng cách xa tự chuyển thành tức thời để không lộ khoảng trống virtualized.
652
658
 
659
+ #### Ví dụ autoplay
660
+
661
+ ```vue
662
+ <script setup lang="ts">
663
+ import { ref } from 'vue'
664
+ import { VirtualCarousel, type VirtualCarouselExpose } from 'vue-virtual-flow'
665
+
666
+ const carousel = ref<VirtualCarouselExpose>()
667
+ const products = ref(loadProducts())
668
+ </script>
669
+
670
+ <template>
671
+ <VirtualCarousel
672
+ ref="carousel"
673
+ :items="products"
674
+ :slides-per-view="3"
675
+ :autoplay="true"
676
+ :autoplay-delay="3000"
677
+ :autoplay-loop="true"
678
+ :pause-on-hover="true"
679
+ >
680
+ <template #default="{ item }">
681
+ <ProductCard :product="item" />
682
+ </template>
683
+ </VirtualCarousel>
684
+
685
+ <button @click="carousel?.stopAutoplay()">Tạm dừng</button>
686
+ <button @click="carousel?.startAutoplay()">Tiếp tục</button>
687
+ </template>
688
+ ```
689
+
690
+ Autoplay cũng tự bắt đầu khi collection `items` ban đầu rỗng nhận được dữ liệu.
691
+ `stopAutoplay()` tạm dừng timer và `startAutoplay()` tiếp tục chạy khi prop
692
+ `autoplay` vẫn được bật. Các thay đổi của `autoplayDelay`, `autoplayLoop` và
693
+ `pauseOnHover` có hiệu lực ngay trong lúc component đang chạy.
694
+
653
695
  ## Cách dùng chung
654
696
 
655
697
  ### Chiều cao viewport
@@ -19,6 +19,10 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
19
19
  hasMore?: boolean;
20
20
  loading?: boolean;
21
21
  loadMoreThreshold?: number;
22
+ autoplay?: boolean;
23
+ autoplayDelay?: number;
24
+ autoplayLoop?: boolean;
25
+ pauseOnHover?: boolean;
22
26
  } & Partial<{}>> & import('vue').PublicProps;
23
27
  expose(exposed: import('vue').ShallowUnwrapRef<VirtualCarouselExpose>): void;
24
28
  attrs: any;
@@ -19,6 +19,10 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
19
19
  hasMore?: boolean;
20
20
  loading?: boolean;
21
21
  loadMoreThreshold?: number;
22
+ autoplay?: boolean;
23
+ autoplayDelay?: number;
24
+ autoplayLoop?: boolean;
25
+ pauseOnHover?: boolean;
22
26
  } & Partial<{}>> & import('vue').PublicProps;
23
27
  expose(exposed: import('vue').ShallowUnwrapRef<VirtualCarouselExpose>): void;
24
28
  attrs: any;
package/dist/types.d.cts CHANGED
@@ -85,6 +85,10 @@ export interface VirtualCarouselProps<T> {
85
85
  hasMore?: boolean;
86
86
  loading?: boolean;
87
87
  loadMoreThreshold?: number;
88
+ autoplay?: boolean;
89
+ autoplayDelay?: number;
90
+ autoplayLoop?: boolean;
91
+ pauseOnHover?: boolean;
88
92
  }
89
93
  export interface VirtualCarouselChangeEvent<T> {
90
94
  index: number;
@@ -114,6 +118,8 @@ export interface VirtualCarouselExpose {
114
118
  next: (behavior?: ScrollBehavior) => void;
115
119
  previous: (behavior?: ScrollBehavior) => void;
116
120
  scrollToIndex: (index: number, options?: ScrollToOptions) => void;
121
+ startAutoplay: () => void;
122
+ stopAutoplay: () => void;
117
123
  }
118
124
  export type VirtualListProps<T> = DynamicVirtualScrollProps<T>;
119
125
  export type VirtualListExpose = VirtualScrollExpose;
package/dist/types.d.ts CHANGED
@@ -85,6 +85,10 @@ export interface VirtualCarouselProps<T> {
85
85
  hasMore?: boolean;
86
86
  loading?: boolean;
87
87
  loadMoreThreshold?: number;
88
+ autoplay?: boolean;
89
+ autoplayDelay?: number;
90
+ autoplayLoop?: boolean;
91
+ pauseOnHover?: boolean;
88
92
  }
89
93
  export interface VirtualCarouselChangeEvent<T> {
90
94
  index: number;
@@ -114,6 +118,8 @@ export interface VirtualCarouselExpose {
114
118
  next: (behavior?: ScrollBehavior) => void;
115
119
  previous: (behavior?: ScrollBehavior) => void;
116
120
  scrollToIndex: (index: number, options?: ScrollToOptions) => void;
121
+ startAutoplay: () => void;
122
+ stopAutoplay: () => void;
117
123
  }
118
124
  export type VirtualListProps<T> = DynamicVirtualScrollProps<T>;
119
125
  export type VirtualListExpose = VirtualScrollExpose;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");function Me(r){return typeof r=="string"||typeof r=="number"||typeof r=="symbol"}function ce(r,R){const S=r[R];return Me(S)?S:void 0}function Te(r){return ce(r,"id")??ce(r,"key")}function ae(r){function R(t,T){const v=r.itemKey();if(typeof v=="function")return v(t,T);if(t!==null&&typeof t=="object"){if(v!==void 0){const u=ce(t,v);if(u!==void 0)return u}const x=Te(t);if(x!==void 0)return x}return T}function S(){}return e.watch(()=>[r.itemKey(),r.items()],S,{immediate:!0}),{getItemKey:R}}function ie(r){return r==="fill"?"100%":typeof r=="number"?`${r}px`:r}function se(r){return(R,S)=>{typeof S=="string"&&(S==="fill"||S.trim().endsWith("%"))}}const ke=["aria-label"],we={key:0,class:"vue-chat-virtual-scroll__loading-older",role:"status","aria-live":"polite"},Se=["aria-posinset","aria-setsize"],fe=e.defineComponent({name:"ChatVirtualScroll",__name:"ChatVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:5},itemKey:{default:void 0},ariaLabel:{default:"Chat messages"},stickToBottom:{type:Boolean,default:!0},bottomThreshold:{default:80},initialScroll:{default:"bottom"},hasOlder:{type:Boolean,default:!1},loadingOlder:{type:Boolean,default:!1},loadOlderThreshold:{default:120}},emits:["scroll","loadOlder","bottomChange"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref(0),z=e.ref(0),L=e.ref(!0),C=new Map,E=new Map;let K,p,b=-1,M=!1;const B=se(),{getItemKey:D}=ae({componentName:"ChatVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),k=e.computed(()=>Math.max(1,t.estimatedItemSize)),P=e.computed(()=>Math.max(0,Math.floor(t.overscan))),j=e.computed(()=>u.value>0?u.value:typeof t.height=="number"?Math.max(0,t.height):k.value),$=e.computed(()=>{z.value;const n=new Array(t.items.length+1),f=new Array(t.items.length);n[0]=0;for(let s=0;s<t.items.length;s+=1){const V=D(t.items[s],s),H=C.get(V)??k.value;f[s]=H,n[s+1]=n[s]+H}return{offsets:n,sizes:f,total:n[t.items.length]??0}}),w=e.computed(()=>{const n=new Map;return t.items.forEach((f,s)=>{n.set(D(f,s),s)}),n});function q(n){if(t.items.length===0)return 0;const f=$.value.offsets;let s=0,V=t.items.length;for(;s<V;){const H=Math.floor((s+V)/2);f[H+1]<=n?s=H+1:V=H}return Math.min(s,t.items.length-1)}const W=e.computed(()=>Math.max(0,q(x.value)-P.value)),_=e.computed(()=>{if(t.items.length===0)return 0;const n=q(x.value+j.value)+1;return Math.min(t.items.length,n+P.value)}),A=e.computed(()=>t.items.slice(W.value,_.value).map((n,f)=>{const s=W.value+f;return{item:n,index:s,key:D(n,s),top:$.value.offsets[s]}})),G=e.computed(()=>({height:ie(t.height)}));function N(){const n=v.value;if(!n)return;const s=Math.max(0,$.value.total-n.scrollTop-n.clientHeight)<=Math.max(0,t.bottomThreshold);s!==L.value&&(L.value=s,M&&T("bottomChange",s))}function c(){var n;u.value=((n=v.value)==null?void 0:n.clientHeight)??0,B(v.value,t.height),e.nextTick(()=>{N(),I()})}function h(n){x.value=n.currentTarget.scrollTop,N(),T("scroll",{scrollTop:x.value,startIndex:W.value,endIndex:_.value}),I()}function I(){const n=v.value;!M||!n||!t.hasOlder||t.loadingOlder||b===t.items.length||n.scrollTop<=Math.max(0,t.loadOlderThreshold)&&(b=t.items.length,T("loadOlder"))}function O(n){const f=n.borderBoxSize;if(f){const s=Array.isArray(f)?f[0]:f;if(s!=null&&s.blockSize)return s.blockSize}return n.contentRect.height}function ee(n){const f=$.value,s=L.value&&t.stickToBottom;let V=0,H=!1;for(const F of n){const te=F.target,l=E.get(te),a=O(F);if(l===void 0||a<=0)continue;const o=C.get(l)??k.value;if(Math.abs(o-a)<.5)continue;const y=w.value.get(l);y!==void 0&&f.offsets[y+1]<=x.value&&(V+=a-o),C.set(l,a),H=!0}H&&(z.value+=1,e.nextTick(()=>{const F=v.value;F&&(s?i("auto"):V!==0&&(F.scrollTop+=V,x.value=F.scrollTop,N()))}))}function Q(n,f){n instanceof HTMLElement&&(E.set(n,f),p==null||p.observe(n))}function J(){for(const[n]of E)n.isConnected||(p==null||p.unobserve(n),E.delete(n))}function ne(n,f={}){const s=v.value;if(!s)return;const V=Math.max(0,$.value.total-s.clientHeight),H=Math.min(Math.max(0,Number.isFinite(n)?n:0),V),F=f.behavior??"auto";F==="auto"&&(x.value=H),s.scrollTo({...f,top:H,behavior:F}),e.nextTick(N)}function Z(n,f={}){const s=v.value;if(!s||t.items.length===0)return;const V=Math.min(t.items.length-1,Math.max(0,Math.floor(n))),{align:H="start",...F}=f,te=$.value.sizes[V];let l=$.value.offsets[V];H==="center"?l-=(s.clientHeight-te)/2:H==="end"&&(l-=s.clientHeight-te);const a=Math.max(0,Math.min(l,$.value.total-s.clientHeight)),o=F.behavior??"auto",y=Math.max(s.clientHeight*3,k.value*10),g=o==="smooth"&&Math.abs(a-s.scrollTop)>y?"auto":o;g==="auto"&&(x.value=a),s.scrollTo({...F,top:a,behavior:g}),e.nextTick(N)}function d(n="auto"){const f=v.value;f&&(n==="auto"&&(x.value=0),f.scrollTo({top:0,behavior:n}),e.nextTick(N))}function i(n="auto"){const f=v.value;if(!f)return;const s=Math.max(0,$.value.total-f.clientHeight);n==="auto"?(f.scrollTop=s,x.value=s):f.scrollTo({top:s,behavior:n}),e.nextTick(N)}let m=t.items.map((n,f)=>D(n,f));return e.watch(()=>t.items.map((n,f)=>D(n,f)),async n=>{const f=m;m=n;const s=v.value,V=(s==null?void 0:s.scrollTop)??0,H=L.value&&t.stickToBottom,F=f[0],te=F===void 0?0:n.indexOf(F),l=te>0?n.slice(0,te).reduce((o,y)=>o+(C.get(y)??k.value),0):0,a=new Set(n);for(const o of C.keys())a.has(o)||C.delete(o);z.value+=1,await e.nextTick(),s&&(l>0?(s.scrollTop=V+l,x.value=s.scrollTop):n.length>f.length&&H&&i("auto"),N(),I())}),e.watch(()=>[t.hasOlder,t.loadingOlder],async([n])=>{n||(b=-1),await e.nextTick(),I()}),e.onMounted(()=>{if(c(),typeof ResizeObserver<"u"){K=new ResizeObserver(c),p=new ResizeObserver(ee),v.value&&K.observe(v.value);for(const[n]of E)p.observe(n)}e.nextTick(()=>{t.initialScroll==="bottom"&&i("auto"),M=!0,N(),I()})}),e.onUpdated(J),e.onBeforeUnmount(()=>{K==null||K.disconnect(),p==null||p.disconnect(),E.clear()}),R({isAtBottom:L,scrollTo:ne,scrollToIndex:Z,scrollToTop:d,scrollToBottom:i}),(n,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:v,class:"vue-chat-virtual-scroll",style:e.normalizeStyle(G.value),role:"log","aria-label":r.ariaLabel,"aria-live":"polite",tabindex:"0",onScrollPassive:h},[r.loadingOlder?(e.openBlock(),e.createElementBlock("div",we,[e.createElementVNode("div",null,[e.renderSlot(n.$slots,"loadingOlder",{},()=>[f[0]||(f[0]=e.createTextVNode("Loading older messages…",-1))])])])):e.createCommentVNode("",!0),r.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-chat-virtual-scroll__spacer",style:e.normalizeStyle({height:`${$.value.total}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,({item:s,index:V,key:H,top:F})=>(e.openBlock(),e.createElementBlock("div",{key:H,ref_for:!0,ref:te=>Q(te,H),class:"vue-chat-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${F}px)`}),role:"article","aria-posinset":V+1,"aria-setsize":r.items.length},[e.renderSlot(n.$slots,"default",{item:s,index:V})],12,Se))),128))],4)):e.renderSlot(n.$slots,"empty",{},void 0,void 0,2)],44,ke))}});function de(r){const R=e.ref(),S=e.ref(0),t=e.ref(!1),T=e.ref(!1),v=e.computed(()=>Math.max(1,r.threshold())),x=e.computed(()=>r.refreshing()||T.value?v.value:S.value),u=e.computed(()=>Math.min(1,S.value/v.value)),z=e.computed(()=>r.refreshing()||T.value?"Refreshing…":u.value>=1?"Release to refresh":"Pull to refresh");function L(){R.value=void 0,t.value=!1,S.value=0}function C(p){var B;const b=p.currentTarget,M=((B=r.scrollTop)==null?void 0:B.call(r))??b.scrollTop;!r.enabled()||r.refreshing()||M>0||p.touches.length!==1||(R.value=p.touches[0].clientY,t.value=!0)}function E(p){var D;if(R.value===void 0||!t.value)return;const b=p.currentTarget;if((((D=r.scrollTop)==null?void 0:D.call(r))??b.scrollTop)>0||p.touches.length!==1){L();return}const B=p.touches[0].clientY-R.value;if(B<=0){S.value=0;return}p.preventDefault(),S.value=Math.min(B*.5,v.value*2)}function K(){if(R.value===void 0)return;const p=S.value>=v.value&&r.enabled()&&!r.refreshing();if(R.value=void 0,t.value=!1,!p){S.value=0;return}S.value=v.value,T.value=!0,r.onRefresh(),e.nextTick(()=>{r.refreshing()||(T.value=!1,S.value=0)})}return e.watch(()=>r.refreshing(),(p,b)=>{p?(T.value=!1,S.value=v.value):b&&(T.value=!1,S.value=0)}),{pulling:t,pullDistance:S,pullOffset:x,pullProgress:u,refreshMessage:z,refreshThreshold:v,handleTouchStart:C,handleTouchMove:E,handleTouchEnd:K,handleTouchCancel:L}}const be=["aria-label"],Be=["aria-posinset","aria-setsize"],me=e.defineComponent({name:"DynamicVirtualScroll",__name:"DynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:R,emit:S}){const t=r,T=S,{pulling:v,pullDistance:x,pullOffset:u,pullProgress:z,refreshMessage:L,refreshThreshold:C,handleTouchStart:E,handleTouchMove:K,handleTouchEnd:p,handleTouchCancel:b}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>T("refresh")}),M=e.ref(),B=e.ref(0),D=e.ref(0),k=e.ref(0),P=new Map,j=new Map;let $,w,q=-1;const W=se(),{getItemKey:_}=ae({componentName:"DynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),A=e.computed(()=>Math.max(1,t.estimatedItemSize)),G=e.computed(()=>Math.max(1,t.loadingItemSize??A.value)),N=e.computed(()=>Math.max(0,Math.floor(t.overscan))),c=e.computed(()=>D.value>0?D.value:typeof t.height=="number"?Math.max(0,t.height):A.value),h=e.computed(()=>{k.value;const l=new Array(t.items.length+1),a=new Array(t.items.length);l[0]=0;for(let o=0;o<t.items.length;o+=1){const y=_(t.items[o],o),g=P.get(y)??A.value;a[o]=g,l[o+1]=l[o]+g}return{offsets:l,sizes:a,total:l[t.items.length]??0}}),I=e.computed(()=>h.value.total+(t.loading?G.value:0)),O=e.computed(()=>{const l=new Map;return t.items.forEach((a,o)=>{l.set(_(a,o),o)}),l});function ee(l){if(t.items.length===0)return 0;const a=h.value.offsets;let o=0,y=t.items.length;for(;o<y;){const g=Math.floor((o+y)/2);a[g+1]<=l?o=g+1:y=g}return Math.min(o,t.items.length-1)}const Q=e.computed(()=>Math.max(0,ee(B.value)-N.value)),J=e.computed(()=>{if(t.items.length===0)return 0;const l=ee(B.value+c.value)+1;return Math.min(t.items.length,l+N.value)}),ne=e.computed(()=>t.items.slice(Q.value,J.value).map((l,a)=>{const o=Q.value+a;return{item:l,index:o,key:_(l,o),top:h.value.offsets[o]}})),Z=e.computed(()=>({height:ie(t.height)}));function d(){var l;D.value=((l=M.value)==null?void 0:l.clientHeight)??0,W(M.value,t.height),e.nextTick(m)}function i(l){B.value=l.currentTarget.scrollTop,T("scroll",{scrollTop:B.value,startIndex:Q.value,endIndex:J.value}),m()}function m(){const l=M.value;if(!l||!t.hasMore||t.loading||q===t.items.length)return;const a=Math.max(0,t.loadMoreThreshold);I.value-l.scrollTop-l.clientHeight<=a&&(q=t.items.length,T("loadMore"))}function n(l){const a=l.borderBoxSize;if(a){const o=Array.isArray(a)?a[0]:a;if(o!=null&&o.blockSize)return o.blockSize}return l.contentRect.height}function f(l){const a=h.value;let o=0,y=!1;for(const g of l){const U=g.target,Y=j.get(U),X=n(g);if(Y===void 0||X<=0)continue;const le=P.get(Y)??A.value;if(Math.abs(le-X)<.5)continue;const oe=O.value.get(Y);oe!==void 0&&a.offsets[oe+1]<=B.value&&(o+=X-le),P.set(Y,X),y=!0}y&&(k.value+=1,e.nextTick(m),o!==0&&e.nextTick(()=>{const g=M.value;g&&(g.scrollTop+=o,B.value=g.scrollTop)}))}function s(l,a){l instanceof HTMLElement&&(j.set(l,a),w==null||w.observe(l))}function V(){for(const[l]of j)l.isConnected||(w==null||w.unobserve(l),j.delete(l))}function H(l,a={}){const o=M.value;if(!o)return;const y=Math.max(0,I.value-o.clientHeight),g=Math.min(Math.max(0,Number.isFinite(l)?l:0),y),U=a.behavior??"auto";U==="auto"&&(B.value=g),o.scrollTo({...a,top:g,behavior:U})}function F(l,a={}){const o=M.value;if(!o||t.items.length===0)return;const y=Math.min(t.items.length-1,Math.max(0,Math.floor(l))),{align:g="start",...U}=a;let Y=h.value.offsets[y];const X=h.value.sizes[y];g==="center"?Y-=(o.clientHeight-X)/2:g==="end"&&(Y-=o.clientHeight-X);const le=Math.max(0,Math.min(Y,I.value-o.clientHeight)),oe=U.behavior??"auto",ue=Math.max(o.clientHeight*3,A.value*10),re=oe==="smooth"&&Math.abs(le-o.scrollTop)>ue?"auto":oe;re==="auto"&&(B.value=le),o.scrollTo({...U,top:le,behavior:re})}function te(l="auto"){var a;(a=M.value)==null||a.scrollTo({top:0,behavior:l})}return e.watch(()=>t.itemKey,()=>{P.clear(),k.value+=1}),e.watch(()=>t.items.length,async()=>{const l=new Set(t.items.map((y,g)=>_(y,g)));for(const y of P.keys())l.has(y)||P.delete(y);k.value+=1,await e.nextTick();const a=M.value;if(!a)return;const o=Math.max(0,I.value-a.clientHeight);a.scrollTop>o&&(a.scrollTop=o,B.value=o),m()}),e.watch(()=>[t.hasMore,t.loading],async([l])=>{l||(q=-1),await e.nextTick(),m()}),e.onMounted(()=>{if(d(),typeof ResizeObserver<"u"){$=new ResizeObserver(d),w=new ResizeObserver(f),M.value&&$.observe(M.value);for(const[l]of j)w.observe(l)}e.nextTick(m)}),e.onUpdated(V),e.onBeforeUnmount(()=>{$==null||$.disconnect(),w==null||w.disconnect(),j.clear()}),R({scrollTo:H,scrollToIndex:F,scrollToTop:te}),(l,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:M,class:e.normalizeClass(["vue-dynamic-virtual-scroll",{"vue-dynamic-virtual-scroll--pulling":e.unref(v)}]),style:e.normalizeStyle(Z.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:i,onTouchstartPassive:a[0]||(a[0]=(...o)=>e.unref(E)&&e.unref(E)(...o)),onTouchmove:a[1]||(a[1]=(...o)=>e.unref(K)&&e.unref(K)(...o)),onTouchend:a[2]||(a[2]=(...o)=>e.unref(p)&&e.unref(p)(...o)),onTouchcancel:a[3]||(a[3]=(...o)=>e.unref(b)&&e.unref(b)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(C)}px`,transform:`translateY(${e.unref(u)-e.unref(C)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"refresh",{pullDistance:e.unref(x),progress:e.unref(z),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(L)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${I.value}px`,transform:`translateY(${e.unref(u)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ne.value,({item:o,index:y,key:g,top:U})=>(e.openBlock(),e.createElementBlock("div",{key:g,ref_for:!0,ref:Y=>s(Y,g),class:"vue-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${U}px)`}),role:"listitem","aria-posinset":y+1,"aria-setsize":r.items.length},[e.renderSlot(l.$slots,"default",{item:o,index:y})],12,Be))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${G.value}px`,transform:`translateY(${h.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"loading",{},()=>[a[4]||(a[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(u)}px)`})},[e.renderSlot(l.$slots,"empty")],4))],46,be))}}),Ie=["aria-label"],ze=["aria-current","aria-posinset","aria-setsize"],Ee={key:1,class:"vue-short-media-feed__empty"},he=e.defineComponent({name:"ShortMediaFeed",__name:"ShortMediaFeed",props:{items:{},activeIndex:{default:0},buffer:{default:1},height:{default:"100dvh"},itemKey:{default:void 0},ariaLabel:{default:"Short media feed"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref($(t.activeIndex));let z,L=-1;const C=se(),{getItemKey:E}=ae({componentName:"ShortMediaFeed",items:()=>t.items,itemKey:()=>t.itemKey}),K=e.computed(()=>Math.max(0,Math.floor(t.buffer))),p=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),b=e.computed(()=>x.value>0?x.value:typeof t.height=="number"?Math.max(1,t.height):0),M=e.computed(()=>Math.max(0,u.value-K.value)),B=e.computed(()=>Math.min(t.items.length,u.value+K.value+1)),D=e.computed(()=>t.items.slice(M.value,B.value).map((c,h)=>({item:c,index:M.value+h}))),k=e.computed(()=>M.value*b.value),P=e.computed(()=>(t.items.length-B.value)*b.value),j=e.computed(()=>({height:ie(t.height)}));function $(c){return t.items.length===0?0:Math.min(t.items.length-1,Math.max(0,Math.floor(Number.isFinite(c)?c:0)))}function w(){if(!t.hasMore||t.loading||L===t.items.length)return;(t.items.length===0?0:t.items.length-1-u.value)<=p.value&&(L=t.items.length,T("loadMore"))}function q(c){const h=$(c);h===u.value||t.items.length===0||(u.value=h,T("update:activeIndex",h),T("change",{index:h,item:t.items[h]}),h===0&&T("reachStart"),h===t.items.length-1&&T("reachEnd"),w())}function W(c,h={}){const I=v.value;I&&(typeof I.scrollTo=="function"?I.scrollTo({...h,top:c}):I.scrollTop=c)}function _(c,h={}){if(t.items.length===0)return;const I=$(c);q(I),W(I*b.value,h)}function A(c){if(b.value<=0)return;const h=c.currentTarget.scrollTop;q(Math.round(h/b.value))}function G(c){let h;c.key==="ArrowDown"||c.key==="PageDown"?h=u.value+1:c.key==="ArrowUp"||c.key==="PageUp"?h=u.value-1:c.key==="Home"?h=0:c.key==="End"&&(h=t.items.length-1),h!==void 0&&(c.preventDefault(),_(h,{behavior:"smooth"}))}function N(){var h;const c=((h=v.value)==null?void 0:h.clientHeight)??0;C(v.value,t.height),!(c<=0||c===x.value)&&(x.value=c,e.nextTick(()=>{W(u.value*c)}))}return e.watch(()=>t.activeIndex,async c=>{const h=$(c);h!==u.value&&(u.value=h,await e.nextTick(),W(h*b.value),w())}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([c])=>{c||(L=-1),await e.nextTick(),w()}),e.watch(()=>t.items.length,async()=>{const c=$(u.value);t.items.length===0?u.value!==0&&(u.value=0,T("update:activeIndex",0)):q(c),await e.nextTick(),W(c*b.value),w()}),e.onMounted(async()=>{N(),typeof ResizeObserver<"u"&&v.value&&(z=new ResizeObserver(N),z.observe(v.value)),await e.nextTick(),W(u.value*b.value),w()}),e.onBeforeUnmount(()=>{z==null||z.disconnect()}),R({scrollToIndex:_}),(c,h)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:v,class:"vue-short-media-feed",style:e.normalizeStyle(j.value),role:"list","aria-orientation":"vertical","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:A,onKeydown:G},[r.items.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${k.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,({item:I,index:O})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(E)(I,O),class:"vue-short-media-feed__item",style:e.normalizeStyle({height:`${b.value}px`}),role:"listitem","aria-current":O===u.value?"true":void 0,"aria-posinset":O+1,"aria-setsize":r.items.length},[e.renderSlot(c.$slots,"default",{item:I,index:O,active:O===u.value})],12,ze))),128)),P.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${P.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",Ee,[e.renderSlot(c.$slots,"empty")]))],44,Ie))}}),$e=["aria-label"],Ve={key:0,class:"vue-virtual-carousel__track",role:"list"},He=["aria-label","aria-current"],Le={key:1,class:"vue-virtual-carousel__empty"},ve=e.defineComponent({name:"VirtualCarousel",__name:"VirtualCarousel",props:{items:{},activeIndex:{default:0},slidesPerView:{default:1},slidesToScroll:{default:1},gap:{default:0},buffer:{default:1},height:{default:"auto"},itemKey:{default:void 0},ariaLabel:{default:"Carousel"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref(0);let z,L=-1;const{getItemKey:C}=ae({componentName:"VirtualCarousel",items:()=>t.items,itemKey:()=>t.itemKey}),E=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(t.slidesPerView)?t.slidesPerView:1))),K=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(t.slidesToScroll)?t.slidesToScroll:1))),p=e.computed(()=>Math.max(0,Number.isFinite(t.gap)?t.gap:0)),b=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.buffer)?t.buffer:0))),M=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),B=e.computed(()=>Math.max(0,x.value)),D=e.computed(()=>{if(B.value<=0)return 0;const d=(E.value-1)*p.value;return Math.max(1,(B.value-d)/E.value)}),k=e.computed(()=>D.value+p.value),P=e.computed(()=>Math.max(0,t.items.length-E.value)),j=e.computed(()=>Math.max(0,u.value-b.value)),$=e.computed(()=>Math.min(t.items.length,u.value+E.value+b.value)),w=e.computed(()=>t.items.slice(j.value,$.value).map((d,i)=>({item:d,index:j.value+i}))),q=e.computed(()=>t.items.length===0?0:t.items.length*D.value+(t.items.length-1)*p.value),W=e.computed(()=>j.value*k.value),_=e.computed(()=>Math.max(0,q.value-$.value*k.value)),A=e.computed(()=>({height:ie(t.height)}));function G(d){return Math.min(P.value,Math.max(0,Math.floor(Number.isFinite(d)?d:0)))}u.value=G(t.activeIndex);function N(d){return d>=u.value&&d<Math.min(t.items.length,u.value+E.value)}function c(){if(!t.hasMore||t.loading||L===t.items.length)return;const d=t.items.length===0?-1:Math.min(t.items.length-1,u.value+E.value-1);t.items.length-1-d<=M.value&&(L=t.items.length,T("loadMore"))}function h(d){const i=G(d);i===u.value||t.items.length===0||(u.value=i,T("update:activeIndex",i),T("change",{index:i,item:t.items[i]}),i===0&&T("reachStart"),i===P.value&&T("reachEnd"),c())}function I(d,i={}){const m=v.value;m&&(typeof m.scrollTo=="function"?m.scrollTo({...i,left:d}):m.scrollLeft=d)}function O(d,i={}){if(t.items.length===0||k.value<=0)return;const m=G(d),n=Math.abs(m-u.value),f=i.behavior==="smooth"&&n>b.value?"auto":i.behavior;h(m),I(m*k.value,{...i,behavior:f})}function ee(d="smooth"){O(u.value+K.value,{behavior:d})}function Q(d="smooth"){O(u.value-K.value,{behavior:d})}function J(d){if(k.value<=0)return;const i=d.currentTarget.scrollLeft;h(Math.round(i/k.value))}function ne(d){d.key==="ArrowRight"||d.key==="PageDown"?(d.preventDefault(),ee()):d.key==="ArrowLeft"||d.key==="PageUp"?(d.preventDefault(),Q()):d.key==="Home"?(d.preventDefault(),O(0,{behavior:"smooth"})):d.key==="End"&&(d.preventDefault(),O(P.value,{behavior:"auto"}))}function Z(){var i;const d=((i=v.value)==null?void 0:i.clientWidth)??0;d<=0||d===x.value||(x.value=d,e.nextTick(()=>{I(u.value*k.value)}))}return e.watch(()=>t.activeIndex,async d=>{const i=G(d);i!==u.value&&(u.value=i,await e.nextTick(),I(i*k.value),c())}),e.watch(()=>[t.items.length,t.slidesPerView,t.gap],async()=>{const d=G(u.value);t.items.length===0?u.value!==0&&(u.value=0,T("update:activeIndex",0)):h(d),await e.nextTick(),I(d*k.value),c()}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([d])=>{d||(L=-1),await e.nextTick(),c()}),e.onMounted(async()=>{Z(),typeof ResizeObserver<"u"&&v.value&&(z=new ResizeObserver(Z),z.observe(v.value)),await e.nextTick(),I(u.value*k.value),c()}),e.onBeforeUnmount(()=>{z==null||z.disconnect()}),R({next:ee,previous:Q,scrollToIndex:O}),(d,i)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:v,class:"vue-virtual-carousel",style:e.normalizeStyle(A.value),role:"region","aria-roledescription":"carousel","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:J,onKeydown:ne},[r.items.length?(e.openBlock(),e.createElementBlock("div",Ve,[W.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${W.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,({item:m,index:n})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(C)(m,n),class:"vue-virtual-carousel__item",style:e.normalizeStyle({flexBasis:`${D.value}px`,marginRight:n<r.items.length-1?`${p.value}px`:"0px"}),role:"listitem","aria-roledescription":"slide","aria-label":`${n+1} of ${r.items.length}`,"aria-current":n===u.value?"true":void 0},[e.renderSlot(d.$slots,"default",{item:m,index:n,active:n===u.value,visible:N(n)})],12,He))),128)),_.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${_.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Le,[e.renderSlot(d.$slots,"empty")]))],44,$e))}}),Ce=["aria-label"],Ke=["aria-posinset","aria-setsize"],pe=e.defineComponent({name:"VirtualScroll",__name:"VirtualScroll",props:{items:{},itemSize:{},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:R,emit:S}){const t=r,T=S,{pulling:v,pullDistance:x,pullOffset:u,pullProgress:z,refreshMessage:L,refreshThreshold:C,handleTouchStart:E,handleTouchMove:K,handleTouchEnd:p,handleTouchCancel:b}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>T("refresh")}),M=e.ref(),B=e.ref(0),D=e.ref(0);let k,P=-1;const j=se(),{getItemKey:$}=ae({componentName:"VirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),w=e.computed(()=>Math.max(1,t.itemSize)),q=e.computed(()=>Math.max(0,Math.floor(t.overscan))),W=e.computed(()=>t.items.length*w.value),_=e.computed(()=>Math.max(1,t.loadingItemSize??w.value)),A=e.computed(()=>W.value+(t.loading?_.value:0)),G=e.computed(()=>D.value>0?D.value:typeof t.height=="number"?t.height:0),N=e.computed(()=>Math.max(0,Math.floor(B.value/w.value)-q.value)),c=e.computed(()=>{const i=Math.ceil((B.value+G.value)/w.value);return Math.min(t.items.length,i+q.value)}),h=e.computed(()=>t.items.slice(N.value,c.value).map((i,m)=>({item:i,index:N.value+m}))),I=e.computed(()=>({height:ie(t.height)})),O=e.computed(()=>({transform:`translateY(${N.value*w.value}px)`}));function ee(){var i;D.value=((i=M.value)==null?void 0:i.clientHeight)??0,j(M.value,t.height),e.nextTick(J)}function Q(i){B.value=i.currentTarget.scrollTop,T("scroll",{scrollTop:B.value,startIndex:N.value,endIndex:c.value}),J()}function J(){const i=M.value;if(!i||!t.hasMore||t.loading||P===t.items.length)return;const m=Math.max(0,t.loadMoreThreshold);A.value-i.scrollTop-i.clientHeight<=m&&(P=t.items.length,T("loadMore"))}function ne(i,m={}){const n=M.value;if(!n)return;const f=Math.max(0,A.value-n.clientHeight),s=Math.min(Math.max(0,Number.isFinite(i)?i:0),f),V=m.behavior??"auto";V==="auto"&&(B.value=s),n.scrollTo({...m,top:s,behavior:V})}function Z(i,m={}){const n=M.value;if(!n||t.items.length===0)return;const f=Math.min(t.items.length-1,Math.max(0,Math.floor(i))),{align:s="start",...V}=m;let H=f*w.value;s==="center"?H-=(n.clientHeight-w.value)/2:s==="end"&&(H-=n.clientHeight-w.value),n.scrollTo({...V,top:Math.max(0,Math.min(H,A.value-n.clientHeight))})}function d(i="auto"){var m;(m=M.value)==null||m.scrollTo({top:0,behavior:i})}return e.watch(()=>[t.items.length,t.itemSize],async()=>{await e.nextTick();const i=M.value;if(!i)return;const m=Math.max(0,A.value-i.clientHeight);i.scrollTop>m&&(i.scrollTop=m,B.value=m),J()}),e.watch(()=>[t.hasMore,t.loading],async([i])=>{i||(P=-1),await e.nextTick(),J()}),e.onMounted(()=>{ee(),typeof ResizeObserver<"u"&&M.value&&(k=new ResizeObserver(ee),k.observe(M.value)),e.nextTick(J)}),e.onBeforeUnmount(()=>{k==null||k.disconnect()}),R({scrollTo:ne,scrollToIndex:Z,scrollToTop:d}),(i,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:M,class:e.normalizeClass(["vue-virtual-scroll",{"vue-virtual-scroll--pulling":e.unref(v)}]),style:e.normalizeStyle(I.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:Q,onTouchstartPassive:m[0]||(m[0]=(...n)=>e.unref(E)&&e.unref(E)(...n)),onTouchmove:m[1]||(m[1]=(...n)=>e.unref(K)&&e.unref(K)(...n)),onTouchend:m[2]||(m[2]=(...n)=>e.unref(p)&&e.unref(p)(...n)),onTouchcancel:m[3]||(m[3]=(...n)=>e.unref(b)&&e.unref(b)(...n))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(C)}px`,transform:`translateY(${e.unref(u)-e.unref(C)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(i.$slots,"refresh",{pullDistance:e.unref(x),progress:e.unref(z),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(L)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-scroll__spacer",style:e.normalizeStyle({height:`${A.value}px`,transform:`translateY(${e.unref(u)}px)`})},[e.createElementVNode("div",{class:"vue-virtual-scroll__content",style:e.normalizeStyle(O.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,({item:n,index:f})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref($)(n,f),class:"vue-virtual-scroll__item",style:e.normalizeStyle({height:`${w.value}px`}),role:"listitem","aria-posinset":f+1,"aria-setsize":r.items.length},[e.renderSlot(i.$slots,"default",{item:n,index:f})],12,Ke))),128))],4),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__loading",style:e.normalizeStyle({height:`${_.value}px`,transform:`translateY(${W.value}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(i.$slots,"loading",{},()=>[m[4]||(m[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(u)}px)`})},[e.renderSlot(i.$slots,"empty")],4))],46,Ce))}}),Ne=["aria-label"],De=["aria-posinset","aria-setsize"],ge=e.defineComponent({name:"WindowDynamicVirtualScroll",__name:"WindowDynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Window dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref(0),z=e.ref(0),L=e.ref(0),C=new Map,E=new Map;let K,p,b=-1;const{getItemKey:M}=ae({componentName:"WindowDynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),{pulling:B,pullDistance:D,pullOffset:k,pullProgress:P,refreshMessage:j,refreshThreshold:$,handleTouchStart:w,handleTouchMove:q,handleTouchEnd:W,handleTouchCancel:_}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>T("refresh"),scrollTop:()=>typeof window>"u"?0:Math.max(0,window.scrollY)}),A=e.computed(()=>Math.max(1,t.estimatedItemSize)),G=e.computed(()=>Math.max(1,t.loadingItemSize??A.value)),N=e.computed(()=>Math.max(0,Math.floor(t.overscan))),c=e.computed(()=>{L.value;const l=new Array(t.items.length+1),a=new Array(t.items.length);l[0]=0;for(let o=0;o<t.items.length;o+=1){const y=M(t.items[o],o),g=C.get(y)??A.value;a[o]=g,l[o+1]=l[o]+g}return{offsets:l,sizes:a,total:l[t.items.length]??0}}),h=e.computed(()=>c.value.total+(t.loading?G.value:0)),I=e.computed(()=>{const l=new Map;return t.items.forEach((a,o)=>{l.set(M(a,o),o)}),l}),O=e.computed(()=>Math.max(0,x.value-z.value));function ee(l){if(t.items.length===0)return 0;const a=c.value.offsets;let o=0,y=t.items.length;for(;o<y;){const g=Math.floor((o+y)/2);a[g+1]<=l?o=g+1:y=g}return Math.min(o,t.items.length-1)}const Q=e.computed(()=>Math.max(0,ee(O.value)-N.value)),J=e.computed(()=>{if(t.items.length===0)return 0;const l=x.value+u.value-z.value,a=Math.max(A.value,l),o=ee(a)+1;return Math.min(t.items.length,o+N.value)}),ne=e.computed(()=>t.items.slice(Q.value,J.value).map((l,a)=>{const o=Q.value+a;return{item:l,index:o,key:M(l,o),top:c.value.offsets[o]}}));function Z(){typeof window>"u"||(x.value=Math.max(0,window.scrollY),u.value=window.innerHeight,v.value&&(z.value=v.value.getBoundingClientRect().top+x.value))}function d(){T("scroll",{scrollTop:O.value,startIndex:Q.value,endIndex:J.value})}function i(){Z(),d(),m()}function m(){if(typeof window>"u"||!t.hasMore||t.loading||b===t.items.length)return;const l=Math.max(0,t.loadMoreThreshold),a=z.value+h.value,o=x.value+u.value;a-o<=l&&(b=t.items.length,T("loadMore"))}function n(l){const a=l.borderBoxSize;if(a){const o=Array.isArray(a)?a[0]:a;if(o!=null&&o.blockSize)return o.blockSize}return l.contentRect.height}function f(l){const a=c.value;let o=0,y=!1;for(const g of l){const U=g.target,Y=E.get(U),X=n(g);if(Y===void 0||X<=0)continue;const le=C.get(Y)??A.value;if(Math.abs(le-X)<.5)continue;const oe=I.value.get(Y);oe!==void 0&&a.offsets[oe+1]<=O.value&&(o+=X-le),C.set(Y,X),y=!0}y&&(L.value+=1,e.nextTick(()=>{if(o!==0&&typeof window<"u"){const g=Math.max(0,x.value+o);x.value=g,window.scrollTo({top:g,behavior:"auto"})}Z(),m()}))}function s(l,a){l instanceof HTMLElement&&(E.set(l,a),p==null||p.observe(l))}function V(){for(const[l]of E)l.isConnected||(p==null||p.unobserve(l),E.delete(l))}function H(l,a={}){if(typeof window>"u")return;Z();const o=Math.max(0,h.value-u.value),y=Math.min(Math.max(0,Number.isFinite(l)?l:0),o),g=Math.max(0,z.value+y),U=a.behavior??"auto";U==="auto"&&(x.value=g),window.scrollTo({...a,top:g,behavior:U})}function F(l,a={}){if(typeof window>"u"||t.items.length===0)return;Z();const o=Math.min(t.items.length-1,Math.max(0,Math.floor(l))),{align:y="start",...g}=a,U=c.value.sizes[o];let Y=z.value+c.value.offsets[o];y==="center"?Y-=(u.value-U)/2:y==="end"&&(Y-=u.value-U);const X=Math.max(z.value,z.value+h.value-u.value),le=Math.max(0,Math.min(Y,X)),oe=g.behavior??"auto",ue=Math.max(u.value*3,A.value*10),re=oe==="smooth"&&Math.abs(le-x.value)>ue?"auto":oe;re==="auto"&&(x.value=le),window.scrollTo({...g,top:le,behavior:re})}function te(l="auto"){typeof window>"u"||(Z(),window.scrollTo({top:Math.max(0,z.value),behavior:l}))}return e.watch(()=>t.itemKey,()=>{C.clear(),L.value+=1}),e.watch(()=>t.items.length,async()=>{const l=new Set(t.items.map((a,o)=>M(a,o)));for(const a of C.keys())l.has(a)||C.delete(a);L.value+=1,await e.nextTick(),Z(),m()}),e.watch(()=>[t.hasMore,t.loading],async([l])=>{l||(b=-1),await e.nextTick(),Z(),m()}),e.onMounted(()=>{if(Z(),window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),typeof ResizeObserver<"u"){K=new ResizeObserver(()=>{Z(),m()}),p=new ResizeObserver(f),v.value&&K.observe(v.value);for(const[l]of E)p.observe(l)}e.nextTick(m)}),e.onUpdated(V),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i),K==null||K.disconnect(),p==null||p.disconnect(),E.clear()}),R({scrollTo:H,scrollToIndex:F,scrollToTop:te}),(l,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"root",ref:v,class:e.normalizeClass(["vue-window-dynamic-virtual-scroll",{"vue-window-dynamic-virtual-scroll--pulling":e.unref(B)}]),role:"list","aria-label":r.ariaLabel,onTouchstartPassive:a[0]||(a[0]=(...o)=>e.unref(w)&&e.unref(w)(...o)),onTouchmove:a[1]||(a[1]=(...o)=>e.unref(q)&&e.unref(q)(...o)),onTouchend:a[2]||(a[2]=(...o)=>e.unref(W)&&e.unref(W)(...o)),onTouchcancel:a[3]||(a[3]=(...o)=>e.unref(_)&&e.unref(_)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref($)}px`,transform:`translateY(${e.unref(k)-e.unref($)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"refresh",{pullDistance:e.unref(D),progress:e.unref(P),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(j)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-window-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${h.value}px`,transform:`translateY(${e.unref(k)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ne.value,({item:o,index:y,key:g,top:U})=>(e.openBlock(),e.createElementBlock("div",{key:g,ref_for:!0,ref:Y=>s(Y,g),class:"vue-window-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${U}px)`}),role:"listitem","aria-posinset":y+1,"aria-setsize":r.items.length},[e.renderSlot(l.$slots,"default",{item:o,index:y})],12,De))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${G.value}px`,transform:`translateY(${c.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"loading",{},()=>[a[4]||(a[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-window-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(k)}px)`})},[e.renderSlot(l.$slots,"empty")],4))],42,Ne))}}),ye=me,xe={install(r){r.component("ChatVirtualScroll",fe),r.component("DynamicVirtualScroll",me),r.component("ShortMediaFeed",he),r.component("VirtualCarousel",ve),r.component("VirtualList",ye),r.component("VirtualScroll",pe),r.component("WindowDynamicVirtualScroll",ge)}};exports.ChatVirtualScroll=fe;exports.DynamicVirtualScroll=me;exports.ShortMediaFeed=he;exports.VirtualCarousel=ve;exports.VirtualList=ye;exports.VirtualScroll=pe;exports.VueVirtualScroll=xe;exports.WindowDynamicVirtualScroll=ge;exports.default=xe;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");function Me(r){return typeof r=="string"||typeof r=="number"||typeof r=="symbol"}function ce(r,P){const b=r[P];return Me(b)?b:void 0}function Te(r){return ce(r,"id")??ce(r,"key")}function ne(r){function P(t,k){const h=r.itemKey();if(typeof h=="function")return h(t,k);if(t!==null&&typeof t=="object"){if(h!==void 0){const u=ce(t,h);if(u!==void 0)return u}const T=Te(t);if(T!==void 0)return T}return k}function b(){}return e.watch(()=>[r.itemKey(),r.items()],b,{immediate:!0}),{getItemKey:P}}function ie(r){return r==="fill"?"100%":typeof r=="number"?`${r}px`:r}function se(r){return(P,b)=>{typeof b=="string"&&(b==="fill"||b.trim().endsWith("%"))}}const ke=["aria-label"],we={key:0,class:"vue-chat-virtual-scroll__loading-older",role:"status","aria-live":"polite"},Se=["aria-posinset","aria-setsize"],fe=e.defineComponent({name:"ChatVirtualScroll",__name:"ChatVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:5},itemKey:{default:void 0},ariaLabel:{default:"Chat messages"},stickToBottom:{type:Boolean,default:!0},bottomThreshold:{default:80},initialScroll:{default:"bottom"},hasOlder:{type:Boolean,default:!1},loadingOlder:{type:Boolean,default:!1},loadOlderThreshold:{default:120}},emits:["scroll","loadOlder","bottomChange"],setup(r,{expose:P,emit:b}){const t=r,k=b,h=e.ref(),T=e.ref(0),u=e.ref(0),I=e.ref(0),K=e.ref(!0),L=new Map,H=new Map;let z,y,w=-1,M=!1;const S=se(),{getItemKey:D}=ne({componentName:"ChatVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),N=e.computed(()=>Math.max(1,t.estimatedItemSize)),W=e.computed(()=>Math.max(0,Math.floor(t.overscan))),Z=e.computed(()=>u.value>0?u.value:typeof t.height=="number"?Math.max(0,t.height):N.value),E=e.computed(()=>{I.value;const n=new Array(t.items.length+1),d=new Array(t.items.length);n[0]=0;for(let s=0;s<t.items.length;s+=1){const $=D(t.items[s],s),V=L.get($)??N.value;d[s]=V,n[s+1]=n[s]+V}return{offsets:n,sizes:d,total:n[t.items.length]??0}}),x=e.computed(()=>{const n=new Map;return t.items.forEach((d,s)=>{n.set(D(d,s),s)}),n});function O(n){if(t.items.length===0)return 0;const d=E.value.offsets;let s=0,$=t.items.length;for(;s<$;){const V=Math.floor((s+$)/2);d[V+1]<=n?s=V+1:$=V}return Math.min(s,t.items.length-1)}const F=e.computed(()=>Math.max(0,O(T.value)-W.value)),_=e.computed(()=>{if(t.items.length===0)return 0;const n=O(T.value+Z.value)+1;return Math.min(t.items.length,n+W.value)}),R=e.computed(()=>t.items.slice(F.value,_.value).map((n,d)=>{const s=F.value+d;return{item:n,index:s,key:D(n,s),top:E.value.offsets[s]}})),te=e.computed(()=>({height:ie(t.height)}));function C(){const n=h.value;if(!n)return;const s=Math.max(0,E.value.total-n.scrollTop-n.clientHeight)<=Math.max(0,t.bottomThreshold);s!==K.value&&(K.value=s,M&&k("bottomChange",s))}function c(){var n;u.value=((n=h.value)==null?void 0:n.clientHeight)??0,S(h.value,t.height),e.nextTick(()=>{C(),B()})}function v(n){T.value=n.currentTarget.scrollTop,C(),k("scroll",{scrollTop:T.value,startIndex:F.value,endIndex:_.value}),B()}function B(){const n=h.value;!M||!n||!t.hasOlder||t.loadingOlder||w===t.items.length||n.scrollTop<=Math.max(0,t.loadOlderThreshold)&&(w=t.items.length,k("loadOlder"))}function G(n){const d=n.borderBoxSize;if(d){const s=Array.isArray(d)?d[0]:d;if(s!=null&&s.blockSize)return s.blockSize}return n.contentRect.height}function J(n){const d=E.value,s=K.value&&t.stickToBottom;let $=0,V=!1;for(const A of n){const i=A.target,l=H.get(i),a=G(A);if(l===void 0||a<=0)continue;const o=L.get(l)??N.value;if(Math.abs(o-a)<.5)continue;const g=x.value.get(l);g!==void 0&&d.offsets[g+1]<=T.value&&($+=a-o),L.set(l,a),V=!0}V&&(I.value+=1,e.nextTick(()=>{const A=h.value;A&&(s?m("auto"):$!==0&&(A.scrollTop+=$,T.value=A.scrollTop,C()))}))}function Q(n,d){n instanceof HTMLElement&&(H.set(n,d),y==null||y.observe(n))}function U(){for(const[n]of H)n.isConnected||(y==null||y.unobserve(n),H.delete(n))}function X(n,d={}){const s=h.value;if(!s)return;const $=Math.max(0,E.value.total-s.clientHeight),V=Math.min(Math.max(0,Number.isFinite(n)?n:0),$),A=d.behavior??"auto";A==="auto"&&(T.value=V),s.scrollTo({...d,top:V,behavior:A}),e.nextTick(C)}function j(n,d={}){const s=h.value;if(!s||t.items.length===0)return;const $=Math.min(t.items.length-1,Math.max(0,Math.floor(n))),{align:V="start",...A}=d,i=E.value.sizes[$];let l=E.value.offsets[$];V==="center"?l-=(s.clientHeight-i)/2:V==="end"&&(l-=s.clientHeight-i);const a=Math.max(0,Math.min(l,E.value.total-s.clientHeight)),o=A.behavior??"auto",g=Math.max(s.clientHeight*3,N.value*10),p=o==="smooth"&&Math.abs(a-s.scrollTop)>g?"auto":o;p==="auto"&&(T.value=a),s.scrollTo({...A,top:a,behavior:p}),e.nextTick(C)}function oe(n="auto"){const d=h.value;d&&(n==="auto"&&(T.value=0),d.scrollTo({top:0,behavior:n}),e.nextTick(C))}function m(n="auto"){const d=h.value;if(!d)return;const s=Math.max(0,E.value.total-d.clientHeight);n==="auto"?(d.scrollTop=s,T.value=s):d.scrollTo({top:s,behavior:n}),e.nextTick(C)}let f=t.items.map((n,d)=>D(n,d));return e.watch(()=>t.items.map((n,d)=>D(n,d)),async n=>{const d=f;f=n;const s=h.value,$=(s==null?void 0:s.scrollTop)??0,V=K.value&&t.stickToBottom,A=d[0],i=A===void 0?0:n.indexOf(A),l=i>0?n.slice(0,i).reduce((o,g)=>o+(L.get(g)??N.value),0):0,a=new Set(n);for(const o of L.keys())a.has(o)||L.delete(o);I.value+=1,await e.nextTick(),s&&(l>0?(s.scrollTop=$+l,T.value=s.scrollTop):n.length>d.length&&V&&m("auto"),C(),B())}),e.watch(()=>[t.hasOlder,t.loadingOlder],async([n])=>{n||(w=-1),await e.nextTick(),B()}),e.onMounted(()=>{if(c(),typeof ResizeObserver<"u"){z=new ResizeObserver(c),y=new ResizeObserver(J),h.value&&z.observe(h.value);for(const[n]of H)y.observe(n)}e.nextTick(()=>{t.initialScroll==="bottom"&&m("auto"),M=!0,C(),B()})}),e.onUpdated(U),e.onBeforeUnmount(()=>{z==null||z.disconnect(),y==null||y.disconnect(),H.clear()}),P({isAtBottom:K,scrollTo:X,scrollToIndex:j,scrollToTop:oe,scrollToBottom:m}),(n,d)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:h,class:"vue-chat-virtual-scroll",style:e.normalizeStyle(te.value),role:"log","aria-label":r.ariaLabel,"aria-live":"polite",tabindex:"0",onScrollPassive:v},[r.loadingOlder?(e.openBlock(),e.createElementBlock("div",we,[e.createElementVNode("div",null,[e.renderSlot(n.$slots,"loadingOlder",{},()=>[d[0]||(d[0]=e.createTextVNode("Loading older messages…",-1))])])])):e.createCommentVNode("",!0),r.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-chat-virtual-scroll__spacer",style:e.normalizeStyle({height:`${E.value.total}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,({item:s,index:$,key:V,top:A})=>(e.openBlock(),e.createElementBlock("div",{key:V,ref_for:!0,ref:i=>Q(i,V),class:"vue-chat-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${A}px)`}),role:"article","aria-posinset":$+1,"aria-setsize":r.items.length},[e.renderSlot(n.$slots,"default",{item:s,index:$})],12,Se))),128))],4)):e.renderSlot(n.$slots,"empty",{},void 0,void 0,2)],44,ke))}});function de(r){const P=e.ref(),b=e.ref(0),t=e.ref(!1),k=e.ref(!1),h=e.computed(()=>Math.max(1,r.threshold())),T=e.computed(()=>r.refreshing()||k.value?h.value:b.value),u=e.computed(()=>Math.min(1,b.value/h.value)),I=e.computed(()=>r.refreshing()||k.value?"Refreshing…":u.value>=1?"Release to refresh":"Pull to refresh");function K(){P.value=void 0,t.value=!1,b.value=0}function L(y){var S;const w=y.currentTarget,M=((S=r.scrollTop)==null?void 0:S.call(r))??w.scrollTop;!r.enabled()||r.refreshing()||M>0||y.touches.length!==1||(P.value=y.touches[0].clientY,t.value=!0)}function H(y){var D;if(P.value===void 0||!t.value)return;const w=y.currentTarget;if((((D=r.scrollTop)==null?void 0:D.call(r))??w.scrollTop)>0||y.touches.length!==1){K();return}const S=y.touches[0].clientY-P.value;if(S<=0){b.value=0;return}y.preventDefault(),b.value=Math.min(S*.5,h.value*2)}function z(){if(P.value===void 0)return;const y=b.value>=h.value&&r.enabled()&&!r.refreshing();if(P.value=void 0,t.value=!1,!y){b.value=0;return}b.value=h.value,k.value=!0,r.onRefresh(),e.nextTick(()=>{r.refreshing()||(k.value=!1,b.value=0)})}return e.watch(()=>r.refreshing(),(y,w)=>{y?(k.value=!1,b.value=h.value):w&&(k.value=!1,b.value=0)}),{pulling:t,pullDistance:b,pullOffset:T,pullProgress:u,refreshMessage:I,refreshThreshold:h,handleTouchStart:L,handleTouchMove:H,handleTouchEnd:z,handleTouchCancel:K}}const be=["aria-label"],Be=["aria-posinset","aria-setsize"],me=e.defineComponent({name:"DynamicVirtualScroll",__name:"DynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:P,emit:b}){const t=r,k=b,{pulling:h,pullDistance:T,pullOffset:u,pullProgress:I,refreshMessage:K,refreshThreshold:L,handleTouchStart:H,handleTouchMove:z,handleTouchEnd:y,handleTouchCancel:w}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>k("refresh")}),M=e.ref(),S=e.ref(0),D=e.ref(0),N=e.ref(0),W=new Map,Z=new Map;let E,x,O=-1;const F=se(),{getItemKey:_}=ne({componentName:"DynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),R=e.computed(()=>Math.max(1,t.estimatedItemSize)),te=e.computed(()=>Math.max(1,t.loadingItemSize??R.value)),C=e.computed(()=>Math.max(0,Math.floor(t.overscan))),c=e.computed(()=>D.value>0?D.value:typeof t.height=="number"?Math.max(0,t.height):R.value),v=e.computed(()=>{N.value;const l=new Array(t.items.length+1),a=new Array(t.items.length);l[0]=0;for(let o=0;o<t.items.length;o+=1){const g=_(t.items[o],o),p=W.get(g)??R.value;a[o]=p,l[o+1]=l[o]+p}return{offsets:l,sizes:a,total:l[t.items.length]??0}}),B=e.computed(()=>v.value.total+(t.loading?te.value:0)),G=e.computed(()=>{const l=new Map;return t.items.forEach((a,o)=>{l.set(_(a,o),o)}),l});function J(l){if(t.items.length===0)return 0;const a=v.value.offsets;let o=0,g=t.items.length;for(;o<g;){const p=Math.floor((o+g)/2);a[p+1]<=l?o=p+1:g=p}return Math.min(o,t.items.length-1)}const Q=e.computed(()=>Math.max(0,J(S.value)-C.value)),U=e.computed(()=>{if(t.items.length===0)return 0;const l=J(S.value+c.value)+1;return Math.min(t.items.length,l+C.value)}),X=e.computed(()=>t.items.slice(Q.value,U.value).map((l,a)=>{const o=Q.value+a;return{item:l,index:o,key:_(l,o),top:v.value.offsets[o]}})),j=e.computed(()=>({height:ie(t.height)}));function oe(){var l;D.value=((l=M.value)==null?void 0:l.clientHeight)??0,F(M.value,t.height),e.nextTick(f)}function m(l){S.value=l.currentTarget.scrollTop,k("scroll",{scrollTop:S.value,startIndex:Q.value,endIndex:U.value}),f()}function f(){const l=M.value;if(!l||!t.hasMore||t.loading||O===t.items.length)return;const a=Math.max(0,t.loadMoreThreshold);B.value-l.scrollTop-l.clientHeight<=a&&(O=t.items.length,k("loadMore"))}function n(l){const a=l.borderBoxSize;if(a){const o=Array.isArray(a)?a[0]:a;if(o!=null&&o.blockSize)return o.blockSize}return l.contentRect.height}function d(l){const a=v.value;let o=0,g=!1;for(const p of l){const q=p.target,Y=Z.get(q),ee=n(p);if(Y===void 0||ee<=0)continue;const le=W.get(Y)??R.value;if(Math.abs(le-ee)<.5)continue;const ae=G.value.get(Y);ae!==void 0&&a.offsets[ae+1]<=S.value&&(o+=ee-le),W.set(Y,ee),g=!0}g&&(N.value+=1,e.nextTick(f),o!==0&&e.nextTick(()=>{const p=M.value;p&&(p.scrollTop+=o,S.value=p.scrollTop)}))}function s(l,a){l instanceof HTMLElement&&(Z.set(l,a),x==null||x.observe(l))}function $(){for(const[l]of Z)l.isConnected||(x==null||x.unobserve(l),Z.delete(l))}function V(l,a={}){const o=M.value;if(!o)return;const g=Math.max(0,B.value-o.clientHeight),p=Math.min(Math.max(0,Number.isFinite(l)?l:0),g),q=a.behavior??"auto";q==="auto"&&(S.value=p),o.scrollTo({...a,top:p,behavior:q})}function A(l,a={}){const o=M.value;if(!o||t.items.length===0)return;const g=Math.min(t.items.length-1,Math.max(0,Math.floor(l))),{align:p="start",...q}=a;let Y=v.value.offsets[g];const ee=v.value.sizes[g];p==="center"?Y-=(o.clientHeight-ee)/2:p==="end"&&(Y-=o.clientHeight-ee);const le=Math.max(0,Math.min(Y,B.value-o.clientHeight)),ae=q.behavior??"auto",ue=Math.max(o.clientHeight*3,R.value*10),re=ae==="smooth"&&Math.abs(le-o.scrollTop)>ue?"auto":ae;re==="auto"&&(S.value=le),o.scrollTo({...q,top:le,behavior:re})}function i(l="auto"){var a;(a=M.value)==null||a.scrollTo({top:0,behavior:l})}return e.watch(()=>t.itemKey,()=>{W.clear(),N.value+=1}),e.watch(()=>t.items.length,async()=>{const l=new Set(t.items.map((g,p)=>_(g,p)));for(const g of W.keys())l.has(g)||W.delete(g);N.value+=1,await e.nextTick();const a=M.value;if(!a)return;const o=Math.max(0,B.value-a.clientHeight);a.scrollTop>o&&(a.scrollTop=o,S.value=o),f()}),e.watch(()=>[t.hasMore,t.loading],async([l])=>{l||(O=-1),await e.nextTick(),f()}),e.onMounted(()=>{if(oe(),typeof ResizeObserver<"u"){E=new ResizeObserver(oe),x=new ResizeObserver(d),M.value&&E.observe(M.value);for(const[l]of Z)x.observe(l)}e.nextTick(f)}),e.onUpdated($),e.onBeforeUnmount(()=>{E==null||E.disconnect(),x==null||x.disconnect(),Z.clear()}),P({scrollTo:V,scrollToIndex:A,scrollToTop:i}),(l,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:M,class:e.normalizeClass(["vue-dynamic-virtual-scroll",{"vue-dynamic-virtual-scroll--pulling":e.unref(h)}]),style:e.normalizeStyle(j.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:m,onTouchstartPassive:a[0]||(a[0]=(...o)=>e.unref(H)&&e.unref(H)(...o)),onTouchmove:a[1]||(a[1]=(...o)=>e.unref(z)&&e.unref(z)(...o)),onTouchend:a[2]||(a[2]=(...o)=>e.unref(y)&&e.unref(y)(...o)),onTouchcancel:a[3]||(a[3]=(...o)=>e.unref(w)&&e.unref(w)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(L)}px`,transform:`translateY(${e.unref(u)-e.unref(L)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"refresh",{pullDistance:e.unref(T),progress:e.unref(I),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(K)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${B.value}px`,transform:`translateY(${e.unref(u)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.value,({item:o,index:g,key:p,top:q})=>(e.openBlock(),e.createElementBlock("div",{key:p,ref_for:!0,ref:Y=>s(Y,p),class:"vue-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${q}px)`}),role:"listitem","aria-posinset":g+1,"aria-setsize":r.items.length},[e.renderSlot(l.$slots,"default",{item:o,index:g})],12,Be))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${te.value}px`,transform:`translateY(${v.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"loading",{},()=>[a[4]||(a[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(u)}px)`})},[e.renderSlot(l.$slots,"empty")],4))],46,be))}}),Ie=["aria-label"],ze=["aria-current","aria-posinset","aria-setsize"],Ee={key:1,class:"vue-short-media-feed__empty"},he=e.defineComponent({name:"ShortMediaFeed",__name:"ShortMediaFeed",props:{items:{},activeIndex:{default:0},buffer:{default:1},height:{default:"100dvh"},itemKey:{default:void 0},ariaLabel:{default:"Short media feed"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:P,emit:b}){const t=r,k=b,h=e.ref(),T=e.ref(0),u=e.ref(E(t.activeIndex));let I,K=-1;const L=se(),{getItemKey:H}=ne({componentName:"ShortMediaFeed",items:()=>t.items,itemKey:()=>t.itemKey}),z=e.computed(()=>Math.max(0,Math.floor(t.buffer))),y=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),w=e.computed(()=>T.value>0?T.value:typeof t.height=="number"?Math.max(1,t.height):0),M=e.computed(()=>Math.max(0,u.value-z.value)),S=e.computed(()=>Math.min(t.items.length,u.value+z.value+1)),D=e.computed(()=>t.items.slice(M.value,S.value).map((c,v)=>({item:c,index:M.value+v}))),N=e.computed(()=>M.value*w.value),W=e.computed(()=>(t.items.length-S.value)*w.value),Z=e.computed(()=>({height:ie(t.height)}));function E(c){return t.items.length===0?0:Math.min(t.items.length-1,Math.max(0,Math.floor(Number.isFinite(c)?c:0)))}function x(){if(!t.hasMore||t.loading||K===t.items.length)return;(t.items.length===0?0:t.items.length-1-u.value)<=y.value&&(K=t.items.length,k("loadMore"))}function O(c){const v=E(c);v===u.value||t.items.length===0||(u.value=v,k("update:activeIndex",v),k("change",{index:v,item:t.items[v]}),v===0&&k("reachStart"),v===t.items.length-1&&k("reachEnd"),x())}function F(c,v={}){const B=h.value;B&&(typeof B.scrollTo=="function"?B.scrollTo({...v,top:c}):B.scrollTop=c)}function _(c,v={}){if(t.items.length===0)return;const B=E(c);O(B),F(B*w.value,v)}function R(c){if(w.value<=0)return;const v=c.currentTarget.scrollTop;O(Math.round(v/w.value))}function te(c){let v;c.key==="ArrowDown"||c.key==="PageDown"?v=u.value+1:c.key==="ArrowUp"||c.key==="PageUp"?v=u.value-1:c.key==="Home"?v=0:c.key==="End"&&(v=t.items.length-1),v!==void 0&&(c.preventDefault(),_(v,{behavior:"smooth"}))}function C(){var v;const c=((v=h.value)==null?void 0:v.clientHeight)??0;L(h.value,t.height),!(c<=0||c===T.value)&&(T.value=c,e.nextTick(()=>{F(u.value*c)}))}return e.watch(()=>t.activeIndex,async c=>{const v=E(c);v!==u.value&&(u.value=v,await e.nextTick(),F(v*w.value),x())}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([c])=>{c||(K=-1),await e.nextTick(),x()}),e.watch(()=>t.items.length,async()=>{const c=E(u.value);t.items.length===0?u.value!==0&&(u.value=0,k("update:activeIndex",0)):O(c),await e.nextTick(),F(c*w.value),x()}),e.onMounted(async()=>{C(),typeof ResizeObserver<"u"&&h.value&&(I=new ResizeObserver(C),I.observe(h.value)),await e.nextTick(),F(u.value*w.value),x()}),e.onBeforeUnmount(()=>{I==null||I.disconnect()}),P({scrollToIndex:_}),(c,v)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:h,class:"vue-short-media-feed",style:e.normalizeStyle(Z.value),role:"list","aria-orientation":"vertical","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:R,onKeydown:te},[r.items.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[N.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${N.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,({item:B,index:G})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(H)(B,G),class:"vue-short-media-feed__item",style:e.normalizeStyle({height:`${w.value}px`}),role:"listitem","aria-current":G===u.value?"true":void 0,"aria-posinset":G+1,"aria-setsize":r.items.length},[e.renderSlot(c.$slots,"default",{item:B,index:G,active:G===u.value})],12,ze))),128)),W.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${W.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",Ee,[e.renderSlot(c.$slots,"empty")]))],44,Ie))}}),$e=["aria-label"],Ve={key:0,class:"vue-virtual-carousel__track",role:"list"},He=["aria-label","aria-current"],Le={key:1,class:"vue-virtual-carousel__empty"},ve=e.defineComponent({name:"VirtualCarousel",__name:"VirtualCarousel",props:{items:{},activeIndex:{default:0},slidesPerView:{default:1},slidesToScroll:{default:1},gap:{default:0},buffer:{default:1},height:{default:"auto"},itemKey:{default:void 0},ariaLabel:{default:"Carousel"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2},autoplay:{type:Boolean,default:!1},autoplayDelay:{default:3e3},autoplayLoop:{type:Boolean,default:!0},pauseOnHover:{type:Boolean,default:!0}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:P,emit:b}){const t=r,k=b,h=e.ref(),T=e.ref(0),u=e.ref(0);let I,K=-1,L,H;const z=e.ref(!1),{getItemKey:y}=ne({componentName:"VirtualCarousel",items:()=>t.items,itemKey:()=>t.itemKey}),w=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(t.slidesPerView)?t.slidesPerView:1))),M=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(t.slidesToScroll)?t.slidesToScroll:1))),S=e.computed(()=>Math.max(0,Number.isFinite(t.gap)?t.gap:0)),D=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.buffer)?t.buffer:0))),N=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),W=e.computed(()=>Number.isFinite(t.autoplayDelay)?Math.max(1,t.autoplayDelay):3e3),Z=e.computed(()=>Math.max(0,T.value)),E=e.computed(()=>{if(Z.value<=0)return 0;const i=(w.value-1)*S.value;return Math.max(1,(Z.value-i)/w.value)}),x=e.computed(()=>E.value+S.value),O=e.computed(()=>Math.max(0,t.items.length-w.value)),F=e.computed(()=>Math.max(0,u.value-D.value)),_=e.computed(()=>Math.min(t.items.length,u.value+w.value+D.value)),R=e.computed(()=>t.items.slice(F.value,_.value).map((i,l)=>({item:i,index:F.value+l}))),te=e.computed(()=>t.items.length===0?0:t.items.length*E.value+(t.items.length-1)*S.value),C=e.computed(()=>F.value*x.value),c=e.computed(()=>Math.max(0,te.value-_.value*x.value)),v=e.computed(()=>({height:ie(t.height)}));function B(i){return Math.min(O.value,Math.max(0,Math.floor(Number.isFinite(i)?i:0)))}u.value=B(t.activeIndex);function G(i){return i>=u.value&&i<Math.min(t.items.length,u.value+w.value)}function J(){if(!t.hasMore||t.loading||K===t.items.length)return;const i=t.items.length===0?-1:Math.min(t.items.length-1,u.value+w.value-1);t.items.length-1-i<=N.value&&(K=t.items.length,k("loadMore"))}function Q(i){const l=B(i);l===u.value||t.items.length===0||(u.value=l,k("update:activeIndex",l),k("change",{index:l,item:t.items[l]}),l===0&&k("reachStart"),l===O.value&&k("reachEnd"),J(),t.autoplay&&!z.value&&m())}function U(i,l={}){const a=h.value;a&&(typeof a.scrollTo=="function"?a.scrollTo({...l,left:i}):a.scrollLeft=i)}function X(i,l={}){if(t.items.length===0||x.value<=0)return;const a=B(i),o=Math.abs(a-u.value),g=l.behavior==="smooth"&&o>D.value?"auto":l.behavior;H=g==="smooth"?a:void 0,Q(a),U(a*x.value,{...l,behavior:g})}function j(i="smooth"){X(u.value+M.value,{behavior:i})}function oe(i="smooth"){X(u.value-M.value,{behavior:i})}function m(){f(),!(!t.autoplay||t.items.length===0)&&(L=setTimeout(()=>{u.value>=O.value?t.autoplayLoop?X(0,{behavior:"smooth"}):f():j("smooth")},W.value))}function f(){L!==void 0&&(clearTimeout(L),L=void 0)}function n(){z.value=!0,t.pauseOnHover&&f()}function d(){z.value=!1,t.autoplay&&m()}function s(){H=void 0}function $(i){if(x.value<=0)return;const l=i.currentTarget.scrollLeft;if(H!==void 0){const a=H*x.value;if(Math.abs(l-a)>1)return;H=void 0}Q(Math.round(l/x.value))}function V(i){i.key==="ArrowRight"||i.key==="PageDown"?(i.preventDefault(),j()):i.key==="ArrowLeft"||i.key==="PageUp"?(i.preventDefault(),oe()):i.key==="Home"?(i.preventDefault(),X(0,{behavior:"smooth"})):i.key==="End"&&(i.preventDefault(),X(O.value,{behavior:"auto"}))}function A(){var l;const i=((l=h.value)==null?void 0:l.clientWidth)??0;i<=0||i===T.value||(T.value=i,e.nextTick(()=>{U(u.value*x.value)}))}return e.watch(()=>t.activeIndex,async i=>{const l=B(i);l!==u.value&&(s(),u.value=l,await e.nextTick(),U(l*x.value),J())}),e.watch(()=>[t.items.length,t.slidesPerView,t.gap],async()=>{const i=B(u.value);t.items.length===0?u.value!==0&&(u.value=0,k("update:activeIndex",0)):Q(i),await e.nextTick(),U(i*x.value),J(),t.autoplay&&t.items.length>0&&!z.value&&m()}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([i])=>{i||(K=-1),await e.nextTick(),J()}),e.watch(()=>t.autoplay,i=>{i&&!z.value?m():f()}),e.watch(()=>t.autoplayDelay,()=>{t.autoplay&&!z.value&&m()}),e.watch(()=>t.autoplayLoop,i=>{!t.autoplay||z.value||(!i&&u.value>=O.value?f():m())}),e.watch(()=>t.pauseOnHover,i=>{i&&z.value?f():!i&&t.autoplay&&m()}),e.onMounted(async()=>{A(),typeof ResizeObserver<"u"&&h.value&&(I=new ResizeObserver(A),I.observe(h.value)),await e.nextTick(),U(u.value*x.value),J(),t.autoplay&&m()}),e.onBeforeUnmount(()=>{I==null||I.disconnect(),f()}),P({next:j,previous:oe,scrollToIndex:X,startAutoplay:m,stopAutoplay:f}),(i,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:h,class:"vue-virtual-carousel",style:e.normalizeStyle(v.value),role:"region","aria-roledescription":"carousel","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:$,onPointerdown:s,onWheelPassive:s,onKeydown:V,onMouseenter:n,onMouseleave:d},[r.items.length?(e.openBlock(),e.createElementBlock("div",Ve,[C.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${C.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,({item:a,index:o})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(y)(a,o),class:"vue-virtual-carousel__item",style:e.normalizeStyle({flexBasis:`${E.value}px`,marginRight:o<r.items.length-1?`${S.value}px`:"0px"}),role:"listitem","aria-roledescription":"slide","aria-label":`${o+1} of ${r.items.length}`,"aria-current":o===u.value?"true":void 0},[e.renderSlot(i.$slots,"default",{item:a,index:o,active:o===u.value,visible:G(o)})],12,He))),128)),c.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${c.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Le,[e.renderSlot(i.$slots,"empty")]))],44,$e))}}),Ce=["aria-label"],Ke=["aria-posinset","aria-setsize"],pe=e.defineComponent({name:"VirtualScroll",__name:"VirtualScroll",props:{items:{},itemSize:{},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:P,emit:b}){const t=r,k=b,{pulling:h,pullDistance:T,pullOffset:u,pullProgress:I,refreshMessage:K,refreshThreshold:L,handleTouchStart:H,handleTouchMove:z,handleTouchEnd:y,handleTouchCancel:w}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>k("refresh")}),M=e.ref(),S=e.ref(0),D=e.ref(0);let N,W=-1;const Z=se(),{getItemKey:E}=ne({componentName:"VirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),x=e.computed(()=>Math.max(1,t.itemSize)),O=e.computed(()=>Math.max(0,Math.floor(t.overscan))),F=e.computed(()=>t.items.length*x.value),_=e.computed(()=>Math.max(1,t.loadingItemSize??x.value)),R=e.computed(()=>F.value+(t.loading?_.value:0)),te=e.computed(()=>D.value>0?D.value:typeof t.height=="number"?t.height:0),C=e.computed(()=>Math.max(0,Math.floor(S.value/x.value)-O.value)),c=e.computed(()=>{const m=Math.ceil((S.value+te.value)/x.value);return Math.min(t.items.length,m+O.value)}),v=e.computed(()=>t.items.slice(C.value,c.value).map((m,f)=>({item:m,index:C.value+f}))),B=e.computed(()=>({height:ie(t.height)})),G=e.computed(()=>({transform:`translateY(${C.value*x.value}px)`}));function J(){var m;D.value=((m=M.value)==null?void 0:m.clientHeight)??0,Z(M.value,t.height),e.nextTick(U)}function Q(m){S.value=m.currentTarget.scrollTop,k("scroll",{scrollTop:S.value,startIndex:C.value,endIndex:c.value}),U()}function U(){const m=M.value;if(!m||!t.hasMore||t.loading||W===t.items.length)return;const f=Math.max(0,t.loadMoreThreshold);R.value-m.scrollTop-m.clientHeight<=f&&(W=t.items.length,k("loadMore"))}function X(m,f={}){const n=M.value;if(!n)return;const d=Math.max(0,R.value-n.clientHeight),s=Math.min(Math.max(0,Number.isFinite(m)?m:0),d),$=f.behavior??"auto";$==="auto"&&(S.value=s),n.scrollTo({...f,top:s,behavior:$})}function j(m,f={}){const n=M.value;if(!n||t.items.length===0)return;const d=Math.min(t.items.length-1,Math.max(0,Math.floor(m))),{align:s="start",...$}=f;let V=d*x.value;s==="center"?V-=(n.clientHeight-x.value)/2:s==="end"&&(V-=n.clientHeight-x.value),n.scrollTo({...$,top:Math.max(0,Math.min(V,R.value-n.clientHeight))})}function oe(m="auto"){var f;(f=M.value)==null||f.scrollTo({top:0,behavior:m})}return e.watch(()=>[t.items.length,t.itemSize],async()=>{await e.nextTick();const m=M.value;if(!m)return;const f=Math.max(0,R.value-m.clientHeight);m.scrollTop>f&&(m.scrollTop=f,S.value=f),U()}),e.watch(()=>[t.hasMore,t.loading],async([m])=>{m||(W=-1),await e.nextTick(),U()}),e.onMounted(()=>{J(),typeof ResizeObserver<"u"&&M.value&&(N=new ResizeObserver(J),N.observe(M.value)),e.nextTick(U)}),e.onBeforeUnmount(()=>{N==null||N.disconnect()}),P({scrollTo:X,scrollToIndex:j,scrollToTop:oe}),(m,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:M,class:e.normalizeClass(["vue-virtual-scroll",{"vue-virtual-scroll--pulling":e.unref(h)}]),style:e.normalizeStyle(B.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:Q,onTouchstartPassive:f[0]||(f[0]=(...n)=>e.unref(H)&&e.unref(H)(...n)),onTouchmove:f[1]||(f[1]=(...n)=>e.unref(z)&&e.unref(z)(...n)),onTouchend:f[2]||(f[2]=(...n)=>e.unref(y)&&e.unref(y)(...n)),onTouchcancel:f[3]||(f[3]=(...n)=>e.unref(w)&&e.unref(w)(...n))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(L)}px`,transform:`translateY(${e.unref(u)-e.unref(L)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(m.$slots,"refresh",{pullDistance:e.unref(T),progress:e.unref(I),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(K)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-scroll__spacer",style:e.normalizeStyle({height:`${R.value}px`,transform:`translateY(${e.unref(u)}px)`})},[e.createElementVNode("div",{class:"vue-virtual-scroll__content",style:e.normalizeStyle(G.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,({item:n,index:d})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(E)(n,d),class:"vue-virtual-scroll__item",style:e.normalizeStyle({height:`${x.value}px`}),role:"listitem","aria-posinset":d+1,"aria-setsize":r.items.length},[e.renderSlot(m.$slots,"default",{item:n,index:d})],12,Ke))),128))],4),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__loading",style:e.normalizeStyle({height:`${_.value}px`,transform:`translateY(${F.value}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(m.$slots,"loading",{},()=>[f[4]||(f[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(u)}px)`})},[e.renderSlot(m.$slots,"empty")],4))],46,Ce))}}),Ne=["aria-label"],De=["aria-posinset","aria-setsize"],ge=e.defineComponent({name:"WindowDynamicVirtualScroll",__name:"WindowDynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Window dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:P,emit:b}){const t=r,k=b,h=e.ref(),T=e.ref(0),u=e.ref(0),I=e.ref(0),K=e.ref(0),L=new Map,H=new Map;let z,y,w=-1;const{getItemKey:M}=ne({componentName:"WindowDynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),{pulling:S,pullDistance:D,pullOffset:N,pullProgress:W,refreshMessage:Z,refreshThreshold:E,handleTouchStart:x,handleTouchMove:O,handleTouchEnd:F,handleTouchCancel:_}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>k("refresh"),scrollTop:()=>typeof window>"u"?0:Math.max(0,window.scrollY)}),R=e.computed(()=>Math.max(1,t.estimatedItemSize)),te=e.computed(()=>Math.max(1,t.loadingItemSize??R.value)),C=e.computed(()=>Math.max(0,Math.floor(t.overscan))),c=e.computed(()=>{K.value;const l=new Array(t.items.length+1),a=new Array(t.items.length);l[0]=0;for(let o=0;o<t.items.length;o+=1){const g=M(t.items[o],o),p=L.get(g)??R.value;a[o]=p,l[o+1]=l[o]+p}return{offsets:l,sizes:a,total:l[t.items.length]??0}}),v=e.computed(()=>c.value.total+(t.loading?te.value:0)),B=e.computed(()=>{const l=new Map;return t.items.forEach((a,o)=>{l.set(M(a,o),o)}),l}),G=e.computed(()=>Math.max(0,T.value-I.value));function J(l){if(t.items.length===0)return 0;const a=c.value.offsets;let o=0,g=t.items.length;for(;o<g;){const p=Math.floor((o+g)/2);a[p+1]<=l?o=p+1:g=p}return Math.min(o,t.items.length-1)}const Q=e.computed(()=>Math.max(0,J(G.value)-C.value)),U=e.computed(()=>{if(t.items.length===0)return 0;const l=T.value+u.value-I.value,a=Math.max(R.value,l),o=J(a)+1;return Math.min(t.items.length,o+C.value)}),X=e.computed(()=>t.items.slice(Q.value,U.value).map((l,a)=>{const o=Q.value+a;return{item:l,index:o,key:M(l,o),top:c.value.offsets[o]}}));function j(){typeof window>"u"||(T.value=Math.max(0,window.scrollY),u.value=window.innerHeight,h.value&&(I.value=h.value.getBoundingClientRect().top+T.value))}function oe(){k("scroll",{scrollTop:G.value,startIndex:Q.value,endIndex:U.value})}function m(){j(),oe(),f()}function f(){if(typeof window>"u"||!t.hasMore||t.loading||w===t.items.length)return;const l=Math.max(0,t.loadMoreThreshold),a=I.value+v.value,o=T.value+u.value;a-o<=l&&(w=t.items.length,k("loadMore"))}function n(l){const a=l.borderBoxSize;if(a){const o=Array.isArray(a)?a[0]:a;if(o!=null&&o.blockSize)return o.blockSize}return l.contentRect.height}function d(l){const a=c.value;let o=0,g=!1;for(const p of l){const q=p.target,Y=H.get(q),ee=n(p);if(Y===void 0||ee<=0)continue;const le=L.get(Y)??R.value;if(Math.abs(le-ee)<.5)continue;const ae=B.value.get(Y);ae!==void 0&&a.offsets[ae+1]<=G.value&&(o+=ee-le),L.set(Y,ee),g=!0}g&&(K.value+=1,e.nextTick(()=>{if(o!==0&&typeof window<"u"){const p=Math.max(0,T.value+o);T.value=p,window.scrollTo({top:p,behavior:"auto"})}j(),f()}))}function s(l,a){l instanceof HTMLElement&&(H.set(l,a),y==null||y.observe(l))}function $(){for(const[l]of H)l.isConnected||(y==null||y.unobserve(l),H.delete(l))}function V(l,a={}){if(typeof window>"u")return;j();const o=Math.max(0,v.value-u.value),g=Math.min(Math.max(0,Number.isFinite(l)?l:0),o),p=Math.max(0,I.value+g),q=a.behavior??"auto";q==="auto"&&(T.value=p),window.scrollTo({...a,top:p,behavior:q})}function A(l,a={}){if(typeof window>"u"||t.items.length===0)return;j();const o=Math.min(t.items.length-1,Math.max(0,Math.floor(l))),{align:g="start",...p}=a,q=c.value.sizes[o];let Y=I.value+c.value.offsets[o];g==="center"?Y-=(u.value-q)/2:g==="end"&&(Y-=u.value-q);const ee=Math.max(I.value,I.value+v.value-u.value),le=Math.max(0,Math.min(Y,ee)),ae=p.behavior??"auto",ue=Math.max(u.value*3,R.value*10),re=ae==="smooth"&&Math.abs(le-T.value)>ue?"auto":ae;re==="auto"&&(T.value=le),window.scrollTo({...p,top:le,behavior:re})}function i(l="auto"){typeof window>"u"||(j(),window.scrollTo({top:Math.max(0,I.value),behavior:l}))}return e.watch(()=>t.itemKey,()=>{L.clear(),K.value+=1}),e.watch(()=>t.items.length,async()=>{const l=new Set(t.items.map((a,o)=>M(a,o)));for(const a of L.keys())l.has(a)||L.delete(a);K.value+=1,await e.nextTick(),j(),f()}),e.watch(()=>[t.hasMore,t.loading],async([l])=>{l||(w=-1),await e.nextTick(),j(),f()}),e.onMounted(()=>{if(j(),window.addEventListener("scroll",m,{passive:!0}),window.addEventListener("resize",m,{passive:!0}),typeof ResizeObserver<"u"){z=new ResizeObserver(()=>{j(),f()}),y=new ResizeObserver(d),h.value&&z.observe(h.value);for(const[l]of H)y.observe(l)}e.nextTick(f)}),e.onUpdated($),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",m),window.removeEventListener("resize",m),z==null||z.disconnect(),y==null||y.disconnect(),H.clear()}),P({scrollTo:V,scrollToIndex:A,scrollToTop:i}),(l,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"root",ref:h,class:e.normalizeClass(["vue-window-dynamic-virtual-scroll",{"vue-window-dynamic-virtual-scroll--pulling":e.unref(S)}]),role:"list","aria-label":r.ariaLabel,onTouchstartPassive:a[0]||(a[0]=(...o)=>e.unref(x)&&e.unref(x)(...o)),onTouchmove:a[1]||(a[1]=(...o)=>e.unref(O)&&e.unref(O)(...o)),onTouchend:a[2]||(a[2]=(...o)=>e.unref(F)&&e.unref(F)(...o)),onTouchcancel:a[3]||(a[3]=(...o)=>e.unref(_)&&e.unref(_)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(E)}px`,transform:`translateY(${e.unref(N)-e.unref(E)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"refresh",{pullDistance:e.unref(D),progress:e.unref(W),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(Z)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-window-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${v.value}px`,transform:`translateY(${e.unref(N)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X.value,({item:o,index:g,key:p,top:q})=>(e.openBlock(),e.createElementBlock("div",{key:p,ref_for:!0,ref:Y=>s(Y,p),class:"vue-window-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${q}px)`}),role:"listitem","aria-posinset":g+1,"aria-setsize":r.items.length},[e.renderSlot(l.$slots,"default",{item:o,index:g})],12,De))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${te.value}px`,transform:`translateY(${c.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"loading",{},()=>[a[4]||(a[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-window-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(N)}px)`})},[e.renderSlot(l.$slots,"empty")],4))],42,Ne))}}),ye=me,xe={install(r){r.component("ChatVirtualScroll",fe),r.component("DynamicVirtualScroll",me),r.component("ShortMediaFeed",he),r.component("VirtualCarousel",ve),r.component("VirtualList",ye),r.component("VirtualScroll",pe),r.component("WindowDynamicVirtualScroll",ge)}};exports.ChatVirtualScroll=fe;exports.DynamicVirtualScroll=me;exports.ShortMediaFeed=he;exports.VirtualCarousel=ve;exports.VirtualList=ye;exports.VirtualScroll=pe;exports.VueVirtualScroll=xe;exports.WindowDynamicVirtualScroll=ge;exports.default=xe;