k2-im 0.1.26 → 0.1.28

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.
@@ -167,8 +167,10 @@ interface ImVideoBody {
167
167
  width: number;
168
168
  /** 视频像素高(BMessage.height)。 */
169
169
  height: number;
170
- /** 时长(秒,BMessage.duration;proto 单位秒,contentType=3|4 有效)。 */
170
+ /** 时长(秒,可含小数);移动端旧消息的毫秒值由 SDK 转换,宿主不得猜单位。 */
171
171
  duration?: number;
172
+ /** SDK 已确认时长为秒的标记;兼容旧缓存时防止重复转换。缺省仍按公开 API 的秒约定传入。 */
173
+ durationUnit?: 'seconds';
172
174
  /** 封面帧原始字节(本地首帧截图,内嵌不单传,对应 BMessage.thumbData bytes)。UI 转 blob 渲染,无需下载即可展示封面。 */
173
175
  thumbData?: Uint8Array;
174
176
  /** 视频文件 MD5(BMessage.MD5;Android 当前未赋值,保留可选)。 */
@@ -1 +1 @@
1
- import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-UNGWXAYA.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-VMKTMZ3K.js';import'./chunk-SVJGRV4M.js';import'./chunk-GMVR64GN.js';import'./chunk-LX7YEO5G.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment,reactive}from'vue';function qt(t){let a=0,v=0;for(let f of t)f.kind==="video"?v+=1:a+=1;return {imageCount:a,videoCount:v}}function Gt(t){return {systemMessage:a=>a.body.system!==void 0?g$1(a.body.system,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):"",mediaPlaceholder:a=>i$1(a.contentType,{locale:t.locale(),durationMs:a.body.voice?.durationMs,stickerImageType:a.body.sticker?.imageType,gameType:a.body.game?.gameType,callKind:a.body.call?.callKind,...a.body.mediaAlbum===void 0?{}:{mediaAlbum:qt(a.body.mediaAlbum.items)}}),lastMessage:a=>a.lastMessageSummary!==void 0?h$2(a.lastMessageSummary,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):a.lastMessagePreview,failureText:a=>a.failure?.displayCode!==void 0?f(a.failure.displayCode,{locale:t.locale(),mediaKind:a.failure.mediaKind,params:a.failure.params}):a.failure?.message??""}}var Et=Symbol("ImThreadReadActions");function At(t){provide(Et,t);}function Yt(){return inject(Et,void 0)}var Ge=defineComponent({name:"ImThreadBodySwitch",inheritAttrs:false,props:{message:{type:Object,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{attrs:a,slots:v}){return At(t.readActions),()=>{let f=h(t.message),m=t.rendererRegistry.resolve(f);return m!==void 0?h$1(m,{...a,message:t.message,presentation:t.presentation}):v["unsupported-body"]!==void 0?v["unsupported-body"]({kind:f,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":f,"aria-hidden":"true"})}}});var We=Symbol("ImThreadViewportRegistration");function xt(){return inject(We,void 0)}var ze=defineComponent({name:"ImThreadItems",props:{items:{type:Array,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{slots:a}){let v=xt();function f(o,d){let I=Array.isArray(d)?d:[d];return I.length===1&&isVNode(I[0])?cloneVNode(I[0],{key:o}):h$1(Fragment,{key:o},I)}function m(o){return d=>{v?.registerMessageNode(o,d instanceof HTMLElement?d:null);}}function k(o,d){return I=>{v?.registerDateNode(o,d,I instanceof HTMLElement?I:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function p(o){let d=k(o.key,o.label);return a["date-separator"]?.({item:o,setElement:d})??h$1("div",{ref:d,"data-im-thread-date-separator":o.key},o.label)}function w(o){return a["entry-unread"]?.({item:o})??h$1("div",{"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function R(o){let d=m(o.message.id);return a.item!==void 0?a.item({item:o,setElement:d}):a.message!==void 0?a.message({item:o,setElement:d}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"deleted-for-everyone"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.message.recalled!==void 0?a["recalled-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"recalled"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.kind==="system"&&a.system!==void 0?a.system({item:o,setElement:d}):h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-first-of-run":o.kind==="message"?String(o.firstOfRun):void 0},[h$1("span",{"data-im-thread-anchor-point":""}),h$1(Ge,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:I=>a["unsupported-body"]?.(I)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,M(o));case "date-separator":return a.item!==void 0?f(o.key,a.item({item:o,setElement:k(o.key,o.label)})):f(o.key,p(o));case "entry-unread":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,w(o));case "system":case "message":return f(o.key,R(o))}return o}))}});var kt=120,ar=500,le=.5,sr=8,Ye=defineComponent({name:"ImThreadViewport",props:{messageIds:{type:Array,required:true},contentKey:{type:String,default:""},loadingOlder:{type:Boolean,default:false},hasNewer:{type:Boolean,default:false},loadingNewer:{type:Boolean,default:false},followThreshold:{type:Number,default:120},olderPrefetchThreshold:{type:Number,default:120},followNewMessages:{type:Boolean,default:true},shouldFollowAppendedMessage:{type:Function,default:void 0},visibleMargin:{type:Number,default:8},resizeFollowEnabled:{type:Boolean,default:true},activeDateOffset:{type:Number,default:16},activeDateEnabled:{type:Boolean,default:false}},emits:{"reach-start":()=>true,"reach-end":()=>true,"visible-range":t=>true,settled:t=>true,"new-message-count":t=>true,"user-scroll":()=>true,"active-date-change":t=>true},setup(t,{emit:a,expose:v,slots:f}){let m$1=ref(null),k=ref(null),M=new Map,p$1=new Map,w=new Set,R=new Map,o$1=0,d=[],I,H,O,D,X=false,x,U=new Set,Y=false,L,W="",s=1,F=false,J=false,_=true,N=false,Q=false,j$1=false,$=0,Z=-1,ie=-1,u,S,T,c,P,B$1=ref(true),q$1=ref(0),z$1=C(e=>{q$1.value=e,a("new-message-count",e);});function be(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function fe(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let h=i.getBoundingClientRect(),y=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:h.top,bottom:h.bottom,anchorTop:y?.getBoundingClientRect().top??h.top}]})}function Pe(e="",n=1){let i=Math.min(1,Math.max(0,n));W!==""&&W!==e&&R.get(W)?.element.style.removeProperty("opacity"),W=e,s=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function ae(){Pe();}function Ee(){let e=m$1.value;if(Y||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,A])=>e.contains(A.element)).map(([A,C])=>{let G=C.element.getBoundingClientRect();return {key:A,label:C.label,top:G.top,height:G.height}}).sort((A,C)=>A.top-C.top),i=e.getBoundingClientRect(),h=n.find(A=>A.height>0)?.height??28,y=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:h});if(y===null){ae(),a("active-date-change",null);return}Pe(y.inlineDateKey,y.inlineOpacity),a("active-date-change",y);}function Ce(e){H={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Ae(e){let n=H;if(n===void 0)return false;let i=Math.max(0,e.scrollHeight-e.clientHeight);return i<n.scrollHeight-n.height&&n.scrollTop>i&&Math.abs(e.scrollTop-i)<=le}function Oe(e){return Ae(e)||L!==void 0&&(L.behavior==="smooth"||Math.abs(e.scrollTop-L.targetTop)<=le)?0:e.scrollTop-o$1}function me(e,n){n!==0&&(o$1=e.scrollTop-n,L=void 0,g$1());}function Ke(e,n){let i=Oe(e);if(c!==void 0)return c.expectedOffset-=i,se(),me(e,i),N||oe(),false;let h=H;if(h===void 0)return false;let y=I,A=y===void 0?void 0:fe([y.id])[0],C=e.scrollTop-h.scrollTop,G=Ae(e)?0:C,Me=y===void 0||A===void 0?0:(A.anchorTop??A.top)-n.top-y.offset+C;return h.scrollHeight!==e.scrollHeight||h.width!==e.clientWidth||h.height!==e.clientHeight||Math.abs(Me)>le?(H=void 0,!F&&!t.loadingNewer&&t.resizeFollowEnabled&&B$1.value&&Math.abs(G)<=le?(Fe(),true):(y!==void 0&&Ne({...y,offset:y.offset-G}),me(e,i),false)):false}function ee(){let e=m$1.value;if(Y||e===null)return;let n=e.getBoundingClientRect();if(Ke(e,n))return;let i=D!==void 0&&X?t.messageIds.filter(C=>w.has(C)):t.messageIds,h=fe(i);if(D!==void 0&&X&&h.length===0){B$1.value=be(e);return}let y=h.filter(C=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:C.top,messageBottom:C.bottom,margin:t.visibleMargin})).map(C=>C.id),A=y.length!==d.length||y.some((C,G)=>d[G]!==C);d=Object.freeze(y),I=o(h,{top:n.top,bottom:n.bottom}),Ce(e),z$1.acknowledgeVisible(y),B$1.value=be(e),A&&a("visible-range",d),a("settled",{visibleMessageIds:d,...d.length===0?{}:{newestVisibleMessageId:d[d.length-1]},isAtBottom:B$1.value,newMessageCount:q$1.value});}function ge(e){if(U.add(e),x!==void 0)return;let n=()=>{x=void 0;let i=[...U];U.clear(),i.forEach(h=>h());};typeof globalThis.requestAnimationFrame=="function"?x=globalThis.requestAnimationFrame(n):x=globalThis.setTimeout(n,0);}function xe(){x!==void 0&&(typeof x=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(x):globalThis.clearTimeout(x),x=void 0,U.clear());}function re(){ge(ee);}function Ie(){let e=m$1.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o(fe(),{top:n.top,bottom:n.bottom});i!==void 0&&(I=i,Ce(e));}function he(){return _&&c===void 0&&!J&&!t.loadingOlder}function ke(){Ie(),_=false,Z=$,J=true,a("reach-start"),ge(()=>{t.loadingOlder||(J=false);});}function Ve(e){return t.hasNewer&&!F&&!t.loadingOlder&&!t.loadingNewer&&be(e)}function r(){F=true,B$1.value=false,ie=$,a("reach-end"),ge(()=>{t.loadingNewer||(F=false);});}function l(){let e=m$1.value;e===null||$===ie||!Ve(e)||r();}function g$1(){let e=m$1.value;if(Y||e===null)return;let n=e.scrollTop,i=Ae(e),h=L,y=false;if(h!==void 0){let C=Math.abs(n-h.targetTop)<=le;y=h.behavior==="smooth"||C,(h.behavior!=="smooth"||C)&&(L=void 0);}!y&&!i&&!N&&c===void 0&&n!==o$1&&(N=true,Q=true,$+=1);let A=N&&!y&&!i&&n!==o$1;if(A&&(a("user-scroll"),ge(Ee)),N&&!j$1&&ye(),!_&&Q&&$!==Z&&n<o$1&&n>et()&&(_=true),c!==void 0&&!y)if(N){let C=K();C!==void 0&&(c.expectedOffset=C);}else se(),oe();he()&&A&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&ke(),A&&Ve(e)&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:be(e),isHistoryWindow:t.hasNewer,isPageSettling:y})&&r(),o$1=n,re();}function b(e,n="auto"){L={targetTop:e,behavior:n};}function V(e){let n=c,i=k.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=le?0:e,n.visualOffset===0){i.style.removeProperty("transform"),i.style.removeProperty("will-change");return}i.style.setProperty("transform",`translate3d(0, ${n.visualOffset}px, 0)`),i.style.setProperty("will-change","transform");}}function E(){P!==void 0&&(clearTimeout(P),P=void 0),c!==void 0&&c.visualOffset!==0&&(I=void 0,H=void 0);let e=k.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),c=void 0,L=void 0;}function K(){let e=m$1.value,n=c;if(e===null||n===void 0)return;let i=fe().find(h=>h.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function se(){let e=c,n=K();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=le||(V(e.visualOffset+i),e.committed=false,e.attempts=0);}function ne(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,!(N||c?.committed!==true)&&E();},ar);}function Te(){let e=m$1.value,n=c;if(Y||e===null||n===void 0||N)return;let i=n.visualOffset;if(Math.abs(i)<=le){n.committed=true,ne();return}let h=Math.max(0,e.scrollHeight-e.clientHeight),y=Math.min(h,Math.max(0,e.scrollTop-i));if(b(y),e.scrollTop=y,Math.abs(e.scrollTop-y)>le){L=void 0,n.committed=false,n.attempts+=1,n.attempts<sr?oe():(E(),L=void 0,o$1=e.scrollTop);return}V(0),o$1=e.scrollTop,n.expectedOffset=K()??n.expectedOffset,n.committed=true,n.attempts=0,ne();}function oe(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,Te();},kt);}function we(e){e!==void 0&&(c===void 0&&(c={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),se(),!N&&Te());}function Ne(e){let n=m$1.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),h=q(e,fe(),{top:i.top,bottom:i.bottom});if(h!==void 0){let y=Math.max(0,n.scrollHeight-n.clientHeight),A=Math.min(y,Math.max(0,n.scrollTop+h));b(A),n.scrollTop=A,o$1=n.scrollTop,H=void 0;}}function et(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function De(){L?.behavior==="smooth"&&(L=void 0),Q=false,N||(N=true,$+=1),u!==void 0&&(clearTimeout(u),u=void 0);}function Le(){let e=m$1.value;e===null||$===Z||(c!==void 0&&E(),_=true,e.scrollTop<=et()&&he()&&ke());}function tt(){I=void 0,H=void 0,u!==void 0&&(clearTimeout(u),u=void 0),E(),N=false,Q=false,j$1=false,S=void 0,T=void 0,$+=1,Z=-1,ie=-1,_=true,J=false,F=false,L=void 0;}function rt(){j$1||(u!==void 0&&(clearTimeout(u),u=void 0),N=false,Q=false,c!==void 0&&(c.attempts=0),Te());}function ye(){j$1||(u!==void 0&&clearTimeout(u),u=setTimeout(()=>{u=void 0,rt();},kt));}function nt(){L=void 0,rt();}function ot(e){j$1=true,De(),S=e.touches?.[0]?.clientY;}function it(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(S!==void 0&&n>S?Le():S!==void 0&&n<S&&l(),S=n);}function He(){j$1=false,S=void 0,ye();}function at(e){De(),e.deltaY<0?Le():e.deltaY>0&&l(),ye();}function st(e){e.pointerType!=="touch"&&(De(),T=e.clientY,ye());}function lt(e){e.pointerType==="touch"||!N||T===void 0||(e.clientY<T?Le():e.clientY>T&&l(),T=e.clientY,ye());}function Be(e){e.pointerType!=="touch"&&(T=void 0,ye());}function dt(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(De(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?Le():l(),ye());}function Fe(e="auto"){let n=m$1.value;if(n===null)return;H=void 0,E();let i=Math.max(0,n.scrollHeight-n.clientHeight);b(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,z$1.clear(),ee();}function ut(){let e=m$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Lt(){let e=m$1.value;return ut()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Ht(e,n={}){let i=m$1.value,h=M.get(e);if(i===null||h===void 0||!i.contains(h)||i.clientHeight<=0)return false;E();let y=i.getBoundingClientRect(),A=h.getBoundingClientRect(),C=n.block??"center",G;C==="start"?G=i.scrollTop+A.top-y.top:C==="end"?G=i.scrollTop+A.bottom-y.bottom:C==="nearest"?A.top>=y.top&&A.bottom<=y.bottom?G=i.scrollTop:A.top<y.top?G=i.scrollTop+A.top-y.top:G=i.scrollTop+A.bottom-y.bottom:G=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:A.height,targetTop:A.top,viewportHeight:i.clientHeight,viewportTop:y.top});let Me=Math.max(0,i.scrollHeight-i.clientHeight),pe=Math.min(Me,Math.max(0,G));H=void 0;let Re=n.behavior??"auto";return b(pe,Re),i.scrollTo?.({top:pe,behavior:Re}),i.scrollTop!==pe&&(i.scrollTop=pe),o$1=i.scrollTop,ee(),true}function Bt(){z$1.clear();}function Ft(){F=true,B$1.value=false;}function _t(){F=false,re();}function jt(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(D?.unobserve(i),O?.unobserve?.(i),p$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),p$1.set(n,e),D?.observe(n),O?.observe(n),re();}function Kt(e,n,i){let h=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),W===e&&i.style.setProperty("opacity",String(s)),h?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(We,{registerMessageNode:jt,registerDateNode:Kt}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;tt();let i=m$1.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=m$1.value;if(i===null)return;let h=new Set(n);n.length>0&&e.length>0&&!e.some(ve=>h.has(ve))&&tt();let A=i.getBoundingClientRect(),C=p(I,fe(),{top:A.top,bottom:A.bottom}),G=B$1.value,Me=n[n.length-1],pe=Me===void 0?-1:e.indexOf(Me),Re=pe<0?[]:e.slice(pe+1).filter(ve=>!h.has(ve)),ct=F||t.loadingNewer,Ut=e.length===n.length&&e.every(ve=>h.has(ve))&&e.some((ve,Ue)=>ve!==n[Ue]);if(await nextTick(),Y)return;if(Ut&&G&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!ct){Fe();return}let ft=n[0];if(ft!==void 0&&e.indexOf(ft)>0&&(J=false,we(C)),Re.length>0){if(ct){F=false,c===void 0&&Ne(C),B$1.value=false,re();return}(G||Re.some(Ue=>t.shouldFollowAppendedMessage?.(Ue)===true))&&t.followNewMessages?Fe():z$1.add(Re);}re();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!F||ge(()=>{t.loadingNewer||(F=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!J||ge(()=>{t.loadingOlder||(J=false);});},{flush:"pre"}),onMounted(()=>{let e=m$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",g$1,{passive:true}),e.addEventListener("scrollend",nt,{passive:true}),e.addEventListener("touchstart",ot,{passive:true}),e.addEventListener("touchmove",it,{passive:true}),e.addEventListener("touchend",He,{passive:true}),e.addEventListener("touchcancel",He,{passive:true}),e.addEventListener("wheel",at,{passive:true}),e.addEventListener("pointerdown",st,{passive:true}),e.addEventListener("pointermove",lt,{passive:true}),e.addEventListener("pointerup",Be,{passive:true}),e.addEventListener("pointercancel",Be,{passive:true}),e.addEventListener("keydown",dt),typeof globalThis.ResizeObserver=="function"){O=new globalThis.ResizeObserver(()=>{Y||m$1.value===null||ee();}),O.observe(e),k.value!==null&&O.observe(k.value);for(let n of M.values())O.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){D=new globalThis.IntersectionObserver(n=>{for(let i of n){let h=p$1.get(i.target);h!==void 0&&(i.isIntersecting?w.add(h):w.delete(h));}X=true,re();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())D.observe(n);}re();}}),onBeforeUnmount(()=>{Y=true;let e=m$1.value;e!==null&&e.removeEventListener("scroll",g$1),e!==null&&(e.removeEventListener("scrollend",nt),e.removeEventListener("touchstart",ot),e.removeEventListener("touchmove",it),e.removeEventListener("touchend",He),e.removeEventListener("touchcancel",He),e.removeEventListener("wheel",at),e.removeEventListener("pointerdown",st),e.removeEventListener("pointermove",lt),e.removeEventListener("pointerup",Be),e.removeEventListener("pointercancel",Be),e.removeEventListener("keydown",dt)),u!==void 0&&clearTimeout(u),E(),xe(),O?.disconnect(),D?.disconnect(),ae(),M.clear(),p$1.clear(),w.clear(),R.clear(),z$1.clear();}),v({getViewportElement:()=>m$1.value,clearNewMessageBadge:Bt,clearActiveDate:ae,isAtBottom:computed(()=>B$1.value),isMeasurable:ut,isScrollable:Lt,newMessageCount:computed(()=>q$1.value),prepareHistoryPageAppend:Ft,cancelHistoryPageAppend:_t,trackRemoteMessageIds:(e,n)=>z$1.trackRemote(e,n),scrollToLatest:Fe,scrollToMessage:Ht,focusViewport:()=>m$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:m$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:k,"data-im-thread-viewport-content":""},f.default?.())])}});var Nt=Symbol("ImThreadSurfaceContext");function ur(t){if(typeof t.getState!="function")throw new TypeError("ImThreadSurfaceContext.getState \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.actions?.loadOlder!="function")throw new TypeError("ImThreadSurfaceContext.actions.loadOlder \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.formatDate!="function")throw new TypeError("ImThreadSurfaceContext.formatDate \u5FC5\u987B\u662F\u51FD\u6570");return Object.freeze({...t,actions:Object.freeze({...t.actions})})}function cr(t){provide(Nt,t);}function $e(){let t=inject(Nt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var Je=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),Qe=Object.freeze({enabled:true,maxFillPages:8}),gr=8,pr=160;function vr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var hr=defineComponent({name:"ImThreadSurface",props:{conversation:{type:Object,required:true},context:{type:Object,default:void 0},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0},viewportOptions:{type:Object,default:()=>({})},initialViewportOptions:{type:Object,default:()=>({})},hooks:{type:Object,default:void 0}},setup(t,{expose:a,slots:v}){let f=t.context??$e(),m=ref(null),k=ref(0),M=ref(true),p=[],w,R=0,o=0,d=null,I="",H="",O="",D=false,X=false,x=ref(false),U=ref(""),Y=ref(false),L,W,s=computed(()=>f.getState()),F=computed(()=>s.value.pageVisible??f.isPageVisible?.()??true),J=computed(()=>s.value.pageEngaged??f.isPageEngaged?.()??true),_=computed(()=>vr(s.value.activeConversation,t.conversation)),N=computed(()=>({...Je,...t.viewportOptions})),Q=computed(()=>{let r=t.initialViewportOptions.maxFillPages??Qe.maxFillPages;return {enabled:t.initialViewportOptions.enabled??Qe.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):Qe.maxFillPages}}),j=computed(()=>!_.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),$=computed(()=>_.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:f.formatDate,leadingItems:f.leadingItems?.(),beforeMessageItems:f.beforeMessageItems}):[]),Z=computed(()=>$.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ie(){L!==void 0&&(clearTimeout(L),L=void 0),W!==void 0&&(clearTimeout(W),W=void 0);}function u(r=false){if(ie(),Y.value=false,r){m.value?.clearActiveDate(),U.value="";return}W=setTimeout(()=>{W=void 0,!Y.value&&(m.value?.clearActiveDate(),U.value="");},pr);}function S(r){if(r===null){u();return}ie(),U.value=r.label,Y.value=true;let l=N.value.activeDateIdleDelay,g=Number.isFinite(l)?Math.max(0,l):Je.activeDateIdleDelay;L=setTimeout(()=>{L=void 0,u();},g);}async function T(r,l){t.hooks?.beforeAction?.(r);try{let g=await l();return t.hooks?.afterAction?.(r,g),g}catch(g){throw t.hooks?.onError?.(r,g),g}}function c(r="automatic"){return !_.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):T({kind:"load-older",source:r},()=>f.actions.loadOlder())}function P(){let r=f.actions.loadNewer,l=s.value.loadingNewer??s.value.loading;return !_.value||l||!s.value.hasNewer||r===void 0?Promise.resolve(0):T({kind:"load-newer"},()=>r())}async function B(r){for(let l=0;l<gr;l+=1){if(!_.value)return;let g=r==="older"?s.value.hasOlder:s.value.hasNewer,b=r==="older"?s.value.olderError:s.value.newerError;if(!g||b!==null||(r==="older"?await c("user-scroll"):await P())>0)return;let E=r==="older"?s.value.hasOlder:s.value.hasNewer,K=r==="older"?s.value.olderError:s.value.newerError;if(!E||K!==null)return}}async function q(){return !_.value||f.actions.loadNewer===void 0?0:T({kind:"load-newer"},()=>f.actions.retryNewer?.()??f.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function z(){if(!_.value)return 0;let r=j.value,l=++R;d=null,O="";let g;try{g=await T({kind:"retry-older"},()=>f.actions.retryOlder?.()??f.actions.loadOlder({force:!0}));}catch(b){throw ee(r,l)&&(O=r),b}return ee(r,l)&&!x.value&&(d=null,Ie()),g}async function be(){if(!_.value)return false;let r=await T({kind:"jump-to-latest"},()=>f.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow));return r&&(await nextTick(),m.value?.scrollToLatest()),r}function fe(r){M.value=r.isAtBottom,k.value=r.newMessageCount,Ie();}function Pe(r,l){return m.value?.scrollToMessage(r,l)??false}function ae(r,l){return !X&&o===l&&j.value===r&&_.value}async function Ee(r,l,g,b){for(let V=0;V<60;V+=1){if(!ae(r,l))return false;if(Pe(g,b))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(E=>window.requestAnimationFrame(()=>E()));}return false}async function Ce(r,l,g){let b=m.value;if(b===null||!b.isMeasurable()||b.isScrollable())return true;let V=0,E=!s.value.hasOlder,K=!s.value.hasNewer||f.actions.loadNewer===void 0,se=async()=>(await nextTick(),await nextTick(),Ee(r,l,g,{behavior:"auto",block:"center"})),ne=async oe=>{if(!ae(r,l)||V>=Q.value.maxFillPages)return false;let we=0;if(oe==="older"){if(E||!s.value.hasOlder)return false;we=await c(),E=!s.value.hasOlder;}else {if(K||!s.value.hasNewer)return false;b.prepareHistoryPageAppend();try{we=await P();}catch(Ne){throw b.cancelHistoryPageAppend(),Ne}we<=0&&!s.value.hasNewer&&b.cancelHistoryPageAppend(),K=!s.value.hasNewer;}return V+=1,we>0?se():!(oe==="older"?E:K)};!E&&!await ne("older")&&(E=true),!K&&!await ne("newer")&&(K=true);let Te="older";for(;ae(r,l)&&V<Q.value.maxFillPages&&b.isMeasurable()&&!b.isScrollable()&&(!E||!K);){let oe=Te==="older"?E?"newer":"older":K?"older":"newer";Te=oe==="older"?"newer":"older",await ne(oe)||(oe==="older"?E=true:K=true);}return ae(r,l)}async function Ae(r,l={behavior:"auto",block:"center"}){if(!_.value||r==="")return false;let g=j.value,b=++o;if(!Z.value.includes(r)){let K=f.actions.loadAround;if(K===void 0||!await T({kind:"locate-message",messageId:r},()=>K(r))||!ae(g,b))return false}return !await Ee(g,b,r,{...l,behavior:"auto"})||!await Ce(g,b,r)?false:Ee(g,b,r,l)}function Oe(){w!==void 0&&(clearTimeout(w),w=void 0);}function me(){if(Oe(),!x.value)return;let r=t.readActions;if(r===void 0||p.length===0)return;let l=Number.isFinite(N.value.visibleReadDelay)?Math.max(0,N.value.visibleReadDelay):Je.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!_.value||!J.value)return;let g=p[p.length-1];if(g===void 0)return;let b=r.resolveTarget===void 0?g:r.resolveTarget(g);b!=null&&Promise.resolve(r.markRead(b)).catch(V=>{t.hooks?.onError?.({kind:"visible-range",messageIds:p},V);});},l);}function Ke(r){p=Object.freeze([...r]);let l={kind:"visible-range",messageIds:p};t.hooks?.beforeAction?.(l);try{f.actions.onVisibleRange?.(p),t.hooks?.afterAction?.(l,void 0);}catch(g){throw t.hooks?.onError?.(l,g),g}x.value?me():Ie();}function ee(r,l){return !X&&R===l&&j.value===r&&!D}function ge(r,l){ee(r,l)&&(I=r,H=xe(s.value.entryUnread),x.value=true,me());}function xe(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function re(r,l,g){for(let b=0;b<60;b+=1){if(!ee(r,l))return false;if(m.value?.scrollToMessage(g,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(E=>window.requestAnimationFrame(()=>E()));}return false}function Ie(){let r=j.value,l=xe(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null&&s.value.messages.length===0||I===r&&(H===l||D)||O===r||d!==null)return;if(!Q.value.enabled){I=r,H=l,x.value=true,me();return}let g=++R;D=false,x.value=false;let b=(async()=>{if(await nextTick(),!ee(r,g))return;let V=m.value;if(V===null||!V.isMeasurable())return;let E=s.value.entryUnread;if(E.state==="located"&&!Z.value.includes(E.firstMessageId))return;let K=E.state==="located"?await re(r,g,E.firstMessageId):false;if(E.state==="located"&&!K)return;K||V.scrollToLatest();let se=0;for(;ee(r,g)&&se<Q.value.maxFillPages&&s.value.error===null&&s.value.hasOlder&&V.isMeasurable()&&!V.isScrollable();)if(await c(),!ee(r,g)||(se+=1,await nextTick(),await nextTick(),!V.isMeasurable()))return;if(!ee(r,g)||!V.isMeasurable())return;let ne=s.value.entryUnread;if(ne.state==="located"){if(!Z.value.includes(ne.firstMessageId)||!await re(r,g,ne.firstMessageId))return}else V.scrollToLatest();await nextTick(),ge(r,g);})().catch(()=>{ee(r,g)&&(O=r);}).finally(()=>{d===b&&(d=null);});d=b;}function he(r,l=false){R+=1,d=null,D=false,x.value=r,(I="",H="",l||(O="")),Oe();}function ke(){if(x.value)return;let r=j.value;D=true,R+=1,d=null,I=r,x.value=true,me();}let Ve=Object.freeze({getViewportElement:()=>m.value?.getViewportElement()??null,loadOlder:c,retryOlder:z,loadNewer:P,retryNewer:q,jumpToLatest:be,scrollToMessage:Pe,locateMessage:Ae,focusViewport:()=>m.value?.focusViewport()});return a(Ve),watch(J,r=>{r&&x.value?me():Oe();}),watch([()=>s.value.activeRemoteMessageRevision??0,m,j],()=>{let r=m.value;if(r===null||!_.value)return;let l=f.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(l,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:F.value})&&(M.value=false);},{flush:"post"}),watch([j,()=>s.value.loading,()=>s.value.error,()=>Z.value.length,()=>s.value.hasOlder,()=>xe(s.value.entryUnread),Q],([r,l,g,,,b],[V,,,,,E])=>{if(r!==V&&(o+=1,he(false),u(true),m.value?.clearNewMessageBadge(),k.value=0,M.value=true),r!==""&&r===V&&b!==E&&!D&&b.startsWith("located:")&&(I="",H="",x.value=false),r===""){he(false);return}if(g!==null&&s.value.messages.length===0){x.value||he(false,true);return}l||Ie();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{X=true,o+=1,he(false),u(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:$.value,actions:Ve},l=[v.header?.(r),v["before-list"]?.(r)];if(!_.value)l.push(v.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)l.push(v.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)l.push(v.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let g=h$1(Ye,{ref:m,messageIds:Z.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:s.value.loadingOlder??s.value.loading,hasNewer:s.value.hasNewer,loadingNewer:s.value.loadingNewer??s.value.loading,followThreshold:N.value.followThreshold,olderPrefetchThreshold:N.value.olderPrefetchThreshold,visibleMargin:N.value.visibleMargin,activeDateOffset:N.value.activeDateOffset,activeDateEnabled:v["active-date"]!==void 0,resizeFollowEnabled:x.value,followNewMessages:F.value,shouldFollowAppendedMessage:b=>{let V=s.value.messages.find(E=>E.id===b);return V===void 0?false:f.shouldFollowMessage?.(V)===true},onReachStart:()=>{B("older").catch(()=>{});},onReachEnd:()=>{B("newer").catch(()=>{});},onSettled:fe,onUserScroll:ke,onActiveDateChange:S,onVisibleRange:Ke,onNewMessageCount:b=>{k.value=b;}},{default:()=>[v["viewport-before"]?.(r),h$1(ze,{items:$.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:v.item,"date-separator":v["date-separator"],"entry-unread":v["entry-unread"],encryption:v.encryption,system:v.system,message:v.message,"recalled-message":v["recalled-message"],"deleted-message":v["deleted-message"],"unsupported-body":v["unsupported-body"]}),v["viewport-after"]?.(r)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[v["active-date"]?.({label:U.value,visible:Y.value&&U.value!==""}),g])),s.value.error!==null&&l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return l.push(v["after-list"]?.(r),v["jump-to-latest"]?.({...r,count:k.value,visible:!M.value||s.value.isHistoryWindow}),v["context-menu"]?.(r),v.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function Tr(t){let a=new Map;for(let f of t){if(a.has(f.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${f.kind}`);a.set(f.kind,f.component);}let v=Object.freeze([...a.keys()]);return Object.freeze({kinds:v,resolve:f=>a.get(f)})}var br=140,Ir=120;function Dt(t,a){if(t.width<=0||t.height<=0)return 0;let v=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),f=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,v*f/(t.width*t.height))}function wr(t,a){return {x:t.x,y:t.top-a,top:t.top-a,bottom:t.bottom+a,left:t.left,right:t.right,width:t.width,height:t.height+a*2,toJSON:()=>({})}}function Ze(t){let a=Math.max(0,t.scrollIdleMs??br),v=Math.max(0,t.visibilityDwellMs??Ir),f=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),m=Math.max(0,t.revealMarginPx??0),k=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,p=new Map,w=reactive(new Set),R=new Set,o=new Set,d=null,I=null,H=null,O=false,D=false,X=false,x,U;function Y(){x!==void 0&&clearTimeout(x),x=void 0;}function L(){U!==void 0&&clearTimeout(U),U=void 0;}function W(u=false){if(!u&&I!==null||d===null)return;let S=d.getBoundingClientRect(),T=wr(S,m);for(let[c,P]of M){let B=c.getBoundingClientRect();P.ratio=Dt(B,S),P.intersecting=P.ratio>0,P.revealIntersecting=m>0?Dt(B,T)>0:P.intersecting&&P.ratio>=f;}}function s(u){return u.intersecting&&u.ratio>=f}function F(){for(let u of M.values())!u.revealIntersecting||w.has(u.key)||(w.add(u.key),t.onRevealed?.(u.item));}function J(u){let S=new Set(u.map(c=>c.key));if(S.size!==o.size||[...S].some(c=>!o.has(c))){o.clear();for(let c of S)o.add(c);t.onSettledVisibleChange?.(u.map(c=>c.item));}}function _(){if(D||O)return;W(),F();let u=d?.getBoundingClientRect(),S=u===void 0?0:(u.top+u.bottom)/2,T=[...M.entries()].filter(([,c])=>s(c)).sort(([c],[P])=>{let B=c.getBoundingClientRect(),q=P.getBoundingClientRect();return Math.abs((B.top+B.bottom)/2-S)-Math.abs((q.top+q.bottom)/2-S)}).slice(0,k).map(([,c])=>c);J(T);for(let c of T)R.has(c.key)||(R.add(c.key),t.onActivated?.(c.item));}function N(){D||O||(L(),U=setTimeout(()=>{U=void 0,_();},v));}function Q(){D||(j(true),W(),F(),J([]),L(),Y(),x=setTimeout(()=>{x=void 0,j(false),N();},a));}function j(u){O!==u&&(O=u,t.onScrollingChange?.(u));}function $(){d?.removeEventListener("scroll",Q),I?.disconnect(),H?.disconnect(),I=null,H=null,d=null;}function Z(u=true){if(D)return;let S=t.getRoot();if(!(S===d&&d!==null)){if($(),d=S,d===null){u&&!X&&(X=true,Promise.resolve().then(()=>{X=false,D||(Z(false),N());}));return}if(d.addEventListener("scroll",Q,{passive:true}),typeof IntersectionObserver<"u"){I=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.intersecting=c.isIntersecting,P.ratio=c.intersectionRatio,m===0&&(P.revealIntersecting=c.isIntersecting&&c.intersectionRatio>=f));}F(),N();},{root:d,threshold:[0,f,1]}),m>0&&(H=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.revealIntersecting=c.isIntersecting);}F();},{root:d,rootMargin:`${m}px 0px`,threshold:0}));for(let T of M.keys())I.observe(T);for(let T of M.keys())H?.observe(T);}else W(),F();}}function ie(u){w.delete(u),R.delete(u),o.delete(u);}return {register(u,S){if(D)return;let T=t.getKey(u),c=w.has(T),P=R.has(T),B=S===null?void 0:M.get(S);B!==void 0&&B.key!==T&&(p.delete(B.key),M.delete(S),ie(B.key));let q=p.get(T);if(q!==void 0&&q!==S&&(I?.unobserve(q),H?.unobserve(q),M.delete(q),p.delete(T)),S===null){q!==void 0&&(I?.unobserve(q),H?.unobserve(q),M.delete(q),p.delete(T)),ie(T);return}let z=M.get(S);if(z?.key===T&&z.item===u){Z();return}M.set(S,{item:u,key:T,intersecting:z?.key===T?z.intersecting:false,ratio:z?.key===T?z.ratio:0,revealIntersecting:z?.key===T?z.revealIntersecting:false}),p.set(T,S),Z(),I?.observe(S),H?.observe(S),W(true),F(),c&&t.onRevealed?.(u),P?t.onActivated?.(u):N();},isRevealed:u=>w.has(t.getKey(u)),isActivated:u=>R.has(t.getKey(u)),isSettledVisible:u=>o.has(t.getKey(u)),isScrolling:()=>O,notifyScroll:Q,refresh(){Z(),W(true),F(),N();},reset(){Y(),L(),j(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear();},dispose(){D||(Y(),L(),j(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear(),D=true);}}}function Mr(t){let a=new Map,v=new Map,f=false,m=p=>{let w=a.get(p.channel);return w===void 0?p.channel:`${p.channel}\0${w.getKey(p.item)}`},k=Ze({getRoot:t.getRoot,getKey:m,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:p=>{for(let w of a.values())w.onScrollingChange?.(p);},onRevealed:p=>a.get(p.channel)?.onRevealed?.(p.item),onActivated:p=>a.get(p.channel)?.onActivated?.(p.item),onSettledVisibleChange:p=>{for(let[w,R]of a){let o=p.filter(I=>I.channel===w).map(I=>I.item),d=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(d);}}});function M(p){return w=>{if(f)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(p))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${p}`);a.set(p,w);let R=new Map;v.set(p,R);let o=false,d=O=>({channel:p,item:O});function I(){for(let O of R.values())k.register(O.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(O,D){if(o||f)return;let X=w.getKey(O),x=R.get(X);if(D===null){x!==void 0&&(k.register(x.target,null),R.delete(X));return}let U=d(O);R.set(X,{target:U,element:D}),k.register(U,D);},isRevealed:O=>k.isRevealed(d(O)),isActivated:O=>k.isActivated(d(O)),isSettledVisible:O=>k.isSettledVisible(d(O)),isScrolling:k.isScrolling,notifyScroll:k.notifyScroll,refresh:k.refresh,reset:I,dispose(){o||(I(),o=true,a.delete(p),v.delete(p));}}}}return {createFactory:M,refresh:k.refresh,dispose(){if(!f){for(let p of v.values())for(let w of p.values())k.register(w.target,null);v.clear(),a.clear(),k.dispose(),f=true;}}}}export{Ge as ImThreadBodySwitch,ze as ImThreadItems,hr as ImThreadSurface,Ye as ImThreadViewport,ur as createImThreadSurfaceContext,Tr as createMessageRendererRegistry,Mr as createThreadVisibilityTargetGroup,Ze as createThreadVisibilityTargets,cr as provideImThreadSurfaceContext,Gt as useImText,$e as useImThreadSurfaceContext,Yt as useOptionalImThreadReadActions};
1
+ import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-YUPKU2L7.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-BIFDS3MH.js';import'./chunk-DVQGXZ6S.js';import'./chunk-FQJBDSXT.js';import'./chunk-O7GQQMEW.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment,reactive}from'vue';function qt(t){let a=0,v=0;for(let f of t)f.kind==="video"?v+=1:a+=1;return {imageCount:a,videoCount:v}}function Gt(t){return {systemMessage:a=>a.body.system!==void 0?g$1(a.body.system,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):"",mediaPlaceholder:a=>i$1(a.contentType,{locale:t.locale(),durationMs:a.body.voice?.durationMs,stickerImageType:a.body.sticker?.imageType,gameType:a.body.game?.gameType,callKind:a.body.call?.callKind,...a.body.mediaAlbum===void 0?{}:{mediaAlbum:qt(a.body.mediaAlbum.items)}}),lastMessage:a=>a.lastMessageSummary!==void 0?h$2(a.lastMessageSummary,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):a.lastMessagePreview,failureText:a=>a.failure?.displayCode!==void 0?f(a.failure.displayCode,{locale:t.locale(),mediaKind:a.failure.mediaKind,params:a.failure.params}):a.failure?.message??""}}var Et=Symbol("ImThreadReadActions");function At(t){provide(Et,t);}function Yt(){return inject(Et,void 0)}var Ge=defineComponent({name:"ImThreadBodySwitch",inheritAttrs:false,props:{message:{type:Object,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{attrs:a,slots:v}){return At(t.readActions),()=>{let f=h(t.message),g=t.rendererRegistry.resolve(f);return g!==void 0?h$1(g,{...a,message:t.message,presentation:t.presentation}):v["unsupported-body"]!==void 0?v["unsupported-body"]({kind:f,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":f,"aria-hidden":"true"})}}});var We=Symbol("ImThreadViewportRegistration");function xt(){return inject(We,void 0)}var ze=defineComponent({name:"ImThreadItems",props:{items:{type:Array,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{slots:a}){let v=xt();function f(o,d){let y=Array.isArray(d)?d:[d];return y.length===1&&isVNode(y[0])?cloneVNode(y[0],{key:o}):h$1(Fragment,{key:o},y)}function g(o){return d=>{v?.registerMessageNode(o,d instanceof HTMLElement?d:null);}}function k(o,d){return y=>{v?.registerDateNode(o,d,y instanceof HTMLElement?y:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function p(o){let d=k(o.key,o.label);return a["date-separator"]?.({item:o,setElement:d})??h$1("div",{ref:d,"data-im-thread-date-separator":o.key},o.label)}function w(o){return a["entry-unread"]?.({item:o})??h$1("div",{"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function R(o){let d=g(o.message.id);return a.item!==void 0?a.item({item:o,setElement:d}):a.message!==void 0?a.message({item:o,setElement:d}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"deleted-for-everyone"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.message.recalled!==void 0?a["recalled-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"recalled"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.kind==="system"&&a.system!==void 0?a.system({item:o,setElement:d}):h$1("article",{ref:d,"data-im-thread-message-id":o.message.id,"data-first-of-run":o.kind==="message"?String(o.firstOfRun):void 0},[h$1("span",{"data-im-thread-anchor-point":""}),h$1(Ge,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:y=>a["unsupported-body"]?.(y)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,M(o));case "date-separator":return a.item!==void 0?f(o.key,a.item({item:o,setElement:k(o.key,o.label)})):f(o.key,p(o));case "entry-unread":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,w(o));case "system":case "message":return f(o.key,R(o))}return o}))}});var kt=120,ar=500,le=.5,sr=8,Ye=defineComponent({name:"ImThreadViewport",props:{messageIds:{type:Array,required:true},contentKey:{type:String,default:""},loadingOlder:{type:Boolean,default:false},hasNewer:{type:Boolean,default:false},loadingNewer:{type:Boolean,default:false},followThreshold:{type:Number,default:120},olderPrefetchThreshold:{type:Number,default:120},followNewMessages:{type:Boolean,default:true},shouldFollowAppendedMessage:{type:Function,default:void 0},visibleMargin:{type:Number,default:8},resizeFollowEnabled:{type:Boolean,default:true},activeDateOffset:{type:Number,default:16},activeDateEnabled:{type:Boolean,default:false}},emits:{"reach-start":()=>true,"reach-end":()=>true,"visible-range":t=>true,settled:t=>true,"new-message-count":t=>true,"user-scroll":()=>true,"active-date-change":t=>true},setup(t,{emit:a,expose:v,slots:f}){let g$1=ref(null),k=ref(null),M=new Map,p$1=new Map,w=new Set,R=new Map,o$1=0,d=[],y,L,x,N,X=false,E,U=new Set,Y=false,H,W="",s=1,_=false,J=false,j$1=true,D=false,Q=false,B$1=false,$=0,Z=-1,ae=-1,u,S,T,c,P,F=ref(true),q$1=ref(0),z$1=C(e=>{q$1.value=e,a("new-message-count",e);});function be(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function fe(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let h=i.getBoundingClientRect(),b=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:h.top,bottom:h.bottom,anchorTop:b?.getBoundingClientRect().top??h.top}]})}function Ee(e="",n=1){let i=Math.min(1,Math.max(0,n));W!==""&&W!==e&&R.get(W)?.element.style.removeProperty("opacity"),W=e,s=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function re(){Ee();}function Ae(){let e=g$1.value;if(Y||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,O])=>e.contains(O.element)).map(([O,C])=>{let G=C.element.getBoundingClientRect();return {key:O,label:C.label,top:G.top,height:G.height}}).sort((O,C)=>O.top-C.top),i=e.getBoundingClientRect(),h=n.find(O=>O.height>0)?.height??28,b=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:h});if(b===null){re(),a("active-date-change",null);return}Ee(b.inlineDateKey,b.inlineOpacity),a("active-date-change",b);}function Ce(e){L={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Oe(e){let n=L;if(n===void 0)return false;let i=Math.max(0,e.scrollHeight-e.clientHeight);return i<n.scrollHeight-n.height&&n.scrollTop>i&&Math.abs(e.scrollTop-i)<=le}function xe(e){return Oe(e)||H!==void 0&&(H.behavior==="smooth"||Math.abs(e.scrollTop-H.targetTop)<=le)?0:e.scrollTop-o$1}function me(e,n){n!==0&&(o$1=e.scrollTop-n,H=void 0,m$1());}function Ke(e,n){let i=xe(e);if(c!==void 0)return c.expectedOffset-=i,se(),me(e,i),D||ie(),false;let h=L;if(h===void 0)return false;let b=y,O=b===void 0?void 0:fe([b.id])[0],C=e.scrollTop-h.scrollTop,G=Oe(e)?0:C,Re=b===void 0||O===void 0?0:(O.anchorTop??O.top)-n.top-b.offset+C;return h.scrollHeight!==e.scrollHeight||h.width!==e.clientWidth||h.height!==e.clientHeight||Math.abs(Re)>le?(L=void 0,!_&&!t.loadingNewer&&t.resizeFollowEnabled&&F.value&&Math.abs(G)<=le?(Fe(),true):(b!==void 0&&Ne({...b,offset:b.offset-G}),me(e,i),false)):false}function ee(){let e=g$1.value;if(Y||e===null)return;let n=e.getBoundingClientRect();if(Ke(e,n))return;let i=N!==void 0&&X?t.messageIds.filter(C=>w.has(C)):t.messageIds,h=fe(i);if(N!==void 0&&X&&h.length===0){F.value=be(e);return}let b=h.filter(C=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:C.top,messageBottom:C.bottom,margin:t.visibleMargin})).map(C=>C.id),O=b.length!==d.length||b.some((C,G)=>d[G]!==C);d=Object.freeze(b),y=o(h,{top:n.top,bottom:n.bottom}),Ce(e),z$1.acknowledgeVisible(b),F.value=be(e),O&&a("visible-range",d),a("settled",{visibleMessageIds:d,...d.length===0?{}:{newestVisibleMessageId:d[d.length-1]},isAtBottom:F.value,newMessageCount:q$1.value});}function ge(e){if(U.add(e),E!==void 0)return;let n=()=>{E=void 0;let i=[...U];U.clear(),i.forEach(h=>h());};typeof globalThis.requestAnimationFrame=="function"?E=globalThis.requestAnimationFrame(n):E=globalThis.setTimeout(n,0);}function Ie(){E!==void 0&&(typeof E=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(E):globalThis.clearTimeout(E),E=void 0,U.clear());}function ne(){ge(ee);}function we(){let e=g$1.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o(fe(),{top:n.top,bottom:n.bottom});i!==void 0&&(y=i,Ce(e));}function pe(){return j$1&&c===void 0&&!J&&!t.loadingOlder}function ke(){we(),j$1=false,Z=$,J=true,a("reach-start"),ge(()=>{t.loadingOlder||(J=false);});}function Ve(e){return t.hasNewer&&!_&&!t.loadingOlder&&!t.loadingNewer&&be(e)}function r(){_=true,F.value=false,ae=$,a("reach-end"),ge(()=>{t.loadingNewer||(_=false);});}function l(){let e=g$1.value;e===null||$===ae||!Ve(e)||r();}function m$1(){let e=g$1.value;if(Y||e===null)return;let n=e.scrollTop,i=Oe(e),h=H,b=false;if(h!==void 0){let C=Math.abs(n-h.targetTop)<=le;b=h.behavior==="smooth"||C,(h.behavior!=="smooth"||C)&&(H=void 0);}!b&&!i&&!D&&c===void 0&&n!==o$1&&(D=true,Q=true,$+=1);let O=D&&!b&&!i&&n!==o$1;if(O&&(a("user-scroll"),ge(Ae)),D&&!B$1&&ye(),!j$1&&Q&&$!==Z&&n<o$1&&n>et()&&(j$1=true),c!==void 0&&!b)if(D){let C=K();C!==void 0&&(c.expectedOffset=C);}else se(),ie();pe()&&O&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&ke(),O&&Ve(e)&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:be(e),isHistoryWindow:t.hasNewer,isPageSettling:b})&&r(),o$1=n,ne();}function I(e,n="auto"){H={targetTop:e,behavior:n};}function V(e){let n=c,i=k.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=le?0:e,n.visualOffset===0){i.style.removeProperty("transform"),i.style.removeProperty("will-change");return}i.style.setProperty("transform",`translate3d(0, ${n.visualOffset}px, 0)`),i.style.setProperty("will-change","transform");}}function A(){P!==void 0&&(clearTimeout(P),P=void 0),c!==void 0&&c.visualOffset!==0&&(y=void 0,L=void 0);let e=k.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),c=void 0,H=void 0;}function K(){let e=g$1.value,n=c;if(e===null||n===void 0)return;let i=fe().find(h=>h.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function se(){let e=c,n=K();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=le||(V(e.visualOffset+i),e.committed=false,e.attempts=0);}function oe(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,!(D||c?.committed!==true)&&A();},ar);}function Te(){let e=g$1.value,n=c;if(Y||e===null||n===void 0||D)return;let i=n.visualOffset;if(Math.abs(i)<=le){n.committed=true,oe();return}let h=Math.max(0,e.scrollHeight-e.clientHeight),b=Math.min(h,Math.max(0,e.scrollTop-i));if(I(b),e.scrollTop=b,Math.abs(e.scrollTop-b)>le){H=void 0,n.committed=false,n.attempts+=1,n.attempts<sr?ie():(A(),H=void 0,o$1=e.scrollTop);return}V(0),o$1=e.scrollTop,n.expectedOffset=K()??n.expectedOffset,n.committed=true,n.attempts=0,oe();}function ie(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,Te();},kt);}function Me(e){e!==void 0&&(c===void 0&&(c={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),se(),!D&&Te());}function Ne(e){let n=g$1.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),h=q(e,fe(),{top:i.top,bottom:i.bottom});if(h!==void 0){let b=Math.max(0,n.scrollHeight-n.clientHeight),O=Math.min(b,Math.max(0,n.scrollTop+h));I(O),n.scrollTop=O,o$1=n.scrollTop,L=void 0;}}function et(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function De(){H?.behavior==="smooth"&&(H=void 0),Q=false,D||(D=true,$+=1),u!==void 0&&(clearTimeout(u),u=void 0);}function Le(){let e=g$1.value;e===null||$===Z||(c!==void 0&&A(),j$1=true,e.scrollTop<=et()&&pe()&&ke());}function tt(){y=void 0,L=void 0,u!==void 0&&(clearTimeout(u),u=void 0),A(),D=false,Q=false,B$1=false,S=void 0,T=void 0,$+=1,Z=-1,ae=-1,j$1=true,J=false,_=false,H=void 0;}function rt(){B$1||(u!==void 0&&(clearTimeout(u),u=void 0),D=false,Q=false,c!==void 0&&(c.attempts=0),Te());}function ye(){B$1||(u!==void 0&&clearTimeout(u),u=setTimeout(()=>{u=void 0,rt();},kt));}function nt(){H=void 0,rt();}function ot(e){B$1=true,De(),S=e.touches?.[0]?.clientY;}function it(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(S!==void 0&&n>S?Le():S!==void 0&&n<S&&l(),S=n);}function He(){B$1=false,S=void 0,ye();}function at(e){De(),e.deltaY<0?Le():e.deltaY>0&&l(),ye();}function st(e){e.pointerType!=="touch"&&(De(),T=e.clientY,ye());}function lt(e){e.pointerType==="touch"||!D||T===void 0||(e.clientY<T?Le():e.clientY>T&&l(),T=e.clientY,ye());}function Be(e){e.pointerType!=="touch"&&(T=void 0,ye());}function dt(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(De(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?Le():l(),ye());}function Fe(e="auto"){let n=g$1.value;if(n===null)return;L=void 0,A();let i=Math.max(0,n.scrollHeight-n.clientHeight);I(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,z$1.clear(),ee();}function ut(){let e=g$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Lt(){let e=g$1.value;return ut()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Ht(e,n={}){let i=g$1.value,h=M.get(e);if(i===null||h===void 0||!i.contains(h)||i.clientHeight<=0)return false;A();let b=i.getBoundingClientRect(),O=h.getBoundingClientRect(),C=n.block??"center",G;C==="start"?G=i.scrollTop+O.top-b.top:C==="end"?G=i.scrollTop+O.bottom-b.bottom:C==="nearest"?O.top>=b.top&&O.bottom<=b.bottom?G=i.scrollTop:O.top<b.top?G=i.scrollTop+O.top-b.top:G=i.scrollTop+O.bottom-b.bottom:G=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:O.height,targetTop:O.top,viewportHeight:i.clientHeight,viewportTop:b.top});let Re=Math.max(0,i.scrollHeight-i.clientHeight),ve=Math.min(Re,Math.max(0,G));L=void 0;let Se=n.behavior??"auto";return I(ve,Se),i.scrollTo?.({top:ve,behavior:Se}),i.scrollTop!==ve&&(i.scrollTop=ve),o$1=i.scrollTop,ee(),true}function Bt(){z$1.clear();}function Ft(){_=true,F.value=false;}function _t(){_=false,ne();}function jt(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(N?.unobserve(i),x?.unobserve?.(i),p$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),p$1.set(n,e),N?.observe(n),x?.observe(n),ne();}function Kt(e,n,i){let h=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),W===e&&i.style.setProperty("opacity",String(s)),h?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(We,{registerMessageNode:jt,registerDateNode:Kt}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;tt();let i=g$1.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=g$1.value;if(i===null)return;let h=new Set(n);n.length>0&&e.length>0&&!e.some(he=>h.has(he))&&tt();let O=i.getBoundingClientRect(),C=p(y,fe(),{top:O.top,bottom:O.bottom}),G=F.value,Re=n[n.length-1],ve=Re===void 0?-1:e.indexOf(Re),Se=ve<0?[]:e.slice(ve+1).filter(he=>!h.has(he)),ct=_||t.loadingNewer,Ut=e.length===n.length&&e.every(he=>h.has(he))&&e.some((he,Ue)=>he!==n[Ue]);if(await nextTick(),Y)return;if(Ut&&G&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!ct){Fe();return}let ft=n[0];if(ft!==void 0&&e.indexOf(ft)>0&&(J=false,Me(C)),Se.length>0){if(ct){_=false,c===void 0&&Ne(C),F.value=false,ne();return}(G||Se.some(Ue=>t.shouldFollowAppendedMessage?.(Ue)===true))&&t.followNewMessages?Fe():z$1.add(Se);}ne();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!_||ge(()=>{t.loadingNewer||(_=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!J||ge(()=>{t.loadingOlder||(J=false);});},{flush:"pre"}),onMounted(()=>{let e=g$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",m$1,{passive:true}),e.addEventListener("scrollend",nt,{passive:true}),e.addEventListener("touchstart",ot,{passive:true}),e.addEventListener("touchmove",it,{passive:true}),e.addEventListener("touchend",He,{passive:true}),e.addEventListener("touchcancel",He,{passive:true}),e.addEventListener("wheel",at,{passive:true}),e.addEventListener("pointerdown",st,{passive:true}),e.addEventListener("pointermove",lt,{passive:true}),e.addEventListener("pointerup",Be,{passive:true}),e.addEventListener("pointercancel",Be,{passive:true}),e.addEventListener("keydown",dt),typeof globalThis.ResizeObserver=="function"){x=new globalThis.ResizeObserver(()=>{Y||g$1.value===null||ee();}),x.observe(e),k.value!==null&&x.observe(k.value);for(let n of M.values())x.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){N=new globalThis.IntersectionObserver(n=>{for(let i of n){let h=p$1.get(i.target);h!==void 0&&(i.isIntersecting?w.add(h):w.delete(h));}X=true,ne();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())N.observe(n);}ne();}}),onBeforeUnmount(()=>{Y=true;let e=g$1.value;e!==null&&e.removeEventListener("scroll",m$1),e!==null&&(e.removeEventListener("scrollend",nt),e.removeEventListener("touchstart",ot),e.removeEventListener("touchmove",it),e.removeEventListener("touchend",He),e.removeEventListener("touchcancel",He),e.removeEventListener("wheel",at),e.removeEventListener("pointerdown",st),e.removeEventListener("pointermove",lt),e.removeEventListener("pointerup",Be),e.removeEventListener("pointercancel",Be),e.removeEventListener("keydown",dt)),u!==void 0&&clearTimeout(u),A(),Ie(),x?.disconnect(),N?.disconnect(),re(),M.clear(),p$1.clear(),w.clear(),R.clear(),z$1.clear();}),v({getViewportElement:()=>g$1.value,clearNewMessageBadge:Bt,clearActiveDate:re,isAtBottom:computed(()=>F.value),isMeasurable:ut,isScrollable:Lt,newMessageCount:computed(()=>q$1.value),prepareHistoryPageAppend:Ft,cancelHistoryPageAppend:_t,trackRemoteMessageIds:(e,n)=>z$1.trackRemote(e,n),scrollToLatest:Fe,scrollToMessage:Ht,focusViewport:()=>g$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:g$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:k,"data-im-thread-viewport-content":""},f.default?.())])}});var Nt=Symbol("ImThreadSurfaceContext");function ur(t){if(typeof t.getState!="function")throw new TypeError("ImThreadSurfaceContext.getState \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.actions?.loadOlder!="function")throw new TypeError("ImThreadSurfaceContext.actions.loadOlder \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.formatDate!="function")throw new TypeError("ImThreadSurfaceContext.formatDate \u5FC5\u987B\u662F\u51FD\u6570");return Object.freeze({...t,actions:Object.freeze({...t.actions})})}function cr(t){provide(Nt,t);}function $e(){let t=inject(Nt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var Je=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),Qe=Object.freeze({enabled:true,maxFillPages:8}),gr=8,pr=160;function vr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var hr=defineComponent({name:"ImThreadSurface",props:{conversation:{type:Object,required:true},context:{type:Object,default:void 0},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0},viewportOptions:{type:Object,default:()=>({})},initialViewportOptions:{type:Object,default:()=>({})},hooks:{type:Object,default:void 0}},setup(t,{expose:a,slots:v}){let f=t.context??$e(),g=ref(null),k=ref(0),M=ref(true),p=[],w,R=0,o=0,d=null,y="",L="",x="",N=false,X=false,E=ref(false),U=ref(""),Y=ref(false),H,W,s=computed(()=>f.getState()),_=computed(()=>s.value.pageVisible??f.isPageVisible?.()??true),J=computed(()=>s.value.pageEngaged??f.isPageEngaged?.()??true),j=computed(()=>vr(s.value.activeConversation,t.conversation)),D=computed(()=>({...Je,...t.viewportOptions})),Q=computed(()=>{let r=t.initialViewportOptions.maxFillPages??Qe.maxFillPages;return {enabled:t.initialViewportOptions.enabled??Qe.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):Qe.maxFillPages}}),B=computed(()=>!j.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),$=computed(()=>j.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:f.formatDate,leadingItems:f.leadingItems?.(),beforeMessageItems:f.beforeMessageItems}):[]),Z=computed(()=>$.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ae(){H!==void 0&&(clearTimeout(H),H=void 0),W!==void 0&&(clearTimeout(W),W=void 0);}function u(r=false){if(ae(),Y.value=false,r){g.value?.clearActiveDate(),U.value="";return}W=setTimeout(()=>{W=void 0,!Y.value&&(g.value?.clearActiveDate(),U.value="");},pr);}function S(r){if(r===null){u();return}ae(),U.value=r.label,Y.value=true;let l=D.value.activeDateIdleDelay,m=Number.isFinite(l)?Math.max(0,l):Je.activeDateIdleDelay;H=setTimeout(()=>{H=void 0,u();},m);}async function T(r,l){t.hooks?.beforeAction?.(r);try{let m=await l();return t.hooks?.afterAction?.(r,m),m}catch(m){throw t.hooks?.onError?.(r,m),m}}function c(r="automatic"){return !j.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):T({kind:"load-older",source:r},()=>f.actions.loadOlder())}function P(){let r=f.actions.loadNewer,l=s.value.loadingNewer??s.value.loading;return !j.value||l||!s.value.hasNewer||r===void 0?Promise.resolve(0):T({kind:"load-newer"},()=>r())}async function F(r){for(let l=0;l<gr;l+=1){if(!j.value)return;let m=r==="older"?s.value.hasOlder:s.value.hasNewer,I=r==="older"?s.value.olderError:s.value.newerError;if(!m||I!==null||(r==="older"?await c("user-scroll"):await P())>0)return;let A=r==="older"?s.value.hasOlder:s.value.hasNewer,K=r==="older"?s.value.olderError:s.value.newerError;if(!A||K!==null)return}}async function q(){return !j.value||f.actions.loadNewer===void 0?0:T({kind:"load-newer"},()=>f.actions.retryNewer?.()??f.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function z(){if(!j.value)return 0;let r=B.value,l=++R;d=null,x="";let m;try{m=await T({kind:"retry-older"},()=>f.actions.retryOlder?.()??f.actions.loadOlder({force:!0}));}catch(I){throw ee(r,l)&&(x=r),I}return ee(r,l)&&!E.value&&(d=null,we()),m}async function be(){if(!j.value)return false;let r=B.value,l=++o;return pe(true),N=true,y=r,L=Ie(s.value.entryUnread),!await T({kind:"jump-to-latest"},()=>f.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow))||!re(r,l)||(await nextTick(),!re(r,l))?false:(g.value?.scrollToLatest(),true)}function fe(r){M.value=r.isAtBottom,k.value=r.newMessageCount,we();}function Ee(r,l){return g.value?.scrollToMessage(r,l)??false}function re(r,l){return !X&&o===l&&B.value===r&&j.value}async function Ae(r,l,m,I){for(let V=0;V<60;V+=1){if(!re(r,l))return false;if(Ee(m,I))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(A=>window.requestAnimationFrame(()=>A()));}return false}async function Ce(r,l,m){let I=g.value;if(I===null||!I.isMeasurable()||I.isScrollable())return true;let V=0,A=!s.value.hasOlder,K=!s.value.hasNewer||f.actions.loadNewer===void 0,se=async()=>(await nextTick(),await nextTick(),Ae(r,l,m,{behavior:"auto",block:"center"})),oe=async ie=>{if(!re(r,l)||V>=Q.value.maxFillPages)return false;let Me=0;if(ie==="older"){if(A||!s.value.hasOlder)return false;Me=await c(),A=!s.value.hasOlder;}else {if(K||!s.value.hasNewer)return false;I.prepareHistoryPageAppend();try{Me=await P();}catch(Ne){throw I.cancelHistoryPageAppend(),Ne}Me<=0&&!s.value.hasNewer&&I.cancelHistoryPageAppend(),K=!s.value.hasNewer;}return V+=1,Me>0?se():!(ie==="older"?A:K)};!A&&!await oe("older")&&(A=true),!K&&!await oe("newer")&&(K=true);let Te="older";for(;re(r,l)&&V<Q.value.maxFillPages&&I.isMeasurable()&&!I.isScrollable()&&(!A||!K);){let ie=Te==="older"?A?"newer":"older":K?"older":"newer";Te=ie==="older"?"newer":"older",await oe(ie)||(ie==="older"?A=true:K=true);}return re(r,l)}async function Oe(r,l={behavior:"auto",block:"center"}){if(!j.value||r==="")return false;let m=B.value,I=++o;if(!Z.value.includes(r)){let K=f.actions.loadAround;if(K===void 0||!await T({kind:"locate-message",messageId:r},()=>K(r))||!re(m,I))return false}return !await Ae(m,I,r,{...l,behavior:"auto"})||!await Ce(m,I,r)?false:Ae(m,I,r,l)}function xe(){w!==void 0&&(clearTimeout(w),w=void 0);}function me(){if(xe(),!E.value)return;let r=t.readActions;if(r===void 0||p.length===0)return;let l=Number.isFinite(D.value.visibleReadDelay)?Math.max(0,D.value.visibleReadDelay):Je.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!j.value||!J.value)return;let m=p[p.length-1];if(m===void 0)return;let I=r.resolveTarget===void 0?m:r.resolveTarget(m);I!=null&&Promise.resolve(r.markRead(I)).catch(V=>{t.hooks?.onError?.({kind:"visible-range",messageIds:p},V);});},l);}function Ke(r){p=Object.freeze([...r]);let l={kind:"visible-range",messageIds:p};t.hooks?.beforeAction?.(l);try{f.actions.onVisibleRange?.(p),t.hooks?.afterAction?.(l,void 0);}catch(m){throw t.hooks?.onError?.(l,m),m}E.value?me():we();}function ee(r,l){return !X&&R===l&&B.value===r&&!N}function ge(r,l){ee(r,l)&&(y=r,L=Ie(s.value.entryUnread),E.value=true,me());}function Ie(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function ne(r,l,m){for(let I=0;I<60;I+=1){if(!ee(r,l))return false;if(g.value?.scrollToMessage(m,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(A=>window.requestAnimationFrame(()=>A()));}return false}function we(){let r=B.value,l=Ie(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null&&s.value.messages.length===0||y===r&&(L===l||N)||x===r||d!==null)return;if(!Q.value.enabled){y=r,L=l,E.value=true,me();return}let m=++R;N=false,E.value=false;let I=(async()=>{if(await nextTick(),!ee(r,m))return;let V=g.value;if(V===null||!V.isMeasurable())return;let A=s.value.entryUnread;if(A.state==="located"&&!Z.value.includes(A.firstMessageId))return;let K=A.state==="located"?await ne(r,m,A.firstMessageId):false;if(A.state==="located"&&!K)return;K||V.scrollToLatest();let se=0;for(;ee(r,m)&&se<Q.value.maxFillPages&&s.value.error===null&&s.value.hasOlder&&V.isMeasurable()&&!V.isScrollable();)if(await c(),!ee(r,m)||(se+=1,await nextTick(),await nextTick(),!V.isMeasurable()))return;if(!ee(r,m)||!V.isMeasurable())return;let oe=s.value.entryUnread;if(oe.state==="located"){if(!Z.value.includes(oe.firstMessageId)||!await ne(r,m,oe.firstMessageId))return}else V.scrollToLatest();await nextTick(),ge(r,m);})().catch(()=>{ee(r,m)&&(x=r);}).finally(()=>{d===I&&(d=null);});d=I;}function pe(r,l=false){R+=1,d=null,N=false,E.value=r,r||(y="",L="",l||(x="")),xe();}function ke(){if(E.value)return;let r=B.value;N=true,R+=1,d=null,y=r,E.value=true,me();}let Ve=Object.freeze({getViewportElement:()=>g.value?.getViewportElement()??null,loadOlder:c,retryOlder:z,loadNewer:P,retryNewer:q,jumpToLatest:be,scrollToMessage:Ee,locateMessage:Oe,focusViewport:()=>g.value?.focusViewport()});return a(Ve),watch(J,r=>{r&&E.value?me():xe();}),watch([()=>s.value.activeRemoteMessageRevision??0,g,B],()=>{let r=g.value;if(r===null||!j.value)return;let l=f.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(l,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:_.value})&&(M.value=false);},{flush:"post"}),watch([B,()=>s.value.loading,()=>s.value.error,()=>Z.value.length,()=>s.value.hasOlder,()=>Ie(s.value.entryUnread),Q],([r,l,m,,,I],[V,,,,,A])=>{if(r!==V&&(o+=1,pe(false),u(true),g.value?.clearNewMessageBadge(),k.value=0,M.value=true),r!==""&&r===V&&I!==A&&!N&&I.startsWith("located:")&&(y="",L="",E.value=false),r===""){pe(false);return}if(m!==null&&s.value.messages.length===0){E.value||pe(false,true);return}l||we();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{X=true,o+=1,pe(false),u(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:$.value,actions:Ve,initialViewportSettled:B.value!==""&&(s.value.messages.length===0?!s.value.loading&&s.value.error===null&&!s.value.hasOlder:E.value&&y===B.value)},l=[v.header?.(r),v["before-list"]?.(r)];if(!j.value)l.push(v.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)l.push(v.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)l.push(v.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let m=h$1(Ye,{ref:g,messageIds:Z.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:s.value.loadingOlder??s.value.loading,hasNewer:s.value.hasNewer,loadingNewer:s.value.loadingNewer??s.value.loading,followThreshold:D.value.followThreshold,olderPrefetchThreshold:D.value.olderPrefetchThreshold,visibleMargin:D.value.visibleMargin,activeDateOffset:D.value.activeDateOffset,activeDateEnabled:v["active-date"]!==void 0,resizeFollowEnabled:E.value,followNewMessages:_.value,shouldFollowAppendedMessage:I=>{let V=s.value.messages.find(A=>A.id===I);return V===void 0?false:f.shouldFollowMessage?.(V)===true},onReachStart:()=>{F("older").catch(()=>{});},onReachEnd:()=>{F("newer").catch(()=>{});},onSettled:fe,onUserScroll:ke,onActiveDateChange:S,onVisibleRange:Ke,onNewMessageCount:I=>{k.value=I;}},{default:()=>[v["viewport-before"]?.(r),h$1(ze,{items:$.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:v.item,"date-separator":v["date-separator"],"entry-unread":v["entry-unread"],encryption:v.encryption,system:v.system,message:v.message,"recalled-message":v["recalled-message"],"deleted-message":v["deleted-message"],"unsupported-body":v["unsupported-body"]}),v["viewport-after"]?.(r)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[v["active-date"]?.({label:U.value,visible:Y.value&&U.value!==""}),m])),s.value.error!==null&&l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return l.push(v["after-list"]?.(r),v["jump-to-latest"]?.({...r,count:k.value,visible:!M.value||s.value.isHistoryWindow}),v["context-menu"]?.(r),v.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function Tr(t){let a=new Map;for(let f of t){if(a.has(f.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${f.kind}`);a.set(f.kind,f.component);}let v=Object.freeze([...a.keys()]);return Object.freeze({kinds:v,resolve:f=>a.get(f)})}var br=140,Ir=120;function Dt(t,a){if(t.width<=0||t.height<=0)return 0;let v=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),f=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,v*f/(t.width*t.height))}function wr(t,a){return {x:t.x,y:t.top-a,top:t.top-a,bottom:t.bottom+a,left:t.left,right:t.right,width:t.width,height:t.height+a*2,toJSON:()=>({})}}function Ze(t){let a=Math.max(0,t.scrollIdleMs??br),v=Math.max(0,t.visibilityDwellMs??Ir),f=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),g=Math.max(0,t.revealMarginPx??0),k=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,p=new Map,w=reactive(new Set),R=new Set,o=new Set,d=null,y=null,L=null,x=false,N=false,X=false,E,U;function Y(){E!==void 0&&clearTimeout(E),E=void 0;}function H(){U!==void 0&&clearTimeout(U),U=void 0;}function W(u=false){if(!u&&y!==null||d===null)return;let S=d.getBoundingClientRect(),T=wr(S,g);for(let[c,P]of M){let F=c.getBoundingClientRect();P.ratio=Dt(F,S),P.intersecting=P.ratio>0,P.revealIntersecting=g>0?Dt(F,T)>0:P.intersecting&&P.ratio>=f;}}function s(u){return u.intersecting&&u.ratio>=f}function _(){for(let u of M.values())!u.revealIntersecting||w.has(u.key)||(w.add(u.key),t.onRevealed?.(u.item));}function J(u){let S=new Set(u.map(c=>c.key));if(S.size!==o.size||[...S].some(c=>!o.has(c))){o.clear();for(let c of S)o.add(c);t.onSettledVisibleChange?.(u.map(c=>c.item));}}function j(){if(N||x)return;W(),_();let u=d?.getBoundingClientRect(),S=u===void 0?0:(u.top+u.bottom)/2,T=[...M.entries()].filter(([,c])=>s(c)).sort(([c],[P])=>{let F=c.getBoundingClientRect(),q=P.getBoundingClientRect();return Math.abs((F.top+F.bottom)/2-S)-Math.abs((q.top+q.bottom)/2-S)}).slice(0,k).map(([,c])=>c);J(T);for(let c of T)R.has(c.key)||(R.add(c.key),t.onActivated?.(c.item));}function D(){N||x||(H(),U=setTimeout(()=>{U=void 0,j();},v));}function Q(){N||(B(true),W(),_(),J([]),H(),Y(),E=setTimeout(()=>{E=void 0,B(false),D();},a));}function B(u){x!==u&&(x=u,t.onScrollingChange?.(u));}function $(){d?.removeEventListener("scroll",Q),y?.disconnect(),L?.disconnect(),y=null,L=null,d=null;}function Z(u=true){if(N)return;let S=t.getRoot();if(!(S===d&&d!==null)){if($(),d=S,d===null){u&&!X&&(X=true,Promise.resolve().then(()=>{X=false,N||(Z(false),D());}));return}if(d.addEventListener("scroll",Q,{passive:true}),typeof IntersectionObserver<"u"){y=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.intersecting=c.isIntersecting,P.ratio=c.intersectionRatio,g===0&&(P.revealIntersecting=c.isIntersecting&&c.intersectionRatio>=f));}_(),D();},{root:d,threshold:[0,f,1]}),g>0&&(L=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.revealIntersecting=c.isIntersecting);}_();},{root:d,rootMargin:`${g}px 0px`,threshold:0}));for(let T of M.keys())y.observe(T);for(let T of M.keys())L?.observe(T);}else W(),_();}}function ae(u){w.delete(u),R.delete(u),o.delete(u);}return {register(u,S){if(N)return;let T=t.getKey(u),c=w.has(T),P=R.has(T),F=S===null?void 0:M.get(S);F!==void 0&&F.key!==T&&(p.delete(F.key),M.delete(S),ae(F.key));let q=p.get(T);if(q!==void 0&&q!==S&&(y?.unobserve(q),L?.unobserve(q),M.delete(q),p.delete(T)),S===null){q!==void 0&&(y?.unobserve(q),L?.unobserve(q),M.delete(q),p.delete(T)),ae(T);return}let z=M.get(S);if(z?.key===T&&z.item===u){Z();return}M.set(S,{item:u,key:T,intersecting:z?.key===T?z.intersecting:false,ratio:z?.key===T?z.ratio:0,revealIntersecting:z?.key===T?z.revealIntersecting:false}),p.set(T,S),Z(),y?.observe(S),L?.observe(S),W(true),_(),c&&t.onRevealed?.(u),P?t.onActivated?.(u):D();},isRevealed:u=>w.has(t.getKey(u)),isActivated:u=>R.has(t.getKey(u)),isSettledVisible:u=>o.has(t.getKey(u)),isScrolling:()=>x,notifyScroll:Q,refresh(){Z(),W(true),_(),D();},reset(){Y(),H(),B(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear();},dispose(){N||(Y(),H(),B(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear(),N=true);}}}function Mr(t){let a=new Map,v=new Map,f=false,g=p=>{let w=a.get(p.channel);return w===void 0?p.channel:`${p.channel}\0${w.getKey(p.item)}`},k=Ze({getRoot:t.getRoot,getKey:g,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:p=>{for(let w of a.values())w.onScrollingChange?.(p);},onRevealed:p=>a.get(p.channel)?.onRevealed?.(p.item),onActivated:p=>a.get(p.channel)?.onActivated?.(p.item),onSettledVisibleChange:p=>{for(let[w,R]of a){let o=p.filter(y=>y.channel===w).map(y=>y.item),d=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(d);}}});function M(p){return w=>{if(f)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(p))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${p}`);a.set(p,w);let R=new Map;v.set(p,R);let o=false,d=x=>({channel:p,item:x});function y(){for(let x of R.values())k.register(x.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(x,N){if(o||f)return;let X=w.getKey(x),E=R.get(X);if(N===null){E!==void 0&&(k.register(E.target,null),R.delete(X));return}let U=d(x);R.set(X,{target:U,element:N}),k.register(U,N);},isRevealed:x=>k.isRevealed(d(x)),isActivated:x=>k.isActivated(d(x)),isSettledVisible:x=>k.isSettledVisible(d(x)),isScrolling:k.isScrolling,notifyScroll:k.notifyScroll,refresh:k.refresh,reset:y,dispose(){o||(y(),o=true,a.delete(p),v.delete(p));}}}}return {createFactory:M,refresh:k.refresh,dispose(){if(!f){for(let p of v.values())for(let w of p.values())k.register(w.target,null);v.clear(),a.clear(),k.dispose(),f=true;}}}}export{Ge as ImThreadBodySwitch,ze as ImThreadItems,hr as ImThreadSurface,Ye as ImThreadViewport,ur as createImThreadSurfaceContext,Tr as createMessageRendererRegistry,Mr as createThreadVisibilityTargetGroup,Ze as createThreadVisibilityTargets,cr as provideImThreadSurfaceContext,Gt as useImText,$e as useImThreadSurfaceContext,Yt as useOptionalImThreadReadActions};
@@ -182,8 +182,10 @@ interface ImVideoBody {
182
182
  width: number;
183
183
  /** 视频像素高(BMessage.height)。 */
184
184
  height: number;
185
- /** 时长(秒,BMessage.duration;proto 单位秒,contentType=3|4 有效)。 */
185
+ /** 时长(秒,可含小数);移动端旧消息的毫秒值由 SDK 转换,宿主不得猜单位。 */
186
186
  duration?: number;
187
+ /** SDK 已确认时长为秒的标记;兼容旧缓存时防止重复转换。缺省仍按公开 API 的秒约定传入。 */
188
+ durationUnit?: 'seconds';
187
189
  /** 封面帧原始字节(本地首帧截图,内嵌不单传,对应 BMessage.thumbData bytes)。UI 转 blob 渲染,无需下载即可展示封面。 */
188
190
  thumbData?: Uint8Array;
189
191
  /** 视频文件 MD5(BMessage.MD5;Android 当前未赋值,保留可选)。 */
@@ -4613,7 +4615,7 @@ interface ConversationMessageApi {
4613
4615
  sendText: (text: string, options?: TextMessageOptions) => Promise<SendMessageResult>;
4614
4616
  /** 分享个人、普通群或社群名片;发送目标仍由当前 handle 的精确会话身份决定。 */
4615
4617
  sendContact: (contact: ContactCardInput, options?: ContactMessageOptions) => Promise<SendMessageResult>;
4616
- /** 读取图片 Blob 并进入既有图片上传/加密/Outbox 链路;图片 caption 当前显式 unsupported。 */
4618
+ /** 发送 JPEG、PNG 或 WebP 原图;核对文件头和 MIME,不支持的格式返回 IM_SDK_IMAGE_FORMAT_UNSUPPORTED。图片 caption 当前显式 unsupported。 */
4617
4619
  sendImage: (file: File | Blob, options?: ImageMessageOptions) => Promise<SendMessageResult>;
4618
4620
  /** 读取视频 Blob 并发送;caption 使用已验证的 BMessage.describe。 */
4619
4621
  sendVideo: (file: File | Blob, options?: VideoMessageOptions) => Promise<SendMessageResult>;
@@ -4630,7 +4632,8 @@ interface ConversationMessageApi {
4630
4632
  * SDK 内部回落成普通图片/视频消息(三端一致)。**校验是整条的**——某一项超限会拒绝整条,
4631
4633
  * 因为协议上它就是一条消息,没有「发一半」这种状态。
4632
4634
  *
4633
- * GIF 不能进合集(三端一致),调用方要先按 MIME 把它拆出去走 `sendGif`。
4635
+ * 图片仅支持 JPEG、PNG、WebP,任一项格式不支持时整批返回 IM_SDK_IMAGE_FORMAT_UNSUPPORTED。
4636
+ * GIF 不能进合集,调用方应先用 Chat Kit 分类工具拆出去走 `sendGif`。
4634
4637
  */
4635
4638
  sendMediaAlbum: (items: readonly MediaAlbumItemInput[], options?: MediaAlbumMessageOptions) => Promise<SendMessageResult>;
4636
4639
  /** 发送已经托管在远端的静态贴图;资源和贴图包身份均为必填合同。 */
@@ -5082,6 +5085,19 @@ interface ImMediaTasksApi {
5082
5085
  file: Blob;
5083
5086
  signal?: AbortSignal;
5084
5087
  }) => Promise<(TKind extends 'video' ? VideoPreviewMetadata : ImagePreviewMetadata) | null>;
5088
+ /**
5089
+ * 从本地视频提取仅供页面展示的高清 JPEG 封面,不上传、不下载、不写缓存。
5090
+ *
5091
+ * 长边最多 960px 且不放大原视频;与发送预读共用同一解码执行器。返回 Blob 由宿主创建和释放
5092
+ * object URL,不能作为 localPreviewMetadata 发进消息正文。读取失败返回 null 并记录诊断;
5093
+ * 宿主取消抛 AbortError,运行时失效或未装配能力时抛与 prepareLocalPreview 相同的明确错误。
5094
+ * @param input.file 本地或已解密的完整视频 Blob。
5095
+ * @param input.signal 页面卸载、换源或切会话时取消这次抽帧。
5096
+ */
5097
+ prepareLocalVideoPoster: (input: {
5098
+ file: Blob;
5099
+ signal?: AbortSignal;
5100
+ }) => Promise<Blob | null>;
5085
5101
  }
5086
5102
 
5087
5103
  /**
@@ -6289,7 +6305,7 @@ type ImLocale = 'en-US' | 'th-TH' | 'vi-VN' | 'zh-CN' | 'zh-TW';
6289
6305
  * 二期收敛:kit 框架无关层不再直接产中文,改产本联合里的码 + 参数(如 {reason}/{label}/{size}),由宿主经 im-i18n 渲染。
6290
6306
  * 动态原始报错(error.message)作为 `{reason}` 参数拼接,不入 catalog(属诊断,不翻译)。
6291
6307
  */
6292
- type ImServiceTextKey = 'common.notConnected' | 'common.selectOrOpenConversation' | 'common.conversationTypeNotReady' | 'common.conversationNotReady' | `recall.${RecallFailReason}` | `edit.${EditFailReason}` | 'localDelete.done' | 'localDelete.notFound' | 'localDelete.inFlight' | 'localDelete.failed' | 'channelDelete.notFound' | 'channelDelete.unsupported' | 'channelDelete.notSent' | 'channelDelete.unavailable' | 'channelDelete.forbidden' | 'channelDelete.timeout' | 'channelDelete.failed' | 'channelDelete.disconnected' | 'directBlock.contactRequired' | 'groupBlock.left' | 'groupBlock.removed' | 'groupBlock.dismissed' | 'groupBlock.unknownRestricted' | 'channelBlock.guest' | 'channelBlock.left' | 'channelBlock.removed' | 'channelBlock.dismissed' | 'channelBlock.muted' | 'channelBlock.allMembersMuted' | 'channelBlock.currentUserMuted' | 'channelBlock.blacklisted' | 'channelBlock.unknownRestricted' | 'channelProfile.loadFailed' | 'channelProfile.notFound' | 'channelProfile.retryAction' | 'channelMembers.title' | 'channelMembers.searchPlaceholder' | 'channelMembers.loading' | 'channelMembers.loadFailed' | 'channelMembers.retryAction' | 'channelMembers.empty' | 'channelMembers.loadingMore' | 'channelMembers.loadMoreFailed' | 'channelMembers.exhausted' | 'channelMembers.loadMoreAction' | 'label.image' | 'label.video' | 'label.file' | 'label.sticker' | 'send.failed' | 'send.retryFailed' | 'send.cancelFailed' | 'send.mediaFailed' | 'send.mediaEmpty' | 'send.mediaCancelled' | 'send.mediaCountLimit' | 'send.mediaTooLarge' | 'send.mediaFormatMismatch' | 'send.videoTooLong' | 'send.videoDurationUnavailable' | 'send.voiceEmpty' | 'send.voiceStorageNotConfigured' | 'send.voiceCancelled' | 'send.voiceFailed' | 'media.uploadWaiting' | 'media.voiceNotReady' | 'media.voiceLoadEmpty' | 'media.voiceLoadFailed' | 'media.videoOpenEmpty' | 'media.videoLoadFailed' | 'media.imageInvalid' | 'media.imageLoadFailed' | 'media.fileDownloadEmpty' | 'media.fileDownloadFailed' | 'conversation.muteEnableFailed' | 'conversation.muteDisableFailed' | 'conversation.backgroundLoadFailed' | 'read.markReadFailed' | 'storage.failed' | 'sync.failed' | 'draft.saveFailed' | 'history.returnLatestFailed' | 'pinned.forbidden' | 'pinned.network' | 'pinned.contract' | 'pinned.unsupported' | 'pinned.failed' | 'pinned.previewUnavailable' | 'pinned.locateFailed' | 'pinned.recalled' | 'pinned.deleted' | 'pinned.protected' | 'pinned.pinAction' | 'pinned.unpinAction' | 'pinned.unpinConfirm' | 'pinned.cancelAction' | 'lifecycle.missingLoginState' | 'lifecycle.prepareFailed' | 'lifecycle.missingConnectParams' | 'lifecycle.connectFailed' | 'lifecycle.disposed' | 'forward.emptyInput' | 'forward.allSkipped' | 'forward.partialSkipped' | 'forward.done' | 'forward.failed';
6308
+ type ImServiceTextKey = 'common.notConnected' | 'common.selectOrOpenConversation' | 'common.conversationTypeNotReady' | 'common.conversationNotReady' | `recall.${RecallFailReason}` | `edit.${EditFailReason}` | 'localDelete.done' | 'localDelete.notFound' | 'localDelete.inFlight' | 'localDelete.failed' | 'channelDelete.notFound' | 'channelDelete.unsupported' | 'channelDelete.notSent' | 'channelDelete.unavailable' | 'channelDelete.forbidden' | 'channelDelete.timeout' | 'channelDelete.failed' | 'channelDelete.disconnected' | 'directBlock.contactRequired' | 'groupBlock.left' | 'groupBlock.removed' | 'groupBlock.dismissed' | 'groupBlock.unknownRestricted' | 'channelBlock.guest' | 'channelBlock.left' | 'channelBlock.removed' | 'channelBlock.dismissed' | 'channelBlock.muted' | 'channelBlock.allMembersMuted' | 'channelBlock.currentUserMuted' | 'channelBlock.blacklisted' | 'channelBlock.unknownRestricted' | 'channelProfile.loadFailed' | 'channelProfile.notFound' | 'channelProfile.retryAction' | 'channelMembers.title' | 'channelMembers.searchPlaceholder' | 'channelMembers.loading' | 'channelMembers.loadFailed' | 'channelMembers.retryAction' | 'channelMembers.empty' | 'channelMembers.loadingMore' | 'channelMembers.loadMoreFailed' | 'channelMembers.exhausted' | 'channelMembers.loadMoreAction' | 'label.image' | 'label.video' | 'label.file' | 'label.sticker' | 'send.failed' | 'send.retryFailed' | 'send.cancelFailed' | 'send.mediaFailed' | 'send.mediaEmpty' | 'send.mediaCancelled' | 'send.mediaCountLimit' | 'send.mediaTooLarge' | 'send.mediaFormatMismatch' | 'send.imageFormatUnsupported' | 'send.videoTooLong' | 'send.videoDurationUnavailable' | 'send.voiceEmpty' | 'send.voiceStorageNotConfigured' | 'send.voiceCancelled' | 'send.voiceFailed' | 'media.uploadWaiting' | 'media.voiceNotReady' | 'media.voiceLoadEmpty' | 'media.voiceLoadFailed' | 'media.videoOpenEmpty' | 'media.videoLoadFailed' | 'media.imageInvalid' | 'media.imageLoadFailed' | 'media.fileDownloadEmpty' | 'media.fileDownloadFailed' | 'conversation.muteEnableFailed' | 'conversation.muteDisableFailed' | 'conversation.backgroundLoadFailed' | 'read.markReadFailed' | 'storage.failed' | 'sync.failed' | 'draft.saveFailed' | 'history.returnLatestFailed' | 'pinned.forbidden' | 'pinned.network' | 'pinned.contract' | 'pinned.unsupported' | 'pinned.failed' | 'pinned.previewUnavailable' | 'pinned.locateFailed' | 'pinned.recalled' | 'pinned.deleted' | 'pinned.protected' | 'pinned.pinAction' | 'pinned.unpinAction' | 'pinned.unpinConfirm' | 'pinned.cancelAction' | 'lifecycle.missingLoginState' | 'lifecycle.prepareFailed' | 'lifecycle.missingConnectParams' | 'lifecycle.connectFailed' | 'lifecycle.disposed' | 'forward.emptyInput' | 'forward.allSkipped' | 'forward.partialSkipped' | 'forward.done' | 'forward.failed';
6293
6309
 
6294
6310
  /** 会话列表摘要的框架无关分段;宿主可自行决定表情使用图片、文本或其它组件呈现。 */
6295
6311
  type ConversationListPreviewSegment = {
@@ -7035,7 +7051,9 @@ declare namespace pinnedMessage_service {
7035
7051
  }
7036
7052
 
7037
7053
  type ConversationCapabilityAction = 'conversation.openProfile' | 'conversation.readHistory' | 'conversation.listPreferences' | 'composer.send' | 'composer.mentionAll' | 'profile.edit' | 'relationship.manage' | 'members.view' | 'members.manage' | 'members.invite' | 'members.remove' | 'members.setAdmin' | 'ownership.transfer' | 'conversation.leave' | 'channel.manageMute' | 'channel.setMemberPrivateChat' | 'channel.dismiss';
7038
- type MessageCapabilityAction = 'message.reply' | 'message.recall' | 'message.edit' | 'message.pin' | 'message.unpin' | 'message.deleteLocal' | 'message.deleteForEveryone' | 'message.forward' | 'message.favorite' | 'message.multiSelect';
7054
+ type MessageCapabilityAction = 'message.reply'
7055
+ /** 新增或替换 Reaction;不控制已有回应展示或移除自己的回应。 */
7056
+ | 'message.react' | 'message.recall' | 'message.edit' | 'message.pin' | 'message.unpin' | 'message.deleteLocal' | 'message.deleteForEveryone' | 'message.forward' | 'message.favorite' | 'message.multiSelect';
7039
7057
  type MemberTargetCapabilityAction = 'members.removeTarget' | 'members.editNicknameTarget' | 'members.setAdminTarget' | 'members.unsetAdminTarget';
7040
7058
  interface MessageCapabilityInput {
7041
7059
  snapshot: ConversationCapabilitySnapshot;
@@ -7155,6 +7173,27 @@ declare namespace forward_service {
7155
7173
  export type { forward_service_ForwardCommandHooks as ForwardCommandHooks, forward_service_ImForwardOperationResult as ImForwardOperationResult };
7156
7174
  }
7157
7175
 
7176
+ /** 媒体入口的去向;不支持的图片必须提示用户,不能自动作为附件发送。 */
7177
+ type MediaFileClassification = 'image' | 'video' | 'sticker' | 'file' | 'unsupported-image';
7178
+ /**
7179
+ * PC/H5 选图、拖拽和批量发送共用的分类规则。GIF 保持原有签名校验和失败提示路径。
7180
+ * 普通图片复用 SDK 文件头白名单;MIME 缺失时仍识别有效图片,并按图片扩展名拦截不支持的文件。
7181
+ * 读取失败会抛给调用方,不能将无法读取的图片静默改成附件。
7182
+ *
7183
+ * @example
7184
+ * await classifyMediaFile(svgFile); // 'unsupported-image',由宿主提示改用文件发送
7185
+ * await classifyMediaFile(pngFile); // 'image',即使 MIME 为空也按文件头识别
7186
+ */
7187
+ declare function classifyMediaFile(file: File): Promise<MediaFileClassification>;
7188
+ type GifFileClassification = 'gif' | 'not-gif' | 'invalid-gif';
7189
+ /**
7190
+ * 同时核对 MIME 与文件头,避免 GIF 合同冲突的文件回落到普通 IMAGE 链路。
7191
+ *
7192
+ * 浏览器 MIME 可以为空;一旦 MIME 或文件头任一方声明 GIF,另一方就必须一致。
7193
+ */
7194
+ declare function classifyGifFile(file: Blob): Promise<GifFileClassification>;
7195
+ declare function isGifFile(file: Blob): Promise<boolean>;
7196
+
7158
7197
  /**
7159
7198
  * 为宿主手里的本地图片/视频文件预读展示元信息(尺寸、视频时长、视频首帧封面 JPEG 字节)。
7160
7199
  *
@@ -7744,15 +7783,6 @@ declare function fetchConversationVoiceBatch(runtime: ChatRuntime, input: Browse
7744
7783
  */
7745
7784
  declare function fetchNextConversationSearchBatch(runtime: ChatRuntime, pageToken: ImPageToken): Promise<SearchBatchResult>;
7746
7785
 
7747
- type GifFileClassification = 'gif' | 'not-gif' | 'invalid-gif';
7748
- /**
7749
- * 同时核对 MIME 与文件头,避免 GIF 合同冲突的文件回落到普通 IMAGE 链路。
7750
- *
7751
- * 浏览器 MIME 可以为空;一旦 MIME 或文件头任一方声明 GIF,另一方就必须一致。
7752
- */
7753
- declare function classifyGifFile(file: Blob): Promise<GifFileClassification>;
7754
- declare function isGifFile(file: Blob): Promise<boolean>;
7755
-
7756
7786
  /**
7757
7787
  * 消息输入区的发送命令:文本、图片、视频、文件、语音、批量发送、取消上传和失败重试。
7758
7788
  *
@@ -8691,5 +8721,5 @@ declare function resampleWaveform(data: readonly number[], targetCount: number):
8691
8721
  */
8692
8722
  declare function placeholderWaveform(seed: string, count: number): number[];
8693
8723
 
8694
- export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, MINI_PROGRAM_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, createChatRuntime, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createNewMessageBadgeController, createThreadItems, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isPinnedMessageProtected, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, message_service as messageService, normalizeLinkHref, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveChannelMiniProgramRelIcon, resolveChannelMiniProgramRelName, resolveChannelMiniProgramRelOpenSurface, resolveChannelMiniProgramRelUrl, resolveChannelPinnedGameCopy, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageTimelineTimestamp, resolveMiniProgramFloatLinkUrl, resolveMiniProgramOpenUrl, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveUnicodeEmoji, resolveVisibleChannelMiniProgramRels, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, sortChannelMiniProgramFloatingItems, spikeCountForDuration, supportsConversationMention, unicodeEmojiTextFromCode };
8695
- export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChannelMiniProgramOpenGame, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationSearchCategory, CreateThreadItemsInput, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, FormatTimeDisplayContext, ForwardCommandHooks, GifFileClassification, HighlightSegment, ImChannelMemberPresentation, ImChannelMentionPresentation, ImChannelProfilePresentation, ImForwardOperationResult, ImGroupMemberPresentation, ImMediaBatchSendResult, ImMessageActionResult, ImMessageBodyKind, ImMessageView, ImPinnedMessageActionResult, ImPinnedMessageSnapshot, ImProfileAccessDestination, ImQuotedMessagePresentation, ImTextResolver, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MessageCapabilityAction, MessageCapabilityInput, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MiniProgramHostLocale, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolvedMediaPresentation, RichExtraSegment, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SendCapabilityMode, SendCommandHooks, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, UnicodeEmojiEntry, VisibleChannelMiniProgramRels };
8724
+ export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, MINI_PROGRAM_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, classifyMediaFile, createChatRuntime, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createNewMessageBadgeController, createThreadItems, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isPinnedMessageProtected, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, message_service as messageService, normalizeLinkHref, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveChannelMiniProgramRelIcon, resolveChannelMiniProgramRelName, resolveChannelMiniProgramRelOpenSurface, resolveChannelMiniProgramRelUrl, resolveChannelPinnedGameCopy, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageTimelineTimestamp, resolveMiniProgramFloatLinkUrl, resolveMiniProgramOpenUrl, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveUnicodeEmoji, resolveVisibleChannelMiniProgramRels, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, sortChannelMiniProgramFloatingItems, spikeCountForDuration, supportsConversationMention, unicodeEmojiTextFromCode };
8725
+ export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChannelMiniProgramOpenGame, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationSearchCategory, CreateThreadItemsInput, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, FormatTimeDisplayContext, ForwardCommandHooks, GifFileClassification, HighlightSegment, ImChannelMemberPresentation, ImChannelMentionPresentation, ImChannelProfilePresentation, ImForwardOperationResult, ImGroupMemberPresentation, ImMediaBatchSendResult, ImMessageActionResult, ImMessageBodyKind, ImMessageView, ImPinnedMessageActionResult, ImPinnedMessageSnapshot, ImProfileAccessDestination, ImQuotedMessagePresentation, ImTextResolver, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaFileClassification, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MessageCapabilityAction, MessageCapabilityInput, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MiniProgramHostLocale, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolvedMediaPresentation, RichExtraSegment, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SendCapabilityMode, SendCommandHooks, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, UnicodeEmojiEntry, VisibleChannelMiniProgramRels };
package/dist/chat-kit.js CHANGED
@@ -1 +1 @@
1
- export{p as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,o as DEFAULT_LOADING_SHOW_DELAY_MS,d as MINI_PROGRAM_LANG_NUMBERS,H as SPIKE_STEP,D as calculateMediaBox,s as canPromoteMediaPresentationSource,u as captureRuntimeClientOperation,t as captureRuntimeOperation,m as channelMiniProgramRelKey,q as createDelayedLoadingIndicator,B as createLinkMatcher,e as csvIncludes,c as decideChannelMiniProgramRelOpen,F as formatFileSize,E as formatMediaDuration,G as getFileExtension,A as hasLinkCandidate,y as highlightSegments,v as mediaService,z as normalizeLinkHref,K as placeholderWaveform,w as readService,J as resampleWaveform,r as resolveBestMediaPresentationSource,g as resolveChannelMiniProgramRelIcon,f as resolveChannelMiniProgramRelName,i as resolveChannelMiniProgramRelOpenSurface,h as resolveChannelMiniProgramRelUrl,j as resolveChannelPinnedGameCopy,n as resolveConversationListPresentation,C as resolveMediaPresentation,b as resolveMiniProgramFloatLinkUrl,a as resolveMiniProgramOpenUrl,x as resolveQuotedMessagePresentation,l as resolveVisibleChannelMiniProgramRels,k as sortChannelMiniProgramFloatingItems,I as spikeCountForDuration}from'./chunk-WYQXQOLW.js';export{j as DEFAULT_EMOJI_ASSET_BASE,i as EMOJI_CATALOG,c as EMOJI_GAME_DICE_STABLE_KEY,b as EMOJI_GAME_RPS_STABLE_KEY,m as EMOJI_TOKEN_RE,L as MAX_BATCH_FILES,a as MAX_RECENT_EMOJI_COUNT,g as UNICODE_EMOJI_CATALOG,K as blockReasonForChannelSession,J as blockReasonForChannelState,Q as blockReasonForGroupState,T as blockReasonForSession,E as canEditMessage,u as canPinChannelMessage,t as canPinGroupMessage,v as canPinMessage,D as canRecallMessage,aa as cancelMediaUpload,O as classifyGifFile,s as createChatRuntime,p as createEmojiMatcher,G as decideConversationAction,I as decideMemberTargetAction,H as decideMessageAction,l as emojiAssetUrl,n as emojiUrlByCode,Aa as fetchConversationFileBatch,Ba as fetchConversationImageBatch,ya as fetchConversationMessageBatch,Ca as fetchConversationVideoBatch,Da as fetchConversationVoiceBatch,Ea as fetchNextConversationSearchBatch,da as forwardService,o as hasEmojiCandidate,P as isGifFile,w as isPinnedMessageProtected,X as isVoiceStorageConfigured,M as mediaBatchBudgetBytes,ia as messageService,e as parseUnicodeEmojiCode,na as pinnedMessageService,d as prependRecentEmoji,xa as profileService,W as replaceInterruptedMediaFile,R as requiresConversationEncryption,z as resolveChannelMemberAvatarUrl,y as resolveChannelMemberDisplayName,k as resolveEmojiToken,C as resolveFriendDisplayName,oa as resolveImProfileAccessDestination,x as resolveMemberDisplayName,r as resolveMessageNotificationDecision,B as resolvePublicNickname,A as resolveSenderAvatarUrl,q as resolveStandaloneEmojiMessage,h as resolveUnicodeEmoji,ba as retryMessage,N as runMediaSendBatch,$ as sendAsFilesBatch,F as sendBlockReasonForDecision,Z as sendMediaAlbum,V as sendMediaFile,_ as sendMediaFilesBatch,U as sendText,Y as sendVoice,S as supportsConversationMention,f as unicodeEmojiTextFromCode}from'./chunk-V7ULSSTZ.js';export{C as createNewMessageBadgeController,i as createThreadItems,f as formatChatDateSeparator,e as formatConversationDisplayTime,c as getLocalDayKey,l as isMessageLocateScrollProtected,v as isMessageTailChangeFromOlderWindowTrim,k as isMessageViewportMeasurable,B as isMessageVisibleForNewMessageBadge,x as loadOlderUntilBoundary,p as refreshPrependMessageAnchorPosition,j as resolveCenteredMessageScrollTop,a as resolveDisplayTimestamp,g as resolveImThreadActiveDate,h as resolveMessageBodyKind,b as resolveMessageTimelineTimestamp,n as resolvePrependMessageAnchor,q as resolvePrependMessageAnchorAdjustment,o as resolvePrependMessageAnchorPosition,s as resolveSurvivingMessageAnchorAdjustment,r as resolveVisibleMessageAnchorPositions,t as shouldCompleteInitialViewport,y as shouldFillInitialHistoryViewport,u as shouldFollowIncomingMessage,z as shouldLoadNewerHistoryPage,m as shouldPrefetchOlderHistory,w as shouldRestoreMessageViewportFocus,d as shouldShowChatDateSeparator,A as shouldTrackRemoteMessageForBadge}from'./chunk-UNGWXAYA.js';import'./chunk-VMKTMZ3K.js';import'./chunk-SVJGRV4M.js';import'./chunk-GMVR64GN.js';export{ra as canTransmit,pa as canTransmitByType,qa as canTransmitContent,oa as requiresForwardTypeConfirmation}from'./chunk-LX7YEO5G.js';import'./chunk-WOT6VMZA.js';
1
+ export{p as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,o as DEFAULT_LOADING_SHOW_DELAY_MS,d as MINI_PROGRAM_LANG_NUMBERS,H as SPIKE_STEP,D as calculateMediaBox,s as canPromoteMediaPresentationSource,u as captureRuntimeClientOperation,t as captureRuntimeOperation,m as channelMiniProgramRelKey,q as createDelayedLoadingIndicator,B as createLinkMatcher,e as csvIncludes,c as decideChannelMiniProgramRelOpen,F as formatFileSize,E as formatMediaDuration,G as getFileExtension,A as hasLinkCandidate,y as highlightSegments,v as mediaService,z as normalizeLinkHref,K as placeholderWaveform,w as readService,J as resampleWaveform,r as resolveBestMediaPresentationSource,g as resolveChannelMiniProgramRelIcon,f as resolveChannelMiniProgramRelName,i as resolveChannelMiniProgramRelOpenSurface,h as resolveChannelMiniProgramRelUrl,j as resolveChannelPinnedGameCopy,n as resolveConversationListPresentation,C as resolveMediaPresentation,b as resolveMiniProgramFloatLinkUrl,a as resolveMiniProgramOpenUrl,x as resolveQuotedMessagePresentation,l as resolveVisibleChannelMiniProgramRels,k as sortChannelMiniProgramFloatingItems,I as spikeCountForDuration}from'./chunk-D2FFU7J5.js';export{j as DEFAULT_EMOJI_ASSET_BASE,i as EMOJI_CATALOG,c as EMOJI_GAME_DICE_STABLE_KEY,b as EMOJI_GAME_RPS_STABLE_KEY,m as EMOJI_TOKEN_RE,L as MAX_BATCH_FILES,a as MAX_RECENT_EMOJI_COUNT,g as UNICODE_EMOJI_CATALOG,K as blockReasonForChannelSession,J as blockReasonForChannelState,R as blockReasonForGroupState,U as blockReasonForSession,E as canEditMessage,u as canPinChannelMessage,t as canPinGroupMessage,v as canPinMessage,D as canRecallMessage,ba as cancelMediaUpload,P as classifyGifFile,O as classifyMediaFile,s as createChatRuntime,p as createEmojiMatcher,G as decideConversationAction,I as decideMemberTargetAction,H as decideMessageAction,l as emojiAssetUrl,n as emojiUrlByCode,Ba as fetchConversationFileBatch,Ca as fetchConversationImageBatch,za as fetchConversationMessageBatch,Da as fetchConversationVideoBatch,Ea as fetchConversationVoiceBatch,Fa as fetchNextConversationSearchBatch,ea as forwardService,o as hasEmojiCandidate,Q as isGifFile,w as isPinnedMessageProtected,Y as isVoiceStorageConfigured,M as mediaBatchBudgetBytes,ja as messageService,e as parseUnicodeEmojiCode,oa as pinnedMessageService,d as prependRecentEmoji,ya as profileService,X as replaceInterruptedMediaFile,S as requiresConversationEncryption,z as resolveChannelMemberAvatarUrl,y as resolveChannelMemberDisplayName,k as resolveEmojiToken,C as resolveFriendDisplayName,pa as resolveImProfileAccessDestination,x as resolveMemberDisplayName,r as resolveMessageNotificationDecision,B as resolvePublicNickname,A as resolveSenderAvatarUrl,q as resolveStandaloneEmojiMessage,h as resolveUnicodeEmoji,ca as retryMessage,N as runMediaSendBatch,aa as sendAsFilesBatch,F as sendBlockReasonForDecision,_ as sendMediaAlbum,W as sendMediaFile,$ as sendMediaFilesBatch,V as sendText,Z as sendVoice,T as supportsConversationMention,f as unicodeEmojiTextFromCode}from'./chunk-H7AM5DTT.js';export{C as createNewMessageBadgeController,i as createThreadItems,f as formatChatDateSeparator,e as formatConversationDisplayTime,c as getLocalDayKey,l as isMessageLocateScrollProtected,v as isMessageTailChangeFromOlderWindowTrim,k as isMessageViewportMeasurable,B as isMessageVisibleForNewMessageBadge,x as loadOlderUntilBoundary,p as refreshPrependMessageAnchorPosition,j as resolveCenteredMessageScrollTop,a as resolveDisplayTimestamp,g as resolveImThreadActiveDate,h as resolveMessageBodyKind,b as resolveMessageTimelineTimestamp,n as resolvePrependMessageAnchor,q as resolvePrependMessageAnchorAdjustment,o as resolvePrependMessageAnchorPosition,s as resolveSurvivingMessageAnchorAdjustment,r as resolveVisibleMessageAnchorPositions,t as shouldCompleteInitialViewport,y as shouldFillInitialHistoryViewport,u as shouldFollowIncomingMessage,z as shouldLoadNewerHistoryPage,m as shouldPrefetchOlderHistory,w as shouldRestoreMessageViewportFocus,d as shouldShowChatDateSeparator,A as shouldTrackRemoteMessageForBadge}from'./chunk-YUPKU2L7.js';import'./chunk-BIFDS3MH.js';import'./chunk-DVQGXZ6S.js';import'./chunk-FQJBDSXT.js';export{ra as canTransmit,pa as canTransmitByType,qa as canTransmitContent,oa as requiresForwardTypeConfirmation}from'./chunk-O7GQQMEW.js';import'./chunk-WOT6VMZA.js';