/*!
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
*/
import{inherits as e,createSuper as t,classCallCheck as i,defineProperty as s,assertThisInitialized as o,createClass as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import a from"../../utils/util.js";import r from"../../utils/sniffer.js";import{DURATION_CHANGE as c,CANPLAY as u,ENDED as l}from"../../events.js";import{runHooks as h}from"../../plugin/hooksDescriptor.js";import p from"../../plugin/plugin.js";import{STATES as d}from"../../state.js";import g from"./touch.js";import v from"../assets/seekicon.js";var f="auto",m="seeking",k="playbackrate",y=["videoClick","videoDbClick"],b=/* @__PURE__ */function(){e(T,p);var b=t(T);function T(e){var t;return i(this,T),t=b.call(this,e),s(o(t),"onTouchStart",function(e){var i=o(t),s=i.player,n=i.config,r=i.pos,c=i.playerConfig,u=t.getTouche(e);if(u&&!n.disableGesture&&t.duration>0&&!s.ended){r.isStart=!0,t.timer&&clearTimeout(t.timer),a.checkIsFunction(c.disableSwipeHandler)&&c.disableSwipeHandler(),t.find(".xg-dur").innerHTML=a.format(t.duration);var l=t.root.getBoundingClientRect();90===s.rotateDeg?(r.top=l.left,r.left=l.top,r.width=l.height,r.height=l.width):(r.top=l.top,r.left=l.left,r.width=l.width,r.height=l.height);var h=parseInt(u.pageX-r.left,10),p=parseInt(u.pageY-r.top,10);r.x=90===s.rotateDeg?p:h,r.y=90===s.rotateDeg?h:p,r.scopeL=n.scopeL*r.width,r.scopeR=(1-n.scopeR)*r.width,r.scopeM1=r.width*(1-n.scopeM)/2,r.scopeM2=r.width-r.scopeM1}}),s(o(t),"onTouchMove",function(e){var i=t.getTouche(e),s=o(t),n=s.pos,a=s.config,r=s.player;if(i&&!a.disableGesture&&t.duration&&n.isStart){var c=a.miniMoveStep,u=a.hideControlsActive,l=parseInt(i.pageX-n.left,10),h=parseInt(i.pageY-n.top,10),p=90===r.rotateDeg?h:l,d=90===r.rotateDeg?l:h;if(Math.abs(p-n.x)>c||Math.abs(d-n.y)>c){var g=p-n.x,v=d-n.y,f=n.scope;if(-1===f&&(0===(f=t.checkScope(p,d,g,v,n))&&(u?r.blur():r.focus({autoHide:!1}),!n.time&&(n.time=parseInt(1e3*r.currentTime,10)+1e3*t.timeOffset)),n.scope=f),-1===f||f>0&&!a.gestureY||0===f&&!a.gestureX)return;t.executeMove(g,v,f,n.width,n.height),n.x=p,n.y=d}}}),s(o(t),"onTouchEnd",function(e){var i=o(t),s=i.player,n=i.pos,r=i.playerConfig;if(setTimeout(function(){s.getPlugin("progress")&&s.getPlugin("progress").resetSeekState()},10),n.isStart){n.scope>-1&&e.cancelable&&e.preventDefault();var c=t.config,u=c.disableGesture,l=c.gestureX;!u&&l?t.endLastMove(n.scope):n.time=0,n.scope=-1,t.resetPos(),a.checkIsFunction(r.enableSwipeHandler)&&r.enableSwipeHandler(),t.changeAction(f)}}),s(o(t),"onRootTouchMove",function(e){!t.config.disableGesture&&t.config.gestureX&&t.checkIsRootTarget(e)&&(e.stopPropagation(),t.pos.isStart?t.onTouchMove(e):t.onTouchStart(e))}),s(o(t),"onRootTouchEnd",function(e){t.pos.scope>-1&&t.onTouchEnd(e)}),t.pos={isStart:!1,x:0,y:0,time:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1},t.timer=null,t}return n(T,[{key:"duration",get:function(){return this.playerConfig.customDuration||this.player.duration}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"registerIcons",value:function(){return{seekTipIcon:{icon:v,class:"xg-seek-pre"}}}},{key:"afterCreate",value:function(){var e=this;y.map(function(t){e.__hooks[t]=null});var t=this.playerConfig,i=this.config,s=this.player;!0===t.closeVideoDblclick&&(i.closedbClick=!0),this.resetPos(),a.isUndefined(t.disableGesture)||(i.disableGesture=!!t.disableGesture),this.appendChild(".xg-seek-icon",this.icons.seekTipIcon),this.xgMask=a.createDom("xg-mask","",{},"xgmask"),s.root.appendChild(this.xgMask),this.initCustomStyle(),this.registerThumbnail();var o="mouse"===this.domEventType?"mouse":"touch";this.touch=new g(this.root,{eventType:o,needPreventDefault:!this.config.disableGesture}),this.root.addEventListener("contextmenu",function(e){e.preventDefault()}),s.root.addEventListener("touchmove",this.onRootTouchMove,!0),s.root.addEventListener("touchend",this.onRootTouchEnd,!0),s.root.addEventListener("touchcancel",this.onRootTouchEnd,!0);var n=this.player.controls;n&&n.center&&(n.center.addEventListener("touchmove",this.onRootTouchMove,!0),n.center.addEventListener("touchend",this.onRootTouchEnd,!0),n.center.addEventListener("touchcancel",this.onRootTouchEnd,!0)),this.on(c,function(){var t=e.player,i=e.config;t.duration>0&&1e3*t.duration<i.moveDuration&&(i.moveDuration=1e3*t.duration)}),this.on([u,l],function(){var t=e.pos,i=t.time;!t.isStart&&i>0&&(e.pos.time=0)});var r={touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",press:"onPress",pressend:"onPressEnd",click:"onClick",doubleclick:"onDbClick"};if(Object.keys(r).map(function(t){e.touch.on(t,function(i){e[r[t]](i)})}),!i.disableActive){var h=s.plugins.progress;h&&(h.addCallBack("dragmove",function(t){e.activeSeekNote(t.currentTime,t.forward)}),["dragend","click"].forEach(function(t){h.addCallBack(t,function(){e.changeAction(f)})}))}}},{key:"registerThumbnail",value:function(){var e=this.player.plugins.thumbnail;if(e&&e.usable){this.thumbnail=e.createThumbnail(null,"mobile-thumbnail");var t=this.find(".time-preview");t.insertBefore(this.thumbnail,t.children[0])}}},{key:"initCustomStyle",value:function(){var e=(this.playerConfig||{}).commonStyle,t=e.playedColor,i=e.progressColor,s=e.timePreviewStyle,o=e.curTimeColor,n=e.durationColor;if(t&&(this.find(".xg-curbar").style.backgroundColor=t),i&&(this.find(".xg-bar").style.backgroundColor=i),s){var r=this.find(".time-preview");Object.keys(s).forEach(function(e){r.style[e]=s[e]})}var c=o||t,u=n;c&&(this.find(".xg-cur").style.color=c),u&&(this.find(".xg-dur").style.color=u),this.config.disableTimeProgress&&a.addClass(this.find(".xg-timebar"),"hide")}},{key:"resetPos",value:function(){var e=this;this.pos?(this.pos.isStart=!1,this.pos.scope=-1,["x","y","width","height","scopeL","scopeR","scopeM1","scopeM2"].map(function(t){e.pos[t]=0})):this.pos={isStart:!1,x:0,y:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1,time:0}}},{key:"changeAction",value:function(e){var t=this.player;this.root.setAttribute("data-xg-action",e);var i=t.plugins.start;i&&i.recover()}},{key:"getTouche",value:function(e){this.player.rotateDeg;var t=e.touches&&e.touches.length>0?e.touches[e.touches.length-1]:e;return{pageX:t.pageX,pageY:t.pageY}}},{key:"checkScope",value:function(e,t,i,s,o){var n=o.width,a=-1;if(e<0||e>n)return a;var r=0===s?Math.abs(i):Math.abs(i/s);return Math.abs(i)>0&&r>=1.73&&e>o.scopeM1&&e<o.scopeM2?a=0:(0===Math.abs(i)||r<=.57)&&(a=e<o.scopeL?1:e>o.scopeR?2:3),a}},{key:"executeMove",value:function(e,t,i,s,o){switch(i){case 0:this.updateTime(e/s*this.config.scopeM);break;case 1:this.updateBrightness(t/o);break;case 2:r.os.isIos||this.updateVolume(t/o)}}},{key:"endLastMove",value:function(e){var t=this,i=this.pos,s=this.player,o=this.config,n=(i.time-this.timeOffset)/1e3;if(0===e)s.seek(Number(n).toFixed(1)),o.hideControlsEnd?s.blur():s.focus(),this.timer=setTimeout(function(){t.pos.time=0},500);this.changeAction(f)}},{key:"checkIsRootTarget",value:function(e){var t=this.player.plugins||{};return(!t.progress||!t.progress.root.contains(e.target))&&(t.start&&t.start.root.contains(e.target)||t.controls&&t.controls.root.contains(e.target))}},{key:"sendUseAction",value:function(e){var t=this.player.paused;this.emitUserAction(e,"switch_play_pause",{prop:"paused",from:t,to:!t})}},{key:"clickHandler",value:function(e){var t=this.player,i=this.config,s=this.playerConfig;t.state<d.RUNNING?s.closeVideoClick||(this.sendUseAction(a.createEvent("click")),t.play()):!i.closedbClick||s.closeVideoClick?t.isActive?t.blur():t.focus():s.closeVideoClick||((t.isActive||i.focusVideoClick)&&(this.sendUseAction(a.createEvent("click")),this.switchPlayPause()),t.focus())}},{key:"dbClickHandler",value:function(e){var t=this.config,i=this.player;!t.closedbClick&&i.state>=d.RUNNING&&(this.sendUseAction(a.createEvent("dblclick")),this.switchPlayPause())}},{key:"onClick",value:function(e){var t=this,i=this.player;h(this,y[0],function(e,i){t.clickHandler(i.e)},{e:e,paused:i.paused})}},{key:"onDbClick",value:function(e){var t=this,i=this.player;h(this,y[1],function(e,i){t.dbClickHandler(i.e)},{e:e,paused:i.paused})}},{key:"onPress",value:function(e){var t=this.pos,i=this.config,s=this.player;i.disablePress||(t.rate=this.player.playbackRate,this.emitUserAction("press","change_rate",{prop:"playbackRate",from:s.playbackRate,to:i.pressRate}),s.playbackRate=i.pressRate,this.changeAction(k))}},{key:"onPressEnd",value:function(e){var t=this.pos,i=this.config,s=this.player;i.disablePress||(this.emitUserAction("pressend","change_rate",{prop:"playbackRate",from:s.playbackRate,to:t.rate}),s.playbackRate=t.rate,t.rate=1,this.changeAction(f))}},{key:"updateTime",value:function(e){var t=this.player,i=this.config,s=this.player.duration;e=Number(e.toFixed(4));var o=parseInt(e*i.moveDuration,10)+this.timeOffset;o=(o+=this.pos.time)<0?0:o>1e3*s?1e3*s-200:o,t.getPlugin("time")&&t.getPlugin("time").updateTime(o/1e3),t.getPlugin("progress")&&t.getPlugin("progress").updatePercent(o/1e3/this.duration,!0),this.activeSeekNote(o/1e3,e>0),i.isTouchingSeek&&t.seek(Number((o-this.timeOffset)/1e3).toFixed(1)),this.pos.time=o}},{key:"updateVolume",value:function(e){this.player.rotateDeg&&(e=-e);var t=this.player,i=this.pos;if(e=parseInt(100*e,10),i.volume+=e,!(Math.abs(i.volume)<10)){var s=parseInt(10*t.volume,10)-parseInt(i.volume/10,10);s=s>10?10:s<1?0:s,t.volume=s/10,i.volume=0}}},{key:"updateBrightness",value:function(e){var t=this.pos,i=this.config,s=this.xgMask;if(i.darkness){this.player.rotateDeg&&(e=-e);var o=t.light+.8*e;o=o>i.maxDarkness?i.maxDarkness:o<0?0:o,s&&(s.style.backgroundColor="rgba(0,0,0,".concat(o,")")),t.light=o}}},{key:"activeSeekNote",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.player,s=this.config,o=!(this.duration!==1/0&&this.duration>0);if(e&&"number"==typeof e&&!o&&!s.disableActive){e<0?e=0:e>i.duration&&(e=i.duration-.2),this.changeAction(m);var n=i.plugins.start;n&&n.focusHide(),this.find(".xg-dur").innerHTML=a.format(this.duration),this.find(".xg-cur").innerHTML=a.format(e),this.find(".xg-curbar").style.width="".concat(e/this.duration*100,"%"),t?a.removeClass(this.find(".xg-seek-show"),"xg-back"):a.addClass(this.find(".xg-seek-show"),"xg-back"),this.updateThumbnails(e)}}},{key:"updateThumbnails",value:function(e){var t=this.player.plugins.thumbnail;t&&t.usable&&this.thumbnail&&t.update(this.thumbnail,e,160,90)}},{key:"switchPlayPause",value:function(){var e=this.player;if(e.state<d.ATTACHED)return!1;e.ended||(e.paused?e.play():e.pause())}},{key:"disableGesture",value:function(){this.config.disableGesture=!0}},{key:"enableGesture",value:function(){this.config.disableGesture=!1}},{key:"destroy",value:function(){var e=this.player;this.timer&&clearTimeout(this.timer),this.thumbnail=null,e.root.removeChild(this.xgMask),this.xgMask=null,this.touch&&this.touch.destroy(),this.touch=null,e.root.removeEventListener("touchmove",this.onRootTouchMove,!0),e.root.removeEventListener("touchend",this.onRootTouchEnd,!0),e.root.removeEventListener("touchcancel",this.onRootTouchEnd,!0);var t=this.player.controls;t&&t.center&&(t.center.removeEventListener("touchmove",this.onRootTouchMove,!0),t.center.removeEventListener("touchend",this.onRootTouchEnd,!0),t.center.removeEventListener("touchcancel",this.onRootTouchEnd,!0))}},{key:"render",value:function(){var e="normal"!==this.config.gradient?"gradient ".concat(this.config.gradient):"gradient";return'\n     <xg-trigger class="trigger">\n     <div class="'.concat(e,'"></div>\n        <div class="time-preview">\n            <div class="xg-seek-show ').concat(this.config.disableSeekIcon?" hide-seek-icon":"",'">\n              <i class="xg-seek-icon"></i>\n              <span class="xg-cur">00:00</span>\n              <span class="xg-separator">/</span>\n              <span class="xg-dur">00:00</span>\n            </div>\n              <div class="xg-bar xg-timebar">\n                <div class="xg-curbar"></div>\n              </div>\n        </div>\n        <div class="xg-playbackrate xg-top-note">\n            <span><i>').concat(this.config.pressRate,"X</i>").concat(this.i18n.FORWARD,"</span>\n        </div>\n     </xg-trigger>\n    ")}}],[{key:"pluginName",get:function(){return"mobile"}},{key:"defaultConfig",get:function(){return{index:0,disableGesture:!1,gestureX:!0,gestureY:!0,gradient:"normal",isTouchingSeek:!1,miniMoveStep:5,miniYPer:5,scopeL:.25,scopeR:.25,scopeM:.9,pressRate:2,darkness:!0,maxDarkness:.8,disableActive:!1,disableTimeProgress:!1,hideControlsActive:!1,hideControlsEnd:!1,moveDuration:36e4,closedbClick:!1,disablePress:!0,disableSeekIcon:!1,focusVideoClick:!1}}}]),T}();export{b as default};