import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{o as t}from"./vendor-motion-COLzAB1Q.js";import{c as n}from"./index-DLFWvoW-.js";import{t as r}from"./media-embed-CTRyFl8E.js";var i=e(t(),1);function a(e,t){return e||(t?o(t):null)}function o(e){switch(r(e)){case`youtube`:{let t=e.match(/youtu\.be\/([^?&]+)/),n=e.match(/[?&]v=([^&]+)/),r=t?.[1]||n?.[1];return r?`https://img.youtube.com/vi/${r}/hqdefault.jpg`:null}case`vimeo`:return null;default:return null}}var s=new Map;async function c(e){if(s.has(e))return s.get(e)??null;try{let{data:t,error:r}=await n.functions.invoke(`vimeo-thumbnail`,{body:{url:e}});if(r||!t?.success)return s.set(e,null),null;let i=t.thumbnail_url;return s.set(e,i),i}catch{return s.set(e,null),null}}function l(e){return e?r(e)===`vimeo`:!1}function u(e,t){let n=a(e,t),[r,o]=(0,i.useState)(n);return(0,i.useEffect)(()=>{if(n){o(n);return}if(!e&&l(t)){let e=!1;return c(t).then(t=>{e||o(t)}),()=>{e=!0}}o(null)},[e,t,n]),r}export{u as t};