@progress/kendo-react-conversational-ui 14.4.0-develop.4 → 14.4.0-develop.6

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.
@@ -102,7 +102,7 @@ const Je = t.forwardRef((Qe, b) => {
102
102
  pageSize: dt,
103
103
  startIndex: gt,
104
104
  endIndex: ft,
105
- onLoadMore: pt,
105
+ onLoadMoreMessages: pt,
106
106
  pinnedMessages: D,
107
107
  repliedToMessages: Be,
108
108
  onReferencedMessageClick: ht,
@@ -177,7 +177,7 @@ const Je = t.forwardRef((Qe, b) => {
177
177
  pageSize: dt,
178
178
  startIndex: gt,
179
179
  endIndex: ft,
180
- onLoadMore: pt,
180
+ onLoadMoreMessages: pt,
181
181
  onReferencedMessageClick: ht,
182
182
  viewItemsWrapperRef: i,
183
183
  authorId: a
@@ -564,7 +564,7 @@ Je.propTypes = {
564
564
  pageSize: o.number,
565
565
  startIndex: o.number,
566
566
  endIndex: o.number,
567
- onLoadMore: o.func,
567
+ onLoadMoreMessages: o.func,
568
568
  pinnedMessages: o.arrayOf(o.object),
569
569
  repliedToMessages: o.arrayOf(o.object),
570
570
  onReferencedMessageClick: o.func
@@ -6,7 +6,7 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  import { Message } from '../../api/message.interface.js';
9
- import { ChatLoadMoreEvent, ChatReferencedMessageClickEvent } from '../Events.js';
9
+ import { ChatLoadMoreMessagesEvent, ChatReferencedMessageClickEvent } from '../Events.js';
10
10
  import { ScrollMode } from '../ChatPropsAndState.js';
11
11
  import * as React from 'react';
12
12
  /** @hidden */
@@ -17,7 +17,7 @@ export interface UseEndlessScrollProps {
17
17
  pageSize?: number;
18
18
  startIndex?: number;
19
19
  endIndex?: number;
20
- onLoadMore?: (event: ChatLoadMoreEvent) => void;
20
+ onLoadMoreMessages?: (event: ChatLoadMoreMessagesEvent) => void;
21
21
  onReferencedMessageClick?: (event: ChatReferencedMessageClickEvent) => void;
22
22
  viewItemsWrapperRef: React.RefObject<HTMLDivElement | null>;
23
23
  authorId?: string | number;
@@ -42,8 +42,8 @@ export interface UseEndlessScrollReturn {
42
42
  * Hook that manages the endless scroll behavior for the Chat component.
43
43
  *
44
44
  * Built-in mode: messages.length === total — Chat manages rendering internally.
45
- * Remote mode: messages.length < total — Chat fires onLoadMore, consumer manages data.
45
+ * Remote mode: messages.length < total — Chat fires onLoadMoreMessages, consumer manages data.
46
46
  *
47
47
  * @hidden
48
48
  */
49
- export declare const useEndlessScroll: ({ scrollMode, processedMessages, total, pageSize, startIndex: startIndexProp, endIndex: endIndexProp, onLoadMore, onReferencedMessageClick, viewItemsWrapperRef, authorId }: UseEndlessScrollProps) => UseEndlessScrollReturn;
49
+ export declare const useEndlessScroll: ({ scrollMode, processedMessages, total, pageSize, startIndex: startIndexProp, endIndex: endIndexProp, onLoadMoreMessages, onReferencedMessageClick, viewItemsWrapperRef, authorId }: UseEndlessScrollProps) => UseEndlessScrollReturn;
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const tt=require("react"),nt=require("../utils.js");function rt(q){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(q){for(const g in q)if(g!=="default"){const e=Object.getOwnPropertyDescriptor(q,g);Object.defineProperty(n,g,e.get?e:{enumerable:!0,get:()=>q[g]})}}return n.default=q,Object.freeze(n)}const r=rt(tt),ct=50,I=100,ut=({scrollMode:q,processedMessages:n,total:g,pageSize:e=ct,startIndex:G,endIndex:U,onLoadMore:m,onReferencedMessageClick:B,viewItemsWrapperRef:u,authorId:V})=>{const d=r.useRef(!1),s=q==="endless",l=g!=null?g:n.length,a=s&&n.length===l&&!d.current,f=s&&(n.length<l||d.current);f&&(d.current=!0);const[b,O]=r.useState(-1),[S,y]=r.useState(-1),X=r.useRef(b),C=r.useRef(S);X.current=b,C.current=S;const o=r.useRef(!1),Y=r.useRef(0),v=r.useRef(0),R=r.useRef(!1),L=r.useRef(l),_=r.useRef(V);_.current=V;const F=r.useRef(!1),j=r.useRef(null),k=r.useRef(!1),$=r.useRef(!1),J=r.useRef(!0),N=r.useRef(l);r.useEffect(()=>{if(a){if(d.current){(b===-1||S===-1)&&(O(0),y(n.length));return}if(b===-1||S===-1){const t=Math.max(0,n.length-e),c=n.length;O(t),y(c)}else if(S<n.length){const t=L.current;if(C.current>=t)y(n.length);else if(n.length>t&&n.slice(t).some(i=>{var T;return((T=i.author)==null?void 0:T.id)!==void 0&&String(i.author.id)===String(_.current)})){const i=Math.max(0,n.length-e);O(i),y(n.length),k.current=!0}}L.current=l}},[a,n.length,e,b,S,l]);const A=G!=null?G:0,x=U!=null?U:n.length,P=r.useCallback(()=>{const t=u.current;t&&(Y.current=t.scrollHeight,v.current=t.scrollTop)},[u]),D=r.useCallback(t=>{var h,i,T;const c=(h=u.current)==null?void 0:h.closest(".k-chat"),E=((T=(i=u.current)==null?void 0:i.querySelector(".k-message-pinned"))==null?void 0:T.offsetHeight)||0;nt.scrollToMessageById(t,c,E)},[u]);r.useLayoutEffect(()=>{if(!R.current)return;const t=u.current;if(!t){R.current=!1;return}const c=t.scrollHeight-Y.current;c>0&&(t.scrollTop=v.current+c),R.current=!1,o.current=!1}),r.useLayoutEffect(()=>{if(!k.current)return;const t=u.current;if(!t){k.current=!1;return}S>=n.length&&S>0&&(k.current=!1,t.scrollTop=t.scrollHeight-t.clientHeight)});const w=r.useRef(!1);r.useLayoutEffect(()=>{if(!s||w.current)return;const t=u.current;t&&t.querySelector("[data-message-id]")&&(t.scrollTop=t.scrollHeight-t.clientHeight,w.current=!0)}),r.useEffect(()=>{if(!s)return;const t=u.current;if(!t)return;let c=t.scrollTop;const E=()=>{const{scrollTop:h,scrollHeight:i,clientHeight:T}=t,K=h<c,p=h>c;if(c=h,!o.current){if(K&&h<=I){if(a){const H=X.current;if(H>0){const Q=Math.max(0,H-e);R.current=!0,P(),O(Q)}}else if(f&&A>0){o.current=!0;const H=Math.max(0,A-e);R.current=!0,P(),m==null||m({startIndex:H,endIndex:A})}}if(p&&i-h-T<=I){if(a){const H=C.current;if(H<n.length){const Q=Math.min(n.length,H+e);$.current=!0,y(Q)}}else if(f&&x<l){o.current=!0,$.current=!0;const H=Math.min(l,x+e);m==null||m({startIndex:x,endIndex:H})}}}};return t.addEventListener("scroll",E,{passive:!0}),()=>t.removeEventListener("scroll",E)},[s,a,f,u,e,n.length,A,x,l,m]),r.useEffect(()=>{var h;const t=x>=l;if(!f){N.current=l,J.current=t;return}const c=N.current,E=J.current;if(N.current=l,J.current=t,l>c&&!E&&t){const i=n[n.length-1];_.current!==void 0&&((h=i==null?void 0:i.author)==null?void 0:h.id)!==void 0&&String(i.author.id)===String(_.current)&&(F.current=!0,$.current=!0)}},[f,l,x,n]),r.useEffect(()=>{!f||!F.current||(F.current=!1,o.current=!1,requestAnimationFrame(()=>{const t=u.current;t&&(t.scrollTop=t.scrollHeight-t.clientHeight)}))},[f,n,u]),r.useEffect(()=>{if(!f||j.current===null)return;const t=j.current,c=u.current;if(!c)return;c.querySelector(`[data-message-id="${t}"]`)&&(j.current=null,o.current=!1,requestAnimationFrame(()=>{D(t)}))},[f,n,u,D]),r.useEffect(()=>{f&&o.current&&!R.current&&(o.current=!1)},[f,A,x]);const z=r.useMemo(()=>{if(a){const t=Math.max(0,b),c=Math.min(n.length,S);if(t>=c){const E=Math.max(0,n.length-e);return n.slice(E)}return n.slice(t,c)}return n},[a,n,b,S,e]),Z=r.useMemo(()=>s?a?S>=n.length:x>=l:!0,[s,a,S,n.length,x,l]),W=r.useCallback(()=>{if(!s||Z){const t=u.current;t&&t.scrollTo({top:t.scrollHeight-t.clientHeight,behavior:"smooth"});return}if(!o.current){if(a){const t=Math.max(0,n.length-e);O(t),y(n.length),requestAnimationFrame(()=>{const c=u.current;c&&(c.scrollTop=c.scrollHeight-c.clientHeight)})}else if(f){F.current=!0,R.current=!1,o.current=!0;const t=Math.max(0,l-e);m==null||m({startIndex:t,endIndex:l})}}},[s,a,f,Z,n.length,e,l,m,u]),M=r.useCallback(t=>{if(!s)D(t);else if(a){const c=u.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))D(t);else{if(o.current)return;const h=n.findIndex(i=>i.id===t||String(i.id)===String(t));if(h>=0){const i=Math.floor(e/2),T=Math.max(0,h-i),K=Math.min(n.length,T+e);o.current=!0,O(T),y(K),requestAnimationFrame(()=>{requestAnimationFrame(()=>{D(t),o.current=!1})})}}}else if(f){const c=u.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))D(t);else{if(o.current)return;j.current=t,R.current=!1,o.current=!0}}B==null||B({id:t})},[s,a,f,u,n,e,B,D]);return{renderedMessages:z,handleScrollToBottom:W,handleReferencedMessageClick:M,isEndless:s,isOnLastBatch:Z,skipAutoScrollRef:$}};exports.useEndlessScroll=ut;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const tt=require("react"),nt=require("../utils.js");function rt(y){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(y){for(const q in y)if(q!=="default"){const l=Object.getOwnPropertyDescriptor(y,q);Object.defineProperty(n,q,l.get?l:{enumerable:!0,get:()=>y[q]})}}return n.default=y,Object.freeze(n)}const r=rt(tt),ct=50,I=100,ut=({scrollMode:y,processedMessages:n,total:q,pageSize:l=ct,startIndex:G,endIndex:U,onLoadMoreMessages:T,onReferencedMessageClick:_,viewItemsWrapperRef:u,authorId:V})=>{const F=r.useRef(!1),S=y==="endless",e=q!=null?q:n.length,a=S&&n.length===e&&!F.current,f=S&&(n.length<e||F.current);f&&(F.current=!0);const[D,B]=r.useState(-1),[E,O]=r.useState(-1),X=r.useRef(D),C=r.useRef(E);X.current=D,C.current=E;const o=r.useRef(!1),Y=r.useRef(0),v=r.useRef(0),b=r.useRef(!1),L=r.useRef(e),j=r.useRef(V);j.current=V;const k=r.useRef(!1),s=r.useRef(null),$=r.useRef(!1),g=r.useRef(!1),J=r.useRef(!0),N=r.useRef(e);r.useEffect(()=>{if(a){if(F.current){(D===-1||E===-1)&&(B(0),O(n.length));return}if(D===-1||E===-1){const t=Math.max(0,n.length-l),c=n.length;B(t),O(c)}else if(E<n.length){const t=L.current;if(C.current>=t)O(n.length);else if(n.length>t&&n.slice(t).some(i=>{var x;return((x=i.author)==null?void 0:x.id)!==void 0&&String(i.author.id)===String(j.current)})){const i=Math.max(0,n.length-l);B(i),O(n.length),$.current=!0}}L.current=e}},[a,n.length,l,D,E,e]);const d=G!=null?G:0,H=U!=null?U:n.length,P=r.useCallback(()=>{const t=u.current;t&&(Y.current=t.scrollHeight,v.current=t.scrollTop)},[u]),A=r.useCallback(t=>{var h,i,x;const c=(h=u.current)==null?void 0:h.closest(".k-chat"),m=((x=(i=u.current)==null?void 0:i.querySelector(".k-message-pinned"))==null?void 0:x.offsetHeight)||0;nt.scrollToMessageById(t,c,m)},[u]);r.useLayoutEffect(()=>{if(!b.current)return;const t=u.current;if(!t){b.current=!1;return}const c=t.scrollHeight-Y.current;c>0&&(t.scrollTop=v.current+c),b.current=!1,o.current=!1}),r.useLayoutEffect(()=>{if(!$.current)return;const t=u.current;if(!t){$.current=!1;return}E>=n.length&&E>0&&($.current=!1,t.scrollTop=t.scrollHeight-t.clientHeight)});const w=r.useRef(!1);r.useLayoutEffect(()=>{if(!S||w.current)return;const t=u.current;t&&t.querySelector("[data-message-id]")&&(t.scrollTop=t.scrollHeight-t.clientHeight,w.current=!0)}),r.useEffect(()=>{if(!S)return;const t=u.current;if(!t)return;let c=t.scrollTop;const m=()=>{const{scrollTop:h,scrollHeight:i,clientHeight:x}=t,K=h<c,p=h>c;if(c=h,!o.current){if(K&&h<=I){if(a){const R=X.current;if(R>0){const Q=Math.max(0,R-l);b.current=!0,P(),B(Q)}}else if(f&&d>0){o.current=!0;const R=Math.max(0,d-l);b.current=!0,P(),T==null||T({startIndex:R,endIndex:d})}}if(p&&i-h-x<=I){if(a){const R=C.current;if(R<n.length){const Q=Math.min(n.length,R+l);g.current=!0,O(Q)}}else if(f&&H<e){o.current=!0,g.current=!0;const R=Math.min(e,H+l);T==null||T({startIndex:H,endIndex:R})}}}};return t.addEventListener("scroll",m,{passive:!0}),()=>t.removeEventListener("scroll",m)},[S,a,f,u,l,n.length,d,H,e,T]),r.useEffect(()=>{var h;const t=H>=e;if(!f){N.current=e,J.current=t;return}const c=N.current,m=J.current;if(N.current=e,J.current=t,e>c&&!m&&t){const i=n[n.length-1];j.current!==void 0&&((h=i==null?void 0:i.author)==null?void 0:h.id)!==void 0&&String(i.author.id)===String(j.current)&&(k.current=!0,g.current=!0)}},[f,e,H,n]),r.useEffect(()=>{!f||!k.current||(k.current=!1,o.current=!1,requestAnimationFrame(()=>{const t=u.current;t&&(t.scrollTop=t.scrollHeight-t.clientHeight)}))},[f,n,u]),r.useEffect(()=>{if(!f||s.current===null)return;const t=s.current,c=u.current;if(!c)return;c.querySelector(`[data-message-id="${t}"]`)&&(s.current=null,o.current=!1,requestAnimationFrame(()=>{A(t)}))},[f,n,u,A]),r.useEffect(()=>{f&&o.current&&!b.current&&(o.current=!1)},[f,d,H]);const z=r.useMemo(()=>{if(a){const t=Math.max(0,D),c=Math.min(n.length,E);if(t>=c){const m=Math.max(0,n.length-l);return n.slice(m)}return n.slice(t,c)}return n},[a,n,D,E,l]),Z=r.useMemo(()=>S?a?E>=n.length:H>=e:!0,[S,a,E,n.length,H,e]),W=r.useCallback(()=>{if(!S||Z){const t=u.current;t&&t.scrollTo({top:t.scrollHeight-t.clientHeight,behavior:"smooth"});return}if(!o.current){if(a){const t=Math.max(0,n.length-l);B(t),O(n.length),requestAnimationFrame(()=>{const c=u.current;c&&(c.scrollTop=c.scrollHeight-c.clientHeight)})}else if(f){k.current=!0,b.current=!1,o.current=!0;const t=Math.max(0,e-l);T==null||T({startIndex:t,endIndex:e})}}},[S,a,f,Z,n.length,l,e,T,u]),M=r.useCallback(t=>{if(!S)A(t);else if(a){const c=u.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;const h=n.findIndex(i=>i.id===t||String(i.id)===String(t));if(h>=0){const i=Math.floor(l/2),x=Math.max(0,h-i),K=Math.min(n.length,x+l);o.current=!0,B(x),O(K),requestAnimationFrame(()=>{requestAnimationFrame(()=>{A(t),o.current=!1})})}}}else if(f){const c=u.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;s.current=t,b.current=!1,o.current=!0}}_==null||_({id:t})},[S,a,f,u,n,l,_,A]);return{renderedMessages:z,handleScrollToBottom:W,handleReferencedMessageClick:M,isEndless:S,isOnLastBatch:Z,skipAutoScrollRef:g}};exports.useEndlessScroll=ut;
@@ -7,179 +7,179 @@
7
7
  */
8
8
  import * as r from "react";
9
9
  import { scrollToMessageById as tt } from "../utils.mjs";
10
- const nt = 50, w = 100, ct = ({
10
+ const nt = 50, s = 100, ct = ({
11
11
  scrollMode: I,
12
12
  processedMessages: n,
13
- total: G,
13
+ total: C,
14
14
  pageSize: i = nt,
15
- startIndex: U,
16
- endIndex: C,
17
- onLoadMore: m,
18
- onReferencedMessageClick: B,
15
+ startIndex: J,
16
+ endIndex: Z,
17
+ onLoadMoreMessages: T,
18
+ onReferencedMessageClick: b,
19
19
  viewItemsWrapperRef: u,
20
- authorId: V
20
+ authorId: Y
21
21
  }) => {
22
- const O = r.useRef(!1), s = I === "endless", l = G != null ? G : n.length, a = s && n.length === l && !O.current, f = s && (n.length < l || O.current);
23
- f && (O.current = !0);
24
- const [q, A] = r.useState(-1), [E, D] = r.useState(-1), X = r.useRef(q), J = r.useRef(E);
25
- X.current = q, J.current = E;
26
- const o = r.useRef(!1), Y = r.useRef(0), d = r.useRef(0), R = r.useRef(!1), L = r.useRef(l), b = r.useRef(V);
27
- b.current = V;
28
- const F = r.useRef(!1), k = r.useRef(null), _ = r.useRef(!1), $ = r.useRef(!1), Z = r.useRef(!0), j = r.useRef(l);
22
+ const F = r.useRef(!1), E = I === "endless", l = C != null ? C : n.length, a = E && n.length === l && !F.current, f = E && (n.length < l || F.current);
23
+ f && (F.current = !0);
24
+ const [D, B] = r.useState(-1), [S, A] = r.useState(-1), d = r.useRef(D), j = r.useRef(S);
25
+ d.current = D, j.current = S;
26
+ const o = r.useRef(!1), L = r.useRef(0), v = r.useRef(0), q = r.useRef(!1), g = r.useRef(l), k = r.useRef(Y);
27
+ k.current = Y;
28
+ const _ = r.useRef(!1), $ = r.useRef(null), G = r.useRef(!1), U = r.useRef(!1), K = r.useRef(!0), N = r.useRef(l);
29
29
  r.useEffect(() => {
30
30
  if (a) {
31
- if (O.current) {
32
- (q === -1 || E === -1) && (A(0), D(n.length));
31
+ if (F.current) {
32
+ (D === -1 || S === -1) && (B(0), A(n.length));
33
33
  return;
34
34
  }
35
- if (q === -1 || E === -1) {
35
+ if (D === -1 || S === -1) {
36
36
  const t = Math.max(0, n.length - i), c = n.length;
37
- A(t), D(c);
38
- } else if (E < n.length) {
39
- const t = L.current;
40
- if (J.current >= t)
41
- D(n.length);
37
+ B(t), A(c);
38
+ } else if (S < n.length) {
39
+ const t = g.current;
40
+ if (j.current >= t)
41
+ A(n.length);
42
42
  else if (n.length > t && n.slice(t).some(
43
43
  (e) => {
44
- var T;
45
- return ((T = e.author) == null ? void 0 : T.id) !== void 0 && String(e.author.id) === String(b.current);
44
+ var x;
45
+ return ((x = e.author) == null ? void 0 : x.id) !== void 0 && String(e.author.id) === String(k.current);
46
46
  }
47
47
  )) {
48
48
  const e = Math.max(0, n.length - i);
49
- A(e), D(n.length), _.current = !0;
49
+ B(e), A(n.length), G.current = !0;
50
50
  }
51
51
  }
52
- L.current = l;
52
+ g.current = l;
53
53
  }
54
- }, [a, n.length, i, q, E, l]);
55
- const y = U != null ? U : 0, x = C != null ? C : n.length, v = r.useCallback(() => {
54
+ }, [a, n.length, i, D, S, l]);
55
+ const O = J != null ? J : 0, H = Z != null ? Z : n.length, P = r.useCallback(() => {
56
56
  const t = u.current;
57
- t && (Y.current = t.scrollHeight, d.current = t.scrollTop);
58
- }, [u]), g = r.useCallback(
57
+ t && (L.current = t.scrollHeight, v.current = t.scrollTop);
58
+ }, [u]), y = r.useCallback(
59
59
  (t) => {
60
- var h, e, T;
61
- const c = (h = u.current) == null ? void 0 : h.closest(".k-chat"), S = ((T = (e = u.current) == null ? void 0 : e.querySelector(".k-message-pinned")) == null ? void 0 : T.offsetHeight) || 0;
62
- tt(t, c, S);
60
+ var h, e, x;
61
+ const c = (h = u.current) == null ? void 0 : h.closest(".k-chat"), m = ((x = (e = u.current) == null ? void 0 : e.querySelector(".k-message-pinned")) == null ? void 0 : x.offsetHeight) || 0;
62
+ tt(t, c, m);
63
63
  },
64
64
  [u]
65
65
  );
66
66
  r.useLayoutEffect(() => {
67
- if (!R.current)
67
+ if (!q.current)
68
68
  return;
69
69
  const t = u.current;
70
70
  if (!t) {
71
- R.current = !1;
71
+ q.current = !1;
72
72
  return;
73
73
  }
74
- const c = t.scrollHeight - Y.current;
75
- c > 0 && (t.scrollTop = d.current + c), R.current = !1, o.current = !1;
74
+ const c = t.scrollHeight - L.current;
75
+ c > 0 && (t.scrollTop = v.current + c), q.current = !1, o.current = !1;
76
76
  }), r.useLayoutEffect(() => {
77
- if (!_.current)
77
+ if (!G.current)
78
78
  return;
79
79
  const t = u.current;
80
80
  if (!t) {
81
- _.current = !1;
81
+ G.current = !1;
82
82
  return;
83
83
  }
84
- E >= n.length && E > 0 && (_.current = !1, t.scrollTop = t.scrollHeight - t.clientHeight);
84
+ S >= n.length && S > 0 && (G.current = !1, t.scrollTop = t.scrollHeight - t.clientHeight);
85
85
  });
86
- const P = r.useRef(!1);
86
+ const w = r.useRef(!1);
87
87
  r.useLayoutEffect(() => {
88
- if (!s || P.current)
88
+ if (!E || w.current)
89
89
  return;
90
90
  const t = u.current;
91
- t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight, P.current = !0);
91
+ t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight, w.current = !0);
92
92
  }), r.useEffect(() => {
93
- if (!s)
93
+ if (!E)
94
94
  return;
95
95
  const t = u.current;
96
96
  if (!t)
97
97
  return;
98
98
  let c = t.scrollTop;
99
- const S = () => {
100
- const { scrollTop: h, scrollHeight: e, clientHeight: T } = t, N = h < c, p = h > c;
99
+ const m = () => {
100
+ const { scrollTop: h, scrollHeight: e, clientHeight: x } = t, V = h < c, p = h > c;
101
101
  if (c = h, !o.current) {
102
- if (N && h <= w) {
102
+ if (V && h <= s) {
103
103
  if (a) {
104
- const H = X.current;
105
- if (H > 0) {
106
- const Q = Math.max(0, H - i);
107
- R.current = !0, v(), A(Q);
104
+ const R = d.current;
105
+ if (R > 0) {
106
+ const X = Math.max(0, R - i);
107
+ q.current = !0, P(), B(X);
108
108
  }
109
- } else if (f && y > 0) {
109
+ } else if (f && O > 0) {
110
110
  o.current = !0;
111
- const H = Math.max(0, y - i);
112
- R.current = !0, v(), m == null || m({ startIndex: H, endIndex: y });
111
+ const R = Math.max(0, O - i);
112
+ q.current = !0, P(), T == null || T({ startIndex: R, endIndex: O });
113
113
  }
114
114
  }
115
- if (p && e - h - T <= w) {
115
+ if (p && e - h - x <= s) {
116
116
  if (a) {
117
- const H = J.current;
118
- if (H < n.length) {
119
- const Q = Math.min(n.length, H + i);
120
- $.current = !0, D(Q);
117
+ const R = j.current;
118
+ if (R < n.length) {
119
+ const X = Math.min(n.length, R + i);
120
+ U.current = !0, A(X);
121
121
  }
122
- } else if (f && x < l) {
123
- o.current = !0, $.current = !0;
124
- const H = Math.min(l, x + i);
125
- m == null || m({ startIndex: x, endIndex: H });
122
+ } else if (f && H < l) {
123
+ o.current = !0, U.current = !0;
124
+ const R = Math.min(l, H + i);
125
+ T == null || T({ startIndex: H, endIndex: R });
126
126
  }
127
127
  }
128
128
  }
129
129
  };
130
- return t.addEventListener("scroll", S, { passive: !0 }), () => t.removeEventListener("scroll", S);
130
+ return t.addEventListener("scroll", m, { passive: !0 }), () => t.removeEventListener("scroll", m);
131
131
  }, [
132
- s,
132
+ E,
133
133
  a,
134
134
  f,
135
135
  u,
136
136
  i,
137
137
  n.length,
138
- y,
139
- x,
138
+ O,
139
+ H,
140
140
  l,
141
- m
141
+ T
142
142
  ]), r.useEffect(() => {
143
143
  var h;
144
- const t = x >= l;
144
+ const t = H >= l;
145
145
  if (!f) {
146
- j.current = l, Z.current = t;
146
+ N.current = l, K.current = t;
147
147
  return;
148
148
  }
149
- const c = j.current, S = Z.current;
150
- if (j.current = l, Z.current = t, l > c && !S && t) {
149
+ const c = N.current, m = K.current;
150
+ if (N.current = l, K.current = t, l > c && !m && t) {
151
151
  const e = n[n.length - 1];
152
- b.current !== void 0 && ((h = e == null ? void 0 : e.author) == null ? void 0 : h.id) !== void 0 && String(e.author.id) === String(b.current) && (F.current = !0, $.current = !0);
152
+ k.current !== void 0 && ((h = e == null ? void 0 : e.author) == null ? void 0 : h.id) !== void 0 && String(e.author.id) === String(k.current) && (_.current = !0, U.current = !0);
153
153
  }
154
- }, [f, l, x, n]), r.useEffect(() => {
155
- !f || !F.current || (F.current = !1, o.current = !1, requestAnimationFrame(() => {
154
+ }, [f, l, H, n]), r.useEffect(() => {
155
+ !f || !_.current || (_.current = !1, o.current = !1, requestAnimationFrame(() => {
156
156
  const t = u.current;
157
157
  t && (t.scrollTop = t.scrollHeight - t.clientHeight);
158
158
  }));
159
159
  }, [f, n, u]), r.useEffect(() => {
160
- if (!f || k.current === null)
160
+ if (!f || $.current === null)
161
161
  return;
162
- const t = k.current, c = u.current;
162
+ const t = $.current, c = u.current;
163
163
  if (!c)
164
164
  return;
165
- c.querySelector(`[data-message-id="${t}"]`) && (k.current = null, o.current = !1, requestAnimationFrame(() => {
166
- g(t);
165
+ c.querySelector(`[data-message-id="${t}"]`) && ($.current = null, o.current = !1, requestAnimationFrame(() => {
166
+ y(t);
167
167
  }));
168
- }, [f, n, u, g]), r.useEffect(() => {
169
- f && o.current && !R.current && (o.current = !1);
170
- }, [f, y, x]);
168
+ }, [f, n, u, y]), r.useEffect(() => {
169
+ f && o.current && !q.current && (o.current = !1);
170
+ }, [f, O, H]);
171
171
  const z = r.useMemo(() => {
172
172
  if (a) {
173
- const t = Math.max(0, q), c = Math.min(n.length, E);
173
+ const t = Math.max(0, D), c = Math.min(n.length, S);
174
174
  if (t >= c) {
175
- const S = Math.max(0, n.length - i);
176
- return n.slice(S);
175
+ const m = Math.max(0, n.length - i);
176
+ return n.slice(m);
177
177
  }
178
178
  return n.slice(t, c);
179
179
  }
180
180
  return n;
181
- }, [a, n, q, E, i]), K = r.useMemo(() => s ? a ? E >= n.length : x >= l : !0, [s, a, E, n.length, x, l]), W = r.useCallback(() => {
182
- if (!s || K) {
181
+ }, [a, n, D, S, i]), Q = r.useMemo(() => E ? a ? S >= n.length : H >= l : !0, [E, a, S, n.length, H, l]), W = r.useCallback(() => {
182
+ if (!E || Q) {
183
183
  const t = u.current;
184
184
  t && t.scrollTo({ top: t.scrollHeight - t.clientHeight, behavior: "smooth" });
185
185
  return;
@@ -187,34 +187,34 @@ const nt = 50, w = 100, ct = ({
187
187
  if (!o.current) {
188
188
  if (a) {
189
189
  const t = Math.max(0, n.length - i);
190
- A(t), D(n.length), requestAnimationFrame(() => {
190
+ B(t), A(n.length), requestAnimationFrame(() => {
191
191
  const c = u.current;
192
192
  c && (c.scrollTop = c.scrollHeight - c.clientHeight);
193
193
  });
194
194
  } else if (f) {
195
- F.current = !0, R.current = !1, o.current = !0;
195
+ _.current = !0, q.current = !1, o.current = !0;
196
196
  const t = Math.max(0, l - i);
197
- m == null || m({ startIndex: t, endIndex: l });
197
+ T == null || T({ startIndex: t, endIndex: l });
198
198
  }
199
199
  }
200
200
  }, [
201
- s,
201
+ E,
202
202
  a,
203
203
  f,
204
- K,
204
+ Q,
205
205
  n.length,
206
206
  i,
207
207
  l,
208
- m,
208
+ T,
209
209
  u
210
210
  ]), M = r.useCallback(
211
211
  (t) => {
212
- if (!s)
213
- g(t);
212
+ if (!E)
213
+ y(t);
214
214
  else if (a) {
215
215
  const c = u.current;
216
216
  if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
217
- g(t);
217
+ y(t);
218
218
  else {
219
219
  if (o.current)
220
220
  return;
@@ -222,10 +222,10 @@ const nt = 50, w = 100, ct = ({
222
222
  (e) => e.id === t || String(e.id) === String(t)
223
223
  );
224
224
  if (h >= 0) {
225
- const e = Math.floor(i / 2), T = Math.max(0, h - e), N = Math.min(n.length, T + i);
226
- o.current = !0, A(T), D(N), requestAnimationFrame(() => {
225
+ const e = Math.floor(i / 2), x = Math.max(0, h - e), V = Math.min(n.length, x + i);
226
+ o.current = !0, B(x), A(V), requestAnimationFrame(() => {
227
227
  requestAnimationFrame(() => {
228
- g(t), o.current = !1;
228
+ y(t), o.current = !1;
229
229
  });
230
230
  });
231
231
  }
@@ -233,33 +233,33 @@ const nt = 50, w = 100, ct = ({
233
233
  } else if (f) {
234
234
  const c = u.current;
235
235
  if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
236
- g(t);
236
+ y(t);
237
237
  else {
238
238
  if (o.current)
239
239
  return;
240
- k.current = t, R.current = !1, o.current = !0;
240
+ $.current = t, q.current = !1, o.current = !0;
241
241
  }
242
242
  }
243
- B == null || B({ id: t });
243
+ b == null || b({ id: t });
244
244
  },
245
245
  [
246
- s,
246
+ E,
247
247
  a,
248
248
  f,
249
249
  u,
250
250
  n,
251
251
  i,
252
- B,
253
- g
252
+ b,
253
+ y
254
254
  ]
255
255
  );
256
256
  return {
257
257
  renderedMessages: z,
258
258
  handleScrollToBottom: W,
259
259
  handleReferencedMessageClick: M,
260
- isEndless: s,
261
- isOnLastBatch: K,
262
- skipAutoScrollRef: $
260
+ isEndless: E,
261
+ isOnLastBatch: Q,
262
+ skipAutoScrollRef: U
263
263
  };
264
264
  };
265
265
  export {