k2-im 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/chat-kit-pinia.d.ts +172 -1
- package/dist/chat-kit-pinia.js +1 -1
- package/dist/chat-kit-vue.d.ts +1 -1
- package/dist/chat-kit-vue.js +1 -1
- package/dist/chat-kit.d.ts +172 -1
- package/dist/chat-kit.js +1 -1
- package/dist/{chunk-TRRJA4DI.js → chunk-54BDLB6M.js} +1 -1
- package/dist/chunk-6QR5GVQ3.js +7 -0
- package/dist/chunk-BO5YFCS4.js +1 -0
- package/dist/chunk-DFE2F575.js +2 -0
- package/dist/{chunk-ATIQZ5XZ.js → chunk-MKV7J6WB.js} +1 -1
- package/dist/chunk-TD3JY2WE.js +1 -0
- package/dist/{chunk-VP466VS6.js → chunk-TQF5HUEX.js} +1 -1
- package/dist/i18n.js +1 -1
- package/dist/index.d.ts +173 -2
- package/dist/index.js +1 -1
- package/dist/sdk.d.ts +173 -2
- package/dist/sdk.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-A4IDVF3H.js +0 -2
- package/dist/chunk-GTRMHOHX.js +0 -7
- package/dist/chunk-MHIB4PGT.js +0 -1
- package/dist/chunk-RZBGTY6A.js +0 -1
package/dist/chat-kit-vue.d.ts
CHANGED
|
@@ -776,7 +776,7 @@ type ImDiagnosticLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
|
776
776
|
/** 诊断产生层;同一 operation 可跨层复用 traceId/operationId。 */
|
|
777
777
|
type ImDiagnosticLayer = 'sdk' | 'core' | 'chat-kit' | 'pinia' | 'worker';
|
|
778
778
|
/** 稳定诊断分类。分类用于构造 payload 前过滤,不能作为业务状态分支。 */
|
|
779
|
-
type ImDiagnosticCategory = 'session' | 'connection' | 'protocol' | 'sync' | 'conversation' | 'history' | 'message' | 'outbox' | 'draft' | 'search' | 'media' | 'profile' | 'storage' | 'crypto';
|
|
779
|
+
type ImDiagnosticCategory = 'session' | 'connection' | 'protocol' | 'sync' | 'conversation' | 'history' | 'message' | 'outbox' | 'draft' | 'search' | 'media' | 'profile' | 'storage' | 'crypto' | 'call';
|
|
780
780
|
/** 经过安全过滤的错误快照;不会保留原始 cause 引用。 */
|
|
781
781
|
interface ImDiagnosticError {
|
|
782
782
|
name?: string;
|
package/dist/chat-kit-vue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h,C,p,i,q,m,z,j,g,B,o}from'./chunk-ATIQZ5XZ.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-VP466VS6.js';import'./chunk-A4IDVF3H.js';import'./chunk-GTRMHOHX.js';import'./chunk-MHIB4PGT.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment}from'vue';function Vt(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}),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 mt=Symbol("ImThreadReadActions");function gt(t){provide(mt,t);}function Dt(){return inject(mt,void 0)}var _e=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:T}){return gt(t.readActions),()=>{let u=h(t.message),f=t.rendererRegistry.resolve(u);return f!==void 0?h$1(f,{...a,message:t.message,presentation:t.presentation}):T["unsupported-body"]!==void 0?T["unsupported-body"]({kind:u,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":u,"aria-hidden":"true"})}}});var je=Symbol("ImThreadViewportRegistration");function vt(){return inject(je,void 0)}var Ke=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 T=vt();function u(o,l){let b=Array.isArray(l)?l:[l];return b.length===1&&isVNode(b[0])?cloneVNode(b[0],{key:o}):h$1(Fragment,{key:o},b)}function f(o){return l=>{T?.registerMessageNode(o,l instanceof HTMLElement?l:null);}}function V(o,l){return b=>{T?.registerDateNode(o,l,b instanceof HTMLElement?b:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function m(o){let l=V(o.key,o.label);return a["date-separator"]?.({item:o,setElement:l})??h$1("div",{ref:l,"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 l=f(o.message.id);return a.item!==void 0?a.item({item:o,setElement:l}):a.message!==void 0?a.message({item:o,setElement:l}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:l})??h$1("article",{ref:l,"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:l})??h$1("article",{ref:l,"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:l}):h$1("article",{ref:l,"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(_e,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:b=>a["unsupported-body"]?.(b)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?u(o.key,a.item({item:o})):u(o.key,M(o));case "date-separator":return a.item!==void 0?u(o.key,a.item({item:o,setElement:V(o.key,o.label)})):u(o.key,m(o));case "entry-unread":return a.item!==void 0?u(o.key,a.item({item:o})):u(o.key,w(o));case "system":case "message":return u(o.key,R(o))}return o}))}});var yt=120,qt=500,Ee=.5,zt=8,Ue=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:T,slots:u}){let f=ref(null),V=ref(null),M=new Map,m$1=new Map,w=new Set,R=new Map,o$1=0,l=[],b,B$1,S,L=false,F,C$1=new Set,_=false,U,z$1="",J=1,s=false,W=false,X=true,A=false,G=false,Y=false,H=0,Z=-1,k,ee,c,h,p$1,v=ref(true),D=ref(0),j$1=C(e=>{D.value=e,a("new-message-count",e);});function q$1(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function $(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let I=i.getBoundingClientRect(),P=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:I.top,bottom:I.bottom,anchorTop:P?.getBoundingClientRect().top??I.top}]})}function Ae(e="",n=1){let i=Math.min(1,Math.max(0,n));z$1!==""&&z$1!==e&&R.get(z$1)?.element.style.removeProperty("opacity"),z$1=e,J=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function Re(){Ae();}function Oe(){let e=f.value;if(_||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,E])=>e.contains(E.element)).map(([E,K])=>{let Q=K.element.getBoundingClientRect();return {key:E,label:K.label,top:Q.top,height:Q.height}}).sort((E,K)=>E.top-K.top),i=e.getBoundingClientRect(),I=n.find(E=>E.height>0)?.height??28,P=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:I});if(P===null){Re(),a("active-date-change",null);return}Ae(P.inlineDateKey,P.inlineOpacity),a("active-date-change",P);}function oe(){let e=f.value;if(_||e===null)return;let n=e.getBoundingClientRect(),i=S!==void 0&&L?t.messageIds.filter(K=>w.has(K)):t.messageIds,I=$(i);if(S!==void 0&&L&&I.length===0){v.value=q$1(e);return}let P=I.filter(K=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:K.top,messageBottom:K.bottom,margin:t.visibleMargin})).map(K=>K.id),E=P.length!==l.length||P.some((K,Q)=>l[Q]!==K);l=Object.freeze(P),b=o(I,{top:n.top,bottom:n.bottom}),j$1.acknowledgeVisible(P),v.value=q$1(e),E&&a("visible-range",l),a("settled",{visibleMessageIds:l,...l.length===0?{}:{newestVisibleMessageId:l[l.length-1]},isAtBottom:v.value,newMessageCount:D.value});}function re(e){if(C$1.add(e),F!==void 0)return;let n=()=>{F=void 0;let i=[...C$1];C$1.clear(),i.forEach(I=>I());};typeof globalThis.requestAnimationFrame=="function"?F=globalThis.requestAnimationFrame(n):F=globalThis.setTimeout(n,0);}function He(){F!==void 0&&(typeof F=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(F):globalThis.clearTimeout(F),F=void 0,C$1.clear());}function ae(){re(oe);}function Se(){let e=f.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o($(),{top:n.top,bottom:n.bottom});i!==void 0&&(b=i);}function fe(){let e=f.value;if(_||e===null)return;let n=e.scrollTop,i=U,I=false;if(i!==void 0){let E=Math.abs(n-i.targetTop)<=Ee;I=i.behavior==="smooth"||E,(i.behavior!=="smooth"||E)&&(U=void 0);}!I&&!A&&h===void 0&&n!==o$1&&(A=true,G=true,H+=1);let P=A&&!I&&n!==o$1;if(P&&(a("user-scroll"),re(Oe)),A&&!Y&&N(),!X&&G&&H!==Z&&n<o$1&&n>d()&&(X=true),h!==void 0&&!I)if(A){let E=ge();E!==void 0&&(h.expectedOffset=E);}else be(),Pe();X&&h===void 0&&!W&&!t.loadingOlder&&P&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&(Se(),X=false,Z=H,W=true,a("reach-start"),re(()=>{t.loadingOlder||(W=false);})),!s&&!t.loadingOlder&&!t.loadingNewer&&t.hasNewer&&P&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:q$1(e),isHistoryWindow:t.hasNewer,isPageSettling:I})&&(s=true,v.value=false,a("reach-end"),re(()=>{t.loadingNewer||(s=false);})),o$1=n,ae();}function ye(e,n="auto"){U={targetTop:e,behavior:n};}function se(e){let n=h,i=V.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=Ee?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 le(){p$1!==void 0&&(clearTimeout(p$1),p$1=void 0);let e=V.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),h=void 0,U=void 0;}function ge(){let e=f.value,n=h;if(e===null||n===void 0)return;let i=$().find(I=>I.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function be(){let e=h,n=ge();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=Ee||(se(e.visualOffset+i),e.committed=false,e.attempts=0);}function pe(){p$1!==void 0&&clearTimeout(p$1),p$1=setTimeout(()=>{p$1=void 0,!(A||h?.committed!==true)&&le();},qt);}function ve(){let e=f.value,n=h;if(_||e===null||n===void 0||A)return;let i=n.visualOffset;if(Math.abs(i)<=Ee){n.committed=true,pe();return}let I=Math.max(0,e.scrollHeight-e.clientHeight),P=Math.min(I,Math.max(0,e.scrollTop-i));if(ye(P),e.scrollTop=P,Math.abs(e.scrollTop-P)>Ee){U=void 0,n.committed=false,n.attempts+=1,n.attempts<zt?Pe():(le(),U=void 0,o$1=e.scrollTop);return}se(0),o$1=e.scrollTop,n.expectedOffset=ge()??n.expectedOffset,n.committed=true,n.attempts=0,pe();}function Pe(){p$1!==void 0&&clearTimeout(p$1),p$1=setTimeout(()=>{p$1=void 0,ve();},yt);}function xe(e){e!==void 0&&(h===void 0&&(h={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),be(),!A&&ve());}function r(e){let n=f.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),I=q(e,$(),{top:i.top,bottom:i.bottom});if(I!==void 0){let P=Math.max(0,n.scrollHeight-n.clientHeight),E=Math.min(P,Math.max(0,n.scrollTop+I));ye(E),n.scrollTop=E,o$1=n.scrollTop;}}function d(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function g$1(){U?.behavior==="smooth"&&(U=void 0),G=false,A||(A=true,H+=1),k!==void 0&&(clearTimeout(k),k=void 0);}function y(){let e=f.value;X||H===Z||e===null||e.scrollTop<=d()||(h?.committed===true&&le(),h===void 0&&(X=true));}function O(){k!==void 0&&(clearTimeout(k),k=void 0),le(),A=false,G=false,Y=false,ee=void 0,c=void 0,H+=1,Z=-1,X=true,W=false,s=false,U=void 0;}function x(){Y||(k!==void 0&&(clearTimeout(k),k=void 0),A=false,G=false,h!==void 0&&(h.attempts=0),ve());}function N(){Y||(k!==void 0&&clearTimeout(k),k=setTimeout(()=>{k=void 0,x();},yt));}function me(){U=void 0,x();}function ie(e){Y=true,g$1(),ee=e.touches?.[0]?.clientY;}function Ie(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(ee!==void 0&&n>ee&&y(),ee=n);}function ne(){Y=false,ee=void 0,N();}function he(e){g$1(),e.deltaY<0&&y(),N();}function Ve(e){e.pointerType!=="touch"&&(g$1(),c=e.clientY,N());}function $e(e){e.pointerType==="touch"||!A||c===void 0||(e.clientY<c&&y(),c=e.clientY,N());}function Ce(e){e.pointerType!=="touch"&&(c=void 0,N());}function Xe(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(g$1(),(e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey)&&y(),N());}function Be(e="auto"){let n=f.value;if(n===null)return;le();let i=Math.max(0,n.scrollHeight-n.clientHeight);ye(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,j$1.clear(),oe();}function Je(){let e=f.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function wt(){let e=f.value;return Je()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Mt(e,n={}){let i=f.value,I=M.get(e);if(i===null||I===void 0||!i.contains(I)||i.clientHeight<=0)return false;le();let P=i.getBoundingClientRect(),E=I.getBoundingClientRect(),K=n.block??"center",Q;K==="start"?Q=i.scrollTop+E.top-P.top:K==="end"?Q=i.scrollTop+E.bottom-P.bottom:K==="nearest"?E.top>=P.top&&E.bottom<=P.bottom?Q=i.scrollTop:E.top<P.top?Q=i.scrollTop+E.top-P.top:Q=i.scrollTop+E.bottom-P.bottom:Q=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:E.height,targetTop:E.top,viewportHeight:i.clientHeight,viewportTop:P.top});let ke=Math.max(0,i.scrollHeight-i.clientHeight),Te=Math.min(ke,Math.max(0,Q)),we=n.behavior??"auto";return ye(Te,we),i.scrollTo?.({top:Te,behavior:we}),i.scrollTop!==Te&&(i.scrollTop=Te),o$1=i.scrollTop,oe(),true}function Rt(){j$1.clear();}function St(){s=true,v.value=false;}function Pt(){s=false,ae();}function Et(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(S?.unobserve(i),B$1?.unobserve?.(i),m$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),m$1.set(n,e),S?.observe(n),B$1?.observe(n),ae();}function At(e,n,i){let I=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),z$1===e&&i.style.setProperty("opacity",String(J)),I?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(je,{registerMessageNode:Et,registerDateNode:At}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;O();let i=f.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=f.value;if(i===null)return;let I=new Set(n);n.length>0&&e.length>0&&!e.some(De=>I.has(De))&&O();let E=i.getBoundingClientRect(),K=p(b,$(),{top:E.top,bottom:E.bottom}),Q=v.value,ke=n[n.length-1],Te=ke===void 0?-1:e.indexOf(ke),we=Te<0?[]:e.slice(Te+1).filter(De=>!I.has(De)),Ot=s||t.loadingNewer;if(await nextTick(),_)return;let Qe=n[0];if(Qe!==void 0&&e.indexOf(Qe)>0&&(W=false,xe(K)),we.length>0){if(Ot){s=false,h===void 0&&r(K),v.value=false,ae();return}(Q||we.some(xt=>t.shouldFollowAppendedMessage?.(xt)===true))&&t.followNewMessages?Be():j$1.add(we);}ae();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!s||re(()=>{t.loadingNewer||(s=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!W||re(()=>{t.loadingOlder||(W=false);});},{flush:"pre"}),onMounted(()=>{let e=f.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",fe,{passive:true}),e.addEventListener("scrollend",me,{passive:true}),e.addEventListener("touchstart",ie,{passive:true}),e.addEventListener("touchmove",Ie,{passive:true}),e.addEventListener("touchend",ne,{passive:true}),e.addEventListener("touchcancel",ne,{passive:true}),e.addEventListener("wheel",he,{passive:true}),e.addEventListener("pointerdown",Ve,{passive:true}),e.addEventListener("pointermove",$e,{passive:true}),e.addEventListener("pointerup",Ce,{passive:true}),e.addEventListener("pointercancel",Ce,{passive:true}),e.addEventListener("keydown",Xe),typeof globalThis.ResizeObserver=="function"){B$1=new globalThis.ResizeObserver(()=>{let n=b;re(()=>{f.value!==null&&(h!==void 0?(be(),A||Pe()):s||t.loadingNewer?r(n):t.resizeFollowEnabled&&v.value?Be():r(n),oe());});}),B$1.observe(e);for(let n of M.values())B$1.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){S=new globalThis.IntersectionObserver(n=>{for(let i of n){let I=m$1.get(i.target);I!==void 0&&(i.isIntersecting?w.add(I):w.delete(I));}L=true,ae();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())S.observe(n);}ae();}}),onBeforeUnmount(()=>{_=true;let e=f.value;e!==null&&e.removeEventListener("scroll",fe),e!==null&&(e.removeEventListener("scrollend",me),e.removeEventListener("touchstart",ie),e.removeEventListener("touchmove",Ie),e.removeEventListener("touchend",ne),e.removeEventListener("touchcancel",ne),e.removeEventListener("wheel",he),e.removeEventListener("pointerdown",Ve),e.removeEventListener("pointermove",$e),e.removeEventListener("pointerup",Ce),e.removeEventListener("pointercancel",Ce),e.removeEventListener("keydown",Xe)),k!==void 0&&clearTimeout(k),le(),He(),B$1?.disconnect(),S?.disconnect(),Re(),M.clear(),m$1.clear(),w.clear(),R.clear(),j$1.clear();}),T({getViewportElement:()=>f.value,clearNewMessageBadge:Rt,clearActiveDate:Re,isAtBottom:computed(()=>v.value),isMeasurable:Je,isScrollable:wt,newMessageCount:computed(()=>D.value),prepareHistoryPageAppend:St,cancelHistoryPageAppend:Pt,trackRemoteMessageIds:(e,n)=>j$1.trackRemote(e,n),scrollToLatest:Be,scrollToMessage:Mt,focusViewport:()=>f.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:f,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:V,"data-im-thread-viewport-content":""},u.default?.())])}});var bt=Symbol("ImThreadSurfaceContext");function Xt(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 Jt(t){provide(bt,t);}function Ge(){let t=inject(bt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var qe=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),ze=Object.freeze({enabled:true,maxFillPages:8}),er=8,tr=160;function rr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var nr=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:T}){let u=t.context??Ge(),f=ref(null),V=ref(0),M=ref(true),m=[],w,R=0,o=0,l=null,b="",B="",S="",L=false,F=false,C=ref(false),_=ref(""),U=ref(false),z,J,s=computed(()=>u.getState()),W=computed(()=>s.value.pageVisible??u.isPageVisible?.()??true),X=computed(()=>s.value.pageEngaged??u.isPageEngaged?.()??true),A=computed(()=>rr(s.value.activeConversation,t.conversation)),G=computed(()=>({...qe,...t.viewportOptions})),Y=computed(()=>{let r=t.initialViewportOptions.maxFillPages??ze.maxFillPages;return {enabled:t.initialViewportOptions.enabled??ze.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):ze.maxFillPages}}),H=computed(()=>!A.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),Z=computed(()=>A.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:u.formatDate,leadingItems:u.leadingItems?.(),beforeMessageItems:u.beforeMessageItems}):[]),k=computed(()=>Z.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ee(){z!==void 0&&(clearTimeout(z),z=void 0),J!==void 0&&(clearTimeout(J),J=void 0);}function c(r=false){if(ee(),U.value=false,r){f.value?.clearActiveDate(),_.value="";return}J=setTimeout(()=>{J=void 0,!U.value&&(f.value?.clearActiveDate(),_.value="");},tr);}function h(r){if(r===null){c();return}ee(),_.value=r.label,U.value=true;let d=G.value.activeDateIdleDelay,g=Number.isFinite(d)?Math.max(0,d):qe.activeDateIdleDelay;z=setTimeout(()=>{z=void 0,c();},g);}async function p(r,d){t.hooks?.beforeAction?.(r);try{let g=await d();return t.hooks?.afterAction?.(r,g),g}catch(g){throw t.hooks?.onError?.(r,g),g}}function v(){return !A.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):p({kind:"load-older"},()=>u.actions.loadOlder())}function D(){let r=u.actions.loadNewer,d=s.value.loadingNewer??s.value.loading;return !A.value||d||!s.value.hasNewer||r===void 0?Promise.resolve(0):p({kind:"load-newer"},()=>r())}async function j(r){for(let d=0;d<er;d+=1){if(!A.value)return;let g=r==="older"?s.value.hasOlder:s.value.hasNewer,y=r==="older"?s.value.olderError:s.value.newerError;if(!g||y!==null||(r==="older"?await v():await D())>0)return;let x=r==="older"?s.value.hasOlder:s.value.hasNewer,N=r==="older"?s.value.olderError:s.value.newerError;if(!x||N!==null)return}}async function q(){return !A.value||u.actions.loadNewer===void 0?0:p({kind:"load-newer"},()=>u.actions.retryNewer?.()??u.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function $(){if(!A.value)return 0;let r=H.value;S="";let d;try{d=await p({kind:"retry-older"},()=>u.actions.retryOlder?.()??u.actions.loadOlder({force:!0}));}catch(g){throw H.value===r&&(S=r),g}return C.value||(l=null,pe()),d}async function Ae(){if(!A.value)return false;let r=await p({kind:"jump-to-latest"},()=>u.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow));return r&&(await nextTick(),f.value?.scrollToLatest()),r}function Re(r){M.value=r.isAtBottom,V.value=r.newMessageCount,pe();}function Oe(r,d){return f.value?.scrollToMessage(r,d)??false}function oe(r,d){return !F&&o===d&&H.value===r&&A.value}async function re(r,d,g,y){for(let O=0;O<60;O+=1){if(!oe(r,d))return false;if(Oe(g,y))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(x=>window.requestAnimationFrame(()=>x()));}return false}async function He(r,d,g){let y=f.value;if(y===null||!y.isMeasurable()||y.isScrollable())return true;let O=0,x=!s.value.hasOlder,N=!s.value.hasNewer||u.actions.loadNewer===void 0,me=async()=>(await nextTick(),await nextTick(),re(r,d,g,{behavior:"auto",block:"center"})),ie=async ne=>{if(!oe(r,d)||O>=Y.value.maxFillPages)return false;let he=0;if(ne==="older"){if(x||!s.value.hasOlder)return false;he=await v(),x=!s.value.hasOlder;}else {if(N||!s.value.hasNewer)return false;y.prepareHistoryPageAppend();try{he=await D();}catch(Ve){throw y.cancelHistoryPageAppend(),Ve}he<=0&&!s.value.hasNewer&&y.cancelHistoryPageAppend(),N=!s.value.hasNewer;}return O+=1,he>0?me():!(ne==="older"?x:N)};!x&&!await ie("older")&&(x=true),!N&&!await ie("newer")&&(N=true);let Ie="older";for(;oe(r,d)&&O<Y.value.maxFillPages&&y.isMeasurable()&&!y.isScrollable()&&(!x||!N);){let ne=Ie==="older"?x?"newer":"older":N?"older":"newer";Ie=ne==="older"?"newer":"older",await ie(ne)||(ne==="older"?x=true:N=true);}return oe(r,d)}async function ae(r,d={behavior:"auto",block:"center"}){if(!A.value||r==="")return false;let g=H.value,y=++o;if(!k.value.includes(r)){let N=u.actions.loadAround;if(N===void 0||!await p({kind:"locate-message",messageId:r},()=>N(r))||!oe(g,y))return false}return !await re(g,y,r,{...d,behavior:"auto"})||!await He(g,y,r)?false:re(g,y,r,d)}function Se(){w!==void 0&&(clearTimeout(w),w=void 0);}function fe(){if(Se(),!C.value)return;let r=t.readActions;if(r===void 0||m.length===0)return;let d=Number.isFinite(G.value.visibleReadDelay)?Math.max(0,G.value.visibleReadDelay):qe.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!A.value||!X.value)return;let g=m[m.length-1];if(g===void 0)return;let y=r.resolveTarget===void 0?g:r.resolveTarget(g);y!=null&&Promise.resolve(r.markRead(y)).catch(O=>{t.hooks?.onError?.({kind:"visible-range",messageIds:m},O);});},d);}function ye(r){m=Object.freeze([...r]);let d={kind:"visible-range",messageIds:m};t.hooks?.beforeAction?.(d);try{u.actions.onVisibleRange?.(m),t.hooks?.afterAction?.(d,void 0);}catch(g){throw t.hooks?.onError?.(d,g),g}C.value?fe():pe();}function se(r,d){return !F&&R===d&&H.value===r&&!L}function le(r,d){se(r,d)&&(b=r,B=ge(s.value.entryUnread),C.value=true,fe());}function ge(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function be(r,d,g){for(let y=0;y<60;y+=1){if(!se(r,d))return false;if(f.value?.scrollToMessage(g,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(x=>window.requestAnimationFrame(()=>x()));}return false}function pe(){let r=H.value,d=ge(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null||b===r&&(B===d||L)||S===r||l!==null)return;if(!Y.value.enabled){b=r,B=d,C.value=true,fe();return}let g=++R;L=false,C.value=false;let y=(async()=>{if(await nextTick(),!se(r,g))return;let O=f.value;if(O===null||!O.isMeasurable())return;let x=s.value.entryUnread;if(x.state==="located"&&!k.value.includes(x.firstMessageId))return;let N=x.state==="located"?await be(r,g,x.firstMessageId):false;if(x.state==="located"&&!N)return;N||O.scrollToLatest();let me=0;for(;se(r,g)&&me<Y.value.maxFillPages&&s.value.hasOlder&&O.isMeasurable()&&!O.isScrollable();)if(await v(),!se(r,g)||(me+=1,await nextTick(),await nextTick(),!O.isMeasurable()))return;if(!se(r,g)||!O.isMeasurable())return;let ie=s.value.entryUnread;if(ie.state==="located"){if(!k.value.includes(ie.firstMessageId)||!await be(r,g,ie.firstMessageId))return}else O.scrollToLatest();await nextTick(),le(r,g);})().catch(()=>{H.value===r&&(S=r);}).finally(()=>{l===y&&(l=null);});l=y;}function ve(r){R+=1,l=null,L=false,C.value=r,(b="",B="",S=""),Se();}function Pe(){if(C.value)return;let r=H.value;L=true,R+=1,l=null,b=r,C.value=true,fe();}let xe=Object.freeze({getViewportElement:()=>f.value?.getViewportElement()??null,loadOlder:v,retryOlder:$,loadNewer:D,retryNewer:q,jumpToLatest:Ae,scrollToMessage:Oe,locateMessage:ae,focusViewport:()=>f.value?.focusViewport()});return a(xe),watch(X,r=>{r&&C.value?fe():Se();}),watch([()=>s.value.activeRemoteMessageRevision??0,f,H],()=>{let r=f.value;if(r===null||!A.value)return;let d=u.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(d,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:W.value})&&(M.value=false);},{flush:"post"}),watch([H,()=>s.value.loading,()=>s.value.error,()=>k.value.length,()=>s.value.hasOlder,()=>ge(s.value.entryUnread),Y],([r,d,g,,,y],[O,,,,,x])=>{if(r!==O&&(o+=1,ve(false),c(true),f.value?.clearNewMessageBadge(),V.value=0,M.value=true),r!==""&&r===O&&y!==x&&!L&&y.startsWith("located:")&&(b="",B="",C.value=false),r===""||g!==null){ve(false);return}d||pe();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{F=true,o+=1,ve(false),c(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:Z.value,actions:xe},d=[T.header?.(r),T["before-list"]?.(r)];if(!A.value)d.push(T.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)d.push(T.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)d.push(T.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)d.push(T.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let g=h$1(Ue,{ref:f,messageIds:k.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:G.value.followThreshold,olderPrefetchThreshold:G.value.olderPrefetchThreshold,visibleMargin:G.value.visibleMargin,activeDateOffset:G.value.activeDateOffset,activeDateEnabled:T["active-date"]!==void 0,resizeFollowEnabled:C.value,followNewMessages:W.value,shouldFollowAppendedMessage:y=>{let O=s.value.messages.find(x=>x.id===y);return O===void 0?false:u.shouldFollowMessage?.(O)===true},onReachStart:()=>{j("older").catch(()=>{});},onReachEnd:()=>{j("newer").catch(()=>{});},onSettled:Re,onUserScroll:Pe,onActiveDateChange:h,onVisibleRange:ye,onNewMessageCount:y=>{V.value=y;}},{default:()=>[T["viewport-before"]?.(r),h$1(Ke,{items:Z.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:T.item,"date-separator":T["date-separator"],"entry-unread":T["entry-unread"],encryption:T.encryption,system:T.system,message:T.message,"recalled-message":T["recalled-message"],"deleted-message":T["deleted-message"],"unsupported-body":T["unsupported-body"]}),T["viewport-after"]?.(r)]});d.push(h$1("div",{"data-im-thread-viewport-shell":""},[T["active-date"]?.({label:_.value,visible:U.value&&_.value!==""}),g])),s.value.error!==null&&d.push(T.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return d.push(T["after-list"]?.(r),T["jump-to-latest"]?.({...r,count:V.value,visible:!M.value||s.value.isHistoryWindow}),T["context-menu"]?.(r),T.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},d)}}});function or(t){let a=new Map;for(let u of t){if(a.has(u.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${u.kind}`);a.set(u.kind,u.component);}let T=Object.freeze([...a.keys()]);return Object.freeze({kinds:T,resolve:u=>a.get(u)})}function It(t,a){if(t.width<=0||t.height<=0)return 0;let T=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),u=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,T*u/(t.width*t.height))}function ir(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 Ye(t){let a=Math.max(0,t.scrollIdleMs??140),T=Math.max(0,t.visibilityDwellMs??120),u=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),f=Math.max(0,t.revealMarginPx??0),V=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,m=new Map,w=new Set,R=new Set,o=new Set,l=null,b=null,B=null,S=false,L=false,F=false,C,_;function U(){C!==void 0&&clearTimeout(C),C=void 0;}function z(){_!==void 0&&clearTimeout(_),_=void 0;}function J(c=false){if(!c&&b!==null||l===null)return;let h=l.getBoundingClientRect(),p=ir(h,f);for(let[v,D]of M){let j=v.getBoundingClientRect();D.ratio=It(j,h),D.intersecting=D.ratio>0,D.revealIntersecting=f>0?It(j,p)>0:D.intersecting&&D.ratio>=u;}}function s(c){return c.intersecting&&c.ratio>=u}function W(){for(let c of M.values())!c.revealIntersecting||w.has(c.key)||(w.add(c.key),t.onRevealed?.(c.item));}function X(c){let h=new Set(c.map(v=>v.key));if(h.size!==o.size||[...h].some(v=>!o.has(v))){o.clear();for(let v of h)o.add(v);t.onSettledVisibleChange?.(c.map(v=>v.item));}}function A(){if(L||S)return;J(),W();let c=l?.getBoundingClientRect(),h=c===void 0?0:(c.top+c.bottom)/2,p=[...M.entries()].filter(([,v])=>s(v)).sort(([v],[D])=>{let j=v.getBoundingClientRect(),q=D.getBoundingClientRect();return Math.abs((j.top+j.bottom)/2-h)-Math.abs((q.top+q.bottom)/2-h)}).slice(0,V).map(([,v])=>v);X(p);for(let v of p)R.has(v.key)||(R.add(v.key),t.onActivated?.(v.item));}function G(){L||S||(z(),_=setTimeout(()=>{_=void 0,A();},T));}function Y(){L||(H(true),J(),W(),X([]),z(),U(),C=setTimeout(()=>{C=void 0,H(false),G();},a));}function H(c){S!==c&&(S=c,t.onScrollingChange?.(c));}function Z(){l?.removeEventListener("scroll",Y),b?.disconnect(),B?.disconnect(),b=null,B=null,l=null;}function k(c=true){if(L)return;let h=t.getRoot();if(!(h===l&&l!==null)){if(Z(),l=h,l===null){c&&!F&&(F=true,Promise.resolve().then(()=>{F=false,L||(k(false),G());}));return}if(l.addEventListener("scroll",Y,{passive:true}),typeof IntersectionObserver<"u"){b=new IntersectionObserver(p=>{for(let v of p){let D=M.get(v.target);D!==void 0&&(D.intersecting=v.isIntersecting,D.ratio=v.intersectionRatio,f===0&&(D.revealIntersecting=v.isIntersecting&&v.intersectionRatio>=u));}W(),G();},{root:l,threshold:[0,u,1]}),f>0&&(B=new IntersectionObserver(p=>{for(let v of p){let D=M.get(v.target);D!==void 0&&(D.revealIntersecting=v.isIntersecting);}W();},{root:l,rootMargin:`${f}px 0px`,threshold:0}));for(let p of M.keys())b.observe(p);for(let p of M.keys())B?.observe(p);}else J(),W();}}function ee(c){w.delete(c),R.delete(c),o.delete(c);}return {register(c,h){if(L)return;let p=t.getKey(c),v=w.has(p),D=R.has(p),j=h===null?void 0:M.get(h);j!==void 0&&j.key!==p&&(m.delete(j.key),M.delete(h),ee(j.key));let q=m.get(p);if(q!==void 0&&q!==h&&(b?.unobserve(q),B?.unobserve(q),M.delete(q),m.delete(p)),h===null){q!==void 0&&(b?.unobserve(q),B?.unobserve(q),M.delete(q),m.delete(p)),ee(p);return}let $=M.get(h);if($?.key===p&&$.item===c){k();return}M.set(h,{item:c,key:p,intersecting:$?.key===p?$.intersecting:false,ratio:$?.key===p?$.ratio:0,revealIntersecting:$?.key===p?$.revealIntersecting:false}),m.set(p,h),k(),b?.observe(h),B?.observe(h),J(true),W(),v&&t.onRevealed?.(c),D?t.onActivated?.(c):G();},isRevealed:c=>w.has(t.getKey(c)),isActivated:c=>R.has(t.getKey(c)),isSettledVisible:c=>o.has(t.getKey(c)),isScrolling:()=>S,notifyScroll:Y,refresh(){k(),J(true),W(),G();},reset(){U(),z(),H(false),X([]),Z(),M.clear(),m.clear(),w.clear(),R.clear();},dispose(){L||(U(),z(),H(false),X([]),Z(),M.clear(),m.clear(),w.clear(),R.clear(),L=true);}}}function ar(t){let a=new Map,T=new Map,u=false,f=m=>{let w=a.get(m.channel);return w===void 0?m.channel:`${m.channel}\0${w.getKey(m.item)}`},V=Ye({getRoot:t.getRoot,getKey:f,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:m=>{for(let w of a.values())w.onScrollingChange?.(m);},onRevealed:m=>a.get(m.channel)?.onRevealed?.(m.item),onActivated:m=>a.get(m.channel)?.onActivated?.(m.item),onSettledVisibleChange:m=>{for(let[w,R]of a){let o=m.filter(b=>b.channel===w).map(b=>b.item),l=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(l);}}});function M(m){return w=>{if(u)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(m))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${m}`);a.set(m,w);let R=new Map;T.set(m,R);let o=false,l=S=>({channel:m,item:S});function b(){for(let S of R.values())V.register(S.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(S,L){if(o||u)return;let F=w.getKey(S),C=R.get(F);if(L===null){C!==void 0&&(V.register(C.target,null),R.delete(F));return}let _=l(S);R.set(F,{target:_,element:L}),V.register(_,L);},isRevealed:S=>V.isRevealed(l(S)),isActivated:S=>V.isActivated(l(S)),isSettledVisible:S=>V.isSettledVisible(l(S)),isScrolling:V.isScrolling,notifyScroll:V.notifyScroll,refresh:V.refresh,reset:b,dispose(){o||(b(),o=true,a.delete(m),T.delete(m));}}}}return {createFactory:M,refresh:V.refresh,dispose(){if(!u){for(let m of T.values())for(let w of m.values())V.register(w.target,null);T.clear(),a.clear(),V.dispose(),u=true;}}}}export{_e as ImThreadBodySwitch,Ke as ImThreadItems,nr as ImThreadSurface,Ue as ImThreadViewport,Xt as createImThreadSurfaceContext,or as createMessageRendererRegistry,ar as createThreadVisibilityTargetGroup,Ye as createThreadVisibilityTargets,Jt as provideImThreadSurfaceContext,Vt as useImText,Ge as useImThreadSurfaceContext,Dt as useOptionalImThreadReadActions};
|
|
1
|
+
import {h,C,p,i,q,m,z,j,g,B,o}from'./chunk-MKV7J6WB.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-TQF5HUEX.js';import'./chunk-DFE2F575.js';import'./chunk-6QR5GVQ3.js';import'./chunk-BO5YFCS4.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment}from'vue';function Vt(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}),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 mt=Symbol("ImThreadReadActions");function gt(t){provide(mt,t);}function Dt(){return inject(mt,void 0)}var _e=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:T}){return gt(t.readActions),()=>{let u=h(t.message),f=t.rendererRegistry.resolve(u);return f!==void 0?h$1(f,{...a,message:t.message,presentation:t.presentation}):T["unsupported-body"]!==void 0?T["unsupported-body"]({kind:u,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":u,"aria-hidden":"true"})}}});var je=Symbol("ImThreadViewportRegistration");function vt(){return inject(je,void 0)}var Ke=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 T=vt();function u(o,l){let b=Array.isArray(l)?l:[l];return b.length===1&&isVNode(b[0])?cloneVNode(b[0],{key:o}):h$1(Fragment,{key:o},b)}function f(o){return l=>{T?.registerMessageNode(o,l instanceof HTMLElement?l:null);}}function V(o,l){return b=>{T?.registerDateNode(o,l,b instanceof HTMLElement?b:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function m(o){let l=V(o.key,o.label);return a["date-separator"]?.({item:o,setElement:l})??h$1("div",{ref:l,"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 l=f(o.message.id);return a.item!==void 0?a.item({item:o,setElement:l}):a.message!==void 0?a.message({item:o,setElement:l}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:l})??h$1("article",{ref:l,"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:l})??h$1("article",{ref:l,"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:l}):h$1("article",{ref:l,"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(_e,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:b=>a["unsupported-body"]?.(b)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?u(o.key,a.item({item:o})):u(o.key,M(o));case "date-separator":return a.item!==void 0?u(o.key,a.item({item:o,setElement:V(o.key,o.label)})):u(o.key,m(o));case "entry-unread":return a.item!==void 0?u(o.key,a.item({item:o})):u(o.key,w(o));case "system":case "message":return u(o.key,R(o))}return o}))}});var yt=120,qt=500,Ee=.5,zt=8,Ue=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:T,slots:u}){let f=ref(null),V=ref(null),M=new Map,m$1=new Map,w=new Set,R=new Map,o$1=0,l=[],b,B$1,S,L=false,F,C$1=new Set,_=false,U,z$1="",J=1,s=false,W=false,X=true,A=false,G=false,Y=false,H=0,Z=-1,k,ee,c,h,p$1,v=ref(true),D=ref(0),j$1=C(e=>{D.value=e,a("new-message-count",e);});function q$1(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function $(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let I=i.getBoundingClientRect(),P=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:I.top,bottom:I.bottom,anchorTop:P?.getBoundingClientRect().top??I.top}]})}function Ae(e="",n=1){let i=Math.min(1,Math.max(0,n));z$1!==""&&z$1!==e&&R.get(z$1)?.element.style.removeProperty("opacity"),z$1=e,J=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function Re(){Ae();}function Oe(){let e=f.value;if(_||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,E])=>e.contains(E.element)).map(([E,K])=>{let Q=K.element.getBoundingClientRect();return {key:E,label:K.label,top:Q.top,height:Q.height}}).sort((E,K)=>E.top-K.top),i=e.getBoundingClientRect(),I=n.find(E=>E.height>0)?.height??28,P=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:I});if(P===null){Re(),a("active-date-change",null);return}Ae(P.inlineDateKey,P.inlineOpacity),a("active-date-change",P);}function oe(){let e=f.value;if(_||e===null)return;let n=e.getBoundingClientRect(),i=S!==void 0&&L?t.messageIds.filter(K=>w.has(K)):t.messageIds,I=$(i);if(S!==void 0&&L&&I.length===0){v.value=q$1(e);return}let P=I.filter(K=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:K.top,messageBottom:K.bottom,margin:t.visibleMargin})).map(K=>K.id),E=P.length!==l.length||P.some((K,Q)=>l[Q]!==K);l=Object.freeze(P),b=o(I,{top:n.top,bottom:n.bottom}),j$1.acknowledgeVisible(P),v.value=q$1(e),E&&a("visible-range",l),a("settled",{visibleMessageIds:l,...l.length===0?{}:{newestVisibleMessageId:l[l.length-1]},isAtBottom:v.value,newMessageCount:D.value});}function re(e){if(C$1.add(e),F!==void 0)return;let n=()=>{F=void 0;let i=[...C$1];C$1.clear(),i.forEach(I=>I());};typeof globalThis.requestAnimationFrame=="function"?F=globalThis.requestAnimationFrame(n):F=globalThis.setTimeout(n,0);}function He(){F!==void 0&&(typeof F=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(F):globalThis.clearTimeout(F),F=void 0,C$1.clear());}function ae(){re(oe);}function Se(){let e=f.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o($(),{top:n.top,bottom:n.bottom});i!==void 0&&(b=i);}function fe(){let e=f.value;if(_||e===null)return;let n=e.scrollTop,i=U,I=false;if(i!==void 0){let E=Math.abs(n-i.targetTop)<=Ee;I=i.behavior==="smooth"||E,(i.behavior!=="smooth"||E)&&(U=void 0);}!I&&!A&&h===void 0&&n!==o$1&&(A=true,G=true,H+=1);let P=A&&!I&&n!==o$1;if(P&&(a("user-scroll"),re(Oe)),A&&!Y&&N(),!X&&G&&H!==Z&&n<o$1&&n>d()&&(X=true),h!==void 0&&!I)if(A){let E=ge();E!==void 0&&(h.expectedOffset=E);}else be(),Pe();X&&h===void 0&&!W&&!t.loadingOlder&&P&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&(Se(),X=false,Z=H,W=true,a("reach-start"),re(()=>{t.loadingOlder||(W=false);})),!s&&!t.loadingOlder&&!t.loadingNewer&&t.hasNewer&&P&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:q$1(e),isHistoryWindow:t.hasNewer,isPageSettling:I})&&(s=true,v.value=false,a("reach-end"),re(()=>{t.loadingNewer||(s=false);})),o$1=n,ae();}function ye(e,n="auto"){U={targetTop:e,behavior:n};}function se(e){let n=h,i=V.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=Ee?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 le(){p$1!==void 0&&(clearTimeout(p$1),p$1=void 0);let e=V.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),h=void 0,U=void 0;}function ge(){let e=f.value,n=h;if(e===null||n===void 0)return;let i=$().find(I=>I.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function be(){let e=h,n=ge();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=Ee||(se(e.visualOffset+i),e.committed=false,e.attempts=0);}function pe(){p$1!==void 0&&clearTimeout(p$1),p$1=setTimeout(()=>{p$1=void 0,!(A||h?.committed!==true)&&le();},qt);}function ve(){let e=f.value,n=h;if(_||e===null||n===void 0||A)return;let i=n.visualOffset;if(Math.abs(i)<=Ee){n.committed=true,pe();return}let I=Math.max(0,e.scrollHeight-e.clientHeight),P=Math.min(I,Math.max(0,e.scrollTop-i));if(ye(P),e.scrollTop=P,Math.abs(e.scrollTop-P)>Ee){U=void 0,n.committed=false,n.attempts+=1,n.attempts<zt?Pe():(le(),U=void 0,o$1=e.scrollTop);return}se(0),o$1=e.scrollTop,n.expectedOffset=ge()??n.expectedOffset,n.committed=true,n.attempts=0,pe();}function Pe(){p$1!==void 0&&clearTimeout(p$1),p$1=setTimeout(()=>{p$1=void 0,ve();},yt);}function xe(e){e!==void 0&&(h===void 0&&(h={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),be(),!A&&ve());}function r(e){let n=f.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),I=q(e,$(),{top:i.top,bottom:i.bottom});if(I!==void 0){let P=Math.max(0,n.scrollHeight-n.clientHeight),E=Math.min(P,Math.max(0,n.scrollTop+I));ye(E),n.scrollTop=E,o$1=n.scrollTop;}}function d(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function g$1(){U?.behavior==="smooth"&&(U=void 0),G=false,A||(A=true,H+=1),k!==void 0&&(clearTimeout(k),k=void 0);}function y(){let e=f.value;X||H===Z||e===null||e.scrollTop<=d()||(h?.committed===true&&le(),h===void 0&&(X=true));}function O(){k!==void 0&&(clearTimeout(k),k=void 0),le(),A=false,G=false,Y=false,ee=void 0,c=void 0,H+=1,Z=-1,X=true,W=false,s=false,U=void 0;}function x(){Y||(k!==void 0&&(clearTimeout(k),k=void 0),A=false,G=false,h!==void 0&&(h.attempts=0),ve());}function N(){Y||(k!==void 0&&clearTimeout(k),k=setTimeout(()=>{k=void 0,x();},yt));}function me(){U=void 0,x();}function ie(e){Y=true,g$1(),ee=e.touches?.[0]?.clientY;}function Ie(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(ee!==void 0&&n>ee&&y(),ee=n);}function ne(){Y=false,ee=void 0,N();}function he(e){g$1(),e.deltaY<0&&y(),N();}function Ve(e){e.pointerType!=="touch"&&(g$1(),c=e.clientY,N());}function $e(e){e.pointerType==="touch"||!A||c===void 0||(e.clientY<c&&y(),c=e.clientY,N());}function Ce(e){e.pointerType!=="touch"&&(c=void 0,N());}function Xe(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(g$1(),(e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey)&&y(),N());}function Be(e="auto"){let n=f.value;if(n===null)return;le();let i=Math.max(0,n.scrollHeight-n.clientHeight);ye(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,j$1.clear(),oe();}function Je(){let e=f.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function wt(){let e=f.value;return Je()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Mt(e,n={}){let i=f.value,I=M.get(e);if(i===null||I===void 0||!i.contains(I)||i.clientHeight<=0)return false;le();let P=i.getBoundingClientRect(),E=I.getBoundingClientRect(),K=n.block??"center",Q;K==="start"?Q=i.scrollTop+E.top-P.top:K==="end"?Q=i.scrollTop+E.bottom-P.bottom:K==="nearest"?E.top>=P.top&&E.bottom<=P.bottom?Q=i.scrollTop:E.top<P.top?Q=i.scrollTop+E.top-P.top:Q=i.scrollTop+E.bottom-P.bottom:Q=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:E.height,targetTop:E.top,viewportHeight:i.clientHeight,viewportTop:P.top});let ke=Math.max(0,i.scrollHeight-i.clientHeight),Te=Math.min(ke,Math.max(0,Q)),we=n.behavior??"auto";return ye(Te,we),i.scrollTo?.({top:Te,behavior:we}),i.scrollTop!==Te&&(i.scrollTop=Te),o$1=i.scrollTop,oe(),true}function Rt(){j$1.clear();}function St(){s=true,v.value=false;}function Pt(){s=false,ae();}function Et(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(S?.unobserve(i),B$1?.unobserve?.(i),m$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),m$1.set(n,e),S?.observe(n),B$1?.observe(n),ae();}function At(e,n,i){let I=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),z$1===e&&i.style.setProperty("opacity",String(J)),I?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(je,{registerMessageNode:Et,registerDateNode:At}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;O();let i=f.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=f.value;if(i===null)return;let I=new Set(n);n.length>0&&e.length>0&&!e.some(De=>I.has(De))&&O();let E=i.getBoundingClientRect(),K=p(b,$(),{top:E.top,bottom:E.bottom}),Q=v.value,ke=n[n.length-1],Te=ke===void 0?-1:e.indexOf(ke),we=Te<0?[]:e.slice(Te+1).filter(De=>!I.has(De)),Ot=s||t.loadingNewer;if(await nextTick(),_)return;let Qe=n[0];if(Qe!==void 0&&e.indexOf(Qe)>0&&(W=false,xe(K)),we.length>0){if(Ot){s=false,h===void 0&&r(K),v.value=false,ae();return}(Q||we.some(xt=>t.shouldFollowAppendedMessage?.(xt)===true))&&t.followNewMessages?Be():j$1.add(we);}ae();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!s||re(()=>{t.loadingNewer||(s=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!W||re(()=>{t.loadingOlder||(W=false);});},{flush:"pre"}),onMounted(()=>{let e=f.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",fe,{passive:true}),e.addEventListener("scrollend",me,{passive:true}),e.addEventListener("touchstart",ie,{passive:true}),e.addEventListener("touchmove",Ie,{passive:true}),e.addEventListener("touchend",ne,{passive:true}),e.addEventListener("touchcancel",ne,{passive:true}),e.addEventListener("wheel",he,{passive:true}),e.addEventListener("pointerdown",Ve,{passive:true}),e.addEventListener("pointermove",$e,{passive:true}),e.addEventListener("pointerup",Ce,{passive:true}),e.addEventListener("pointercancel",Ce,{passive:true}),e.addEventListener("keydown",Xe),typeof globalThis.ResizeObserver=="function"){B$1=new globalThis.ResizeObserver(()=>{let n=b;re(()=>{f.value!==null&&(h!==void 0?(be(),A||Pe()):s||t.loadingNewer?r(n):t.resizeFollowEnabled&&v.value?Be():r(n),oe());});}),B$1.observe(e);for(let n of M.values())B$1.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){S=new globalThis.IntersectionObserver(n=>{for(let i of n){let I=m$1.get(i.target);I!==void 0&&(i.isIntersecting?w.add(I):w.delete(I));}L=true,ae();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())S.observe(n);}ae();}}),onBeforeUnmount(()=>{_=true;let e=f.value;e!==null&&e.removeEventListener("scroll",fe),e!==null&&(e.removeEventListener("scrollend",me),e.removeEventListener("touchstart",ie),e.removeEventListener("touchmove",Ie),e.removeEventListener("touchend",ne),e.removeEventListener("touchcancel",ne),e.removeEventListener("wheel",he),e.removeEventListener("pointerdown",Ve),e.removeEventListener("pointermove",$e),e.removeEventListener("pointerup",Ce),e.removeEventListener("pointercancel",Ce),e.removeEventListener("keydown",Xe)),k!==void 0&&clearTimeout(k),le(),He(),B$1?.disconnect(),S?.disconnect(),Re(),M.clear(),m$1.clear(),w.clear(),R.clear(),j$1.clear();}),T({getViewportElement:()=>f.value,clearNewMessageBadge:Rt,clearActiveDate:Re,isAtBottom:computed(()=>v.value),isMeasurable:Je,isScrollable:wt,newMessageCount:computed(()=>D.value),prepareHistoryPageAppend:St,cancelHistoryPageAppend:Pt,trackRemoteMessageIds:(e,n)=>j$1.trackRemote(e,n),scrollToLatest:Be,scrollToMessage:Mt,focusViewport:()=>f.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:f,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:V,"data-im-thread-viewport-content":""},u.default?.())])}});var bt=Symbol("ImThreadSurfaceContext");function Xt(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 Jt(t){provide(bt,t);}function Ge(){let t=inject(bt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var qe=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),ze=Object.freeze({enabled:true,maxFillPages:8}),er=8,tr=160;function rr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var nr=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:T}){let u=t.context??Ge(),f=ref(null),V=ref(0),M=ref(true),m=[],w,R=0,o=0,l=null,b="",B="",S="",L=false,F=false,C=ref(false),_=ref(""),U=ref(false),z,J,s=computed(()=>u.getState()),W=computed(()=>s.value.pageVisible??u.isPageVisible?.()??true),X=computed(()=>s.value.pageEngaged??u.isPageEngaged?.()??true),A=computed(()=>rr(s.value.activeConversation,t.conversation)),G=computed(()=>({...qe,...t.viewportOptions})),Y=computed(()=>{let r=t.initialViewportOptions.maxFillPages??ze.maxFillPages;return {enabled:t.initialViewportOptions.enabled??ze.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):ze.maxFillPages}}),H=computed(()=>!A.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),Z=computed(()=>A.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:u.formatDate,leadingItems:u.leadingItems?.(),beforeMessageItems:u.beforeMessageItems}):[]),k=computed(()=>Z.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ee(){z!==void 0&&(clearTimeout(z),z=void 0),J!==void 0&&(clearTimeout(J),J=void 0);}function c(r=false){if(ee(),U.value=false,r){f.value?.clearActiveDate(),_.value="";return}J=setTimeout(()=>{J=void 0,!U.value&&(f.value?.clearActiveDate(),_.value="");},tr);}function h(r){if(r===null){c();return}ee(),_.value=r.label,U.value=true;let d=G.value.activeDateIdleDelay,g=Number.isFinite(d)?Math.max(0,d):qe.activeDateIdleDelay;z=setTimeout(()=>{z=void 0,c();},g);}async function p(r,d){t.hooks?.beforeAction?.(r);try{let g=await d();return t.hooks?.afterAction?.(r,g),g}catch(g){throw t.hooks?.onError?.(r,g),g}}function v(){return !A.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):p({kind:"load-older"},()=>u.actions.loadOlder())}function D(){let r=u.actions.loadNewer,d=s.value.loadingNewer??s.value.loading;return !A.value||d||!s.value.hasNewer||r===void 0?Promise.resolve(0):p({kind:"load-newer"},()=>r())}async function j(r){for(let d=0;d<er;d+=1){if(!A.value)return;let g=r==="older"?s.value.hasOlder:s.value.hasNewer,y=r==="older"?s.value.olderError:s.value.newerError;if(!g||y!==null||(r==="older"?await v():await D())>0)return;let x=r==="older"?s.value.hasOlder:s.value.hasNewer,N=r==="older"?s.value.olderError:s.value.newerError;if(!x||N!==null)return}}async function q(){return !A.value||u.actions.loadNewer===void 0?0:p({kind:"load-newer"},()=>u.actions.retryNewer?.()??u.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function $(){if(!A.value)return 0;let r=H.value;S="";let d;try{d=await p({kind:"retry-older"},()=>u.actions.retryOlder?.()??u.actions.loadOlder({force:!0}));}catch(g){throw H.value===r&&(S=r),g}return C.value||(l=null,pe()),d}async function Ae(){if(!A.value)return false;let r=await p({kind:"jump-to-latest"},()=>u.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow));return r&&(await nextTick(),f.value?.scrollToLatest()),r}function Re(r){M.value=r.isAtBottom,V.value=r.newMessageCount,pe();}function Oe(r,d){return f.value?.scrollToMessage(r,d)??false}function oe(r,d){return !F&&o===d&&H.value===r&&A.value}async function re(r,d,g,y){for(let O=0;O<60;O+=1){if(!oe(r,d))return false;if(Oe(g,y))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(x=>window.requestAnimationFrame(()=>x()));}return false}async function He(r,d,g){let y=f.value;if(y===null||!y.isMeasurable()||y.isScrollable())return true;let O=0,x=!s.value.hasOlder,N=!s.value.hasNewer||u.actions.loadNewer===void 0,me=async()=>(await nextTick(),await nextTick(),re(r,d,g,{behavior:"auto",block:"center"})),ie=async ne=>{if(!oe(r,d)||O>=Y.value.maxFillPages)return false;let he=0;if(ne==="older"){if(x||!s.value.hasOlder)return false;he=await v(),x=!s.value.hasOlder;}else {if(N||!s.value.hasNewer)return false;y.prepareHistoryPageAppend();try{he=await D();}catch(Ve){throw y.cancelHistoryPageAppend(),Ve}he<=0&&!s.value.hasNewer&&y.cancelHistoryPageAppend(),N=!s.value.hasNewer;}return O+=1,he>0?me():!(ne==="older"?x:N)};!x&&!await ie("older")&&(x=true),!N&&!await ie("newer")&&(N=true);let Ie="older";for(;oe(r,d)&&O<Y.value.maxFillPages&&y.isMeasurable()&&!y.isScrollable()&&(!x||!N);){let ne=Ie==="older"?x?"newer":"older":N?"older":"newer";Ie=ne==="older"?"newer":"older",await ie(ne)||(ne==="older"?x=true:N=true);}return oe(r,d)}async function ae(r,d={behavior:"auto",block:"center"}){if(!A.value||r==="")return false;let g=H.value,y=++o;if(!k.value.includes(r)){let N=u.actions.loadAround;if(N===void 0||!await p({kind:"locate-message",messageId:r},()=>N(r))||!oe(g,y))return false}return !await re(g,y,r,{...d,behavior:"auto"})||!await He(g,y,r)?false:re(g,y,r,d)}function Se(){w!==void 0&&(clearTimeout(w),w=void 0);}function fe(){if(Se(),!C.value)return;let r=t.readActions;if(r===void 0||m.length===0)return;let d=Number.isFinite(G.value.visibleReadDelay)?Math.max(0,G.value.visibleReadDelay):qe.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!A.value||!X.value)return;let g=m[m.length-1];if(g===void 0)return;let y=r.resolveTarget===void 0?g:r.resolveTarget(g);y!=null&&Promise.resolve(r.markRead(y)).catch(O=>{t.hooks?.onError?.({kind:"visible-range",messageIds:m},O);});},d);}function ye(r){m=Object.freeze([...r]);let d={kind:"visible-range",messageIds:m};t.hooks?.beforeAction?.(d);try{u.actions.onVisibleRange?.(m),t.hooks?.afterAction?.(d,void 0);}catch(g){throw t.hooks?.onError?.(d,g),g}C.value?fe():pe();}function se(r,d){return !F&&R===d&&H.value===r&&!L}function le(r,d){se(r,d)&&(b=r,B=ge(s.value.entryUnread),C.value=true,fe());}function ge(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function be(r,d,g){for(let y=0;y<60;y+=1){if(!se(r,d))return false;if(f.value?.scrollToMessage(g,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(x=>window.requestAnimationFrame(()=>x()));}return false}function pe(){let r=H.value,d=ge(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null||b===r&&(B===d||L)||S===r||l!==null)return;if(!Y.value.enabled){b=r,B=d,C.value=true,fe();return}let g=++R;L=false,C.value=false;let y=(async()=>{if(await nextTick(),!se(r,g))return;let O=f.value;if(O===null||!O.isMeasurable())return;let x=s.value.entryUnread;if(x.state==="located"&&!k.value.includes(x.firstMessageId))return;let N=x.state==="located"?await be(r,g,x.firstMessageId):false;if(x.state==="located"&&!N)return;N||O.scrollToLatest();let me=0;for(;se(r,g)&&me<Y.value.maxFillPages&&s.value.hasOlder&&O.isMeasurable()&&!O.isScrollable();)if(await v(),!se(r,g)||(me+=1,await nextTick(),await nextTick(),!O.isMeasurable()))return;if(!se(r,g)||!O.isMeasurable())return;let ie=s.value.entryUnread;if(ie.state==="located"){if(!k.value.includes(ie.firstMessageId)||!await be(r,g,ie.firstMessageId))return}else O.scrollToLatest();await nextTick(),le(r,g);})().catch(()=>{H.value===r&&(S=r);}).finally(()=>{l===y&&(l=null);});l=y;}function ve(r){R+=1,l=null,L=false,C.value=r,(b="",B="",S=""),Se();}function Pe(){if(C.value)return;let r=H.value;L=true,R+=1,l=null,b=r,C.value=true,fe();}let xe=Object.freeze({getViewportElement:()=>f.value?.getViewportElement()??null,loadOlder:v,retryOlder:$,loadNewer:D,retryNewer:q,jumpToLatest:Ae,scrollToMessage:Oe,locateMessage:ae,focusViewport:()=>f.value?.focusViewport()});return a(xe),watch(X,r=>{r&&C.value?fe():Se();}),watch([()=>s.value.activeRemoteMessageRevision??0,f,H],()=>{let r=f.value;if(r===null||!A.value)return;let d=u.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(d,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:W.value})&&(M.value=false);},{flush:"post"}),watch([H,()=>s.value.loading,()=>s.value.error,()=>k.value.length,()=>s.value.hasOlder,()=>ge(s.value.entryUnread),Y],([r,d,g,,,y],[O,,,,,x])=>{if(r!==O&&(o+=1,ve(false),c(true),f.value?.clearNewMessageBadge(),V.value=0,M.value=true),r!==""&&r===O&&y!==x&&!L&&y.startsWith("located:")&&(b="",B="",C.value=false),r===""||g!==null){ve(false);return}d||pe();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{F=true,o+=1,ve(false),c(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:Z.value,actions:xe},d=[T.header?.(r),T["before-list"]?.(r)];if(!A.value)d.push(T.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)d.push(T.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)d.push(T.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)d.push(T.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let g=h$1(Ue,{ref:f,messageIds:k.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:G.value.followThreshold,olderPrefetchThreshold:G.value.olderPrefetchThreshold,visibleMargin:G.value.visibleMargin,activeDateOffset:G.value.activeDateOffset,activeDateEnabled:T["active-date"]!==void 0,resizeFollowEnabled:C.value,followNewMessages:W.value,shouldFollowAppendedMessage:y=>{let O=s.value.messages.find(x=>x.id===y);return O===void 0?false:u.shouldFollowMessage?.(O)===true},onReachStart:()=>{j("older").catch(()=>{});},onReachEnd:()=>{j("newer").catch(()=>{});},onSettled:Re,onUserScroll:Pe,onActiveDateChange:h,onVisibleRange:ye,onNewMessageCount:y=>{V.value=y;}},{default:()=>[T["viewport-before"]?.(r),h$1(Ke,{items:Z.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:T.item,"date-separator":T["date-separator"],"entry-unread":T["entry-unread"],encryption:T.encryption,system:T.system,message:T.message,"recalled-message":T["recalled-message"],"deleted-message":T["deleted-message"],"unsupported-body":T["unsupported-body"]}),T["viewport-after"]?.(r)]});d.push(h$1("div",{"data-im-thread-viewport-shell":""},[T["active-date"]?.({label:_.value,visible:U.value&&_.value!==""}),g])),s.value.error!==null&&d.push(T.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return d.push(T["after-list"]?.(r),T["jump-to-latest"]?.({...r,count:V.value,visible:!M.value||s.value.isHistoryWindow}),T["context-menu"]?.(r),T.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},d)}}});function or(t){let a=new Map;for(let u of t){if(a.has(u.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${u.kind}`);a.set(u.kind,u.component);}let T=Object.freeze([...a.keys()]);return Object.freeze({kinds:T,resolve:u=>a.get(u)})}function It(t,a){if(t.width<=0||t.height<=0)return 0;let T=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),u=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,T*u/(t.width*t.height))}function ir(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 Ye(t){let a=Math.max(0,t.scrollIdleMs??140),T=Math.max(0,t.visibilityDwellMs??120),u=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),f=Math.max(0,t.revealMarginPx??0),V=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,m=new Map,w=new Set,R=new Set,o=new Set,l=null,b=null,B=null,S=false,L=false,F=false,C,_;function U(){C!==void 0&&clearTimeout(C),C=void 0;}function z(){_!==void 0&&clearTimeout(_),_=void 0;}function J(c=false){if(!c&&b!==null||l===null)return;let h=l.getBoundingClientRect(),p=ir(h,f);for(let[v,D]of M){let j=v.getBoundingClientRect();D.ratio=It(j,h),D.intersecting=D.ratio>0,D.revealIntersecting=f>0?It(j,p)>0:D.intersecting&&D.ratio>=u;}}function s(c){return c.intersecting&&c.ratio>=u}function W(){for(let c of M.values())!c.revealIntersecting||w.has(c.key)||(w.add(c.key),t.onRevealed?.(c.item));}function X(c){let h=new Set(c.map(v=>v.key));if(h.size!==o.size||[...h].some(v=>!o.has(v))){o.clear();for(let v of h)o.add(v);t.onSettledVisibleChange?.(c.map(v=>v.item));}}function A(){if(L||S)return;J(),W();let c=l?.getBoundingClientRect(),h=c===void 0?0:(c.top+c.bottom)/2,p=[...M.entries()].filter(([,v])=>s(v)).sort(([v],[D])=>{let j=v.getBoundingClientRect(),q=D.getBoundingClientRect();return Math.abs((j.top+j.bottom)/2-h)-Math.abs((q.top+q.bottom)/2-h)}).slice(0,V).map(([,v])=>v);X(p);for(let v of p)R.has(v.key)||(R.add(v.key),t.onActivated?.(v.item));}function G(){L||S||(z(),_=setTimeout(()=>{_=void 0,A();},T));}function Y(){L||(H(true),J(),W(),X([]),z(),U(),C=setTimeout(()=>{C=void 0,H(false),G();},a));}function H(c){S!==c&&(S=c,t.onScrollingChange?.(c));}function Z(){l?.removeEventListener("scroll",Y),b?.disconnect(),B?.disconnect(),b=null,B=null,l=null;}function k(c=true){if(L)return;let h=t.getRoot();if(!(h===l&&l!==null)){if(Z(),l=h,l===null){c&&!F&&(F=true,Promise.resolve().then(()=>{F=false,L||(k(false),G());}));return}if(l.addEventListener("scroll",Y,{passive:true}),typeof IntersectionObserver<"u"){b=new IntersectionObserver(p=>{for(let v of p){let D=M.get(v.target);D!==void 0&&(D.intersecting=v.isIntersecting,D.ratio=v.intersectionRatio,f===0&&(D.revealIntersecting=v.isIntersecting&&v.intersectionRatio>=u));}W(),G();},{root:l,threshold:[0,u,1]}),f>0&&(B=new IntersectionObserver(p=>{for(let v of p){let D=M.get(v.target);D!==void 0&&(D.revealIntersecting=v.isIntersecting);}W();},{root:l,rootMargin:`${f}px 0px`,threshold:0}));for(let p of M.keys())b.observe(p);for(let p of M.keys())B?.observe(p);}else J(),W();}}function ee(c){w.delete(c),R.delete(c),o.delete(c);}return {register(c,h){if(L)return;let p=t.getKey(c),v=w.has(p),D=R.has(p),j=h===null?void 0:M.get(h);j!==void 0&&j.key!==p&&(m.delete(j.key),M.delete(h),ee(j.key));let q=m.get(p);if(q!==void 0&&q!==h&&(b?.unobserve(q),B?.unobserve(q),M.delete(q),m.delete(p)),h===null){q!==void 0&&(b?.unobserve(q),B?.unobserve(q),M.delete(q),m.delete(p)),ee(p);return}let $=M.get(h);if($?.key===p&&$.item===c){k();return}M.set(h,{item:c,key:p,intersecting:$?.key===p?$.intersecting:false,ratio:$?.key===p?$.ratio:0,revealIntersecting:$?.key===p?$.revealIntersecting:false}),m.set(p,h),k(),b?.observe(h),B?.observe(h),J(true),W(),v&&t.onRevealed?.(c),D?t.onActivated?.(c):G();},isRevealed:c=>w.has(t.getKey(c)),isActivated:c=>R.has(t.getKey(c)),isSettledVisible:c=>o.has(t.getKey(c)),isScrolling:()=>S,notifyScroll:Y,refresh(){k(),J(true),W(),G();},reset(){U(),z(),H(false),X([]),Z(),M.clear(),m.clear(),w.clear(),R.clear();},dispose(){L||(U(),z(),H(false),X([]),Z(),M.clear(),m.clear(),w.clear(),R.clear(),L=true);}}}function ar(t){let a=new Map,T=new Map,u=false,f=m=>{let w=a.get(m.channel);return w===void 0?m.channel:`${m.channel}\0${w.getKey(m.item)}`},V=Ye({getRoot:t.getRoot,getKey:f,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:m=>{for(let w of a.values())w.onScrollingChange?.(m);},onRevealed:m=>a.get(m.channel)?.onRevealed?.(m.item),onActivated:m=>a.get(m.channel)?.onActivated?.(m.item),onSettledVisibleChange:m=>{for(let[w,R]of a){let o=m.filter(b=>b.channel===w).map(b=>b.item),l=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(l);}}});function M(m){return w=>{if(u)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(m))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${m}`);a.set(m,w);let R=new Map;T.set(m,R);let o=false,l=S=>({channel:m,item:S});function b(){for(let S of R.values())V.register(S.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(S,L){if(o||u)return;let F=w.getKey(S),C=R.get(F);if(L===null){C!==void 0&&(V.register(C.target,null),R.delete(F));return}let _=l(S);R.set(F,{target:_,element:L}),V.register(_,L);},isRevealed:S=>V.isRevealed(l(S)),isActivated:S=>V.isActivated(l(S)),isSettledVisible:S=>V.isSettledVisible(l(S)),isScrolling:V.isScrolling,notifyScroll:V.notifyScroll,refresh:V.refresh,reset:b,dispose(){o||(b(),o=true,a.delete(m),T.delete(m));}}}}return {createFactory:M,refresh:V.refresh,dispose(){if(!u){for(let m of T.values())for(let w of m.values())V.register(w.target,null);T.clear(),a.clear(),V.dispose(),u=true;}}}}export{_e as ImThreadBodySwitch,Ke as ImThreadItems,nr as ImThreadSurface,Ue as ImThreadViewport,Xt as createImThreadSurfaceContext,or as createMessageRendererRegistry,ar as createThreadVisibilityTargetGroup,Ye as createThreadVisibilityTargets,Jt as provideImThreadSurfaceContext,Vt as useImText,Ge as useImThreadSurfaceContext,Dt as useOptionalImThreadReadActions};
|
package/dist/chat-kit.d.ts
CHANGED
|
@@ -2120,6 +2120,69 @@ type ImEvent = {
|
|
|
2120
2120
|
callId: string;
|
|
2121
2121
|
peerId: string;
|
|
2122
2122
|
reason: ImDirectCallFailReason;
|
|
2123
|
+
}
|
|
2124
|
+
/** 群会议来电;`expired` 为 true 时已过 30s,不得振铃。 */
|
|
2125
|
+
| {
|
|
2126
|
+
type: 'group-call:incoming';
|
|
2127
|
+
conversation: ConversationRef<'group'>;
|
|
2128
|
+
callId: string;
|
|
2129
|
+
groupId: string;
|
|
2130
|
+
inviterId: string;
|
|
2131
|
+
inviteIds: readonly string[];
|
|
2132
|
+
createdAt: number;
|
|
2133
|
+
expired: boolean;
|
|
2134
|
+
}
|
|
2135
|
+
/** 有人响应群会议邀请。 */
|
|
2136
|
+
| {
|
|
2137
|
+
type: 'group-call:answered';
|
|
2138
|
+
conversation: ConversationRef<'group'>;
|
|
2139
|
+
callId: string;
|
|
2140
|
+
groupId: string;
|
|
2141
|
+
userId: string;
|
|
2142
|
+
agreed: boolean;
|
|
2143
|
+
}
|
|
2144
|
+
/** 有人加入群会议;会中再邀时 `isInvite` 为 true。 */
|
|
2145
|
+
| {
|
|
2146
|
+
type: 'group-call:joined';
|
|
2147
|
+
conversation: ConversationRef<'group'>;
|
|
2148
|
+
callId: string;
|
|
2149
|
+
groupId: string;
|
|
2150
|
+
userId: string;
|
|
2151
|
+
inviteIds: readonly string[];
|
|
2152
|
+
isInvite: boolean;
|
|
2153
|
+
}
|
|
2154
|
+
/** 有人退出群会议,会议本身可能仍在进行。 */
|
|
2155
|
+
| {
|
|
2156
|
+
type: 'group-call:left';
|
|
2157
|
+
conversation: ConversationRef<'group'>;
|
|
2158
|
+
callId: string;
|
|
2159
|
+
groupId: string;
|
|
2160
|
+
userId: string;
|
|
2161
|
+
}
|
|
2162
|
+
/** 整场群会议结束。 */
|
|
2163
|
+
| {
|
|
2164
|
+
type: 'group-call:finished';
|
|
2165
|
+
conversation: ConversationRef<'group'>;
|
|
2166
|
+
callId: string;
|
|
2167
|
+
groupId: string;
|
|
2168
|
+
userId: string;
|
|
2169
|
+
}
|
|
2170
|
+
/** 被邀人忙线。 */
|
|
2171
|
+
| {
|
|
2172
|
+
type: 'group-call:busy';
|
|
2173
|
+
conversation: ConversationRef<'group'>;
|
|
2174
|
+
callId: string;
|
|
2175
|
+
groupId: string;
|
|
2176
|
+
userId: string;
|
|
2177
|
+
hintUserId: string;
|
|
2178
|
+
}
|
|
2179
|
+
/** 主叫 createRoom ACK 失败。 */
|
|
2180
|
+
| {
|
|
2181
|
+
type: 'group-call:failed';
|
|
2182
|
+
conversation: ConversationRef<'group'>;
|
|
2183
|
+
callId: string;
|
|
2184
|
+
groupId: string;
|
|
2185
|
+
reason: 'ack-error';
|
|
2123
2186
|
} | {
|
|
2124
2187
|
type: 'notification';
|
|
2125
2188
|
cmdId: number;
|
|
@@ -2176,7 +2239,7 @@ type ImDiagnosticLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
|
2176
2239
|
/** 诊断产生层;同一 operation 可跨层复用 traceId/operationId。 */
|
|
2177
2240
|
type ImDiagnosticLayer = 'sdk' | 'core' | 'chat-kit' | 'pinia' | 'worker';
|
|
2178
2241
|
/** 稳定诊断分类。分类用于构造 payload 前过滤,不能作为业务状态分支。 */
|
|
2179
|
-
type ImDiagnosticCategory = 'session' | 'connection' | 'protocol' | 'sync' | 'conversation' | 'history' | 'message' | 'outbox' | 'draft' | 'search' | 'media' | 'profile' | 'storage' | 'crypto';
|
|
2242
|
+
type ImDiagnosticCategory = 'session' | 'connection' | 'protocol' | 'sync' | 'conversation' | 'history' | 'message' | 'outbox' | 'draft' | 'search' | 'media' | 'profile' | 'storage' | 'crypto' | 'call';
|
|
2180
2243
|
/** 经过安全过滤的错误快照;不会保留原始 cause 引用。 */
|
|
2181
2244
|
interface ImDiagnosticError {
|
|
2182
2245
|
name?: string;
|
|
@@ -2223,6 +2286,19 @@ interface ImDiagnosticWriter$1<TMessage = ImMessage> {
|
|
|
2223
2286
|
record: (level: ImDiagnosticLevel, layer: ImDiagnosticLayer, category: ImDiagnosticCategory, event: string, context?: () => ImDiagnosticRecordContext<TMessage>) => void;
|
|
2224
2287
|
}
|
|
2225
2288
|
|
|
2289
|
+
type ImGroupCallMemberStatus = 'ringing' | 'in-call';
|
|
2290
|
+
interface ImGroupCallMember {
|
|
2291
|
+
readonly userId: string;
|
|
2292
|
+
readonly status: ImGroupCallMemberStatus;
|
|
2293
|
+
}
|
|
2294
|
+
interface ImGroupCallMeetingSnapshot {
|
|
2295
|
+
readonly groupId: string;
|
|
2296
|
+
readonly callId: string;
|
|
2297
|
+
readonly inviterId: string;
|
|
2298
|
+
readonly members: readonly ImGroupCallMember[];
|
|
2299
|
+
readonly createdAt: number;
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2226
2302
|
/**
|
|
2227
2303
|
* 根据 CHANNEL 角色、生命周期和禁言事实计算稳定访问能力。
|
|
2228
2304
|
*
|
|
@@ -4703,6 +4779,55 @@ interface ImProductEventMap {
|
|
|
4703
4779
|
peerId: string;
|
|
4704
4780
|
reason: 'peer-offline' | 'ack-error';
|
|
4705
4781
|
}>;
|
|
4782
|
+
'group-call:incoming': Readonly<{
|
|
4783
|
+
ref: ConversationRef<'group'>;
|
|
4784
|
+
callId: string;
|
|
4785
|
+
groupId: string;
|
|
4786
|
+
inviterId: string;
|
|
4787
|
+
inviteIds: readonly string[];
|
|
4788
|
+
createdAt: number;
|
|
4789
|
+
expired: boolean;
|
|
4790
|
+
}>;
|
|
4791
|
+
'group-call:answered': Readonly<{
|
|
4792
|
+
ref: ConversationRef<'group'>;
|
|
4793
|
+
callId: string;
|
|
4794
|
+
groupId: string;
|
|
4795
|
+
userId: string;
|
|
4796
|
+
agreed: boolean;
|
|
4797
|
+
}>;
|
|
4798
|
+
'group-call:joined': Readonly<{
|
|
4799
|
+
ref: ConversationRef<'group'>;
|
|
4800
|
+
callId: string;
|
|
4801
|
+
groupId: string;
|
|
4802
|
+
userId: string;
|
|
4803
|
+
inviteIds: readonly string[];
|
|
4804
|
+
isInvite: boolean;
|
|
4805
|
+
}>;
|
|
4806
|
+
'group-call:left': Readonly<{
|
|
4807
|
+
ref: ConversationRef<'group'>;
|
|
4808
|
+
callId: string;
|
|
4809
|
+
groupId: string;
|
|
4810
|
+
userId: string;
|
|
4811
|
+
}>;
|
|
4812
|
+
'group-call:finished': Readonly<{
|
|
4813
|
+
ref: ConversationRef<'group'>;
|
|
4814
|
+
callId: string;
|
|
4815
|
+
groupId: string;
|
|
4816
|
+
userId: string;
|
|
4817
|
+
}>;
|
|
4818
|
+
'group-call:busy': Readonly<{
|
|
4819
|
+
ref: ConversationRef<'group'>;
|
|
4820
|
+
callId: string;
|
|
4821
|
+
groupId: string;
|
|
4822
|
+
userId: string;
|
|
4823
|
+
hintUserId: string;
|
|
4824
|
+
}>;
|
|
4825
|
+
'group-call:failed': Readonly<{
|
|
4826
|
+
ref: ConversationRef<'group'>;
|
|
4827
|
+
callId: string;
|
|
4828
|
+
groupId: string;
|
|
4829
|
+
reason: 'ack-error';
|
|
4830
|
+
}>;
|
|
4706
4831
|
}
|
|
4707
4832
|
/** 从产品事件表推导的全量可判别联合。 */
|
|
4708
4833
|
type ImProductEvent = {
|
|
@@ -4724,6 +4849,50 @@ interface ImEventsApi {
|
|
|
4724
4849
|
on: <TType extends keyof ImProductEventMap>(type: TType, listener: (payload: ImProductEventMap[TType]) => void) => () => void;
|
|
4725
4850
|
}
|
|
4726
4851
|
|
|
4852
|
+
interface ImGroupCallCreateInput {
|
|
4853
|
+
groupId: string;
|
|
4854
|
+
callId: string;
|
|
4855
|
+
inviteIds: readonly string[];
|
|
4856
|
+
}
|
|
4857
|
+
interface ImGroupCallJoinInput {
|
|
4858
|
+
groupId: string;
|
|
4859
|
+
callId: string;
|
|
4860
|
+
inviteIds: readonly string[];
|
|
4861
|
+
isInvite: boolean;
|
|
4862
|
+
}
|
|
4863
|
+
interface ImGroupCallTargetInput {
|
|
4864
|
+
groupId: string;
|
|
4865
|
+
callId: string;
|
|
4866
|
+
}
|
|
4867
|
+
interface ImGroupCallAnswerInput extends ImGroupCallTargetInput {
|
|
4868
|
+
agreed: boolean;
|
|
4869
|
+
}
|
|
4870
|
+
interface ImGroupCallStatusInput extends ImGroupCallTargetInput {
|
|
4871
|
+
isMute: boolean;
|
|
4872
|
+
status: boolean;
|
|
4873
|
+
}
|
|
4874
|
+
interface ImGroupCallBusyInput extends ImGroupCallTargetInput {
|
|
4875
|
+
hintUserId: string;
|
|
4876
|
+
}
|
|
4877
|
+
interface ImGroupCallsApi {
|
|
4878
|
+
/** 发起群会议 (0x4101) */
|
|
4879
|
+
createRoom: (input: ImGroupCallCreateInput) => void;
|
|
4880
|
+
/** 加入群会议 (0x4109) */
|
|
4881
|
+
joinRoom: (input: ImGroupCallJoinInput) => void;
|
|
4882
|
+
/** 响应群会议邀请 (0x4105) */
|
|
4883
|
+
answer: (input: ImGroupCallAnswerInput) => void;
|
|
4884
|
+
/** 退出群会议 (0x410d) */
|
|
4885
|
+
hangup: (input: ImGroupCallTargetInput) => void;
|
|
4886
|
+
/** 结束整场群会议 (0x4111) */
|
|
4887
|
+
finish: (input: ImGroupCallTargetInput) => void;
|
|
4888
|
+
/** 修改状态 (0x4115) */
|
|
4889
|
+
setStatus: (input: ImGroupCallStatusInput) => void;
|
|
4890
|
+
/** 忙线 (0x411d) */
|
|
4891
|
+
busy: (input: ImGroupCallBusyInput) => void;
|
|
4892
|
+
/** 当前群的进行中会议;没有则 null。 */
|
|
4893
|
+
inspectMeeting: (groupId: string) => ImGroupCallMeetingSnapshot | null;
|
|
4894
|
+
}
|
|
4895
|
+
|
|
4727
4896
|
/**
|
|
4728
4897
|
* 当前 prefix/account 本地数据的分类查询和明确清理动作。
|
|
4729
4898
|
* API 区分可重建缓存与整账号 purge,严格按 namespace factory 定位;不存在无边界 `clearAll`。
|
|
@@ -5386,6 +5555,8 @@ interface ImProductClient {
|
|
|
5386
5555
|
interface ImClient extends Omit<ImProductClient, 'capabilities' | 'channels' | 'contacts' | 'conversations' | 'groups'> {
|
|
5387
5556
|
/** internal/testing 与高级宿主使用的单聊音视频信令;稳定 default 产品门面不暴露此能力。 */
|
|
5388
5557
|
readonly calls: ImDirectCallsApi;
|
|
5558
|
+
/** internal/testing 群通话门面。 */
|
|
5559
|
+
readonly groupCalls: ImGroupCallsApi;
|
|
5389
5560
|
/**
|
|
5390
5561
|
* 打开一个拥有独立连续窗口与生命周期的 direct、GROUP 或 CHANNEL 会话句柄。
|
|
5391
5562
|
*
|
package/dist/chat-kit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,b as DEFAULT_LOADING_SHOW_DELAY_MS,t as SPIKE_STEP,p as calculateMediaBox,f as canPromoteMediaPresentationSource,h as captureRuntimeClientOperation,g as captureRuntimeOperation,d as createDelayedLoadingIndicator,n as createLinkMatcher,r as formatFileSize,q as formatMediaDuration,s as getFileExtension,m as hasLinkCandidate,k as highlightSegments,i as mediaService,l as normalizeLinkHref,w as placeholderWaveform,j as readService,v as resampleWaveform,e as resolveBestMediaPresentationSource,a as resolveConversationListPresentation,o as resolveMediaPresentation,u as spikeCountForDuration}from'./chunk-
|
|
1
|
+
export{c as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,b as DEFAULT_LOADING_SHOW_DELAY_MS,t as SPIKE_STEP,p as calculateMediaBox,f as canPromoteMediaPresentationSource,h as captureRuntimeClientOperation,g as captureRuntimeOperation,d as createDelayedLoadingIndicator,n as createLinkMatcher,r as formatFileSize,q as formatMediaDuration,s as getFileExtension,m as hasLinkCandidate,k as highlightSegments,i as mediaService,l as normalizeLinkHref,w as placeholderWaveform,j as readService,v as resampleWaveform,e as resolveBestMediaPresentationSource,a as resolveConversationListPresentation,o as resolveMediaPresentation,u as spikeCountForDuration}from'./chunk-54BDLB6M.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,K as MAX_BATCH_FILES,a as MAX_RECENT_EMOJI_COUNT,g as UNICODE_EMOJI_CATALOG,J as blockReasonForChannelSession,I as blockReasonForChannelState,O as blockReasonForGroupState,R as blockReasonForSession,D as canEditMessage,t as canPinChannelMessage,s as canPinGroupMessage,u as canPinMessage,C as canRecallMessage,Z as cancelMediaUpload,r as createChatRuntime,p as createEmojiMatcher,F as decideConversationAction,H as decideMemberTargetAction,G as decideMessageAction,l as emojiAssetUrl,n as emojiUrlByCode,xa as fetchConversationFileBatch,ya as fetchConversationImageBatch,va as fetchConversationMessageBatch,za as fetchConversationVideoBatch,Aa as fetchConversationVoiceBatch,Ba as fetchNextConversationSearchBatch,aa as forwardService,o as hasEmojiCandidate,N as isGifFile,v as isPinnedMessageProtected,V as isVoiceStorageConfigured,L as mediaBatchBudgetBytes,fa as messageService,e as parseUnicodeEmojiCode,ka as pinnedMessageService,d as prependRecentEmoji,ua as profileService,U as replaceInterruptedMediaFile,P as requiresConversationEncryption,y as resolveChannelMemberAvatarUrl,x as resolveChannelMemberDisplayName,k as resolveEmojiToken,B as resolveFriendDisplayName,la as resolveImProfileAccessDestination,w as resolveMemberDisplayName,A as resolvePublicNickname,z as resolveSenderAvatarUrl,q as resolveStandaloneEmojiMessage,h as resolveUnicodeEmoji,_ as retryMessage,M as runMediaSendBatch,Y as sendAsFilesBatch,E as sendBlockReasonForDecision,T as sendMediaFile,X as sendMediaFilesBatch,S as sendText,W as sendVoice,Q as supportsConversationMention,f as unicodeEmojiTextFromCode}from'./chunk-TD3JY2WE.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-MKV7J6WB.js';import'./chunk-TQF5HUEX.js';import'./chunk-DFE2F575.js';import'./chunk-6QR5GVQ3.js';export{fa as canTransmit,da as canTransmitByType,ea as canTransmitContent,ca as requiresForwardTypeConfirmation}from'./chunk-BO5YFCS4.js';import'./chunk-WOT6VMZA.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {p as p$1}from'./chunk-RZBGTY6A.js';import {e,a as a$1}from'./chunk-ATIQZ5XZ.js';import {j,h}from'./chunk-VP466VS6.js';import {U as U$1}from'./chunk-MHIB4PGT.js';import {a}from'./chunk-WOT6VMZA.js';var N=p$1();function H(e$1,n){let t=n.suppressDraft===true?null:e$1.draft,i=t?.text.trim()??"",r,a="",s="";return t!==null?r=i===""?[]:G(e$1,i,n.locale):$(e$1)?r=y(K(e$1,n)):e$1.lastMessageSummary?.kind==="channel-moderation-deleted"||e$1.lastMessageDeletedForEveryone!==void 0?r=y(x(e$1,e$1.lastMessageSummary?.kind==="channel-moderation-deleted"?e$1.lastMessageSummary:{kind:"channel-moderation-deleted",by:e$1.lastMessageDeletedForEveryone?.by??""},n)):e$1.lastMessageSummary?.kind==="recalled"||e$1.lastMessageRecalled!==void 0?r=y(x(e$1,e$1.lastMessageSummary?.kind==="recalled"?e$1.lastMessageSummary:{kind:"recalled",by:e$1.lastMessageRecalled?.by??""},n)):(a=z(e$1,n),s=e$1.mentionUnreadCount>0?n.labels.mentionBadge:"",r=W(e$1,n)),{preview:`${s}${a}${r.map(l=>l.text).join("")}`||(t===null?n.labels.emptyPreview:""),previewSegments:r,senderPrefix:a,mentionBadge:s,time:e(a$1(t?.updatedAt,e$1.timestamp),{locale:n.locale,...n.now===void 0?{}:{now:n.now}}),hasDraft:t!==null}}function y(e){return [{kind:"text",text:e}]}function O(e){return e.map(n=>n.kind==="emoji"?{kind:"emoji",text:n.text,code:n.code}:{kind:n.kind,text:n.text})}function G(e,n,t){let i=e.draft?.mentions??[],r=[],a={},s=false;for(let l of i){if(l.userId==="0"){s=true;continue}r.includes(l.userId)||r.push(l.userId),l.displayName.trim()!==""&&(a[l.userId]=l.displayName);}let o=s||r.length>0?{atAll:s,atUserIds:r,...Object.keys(a).length===0?{}:{atUsersName:a}}:void 0;return O(U$1(n,{mention:o,resolveName:l=>a[l]??l,atAllDisplay:j(t),matchers:[N]}))}function W(e,n){let t=e.lastMessageSummary;if(t!==void 0&&t.kind!=="text")return y(x(e,t,n));let i=(t?.kind==="text"?t.text:e.lastMessagePreview).trim();if(i==="")return y(n.labels.emptyPreview);let r=e.lastMessageMention?.atUsersName;return O(U$1(i,{mention:e.lastMessageMention===void 0?void 0:{...e.lastMessageMention,atUserIds:[...e.lastMessageMention.atUserIds]},resolveName:a=>n.resolveName(e.ref,a,r?.[a]),selfId:n.accountId,atAllDisplay:j(n.locale),matchers:[N]}))}function x(e,n,t){return h(q(n),{locale:t.locale,selfId:t.accountId,resolveName:i=>t.resolveName(e.ref,i)})}function $(e){return e.lastMessageSummary?.kind==="system"||e.lastMessageSenderId==="system"||e.lastMessageSystemEvent!==void 0}function K(e,n){return e.lastMessageSummary?.kind==="system"?x(e,e.lastMessageSummary,n):e.lastMessageSystemEvent===void 0?e.lastMessagePreview.trim()||n.labels.emptyPreview:x(e,{kind:"system",system:{eventType:e.lastMessageSystemEvent,...e.lastMessageSystemTargetsSelf===true?{targetUserIds:[n.accountId]}:{},...e.lastMessagePreview.trim()===""?{}:{fallbackText:e.lastMessagePreview.trim()}}},n)}function z(e,n){let t=e.lastMessageSenderId;return e.ref.conversationType!=="group"&&e.ref.conversationType!=="channel"||t===void 0||t===""||t==="system"?"":`${t===n.accountId?n.labels.selfSender:n.resolveName(e.ref,t)}: `}function q(e){return e.kind!=="system"?e:{kind:"system",system:{eventType:e.system.eventType,...e.system.operatorId===void 0?{}:{operatorId:e.system.operatorId},...e.system.targetUserIds===void 0?{}:{targetUserIds:[...e.system.targetUserIds]},...e.system.fallbackText===void 0?{}:{fallbackText:e.system.fallbackText}}}}var J=160,Q=220;function Y(e){let n=Math.max(0,e.showDelayMs??160),t=Math.max(0,e.minimumVisibleMs??220),i=e.now??Date.now,r=e.setTimer??((d,M)=>setTimeout(d,M)),a=e.clearTimer??(d=>clearTimeout(d)),s="",o=false,l=false,v=0,c,u,f=false;function g(){c!==void 0&&a(c),c=void 0;}function m(){u!==void 0&&a(u),u=void 0;}function h(d){l!==d&&(l=d,v=d?i():0,e.onVisibleChange(d));}function I(d){g(),c=r(()=>{c=void 0,!(f||!o||s!==d)&&h(true);},n);}function j(){if(g(),!l)return;let d=t-Math.max(0,i()-v);if(d<=0){h(false);return}m(),u=r(()=>{u=void 0,!(f||o)&&h(false);},d);}return {update(d,M){if(f)return;if(s!==M){s=M,o=d,g(),m(),h(false),d&&I(M);return}if(o=d,d){m(),!l&&c===void 0&&I(M);return}j();},dispose(){f||(f=true,o=false,g(),m(),h(false));}}}var S={placeholder:0,thumbnail:1,local:2,original:3};function X(e){let n;for(let t of e)t.value!==void 0&&(n===void 0||S[t.quality]>S[n.quality])&&(n=t);return n}function Z(e,n){return S[n]>=S[e]}function ee(e){let n=e.getGeneration();return Object.freeze({isCurrent:()=>e.getGeneration()===n})}function T(e){let n=e.getClient();if(n===null)return null;let t=e.getGeneration();return Object.freeze({client:n,isCurrent:()=>e.getGeneration()===t&&e.getClient()===n})}var _={};a(_,{acquireMediaBlob:()=>te,detectImageMime:()=>D,detectVideoMime:()=>F,loadCachedImageObjectUrl:()=>ae,loadCachedVideoObjectUrl:()=>ie,loadFileObjectUrl:()=>se,loadImageObjectUrl:()=>oe,loadVideoObjectUrl:()=>re,loadVoiceBytes:()=>ne});function A(e){if(e.conversationType!=="supergroup")return {conversation:{conversationType:e.conversationType,conversationId:e.conversationId},messageId:e.id}}async function C(e,n,t){let i=e.getClient(),r=A(n);if(i===null||r===void 0)throw new Error("media download unavailable");let a=t===void 0?void 0:i.media.subscribe(s=>{let o=s.find(l=>l.direction==="download"&&l.messageId===r.messageId&&l.ref.conversationType===r.conversation.conversationType&&l.ref.conversationId===r.conversation.conversationId);o!==void 0&&t(o.percent);});try{return await i.media.download(r)}finally{a?.();}}function D(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70?"image/gif":e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}async function U(e){let n=new Uint8Array(await e.slice(0,12).arrayBuffer()),t=D(n);return t===null?null:URL.createObjectURL(e.type===t?e:e.slice(0,e.size,t))}function F(e){return e.length>=4&&e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163?"video/webm":(e.length>=8&&e[4]===102&&e[5]===116&&e[6]===121&&e[7]===112,"video/mp4")}function te(e,n){return e.acquireMediaBlob({conversationType:n.conversationType,conversationId:n.conversationId,messageId:n.id})}async function ne(e,n,t){let i=e.getClient(),r=n.body.voice;if(i===null||r===void 0)return null;let a=e.getSelfVoiceBytes(n.id);if(a!==void 0)return a;let s=e.getGeneration();try{let o=new Uint8Array(await(await C(e,n)).arrayBuffer());return o.length===0?(e.getGeneration()===s&&t.setNote(t.t("media.voiceLoadEmpty")),null):o}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.voiceLoadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}async function re(e,n,t,i){let r=e.getClient(),a=n.body.video;if(r===null||a===void 0)return null;let s=e.getGeneration();try{let o=await C(e,n,i);if(o.size===0)return e.getGeneration()===s&&t.setNote(t.t("media.videoOpenEmpty")),null;let l=URL.createObjectURL(o);return e.getGeneration()!==s?(URL.revokeObjectURL(l),null):l}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.videoLoadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}async function ie(e,n){let t=e.getClient(),i=A(n);if(t===null||i===void 0||n.body.video===void 0)return null;let r=e.getGeneration();try{let a=await t.media.getCached(i);if(a===null||a.size===0||e.getGeneration()!==r)return null;let s=new Uint8Array(await a.slice(0,12).arrayBuffer()),o=a.type||F(s);return e.getGeneration()!==r?null:URL.createObjectURL(a.type===o?a:a.slice(0,a.size,o))}catch{return null}}async function oe(e,n,t){let i=e.getClient(),r=n.body.image;if(i===null||r===void 0)return null;let a=e.getGeneration();try{let s=await C(e,n),o=await U(s);return o===null?(e.getGeneration()===a&&t.setNote(t.t("media.imageInvalid",{size:s.size})),null):e.getGeneration()!==a?(URL.revokeObjectURL(o),null):o}catch(s){return e.getGeneration()===a&&t.setNote(t.t("media.imageLoadFailed",{reason:s instanceof Error?s.message:String(s)})),null}}async function ae(e,n){let t=e.getClient(),i=A(n);if(t===null||i===void 0||n.body.image===void 0)return null;let r=e.getGeneration();try{let a=await t.media.getCached(i);if(a===null||a.size===0||e.getGeneration()!==r)return null;let s=await U(a);return s===null?null:e.getGeneration()!==r?(URL.revokeObjectURL(s),null):s}catch{return null}}async function se(e,n,t,i){let r=e.getClient(),a=n.body.file;if(r===null||a===void 0)return null;let s=e.getGeneration();try{let o=await C(e,n,i);if(o.size===0)return e.getGeneration()===s&&t.setNote(t.t("media.fileDownloadEmpty")),null;let l=URL.createObjectURL(o);return e.getGeneration()!==s?(URL.revokeObjectURL(l),null):l}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.fileDownloadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}var B={};a(B,{markReadUpTo:()=>le});function le(e,n,t,i){let r=T(e);if(r===null||n.conversationId===""||t==="")return;let a=r.client.conversations.list().find(o=>o.id===n.conversationId&&o.type===n.conversationType);if(a?.manuallyUnread===true&&a.unreadCount<=0){r.client.conversations.markConversationRead(n).catch(o=>{r.isCurrent()&&e.getDiagnostics().record("warn","chat-kit","conversation","clear-manual-unread-skipped",()=>({conversation:n,error:{message:"\u6E05\u9664\u624B\u5DE5\u672A\u8BFB\u63D0\u9192\u5931\u8D25",data:o}}));});return}if(a?.type==="group"&&a.unreadCount<=0)return;let s=i.getConversationHandle();s===void 0||s.ref.conversationId!==n.conversationId||s.ref.conversationType!==n.conversationType||s.markRead(t).catch(o=>{r.isCurrent()&&i.getConversationHandle()===s&&e.getDiagnostics().record("warn","chat-kit","message","mark-read-skipped",()=>({conversation:n,data:{messageId:t},error:{message:"markRead \u8DF3\u8FC7",data:o}}));});}function de(e,n){if(n.length===0)return [{text:e,hit:false}];let t=[],i=0;for(let[r,a]of n)r>i&&t.push({text:e.slice(i,r),hit:false}),t.push({text:e.slice(r,a),hit:true}),i=a;return i<e.length&&t.push({text:e.slice(i),hit:false}),t}var ce=/\b(?:https?:\/\/|www\.)[^\s<>"')】]+/gi,me=/\b(?:https?:\/\/|www\.)/i,ue=/[),.!?;:,。!?;:、)】]+$/u;function V(e){let n=/^www\./i.test(e)?`https://${e}`:e;try{let t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function fe(e){return me.test(e)}function pe(){return e=>{let n=[];for(let t of e.matchAll(ce)){if(t.index===void 0)continue;let i=t[0].replace(ue,"");if(i==="")continue;let r=V(i);r!==void 0&&n.push({start:t.index,end:t.index+i.length-1,segment:{kind:"link",text:i,href:r}});}return n}}function p(e,n){if(!Number.isFinite(e)||e<=0)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${n} \u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6709\u9650\u6570`)}function ge(e){if(p(e.fallbackAspectRatio,"fallbackAspectRatio"),!Array.isArray(e.rules)||e.rules.length===0)throw new Error("\u5A92\u4F53\u5C55\u793A\u7B56\u7565 rules \u4E0D\u80FD\u4E3A\u7A7A");let n=new Set;e.rules.forEach((t,i)=>{let r=`rules[${i}]`;if(t.id.trim()==="")throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.id \u4E0D\u80FD\u4E3A\u7A7A`);if(n.has(t.id))throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565\u89C4\u5219 id \u91CD\u590D\uFF1A${t.id}`);if(n.add(t.id),t.minAspectRatio!==void 0&&(!Number.isFinite(t.minAspectRatio)||t.minAspectRatio<0))throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.minAspectRatio \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6709\u9650\u6570`);if(t.maxAspectRatio!==void 0&&p(t.maxAspectRatio,`${r}.maxAspectRatio`),t.minAspectRatio!==void 0&&t.maxAspectRatio!==void 0&&t.minAspectRatio>=t.maxAspectRatio)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r} \u7684\u5BBD\u9AD8\u6BD4\u4E0B\u754C\u5FC5\u987B\u5C0F\u4E8E\u4E0A\u754C`);if(p(t.preferredWidth,`${r}.preferredWidth`),p(t.minWidth,`${r}.minWidth`),p(t.maxWidth,`${r}.maxWidth`),p(t.minHeight,`${r}.minHeight`),p(t.maxHeight,`${r}.maxHeight`),t.minWidth>t.preferredWidth||t.preferredWidth>t.maxWidth)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.preferredWidth \u5FC5\u987B\u4F4D\u4E8E minWidth \u548C maxWidth \u4E4B\u95F4`);if(t.minHeight>t.maxHeight)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.minHeight \u4E0D\u80FD\u5927\u4E8E maxHeight`);if(typeof t.allowUpscale!="boolean")throw new TypeError(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.allowUpscale \u5FC5\u987B\u662F boolean`);if(t.fit!=="cover"&&t.fit!=="contain")throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.fit \u53EA\u652F\u6301 cover \u6216 contain`)});}function he(e){let{intrinsicWidth:n,intrinsicHeight:t,availableWidth:i,policy:r}=e;p(i,"availableWidth"),ge(r);let a=Number.isFinite(n)&&Number.isFinite(t)&&n>0&&t>0,s=a?n/t:r.fallbackAspectRatio,o=r.rules.find(m=>{let h=m.minAspectRatio===void 0||s>=m.minAspectRatio,I=m.maxAspectRatio===void 0||s<m.maxAspectRatio;return h&&I});if(o===void 0)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565\u6CA1\u6709\u5339\u914D\u5BBD\u9AD8\u6BD4 ${s}`);let l=!o.allowUpscale&&a?Math.min(o.preferredWidth,n):o.preferredWidth,v=Math.min(i,o.maxWidth,Math.max(o.minWidth,l)),c=Math.max(1,Math.round(v)),u=c/s,f=Math.min(o.maxHeight,Math.max(o.minHeight,u)),g=Math.max(1,Math.round(f));return {width:c,height:g,aspectRatio:c/g,sourceAspectRatio:s,ruleId:o.id,fit:o.fit,aspectClamped:f!==u}}function ve(e,n,t,i){if(!Number.isFinite(e)||!Number.isFinite(n)||e<=0||n<=0)return null;let r=Math.min(t/e,i/n,1);return {width:`${Math.max(1,Math.round(e*r))}px`,aspectRatio:`${e} / ${n}`}}function Me(e){if(!Number.isFinite(e)||e<=0)return "0:00";let n=Math.floor(e),t=Math.floor(n/3600),i=Math.floor(n%3600/60),r=n%60,a=s=>s.toString().padStart(2,"0");return t>0?`${t}:${a(i)}:${a(r)}`:`${i}:${a(r)}`}function ye(e){if(!Number.isFinite(e)||e<=0)return "0 B";let n=["B","KB","MB","GB","TB"],t=Math.min(n.length-1,Math.floor(Math.log(e)/Math.log(1024))),i=e/1024**t;return `${t===0?i:Math.round(i*10)/10} ${n[t]}`}function xe(e){let n=e.lastIndexOf(".");return n>-1&&n<e.length-1?e.slice(n+1).toLowerCase():""}var Ie=4;function Se(e){let n=Math.min(Math.max(e/1e3,0)/10,1);return Math.round(22+24*n)}function Ce(e,n){if(e.length===0)return Array.from({length:n},()=>0);let t=[],i=(e.length-1)/Math.max(1,n-1);for(let r=0;r<n;r+=1){let a=r*i,s=Math.round(a),o=e[Math.max(0,s-1)]??0,l=e[Math.min(e.length-1,s)]??0,v=e[Math.min(e.length-1,s+1)]??0;t.push((o+l+v)/3);}return t}function be(e,n){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);let i=[];for(let r=0;r<n;r+=1)t=Math.imul(t^t>>>15,2246822519)>>>0,i.push(90+t%111);return i}
|
|
1
|
+
import {p as p$1}from'./chunk-TD3JY2WE.js';import {e,a as a$1}from'./chunk-MKV7J6WB.js';import {j,h}from'./chunk-TQF5HUEX.js';import {X as X$1}from'./chunk-BO5YFCS4.js';import {a}from'./chunk-WOT6VMZA.js';var N=p$1();function H(e$1,n){let t=n.suppressDraft===true?null:e$1.draft,i=t?.text.trim()??"",r,a="",s="";return t!==null?r=i===""?[]:G(e$1,i,n.locale):$(e$1)?r=y(K(e$1,n)):e$1.lastMessageSummary?.kind==="channel-moderation-deleted"||e$1.lastMessageDeletedForEveryone!==void 0?r=y(x(e$1,e$1.lastMessageSummary?.kind==="channel-moderation-deleted"?e$1.lastMessageSummary:{kind:"channel-moderation-deleted",by:e$1.lastMessageDeletedForEveryone?.by??""},n)):e$1.lastMessageSummary?.kind==="recalled"||e$1.lastMessageRecalled!==void 0?r=y(x(e$1,e$1.lastMessageSummary?.kind==="recalled"?e$1.lastMessageSummary:{kind:"recalled",by:e$1.lastMessageRecalled?.by??""},n)):(a=z(e$1,n),s=e$1.mentionUnreadCount>0?n.labels.mentionBadge:"",r=W(e$1,n)),{preview:`${s}${a}${r.map(l=>l.text).join("")}`||(t===null?n.labels.emptyPreview:""),previewSegments:r,senderPrefix:a,mentionBadge:s,time:e(a$1(t?.updatedAt,e$1.timestamp),{locale:n.locale,...n.now===void 0?{}:{now:n.now}}),hasDraft:t!==null}}function y(e){return [{kind:"text",text:e}]}function O(e){return e.map(n=>n.kind==="emoji"?{kind:"emoji",text:n.text,code:n.code}:{kind:n.kind,text:n.text})}function G(e,n,t){let i=e.draft?.mentions??[],r=[],a={},s=false;for(let l of i){if(l.userId==="0"){s=true;continue}r.includes(l.userId)||r.push(l.userId),l.displayName.trim()!==""&&(a[l.userId]=l.displayName);}let o=s||r.length>0?{atAll:s,atUserIds:r,...Object.keys(a).length===0?{}:{atUsersName:a}}:void 0;return O(X$1(n,{mention:o,resolveName:l=>a[l]??l,atAllDisplay:j(t),matchers:[N]}))}function W(e,n){let t=e.lastMessageSummary;if(t!==void 0&&t.kind!=="text")return y(x(e,t,n));let i=(t?.kind==="text"?t.text:e.lastMessagePreview).trim();if(i==="")return y(n.labels.emptyPreview);let r=e.lastMessageMention?.atUsersName;return O(X$1(i,{mention:e.lastMessageMention===void 0?void 0:{...e.lastMessageMention,atUserIds:[...e.lastMessageMention.atUserIds]},resolveName:a=>n.resolveName(e.ref,a,r?.[a]),selfId:n.accountId,atAllDisplay:j(n.locale),matchers:[N]}))}function x(e,n,t){return h(q(n),{locale:t.locale,selfId:t.accountId,resolveName:i=>t.resolveName(e.ref,i)})}function $(e){return e.lastMessageSummary?.kind==="system"||e.lastMessageSenderId==="system"||e.lastMessageSystemEvent!==void 0}function K(e,n){return e.lastMessageSummary?.kind==="system"?x(e,e.lastMessageSummary,n):e.lastMessageSystemEvent===void 0?e.lastMessagePreview.trim()||n.labels.emptyPreview:x(e,{kind:"system",system:{eventType:e.lastMessageSystemEvent,...e.lastMessageSystemTargetsSelf===true?{targetUserIds:[n.accountId]}:{},...e.lastMessagePreview.trim()===""?{}:{fallbackText:e.lastMessagePreview.trim()}}},n)}function z(e,n){let t=e.lastMessageSenderId;return e.ref.conversationType!=="group"&&e.ref.conversationType!=="channel"||t===void 0||t===""||t==="system"?"":`${t===n.accountId?n.labels.selfSender:n.resolveName(e.ref,t)}: `}function q(e){return e.kind!=="system"?e:{kind:"system",system:{eventType:e.system.eventType,...e.system.operatorId===void 0?{}:{operatorId:e.system.operatorId},...e.system.targetUserIds===void 0?{}:{targetUserIds:[...e.system.targetUserIds]},...e.system.fallbackText===void 0?{}:{fallbackText:e.system.fallbackText}}}}var J=160,Q=220;function Y(e){let n=Math.max(0,e.showDelayMs??160),t=Math.max(0,e.minimumVisibleMs??220),i=e.now??Date.now,r=e.setTimer??((d,M)=>setTimeout(d,M)),a=e.clearTimer??(d=>clearTimeout(d)),s="",o=false,l=false,v=0,c,u,f=false;function g(){c!==void 0&&a(c),c=void 0;}function m(){u!==void 0&&a(u),u=void 0;}function h(d){l!==d&&(l=d,v=d?i():0,e.onVisibleChange(d));}function I(d){g(),c=r(()=>{c=void 0,!(f||!o||s!==d)&&h(true);},n);}function j(){if(g(),!l)return;let d=t-Math.max(0,i()-v);if(d<=0){h(false);return}m(),u=r(()=>{u=void 0,!(f||o)&&h(false);},d);}return {update(d,M){if(f)return;if(s!==M){s=M,o=d,g(),m(),h(false),d&&I(M);return}if(o=d,d){m(),!l&&c===void 0&&I(M);return}j();},dispose(){f||(f=true,o=false,g(),m(),h(false));}}}var S={placeholder:0,thumbnail:1,local:2,original:3};function X(e){let n;for(let t of e)t.value!==void 0&&(n===void 0||S[t.quality]>S[n.quality])&&(n=t);return n}function Z(e,n){return S[n]>=S[e]}function ee(e){let n=e.getGeneration();return Object.freeze({isCurrent:()=>e.getGeneration()===n})}function T(e){let n=e.getClient();if(n===null)return null;let t=e.getGeneration();return Object.freeze({client:n,isCurrent:()=>e.getGeneration()===t&&e.getClient()===n})}var _={};a(_,{acquireMediaBlob:()=>te,detectImageMime:()=>D,detectVideoMime:()=>F,loadCachedImageObjectUrl:()=>ae,loadCachedVideoObjectUrl:()=>ie,loadFileObjectUrl:()=>se,loadImageObjectUrl:()=>oe,loadVideoObjectUrl:()=>re,loadVoiceBytes:()=>ne});function A(e){if(e.conversationType!=="supergroup")return {conversation:{conversationType:e.conversationType,conversationId:e.conversationId},messageId:e.id}}async function C(e,n,t){let i=e.getClient(),r=A(n);if(i===null||r===void 0)throw new Error("media download unavailable");let a=t===void 0?void 0:i.media.subscribe(s=>{let o=s.find(l=>l.direction==="download"&&l.messageId===r.messageId&&l.ref.conversationType===r.conversation.conversationType&&l.ref.conversationId===r.conversation.conversationId);o!==void 0&&t(o.percent);});try{return await i.media.download(r)}finally{a?.();}}function D(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"image/png":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70?"image/gif":e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?"image/webp":null}async function U(e){let n=new Uint8Array(await e.slice(0,12).arrayBuffer()),t=D(n);return t===null?null:URL.createObjectURL(e.type===t?e:e.slice(0,e.size,t))}function F(e){return e.length>=4&&e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163?"video/webm":(e.length>=8&&e[4]===102&&e[5]===116&&e[6]===121&&e[7]===112,"video/mp4")}function te(e,n){return e.acquireMediaBlob({conversationType:n.conversationType,conversationId:n.conversationId,messageId:n.id})}async function ne(e,n,t){let i=e.getClient(),r=n.body.voice;if(i===null||r===void 0)return null;let a=e.getSelfVoiceBytes(n.id);if(a!==void 0)return a;let s=e.getGeneration();try{let o=new Uint8Array(await(await C(e,n)).arrayBuffer());return o.length===0?(e.getGeneration()===s&&t.setNote(t.t("media.voiceLoadEmpty")),null):o}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.voiceLoadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}async function re(e,n,t,i){let r=e.getClient(),a=n.body.video;if(r===null||a===void 0)return null;let s=e.getGeneration();try{let o=await C(e,n,i);if(o.size===0)return e.getGeneration()===s&&t.setNote(t.t("media.videoOpenEmpty")),null;let l=URL.createObjectURL(o);return e.getGeneration()!==s?(URL.revokeObjectURL(l),null):l}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.videoLoadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}async function ie(e,n){let t=e.getClient(),i=A(n);if(t===null||i===void 0||n.body.video===void 0)return null;let r=e.getGeneration();try{let a=await t.media.getCached(i);if(a===null||a.size===0||e.getGeneration()!==r)return null;let s=new Uint8Array(await a.slice(0,12).arrayBuffer()),o=a.type||F(s);return e.getGeneration()!==r?null:URL.createObjectURL(a.type===o?a:a.slice(0,a.size,o))}catch{return null}}async function oe(e,n,t){let i=e.getClient(),r=n.body.image;if(i===null||r===void 0)return null;let a=e.getGeneration();try{let s=await C(e,n),o=await U(s);return o===null?(e.getGeneration()===a&&t.setNote(t.t("media.imageInvalid",{size:s.size})),null):e.getGeneration()!==a?(URL.revokeObjectURL(o),null):o}catch(s){return e.getGeneration()===a&&t.setNote(t.t("media.imageLoadFailed",{reason:s instanceof Error?s.message:String(s)})),null}}async function ae(e,n){let t=e.getClient(),i=A(n);if(t===null||i===void 0||n.body.image===void 0)return null;let r=e.getGeneration();try{let a=await t.media.getCached(i);if(a===null||a.size===0||e.getGeneration()!==r)return null;let s=await U(a);return s===null?null:e.getGeneration()!==r?(URL.revokeObjectURL(s),null):s}catch{return null}}async function se(e,n,t,i){let r=e.getClient(),a=n.body.file;if(r===null||a===void 0)return null;let s=e.getGeneration();try{let o=await C(e,n,i);if(o.size===0)return e.getGeneration()===s&&t.setNote(t.t("media.fileDownloadEmpty")),null;let l=URL.createObjectURL(o);return e.getGeneration()!==s?(URL.revokeObjectURL(l),null):l}catch(o){return e.getGeneration()===s&&t.setNote(t.t("media.fileDownloadFailed",{reason:o instanceof Error?o.message:String(o)})),null}}var B={};a(B,{markReadUpTo:()=>le});function le(e,n,t,i){let r=T(e);if(r===null||n.conversationId===""||t==="")return;let a=r.client.conversations.list().find(o=>o.id===n.conversationId&&o.type===n.conversationType);if(a?.manuallyUnread===true&&a.unreadCount<=0){r.client.conversations.markConversationRead(n).catch(o=>{r.isCurrent()&&e.getDiagnostics().record("warn","chat-kit","conversation","clear-manual-unread-skipped",()=>({conversation:n,error:{message:"\u6E05\u9664\u624B\u5DE5\u672A\u8BFB\u63D0\u9192\u5931\u8D25",data:o}}));});return}if(a?.type==="group"&&a.unreadCount<=0)return;let s=i.getConversationHandle();s===void 0||s.ref.conversationId!==n.conversationId||s.ref.conversationType!==n.conversationType||s.markRead(t).catch(o=>{r.isCurrent()&&i.getConversationHandle()===s&&e.getDiagnostics().record("warn","chat-kit","message","mark-read-skipped",()=>({conversation:n,data:{messageId:t},error:{message:"markRead \u8DF3\u8FC7",data:o}}));});}function de(e,n){if(n.length===0)return [{text:e,hit:false}];let t=[],i=0;for(let[r,a]of n)r>i&&t.push({text:e.slice(i,r),hit:false}),t.push({text:e.slice(r,a),hit:true}),i=a;return i<e.length&&t.push({text:e.slice(i),hit:false}),t}var ce=/\b(?:https?:\/\/|www\.)[^\s<>"')】]+/gi,me=/\b(?:https?:\/\/|www\.)/i,ue=/[),.!?;:,。!?;:、)】]+$/u;function V(e){let n=/^www\./i.test(e)?`https://${e}`:e;try{let t=new URL(n);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function fe(e){return me.test(e)}function pe(){return e=>{let n=[];for(let t of e.matchAll(ce)){if(t.index===void 0)continue;let i=t[0].replace(ue,"");if(i==="")continue;let r=V(i);r!==void 0&&n.push({start:t.index,end:t.index+i.length-1,segment:{kind:"link",text:i,href:r}});}return n}}function p(e,n){if(!Number.isFinite(e)||e<=0)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${n} \u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6709\u9650\u6570`)}function ge(e){if(p(e.fallbackAspectRatio,"fallbackAspectRatio"),!Array.isArray(e.rules)||e.rules.length===0)throw new Error("\u5A92\u4F53\u5C55\u793A\u7B56\u7565 rules \u4E0D\u80FD\u4E3A\u7A7A");let n=new Set;e.rules.forEach((t,i)=>{let r=`rules[${i}]`;if(t.id.trim()==="")throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.id \u4E0D\u80FD\u4E3A\u7A7A`);if(n.has(t.id))throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565\u89C4\u5219 id \u91CD\u590D\uFF1A${t.id}`);if(n.add(t.id),t.minAspectRatio!==void 0&&(!Number.isFinite(t.minAspectRatio)||t.minAspectRatio<0))throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.minAspectRatio \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 0 \u7684\u6709\u9650\u6570`);if(t.maxAspectRatio!==void 0&&p(t.maxAspectRatio,`${r}.maxAspectRatio`),t.minAspectRatio!==void 0&&t.maxAspectRatio!==void 0&&t.minAspectRatio>=t.maxAspectRatio)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r} \u7684\u5BBD\u9AD8\u6BD4\u4E0B\u754C\u5FC5\u987B\u5C0F\u4E8E\u4E0A\u754C`);if(p(t.preferredWidth,`${r}.preferredWidth`),p(t.minWidth,`${r}.minWidth`),p(t.maxWidth,`${r}.maxWidth`),p(t.minHeight,`${r}.minHeight`),p(t.maxHeight,`${r}.maxHeight`),t.minWidth>t.preferredWidth||t.preferredWidth>t.maxWidth)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.preferredWidth \u5FC5\u987B\u4F4D\u4E8E minWidth \u548C maxWidth \u4E4B\u95F4`);if(t.minHeight>t.maxHeight)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.minHeight \u4E0D\u80FD\u5927\u4E8E maxHeight`);if(typeof t.allowUpscale!="boolean")throw new TypeError(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.allowUpscale \u5FC5\u987B\u662F boolean`);if(t.fit!=="cover"&&t.fit!=="contain")throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565 ${r}.fit \u53EA\u652F\u6301 cover \u6216 contain`)});}function he(e){let{intrinsicWidth:n,intrinsicHeight:t,availableWidth:i,policy:r}=e;p(i,"availableWidth"),ge(r);let a=Number.isFinite(n)&&Number.isFinite(t)&&n>0&&t>0,s=a?n/t:r.fallbackAspectRatio,o=r.rules.find(m=>{let h=m.minAspectRatio===void 0||s>=m.minAspectRatio,I=m.maxAspectRatio===void 0||s<m.maxAspectRatio;return h&&I});if(o===void 0)throw new Error(`\u5A92\u4F53\u5C55\u793A\u7B56\u7565\u6CA1\u6709\u5339\u914D\u5BBD\u9AD8\u6BD4 ${s}`);let l=!o.allowUpscale&&a?Math.min(o.preferredWidth,n):o.preferredWidth,v=Math.min(i,o.maxWidth,Math.max(o.minWidth,l)),c=Math.max(1,Math.round(v)),u=c/s,f=Math.min(o.maxHeight,Math.max(o.minHeight,u)),g=Math.max(1,Math.round(f));return {width:c,height:g,aspectRatio:c/g,sourceAspectRatio:s,ruleId:o.id,fit:o.fit,aspectClamped:f!==u}}function ve(e,n,t,i){if(!Number.isFinite(e)||!Number.isFinite(n)||e<=0||n<=0)return null;let r=Math.min(t/e,i/n,1);return {width:`${Math.max(1,Math.round(e*r))}px`,aspectRatio:`${e} / ${n}`}}function Me(e){if(!Number.isFinite(e)||e<=0)return "0:00";let n=Math.floor(e),t=Math.floor(n/3600),i=Math.floor(n%3600/60),r=n%60,a=s=>s.toString().padStart(2,"0");return t>0?`${t}:${a(i)}:${a(r)}`:`${i}:${a(r)}`}function ye(e){if(!Number.isFinite(e)||e<=0)return "0 B";let n=["B","KB","MB","GB","TB"],t=Math.min(n.length-1,Math.floor(Math.log(e)/Math.log(1024))),i=e/1024**t;return `${t===0?i:Math.round(i*10)/10} ${n[t]}`}function xe(e){let n=e.lastIndexOf(".");return n>-1&&n<e.length-1?e.slice(n+1).toLowerCase():""}var Ie=4;function Se(e){let n=Math.min(Math.max(e/1e3,0)/10,1);return Math.round(22+24*n)}function Ce(e,n){if(e.length===0)return Array.from({length:n},()=>0);let t=[],i=(e.length-1)/Math.max(1,n-1);for(let r=0;r<n;r+=1){let a=r*i,s=Math.round(a),o=e[Math.max(0,s-1)]??0,l=e[Math.min(e.length-1,s)]??0,v=e[Math.min(e.length-1,s+1)]??0;t.push((o+l+v)/3);}return t}function be(e,n){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);let i=[];for(let r=0;r<n;r+=1)t=Math.imul(t^t>>>15,2246822519)>>>0,i.push(90+t%111);return i}
|
|
2
2
|
export{H as a,J as b,Q as c,Y as d,X as e,Z as f,ee as g,T as h,_ as i,B as j,de as k,V as l,fe as m,pe as n,he as o,ve as p,Me as q,ye as r,xe as s,Ie as t,Se as u,Ce as v,be as w};
|