/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_virtual/_rollupPluginBabelHelpers.js"),t=require("../../../_virtual/index.js"),i=require("./utils/util.js"),a=require("./utils/sniffer.js"),r=require("./error.js"),n=require("./events.js");function d(e,t){this&&this.emit&&("error"===e?this.errorHandler(e,t.error):this.emit(e,t))}var o=function(t){e.inherits(s,t);var o=e.createSuper(s);function s(t){var r;e.classCallCheck(this,s),(r=o.call(this,t))._hasStart=!1,r._currentTime=0,r._duration=0,r._internalOp={},r._lastMuted=!1,r.vtype="MP4",r._rate=-1,r.mediaConfig=Object.assign({},{controls:!1,autoplay:t.autoplay,playsinline:t.playsinline,"x5-playsinline":t.playsinline,"webkit-playsinline":t.playsinline,"x5-video-player-fullscreen":t["x5-video-player-fullscreen"]||t.x5VideoPlayerFullscreen,"x5-video-orientation":t["x5-video-orientation"]||t.x5VideoOrientation,airplay:t.airplay,"webkit-airplay":t.airplay,tabindex:0|t.tabindex,mediaType:t.mediaType||"video","data-index":-1},t.videoConfig,t.videoAttributes);var n=t["x5-video-player-type"]||t.x5VideoPlayerType;return a.default.isWeixin&&a.default.os.isAndroid&&n&&(r.mediaConfig["x5-video-player-type"]=n,delete r.mediaConfig.playsinline,delete r.mediaConfig["webkit-playsinline"],delete r.mediaConfig["x5-playsinline"]),t.loop&&(r.mediaConfig.loop="loop"),t.autoplayMuted&&!Object.prototype.hasOwnProperty.call(r.mediaConfig,"muted")&&(r.mediaConfig.muted=!0),r.media=t.mediaEl instanceof HTMLMediaElement?t.mediaEl:"function"==typeof t.mediaEl?t.mediaEl(r.mediaConfig):i.default.createDom(r.mediaConfig.mediaType,"",r.mediaConfig,""),t.defaultPlaybackRate&&(r.media.defaultPlaybackRate=r.media.playbackRate=t.defaultPlaybackRate),"Number"===i.default.typeOf(t.volume)&&(r.volume=t.volume),t.autoplayMuted&&(r.media.muted=!0,r._lastMuted=!0),t.autoplay&&(r.media.autoplay=!0),t.playsinline&&(r.media.playsinline=!0),r._interval={},r.mediaEventMiddleware={},r.attachVideoEvents(),r}return e.createClass(s,[{key:"setEventsMiddleware",value:function(e){var t=this;Object.keys(e).map(function(i){t.mediaEventMiddleware[i]=e[i]})}},{key:"removeEventsMiddleware",value:function(e){var t=this;Object.keys(e).map(function(e){delete t.mediaEventMiddleware[e]})}},{key:"attachVideoEvents",value:function(){var t=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.media;this._evHandlers||(this._evHandlers=n.VIDEO_EVENTS.map(function(a){var r="on".concat(a.charAt(0).toUpperCase()).concat(a.slice(1));return"function"==typeof t[r]&&t.on(a,t[r]),e.defineProperty({},a,function(e,t){return function(a,r){var n={player:t,eventName:e,originalEvent:a,detail:a.detail||{},timeStamp:a.timeStamp,currentTime:t.currentTime,duration:t.duration,paused:t.paused,ended:t.ended,isInternalOp:!!t._internalOp[a.type],muted:t.muted,volume:t.volume,host:i.default.getHostFromUrl(t.currentSrc),vtype:t.vtype};if(t.removeInnerOP(a.type),"timeupdate"===e&&(t._currentTime=t.media&&t.media.currentTime),"ratechange"===e){var o=t.media?t.media.playbackRate:0;if(o&&t._rate===o)return;t._rate=t.media&&t.media.playbackRate}if("durationchange"===e&&(t._duration=t.media.duration),"volumechange"===e&&(n.isMutedChange=t._lastMuted!==t.muted,t._lastMuted=t.muted),"error"===e&&(n.error=r||t.video.error),t.mediaEventMiddleware[e]){var s=d.bind(t,e,n);try{t.mediaEventMiddleware[e].call(t,n,s)}catch(u){throw d.call(t,e,n),u}}else d.call(t,e,n)}}(a,t))})),this._evHandlers.forEach(function(e){var t=Object.keys(e)[0];a.addEventListener(t,e[t],!1)})}},{key:"detachVideoEvents",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.media;this._evHandlers.forEach(function(e){var i=Object.keys(e)[0];t.removeEventListener(i,e[i],!1)}),this._evHandlers.forEach(function(t){var i=Object.keys(t)[0],a="on".concat(i.charAt(0).toUpperCase()).concat(i.slice(1));"function"==typeof e[a]&&e.off(i,e[a])}),this._evHandlers=null}},{key:"_attachSourceEvents",value:function(e,t){var a=this;e.removeAttribute("src"),e.load(),t.forEach(function(e,t){a.media.appendChild(i.default.createDom("source","",{src:"".concat(e.src),type:"".concat(e.type||""),"data-index":t+1}))});var d=e.children;if(d){this._videoSourceCount=d.length,this._videoSourceIndex=d.length,this._vLoadeddata=function(e){a.emit(n.SOURCE_SUCCESS,{src:e.target.currentSrc,host:i.default.getHostFromUrl(e.target.currentSrc)})};for(var o=null,s=0;s<this._evHandlers.length;s++)if("error"===Object.keys(this._evHandlers[s])[0]){o=this._evHandlers[s];break}!this._sourceError&&(this._sourceError=function(e){var t=parseInt(e.target.getAttribute("data-index"),10);if(a._videoSourceIndex--,0===a._videoSourceIndex||t>=a._videoSourceCount){var i={code:4,message:"sources_load_error"};o?o.error(e,i):a.errorHandler("error",i)}var d=r.ERROR_TYPE_MAP[4];a.emit(n.SOURCE_ERROR,new r.default(a,{errorType:d,errorCode:4,errorMessage:"sources_load_error",mediaError:{code:4,message:"sources_load_error"},src:e.target.src}))});for(var u=0;u<d.length;u++)d[u].addEventListener("error",this._sourceError);e.addEventListener("loadeddata",this._vLoadeddata)}}},{key:"_detachSourceEvents",value:function(e){var t=e.children;if(t&&0!==t.length&&this._sourceError){for(var i=0;i<t.length;i++)t[i].removeEventListener("error",this._sourceError);for(;t.length>0;)e.removeChild(t[0]);this._vLoadeddata&&e.removeEventListener("loadeddata",this._vLoadeddata)}}},{key:"errorHandler",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.media&&(this.media.error||t)){var i=this.media.error||t,a=i.code?r.ERROR_TYPE_MAP[i.code]:"other";i.message;this.media.currentSrc||this.media.srcObject||(i={code:6,message:"empty_src"}),this.emit(e,new r.default(this,{errorType:a,errorCode:i.code,errorMessage:i.message||"",mediaError:i}))}}},{key:"destroy",value:function(){for(var e in this.media&&(this.media.pause&&(this.media.pause(),this.media.muted=!0),this.media.removeAttribute("src"),this.media.load()),this._currentTime=0,this._duration=0,this.mediaConfig=null,this._interval)Object.prototype.hasOwnProperty.call(this._interval,e)&&(clearInterval(this._interval[e]),this._interval[e]=null);this.detachVideoEvents(),this.media=null,this.mediaEventMiddleware={},this.removeAllListeners()}},{key:"video",get:function(){return this.media},set:function(e){this.media=e}},{key:"play",value:function(){return this.media?this.media.play():null}},{key:"pause",value:function(){this.media&&this.media.pause()}},{key:"load",value:function(){this.media&&this.media.load()}},{key:"canPlayType",value:function(e){return!!this.media&&this.media.canPlayType(e)}},{key:"getBufferedRange",value:function(e){var t=[0,0];if(!this.media)return t;e||(e=this.media.buffered);var i=this.media.currentTime;if(e)for(var a=0,r=e.length;a<r&&(t[0]=e.start(a),t[1]=e.end(a),!(t[0]<=i&&i<=t[1]));a++);return t[0]-i<=0&&i-t[1]<=0?t:[0,0]}},{key:"autoplay",get:function(){return!!this.media&&this.media.autoplay},set:function(e){this.media&&(this.media.autoplay=e)}},{key:"buffered",get:function(){return this.media?this.media.buffered:null}},{key:"buffered2",get:function(){return this.media&&this.media.buffered?i.default.getBuffered2(this.media.buffered):null}},{key:"bufferedPoint",get:function(){var e={start:0,end:0};if(!this.media)return e;var t=this.media.buffered;if(!t||0===t.length)return e;for(var i=0;i<t.length;i++)if((t.start(i)<=this.currentTime||t.start(i)<.1)&&t.end(i)>=this.currentTime)return{start:t.start(i),end:t.end(i)};return e}},{key:"crossOrigin",get:function(){return this.media?this.media.crossOrigin:""},set:function(e){this.media&&(this.media.crossOrigin=e)}},{key:"currentSrc",get:function(){return this.media?this.media.currentSrc:""},set:function(e){this.media&&(this.media.currentSrc=e)}},{key:"currentTime",get:function(){return this.media?void 0!==this.media.currentTime?this.media.currentTime:this._currentTime:0},set:function(e){this.media&&(this.media.currentTime=e)}},{key:"defaultMuted",get:function(){return!!this.media&&this.media.defaultMuted},set:function(e){this.media&&(this.media.defaultMuted=e)}},{key:"duration",get:function(){return this._duration}},{key:"ended",get:function(){return!!this.media&&this.media.ended}},{key:"error",get:function(){return this.media.error}},{key:"errorNote",get:function(){if(!this.media.error)return"";return["MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"][this.media.error.code-1]}},{key:"loop",get:function(){return!!this.media&&this.media.loop},set:function(e){this.media&&(this.media.loop=e)}},{key:"muted",get:function(){return!!this.media&&this.media.muted},set:function(e){this.media&&this.media.muted!==e&&(this._lastMuted=this.media.muted,this.media.muted=e)}},{key:"networkState",get:function(){return this.media.networkState}},{key:"paused",get:function(){return!this.media||this.media.paused}},{key:"playbackRate",get:function(){return this.media?this.media.playbackRate:0},set:function(e){this.media&&e!==1/0&&(this.media.defaultPlaybackRate=e,this.media.playbackRate=e)}},{key:"played",get:function(){return this.media?this.media.played:null}},{key:"preload",get:function(){return!!this.media&&this.media.preload},set:function(e){this.media&&(this.media.preload=e)}},{key:"readyState",get:function(){return this.media.readyState}},{key:"seekable",get:function(){return!!this.media&&this.media.seekable}},{key:"seeking",get:function(){return!!this.media&&this.media.seeking}},{key:"src",get:function(){return this.media?this.media.src:""},set:function(e){this.media&&(this.emit(n.URL_CHANGE,e),this.emit(n.WAITING),this._currentTime=0,this._duration=0,i.default.isMSE(this.media)?this.onWaiting():(this._detachSourceEvents(this.media),"Array"===i.default.typeOf(e)?this._attachSourceEvents(this.media,e):e?this.media.src=e:this.media.removeAttribute("src"),this.load()))}},{key:"volume",get:function(){return this.media?this.media.volume:0},set:function(e){e!==1/0&&this.media&&(this.media.volume=e)}},{key:"aspectRatio",get:function(){return this.media?this.media.videoWidth/this.media.videoHeight:0}},{key:"addInnerOP",value:function(e){this._internalOp[e]=!0}},{key:"removeInnerOP",value:function(e){delete this._internalOp[e]}},{key:"emit",value:function(t,i){for(var a,r=arguments.length,n=new Array(r>2?r-2:0),d=2;d<r;d++)n[d-2]=arguments[d];(a=e.get(e.getPrototypeOf(s.prototype),"emit",this)).call.apply(a,[this,t,i].concat(n))}},{key:"on",value:function(t,i){for(var a,r=arguments.length,n=new Array(r>2?r-2:0),d=2;d<r;d++)n[d-2]=arguments[d];(a=e.get(e.getPrototypeOf(s.prototype),"on",this)).call.apply(a,[this,t,i].concat(n))}},{key:"once",value:function(t,i){for(var a,r=arguments.length,n=new Array(r>2?r-2:0),d=2;d<r;d++)n[d-2]=arguments[d];(a=e.get(e.getPrototypeOf(s.prototype),"once",this)).call.apply(a,[this,t,i].concat(n))}},{key:"off",value:function(t,i){for(var a,r=arguments.length,n=new Array(r>2?r-2:0),d=2;d<r;d++)n[d-2]=arguments[d];(a=e.get(e.getPrototypeOf(s.prototype),"off",this)).call.apply(a,[this,t,i].concat(n))}},{key:"offAll",value:function(){e.get(e.getPrototypeOf(s.prototype),"removeAllListeners",this).call(this)}}]),s}(t.default);exports.default=o;