/*!
* artplayer-plugin-hls-control.js v1.0.2
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"==typeof define&&define.amd?(t.ArtplayerPluginHlsControl=e(),define(function(){return t.ArtplayerPluginHlsControl})):(t="undefined"!==typeof globalThis?globalThis:t||self).ArtplayerPluginHlsControl=e()}(this,function(){"use strict";function t(t,e){const l=new Map;return t.filter(t=>{const n=t[e];return void 0===n||!l.has(n)&&l.set(n,1)})}function e(e={}){return l=>{const{$video:n}=l.template,{errorHandle:o}=l.constructor.utils;function i(){o(l.hls?.media===n,'Cannot find instance of HLS from "art.hls"'),function(n){if(!n.levels.length)return;const o=e.quality||{},i=o.auto||"Auto",s=o.title||"Quality",a=o.getName||(t=>t.name||`${t.height}P`),c=n.levels[n.currentLevel],r=c?a(c):i,u=t(n.levels.map((t,e)=>({html:a(t,e),value:e,default:n.currentLevel===e})),"html").sort((t,e)=>e.value-t.value);u.push({html:i,value:-1,default:-1===n.currentLevel});const d=t=>(n.currentLevel=t.value,l.notice.show=`${s}: ${t.html}`,o.control&&l.controls.check(t),o.setting&&l.setting.check(t),t.html);o.control&&l.controls.update({name:"hls-quality",position:"right",html:r,style:{padding:"0 10px"},selector:u,onSelect:d}),o.setting&&l.setting.update({name:"hls-quality",tooltip:r,html:s,icon:'',width:200,selector:u,onSelect:d})}(l.hls),function(n){if(!n.audioTracks.length)return;const o=e.audio||{},i=o.auto||"Auto",s=o.title||"Audio",a=o.getName||(t=>t.name||t.lang||t.language),c=n.audioTracks[n.audioTrack],r=c?a(c):i,u=t(n.audioTracks.map((t,e)=>({html:a(t,e),value:t.id,default:n.audioTrack===t.id})),"html"),d=t=>(n.audioTrack=t.value,l.notice.show=`${s}: ${t.html}`,o.control&&l.controls.check(t),o.setting&&l.setting.check(t),t.html);o.control&&l.controls.update({name:"hls-audio",position:"right",html:r,style:{padding:"0 10px"},selector:u,onSelect:d}),o.setting&&l.setting.update({name:"hls-audio",tooltip:r,html:s,icon:'',width:200,selector:u,onSelect:d})}(l.hls)}return l.on("ready",i),l.on("restart",i),{name:"artplayerPluginHlsControl",update:i}}}return"undefined"!==typeof window&&(window.artplayerPluginHlsControl=e),e});