import{P as n}from"./p-848b9fe8.js";import"./p-d7399561.js";import"./p-7dedb08f.js";export default({config:e,selector:t,src:o,preload:r})=>new Promise((async a=>{if(!window.Hls)for(;!window.hasOwnProperty("Hls");)await new Promise((e=>setTimeout(e,50)));if(window.Hls.isSupported()){let s=!["metadata","none"].includes(r);wp?.blocks&&(s=!0);var l=new window.Hls({autoStartLoad:s});return l.loadSource(o),l.on(window.Hls.Events.LEVEL_SWITCHED,((e,n)=>{t.closest(".presto-player__wrapper").querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span").innerHTML=l.autoLevelEnabled?`AUTO (${l.levels[n.level].height}p)`:"AUTO"})),void l.on(window.Hls.Events.MANIFEST_PARSED,(function(){var o=l.levels.map((function(e){return e.height}));o.unshift(0);const r=(o||[]).findIndex((e=>e===parseInt(window?.prestoPlayer?.hls_start_level)));l.startLevel=r?r-1:2,e.quality={default:0,options:o,forced:!0,onChange:function(e){0===e?prestoHLS.currentLevel=-1:prestoHLS.levels.forEach((function(t,n){t.height===e&&(console.log("Found quality match with "+e),prestoHLS.currentLevel=n)}))}},l.attachMedia(t),window.prestoHLS=l;const s=new n(t,{...e});s.hls=l;const i=()=>{l.startLoad(-1),s.off("waiting",i)};return s.on("waiting",i),s.on("languagechange",(()=>{setTimeout((()=>l.subtitleTrack=s.currentTrack),50)})),a(s)}))}return t.canPlayType("application/vnd.apple.mpegurl"),a(new n(t,{...e}))}));