openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.18 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Oa as t,ka as n}from"./control-ui-connection-Bfj9beF_.js";import{BA as r,QA as i,ZA as a,dj as o,ej as s,mj as c,nj as l,pj as u,zA as d}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as f,F as p,O as m,Rt as h,U as g,a as _,d as v,g as y,j as b,l as x,u as S,x as C}from"./solid-runtime-C416s-HC.js";import{D as w,O as T,g as E,j as D}from"./config-runtime-ECF4aWQv.js";import{n as O,t as k}from"./en-board-document-CgVI8wPN.js";import{n as A,t as j}from"./board-widget-error-Ca87fMFk.js";import{n as M}from"./sandbox-host-BQQkpiFr.js";import{n as N,r as P}from"./board-layout-2ytmMZqb.js";function F(e){let t=I.safeParse(e);if(!t.success)throw new N(`invalid_operation`,`Website props must contain only a valid HTTPS url of at most 2048 characters`);let n=new URL(t.data.url);if(n.username||n.password)throw new N(`invalid_operation`,`Website URLs must not contain embedded credentials`);return t.data}var I;function L(){return(L=e((()=>{E(),P(),I=w({url:T().max(2048).pipe(D({protocol:/^https$/,normalize:!0}).max(2048))})})))()}var R,z;function B(){return(B=e((()=>{n(),R={board:{widget:{websiteOpen:`Open website`,websiteEmbedHint:`If this site does not load here, open it in a new tab.`,websiteSameOrigin:`Open this website in a new tab. Gateway and Control UI pages cannot be embedded in a website widget.`}}},z=Object.assign(()=>Object.assign(t.board.widget,R.board.widget),{catalog:R})})))()}function V(e){let t=l(),[n]=f((t=!1)=>t||e.active),r=p(()=>{try{let n=new URL(F(e.widget?.props).url),r=M(t?.gateway.connection.gatewayUrl??``,window.location.origin);return{url:n,sameHost:n.hostname===window.location.hostname||n.hostname===new URL(r).hostname}}catch(e){return{error:e}}});return b(m,{get when(){return n()},get children(){return b(m,{get when(){return r().url},get fallback(){return b(j,{get error(){return r().error}})},get children(){var t=U(),n=t.firstChild,i=n.firstChild,a=i.nextSibling,o=a.firstChild,s=o.nextSibling,l=h();return v(t,b(m,{get when(){return!r().sameHost},get fallback(){var e=W();return v(e,()=>c(`board.widget.websiteSameOrigin`)),e},get children(){var t=H();return x(()=>({e:e.widget?.title||c(`board.widget.kindWebsite`),t:r().url?.href}),({e,t:n},r)=>{e!==r?.e&&y(t,`title`,e),n!==r?.t&&y(t,`src`,n)}),t}}),n),v(i,()=>r().url?.host),v(a,()=>c(`board.widget.websiteOpen`),o),v(a,b(d,{name:`externalLink`}),s),x(()=>({e:r().url?.href,t:c(`board.widget.websiteEmbedHint`)}),({e,t},n)=>{e!==n?.e&&y(a,`href`,e),t!==n?.t&&y(a,`title`,t),_(a,l)}),t}})}})}var H,U,W,G;function K(){return(K=e((()=>{S(),g(),L(),A(),r(),k(),B(),s(),o(),i(),H=C(`<iframe class=board-website__frame sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"referrerpolicy=no-referrer>`),U=C(`<div class=board-website><div class=board-website__footer><span class=board-website__origin></span><a target=_blank rel="noopener noreferrer"><!><!>`),W=C(`<p class=board-website__notice role=alert>`),u(O),z(),G=a(`openclaw-website-widget`,V,{properties:{widget:{default:void 0,attribute:!1},active:{default:!0,type:Boolean}}})})))()}K();export{G as WebsiteWidget};