const i=/(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)(?:\/shorts)?\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/,u=new Map,s=new Map;function l(e){return e.match(i)?.[1]}async function b(e,n){if(u.has(e))return u.get(e);if(s.has(e))return s.get(e);const t=new Promise(async r=>{const c=["maxresdefault","sddefault","hqdefault"];for(const a of c)for(const f of[!0,!1]){const o=p(e,a,f);if((await fetch(o,{mode:"no-cors",signal:n.signal})).status<400){u.set(e,o),r(o);return}}}).catch(()=>"").finally(()=>s.delete(e));return s.set(e,t),t}function p(e,n,t){return`https://i.ytimg.com/${t?"vi_webp":"vi"}/${e}/${n}.${t?"webp":"jpg"}`}export{b as findYouTubePoster,l as resolveYouTubeVideoId};
