/*!
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 n,defineProperty as i,assertThisInitialized as l,createClass as s,get as r,getPrototypeOf as c}from"../../_virtual/_rollupPluginBabelHelpers.js";import o from"../../utils/util.js";import a from"../../utils/sniffer.js";import{FULLSCREEN_CHANGE as u}from"../../events.js";import{POSITIONS as f}from"../../plugin/plugin.js";import{xgIconTips as h}from"../common/iconTools.js";import p from"../common/iconPlugin.js";import g from"./backicon.js";import y from"../assets/requestFull.js";import d from"../assets/exitFull.js";var m=/* @__PURE__ */function(){e(k,p);var m=t(k);function k(){var e;n(this,k);for(var t=arguments.length,s=new Array(t),r=0;r<t;r++)s[r]=arguments[r];return e=m.call.apply(m,[this].concat(s)),i(l(e),"_onOrientationChange",function(t){e.player.fullscreen&&e.config.rotateFullscreen&&(90===window.orientation||-90===window.orientation?e.player.setRotateDeg(0):e.player.setRotateDeg(90))}),e}return s(k,[{key:"afterCreate",value:function(){var e=this;r(c(k.prototype),"afterCreate",this).call(this);var t=this.config,n=this.playerConfig;if(!t.disable){t.target&&(this.playerConfig.fullscreenTarget=this.config.target);var i=o.getFullScreenEl();n.fullscreenTarget===i&&this.player.getFullscreen().catch(function(e){}),this.initIcons(),this.handleFullscreen=this.hook("fullscreenChange",this.toggleFullScreen,{pre:function(t){var n=e.player.fullscreen;e.emitUserAction(t,"switch_fullscreen",{prop:"fullscreen",from:n,to:!n})}}),this.bind(".xgplayer-fullscreen",["touchend","click"],this.handleFullscreen),this.on(u,function(t){var n=e.find(".xg-tips");n&&e.changeLangTextKey(n,t?e.i18nKeys.EXITFULLSCREEN_TIPS:e.i18nKeys.FULLSCREEN_TIPS),e.animate(t)}),this.config.needBackIcon&&(this.topBackIcon=this.player.registerPlugin({plugin:g,options:{config:{onClick:function(t){e.handleFullscreen(t)}}}})),"mobile"===a.device&&window.addEventListener("orientationchange",this._onOrientationChange)}}},{key:"registerIcons",value:function(){return{fullscreen:{icon:y,class:"xg-get-fullscreen"},exitFullscreen:{icon:d,class:"xg-exit-fullscreen"}}}},{key:"destroy",value:function(){r(c(k.prototype),"destroy",this).call(this),this.unbind(".xgplayer-icon","mobile"===a.device?"touchend":"click",this.handleFullscreen),"mobile"===a.device&&window.removeEventListener("orientationchange",this._onOrientationChange)}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(".xgplayer-icon",e.fullscreen),this.appendChild(".xgplayer-icon",e.exitFullscreen)}},{key:"toggleFullScreen",value:function(e){e instanceof Event&&(e.preventDefault(),e.stopPropagation());var t=this.player,n=this.config;!0===n.useCssFullscreen||"function"==typeof n.useCssFullscreen&&n.useCssFullscreen()?(t.fullscreen?t.exitCssFullscreen():t.getCssFullscreen(),this.animate(t.fullscreen)):n.rotateFullscreen?(t.fullscreen?t.exitRotateFullscreen():t.getRotateFullscreen(),this.animate(t.fullscreen)):n.switchCallback&&"function"==typeof n.switchCallback?n.switchCallback(t.fullscreen):t.fullscreen?(t.exitFullscreen(),n.useScreenOrientation&&this.unlockScreen()):(t.getFullscreen().catch(function(e){}),n.useScreenOrientation&&t.aspectRatio>1&&this.lockScreen(n.lockOrientationType))}},{key:"animate",value:function(e){e?this.setAttr("data-state","full"):this.setAttr("data-state","normal"),this.topBackIcon&&(e?(this.topBackIcon.show(),this.hide()):(this.topBackIcon.hide(),this.show()))}},{key:"render",value:function(){if(!this.config.disable){return'<xg-icon class="xgplayer-fullscreen">\n    <div class="xgplayer-icon">\n    </div>\n    '.concat(h(this,"FULLSCREEN_TIPS",this.playerConfig.isHideTips),"\n    </xg-icon>")}}},{key:"lockScreen",value:function(e){try{screen.orientation.lock(e).catch(function(e){})}catch(t){}}},{key:"unlockScreen",value:function(){try{screen.orientation.unlock().catch(function(e){})}catch(e){}}}],[{key:"pluginName",get:function(){return"fullscreen"}},{key:"defaultConfig",get:function(){return{position:f.CONTROLS_RIGHT,index:0,useCssFullscreen:!1,rotateFullscreen:!1,useScreenOrientation:!1,lockOrientationType:"landscape",switchCallback:null,target:null,disable:!1,needBackIcon:!1}}}]),k}();export{m as default};