import{o as e}from"./rolldown-runtime-C_s2cVnS.js";import{h as t,m as n,n as r}from"./vendor-react-nmZsNlRz.js";import{E as i}from"./index-DjNTYlku.js";var a=e(t(),1),o=r();function s(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var c=e(n(),1),l={instagram:{id:`hermes-ig-embed`,src:`https://www.instagram.com/embed.js`},tiktok:{id:`hermes-tt-embed`,src:`https://www.tiktok.com/embed.js`},twitter:{id:`hermes-tw-embed`,src:`https://platform.twitter.com/widgets.js`}},u=[0,300,800,1600,3e3];function d(e,t){let n=s(e.sourceUrl);switch(e.provider){case`instagram`:return`<blockquote class="instagram-media" data-instgrm-permalink="${n}" data-instgrm-version="14" style="margin:0;width:100%;min-width:0;max-width:100%"></blockquote>`;case`tiktok`:return`<blockquote class="tiktok-embed" cite="${n}" data-video-id="${s(e.id.replace(/^tiktok:/,``))}" style="margin:0;max-width:100%"><section></section></blockquote>`;case`twitter`:return`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${t}" data-chrome="transparent"><a href="${n}"></a></blockquote>`;default:return``}}function f(e){let{id:t,src:n}=l[e];if(e===`tiktok`)document.getElementById(t)?.remove();else if(document.getElementById(t))return Promise.resolve();return new Promise(e=>{let r=document.createElement(`script`);r.async=!0,r.id=t,r.onload=()=>e(),r.onerror=()=>e(),r.src=n,document.body.appendChild(r)})}function p(e,t){let n=window;e===`instagram`?n.instgrm?.Embeds?.process?.():e===`twitter`&&n.twttr?.widgets?.load?.(t)}function m(e){let t=(0,o.c)(5),{descriptor:n}=e,r=i(),s=(0,a.useRef)(null),l,m;t[0]!==n||t[1]!==r?(l=()=>{let e=s.current;if(!e)return;let t=!1,i=[];return e.innerHTML=d(n,r?`dark`:`light`),f(n.provider).then(()=>{for(let r of u)i.push(window.setTimeout(()=>!t&&p(n.provider,e),r))}),()=>{t=!0;for(let e of i)clearTimeout(e);e.innerHTML=``}},m=[n,r],t[0]=n,t[1]=r,t[2]=l,t[3]=m):(l=t[2],m=t[3]),(0,a.useEffect)(l,m);let h;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,c.jsx)(`div`,{className:`w-full [&_.instagram-media]:!min-w-0 [&_iframe]:!m-0 [&_iframe]:!max-w-full [&_iframe]:[color-scheme:light]`,ref:s}),t[4]=h):h=t[4],h}export{m as default};