/*!
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 t,createSuper as e,classCallCheck as i,createClass as o,get as n,getPrototypeOf as r}from"../../_virtual/_rollupPluginBabelHelpers.js";import a from"../../utils/util.js";import{VIDEO_RESIZE as s,ROTATE as c}from"../../events.js";import{POSITIONS as l}from"../../plugin/plugin.js";import{xgIconTips as h}from"../common/iconTools.js";import g from"../common/iconPlugin.js";import f from"../assets/rotate.js";var u=/* @__PURE__ */function(){t(p,g);var u=e(p);function p(t){var e;return i(this,p),(e=u.call(this,t)).rotateDeg=e.config.rotateDeg||0,e}return o(p,[{key:"afterCreate",value:function(){var t=this;if(!this.config.disable){n(r(p.prototype),"afterCreate",this).call(this),this.appendChild(".xgplayer-icon",this.icons.rotate),this.onBtnClick=this.onBtnClick.bind(this),this.bind(".xgplayer-icon",["click","touchend"],this.onBtnClick),this.on(s,function(){t.rotateDeg&&t.config.innerRotate&&a.setTimeout(t,function(){t.updateRotateDeg(t.rotateDeg,t.config.innerRotate)},100)});var e=this.player.root;this.rootWidth=e.style.width||e.offsetWidth||e.clientWidth,this.rootHeight=e.style.height||e.offsetHeight||e.clientHeight,this.rotateDeg&&this.updateRotateDeg(this.rotateDeg,this.config.innerRotate)}}},{key:"destroy",value:function(){n(r(p.prototype),"destroy",this).call(this),this.unbind(".xgplayer-icon",["click","touchend"],this.onBtnClick)}},{key:"onBtnClick",value:function(t){t.preventDefault(),t.stopPropagation(),this.emitUserAction(t,"rotate"),this.rotate(this.config.clockwise,this.config.innerRotate,1)}},{key:"updateRotateDeg",value:function(t,e){if(t||(t=0),e)this.player.videoRotateDeg=t;else{var i=this.player,o=this.rootWidth,n=this.rootHeight,r=i.root,a=i.innerContainer,s=i.media,c=r.offsetWidth,l=a&&e?a.offsetHeight:r.offsetHeight,h=o,g=n,f=0,u=0;.75!==t&&.25!==t||(h="".concat(l,"px"),g="".concat(c,"px"),f=-(l-c)/2,u=-(c-l)/2);var p="translate(".concat(f,"px,").concat(u,"px) rotate(").concat(t,"turn)"),d={transformOrigin:"center center",transform:p,webKitTransform:p,height:g,width:h},y=e?s:r,m=e?i.getPlugin("poster"):null;Object.keys(d).map(function(t){y.style[t]=d[t],m&&m.root&&(m.root.style[t]=d[t])})}}},{key:"rotate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=this.player;this.rotateDeg||(this.rotateDeg=0);var n=t?1:-1;this.rotateDeg=(this.rotateDeg+1+.25*n*i)%1,this.updateRotateDeg(this.rotateDeg,e),o.emit(c,360*this.rotateDeg)}},{key:"registerIcons",value:function(){return{rotate:f}}},{key:"render",value:function(){if(!this.config.disable)return'\n    <xg-icon class="xgplayer-rotate">\n      <div class="xgplayer-icon">\n      </div>\n      '.concat(h(this,"ROTATE_TIPS",this.playerConfig.isHideTips),"\n    </xg-icon>")}}],[{key:"pluginName",get:function(){return"rotate"}},{key:"defaultConfig",get:function(){return{position:l.CONTROLS_RIGHT,index:6,innerRotate:!0,clockwise:!1,rotateDeg:0,disable:!1}}}]),p}();export{u as default};