/*!
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 t=require("../../_virtual/_rollupPluginBabelHelpers.js"),e=require("../../utils/util.js"),a=require("../../events.js"),i=require("../../plugin/plugin.js"),s=require("../../state.js"),n=require("../assets/play.js"),o=require("../assets/pause.js");var u={};function l(t){t?window.clearTimeout(t):Object.keys(u).map(function(t){window.clearTimeout(u[t].id),delete u[t]})}var r=function(i){t.inherits(d,i);var r=t.createSuper(d);function d(a){var i;return t.classCallCheck(this,d),i=r.call(this,a),t.defineProperty(t.assertThisInitialized(i),"onPlayerReset",function(){i.autoPlayStart=!1;var t="auto"===i.config.mode?"auto-hide":"hide";i.setAttr("data-state","play"),e.default.removeClass(i.root,t),i.show()}),t.defineProperty(t.assertThisInitialized(i),"onAutoplayStart",function(){if(!i.autoPlayStart){var t="auto"===i.config.mode?"auto-hide":"hide";e.default.addClass(i.root,t),i.autoPlayStart=!0,i.toggleTo("play")}}),i.autoPlayStart=!1,i}return t.createClass(d,[{key:"afterCreate",value:function(){var t=this.playerConfig;this.initIcons(),this.listenEvents(),this.bindClickEvents(),t.autoplay||this.show()}},{key:"listenEvents",value:function(){var t=this,i=this.player,s=this.playerConfig;this.once(a.READY,function(){s&&(s.lang&&"en"===s.lang?e.default.addClass(i.root,"lang-is-en"):"jp"===s.lang&&e.default.addClass(i.root,"lang-is-jp"))}),this.on(a.AUTOPLAY_STARTED,this.onAutoplayStart),this.on(a.AUTOPLAY_PREVENTED,function(){var a="auto"===t.config.mode?"auto-hide":"hide";t.setAttr("data-state","play"),e.default.removeClass(t.root,a),t.show()}),this.on(a.PLAY,function(){t.toggleTo("play")}),this.on(a.PAUSE,function(){t.toggleTo("pause")}),this.on(a.RESET,function(){t.onPlayerReset()})}},{key:"bindClickEvents",value:function(){var t=this;this.clickHandler=this.hook("startClick",this.switchPausePlay,{pre:function(e){e.cancelable&&e.preventDefault(),e.stopPropagation();var a=t.player.paused;t.emitUserAction(e,"switch_play_pause",{props:"paused",from:a,to:!a})}}),this.bind(["click","touchend"],this.clickHandler)}},{key:"registerIcons",value:function(){return{startPlay:{icon:n.default,class:"xg-icon-play"},startPause:{icon:o.default,class:"xg-icon-pause"}}}},{key:"initIcons",value:function(){var t=this.icons;this.appendChild("xg-start-inner",t.startPlay),this.appendChild("xg-start-inner",t.startPause)}},{key:"hide",value:function(){e.default.addClass(this.root,"hide")}},{key:"show",value:function(t){e.default.removeClass(this.root,"hide")}},{key:"focusHide",value:function(){e.default.addClass(this.root,"focus-hide")}},{key:"recover",value:function(){e.default.removeClass(this.root,"focus-hide")}},{key:"switchStatus",value:function(t){t?this.setAttr("data-state",this.player.paused?"pause":"play"):this.setAttr("data-state",this.player.paused?"play":"pause")}},{key:"animate",value:function(t){var a=this;this._animateId=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{start:null,end:null};return u[t]&&window.clearTimeout(u[t].id),u[t]={},a.start&&a.start(),u[t].id=window.setTimeout(function(){a.end&&a.end(),window.clearTimeout(u[t].id),delete u[t]},e),u[t].id}("pauseplay",400,{start:function(){e.default.addClass(a.root,"interact"),a.show(),a.switchStatus(!0)},end:function(){e.default.removeClass(a.root,"interact"),!t&&a.hide(),a._animateId=null}})}},{key:"endAnimate",value:function(){e.default.removeClass(this.root,"interact"),l(this._animateId),this._animateId=null}},{key:"switchPausePlay",value:function(t){var e=this.player;(t.cancelable&&t.preventDefault(),t.stopPropagation(),e.state<s.STATES.READY)||(this.player.paused||e.state!==s.STATES.RUNNING?e.play():e.pause())}},{key:"onPlayPause",value:function(t){this.toggleTo(t)}},{key:"toggleTo",value:function(t){var e=this.config,a=this.player;if(a&&!(a.state<s.STATES.RUNNING)&&this.autoPlayStart){if("show"===e.mode)return this.switchStatus(),void this.show();if("auto"!==e.mode){if(e.isShowPause&&a.paused&&!a.ended||e.isShowEnd&&a.ended)return this.switchStatus(),this.show(),void this.endAnimate();if(e.disableAnimate)return this.switchStatus(),void this.hide();if("play"===t)this.autoPlayStart?this.animate():this.hide();else{if(!this.autoPlayStart||a.ended)return;this.animate()}}else this.switchStatus()}}},{key:"destroy",value:function(){this.unbind(["click","touchend"],this.clickHandler),l(this._animateId)}},{key:"render",value:function(){var t=this.playerConfig.autoplay?"auto"===this.config.mode?"auto-hide":"hide":"";return'\n    <xg-start class="xgplayer-start '.concat(t,'">\n    <xg-start-inner></xg-start-inner>\n    </xg-start>')}}],[{key:"pluginName",get:function(){return"start"}},{key:"defaultConfig",get:function(){return{isShowPause:!1,isShowEnd:!1,disableAnimate:!1,mode:"hide"}}}]),d}(i.default);exports.default=r;