UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.48 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Dw as t,GN as n,JN as r,fN as i,kw as a,pN as o,qN as s}from"./_2_____________________________.js";import{B as c,F as l,O as u,Rt as d,U as f,a as p,d as m,f as h,g,gt as _,j as v,l as y,m as b,s as x,u as S,x as C}from"./_6____________________.js";import{n as w,t as T}from"./en-chat-session-optional-Dhpd_jPf.js";function E(e){let t,[n,o]=c(!0),s=l(()=>e.enabled&&n()),f=()=>e.videoTitle.trim()||r(`chat.youtube.video`),x=l(()=>e.video?.watchUrl),[S,C]=c(()=>(x(),s(),!1)),[w,T]=c(()=>(x(),!1)),E,L=l(()=>{if(!e.video)return;let t=new URL(e.video.embedUrl);return t.searchParams.set(`autoplay`,`1`),t.href}),R=()=>{I.get(t.ownerDocument)===z&&I.delete(t.ownerDocument)},z=()=>{R(),C(!1)},B=()=>{I.get(t.ownerDocument)?.(),I.set(t.ownerDocument,z),C(!0)};_(()=>{let e=a([t],([e])=>{e&&o(e.contentRect.width>=200)});return()=>{e(),R()}});let V=()=>[v(u,{get when(){return!w()},get children(){var t=D();return t.addEventListener(`error`,()=>T(!0)),y(()=>e.video?.thumbnailUrl,e=>{g(t,`src`,e)}),t}}),(()=>{var e=O();return m(e,v(i,{get name(){return s()?`play`:`externalLink`}})),e})()];var H=N();return b(()=>e=>t=e,H),H._$owner=d(),m(H,v(u,{get when(){return e.video},get children(){var t=M(),n=t.firstChild,a=n.nextSibling,o=a.firstChild,c=o.firstChild,l=c.nextSibling,x=o.nextSibling,C=x.firstChild,w=C.nextSibling,T=d();return m(n,v(u,{get when(){return h(()=>!!S())()?s():S()},get fallback(){return v(u,{get when(){return s()},get fallback(){var t=F(),n=d();return m(t,v(V,{})),y(()=>({e:e.video?.watchUrl,t:r(`chat.youtube.openVideo`,{title:f()})}),({e,t:r},i)=>{e!==i?.e&&g(t,`href`,e),r!==i?.t&&g(t,`aria-label`,r),p(t,n)}),t},get children(){var e=P();return e._$$click=B,b(()=>e=>{E=e},e),m(e,v(V,{})),y(()=>r(`chat.youtube.play`,{title:f()}),t=>{g(e,`aria-label`,t)}),e}})},get children(){var e=k();return y(()=>({e:L(),t:r(`chat.youtube.player`,{title:f()})}),({e:t,t:n},r)=>{t!==r?.e&&g(e,`src`,t),n!==r?.t&&g(e,`title`,n)}),e}})),m(c,()=>r(`chat.youtube.provider`)),m(l,f),m(x,()=>r(`chat.youtube.open`),C),m(x,v(i,{name:`externalLink`}),w),m(a,v(u,{get when(){return S()},get children(){var e=A();return e._$$click=()=>{z(),_(()=>E?.focus())},m(e,v(i,{name:`x`})),y(()=>r(`chat.youtube.close`),t=>{g(e,`aria-label`,t)}),e}}),null),m(t,v(u,{get when(){return!s()},get children(){var t=j();return m(t,()=>r(e.enabled?`chat.youtube.narrow`:`chat.youtube.strict`)),t}}),null),y(()=>({e:f(),t:e.video?.watchUrl}),({e,t:n},r)=>{e!==r?.e&&g(t,`aria-label`,e),n!==r?.t&&g(x,`href`,n),p(x,T)}),t}})),H}var D,O,k,A,j,M,N,P,F,I;function L(){return(L=e((()=>{S(),f(),o(),T(),n(),t(),D=C(`<img alt loading=lazy referrerpolicy=no-referrer>`,1),O=C(`<span class=play aria-hidden=true>`),k=C(`<iframe sandbox="allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox"allow="autoplay; encrypted-media; fullscreen; picture-in-picture"allowfullscreen referrerpolicy=strict-origin-when-cross-origin>`),A=C(`<button class=close type=button>`),j=C(`<p class=notice role=status>`),M=C(`<section class=card><div class=stage></div><div class=footer><div class=caption><span class=provider></span><p class=title></p></div><a class=watch target=_blank rel="noopener noreferrer"><!><!>`),N=C(`<openclaw-youtube-video>`,1),P=C(`<button class=preview type=button>`),F=C(`<a class=preview target=_blank rel="noopener noreferrer">`),s(w),I=new WeakMap,x([`click`])})))()}L();export{E as YouTubeVideoCard};