UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.19 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{mi as t,pi as n}from"./_4____________________________.js";import{GN as r,IN as i,JN as a,MN as o,PN as s,fN as c,jN as l,pN as u,qN as d}from"./_2_____________________________.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"./_6____________________.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-Cq3FswDC.js";import{n as A,t as j}from"./board-widget-error-C-bzuTTa.js";import{n as M}from"./widget-sandbox-runtime-DfYFz8qf.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((()=>{t(),R={board:{widget:{websiteOpen:`Open website`,websiteEmbedHint:`If this site doesn’t load here, open it in a new tab.`,websiteSameOrigin:`Open this website in a new tab. Gateway and OpenClaw pages can’t be embedded in a website widget.`}}},z=Object.assign(()=>Object.assign(n.board.widget,R.board.widget),{catalog:R})})))()}function V(e){let t=i(),[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,o=i.nextSibling,s=o.firstChild,l=s.nextSibling,u=h();return v(t,b(m,{get when(){return!r().sameHost},get fallback(){var e=W();return v(e,()=>a(`board.widget.websiteSameOrigin`)),e},get children(){var t=H();return x(()=>({e:e.widget?.title||a(`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(o,()=>a(`board.widget.websiteOpen`),s),v(o,b(c,{name:`externalLink`}),l),x(()=>({e:r().url?.href,t:a(`board.widget.websiteEmbedHint`)}),({e,t},n)=>{e!==n?.e&&y(o,`href`,e),t!==n?.t&&y(o,`title`,t),_(o,u)}),t}})}})}var H,U,W,G;function K(){return(K=e((()=>{S(),g(),L(),A(),u(),k(),B(),s(),r(),o(),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>`),d(O),z(),G=l(`openclaw-website-widget`,V,{properties:{widget:{default:void 0,attribute:!1},active:{default:!0,type:Boolean}}})})))()}K();export{G as WebsiteWidget};