/*! * artplayer.js v5.4.1 * 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.Artplayer=e(),define(function(){return t.Artplayer})):(t="undefined"!==typeof globalThis?globalThis:t||self).Artplayer=e()}(this,function(){"use strict";var t,e=Object.defineProperty,r=Object.defineProperties,o=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,r,o)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,l=(t,e)=>{for(var r in e||(e={}))a.call(e,r)&&s(t,r,e[r]);if(n)for(var r of n(e))i.call(e,r)&&s(t,r,e[r]);return t},c=(t,e)=>r(t,o(e)),d=(t,e,r)=>new Promise((o,n)=>{var a=t=>{try{s(r.next(t))}catch(e){n(e)}},i=t=>{try{s(r.throw(t))}catch(e){n(e)}},s=t=>t.done?o(t.value):Promise.resolve(t.value).then(a,i);s((r=r.apply(t,e)).next())});function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h,u={exports:{}};var m=(h||(h=1,u.exports=function(){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}var e=Object.prototype.toString,r=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var n=t(r);if("boolean"===n)return"boolean";if("string"===n)return"string";if("number"===n)return"number";if("symbol"===n)return"symbol";if("function"===n)return"GeneratorFunction"===o(r)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(r))return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(r))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(r))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(r))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(r))return"regexp";switch(o(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(r))return"generator";switch(n=e.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function o(t){return t.constructor?t.constructor.name:null}function n(t,e){var o=2=1,k=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(y)||x,$="undefined"!==typeof window&&"undefined"!==typeof document;function E(t,e=document){return e.querySelector(t)}function T(t,e=document){return Array.from(e.querySelectorAll(t))}function C(t,e){return t.classList.add(e)}function z(t,e){return t.classList.remove(e)}function L(t,e){return t.classList.contains(e)}function S(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function M(t){return t.parentNode.removeChild(t)}function A(t,e,r){return t.style[e]=r,t}function P(t,e){for(const r in e)A(t,r,e[r]);return t}function I(t){return Array.from(t.parentElement.children).filter(e=>e!==t)}function O(t,e){I(t).forEach(t=>z(t,e)),C(t,e)}function R(t,e,r="top"){k||(t.setAttribute("aria-label",e),C(t,"hint--rounded"),C(t,`hint--${r}`))}function _(t,e=0){const r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,n=window.innerWidth||document.documentElement.clientWidth,a=r.top-e<=o&&r.top+r.height+e>=0,i=r.left-e<=n+e&&r.left+r.width+e>=0;return a&&i}function V(t,e){return j(t).includes(e)}function Y(t,e){return e.parentNode.replaceChild(t,e),t}function D(t){return document.createElement(t)}function N(t="",e=""){const r=D("i");return C(r,"art-icon"),C(r,`art-icon-${t}`),S(r,e),r}function F(t,e){let r=document.getElementById(t);r||(r=document.createElement("style"),r.id=t,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(r)}):(document.head||document.documentElement).appendChild(r)),r.textContent=e}function H(){const t=document.createElement("div");return t.style.display="flex","flex"===t.style.display}function B(t){return t.getBoundingClientRect()}function W(t,e){return new Promise((r,o)=>{const n=new Image;n.onload=function(){if(e&&1!==e){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=n.width*e,a.height=n.height*e,i.drawImage(n,0,0,a.width,a.height),a.toBlob(e=>{const n=URL.createObjectURL(e),a=new Image;a.onload=function(){r(a)},a.onerror=function(){URL.revokeObjectURL(n),o(new Error(`Image load failed: ${t}`))},a.src=n})}else r(n)},n.onerror=function(){o(new Error(`Image load failed: ${t}`))},n.src=t})}function j(t){if(t.composedPath)return t.composedPath();const e=[];let r=t.target;for(;r;)e.push(r),r=r.parentNode;return e.includes(window)||void 0===window||e.push(window),e}function U(){const t=document.createElement("div");t.style.cssText="position:fixed;top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);pointer-events:none;visibility:hidden;",document.body.appendChild(t);const e=getComputedStyle(t),r={top:Number.parseFloat(e.top)||0,right:Number.parseFloat(e.right)||0,bottom:Number.parseFloat(e.bottom)||0,left:Number.parseFloat(e.left)||0};return t.remove(),r}class q extends Error{constructor(t,e){super(t),"captureStackTrace"in Error&&"function"===typeof Error.captureStackTrace&&Error.captureStackTrace(this,e||this.constructor),this.name="ArtPlayerError"}}function X(t,e){if(!t)throw new q(e);return t}function G(t){const e=t;return e&&"function"===typeof e.catch?e.catch(()=>{}):t}function K(t){const e=t.search(/[?#]/),r=(e<0?t:t.slice(0,e)).trim().toLowerCase();return r.slice(r.lastIndexOf(".")+1)}function Z(t,e){const r=document.createElement("a");r.style.display="none",r.href=t,r.download=e,document.body.appendChild(r);try{r.click()}finally{r.remove()}}function J(t,e,r){return Math.max(Math.min(t,Math.max(e,r)),Math.min(e,r))}function Q(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tt(t){if(!t)return"00:00";const e=Math.floor(t/3600),r=Math.floor((t-3600*e)/60),o=Math.floor(t-3600*e-60*r);return(e>0?[e,r,o]:[r,o]).map(t=>t<10?`0${t}`:String(t)).join(":")}const et={"&":"&","<":"<",">":">","'":"'",'"':"""},rt={"&":"&","<":"<",">":">","'":"'",""":'"'},ot=/(&|<|>|'|")/g;function nt(t){return t.replace(/[&<>'"]/g,t=>et[t]||t)}const at=Object.defineProperty,{hasOwnProperty:it}=Object.prototype;function st(t,e){return it.call(t,e)}function lt(t,e){return Object.getOwnPropertyDescriptor(t,e)}function ct(...t){const e=t=>!!t&&"object"===typeof t&&!Array.isArray(t);return t.reduce((t,r)=>(Object.keys(r).forEach(o=>{const n=t[o],a=r[o];let i;i=Array.isArray(n)&&Array.isArray(a)?n.concat(...a):e(n)&&e(a)?ct(n,a):a,at(t,o,{value:i,enumerable:!0,configurable:!0,writable:!0})}),t),{})}function dt(t){return"WEBVTT \r\n\r\n".concat((e=t,e.replace(/(\d\d:\d\d:\d\d)[,.](\d+)/g,(t,e,r)=>{let o=r.slice(0,3);return 1===r.length&&(o=`${r}00`),2===r.length&&(o=`${r}0`),`${e},${o}`})).replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").replace(/\{[\s\S]*?\}/g,"").concat("\r\n\r\n"));var e}function pt(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function ht(t){const e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function r(t=""){return t.split(/[:.]/).map((t,e,r)=>{if(e===r.length-1){if(1===t.length)return`.${t}00`;if(2===t.length)return`.${t}0`}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===r.length-1?`.${t}`:`:${t}`}).join("")}return`WEBVTT\n\n${t.split(/\r?\n/).map(t=>{const o=t.match(e);if(!o)return null;const[,n="",a="",,,i=""]=o;return{start:r(n.trim()),end:r(a.trim()),text:i.replace(/\{[\s\S]*?\}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map(t=>t.trim()).join("\n")}}).filter(t=>t).map((t,e)=>t?`${e+1}\n${t.start} --\x3e ${t.end}\n${t.text}`:"").filter(t=>t.trim()).join("\n\n")}`}function ut(t,e){let r=!1;return function(...o){r||(t.apply(this,o),r=!0,setTimeout(()=>{r=!1},e))}}const mt=Object.freeze(Object.defineProperty({__proto__:null,ArtPlayerError:q,addClass:C,append:S,assToVtt:ht,capitalize:Q,clamp:J,createElement:D,debounce:function(t,e){let r;return function(...o){clearTimeout(r),r=setTimeout(()=>(r=void 0,t.apply(this,o)),e)}},def:at,download:Z,errorHandle:X,escape:nt,get:lt,getComposedPath:j,getExt:K,getIcon:N,getRect:B,getSafeAreaInsets:U,getStyle:function(t,e,r=!0){const o=window.getComputedStyle(t,null).getPropertyValue(e);return r?Number.parseFloat(o):o},has:st,hasClass:L,includeFromEvent:V,inverseClass:O,isBrowser:$,isIOS:w,isIOS13:x,isInViewport:_,isMobile:k,isSafari:b,loadImg:W,mergeDeep:ct,query:E,queryAll:T,remove:M,removeClass:z,replaceElement:Y,secondToTime:tt,setStyle:A,setStyleText:F,setStyles:P,siblings:I,silencePromise:G,sleep:function(t=0){return new Promise(e=>setTimeout(e,t))},srtToVtt:dt,supportsFlex:H,throttle:ut,tooltip:R,unescape:function(t){return t.replace(ot,t=>rt[t]||t)},userAgent:y,vttToBlob:pt},Symbol.toStringTag,{value:"Module"})),ft="array",gt="boolean",vt="string",yt="number",bt="object",wt="function";function xt(t,e,r){return X(e===vt||e===yt||t instanceof Element,`${r.join(".")} require '${vt}' or 'Element' type`)}const kt={html:xt,disable:`?${gt}`,name:`?${vt}`,index:`?${yt}`,style:`?${bt}`,click:`?${wt}`,mounted:`?${wt}`,tooltip:`?${vt}|${yt}`,width:`?${yt}`,selector:`?${ft}`,onSelect:`?${wt}`,switch:`?${gt}`,onSwitch:`?${wt}`,range:`?${ft}`,onRange:`?${wt}`,onChange:`?${wt}`},$t={id:vt,container:xt,url:vt,poster:vt,type:vt,theme:vt,lang:vt,volume:yt,isLive:gt,muted:gt,autoplay:gt,autoSize:gt,autoMini:gt,loop:gt,flip:gt,playbackRate:gt,aspectRatio:gt,screenshot:gt,setting:gt,hotkey:gt,pip:gt,mutex:gt,backdrop:gt,fullscreen:gt,fullscreenWeb:gt,subtitleOffset:gt,miniProgressBar:gt,useSSR:gt,playsInline:gt,lock:gt,gesture:gt,fastForward:gt,autoPlayback:gt,autoOrientation:gt,airplay:gt,proxy:`?${wt}`,plugins:[wt],layers:[kt],contextmenu:[kt],settings:[kt],controls:[c(l({},kt),{position:(t,e,r)=>{const o=["top","left","right"];return X("string"===typeof t&&o.includes(t),`${r.join(".")} only accept ${o.toString()} as parameters`)}})],quality:[{default:`?${gt}`,html:vt,url:vt}],highlight:[{time:yt,text:vt}],thumbnails:{url:vt,number:yt,column:yt,width:yt,height:yt,scale:yt},subtitle:{url:vt,name:vt,type:vt,style:bt,escape:gt,encoding:vt,onVttLoad:wt},moreVideoAttr:bt,i18n:bt,icons:bt,cssVar:bt,customType:bt};class Et{constructor(t){this.id=0,this.art=t,this.cache=new Map,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.update=this.update.bind(this)}get show(){return L(this.art.template.$player,`art-${this.name}-show`)}set show(t){const{$player:e}=this.art.template,r=`art-${this.name}-show`;t?C(e,r):z(e,r),this.art.emit(this.name,t)}toggle(){this.show=!this.show}add(t){const e="function"===typeof t?t(this.art):t;if(e.html=e.html||"",f(e,kt),!this.$parent||!this.name||e.disable)return;const r=e.name||`${this.name}${this.id}`;X(!this.cache.has(r),`Can't add an existing [${r}] to the [${this.name}]`),this.id+=1;const o=D("div");C(o,`art-${this.name}`),C(o,`art-${this.name}-${r}`);const n=Array.from(this.$parent.children);o.dataset.index=e.index||this.id;const a=n.find(t=>Number(t.dataset.index)>=Number(o.dataset.index));a?a.insertAdjacentElement("beforebegin",o):S(this.$parent,o),e.html&&S(o,e.html),e.style&&P(o,e.style),e.tooltip&&R(o,e.tooltip);const i=[];if(e.click){const t=this.art.events.proxy(o,"click",t=>{t.preventDefault(),e.click.call(this.art,this,t)});i.push(t)}return e.selector&&["left","right"].includes(e.position)&&this.selector(e,o,i),this[r]=o,this.cache.set(r,{$ref:o,events:i,option:e}),e.mounted&&e.mounted.call(this.art,o),o}remove(t){X(this.cache.has(t),`Can't find [${t}] from the [${this.name}]`);const e=this.cache.get(t);e.option.beforeUnmount&&e.option.beforeUnmount.call(this.art,e.$ref);for(const r of e.events)this.art.events.remove(r);this.cache.delete(t),delete this[t],M(e.$ref)}update(t){if(this.cache.has(t.name)){const e=this.cache.get(t.name);t=Object.assign(e.option,t),this.remove(t.name)}return this.add(t)}}class Tt extends Et{constructor(t){super(t),this.name="contextmenu",this.$parent=t.template.$contextmenu,k||this.init()}init(){const{option:t,proxy:e,template:{$player:r,$contextmenu:o}}=this.art;t.playbackRate&&this.add(function(t){return e=>{const{i18n:r,constructor:{PLAYBACK_RATE:o}}=e,n=o.map(t=>`${1===t?r.get("Normal"):t.toFixed(1)}`).join("");return c(l({},t),{html:`${r.get("Play Speed")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.playbackRate=Number(o),t.show=!1)},mounted:t=>{const r=E('[data-value="1"]',t);r&&O(r,"art-current"),e.on("video:ratechange",()=>{const r=T("span",t).find(t=>Number(t.dataset.value)===e.playbackRate);r&&O(r,"art-current")})}})}}({name:"playbackRate",index:10})),t.aspectRatio&&this.add(function(t){return e=>{const{i18n:r,constructor:{ASPECT_RATIO:o}}=e,n=o.map(t=>`${"default"===t?r.get("Default"):t}`).join("");return c(l({},t),{html:`${r.get("Aspect Ratio")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.aspectRatio=o,t.show=!1)},mounted:t=>{const r=E('[data-value="default"]',t);r&&O(r,"art-current"),e.on("aspectRatio",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"aspectRatio",index:20})),t.flip&&this.add(function(t){return e=>{const{i18n:r,constructor:{FLIP:o}}=e,n=o.map(t=>`${r.get(Q(t))}`).join("");return c(l({},t),{html:`${r.get("Video Flip")}: ${n}`,click:(t,r)=>{const{value:o}=r.target.dataset;o&&(e.flip=o.toLowerCase(),t.show=!1)},mounted:t=>{const r=E('[data-value="normal"]',t);r&&O(r,"art-current"),e.on("flip",e=>{const r=T("span",t).find(t=>t.dataset.value===e);r&&O(r,"art-current")})}})}}({name:"flip",index:30})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Video Info"),click:t=>{e.info.show=!0,t.show=!1}})}({name:"info",index:40})),this.add(function(t){return c(l({},t),{html:`ArtPlayer ${g}`})}({name:"version",index:50})),this.add(function(t){return e=>c(l({},t),{html:e.i18n.get("Close"),click:t=>{t.show=!1}})}({name:"close",index:60}));for(let n=0;n{if(!this.art.constructor.CONTEXTMENU)return;t.preventDefault(),this.show=!0;const e=t.clientX,n=t.clientY,{height:a,width:i,left:s,top:l}=B(r),{height:c,width:d}=B(o);let p=e-s,h=n-l;e+d>s+i&&(p=i-d),n+c>l+a&&(h=a-c),P(o,{top:`${h}px`,left:`${p}px`})}),e(r,"click",t=>{V(t,o)||(this.show=!1)}),this.art.on("blur",()=>{this.show=!1})}}class Ct extends Error{constructor(t){super("Failed to release ArtPlayer resources"),this.errors=t,this.name="ResourceCleanupError"}}class zt{constructor(){this.cleanups=new Set,this.disposed=!1}get closed(){return this.disposed}add(t){let e=!0;const r=()=>{e&&(e=!1,this.cleanups.delete(r),t())};return this.closed?r():this.cleanups.add(r),r}child(){const t=new zt,e=this.add(()=>{t.dispose()});return t.add(()=>{e()}),t}dispose(){if(this.closed)return;this.disposed=!0;const t=[];for(const r of Array.from(this.cleanups).reverse())try{r()}catch(e){e instanceof Ct?t.push(...e.errors):t.push(e)}if(t.length)throw new Ct(t)}}const Lt=new WeakMap,St=new WeakMap;function Mt(t){const e=Lt.get(t);if(!e)throw new Error("ArtPlayer lifecycle has not been initialized");return e}function At(t){return Mt(t).scope}function Pt(t){const e=Mt(t);return e.destroying||e.scope.closed}function It(t,e,r,o,n=!1){var a,i,s;const l=Mt(t);if(l.destroying||l.scope.closed)return;l.destroying=!0;const c=[],d=t=>{try{t()}catch(e){c.push(...e instanceof Ct?e.errors:[e])}};o&&(null==(a=t.template)?void 0:a.$video)&&d(()=>t.reset()),d(()=>l.scope.dispose()),d(()=>{var e;return null==(e=t.template)?void 0:e.destroy(r)});const p=e.indexOf(t);-1!==p&&e.splice(p,1),t.isDestroy=!0,n||(null==(i=l.releaseContainer)||i.call(l),l.releaseContainer=void 0),d(()=>t.emit("destroy")),n&&l.rollback&&d(l.rollback),l.rollback=void 0,null==(s=l.releaseContainer)||s.call(l),l.releaseContainer=void 0;for(const h of c.slice(1))console.warn("Additional ArtPlayer cleanup failure:",h);if(c.length)throw c[0]}function Ot(t,e,r){if(t.closed)return()=>{};let o=!0,n=()=>{};const a=setTimeout(()=>{o&&(n(),t.closed||e())},r);return n=t.add(()=>{o=!1,clearTimeout(a)}),n}function Rt(t,e=0){return t.closed?Promise.resolve(!1):new Promise(r=>{let o=!1,n=()=>{};const a=setTimeout(()=>{o=!0,n(),r(!0)},e);n=t.add(()=>{clearTimeout(a),o||r(!1)})})}function _t(t,e){const{$progress:r}=t.template,{left:o}=B(r),n=J((k?e.touches[0].clientX:e.clientX)-o,0,r.clientWidth),a=n/r.clientWidth*t.duration;return{second:a,time:tt(a),width:n,percentage:J(n/r.clientWidth,0,1)}}function Vt(t,e){if(t.isRotate){const r=(e.touches[0].clientY-t.top)/t.height,o=r*t.duration;t.emit("setBar","played",r,e),t.seek=o}else{const{second:r,percentage:o}=_t(t,e);t.emit("setBar","played",o,e),t.seek=r}}function Yt(t){return e=>{const{icons:r,option:o,proxy:n}=e,{$player:a,$progress:i}=e.template;return c(l({},t),{html:'\n
\n
\n
\n
\n
\n
\n
00:00
\n
\n ',mounted:t=>{let s=null,l=!1;const c=E(".art-progress-hover",t),d=E(".art-progress-loaded",t),p=E(".art-progress-played",t),h=E(".art-progress-highlight",t),u=E(".art-progress-indicator",t),m=E(".art-progress-tip",t);function f(r,o){const{width:n,time:a}=o||_t(e,r);m.textContent=a||"00:00";const i=m.clientWidth;n<=i/2?A(m,"left",0):n>t.clientWidth-i/2?A(m,"left",t.clientWidth-i+"px"):A(m,"left",n-i/2+"px")}r.indicator?S(u,r.indicator):A(u,"backgroundColor","var(--art-theme)"),e.on("setBar",function(r,o,n){const i="played"===r&&n&&k;if("loaded"===r&&A(d,"width",100*o+"%"),"hover"===r&&(A(c,"width",100*o+"%"),V(n,h)?function(r){const{width:o}=_t(e,r),{text:n}=r.target.dataset;m.textContent=n;const a=m.clientWidth;o<=a/2?A(m,"left",0):o>t.clientWidth-a/2?A(m,"left",t.clientWidth-a+"px"):A(m,"left",o-a/2+"px")}(n):f(n),0===o?z(a,"art-progress-hover"):C(a,"art-progress-hover")),"played"===r&&(A(p,"width",100*o+"%"),A(u,"left",100*o+"%")),i){C(a,"art-progress-hover");f(n,{width:t.clientWidth*o,time:tt(o*e.duration)}),clearTimeout(s),s=setTimeout(()=>{z(a,"art-progress-hover")},500)}}),e.on("video:loadedmetadata",function(){h.textContent="";for(let t=0;t`;S(h,a)}}),e.constructor.USE_RAF?e.on("raf",()=>{e.emit("setBar","played",e.played),e.emit("setBar","loaded",e.loaded)}):(e.on("video:timeupdate",()=>{e.emit("setBar","played",e.played)}),e.on("video:progress",()=>{e.emit("setBar","loaded",e.loaded)}),e.on("video:ended",()=>{e.emit("setBar","played",1)})),e.emit("setBar","loaded",e.loaded||0),k||(n(i,"click",t=>{t.target!==u&&Vt(e,t)}),n(i,"mousemove",t=>{const{percentage:r}=_t(e,t);e.emit("setBar","hover",r,t)}),n(i,"mouseleave",t=>{e.emit("setBar","hover",0,t)}),n(i,"mousedown",t=>{l=0===t.button}),e.on("document:mousemove",t=>{if(l){const{second:r,percentage:o}=_t(e,t);e.emit("setBar","played",o,t),e.seek=r}}),e.on("document:mouseup",()=>{l&&(l=!1)}))}})}}class Dt extends Et{constructor(t){super(t),this.isHover=!1,this.name="control",this.timer=Date.now();const{constructor:e}=t,{$player:r,$bottom:o}=this.art.template;t.on("mousemove",()=>{k||(this.show=!0)}),t.on("click",()=>{k?this.toggle():this.show=!0}),t.on("document:mousemove",t=>{this.isHover=V(t,o)}),t.on("video:timeupdate",()=>{!t.setting.show&&!this.isHover&&!t.isInput&&t.playing&&this.show&&Date.now()-this.timer>=e.CONTROL_HIDE_TIME&&(this.show=!1)}),t.on("control",t=>{t?(z(r,"art-hide-cursor"),C(r,"art-hover"),this.timer=Date.now()):(C(r,"art-hide-cursor"),z(r,"art-hover"))}),this.init()}init(){const{option:t}=this.art;t.isLive||this.add(Yt({name:"progress",position:"top",index:10})),this.add({name:"thumbnails",position:"top",index:20}),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.play),i=S(t,o.pause);function s(){A(a,"display","flex"),A(i,"display","none")}function l(){A(a,"display","none"),A(i,"display","flex")}R(a,n.get("Play")),R(i,n.get("Pause")),r(a,"click",()=>{G(e.play())}),r(i,"click",()=>{e.pause()}),e.playing?l():s(),e.on("video:playing",()=>{l()}),e.on("video:pause",()=>{s()})}})}({name:"playAndPause",position:"left",index:10})),this.add(function(t){return e=>c(l({},t),{mounted:t=>{const{proxy:r,icons:o}=e,n=S(t,o.volume),a=S(t,o.volumeClose),i=S(t,'
'),s=S(i,'
'),l=S(s,'
'),c=S(s,'
'),d=S(c,'
'),p=S(d,'
'),h=S(c,'
');function u(t){const{top:e,height:r}=B(c);return 1-(t.clientY-e)/r}function m(){if(e.muted||0===e.volume)A(n,"display","none"),A(a,"display","flex"),A(h,"top","100%"),A(p,"top","100%"),l.textContent=0;else{const t=100*e.volume;A(n,"display","flex"),A(a,"display","none"),A(h,"top",100-t+"%"),A(p,"top",100-t+"%"),l.textContent=Math.floor(t)}}if(m(),e.on("video:volumechange",m),r(n,"click",()=>{e.muted=!0}),r(a,"click",()=>{e.muted=!1}),k)A(i,"display","none");else{let t=!1;r(c,"mousedown",r=>{t=0===r.button,e.volume=u(r)}),e.on("document:mousemove",r=>{t&&(e.muted=!1,e.volume=u(r))}),e.on("document:mouseup",()=>{t&&(t=!1)})}}})}({name:"volume",position:"left",index:20})),t.isLive||this.add(function(t){return e=>c(l({},t),{style:k?{fontSize:"12px",padding:"0 5px"}:{cursor:"auto",padding:"0 10px"},mounted:t=>{function r(){const r=`${tt(e.currentTime)} / ${tt(e.duration)}`;r!==t.textContent&&(t.textContent=r)}r();const o=["video:loadedmetadata","video:timeupdate","video:progress"];for(let n=0;n{e&&!At(this.art).closed&&(this.art.quality=t.quality)}),t.screenshot&&!k&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Screenshot"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.screenshot),r(t,"click",()=>{e.screenshot()})}})}({name:"screenshot",position:"right",index:20})),t.setting&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Show Setting"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e;S(t,o.setting),r(t,"click",()=>{e.setting.toggle(),e.setting.resize()}),e.on("setting",e=>{R(t,n.get(e?"Hide Setting":"Show Setting"))})}})}({name:"setting",position:"right",index:30})),t.pip&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("PIP Mode"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e;S(t,o.pip),r(t,"click",()=>{e.pip=!e.pip}),e.on("pip",e=>{R(t,n.get(e?"Exit PIP Mode":"PIP Mode"))})}})}({name:"pip",position:"right",index:40})),t.airplay&&window.WebKitPlaybackTargetAvailabilityEvent&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("AirPlay"),mounted:t=>{const{proxy:r,icons:o}=e;S(t,o.airplay),r(t,"click",()=>e.airplay())}})}({name:"airplay",position:"right",index:50})),t.fullscreenWeb&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Web Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.fullscreenWebOn),i=S(t,o.fullscreenWebOff);A(i,"display","none"),r(t,"click",()=>{e.fullscreenWeb=!e.fullscreenWeb}),e.on("fullscreenWeb",e=>{e?(R(t,n.get("Exit Web Fullscreen")),A(a,"display","none"),A(i,"display","inline-flex")):(R(t,n.get("Web Fullscreen")),A(a,"display","inline-flex"),A(i,"display","none"))})}})}({name:"fullscreenWeb",position:"right",index:60})),t.fullscreen&&this.add(function(t){return e=>c(l({},t),{tooltip:e.i18n.get("Fullscreen"),mounted:t=>{const{proxy:r,icons:o,i18n:n}=e,a=S(t,o.fullscreenOn),i=S(t,o.fullscreenOff);A(i,"display","none"),r(t,"click",()=>{e.fullscreen=!e.fullscreen}),e.on("fullscreen",e=>{e?(R(t,n.get("Exit Fullscreen")),A(a,"display","none"),A(i,"display","inline-flex")):(R(t,n.get("Fullscreen")),A(a,"display","inline-flex"),A(i,"display","none"))})}})}({name:"fullscreen",position:"right",index:70}));for(let e=0;et.selector}),at(e,"$control_item",{get:()=>r}),at(e,"$control_value",{get:()=>n})}const i=o(a,"click",e=>d(this,null,function*(){const r=j(e),o=t.selector.find(t=>t.$control_item===r.find(e=>t.$control_item===e));this.check(o),t.onSelect&&(n.innerHTML=yield t.onSelect.call(this.art,o,o.$control_item,e))}));r.push(i)}}function Nt(t,e,r,o){const n=e-o,a=r-t;let i=0;if(Math.abs(a)<2&&Math.abs(n)<2)return i;const s=function(t,e){return 180*Math.atan2(e,t)/Math.PI}(a,n);return s>=-45&&s<45?i=4:s>=45&&s<135?i=1:s>=-135&&s<-45?i=2:(s>=135&&s<=180||s>=-180&&s<-135)&&(i=3),i}function Ft(t){if(t.constructor.USE_RAF){const e=At(t);let r=()=>{};!function o(){t.playing&&t.emit("raf"),t.isDestroy||(r=function(t,e){if(t.closed)return()=>{};let r=!0,o=()=>{};const n=requestAnimationFrame(n=>{r&&(o(),t.closed||e(n))});return o=t.add(()=>{r=!1,cancelAnimationFrame(n)}),o}(e,o))}(),t.on("destroy",()=>{r()})}}const Ht=new WeakMap;class Bt{constructor(t){this.destroyEvents=new Set;const e=At(t);Ht.set(this,e),e.add(()=>this.destroy()),this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),function(t,e){const{constructor:r,template:{$player:o,$video:n}}=t;function a(e){V(e,o)?(t.isInput="INPUT"===e.target.tagName,t.isFocus=!0,t.emit("focus",e)):(t.isInput=!1,t.isFocus=!1,t.emit("blur",e))}t.on("document:click",a),t.on("document:contextmenu",a);let i=[];e.proxy(n,"click",e=>{const o=Date.now();i.push(o);const{MOBILE_CLICK_PLAY:n,DBCLICK_TIME:a,MOBILE_DBCLICK_PLAY:s,DBCLICK_FULLSCREEN:l}=r,c=i.filter(t=>o-t<=a);switch(c.length){case 1:t.emit("click",e),k?!t.isLock&&n&&G(t.toggle()):G(t.toggle()),i=c;break;case 2:t.emit("dblclick",e),k?!t.isLock&&s&&G(t.toggle()):l&&(t.fullscreen=!t.fullscreen),i=[];break;default:i=[]}})}(t,this),function(t,e){const{$player:r}=t.template;e.hover(r,e=>{C(r,"art-hover"),t.emit("hover",!0,e)},e=>{z(r,"art-hover"),t.emit("hover",!1,e)})}(t,this),function(t,e){const{$player:r}=t.template;e.proxy(r,"mousemove",e=>{t.emit("mousemove",e)})}(t,this),function(t,e){const{option:r,constructor:o}=t;t.on("resize",()=>{const{aspectRatio:e,notice:o}=t;"standard"===t.state&&r.autoSize&&t.autoSize(),t.aspectRatio=e,o.show=""});const n=At(t);let a=()=>{};const i=()=>{a(),a=Ot(n,()=>t.emit("resize"),o.RESIZE_TIME)};t.on("window:orientationchange",()=>i()),t.on("window:resize",()=>i()),screen&&screen.orientation&&screen.orientation.onchange&&e.proxy(screen.orientation,"change",()=>i())}(t,this),function(t,e){if(k&&!t.option.isLive){const{$video:r,$progress:o}=t.template;let n=null,a=!1,i=0,s=0,l=0;const c=e=>{if(1===e.touches.length&&!t.isLock){n===o&&Vt(t,e),a=!0;const{pageX:r,pageY:c}=e.touches[0];i=r,s=c,l=t.currentTime}},d=e=>{if(1===e.touches.length&&a&&t.duration){const{pageX:o,pageY:a}=e.touches[0],c=Nt(i,s,o,a),d=[3,4].includes(c),p=[1,2].includes(c);if(d&&!t.isRotate||p&&t.isRotate){const c=J((o-i)/t.width,-1,1),d=J((a-s)/t.height,-1,1),p=t.isRotate?d:c,h=n===r?t.constructor.TOUCH_MOVE_RATIO:1,u=J(l+t.duration*p*h,0,t.duration);t.seek=u,t.emit("setBar","played",J(u/t.duration,0,1),e),t.notice.show=`${tt(u)} / ${tt(t.duration)}`}}},p=()=>{a&&(i=0,s=0,l=0,a=!1,n=null)};t.option.gesture&&(e.proxy(r,"touchstart",t=>{n=r,c(t)}),e.proxy(r,"touchmove",d)),e.proxy(o,"touchstart",t=>{n=o,c(t)}),e.proxy(o,"touchmove",d),t.on("document:touchend",p)}}(t,this),function(t){const{option:e,constructor:r,template:{$container:o}}=t,n=ut(()=>{t.emit("view",_(o,r.SCROLL_GAP))},r.SCROLL_TIME);t.on("window:scroll",()=>n()),t.on("view",r=>{e.autoMini&&(t.mini=!r)})}(t),function(t,e){const r=["click","mouseup","keydown","touchend","touchmove","mousemove","pointerup","contextmenu","pointermove","visibilitychange","webkitfullscreenchange"],o=["resize","scroll","orientationchange"],n=[];function a(a={}){for(let t=0;t{const o=a.document||i.ownerDocument||document,s=e.proxy(o,r,e=>{t.emit(`document:${r}`,e)});n.push(s)}),o.forEach(r=>{var o;const s=a.window||(null==(o=i.ownerDocument)?void 0:o.defaultView)||window,l=e.proxy(s,r,e=>{t.emit(`window:${r}`,e)});n.push(l)})}a(),e.bindGlobalEvents=a}(t,this),Ft(t)}proxy(t,e,r,o={}){if(Array.isArray(e))return e.map(e=>this.proxy(t,e,r,o));if(Ht.get(this).closed)return()=>{};t.addEventListener(e,r,o);const n=()=>t.removeEventListener(e,r,o);return this.destroyEvents.add(n),n}hover(t,e,r){e&&this.proxy(t,"mouseenter",e),r&&this.proxy(t,"mouseleave",r)}remove(t){if(this.destroyEvents.has(t))try{t()}catch(e){console.warn("Failed to remove event listener:",e)}finally{this.destroyEvents.delete(t)}}destroy(){for(const e of this.destroyEvents)try{e()}catch(t){console.warn("Failed to destroy event listener:",t)}this.destroyEvents.clear()}}class Wt{constructor(t){this.art=t,this.keys={},k||this.init()}init(){const{constructor:t}=this.art;this.art.option.hotkey&&(this.add("Escape",()=>{this.art.fullscreenWeb&&(this.art.fullscreenWeb=!1)}),this.add("Space",()=>{G(this.art.toggle())}),this.add("ArrowLeft",()=>{this.art.backward=t.SEEK_STEP}),this.add("ArrowUp",()=>{this.art.volume+=t.VOLUME_STEP}),this.add("ArrowRight",()=>{this.art.forward=t.SEEK_STEP}),this.add("ArrowDown",()=>{this.art.volume-=t.VOLUME_STEP})),this.art.on("document:keydown",t=>{if(this.art.isFocus){const e=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==r&&"true"!==r&&!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey){const e=this.keys[t.code];if(e){t.preventDefault();for(let r=0;r\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n',state:'\r\n\r\n\r\n',play:'\r\n \r\n',pause:'\r\n \r\n',check:'\r\n\r\n',volume:'\r\n \r\n \r\n',volumeClose:'\r\n \r\n \r\n',screenshot:'\r\n\t\r\n\r\n',setting:'\r\n \r\n \r\n',pip:'\r\n\r\n',arrowLeft:'\r\n \r\n',arrowRight:'\r\n \r\n',playbackRate:'',aspectRatio:'',config:'',lock:'\r\n\r\n\r\n\r\n\r\n',flip:'\r\n\r\n\r\n\r\n\r\n\r\n',unlock:'\r\n\r\n\r\n',fullscreenOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenOn:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOff:'\r\n\r\n\r\n\r\n\r\n',fullscreenWebOn:'\r\n\r\n\r\n\r\n\r\n',switchOn:'\r\n\r\n\r\n \r\n',switchOff:'\r\n\r\n\r\n \r\n\r\n',error:'\r\n\r\n\r\n\r\n\r\n',close:'\r\n\r\n\r\n\r\n\r\n',airplay:'\r\n \r\n \r\n \r\n \r\n\r\n'},t.option.icons);for(const r in e)at(this,r,{get:()=>N(r,e[r])})}}class Xt extends Et{constructor(t){super(t),this.name="info",k||this.init()}init(){const{proxy:t,constructor:e,template:{$infoPanel:r,$infoClose:o,$video:n}}=this.art;t(o,"click",()=>{this.show=!1});let a=()=>{};const i=T("[data-video]",r)||[];this.art.on("destroy",()=>a());const s=At(this.art);!function t(){for(let e=0;e{A(n,"display","none"),A(a,"display",null)}),o.proxy(e.$state,"click",()=>G(t.play()))}}class Jt{constructor(t){this.art=t,this.timer=null,At(t).add(()=>this.destroy()),t.on("destroy",()=>this.destroy())}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}set show(t){if(At(this.art).closed)return;const{constructor:e,template:{$player:r,$noticeInner:o}}=this.art;t?(o.textContent=t instanceof Error?t.message.trim():t,C(r,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout(()=>{o.textContent="",z(r,"art-notice-show")},e.NOTICE_TIME)):z(r,"art-notice-show")}get show(){const{template:{$player:t}}=this.art;return t.classList.contains("art-notice-show")}}function Qt(t,e,r,o=!1){const n=e=>{Pt(t)||r(e)};t[o?"once":"on"](e,n),At(t).add(()=>{t.off(e,n)})}function te(t,e,r){for(const[o,n]of e){if(Pt(t)||r&&!r())return;t[o].show=n}}const ee=new WeakMap,re=new WeakMap,oe=new WeakMap;function ne(t){return oe.get(t)||At(t)}function ae(t){const e=ee.get(t),r=oe.get(t);return()=>ee.get(t)===e&&(!e||e.active())&&oe.get(t)===r&&(!r||!r.closed)}function ie(t){const e=oe.get(t),r=At(t).child(),o=r.child();oe.set(t,r),r.add(()=>{oe.get(t)===r&&oe.delete(t)});const n={scope:o,assigned:!1,acceptingEvents:!1,active:()=>!Pt(t)&&!o.closed&&ee.get(t)===n};return ee.set(t,n),o.add(()=>{ee.get(t)===n&&ee.delete(t),n.onAssigned=void 0,n.onError=void 0}),null==e||e.dispose(),n}function se(t){t.assigned=!0;const e=t.onAssigned;t.onAssigned=void 0,t.active()&&(null==e||e())}function le(t,e,r){re.set(t,e),e.acceptingEvents=!0;try{t.url=r}finally{re.get(t)===e&&(re.delete(t),se(e))}}function ce(t,e){t.active()&&(t.onError?t.onError(e):console.warn("Failed to initialize ArtPlayer source:",e),t.scope.dispose())}function de(t){const{option:e,constructor:r,i18n:o,notice:n,template:{$player:a}}=t;let i,s=ne(t),l=0;return{reset(){l=0,null==i||i.dispose(),z(a,"art-error")},loadStart(){z(a,"art-error")},schedule(c){(c=>d(null,null,function*(){if(Pt(t))return;const d=ne(t);if(d!==s&&(s=d,l=0),i&&!i.closed)return;const p=d.child();i=p,p.add(()=>{i===p&&(i=void 0)});const h=()=>!Pt(t)&&!p.closed&&d===ne(t),u=l{console.warn("ArtPlayer reconnect failed:",t)})}}}function pe(t){!function(t){const{proxy:e,template:{$video:r}}=t;for(let o=0;o{Pt(t)||t.emit(`video:${e.type}`,e)})}(t);const e=de(t);!function(t,e){Qt(t,"video:canplay",()=>{e.reset(),te(t,[["loading",!1]])}),Qt(t,"video:canplay",()=>{te(t,[["loading",!1],["controls",!0],["mask",!0]]),Pt(t)||(t.isReady=!0,t.emit("ready"))},!0)}(t,e),function(t){const{option:e}=t;Qt(t,"video:ended",()=>{if(e.loop){const e=ae(t);if(t.seek=0,Pt(t)||!e())return;G(t.play()),e()&&te(t,[["controls",!1],["mask",!1]],e)}else te(t,[["controls",!0],["mask",!0]])})}(t),Qt(t,"video:error",e.schedule),function(t,e){const{template:{$poster:r}}=t;Qt(t,"video:loadedmetadata",()=>{t.emit("resize"),k&&te(t,[["loading",!1],["controls",!0],["mask",!0]])}),Qt(t,"video:loadstart",()=>{e.loadStart(),te(t,[["loading",!0],["mask",!1],["controls",!0]])}),Qt(t,"video:pause",()=>{te(t,[["controls",!0],["mask",!0]])}),Qt(t,"video:play",()=>{te(t,[["mask",!1]]),Pt(t)||A(r,"display","none")}),Qt(t,"video:playing",()=>te(t,[["mask",!1]])),Qt(t,"video:progress",()=>{t.playing&&te(t,[["loading",!1]])}),Qt(t,"video:seeked",()=>te(t,[["loading",!1],["mask",!0]])),Qt(t,"video:seeking",()=>te(t,[["loading",!0],["mask",!1]])),Qt(t,"video:timeupdate",()=>te(t,[["mask",!1]])),Qt(t,"video:waiting",()=>te(t,[["loading",!0],["mask",!1]]))}(t,e)}const he=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],ue=(()=>{if("undefined"===typeof document)return!1;const t=he[0],e={};for(const r of he){if(r[1]in document){for(const[o,n]of r.entries())e[t[o]]=n;return e}}return!1})(),me={change:ue.fullscreenchange,error:ue.fullscreenerror},fe={request:(t=document.documentElement,e)=>new Promise((r,o)=>{const n=()=>{fe.off("change",n),r()};fe.on("change",n);const a=t[ue.requestFullscreen](e);a instanceof Promise&&a.then(n).catch(o)}),exit:()=>new Promise((t,e)=>{if(!fe.isFullscreen)return void t();const r=()=>{fe.off("change",r),t()};fe.on("change",r);const o=document[ue.exitFullscreen]();o instanceof Promise&&o.then(r).catch(e)}),toggle:(t,e)=>fe.isFullscreen?fe.exit():fe.request(t,e),onchange(t){fe.on("change",t)},onerror(t){fe.on("error",t)},on(t,e){const r=me[t];r&&document.addEventListener(r,e,!1)},off(t,e){const r=me[t];r&&document.removeEventListener(r,e,!1)},raw:ue};function ge(t){const{i18n:e,notice:r,template:{$video:o,$player:n}}=t,a=t=>{fe.on("change",()=>{t.emit("fullscreen",fe.isFullscreen),fe.isFullscreen?(t.state="fullscreen",C(n,"art-fullscreen")):z(n,"art-fullscreen"),t.emit("resize")}),fe.on("error",e=>{t.emit("fullscreenError",e)}),at(t,"fullscreen",{get:()=>fe.isFullscreen,set(t){return d(this,null,function*(){t?yield fe.request(n):yield fe.exit()})}})};t.once("video:loadedmetadata",()=>{var n;fe.isEnabled?a(t):o.webkitSupportsFullscreen?((n=t).on("document:webkitfullscreenchange",()=>{n.emit("fullscreen",n.fullscreen),n.emit("resize")}),at(n,"fullscreen",{get:()=>document.fullscreenElement===o,set(t){t?(n.state="fullscreen",o.webkitEnterFullscreen()):o.webkitExitFullscreen()}})):at(t,"fullscreen",{get:()=>!1,set(){r.show=e.get("Fullscreen Not Supported")}}),at(t,"fullscreen",lt(t,"fullscreen"))})}function ve(t){const{icons:e,proxy:r,storage:o,template:{$player:n,$video:a}}=t;let i=!1,s=0,l=0;function c(){const{$mini:e}=t.template;e&&(z(n,"art-mini"),A(e,"display","none"),n.prepend(a),t.emit("mini",!1))}function d(e,r){t.playing?(A(e,"display","none"),A(r,"display","flex")):(A(e,"display","flex"),A(r,"display","none"))}function p(){const{$mini:e}=t.template,r=B(e),n=window.innerHeight-r.height-50,a=window.innerWidth-r.width-50;o.set("top",n),o.set("left",a),A(e,"top",`${n}px`),A(e,"left",`${a}px`)}at(t,"mini",{get:()=>L(n,"art-mini"),set(h){if(h){t.state="mini",C(n,"art-mini");const h=function(){const{$mini:n}=t.template;if(n)return S(n,a),A(n,"display","flex");{const n=D("div");C(n,"art-mini-popup"),S(document.body,n),t.template.$mini=n,S(n,a);const p=S(n,'
');S(p,e.close),r(p,"click",c);const h=S(n,'
'),u=S(h,e.play),m=S(h,e.pause);return r(u,"click",()=>G(t.play())),r(m,"click",()=>t.pause()),d(u,m),t.on("video:playing",()=>d(u,m)),t.on("video:pause",()=>d(u,m)),t.on("video:timeupdate",()=>d(u,m)),r(n,"mousedown",t=>{i=0===t.button,s=t.pageX,l=t.pageY}),t.on("document:mousemove",t=>{if(i){C(n,"art-mini-dragging");const e=t.pageX-s,r=t.pageY-l;A(n,"transform",`translate(${e}px, ${r}px)`)}}),t.on("document:mouseup",()=>{if(i){i=!1,z(n,"art-mini-dragging");const t=B(n);o.set("left",t.left),o.set("top",t.top),A(n,"left",`${t.left}px`),A(n,"top",`${t.top}px`),A(n,"transform",null)}}),n}}(),u=o.get("top"),m=o.get("left");"number"===typeof u&&"number"===typeof m?(A(h,"top",`${u}px`),A(h,"left",`${m}px`),_(h)||p()):p(),t.emit("mini",!0)}else c()}})}function ye(t){const{i18n:e,notice:r,template:{$video:o}}=t;document.pictureInPictureEnabled?function(t){const{template:{$video:e},proxy:r,notice:o}=t;e.disablePictureInPicture=!1,at(t,"pip",{get:()=>document.pictureInPictureElement,set(r){r?(t.state="pip",e.requestPictureInPicture().catch(t=>{throw o.show=t,t})):document.exitPictureInPicture().catch(t=>{throw o.show=t,t})}}),r(e,"enterpictureinpicture",()=>{t.emit("pip",!0)}),r(e,"leavepictureinpicture",()=>{t.emit("pip",!1)})}(t):o.webkitSupportsPresentationMode?function(t){const{$video:e}=t.template;e.webkitSetPresentationMode("inline"),at(t,"pip",{get:()=>"picture-in-picture"===e.webkitPresentationMode,set(r){r?(t.state="pip",e.webkitSetPresentationMode("picture-in-picture"),t.emit("pip",!0)):(e.webkitSetPresentationMode("inline"),t.emit("pip",!1))}})}(t):at(t,"pip",{get:()=>!1,set(){r.show=e.get("PIP Not Supported")}})}function be(t,e,r,o,n=!0){let a,i=!1;const s=e=>{t.closed||i||(n&&(i=!0,a()),o(e))};return e[n?"once":"on"](r,s),a=t.add(()=>{e.off(r,s)}),s}function we(t,e,r){return new Promise((o,n)=>{if(Pt(t)||e===t.url)return void o();const a=ie(t),i=a.scope.child();let s=!1;const l=(t=!1,e)=>{s||(s=!0,a.onError=void 0,a.onAssigned=void 0,i.dispose(),t?n(e):o(),t&&a.scope.dispose())};i.add(()=>{l()});const c=()=>!s&&a.active(),p=t=>l(!0,t);a.onError=p;try{const{playing:o,aspectRatio:n,playbackRate:s}=t;if(t.pause(),!c())return;const h=i.child(),u={"video:error":p,"video:loadedmetadata":()=>{if(c())try{t.currentTime=r}catch(e){p(e)}},"video:canplay":()=>{if(!c())return;h.dispose();d(null,null,function*(){if(t.playbackRate=s,c()&&(t.aspectRatio=n,c())){if(o)try{yield t.play()}catch(e){}c()&&(t.notice.show="",l())}}).catch(p)}},m=i.child(),f=[],g=Object.keys(u);for(const e of g)be(m,t,e,t=>{a.acceptingEvents&&f.push([e,t])},!1);if(le(t,a,e),!c())return;if(t.notice.show="",!c())return;const v=()=>{if(m.dispose(),!e)return void l();const r={};for(const e of g)r[e]=be(h,t,e,u[e]);for(const[t,e]of f){if(!c()||h.closed)break;r[t](e)}f.length=0};a.assigned?v():a.onAssigned=v}catch(h){p(h)}})}function xe(t){const{option:e,template:{$progress:r,$video:o}}=t;let n=null,a=!1,i=null;t.on("setBar",(n,s,l)=>d(null,null,function*(){var c;const d=null==(c=t.controls)?void 0:c.thumbnails,{url:p,scale:h}=e.thumbnails;if(!d||!p)return;if("hover"===n||"played"===n&&l&&k){if(i||a||(a=!0,i=yield W(p,h),a=!1),!i)return;const n=r.clientWidth*s;n>0&&nr.clientWidth-u/2?A(s,"left",r.clientWidth-u+"px"):A(s,"left",n-u/2+"px")}(n)}})),at(t,"thumbnails",{get:()=>t.option.thumbnails,set(e){e.url&&!t.option.isLive&&(t.option.thumbnails=e,clearTimeout(n),n=null,a=!1,i=null)}})}function ke(t){const{option:e,template:{$video:r}}=t;at(t,"url",{get:()=>r.src,set(o){return d(this,null,function*(){if(Pt(t))return;const n=function(t){const e=re.get(t);return re.delete(t),e||ie(t)}(t);n.acceptingEvents=!1;try{if(!o)return void((yield Rt(n.scope))&&n.active()&&(t.loading.show=!0));const a=t.url,i=e.type||K(o),s=e.customType[i];if(i&&s){if(!(yield Rt(n.scope))||!n.active())return;t.loading.show=!0}if(!n.active())return;const l=n.scope.child();let c=!1,d=!1;be(l,t,"video:canplay",()=>{c=!d}),be(l,t,"video:error",()=>{d=!0});try{if(n.acceptingEvents=!0,i&&s){const e=s.call(t,r,o,t);Promise.resolve(e).catch(t=>ce(n,t))}else{if(a&&URL.revokeObjectURL(a),!n.active())return;r.src=o}}finally{l.dispose()}if(!n.active())return;if(a!==t.url&&(t.option.url=o,n.active()&&t.isReady&&a)){const e=()=>{n.active()&&t.emit("restart",o)};c?e():d||be(n.scope,t,"video:canplay",e)}}catch(a){ce(n,a)}finally{se(n)}})}})}Object.defineProperties(fe,{isFullscreen:{get:()=>Boolean(document[ue.fullscreenElement])},element:{enumerable:!0,get:()=>document[ue.fullscreenElement]},isEnabled:{enumerable:!0,get:()=>Boolean(document[ue.fullscreenEnabled])}});class $e{constructor(t){ke(t),function(t){const{template:{$video:e}}=t;at(t,"attr",{value(t,r){if(void 0===r)return e[t];e[t]=r}})}(t),function(t){const{i18n:e,notice:r,option:o,constructor:{instances:n},template:{$video:a}}=t;at(t,"play",{value(){return d(this,null,function*(){const i=ae(t),s=yield a.play();if(!i())return s;const l=e.get("Play");if(!i())return s;if(r.show=l,!i())return s;if(t.emit("play"),o.mutex)for(let e=0;et.playing?t.pause():t.play()})}(t),function(t){const{notice:e}=t;at(t,"seek",{set(r){t.currentTime=r,t.duration&&(e.show=`${tt(t.currentTime)} / ${tt(t.duration)}`),t.emit("seek",t.currentTime,r)}});const r=t;at(t,"forward",{set(e){r.seek=t.currentTime+e}}),at(t,"backward",{set(e){r.seek=t.currentTime-e}})}(t),function(t){const{template:{$video:e},i18n:r,notice:o,storage:n}=t;at(t,"volume",{get:()=>e.volume||0,set:t=>{e.volume=J(t,0,1),o.show=`${r.get("Volume")}: ${Number.parseInt(String(100*e.volume),10)}`,0!==e.volume&&n.set("volume",e.volume)}}),at(t,"muted",{get:()=>e.muted,set:r=>{e.muted=r,t.emit("muted",r)}})}(t),function(t){const{$video:e}=t.template;at(t,"currentTime",{get:()=>e.currentTime||0,set:r=>{const o=Number.parseFloat(r);Number.isNaN(o)||(e.currentTime=J(o,0,t.duration))}})}(t),function(t){at(t,"duration",{get:()=>{const{duration:e}=t.template.$video;return e===1/0?0:e||0}})}(t),function(t){const e=e=>we(t,e,0);at(t,"switchQuality",{value:e=>we(t,e,t.currentTime)}),at(t,"switchUrl",{value:e}),at(t,"switch",{set:e})}(t),function(t){const{template:{$video:e},i18n:r,notice:o}=t,n=t;at(t,"playbackRate",{get:()=>e.playbackRate,set(t){if(t){if(t===e.playbackRate)return;e.playbackRate=t,o.show=`${r.get("Rate")}: ${1===t?r.get("Normal"):`${t}x`}`}else n.playbackRate=1}})}(t),function(t){const{i18n:e,notice:r,template:{$video:o,$player:n}}=t;at(t,"aspectRatio",{get:()=>n.dataset.aspectRatio||"default",set(a){if(a||(a="default"),"default"===a)A(o,"width",null),A(o,"height",null),A(o,"margin",null),delete n.dataset.aspectRatio;else{const t=a.split(":").map(Number),{clientWidth:e,clientHeight:r}=n,i=e/r,s=t[0]/t[1];i>s?(A(o,"width",s*r+"px"),A(o,"height","100%"),A(o,"margin","0 auto")):(A(o,"width","100%"),A(o,"height",e/s+"px"),A(o,"margin","auto 0")),n.dataset.aspectRatio=a}r.show=`${e.get("Aspect Ratio")}: ${"default"===a?e.get("Default"):a}`,t.emit("aspectRatio",a)}})}(t),function(t){const{notice:e,template:{$video:r}}=t,o=D("canvas");at(t,"getDataURL",{value:()=>new Promise((t,n)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),t(o.toDataURL("image/png"))}catch(a){e.show=a,n(a)}})}),at(t,"getBlobUrl",{value:()=>new Promise((t,n)=>{try{o.width=r.videoWidth,o.height=r.videoHeight,o.getContext("2d").drawImage(r,0,0),o.toBlob(e=>{t(URL.createObjectURL(e))})}catch(a){e.show=a,n(a)}})}),at(t,"screenshot",{value:e=>d(null,null,function*(){const o=yield t.getDataURL();return Z(o,`${e||`artplayer_${tt(r.currentTime)}`}.png`),t.emit("screenshot",o),o})})}(t),ge(t),function(t){const{constructor:e,template:{$container:r,$player:o}}=t;let n="";at(t,"fullscreenWeb",{get:()=>L(o,"art-fullscreen-web"),set(a){a?(n=o.style.cssText,e.FULLSCREEN_WEB_IN_BODY&&S(document.body,o),t.state="fullscreenWeb",A(o,"width","100%"),A(o,"height","100%"),C(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!0)):(e.FULLSCREEN_WEB_IN_BODY&&S(r,o),n&&(o.style.cssText=n,n=""),z(o,"art-fullscreen-web"),t.emit("fullscreenWeb",!1)),t.emit("resize")}})}(t),ye(t),function(t){const{$video:e}=t.template,r=t;at(t,"loaded",{get:()=>r.loadedTime/e.duration}),at(t,"loadedTime",{get:()=>e.buffered.length?e.buffered.end(e.buffered.length-1):0})}(t),function(t){at(t,"played",{get:()=>t.currentTime/t.duration})}(t),function(t){const{$video:e}=t.template;at(t,"playing",{get:()=>"boolean"===typeof e.playing?e.playing:!!(e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)})}(t),function(t){const{$container:e,$player:r,$video:o}=t.template;at(t,"autoSize",{value(){const{videoWidth:n,videoHeight:a}=o,{width:i,height:s}=B(e),l=n/a;if(i/s>l)A(r,"width",s*l/i*100+"%"),A(r,"height","100%");else{const t=i/l/s*100;A(r,"width","100%"),A(r,"height",`${t}%`)}t.emit("autoSize",{width:t.width,height:t.height})}})}(t),function(t){const e=t;at(t,"rect",{get:()=>B(t.template.$player)});const r=["bottom","height","left","right","top","width"];for(let o=0;oe.rect[n]})}at(t,"x",{get:()=>e.left+window.pageXOffset}),at(t,"y",{get:()=>e.top+window.pageYOffset})}(t),function(t){const{template:{$player:e},i18n:r,notice:o}=t;at(t,"flip",{get:()=>e.dataset.flip||"normal",set(n){n||(n="normal"),"normal"===n?delete e.dataset.flip:e.dataset.flip=n,o.show=`${r.get("Video Flip")}: ${r.get(Q(n))}`,t.emit("flip",n)}})}(t),ve(t),function(t){const{template:{$poster:e}}=t;at(t,"poster",{get:()=>{try{return e.style.backgroundImage.match(/"(.*)"/)[1]}catch(t){return""}},set(t){A(e,"backgroundImage",`url(${t})`)}})}(t),function(t){const{template:{$container:e,$video:r}}=t;at(t,"autoHeight",{value(){const{clientWidth:o}=e,{videoHeight:n,videoWidth:a}=r,i=n*(o/a);A(e,"height",`${i}px`),t.emit("autoHeight",i)}})}(t),function(t){const{$player:e}=t.template;at(t,"cssVar",{value:(t,r)=>r?e.style.setProperty(t,r):getComputedStyle(e).getPropertyValue(t)})}(t),function(t){at(t,"theme",{get:()=>t.cssVar("--art-theme"),set(e){t.cssVar("--art-theme",e)}})}(t),function(t){at(t,"type",{get:()=>t.option.type,set(e){t.option.type=e}})}(t),function(t){const e=["mini","pip","fullscreen","fullscreenWeb"];at(t,"state",{get:()=>e.find(e=>t[e])||"standard",set(r){for(let o=0;o{switch(t.availability){case"available":a=!0;break;case"not-available":a=!1}}):a=!1,at(t,"airplay",{value(){a?(n.webkitShowPlaybackTargetPicker(),t.emit("airplay")):r.show=e.get("AirPlay Not Available")}})}(t),function(t){at(t,"quality",{set(e){const{controls:r,notice:o,i18n:n}=t,a=e.find(t=>t.default)||e[0];r.update({name:"quality",position:"right",index:10,style:{marginRight:"10px"},html:(null==a?void 0:a.html)||"",selector:e,onSelect(e){return d(this,null,function*(){return yield t.switchQuality(e.url),o.show=`${n.get("Switch Video")}: ${e.html}`,e.html})}})}})}(t),xe(t),pe(t),function(t){const{option:e,storage:r,template:{$video:o,$poster:n}}=t;for(const i in e.moreVideoAttr)t.attr(i,e.moreVideoAttr[i]);e.muted&&(t.muted=e.muted),e.volume&&(o.volume=J(e.volume,0,1));const a=r.get("volume");"number"===typeof a&&(o.volume=J(a,0,1)),e.poster&&A(n,"backgroundImage",`url(${e.poster})`),e.autoplay&&(o.autoplay=e.autoplay),e.playsInline&&(o.playsInline=!0,o["webkit-playsinline"]=!0),e.theme&&(e.cssVar["--art-theme"]=e.theme);for(const i in e.cssVar)t.cssVar(i,e.cssVar[i]);t.url=e.url}(t)}}function Ee(t){const{notice:e,constructor:r,template:{$player:o,$video:n}}=t,a="art-auto-orientation",i="art-auto-orientation-fullscreen";let s=!1;function l(){const{videoWidth:t,videoHeight:e}=n,r=document.documentElement.clientWidth,o=document.documentElement.clientHeight;return t>e&&ro}return t.on("fullscreenWeb",e=>{var n;if(e){if(l()){const e=Number(null!=(n=r.AUTO_ORIENTATION_TIME)?n:0);setTimeout(()=>{t.fullscreenWeb&&!L(o,a)&&function(){const e=U(),r=document.documentElement.clientWidth,n=document.documentElement.clientHeight-e.top-e.bottom,i=r-e.left-e.right;A(o,"width",`${n}px`),A(o,"height",`${i}px`),A(o,"transform-origin","0 0"),A(o,"transform",`rotate(90deg) translate(${e.top}px, -${r-e.right}px)`),C(o,a),t.isRotate=!0,t.emit("resize")}()},e)}}else L(o,a)&&(A(o,"width",""),A(o,"height",""),A(o,"transform-origin",""),A(o,"transform",""),z(o,a),t.isRotate=!1,t.emit("resize"))}),t.on("fullscreen",t=>d(null,null,function*(){var r;const n=!!(null==(r=null==screen?void 0:screen.orientation)?void 0:r.lock);if(t){if(n&&l())try{const t=screen.orientation.type.startsWith("portrait")?"landscape":"portrait";yield screen.orientation.lock(t),s=!0,C(o,i)}catch(a){s=!1,e.show=a}}else if(L(o,i)&&z(o,i),n&&s){try{screen.orientation.unlock()}catch(c){}s=!1}})),{name:"autoOrientation",get state(){return L(o,a)}}}function Te(t){const{i18n:e,icons:r,storage:o,constructor:n,proxy:a,template:{$poster:i}}=t,s=t.layers.add({name:"auto-playback",html:'\n
\n
\n
\n '}),l=E(".art-auto-playback-last",s),c=E(".art-auto-playback-jump",s),d=E(".art-auto-playback-close",s);S(d,r.close);let p=null;function h(){const r=(o.get("times")||{})[t.option.id||t.option.url];clearTimeout(p),A(s,"display","none"),r&&r>=n.AUTO_PLAYBACK_MIN&&(A(s,"display","flex"),l.textContent=`${e.get("Last Seen")} ${tt(r)}`,c.textContent=e.get("Jump Play"),a(d,"click",()=>{A(s,"display","none")}),a(c,"click",()=>{t.seek=r,G(t.play()),A(i,"display","none"),A(s,"display","none")}),t.once("video:timeupdate",()=>{p=setTimeout(()=>{A(s,"display","none")},n.AUTO_PLAYBACK_TIMEOUT)}))}return t.on("video:timeupdate",()=>{if(t.playing){const e=o.get("times")||{},r=Object.keys(e);r.length>n.AUTO_PLAYBACK_MAX&&delete e[r[0]],e[t.option.id||t.option.url]=t.currentTime,o.set("times",e)}}),t.on("ready",h),t.on("restart",h),{name:"auto-playback",get times(){return o.get("times")||{}},clear:()=>o.del("times"),delete(t){const e=o.get("times")||{};return delete e[t],o.set("times",e),e}}}function Ce(t){const{constructor:e,proxy:r,template:{$player:o,$video:n}}=t;let a=null,i=!1,s=1;const l=()=>{clearTimeout(a),i&&(i=!1,t.playbackRate=s,z(o,"art-fast-forward"))};return r(n,"touchstart",r=>{1===r.touches.length&&t.playing&&!t.isLock&&(a=setTimeout(()=>{i=!0,s=t.playbackRate,t.playbackRate=e.FAST_FORWARD_VALUE,C(o,"art-fast-forward")},e.FAST_FORWARD_TIME))}),t.on("document:touchmove",l),t.on("document:touchend",l),{name:"fastForward",get state(){return L(o,"art-fast-forward")}}}function ze(t){const{layers:e,icons:r,template:{$player:o}}=t;function n(){return L(o,"art-lock")}function a(){C(o,"art-lock"),t.isLock=!0,t.emit("lock",!0)}function i(){z(o,"art-lock"),t.isLock=!1,t.emit("lock",!1)}return e.add({name:"lock",mounted(e){const o=S(e,r.lock),n=S(e,r.unlock);A(o,"display","none"),t.on("lock",t=>{t?(A(o,"display","inline-flex"),A(n,"display","none")):(A(o,"display","none"),A(n,"display","inline-flex"))})},click(){n()?i():a()}}),{name:"lock",get state(){return n()},set state(t){t?a():i()}}}function Le(t){return t.on("control",e=>{e?z(t.template.$player,"art-mini-progress-bar"):C(t.template.$player,"art-mini-progress-bar")}),{name:"mini-progress-bar"}}class Se{constructor(t){this.art=t,this.id=0;const{option:e}=t;!function(t,e){Pt(t.art)||!e.miniProgressBar||e.isLive||t.add(Le),!Pt(t.art)&&e.lock&&k&&t.add(ze),Pt(t.art)||!e.autoPlayback||e.isLive||t.add(Te),!Pt(t.art)&&e.autoOrientation&&k&&t.add(Ee),!Pt(t.art)&&e.fastForward&&k&&!e.isLive&&t.add(Ce)}(this,e);for(let r=0;rconsole.warn("Failed to initialize ArtPlayer plugin:",t))}}add(t){X(!Pt(this.art),"Cannot add a plugin after ArtPlayer is destroyed"),this.id+=1;const e=t.call(this.art,this.art);return e instanceof Promise?e.then(e=>this.next(t,e)):this.next(t,e)}next(t,e){return function(t,e,r){if(Pt(t.art))return t;const o=r&&r.name||e.name||`plugin${t.id}`;if(Pt(t.art))return t;let n=o;const a=st(t,n);if(Pt(t.art))return t;const i=`Cannot add a plugin that already has the same name: ${o}`;return Pt(t.art)||(X(!a,i),("object"===typeof o&&null!==o||"function"===typeof o)&&(n=Reflect.ownKeys({[n]:void 0})[0]),Pt(t.art)||at(t,n,{value:r})),t}(this,t,e)}}class Me extends Et{constructor(t){super(t);const{option:e,controls:r,template:{$setting:o}}=t;this.name="setting",this.$parent=o,this.id=0,this.active=null,this.cache=new Map,this.option=[...this.builtin,...e.settings],e.setting&&(this.format(),this.render(),t.on("blur",()=>{this.show&&(this.show=!1,this.render())}),t.on("focus",t=>{const e=V(t,r.setting),o=V(t,this.$parent);!this.show||e||o||(this.show=!1,this.render())}),t.on("resize",()=>this.resize()))}get builtin(){const t=[],{option:e}=this.art;return e.playbackRate&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,PLAYBACK_RATE:n}}=t;function a(t){return 1===t?e.get("Normal"):t.toFixed(1)}function i(){const e=t.setting.find(`playback-rate-${t.playbackRate}`);t.setting.check(e)}return{width:o,name:"playback-rate",html:e.get("Play Speed"),tooltip:a(t.playbackRate),icon:r.playbackRate,selector:n.map(e=>({value:e,name:`playback-rate-${e}`,default:e===t.playbackRate,html:a(e)})),onSelect:e=>(t.playbackRate=e.value,e.html),mounted:()=>{i(),t.on("video:ratechange",()=>i())}}}(this.art)),e.aspectRatio&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,ASPECT_RATIO:n}}=t;function a(t){return"default"===t?e.get("Default"):t}function i(){const e=t.setting.find(`aspect-ratio-${t.aspectRatio}`);t.setting.check(e)}return{width:o,name:"aspect-ratio",html:e.get("Aspect Ratio"),icon:r.aspectRatio,tooltip:a(t.aspectRatio),selector:n.map(e=>({value:e,name:`aspect-ratio-${e}`,default:e===t.aspectRatio,html:a(e)})),onSelect:e=>(t.aspectRatio=e.value,e.html),mounted:()=>{i(),t.on("aspectRatio",()=>i())}}}(this.art)),e.flip&&t.push(function(t){const{i18n:e,icons:r,constructor:{SETTING_ITEM_WIDTH:o,FLIP:n}}=t;function a(t){return e.get(Q(t))}function i(){const e=t.setting.find(`flip-${t.flip}`);t.setting.check(e)}return{width:o,name:"flip",html:e.get("Video Flip"),tooltip:a(t.flip),icon:r.flip,selector:n.map(e=>({value:e,name:`flip-${e}`,default:e===t.flip,html:a(e)})),onSelect:e=>(t.flip=e.value,e.html),mounted:()=>{i(),t.on("flip",()=>i())}}}(this.art)),e.subtitleOffset&&t.push(function(t){const{i18n:e,icons:r,constructor:o}=t;return{width:o.SETTING_ITEM_WIDTH,name:"subtitle-offset",html:e.get("Subtitle Offset"),icon:r.subtitle,tooltip:"0s",range:[0,-10,10,.1],onChange:e=>(t.subtitleOffset=e.range[0],`${e.range[0]}s`),mounted:(e,r)=>{t.on("subtitleOffset",t=>{r.$range.value=t,r.tooltip=`${t}s`})}}}(this.art)),t}traverse(t,e=this.option){var r;for(let o=0;o{e.default=e===t,e.default&&e.$item&&O(e.$item,"art-current")},t.$option),this.render(t.$parents))}format(t=this.option,e,r,o=[]){for(let n=0;ne}),at(a,"$parents",{get:()=>r}),at(a,"$option",{get:()=>t});const o=[];at(a,"$events",{get:()=>o}),at(a,"$formatted",{get:()=>!0})}this.format(a.selector||[],a,t,o)}this.option=t}find(t=""){let e=null;return this.traverse(r=>{r.name===t&&(e=r)}),e}resize(){var t,e;const{controls:r,constructor:{SETTING_WIDTH:o,SETTING_ITEM_HEIGHT:n},template:{$player:a,$setting:i}}=this.art;if(r.setting&&this.show){const s=(null==(e=null==(t=this.active[0])?void 0:t.$parent)?void 0:e.width)||o,{left:l,width:c}=B(r.setting),{left:d,width:p}=B(a),h=l-d+c/2-s/2;if(A(i,"height",`${this.active===this.option?this.active.length*n:(this.active.length+1)*n}px`),A(i,"width",`${s}px`),this.art.isRotate||k)return;h+s>p?(A(i,"left",null),A(i,"right",null)):(A(i,"left",`${h}px`),A(i,"right","auto"))}}inactivate(t){for(let e=0;e'),s=D("div");C(s,"art-setting-item-left-icon"),S(s,o),S(i,s),S(i,t.$parent.html);const l=r(a,"click",()=>this.render(t.$parents));t.$parent.$events.push(l),S(e,a)}createItem(t,e=!1){var r,o;if(!this.cache.has(t.$option))return;const n=this.cache.get(t.$option),a=t.$item;let i="selector";st(t,"switch")&&(i="switch"),st(t,"range")&&(i="range"),st(t,"onClick")&&(i="button");const{icons:s,proxy:l,constructor:c}=this.art,p=D("div");C(p,"art-setting-item"),A(p,"height",`${c.SETTING_ITEM_HEIGHT}px`),p.dataset.name=t.name||"",p.dataset.value=t.value||"";const h=S(p,'
'),u=S(p,'
'),m=D("div");switch(C(m,"art-setting-item-left-icon"),i){case"button":case"switch":case"range":S(m,t.icon||s.config);break;case"selector":(null==(r=t.selector)?void 0:r.length)?S(m,t.icon||s.config):S(m,s.check)}S(h,m),at(t,"$icon",{configurable:!0,get:()=>m}),at(t,"icon",{configurable:!0,get:()=>m.innerHTML,set(t){m.innerHTML="",S(m,t)}});const f=D("div");C(f,"art-setting-item-left-text"),S(f,t.html||""),S(h,f),at(t,"$html",{configurable:!0,get:()=>f}),at(t,"html",{configurable:!0,get:()=>f.innerHTML,set(t){f.innerHTML="",S(f,t)}});const g=D("div");switch(C(g,"art-setting-item-right-tooltip"),S(g,t.tooltip||""),S(u,g),at(t,"$tooltip",{configurable:!0,get:()=>g}),at(t,"tooltip",{configurable:!0,get:()=>g.innerHTML,set(t){g.innerHTML="",S(g,t)}}),i){case"switch":{const e=D("div");C(e,"art-setting-item-right-icon");const r=S(e,s.switchOn),o=S(e,s.switchOff);A(t.switch?o:r,"display","none"),S(u,e),at(t,"$switch",{configurable:!0,get:()=>e});let n=t.switch;at(t,"switch",{configurable:!0,get:()=>n,set(t){n=t,t?(A(o,"display","none"),A(r,"display",null)):(A(o,"display",null),A(r,"display","none"))}});break}case"range":{const e=D("div");C(e,"art-setting-item-right-icon");const r=S(e,'');r.value=t.range[0],r.min=t.range[1],r.max=t.range[2],r.step=t.range[3],C(r,"art-setting-range"),S(u,e),at(t,"$range",{configurable:!0,get:()=>r});let o=[...t.range];at(t,"range",{configurable:!0,get:()=>o,set(t){o=[...t],r.value=t[0],r.min=t[1],r.max=t[2],r.step=t[3]}})}break;case"selector":if(null==(o=t.selector)?void 0:o.length){const t=D("div");C(t,"art-setting-item-right-icon"),S(t,s.arrowRight),S(u,t)}}switch(i){case"switch":if(t.onSwitch){const e=l(p,"click",e=>d(this,null,function*(){t.switch=yield t.onSwitch.call(this.art,t,p,e)}));t.$events.push(e)}break;case"range":if(t.$range){if(t.onRange){const e=l(t.$range,"change",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onRange.call(this.art,t,p,e)}));t.$events.push(e)}if(t.onChange){const e=l(t.$range,"input",e=>d(this,null,function*(){t.range[0]=t.$range.valueAsNumber,t.tooltip=yield t.onChange.call(this.art,t,p,e)}));t.$events.push(e)}}break;case"selector":{const e=l(p,"click",e=>d(this,null,function*(){var r;(null==(r=t.selector)?void 0:r.length)?this.render(t.selector):(this.check(t),t.$parent.onSelect&&(t.$parent.tooltip=yield t.$parent.onSelect.call(this.art,t,p,e)))}));t.$events.push(e),t.default&&C(p,"art-current")}break;case"button":if(t.onClick){const e=l(p,"click",e=>d(this,null,function*(){t.tooltip=yield t.onClick.call(this.art,t,p,e)}));t.$events.push(e)}}at(t,"$item",{configurable:!0,get:()=>p}),e?Y(p,a):S(n,p),t.mounted&&Ot(At(this.art),()=>t.mounted.call(this.art,t.$item,t),0)}render(t=this.option){var e;if(this.active=t,this.cache.has(t)){O(this.cache.get(t),"art-current")}else{const r=D("div");this.cache.set(t,r),C(r,"art-setting-panel"),S(this.$parent,r),O(r,"art-current"),(null==(e=t[0])?void 0:e.$parent)&&this.createHeader(t[0]);for(let e=0;enull,this.init(t.option.subtitle);let e=!1;t.on("video:timeupdate",()=>{if(!this.url)return;const t=this.art.template.$video.webkitDisplayingFullscreen;"boolean"===typeof t&&t!==e&&(e=t,this.createTrack(t?"subtitles":"metadata",this.url))})}get url(){return this.art.template.$track.src}set url(t){this.switch(t)}get textTrack(){var t,e;return null==(e=null==(t=this.art.template.$video)?void 0:t.textTracks)?void 0:e[0]}get activeCues(){return this.textTrack?Array.from(this.textTrack.activeCues):[]}get cues(){return this.textTrack?Array.from(this.textTrack.cues):[]}style(t,e){const{$subtitle:r}=this.art.template;return"object"===typeof t?P(r,t):A(r,t,e)}update(){const{option:{subtitle:t},template:{$subtitle:e}}=this.art;e.innerHTML="",this.activeCues.length&&(this.art.emit("subtitleBeforeUpdate",this.activeCues),e.innerHTML=this.activeCues.map((e,r)=>e.text.split(/\r?\n/).filter(t=>t.trim()).map(e=>`
\n ${t.escape?nt(e):e}\n
`).join("")).join(""),this.art.emit("subtitleAfterUpdate",this.activeCues))}switch(t){return d(this,arguments,function*(t,e={}){const{i18n:r,notice:o,option:n}=this.art,a=c(l(l({},n.subtitle),e),{url:t}),i=yield this.init(a);return e.name&&(o.show=`${r.get("Switch Subtitle")}: ${e.name}`),i})}createTrack(t,e){const{template:r,proxy:o,option:n}=this.art,{$video:a,$track:i}=r,s=D("track");s.default=!0,s.kind=t,s.src=e,s.label=n.subtitle.name||"Artplayer",s.track.mode="hidden",s.onload=()=>{this.art.emit("subtitleLoad",this.cues,this.option)},this.art.events.remove(this.destroyEvent),i.onload=null,M(i),S(a,s),r.$track=s,this.destroyEvent=o(this.textTrack,"cuechange",()=>this.update())}init(t){return d(this,null,function*(){const{notice:e,template:{$subtitle:r}}=this.art;return this.textTrack?(f(t,$t.subtitle),t.url?(this.option=t,this.style(t.style),fetch(t.url).then(t=>t.arrayBuffer()).then(e=>{const r=new TextDecoder(t.encoding).decode(e);switch(t.type||K(t.url)){case"srt":{const e=dt(r);return pt(t.onVttLoad(e))}case"ass":{const e=ht(r);return pt(t.onVttLoad(e))}case"vtt":return pt(t.onVttLoad(r));default:return t.url}}).then(t=>(r.innerHTML="",this.url===t||(URL.revokeObjectURL(this.url),this.createTrack("metadata",t)),t)).catch(t=>{throw r.innerHTML="",e.show=t,t})):void 0):null})}}class Oe{constructor(t){this.art=t;const{option:e,constructor:r}=t;e.container instanceof Element?this.$container=e.container:(this.$container=E(e.container),X(this.$container,`No container element found by ${e.container}`)),X(H(),"The current browser does not support flex layout");const o=this.$container.tagName.toLowerCase();X("div"===o,`Unsupported container element type, only support 'div' but got '${o}'`),X(r.instances.every(t=>t.template.$container!==this.$container),"Cannot mount multiple instances on the same dom element"),this.query=this.query.bind(this),function(t,e,r){const o=St.get(e);if(o&&o!==t)throw new Error("Cannot mount multiple instances on the same dom element");const n=Mt(t);n.rollback=r,St.set(e,t),n.releaseContainer=()=>{St.get(e)===t&&St.delete(e)}}(t,this.$container,function(t){const e=[];return function t(r){const o=Array.from(r.childNodes);e.push({node:r,children:o,attributes:1===r.nodeType?Array.from(r.attributes,t=>[t.name,t.value]):void 0,value:r.nodeValue}),o.forEach(t)}(t),()=>{for(const{node:t,children:r,attributes:o,value:n}of e){for(;t.firstChild;)t.removeChild(t.firstChild);for(const e of r)t.appendChild(e);if(o){const e=t;for(const t of Array.from(e.attributes))e.removeAttribute(t.name);for(const[t,r]of o)e.setAttribute(t,r)}else t.nodeValue=n}}}(this.$container)),this.$container.dataset.artId=t.id,this.init()}static get html(){return`\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Player version:
\n
${g}
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n `}query(t){return E(t,this.$container)}init(){const{option:t}=this.art;if(t.useSSR||(this.$container.innerHTML=Oe.html),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query("track"),this.$poster=this.query(".art-poster"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsCenter=this.query(".art-controls-center"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$contextmenu=this.query(".art-contextmenus"),t.proxy){const e=t.proxy.call(this.art,this.art);X(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement,"Function 'option.proxy' needs to return 'HTMLVideoElement' or 'HTMLCanvasElement'"),Y(e,this.$video),e.className="art-video",this.$video=e}t.backdrop&&C(this.$player,"art-backdrop"),k&&C(this.$player,"art-mobile")}destroy(t){t?this.$container.innerHTML="":C(this.$player,"art-destroy")}}const Re=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class _e{on(t,e,r){const o=this.e||(this.e={});let n=Re(o,t)?o[t]:void 0;return n||(n=[],Object.defineProperty(o,t,{value:n,enumerable:!0,configurable:!0,writable:!0})),n.push({fn:e,ctx:r}),this}once(t,e,r){const o=this,n=e;let a=!1;function i(...e){a||(a=!0,o.off(t,i),n.apply(r,e))}return i._=e,this.on(t,i,r)}emit(t,...e){const r=this.e||(this.e={}),o=(Re(r,t)&&r[t]||[]).slice();for(const n of o)n.fn.apply(n.ctx,e);return this}off(t,e){const r=this.e||(this.e={}),o=Re(r,t)?r[t]:void 0,n=[];if(o&&e)for(let a=0,i=o.length;ae.call(this,this)),De.DEBUG){const t=t=>console.log(`[ART.${this.id}] -> ${t}`);t(`Version@${De.version}`);for(let e=0;et(`Event@${e.type}`))}(function(t){const e=Mt(t);return e.rollback=void 0,!e.scope.closed})(this)&&Ye.push(this)}catch(o){try{It(this,Ye,!0,De.REMOVE_SRC_WHEN_DESTROY,!0)}catch(n){console.warn("Failed to clean up ArtPlayer initialization:",n)}throw o}}static get instances(){return Ye}static get version(){return g}static get config(){return v}static get utils(){return mt}static get scheme(){return $t}static get Emitter(){return _e}static get validator(){return f}static get kindOf(){return f.kindOf}static get html(){return Oe.html}static get option(){return{id:"",container:"#artplayer",url:"",poster:"",type:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,autoMini:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,backdrop:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,useSSR:!1,playsInline:!0,lock:!1,gesture:!0,fastForward:!1,autoPlayback:!1,autoOrientation:!1,airplay:!1,proxy:void 0,layers:[],contextmenu:[],controls:[],settings:[],quality:[],highlight:[],plugins:[],thumbnails:{url:"",number:60,column:10,width:0,height:0,scale:1},subtitle:{url:"",type:"",style:{},name:"",escape:!0,encoding:"utf-8",onVttLoad:t=>t},moreVideoAttr:{controls:!1,preload:b?"auto":"metadata"},i18n:{},icons:{},cssVar:{},customType:{},lang:null==navigator?void 0:navigator.language.toLowerCase()}}get proxy(){return this.events.proxy}get query(){return this.template.query}get video(){return this.template.$video}reset(){this.video.removeAttribute("src"),this.video.load()}destroy(t=!0){It(this,Ye,t,De.REMOVE_SRC_WHEN_DESTROY)}}return De.STYLE=Pe,De.DEBUG=!1,De.CONTEXTMENU=!0,De.NOTICE_TIME=2e3,De.SETTING_WIDTH=250,De.SETTING_ITEM_WIDTH=200,De.SETTING_ITEM_HEIGHT=35,De.RESIZE_TIME=200,De.SCROLL_TIME=200,De.SCROLL_GAP=50,De.AUTO_PLAYBACK_MAX=10,De.AUTO_PLAYBACK_MIN=5,De.AUTO_PLAYBACK_TIMEOUT=3e3,De.RECONNECT_TIME_MAX=5,De.RECONNECT_SLEEP_TIME=1e3,De.CONTROL_HIDE_TIME=3e3,De.DBCLICK_TIME=300,De.DBCLICK_FULLSCREEN=!0,De.MOBILE_DBCLICK_PLAY=!0,De.MOBILE_CLICK_PLAY=!1,De.AUTO_ORIENTATION_TIME=200,De.INFO_LOOP_TIME=1e3,De.FAST_FORWARD_VALUE=3,De.FAST_FORWARD_TIME=1e3,De.TOUCH_MOVE_RATIO=.5,De.VOLUME_STEP=.1,De.SEEK_STEP=5,De.PLAYBACK_RATE=[.5,.75,1,1.25,1.5,2],De.ASPECT_RATIO=["default","4:3","16:9"],De.FLIP=["normal","horizontal","vertical"],De.FULLSCREEN_WEB_IN_BODY=!0,De.LOG_VERSION=!0,De.USE_RAF=!1,De.REMOVE_SRC_WHEN_DESTROY=!0,$&&(window.Artplayer=De,F("artplayer-style",Pe),setTimeout(()=>{De.LOG_VERSION&&console.log(`%c ArtPlayer %c ${De.version} %c https://artplayer.org`,"color: #fff; background: #5f5f5f","color: #fff; background: #4bc729","")},100)),De});