UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.57 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Wo as t}from"./_4____________________________.js";import{C_ as n,GN as r,JN as i,MN as a,Mw as o,Nw as s,Pw as c,fN as l,jN as u,pN as d,w_ as f}from"./_2_____________________________.js";import{C as p,F as m,U as h,d as g,g as _,gt as v,j as y,l as b,m as x,s as S,u as C,x as w}from"./_6____________________.js";import{B as T,V as E,it as D,lt as O,rt as k,st as A}from"./control-ui-boot-chat-CqvkfPXD.js";var j,M,N;function P(){return(P=e((()=>{C(),h(),d(),n(),s(),r(),a(),D(),E(),j=w(`<button type=button class="btn primary chat-comment-pin">`),f(),M=new WeakMap,N=u(`openclaw-chat-comment-pins`,(e,n)=>{let r=null,a,s,u,d=!1,f=null,h=[],S=m(()=>({attachments:e.attachments,sessionKey:e.sessionKey}),{equals:(e,t)=>e.attachments===t.attachments&&e.sessionKey===t.sessionKey}),C=m(()=>k(S().attachments,S().sessionKey)),w={visiblePin:e=>{let t=r?.getBoundingClientRect();if(t)return h.find(n=>{if(!n.isConnected||n.dataset.attachmentId!==e||n.hidden)return!1;let r=n.getBoundingClientRect();return r.width>0&&r.height>0&&r.top>=Math.max(t.top,0)&&r.bottom<=Math.min(t.bottom,window.innerHeight)&&r.left>=Math.max(t.left,0)&&r.right<=Math.min(t.right,window.innerWidth)})}};function E(e){return!n.contains(e)&&!f?.every(t=>{let n=t.compareDocumentPosition(e);return(n&Node.DOCUMENT_POSITION_FOLLOWING)!==0&&(n&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_DISCONNECTED))===0})}let D=()=>{n.isConnected&&c(n,N)};function N(){if(!r)return;let t=e.transcript?.contentElement,i=t?.isConnected?t:void 0;i!==u&&(u&&a?.unobserve(u),i&&a?.observe(i),u=i);let o=n.getBoundingClientRect(),s=r.getBoundingClientRect().right-28,c=[],l=[],d=[],p=!0;h=h.filter(e=>e.isConnected);for(let t of C()){let n=h.find(e=>e.dataset.attachmentId===t.id);if(!n){p=!1;continue}let r=O(e.transcript?.messageElements.elements.values()??[],t.selectionAnnotation),i=r?A(r):null;if(!r||!i){l.push(n),p=!1;continue}d.push(r.bubble);let a=Math.min(i.right+4,s)-o.left,u=i.top+(i.height-24)/2-o.top;for(;c.some(e=>Math.abs(e.left-a)<24&&Math.abs(e.top-u)<24);)a+48<=s-o.left?a+=24:u+=24;c.push({pin:n,left:a,top:u})}return f=p?d:null,()=>{for(let e of l)e.hidden=!0;for(let{pin:e,left:t,top:n}of c)e.hidden=!1,e.style.left=`${t}px`,e.style.top=`${n}px`}}return v(()=>{M.set(n,D);let i=e.threadState;i&&(i.commentPins=w);let c;return queueMicrotask(()=>{d||(r=n.closest(`.chat-thread`),r&&(a=new ResizeObserver(D),a.observe(r),s=new MutationObserver(e=>{e.some(e=>E(e.target))&&D()}),s.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0}),c=t(r,`scroll`,D,{passive:!0}),D()))}),()=>{M.delete(n),i?.commentPins===w&&(i.commentPins=void 0),d=!0,a?.disconnect(),s?.disconnect(),c?.(),o(n)}}),y(p,{get each(){return C()},keyed:e=>e.id,children:(t,n)=>(()=>{var r=j();return r._$$click=e=>{e.stopPropagation(),T(e,t().id,`edit`)},r._$$pointerup=e=>e.stopPropagation(),x(()=>e=>h.push(e),r),g(r,y(l,{name:`messageSquare`})),b(()=>({e:t().id,t:i(`chat.messages.editAnnotation`,{number:String(n()+1)}),a:t().selectionAnnotation.comment||t().selectionAnnotation.text,o:e.disabled}),({e,t,a:n,o:i},a)=>{e!==a?.e&&_(r,`data-attachment-id`,e),t!==a?.t&&_(r,`aria-label`,t),n!==a?.a&&_(r,`title`,n),i!==a?.o&&_(r,`disabled`,i)}),r})()})},{propertyChanged:e=>M.get(e)?.(),properties:{threadState:{default:void 0,attribute:!1},transcript:{default:void 0,attribute:!1},attachments:{default:[],attribute:!1},sessionKey:{default:``},disabled:{default:!1,attribute:!1}}}),S([`pointerup`,`click`])})))()}P();export{N as ChatCommentPins};