/*! For license information please see player-12.27bdc997.js.LICENSE.txt */ "use strict";!function(e,t){"object"==typeof module&&"object"==typeof module.exports?t():"function"==typeof define&&define.amd?define([],t):(e="undefined"!=typeof globalThis?globalThis:e||self)&&t()}(this,function(){"use strict";"object"==typeof window&&(window.openRedirect={version:"1.2.20",webpackPluginVersion:"3.4.22",reportOnly:!1})}),!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).xss={})}(this,function(e){"use strict";var t=function(){return(t=Object.assign||function(e){for(var t,r=1,n=arguments.length;r/g,o=/&#([a-zA-Z0-9]*);?/gim,s=/"/g,l=/:?/gim,u=/&newline;?/gim,c=/((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi,d=/u\s*r\s*l\s*\(.*/gi,f=/e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi,h=/"/g,p=function(e){return e.replace(i,"<").replace(a,">")},g={indexOf:function(e,t){var r,n;for(r=0,n=e.length;r127&&n<2048?t+=String.fromCharCode(n>>6|192)+String.fromCharCode(63&n|128):t+=String.fromCharCode(n>>12|224)+String.fromCharCode(n>>6&63|128)+String.fromCharCode(63&n|128)}return t}(e);c>2,a=(3&t)<<4|(r=e.charCodeAt(c++))>>4,o=(15&r)<<2|(n=e.charCodeAt(c++))>>6,s=63&n,isNaN(r)?o=s=64:isNaN(n)&&(s=64),u=u+l.charAt(i)+l.charAt(a)+l.charAt(o)+l.charAt(s);return u}function _(e){var t,r,n,i,a,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");u>4,r=(15&i)<<4|(a=s.indexOf(e.charAt(u++)))>>2,n=(3&a)<<6|(o=s.indexOf(e.charAt(u++))),l+=String.fromCharCode(t),64!==a&&(l+=String.fromCharCode(r)),64!==o&&(l+=String.fromCharCode(n));return function(e){for(var t="",r=0,n=0,i=0,a=0;r191&&n<224?(t+=String.fromCharCode((31&n)<<6|63&(a=e.charCodeAt(r+1))),r+=2):(a=e.charCodeAt(r+1),t+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&(i=e.charCodeAt(r+2))),r+=3);return t}(l)}function T(e,t,r){var n="",i=0,a=!1,o=!1,s=0,l=e.length,u="",c="";e:for(s=0;s"===d||s===l-1){n+=r(e.slice(i,a)),u=function(e){var t,r=g.spaceIndex(e);return t=-1===r?e.slice(1,-1):e.slice(1,r+1),"/"===(t=g.trim(t).toLowerCase()).slice(0,1)&&(t=t.slice(1)),"/"===t.slice(-1)&&(t=t.slice(0,-1)),t}(c=e.slice(a,s+1)),n+=t(a,n.length,u,c,"0;t--){var r=e[t];if(" "!==r)return"="===r?t:-1}return -1}(e,u-1))){l(o,m(g.trim(e.slice(r,u)))),o=!1,r=u+1;continue}}}else{if(-1===(d=e.indexOf(c,u+1)))break;l(o,g.trim(e.slice(i+1,d))),o=!1,r=(u=d)+1}}else o=e.slice(r,u),r=u+1,i='"'===e.charAt(r)||"'"===e.charAt(r)?r:function(e,t){for(;te.charCodeAt(r)?" ":e.charAt(r);return g.trim(t)}(e=(e=(e=e.replace(s,'"')).replace(o,function(e,t){return"x"===t[0]||"X"===t[0]?String.fromCharCode(parseInt(t.substr(1),16)):String.fromCharCode(parseInt(t,10))})).replace(l,":").replace(u," "))}(r),"href"===t||"src"===t){if("#"===(r=g.trim(r)))return"#";if("http://"!==r.substr(0,7)&&"https://"!==r.substr(0,8)&&"mailto:"!==r.substr(0,7)&&"tel:"!==r.substr(0,4)&&"data:image/"!==r.substr(0,11)&&"ftp://"!==r.substr(0,6)&&"./"!==r.substr(0,2)&&"../"!==r.substr(0,3)&&"#"!==r[0]&&"/"!==r[0])return""}else if("background"===t){if(c.lastIndex=0,c.test(r))return""}else if("style"===t&&(f.lastIndex=0,f.test(r)||(d.lastIndex=0,d.test(r)&&(c.lastIndex=0,c.test(r)))))return"";return r=function(e){return e=p(e=e.replace(h,"""))}(r)}var S=function(e){return"string"==typeof e?e.replace(/'/g,'"').replace('=""',"").replace(/\s+/g,"").toLowerCase():""},k=function(){function e(e){var t=function(e){var t={};for(var r in e)t[r]=e[r];return t}(e||{});t.stripIgnoreTag&&(t.onIgnoreTag,t.onIgnoreTag=function(){return""}),t.whiteList={},t.onTag=function(){},t.onTagAttr=function(){},t.onIgnoreTag=function(){},t.onIgnoreTagAttr=function(){},t.safeAttrValue=E,t.escapeHtml=p,this.options=Object.assign(t,e)}return e.prototype.process=function(e){if(!(e=(e=e||"").toString()))return"";var t,r,n,i,a,o,s=this.options,l=s.whiteList,u=s.onTag,c=s.onIgnoreTag,d=s.onTagAttr,f=s.onIgnoreTagAttr,h=s.safeAttrValue,p=s.escapeHtml;s.stripBlankChar&&(e=(t=(t=e.split("")).filter(function(e){var t=e.charCodeAt(0);return!(127===t||t<=31&&10!==t&&13!==t)})).join("")),s.allowCommentTag||(e=function(e){for(var t="",r=0;r");var s=function(e){var t=g.spaceIndex(e);if(-1===t)return{html:"",closing:"/"===e[e.length-2]};var r="/"===(e=g.trim(e.slice(t+1,-1)))[e.length-1];return r&&(e=g.trim(e.slice(0,-1))),{html:e,closing:r}}(n),v=l[r],m=b(s.html,function(e,t){var n=-1!==g.indexOf(v,e),i=d(r,e,t,n);return null==i?n?(t=h(r,e,t,null))?"".concat(e,'="').concat(t,'"'):e:null==(i=f(r,e,t,n))?void 0:i:i});return n="<".concat(r),m&&(n+=" ".concat(m)),s.closing&&(n+=" /"),n+=">"}return null==(o=c(r,n,a))?p(n):o},p);return v&&(m=v.remove(m)),m},e}(),R=Function("\nvar _checkXSS = function (it) {\n return it && it.Math == Math && it;\n};\nreturn _checkXSS(typeof globalThis === 'object' && globalThis) ||\n_checkXSS(typeof window === 'object' && window) ||\n_checkXSS(typeof self === 'object' && self) ||\n_checkXSS(typeof global === 'object' && global) ||\nFunction('return this')();\n")(),x=new(function(){function e(){var e=this;this.batchData=[],this.uniqKeys=new Set,this.timeout=2e3,this.lock=!1,this.getSlardarBid=function(){var t,r,n="douyin_web";if(!g.includes(n,"bid"))return n;if(e.config&&e.config.bid)return e.config.bid;if(R&&R._xssBid)return R._xssBid;if(R&&R.slardar&&"function"==typeof R.slardar.config){var i=(R.slardar.config()||{}).bid;if(i)return i}if(R&&R.Slardar&&"function"==typeof R.Slardar.config){var a=(R.Slardar.config()||{}).bid;if(a)return a}return(null===(r=null===(t=null==R?void 0:R.Slardar)||void 0===t?void 0:t._baseParams)||void 0===r?void 0:r.bid)||"argus"},this.getConfigRegion=function(){var t;return g.includes("cn","region")?e.config&&e.config.region?e.config.region:((null===(t=null==R?void 0:R.gfdatav1)||void 0===t?void 0:t.region)||"cn").toLowerCase():"cn"},this.gerReportUrl=function(){var t={cn:_("aHR0cHM6Ly9tb24uemlqaWVhcGkuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),boe:_("aHR0cHM6Ly9tb24uemlqaWVhcGkuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),ttp:_("aHR0cHM6Ly9tb24udXMudGlrdG9rdi5jb20vbW9uaXRvcl9icm93c2VyL2NvbGxlY3QvYmF0Y2gvc2VjdXJpdHkvP2JpZD0="),va:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),maliva:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),sg:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9"),boei18n:_("aHR0cHM6Ly9tb24tdmEuYnl0ZW92ZXJzZWEuY29tL21vbml0b3JfYnJvd3Nlci9jb2xsZWN0L2JhdGNoL3NlY3VyaXR5Lz9iaWQ9")}[e.getConfigRegion()];if(t)return t+e.getSlardarBid()}}return e.prototype.setConfig=function(e){this.config=e},e.prototype.upload=function(){var e=this,t=this.gerReportUrl();!this.lock&&t&&0!==this.batchData.length&&(this.lock=!0,setTimeout(function(){var r=e.batchData.slice(0,100);e.batchData=e.batchData.slice(100),R.fetch(t,{method:"post",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}}).catch(function(e){}),e.lock=!1,e.upload()},this.timeout))},e.prototype.generateKey=function(e){return e.collectKey?[e.collectMode,e.collectKey].join("___"):""},e.prototype.push=function(e){this.batchData.push(e),this.upload()},e.prototype.report=function(e){var t=this.generateKey(e);if(R.fetch&&e.collectKey){var r="object"==typeof window?window.location.href:"SSR";e.documentUrl=r;var n={age:Math.floor(Date.now()),type:"xss",url:r,body:e,"user-agent":""};"enforce"===e.disposition&&"SSR"!==r||(n.url=t),"SSR"===r&&(n.url="SSR___".concat(n.url),n.body.ssr=!0),this.push(n)}},e}()),w=function(e){for(var t=0,r=function(r){Array.isArray(e[r])?0===e[r].length?delete e[r]:(e[r]=g.from(g.uniq(e[r])),t+=e[r].length):0===g.keys(e[r]).length?delete e[r]:g.keys(e[r]).forEach(function(n){e[r][n]=g.from(g.uniq(e[r][n])),t+=e[r][n].length})},n=0,i=g.keys(e);n0)return t&&t("javascript:"),!1;if(/^javascript:/i.test(e)){var i=e.slice(11).replace(/\s/g,"").trim();return!!g.some(["void","void(0)","void0","false","undefined",";"],function(e){return e===i})||(t&&t("javascript:"),!1)}return!0}var A=function(e,t){var r,n,i="<%= isSaveValidUrl =>";if("string"!=typeof e||(n=Number("<%= urlLimit =>"),void 0!==r&&(n=r),"NaN"!==e.toString()&&-1!==n&&e.length>=n)||P(e,t))return e;try{if(!0===(i=JSON.parse(i))||"true"===i){var a=new URL(e);return a.origin+a.pathname}}catch(e){}return"#"};function O(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=[]),"string"!=typeof e)return!0;if(!P(e=C(e)))return!1;var i,a={url:(i=e.match(/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/)||[])[0],scheme:i[1],slash:i[2],host:i[3],port:i[4],path:i[5],query:i[6],hash:i[7]},o=a.scheme,s=a.host;return n?!!n(e):!(!o||!s)&&(!g.includes(["http","https","file"],o)||("object"==typeof window&&window&&(t=r(r([],t,!0),[location.host],!1)),g.some(t,function(e){return!!(e instanceof RegExp&&e.test(s))||e===s})))}var I={a:["target","title","spellcheck","rel"],canvas:[],abbr:["title"],address:[],area:["shape","coords","alt"],article:[],aside:[],audio:["autoplay","controls","loop","preload"],b:[],bdi:["dir"],bdo:["dir"],big:[],blockquote:["cite"],br:[],caption:[],center:[],cite:[],code:[],col:["align","valign","span","width"],colgroup:["align","valign","span","width"],dd:[],del:["datetime"],details:["open"],div:["dir"],dl:[],dt:[],em:[],font:["color","size","face"],footer:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],header:[],hr:[],i:[],img:["alt","title","width","height","decoding"],ins:["datetime"],li:[],mark:[],nav:[],ol:["start"],p:[],pre:[],s:[],section:[],small:[],span:[],sub:[],sup:[],delete:[],form:[],strong:[],mask:["maskunits","x","y","width","height","fill"],table:["width","border","align","valign"],tbody:["align","valign"],td:["width","rowspan","colspan","align","valign"],tfoot:["align","valign"],th:["width","rowspan","colspan","align","valign"],thead:["align","valign"],tr:["rowspan","align","valign"],tt:[],u:[],ul:[],wbr:[],video:["autoplay","controls","loop","preload","height","width"],svg:["viewBox","version","xmlns","fill","width","height","stroke","stroke-width","style"],path:["d","fill","opacity","stroke","p-id","fill-rule","clip-rule","stroke-width","stroke-linecap","stroke-linejoin","fill-opacity","mask"],rect:["x","y","width","height","fill","stroke","rx"],g:[]},M={collect:null,initCollect:function(){this.collect={whiteList:{},filterProtocol:[]}},removeCollect:function(){var e=w(this.collect),t=e.count,r=e.ret;return this.collect=null,{collectKey:0===t?null:JSON.stringify(r),collectMode:"white"}},onIgnoreTagAttr:function(e,t,n){return e&&g.indexOf(["href","src"],t)>-1?M.domainWhiteList&&Array.isArray(M.domainWhiteList)&&M.domainWhiteList.length>0&&!O(n,r([],M.domainWhiteList,!0))?"":"".concat(t,'="').concat(A(n,function(e){var t;null===(t=M.collect)||void 0===t||t.filterProtocol.push(e)}),'"'):e&&(g.indexOf(["style","class","id"],t)>-1||t.indexOf("data-")>-1)?"".concat(t,'="').concat(n,'"'):(M.collect.whiteList[e]=M.collect.whiteList[e]||[],void M.collect.whiteList[e].push(t))},onIgnoreTag:function(e,t){if("style"===e)return t;T(t,function(e,t,r,n){b(D(n).html.replace("/",""),function(e){M.collect.whiteList[r]=M.collect.whiteList[r]||[],M.collect.whiteList[r].push(e)})},p)},whiteList:I,mergeWhiteList:function(e){for(var t,r={},n=0,i=g.keys(I);n");var a=D(n),o=b(a.html,function(e,t){var n,i=0;if(F.blackList[r]&&g.includes(F.blackList[r],e)&&(H.collect.blackList[r]=H.collect.blackList[r]||[],H.collect.blackList[r].push(e),i++),F.blackAttrRegExps.length&&F.blackAttrRegExps.some(function(t){return t.test(e)})&&g.forEach(F.blackAttrRegExps,function(t){t.test(e)&&(H.collect.blackAttrRegExps.push("".concat(t.toString(),"->").concat(e)),i++)}),F.blackAttrs.length&&g.includes(F.blackAttrs,e)&&(F.blackAttrs.push(e),i++),!i){if(F.filterList&&F.filterList[r]&&g.includes(F.filterList[r],e)){var a=A(t,function(e){var t;null===(t=H.collect)||void 0===t||t.filterProtocol.push(e)});return a!==t&&(H.collect.filterList[r]=H.collect.filterList[r]||[],H.collect.filterList[r].push(e)),t?"".concat(e,"='").concat(a,"'"):e}return F.filterAttrs&&g.includes(F.filterAttrs,e)?((a=A(t,function(e){var t;null===(t=H.collect)||void 0===t||t.filterProtocol.push(e)}))!==t&&(null===(n=H.collect)||void 0===n||n.filterAttrs.push(e)),t?"".concat(e,"='").concat(a,"'"):e):t?"".concat(e,"='").concat(t,"'"):e}});return n="<".concat(r),o&&(n+=" ".concat(o)),a.closing&&(n+=" /"),n+=">"},p);null===(r=H.collect)||void 0===r||r.blackTags.push(e)}},j=function(e){var t=e.reportOnly,r=void 0===t||t,n=e.block;return r&&"all"===r?"report":("string"==typeof r&&("true"===r&&(r=!0),"false"===r&&(r=!1)),n?"enforce":r?"report":"enforce")},Z=function(e){return function(r,n,i){if(!r||"string"!=typeof r)return r;var a=n;e===L&&(a=M).initCollect();var o=e(r,a);if(S(o)===S(r))return r;if(!i)return o;var s=i.logType,l=j(i),u=a.removeCollect();return x.report(t(t({type:s,disposition:l},u),{sourceText:y(r),filterText:y(o)})),"enforce"===l?o:r}},Y=Z(function(e,t){return void 0===t&&(t={}),t&&t.whiteList||(t.whiteList={a:["target","href","title"],abbr:["title"],address:[],area:["shape","coords","href","alt"],article:[],aside:[],audio:["autoplay","controls","crossorigin","loop","muted","preload","src"],b:[],bdi:["dir"],bdo:["dir"],big:[],blockquote:["cite"],br:[],caption:[],center:[],cite:[],code:[],col:["align","valign","span","width"],colgroup:["align","valign","span","width"],dd:[],del:["datetime"],details:["open"],div:[],dl:[],dt:[],em:[],figcaption:[],figure:[],font:["color","size","face"],footer:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],header:[],hr:[],i:[],img:["src","alt","title","width","height"],ins:["datetime"],li:[],mark:[],nav:[],ol:[],p:[],pre:[],s:[],section:[],small:[],span:[],sub:[],summary:[],sup:[],strong:[],strike:[],table:["width","border","align","valign"],tbody:["align","valign"],td:["width","rowspan","colspan","align","valign"],tfoot:["align","valign"],th:["width","rowspan","colspan","align","valign"],thead:["align","valign"],tr:["rowspan","align","valign"],tt:[],u:[],ul:[],video:["autoplay","controls","crossorigin","loop","muted","playsinline","poster","preload","src","height","width"]}),new k(t).process(e)}),W=Z(L),z=function(e,t,r){var n=[],i=A(e,function(e){n.push(e)});if(i===e)return e;n=g.from(g.uniq(n));var a=t||r||{};if(!a)return i;var o=a.logType,s=j(r);return x.report({type:o,disposition:s,collectKey:n.join("___"),collectData:JSON.stringify(n),collectMode:"black",sourceText:y(e),filterText:y(i)}),"enforce"===s?i:e},K=R._xssProject||{},q=R.xssNamespace||{},X="3.0.26",J={FilterXSS:k,version:X,webpackPluginVersion:"<%= webpackPluginVersion =>",reportOnly:"<%= reportOnly =>",filterXSS:Y,_filterXSS:W,filterUrl:z,Config:M,BlackConfig:H,project:K,setProjectName:function(e){K[e]=this,R._xssProjectName=e}};q.douyin_web=J,R.xssNamespace=q,R.Math&&!R.Math.xssNamespace&&(R.Math.xssNamespace=q),K[X]=J,R.globalThis=R,R.getFilterXss=function(){return void 0!==this._xssProjectName?this._xssProject[this._xssProjectName]:J},R.xss=J,R.isSafeUrl=O,R.isSafeDomain=O,R.isSafeProtocol=P,R._xssProject=K,R._xssProjectName&&(K[R._xssProjectName]=J);var Q=J.setProjectName.bind(J);e.BlackConfig=H,e.Config=M,e.FilterXSS=k,e._filterXSS=W,e.filterUrl=z,e.filterXSS=Y,e.isSafeDomain=O,e.isSafeProtocol=P,e.isSafeUrl=O,e.project=K,e.setProjectName=Q,e.setXssNamespace=function(e){var t=e.appId,r=e.bid,n=e.region;q[t]=J;M.bid=r,M.region=n,M.enabled=!0},e.xssNamespace=q,Object.defineProperty(e,"__esModule",{value:!0})}),(self.webpackChunkdouyin_web=self.webpackChunkdouyin_web||[]).push([["79122"],{167033:function(e,t,r){r.d(t,{L8:function(){return f},LM:function(){return g},LQ:function(){return S},P9:function(){return l},RB:function(){return w},_P:function(){return o},ab:function(){return x},cM:function(){return c},fC:function(){return E},je:function(){return d},kM:function(){return _},ky:function(){return v},lv:function(){return h},pv:function(){return b},qP:function(){return R},rg:function(){return u},uV:function(){return a},vR:function(){return p},xV:function(){return y},xp:function(){return L},xv:function(){return s},yc:function(){return T}});var n=r(726949);r(346984),r(705574),r(303846),r(802824),r(162093),r(497397),r(232070),r(918016),r(2885),r(248385),r(679308),r(374285),r(759943),r(414931),r(706056),r(240148),r(683656),r(228983),r(499222),r(663030);var i="undefined"!=typeof window&&window.location.href.indexOf("loggerdebug")>-1;function a(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=0,r=0;r3&&t[2]&&(r=t[2]),r}function s(e){var t=new Date().getTime();try{e=parseInt(e)}catch(t){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=window.performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)})}function l(e){return function(t){return Object.prototype.toString.call(t)==="[object ".concat(e,"]")}}function u(e){var t={};if(e instanceof window.XMLHttpRequest)try{e.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(function(e){var r=e.split(": "),n=r.shift(),i=r.join(": ");t[n]=i})}catch(e){}return t}function c(e){for(var t,r=arguments.length,n=Array(r>1?r-1:0),a=1;a1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(r,n){try{!e&&n(Error("url is undefined"));var i=d(),a=i,o={},s=new window.XMLHttpRequest;s.open("get",e),s.onreadystatechange=function(){2===s.readyState&&(o.headers=u(s),o.connectTime=d()-a,o.status=s.status,o.statusText=s.statusText,i=d())},s.onload=function(){r(o)},s.onprogress=function(e){var t=d()-i,r=0;r=parseInt(e.loaded/1e3/(t/1e3),10),o.speed=0|r,o.costTime=t},s.onerror=function(){!o.status&&(o.status=-1,o.costTime=d()-i),n(o)},s.ontimeout=function(){!o.status&&(o.status=-2,o.costTime=d()-i),r(o)},s.onabort=function(){r(o)},s.responseType="arraybuffer",s.timeout=t.timeout||1e4,s.setRequestHeader("Range","bytes=".concat(t.range||"0-1048576")),s.send()}catch(e){n(e)}})}function g(e){return!!(!e||window.location.href.indexOf(e)>-1)||!1}function v(e){return!!e&&/^blob:/.test(e)}var m={x_response_sinfo:"x-response-sinfo",x_response_cache:"x-response-cache",x_response_cinfo:"x-response-cinfo"};function y(e){if(!e)return{};var t={};return Object.keys(m).map(function(r){if(e[r]||"string"!=typeof m[r]){if(!e[r]&&m[r]instanceof Array){var n=m[r].filter(function(t){return void 0!==e[t]});n.length>0?t[r]=e[n[0]]:t[r]=""}}else t[r]=e[m[r]]||""}),t}function _(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return Object.keys(t).map(function(n){if("append"===r){var i,a;e[n]=(i=e[n],a=t[n],i?"string"==typeof a||"number"==typeof a?"".concat(i," ").concat(a):a:a)}else e[n]=t[n]}),e}function b(e,t){if(!e||!t)return!1;try{return Array.prototype.some.call(e.classList,function(e){return e===t})}catch(i){var r=e.className&&"object"===(0,n.Ac)(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))}}function E(e){if("String"===_(e))return e.replace("P","p");if(!e)return"";if("Number"===_(e))return"".concat(e)}function S(e){try{return JSON.stringify(e)}catch(e){return""}}var k={UN_KNOW:0,EXPIRED:1,NO_EXPIRED:2};function R(e){if(!e||"String"!==_(e))return 0;var t=0;try{var r=RegExp("(\\?|&)x-tos-expires=([^&]*)(&|$)"),n=e.match(r);if(null!==n)t=parseInt(n[2],10);else{var i=e.split("/");i.length>5&&8===i[4].length&&(t=parseInt(i[4],16))}if(t>0){var a=parseInt(new Date().getTime()/1e3,10);return t0?JSON.stringify(e):""}catch(e){return""}}},515951:function(e,t,r){r.d(t,{Z:function(){return U}});var n=r(61072);r(346984),r(705574),r(941533),r(451236),r(303846),r(124300),r(802824),r(162093),r(9498),r(117232),r(503e3),r(497397),r(232070),r(932651),r(2885),r(248385),r(679308),r(88856),r(759943),r(414931),r(706056),r(591111),r(663030),r(490629);var i=r(659830),a=r(75740),o=r(924718),s=r(365791),l=r(317153),u=r(755290),c=r(734123),d=r(403826),f=r(938310),h=r(364812),p=r(403177),g=r(576005),v=r(631144),m=r(861504),y=r(392671),_=r(937049),T=r(614184),b=r(374260),E=r(588984),S=r(858985),k=r(107093),R=r(235154),x=r(718828),w=r(441226),L=r(144144),D="DESTROYED",C="xglog_cache",P="degrade",A={UPDATE_URL:"UPDATE_URL"},O=null,I=null,M=null,N=null,B=0,U=function(e){var t,r,u,p,U,F,V,G;function H(e){var t,r,o,s;return(0,n.PA)(this,H),r=(0,n.$w)(this,H,[e]),(0,n._x)(r,"_onChangeConfig",function(e){if(e){var t=e.nextBufferLength===r.config.minBufferLength;if(r.setConfig(e),e.nextBufferLength&&!t)try{r._onTimeUpdate()}catch(e){}}}),(0,n._x)(r,"fpsStuckHandle",function(e){var t=r.player,n=r.config,i=r.mse;if(!r.fpsStuckTime&&(r.fpsStuckTime=e.currentTime,r.log(d._.LOG,"fpsStuckHandle, currentTime,",e.currentTime)),i&&r.fpsStuckTime>0){var a=t.bufferedPoint;i.clearOpQueues(f.d1.VIDEO,!!n.enableMsePatches),r.log(d._.LOG,"fpsStuckHandle, remove: ".concat(a.start,"-").concat(a.end,","),"stuckTime: ".concat(r.fpsStuckTime)),i.remove(f.d1.VIDEO,a.start,a.end).then(function(){t.currentTime=r.fpsStuckTime,r.fpsStuckTime=null}),!r._firstMetFPSStuck&&(r._firstMetFPSStuck=!0,r.log(d._.LOG,"firstMetFPSStuck"),r.emit(C))}}),(0,n._x)(r,"_replayHook",function(e){}),(0,n._x)(r,"_retryHook",function(){var e=r.player,t=r.playerConfig,n=e.paused;r.softDecode?e.vtype=a.l0.MP4_MSE_SOFT:e.vtype=a.l0.MP4_MSE,r._defInited=!1,r._MSEError=!1,e.video.removeEventListener("loadedmetadata",r.__onmetadataHandle);var i=e.currentTime||0;r.log(d._.LOG,"retryHook ",t.vid,r.codecType,i);var o=function(){r.__onmetadataHandle=function(){i&&(e.currentTime=i,r.log(d._.LOG,"retryHook update currentTime",t.vid,r.codecType,i)),n?e.pause():e.play(),e.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},e.video.addEventListener("loadedmetadata",r.__onmetadataHandle)};return!r.config.enableMsePatches&&o(),r._destroyMSE(),r._reset(),r.states=[],r.playerStartInit(t.url),r.config.enableMsePatches&&o(),!1}),(0,n._x)(r,"_playHook",function(e){r._usePaused=!1,r._cancelLoading=!1,r.log(d._.LOG,"playHook"),r._startProgress()}),(0,n._x)(r,"_pauseHook",function(e){var t;r._usePaused=!0;for(var n=arguments.length,i=Array(n>1?n-1:0),a=1;ai.indexOf(null===m.Im||void 0===m.Im?void 0:m.Im.BUFFER_CONTROLS)&&(clearTimeout(r.checkResumePlayTimer),r.checkResumePlayTimer=null,r.log(d._.LOG,"pause hook clear buffer_control state")),r._loadStuckCheck()}),(0,n._x)(r,"abrSwitchURL",(o=(0,n.x)((0,n.l5)().mark(function e(t){var i,a,o,s;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:i=r.playerConfig.definition.list,a=0,o=0;case 4:if(!(o0&&(e=p[0]),r._handlerUrl(e.url),e._mainURL=h._mainURL,e._backupURL=h._backupURL,r._switchBitRateWay&&!a){r.oldChangeDefinition(e,t);return}var g="自动"===e.definition||"auto"===e.definition;if(a)r.log(d._.LOG,"[switchBitrate:ABR], ready to switch bitRate, ",e.bitrate,e.definition);else{var v=!1;if(g)null===(y=r._abrService)||void 0===y||y.updateCurrentHDRStatus(null===(T=t)||void 0===T?void 0:T.isHDR),null===(b=r._abrService)||void 0===b||b.enable(),v=!0;else{r._abrService&&r._abrService.disable();var m,y,T,b,E,S=null===(E=l.definition)||void 0===E?void 0:E.list;if(S&&(!e.bitrate||!e.uri||!e.size||!e.duration)){for(var R=0;R=u.timeRange[u.timeRange.length-1].startTime)){n.next=9;break}return r.log(d._.LOG,"switch bitrate last segment, so return"),n.abrupt("return");case 9:if(m=null===(o=r._abrService)||void 0===o?void 0:o.isCurrentInAbr(),null==u||u.updateChangeBitRateTime(c),y=u.getFragmentIdx(c),!(g[1]0&&T[1]>c&&(!r._abrService||!m)&&(r.removeBuffer(f.d1.VIDEO,c,T[1]),r.log(d._.LOG,"switchBitrate: ready to remove buffer, ".concat(c," - ").concat(T[1]))),(b=u.getFragmentIdx(s.currentTime))>0&&(E=s.buffered.start(0),S=u.timeRange[b].startTime-1,r.removeBuffer(f.d1.VIDEO,E,S,function(){r.log(d._.LOG,"switchBitrate: remove old bitrate buffer end",JSON.stringify(s.getBufferedRange(s.buffered)))}),r.log(d._.LOG,"switchBitrate: ready to remove pre buffer, ".concat(E," - ").concat(S))),k=u.getAdaptIdxBySrcIdx(b)+1,r.log(d._.LOG,"switchBitrate: resetFragmentLoadState, ".concat(k,", changeBitRateIdx: ").concat(_)),u.resetFragmentLoadState(k),r._curLoadSegmentIdx=k,r.mp4.readyToChangeBitrate(e),r._setCurrentDefinition(e),r._emitDefinitionChangeDetailEvent(c),r.canDownload=!0,r._onTimeUpdate(),R={width:e.width||e.vwidth,height:e.height||e.vheight},s.emit("RESOLUTION_UPDATE",R);case 41:case"end":return n.stop()}},i)})),function(e){return o.apply(this,arguments)})).catch(function(t){r.log(d._.ERROR,"switchBitrate: GET_LICENSE_ERROR, ".concat(null==t?void 0:t.message));var n=new c.Errors(r.player,{errorType:_.iR.DRM,errorCode:_.O1.custom_drm,errorMessage:(null==t?void 0:t.message)||"GET_LICENSE_ERROR",vid:l.vid});t.errorType="GET_LICENSE_ERROR",r.emit("GET_LICENSE_ERROR",n),r.changeState("LICENSE_ERROR",{d:e.definition})})}}),(0,n._x)(r,"_onVideoError",function(e){var t,n,i=r.player;r.changeState("video_error",{code:e.code||(null==i||null===(t=i.video)||void 0===t||null===(t=t.error)||void 0===t?void 0:t.code),message:e.message||(null==i||null===(n=i.video)||void 0===n||null===(n=n.error)||void 0===n?void 0:n.message),videoType:r.useVideoLoad})}),(0,n._x)(r,"removeBuffer",function(e,t,n,i){var a,o=r.getBufferDur();null===(a=r.mse)||void 0===a||a.remove(e,t,n).then(function(){var e=r.player,t=o-r.getBufferDur();if(t>0){r.emit("removeBuffer",{removeDur:t});for(var n=[],a=0;a0&&r._waitInBufferTimer&&(r._waitAdjustTimeCnt-=1,r.log(d._.WARN,"[waitInBuffer resume play], waitAdjustTimeCnt,",r._waitAdjustTimeCnt)),clearTimeout(r._waitInBufferTimer),r._waitInBufferTimer=null;var e=r.mp4,t=r.player,n=r.config.resumePlayWaterLevel;if(!e){r.checkResumePlayTimer>0&&(clearTimeout(r.checkResumePlayTimer),r.checkResumePlayTimer=null,t.isBufferControlPaused&&(t.isBufferControlPaused=!1),t.paused&&t.play());return}if(e&&e.meta&&e.meta.duration-t.currentTime<=n)return;if(r.waitLevelStartTime<0&&(r.waitLevelStartTime=t.currentTime),!r.playFlag&&(r.playFlag=!0),void 0!==t.isBufferControlPaused&&!(n<=0)){if(n>0&&t.currentTime-r.waitLevelStartTime>=m.Ef){var i=t.getBufferedRange(t.buffered2);i[1]>0&&i[1]-t.currentTime0){var f=r._processArrayUrl(o.H264DefinitionList);o.H264DefinitionList=f,i.config.definition.list=f,i.config.url=f[0].url,i.config.defaultBitrate=o.H264DefinitionList[0].bitrate,i.config.defaultDefinition=o.H264DefinitionList[0].definition,r.isH265DegradeH264=!0,i.playNext(c),r.__onmetadataHandle=function(){i.currentTime=l,r.isH265DegradeH264=!1,r.log(d._.LOG,"H265DegradeH264 update currentTime",l),i.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},i.video.addEventListener("loadedmetadata",r.__onmetadataHandle)}else i.pause(),r._reset(),r.states=[],r.checkReUseMSE(!1,s.enableMsePatches),r.log(d._.ERROR,"H265 error,degrade h264 but no h264 url"),r.emit("error",e)}),(0,n._x)(r,"_onMp4MetaReady",function(e,t){if(!t||t.hasDestroyed){r.log(d._.LOG,"Mp4MetaReady but return, ".concat(!!t,", ").concat(null==t?void 0:t.hasDestroyed));return}var n=r._checkMetaInfo(e);if(n){r._errorHandler(n);return}var i=e.videoCodec,a=e.audioCodec;r._mediaCodec.videoCodec=i,r._mediaCodec.audioCodec=a;try{r._initEME(e),r.softDecode?(r.log(d._.LOG,"initMseProxy"),r._initMseProxy()):r.player.video instanceof HTMLVideoElement&&(r.log(d._.LOG,"initMse"),r._initMse(e)),r._initPromise&&r._initPromise.resolve()}catch(e){r._errorHandler(new c.Errors(r.player,{errorType:_.iR.MEDIA,errorCode:_.O1.eme_hijack,errorMessage:(null==e?void 0:e.message)||"eme or mse catch err",vid:r.playerConfig.vid}));return}if(null!=t&&t.timeRange){var o=[];t.timeRange.every(function(e){return o.push({startTime:e.startTime,endTime:e.endTime}),!0}),r.emit("KEYFRAMETIME",o)}t===r.mp4&&r._loadData()}),(0,n._x)(r,"_onMp4Error",(s=(0,n.x)((0,n.l5)().mark(function e(t){return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r._errorHandler(t);case 1:case"end":return e.stop()}},e)})),function(e){return s.apply(this,arguments)})),(0,n._x)(r,"_onMp4Progress",function(e){r.emit("progress_event",e)}),(0,n._x)(r,"_onMp4DataCallBack",function(){r._isMseInit&&r._onTimeUpdate()}),(0,n._x)(r,"_updateDrmConfig",function(e){var t=r.config;r.mp4.updateSecretKey(t.useEME,t.secretKey,t.decryptKey,t.keyValue),r._secretkey&&e.kid&&r._secretkey.updateKid(e.kid)}),(0,n._x)(r,"_updateMSE",function(e){r.player.video instanceof HTMLVideoElement&&(r.log(d._.LOG,"updateMse",e.videoCodec),r._initMse(e))}),(0,n._x)(r,"_onVideoTimeUpdate",function(){var e,t,n,i=r.mse,a=r.player;r.waitLevelStartTime<0&&(r.waitLevelStartTime=a.currentTime),r.checkReStartTimer(),r._isEnded(),a.isSeeking&&(a.isSeeking=!1),!r.useVideoLoad&&i&&r._removeBuffEndTime>0&&a.currentTime>r._removeBuffEndTime+1&&(r.log(d._.LOG,"remove old bitrate buffer,0 - ".concat(r._removeBuffEndTime)),r.removeBuffer(f.d1.VIDEO,0,r._removeBuffEndTime-1),r._removeBuffEndTime=0),a.currentTime>=(null===(e=r._definitionChangePointInfo)||void 0===e?void 0:e.changeStartTime)&&(r.needStarLoadFirstSegment=!0,(0,R.u8)()&&(r.log(d._.LOG,"definitionChangePointInfo update\n changeDefinitionSeekState = 2\n ".concat(a.currentTime)),a.changeDefinitionSeekState=2)),r._definitionChangePointInfo&&a.currentTime>r._definitionChangePointInfo.changeStartTime&&(a.emit(c.Events.AFTER_DEFINITION_CHANGE,r._definitionChangePointInfo.changeInfo),r.log(d._.LOG,c.Events.AFTER_DEFINITION_CHANGE,", currentTime,",a.currentTime,",from ",null===(t=r._definitionChangePointInfo)||void 0===t||null===(t=t.changeInfo)||void 0===t||null===(t=t.from)||void 0===t?void 0:t.definition," to ",null===(n=r._definitionChangePointInfo)||void 0===n||null===(n=n.changeInfo)||void 0===n||null===(n=n.to)||void 0===n?void 0:n.definition),r._definitionChangePointInfo=null),!r.useVideoLoad&&null===r._requestTimer&&(r._offineLine||r._cancelLoading||r._startProgress()),r._lastBufferPoint=a.bufferedPoint}),(0,n._x)(r,"_onBufferedReset",function(){r.mp4&&r.mp4.videoTrak&&r.mp4.resetFragmentLoadState(0)}),(0,n._x)(r,"_onOnlineHandler",function(){r._offineLine=!1;var e=r.playerConfig,t=r.player,n=t.currentTime,i=t.paused;r.log(d._.LOG,"online useVideoLoad:",r.useVideoLoad,r._hasStartProgressBack),r.useVideoLoad?(r.__onmetadataHandle=function(){n&&(t.currentTime=n),r.log(d._.LOG,"onOnlineHandler update currentTime",e.vid,r.codecType,r._currentTime),i?t.pause():t.play(),t.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},t.video.addEventListener("loadedmetadata",r.__onmetadataHandle),r._setPlayerSrc(e.url)):(r._hasStartProgressBack&&r._startProgress(),r._hasStartProgressBack=!1)}),(0,n._x)(r,"_onOfflineHandler",function(){r._offineLine=!0,r.log(d._.LOG,"offline, ",r._hasStartProgress),r._hasStartProgress&&(r._stopProgress(),r._hasStartProgressBack=!0)}),(0,n._x)(r,"_loadDataSuccess",function(e){if(!r.isDestroy&&(!!r.mse||!!r.mseProxy)){try{e.initSeg&&(r._appendInitSeg(e.initSeg),(!e.buffer||e.buffer.byteLength<1)&&r._onTimeUpdate());var t=e.buffer,i=e.state,a=e.context,o=e.videoTrack,s=e.audioTrack;try{var l=r.mp4.cachePreloadData(e),u=l.needCache,h=l.preloadData;if(u){var p=r.player.preloader;if(p){var g=r.player.curDefinition,v=r._getPreloadMeta(g);h.codecType=r.codecType,h.definition=g.definition;var m=p.getDataUniqueKey(v);h.cacheKey=m,p.getItem(v,!0).then(function(e){p.setItem(v,Object.assign({},e||{},(0,n._x)({},m,h)),!0)})}}}catch(e){}if(r.debugInfo.loadIndx=a?a.fragIndex:-1,r.mse){if(i&&(!t||(null==t?void 0:t.byteLength)<=0)&&null!==(E=r.mp4)&&void 0!==E&&E.checkIsLoadEnd(null===(S=a.range)||void 0===S?void 0:S[1])){var y=r.player.buffered;r._loadedEnd=!0;var T=0;y&&(null==y?void 0:y.length)>0&&(T=y.end(y.length-1)),r._isEnded(),r.log(d._.LOG,"loaded ended !!!==>>>","range: ".concat(JSON.stringify(a.range)),"fragIndex: ".concat(a.fragIndex),"bufferEndTime: ".concat(T),"meta_duration: ".concat(r.mp4.meta.duration))}if(t&&(null==t?void 0:t.byteLength)>0){r._appendBuffer(f.d1.VIDEO,t,a,i);var b=r.getDataBitRate(a.fragIndex);r.player.emit("addVideoBufferEnd",{start:Math.floor(a.startPts),end:a.endPts,bandwidth:b.bitrate})}}else if(r.mseProxy&&(o&&o.samples.length>0||s&&s.samples.length>0)){if(o.editListApplied){var E,S,k,R=o.editList,x=o.samples,w=0;(null==R||null===(k=R.entries)||void 0===k?void 0:k.length)>0&&(w=R.entries[0].media_time),x.forEach(function(e){e.dts+=w,e.pts+=w,e.originDts+=w,e.originPts+=w}),o.baseMediaDecodeTime+=w}r.log(d._.LOG,"[xgvideo] append","index: ".concat(a.fragIndex),"range: ".concat(JSON.stringify(e.context.range)),"timeRange: ".concat(a.timeRange)),r.mseProxy.appendBuffer(o,s)}}catch(e){r.changeState("APPEND_DATA_ERROR",{errMsg:null==e?void 0:e.message});var L=new c.Errors(r.player,{errorType:_.iR.MEDIA,errorCode:_.O1.mseAppend,vid:r.playerConfig.vid,errorMessage:e.message,mediaError:{code:_.O1.mseAppend,message:e.message}});r._errorHandler(L)}null!=e&&e.state&&r._onTimeUpdate()}}),(0,n._x)(r,"_onResumePlaying",function(){r._resumePlay=!0}),(0,n._x)(r,"_seekOnce",function(e){var t=r.player;if(!!t)t.currentTime=e+.1*Math.pow(2,r._currentSeekTimes||0),r._currentSeekTimes++,r.log(d._.LOG,"当前第".concat(r._currentSeekTimes,"次Seek,currentTime=").concat(null==t?void 0:t.currentTime))}),(0,n._x)(r,"_onWaiting",function(){r.checkReStartTimer(),r._isEnded();var e,t=JSON.stringify(r.getAllBufferRange());r.changeState("waiting",{curtime:r.player.currentTime,buffer:t});var n=r.player,i=r.config,a=r.playerConfig,o=r.mp4;clearTimeout(r._waitInBufferTimer),r._waitInBufferTimer=null;var s=n.currentTime;r.log(d._.LOG,",[onWaiting],curTime, ",s,",buffer,",t,",dur,",null==o||null===(e=o.meta)||void 0===e?void 0:e.duration);var l=n.bufferedPoint;l.end>0&&(l.end-s>=2||r._loadedEnd)?r._waitAdjustTimeCnt=0&&(o.seekTimeAfterMetaReady=u),e.abrupt("return");case 15:if(r._startProgress(),o.bufferUsedPos=0,o.metaLoading=!1,r._loadedEnd=!1,r._definitionChangePointInfo&&(r._definitionChangePointInfo.changeStartTime=u,r.log(d._.LOG,"[seeking update definitionChangePointInfo]",u)),o.changeBitRateTime>0&&(o.updateChangeBitRateTime(u),r.log(d._.LOG,"[seeking update changeBitRateTime]",u)),h=0,!(c.end>0)){e.next=30;break}if(!(r.isSeekingInSameBuffer(u,c)&&(!l.enableMsePatches||o.checkInAdaptTimeRange(c)))){e.next=26;break}return r.log(d._.LOG,"[seeking in buffered], linear buffer, curTime: ".concat(u,", buffered: ").concat(c.start,"-").concat(c.end)),e.abrupt("return");case 26:o.seekTime=c.end,r.log(d._.LOG,"[seeking in buffered], but is not continuous: ".concat(c.start,"-").concat(c.end)),e.next=32;break;case 30:o.seekTime=u,r.log(d._.LOG,"[seeking out buffered], seekTime: ".concat(u));case 32:return p=o.getFragmentIdx(o.seekTime),h=(g=r.getAdaptTimeRangeIdx(p))<0?r._curLoadSegmentIdx:g,o.seekTime===u&&null!=s&&s.isFull()&&(m=(v=r.getAllBufferRange())[v.length-1],r._checkRemovePlayedBuffer([m.start,m.end],u,!0,!0)),r.log(d._.LOG,"[seekTime resetFragmentLoadState], adaptIdx: ".concat(h)),o.resetFragmentLoadState(h),null==s||s.clearOpQueues(f.d1.VIDEO,!!l.enableMsePatches),1===a.changeDefinitionSeekState?null==s||s.remove(f.d1.VIDEO,0,1/0).then(function(){a.changeDefinitionSeekState=2,r.log(d._.LOG,"[seeking], changeDefinitionSeek remove buffer end, changeDefinitionSeekState = 2")}):l.removeBufferAtSeek&&(y=o.seekTime,_=1/0,r.log(d._.LOG,"[seeking mse remove], ".concat(y,"-").concat(_)),null==s||s.remove(f.d1.VIDEO,y,_)),r.canDownload=!1,e.next=43,o.cancelLoading();case 43:r.canDownload=!0,o.fillFirstSegment=!1,r._curLoadSegmentIdx=h,r._onTimeUpdate(),r._isEnded();case 48:case"end":return e.stop()}},e)}))),r.initLog(null===(t=r.player.playerId)||void 0===t||null===(t=t.toString())||void 0===t?void 0:t.slice(-4)),r.log(d._.LOG,"plugin version: ".concat(L.i),"playerId: ".concat(r.playerId),"vid: ".concat(r.playerConfig.vid)),r._pendingPromises=[],r._allInitPromise=new w.Z,r._isInit=!1,r._isEventInit=!1,r.preloader=null,r._useVideoLoad=!1,r.mse=null,r.mp4=null,r.eme=null,r._isMseInit=!1,r._corePromise=null,r._initPromise=null,r._hasStartProgress=!1,r._hasStartProgressBack=!1,r._curLoadSegmentIdx=0,r._abrService=null,r._checkRemoveBufferLastTime=k.Z.nowTime(),r.playFlag=!1,r.config.resumePlayWaterLevel=Math.min(r.config.minBufferLength,r.config.resumePlayWaterLevel),r.checkResumePlayTimer=null,r._MSEError=!1,r._waitAdjustTimeCnt=0,r._waitInBufferTimer=null,r.isActive=!0,r.debugInfo={},r.seekTimeAfterMetaReady=void 0,r._suspendLoading=!1,r.states=[],r.removeVideoList=[],r._lastCheckTime=k.Z.nowTime(),r._lastCheckLagTime=k.Z.nowTime(),r._changeDefState=null,r._defInited=!1,r._removeBuffEndTime=0,r._lastTimeupdateTime2=0,r.waitLevelStartTime=-1,r.preLoadData=null,r.forPreloadTimeCache=null,r._usePaused=!1,r.hitpreload=!1,r.isH265DegradeH264=!1,r.loadstartTimer=null,r.loadedmetadataTimer=null,r.loadeddataTimer=null,r.canplayTimer=null,r.adaptRangeRes=[],r._definitionChangePointInfo=null,r._lastTimeupdateTime2=0,r.waitLevelStartTime=-1,r.timerStepList=[],r._isH265SoftDecoder=!1,r._beforeLoadStartCostTime=0,r._requestTimer=null,r.firstFrameCostTime={},r._mediaCodec={videoCodec:"",audioCodec:""},r._setTimelineData(),r._updatePropsByConfig(),r.player._customExpiryCheck=r.config.enableCusExpiryCheck,r._bindSrcTiming=m.Iv.META_READY,r}return(0,n.XW)(H,e),(0,n.qH)(H,[{key:"_setTimelineData",value:function(){this._startTimelines={startstage:-1,startmessage:"",httpCode:-1,httpError:[],reqtime:-1,downgradetime:-1,fcost:-1,ffcost:-1,startbufferlength:-1,playerError:"",startdelta:-1,loadstarttime:-1,loadeddatatime:-1,loadstarttype:-1,loadeddatatype:-1,playtime:-1,playerstate:-1},this._hasFirstFramed=!1}},{key:"setConfig",value:function(e){this.config=Object.assign(this.config,e),this._updatePropsByConfig()}},{key:"_updatePropsByConfig",value:function(){this._maxBufferLength=this.config.maxBufferLength,this._minBufferLength=this.config.minBufferLength,this._nextBufferLength=this.config.nextBufferLength,this._switchBitRateWay=this.config.switchBitRateWay,this._tickInSeconds=this.config.tickInSeconds||m._X}},{key:"initLog",value:function(e){var t=this.config.logCacheConfig,r=t.logCacheLevel,n=t.logMaxSize;this.logger=new d.Y(H.pluginName+e,{logCacheLevel:r,logMaxSize:n}),x.i5&&d.Y.enable()}},{key:"playerlogger",value:function(e){e?d.Y.enable():d.Y.disable()}},{key:"_setStartTimelines",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._hasFirstFramed&&this._startTimelines){this._startTimelines.startstage=e,this._startTimelines.startmessage="".concat(a.sm[e]||"","-").concat((null==t?void 0:t.message)||"");var r=this._startTimelines.httpCode;this._startTimelines.httpCode=-1!==r?r:(null==t?void 0:t.httpCode)||-1,e===a.l1.PLAYER_ERROR&&(this._startTimelines.playerError=(null==t?void 0:t.message)||"")}}},{key:"afterCreate",value:function(){var e=this,t=this.playerConfig,r=this.config,i=this.player;if(r.width=t.width||0,r.height=t.height||0,t.vid=t.vid||r.vid,"object"!==(0,n.Ac)(r.reqParams)&&(r.reqParams={}),!f.d1.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){this._setStartTimelines(a.l1.NOT_SUPPORTED);return}void 0===r.supportHevc&&null!==c.Sniffer&&void 0!==c.Sniffer&&c.Sniffer.isHevcSupported&&c.Sniffer.isHevcSupported()&&this.player.video instanceof HTMLVideoElement&&(r.supportHevc=!0),void 0===r.supportVvcc&&(r.supportVvcc=(0,R.E0)()),this.softDecode?i.vtype=a.l0.MP4_MSE_SOFT:i.vtype=a.l0.MP4_MSE,(!(0,R.KI)()||this.softDecode)&&(r.useEME=!1),r.useEME=!1!==r.useEME,this.checkConfig(),r.onlyInit&&(t.autoplay=!1,t.videoInit=!1,this._hasStartProgress=!1,this._hasStartProgressBack=!1),t.useWaterLevel&&(t.userGestureEventMiddleware||(t.userGestureEventMiddleware=S.Ru),t.videoEventMiddleware||i.setEventsMiddleware(S.f4)),this._proxyPlayer(),i.useHooks("replay",this._replayHook),i.useHooks("play",this._playHook),i.useHooks("pause",this._pauseHook),i.useHooks("retry",this._retryHook),this.on("source_error",this._onSourceError),this.on("error",this._onSourceError),i.video.addEventListener(m.fD.BUFFERED_RESET,this._onBufferedReset),this._bindNetworkStateChange(),this.on(c.Events.TIME_UPDATE,this._onVideoTimeUpdate),this.on(c.Events.LOADED_DATA,function(){var t;-1===e._startTimelines.loadeddatatime&&(e._startTimelines.loadeddatatime=k.Z.nowTime(),e._startTimelines.loadeddatatype=i.vtype===a.l0.MP4_MSE?1:2),e.loadedDataEventRev=!0,e.changeState("LOADED_DATA"),e.deleteVideo(),e.mp4&&e.mp4.updateLoadedDataDone(),e._onTimeUpdate(),null!==(t=e.config)&&void 0!==t&&t.enableFPSStuckHandle&&e.on(c.Events.FPS_STUCK,e.fpsStuckHandle)}),this.on(c.Events.LOAD_START,function(){e.changeState("LOAD_START"),e._bindSrcTiming===m.Iv.META_READY?e._beforeLoadStartCostTime=new Date().getTime()-e._tm:e._beforeLoadStartCostTime=0,e.log(d._.LOG,"mp4plugin loadstart",e._beforeLoadStartCostTime),-1===e._startTimelines.loadstarttime&&(e._startTimelines.loadstarttime=k.Z.nowTime(),e._startTimelines.loadstarttype=i.vtype===a.l0.MP4_MSE?1:2),e.codecType===a.u7.H265&&!e.config.supportHevc&&(e._isMseInit=!0,e._onTimeUpdate())}),this.on(c.Events.ENDED,function(){e.log(d._.LOG,"mp4plugin receive player video ended event"),e._onEnded()}),this.on(c.Events.PAUSE,function(){e._usePaused=!0}),this.on(c.Events.PLAY,function(){e._usePaused=!1}),this.on(c.Events.AUTOPLAY_STARTED,function(){e._startTimelines&&(e._startTimelines.playtime=k.Z.nowTime())}),this.on("xglog",function(t){if("firstFrame"===t.eventType){var r,n=e.preLoadData&&e.preLoadData.definition?e.preLoadData.definition:-1,i=e.player;e._startTimelines.fcost=k.Z.nowTime()-e._startTimelines.reqtime,e._startTimelines.ffcost=t.fvt,e._hasFirstFramed=!0,e.log(d._.DEBUG,"[xgplayer-encrypt-mp4]>>>>firstFrame ".concat(e.playerConfig.vid,", ").concat(t.fvt,", codecType: ").concat(e.codecType),"hitPreload: ".concat(e.hitpreload,", video: ").concat(e._useVideoLoad,", preloadBitrate: ").concat(n),"curDefinition: ".concat(null===(r=i.curDefinition)||void 0===r?void 0:r.definition))}}),i.mp4MseFlag=!0}},{key:"_startBufferCheck",value:function(){var e=this.player;if(!e.video)return;var t=[];if(!!e.video.buffered){for(var r=0,n=e.video.buffered.length;r=t.bufferThreshold&&!this._hasTriggerBufferThreshold&&(this._hasTriggerBufferThreshold=!0,e.emit("BUFFER_THRESHOLD",i-e.video.currentTime))}}},{key:"_startUrlExpiredCheck",value:function(){var e,t,r,n=this.player;if(null!==(e=this.expiryCheckPlugin)&&void 0!==e&&null!==(e=e.config)&&void 0!==e&&e.useCdnExpiryTime){null===(t=(r=this.expiryCheckPlugin).handleUrlExpiryCheckByCdnPath)||void 0===t||t.call(r);return}var i=n.config;i.definition&&i.definition.list&&i.definition.list.length>0&&(this.urlExpireTimestamp=i.definition.list[0].url_expire||0,this._handleUrlExpire())}},{key:"cancelLoading",value:(t=(0,n.x)((0,n.l5)().mark(function e(){var t,r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mp4){e.next=2;break}return e.abrupt("return");case 2:return this._cancelLoading=!0,this.log(d._.LOG,"player cancelLoading",this.playerConfig.vid),this._stopProgress(),null===(t=this.preloader)||void 0===t||null===(r=t.cancelLoading)||void 0===r||r.call(t),e.next=8,this.mp4.cancelLoading();case 8:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"suspendLoading",value:function(){var e,t=this.mp4;if(!!t&&!this._suspendLoading)this._suspendLoading=!0,this.log(d._.LOG,"player suspendLoading",this.playerConfig.vid),this._stopProgress(),null!=t&&null!==(e=t.adaptTimeRange[this._curLoadSegmentIdx])&&void 0!==e&&e.isLoading&&(t.resetFragmentLoadState(this._curLoadSegmentIdx,!0),this.cancelLoading())}},{key:"resumeLoading",value:function(){if(!!this.mp4&&!!this._suspendLoading)this._suspendLoading=!1,this.log(d._.LOG,"player resumeLoading",this.playerConfig.vid),this._startProgress()}},{key:"checkConfig",value:function(){var e=this.playerConfig,t=this.config,r=e.defaultDefinition,n=e.defaultBitrate;if(!r){var i=this.playerConfig.definition;r=i&&i.defaultDefinition?i.defaultDefinition:t.definition}!n&&t.bitrate&&(n=t.bitrate),e.defaultDefinition=r,e.defaultBitrate=n}},{key:"beforePlayerInit",value:function(){var e=this,t=this.player,r=this;!this._isInit&&(c.BasePlugin.defineGetterOrSetter(t,{__url:{get:function(){return r.mse?r.mse.url:t.config.url},configurable:!0},downloadSpeed:{get:function(){return B/8},configurable:!0},playerVersion:{get:function(){return L.i},configurable:!0},menuCodeType:{get:function(){return r.mp4&&r.mp4.meta?r.mp4.meta.videoCodec:r.codecType===a.u7.H264?"avc":"hevc"},configurable:!0},playerType:{get:function(){return"MP4"},configurable:!0},supportMenus:{get:function(){return{speed:null==t?void 0:t.mp4MseFlag,cdn:null==t?void 0:t.mp4MseFlag,resolution:null==t?void 0:t.mp4MseFlag}},configurable:!0},preloadActive:{get:function(){return e.isActive},set:function(t){e.isActive=t,e.isActive&&e._startProgress()},configurable:!0},performance:{get:function(){var t={};return e.states.forEach(function(e){t[e.state.toLowerCase()]=e.t2}),t},configurable:!0},domain:{get:function(){return r.domain},configurable:!0},loadURL:{get:function(){return r.loadURL},configurable:!0},abrInstance:{get:function(){return r.abrInstance},configurable:!0},pcdnReq:{get:function(){var e=o.e.pcdnReqCnt,t=T.Yx.pcdnDownLoadReqCnt;return{pcdn_tracker_request_cnt:e.pcdn_tracker_request_cnt,pcdn_tracker_failed_cnt:e.pcdn_tracker_failed_cnt,pcdn_download_request_cnt:t.pcdn_download_request_cnt,pcdn_download_failed_cnt:t.pcdn_download_failed_cnt}},configurable:!0},retryInfo:{get:function(){return T.Tw},configurable:!0},softDecoder:{get:function(){return e._isH265SoftDecoder},configurable:!0},logCache:{get:function(){if(!!r.logger){var t,n,i,a="";try{a=JSON.stringify(e.config)}catch(e){a="config stringify error"}return r.log(d._.LOG,"timerStepList, ".concat(JSON.stringify(e.timerStepList),",\n currentTime: ").concat(null===(t=r.player)||void 0===t?void 0:t.currentTime,"\n buffer, ").concat(JSON.stringify(r.getAllBufferRange()),",\n state: ").concat(JSON.stringify(r.states),",\n isActive:").concat(r.isActive,",\n preRangeType: ").concat(null===(n=r.player)||void 0===n||null===(n=n.preloader)||void 0===n||null===(n=n._config)||void 0===n?void 0:n.loadRangeType,",\n loadRangeType: ").concat(null===(i=r.config)||void 0===i?void 0:i.loadRangeType,",\n Mp4EncryptPlayer version, ").concat(L.i,",\n Mp4EncryptPlayer config, ").concat(a)),r.logger.getLogCache()}},configurable:!0},pcdnVVStat:{get:function(){var e,t=r.mp4,i=r.pcdn;return t?(0,n.Zj)((0,n.Zj)({},t.pcdnVVStat),{},{trace_id:null===(e=t.pcdnTraceInfo)||void 0===e?void 0:e.trace_id,cancelCnt:(null==t?void 0:t.pSCCancelCnt)||0,is_try_open:i?1:0}):null},configurable:!0},beforeLoadStartCostTime:{get:function(){return e.useVideoLoad?0:e._beforeLoadStartCostTime},configurable:!0},mediaCodec:{get:function(){return e._mediaCodec},configurable:!0},bandwidth:{get:function(){var e,t,i=r.mp4,a=i?i.loadInfo:null;return{vid:null===(e=r.playerConfig)||void 0===e?void 0:e.vid,cdn:{speed:null==a||null===(t=a[T._R.CDN])||void 0===t?void 0:t.loadSpeed,size:a&&a[T._R.CDN]?a[T._R.CDN].loadLen:0},pcdn:(0,n.Zj)({size:a&&a[T._R.PCDN]?a[T._R.PCDN].loadLen:0},null==i?void 0:i.pcdnTraceInfo)}},configurable:!0},ext:{get:function(){var e,t,n,i,a,o,s,l,u=[];if((null===(e=r.player)||void 0===e||null===(e=e.video)||void 0===e||null===(e=e.buffered)||void 0===e?void 0:e.length)>0){for(var c=r.player.video.buffered,d=0,f=(null==c?void 0:c.length)||0;d0){var i={},a=e.preloader;if(a){var o=a.getPreloadMetaByVid(t.vid);if(o){var s=a.getDataUniqueKey(o),l=(0,S.Vh)(o,n);l?(l.cacheKey=s,(r=l).type="preload",r.preLoadMeta=o,i={m:1,t:2,ck:s}):i={m:0,t:1,ck:s}}}else i={t:0};if(this.changeState(m.fp.PRELOAD_CHECK,i),r&&t.userSelectDefinition&&t.focusUserDefinition){var u={m:1,ud:t.userSelectDefinition,d:r.definition};t.userSelectDefinition!==r.definition&&(r=null,u.m=1),this.changeState(m.fp.USER_DEFI_CHECK,u)}!r&&this.bitRateAdapter&&(this.bitRateAdapter.speed=T.Yx.speed,(r=this.getDefinitonFromAdapter(n,t.userSelectDefinition))&&(r.type="bitRateAdapter"))}if(!r||!r.url){var d,f=(null===(d=t.definition)||void 0===d?void 0:d.defaultDefinition)||t.defaultDefinition;if("Array"===c.Util.typeOf(t.url)&&t.url.length>0||"String"===c.Util.typeOf(t.url)&&t.url){var h=this._getDefinitionItem(f),p=t.defaultBitrate||t.bitrate||(null==h?void 0:h.bitrate);r={url:t.url,definition:(null==h?void 0:h.definition)||f||-1,duration:(null==h?void 0:h.duration)||t.duration||this.config.duration||0,bitrate:p,uri:t.uri||(null==h?void 0:h.uri),file_id:null==h?void 0:h.file_id,size:(null==h?void 0:h.size)||t.size,type:"default"}}else r=n[n.length-1]}return this.playerConfig.url=r.url,r.networkSpeed=T.Yx.speed,e.curDefinition=r,r}},{key:"_setPlayerSrc",value:function(e){var t=this.player;this._removeVideoSource();var r="Array"===c.Util.typeOf(e);e=r?this._processArrayUrl(e):this._processUrl(e),r?(t.video.removeAttribute("src"),t._detachSourceEvents||e.forEach(function(e){t.video.appendChild(c.Util.createDom("source","",{src:"".concat(e.src),type:"".concat(e.type||"")}))}),t._attachSourceEvents(t.video,e)):t.video.src=e,t.play(),t.mp4MseFlag=!1,t.emit("playertypechange"),this._startTimelines.downgradetime=k.Z.nowTime()}},{key:"_removeVideoSource",value:function(e){var t=this.player,r=(e=e||t.video).children;if(r.length>0)for(t._detachSourceEvents(e);r.length>0;)e.removeChild(r[0])}},{key:"_getDefinitionItem",value:function(e){var t=this.playerConfig;if(!t.definition||!t.definition.list)return null;for(var r=0;r0&&(!t.curDefinition&&(t.curDefinition=r.definition.list[0]),!t.curDefinition.vwidth&&Object.assign(t.curDefinition,this._getDefinitionItem(t.curDefinition.definition)),this._abrService.updateAbrCacheData()),this._abrService&&this._abrService.isCurrentAutoDefi){var n=r.definition.list.length;t.curDefinition=r.definition.list[n-1]}for(var i=0;i0&&(t.length>1&&(!r.keyValue&&t[0].secretKey&&(r.secretKey=t[0].secretKey),r.decryptKey=t[0].decryptKey),o=t[t.length-1].data),!o&&r.needPreloadCheck&&(e.codecType!==a.u7.H265||r.supportHevc))e.useVideoLoad=!0,e.log(d._.LOG,"no_preload"),n.reject(Error("no_preload"));else if(e.vtype&&"MP3"===e.vtype)e.useVideoLoad=!0,e.log(d._.LOG,"vtype_not_MP4"),n.reject(Error("vtype_not_MP4"));else{var s,l=r._mainURL;e._initMp4(l,o,{fileSize:i?i.size:0}),e.updateLoadInfo(null===(s=o)||void 0===s?void 0:s.cacheKey),e.checkPCDN(),e.initAdaptRange(),e._initAbrService()}}).catch(function(r){e.log(d._.ERROR,"getLicense or checkPreloader reject",null==r?void 0:r.message,null==r?void 0:r.stack);var a,o,s,l=(null==r||null===(a=r.error)||void 0===a?void 0:a.code)||("getLicense"===r.method?_.O1.custom_drm:_.O1.other),u=(null==r?void 0:r.message)||(null==r||null===(o=r.error)||void 0===o?void 0:o.message)||"getLicense or checkPreloader reject";"getLicense"===r.method?(s=new c.Errors(e.player,{errorType:_.iR.DRM,errorCode:l,errorMessage:u,vid:t.vid}),e.emit("GET_LICENSE_ERROR",s),e.changeState("LICENSE_ERROR",{d:i?i.definition:0})):s=new c.Errors(e.player,{errorType:_.iR.OTHER,errorCode:l,errorMessage:u,vid:t.vid}),n.reject(s)})}catch(e){n.reject(e)}return n}},{key:"updateLoadInfo",value:function(e){var t;if(!!e&&!!this.mp4)this.mp4.loadInfo=null===(t=this.preloader)||void 0===t?void 0:t.getLoadInfoAndDelete(e)}},{key:"initAdaptRange",value:function(){var e=this.config,t=this.player,r=this.playerConfig,n=t.curDefinition,i=n.bitrate,a=n.duration;null!=e&&e.adaptRange&&(this.adaptRange=new s.Q(t,i,a||r.duration,e.adaptRange))}},{key:"getPCDNReqId",value:function(){var e=this.player.curDefinition,t=this.playerConfig.vid;return e.uri?e.uri.slice(-20)+e.bitrate:t?t.slice(-20)+e.bitrate:void 0}},{key:"checkPCDN",value:function(){var e,t=this,r=this.config,n=this.player,i=this.mp4,a=n.curDefinition;if(null!==(e=r.pcdnConfig)&&void 0!==e&&e.openPCDN&&a.duration>=r.pcdnConfig.minDuration){r.pcdnConfig.app_id&&(m.tE.app_id=r.pcdnConfig.app_id),r.pcdnConfig.sid&&(m.tE.sid=r.pcdnConfig.sid);var s,l=r._mainURL;if(!a.uri||!a.bitrate||0>=l.indexOf("video/")){this.log(d._.LOG,"uri null or bitrate null or url not contain video cannot use pcdn"),this.pcdn=null;return}!(0,S.Pj)(l)&&(l=document.location.protocol+l);var u={vid:a.uri,sfid:a.file_id,cdn_url:l,file_type:null===(s=this.vtype||"MP4")||void 0===s?void 0:s.toLowerCase(),bitrate:a.bitrate,duration:Math.floor((null==a?void 0:a.duration)||0),size:(null==a?void 0:a.size)||k.Z.getFileSize(a.bitrate,a.duration)};if(this.pcdn)this.pcdn.resetTrackeArgs();else{var c=Object.assign({},{productConfig:m.tE},r.pcdnConfig),f=u.bitrate,h=u.duration;this.pcdn=new o.e(c,n,f,h)}this.pcdn.fetchPCDNNode(null,u,this.getPCDNReqId()).then(function(e){var r,n,a=t.getPCDNReqId();if(null!=e&&e.req_id&&a!==e.req_id){t.log(d._.LOG,",fetchPCDNNode is not match curDefinition reqId",a,", pcdnRet.req_id",e.req_id);return}i&&e&&(t.log(d._.LOG,"".concat(t.playerConfig.vid," get peer end,pcdn node update,"),null==e||null===(r=e.nodes)||void 0===r?void 0:r.length),i.updateNode(null==e?void 0:e.nodes),i.pcdnTraceInfo={uri:e.vid,fid:e.fid,trace_id:null==e?void 0:e.trace_id},i.pcdnVVStat&&(i.pcdnVVStat.try_req_node+=1,i.pcdnVVStat.req_node_succ+=1,i.pcdnVVStat.has_ret_node+=(null==e||null===(n=e.nodes)||void 0===n?void 0:n.length)>0?1:0))}).catch(function(e){(null==i?void 0:i.pcdnVVStat)&&(i.pcdnVVStat.try_req_node+=1),t.checkURLExpired(e,"_fetchPCDNNode")})}else this.pcdn=null}},{key:"initTimer",value:function(){if(!this._requestTimer){var e=this.config.timerInWorker;this._requestTimer=new y.f({frequency:this._tickInSeconds,timerInWorker:e}),this._requestTimer.on(m.sW,this.timerHandle)}}},{key:"playerStartInit",value:(u=(0,n.x)((0,n.l5)().mark(function e(t){var r,o,s,l,u,h,p,g,v,y,T,b,E,S,R,x,w,L,P,A,O,I,M,N,B,U,F,V,G=this;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log(d._.LOG,"playerStartInit",this.player.hasStart,this.playerId,t),!this.isDestroy){e.next=4;break}return this._setStartTimelines(a.l1.START_INIT_DESTROY),e.abrupt("return");case 4:if(r=this.playerConfig,o=this.player,s=this.config,this.states=[],this._sTime=k.Z.nowTime(),this._lastBufferPoint=void 0,this._usePaused=!1,this.isActive&&(null==o?void 0:o.currentTime)!==0&&(this.log(d._.LOG,"[playerStartInit] reset current = 0 ,buffer,",JSON.stringify(null==o||null===(l=o.buffered2)||void 0===l?void 0:l.bufferedList)),this.player.currentTime=0),this._isH265SoftDecoder=this.softDecode,s.reUseMSE&&this.mse&&"String"===c.Util.typeOf(t)&&/^blob/.test(t)&&t!==this.mse.url&&(t=r.url,this._destroyMSE()),(!t||"__auto__"===t||"anytext"===t)&&(u=r.definition)&&u.list&&u.list.length>0&&u.defaultDefinition&&(u.list.map(function(e){e.definition===u.defaultDefinition&&(r.url=e.url,G.player.curDefinition=e)}),(!r.url||"__auto__"===t||"anytext"===t)&&(t=(h=u.list[0]).url,r.url=h.url,u.defaultDefinition=h.definition,this.player.curDefinition=h)),this.initTimer(),p=o.oldBit,g=this._defInited?null:this.getInitBitrate(),o.oldBit=null==o||null===(F=o.curDefinition)||void 0===F?void 0:F.bitrate,!(!o.changeDefinitionFlag&&p&&p!==(null==o||null===(V=o.curDefinition)||void 0===V?void 0:V.bitrate))){e.next=23;break}if(!this.mp4){e.next=22;break}return this.canDownload=!1,e.next=22,this.mp4.cancelLoading();case 22:if(this.mse){this.once(c.Events.LOAD_START,function(){G.log(d._.LOG,"playerStartInit changeBtrate changeDefinitionSeekState = 1, currentTime += 0.001"),o.changeDefinitionSeekState=1,G.player.currentTime+=.001});try{this.mse.clearOpQueues(f.d1.VIDEO,!!s.enableMsePatches),this.mseAbort(),this.mse.remove(f.d1.VIDEO,0,1/0).then(function(){G.log(d._.LOG,"playerStartInit remove all buffer end")})}catch(e){this.log(d._.LOG,"playerStartInit mse func err, ".concat(null==e?void 0:e.message))}}case 23:if(o.changeDefinitionFlag=void 0,y=(v=this.config).kid,T=v.drmKeyToken,b=v.secretKey,E=v.keyValue,S=v.drm,y||T||b||E||S?this._secretkey?this._secretkey.updateConfig(this.config):(this._secretkey=new i.XGSecretKey(this.config),this._secretkey.on(i.EVENT_EME.ERROR,this._errorHandler)):this._secretkey=null,this._defInited=!0,this.log(d._.LOG,"[playerStartInit] ".concat(r.vid," curDefinition"),g||this.player.curDefinition),x=(R=this.player).preloader,w=R.playerId,x&&x.addPlayingId(r.vid,w),s.needPreloadCheck&&!this.softDecode&&!this._secretkey&&(L=!1,P="",x&&(A=this.player.curDefinition,O=this._getPreloadMeta(A),I=x.hasItemSameVid(O),P=x.getDataUniqueKey(O),I&&(L=!0)),!L&&(M=x?"no preload data":"no preloader",this.useVideoLoad=!0,this.player.vtype=a.l0.MP4_0,this._setStartTimelines(a.l1.NO_PRELOAD,{message:a.l0.MP4_0}),this.log(d._.LOG,"[playerStartInit] ".concat(r.vid," ").concat(M),!!x),N=new c.Errors(this.player,{errorType:"runtime",errorTypeCode:_.iR.runtime,errorCode:_.O1.other,vid:this.playerConfig.vid,errorMessage:M}),this.changeState(m.fp.PRELOAD_MATCH,{m:0,ck:P}),this.player.emit("playCatch",this.player.vtype,N))),!this.useVideoLoad){e.next=39;break}if(t=this.playerConfig.url,!s.closeDowngrade){e.next=36;break}return this._setStartTimelines(a.l1.CLOSE_DWNGRADE,{message:"isDestroy"}),e.abrupt("return");case 36:return this._playerStartInitCall(t),this._startProgress(),e.abrupt("return");case 39:if(!this.isDestroy){e.next=42;break}return this._setStartTimelines(a.l1.START_INIT_DESTROY,{message:"isDestroy"}),e.abrupt("return");case 42:this.player.mp4MseFlag=!0,this._tm=new Date().getTime(),this._reset(),B=this.playerConfig.vid,this.changeState("PLAYER_START_INIT"),this.mse||s.bindSrcTiming!==m.Iv.INIT?this._bindSrcTiming=m.Iv.META_READY:(this._bindSrcTiming=m.Iv.INIT,this.log(d._.LOG,"playerStartInit new MSE",this._bindSrcTiming),this.mse=new f.d1(this.player.video)),U=this._initMp4Kernel(),this._initPromise=U,this._addPendingPromise(this._initPromise),U.then(function(){if(G.isDestroy){G._setStartTimelines(a.l1.START_INIT_DESTROY,{message:"then destroy"});return}G.mse&&(t=G.mse.url),G.changeState("PLAY_INIT_OK"),G._bindEvents(),G._startProgress()}).catch(function(e){var r,n,i=!!G._initPromise&&G._initPromise.isBreak;if(G.isDestroy||i||e===D){var o="isDestroy:".concat(G.isDestroy,",isBreak:").concat(i,",e:").concat(e);G._setStartTimelines(a.l1.INIT_PROMISE_CATCH,{message:o});return}if(G.log(d._.LOG,"_initMp4Kernel.catch: ".concat(B," isDestroy:").concat(G.isDestroy,",\n errorCode:").concat((null==e?void 0:e.errorCode)||_.O1.other,",errMsg:").concat((null==e?void 0:e.errorMessage)||(null==e?void 0:e.message))),(null==e?void 0:e.errorCode)===_.O1["403"]&&(G._setStartTimelines(a.l1.HTTP_ERROR,{message:"request 403",httpCode:403}),G._emitExpireEvent(e)&&s.urlExpireDisableErrorEvent)){G._initPromise=null,G.log(d._.LOG,"initMp4Kernel urlExpireDisableErrorEvent",s.urlExpireDisableErrorEvent,",errorCode,",e.errorCode),G._stopProgress(),G.emit(C);return}var l=e;!l.errorCode&&((l=new c.Errors(G.player,{errorType:_.iR.RUNTIME,errorCode:(null==e?void 0:e.errorCode)||_.O1.other,vid:G.playerConfig.vid,errorMessage:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),mediaError:{code:(null==e?void 0:e.httpCode)||_.O1.other,message:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),errorType:null==e?void 0:e.errorType}})).url=t),G._setStartTimelines(a.l1.INIT_PROMISE_CATCH,{message:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message)}),G.changeState("PLAY_INIT_CATCH",{c:l.errorCode,m:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),t:null==e?void 0:e.errorType}),G.useVideoLoad=!0,G.player.vtype=a.l0.MP4_1,G.player.emit("playCatch",G.player.vtype,l);var u=G.checkIsDegraded(l);if(G.log(d._.WARN,"PLAY_INIT_CATCH final error !!!!, ",B,null===(r=l)||void 0===r?void 0:r.errorCode,null===(n=l)||void 0===n?void 0:n.errorMessage,",degrade:",u),G.emit(C),!u){G.player.pause(),G._reset(),G.states=[],G.emit("error",l),G._initPromise=null;return}}).finally(function(){if(!!G._initPromise){var e,r=G._initPromise.isBreak;G._initPromise&&G._removePendingPromise(G._initPromise),G._initPromise=null,G._usePaused&&(G.playerConfig.autoplay=!1),G.softDecode&&"Array"===c.Util.typeOf(t)&&(t=t[0].src),"String"===c.Util.typeOf(t)&&!/^blob/.test(t)&&G._destroyMSE();var n=(null===(e=G.player)||void 0===e?void 0:e.currentSrc)===t;G.changeState("PLAY_INIT_FINALLY",{isDestroy:G.isDestroy,isBreak:r,reUseSrc:n}),G.isDestroy||r||G._playerStartInitCall(t),G._bindSrcTiming===m.Iv.META_READY&&G.reUseMSEEmitEvents(n),G._abrService&&G._abrService.isCurrentInAbr()&&(G._abrService.enable(),G._abrService.execute())}});case 52:case"end":return e.stop()}},e,this)})),function(e){return u.apply(this,arguments)})},{key:"_playerStartInitCall",value:function(e){e="Array"===c.Util.typeOf(e)?this._processArrayUrl(e):this._processUrl(e),I.call(this.player,e),this._startTimelines.downgradetime=k.Z.nowTime()}},{key:"_destroyMSE",value:function(){var e=this;if(!!this.mse)try{this.mse.clearOpQueues(f.d1.VIDEO,!!this.config.enableMsePatches);var t=this.config.enableMsePatches?this.mseAbort():this.mse.abort();if(!t)return;t.then((0,n.x)((0,n.l5)().mark(function t(){var r,i;return(0,n.l5)().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null===(r=e.mse)||void 0===r?void 0:r.unbindMedia();case 2:e.mse&&e.log(d._.LOG,"destroyMSE ",null===(i=e.playerConfig)||void 0===i?void 0:i.vid),e.mse=null;case 4:case"end":return t.stop()}},t)}))).catch(function(){})}catch(e){}}},{key:"reUseMSEEmitEvents",value:function(e){var t,r=this;e&&/^blob/.test(null===(t=this.player)||void 0===t?void 0:t.currentSrc)&&(clearTimeout(this.loadstartTimer),clearTimeout(this.loadedmetadataTimer),clearTimeout(this.loadeddataTimer),clearTimeout(this.canplayTimer),this.loadstartTimer=setTimeout(function(){clearTimeout(r.loadstartTimer),r.loadstartTimer=null,r.emit(c.Events.LOAD_START),r.log(d._.LOG,"reUseMSE add emit loadstart event")},10),this.loadedmetadataTimer=setTimeout(function(){clearTimeout(r.loadedmetadataTimer),r.loadedmetadataTimer=null,r.emit(c.Events.LOADED_METADATA),r.log(d._.LOG,"reUseMSE add emit loadedmetadata event")},25),this.loadeddataTimer=setTimeout(function(){clearTimeout(r.loadeddataTimer),r.loadeddataTimer=null,r.emit(c.Events.LOADED_DATA),r.log(d._.LOG,"reUseMSE add emit loadeddata event")},50),this.canplayTimer=setTimeout(function(){clearTimeout(r.canplayTimer),r.canplayTimer=null,r.emit(c.Events.CANPLAY),r.log(d._.LOG,"reUseMSE add emit canplay event")},90))}},{key:"playNext",value:function(e){var t=this,r=this.player;this._setTimelineData(),this._defInited=!1,this._hasTriggerBufferThreshold=!1,r.resetState(),r._currentTime=0,r._duration=0,r.isPlaying=!1,this._useVideoLoad=!1,this._MSEError=!1;var n=this.softDecode;r.pause(),this._reset(),this.states=[];["url","vid","kid","playAuthToken","keyToken","startTime","secretKey"].forEach(function(e){delete t.config[e]}),e.vtype&&(this.vtype=e.vtype.toUpperCase()),r.setConfig(e),this.checkReUseMSE(this.config.reUseMSE),this.softDecode?r.vtype=a.l0.MP4_MSE_SOFT:r.vtype=a.l0.MP4_MSE,this.codecType=this.playerConfig.codecType?this.playerConfig.codecType.toLowerCase():a.u7.H264,n!==this.softDecode&&this.h265_h264_switch(this.playerConfig.mediaType||"video"),this.checkConfig(),this.log(d._.LOG,"[Index] playNext",e.vtype,e.vid),r.start(),this.config.reUseMSE&&!this.isH265DegradeH264&&(this.__onmetadataHandle=function(){t.log(d._.LOG,"[Index] playNext metadata update currentTime = 0"),0!==r.currentTime&&(r.currentTime=0),r.video.removeEventListener("loadedmetadata",t.__onmetadataHandle),t.__onmetadataHandle=null},r.video.addEventListener("loadedmetadata",this.__onmetadataHandle)),this.emit("playnext")}},{key:"h265_h264_switch",value:function(e){this.log(d._.LOG,"[Index],h265_switch_h264",e);var t=this.player,r=c.Util.createDom(e,"",this.getVideoConfig(this.playerConfig),"xgplayer-".concat(e,"-img"));this.removeVideoList.push(t.video),r.muted=t.video.muted,r.volume=t.video.volume,t.media?t.media=r:t.video=r,t.attachVideoEvents(t.video)}},{key:"getVideoConfig",value:function(e){var t=Object.assign({},{controls:!1,autoplay:e.autoplay,playsinline:e.playsinline,"x5-playsinline":e.playsinline,"webkit-playsinline":e.playsinline,"x5-video-player-fullscreen":e["x5-video-player-fullscreen"]||e.x5VideoPlayerFullscreen,"x5-video-orientation":e["x5-video-orientation"]||e.x5VideoOrientation,airplay:e.airplay,"webkit-airplay":e.airplay,tabindex:2,mediaType:e.mediaType||"video"},e.videoConfig,e.videoAttributes);return e.loop&&(t.loop="loop"),t}},{key:"next",value:function(e){this.playNext(e)}},{key:"oldChangeDefinition",value:(p=(0,n.x)((0,n.l5)().mark(function e(t,r){var i,a,o,s,l,u,h,p,g,v,m,y,_=this;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=this.config,a=this.player,o=this.playerConfig,a.changeDefinitionFlag=!0,a.emit(c.Events.DEFINITION_CHANGE,{from:r,to:t}),a.emit(c.Events.WAITING),l=(s=a.definitionList).filter(function(e){return e.definition===t.definition||e.definition===Number(t.definition)}),(u=s.filter(function(e){return e.definition===r.definition||e.definition===Number(r.definition)})).length>0&&(u[0].selected=!1),!(l.length>0)){e.next=13;break}(t=l[0]).selected=!0,e.next=14;break;case 13:return e.abrupt("return");case 14:return a.curDefinition=t,this.log(d._.LOG,"[oldChangeDefinition],currentTime,",a.currentTime,",from,",r,",to,",t),h=a.currentTime,(p=a.paused)&&(this.config.autoplayBack=o.autoplay,o.autoplay=!1),this._changeDefState={currentTime:h,paused:p},i.definition=t.definition,["keyValue","kid","secretKey","drm","getLicenseUrl","drmKeyToken","sessionId"].forEach(function(e){i[e]=t[e]}),e.next=24,null===(v=this.mp4)||void 0===v?void 0:v.cancelLoading();case 24:if(null===(m=this.mse)||void 0===m||m.clearOpQueues(f.d1.VIDEO,!!i.enableMsePatches),g=null===(y=this.mse)||void 0===y?void 0:y.abort(f.d1.VIDEO)){e.next=28;break}return e.abrupt("return");case 28:g.then(function(){o.url=t.url,o.userSelectDefinition=t.definition,o.defaultDefinition=t.definition,a.currentTime=0,a.pause(),_._reset(),_.states=[],_.checkReUseMSE(!1,i.enableMsePatches),_._isMseInit=!1,_.eme=null,_._handlerUrl(t.url),_.once(c.Events.CANPLAY_THROUGH,function(){void 0!==_.config.autoplayBack&&_.config.autoplayBack!==o.autoplay&&(o.autoplay=_.config.autoplayBack,_.config.autoplayBack=void 0)}),a.video.removeEventListener("loadedmetadata",_._changeDefineCanPlay),_._changeDefineCanPlay=function(){_.changeDefineCanPlay(h,p,r,t),a.video.removeEventListener("loadedmetadata",_._changeDefineCanPlay)},a.video.addEventListener("loadedmetadata",_._changeDefineCanPlay),a.video.load(),_.playerStartInit(o.url)}).catch(function(){});case 29:case"end":return e.stop()}},e,this)})),function(e,t){return p.apply(this,arguments)})},{key:"_emitDefinitionChangeDetailEvent",value:function(e){var t=this._currDefinition,r=t.bitrate,n=t.definition,i=t.file_id,a=t.width,o=t.vwidth,s=t.height,l=t.vheight;this.player.emit("definitionChangeDetail",{start:e,bitrate:r,definition:n,mediaType:"video",url:this.config._mainURL,fileid:i});this.player.emit("RESOLUTION_UPDATE",{width:a||o,height:s||l})}},{key:"getCurGopEndTime",value:function(e){var t=this.player;if(!t)return 0;var r=this.mp4,n=r.getFragmentIdx(e||t.currentTime);return r.timeRange[n].endTime}},{key:"_setCurrentDefinition",value:function(e){var t=this.player.config;if(t.definition&&t.definition.list){var r=t.definition.list.filter(function(t){return t.bitrate===e.bitrate||t.definition===e.definition});this._currDefinition=r&&r[0]}!this._currDefinition&&(this._currDefinition={})}},{key:"switchURL",value:function(e,t){var r=this;if(t&&"object"===(0,n.Ac)(t)&&t.action===A.UPDATE_URL){this._updateURL({url:null==e?void 0:e.url});return}if(this.useVideoLoad){N.call(this.player,e);return}var i=this.player,a=this.config;i.config.definition.list=[e],i.config.url=e.url,i.config.defaultBitrate=e.bitrate,i.config.defaultDefinition=e.definition;["keyValue","kid","secretKey","drm","getLicenseUrl","drmKeyToken","sessionId"].forEach(function(t){a[t]=e[t]}),this.__onmetadataHandle=function(){i.currentTime=0,i.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},i.video.addEventListener("loadedmetadata",this.__onmetadataHandle),this.playNext(a)}},{key:"_updateURL",value:function(e){var t=this.player,r=this.config,n=(e||{}).url;return!!t&&!!n&&((t.config.url=n,t.curDefinition&&(t.curDefinition.url=n),this._handlerUrl(n),!this.useVideoLoad&&this.mp4)?(this.mp4.updateUrl(r._mainURL,r._backupURL),!0):!!this.useVideoLoad&&(N.call(this.player,n),!0))}},{key:"_handlerUrl",value:function(e){var t,r=this.config,n=this.playerConfig;if(!e)return!1;var i=[];if("String"===c.Util.typeOf(e))t=e,n.backupURL&&i.push(n.backupURL);else if("Array"===c.Util.typeOf(e)&&e.length>0&&(t=e[0].src,e.length>1))for(var a=1;a=0&&e.emit("DECODER_FAILED",{codecType:e.config.codecType,vid:null===(l=e.playerConfig)||void 0===l?void 0:l.vid,message:null==t||null===(u=t.error)||void 0===u?void 0:u.message}),e.log(d._.ERROR,"error middleware",JSON.stringify(f),", isDegrade,",!e._MSEError&&!e.useVideoLoad,r.currentTime),!e._MSEError&&!e.useVideoLoad){r.vtype=a.l0.MP4_2,e._MSEError=!0,null===(c=e.mp4)||void 0===c||c.cancelLoading(),e._startDegradedPlayback(f,r.paused),e.emit(C);return}e.emit(C),e.useVideoLoad&&n(t.eventName,null==t?void 0:t.error)}})),this._isEventInit=!0}},{key:"getBufferDur",value:function(){if(!(null!==(e=this.player)&&void 0!==e&&e.buffered))return 0;for(var e,t=this.player.buffered,r=0,n=0,i=t.length;n0){for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:{};!this._pTime&&(this._pTime=k.Z.nowTime());var r=k.Z.nowTime()-this._pTime,n=k.Z.nowTime()-this._sTime;this.log(d._.LOG,">>>changeState[".concat(e,"]"),r,n,JSON.stringify(t)),this.states.push({state:e,t1:r,t2:n,data:t}),this._pTime=k.Z.nowTime()}},{key:"_initMseProxy",value:function(){var e,t=this.player.video||this.player.media;t instanceof HTMLVideoElement&&this.h265_h264_switch(this.playerConfig.mediaType),this.softDecode&&t&&(this.mseProxy=t,null===(e=t.setPlayMode)||void 0===e||e.call(t,"VOD"),t.addEventListener("lowdecode",this._lowDecoder),t.addEventListener("error",this._onError),this.player.forceDegradeToVideo=function(){})}},{key:"notSupportError",value:function(e){return this.log(d._.LOG,e,m.eT),new c.Errors(this.player,{errorType:_.iR.MEDIA,errorCode:_.O1.mse,errorMessage:"".concat(e," ").concat(m.eT),vid:this.playerConfig.vid})}},{key:"removeAndRejectInitPromise",value:function(e){this._initPromise&&(this._removePendingPromise(this._initPromise),this._initPromise.reject(e))}},{key:"_initMp4",value:function(e,t){var r,i,a,o,s,l,u,c,f,h=this,p=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},g=this.config,v=this.player,y=this.playerConfig;this.mp4&&(this.mp4.destroy(),this.mp4=null),this._startTimelines.reqtime=k.Z.nowTime(),this.changeState("MP4_NEW",{});var _=0;null!=g&&null!==(o=g.pcdnConfig)&&void 0!==o&&o.openPCDN&&(_=(null==g||null===(i=g.pcdnConfig)||void 0===i?void 0:i.switchPCDNMaxCnt)||2),null!=g&&null!==(s=g.pcdnConfig)&&void 0!==s&&s.adaptPCDNConfig&&null!=g&&null!==(l=g.pcdnConfig)&&void 0!==l&&null!==(l=l.adaptPCDNConfig)&&void 0!==l&&l.PCDNBufferControl&&(_=0),this._setCurrentDefinition(v.curDefinition);var R=b.Z;(null==g?void 0:g.loadRangeType)===m.TJ.SIZE&&(R=E.Z);var w=null===(u=v.curDefinition)||void 0===u||null===(u=u.pktOffsetMap)||void 0===u?void 0:u.find(function(e){return(null==e?void 0:e.time)===((null==g?void 0:g.firstLoadTimePos)||m.he)}),L=g.enableWorker,D=g.useUrlRange,P=g.retryCount,A=g.retryDelay,O=g.timeout,I=g.processMaxGapTime,M=g.onProcessMinLen,N=g.supportHevc,U=g.afterLoadeddataCallBackLen,F=g.firstLoadBuffer,V=g.memoryOpt,G=g.emitMediaListControl,H=g.reqOptions,j=g.audioGroupingStrategy,Z=g.fixEditListOffset,Y=g.fixEditListOffsetThreshold,W=g.isAddRange,z=g.disableRepeatRange,K=g.alwaysStreamingLoad,q=g.loadRangeType,X=g.changeUrlRetry,J=g.dynamicTimeoutIns;this.mp4=new R(e,v.curDefinition.bitrate,{segmentDuration:g.segmentMinDuration,enableWorker:L,softDecode:this.softDecode,codecType:this.codecType,chunkSize:g.preloadSize,firstLoadSize:null==w?void 0:w.offset,duration:y.duration||0,fileSize:p.fileSize||0,playerId:this.playerId,vid:y.vid,useUrlRange:D,retryCount:P,retryDelay:A,timeout:O,processMaxGapTime:I,onProcessMinLen:M,supportHevc:N,afterLoadeddataCallBackLen:U,firstLoadBuffer:F,logger:this.logger,memoryOpt:V,emitMediaListControl:G,enablePreloadCache:g.enablePreloadCache,switchPCDNMaxCnt:_,reqOptions:H,audioGroupingStrategy:j,fixEditListOffset:Z,fixEditListOffsetThreshold:Y,isAddRange:W,disableRepeatRange:z,alwaysStreamingLoad:K,loadRangeType:q,enableMsePatches:g.enableMsePatches,changeUrlRetry:X,dynamicTimeoutIns:J},this.config._backupURL,""),this.mp4.once(T.kL.META_READY,this._onMp4MetaReady),this.mp4.on(T.kL.ERROR,this._onMp4Error),this.mp4.on(T.kL.UPDATE_EME,this._updateDrmConfig),this.mp4.on(T.kL.INIT_MSE,this._updateMSE),this.mp4.on(T.kL.TASK_PROGRESS,this._onMp4Progress),this.mp4.on(T.kL.MOOV_REQ_PROGRESS,this._onMp4DataCallBack),this.mp4.MP4Loader.on("networkError",function(e){var t;null===(t=h.player)||void 0===t||t.emit("networkError",e)}),this.mp4.on(T.kL.LOAD_ERROR,function(e){var t;null===(t=h.player)||void 0===t||t.emit("source_error",e)}),this.mp4.on(T.kL.REMOVE_PCDN_NODE,function(e){h.pcdn&&e&&h.pcdn.removePCDNNode(e.vid,e.bitrate,e.url)}),this.mp4.on(T.kL.CHANGE_URL,function(e){h.player&&(h.player.emit("initialUrl",{url:e}),h.player.emit("changeHost",k.Z.getHostFromUrl(e)))}),this.mp4.on(T.kL.UPDATE_LOAD_IDX,(r=(0,n.x)((0,n.l5)().mark(function e(t){var r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=h.mp4)||void 0===r?void 0:r.cancelLoading();case 2:h._curLoadSegmentIdx=t,h.log(d._.LOG,"[update curLoadSegmentIdx]",t);case 4:case"end":return e.stop()}},e)})),function(e){return r.apply(this,arguments)})),this.mp4.on(T.kL.CANCEL_LOADED_LEN,function(e){if(!!h.player){var t,r,n=y.vid,i=(null==e?void 0:e.load_type)||T._R.CDN,a=null===(t=h.mp4)||void 0===t?void 0:t.getCurSwitchPCDNCnt(),o=h._currDefinition,s=o.bitrate,l=o.definition,u=o.file_id;i===T._R.CDN?h.player.emit("prf_data_size",{vid:n,task_type:1,cdn_size:e.len,change_cnt:a,definition:l,bitrate:s,fileid:u}):h.player.emit("prf_data_size",{vid:n,task_type:1,pcdn_size:e.len,trace_id:null===(r=h.mp4)||void 0===r||null===(r=r.pcdnTraceInfo)||void 0===r?void 0:r.trace_id,change_cnt:a,definition:l,bitrate:s,fileid:u}),h.mp4&&h.mp4.updateLoadInfo(i,e.len),x.XO}}),this.mp4.MP4Loader.on(m.kW,function(e){B=e.speed,!h.debugInfo.speed&&(h.debugInfo.speed=[]),h.debugInfo.speed.push(B),h.debugInfo.speed.length>10&&h.debugInfo.speed.shift();var t=(null==e||null===(E=e.priOptions)||void 0===E?void 0:E.type)||T._R.CDN;h.emit(m.kW,(0,n.Zj)((0,n.Zj)({},e),{},{type:t}));var r=(null===(k=h.playerConfig)||void 0===k?void 0:k.vid)||(null==e?void 0:e.vid);if((null==e?void 0:e.len)>0){if(!h.player)return;var i=(null==e||null===(R=e.priOptions)||void 0===R?void 0:R.type)||T._R.CDN,a=(0,S.pl)(e.len,e.time),o=(null===(w=h.adaptRangeRes)||void 0===w?void 0:w.length)>0?h.adaptRangeRes.shift():{},s=o.cachedBufferDur,l=o.loadTarDuration,u=o.loadDuration,c=o.forceSetMin;o.idx;var d=o.PCDNInBuffer,f=o.PCDNOutBuffer,p=o.loadSize,g=null===(L=h.mp4)||void 0===L?void 0:L.getCurSwitchPCDNCnt(),v=h._currDefinition,y=v.bitrate,_={vid:r,task_type:1,buffer_dur:s||-1,load_tar_dur:l||-1,load_dur:u||-1,force_set_min:c,in_buf:d||-1,out_buf:f||-1,change_cnt:g,bitrate:y,definition:v.definition,fileid:v.file_id,load_size:p||-1,rtt:(null==e||null===(D=e.priOptions)||void 0===D?void 0:D.rtt)||0};i===T._R.CDN?(_.cdn_size=e.len,_.cdn_speed=a):(_.pcdn_size=e.len,_.pcdn_speed=a),h.player.emit("prf_data_size",_),x.XO;var b=e.index?null===(C=h.mp4)||void 0===C||null===(C=C.adaptTimeRange[e.index])||void 0===C||null===(C=C.timeRangeIdx)||void 0===C?void 0:C[1]:null;if(b&&b>=h.mp4.timeRange.length-1)for(;(null===(P=h.adaptRangeRes)||void 0===P?void 0:P.length)>0;){var E,k,R,w,L,D,C,P,A,O=h.adaptRangeRes.shift(),I=O.cachedBufferDur,M=O.loadTarDuration,N=O.loadDuration,U=O.forceSetMin,F=(O.idx,O.loadSize),V=O.PCDNInBuffer,G=O.PCDNOutBuffer,H=null===(A=h.mp4)||void 0===A?void 0:A.getCurSwitchPCDNCnt();_.buffer_dur=I||-1,_.load_tar_dur=M||-1,_.load_dur=N||-1,_.force_set_min=U||-1,_.in_buf=V||-1,_.out_buf=G||-1,_.load_size=F||-1,_.change_cnt=H,h.player.emit("prf_data_size",_),x.XO}h.mp4&&h.mp4.updateLoadInfo(i,e.len)}}),this.mp4.on(m.fD.MEDIA_LIST,function(e){var t;null===(t=h.player)||void 0===t||t.emit(m.fD.MEDIA_LIST,e)}),this.mp4.on(m.fD.FIRST_MET_MUX_NOT_CONTINUE,function(){h.emit(C)}),null!=g&&null!==(c=g.pcdnConfig)&&void 0!==c&&c.adaptPCDNConfig&&null!=g&&null!==(f=g.pcdnConfig)&&void 0!==f&&null!==(f=f.adaptPCDNConfig)&&void 0!==f&&f.PCDNBufferControl&&(null===(a=this.mp4)||void 0===a||a.setSwitchPCDNCallBack(function(){var e=h.pcdn;if(!e)return -1;var t=e.getPCDNChangeCnt()||-1;return h.log(d._.LOG,"[updateSwitchPCDNMaxCnt]",t),t})),this.changeState("MP4_INIT",{destroy:this.mp4.hasDestroyed}),this.emit("loadstart_mse"),this.mp4.bufferTimeFuncCallBack=function(){return v.bufferedPoint.end-v.currentTime},this.mp4.init(t),this._emitDefinitionChangeDetailEvent(0)}},{key:"_checkPreloader",value:(U=(0,n.x)((0,n.l5)().mark(function e(){var t,r,i,a,o,s,l,u,c,f,h,p,g;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(t=this.player).curDefinition,i=t.preloader,o=(a=Promise.withResolvers()).promise,s=a.resolve,l={method:"checkPreloader",success:0,type:"error",cacheKey:""},i){e.next=9;break}return this.changeState(m.fp.PRELOAD_ERROR,{t:2}),l.success=0,l.error=Error("no_preloader"),s(l),e.abrupt("return",o);case 9:if(u=this._getPreloadMeta(r),c=i.getDataUniqueKey(u),l.cacheKey=c,!c){e.next=46;break}return e.next=15,i.getPreLoadData(u);case 15:if(!(f=e.sent)){e.next=39;break}if(p=f.bitrate,g=f.orgDefinition,delete f.generateBy,!(p&&r.bitrate&&p!==r.bitrate)){e.next=27;break}return this.preLoadData=null,l.success=0,l.error=Error("bitrate_not_match_cut_".concat(r.bitrate,"_cache_").concat(p)),this.changeState(m.fp.PRELOAD_ERROR,{t:1,bitrate:p,ck:c}),s(l),this.log(d._.LOG,">>>check Preloader bitrate_not_match cacheKey".concat(c,"\n curDefinition:").concat(r.bitrate," cache:").concat(p)),e.abrupt("return",o);case 27:r.orgDefinition=g,x.i5,this.preLoadData=f,this.emit("PRELOAD_INFO",this.preLoadData),l.success=1,l.data=f,null===(h=this.preloader)||void 0===h||h.setUsePreloadInfo(c,!0),this.changeState(m.fp.PRELOAD_OK,{t:4,l:this.preLoadData.byteLength,ck:c}),f.mediaSegList&&f.mediaSegList.length>0||f.buffer&&f.buffer.byteLength>0?this.hitpreload=!0:this.hitpreload=!1,s(l),e.next=44;break;case 39:this.preLoadData=null,this.changeState(m.fp.PRELOAD_ERROR,{t:0,ck:c}),l.success=0,l.error=Error("none_preload"),s(l);case 44:e.next=50;break;case 46:this.changeState(m.fp.PRELOAD_ERROR,{t:3,ck:c}),l.success=0,l.error=Error("none_preload"),s(l);case 50:return e.abrupt("return",o);case 51:case"end":return e.stop()}},e,this)})),function(){return U.apply(this,arguments)})},{key:"_initEME",value:function(e){var t,r,n=this.config,a=n.kid,o=n.drmKeyToken,s=n.secretKey,l=n.keyValue,u=n.drm,f=n.useEME;if((a||o||s||l||u)&&f&&!(0,i.checkEMEValid)()){this.log(d._.ERROR,"checkEMEInValid"),this._errorHandler(new c.Errors(this.player,{errorType:_.iR.MEDIA,errorCode:_.O1.eme_hijack,errorMessage:"checkEMEInValid",vid:this.playerConfig.vid}));return}var h=this.player,p=this.config;this._updateDrmConfig(e),this.log(d._.LOG,"useEME: ",p.useEME),null===(t=this._secretkey)||void 0===t||t.setOptions('video/mp4; codecs="avc1.64001E"','audio/mp4; codecs="mp4a.40.2"'),null===(r=this._secretkey)||void 0===r||r.setupEME(h.video)}},{key:"_initMse",value:(F=(0,n.x)((0,n.l5)().mark(function e(t){var r,a=this,o,s,l,u,h,p,g,v,y,T,b,E,S,k,R,x,w,L,D=arguments;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=D.length>1&&void 0!==D[1]&&D[1],l=(s=this.config).kid,u=s.drmKeyToken,h=s.secretKey,p=s.keyValue,g=s.drm,v=s.useEME,!((l||u||h||p||g)&&v&&!(0,i.checkMSEValid)())){e.next=6;break}return this.log(d._.ERROR,"checkMSEInValid "),this._errorHandler(new c.Errors(this.player,{errorType:_.iR.MEDIA,errorCode:_.O1.mse_hijack,errorMessage:"checkMSEInValid",vid:this.playerConfig.vid})),e.abrupt("return");case 6:null===(r=this.player)||void 0===r||r.emit("codecsupdate",t.videoCodec),this.updateMSEDuration(),y=this.mp4&&this.mp4.checkCodecH265(),T=this.mp4&&this.mp4.checkCodecH266(),b=!!t.videoCodec,E=!!t.audioCodec,S=b&&E?y?'video/mp4; codecs="hev1.1.6.L93.B0, mp4a.40.5"':T?'video/mp4; codecs="bvc2.1.6.L93.B0, mp4a.40.5"':'video/mp4; codecs="avc1.64001E, mp4a.40.5"':b?y?'video/mp4; codecs="hev1.1.6.L93.B0"':T?'video/mp4; codecs="bvc2.1.6.L93.B0"':'video/mp4; codecs="avc1.64001E"':'video/mp4; codecs="mp4a.40.5"',k=(0,n._x)({},f.d1.VIDEO,{mimeType:"video/mp4",codec:S}),this.mse?this._bindSrcTiming===m.Iv.INIT?R=this.mse._openPromise:(this.log(d._.LOG,"MSE exist"),w=(x=Promise.withResolvers()).promise,L=x.resolve,R=w,L()):(this.log(d._.LOG,"new MSE",this._bindSrcTiming),this.mse=new f.d1,R=this.mse.bindMedia(this.player.video)),R.then(function(){if(!!a.mse){a.changeState("MSE_OPEN");try{var e=Object.keys(k).map(function(e){return a.mse.createOrChangeSource(e,k[e].codec)});Promise.all(e).then(function(){a.changeState("MSE_OPEN_DONE"),a._isMseInit=!0;var e=a.seekTimeAfterMetaReady;if(a.config.enableMsePatches&&a.player&&"number"==typeof e&&e>=0){var t=a.player.bufferedPoint;a.seekTimeAfterMetaReady=void 0,e>=t.start&&e<=t.end?a._onSeeking():a.player.currentTime=e}else try{a._onTimeUpdate()}catch(e){throw a.log(d._.ERROR,"MSE createOrChangeSource onTimeUpdate catch err: ",null==e?void 0:e.message),e}}).catch(function(){var e=(0,n.x)((0,n.l5)().mark(function e(t){var r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a.config.reUseMSE=!1,a.log(d._.WARN,"MSE createOrChangeSource catch err: ",null==t?void 0:t.message),e.next=4,null===(r=a.mse)||void 0===r?void 0:r.unbindMedia();case 4:a.mse=null,a._isMseInit=!1,o?a.MSEErrorHandle(t):a._initMse(a.mp4.meta,!0);case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}())}catch(e){a.MSEErrorHandle(e)}}}),this.changeState("MSE_INIT");case 17:case"end":return e.stop()}},e,this)})),function(e){return F.apply(this,arguments)})},{key:"MSEErrorHandle",value:function(e){var t=new c.Errors(this.player,{errorType:_.iR.mse,errorCode:_.O1.mse,vid:this.playerConfig.vid,errorMessage:e.message,mediaError:{code:_.O1.mse,message:e.message}});this.log(d._.ERROR,"initMse error: ",null==e?void 0:e.message),this._errorHandler(t)}},{key:"_appendInitSeg",value:function(e){var t=this;if(!!this.mse&&!this._MSEError)this.changeState("MSE_INITSEG"),this.mse.append(f.d1.VIDEO,e,{vid:this.playerConfig.vid,range:null,dataLen:e.byteLength,isinit:!0}).then(function(e){t.changeState("MSE_INITSEG_OK",{costtime:null==e?void 0:e.costtime})}),this.config.useEME&&this._secretkey&&(this._secretkey.emit(i.EVENT_EME.ENCRYPTED),this.player.emit(i.EVENT_EME.ENCRYPTED))}},{key:"_checkMetaInfo",value:function(e){if(!e)return new c.Errors(this.player,{errorType:_.iR.DEMUX,errorCode:_.O1.metaError,errorMessage:"meta is null",vid:this.playerConfig.vid});var t,r=this.player.video||this.player.media,n=this.mp4.checkCodecH265(),i=this.mp4.checkCodecH266();if(this.changeState("MP4_META_READY",{isH265:n,isH266:i}),n&&(this.codecType!==a.u7.H265&&(this.codecType=a.u7.H265,this.log(d._.LOG,"codecType fix ".concat(this.codecType,", ").concat(e.videoCodec))),!this.softDecode&&!this.config.supportHevc)||i&&(this.codecType!==a.u7.H266&&(this.codecType=a.u7.H266,this.log(d._.LOG,"codecType fix ",this.codecType,e.videoCodec)),!(this.softDecode&&(null===(t=r.canPlayType)||void 0===t?void 0:t.call(r,'video/mp4; codecs="'.concat(e.videoCodec,'"')))==="probably")&&!this.config.supportVvcc))return this.notSupportError("".concat(this.codecType," - ").concat(e.videoCodec));var o=this.config,s=o.enableCheckTrackGap,l=o.trackGap;if(e.videoCodec&&e.audioCodec&&s){var u=e.moov.trak,f=e.moov.mvhd.timescale;if(Math.abs(this._getTrakDuration(u[0],f)-this._getTrakDuration(u[1],f))>l)return new c.Errors(this.player,{errorType:_.iR.DEMUX,errorCode:_.O1.metaError,errorMessage:"video track and audio track duration long gap, mse cannot play to end",vid:this.playerConfig.vid})}return null}},{key:"_getTrakDuration",value:function(e,t){return e.tkhd.duration/t}},{key:"_stopProgress",value:function(){this.log(d._.LOG,"stopProgress",this._hasStartProgress),this._hasStartProgress=!1,this._requestTimer&&this._requestTimer.stop(),this._bufferBreakTimer&&(clearTimeout(this._bufferBreakTimer),this._bufferBreakTimer=null,this._bufferBreakFlag=void 0),this._seekResumTimer&&(clearTimeout(this._seekResumTimer),this._seekResumTimer=null)}},{key:"checkReStartTimer",value:function(){var e=k.Z.nowTime()-this._lastTimeupdateTime2;e>2*this._tickInSeconds*1e3&&!this._offineLine&&(this.log(d._.LOG,"checkReStartTimer reStart timer",e,k.Z.nowTime()),this._stopProgress(),this._startProgress(),this._lastTimeupdateTime2=k.Z.nowTime())}},{key:"_bindNetworkStateChange",value:function(){window.addEventListener("online",this._onOnlineHandler),window.addEventListener("offline",this._onOfflineHandler)}},{key:"_unbindNetworkStateChange",value:function(){window.removeEventListener("online",this._onOnlineHandler),window.removeEventListener("offline",this._onOfflineHandler)}},{key:"_onSuperStart",value:function(e){var t=this,r=this.player;(0,x.cM)("_onSuperStart:".concat(e),this.mse),r.video.src=e,this.once("canplay",function(){r.play(),t.on("waiting",t._onWaiting)})}},{key:"_appendBuffer",value:function(e,t,r,n){var i=this,o=this.mse,s=this.playerConfig,l=this.player,u=s.vid;if(r=r||{},this.log(d._.LOG,"appendStart",r.fragIndex,JSON.stringify(r.range)),this._MSEError){this.log(d._.ERROR,"_MSEError, not append return");return}o.append(e,t,{vid:u,state:n,context:JSON.stringify(r)}).then(function(e){2===l.changeDefinitionSeekState&&(l.changeDefinitionSeekState=3,i.log(d._.LOG,"appendEnd changeDefinitionSeekState += 0.001"),l.currentTime+=.001);var t,a,o,s,u=i.getAllBufferRange(),c=null!=e&&null!==(t=e.context)&&void 0!==t&&t.context?JSON.parse(null==e||null===(a=e.context)||void 0===a?void 0:a.context):{};if(i.log(d._.LOG,"appendEnd ",null==c?void 0:c.fragIndex,JSON.stringify(null==c?void 0:c.range),", costTime,",null==e?void 0:e.costtime,", opt,",null==e?void 0:e.name,",buffer,",JSON.stringify(u),l.currentTime),!i.loadedDataEventRev){var f=(null==e?void 0:e.costtime)||0,h=i.states.findIndex(function(e){return"APPEND_DATA_OK"===e.state});h>=0?(i.states[h].data.cnt+=1,i.states[h].data.costtime+=f):i.changeState("APPEND_DATA_OK",{costtime:f,cnt:1})}if(i.mse&&n&&(null!==(o=i.mp4)&&void 0!==o&&o.checkIsLoadEnd(null===(s=r.range)||void 0===s?void 0:s[1])||i._loadedEnd)){var p=i.player.buffered;i._loadedEnd=!0;var g=0;p&&(null==p?void 0:p.length)>0&&(g=p.end(p.length-1)),i._isEnded(),i.log(d._.LOG,"loaded ended !!!===>>>",JSON.stringify(r.range),", fragIndex,",r.fragIndex,", bufferEndTime,",g,",meta_duration,",i.mp4.meta.duration)}}).catch(function(e){var t=i.player,n=i.mse;if(!i._hasFirstFramed&&i._setStartTimelines(a.l1.MSE_ERROR,{message:null==e?void 0:e.message}),!i._MSEError&&!!t){var o=t.media||t.video;if(e&&null!=n&&n.isFull()){i.log(d._.WARN,"[MSE is full]");var s=t.getBufferedRange();i._checkRemovePlayedBuffer(s,t.currentTime,!0)}else{var l,f,h,p,g="".concat(null!=o&&o.error?[o.error.code,o.error.message].join("-"):"MEDIA_EMPTY"),v="".concat((null==e?void 0:e.errorCode)||"","-").concat((null==e?void 0:e.errorMessage)||(null==e?void 0:e.message)||"MSE_EMPTY"),m="".concat(v,"|").concat(g);i._MSEError=!0,i.changeState("_MSEError",{fragIndex:null===(l=r)||void 0===l?void 0:l.fragIndex,range:null===(f=r)||void 0===f?void 0:f.range}),i.log(d._.LOG,"MSE append error",null===(h=r)||void 0===h?void 0:h.fragIndex,JSON.stringify(null===(p=r)||void 0===p?void 0:p.range));var y=new c.Errors(t,{errorType:_.iR.MEDIA,errorCode:_.O1.mseAppend,vid:u,errorMessage:m,mediaError:{code:_.O1.mseAppend,message:m}});i._errorHandler(y)}}})}},{key:"_loadData",value:(V=(0,n.x)((0,n.l5)().mark(function e(){var t,r;return(0,n.l5)().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!this.mp4||!this._isMseInit&&!this.softDecode)){e.next=2;break}return e.abrupt("return");case 2:if(e.prev=2,t=this.player,r=h.l.info(h.l.get(t.media||t.video),t.currentTime),!(!this.config.alwaysStreamingLoad&&r.remaining>5)){e.next=10;break}return e.next=8,this.mp4.loadAllFragmentData(this._curLoadSegmentIdx,this._loadDataSuccess);case 8:e.next=12;break;case 10:return e.next=12,this.mp4.load(this._curLoadSegmentIdx,this._loadDataSuccess);case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(2),this.log(d._.ERROR,"[Index] _loadData error",this.playerConfig.vid,null===e.t0||void 0===e.t0?void 0:e.t0.message);case 17:case"end":return e.stop()}},e,this,[[2,14]])})),function(){return V.apply(this,arguments)})},{key:"_getPreloadMeta",value:function(e){var t=(0,S.F5)(e);return!t.vid&&(t={vid:this.playerConfig.vid,codecType:this.codecType,vtype:"MP4",bitrate:e.bitrate||0,mediaType:"video",definition:e.definition}),t}},{key:"getDataBitRate",value:function(e){var t=this.mp4,r=this.playerConfig;if(!t)return 0;for(var n=t.getDataBitRate(e),i=r.definition.list,a=0,o=0;i&&o.1||!n&&r.paused||n&&this.playFlag&&r.paused)(1===this._bufferBreakFlag||2===this._bufferBreakFlag)&&(this.log(d._.LOG,"视频没有卡死,重置卡死标记,curtime,",r.currentTime),this._bufferBreakFlag=0,clearTimeout(this._bufferBreakTimer),this._bufferBreakFlag=null);else if(!this._bufferBreakFlag){this._bufferBreakFlag=1;var i=JSON.stringify(this.getAllBufferRange()),a=this.getWaitingTimeOut();this.log(d._.LOG,"卡死计时开始! ".concat(a,"ms后确认卡死,"),r.currentTime,i),this._bufferBreakTimer=setTimeout(function(){if(!e.isDestroy&&!t.disableInactiveWaitingCheck&&(!!n||!r.paused)&&(!n||!e.playFlag||!r.paused)){if(1===e._bufferBreakFlag){var i=r.currentTime,a=r.bufferedPoint;if(a.end>0&&a.end-i>=2){e.retrySeekResum(i);return}}e._bufferBreakFlag=2,e.waitTimeoutDegrade()}},a)}this._lastCurrentTime=r.currentTime}}},{key:"getWaitingTimeOut",value:function(){var e=this.player,t=this.config.waitingTimeOut;if(!this.playFlag){var r,n=null===(r=e.curDefinition)||void 0===r?void 0:r.duration;if(n>0){var i=m.zb.find(function(e){return n>=e.range[0]&&n0&&i.waitingRetryDuration)){e.next=14;break}return a=Math.min(i.waitingRetrySeekTimes,3),this._currentSeekTimes=0,this.off("playing",this._onResumePlaying),this.once("playing",this._onResumePlaying),o=function(){if(!r||s._resumePlay||r.paused){s.log(d._.LOG,"当前播放实例已恢复或处于暂停状态,退出重试 player=".concat(!!r,",_resumePlay=").concat(s._resumePlay,",paused=").concat(null==r?void 0:r.paused));return}if(s._currentSeekTimes1&&void 0!==arguments[1]?arguments[1]:0,r=!1,n=this.player.video.buffered,i=0;it.currentTime)||!t.video||!t.video.buffered||1===t.video.buffered.length||this._isInBuffer(e,.2)}},{key:"isOpenPCDN",value:function(e){var t=this;if(this.pcdn&&this.mp4){var r=e-this.player.currentTime,n=this.pcdn,i=this.config,a=this.mp4,o=i.pcdnConfig,s=n.getPCDNInBuffer()||o.enterMinBuffer,l=n.getPCDNOutBuffer()||o.outMaxBuffer;if(r>=s){if(a.updatePCDNState(T.oy.OPEN),a.isUpdateNode){var u=this.player.curDefinition,c=u.uri,f=u.bitrate;this.pcdn.getPCDNNode(c,f,this.getPCDNReqId()).then(function(e){if(!!a){var r,i=t.getPCDNReqId();if(null!=e&&e.req_id&&i!==e.req_id){t.log(d._.LOG,",getPCDNNode is not match curDefinition reqId",i,", pcdnRet.req_id",e.req_id);return}a.updateNode(null==e?void 0:e.nodes),n.updatePCDNBitrate(f),e&&(a.pcdnTraceInfo={uri:e.vid,fid:e.fid,trace_id:null==e?void 0:e.trace_id}),e&&a.pcdnVVStat&&(a.pcdnVVStat.try_req_node+=1,a.pcdnVVStat.req_node_succ+=1,a.pcdnVVStat.has_ret_node+=(null==e||null===(r=e.nodes)||void 0===r?void 0:r.length)>0?1:0)}}).catch(function(e){(null==a?void 0:a.pcdnVVStat)&&(a.pcdnVVStat.try_req_node+=1),t.checkURLExpired(e,"_getPCDNNode")})}}else rm.zK&&this.timerStepList.shift(),this._lastTimeupdateTime2>0&&this.timerStepList.push(k.Z.nowTime()-this._lastTimeupdateTime2)}},{key:"_onTimeUpdate",value:function(){this.pushTimerStep(),this._lastTimeupdateTime2=k.Z.nowTime();var e=this.mse,t=this.mp4,r=this.player,n=this.config;if(!r)return;if((0,R.yx)()&&r.paused!==this._usePaused&&(this._usePaused?r.pause():r.play()),this.useVideoLoad||!t){this.useVideoLoad&&null!==(o=this.expiryCheckPlugin)&&void 0!==o&&null!==(o=o.config)&&void 0!==o&&o.enableExpiryCheck&&k.Z.nowTime()-this._lastCheckTime>1e3&&(this._lastCheckTime=k.Z.nowTime(),this._startUrlExpiredCheck());return}var i=r.getBufferedRange();k.Z.nowTime()-this._lastCheckTime>1e3&&(this._lastCheckTime=k.Z.nowTime(),this._loadStuckCheck(),this._startUrlExpiredCheck(),this._checkRemovePlayedBuffer(i,r.currentTime));var a=t.timeRange;if(!!a&&!(a.length<1)){if((e||this.mseProxy)&&this.canDownload&&!this._suspendLoading){var o,s,l,u=this._maxBufferLength,c=!1;(this.playFlag&&r.paused||!this.isActive)&&(c=!0),c?u=r.isInstNext&&this._nextBufferLength>=0?this._nextBufferLength:this._minBufferLength:null!==(l=this.config)&&void 0!==l&&null!==(l=l.adaptRange)&&void 0!==l&&l.targetCacheControl&&(u=this.adaptRange.getAdaptCacheBuffer()),!this.preLoadData&&null!==(s=this.config)&&void 0!==s&&null!==(s=s.adaptRange)&&void 0!==s&&s.targetCacheControl&&(u+=this.config.noPreloadAddBufferLen);var d=r.currentTime+u;i[1]-d<0&&(this.isOpenPCDN(i[1]),(null==n?void 0:n.loadRangeType)===m.TJ.SIZE?this.sizeRangeCheckLoad(c,u,i[1]-r.currentTime):this.gopRangeCheckLoad(c,u)),this.playFlag&&!this._hasTriggerBufferThreshold&&this._startBufferCheck()}}}},{key:"sizeRangeCheckLoad",value:function(e,t,r){var n=this.player,i=this.mp4;this.config;var a=i.adaptTimeRange,o=a.length,s=i.size-1||n.curDefinition.size-1;if(!(null!=a&&a.length)||(null===(u=a[o-1])||void 0===u?void 0:u.range[1])0){var l=a.findIndex(function(e){return!e.downloaded});if(!(null!=a&&a.length)||l>=0||a[o-1].downloaded){var u,c,f=this.calculateAdaptRange(e,t),h=f.adaptRangeRes,p=f.loadDuration;if(h.loadDuration=p,l<0?i.changeBitRateTime>0&&(null===(c=a[o-1])||void 0===c?void 0:c.range[1])>=s?(this._curLoadSegmentIdx=a.length-1,this.log(d._.LOG,"changeBitRateTime> 0 and load last adaptTime")):this._curLoadSegmentIdx=i.updateAdaptTimeRange(null,p):this._curLoadSegmentIdx=l,l>0&&i.changeBitRateTime<=0){var g=a[l-1];if(null!=g&&g.downloaded&&r>0&&(null==g?void 0:g.endTime)-n.currentTime>=t)return}var v=a[this._curLoadSegmentIdx];if(this._curLoadSegmentIdx>=0&&this._isInBuffer(v)&&this._removeBuffEndTime<=0&&this._curLoadSegmentIdx>=0&&v.endTime-v.startTime>1){this.log(d._.LOG,"onTimeUpdate, ".concat(this._curLoadSegmentIdx," download segment, has buffer: "),v.startTime,v.endTime,n.currentTime),v.downloaded=!0,v.isLoading=!0,i.seekTime0)&&(this.log(d._.LOG,"[onTimeUpdate],load index==>>>, ",this._curLoadSegmentIdx,JSON.stringify(a[this._curLoadSegmentIdx])),this._loadData())}}}},{key:"adaptRangeResPush",value:function(e){var t;(!this.adaptRangeRes.length||(null===(t=this.adaptRangeRes[e.length-1])||void 0===t?void 0:t.idx)!==this._curLoadSegmentIdx)&&(this.adaptRangeRes.push(e),this.log(d._.LOG,"adaptRangeRes>>>>",e))}},{key:"gopRangeCheckLoad",value:function(e,t){var r=this,n=this.player,i=this.mp4,a=i.timeRange,o=i.adaptTimeRange,s=i.changeBitRateTime;a.every(function(i,a){if(void 0!==i.adaptTimeRangeIdx&&i.adaptTimeRangeIdx>=0&&o&&o[i.adaptTimeRangeIdx].downloaded&&!(s>0&&i.adaptTimeRangeIdx===o.length-1&&o[i.adaptTimeRangeIdx].downloaded))return!0;var l=r.mp4.getAdaptIdxBySrcIdx(a,!0),u=l>=0?o[l]:null,c=l>=0&&r._isInBuffer(u);if(r._removeBuffEndTime<=0&&l>=0&&u.endTime-u.startTime>1&&c)return o[l].downloaded=!0,o[l].isLoading=!0,r.log(d._.LOG,"onTimeUpdate, ".concat(l," download segment, has buffer"),u.startTime,u.endTime,n.currentTime),!0;if(i.startTime-n.currentTime0)&&(r.log(d._.LOG,"[onTimeUpdate],load index==>>>, ",r._curLoadSegmentIdx,JSON.stringify(o[r._curLoadSegmentIdx])),r._loadData())}})}},{key:"calculateAdaptRange",value:function(e,t){var r,n,i,a,o,s={forceSetMin:e};return null!==(r=this.pcdn)&&void 0!==r&&r.isOpenAdaptPCDN&&(s.PCDNInBuffer=this.pcdn.curPCDNInBuffer,s.PCDNOutBuffer=this.pcdn.curPCDNOutBuffer),!this.playFlag||e?a=this._minBufferLength:null!==(o=this.config)&&void 0!==o&&null!==(o=o.adaptRange)&&void 0!==o&&o.rangeControl?(a=this.adaptRange.getAdaptLoadDuration(),s.loadTarDuration=a):a=this.config.rangeMaxDuration,(null===(n=this.config)||void 0===n||null===(n=n.adaptRange)||void 0===n?void 0:n.targetCacheControl)&&(s.cachedBufferDur=t),!this.playFlag&&null!==(i=this.config)&&void 0!==i&&null!==(i=i.adaptRange)&&void 0!==i&&i.rangeControl&&(s.loadTarDuration=a),{adaptRangeRes:s,loadDuration:a}}},{key:"checkReUseMSE",value:function(e){var t=this,r=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=this.mse;if(!!n)if(e||this.config.reUseMSE){n.clearOpQueues(f.d1.VIDEO,r),this.mseAbort();var i,a=null===(i=this.player)||void 0===i?void 0:i.buffered;if((null==a?void 0:a.length)>0){var o=a.end(a.length-1);this.log(d._.LOG,"reUseMSE remove buffer, 0-",o),this._canUpdateDuration=!1,this.removeBuffer(f.d1.VIDEO,0,o,function(){var e;t._canUpdateDuration=!0,(null===(e=t.mp4)||void 0===e||null===(e=e.meta)||void 0===e?void 0:e.duration)&&t.updateMSEDuration()})}}else n.unbindMedia(),this.mse=null,this._unloadVideo()}},{key:"updateMSEDuration",value:function(){var e,t=this.mse,r=this.mp4;this._canUpdateDuration&&null!=r&&null!==(e=r.meta)&&void 0!==e&&e.duration&&r.meta.duration!==t.duration&&(this.log(d._.LOG,"updateMSEDuration ",r.meta.duration,",oldDuration,",t.duration),t.updateDuration(r.meta.duration),this._canUpdateDuration=null)}},{key:"_reset",value:function(){this._bindSrcTiming=m.Iv.META_READY,this._definitionChangePointInfo=null,this.adaptRangeRes=[],this.hitpreload=!1,this._sTime=k.Z.nowTime(),this._removeBuffEndTime=0,this._usePaused=!1,this.useVideoLoad=!1,this._isMseInit=!1,this.loadedDataEventRev=!1,this.needStarLoadFirstSegment=!1,this._curLoadSegmentIdx=0,this.emitExpireTimestamp=null,this.preLoadData=null,this.forPreloadTimeCache=null,this.playFlag=!1,this.waitLevelStartTime=-1,this._waitAdjustTimeCnt=0,this._firstMetFPSStuck=!1,this._initPromise&&"pending"===this._initPromise.state&&this._initPromise.reject(D),this.checkResumePlayTimer&&(clearTimeout(this.checkResumePlayTimer),this.checkResumePlayTimer=null),this._stopProgress(),this.mp4&&(this.mp4.destroy(),this.mp4=null),this.mseProxy&&(this.player.video.removeEventListener("lowdecode",this._onDegrade),this.player.video.removeEventListener("error",this._onError)),this.__onmetadataHandle&&(this.player.video.removeEventListener("loadedmetadata",this.__onmetadataHandle),this.__onmetadataHandle=null),this._unloadVideo(),this._cancelPendingPromises(),this._abrService&&(this._abrService.destroy(),this._abrService=null),this._waitInBufferTimer&&(clearTimeout(this._waitInBufferTimer),this._waitInBufferTimer=null),this.canDownload=!0,this._suspendLoading=!1,this._mediaCodec={videoCodec:"",audioCodec:""}}},{key:"removeErrorUrls",value:function(e,t,r){return e.errorCode===_.O1["403"]&&this._emitExpireEvent(e),r}},{key:"_setPlayerError",value:function(e){if(!this._hasFirstFramed){var t="".concat(this.player.vtype," ").concat(null==e?void 0:e.errorCode,"-").concat(null==e?void 0:e.errorMessage,"-").concat(null==e?void 0:e.rangeStart,"-").concat(null==e?void 0:e.rangeEnd);this._setStartTimelines(a.l1.PLAYER_ERROR,{message:t,httpCode:null==e?void 0:e.errorCode})}}},{key:"checkIsDegraded",value:function(e){var t=this.config,r=t.notDegradeErrorList,n=t.drm,i=t.kid,a=t.drmKeyToken,o=t.keyValue,s=t.secretKey;return!(n||i||a||o||s||e.errorCode>=7e3&&e.errorCode<=7999||(null==r?void 0:r.length)>0&&(e.errorCode===_.O1.timeout&&r.indexOf("timeout")>=0||e.errorCode===_.O1["403"]&&(r.indexOf(403)>=0||r.indexOf("403")>=0)||e.errorCode===_.O1["404"]&&(r.indexOf(404)>=0||r.indexOf("404")>=0)))&&!0}},{key:"_startDegradedPlayback",value:function(e,t){var r=this;this.canDownload=!1;var n=this.player,i=this.playerConfig,o=this.config;if(!n){this._setStartTimelines(a.l1.DESTROY,{message:"-degrade"});return}this.mse&&(this.mse.clearOpQueues(f.d1.VIDEO,!!o.enableMsePatches),this.mseAbort()),this._currentTime=n.currentTime||0,this.player.pause(),this._reset(),this.states=[],this._replay=null;var s=i.H264DefinitionList;if(this.codecType===a.u7.H265&&this.softDecode)this.log(d._.LOG,"h265 softDecode err,degrade use 264 play",i.vid),this._onDegrade(e);else if(this.codecType===a.u7.H264||o.supportHevc||o.supportVvcc||(null==s?void 0:s.length)>0){var l=o.drm,u=o.kid,c=o.drmKeyToken,h=o.keyValue,p=o.secretKey;if(l||u||c||h||p)l&&Object.keys(l).map(function(t){l&&(e[t]=l[t])}),this.log(d._.ERROR,"final error !!!!, ",i.vid,null==e?void 0:e.errorCode,null==e?void 0:e.errorMessage),this.emit("error",e);else{this.log(d._.LOG,this.codecType,"MSE degrade video,",i.vid,n.currentTime),this.emit(P,{errc:null==e?void 0:e.errorCode,err_msg:(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message),CodecTypes:this.codecType,media_type:i.mediaType}),this.useVideoLoad=!0,this.__onmetadataHandle=function(){var e;if(!!r.player)r._currentTime&&(r.player.currentTime=r._currentTime),r.log(d._.LOG,"DegradedPlayback update currentTime",null===(e=r.playerConfig)||void 0===e?void 0:e.vid,r.codecType,r._currentTime),t?r.player.pause():r.player.play(),r.player.video.removeEventListener("loadedmetadata",r.__onmetadataHandle),r.__onmetadataHandle=null},n.video.addEventListener("loadedmetadata",this.__onmetadataHandle);var g,v=i.url;if((null==e||null===(g=e.message)||void 0===g?void 0:g.indexOf(m.eT))>=0&&(null==s?void 0:s.length)>0){var y=s.length,_=this.player.curDefinition.definition,T=_&&s.find(function(e){return e.definition===_});!T&&(i.H264DefinitionList.sort(function(e,t){return e.bitrate-t.bitrate}),T=i.H264DefinitionList[Math.floor(y/2)]),T&&(v=T.url,this.playerConfig.codecType=a.u7.H264,this.codecType=a.u7.H264)}this._setPlayerSrc(v)}}else this.log(d._.ERROR,"degrade player failed"),this.emit("error",e)}},{key:"mseAbort",value:function(){var e;if(null!==(e=this.mse)&&void 0!==e&&e.abort){var t=this.mse.abort(f.d1.VIDEO);if(t)return t.catch(function(){}),t}}},{key:"isSeekingInSameBuffer",value:function(e,t){var r=!1,n=this.mp4,i=this._lastBufferPoint;return n.meta&&n.meta.duration-t.end<.5&&(r=!0),i&&0!==e&&e>=i.start&&e-1&&this._pendingPromises.splice(t,1)}},{key:"_cancelPendingPromises",value:function(){this._pendingPromises.length>0&&this._pendingPromises.forEach(function(e){e.reject(D)}),this._pendingPromises=[]}},{key:"_onMediaExpired",value:function(){this.log(d._.LOG,"MediaExpired stopProgress"),this._stopProgress(),this.emit(m.fD.MEDIA_EXPIRED)}},{key:"_isEnded",value:function(){var e,t,r,n,i=this.player,a=this.mp4;if(!i)return!1;var o=i.bufferedPoint,s=o?o.end:0;this.checkStartLoadFirstSegment(s);var l=i.currentTime;l>1&&s>l&&(s-l>=2||i.duration-l<1)&&2===i.video.readyState?k.Z.nowTime()-this._lastCheckLagTime>=3e3&&(this.log(d._.LOG,"[has buffer but waiting,seek 0.2 adjust],curTime,",l,", bufferend,",s,", duration,",null==a||null===(n=a.meta)||void 0===n?void 0:n.duration),i.currentTime=l+.2,this._lastCheckLagTime=k.Z.nowTime()):this._lastCheckLagTime=k.Z.nowTime();var u=(null===(e=i.buffered)||void 0===e?void 0:e.length)||0;if(u<=0||!i.buffered)return!1;var c=(null===(t=i.buffered)||void 0===t?void 0:t.end(u-1))||0;return!!(null!=a&&null!==(r=a.meta)&&void 0!==r&&r.duration&&a.meta.duration-i.currentTime<1&&(this._loadedEnd||1>Math.abs(a.meta.duration-c)))&&(this._stopProgress(),this.log(d._.LOG,"[isEnded],stopProgress and endOfStream,curTime, ",i.currentTime,", bufferend,",c,", duration,",a.meta.duration),this.mse&&this.mse.endOfStream().then(function(){}),!0)}},{key:"checkStartLoadFirstSegment",value:function(e){var t=this.player,r=this.mp4,n=this.config;if(!!t&&!!n.loadFirstGopData&&!!(null!=r&&null!==(i=r.meta)&&void 0!==i&&i.duration)&&!!(null!=t&&null!==(a=t.buffered)&&void 0!==a&&a.length)&&!!this.needStarLoadFirstSegment){if((this._loadedEnd||.5>Math.abs(e-this.mp4.meta.duration))&&t.buffered.start(0)>=r.timeRange[0].endTime){this.log(d._.LOG,"changeBitrate load end, reload loadFirstSegment"),this.needStarLoadFirstSegment=!1,r.resetDemuxSampleIdx(0),r._loadSuccessCallBack=this._loadDataSuccess;var i,a,o,s=(null===(o=r.timeRange[0])||void 0===o?void 0:o.range)||r.calculateRange(0);r.fillFirstSegment=!0,r.startLoad(s,0)}}}},{key:"_clearMediaKeys",value:function(){var e=this.player;e.video&&"function"==typeof e.video.setMediaKeys&&e.video.setMediaKeys(null).catch(function(){})}},{key:"_checkRemovePlayedBuffer",value:function(e,t,r,n){var i=this,a=this.mse,o=this.mp4,s=this.player;if(!a||!o||!s)return;if(r&&(clearTimeout(this._removeBufferTimer),this._removeBufferTimer=null),!e&&(e=s.getBufferedRange()),!t&&(t=s.currentTime),!(!r&&k.Z.nowTime()-this._checkRemoveBufferLastTime<=this.config.removeBufferLen)){if(this._checkRemoveBufferLastTime=k.Z.nowTime(),e&&e[0]>=0&&(t-e[0]>this.config.removeBufferLen||a.isFull())){var l=n?e[1]:t-(a.isFull()?0:15),u=o.getFragmentIdx(l);if(u>0&&(n||o.timeRange[u].startTime>>",h,c,t),this.removeBuffer(f.d1.VIDEO,h,c)):a.isFull()&&!this._removeBufferTimer&&(this._removeBufferTimer=setTimeout(function(){i._checkRemovePlayedBuffer(null,null,!0)},1e4))}}}}},{key:"onMediaUpdate",value:function(e){var t=e.vid,r=e.kid,n=e.url,i=this.player,a=this.config;if(t===this.playerConfig.vid&&r===a.kid&&n){this.playerConfig.url=n,this._handlerUrl(n);var o=a._mainURL;return this.useVideoLoad?i.src=n:this.mp4&&this.mp4.updateUrl(o),!0}return!1}},{key:"enableAutoBuffer",value:function(e){var t=this;if(e){if(!this._allInitPromise){this.log(d._.LOG,"player destroyed!!");return}this._allInitPromise.then(function(){t.log(d._.LOG,"enableAutoBuffer true"),t._startProgress()})}else this._stopProgress(),this.log(d._.LOG,"enableAutoBuffer false")}},{key:"bitRateAdapter",get:function(){return this.player&&this.player.plugins?this.config.needAutoBitrate?this.player.plugins.bitrateselector:null:null}},{key:"getDefinitonFromAdapter",value:function(e,t){if(!this.bitRateAdapter)return null;var r=this.bitRateAdapter;return r.getSuitableBitrate?r.getSuitableBitrate(e,t):r.bitRateAdapter?r.bitRateAdapter.select(e):null}},{key:"log",value:function(e,t){for(var r=(this.playerConfig||{}).vid,n=r?"[Index]".concat(r," ").concat(t):"[Index] ".concat(t),i=arguments.length,a=Array(i>2?i-2:0),o=2;o=this.urlExpireTimestamp&&this.urlExpireTimestamp>0&&!n&&t.getServerTime&&(r.serverTimeDiffPromise=r.serverTimeDiffPromise||t.getServerTime().catch(function(){return 0}),r.serverTimeDiffPromise.then(function(t){if(t&&(r.serverTimeDiff=new Date().getTime()/1e3-t),new Date().getTime()/1e3>=e.urlExpireTimestamp+r.serverTimeDiff){e.urlExpireTimestamp=new Date().getTime()/1e3+86400;var n=new _.oO("network",_.O1["403"]);e._emitExpireEvent(n)}}))}},{key:"_emitExpireEvent",value:function(e){var t=this.player,r=new Date().getTime()/1e3;return this.emitExpireTimestamp?!!(r-this.emitExpireTimestamp>300)&&(this.emitExpireTimestamp=r,t.emit("MEDIA_EXPIRED",e),!0):(this.emitExpireTimestamp=r,t.emit("MEDIA_EXPIRED",e),!0)}},{key:"reportBugPostPlayerLog",value:function(){this.log(d._.LOG,"reportBugPostPlayerLog"),this.emit(C)}},{key:"getAllBufferRange",value:function(){var e=[],t=this.player;if(!t||!(null!=t&&t.buffered))return e;var r=t.buffered;if(r)for(var n=0,i=r.length;n=2160)return o.Res2160p;if(t>=1440)return o.Res1440p;else if(t>=1080)return o.Res1080p;else if(t>=720)return o.Res720p;else if(t>=540)return o.Res540p;else if(t>=480)return o.Res480p;else if(t>=360)return o.Res360p}var r=e.qualityType;if(r){if(r>=70&&r<=74)return o.Res2160p;if(r>=6&&r<=7)return o.Res1440p;else if(r>=1&&r<=5)return o.Res1080p;else if(r>=10&&r<=19)return o.Res720p;else if(r>=20&&r<=29)return o.Res540p;else if(r>=30&&r<=39)return o.Res480p;else if(r>=40&&r<=49)return o.Res360p}var n=e.gearName;if(n){if(n.includes("2160"))return o.Res2160p;if(n.includes("1440"))return o.Res1440p;else if(n.includes("1080"))return o.Res1080p;else if(n.includes("720"))return o.Res720p;else if(n.includes("540"))return o.Res540p;else if(n.includes("480"))return o.Res480p;else if(n.includes("360"))return o.Res360p}return""}(e);return p===o.Res1440p&&l?h=a(e,"1080",t,d):p===o.Res1080p&&u?h=a(e,"720",t,d):p===o.Res720p&&c&&(h=a(e,"540",t,d)),!h&&(h=e),(0,n.Zj)((0,n.Zj)({},h),{},{type:"overscore",fromType:e.type,orgDefinition:e.definition})}function a(e,t,r,n){for(var i=t.toLowerCase(),a=0;ao){if("number"==typeof s&&e.currentTime>s||e.currentTime>e.duration/2)return null==r||r("log","[checkIfStartPreload] hit buffer",u,"startPreloadMinBuffer",o),!0}else if(e.currentTime+o+1>e.duration&&e.currentTime+u>e.duration-1)return null==r||r("log","[checkIfStartPreload] hit end"),!0}else{var c="number"==typeof l&&e.duration>l+5?l:e.duration/2,d=Math.min(e.currentTime+l,e.duration),f=n[1]-d;if(e.currentTime>c&&f>-1)return null==r||r("log","[checkIfStartPreload] hit minPos",c,"minCacheTime",d),!0}return!1}function i(e,t,r){var n=t.endPreloadControl,i=t.endPreloadMinBuffer,o=t.startPreloadMinBuffer;if(!e)return!1;if(n){if("number"==typeof o&&e.currentTime+o>=e.duration)return!1;var s=Math.max(a(e.buffered,e.currentTime)[1]-e.currentTime,0);if(s<=i)return null==r||r("log","[checkIfCancelPreload] hit buffer:",s,"endPreloadMinBuffer:",i,"video:","".concat(e.currentTime,"/").concat(e.duration)),!0}return!1}function a(e,t){var r=[0,0];if(e)for(var n=0,i=e.length;ne.length)&&(t=e.length);for(var r=0,n=Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function d(e,t,r){return(t=E(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(l&&u){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:D(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function _(e,t){return(_=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){u=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||k(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||k(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t){if(e){if("string"==typeof e)return n(e,t);var r=({}).toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}},613753:function(e,t,r){r.d(t,{N:function(){return i}});var n=r(730210);r(932651);var i=(0,n.qH)(function e(t,r){(0,n.PA)(this,e),this.config=t,this.instManager=r},[{key:"updateConfig",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!!e)t?Object.assign(this.config,e):this.config=e}}])},340343:function(e,t,r){r.d(t,{Q:function(){return a}});var n=r(137263);r(162093),r(2885),r(248385);var i=r(4610),a=(0,n.qH)(function e(t,r,i,a){var o=this;(0,n.PA)(this,e),this.config=e.getDefaultConfig(),this.bitrate=0,this.lastAdaptCacheBuffer=0,a&&Object.keys(a).map(function(e){void 0!==a[e]&&null!==a[e]&&(o.config[e]=a[e])}),this.duration=i,this.player=t,this.updateBitrate(r)},[{key:"updateBitrate",value:function(e){this.bitrate=e,!this.bitrate&&(this.bitrate=this.config.minBandwidth)}},{key:"getAdaptLoadDuration",value:function(){var e=this.player,t=this.config;if(!t.rangeControl)return -1;var r=(null==e?void 0:e.bufferedPoint)||null,n=e&&null!=r&&r.end?r.end-e.currentTime:0;if(t.use_weibull){var a=this.calcToPlayDurationMs(t.cdf_for_playing_media_low)/1e3;a>this.lastAdaptCacheBuffer&&(a=this.lastAdaptCacheBuffer);var o=0;return ne.duration&&(o=e.duration-n),(0,i.uZ)(o,t.rangeMinDuration,t.rangeMaxDuration)}return Math.max(t.rangeMaxDuration-n,t.rangeMinDuration)}},{key:"getAdaptCacheBuffer",value:function(){var e=this.player,t=this.config,r=this.bitrate;if(!t.targetCacheControl)return this.lastAdaptCacheBuffer=-1,-1;var n=t.estPlayTime,i=(null==e?void 0:e.currentTime)||0,a=n;t.use_weibull?a=this.calcToPlayDurationMs(t.cdf_for_playing_media_buffer)/1e3:t.estPTcontrol&&(a=Math.min(n,(this.duration||(null==e?void 0:e.duration)||0)-i));var o=t.playbackRateControl&&e?e.playbackRate:1,s=e&&1024*e.avgSpeed/o||0,l=Math.max(t.safeFactor*s,t.minBandwidth);null!=e&&e.avgSpeed&&(l=t.safeFactor*s);var u=r>0?Math.floor((1-l/r)*a):0;return u=t.minDangerThreshold+Math.max(u,0),this.lastAdaptCacheBuffer=Math.min(Math.max(t.cacheSafeFactor*u,t.minTargetCacheDur),t.maxTargetCacheDur),this.lastAdaptCacheBuffer}},{key:"calcToPlayDurationMs",value:function(e){var t,r=this.player,n=this.config,a=null==r||null===(t=r.config)||void 0===t||null===(t=t.mediaInfo)||void 0===t?void 0:t.play_time_prob_dist,o=(0,i.eq)(a,n.default_weibull_param||i.XB),s=1e3*(this.duration||(null==r?void 0:r.duration)||0),l=1e3*((null==r?void 0:r.currentTime)||0),u=(0,i.cF)(o,e,s,l)-l;return u=(0,i.uZ)(u,n.min_to_play_ms,n.max_to_play_ms)}}],[{key:"getDefaultConfig",value:function(){return{rangeMaxDuration:15,rangeMinDuration:5,rangeMinSize:409600,safeFactor:.1,cacheSafeFactor:3,minDangerThreshold:5,estPlayTime:12,minBandwidth:1e6,estPTcontrol:!1,minTargetCacheDur:30,maxTargetCacheDur:60,targetCacheControl:!1,rangeControl:!1,playbackRateControl:!1,use_weibull:!1,default_weibull_param:i.XB,cdf_for_playing_media_buffer:.5,cdf_for_playing_media_low:.25,min_to_play_ms:1e3,max_to_play_ms:5e3}}}])},740651:function(e,t,r){r.d(t,{q:function(){return l}});var n,i=r(137263),a=r(734123),o=r(830571),s=r(373974),l=function(e){function t(e){(0,i.PA)(this,t);var r,a=(r=(0,i.$w)(this,t,[e])).player,o=r.playerConfig;return r.playerId=a.playerId,r.codecType=o.codecType?o.codecType.toLowerCase():s.u7.H264,r.bizType=a.bizType="number"==typeof o.bizType?o.bizType:s.Ye.Normal,o.vtype&&(r.vtype=o.vtype.toUpperCase()),n&&(a.preloader=n),r}return(0,i.XW)(t,e),(0,i.qH)(t,[{key:"softDecode",get:function(){var e;return(null===(e=this.playerConfig)||void 0===e?void 0:e.mediaType)==="xg-video"}}],[{key:"registerPreloader",value:function(e){if(!!e)n=e,o.w.getInstance().findAll(function(e){return!e.config.isLive&&(e.preloader=n),!1})}}])}(a.BasePlugin)},373974:function(e,t,r){r.d(t,{Ye:function(){return l},_R:function(){return d},kW:function(){return c},l0:function(){return s},l1:function(){return f},sm:function(){return h},u7:function(){return u}});var n,i,a,o=r(137263);var s=((n=s||{}).MP4="MP4",n.MP4_MSE_SOFT="MP4_MSE_SOFT",n.MP4_MSE="MP4_MSE",n.MP4_0="MP4_0",n.MP4_1="MP4_1",n.MP4_2="MP4_2",n.DASH="DASH",n.HLS="HLS",n);var l=((i=l||{})[i.Normal=0]="Normal",i[i.Ad=1]="Ad",i);var u=((a=u||{})[a.AVC=0]="AVC",a[a.HEVC=1]="HEVC",a[a.VVC=2]="VVC",a.H264="h264",a.H265="h265",a.H266="h266",a),c="real_time_speed",d={CDN:"cdn",PCDN:"pcdn"},f={BEFEORE_START:0,NOT_SUPPORTED:1,START_INIT_DESTROY:2,NO_PRELOAD:3,CLOSE_DWNGRADE:4,INIT_PROMISE_CATCH:5,PLAYER_ERROR:6,HTTP_ERROR:7,MSE_ERROR:8,DESTROY:9},h=(0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)((0,o._x)({},f.BEFEORE_START,"before start"),f.NOT_SUPPORTED,"codec not support"),f.START_INIT_DESTROY,"start init destroy"),f.NO_PRELOAD,"no preload"),f.CLOSE_DWNGRADE,"close downgrade"),f.INIT_PROMISE_CATCH,"init promise catch"),f.PLAYER_ERROR,"player error"),f.HTTP_ERROR,"http error"),f.MSE_ERROR,"mse error"),f.DESTROY,"destroy")},428235:function(e,t,r){r.d(t,{Z:function(){return a}});var n=function(){return i&&!function(){var e="_localstorage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()}();function i(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}let a={length:n?localStorage.length:0,clear:function(e){try{for(var t=localStorage.length-1;t>=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}}catch(e){}},getItem:function(e){try{return localStorage.getItem(e)}catch(e){return null}},key:function(e){try{return localStorage.key(e)}catch(e){return null}},setItem:function(e,t){try{localStorage.setItem(e,t)}catch(e){}},removeItem:function(e){try{localStorage.removeItem(e)}catch(e){}},isSupport:n}},510142:function(e,t,r){r.d(t,{l:function(){return i}});var n=r(204885);function i(){(0,n.z)()}},165436:function(e,t,r){r.d(t,{Z:function(){return i}});var n=r(405935);r(248385),r(679308);var i=function(){function e(){(0,n.PA)(this,e);var t,r,i=new Promise(function(e,n){t=e,r=n});return i.resolve=t,i.reject=r,i}return(0,n.qH)(e,[{key:"resolve",value:function(e){}},{key:"reject",value:function(e){}}]),e}()},92956:function(e,t,r){r.d(t,{Z:function(){return i}});var n=r(405935),i=function(){function e(){(0,n.PA)(this,e)}return(0,n.qH)(e,null,[{key:"install",value:function(){if(window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,window.cancelAnimationFrame=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame,!window.requestAnimationFrame){var e=Date.now();window.requestAnimationFrame=function(t){var r=Date.now(),n=Math.max(16.7-(r-e),0),i=setTimeout(t,n);return e=r+n,i}}!window.cancelAnimationFrame&&(window.cancelAnimationFrame=function(e){clearTimeout(e)})}}]),e}()},227346:function(e,t,r){r.d(t,{p:function(){return n}});function n(e,t,r){var n;return function(i){var a,o,s,l,u,c,d;return new Worker(n=n||(a=e,o=t,s=r,l=void 0===o?null:o,c=(u=function(e,t){var r=atob(e);if(t){for(var n=new Uint8Array(r.length),i=0,a=r.length;i=1300){(0,o.DO)(1);return}if(t>=1e3){(0,o.DO)(3);return}t>=500&&(0,o.Dd)()}},{key:"addWaiting",value:function(){this._dot.push({action:u.WAITIGN,dot:this._getTimestap()})}},{key:"addSeeking",value:function(){this._dot.push({action:u.SEEKING,dot:this._getTimestap()})}},{key:"addSeeked",value:function(){this._dot.push({action:u.SEEKED,dot:this._getTimestap()})}},{key:"_getTimestap",value:function(){return performance.now()}},{key:"increaseLowDecodeCount",value:function(e){this._currentLowDecodeCount++,this._currentLowDecodeCount>=1&&e<=(0,s.tT)().tempDisabledThreshold&&(l.kg.warn("Analyse","disabled!, fps=".concat(e,", threshold=").concat((0,s.tT)().tempDisabledThreshold)),(0,o.DO)(2))}},{key:"reset",value:function(){this._currentLowDecodeCount=0,this._dot=[]}}]),e}()},685290:function(e,t,r){r.d(t,{Z:function(){return o},s:function(){return a}});var n=r(315355),i=r(919209);function a(e){var t;(null===(t=e.buffer)||void 0===t?void 0:t.close)&&e.buffer.close()}r(9498),r(705574),r(663030);var o=function(){function e(t){(0,n.Z)(this,e),this.TAG="FrameQueue",this._parent=t,this._lastGopId=0,this._frames=[]}return(0,i.Z)(e,[{key:"currentTimeDts",get:function(){return this._parent.preciseVideoDts}},{key:"length",get:function(){return this._frames.length}},{key:"frames",get:function(){return this._frames}},{key:"append",value:function(e){if(!e.info){a(e);return}this._frames.push(e)}},{key:"appendVodFrame",value:function(e){this._frames.push(e)}},{key:"nextFrame",value:function(){var e=this._frames.length;return 1===this._parent.noAudio&&e>3&&(this._frames=this._frames.slice(e-2)),this._frames[0]}},{key:"shift",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this._frames.shift();return this.deletePassed(e),t}},{key:"deletePassed",value:function(e){this._frames=this._frames.filter(function(t){return!!t.info&&!!(t.info.dts>e)||(a(t),!1)})}},{key:"empty",value:function(){this._frames.forEach(function(e){return a(e)}),this._frames=[]}},{key:"destroy",value:function(){this.empty(),this._lastGopId=0}}]),e}()},830361:function(e,t,r){r.d(t,{Z:function(){return c}});var n=r(264911),i=r(315355),a=r(919209),o=r(272787);r(124300),r(248385),r(591111),r(490629),r(656562);var s=r(597931),l=r(874668),u=[],c=function(){function e(t,r,a){var s=this;(0,i.Z)(this,e),(0,o.Z)(this,"TAG","RenderWorker"),(0,o.Z)(this,"timerWorkerCache",u),(0,o.Z)(this,"_errorOccur",!1),(0,o.Z)(this,"_doTask",function(e){var t,r;if("NEXT_TICK"===e.data.type){null===(t=s._task)||void 0===t||t.call(s);return}if("RENDER_ERR"===e.data.type){s._emitError(e.data.msg);return}"RESIZE_EVENT"===e.data.type&&(null===(r=s._parent)||void 0===r||r.emitResizeEvent())}),(0,o.Z)(this,"_onError",function(e){s._emitError(e.message)}),(0,o.Z)(this,"_emitError",function(e){s._errorOccur=!0,s._worker&&(s._worker._cvs=null,s._worker._offscreen=null),s._cvs&&(s._cvs._worker=null),s._parent._emitError(e,3)}),this._task=t,this._parent=a;var l=this._initCanvasWorkerPair(r),c=(0,n.Z)(l,2),d=c[0],f=c[1];f&&(this._worker=f,this._cvs=d,this._bindEvent())}return(0,a.Z)(e,[{key:"canvas",get:function(){return this._cvs}},{key:"_initCanvasWorkerPair",value:function(e){var t,r=this,n=e.canvas||(null===(t=u.pop())||void 0===t?void 0:t._cvs)||document.createElement("canvas");if(n.style.margin="auto",n.style.position="absolute",n.style.pointerEvents="none",n._worker)return s.kg.log(this.TAG,"init canvas && worker, use cached,",n.width,n.height),[n,n._worker];try{var i=new Blob(["\n class FrameRender {\n constructor (configs) {\n this.TAG = 'FrameRender'\n this.configs = Object.assign({}, configs)\n this.canvas = this.configs.canvas\n this.meta = Object.assign({}, this.configs.meta)\n this._initMeta()\n this._initContextGL()\n if (this.contextGL) {\n this._initProgram()\n this._initBuffers()\n this._initTextures()\n }\n }\n\n _initMeta () {\n this.chroma = this.meta.chromaFormat\n this.height = this.meta.height\n this.width = this.meta.width\n if (this.canvas.width !== this.meta.width || this.canvas.height !== this.meta.height) {\n this.canvas.width = this.meta.width\n this.canvas.height = this.meta.height\n self.postMessage({\n type: 'RESIZE_EVENT'\n })\n }\n this.clear()\n }\n\n _initContextGL () {\n if (this.configs.type === '2d') {\n this.ctx = this.canvas.getContext('2d')\n return\n }\n var canvas = this.canvas\n let gl = null\n\n var validContextNames = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d']\n let nameIndex = 0\n\n while (!gl && nameIndex < validContextNames.length) {\n var contextName = validContextNames[nameIndex]\n\n try {\n gl = canvas.getContext(contextName, this.configs.glCtxOptions)\n break\n } catch (e) {\n gl = null\n }\n\n if (!gl || typeof gl.getParameter !== 'function') {\n gl = null\n }\n\n ++nameIndex\n }\n\n if(!gl) {\n throw new Error('init webgl context error')\n }\n\n this.contextGL = gl\n }\n\n _initProgram () {\n var gl = this.contextGL\n\n // vertex shader is the same for all types\n var vertexShaderScript\n var fragmentShaderScript\n vertexShaderScript = [\n 'attribute vec4 vertexPos;',\n 'attribute vec4 texturePos;',\n 'attribute vec4 uTexturePos;',\n 'attribute vec4 vTexturePos;',\n 'varying vec2 textureCoord;',\n 'varying vec2 uTextureCoord;',\n 'varying vec2 vTextureCoord;',\n\n 'void main()',\n '{',\n ' gl_Position = vertexPos;',\n ' textureCoord = texturePos.xy;',\n ' uTextureCoord = uTexturePos.xy;',\n ' vTextureCoord = vTexturePos.xy;',\n '}'\n ].join('')\n\n fragmentShaderScript = [\n 'precision highp float;',\n 'varying highp vec2 textureCoord;',\n 'varying highp vec2 uTextureCoord;',\n 'varying highp vec2 vTextureCoord;',\n 'uniform sampler2D ySampler;',\n 'uniform sampler2D uSampler;',\n 'uniform sampler2D vSampler;',\n 'uniform mat4 YUV2RGB;',\n\n 'void main(void) {',\n ' highp float y = texture2D(ySampler, textureCoord).r;',\n ' highp float u = texture2D(uSampler, uTextureCoord).r;',\n ' highp float v = texture2D(vSampler, vTextureCoord).r;',\n ' gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',\n '}'\n ].join('')\n\n var YUV2RGB = [1.16438, 0.0, 1.59603, -0.87079, 1.16438, -0.39176, -0.81297, 0.52959, 1.16438, 2.01723, 0.0, -1.08139, 0, 0, 0, 1]\n var vertexShader = gl.createShader(gl.VERTEX_SHADER)\n gl.shaderSource(vertexShader, vertexShaderScript)\n gl.compileShader(vertexShader)\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n console.log('Vertex shader failed to compile: ' + gl.getShaderInfoLog(vertexShader))\n }\n\n var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER)\n gl.shaderSource(fragmentShader, fragmentShaderScript)\n gl.compileShader(fragmentShader)\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n console.log('Fragment shader failed to compile: ' + gl.getShaderInfoLog(fragmentShader))\n }\n\n var program = gl.createProgram()\n gl.attachShader(program, vertexShader)\n gl.attachShader(program, fragmentShader)\n gl.linkProgram(program)\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n console.log('Program failed to compile: ' + gl.getProgramInfoLog(program))\n }\n\n gl.useProgram(program)\n\n var YUV2RGBRef = gl.getUniformLocation(program, 'YUV2RGB')\n gl.uniformMatrix4fv(YUV2RGBRef, false, YUV2RGB)\n\n this.shaderProgram = program\n }\n\n _initBuffers () {\n var gl = this.contextGL\n const program = this.shaderProgram\n\n var vertexPosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), gl.STATIC_DRAW)\n\n var vertexPosRef = gl.getAttribLocation(program, 'vertexPos')\n gl.enableVertexAttribArray(vertexPosRef)\n gl.vertexAttribPointer(vertexPosRef, 2, gl.FLOAT, false, 0, 0)\n\n var texturePosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.STATIC_DRAW)\n\n var texturePosRef = gl.getAttribLocation(program, 'texturePos')\n gl.enableVertexAttribArray(texturePosRef)\n gl.vertexAttribPointer(texturePosRef, 2, gl.FLOAT, false, 0, 0)\n\n this.texturePosBuffer = texturePosBuffer\n\n var uTexturePosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, uTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.STATIC_DRAW)\n\n var uTexturePosRef = gl.getAttribLocation(program, 'uTexturePos')\n gl.enableVertexAttribArray(uTexturePosRef)\n gl.vertexAttribPointer(uTexturePosRef, 2, gl.FLOAT, false, 0, 0)\n\n this.uTexturePosBuffer = uTexturePosBuffer\n\n var vTexturePosBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, vTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.STATIC_DRAW)\n\n var vTexturePosRef = gl.getAttribLocation(program, 'vTexturePos')\n gl.enableVertexAttribArray(vTexturePosRef)\n gl.vertexAttribPointer(vTexturePosRef, 2, gl.FLOAT, false, 0, 0)\n\n this.vTexturePosBuffer = vTexturePosBuffer\n }\n\n _initTextures () {\n var gl = this.contextGL\n var program = this.shaderProgram\n var yTextureRef = this._initTexture()\n var ySamplerRef = gl.getUniformLocation(program, 'ySampler')\n gl.uniform1i(ySamplerRef, 0)\n this.yTextureRef = yTextureRef\n\n var uTextureRef = this._initTexture()\n var uSamplerRef = gl.getUniformLocation(program, 'uSampler')\n gl.uniform1i(uSamplerRef, 1)\n this.uTextureRef = uTextureRef\n\n var vTextureRef = this._initTexture()\n var vSamplerRef = gl.getUniformLocation(program, 'vSampler')\n gl.uniform1i(vSamplerRef, 2)\n this.vTextureRef = vTextureRef\n\n // fix WebGL: INVALID_OPERATION: texImage2D: ArrayBufferView not big enough for request\n // texture bound to texture unit 1 is not renderable. It might be non-power-of-2 or have incompatible texture filtering (maybe)\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1)\n }\n\n _initTexture () {\n var gl = this.contextGL\n\n var textureRef = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, textureRef)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)\n gl.bindTexture(gl.TEXTURE_2D, null)\n\n return textureRef\n }\n\n _drawPictureGL (data, width, height, yLinesize, uvLinesize) {\n var ylen = yLinesize * height\n let uvlen = (uvLinesize * height) / 2\n if (this.chroma === 444 || this.chroma === 422) {\n uvlen *= 2\n }\n data = new Uint8Array(data)\n var renderData = {\n yData: data.subarray(0, ylen),\n uData: data.subarray(ylen, ylen + uvlen),\n vData: data.subarray(ylen + uvlen, ylen + uvlen + uvlen)\n }\n this._drawPictureGL420(renderData, width, height, yLinesize, uvLinesize)\n }\n\n _drawPictureGL420 (data, width, height, yLinesize, uvLinesize) {\n var gl = this.contextGL\n var texturePosBuffer = this.texturePosBuffer\n var uTexturePosBuffer = this.uTexturePosBuffer\n var vTexturePosBuffer = this.vTexturePosBuffer\n\n var yTextureRef = this.yTextureRef\n var uTextureRef = this.uTextureRef\n var vTextureRef = this.vTextureRef\n\n var yData = data.yData\n var uData = data.uData\n var vData = data.vData\n\n var yDataPerRow = yLinesize\n var yRowCnt = height\n\n var uDataPerRow = uvLinesize\n let uRowCnt = height / 2\n\n if (this.chroma === 422 || this.chroma === 444) {\n uRowCnt = height\n }\n\n var vDataPerRow = uvLinesize\n var vRowCnt = uRowCnt\n\n var ratiow = this.canvas.width / this.width\n var ratioh = this.canvas.height / this.height\n let left = 0\n let top = 0\n let w = this.canvas.width\n let h = this.canvas.height\n if (ratiow < ratioh) {\n h = (this.height * this.canvas.width) / this.width\n top = parseInt((this.canvas.height - (this.height * this.canvas.width) / this.width) / 2)\n } else {\n w = (this.width * this.canvas.height) / this.height\n left = parseInt((this.canvas.width - (this.width * this.canvas.height) / this.height) / 2)\n }\n gl.viewport(left, top, w, h)\n\n const texturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1])\n gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, texturePosValues, gl.DYNAMIC_DRAW)\n\n const uTexturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1])\n gl.bindBuffer(gl.ARRAY_BUFFER, uTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, uTexturePosValues, gl.DYNAMIC_DRAW)\n\n const vTexturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1])\n gl.bindBuffer(gl.ARRAY_BUFFER, vTexturePosBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, vTexturePosValues, gl.DYNAMIC_DRAW)\n\n gl.activeTexture(gl.TEXTURE0)\n gl.bindTexture(gl.TEXTURE_2D, yTextureRef)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, yDataPerRow, yRowCnt, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData)\n\n gl.activeTexture(gl.TEXTURE1)\n gl.bindTexture(gl.TEXTURE_2D, uTextureRef)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, uDataPerRow, uRowCnt, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, uData)\n\n gl.activeTexture(gl.TEXTURE2)\n gl.bindTexture(gl.TEXTURE_2D, vTextureRef)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, vDataPerRow, vRowCnt, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, vData)\n\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)\n }\n\n _drawPicture2d (data) {\n if (!data) {\n return\n }\n if (this.canvas) {\n if (!this.ctx) {\n this.ctx = this.canvas.getContext('2d')\n }\n var width = data.displayWidth || data.width\n var height = data.displayHeight || data.height\n if (this.canvas.height !== height || this.canvas.width !== width) {\n this.canvas.height = height\n this.canvas.width = width\n }\n try {\n this.ctx.drawImage(data.dom || data, 0, 0, width, height)\n } catch (error) {\n // console.error(this.TAG, '_drawPicture2d', data, data.dom, error, error.message)\n }\n }\n }\n\n _resize (width, height) {\n if (this.canvas.width !== width || this.canvas.height !== height) {\n this.width = width\n this.height = height\n this.canvas.width = width\n this.canvas.height = height\n self.postMessage({\n type: 'RESIZE_EVENT'\n })\n }\n }\n\n render (data, width, height, yLinesize, uvLinesize) {\n this._resize(width, height)\n var gl = this.contextGL\n if (gl) {\n this._drawPictureGL(data, width, height, yLinesize, uvLinesize)\n } else {\n this._drawPicture2d(data)\n }\n }\n\n updateMeta (meta) {\n this.meta = Object.assign({}, meta)\n this._initMeta()\n }\n\n clear () {\n if (this.contextGL) {\n this.contextGL.clear(this.contextGL.DEPTH_BUFFER_BIT | this.contextGL.COLOR_BUFFER_BIT)\n }\n }\n }\n\n var timer\n var frameRender\n\n function initTimer (interval) {\n stopTimer()\n clearInterval(timer)\n timer = setInterval(function () {\n self.postMessage({ type: 'NEXT_TICK' })\n }, interval)\n }\n\n function stopTimer () {\n clearInterval(timer)\n }\n\n function initWebgl (canvas, meta, type) {\n try {\n frameRender = new FrameRender({\n canvas,\n meta,\n type\n })\n } catch (e) {\n self.postMessage({\n type: 'RENDER_ERR',\n msg: e && e.message\n })\n }\n }\n\n self.onmessage = function (e) {\n var { type, interval } = e.data\n switch (type) {\n case 'START':\n initTimer(interval)\n break\n case 'DESTROY':\n stopTimer()\n break\n case 'OFFSCREEN_CANVAS':\n if (!frameRender) {\n initWebgl(e.data.canvas, e.data.meta, e.data.ctxType)\n }\n break\n case 'UPDATE_META':\n frameRender && frameRender.updateMeta(e.data.meta)\n break\n case 'RENDER':\n try {\n frameRender && frameRender.render(e.data.data, e.data.width, e.data.height, e.data.yLinesize, e.data.uvLinesize)\n } catch (e) {\n self.postMessage({\n type: 'RENDER_ERR',\n msg: e && e.message\n })\n }\n break\n case 'CLEAR':\n frameRender && frameRender.clear()\n break\n default:\n }\n }\n"],{type:"application/javascript"}),a=new Worker(URL.createObjectURL(i));if((0,l.tT)().offscreenCanvas){var o=n.transferControlToOffscreen();a._offscreen=o,a._cvs=n,n._worker=a}return s.kg.log(this.TAG,"init canvas && worker, new created"),[n,a]}catch(e){setTimeout(function(){r._emitError(e.message)})}return[]}},{key:"_bindEvent",value:function(){this._worker.addEventListener("message",this._doTask),this._worker.addEventListener("error",this._onError)}},{key:"startLoop",value:function(e){var t;(e=parseInt(e))<10?e=10:e>60?e=60:e-=8,null===(t=this._worker)||void 0===t||t.postMessage({type:"START",interval:e})}},{key:"stopLoop",value:function(){this._worker.postMessage({type:"DESTROY"})}},{key:"initRenderContext",value:function(e){var t,r,n,i=e.meta,a=e.type;if(null!==(t=this._worker)&&void 0!==t&&t._offscreen&&(this._worker._offscreen.width=i.width,this._worker._offscreen.height=i.height),null!==(r=this._worker)&&void 0!==r&&null!==(n=r._offscreen)&&void 0!==n&&n.cloned){this._worker.postMessage({type:"UPDATE_META",meta:i});return}this._worker.postMessage({type:"OFFSCREEN_CANVAS",canvas:this._worker._offscreen,meta:i,ctxType:a},[this._worker._offscreen]),this._worker._offscreen.cloned=1}},{key:"render",value:function(e,t,r,n,i){this._worker.postMessage({type:"RENDER",data:e,width:t,height:r,yLinesize:n,uvLinesize:i},[e])}},{key:"destroy",value:function(e){this._worker&&(this._worker.postMessage({type:"DESTROY"}),this._worker.removeEventListener("message",this._doTask),this._worker.removeEventListener("error",this._onError),e&&!this._errorOccur&&(u.push(this._worker),this._worker.postMessage({type:"CLEAR"}),s.kg.log(this.TAG,"cache render worker")),this._worker=null,this._task=null)}}]),e}()},976290:function(e,t,r){r.d(t,{i:function(){return a}});var n=r(182432),i=r(275764);function a(e){return(0,n.Zj)({loaderType:i.t.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:i.U.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}},697946:function(e,t,r){r.d(t,{PA:function(){return a},ZQ:function(){return u},Zj:function(){return i},_x:function(){return l},qH:function(){return s},u:function(){return c}});function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=Array(t);r1?t-1:0),n=1;n>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var o=8;return r.forEach(function(e){a.set(e,o),o+=e.byteLength}),a}},{key:"type",value:function(t){return!e.types[t]&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]),e.types[t]}},{key:"FullBox",value:function(t,r,n){for(var i=arguments.length,a=Array(i>3?i-3:0),o=3;o>16&255,n>>8&255,255&n])].concat(a))}},{key:"ftyp",value:function(t){var r=t.find(function(e){return e.type===i.Vc.VIDEO});if((null==r?void 0:r.codecType)===i._e.HEVC)return e.FTYPHEV1;var n=(0,a.YW)({track:r});return null!=n&&n.buildFtyp?n.buildFtyp({track:r,tracks:t,MP4:e}):e.FTYPAVC1}},{key:"initSegment",value:function(t){if(!t||!t.length)return new Uint8Array;var r=e.ftyp(t);return(0,o.gJ)(r,e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],(0,o.Qc)(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(!t[0].useEME||!t[0].encv&&!t[0].enca)return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat((0,n.u)(t.map(function(t){return e.trak(t)})),[e.mvex(t)]));!t[0].pssh&&(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat((0,n.u)(t.map(function(t){return e.trak(t)})),[r]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]))}},{key:"edts",value:function(t){return e.box(e.types.edts,e.elst(t))}},{key:"elst",value:function(t){t.entries;var r=t.entriesData,n=t.version;return e.FullBox(e.types.elst,n,0,r)}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]))}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===i.Vc.VIDEO?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){return t&&t.ext,e.box(e.types.stbl,e.stsd(t),e.STTS,(0,void 0),e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===i.yQ.OPUS?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1vvc1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,n=t.enca.sampleRate,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,n>>8&255,255&n,0,0]),a=e.esds(t.config),o=e.sinf(t.enca);return e.box(e.types.enca,i,a,o)}},{key:"encv",value:function(t){var r=t.width,o=t.height,s=t.sarRatio&&t.sarRatio.length>1?t.sarRatio[0]:0,l=t.sarRatio&&t.sarRatio.length>1?t.sarRatio[1]:0,u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,r>>8&255,255&r,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),c=(0,a.YW)({track:t});if(t.codecType===i._e.HEVC)d=e.hvcC(t);else if(null!=c&&c.buildConfigBox)d=c.buildConfigBox({track:t,MP4:e});else{var d,f,h,p=t.sps&&t.sps.length>0?t.sps[0]:[],g=t.pps&&t.pps.length>0?t.pps[0]:[],v=new Uint8Array((f=(h=[1,p[1],p[2],p[3],255,225,p.length>>>8&255,255&p.length]).concat.apply(h,(0,n.u)(p)).concat([1,g.length>>>8&255,255&g.length])).concat.apply(f,(0,n.u)(g)));d=e.box(e.types.avcC,v)}var m=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),y=e.sinf(t.encv),_=[u,d,e.box(e.types.btrt,m),y];if(t.sarRatio&&t.sarRatio.length>1){var T=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,l>>24,l>>16&255,l>>8&255,255&l]);_.push(e.box(e.types.pasp,T))}return e.box.apply(e,[e.types.encv].concat(_))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat((0,o.Qc)(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"av01",value:function(t){return e.box(e.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1vvc1",value:function(t){if(t.codecType===i._e.HEVC)n=e.hvcC(t),o=e.types.hvc1;else if(null!==(r=(0,a.YW)({track:t}))&&void 0!==r&&r.buildConfigBox){var r,n,o,s=(0,a.YW)({track:t});n=s.buildConfigBox({track:t,MP4:e}),o=e.type(s.getSampleEntryType?s.getSampleEntryType({track:t}):s.sampleEntries[0])}else n=e.avcC(t),o=e.types.avc1;var l=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n];return t.codecType===i._e.HEVC?l.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&l.push(e.pasp(t.sarRatio)),e.box.apply(e,[o].concat(l))}},{key:"avcC",value:function(t){var r,i,a,o=[],s=[];return t.sps.forEach(function(e){a=e.byteLength,o.push(a>>>8&255),o.push(255&a),o.push.apply(o,(0,n.u)(e))}),t.pps.forEach(function(e){a=e.byteLength,s.push(a>>>8&255),s.push(255&a),s.push.apply(s,(0,n.u)(e))}),e.box(e.types.avcC,new Uint8Array((r=(i=[1,o[3],o[4],o[5],255,224|t.sps.length]).concat.apply(i,o).concat([t.pps.length])).concat.apply(r,s)))}},{key:"vvcC",value:function(t){var r=(0,a.YW)({track:t});return null!=r&&r.buildConfigBox?r.buildConfigBox({track:t,MP4:e}):e.box(e.types.vvcC,new Uint8Array(t.vvcC))}},{key:"hvcC",value:function(t){var r,i=t.hvcC;if(i instanceof ArrayBuffer||i instanceof Uint8Array)return i;var a=t.vps,o=t.sps,s=t.pps;if(i){var l=i.generalProfileCompatibilityFlags,u=i.generalConstraintIndicatorFlags,c=(a.length&&1)+(o.length&&1)+(s.length&&1);r=[1,i.generalProfileSpace<<6|i.generalTierFlag<<5|i.generalProfileIdc,l>>>24,l>>>16,l>>>8,l,u[0],u[1],u[2],u[3],u[4],u[5],i.generalLevelIdc,240,0,252,252|i.chromaFormatIdc,248|i.bitDepthLumaMinus8,248|i.bitDepthChromaMinus8,0,0,i.numTemporalLayers<<3|i.temporalIdNested<<2|3,c];var d=function(e){var t;r.push(e.length>>8,e.length),(t=r).push.apply(t,(0,n.u)(e))};a.length&&(r.push(160,0,a.length),a.forEach(d)),o.length&&(r.push(161,0,o.length),o.forEach(d)),s.length&&(r.push(162,0,s.length),s.forEach(d))}else r=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(r))}},{key:"pasp",value:function(t){var r=(0,n.ZQ)(t,2),i=r[0],a=r[1];return e.box(e.types.pasp,new Uint8Array([i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),n=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,n)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat((0,n.u)(t.map(function(t){return e.trex(t.id)}))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat((0,n.u)(t.map(function(t){return e.traf(t)}))))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach(function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2+6*e.subsamples.length)}),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var a=e.saiz(t),o=e.saio(t),s=e.trun1(t),l=e.senc(t);return e.box(e.types.traf,r,n,a,o,s,l)}if(t.isAudioEncryption){var u=e.sbgp(),c=e.saiz(t),d=e.saio(t),f=e.senc(t),h=e.trun1(t);return e.box(e.types.traf,r,n,u,c,d,f,h)}var p=e.sbgp(),g=e.trun1(t);return e.box(e.types.traf,r,n,p,g)}else{if(t.isVideo){var v=e.trun1(t);return e.box(e.types.traf,r,n,v)}var m=e.sbgp(),y=e.saiz(t),_=e.saio(t),T=e.senc(t),b=e.trun1(t);return e.box(e.types.traf,r,n,m,y,_,T,b)}}var E=e.sdtp(t);return e.box(e.types.traf,r,n,E,e.trun(t.samples,E.byteLength+76))}},{key:"sdtp",value:function(t){var r=new s.Z;return t.samples.forEach(function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))}),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new s.Z,n=s.Z.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=s.Z.writeUint32(76+16*t.samples.length+a+77),!t.isVideoEncryption&&t.isAudioEncryption&&(i=s.Z.writeUint32(76+16*t.samples.length+20))}else{var o=76+12*t.samples.length+52;t.isAudioEncryption&&(o=76+12*t.samples.length+8*t.audioSenc.length+105),i=s.Z.writeUint32(o)}return t.samples.forEach(function(e){r.write(s.Z.writeUint32(e.duration)),r.write(s.Z.writeUint32(e.size)),r.write(s.Z.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(s.Z.writeUint32(e.cts?e.cts:0))}),e.box(e.types.trun,this.extension(0,t.flags),n,i,r.buffer)}},{key:"senc",value:function(t){var r=new s.Z,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,o=[],l=0;return t.isVideo?(o=t.videoSenc,l=t.videoSencLength):o=t.audioSenc,l=l||i*n,r.write(s.Z.writeUint32(16+l),e.types.senc,this.extension(0,a)),r.write(s.Z.writeUint32(n)),o.forEach(function(e){for(var t=0;t>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,n)}},{key:"saiz",value:function(t){var r=t.samples.length,n=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,n)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t){var r=Math.floor(t/(l+1)),n=Math.floor(t%(l+1));return e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var o=0;o>>24&255,l>>>16&255,l>>>8&255,255&l,u>>>24&255,u>>>16&255,u>>>8&255,255&u,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*o)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat((0,n.u)(t.map(function(t){return e.trackMP4(t)}))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===i.Vc.VIDEO?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,n=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&n.push(e.stss(r.stss)),r.ctts.length&&n.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(n))}},{key:"stts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach(function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8}),e.box(e.types.stts,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach(function(e){var t=e.firstChunk,r=e.samplesPerChunk,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12}),e.box(e.types.stsc,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsz",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach(function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4}),e.box(e.types.stsz,(0,o.gJ)(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stco",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach(function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4}),e.box(e.types.stco,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stss",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach(function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4}),e.box(e.types.stss,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"ctts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach(function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8}),e.box(e.types.ctts,(0,o.gJ)(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,a=t.samples[0].sampleOffset*n,o=8;t.samples.forEach(function(e){o+=e.size});var s=0;if(t.isVideo){var l,u=0;t.videoSenc&&(l=t.videoSenc),t.isVideo&&l.forEach(function(e){u+=8,e.subsamples&&e.subsamples.length&&(u+=2+6*e.subsamples.length)}),t.videoSencLength=u,s=o+141+16*t.samples.length+u,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(s=o+16*t.samples.length+84)}else s=o+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(s=o+169+12*t.samples.length+8*t.audioSenc.length);var c=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,1,0,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,c)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();(0,n._x)(u,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","edts","elst","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp","vvc1","vvi1","vvcC"].reduce(function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e},Object.create(null))),(0,n._x)(u,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])}),(0,n._x)(u,"FTYPAVC1",u.box(u.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),(0,n._x)(u,"FTYPHEV1",u.box(u.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),(0,n._x)(u,"FTYPVVC1",u.box(u.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,118,118,99,49]))),(0,n._x)(u,"DINF",u.box(u.types.dinf,u.box(u.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),(0,n._x)(u,"VMHD",u.box(u.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),(0,n._x)(u,"SMHD",u.box(u.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),(0,n._x)(u,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),(0,n._x)(u,"STTS",u.box(u.types.stts,u.StblTable)),(0,n._x)(u,"STSC",u.box(u.types.stsc,u.StblTable)),(0,n._x)(u,"STSZ",u.box(u.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),(0,n._x)(u,"STCO",u.box(u.types.stco,u.StblTable))},365975:function(e,t,r){r.d(t,{W:function(){return a}});var n=r(519357),i=r(146202),a=function(){function e(){(0,n.PA)(this,e)}return(0,n.qH)(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n,i,a=t.length,o=0;o+2=a)){var s=o,l=[],u=(60&t[o+2])>>>2,c=e.FREQ[u];if(!c)throw Error("Invalid sampling index: ".concat(u));for(var d=((192&t[o+2])>>>6)+1,f=(1&t[o+2])<<2|(192&t[o+3])>>>6,h=e._getConfig(u,f,d),p=h.config,g=h.codec,v=0,m=e.getFrameDuration(c);o+7>5,a-o=a?void 0:t.subarray(o),frames:l,samplingFrequencyIndex:u,sampleRate:c,objectType:d,channelCount:f,codec:g,config:p,originCodec:"mp4a.40.".concat(d)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(!!t.length){var r=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,i=(120&t[1])>>>3,a=e.FREQ[n];if(a){var o=e._getConfig(n,i,r),s=o.config;return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s,codec:o.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,a,o=[];return i.vU?e>=6?(n=5,a=e-3):(n=2,a=e):i.Dt?(n=2,a=e):(n=2===r||5===r?r:5,a=e,e>=6?a=e-3:1===t&&(n=2,a=e)),o[0]=n<<3,o[0]|=(14&e)>>1,o[1]=(1&e)<<7,o[1]|=t<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t||3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();(0,n._x)(a,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350])}}]);