UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.8 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Ai as t,In as n,ba as r,ji as i,va as a}from"./_4____________________________.js";import{Iw as o,Lw as s,zw as c}from"./_2_____________________________.js";function l(e,t){return`${n(t)}${u}${encodeURIComponent(e)}`}var u;function d(){return(d=e((()=>{u=`/__openclaw__/users/background/`})))()}function f(e,t){let n=e.gateway,r=n.snapshot,o=r.selfUser?.id;if(!i(t)||r.phase!==`connected`||!r.client||!o)return null;let s=c({hello:r.hello,settings:n.connection,password:n.connection.password}),u=new URL(a(n.connection.gatewayUrl));u.protocol=u.protocol.replace(/^ws/u,`http`);let d=u.origin===location.origin?e.resourceBasePath:``,f=new URL(l(t,d),u.origin).href;return{client:r.client,auth:s,url:f,identity:JSON.stringify([n.connectionRevision,n.connection.gatewayUrl,o,f,s])}}function p(e,t){return f(e,t)?.identity??null}async function m(e,t,n){let r=f(e,t);if(!r)throw new DOMException(`Background image has no current profile`,`AbortError`);let i=AbortSignal.any([n.signal,...e.lifecycleAbortSignal?[e.lifecycleAbortSignal]:[],AbortSignal.timeout(3e4)]),a=()=>{let a=f(e,t);return!i.aborted&&n.isCurrent()&&a?.client===r.client&&a.identity===r.identity},s=()=>{if(i.throwIfAborted(),!a())throw new DOMException(`Background image belongs to a retired profile`,`AbortError`)},c=await o(r.url,{credentials:`include`,cache:`no-store`,redirect:`error`,signal:i},r.auth,a);if(s(),!c.ok||c.headers.get(`content-type`)?.split(`;`,1)[0]?.trim()!==`image/jpeg`)throw c.body?.cancel(),Error(`Background image unavailable`);let l=await c.blob();if(s(),!l.size||l.size>2097152)throw Error(`Background image exceeds its serving limit`);return URL.createObjectURL(l)}function h(){return(h=e((()=>{t(),d(),s(),r()})))()}export{h as n,m as r,p as t};