UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 9.12 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{yt as t}from"./control-ui-connection-Bfj9beF_.js";import{BA as n,Gn as r,Qb as i,Wn as a,Xb as o,Yb as s,a_ as c,dj as l,fa as u,i_ as d,jA as ee,ma as f,mj as p,pa as m,pj as h,zA as te}from"./control-ui-boot-shared-DFTSUQQ0.js";import{C as ne,J as re,O as g,U as _,d as v,f as y,g as b,gt as x,j as S,l as C,m as w,s as T,u as E,v as ie,x as D}from"./solid-runtime-C416s-HC.js";import{G as O,fs as k,q as A}from"./control-ui-boot-chat-DewxEbIm.js";import{F as ae,I as oe}from"./markdown-runtime-DmM7zNej.js";import{a as j,i as M,r as N}from"./chat-attachment-preview-chip-wl3qMjij.js";import{n as se,t as ce}from"./chat-pasted-text-DltqvZsT.js";function le(e){let n=/^data:([^,]*),(.*)$/s.exec(e);if(!n)return null;let r=n[1],i=n[2];try{return r.toLowerCase().includes(`;base64`)?new TextDecoder().decode(t(i)):decodeURIComponent(i.replace(/\+/g,`%20`))}catch{return null}}function P(e,t){return e.trim()?`${e.replace(/\s+$/u,``)}\n\n${t}`:t}function F(e,t){let n=s(e),r=n?le(n):null;r&&t.onDraftChange&&(f(e,t),t.onDraftChange(P(t.getDraft?.()??t.draft??``,r)))}function I(e){let t=()=>e.controls.readSignal?.aborted?void 0:u(e.controls).find(t=>t.id===e.attachment.id),n=()=>e.attachment.fileName?.trim()?p(`chat.composer.removeNamedAttachment`,{name:e.attachment.fileName}):p(`chat.composer.removeAttachment`),r=()=>{t()&&!e.controls.disabled&&f(e.attachment,e.controls)},i=()=>(()=>{var n=L();return n._$$click=()=>{let n=t();n&&!e.controls.disabled&&F(n,e.controls)},v(n,()=>p(`chat.attachments.showInTextField`)),C(()=>e.controls.disabled,e=>{b(n,`disabled`,e)}),n})(),a=i(),c=S(N,{get label(){return n()},get disabled(){return e.controls.disabled},onClick:r});return S(ce,{get src(){return s(e.attachment)??void 0},get sizeBytes(){return e.attachment.sizeBytes},get scope(){return e.attachment.id},onOpen:()=>{t()&&e.controls.onOpenSidebar?.({kind:`attachment`,attachmentKind:`document`,title:e.attachment.fileName??p(`chat.attachments.pastedText`),mimeType:`text/plain`,plainText:!0,sourceIdentity:e.attachment.id,resolveSource:()=>{let e=t();if(!e)return{status:`unavailable`};let n=o(e);return n?{status:`ready`,src:n,sizeBytes:e.sizeBytes}:{status:`unavailable`}},renderActions:()=>[y(i),(()=>{var t=R();return t._$$click=r,v(t,S(te,{name:`trash`})),C(()=>({e:n(),t:e.controls.disabled}),({e,t:n},r)=>{e!==r?.e&&b(t,`aria-label`,e),n!==r?.t&&b(t,`disabled`,n)}),t})()]})},composerAction:a,composerRemoveAction:c})}var L,R;function z(){return(z=e((()=>{E(),n(),d(),l(),i(),m(),j(),se(),L=D(`<button class=chat-attachment-text-action type=button>`),R=D(`<button class="btn btn--sm"type=button>`),h(c),T([`click`])})))()}function B(e){let t=()=>o(e.attachment);return S(g,{get when(){return t()},children:t=>S(g,{get when(){return e.controls.onOpenImage},get fallback(){var n=G();return C(()=>({e:t(),t:e.alt}),({e,t},r)=>{e!==r?.e&&b(n,`src`,e),t!==r?.t&&b(n,`alt`,t)}),n},get children(){var n=W(),r=n.firstChild;return n._$$click=()=>e.controls.onOpenImage?.({src:t(),title:e.title}),w(()=>[e.buttonRef],n),C(()=>({e:p(`chat.imageLightbox.open`,{title:e.title}),t:t(),a:e.alt}),({e,t,a:i},a)=>{e!==a?.e&&b(n,`aria-label`,e),t!==a?.t&&b(r,`src`,t),i!==a?.a&&b(r,`alt`,i)}),n}})})}function V(e){let t,n;x(()=>{let r=t??n;return r?e.controls.registerBrowserAnnotationFocus?.(e.attachment.id,r):void 0});let r=()=>e.annotation.title.trim()||e.annotation.displayUrl.trim()||e.attachment.fileName||p(`chat.attachments.attachedFile`);var i=K(),a=i.firstChild,o=a.nextSibling.firstChild,s=o.nextSibling.firstChild;return v(a,S(B,{buttonRef:e=>{t=e},get attachment(){return e.attachment},get alt(){return p(`chat.composer.browserAnnotationPreview`)},get title(){return r()},get controls(){return e.controls}})),v(o,r),v(s,()=>p(e.annotation.markedRegionCount===1?`chat.composer.browserAnnotationRegion`:`chat.composer.browserAnnotationRegions`,{count:String(e.annotation.markedRegionCount)})),v(i,S(N,{buttonRef:e=>{n=e},get label(){return p(`chat.composer.removeBrowserAnnotation`,{name:r()})},get disabled(){return e.controls.disabled},class:`chat-attachment-remove chat-browser-annotation-card__remove`,onClick:()=>e.controls.onRemoveAttachment?e.controls.onRemoveAttachment(e.attachment):f(e.attachment,e.controls)}),null),C(()=>({e:e.attachment.id,t:`${p(`chat.composer.browserAnnotation`)}: ${r()}`,a:r()}),({e,t,a:n},r)=>{e!==r?.e&&b(i,`data-attachment-id`,e),t!==r?.t&&b(i,`aria-label`,t),n!==r?.a&&b(o,`title`,n)}),i}function H(e){let t=()=>e.entry.attachment,n=()=>e.entry.state===`reading`,r=()=>e.entry.state===`error`,i=()=>!!(e.entry.preparation||e.entry.errorMessage&&t().mimeType.startsWith(`video/`)),a=()=>p(e.entry.errorMessage??`chat.attachments.readFailed`,{names:t().fileName??p(`chat.attachments.attachedFile`),more:``}),s=()=>{let e=t().fileName;return e?.trim()?p(`chat.composer.removeNamedAttachment`,{name:e}):p(`chat.composer.removeAttachment`)};return S(g,{get when(){return t().browserAnnotation},get fallback(){return S(g,{get when(){return k(t())},get fallback(){var c=J(),l=c.firstChild,u=l.nextSibling,d=u.nextSibling;return v(c,(()=>{var s=y(()=>!!i());return()=>s()?S(M,{get attachment(){return t()},get videoPreparation(){return{state:r()?`error`:e.entry.preparation??`offer`,progress:e.entry.progress}},get metadata(){return y(()=>e.entry.preparation===`compressing`)()?(()=>{var t=Y();return v(t,()=>p(`chat.attachments.compressing`,{progress:String(Math.floor((e.entry.progress??0)*100))})),t})():(()=>{var t=X(),n=t.firstChild,i=n.firstChild;return v(t,(()=>{var e=y(()=>!!r());return()=>e()?(()=>{var e=Z();return v(e,a),e})():r()})(),n),n._$$click=()=>e.entry.read.compress?.(),v(i,()=>p(r()?`chat.attachments.retryCompression`:`chat.attachments.compressToFit`)),C(()=>({e:r()?a():p(`chat.attachments.compressionHint`),t:e.controls.disabled}),({e,t},r)=>{e!==r?.e&&b(n,`title`,e),t!==r?.t&&b(n,`disabled`,t)}),t})()}}):y(()=>!!n())()?void 0:y(()=>!!(t().mimeType.startsWith(`image/`)&&o(t())))()?S(B,{get attachment(){return t()},get alt(){return t().fileName?.trim()||p(`chat.composer.attachmentPreview`)},get title(){return t().fileName?.trim()||p(`chat.imageLightbox.untitled`)},get controls(){return e.controls}}):S(M,{get attachment(){return t()}})})(),l),v(c,S(g,{get when(){return y(()=>!!n())()?!i():n()},get children(){var t=q(),n=t.firstChild.nextSibling.firstChild.nextSibling.firstChild;return C(()=>({e:e.entry.progress===void 0?`true`:`false`,t:e.entry.progress===void 0?void 0:`scaleX(${e.entry.progress})`}),({e,t:r},i)=>{e!==i?.e&&b(t,`data-indeterminate`,e),r!==i?.t&&ie(n,`transform`,r)}),t}}),u),v(c,S(N,{get label(){return s()},get disabled(){return e.controls.disabled},onClick:()=>{e.controls.attachmentReads?.remove(e.entry.read),f(t(),e.controls)}}),d),C(()=>({e:!!i(),t:!!t().mimeType.startsWith(`video/`),a:!t().mimeType.startsWith(`image/`),o:!!r(),i:n()&&e.entry.preparation!==`offer`?`true`:`false`}),({e,t,a:n,o:r,i},a)=>{e!==a?.e&&c.classList.toggle(`chat-attachment-thumb--preparation`,e),t!==a?.t&&c.classList.toggle(`chat-attachment-thumb--video`,t),n!==a?.a&&c.classList.toggle(`chat-attachment-thumb--file`,n),r!==a?.o&&c.classList.toggle(`chat-attachment-thumb--error`,r),i!==a?.i&&b(c,`aria-busy`,i)}),c},get children(){return S(I,{get attachment(){return t()},get controls(){return e.controls}})}})},children:n=>S(V,{get attachment(){return t()},get annotation(){return n()},get controls(){return e.controls}})})}function U(e){var t=Q(),n=t.firstChild,i=n.nextSibling,a=r(!0);return(typeof a==`function`||Array.isArray(a))&&w(()=>a,t),v(t,S(O,re(()=>e.controls)),n),v(t,S(ne,{get each(){return e.entries.filter(({attachment:e})=>!e.selectionAnnotation)},keyed:e=>e.attachment.id,children:t=>S(H,{get entry(){return t()},get controls(){return e.controls}})}),i),C(()=>e.controls.disabled?`true`:void 0,e=>{b(t,`data-disabled`,e)}),t}var W,G,K,q,J,Y,X,Z,Q;function $(){return($=e((()=>{E(),_(),a(),ee(),d(),ae(),l(),i(),m(),j(),z(),A(),W=D(`<button type=button class="chat-message-image-button chat-attachment-image-button"><img>`),G=D(`<img>`),K=D(`<div class="chat-attachment-thumb chat-attachment-thumb--browser-annotation"role=group><div class=chat-browser-annotation-card__preview></div><div class="chat-attachment-file__body chat-browser-annotation-card__body"><span class="chat-attachment-file__name chat-browser-annotation-card__identity"></span><span class="chat-attachment-file__meta chat-browser-annotation-card__meta"><span>`),q=D(`<span class=chat-attachment-loading data-state=reading aria-hidden=true><span class=chat-attachment-loading__icon></span><span class=chat-attachment-loading__body><span class=chat-attachment-loading__title></span><span class=chat-attachment-loading__line><span>`),J=D(`<div class=chat-attachment-thumb><!><!><!>`),Y=D(`<span class=chat-attachment-file__type role=status>`),X=D(`<span class=chat-attachment-file__type><button type=button class=chat-attachment-compress><span>`),Z=D(`<span class=sr-only role=status>`),Q=D(`<div class=chat-attachments-preview><!><!>`),h(c),h(oe),T([`click`])})))()}$();export{U as AttachmentPreviewStrip};