openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 5.61 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{$t as t,Ai as n,Ei as r,I as i,R as a,Wo as o,an as s}from"./_4____________________________.js";import{IN as c,PN as l,QN as u,YN as d}from"./_2_____________________________.js";import{B as f,F as p,P as m,U as h,f as g,g as _,gt as v,l as y,m as b,u as x,v as S,x as C}from"./_6____________________.js";import{Rt as w,zt as T}from"./control-ui-boot-new-pHXPNTZp.js";import{n as E,r as D,t as O}from"./session-background-contrast-K4DcVRHc.js";import{n as k,r as A,t as j}from"./session-background-image-Cr_LwQ3x.js";function M(e){let t=null,n=[],r=[];v(()=>(t=typeof ResizeObserver>`u`?null:new ResizeObserver(o),n.forEach(e=>t?.observe(e)),s));function i(t){let n;for(let i of r)i.kind===t&&e.parentElement?.contains(i.element)&&(!n||n.compareDocumentPosition(i.element)&Node.DOCUMENT_POSITION_PRECEDING)&&(n=i.element);return n}function a(a,c=[]){if(r=c,!a){s();return}let l=[e.parentElement,i(`composer`),i(`welcome`)].filter(e=>!!e);(l.length!==n.length||l.some((e,t)=>e!==n[t]))&&(s(),n=l,n.forEach(e=>t?.observe(e))),o()}function o(){let t=i(`composer`),n=e.getBoundingClientRect(),r=t?.getBoundingClientRect(),a=i(`scroll`)?.scrollTop??0,o=r?Math.max(0,r.top-n.top+a+r.height/2):n.height*.55,s=Math.round(o)+`px`;e.style.getPropertyValue(`--session-background-fade-end`)!==s&&e.style.setProperty(`--session-background-fade-end`,s)}function s(){t?.disconnect(),n=[]}return{update:a}}function N(e,t){if(e)return(t===`preview`||(t===`new-session`?e.showOnNewSession:e.showInSessions))&&e.visibility>0?e.source:{kind:`none`}}function P(e){let t=e.host,n=c(),i=()=>e.context??n,l=M(t),[d,h]=f(0),x=()=>h(e=>e+1),[C,w]=f(),E,k=typeof matchMedia==`function`?matchMedia(`(forced-colors: active), (prefers-contrast: more), (prefers-reduced-transparency: reduce)`):null,P=null,R=null,z=null,B=``,V=0,H=()=>e.surface===`preview`?e.preferenceOverride??i()?.theme.settings.background:i()?.theme.settings.background,U=()=>{let t=i(),n=t?.gateway.snapshot.selfUser?.id;if(!(t&&n&&s(t.gateway.connection.gatewayUrl,n)===null))return N(H(),e.surface)},W=()=>{let t=U();return i()&&e.presented&&!k?.matches&&t?.kind===`custom`?j(i(),t.assetId):null},G=e=>{let n=t.isConnected&&e!==`preview`?t.closest(`.new-session-page, .sidebar-region`):null;z!==n&&(z?.removeAttribute(`data-background-custom`),z?.removeAttribute(`data-background-painted`),z=n),n?.toggleAttribute(`data-background-custom`,t.hasAttribute(`data-custom`)),n?.toggleAttribute(`data-background-painted`,t.hasAttribute(`data-painted`))},K=(n=e.surface)=>{let r=P;P=null,r?.controller.abort(),w(void 0),r?.url&&(E?.removeAttribute(`src`),t.removeAttribute(`data-painted`),G(n),URL.revokeObjectURL(r.url))},q=(e,t,n)=>{P&&(P.context!==e||P.client!==e?.gateway.snapshot.client||P.identity!==t)&&K(n)},J=p(()=>u(i(),{read:e=>e,equality:`revision`,subscribe:(t,n)=>{let r=()=>{q(i(),W(),e.surface),n()},a=[t?.theme.subscribe(r),t?.gateway.subscribe(r)];return()=>a.forEach(e=>e?.())}}));v(()=>a(()=>{P?.url||(R=null,K(),x())})),v(()=>{let e=T(t.ownerDocument,[`data-theme`,`data-theme-mode`,`data-theme-background`],x),n=k&&o(k,`change`,()=>{K(),x()});return queueMicrotask(()=>{t.isConnected&&x()}),()=>{e(),n?.(),P?.controller.abort(),P?.url&&URL.revokeObjectURL(P.url),P=null,z?.removeAttribute(`data-background-custom`),z?.removeAttribute(`data-background-painted`)}});let Y=p(()=>{d(),J().revision();let n=U(),a=H()?.presentation===`full-bleed`,o=e.presented&&!k?.matches;if(o&&n?.kind===`custom`&&t.isConnected){let e=O(t);B!==e&&(V=D(t),B=e)}let s=H()?.visibility??0,c=t.ownerDocument.documentElement.dataset.themeBackground===`plugin`;return{source:n,fullBleed:a,visible:o,opacity:n?.kind===`theme`?a&&!c?s*L:Math.min(1,s/r.visibility):V*s*(i()?.theme.resolvedMode===`light`?.65:1),surface:e.surface,context:i(),identity:W(),layoutTargets:e.layoutTargets}});return m(()=>({...Y(),image:C()}),e=>{if(t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`data-presentation`,e.fullBleed?`full-bleed`:`faded`),t.setAttribute(`data-surface`,e.surface),t.toggleAttribute(`data-custom`,e.visible&&e.source?.kind===`custom`),q(e.context,e.identity,e.surface),t.toggleAttribute(`data-painted`,!!(e.visible&&e.opacity>0&&(e.source?.kind===`theme`||e.source?.kind===`custom`&&e.image))),G(e.surface),l.update((e.surface===`new-session`||e.surface===`preview`)&&e.visible&&!!(e.source&&e.source.kind!==`none`)&&!e.fullBleed,e.layoutTargets),R!==e.identity&&(R=null),!t.isConnected||!e.context||!e.identity||R===e.identity||P||e.source?.kind!==`custom`)return;let n={identity:e.identity,context:e.context,client:e.context.gateway.snapshot.client,controller:new AbortController,url:null};P=n,A(e.context,e.source.assetId,{signal:n.controller.signal,isCurrent:()=>t.isConnected&&P===n}).then(e=>{P!==n||!t.isConnected||W()!==n.identity?URL.revokeObjectURL(e):(n.url=e,w(e))}).catch(()=>{})}),g(()=>g(()=>!!(Y().visible&&Y().source&&Y().source?.kind!==`none`))()?g(()=>Y().source?.kind===`theme`)()?(()=>{var e=F();return y(()=>String(Y().opacity),t=>{S(e,`opacity`,t)}),e})():g(()=>!!C())()?(()=>{var e=I();return e.addEventListener(`error`,()=>{R=P?.identity??null,K(),x()}),b(()=>e=>E=e,e),y(()=>({e:String(Y().opacity),t:C()}),({e:t,t:n},r)=>{t!==r?.e&&S(e,`opacity`,t),n!==r?.t&&_(e,`src`,n)}),e})():void 0:void 0)}var F,I,L;function R(){return(R=e((()=>{x(),h(),n(),i(),t(),l(),w(),d(),E(),k(),F=C(`<div class="session-background__image session-background__image--theme">`),I=C(`<img class=session-background__image alt decoding=async draggable=false>`),L=.7})))()}R();export{P as SessionBackgroundContent};