itube-modern-player 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var ITubePlayer=(function(){"use strict";function l(r,e,t){const s=document.createElement(r);if(e&&(s.className=e),t)for(const[i,n]of Object.entries(t))s.setAttribute(i,n);return s}function m(r,e,t){const s=l("button",`imp-btn ${r}`,{type:"button","aria-label":e,title:e});return s.innerHTML=t,s}function E(r,e,t){r.innerHTML=e,t!==void 0&&(r.setAttribute("aria-label",t),r.setAttribute("title",t))}function y(r,e,t){return Math.min(t,Math.max(e,r))}function k(r){if(!Number.isFinite(r)||r<0)return"0:00";const e=Math.floor(r%60),t=Math.floor(r/60%60),s=Math.floor(r/3600),i=s>0?String(t).padStart(2,"0"):String(t),n=String(e).padStart(2,"0");return s>0?`${s}:${i}:${n}`:`${i}:${n}`}function T(r){const e=r.trim().match(/^(?:(\d+):)?(\d{1,2}):(\d{2})(?:[.,](\d{1,3}))?$/);if(!e)return null;const t=e[1]?Number(e[1]):0,s=Number(e[2]),i=Number(e[3]),n=e[4]?Number(e[4].padEnd(3,"0")):0;return t*3600+s*60+i+n/1e3}function $(r){const e=[],t=r.replace(/\r\n?/g,`
|
|
2
2
|
`).split(/\n\n+/);for(const s of t){const i=s.split(`
|
|
3
|
-
`).filter(v=>v.trim()!=="");if(i.length===0)continue;let n=i.findIndex(v=>v.includes("-->"));if(n===-1)continue;const[o,a]=i[n].split("-->"),
|
|
4
|
-
`).trim();p&&e.push({start:c,end:h,text:p})}return e}function K(r,e){try{return new URL(r,new URL(e,window.location.href)).toString()}catch{return r}}class X{constructor(){this.listeners=new Map}on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>this.off(e,t)}once(e,t){const s=this.on(e,i=>{s(),t(i)});return s}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,t){const s=this.listeners.get(e);if(s)for(const i of[...s])try{i(t)}catch(n){console.error("[itube-player] listener error",n)}}removeAll(){this.listeners.clear()}}const u=(r,e="0 0 24 24")=>`<svg viewBox="${e}" fill="currentColor" aria-hidden="true" focusable="false">${r}</svg>`,Y={play:u('<path d="M8 5.14v13.72c0 .8.87 1.3 1.56.88l10.54-6.86a1.05 1.05 0 0 0 0-1.76L9.56 4.26C8.87 3.84 8 4.34 8 5.14Z"/>'),pause:u('<rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/>'),replay:u('<path d="M12 5V2.5L7.5 6 12 9.5V7a5 5 0 1 1-5 5H5a7 7 0 1 0 7-7Z"/>'),bigPlay:u('<path d="M8 5.14v13.72c0 .8.87 1.3 1.56.88l10.54-6.86a1.05 1.05 0 0 0 0-1.76L9.56 4.26C8.87 3.84 8 4.34 8 5.14Z"/>'),volumeHigh:u('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="M14.5 8.6a4.5 4.5 0 0 1 0 6.8v-1.9a2.5 2.5 0 0 0 0-3v-1.9Z"/><path d="M14.5 5.2a8 8 0 0 1 0 13.6v-2a6 6 0 0 0 0-9.6v-2Z"/>'),volumeLow:u('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="M14.5 8.6a4.5 4.5 0 0 1 0 6.8v-1.9a2.5 2.5 0 0 0 0-3v-1.9Z"/>'),volumeMute:u('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="m15.3 9.3 1.4 1.4 1.4-1.4 1.4 1.4-1.4 1.4 1.4 1.4-1.4 1.4-1.4-1.4-1.4 1.4-1.4-1.4 1.4-1.4-1.4-1.4 1.4-1.4Z"/>'),fullscreen:u('<path d="M5 5h5v2H7v3H5V5Zm9 0h5v5h-2V7h-3V5ZM5 14h2v3h3v2H5v-5Zm12 0h2v5h-5v-2h3v-3Z"/>'),fullscreenExit:u('<path d="M10 10H5V8h3V5h2v5Zm4 0V5h2v3h3v2h-5Zm-4 4v5H8v-3H5v-2h5Zm4 0h5v2h-3v3h-2v-5Z"/>'),pip:u('<path d="M3 5h18v14H3V5Zm2 2v10h14V7H5Z"/><rect x="12" y="11" width="6" height="4"/>'),settings:u('<path d="M12 8.5A3.5 3.5 0 1 0 12 15.5 3.5 3.5 0 0 0 12 8.5Zm0 2a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/><path d="M10.3 2.8 9.9 5.1a7 7 0 0 0-1.5.86l-2.2-.8-1.7 3 1.8 1.5a7 7 0 0 0 0 1.7l-1.8 1.5 1.7 3 2.2-.8c.46.36.97.65 1.5.86l.4 2.3h3.4l.4-2.3a7 7 0 0 0 1.5-.86l2.2.8 1.7-3-1.8-1.5a7 7 0 0 0 0-1.7l1.8-1.5-1.7-3-2.2.8a7 7 0 0 0-1.5-.86l-.4-2.3h-3.4Zm1.7 5.7a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7Z"/>'),speed:u('<path d="M12 4a9 9 0 0 0-9 9 8.96 8.96 0 0 0 1.62 5.16l1.64-1.15A7 7 0 0 1 5 13a7 7 0 1 1 12.74 4.01l1.64 1.15A8.96 8.96 0 0 0 21 13a9 9 0 0 0-9-9Z"/><path d="m15.6 8.3-3.95 3.13a1.5 1.5 0 1 0 1.92 1.92L16.7 9.4a.78.78 0 0 0-1.1-1.1Z"/>'),scenes:u('<path d="M3 5h18v14H3V5Zm2 2v10h3V7H5Zm5 0v10h9V7h-9Zm-5 3h3v1H5v-1Zm0 3h3v1H5v-1Z"/>'),shuffle:u('<path d="M4 6h2.6c1.5 0 2.9.7 3.8 1.9l4.1 5.4a2.75 2.75 0 0 0 2.2 1.1H19l-1.8-1.8 1.4-1.4 4.2 4.2-4.2 4.2-1.4-1.4L19 16.4h-2.3a4.75 4.75 0 0 1-3.8-1.9L8.8 9.1A2.75 2.75 0 0 0 6.6 8H4V6Z"/><path d="M19 7.6h-2.3c-.86 0-1.67.41-2.18 1.1l-.93 1.23-1.25-1.65.58-.77A4.75 4.75 0 0 1 16.7 5.6H19L17.2 3.8l1.4-1.4 4.2 4.2-4.2 4.2-1.4-1.4L19 7.6Z" transform="translate(0 1.2)"/>'),repeat:u('<path d="M7 7h10v2.5L21 6l-4-3.5V5H5v6h2V7Zm10 10H7v-2.5L3 18l4 3.5V19h12v-6h-2v4Z"/>'),subtitles:u('<path d="M3 5h18v14H3V5Zm2 2v10h14V7H5Zm2 3h6v2H7v-2Zm8 0h2v2h-2v-2ZM7 14h2v2H7v-2Zm4 0h6v2h-6v-2Z"/>'),list:u('<path d="M4 6h2v2H4V6Zm4 0h12v2H8V6ZM4 11h2v2H4v-2Zm4 0h12v2H8v-2ZM4 16h2v2H4v-2Zm4 0h12v2H8v-2Z"/>'),next:u('<path d="M6 5.5v13c0 .77.84 1.25 1.5.85l9-6.5a1 1 0 0 0 0-1.7l-9-6.5c-.66-.4-1.5.08-1.5.85Z"/><rect x="17" y="5" width="2.5" height="14" rx="1"/>'),previous:u('<path d="M18 5.5v13c0 .77-.84 1.25-1.5.85l-9-6.5a1 1 0 0 1 0-1.7l9-6.5c.66-.4 1.5.08 1.5.85Z"/><rect x="4.5" y="5" width="2.5" height="14" rx="1"/>'),seekForward:u('<path d="M12 4V1.5L17 5.5 12 9.5V7a5.5 5.5 0 1 0 5.5 5.5H20A8 8 0 1 1 12 4Z"/>'),seekBack:u('<path d="M12 4V1.5L7 5.5 12 9.5V7a5.5 5.5 0 1 1-5.5 5.5H4A8 8 0 1 0 12 4Z"/>'),like:u('<path d="M9 21H5a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h4v11Zm2 0h7.1a2 2 0 0 0 2-1.6l1.3-7a2 2 0 0 0-2-2.4H14V5.5A2.5 2.5 0 0 0 11.5 3l-.5.1V10h-.9L11 21Z"/>'),dislike:u('<path d="M15 3h4a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-4V3Zm-2 0H5.9a2 2 0 0 0-2 1.6l-1.3 7a2 2 0 0 0 2 2.4H10v4.5A2.5 2.5 0 0 0 12.5 21l.5-.1V14h.9L13 3Z"/>'),addTo:u('<path d="M4 6h12v2H4V6Zm0 4h12v2H4v-2Zm0 4h8v2H4v-2Zm14 0v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4Z"/>'),share:u('<path d="M18 8a3 3 0 1 0-2.83-4H15a3 3 0 0 0 .14 1.06L8.4 8.94a3 3 0 1 0 0 6.12l6.74 3.88A3 3 0 1 0 16 16.6l-6.74-3.88a3.03 3.03 0 0 0 0-1.44L16 7.4c.55.38 1.24.6 2 .6Z"/>'),report:u('<path d="M5 3h2v18H5V3Zm4 1h10l-2.5 4L19 12H9V4Z"/>'),more:u('<circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/>'),close:u('<path d="m6.4 5 5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19 5 17.6 10.6 12 5 6.4 6.4 5Z"/>')},_={play:"Play",pause:"Pause",replay:"Replay",mute:"Mute",unmute:"Unmute",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",pip:"Picture-in-picture",settings:"Playback speed",scenes:"Scenes",shuffle:"Shuffle",repeat:"Repeat",subtitles:"Subtitles",subtitlesOff:"Off",speed:"Speed",quality:"Quality",qualityAuto:"Auto",next:"Next",previous:"Previous",playlist:"Playlist",like:"Like",dislike:"Dislike",addTo:"Save to…",share:"Share",report:"Report",more:"More actions",seekForward:"Seek forward",seekBack:"Seek back",live:"LIVE",related:"More videos",adLabel:"Ad",skipAd:"Skip ad",skipAdIn:"Skip in",visitAdvertiser:"Visit advertiser",sponsored:"Sponsored"},O={en:_};function J(r){for(const[e,t]of Object.entries(r))t&&(O[e]=t)}function ee(r){return r&&O[r]||_}function te(r,e,t=100){if(r.length===0||!Number.isFinite(e)||e<=0)return[];const s=new Array(t).fill(0);let i=!1;for(const h of r){if(!Number.isFinite(h.time)||h.time<0||h.time>e)continue;const p=Math.max(0,h.value);if(p===0)continue;const v=Math.min(t-1,Math.floor(h.time/e*t));s[v]+=p,i=!0}if(!i)return[];const n=[.06,.24,.4,.24,.06],o=s.map((h,p)=>n.reduce((v,d,b)=>v+d*(s[p+b-2]??0),0)),a=Math.max(...o);if(a<=0)return[];const c=.08;return o.map(h=>c+(1-c)*(h/a))}function ie(r,e=1e3,t=100){if(r.length===0)return"";const s=e/(r.length-1||1);let i=`M 0 ${t}`;return r.forEach((n,o)=>{i+=` L ${(o*s).toFixed(1)} ${(t-n*t).toFixed(1)}`}),i+=` L ${e} ${t} Z`,i}async function se(r,e){if(r.src)return{roll:r.roll,mediaUrl:r.src,clickThrough:r.clickUrl,impressions:[],tracking:{}};if(!r.vastTag)throw new Error('Ad roll has neither "vastTag" nor "src"');return N(r,r.vastTag,e,0,{impressions:[],tracking:{}})}async function N(r,e,t,s,i){if(s>t.maxWrapperDepth)throw new Error("VAST wrapper depth limit exceeded");const n=new AbortController,o=setTimeout(()=>n.abort(),t.requestTimeout);let a;try{const f=await fetch(e,{signal:n.signal,credentials:"omit"});if(!f.ok)throw new Error(`VAST request failed (${f.status})`);a=await f.text()}finally{clearTimeout(o)}const c=new DOMParser().parseFromString(a,"text/xml");if(c.querySelector("parsererror"))throw new Error("VAST response is not valid XML");const h=c.querySelector("VAST > Ad");if(!h)throw new Error("VAST response contains no ads");ne(h,i);const p=h.querySelector(":scope > Wrapper");if(p){const f=w(p.querySelector("VASTAdTagURI"));if(!f)throw new Error("VAST wrapper without VASTAdTagURI");return N(r,f,t,s+1,i)}const v=h.querySelector(":scope > InLine");if(!v)throw new Error("VAST ad has neither InLine nor Wrapper");const d=v.querySelector("Creatives > Creative > Linear");if(!d)throw new Error("VAST ad has no Linear creative");const b=re(d);if(!b)throw new Error("VAST ad has no playable MediaFile");return{roll:r.roll,mediaUrl:b.url,mediaType:b.type,clickThrough:w(d.querySelector("VideoClicks > ClickThrough"))??r.clickUrl,duration:P(w(d.querySelector(":scope > Duration"))),skipOffset:oe(d.getAttribute("skipoffset"),P(w(d.querySelector(":scope > Duration")))),impressions:i.impressions,tracking:i.tracking,adTitle:w(v.querySelector(":scope > AdTitle"))??void 0}}function ne(r,e){var t,s;for(const i of r.querySelectorAll("Impression")){const n=w(i);n&&e.impressions.push(n)}for(const i of r.querySelectorAll("Linear > TrackingEvents > Tracking")){const n=i.getAttribute("event"),o=w(i);!n||!o||["start","firstQuartile","midpoint","thirdQuartile","complete","skip","pause","resume"].includes(n)&&((t=e.tracking)[n]??(t[n]=[])).push(o)}for(const i of r.querySelectorAll("Linear > VideoClicks > ClickTracking")){const n=w(i);n&&((s=e.tracking).click??(s.click=[])).push(n)}}function re(r){const t=[...r.querySelectorAll("MediaFiles > MediaFile")].map(o=>({url:w(o)??"",type:o.getAttribute("type")??void 0,delivery:o.getAttribute("delivery")??"",bitrate:Number(o.getAttribute("bitrate")??0),apiFramework:o.getAttribute("apiFramework")??""})).filter(o=>o.url&&o.apiFramework.toUpperCase()!=="VPAID").filter(o=>!o.type||/(video\/(mp4|webm|ogg)|application\/(x-mpegurl|vnd\.apple\.mpegurl))/i.test(o.type));if(t.length===0)return null;t.sort((o,a)=>o.bitrate-a.bitrate);const s=t.filter(o=>o.delivery!=="streaming"),i=s.length>0?s:t,n=i[Math.floor(i.length/2)];return{url:n.url,type:n.type}}function P(r){if(!r)return;const e=r.trim().match(/^(?:(\d+):)?(\d{1,2}):(\d{2})(?:\.(\d{1,3}))?$/);if(e)return(e[1]?Number(e[1])*3600:0)+Number(e[2])*60+Number(e[3])+(e[4]?Number(e[4].padEnd(3,"0"))/1e3:0)}function oe(r,e){if(!r)return;const t=r.trim().match(/^(\d+(?:\.\d+)?)%$/);return t?e!==void 0?Number(t[1])/100*e:void 0:P(r)}function A(r){if(r)for(const e of r)try{new Image().src=e}catch{}}function w(r){return r?.textContent?.trim().replace(/^<!\[CDATA\[|\]\]>$/g,"").trim()||null}class le{constructor(e,t){this.host=e,this.playedRolls=new Set,this.sourcesSeen=0,this.activeBreak=null,this.layer=null,this.adVideo=null,this.destroyed=!1,this.opts={skipDelay:5,maxWrapperDepth:3,requestTimeout:8e3,mediaTimeout:1e4,playOn:"every",...t}}ensureAdVideo(){if(!this.adVideo){this.adVideo=l("video","imp-ad__video",{playsinline:""});try{this.adVideo.load()}catch{}}return this.adVideo}get adPlaying(){return this.activeBreak!==null}get hasPendingPreRoll(){return this.pending("preRoll").length>0}resetForNewSource(){if(this.sourcesSeen++,this.opts.playOn==="first"&&this.sourcesSeen>1){for(const e of this.opts.adList)this.playedRolls.add(e);return}this.playedRolls.clear()}async playPreRoll(){await this.playRolls(this.pending("preRoll"))}async playPostRoll(){await this.playRolls(this.pending("postRoll"))}checkMidRolls(e){if(this.adPlaying)return;const t=this.pending("midRoll").filter(s=>s.timer!==void 0&&e>=s.timer);t.length>0&&this.playRolls(t)}pending(e){return this.opts.adList.filter(t=>t.roll===e&&!this.playedRolls.has(t))}async playRolls(e){if(e.length===0||this.destroyed)return;if(this.activeBreak)return this.activeBreak;this.ensureAdVideo();const t=(async()=>{const s=this.host.contentVideo,i=!s.paused&&!s.ended;s.pause();for(const n of e){this.playedRolls.add(n);try{const o=await se(n,this.opts);await this.playAd(o)}catch(o){const a=o instanceof Error?o:new Error(String(o));this.host.emitter.emit("aderror",{roll:n,error:a})}if(this.destroyed)return}(i||e[0].roll==="preRoll")&&s.play().catch(()=>{})})();return this.activeBreak=t.finally(()=>{this.activeBreak=null}),this.activeBreak}playAd(e){return new Promise(t=>{const{labels:s}=this.host,i=l("div","imp-ad"),n=this.ensureAdVideo(),o=new AbortController,a=o.signal;n.src=e.mediaUrl,n.muted=this.host.contentVideo.muted,n.volume=this.host.contentVideo.volume;const c=l("div","imp-spinner imp-ad__spinner"),h=l("div","imp-ad__hud"),p=l("span","imp-ad__badge");p.textContent=e.adTitle?`${s.adLabel} · ${e.adTitle}`:s.adLabel;const v=l("span","imp-ad__countdown");h.append(p,v);const d=l("div","imp-ad__actions");let b=null;e.clickThrough&&(b=l("button","imp-ad__visit",{type:"button"}),b.textContent=s.visitAdvertiser,d.append(b));const f=l("button","imp-ad__skip",{type:"button"});f.hidden=!0,d.append(f),i.append(n,c,h,d),this.host.container.append(i),this.layer=i;const D=e.skipOffset??this.opts.skipDelay,W=new Set,S=g=>{W.has(g)||(W.add(g),A(e.tracking[g]))};let I=Date.now(),z=-1;const Le=setInterval(()=>{if(n.paused){I=Date.now();return}if(n.currentTime!==z){z=n.currentTime,I=Date.now();return}Date.now()-I>=this.opts.mediaTimeout&&(this.host.emitter.emit("aderror",{roll:{roll:e.roll},error:new Error(`Ad media stalled for ${this.opts.mediaTimeout} ms — skipping`)}),q())},500),q=()=>{clearInterval(Le),o.abort(),n.pause(),n.removeAttribute("src"),n.load(),i.remove(),this.layer=null,t()},Q=g=>{g?(S("skip"),this.host.emitter.emit("adskip",{ad:e})):S("complete"),this.host.emitter.emit("adend",{ad:e}),q()};n.addEventListener("playing",()=>{A(e.impressions),S("start"),this.host.emitter.emit("adstart",{ad:e})},{once:!0,signal:a}),n.addEventListener("playing",()=>{c.hidden=!0},{signal:a}),n.addEventListener("waiting",()=>{c.hidden=!1},{signal:a}),n.addEventListener("timeupdate",()=>{const g=n.currentTime,x=n.duration;if(Number.isFinite(x)&&x>0&&(v.textContent=k(Math.max(0,x-g)),g/x>=.25&&S("firstQuartile"),g/x>=.5&&S("midpoint"),g/x>=.75&&S("thirdQuartile")),D>=0){const j=Math.ceil(D-g);j>0?(f.hidden=!1,f.disabled=!0,f.textContent=`${s.skipAdIn} ${j}`):(f.hidden=!1,f.disabled=!1,f.textContent=s.skipAd)}},{signal:a}),n.addEventListener("ended",()=>Q(!1),{signal:a}),n.addEventListener("error",()=>{this.host.emitter.emit("aderror",{roll:{roll:e.roll},error:new Error("Ad media failed to play")}),q()},{signal:a}),f.addEventListener("click",()=>Q(!0));const U=()=>{e.clickThrough&&(S("click"),this.host.emitter.emit("adclick",{ad:e}),window.open(e.clickThrough,"_blank","noopener"),n.pause())};n.addEventListener("click",U,{signal:a}),b?.addEventListener("click",U);let G=!1,M=!1;n.addEventListener("playing",()=>{G=!0},{once:!0,signal:a}),n.addEventListener("pause",()=>{n.ended||!i.isConnected||(i.classList.add("imp-ad--paused"),G&&!M&&(M=!0,A(e.tracking.pause),this.host.emitter.emit("adpause",{ad:e})))},{signal:a}),n.addEventListener("play",()=>{i.classList.remove("imp-ad--paused"),M&&(M=!1,A(e.tracking.resume),this.host.emitter.emit("adresume",{ad:e}))},{signal:a}),i.addEventListener("click",g=>{(g.target===i||i.classList.contains("imp-ad--paused"))&&n.paused&&n.play().catch(()=>{})}),n.play().catch(()=>{i.classList.add("imp-ad--paused")})})}get closeIcon(){return this.host.closeIcon}destroy(){this.destroyed=!0,this.adVideo?.pause(),this.layer?.remove(),this.layer=null,this.adVideo=null}}function ae(r,e){const t=[...r].sort((i,n)=>i.start-n.start),s=[];for(let i=0;i<t.length;i++){const n=Math.max(0,t[i].start);if(Number.isFinite(e)&&n>=e)continue;let o=t[i].end??t[i+1]?.start??e;Number.isFinite(e)&&(o=Math.min(o,e)),!(o<=n)&&s.push({start:n,end:o,title:t[i].title})}return s}async function he(r){const e=await fetch(r);if(!e.ok)throw new Error(`Failed to load chapters VTT (${e.status})`);const t=await e.text();return $(t).map(s=>({start:s.start,end:s.end,title:s.text}))}function Z(r,e){for(const t of r)if(e>=t.start&&e<t.end)return t;return null}function ce(r,e){return e?/application\/(x-mpegurl|vnd\.apple\.mpegurl)/i.test(e):/\.m3u8(\?|#|$)/i.test(r)}let L;async function de(){if(L!==void 0)return L;const r=globalThis.Hls;if(r)return L=r,L;try{L=(await import("hls.js/light")).default}catch{L=null}return L}async function ue(r,e,t,s){if(ce(e,t)){const i=r.canPlayType("application/vnd.apple.mpegurl"),n=i?null:await de();return n&&n.isSupported()?pe(n,r,e,s):i?(r.src=e,R(r)):(s.onError("HLS is not supported in this browser and hls.js could not be loaded."),R(r))}return r.src=e,R(r)}function R(r){return{kind:"native",levels:[],selected:-1,setLevel(){},destroy(){r.removeAttribute("src"),r.load()}}}function pe(r,e,t,s){const i=new r({enableWorker:!0}),n={kind:"hls",levels:[],selected:-1,setLevel(c){n.selected=c,i.currentLevel=c},destroy(){i.destroy(),e.removeAttribute("src"),e.load()}};i.on(r.Events.MANIFEST_PARSED,()=>{n.levels=i.levels.map((c,h)=>({index:h,label:c.height?`${c.height}p`:`${Math.round(c.bitrate/1e3)} kbps`})).reverse(),s.onLevels(n.levels)}),i.on(r.Events.LEVEL_SWITCHED,(c,h)=>{const p=i.levels[h.level];p&&s.onLevelSwitch(p.height?`${p.height}p`:`${Math.round(p.bitrate/1e3)} kbps`)});let o=0,a=!1;return i.on(r.Events.ERROR,(c,h)=>{if(h.fatal)switch(h.type){case r.ErrorTypes.NETWORK_ERROR:i.startLoad();break;case r.ErrorTypes.MEDIA_ERROR:o<3?(o++,i.recoverMediaError()):(s.onError(`HLS media error: ${h.details}`,h),i.destroy());break;default:if(a)s.onError(`HLS fatal error: ${h.details}`,h),i.destroy();else{a=!0;try{i.loadSource(t),i.startLoad()}catch{s.onError(`HLS fatal error: ${h.details}`,h),i.destroy()}}}}),i.loadSource(t),i.attachMedia(e),n}class V{constructor(e){this.cues=e}static async load(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load thumbnails VTT (${t.status})`);const s=await t.text(),i=[];for(const n of $(s)){const[o,a]=n.text.trim().split("#");if(!o)continue;const c={start:n.start,end:n.end,src:K(o,e)},h=a?.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);h&&(c.xywh={x:Number(h[1]),y:Number(h[2]),w:Number(h[3]),h:Number(h[4])}),i.push(c)}return i.sort((n,o)=>n.start-o.start),new V(i)}cueAt(e){let t=0,s=this.cues.length-1;for(;t<=s;){const i=t+s>>1,n=this.cues[i];if(e<n.start)s=i-1;else if(e>=n.end)t=i+1;else return n}return null}}class C{constructor(e){this.anchor=e,this.outsideListener=null,this.root=l("div","imp-menu"),this.root.hidden=!0,this.backdrop=l("div","imp-menu__backdrop"),this.backdrop.hidden=!0,this.backdrop.addEventListener("pointerdown",t=>{t.preventDefault(),this.close()}),e.append(this.backdrop)}get open(){return!this.root.hidden}toggle(e){this.open?this.close():this.show(e)}show(e){this.root.textContent="";for(const t of e){if(t.items.length===0)continue;const s=l("div","imp-menu__section");if(t.title){const i=l("div","imp-menu__title");i.textContent=t.title,s.append(i)}for(const i of t.items){const n=l("button","imp-menu__item",{type:"button",role:"menuitemradio"});if(n.setAttribute("aria-checked",String(i.active)),i.active&&n.classList.add("imp-menu__item--active"),i.icon){const a=l("span","imp-menu__icon");i.icon.trimStart().startsWith("<svg")?a.innerHTML=i.icon:a.append(l("img","",{src:i.icon,alt:""})),n.append(a)}const o=l("span","imp-menu__label");o.textContent=i.label,n.append(o),n.addEventListener("click",()=>{t.onSelect(i.value),this.close()}),s.append(n)}this.root.append(s)}this.root.hidden=!1,this.backdrop.hidden=!1,this.outsideListener=t=>{const s=t.target;!this.root.contains(s)&&!this.anchor.contains(s)&&this.close()},setTimeout(()=>{this.outsideListener&&document.addEventListener("pointerdown",this.outsideListener)},0)}close(){this.root.hidden=!0,this.backdrop.hidden=!0,this.outsideListener&&(document.removeEventListener("pointerdown",this.outsideListener),this.outsideListener=null)}destroy(){this.close(),this.root.remove()}}class me{constructor(e){this.cb=e,this.segments=[],this.duration=0,this.chapters=[],this.thumbnails=null,this.scrubbing=!1,this.root=l("div","imp-progress",{role:"slider","aria-label":"Seek",tabindex:"-1"}),this.buffered=l("div","imp-progress__buffered"),this.track=l("div","imp-progress__track"),this.handle=l("div","imp-progress__handle"),this.tooltipThumb=l("div","imp-progress__thumb"),this.tooltipChapter=l("div","imp-progress__tooltip-chapter"),this.tooltipTime=l("div","imp-progress__tooltip-time"),this.tooltip=l("div","imp-progress__tooltip"),this.tooltip.append(this.tooltipThumb,this.tooltipChapter,this.tooltipTime),this.heatmap=l("div","imp-progress__heatmap"),this.heatmap.hidden=!0,this.root.append(this.heatmap,this.buffered,this.track,this.handle,this.tooltip),this.setChapters([]),this.bindPointer()}setHeatmap(e){if(e.length===0){this.heatmap.hidden=!0,this.heatmap.textContent="";return}this.heatmap.innerHTML=`<svg viewBox="0 0 1000 100" preserveAspectRatio="none" aria-hidden="true"><path d="${ie(e)}"/></svg>`,this.heatmap.hidden=!1}setDuration(e){this.duration=Number.isFinite(e)?e:0,this.root.classList.toggle("imp-progress--live",!Number.isFinite(e)),this.chapters.length===0&&this.setChapters([])}setChapters(e){this.chapters=e,this.track.textContent="",this.segments=[];const t=e.length>0?e:[{start:0,end:this.duration||1,title:""}],s=[];let i=0;for(const n of t)n.start>i&&s.push({start:i,end:n.start,title:""}),s.push(n),i=n.end;this.duration>0&&i<this.duration&&s.push({start:i,end:this.duration,title:""});for(const n of s){const o=l("div","imp-progress__segment");o.style.flexGrow=String(Math.max(n.end-n.start,.01));const a=l("div","imp-progress__fill");o.append(a),this.track.append(o),this.segments.push({chapter:n,root:o,fill:a})}}setThumbnails(e){this.thumbnails=e}update(e,t,s){if(t!==this.duration&&Number.isFinite(t)&&this.setDuration(t),this.scrubbing)return;this.render(e);const i=this.duration>0?y(s/this.duration,0,1):0;this.buffered.style.width=`${i*100}%`,this.root.setAttribute("aria-valuemin","0"),this.root.setAttribute("aria-valuemax",String(Math.round(this.duration))),this.root.setAttribute("aria-valuenow",String(Math.round(e))),this.root.setAttribute("aria-valuetext",`${k(e)} / ${k(this.duration)}`)}render(e){for(const{chapter:s,fill:i}of this.segments){const n=s.end-s.start,o=n>0?y((e-s.start)/n,0,1):0;i.style.transform=`scaleX(${o})`}const t=this.duration>0?y(e/this.duration,0,1):0;this.handle.style.left=`${t*100}%`}timeFromEvent(e){const t=this.root.getBoundingClientRect();return(t.width>0?y((e.clientX-t.left)/t.width,0,1):0)*this.duration}bindPointer(){this.root.addEventListener("pointerdown",e=>{this.duration<=0||(e.preventDefault(),this.scrubbing=!0,this.root.classList.add("imp-progress--scrubbing"),this.root.setPointerCapture(e.pointerId),this.cb.onScrubStart(),this.render(this.timeFromEvent(e)),this.showTooltip(e))}),this.root.addEventListener("pointermove",e=>{this.duration<=0||(this.showTooltip(e),this.scrubbing&&this.render(this.timeFromEvent(e)))}),this.root.addEventListener("pointerup",e=>{this.scrubbing&&(this.scrubbing=!1,this.root.classList.remove("imp-progress--scrubbing"),this.cb.onSeek(this.timeFromEvent(e)),this.cb.onScrubEnd())}),this.root.addEventListener("pointercancel",()=>{this.scrubbing=!1,this.root.classList.remove("imp-progress--scrubbing"),this.cb.onScrubEnd()}),this.root.addEventListener("pointerleave",()=>this.hideTooltip())}showTooltip(e){const t=this.timeFromEvent(e);this.tooltipTime.textContent=k(t);const s=Z(this.chapters,t);this.tooltipChapter.textContent=s?.title??"",this.tooltipChapter.hidden=!s?.title;const i=this.thumbnails?.cueAt(t)??null;i?(this.tooltipThumb.hidden=!1,this.tooltipThumb.style.backgroundImage=`url("${i.src}")`,i.xywh?(this.tooltipThumb.style.width=`${i.xywh.w}px`,this.tooltipThumb.style.height=`${i.xywh.h}px`,this.tooltipThumb.style.backgroundPosition=`-${i.xywh.x}px -${i.xywh.y}px`,this.tooltipThumb.style.backgroundSize="auto"):(this.tooltipThumb.style.width="160px",this.tooltipThumb.style.height="90px",this.tooltipThumb.style.backgroundPosition="center",this.tooltipThumb.style.backgroundSize="cover")):this.tooltipThumb.hidden=!0,this.tooltip.classList.add("imp-progress__tooltip--visible");const n=this.root.getBoundingClientRect(),o=y(e.clientX-n.left,0,n.width),a=this.tooltip.offsetWidth/2;this.tooltip.style.left=`${y(o,a,Math.max(a,n.width-a))}px`}hideTooltip(){this.tooltip.classList.remove("imp-progress__tooltip--visible")}}const B=class B{constructor(e){this.player=e,this.subtitlesBtn=null,this.settingsBtn=null,this.settingsMenu=null,this.subtitlesMenu=null,this.moreMenu=null,this.moreWrap=null,this.qualityBtn=null,this.qualityMenu=null,this.scenesBtn=null,this.likeBtn=null,this.dislikeBtn=null,this.likeCountEl=null,this.dislikeCountEl=null,this.prevBtn=null,this.nextBtn=null,this.seekBackBtn=null,this.seekFwdBtn=null,this.centerPlayBtn=null,this.centerPrevBtn=null,this.centerNextBtn=null,this.collapsibles=[],this.overflowed=new Set,this.resizeObserver=null,this.reflowScheduled=!1,this.actionItems=[],this.wasPlayingBeforeScrub=!1,this.disposers=[],this.onWindowResize=null;const{labels:t,icons:s}=e,i=e.controlsOptions;this.root=l("div","imp-controls"),this.progress=new me({onSeek:d=>e.seek(d),onScrubStart:()=>{this.wasPlayingBeforeScrub=!e.paused,e.pause()},onScrubEnd:()=>{this.wasPlayingBeforeScrub&&e.play()}}),i.progress&&this.root.append(this.progress.root);const n=l("div","imp-controls__row");this.row=n,this.root.append(n);const o=l("div","imp-controls__group"),a=l("div","imp-controls__group");this.rightGroup=a;const c=l("div","imp-controls__spacer");this.chapterLabel=l("div","imp-controls__chapter"),n.append(o,c,a),c.append(this.chapterLabel);const h=typeof i.seekButtons=="object"?i.seekButtons:{},p=h.back??e.seekStep,v=h.forward??e.seekStep;if(i.playlist&&e.hasPlaylist&&(this.prevBtn=m("imp-btn--prev",t.previous,s.previous),this.prevBtn.addEventListener("click",()=>e.previous()),o.append(this.prevBtn)),i.seekButtons&&(this.seekBackBtn=m("imp-btn--seek-back",`${t.seekBack} ${p}s`,s.seekBack),this.seekBackBtn.addEventListener("click",()=>e.skip(-p)),o.append(this.seekBackBtn)),i.play&&(this.playBtn=m("imp-btn--play",t.play,s.play),this.playBtn.addEventListener("click",()=>e.togglePlay()),o.append(this.playBtn)),i.seekButtons&&(this.seekFwdBtn=m("imp-btn--seek-forward",`${t.seekForward} ${v}s`,s.seekForward),this.seekFwdBtn.addEventListener("click",()=>e.skip(v)),o.append(this.seekFwdBtn)),i.playlist&&e.hasPlaylist&&(this.nextBtn=m("imp-btn--next",t.next,s.next),this.nextBtn.addEventListener("click",()=>e.next()),o.append(this.nextBtn)),i.volume){const d=l("div","imp-volume");this.muteBtn=m("imp-btn--mute",t.mute,s.volumeHigh),this.muteBtn.addEventListener("click",()=>e.toggleMute()),this.volumeSlider=l("input","imp-volume__slider",{type:"range",min:"0",max:"1",step:"0.05","aria-label":"Volume"}),this.volumeSlider.addEventListener("input",()=>{e.setVolume(Number(this.volumeSlider.value))}),d.append(this.muteBtn,this.volumeSlider),o.append(d)}if(i.time&&(this.timeLabel=l("div","imp-controls__time"),this.liveBadge=l("span","imp-controls__live"),this.liveBadge.textContent=t.live,this.liveBadge.hidden=!0,o.append(this.timeLabel,this.liveBadge)),this.buildLikeDislike(a),i.subtitles){this.subtitlesBtn=m("imp-btn--subtitles",t.subtitles,s.subtitles),this.subtitlesMenu=new C(this.subtitlesBtn);const d=l("div","imp-controls__menu-anchor");d.append(this.subtitlesBtn,this.subtitlesMenu.root),this.subtitlesBtn.addEventListener("click",()=>this.toggleSubtitlesMenu()),a.append(d),this.registerCollapsible({key:"subtitles",el:d,priority:30,available:()=>e.subtitleTracks.length>0,section:()=>this.subtitlesSection()})}if(i.settings){this.settingsBtn=m("imp-btn--settings",t.settings,s.speed),this.settingsMenu=new C(this.settingsBtn);const d=l("div","imp-controls__menu-anchor");d.append(this.settingsBtn,this.settingsMenu.root),this.settingsBtn.addEventListener("click",()=>this.toggleSettingsMenu()),a.append(d),this.registerCollapsible({key:"settings",el:d,priority:40,available:()=>!0,section:()=>this.speedSection()})}if(i.quality){this.qualityBtn=m("imp-btn--quality",t.quality,s.settings),this.qualityMenu=new C(this.qualityBtn);const d=l("div","imp-controls__menu-anchor");d.append(this.qualityBtn,this.qualityMenu.root),this.qualityBtn.addEventListener("click",()=>this.toggleQualityMenu()),a.append(d),this.registerCollapsible({key:"quality",el:d,priority:10,available:()=>e.qualityLevels.length>0,section:()=>this.qualitySection()})}if(i.scenes&&(this.scenesBtn=m("imp-btn--scenes",t.scenes,s.scenes),this.scenesBtn.addEventListener("click",()=>e.toggleScenesPanel()),a.append(this.scenesBtn),this.registerCollapsible({key:"scenes",el:this.scenesBtn,priority:25,available:()=>e.chapterList.length>0,section:()=>this.simpleSection("scenes",t.scenes,s.scenes,()=>e.toggleScenesPanel())})),i.playlist&&e.hasPlaylist){const d=m("imp-btn--list",t.playlist,s.list);d.addEventListener("click",()=>e.togglePlaylistPanel()),a.append(d),this.registerCollapsible({key:"list",el:d,priority:50,available:()=>!0,section:()=>this.simpleSection("list",t.playlist,s.list,()=>e.togglePlaylistPanel())})}if(i.pip&&"requestPictureInPicture"in HTMLVideoElement.prototype){const d=m("imp-btn--pip",t.pip,s.pip);d.addEventListener("click",()=>void e.togglePip()),a.append(d),this.registerCollapsible({key:"pip",el:d,priority:20,available:()=>!0,section:()=>this.simpleSection("pip",t.pip,s.pip,()=>void e.togglePip())})}if(i.fullscreen&&(this.fullscreenBtn=m("imp-btn--fullscreen",t.fullscreen,s.fullscreen),this.fullscreenBtn.addEventListener("click",()=>void e.toggleFullscreen()),a.append(this.fullscreenBtn)),this.prevBtn&&this.registerCollapsible({key:"prev",el:this.prevBtn,priority:70,available:()=>!0,section:()=>e.hasPrevious?this.simpleSection("prev",t.previous,s.previous,()=>e.previous()):null}),this.nextBtn&&this.registerCollapsible({key:"next",el:this.nextBtn,priority:72,available:()=>!0,section:()=>e.hasNext?this.simpleSection("next",t.next,s.next,()=>e.next()):null}),this.seekBackBtn){const d=this.seekBackBtn;this.registerCollapsible({key:"seekBack",el:d,priority:80,available:()=>Number.isFinite(e.duration)&&e.duration>0,section:()=>this.simpleSection("seekBack",`${t.seekBack} ${p}s`,s.seekBack,()=>e.skip(-p))})}if(this.seekFwdBtn){const d=this.seekFwdBtn;this.registerCollapsible({key:"seekFwd",el:d,priority:82,available:()=>Number.isFinite(e.duration)&&e.duration>0,section:()=>this.simpleSection("seekFwd",`${t.seekForward} ${v}s`,s.seekForward,()=>e.skip(v))})}if(this.center=l("div","imp-center-controls"),i.playlist&&e.hasPlaylist&&(this.centerPrevBtn=this.makeCenterButton("prev",t.previous,s.previous),this.centerPrevBtn.addEventListener("click",()=>e.previous()),this.center.append(this.centerPrevBtn)),i.seekButtons){const d=this.makeCenterButton("seek-back",`${t.seekBack} ${p}s`,s.seekBack);d.addEventListener("click",()=>e.skip(-p)),this.center.append(d)}if(i.play&&(this.centerPlayBtn=this.makeCenterButton("play",t.play,s.play),this.centerPlayBtn.addEventListener("click",()=>e.togglePlay()),this.center.append(this.centerPlayBtn)),i.seekButtons){const d=this.makeCenterButton("seek-forward",`${t.seekForward} ${v}s`,s.seekForward);d.addEventListener("click",()=>e.skip(v)),this.center.append(d)}i.playlist&&e.hasPlaylist&&(this.centerNextBtn=this.makeCenterButton("next",t.next,s.next),this.centerNextBtn.addEventListener("click",()=>e.next()),this.center.append(this.centerNextBtn)),this.center.style.display="none",this.buildMoreDropdown(a),this.bind(),this.syncVolume(),this.syncPlayState(),this.setLikeState(e.actionsOptions.likeState??null),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.scheduleReflow()),this.resizeObserver.observe(e.container)),this.onWindowResize=()=>this.scheduleReflow(),window.addEventListener("resize",this.onWindowResize)}registerCollapsible(e){this.collapsibles.push(e)}makeCenterButton(e,t,s){const i=l("button",`imp-center-btn imp-center-btn--${e}`,{type:"button","aria-label":t,title:t});return i.innerHTML=s,i}buildLikeDislike(e){const t=this.player,s=t.actionsOptions,{labels:i,icons:n}=t;if(s.like){this.likeBtn=m("imp-btn--like",i.like,n.like),this.likeBtn.addEventListener("click",()=>t.emit("action",{id:"like"})),this.likeCountEl=this.attachCountTooltip(this.likeBtn,s.likeCount);const o=this.wrapWithTooltip(this.likeBtn,this.likeCountEl);e.append(o),this.registerCollapsible({key:"like",el:o,priority:62,available:()=>!0,section:()=>this.simpleSection("like",i.like,n.like,()=>t.emit("action",{id:"like"}))})}if(s.dislike){this.dislikeBtn=m("imp-btn--dislike",i.dislike,n.dislike),this.dislikeBtn.addEventListener("click",()=>t.emit("action",{id:"dislike"})),this.dislikeCountEl=this.attachCountTooltip(this.dislikeBtn,s.dislikeCount);const o=this.wrapWithTooltip(this.dislikeBtn,this.dislikeCountEl);e.append(o),this.registerCollapsible({key:"dislike",el:o,priority:60,available:()=>!0,section:()=>this.simpleSection("dislike",i.dislike,n.dislike,()=>t.emit("action",{id:"dislike"}))})}}attachCountTooltip(e,t){const s=l("span","imp-count-tooltip");return this.setCountText(s,t),s}wrapWithTooltip(e,t){const s=l("div","imp-action");return s.append(e,t),s}setCountText(e,t){const s=t==null||t===""?"":String(t);e.textContent=s,e.hidden=s===""}setLikeCounts(e,t){this.likeCountEl&&e!==void 0&&this.setCountText(this.likeCountEl,e),this.dislikeCountEl&&t!==void 0&&this.setCountText(this.dislikeCountEl,t)}setLikeState(e){this.likeBtn?.classList.toggle("imp-btn--active",e==="like"),this.dislikeBtn?.classList.toggle("imp-btn--active",e==="dislike")}buildMoreDropdown(e){const t=this.player,s=t.actionsOptions,{labels:i,icons:n}=t;s.addTo&&this.actionItems.push({value:"addTo",label:i.addTo,icon:n.addTo,run:()=>t.emit("action",{id:"addTo"})}),s.share&&this.actionItems.push({value:"share",label:i.share,icon:n.share,run:()=>void t.share()}),s.report&&this.actionItems.push({value:"report",label:i.report,icon:n.report,run:()=>t.emit("action",{id:"report"})});for(const c of s.custom??[])this.actionItems.push({value:`custom:${c.id}`,label:c.title,icon:c.icon,run:()=>t.emit("customaction",{id:c.id})});const o=m("imp-btn--more",i.more,n.more);this.moreMenu=new C(o);const a=l("div","imp-controls__menu-anchor imp-controls__more");a.append(o,this.moreMenu.root),o.addEventListener("click",()=>{this.closeMenus(this.moreMenu),this.moreMenu?.toggle(this.buildMoreSections())}),e.append(a),this.moreWrap=a}buildMoreSections(){const e=[],t=new Map,s=[],i=["prev","next","seekBack","seekFwd","like","dislike","scenes","pip","list","subtitles","settings","quality"],n=this.collapsibles.filter(o=>this.overflowed.has(o.key)&&o.available()).sort((o,a)=>i.indexOf(o.key)-i.indexOf(a.key));for(const o of n){const a=o.section();if(a)if(!a.title&&a.items.length===1){const c=a.items[0];s.push(c),t.set(c.value,()=>a.onSelect(c.value))}else e.push(a)}if(s.length>0&&e.unshift({title:"",items:s,onSelect:o=>t.get(o)?.()}),this.actionItems.length>0){const o=new Map(this.actionItems.map(a=>[a.value,a.run]));e.push({title:"",items:this.actionItems.map(({value:a,label:c,icon:h})=>({value:a,label:c,icon:h,active:!1})),onSelect:a=>o.get(a)?.()})}return e}simpleSection(e,t,s,i){return{title:"",items:[{value:e,label:t,icon:s,active:!1}],onSelect:()=>i()}}speedSection(){const e=this.player;return{title:e.labels.speed,items:e.playbackRates.map(t=>({label:t===1?"1× (normal)":`${t}×`,value:String(t),active:e.playbackRate===t})),onSelect:t=>e.setPlaybackRate(Number(t))}}qualitySection(){const e=this.player;return{title:e.labels.quality,items:[...e.qualityAutoAvailable?[{label:e.labels.qualityAuto,value:"-1",active:e.currentQuality===-1}]:[],...e.qualityLevels.map(t=>({label:t.label,value:String(t.index),active:e.currentQuality===t.index}))],onSelect:t=>e.setQuality(Number(t))}}subtitlesSection(){const e=this.player;return{title:e.labels.subtitles,items:[{label:e.labels.subtitlesOff,value:"-1",active:e.activeSubtitle===-1},...e.subtitleTracks.map((t,s)=>({label:t.label,value:String(s),active:e.activeSubtitle===s}))],onSelect:t=>e.setSubtitle(Number(t))}}scheduleReflow(){this.reflowScheduled||(this.reflowScheduled=!0,requestAnimationFrame(()=>{this.reflowScheduled=!1,this.reflow()}))}reflow(){const e=window.innerWidth<=767;this.center.style.display=e?"flex":"none",this.playBtn&&(this.playBtn.style.display=e?"none":""),this.overflowed.clear();for(const i of this.collapsibles){if(e&&B.CENTER_KEYS.has(i.key)){i.el.style.display="none";continue}const n=i.available();i.el.style.display=n?"":"none",i.el.classList.remove("imp-collapsed")}const t=this.collapsibles.filter(i=>i.available()&&!(e&&B.CENTER_KEYS.has(i.key))).sort((i,n)=>i.priority-n.priority);let s=t.length;for(;s-- >0&&this.overflowsRow();){const i=t.find(n=>!this.overflowed.has(n.key));if(!i)break;i.el.style.display="none",i.el.classList.add("imp-collapsed"),this.overflowed.add(i.key)}if(this.moreWrap){const i=this.actionItems.length>0||this.overflowed.size>0;this.moreWrap.style.display=i?"":"none"}}overflowsRow(){const e=this.row.getBoundingClientRect().right;return this.rightGroup.getBoundingClientRect().right>e+1}bind(){const e=this.player;this.disposers.push(e.on("timeupdate",({currentTime:t,duration:s})=>{this.progress.update(t,s,e.bufferedEnd),this.timeLabel&&(e.live?(this.timeLabel.hidden=!0,this.liveBadge.hidden=!1):(this.timeLabel.hidden=!1,this.liveBadge.hidden=!0,this.timeLabel.textContent=`${k(t)} / ${k(s)}`))}),e.on("play",()=>this.syncPlayState()),e.on("pause",()=>this.syncPlayState()),e.on("ended",()=>this.syncPlayState()),e.on("volumechange",()=>this.syncVolume()),e.on("chapterchange",({chapter:t})=>{this.chapterLabel.textContent=t?.title??""}),e.on("fullscreenchange",({active:t})=>{this.fullscreenBtn&&E(this.fullscreenBtn,t?e.icons.fullscreenExit:e.icons.fullscreen,t?e.labels.exitFullscreen:e.labels.fullscreen),this.scheduleReflow()}),e.on("playlistitemchange",()=>{this.syncPlaylistButtons(),this.scheduleReflow()}),e.on("sourcechange",()=>{this.syncPlaylistButtons(),this.scheduleReflow()})),this.syncPlaylistButtons(),this.reflow()}syncPlayState(){const e=this.player,[t,s]=e.ended?[e.icons.replay,e.labels.replay]:e.paused?[e.icons.play,e.labels.play]:[e.icons.pause,e.labels.pause];this.playBtn&&E(this.playBtn,t,s),this.centerPlayBtn&&E(this.centerPlayBtn,t,s)}syncVolume(){if(!this.muteBtn)return;const e=this.player,t=e.muted?0:e.volume,s=t===0?e.icons.volumeMute:t<.5?e.icons.volumeLow:e.icons.volumeHigh;E(this.muteBtn,s,e.muted?e.labels.unmute:e.labels.mute),this.volumeSlider.value=String(t),this.volumeSlider.style.setProperty("--imp-volume-fill",`${t*100}%`)}syncFeatureButtons(){this.scheduleReflow()}syncPlaylistButtons(){const e=this.player;this.prevBtn&&(this.prevBtn.disabled=!e.hasPrevious),this.nextBtn&&(this.nextBtn.disabled=!e.hasNext),this.centerPrevBtn&&(this.centerPrevBtn.disabled=!e.hasPrevious),this.centerNextBtn&&(this.centerNextBtn.disabled=!e.hasNext)}closeMenus(e){for(const t of[this.settingsMenu,this.subtitlesMenu,this.qualityMenu,this.moreMenu])t&&t!==e&&t.close()}toggleSettingsMenu(){this.settingsMenu&&(this.closeMenus(this.settingsMenu),this.settingsMenu.toggle([this.speedSection()]))}toggleQualityMenu(){!this.qualityMenu||this.player.qualityLevels.length===0||(this.closeMenus(this.qualityMenu),this.qualityMenu.toggle([this.qualitySection()]))}toggleSubtitlesMenu(){!this.subtitlesMenu||this.player.subtitleTracks.length===0||(this.closeMenus(this.subtitlesMenu),this.subtitlesMenu.toggle([this.subtitlesSection()]))}destroy(){for(const e of this.disposers)e();this.disposers=[],this.resizeObserver?.disconnect(),this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize),this.settingsMenu?.destroy(),this.subtitlesMenu?.destroy(),this.qualityMenu?.destroy(),this.moreMenu?.destroy(),this.root.remove()}};B.CENTER_KEYS=new Set(["seekBack","seekFwd","prev","next"]);let F=B;class ve{constructor(e){this.root=l("div","imp-poster"),this.image=l("img","imp-poster__image",{alt:"",decoding:"async"}),this.image.hidden=!0;const t=m("imp-poster__play",e.labels.play,e.icons.bigPlay);t.addEventListener("click",()=>void e.play()),this.root.append(this.image,t),this.root.addEventListener("click",s=>{(s.target===this.root||s.target===this.image)&&e.play()})}setSource(e){e?.poster?(this.image.src=e.poster,this.image.fetchPriority="high",this.image.hidden=!1):(this.image.removeAttribute("src"),this.image.hidden=!0)}show(){this.root.hidden=!1}hide(){this.root.hidden=!0}}class fe{constructor(e){this.labels=e,this.channelUrl=null,this.custom=null,this.root=l("div","imp-pause-screen"),this.root.hidden=!0,this.defaultContent=l("div","imp-pause-screen__default"),this.channel=l("button","imp-channel",{type:"button"}),this.channel.hidden=!0,this.channelAvatar=l("div","imp-channel__avatar"),this.channelName=l("div","imp-channel__name"),this.channel.append(this.channelName,this.channelAvatar),this.channel.addEventListener("click",()=>{this.channelUrl&&window.open(this.channelUrl,"_blank","noopener")});const t=l("div","imp-pause-screen__heading");this.title=l("div","imp-pause-screen__title"),this.description=l("div","imp-pause-screen__description"),this.sponsor=l("a","imp-sponsor",{target:"_blank",rel:"nofollow noopener"}),this.sponsor.hidden=!0,this.sponsorLabel=l("span","imp-sponsor__label"),this.sponsorText=l("span","imp-sponsor__text"),this.sponsor.append(this.sponsorLabel,this.sponsorText),this.sponsor.addEventListener("click",s=>s.stopPropagation()),t.append(this.title,this.description,this.sponsor),this.defaultContent.append(t,this.channel),this.root.append(this.defaultContent)}setCustomContent(e){this.custom?.remove(),this.custom=e,e&&(e.classList.add("imp-pause-screen__custom"),this.root.append(e)),this.defaultContent.hidden=e!==null,this.root.classList.toggle("imp-pause-screen--custom",e!==null)}get hasCustom(){return this.custom!==null}setSource(e){this.title.textContent=e?.title??"",this.description.textContent=e?.description??"";const t=e?.sponsor;this.sponsor.hidden=!t,t&&(this.sponsor.href=t.url,this.sponsorText.textContent=t.text,this.sponsorLabel.textContent=t.label??this.labels.sponsored);const s=e?.channel;this.channel.hidden=!s,this.channelUrl=s?.url??null,this.channel.classList.toggle("imp-channel--link",!!s?.url),s&&(this.channelName.textContent=s.name,this.channelAvatar.className=`imp-channel__avatar imp-channel__avatar--${s.avatarShape??"circle"}`,s.avatar?(this.channelAvatar.textContent="",this.channelAvatar.style.backgroundImage=`url("${s.avatar}")`):(this.channelAvatar.style.backgroundImage="",this.channelAvatar.textContent=(s.name.trim()[0]??"?").toUpperCase()))}show(){this.root.hidden=!1}hide(){this.root.hidden=!0}}class ge{constructor(e){this.player=e,this.clickBehavior="player",this.root=l("div","imp-related"),this.root.hidden=!0,this.heading=l("div","imp-related__title"),this.grid=l("div","imp-related__grid");const t=m("imp-related__close","Close",e.icons.close);t.addEventListener("click",()=>this.hide()),this.root.append(t,this.heading,this.grid)}setOptions(e){if(this.grid.textContent="",!!e){this.clickBehavior=e.clickBehavior??"player",this.heading.textContent=e.title??this.player.labels.related;for(const t of e.items)this.grid.append(this.buildCard(t))}}buildCard(e){const t=l("button","imp-related__card",{type:"button"}),s=l("div","imp-related__thumb");if(e.poster&&(s.style.backgroundImage=`url("${e.poster}")`),e.duration){const n=l("span","imp-related__duration");n.textContent=e.duration,s.append(n)}const i=l("div","imp-related__card-title");return i.textContent=e.title,t.append(s,i),t.addEventListener("click",()=>{this.player.emit("relatedclick",{item:e}),this.hide(),this.activate(e)}),t}activate(e){const t=e.url??e.source?.src;switch(this.clickBehavior){case"newWindow":t&&window.open(t,"_blank","noopener");break;case"currentTab":t&&(window.location.href=t);break;case"player":default:e.source?(this.player.load(e.source),this.player.play()):e.url&&window.open(e.url,"_blank","noopener")}}get visible(){return!this.root.hidden}show(){this.grid.childElementCount!==0&&(this.root.hidden=!1,this.player.emit("relatedshow",void 0))}hide(){this.root.hidden=!0}}class ye{constructor(e,t="sidebar",s){this.player=e,this.root=l("div",`imp-playlist imp-playlist--${t}`),this.root.hidden=!0;const i=l("div","imp-playlist__header"),n=l("div","imp-playlist__heading");if(s){const c=l("div","imp-playlist__kicker");c.textContent=e.labels.playlist;const h=l("div","imp-playlist__name");h.textContent=s,n.append(c,h)}else n.textContent=e.labels.playlist;const o=l("div","imp-playlist__tools");this.shuffleBtn=m("imp-playlist__shuffle",e.labels.shuffle,e.icons.shuffle),this.shuffleBtn.addEventListener("click",()=>{e.setShuffle(!e.shuffle),this.syncModes()}),this.repeatBtn=m("imp-playlist__repeat",e.labels.repeat,e.icons.repeat),this.repeatBtn.addEventListener("click",()=>{e.setRepeat(!e.repeat),this.syncModes()});const a=m("imp-playlist__close","Close",e.icons.close);a.addEventListener("click",()=>this.hide()),o.append(this.shuffleBtn,this.repeatBtn,a),i.append(n,o),this.list=l("div","imp-playlist__list"),this.root.append(i,this.list),this.rebuild(),this.syncModes()}syncModes(){this.shuffleBtn.classList.toggle("imp-btn--active",this.player.shuffle),this.repeatBtn.classList.toggle("imp-btn--active",this.player.repeat)}rebuild(){this.list.textContent="",this.player.playlist.forEach((e,t)=>{const s=l("button","imp-playlist__item",{type:"button"});t===this.player.index&&s.classList.add("imp-playlist__item--active");const i=l("div","imp-playlist__thumb");e.poster&&(i.style.backgroundImage=`url("${e.poster}")`);const n=l("div","imp-playlist__meta"),o=l("div","imp-playlist__title");if(o.textContent=e.title??`#${t+1}`,n.append(o),e.duration){const a=l("div","imp-playlist__duration");a.textContent=k(e.duration),n.append(a)}s.append(i,n),s.addEventListener("click",()=>{this.player.playItem(t)}),this.list.append(s)})}get visible(){return!this.root.hidden}show(){this.rebuild(),this.root.hidden=!1}hide(){this.root.hidden=!0}toggle(){this.visible?this.hide():this.show()}}class be{constructor(e,t="bottom"){this.player=e,this.items=[],this.root=l("div",`imp-playlist imp-scenes imp-playlist--${t}`),this.root.hidden=!0;const s=l("div","imp-playlist__header"),i=l("span");i.textContent=e.labels.scenes;const n=m("imp-playlist__close","Close",e.icons.close);n.addEventListener("click",()=>this.hide()),s.append(i,n),this.list=l("div","imp-playlist__list"),this.root.append(s,this.list),e.on("chapterchange",()=>this.syncActive())}rebuild(){this.list.textContent="",this.items=[];const e=this.player.thumbnails;for(const t of this.player.chapterList){const s=l("button","imp-playlist__item",{type:"button"}),i=l("div","imp-playlist__thumb"),n=e?.cueAt(t.start+.01)??null;if(n?.xywh){const h=l("div","imp-scenes__sprite");h.style.width=`${n.xywh.w}px`,h.style.height=`${n.xywh.h}px`,h.style.backgroundImage=`url("${n.src}")`,h.style.backgroundPosition=`-${n.xywh.x}px -${n.xywh.y}px`,h.style.setProperty("--imp-sprite-w",String(n.xywh.w)),i.append(h)}else n&&(i.style.backgroundImage=`url("${n.src}")`);const o=l("div","imp-playlist__meta"),a=l("div","imp-playlist__title");a.textContent=t.title||k(t.start);const c=l("div","imp-playlist__duration");c.textContent=k(t.start),o.append(a,c),s.append(i,o),s.addEventListener("click",()=>{this.player.seek(t.start),this.player.play()}),this.list.append(s),this.items.push(s)}this.syncActive()}syncActive(){const e=this.player.chapter,t=this.player.chapterList;this.items.forEach((s,i)=>{s.classList.toggle("imp-playlist__item--active",e!==null&&t[i]===e)})}get visible(){return!this.root.hidden}show(){this.rebuild(),this.root.hidden=!1}hide(){this.root.hidden=!0}toggle(){this.visible?this.hide():this.show()}}function H(r){return r?typeof r=="string"?[{src:r,label:"Subtitles"}]:Array.isArray(r)?r:[r]:[]}const ke={play:!0,progress:!0,time:!0,volume:!0,fullscreen:!0,pip:!0,settings:!0,quality:!1,scenes:!0,heatmap:!0,subtitles:!0,seekButtons:!0,playlist:!0,hideDelay:2500};class we{constructor(e,t={}){this.scrubbing=!1,this.emitter=new X,this.abort=new AbortController,this.sources=[],this.currentIndex=-1,this.sourceController=null,this.loadToken=0,this.chapters=[],this.currentChapter=null,this.progressiveQuality=-1,this.thumbTrack=null,this.shuffleMode=!1,this.decodeRecoveries=0,this.adManager=null,this.playedOnce=!1,this.idleTimer=null,this.destroyed=!1;const s=typeof e=="string"?document.querySelector(e):e;if(!s)throw new Error(`[itube-player] mount target not found: ${String(e)}`);this.mount=s,this.options=t,this.labels={..._,...ee(t.language),...t.labels},this.icons={...Y,...t.icons},this.controlsOptions={...ke,...t.controls},this.actionsOptions=t.actions??{},this.playbackRates=t.playbackRates??[.5,.75,1,1.25,1.5,2],this.seekStep=t.seekStep??10,this.playlistOptions={title:"",autoAdvance:!0,loop:!1,shuffle:!1,startIndex:0,layout:"sidebar",...t.playlist},this.shuffleMode=this.playlistOptions.shuffle,this.sources=t.source?Array.isArray(t.source)?[...t.source]:[t.source]:[],this.container=l("div","imp-player",{tabindex:"0"}),t.className&&this.container.classList.add(t.className);const i=t.styling;if(i?.themeColor&&this.container.style.setProperty("--imp-accent",i.themeColor),i?.likeColor&&this.container.style.setProperty("--imp-like",i.likeColor),i?.dislikeColor&&this.container.style.setProperty("--imp-dislike",i.dislikeColor),i?.borderRadius!==void 0){const h=typeof i.borderRadius=="number"?`${i.borderRadius}px`:i.borderRadius;this.container.style.setProperty("--imp-radius",h)}i?.playButtonStyle==="inverted"&&this.container.classList.add("imp-player--play-inverted"),this.video=l("video","imp-video"),t.playsInline!==!1&&this.video.setAttribute("playsinline",""),t.crossOrigin!==void 0&&(this.video.crossOrigin=t.crossOrigin),this.video.preload="metadata",t.loop&&(this.video.loop=!0),t.muted&&(this.video.muted=!0),this.video.volume=y(t.volume??1,0,1);const n=l("div","imp-layer");this.spinner=l("div","imp-spinner"),this.spinner.hidden=!0,this.errorBox=l("div","imp-error"),this.errorBox.hidden=!0,this.pauseScreen=new fe(this.labels),this.poster=new ve(this),this.related=new ge(this),this.related.setOptions(t.related),this.controls=new F(this),this.playlistPanel=new ye(this,this.playlistOptions.layout,this.playlistOptions.title||void 0),this.scenesPanel=new be(this,t.scenes?.layout??"bottom");const o=l("div","imp-layer__middle");o.append(this.spinner,this.errorBox,this.controls.center);const a=l("div","imp-layer__bottom");a.append(this.controls.root),n.append(this.pauseScreen.root,this.related.root,o,a),this.container.append(this.video,n,this.poster.root,this.playlistPanel.root,this.scenesPanel.root),this.mount.append(this.container),t.pauseScreen instanceof HTMLElement?this.pauseScreen.setCustomContent(t.pauseScreen):typeof t.pauseScreen=="function"&&this.pauseScreen.setCustomContent(t.pauseScreen(this));const c=t.adConfig??t.ads;c&&c.adList.length>0&&(this.adManager=new le({container:this.container,contentVideo:this.video,emitter:this.emitter,labels:this.labels,closeIcon:this.icons.close},c)),this.emitter.on("error",({message:h})=>{this.errorBox.textContent=h,this.errorBox.hidden=!1,this.spinner.hidden=!0,this.poster.hide()}),this.bindVideoEvents(),this.bindIdleHide(),t.keyboard!==!1&&this.bindKeyboard(),this.video.addEventListener("click",()=>{this.playedOnce&&!this.adPlaying&&this.togglePlay()},{signal:this.abort.signal}),this.pauseScreen.root.addEventListener("click",h=>{this.pauseScreen.hasCustom||h.target===this.pauseScreen.root&&this.togglePlay()},{signal:this.abort.signal}),this.sources.length>0&&this.loadItem(y(this.playlistOptions.startIndex,0,this.sources.length-1),!!t.autoplay),this.emitter.emit("ready",{player:this})}on(e,t){return this.emitter.on(e,t)}once(e,t){return this.emitter.once(e,t)}off(e,t){this.emitter.off(e,t)}emit(e,t){this.emitter.emit(e,t)}get paused(){return this.video.paused}get ended(){return this.video.ended}get currentTime(){return this.video.currentTime}get duration(){return this.video.duration||0}get live(){return this.video.duration===1/0}get bufferedEnd(){const e=this.video.buffered;return e.length>0?e.end(e.length-1):0}get adPlaying(){return this.adManager?.adPlaying??!1}async play(){this.destroyed||this.adPlaying||this.adManager&&(await this.adManager.playPreRoll(),this.destroyed||!this.video.paused)||await this.video.play()}pause(){this.adPlaying||this.video.pause()}togglePlay(){this.video.paused||this.video.ended?this.play():this.pause()}seek(e){Number.isFinite(this.video.duration)&&(this.video.currentTime=y(e,0,this.video.duration))}skip(e){this.seek(this.video.currentTime+e)}get volume(){return this.video.volume}get muted(){return this.video.muted}setVolume(e){this.video.volume=y(e,0,1),e>0&&(this.video.muted=!1)}setMuted(e){this.video.muted=e}toggleMute(){this.video.muted=!this.video.muted}get playbackRate(){return this.video.playbackRate}setPlaybackRate(e){this.video.playbackRate=e,this.emitter.emit("ratechange",{rate:e})}get qualityLevels(){if(this.sourceController?.kind==="hls")return this.sourceController.levels;const e=this.source?.qualities;return e?e.map((t,s)=>({index:s,label:t.label??String(t.quality??s)})):[]}get qualityAutoAvailable(){return this.sourceController?.kind==="hls"}get currentQuality(){return this.sourceController?.kind==="hls"?this.sourceController.selected:this.progressiveQuality}setQuality(e){if(this.sourceController?.kind==="hls"){this.sourceController.setLevel(e);const n=e===-1?this.labels.qualityAuto:this.sourceController.levels.find(o=>o.index===e)?.label??String(e);this.emitter.emit("qualitychange",{label:n});return}const t=this.source?.qualities;if(!t||!t[e]||e===this.progressiveQuality)return;const s=this.video.currentTime,i=!this.video.paused&&!this.video.ended;this.progressiveQuality=e,this.video.src=t[e].src,this.video.currentTime=s,i&&this.video.play().catch(()=>{}),this.emitter.emit("qualitychange",{label:t[e].label??String(t[e].quality??e)})}get subtitleTracks(){return H(this.source?.subtitles)}get activeSubtitle(){const e=this.video.textTracks;for(let t=0;t<e.length;t++)if(e[t].mode==="showing")return t;return-1}setSubtitle(e){const t=this.video.textTracks;for(let s=0;s<t.length;s++)t[s].mode=s===e?"showing":"disabled";this.emitter.emit("subtitlechange",{track:this.subtitleTracks[e]??null})}get playlist(){return this.sources}get index(){return this.currentIndex}get source(){return this.sources[this.currentIndex]??null}get hasPlaylist(){return this.sources.length>1}get hasNext(){return this.shuffleMode||this.playlistOptions.loop?this.sources.length>1:this.currentIndex<this.sources.length-1}get hasPrevious(){return this.playlistOptions.loop?this.sources.length>1:this.currentIndex>0}get shuffle(){return this.shuffleMode}setShuffle(e){this.shuffleMode=e}get repeat(){return this.playlistOptions.loop}setRepeat(e){this.playlistOptions.loop=e}next(){if(this.hasNext){if(this.shuffleMode&&this.sources.length>1){let e=this.currentIndex;for(;e===this.currentIndex;)e=Math.floor(Math.random()*this.sources.length);this.playItem(e);return}this.playItem((this.currentIndex+1)%this.sources.length)}}previous(){this.hasPrevious&&this.playItem((this.currentIndex-1+this.sources.length)%this.sources.length)}playItem(e){e<0||e>=this.sources.length||this.loadItem(e,!0).then(()=>{this.emitter.emit("playlistitemchange",{source:this.sources[e],index:e})})}togglePlaylistPanel(){this.scenesPanel.hide(),this.playlistPanel.toggle()}toggleScenesPanel(){this.playlistPanel.hide(),this.scenesPanel.toggle()}get thumbnails(){return this.thumbTrack}load(e,t=0){this.sources=Array.isArray(e)?[...e]:[e],this.playlistPanel.rebuild(),this.loadItem(y(t,0,this.sources.length-1),!1)}get isFullscreen(){return document.fullscreenElement===this.container}async toggleFullscreen(){this.isFullscreen?await document.exitFullscreen():this.container.requestFullscreen?await this.container.requestFullscreen():this.video.webkitEnterFullscreen?.()}async togglePip(){document.pictureInPictureElement===this.video?await document.exitPictureInPicture():await this.video.requestPictureInPicture()}get chapterList(){return this.chapters}get chapter(){return this.currentChapter}async share(){const e={title:this.source?.title??document.title,url:window.location.href};if(typeof navigator.share=="function"){try{await navigator.share(e)}catch{}return}this.emitter.emit("action",{id:"share"})}setLikeState(e){this.controls.setLikeState(e)}setLikeCounts(e,t){this.controls.setLikeCounts(e,t)}setPauseScreenContent(e){this.pauseScreen.setCustomContent(e)}destroy(){this.destroyed||(this.destroyed=!0,this.loadToken++,this.adManager?.destroy(),this.controls.destroy(),this.sourceController?.destroy(),this.abort.abort(),this.idleTimer&&clearTimeout(this.idleTimer),this.container.remove(),this.emitter.emit("destroy",void 0),this.emitter.removeAll())}async loadItem(e,t){const s=++this.loadToken,i=this.sources[e];if(!i)return;this.currentIndex=e,this.sourceController?.destroy(),this.sourceController=null,this.chapters=[],this.currentChapter=null,this.progressiveQuality=-1,this.playedOnce=!1;for(const c of[...this.video.querySelectorAll("track")])c.remove();this.adManager?.resetForNewSource(),this.related.hide(),this.pauseScreen.hide(),this.scenesPanel.hide(),this.thumbTrack=null,this.errorBox.hidden=!0,this.decodeRecoveries=0,this.video.poster=i.poster??"",this.poster.setSource(i),this.pauseScreen.setSource(i),this.controls.progress.setChapters([]),this.controls.progress.setThumbnails(null),this.controls.progress.setHeatmap([]),t?this.poster.hide():this.poster.show(),this.playlistPanel.rebuild();for(const c of H(i.subtitles)){const h=l("track","",{kind:"subtitles",src:c.src,label:c.label,...c.srclang?{srclang:c.srclang}:{}});c.default&&h.setAttribute("default",""),this.video.append(h)}let n=i.src,o=i.type;if(i.qualities&&i.qualities.length>0){const c=Math.max(0,i.qualities.findIndex(h=>h.src===i.src));this.progressiveQuality=c,n=i.qualities[c].src,o=i.qualities[c].type??o}this.video.preload=this.adManager?.hasPendingPreRoll?"auto":"metadata";const a=await ue(this.video,n,o,{onLevels:()=>{s===this.loadToken&&this.controls.syncFeatureButtons()},onLevelSwitch:c=>this.emitter.emit("qualitychange",{label:c}),onError:(c,h)=>this.emitter.emit("error",{message:c,cause:h})});if(s!==this.loadToken){a.destroy();return}if(this.sourceController=a,this.emitter.emit("sourcechange",{source:i,index:e}),i.thumbnails&&V.load(i.thumbnails).then(c=>{s===this.loadToken&&(this.thumbTrack=c,this.controls.progress.setThumbnails(c),this.scenesPanel.visible&&this.scenesPanel.rebuild())}).catch(c=>this.emitter.emit("error",{message:"Failed to load thumbnails track",cause:c})),i.chapters){const c=h=>{const p=()=>{s===this.loadToken&&(this.chapters=ae(h,this.video.duration),this.controls.progress.setChapters(this.chapters),this.controls.syncFeatureButtons(),this.scenesPanel.visible&&this.scenesPanel.rebuild())};Number.isFinite(this.video.duration)&&this.video.duration>0?p():this.video.addEventListener("loadedmetadata",p,{once:!0,signal:this.abort.signal})};typeof i.chapters=="string"?he(i.chapters).then(h=>c(h)).catch(h=>this.emitter.emit("error",{message:"Failed to load chapters track",cause:h})):c(i.chapters)}if(i.heatmap&&i.heatmap.length>0&&this.controlsOptions.heatmap){const c=i.heatmap,h=()=>{s===this.loadToken&&this.controls.progress.setHeatmap(te(c,this.video.duration))};Number.isFinite(this.video.duration)&&this.video.duration>0?h():this.video.addEventListener("loadedmetadata",h,{once:!0,signal:this.abort.signal})}t&&this.play().catch(()=>{s===this.loadToken&&this.poster.show()})}bindVideoEvents(){const{signal:e}=this.abort,t=this.video;t.addEventListener("play",()=>{this.playedOnce=!0,this.poster.hide(),this.pauseScreen.hide(),this.related.visible||this.related.hide(),this.related.hide(),this.emitter.emit("play",void 0),this.scheduleIdle()},{signal:e}),t.addEventListener("pause",()=>{this.emitter.emit("pause",void 0),this.showControlsNow(),!(this.video.ended||this.scrubbing||this.adPlaying||!this.playedOnce)&&(this.options.pauseScreen!==!1&&this.pauseScreen.show(),this.options.related?.showOn?.includes("pause")&&this.related.show())},{signal:e}),t.addEventListener("ended",()=>{this.handleEnded()},{signal:e}),t.addEventListener("timeupdate",()=>{this.emitter.emit("timeupdate",{currentTime:t.currentTime,duration:t.duration||0}),this.adManager?.checkMidRolls(t.currentTime);const s=Z(this.chapters,t.currentTime);s!==this.currentChapter&&(this.currentChapter=s,this.emitter.emit("chapterchange",{chapter:s}))},{signal:e}),t.addEventListener("progress",()=>{this.emitter.emit("progress",{buffered:this.bufferedEnd})},{signal:e}),t.addEventListener("volumechange",()=>{this.emitter.emit("volumechange",{volume:t.volume,muted:t.muted})},{signal:e}),t.addEventListener("seeking",()=>this.emitter.emit("seeking",{currentTime:t.currentTime}),{signal:e}),t.addEventListener("seeked",()=>this.emitter.emit("seeked",{currentTime:t.currentTime}),{signal:e}),t.addEventListener("waiting",()=>{this.spinner.hidden=!1},{signal:e});for(const s of["playing","canplay","seeked"])t.addEventListener(s,()=>{this.spinner.hidden=!0,this.errorBox.hidden=!0,this.decodeRecoveries=0},{signal:e});t.addEventListener("error",()=>{const s=t.error;if(!s||this.sourceController?.kind==="hls"||t.getAttribute("src")===null&&!t.currentSrc)return;if((s.code===MediaError.MEDIA_ERR_DECODE||/DEMUXER|PARSE|DECODE/i.test(s.message||""))&&this.decodeRecoveries<2&&Number.isFinite(t.duration)){this.decodeRecoveries++;const n=t.currentTime,o=!t.paused;t.load();const a=()=>{try{t.currentTime=n}catch{}o&&t.play().catch(()=>{})};t.readyState>=1?a():t.addEventListener("loadedmetadata",a,{once:!0,signal:this.abort.signal});return}this.emitter.emit("error",{message:s.message||`Media error (code ${s.code})`,cause:s})},{signal:e}),t.addEventListener("enterpictureinpicture",()=>this.emitter.emit("pipchange",{active:!0}),{signal:e}),t.addEventListener("leavepictureinpicture",()=>this.emitter.emit("pipchange",{active:!1}),{signal:e}),document.addEventListener("fullscreenchange",()=>{this.emitter.emit("fullscreenchange",{active:this.isFullscreen}),this.container.classList.toggle("imp-player--fullscreen",this.isFullscreen)},{signal:e})}async handleEnded(){if(this.emitter.emit("ended",void 0),this.showControlsNow(),!(this.adManager&&(await this.adManager.playPostRoll(),this.destroyed))){if(this.playlistOptions.autoAdvance&&this.hasNext){this.next();return}(this.options.related?.showOn?.includes("ended")??!!this.options.related)&&this.related.show()}}bindIdleHide(){const{signal:e}=this.abort,t=()=>{this.showControlsNow(),this.scheduleIdle()};this.container.addEventListener("pointermove",t,{signal:e}),this.container.addEventListener("pointerdown",t,{signal:e}),this.container.addEventListener("keydown",t,{signal:e}),this.container.addEventListener("pointerleave",()=>{this.video.paused||this.container.classList.add("imp-player--idle")},{signal:e})}showControlsNow(){this.container.classList.remove("imp-player--idle")}scheduleIdle(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{!this.video.paused&&!this.destroyed&&this.container.classList.add("imp-player--idle")},this.controlsOptions.hideDelay)}bindKeyboard(){this.container.addEventListener("keydown",e=>{const t=e.target;if(t.closest("input, select, textarea, [contenteditable]"))return;const i=t.closest("button")!==null;switch(e.key){case" ":case"k":if(e.key===" "&&i)return;e.preventDefault(),this.togglePlay();break;case"ArrowLeft":e.preventDefault(),this.skip(-this.seekStep);break;case"ArrowRight":e.preventDefault(),this.skip(this.seekStep);break;case"ArrowUp":e.preventDefault(),this.setVolume(this.volume+.1);break;case"ArrowDown":e.preventDefault(),this.setVolume(this.volume-.1);break;case"m":this.toggleMute();break;case"f":this.toggleFullscreen();break;case"Home":this.seek(0);break;case"End":this.seek(this.duration);break;default:/^[0-9]$/.test(e.key)&&Number.isFinite(this.video.duration)&&this.seek(Number(e.key)/10*this.video.duration)}},{signal:this.abort.signal})}}return J({en:_,ru:{play:"Воспроизвести",pause:"Пауза",replay:"Смотреть снова",mute:"Выключить звук",unmute:"Включить звук",fullscreen:"Во весь экран",exitFullscreen:"Выйти из полноэкранного режима",pip:"Картинка в картинке",settings:"Скорость воспроизведения",subtitles:"Субтитры",subtitlesOff:"Выкл.",speed:"Скорость",quality:"Качество",qualityAuto:"Авто",next:"Следующее",previous:"Предыдущее",playlist:"Плейлист",scenes:"Сцены",shuffle:"Перемешать",repeat:"Повтор",like:"Нравится",dislike:"Не нравится",addTo:"Сохранить в…",share:"Поделиться",report:"Пожаловаться",more:"Ещё",seekForward:"Перемотать вперёд",seekBack:"Перемотать назад",live:"В ЭФИРЕ",related:"Похожие видео",adLabel:"Реклама",skipAd:"Пропустить рекламу",skipAdIn:"Пропуск через",visitAdvertiser:"Перейти к рекламодателю",sponsored:"Спонсор"},de:{play:"Wiedergabe",pause:"Pause",replay:"Erneut abspielen",mute:"Stummschalten",unmute:"Ton einschalten",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",pip:"Bild im Bild",settings:"Wiedergabegeschwindigkeit",subtitles:"Untertitel",subtitlesOff:"Aus",speed:"Geschwindigkeit",quality:"Qualität",qualityAuto:"Automatisch",next:"Weiter",previous:"Zurück",playlist:"Playlist",scenes:"Szenen",shuffle:"Zufallswiedergabe",repeat:"Wiederholen",like:"Mag ich",dislike:"Mag ich nicht",addTo:"Speichern in…",share:"Teilen",report:"Melden",more:"Weitere Aktionen",seekForward:"Vorspulen",seekBack:"Zurückspulen",live:"LIVE",related:"Weitere Videos",adLabel:"Anzeige",skipAd:"Werbung überspringen",skipAdIn:"Überspringen in",visitAdvertiser:"Zum Werbetreibenden",sponsored:"Gesponsert"},es:{play:"Reproducir",pause:"Pausa",replay:"Volver a reproducir",mute:"Silenciar",unmute:"Activar sonido",fullscreen:"Pantalla completa",exitFullscreen:"Salir de pantalla completa",pip:"Imagen en imagen",settings:"Velocidad de reproducción",subtitles:"Subtítulos",subtitlesOff:"Desactivados",speed:"Velocidad",quality:"Calidad",qualityAuto:"Automática",next:"Siguiente",previous:"Anterior",playlist:"Lista de reproducción",scenes:"Escenas",shuffle:"Aleatorio",repeat:"Repetir",like:"Me gusta",dislike:"No me gusta",addTo:"Guardar en…",share:"Compartir",report:"Denunciar",more:"Más acciones",seekForward:"Avanzar",seekBack:"Retroceder",live:"EN VIVO",related:"Más vídeos",adLabel:"Anuncio",skipAd:"Omitir anuncio",skipAdIn:"Omitir en",visitAdvertiser:"Visitar al anunciante",sponsored:"Patrocinado"},it:{play:"Riproduci",pause:"Pausa",replay:"Riproduci di nuovo",mute:"Disattiva audio",unmute:"Attiva audio",fullscreen:"Schermo intero",exitFullscreen:"Esci da schermo intero",pip:"Picture-in-picture",settings:"Velocità di riproduzione",subtitles:"Sottotitoli",subtitlesOff:"Disattivati",speed:"Velocità",quality:"Qualità",qualityAuto:"Automatica",next:"Successivo",previous:"Precedente",playlist:"Playlist",scenes:"Scene",shuffle:"Casuale",repeat:"Ripeti",like:"Mi piace",dislike:"Non mi piace",addTo:"Salva in…",share:"Condividi",report:"Segnala",more:"Altre azioni",seekForward:"Avanti veloce",seekBack:"Indietro",live:"LIVE",related:"Altri video",adLabel:"Annuncio",skipAd:"Salta annuncio",skipAdIn:"Salta tra",visitAdvertiser:"Visita l'inserzionista",sponsored:"Sponsorizzato"},ja:{play:"再生",pause:"一時停止",replay:"もう一度見る",mute:"ミュート",unmute:"ミュート解除",fullscreen:"全画面",exitFullscreen:"全画面を終了",pip:"ピクチャーインピクチャー",settings:"再生速度",subtitles:"字幕",subtitlesOff:"オフ",speed:"速度",quality:"画質",qualityAuto:"自動",next:"次へ",previous:"前へ",playlist:"プレイリスト",scenes:"シーン",shuffle:"シャッフル",repeat:"リピート",like:"高く評価",dislike:"低く評価",addTo:"保存…",share:"共有",report:"報告",more:"その他の操作",seekForward:"早送り",seekBack:"巻き戻し",live:"ライブ",related:"関連動画",adLabel:"広告",skipAd:"広告をスキップ",skipAdIn:"スキップまで",visitAdvertiser:"広告主のサイトへ",sponsored:"スポンサー"},ko:{play:"재생",pause:"일시정지",replay:"다시 보기",mute:"음소거",unmute:"음소거 해제",fullscreen:"전체화면",exitFullscreen:"전체화면 종료",pip:"PIP 모드",settings:"재생 속도",subtitles:"자막",subtitlesOff:"사용 안 함",speed:"속도",quality:"화질",qualityAuto:"자동",next:"다음",previous:"이전",playlist:"재생목록",scenes:"장면",shuffle:"셔플",repeat:"반복",like:"좋아요",dislike:"싫어요",addTo:"저장…",share:"공유",report:"신고",more:"더보기",seekForward:"앞으로 감기",seekBack:"뒤로 감기",live:"실시간",related:"관련 동영상",adLabel:"광고",skipAd:"광고 건너뛰기",skipAdIn:"건너뛰기까지",visitAdvertiser:"광고주 방문",sponsored:"스폰서"},zh:{play:"播放",pause:"暂停",replay:"重新播放",mute:"静音",unmute:"取消静音",fullscreen:"全屏",exitFullscreen:"退出全屏",pip:"画中画",settings:"播放速度",subtitles:"字幕",subtitlesOff:"关闭",speed:"速度",quality:"画质",qualityAuto:"自动",next:"下一个",previous:"上一个",playlist:"播放列表",scenes:"场景",shuffle:"随机播放",repeat:"循环播放",like:"赞",dislike:"踩",addTo:"保存到…",share:"分享",report:"举报",more:"更多操作",seekForward:"快进",seekBack:"快退",live:"直播",related:"更多视频",adLabel:"广告",skipAd:"跳过广告",skipAdIn:"可跳过",visitAdvertiser:"访问广告主",sponsored:"赞助"},pt:{play:"Reproduzir",pause:"Pausar",replay:"Assistir novamente",mute:"Sem som",unmute:"Ativar som",fullscreen:"Tela cheia",exitFullscreen:"Sair da tela cheia",pip:"Picture-in-picture",settings:"Velocidade de reprodução",subtitles:"Legendas",subtitlesOff:"Desativadas",speed:"Velocidade",quality:"Qualidade",qualityAuto:"Automática",next:"Próximo",previous:"Anterior",playlist:"Playlist",scenes:"Cenas",shuffle:"Aleatório",repeat:"Repetir",like:"Gostei",dislike:"Não gostei",addTo:"Salvar em…",share:"Compartilhar",report:"Denunciar",more:"Mais ações",seekForward:"Avançar",seekBack:"Retroceder",live:"AO VIVO",related:"Mais vídeos",adLabel:"Anúncio",skipAd:"Pular anúncio",skipAdIn:"Pular em",visitAdvertiser:"Visitar anunciante",sponsored:"Patrocinado"},ar:{play:"تشغيل",pause:"إيقاف مؤقت",replay:"إعادة التشغيل",mute:"كتم الصوت",unmute:"إلغاء كتم الصوت",fullscreen:"ملء الشاشة",exitFullscreen:"الخروج من ملء الشاشة",pip:"صورة داخل صورة",settings:"سرعة التشغيل",subtitles:"الترجمة",subtitlesOff:"إيقاف",speed:"السرعة",quality:"الجودة",qualityAuto:"تلقائي",next:"التالي",previous:"السابق",playlist:"قائمة التشغيل",scenes:"المشاهد",shuffle:"تشغيل عشوائي",repeat:"تكرار",like:"أعجبني",dislike:"لم يعجبني",addTo:"حفظ في…",share:"مشاركة",report:"إبلاغ",more:"المزيد من الإجراءات",seekForward:"تقديم",seekBack:"إرجاع",live:"مباشر",related:"المزيد من الفيديوهات",adLabel:"إعلان",skipAd:"تخطي الإعلان",skipAdIn:"التخطي بعد",visitAdvertiser:"زيارة المعلن",sponsored:"برعاية"},hi:{play:"चलाएं",pause:"रोकें",replay:"फिर से चलाएं",mute:"म्यूट करें",unmute:"अनम्यूट करें",fullscreen:"फ़ुल स्क्रीन",exitFullscreen:"फ़ुल स्क्रीन से बाहर निकलें",pip:"पिक्चर-इन-पिक्चर",settings:"प्लेबैक गति",subtitles:"सबटाइटल",subtitlesOff:"बंद",speed:"गति",quality:"क्वालिटी",qualityAuto:"ऑटो",next:"अगला",previous:"पिछला",playlist:"प्लेलिस्ट",scenes:"दृश्य",shuffle:"शफ़ल",repeat:"दोहराएं",like:"पसंद",dislike:"नापसंद",addTo:"इसमें सहेजें…",share:"साझा करें",report:"रिपोर्ट करें",more:"अधिक कार्रवाइयां",seekForward:"आगे बढ़ाएं",seekBack:"पीछे करें",live:"लाइव",related:"और वीडियो",adLabel:"विज्ञापन",skipAd:"विज्ञापन छोड़ें",skipAdIn:"छोड़ें",visitAdvertiser:"विज्ञापनदाता देखें",sponsored:"प्रायोजित"}}),we})();
|
|
3
|
+
`).filter(v=>v.trim()!=="");if(i.length===0)continue;let n=i.findIndex(v=>v.includes("-->"));if(n===-1)continue;const[o,a]=i[n].split("-->"),d=T(o),h=T((a??"").split(" ")[1]??a??"")??T(a??"");if(d===null||h===null)continue;const p=i.slice(n+1).join(`
|
|
4
|
+
`).trim();p&&e.push({start:d,end:h,text:p})}return e}function K(r,e){try{return new URL(r,new URL(e,window.location.href)).toString()}catch{return r}}class X{constructor(){this.listeners=new Map}on(e,t){let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(t),()=>this.off(e,t)}once(e,t){const s=this.on(e,i=>{s(),t(i)});return s}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,t){const s=this.listeners.get(e);if(s)for(const i of[...s])try{i(t)}catch(n){console.error("[itube-player] listener error",n)}}removeAll(){this.listeners.clear()}}const u=(r,e="0 0 24 24")=>`<svg viewBox="${e}" fill="currentColor" aria-hidden="true" focusable="false">${r}</svg>`,Y={play:u('<path d="M8 5.14v13.72c0 .8.87 1.3 1.56.88l10.54-6.86a1.05 1.05 0 0 0 0-1.76L9.56 4.26C8.87 3.84 8 4.34 8 5.14Z"/>'),pause:u('<rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/>'),replay:u('<path d="M12 5V2.5L7.5 6 12 9.5V7a5 5 0 1 1-5 5H5a7 7 0 1 0 7-7Z"/>'),bigPlay:u('<path d="M8 5.14v13.72c0 .8.87 1.3 1.56.88l10.54-6.86a1.05 1.05 0 0 0 0-1.76L9.56 4.26C8.87 3.84 8 4.34 8 5.14Z"/>'),volumeHigh:u('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="M14.5 8.6a4.5 4.5 0 0 1 0 6.8v-1.9a2.5 2.5 0 0 0 0-3v-1.9Z"/><path d="M14.5 5.2a8 8 0 0 1 0 13.6v-2a6 6 0 0 0 0-9.6v-2Z"/>'),volumeLow:u('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="M14.5 8.6a4.5 4.5 0 0 1 0 6.8v-1.9a2.5 2.5 0 0 0 0-3v-1.9Z"/>'),volumeMute:u('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="m15.3 9.3 1.4 1.4 1.4-1.4 1.4 1.4-1.4 1.4 1.4 1.4-1.4 1.4-1.4-1.4-1.4 1.4-1.4-1.4 1.4-1.4-1.4-1.4 1.4-1.4Z"/>'),fullscreen:u('<path d="M5 5h5v2H7v3H5V5Zm9 0h5v5h-2V7h-3V5ZM5 14h2v3h3v2H5v-5Zm12 0h2v5h-5v-2h3v-3Z"/>'),fullscreenExit:u('<path d="M10 10H5V8h3V5h2v5Zm4 0V5h2v3h3v2h-5Zm-4 4v5H8v-3H5v-2h5Zm4 0h5v2h-3v3h-2v-5Z"/>'),pip:u('<path d="M3 5h18v14H3V5Zm2 2v10h14V7H5Z"/><rect x="12" y="11" width="6" height="4"/>'),settings:u('<path d="M12 8.5A3.5 3.5 0 1 0 12 15.5 3.5 3.5 0 0 0 12 8.5Zm0 2a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/><path d="M10.3 2.8 9.9 5.1a7 7 0 0 0-1.5.86l-2.2-.8-1.7 3 1.8 1.5a7 7 0 0 0 0 1.7l-1.8 1.5 1.7 3 2.2-.8c.46.36.97.65 1.5.86l.4 2.3h3.4l.4-2.3a7 7 0 0 0 1.5-.86l2.2.8 1.7-3-1.8-1.5a7 7 0 0 0 0-1.7l1.8-1.5-1.7-3-2.2.8a7 7 0 0 0-1.5-.86l-.4-2.3h-3.4Zm1.7 5.7a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7Z"/>'),speed:u('<path d="M12 4a9 9 0 0 0-9 9 8.96 8.96 0 0 0 1.62 5.16l1.64-1.15A7 7 0 0 1 5 13a7 7 0 1 1 12.74 4.01l1.64 1.15A8.96 8.96 0 0 0 21 13a9 9 0 0 0-9-9Z"/><path d="m15.6 8.3-3.95 3.13a1.5 1.5 0 1 0 1.92 1.92L16.7 9.4a.78.78 0 0 0-1.1-1.1Z"/>'),scenes:u('<path d="M3 5h18v14H3V5Zm2 2v10h3V7H5Zm5 0v10h9V7h-9Zm-5 3h3v1H5v-1Zm0 3h3v1H5v-1Z"/>'),shuffle:u('<path d="M4 6h2.6c1.5 0 2.9.7 3.8 1.9l4.1 5.4a2.75 2.75 0 0 0 2.2 1.1H19l-1.8-1.8 1.4-1.4 4.2 4.2-4.2 4.2-1.4-1.4L19 16.4h-2.3a4.75 4.75 0 0 1-3.8-1.9L8.8 9.1A2.75 2.75 0 0 0 6.6 8H4V6Z"/><path d="M19 7.6h-2.3c-.86 0-1.67.41-2.18 1.1l-.93 1.23-1.25-1.65.58-.77A4.75 4.75 0 0 1 16.7 5.6H19L17.2 3.8l1.4-1.4 4.2 4.2-4.2 4.2-1.4-1.4L19 7.6Z" transform="translate(0 1.2)"/>'),repeat:u('<path d="M7 7h10v2.5L21 6l-4-3.5V5H5v6h2V7Zm10 10H7v-2.5L3 18l4 3.5V19h12v-6h-2v4Z"/>'),subtitles:u('<path d="M3 5h18v14H3V5Zm2 2v10h14V7H5Zm2 3h6v2H7v-2Zm8 0h2v2h-2v-2ZM7 14h2v2H7v-2Zm4 0h6v2h-6v-2Z"/>'),list:u('<path d="M4 6h2v2H4V6Zm4 0h12v2H8V6ZM4 11h2v2H4v-2Zm4 0h12v2H8v-2ZM4 16h2v2H4v-2Zm4 0h12v2H8v-2Z"/>'),next:u('<path d="M6 5.5v13c0 .77.84 1.25 1.5.85l9-6.5a1 1 0 0 0 0-1.7l-9-6.5c-.66-.4-1.5.08-1.5.85Z"/><rect x="17" y="5" width="2.5" height="14" rx="1"/>'),previous:u('<path d="M18 5.5v13c0 .77-.84 1.25-1.5.85l-9-6.5a1 1 0 0 1 0-1.7l9-6.5c.66-.4 1.5.08 1.5.85Z"/><rect x="4.5" y="5" width="2.5" height="14" rx="1"/>'),seekForward:u('<path d="M12 4V1.5L17 5.5 12 9.5V7a5.5 5.5 0 1 0 5.5 5.5H20A8 8 0 1 1 12 4Z"/>'),seekBack:u('<path d="M12 4V1.5L7 5.5 12 9.5V7a5.5 5.5 0 1 1-5.5 5.5H4A8 8 0 1 0 12 4Z"/>'),like:u('<path d="M9 21H5a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h4v11Zm2 0h7.1a2 2 0 0 0 2-1.6l1.3-7a2 2 0 0 0-2-2.4H14V5.5A2.5 2.5 0 0 0 11.5 3l-.5.1V10h-.9L11 21Z"/>'),dislike:u('<path d="M15 3h4a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-4V3Zm-2 0H5.9a2 2 0 0 0-2 1.6l-1.3 7a2 2 0 0 0 2 2.4H10v4.5A2.5 2.5 0 0 0 12.5 21l.5-.1V14h.9L13 3Z"/>'),addTo:u('<path d="M4 6h12v2H4V6Zm0 4h12v2H4v-2Zm0 4h8v2H4v-2Zm14 0v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4Z"/>'),share:u('<path d="M18 8a3 3 0 1 0-2.83-4H15a3 3 0 0 0 .14 1.06L8.4 8.94a3 3 0 1 0 0 6.12l6.74 3.88A3 3 0 1 0 16 16.6l-6.74-3.88a3.03 3.03 0 0 0 0-1.44L16 7.4c.55.38 1.24.6 2 .6Z"/>'),report:u('<path d="M5 3h2v18H5V3Zm4 1h10l-2.5 4L19 12H9V4Z"/>'),more:u('<circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/>'),close:u('<path d="m6.4 5 5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19 5 17.6 10.6 12 5 6.4 6.4 5Z"/>')},_={play:"Play",pause:"Pause",replay:"Replay",mute:"Mute",unmute:"Unmute",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",pip:"Picture-in-picture",settings:"Playback speed",scenes:"Scenes",shuffle:"Shuffle",repeat:"Repeat",subtitles:"Subtitles",subtitlesOff:"Off",speed:"Speed",quality:"Quality",qualityAuto:"Auto",next:"Next",previous:"Previous",playlist:"Playlist",like:"Like",dislike:"Dislike",addTo:"Save to…",share:"Share",report:"Report",more:"More actions",seekForward:"Seek forward",seekBack:"Seek back",live:"LIVE",related:"More videos",adLabel:"Ad",skipAd:"Skip ad",skipAdIn:"Skip in",visitAdvertiser:"Visit advertiser",sponsored:"Sponsored"},O={en:_};function J(r){for(const[e,t]of Object.entries(r))t&&(O[e]=t)}function ee(r){return r&&O[r]||_}function te(r,e,t=100){if(r.length===0||!Number.isFinite(e)||e<=0)return[];const s=new Array(t).fill(0);let i=!1;for(const h of r){if(!Number.isFinite(h.time)||h.time<0||h.time>e)continue;const p=Math.max(0,h.value);if(p===0)continue;const v=Math.min(t-1,Math.floor(h.time/e*t));s[v]+=p,i=!0}if(!i)return[];const n=[.06,.24,.4,.24,.06],o=s.map((h,p)=>n.reduce((v,c,b)=>v+c*(s[p+b-2]??0),0)),a=Math.max(...o);if(a<=0)return[];const d=.08;return o.map(h=>d+(1-d)*(h/a))}function ie(r,e=1e3,t=100){if(r.length===0)return"";const s=e/(r.length-1||1);let i=`M 0 ${t}`;return r.forEach((n,o)=>{i+=` L ${(o*s).toFixed(1)} ${(t-n*t).toFixed(1)}`}),i+=` L ${e} ${t} Z`,i}async function se(r,e){if(r.src)return{roll:r.roll,mediaUrl:r.src,clickThrough:r.clickUrl,impressions:[],tracking:{}};if(!r.vastTag)throw new Error('Ad roll has neither "vastTag" nor "src"');return N(r,r.vastTag,e,0,{impressions:[],tracking:{}})}async function N(r,e,t,s,i){if(s>t.maxWrapperDepth)throw new Error("VAST wrapper depth limit exceeded");const n=new AbortController,o=setTimeout(()=>n.abort(),t.requestTimeout);let a;try{const f=await fetch(e,{signal:n.signal,credentials:"omit"});if(!f.ok)throw new Error(`VAST request failed (${f.status})`);a=await f.text()}finally{clearTimeout(o)}const d=new DOMParser().parseFromString(a,"text/xml");if(d.querySelector("parsererror"))throw new Error("VAST response is not valid XML");const h=d.querySelector("VAST > Ad");if(!h)throw new Error("VAST response contains no ads");ne(h,i);const p=h.querySelector(":scope > Wrapper");if(p){const f=w(p.querySelector("VASTAdTagURI"));if(!f)throw new Error("VAST wrapper without VASTAdTagURI");return N(r,f,t,s+1,i)}const v=h.querySelector(":scope > InLine");if(!v)throw new Error("VAST ad has neither InLine nor Wrapper");const c=v.querySelector("Creatives > Creative > Linear");if(!c)throw new Error("VAST ad has no Linear creative");const b=re(c);if(!b)throw new Error("VAST ad has no playable MediaFile");return{roll:r.roll,mediaUrl:b.url,mediaType:b.type,clickThrough:w(c.querySelector("VideoClicks > ClickThrough"))??r.clickUrl,duration:P(w(c.querySelector(":scope > Duration"))),skipOffset:oe(c.getAttribute("skipoffset"),P(w(c.querySelector(":scope > Duration")))),impressions:i.impressions,tracking:i.tracking,adTitle:w(v.querySelector(":scope > AdTitle"))??void 0}}function ne(r,e){var t,s;for(const i of r.querySelectorAll("Impression")){const n=w(i);n&&e.impressions.push(n)}for(const i of r.querySelectorAll("Linear > TrackingEvents > Tracking")){const n=i.getAttribute("event"),o=w(i);!n||!o||["start","firstQuartile","midpoint","thirdQuartile","complete","skip","pause","resume"].includes(n)&&((t=e.tracking)[n]??(t[n]=[])).push(o)}for(const i of r.querySelectorAll("Linear > VideoClicks > ClickTracking")){const n=w(i);n&&((s=e.tracking).click??(s.click=[])).push(n)}}function re(r){const t=[...r.querySelectorAll("MediaFiles > MediaFile")].map(o=>({url:w(o)??"",type:o.getAttribute("type")??void 0,delivery:o.getAttribute("delivery")??"",bitrate:Number(o.getAttribute("bitrate")??0),apiFramework:o.getAttribute("apiFramework")??""})).filter(o=>o.url&&o.apiFramework.toUpperCase()!=="VPAID").filter(o=>!o.type||/(video\/(mp4|webm|ogg)|application\/(x-mpegurl|vnd\.apple\.mpegurl))/i.test(o.type));if(t.length===0)return null;t.sort((o,a)=>o.bitrate-a.bitrate);const s=t.filter(o=>o.delivery!=="streaming"),i=s.length>0?s:t,n=i[Math.floor(i.length/2)];return{url:n.url,type:n.type}}function P(r){if(!r)return;const e=r.trim().match(/^(?:(\d+):)?(\d{1,2}):(\d{2})(?:\.(\d{1,3}))?$/);if(e)return(e[1]?Number(e[1])*3600:0)+Number(e[2])*60+Number(e[3])+(e[4]?Number(e[4].padEnd(3,"0"))/1e3:0)}function oe(r,e){if(!r)return;const t=r.trim().match(/^(\d+(?:\.\d+)?)%$/);return t?e!==void 0?Number(t[1])/100*e:void 0:P(r)}function A(r){if(r)for(const e of r)try{new Image().src=e}catch{}}function w(r){return r?.textContent?.trim().replace(/^<!\[CDATA\[|\]\]>$/g,"").trim()||null}class le{constructor(e,t){this.host=e,this.playedRolls=new Set,this.sourcesSeen=0,this.activeBreak=null,this.layer=null,this.adVideo=null,this.destroyed=!1,this.opts={skipDelay:5,maxWrapperDepth:3,requestTimeout:8e3,mediaTimeout:1e4,playOn:"every",...t}}ensureAdVideo(){if(!this.adVideo){this.adVideo=l("video","imp-ad__video",{playsinline:""});try{this.adVideo.load()}catch{}}return this.adVideo}get adPlaying(){return this.activeBreak!==null}get hasPendingPreRoll(){return this.pending("preRoll").length>0}resetForNewSource(){if(this.sourcesSeen++,this.opts.playOn==="first"&&this.sourcesSeen>1){for(const e of this.opts.adList)this.playedRolls.add(e);return}this.playedRolls.clear()}async playPreRoll(){await this.playRolls(this.pending("preRoll"))}async playPostRoll(){await this.playRolls(this.pending("postRoll"))}checkMidRolls(e){if(this.adPlaying)return;const t=this.pending("midRoll").filter(s=>s.timer!==void 0&&e>=s.timer);t.length>0&&this.playRolls(t)}pending(e){return this.opts.adList.filter(t=>t.roll===e&&!this.playedRolls.has(t))}async playRolls(e){if(e.length===0||this.destroyed)return;if(this.activeBreak)return this.activeBreak;this.ensureAdVideo();const t=(async()=>{const s=this.host.contentVideo,i=!s.paused&&!s.ended;s.pause();for(const n of e){this.playedRolls.add(n);try{const o=await se(n,this.opts);await this.playAd(o)}catch(o){const a=o instanceof Error?o:new Error(String(o));this.host.emitter.emit("aderror",{roll:n,error:a})}if(this.destroyed)return}(i||e[0].roll==="preRoll")&&s.play().catch(()=>{})})();return this.activeBreak=t.finally(()=>{this.activeBreak=null}),this.activeBreak}playAd(e){return new Promise(t=>{const{labels:s}=this.host,i=l("div","imp-ad"),n=this.ensureAdVideo(),o=new AbortController,a=o.signal;n.src=e.mediaUrl,n.muted=this.host.contentVideo.muted,n.volume=this.host.contentVideo.volume;const d=l("div","imp-spinner imp-ad__spinner"),h=l("div","imp-ad__hud"),p=l("span","imp-ad__badge");p.textContent=e.adTitle?`${s.adLabel} · ${e.adTitle}`:s.adLabel;const v=l("span","imp-ad__countdown");h.append(p,v);const c=l("div","imp-ad__actions");let b=null;e.clickThrough&&(b=l("button","imp-ad__visit",{type:"button"}),b.textContent=s.visitAdvertiser,c.append(b));const f=l("button","imp-ad__skip",{type:"button"});f.hidden=!0,c.append(f),i.append(n,d,h,c),this.host.container.append(i),this.layer=i;const D=e.skipOffset??this.opts.skipDelay,W=new Set,S=g=>{W.has(g)||(W.add(g),A(e.tracking[g]))};let I=Date.now(),z=-1;const Le=setInterval(()=>{if(n.paused){I=Date.now();return}if(n.currentTime!==z){z=n.currentTime,I=Date.now();return}Date.now()-I>=this.opts.mediaTimeout&&(this.host.emitter.emit("aderror",{roll:{roll:e.roll},error:new Error(`Ad media stalled for ${this.opts.mediaTimeout} ms — skipping`)}),q())},500),q=()=>{clearInterval(Le),o.abort(),n.pause(),n.removeAttribute("src"),n.load(),i.remove(),this.layer=null,t()},Q=g=>{g?(S("skip"),this.host.emitter.emit("adskip",{ad:e})):S("complete"),this.host.emitter.emit("adend",{ad:e}),q()};n.addEventListener("playing",()=>{A(e.impressions),S("start"),this.host.emitter.emit("adstart",{ad:e})},{once:!0,signal:a}),n.addEventListener("playing",()=>{d.hidden=!0},{signal:a}),n.addEventListener("waiting",()=>{d.hidden=!1},{signal:a}),n.addEventListener("timeupdate",()=>{const g=n.currentTime,x=n.duration;if(Number.isFinite(x)&&x>0&&(v.textContent=k(Math.max(0,x-g)),g/x>=.25&&S("firstQuartile"),g/x>=.5&&S("midpoint"),g/x>=.75&&S("thirdQuartile")),D>=0){const j=Math.ceil(D-g);j>0?(f.hidden=!1,f.disabled=!0,f.textContent=`${s.skipAdIn} ${j}`):(f.hidden=!1,f.disabled=!1,f.textContent=s.skipAd)}},{signal:a}),n.addEventListener("ended",()=>Q(!1),{signal:a}),n.addEventListener("error",()=>{this.host.emitter.emit("aderror",{roll:{roll:e.roll},error:new Error("Ad media failed to play")}),q()},{signal:a}),f.addEventListener("click",()=>Q(!0));const U=()=>{e.clickThrough&&(S("click"),this.host.emitter.emit("adclick",{ad:e}),window.open(e.clickThrough,"_blank","noopener"),n.pause())};n.addEventListener("click",U,{signal:a}),b?.addEventListener("click",U);let G=!1,M=!1;n.addEventListener("playing",()=>{G=!0},{once:!0,signal:a}),n.addEventListener("pause",()=>{n.ended||!i.isConnected||(i.classList.add("imp-ad--paused"),G&&!M&&(M=!0,A(e.tracking.pause),this.host.emitter.emit("adpause",{ad:e})))},{signal:a}),n.addEventListener("play",()=>{i.classList.remove("imp-ad--paused"),M&&(M=!1,A(e.tracking.resume),this.host.emitter.emit("adresume",{ad:e}))},{signal:a}),i.addEventListener("click",g=>{(g.target===i||i.classList.contains("imp-ad--paused"))&&n.paused&&n.play().catch(()=>{})}),n.play().catch(()=>{i.classList.add("imp-ad--paused")})})}get closeIcon(){return this.host.closeIcon}destroy(){this.destroyed=!0,this.adVideo?.pause(),this.layer?.remove(),this.layer=null,this.adVideo=null}}function ae(r,e){const t=[...r].sort((i,n)=>i.start-n.start),s=[];for(let i=0;i<t.length;i++){const n=Math.max(0,t[i].start);if(Number.isFinite(e)&&n>=e)continue;let o=t[i].end??t[i+1]?.start??e;Number.isFinite(e)&&(o=Math.min(o,e)),!(o<=n)&&s.push({start:n,end:o,title:t[i].title})}return s}async function he(r){const e=await fetch(r);if(!e.ok)throw new Error(`Failed to load chapters VTT (${e.status})`);const t=await e.text();return $(t).map(s=>({start:s.start,end:s.end,title:s.text}))}function Z(r,e){for(const t of r)if(e>=t.start&&e<t.end)return t;return null}function de(r,e){return e?/application\/(x-mpegurl|vnd\.apple\.mpegurl)/i.test(e):/\.m3u8(\?|#|$)/i.test(r)}let L;async function ce(){if(L!==void 0)return L;const r=globalThis.Hls;if(r)return L=r,L;try{L=(await import("hls.js/light")).default}catch{L=null}return L}async function ue(r,e,t,s){if(de(e,t)){const i=r.canPlayType("application/vnd.apple.mpegurl"),n=i?null:await ce();return n&&n.isSupported()?pe(n,r,e,s):i?(r.src=e,R(r)):(s.onError("HLS is not supported in this browser and hls.js could not be loaded."),R(r))}return r.src=e,R(r)}function R(r){return{kind:"native",levels:[],selected:-1,setLevel(){},destroy(){r.removeAttribute("src"),r.load()}}}function pe(r,e,t,s){const i=new r({enableWorker:!0}),n={kind:"hls",levels:[],selected:-1,setLevel(d){n.selected=d,i.currentLevel=d},destroy(){i.destroy(),e.removeAttribute("src"),e.load()}};i.on(r.Events.MANIFEST_PARSED,()=>{n.levels=i.levels.map((d,h)=>({index:h,label:d.height?`${d.height}p`:`${Math.round(d.bitrate/1e3)} kbps`})).reverse(),s.onLevels(n.levels)}),i.on(r.Events.LEVEL_SWITCHED,(d,h)=>{const p=i.levels[h.level];p&&s.onLevelSwitch(p.height?`${p.height}p`:`${Math.round(p.bitrate/1e3)} kbps`)});let o=0,a=!1;return i.on(r.Events.ERROR,(d,h)=>{if(h.fatal)switch(h.type){case r.ErrorTypes.NETWORK_ERROR:i.startLoad();break;case r.ErrorTypes.MEDIA_ERROR:o<3?(o++,i.recoverMediaError()):(s.onError(`HLS media error: ${h.details}`,h),i.destroy());break;default:if(a)s.onError(`HLS fatal error: ${h.details}`,h),i.destroy();else{a=!0;try{i.loadSource(t),i.startLoad()}catch{s.onError(`HLS fatal error: ${h.details}`,h),i.destroy()}}}}),i.loadSource(t),i.attachMedia(e),n}class V{constructor(e){this.cues=e}static async load(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load thumbnails VTT (${t.status})`);const s=await t.text(),i=[];for(const n of $(s)){const[o,a]=n.text.trim().split("#");if(!o)continue;const d={start:n.start,end:n.end,src:K(o,e)},h=a?.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);h&&(d.xywh={x:Number(h[1]),y:Number(h[2]),w:Number(h[3]),h:Number(h[4])}),i.push(d)}return i.sort((n,o)=>n.start-o.start),new V(i)}cueAt(e){let t=0,s=this.cues.length-1;for(;t<=s;){const i=t+s>>1,n=this.cues[i];if(e<n.start)s=i-1;else if(e>=n.end)t=i+1;else return n}return null}}class C{constructor(e){this.anchor=e,this.outsideListener=null,this.root=l("div","imp-menu"),this.root.hidden=!0,this.backdrop=l("div","imp-menu__backdrop"),this.backdrop.hidden=!0,this.backdrop.addEventListener("pointerdown",t=>{t.preventDefault(),this.close()}),e.append(this.backdrop)}get open(){return!this.root.hidden}toggle(e){this.open?this.close():this.show(e)}show(e){this.root.textContent="";for(const t of e){if(t.items.length===0)continue;const s=l("div","imp-menu__section");if(t.title){const i=l("div","imp-menu__title");i.textContent=t.title,s.append(i)}for(const i of t.items){const n=l("button","imp-menu__item",{type:"button",role:"menuitemradio"});if(n.setAttribute("aria-checked",String(i.active)),i.active&&n.classList.add("imp-menu__item--active"),i.icon){const a=l("span","imp-menu__icon");i.icon.trimStart().startsWith("<svg")?a.innerHTML=i.icon:a.append(l("img","",{src:i.icon,alt:""})),n.append(a)}const o=l("span","imp-menu__label");o.textContent=i.label,n.append(o),n.addEventListener("click",()=>{t.onSelect(i.value),this.close()}),s.append(n)}this.root.append(s)}this.root.hidden=!1,this.backdrop.hidden=!1,this.outsideListener=t=>{const s=t.target;!this.root.contains(s)&&!this.anchor.contains(s)&&this.close()},setTimeout(()=>{this.outsideListener&&document.addEventListener("pointerdown",this.outsideListener)},0)}close(){this.root.hidden=!0,this.backdrop.hidden=!0,this.outsideListener&&(document.removeEventListener("pointerdown",this.outsideListener),this.outsideListener=null)}destroy(){this.close(),this.root.remove()}}class me{constructor(e){this.cb=e,this.segments=[],this.duration=0,this.chapters=[],this.thumbnails=null,this.scrubbing=!1,this.root=l("div","imp-progress",{role:"slider","aria-label":"Seek",tabindex:"-1"}),this.buffered=l("div","imp-progress__buffered"),this.track=l("div","imp-progress__track"),this.handle=l("div","imp-progress__handle"),this.tooltipThumb=l("div","imp-progress__thumb"),this.tooltipChapter=l("div","imp-progress__tooltip-chapter"),this.tooltipTime=l("div","imp-progress__tooltip-time"),this.tooltip=l("div","imp-progress__tooltip"),this.tooltip.append(this.tooltipThumb,this.tooltipChapter,this.tooltipTime),this.heatmap=l("div","imp-progress__heatmap"),this.heatmap.hidden=!0,this.root.append(this.heatmap,this.buffered,this.track,this.handle,this.tooltip),this.setChapters([]),this.bindPointer()}setHeatmap(e){if(e.length===0){this.heatmap.hidden=!0,this.heatmap.textContent="";return}this.heatmap.innerHTML=`<svg viewBox="0 0 1000 100" preserveAspectRatio="none" aria-hidden="true"><path d="${ie(e)}"/></svg>`,this.heatmap.hidden=!1}setDuration(e){this.duration=Number.isFinite(e)?e:0,this.root.classList.toggle("imp-progress--live",!Number.isFinite(e)),this.chapters.length===0&&this.setChapters([])}setChapters(e){this.chapters=e,this.track.textContent="",this.segments=[];const t=e.length>0?e:[{start:0,end:this.duration||1,title:""}],s=[];let i=0;for(const n of t)n.start>i&&s.push({start:i,end:n.start,title:""}),s.push(n),i=n.end;this.duration>0&&i<this.duration&&s.push({start:i,end:this.duration,title:""});for(const n of s){const o=l("div","imp-progress__segment");o.style.flexGrow=String(Math.max(n.end-n.start,.01));const a=l("div","imp-progress__fill");o.append(a),this.track.append(o),this.segments.push({chapter:n,root:o,fill:a})}}setThumbnails(e){this.thumbnails=e}update(e,t,s){if(t!==this.duration&&Number.isFinite(t)&&this.setDuration(t),this.scrubbing)return;this.render(e);const i=this.duration>0?y(s/this.duration,0,1):0;this.buffered.style.width=`${i*100}%`,this.root.setAttribute("aria-valuemin","0"),this.root.setAttribute("aria-valuemax",String(Math.round(this.duration))),this.root.setAttribute("aria-valuenow",String(Math.round(e))),this.root.setAttribute("aria-valuetext",`${k(e)} / ${k(this.duration)}`)}render(e){for(const{chapter:s,fill:i}of this.segments){const n=s.end-s.start,o=n>0?y((e-s.start)/n,0,1):0;i.style.transform=`scaleX(${o})`}const t=this.duration>0?y(e/this.duration,0,1):0;this.handle.style.left=`${t*100}%`}timeFromEvent(e){const t=this.root.getBoundingClientRect();return(t.width>0?y((e.clientX-t.left)/t.width,0,1):0)*this.duration}bindPointer(){this.root.addEventListener("pointerdown",e=>{this.duration<=0||(e.preventDefault(),this.scrubbing=!0,this.root.classList.add("imp-progress--scrubbing"),this.root.setPointerCapture(e.pointerId),this.cb.onScrubStart(),this.render(this.timeFromEvent(e)),this.showTooltip(e))}),this.root.addEventListener("pointermove",e=>{this.duration<=0||(this.showTooltip(e),this.scrubbing&&this.render(this.timeFromEvent(e)))}),this.root.addEventListener("pointerup",e=>{this.scrubbing&&(this.scrubbing=!1,this.root.classList.remove("imp-progress--scrubbing"),this.cb.onSeek(this.timeFromEvent(e)),this.cb.onScrubEnd())}),this.root.addEventListener("pointercancel",()=>{this.scrubbing=!1,this.root.classList.remove("imp-progress--scrubbing"),this.cb.onScrubEnd()}),this.root.addEventListener("pointerleave",()=>this.hideTooltip())}showTooltip(e){const t=this.timeFromEvent(e);this.tooltipTime.textContent=k(t);const s=Z(this.chapters,t);this.tooltipChapter.textContent=s?.title??"",this.tooltipChapter.hidden=!s?.title;const i=this.thumbnails?.cueAt(t)??null;i?(this.tooltipThumb.hidden=!1,this.tooltipThumb.style.backgroundImage=`url("${i.src}")`,i.xywh?(this.tooltipThumb.style.width=`${i.xywh.w}px`,this.tooltipThumb.style.height=`${i.xywh.h}px`,this.tooltipThumb.style.backgroundPosition=`-${i.xywh.x}px -${i.xywh.y}px`,this.tooltipThumb.style.backgroundSize="auto"):(this.tooltipThumb.style.width="160px",this.tooltipThumb.style.height="90px",this.tooltipThumb.style.backgroundPosition="center",this.tooltipThumb.style.backgroundSize="cover")):this.tooltipThumb.hidden=!0,this.tooltip.classList.add("imp-progress__tooltip--visible");const n=this.root.getBoundingClientRect(),o=y(e.clientX-n.left,0,n.width),a=this.tooltip.offsetWidth/2;this.tooltip.style.left=`${y(o,a,Math.max(a,n.width-a))}px`}hideTooltip(){this.tooltip.classList.remove("imp-progress__tooltip--visible")}}const B=class B{constructor(e){this.player=e,this.subtitlesBtn=null,this.settingsBtn=null,this.settingsMenu=null,this.subtitlesMenu=null,this.moreMenu=null,this.moreWrap=null,this.qualityBtn=null,this.qualityMenu=null,this.scenesBtn=null,this.likeBtn=null,this.dislikeBtn=null,this.likeCountEl=null,this.dislikeCountEl=null,this.prevBtn=null,this.nextBtn=null,this.seekBackBtn=null,this.seekFwdBtn=null,this.centerPlayBtn=null,this.centerPrevBtn=null,this.centerNextBtn=null,this.collapsibles=[],this.overflowed=new Set,this.resizeObserver=null,this.reflowScheduled=!1,this.actionItems=[],this.wasPlayingBeforeScrub=!1,this.disposers=[],this.onWindowResize=null;const{labels:t,icons:s}=e,i=e.controlsOptions;this.root=l("div","imp-controls"),this.progress=new me({onSeek:c=>e.seek(c),onScrubStart:()=>{this.wasPlayingBeforeScrub=!e.paused,e.pause()},onScrubEnd:()=>{this.wasPlayingBeforeScrub&&e.play()}}),i.progress&&this.root.append(this.progress.root);const n=l("div","imp-controls__row");this.row=n,this.root.append(n);const o=l("div","imp-controls__group"),a=l("div","imp-controls__group");this.rightGroup=a;const d=l("div","imp-controls__spacer");this.chapterLabel=l("div","imp-controls__chapter"),n.append(o,d,a),d.append(this.chapterLabel);const h=typeof i.seekButtons=="object"?i.seekButtons:{},p=h.back??e.seekStep,v=h.forward??e.seekStep;if(i.playlist&&e.hasPlaylist&&(this.prevBtn=m("imp-btn--prev",t.previous,s.previous),this.prevBtn.addEventListener("click",()=>e.previous()),o.append(this.prevBtn)),i.seekButtons&&(this.seekBackBtn=m("imp-btn--seek-back",`${t.seekBack} ${p}s`,s.seekBack),this.seekBackBtn.addEventListener("click",()=>e.skip(-p)),o.append(this.seekBackBtn)),i.play&&(this.playBtn=m("imp-btn--play",t.play,s.play),this.playBtn.addEventListener("click",()=>e.togglePlay()),o.append(this.playBtn)),i.seekButtons&&(this.seekFwdBtn=m("imp-btn--seek-forward",`${t.seekForward} ${v}s`,s.seekForward),this.seekFwdBtn.addEventListener("click",()=>e.skip(v)),o.append(this.seekFwdBtn)),i.playlist&&e.hasPlaylist&&(this.nextBtn=m("imp-btn--next",t.next,s.next),this.nextBtn.addEventListener("click",()=>e.next()),o.append(this.nextBtn)),i.volume){const c=l("div","imp-volume");this.muteBtn=m("imp-btn--mute",t.mute,s.volumeHigh),this.muteBtn.addEventListener("click",()=>e.toggleMute()),this.volumeSlider=l("input","imp-volume__slider",{type:"range",min:"0",max:"1",step:"0.05","aria-label":"Volume"}),this.volumeSlider.addEventListener("input",()=>{e.setVolume(Number(this.volumeSlider.value))}),c.append(this.muteBtn,this.volumeSlider),o.append(c)}if(i.time&&(this.timeLabel=l("div","imp-controls__time"),this.liveBadge=l("span","imp-controls__live"),this.liveBadge.textContent=t.live,this.liveBadge.hidden=!0,o.append(this.timeLabel,this.liveBadge)),this.buildLikeDislike(a),i.subtitles){this.subtitlesBtn=m("imp-btn--subtitles",t.subtitles,s.subtitles),this.subtitlesMenu=new C(this.subtitlesBtn);const c=l("div","imp-controls__menu-anchor");c.append(this.subtitlesBtn,this.subtitlesMenu.root),this.subtitlesBtn.addEventListener("click",()=>this.toggleSubtitlesMenu()),a.append(c),this.registerCollapsible({key:"subtitles",el:c,priority:30,available:()=>e.subtitleTracks.length>0,section:()=>this.subtitlesSection()})}if(i.settings){this.settingsBtn=m("imp-btn--settings",t.settings,s.speed),this.settingsMenu=new C(this.settingsBtn);const c=l("div","imp-controls__menu-anchor");c.append(this.settingsBtn,this.settingsMenu.root),this.settingsBtn.addEventListener("click",()=>this.toggleSettingsMenu()),a.append(c),this.registerCollapsible({key:"settings",el:c,priority:40,available:()=>!0,section:()=>this.speedSection()})}if(i.quality){this.qualityBtn=m("imp-btn--quality",t.quality,s.settings),this.qualityMenu=new C(this.qualityBtn);const c=l("div","imp-controls__menu-anchor");c.append(this.qualityBtn,this.qualityMenu.root),this.qualityBtn.addEventListener("click",()=>this.toggleQualityMenu()),a.append(c),this.registerCollapsible({key:"quality",el:c,priority:10,available:()=>e.qualityLevels.length>0,section:()=>this.qualitySection()})}if(i.scenes&&(this.scenesBtn=m("imp-btn--scenes",t.scenes,s.scenes),this.scenesBtn.addEventListener("click",()=>e.toggleScenesPanel()),a.append(this.scenesBtn),this.registerCollapsible({key:"scenes",el:this.scenesBtn,priority:25,available:()=>e.chapterList.length>0,section:()=>this.simpleSection("scenes",t.scenes,s.scenes,()=>e.toggleScenesPanel())})),i.playlist&&e.hasPlaylist){const c=m("imp-btn--list",t.playlist,s.list);c.addEventListener("click",()=>e.togglePlaylistPanel()),a.append(c),this.registerCollapsible({key:"list",el:c,priority:50,available:()=>!0,section:()=>this.simpleSection("list",t.playlist,s.list,()=>e.togglePlaylistPanel())})}if(i.pip&&"requestPictureInPicture"in HTMLVideoElement.prototype){const c=m("imp-btn--pip",t.pip,s.pip);c.addEventListener("click",()=>void e.togglePip()),a.append(c),this.registerCollapsible({key:"pip",el:c,priority:20,available:()=>!0,section:()=>this.simpleSection("pip",t.pip,s.pip,()=>void e.togglePip())})}if(i.fullscreen&&(this.fullscreenBtn=m("imp-btn--fullscreen",t.fullscreen,s.fullscreen),this.fullscreenBtn.addEventListener("click",()=>void e.toggleFullscreen()),a.append(this.fullscreenBtn)),this.prevBtn&&this.registerCollapsible({key:"prev",el:this.prevBtn,priority:70,available:()=>!0,section:()=>e.hasPrevious?this.simpleSection("prev",t.previous,s.previous,()=>e.previous()):null}),this.nextBtn&&this.registerCollapsible({key:"next",el:this.nextBtn,priority:72,available:()=>!0,section:()=>e.hasNext?this.simpleSection("next",t.next,s.next,()=>e.next()):null}),this.seekBackBtn){const c=this.seekBackBtn;this.registerCollapsible({key:"seekBack",el:c,priority:80,available:()=>Number.isFinite(e.duration)&&e.duration>0,section:()=>this.simpleSection("seekBack",`${t.seekBack} ${p}s`,s.seekBack,()=>e.skip(-p))})}if(this.seekFwdBtn){const c=this.seekFwdBtn;this.registerCollapsible({key:"seekFwd",el:c,priority:82,available:()=>Number.isFinite(e.duration)&&e.duration>0,section:()=>this.simpleSection("seekFwd",`${t.seekForward} ${v}s`,s.seekForward,()=>e.skip(v))})}if(this.center=l("div","imp-center-controls"),i.playlist&&e.hasPlaylist&&(this.centerPrevBtn=this.makeCenterButton("prev",t.previous,s.previous),this.centerPrevBtn.addEventListener("click",()=>e.previous()),this.center.append(this.centerPrevBtn)),i.seekButtons){const c=this.makeCenterButton("seek-back",`${t.seekBack} ${p}s`,s.seekBack);c.addEventListener("click",()=>e.skip(-p)),this.center.append(c)}if(i.play&&(this.centerPlayBtn=this.makeCenterButton("play",t.play,s.play),this.centerPlayBtn.addEventListener("click",()=>e.togglePlay()),this.center.append(this.centerPlayBtn)),i.seekButtons){const c=this.makeCenterButton("seek-forward",`${t.seekForward} ${v}s`,s.seekForward);c.addEventListener("click",()=>e.skip(v)),this.center.append(c)}i.playlist&&e.hasPlaylist&&(this.centerNextBtn=this.makeCenterButton("next",t.next,s.next),this.centerNextBtn.addEventListener("click",()=>e.next()),this.center.append(this.centerNextBtn)),this.center.style.display="none",this.buildMoreDropdown(a),this.bind(),this.syncVolume(),this.syncPlayState(),this.setLikeState(e.actionsOptions.likeState??null),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.scheduleReflow()),this.resizeObserver.observe(e.container)),this.onWindowResize=()=>this.scheduleReflow(),window.addEventListener("resize",this.onWindowResize)}registerCollapsible(e){this.collapsibles.push(e)}makeCenterButton(e,t,s){const i=l("button",`imp-center-btn imp-center-btn--${e}`,{type:"button","aria-label":t,title:t});return i.innerHTML=s,i}buildLikeDislike(e){const t=this.player,s=t.actionsOptions,{labels:i,icons:n}=t;if(s.like){this.likeBtn=m("imp-btn--like",i.like,n.like),this.likeBtn.addEventListener("click",()=>t.emit("action",{id:"like"})),this.likeCountEl=this.attachCountTooltip(this.likeBtn,s.likeCount);const o=this.wrapWithTooltip(this.likeBtn,this.likeCountEl);e.append(o),this.registerCollapsible({key:"like",el:o,priority:62,available:()=>!0,section:()=>this.simpleSection("like",i.like,n.like,()=>t.emit("action",{id:"like"}))})}if(s.dislike){this.dislikeBtn=m("imp-btn--dislike",i.dislike,n.dislike),this.dislikeBtn.addEventListener("click",()=>t.emit("action",{id:"dislike"})),this.dislikeCountEl=this.attachCountTooltip(this.dislikeBtn,s.dislikeCount);const o=this.wrapWithTooltip(this.dislikeBtn,this.dislikeCountEl);e.append(o),this.registerCollapsible({key:"dislike",el:o,priority:60,available:()=>!0,section:()=>this.simpleSection("dislike",i.dislike,n.dislike,()=>t.emit("action",{id:"dislike"}))})}}attachCountTooltip(e,t){const s=l("span","imp-count-tooltip");return this.setCountText(s,t),s}wrapWithTooltip(e,t){const s=l("div","imp-action");return s.append(e,t),s}setCountText(e,t){const s=t==null||t===""?"":String(t);e.textContent=s,e.hidden=s===""}setLikeCounts(e,t){this.likeCountEl&&e!==void 0&&this.setCountText(this.likeCountEl,e),this.dislikeCountEl&&t!==void 0&&this.setCountText(this.dislikeCountEl,t)}setLikeState(e){this.likeBtn?.classList.toggle("imp-btn--active",e==="like"),this.dislikeBtn?.classList.toggle("imp-btn--active",e==="dislike")}buildMoreDropdown(e){const t=this.player,s=t.actionsOptions,{labels:i,icons:n}=t;s.addTo&&this.actionItems.push({value:"addTo",label:i.addTo,icon:n.addTo,run:()=>t.emit("action",{id:"addTo"})}),s.share&&this.actionItems.push({value:"share",label:i.share,icon:n.share,run:()=>void t.share()}),s.report&&this.actionItems.push({value:"report",label:i.report,icon:n.report,run:()=>t.emit("action",{id:"report"})});for(const d of s.custom??[])this.actionItems.push({value:`custom:${d.id}`,label:d.title,icon:d.icon,run:()=>t.emit("customaction",{id:d.id})});const o=m("imp-btn--more",i.more,n.more);this.moreMenu=new C(o);const a=l("div","imp-controls__menu-anchor imp-controls__more");a.append(o,this.moreMenu.root),o.addEventListener("click",()=>{this.closeMenus(this.moreMenu),this.moreMenu?.toggle(this.buildMoreSections())}),e.append(a),this.moreWrap=a}buildMoreSections(){const e=[],t=new Map,s=[],i=["prev","next","seekBack","seekFwd","like","dislike","scenes","pip","list","subtitles","settings","quality"],n=this.collapsibles.filter(o=>this.overflowed.has(o.key)&&o.available()).sort((o,a)=>i.indexOf(o.key)-i.indexOf(a.key));for(const o of n){const a=o.section();if(a)if(!a.title&&a.items.length===1){const d=a.items[0];s.push(d),t.set(d.value,()=>a.onSelect(d.value))}else e.push(a)}if(s.length>0&&e.unshift({title:"",items:s,onSelect:o=>t.get(o)?.()}),this.actionItems.length>0){const o=new Map(this.actionItems.map(a=>[a.value,a.run]));e.push({title:"",items:this.actionItems.map(({value:a,label:d,icon:h})=>({value:a,label:d,icon:h,active:!1})),onSelect:a=>o.get(a)?.()})}return e}simpleSection(e,t,s,i){return{title:"",items:[{value:e,label:t,icon:s,active:!1}],onSelect:()=>i()}}speedSection(){const e=this.player;return{title:e.labels.speed,items:e.playbackRates.map(t=>({label:t===1?"1× (normal)":`${t}×`,value:String(t),active:e.playbackRate===t})),onSelect:t=>e.setPlaybackRate(Number(t))}}qualitySection(){const e=this.player;return{title:e.labels.quality,items:[...e.qualityAutoAvailable?[{label:e.labels.qualityAuto,value:"-1",active:e.currentQuality===-1}]:[],...e.qualityLevels.map(t=>({label:t.label,value:String(t.index),active:e.currentQuality===t.index}))],onSelect:t=>e.setQuality(Number(t))}}subtitlesSection(){const e=this.player;return{title:e.labels.subtitles,items:[{label:e.labels.subtitlesOff,value:"-1",active:e.activeSubtitle===-1},...e.subtitleTracks.map((t,s)=>({label:t.label,value:String(s),active:e.activeSubtitle===s}))],onSelect:t=>e.setSubtitle(Number(t))}}scheduleReflow(){this.reflowScheduled||(this.reflowScheduled=!0,requestAnimationFrame(()=>{this.reflowScheduled=!1,this.reflow()}))}reflow(){const e=window.innerWidth<=767;this.center.style.display=e?"flex":"none",this.playBtn&&(this.playBtn.style.display=e?"none":""),this.overflowed.clear();for(const i of this.collapsibles){if(e&&B.CENTER_KEYS.has(i.key)){i.el.style.display="none";continue}const n=i.available();i.el.style.display=n?"":"none",i.el.classList.remove("imp-collapsed")}const t=this.collapsibles.filter(i=>i.available()&&!(e&&B.CENTER_KEYS.has(i.key))).sort((i,n)=>i.priority-n.priority);let s=t.length;for(;s-- >0&&this.overflowsRow();){const i=t.find(n=>!this.overflowed.has(n.key));if(!i)break;i.el.style.display="none",i.el.classList.add("imp-collapsed"),this.overflowed.add(i.key)}if(this.moreWrap){const i=this.actionItems.length>0||this.overflowed.size>0;this.moreWrap.style.display=i?"":"none"}}overflowsRow(){const e=this.row.getBoundingClientRect().right;return this.rightGroup.getBoundingClientRect().right>e+1}bind(){const e=this.player;this.disposers.push(e.on("timeupdate",({currentTime:t,duration:s})=>{this.progress.update(t,s,e.bufferedEnd),this.timeLabel&&(e.live?(this.timeLabel.hidden=!0,this.liveBadge.hidden=!1):(this.timeLabel.hidden=!1,this.liveBadge.hidden=!0,this.timeLabel.textContent=`${k(t)} / ${k(s)}`))}),e.on("play",()=>this.syncPlayState()),e.on("pause",()=>this.syncPlayState()),e.on("ended",()=>this.syncPlayState()),e.on("volumechange",()=>this.syncVolume()),e.on("chapterchange",({chapter:t})=>{this.chapterLabel.textContent=t?.title??""}),e.on("fullscreenchange",({active:t})=>{this.fullscreenBtn&&E(this.fullscreenBtn,t?e.icons.fullscreenExit:e.icons.fullscreen,t?e.labels.exitFullscreen:e.labels.fullscreen),this.scheduleReflow()}),e.on("playlistitemchange",()=>{this.syncPlaylistButtons(),this.scheduleReflow()}),e.on("sourcechange",()=>{this.syncPlaylistButtons(),this.scheduleReflow()})),this.syncPlaylistButtons(),this.reflow()}syncPlayState(){const e=this.player,[t,s]=e.ended?[e.icons.replay,e.labels.replay]:e.paused?[e.icons.play,e.labels.play]:[e.icons.pause,e.labels.pause];this.playBtn&&E(this.playBtn,t,s),this.centerPlayBtn&&E(this.centerPlayBtn,t,s)}syncVolume(){if(!this.muteBtn)return;const e=this.player,t=e.muted?0:e.volume,s=t===0?e.icons.volumeMute:t<.5?e.icons.volumeLow:e.icons.volumeHigh;E(this.muteBtn,s,e.muted?e.labels.unmute:e.labels.mute),this.volumeSlider.value=String(t),this.volumeSlider.style.setProperty("--imp-volume-fill",`${t*100}%`)}syncFeatureButtons(){this.scheduleReflow()}syncPlaylistButtons(){const e=this.player;this.prevBtn&&(this.prevBtn.disabled=!e.hasPrevious),this.nextBtn&&(this.nextBtn.disabled=!e.hasNext),this.centerPrevBtn&&(this.centerPrevBtn.disabled=!e.hasPrevious),this.centerNextBtn&&(this.centerNextBtn.disabled=!e.hasNext)}closeMenus(e){for(const t of[this.settingsMenu,this.subtitlesMenu,this.qualityMenu,this.moreMenu])t&&t!==e&&t.close()}toggleSettingsMenu(){this.settingsMenu&&(this.closeMenus(this.settingsMenu),this.settingsMenu.toggle([this.speedSection()]))}toggleQualityMenu(){!this.qualityMenu||this.player.qualityLevels.length===0||(this.closeMenus(this.qualityMenu),this.qualityMenu.toggle([this.qualitySection()]))}toggleSubtitlesMenu(){!this.subtitlesMenu||this.player.subtitleTracks.length===0||(this.closeMenus(this.subtitlesMenu),this.subtitlesMenu.toggle([this.subtitlesSection()]))}destroy(){for(const e of this.disposers)e();this.disposers=[],this.resizeObserver?.disconnect(),this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize),this.settingsMenu?.destroy(),this.subtitlesMenu?.destroy(),this.qualityMenu?.destroy(),this.moreMenu?.destroy(),this.root.remove()}};B.CENTER_KEYS=new Set(["seekBack","seekFwd","prev","next"]);let F=B;class ve{constructor(e){this.root=l("div","imp-poster"),this.image=l("img","imp-poster__image",{alt:"",decoding:"async"}),this.image.hidden=!0;const t=m("imp-poster__play",e.labels.play,e.icons.bigPlay);t.addEventListener("click",()=>void e.play()),this.root.append(this.image,t),this.root.addEventListener("click",s=>{(s.target===this.root||s.target===this.image)&&e.play()})}setSource(e){e?.poster?(this.image.src=e.poster,this.image.fetchPriority="high",this.image.hidden=!1):(this.image.removeAttribute("src"),this.image.hidden=!0)}show(){this.root.hidden=!1}hide(){this.root.hidden=!0}}class fe{constructor(e){this.labels=e,this.channelUrl=null,this.custom=null,this.root=l("div","imp-pause-screen"),this.root.hidden=!0,this.defaultContent=l("div","imp-pause-screen__default"),this.channel=l("button","imp-channel",{type:"button"}),this.channel.hidden=!0,this.channelAvatar=l("div","imp-channel__avatar"),this.channelName=l("div","imp-channel__name"),this.channel.append(this.channelName,this.channelAvatar),this.channel.addEventListener("click",()=>{this.channelUrl&&window.open(this.channelUrl,"_blank","noopener")});const t=l("div","imp-pause-screen__heading");this.title=l("div","imp-pause-screen__title"),this.description=l("div","imp-pause-screen__description"),this.sponsor=l("a","imp-sponsor",{target:"_blank",rel:"nofollow noopener"}),this.sponsor.hidden=!0,this.sponsorLabel=l("span","imp-sponsor__label"),this.sponsorText=l("span","imp-sponsor__text"),this.sponsor.append(this.sponsorLabel,this.sponsorText),this.sponsor.addEventListener("click",s=>s.stopPropagation()),t.append(this.title,this.description,this.sponsor),this.defaultContent.append(t,this.channel),this.root.append(this.defaultContent)}setCustomContent(e){this.custom?.remove(),this.custom=e,e&&(e.classList.add("imp-pause-screen__custom"),this.root.append(e)),this.defaultContent.hidden=e!==null,this.root.classList.toggle("imp-pause-screen--custom",e!==null)}get hasCustom(){return this.custom!==null}setSource(e){this.title.textContent=e?.title??"",this.description.textContent=e?.description??"";const t=e?.sponsor;this.sponsor.hidden=!t,t&&(this.sponsor.href=t.url,this.sponsorText.textContent=t.text,this.sponsorLabel.textContent=t.label??this.labels.sponsored);const s=e?.channel;this.channel.hidden=!s,this.channelUrl=s?.url??null,this.channel.classList.toggle("imp-channel--link",!!s?.url),s&&(this.channelName.textContent=s.name,this.channelAvatar.className=`imp-channel__avatar imp-channel__avatar--${s.avatarShape??"circle"}`,s.avatar?(this.channelAvatar.textContent="",this.channelAvatar.style.backgroundImage=`url("${s.avatar}")`):(this.channelAvatar.style.backgroundImage="",this.channelAvatar.textContent=(s.name.trim()[0]??"?").toUpperCase()))}show(){this.root.hidden=!1}hide(){this.root.hidden=!0}}class ge{constructor(e){this.player=e,this.clickBehavior="player",this.root=l("div","imp-related"),this.root.hidden=!0,this.heading=l("div","imp-related__title"),this.grid=l("div","imp-related__grid");const t=m("imp-related__close","Close",e.icons.close);t.addEventListener("click",()=>this.hide()),this.root.append(t,this.heading,this.grid)}setOptions(e){if(this.grid.textContent="",!!e){this.clickBehavior=e.clickBehavior??"player",this.heading.textContent=e.title??this.player.labels.related;for(const t of e.items)this.grid.append(this.buildCard(t))}}buildCard(e){const t=l("button","imp-related__card",{type:"button"}),s=l("div","imp-related__thumb");if(e.poster&&(s.style.backgroundImage=`url("${e.poster}")`),e.duration){const n=l("span","imp-related__duration");n.textContent=e.duration,s.append(n)}const i=l("div","imp-related__card-title");return i.textContent=e.title,t.append(s,i),t.addEventListener("click",()=>{this.player.emit("relatedclick",{item:e}),this.hide(),this.activate(e)}),t}activate(e){const t=e.url??e.source?.src;switch(this.clickBehavior){case"newWindow":t&&window.open(t,"_blank","noopener");break;case"currentTab":t&&(window.location.href=t);break;case"player":default:e.source?(this.player.load(e.source),this.player.play()):e.url&&window.open(e.url,"_blank","noopener")}}get visible(){return!this.root.hidden}show(){this.grid.childElementCount!==0&&(this.root.hidden=!1,this.player.emit("relatedshow",void 0))}hide(){this.root.hidden=!0}}class ye{constructor(e,t="sidebar",s){this.player=e,this.root=l("div",`imp-playlist imp-playlist--${t}`),this.root.hidden=!0;const i=l("div","imp-playlist__header"),n=l("div","imp-playlist__heading");if(s){const d=l("div","imp-playlist__kicker");d.textContent=e.labels.playlist;const h=l("div","imp-playlist__name");h.textContent=s,n.append(d,h)}else n.textContent=e.labels.playlist;const o=l("div","imp-playlist__tools");this.shuffleBtn=m("imp-playlist__shuffle",e.labels.shuffle,e.icons.shuffle),this.shuffleBtn.addEventListener("click",()=>{e.setShuffle(!e.shuffle),this.syncModes()}),this.repeatBtn=m("imp-playlist__repeat",e.labels.repeat,e.icons.repeat),this.repeatBtn.addEventListener("click",()=>{e.setRepeat(!e.repeat),this.syncModes()});const a=m("imp-playlist__close","Close",e.icons.close);a.addEventListener("click",()=>this.hide()),o.append(this.shuffleBtn,this.repeatBtn,a),i.append(n,o),this.list=l("div","imp-playlist__list"),this.root.append(i,this.list),this.rebuild(),this.syncModes()}syncModes(){this.shuffleBtn.classList.toggle("imp-btn--active",this.player.shuffle),this.repeatBtn.classList.toggle("imp-btn--active",this.player.repeat)}rebuild(){this.list.textContent="",this.player.playlist.forEach((e,t)=>{const s=l("button","imp-playlist__item",{type:"button"});t===this.player.index&&s.classList.add("imp-playlist__item--active");const i=l("div","imp-playlist__thumb");e.poster&&(i.style.backgroundImage=`url("${e.poster}")`);const n=l("div","imp-playlist__meta"),o=l("div","imp-playlist__title");if(o.textContent=e.title??`#${t+1}`,n.append(o),e.duration){const a=l("div","imp-playlist__duration");a.textContent=k(e.duration),n.append(a)}s.append(i,n),s.addEventListener("click",()=>{this.player.playItem(t)}),this.list.append(s)})}get visible(){return!this.root.hidden}show(){this.rebuild(),this.root.hidden=!1}hide(){this.root.hidden=!0}toggle(){this.visible?this.hide():this.show()}}class be{constructor(e,t="bottom"){this.player=e,this.items=[],this.root=l("div",`imp-playlist imp-scenes imp-playlist--${t}`),this.root.hidden=!0;const s=l("div","imp-playlist__header"),i=l("span");i.textContent=e.labels.scenes;const n=m("imp-playlist__close","Close",e.icons.close);n.addEventListener("click",()=>this.hide()),s.append(i,n),this.list=l("div","imp-playlist__list"),this.root.append(s,this.list),e.on("chapterchange",()=>this.syncActive())}rebuild(){this.list.textContent="",this.items=[];const e=this.player.thumbnails;for(const t of this.player.chapterList){const s=l("button","imp-playlist__item",{type:"button"}),i=l("div","imp-playlist__thumb"),n=e?.cueAt(t.start+.01)??null;if(n?.xywh){const h=l("div","imp-scenes__sprite");h.style.width=`${n.xywh.w}px`,h.style.height=`${n.xywh.h}px`,h.style.backgroundImage=`url("${n.src}")`,h.style.backgroundPosition=`-${n.xywh.x}px -${n.xywh.y}px`,h.style.setProperty("--imp-sprite-w",String(n.xywh.w)),i.append(h)}else n&&(i.style.backgroundImage=`url("${n.src}")`);const o=l("div","imp-playlist__meta"),a=l("div","imp-playlist__title");a.textContent=t.title||k(t.start);const d=l("div","imp-playlist__duration");d.textContent=k(t.start),o.append(a,d),s.append(i,o),s.addEventListener("click",()=>{this.player.seek(t.start),this.player.play()}),this.list.append(s),this.items.push(s)}this.syncActive()}syncActive(){const e=this.player.chapter,t=this.player.chapterList;this.items.forEach((s,i)=>{s.classList.toggle("imp-playlist__item--active",e!==null&&t[i]===e)})}get visible(){return!this.root.hidden}show(){this.rebuild(),this.root.hidden=!1}hide(){this.root.hidden=!0}toggle(){this.visible?this.hide():this.show()}}function H(r){return r?typeof r=="string"?[{src:r,label:"Subtitles"}]:Array.isArray(r)?r:[r]:[]}const ke={play:!0,progress:!0,time:!0,volume:!0,fullscreen:!0,pip:!0,settings:!0,quality:!1,scenes:!0,heatmap:!0,subtitles:!0,seekButtons:!0,playlist:!0,hideDelay:2500};class we{constructor(e,t={}){this.scrubbing=!1,this.emitter=new X,this.abort=new AbortController,this.sources=[],this.currentIndex=-1,this.sourceController=null,this.loadToken=0,this.chapters=[],this.currentChapter=null,this.progressiveQuality=-1,this.thumbTrack=null,this.shuffleMode=!1,this.decodeRecoveries=0,this.adManager=null,this.playedOnce=!1,this.idleTimer=null,this.destroyed=!1;const s=typeof e=="string"?document.querySelector(e):e;if(!s)throw new Error(`[itube-player] mount target not found: ${String(e)}`);this.mount=s,this.options=t,this.labels={..._,...ee(t.language),...t.labels},this.icons={...Y,...t.icons},this.controlsOptions={...ke,...t.controls},this.actionsOptions=t.actions??{},this.playbackRates=t.playbackRates??[.5,.75,1,1.25,1.5,2],this.seekStep=t.seekStep??10,this.playlistOptions={title:"",autoAdvance:!0,loop:!1,shuffle:!1,startIndex:0,layout:"sidebar",...t.playlist},this.shuffleMode=this.playlistOptions.shuffle,this.sources=t.source?Array.isArray(t.source)?[...t.source]:[t.source]:[],this.container=l("div","imp-player",{tabindex:"0"}),t.className&&this.container.classList.add(t.className);const i=t.styling;if(i?.themeColor&&this.container.style.setProperty("--imp-accent",i.themeColor),i?.likeColor&&this.container.style.setProperty("--imp-like",i.likeColor),i?.dislikeColor&&this.container.style.setProperty("--imp-dislike",i.dislikeColor),i?.borderRadius!==void 0){const h=typeof i.borderRadius=="number"?`${i.borderRadius}px`:i.borderRadius;this.container.style.setProperty("--imp-radius",h)}i?.playButtonStyle==="inverted"&&this.container.classList.add("imp-player--play-inverted"),this.video=l("video","imp-video"),t.playsInline!==!1&&this.video.setAttribute("playsinline",""),t.crossOrigin!==void 0&&(this.video.crossOrigin=t.crossOrigin),this.video.preload="metadata",t.loop&&(this.video.loop=!0),t.muted&&(this.video.muted=!0),this.video.volume=y(t.volume??1,0,1);const n=l("div","imp-layer");this.spinner=l("div","imp-spinner"),this.spinner.hidden=!0,this.errorBox=l("div","imp-error"),this.errorBox.hidden=!0,this.pauseScreen=new fe(this.labels),this.poster=new ve(this),this.related=new ge(this),this.related.setOptions(t.related),this.controls=new F(this),this.playlistPanel=new ye(this,this.playlistOptions.layout,this.playlistOptions.title||void 0),this.scenesPanel=new be(this,t.scenes?.layout??"bottom");const o=l("div","imp-layer__middle");o.append(this.spinner,this.errorBox,this.controls.center);const a=l("div","imp-layer__bottom");a.append(this.controls.root),n.append(this.pauseScreen.root,this.related.root,o,a),this.container.append(this.video,n,this.poster.root,this.playlistPanel.root,this.scenesPanel.root),this.mount.append(this.container),t.pauseScreen instanceof HTMLElement?this.pauseScreen.setCustomContent(t.pauseScreen):typeof t.pauseScreen=="function"&&this.pauseScreen.setCustomContent(t.pauseScreen(this));const d=t.adConfig??t.ads;d&&d.adList.length>0&&(this.adManager=new le({container:this.container,contentVideo:this.video,emitter:this.emitter,labels:this.labels,closeIcon:this.icons.close},d)),this.emitter.on("error",({message:h})=>{this.errorBox.textContent=h,this.errorBox.hidden=!1,this.spinner.hidden=!0,this.poster.hide()}),this.bindVideoEvents(),this.bindIdleHide(),t.keyboard!==!1&&this.bindKeyboard(),this.video.addEventListener("click",()=>{this.playedOnce&&!this.adPlaying&&this.togglePlay()},{signal:this.abort.signal}),this.pauseScreen.root.addEventListener("click",h=>{this.pauseScreen.hasCustom||h.target===this.pauseScreen.root&&this.togglePlay()},{signal:this.abort.signal}),this.sources.length>0&&this.loadItem(y(this.playlistOptions.startIndex,0,this.sources.length-1),!!t.autoplay),this.emitter.emit("ready",{player:this})}on(e,t){return this.emitter.on(e,t)}once(e,t){return this.emitter.once(e,t)}off(e,t){this.emitter.off(e,t)}emit(e,t){this.emitter.emit(e,t)}get paused(){return this.video.paused}get ended(){return this.video.ended}get currentTime(){return this.video.currentTime}get duration(){return this.video.duration||0}get live(){return this.video.duration===1/0}get bufferedEnd(){const e=this.video.buffered;return e.length>0?e.end(e.length-1):0}get adPlaying(){return this.adManager?.adPlaying??!1}async play(){this.destroyed||this.adPlaying||this.adManager&&(await this.adManager.playPreRoll(),this.destroyed||!this.video.paused)||await this.video.play()}pause(){this.adPlaying||this.video.pause()}togglePlay(){this.video.paused||this.video.ended?this.play():this.pause()}seek(e){Number.isFinite(this.video.duration)&&(this.video.currentTime=y(e,0,this.video.duration))}skip(e){this.seek(this.video.currentTime+e)}get volume(){return this.video.volume}get muted(){return this.video.muted}setVolume(e){this.video.volume=y(e,0,1),e>0&&(this.video.muted=!1)}setMuted(e){this.video.muted=e}toggleMute(){this.video.muted=!this.video.muted}get playbackRate(){return this.video.playbackRate}setPlaybackRate(e){this.video.playbackRate=e,this.emitter.emit("ratechange",{rate:e})}get qualityLevels(){if(this.sourceController?.kind==="hls")return this.sourceController.levels;const e=this.source?.qualities;return e?e.map((t,s)=>({index:s,label:t.label??String(t.quality??s)})):[]}get qualityAutoAvailable(){return this.sourceController?.kind==="hls"}get currentQuality(){return this.sourceController?.kind==="hls"?this.sourceController.selected:this.progressiveQuality}setQuality(e){if(this.sourceController?.kind==="hls"){this.sourceController.setLevel(e);const n=e===-1?this.labels.qualityAuto:this.sourceController.levels.find(o=>o.index===e)?.label??String(e);this.emitter.emit("qualitychange",{label:n});return}const t=this.source?.qualities;if(!t||!t[e]||e===this.progressiveQuality)return;const s=this.video.currentTime,i=!this.video.paused&&!this.video.ended;this.progressiveQuality=e,this.video.src=t[e].src,this.video.currentTime=s,i&&this.video.play().catch(()=>{}),this.emitter.emit("qualitychange",{label:t[e].label??String(t[e].quality??e)})}get subtitleTracks(){return H(this.source?.subtitles)}get activeSubtitle(){const e=this.video.textTracks;for(let t=0;t<e.length;t++)if(e[t].mode==="showing")return t;return-1}setSubtitle(e){const t=this.video.textTracks;for(let s=0;s<t.length;s++)t[s].mode=s===e?"showing":"disabled";this.emitter.emit("subtitlechange",{track:this.subtitleTracks[e]??null})}get playlist(){return this.sources}get index(){return this.currentIndex}get source(){return this.sources[this.currentIndex]??null}get hasPlaylist(){return this.sources.length>1}get hasNext(){return this.shuffleMode||this.playlistOptions.loop?this.sources.length>1:this.currentIndex<this.sources.length-1}get hasPrevious(){return this.playlistOptions.loop?this.sources.length>1:this.currentIndex>0}get shuffle(){return this.shuffleMode}setShuffle(e){this.shuffleMode=e}get repeat(){return this.playlistOptions.loop}setRepeat(e){this.playlistOptions.loop=e}next(){if(this.hasNext){if(this.shuffleMode&&this.sources.length>1){let e=this.currentIndex;for(;e===this.currentIndex;)e=Math.floor(Math.random()*this.sources.length);this.playItem(e);return}this.playItem((this.currentIndex+1)%this.sources.length)}}previous(){this.hasPrevious&&this.playItem((this.currentIndex-1+this.sources.length)%this.sources.length)}playItem(e){e<0||e>=this.sources.length||this.loadItem(e,!0).then(()=>{this.emitter.emit("playlistitemchange",{source:this.sources[e],index:e})})}togglePlaylistPanel(){this.scenesPanel.hide(),this.playlistPanel.toggle()}toggleScenesPanel(){this.playlistPanel.hide(),this.scenesPanel.toggle()}get thumbnails(){return this.thumbTrack}load(e,t=0){this.sources=Array.isArray(e)?[...e]:[e],this.playlistPanel.rebuild(),this.loadItem(y(t,0,this.sources.length-1),!1)}get isFullscreen(){return document.fullscreenElement===this.container}async toggleFullscreen(){this.isFullscreen?await document.exitFullscreen():this.container.requestFullscreen?await this.container.requestFullscreen():this.video.webkitEnterFullscreen?.()}async togglePip(){document.pictureInPictureElement===this.video?await document.exitPictureInPicture():await this.video.requestPictureInPicture()}get chapterList(){return this.chapters}get chapter(){return this.currentChapter}async share(){const e={title:this.source?.title??document.title,url:window.location.href};if(typeof navigator.share=="function"){try{await navigator.share(e)}catch{}return}this.emitter.emit("action",{id:"share"})}setLikeState(e){this.controls.setLikeState(e)}setLikeCounts(e,t){this.controls.setLikeCounts(e,t)}setPauseScreenContent(e){this.pauseScreen.setCustomContent(e)}destroy(){this.destroyed||(this.destroyed=!0,this.loadToken++,this.adManager?.destroy(),this.controls.destroy(),this.sourceController?.destroy(),this.abort.abort(),this.idleTimer&&clearTimeout(this.idleTimer),this.container.remove(),this.emitter.emit("destroy",void 0),this.emitter.removeAll())}async loadItem(e,t){const s=++this.loadToken,i=this.sources[e];if(!i)return;this.currentIndex=e,this.sourceController?.destroy(),this.sourceController=null,this.chapters=[],this.currentChapter=null,this.progressiveQuality=-1,this.playedOnce=!1;for(const d of[...this.video.querySelectorAll("track")])d.remove();this.adManager?.resetForNewSource(),this.related.hide(),this.pauseScreen.hide(),this.scenesPanel.hide(),this.thumbTrack=null,this.errorBox.hidden=!0,this.decodeRecoveries=0,this.video.poster=i.poster??"",this.poster.setSource(i),this.pauseScreen.setSource(i),this.controls.progress.setChapters([]),this.controls.progress.setThumbnails(null),this.controls.progress.setHeatmap([]),t?this.poster.hide():this.poster.show(),this.playlistPanel.rebuild();for(const d of H(i.subtitles)){const h=l("track","",{kind:"subtitles",src:d.src,label:d.label,...d.srclang?{srclang:d.srclang}:{}});d.default&&h.setAttribute("default",""),this.video.append(h)}let n=i.src,o=i.type;if(i.qualities&&i.qualities.length>0){const d=Math.max(0,i.qualities.findIndex(h=>h.src===i.src));this.progressiveQuality=d,n=i.qualities[d].src,o=i.qualities[d].type??o}this.video.preload=this.adManager?.hasPendingPreRoll?"auto":"metadata";const a=await ue(this.video,n,o,{onLevels:()=>{s===this.loadToken&&this.controls.syncFeatureButtons()},onLevelSwitch:d=>this.emitter.emit("qualitychange",{label:d}),onError:(d,h)=>this.emitter.emit("error",{message:d,cause:h})});if(s!==this.loadToken){a.destroy();return}if(this.sourceController=a,this.emitter.emit("sourcechange",{source:i,index:e}),i.thumbnails&&V.load(i.thumbnails).then(d=>{s===this.loadToken&&(this.thumbTrack=d,this.controls.progress.setThumbnails(d),this.scenesPanel.visible&&this.scenesPanel.rebuild())}).catch(d=>this.emitter.emit("error",{message:"Failed to load thumbnails track",cause:d})),i.chapters){const d=h=>{const p=()=>{s===this.loadToken&&(this.chapters=ae(h,this.video.duration),this.controls.progress.setChapters(this.chapters),this.controls.syncFeatureButtons(),this.scenesPanel.visible&&this.scenesPanel.rebuild())};Number.isFinite(this.video.duration)&&this.video.duration>0?p():this.video.addEventListener("loadedmetadata",p,{once:!0,signal:this.abort.signal})};typeof i.chapters=="string"?he(i.chapters).then(h=>d(h)).catch(h=>this.emitter.emit("error",{message:"Failed to load chapters track",cause:h})):d(i.chapters)}if(i.heatmap&&i.heatmap.length>0&&this.controlsOptions.heatmap){const d=i.heatmap,h=()=>{s===this.loadToken&&this.controls.progress.setHeatmap(te(d,this.video.duration))};Number.isFinite(this.video.duration)&&this.video.duration>0?h():this.video.addEventListener("loadedmetadata",h,{once:!0,signal:this.abort.signal})}t&&this.play().catch(()=>{s===this.loadToken&&this.poster.show()})}bindVideoEvents(){const{signal:e}=this.abort,t=this.video;t.addEventListener("play",()=>{this.playedOnce=!0,this.poster.hide(),this.pauseScreen.hide(),this.related.visible||this.related.hide(),this.related.hide(),t.readyState<3&&(this.spinner.hidden=!1),this.emitter.emit("play",void 0),this.scheduleIdle()},{signal:e}),t.addEventListener("pause",()=>{this.spinner.hidden=!0,this.emitter.emit("pause",void 0),this.showControlsNow(),!(this.video.ended||this.scrubbing||this.adPlaying||!this.playedOnce)&&(this.options.pauseScreen!==!1&&this.pauseScreen.show(),this.options.related?.showOn?.includes("pause")&&this.related.show())},{signal:e}),t.addEventListener("ended",()=>{this.handleEnded()},{signal:e}),t.addEventListener("timeupdate",()=>{this.emitter.emit("timeupdate",{currentTime:t.currentTime,duration:t.duration||0}),this.adManager?.checkMidRolls(t.currentTime);const s=Z(this.chapters,t.currentTime);s!==this.currentChapter&&(this.currentChapter=s,this.emitter.emit("chapterchange",{chapter:s}))},{signal:e}),t.addEventListener("progress",()=>{this.emitter.emit("progress",{buffered:this.bufferedEnd})},{signal:e}),t.addEventListener("volumechange",()=>{this.emitter.emit("volumechange",{volume:t.volume,muted:t.muted})},{signal:e}),t.addEventListener("seeking",()=>this.emitter.emit("seeking",{currentTime:t.currentTime}),{signal:e}),t.addEventListener("seeked",()=>this.emitter.emit("seeked",{currentTime:t.currentTime}),{signal:e}),t.addEventListener("waiting",()=>{this.spinner.hidden=!1},{signal:e});for(const s of["playing","canplay","seeked"])t.addEventListener(s,()=>{this.spinner.hidden=!0,this.errorBox.hidden=!0,this.decodeRecoveries=0},{signal:e});t.addEventListener("error",()=>{const s=t.error;if(!s||this.sourceController?.kind==="hls"||t.getAttribute("src")===null&&!t.currentSrc)return;if((s.code===MediaError.MEDIA_ERR_DECODE||/DEMUXER|PARSE|DECODE/i.test(s.message||""))&&this.decodeRecoveries<2&&Number.isFinite(t.duration)){this.decodeRecoveries++;const n=t.currentTime,o=!t.paused;t.load();const a=()=>{try{t.currentTime=n}catch{}o&&t.play().catch(()=>{})};t.readyState>=1?a():t.addEventListener("loadedmetadata",a,{once:!0,signal:this.abort.signal});return}this.emitter.emit("error",{message:s.message||`Media error (code ${s.code})`,cause:s})},{signal:e}),t.addEventListener("enterpictureinpicture",()=>this.emitter.emit("pipchange",{active:!0}),{signal:e}),t.addEventListener("leavepictureinpicture",()=>this.emitter.emit("pipchange",{active:!1}),{signal:e}),document.addEventListener("fullscreenchange",()=>{this.emitter.emit("fullscreenchange",{active:this.isFullscreen}),this.container.classList.toggle("imp-player--fullscreen",this.isFullscreen)},{signal:e})}async handleEnded(){if(this.emitter.emit("ended",void 0),this.showControlsNow(),!(this.adManager&&(await this.adManager.playPostRoll(),this.destroyed))){if(this.playlistOptions.autoAdvance&&this.hasNext){this.next();return}(this.options.related?.showOn?.includes("ended")??!!this.options.related)&&this.related.show()}}bindIdleHide(){const{signal:e}=this.abort,t=()=>{this.showControlsNow(),this.scheduleIdle()};this.container.addEventListener("pointermove",t,{signal:e}),this.container.addEventListener("pointerdown",t,{signal:e}),this.container.addEventListener("keydown",t,{signal:e}),this.container.addEventListener("pointerleave",()=>{this.video.paused||this.container.classList.add("imp-player--idle")},{signal:e})}showControlsNow(){this.container.classList.remove("imp-player--idle")}scheduleIdle(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{!this.video.paused&&!this.destroyed&&this.container.classList.add("imp-player--idle")},this.controlsOptions.hideDelay)}bindKeyboard(){this.container.addEventListener("keydown",e=>{const t=e.target;if(t.closest("input, select, textarea, [contenteditable]"))return;const i=t.closest("button")!==null;switch(e.key){case" ":case"k":if(e.key===" "&&i)return;e.preventDefault(),this.togglePlay();break;case"ArrowLeft":e.preventDefault(),this.skip(-this.seekStep);break;case"ArrowRight":e.preventDefault(),this.skip(this.seekStep);break;case"ArrowUp":e.preventDefault(),this.setVolume(this.volume+.1);break;case"ArrowDown":e.preventDefault(),this.setVolume(this.volume-.1);break;case"m":this.toggleMute();break;case"f":this.toggleFullscreen();break;case"Home":this.seek(0);break;case"End":this.seek(this.duration);break;default:/^[0-9]$/.test(e.key)&&Number.isFinite(this.video.duration)&&this.seek(Number(e.key)/10*this.video.duration)}},{signal:this.abort.signal})}}return J({en:_,ru:{play:"Воспроизвести",pause:"Пауза",replay:"Смотреть снова",mute:"Выключить звук",unmute:"Включить звук",fullscreen:"Во весь экран",exitFullscreen:"Выйти из полноэкранного режима",pip:"Картинка в картинке",settings:"Скорость воспроизведения",subtitles:"Субтитры",subtitlesOff:"Выкл.",speed:"Скорость",quality:"Качество",qualityAuto:"Авто",next:"Следующее",previous:"Предыдущее",playlist:"Плейлист",scenes:"Сцены",shuffle:"Перемешать",repeat:"Повтор",like:"Нравится",dislike:"Не нравится",addTo:"Сохранить в…",share:"Поделиться",report:"Пожаловаться",more:"Ещё",seekForward:"Перемотать вперёд",seekBack:"Перемотать назад",live:"В ЭФИРЕ",related:"Похожие видео",adLabel:"Реклама",skipAd:"Пропустить рекламу",skipAdIn:"Пропуск через",visitAdvertiser:"Перейти к рекламодателю",sponsored:"Спонсор"},de:{play:"Wiedergabe",pause:"Pause",replay:"Erneut abspielen",mute:"Stummschalten",unmute:"Ton einschalten",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",pip:"Bild im Bild",settings:"Wiedergabegeschwindigkeit",subtitles:"Untertitel",subtitlesOff:"Aus",speed:"Geschwindigkeit",quality:"Qualität",qualityAuto:"Automatisch",next:"Weiter",previous:"Zurück",playlist:"Playlist",scenes:"Szenen",shuffle:"Zufallswiedergabe",repeat:"Wiederholen",like:"Mag ich",dislike:"Mag ich nicht",addTo:"Speichern in…",share:"Teilen",report:"Melden",more:"Weitere Aktionen",seekForward:"Vorspulen",seekBack:"Zurückspulen",live:"LIVE",related:"Weitere Videos",adLabel:"Anzeige",skipAd:"Werbung überspringen",skipAdIn:"Überspringen in",visitAdvertiser:"Zum Werbetreibenden",sponsored:"Gesponsert"},es:{play:"Reproducir",pause:"Pausa",replay:"Volver a reproducir",mute:"Silenciar",unmute:"Activar sonido",fullscreen:"Pantalla completa",exitFullscreen:"Salir de pantalla completa",pip:"Imagen en imagen",settings:"Velocidad de reproducción",subtitles:"Subtítulos",subtitlesOff:"Desactivados",speed:"Velocidad",quality:"Calidad",qualityAuto:"Automática",next:"Siguiente",previous:"Anterior",playlist:"Lista de reproducción",scenes:"Escenas",shuffle:"Aleatorio",repeat:"Repetir",like:"Me gusta",dislike:"No me gusta",addTo:"Guardar en…",share:"Compartir",report:"Denunciar",more:"Más acciones",seekForward:"Avanzar",seekBack:"Retroceder",live:"EN VIVO",related:"Más vídeos",adLabel:"Anuncio",skipAd:"Omitir anuncio",skipAdIn:"Omitir en",visitAdvertiser:"Visitar al anunciante",sponsored:"Patrocinado"},it:{play:"Riproduci",pause:"Pausa",replay:"Riproduci di nuovo",mute:"Disattiva audio",unmute:"Attiva audio",fullscreen:"Schermo intero",exitFullscreen:"Esci da schermo intero",pip:"Picture-in-picture",settings:"Velocità di riproduzione",subtitles:"Sottotitoli",subtitlesOff:"Disattivati",speed:"Velocità",quality:"Qualità",qualityAuto:"Automatica",next:"Successivo",previous:"Precedente",playlist:"Playlist",scenes:"Scene",shuffle:"Casuale",repeat:"Ripeti",like:"Mi piace",dislike:"Non mi piace",addTo:"Salva in…",share:"Condividi",report:"Segnala",more:"Altre azioni",seekForward:"Avanti veloce",seekBack:"Indietro",live:"LIVE",related:"Altri video",adLabel:"Annuncio",skipAd:"Salta annuncio",skipAdIn:"Salta tra",visitAdvertiser:"Visita l'inserzionista",sponsored:"Sponsorizzato"},ja:{play:"再生",pause:"一時停止",replay:"もう一度見る",mute:"ミュート",unmute:"ミュート解除",fullscreen:"全画面",exitFullscreen:"全画面を終了",pip:"ピクチャーインピクチャー",settings:"再生速度",subtitles:"字幕",subtitlesOff:"オフ",speed:"速度",quality:"画質",qualityAuto:"自動",next:"次へ",previous:"前へ",playlist:"プレイリスト",scenes:"シーン",shuffle:"シャッフル",repeat:"リピート",like:"高く評価",dislike:"低く評価",addTo:"保存…",share:"共有",report:"報告",more:"その他の操作",seekForward:"早送り",seekBack:"巻き戻し",live:"ライブ",related:"関連動画",adLabel:"広告",skipAd:"広告をスキップ",skipAdIn:"スキップまで",visitAdvertiser:"広告主のサイトへ",sponsored:"スポンサー"},ko:{play:"재생",pause:"일시정지",replay:"다시 보기",mute:"음소거",unmute:"음소거 해제",fullscreen:"전체화면",exitFullscreen:"전체화면 종료",pip:"PIP 모드",settings:"재생 속도",subtitles:"자막",subtitlesOff:"사용 안 함",speed:"속도",quality:"화질",qualityAuto:"자동",next:"다음",previous:"이전",playlist:"재생목록",scenes:"장면",shuffle:"셔플",repeat:"반복",like:"좋아요",dislike:"싫어요",addTo:"저장…",share:"공유",report:"신고",more:"더보기",seekForward:"앞으로 감기",seekBack:"뒤로 감기",live:"실시간",related:"관련 동영상",adLabel:"광고",skipAd:"광고 건너뛰기",skipAdIn:"건너뛰기까지",visitAdvertiser:"광고주 방문",sponsored:"스폰서"},zh:{play:"播放",pause:"暂停",replay:"重新播放",mute:"静音",unmute:"取消静音",fullscreen:"全屏",exitFullscreen:"退出全屏",pip:"画中画",settings:"播放速度",subtitles:"字幕",subtitlesOff:"关闭",speed:"速度",quality:"画质",qualityAuto:"自动",next:"下一个",previous:"上一个",playlist:"播放列表",scenes:"场景",shuffle:"随机播放",repeat:"循环播放",like:"赞",dislike:"踩",addTo:"保存到…",share:"分享",report:"举报",more:"更多操作",seekForward:"快进",seekBack:"快退",live:"直播",related:"更多视频",adLabel:"广告",skipAd:"跳过广告",skipAdIn:"可跳过",visitAdvertiser:"访问广告主",sponsored:"赞助"},pt:{play:"Reproduzir",pause:"Pausar",replay:"Assistir novamente",mute:"Sem som",unmute:"Ativar som",fullscreen:"Tela cheia",exitFullscreen:"Sair da tela cheia",pip:"Picture-in-picture",settings:"Velocidade de reprodução",subtitles:"Legendas",subtitlesOff:"Desativadas",speed:"Velocidade",quality:"Qualidade",qualityAuto:"Automática",next:"Próximo",previous:"Anterior",playlist:"Playlist",scenes:"Cenas",shuffle:"Aleatório",repeat:"Repetir",like:"Gostei",dislike:"Não gostei",addTo:"Salvar em…",share:"Compartilhar",report:"Denunciar",more:"Mais ações",seekForward:"Avançar",seekBack:"Retroceder",live:"AO VIVO",related:"Mais vídeos",adLabel:"Anúncio",skipAd:"Pular anúncio",skipAdIn:"Pular em",visitAdvertiser:"Visitar anunciante",sponsored:"Patrocinado"},ar:{play:"تشغيل",pause:"إيقاف مؤقت",replay:"إعادة التشغيل",mute:"كتم الصوت",unmute:"إلغاء كتم الصوت",fullscreen:"ملء الشاشة",exitFullscreen:"الخروج من ملء الشاشة",pip:"صورة داخل صورة",settings:"سرعة التشغيل",subtitles:"الترجمة",subtitlesOff:"إيقاف",speed:"السرعة",quality:"الجودة",qualityAuto:"تلقائي",next:"التالي",previous:"السابق",playlist:"قائمة التشغيل",scenes:"المشاهد",shuffle:"تشغيل عشوائي",repeat:"تكرار",like:"أعجبني",dislike:"لم يعجبني",addTo:"حفظ في…",share:"مشاركة",report:"إبلاغ",more:"المزيد من الإجراءات",seekForward:"تقديم",seekBack:"إرجاع",live:"مباشر",related:"المزيد من الفيديوهات",adLabel:"إعلان",skipAd:"تخطي الإعلان",skipAdIn:"التخطي بعد",visitAdvertiser:"زيارة المعلن",sponsored:"برعاية"},hi:{play:"चलाएं",pause:"रोकें",replay:"फिर से चलाएं",mute:"म्यूट करें",unmute:"अनम्यूट करें",fullscreen:"फ़ुल स्क्रीन",exitFullscreen:"फ़ुल स्क्रीन से बाहर निकलें",pip:"पिक्चर-इन-पिक्चर",settings:"प्लेबैक गति",subtitles:"सबटाइटल",subtitlesOff:"बंद",speed:"गति",quality:"क्वालिटी",qualityAuto:"ऑटो",next:"अगला",previous:"पिछला",playlist:"प्लेलिस्ट",scenes:"दृश्य",shuffle:"शफ़ल",repeat:"दोहराएं",like:"पसंद",dislike:"नापसंद",addTo:"इसमें सहेजें…",share:"साझा करें",report:"रिपोर्ट करें",more:"अधिक कार्रवाइयां",seekForward:"आगे बढ़ाएं",seekBack:"पीछे करें",live:"लाइव",related:"और वीडियो",adLabel:"विज्ञापन",skipAd:"विज्ञापन छोड़ें",skipAdIn:"छोड़ें",visitAdvertiser:"विज्ञापनदाता देखें",sponsored:"प्रायोजित"}}),we})();
|
|
5
5
|
//# sourceMappingURL=itube-modern-player.iife.js.map
|