function _classCallCheck(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function");}function _possibleConstructorReturn(n,t){if(!n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&(typeof t=="object"||typeof t=="function")?t:n}function _inherits(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof t);n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}});t&&(Object.setPrototypeOf?Object.setPrototypeOf(n,t):n.__proto__=t)}var _createClass=function(){function n(n,t){for(var i,r=0;r<t.length;r++)i=t[r],i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}return function(t,i,r){return i&&n(t.prototype,i),r&&n(t,r),t}}(),IframeVideoFrame=function(n){function t(n){_classCallCheck(this,t);var i=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,n));return i.interval=null,i.state={iframeId:""},i}return _inherits(t,n),_createClass(t,[{key:"componentDidMount",value:function(){this.setState({iframeId:"live-play-"+this.props.platformType.toLowerCase()})}},{key:"render",value:function(){var t=this.props.autoPlay?1:0,n=this.props.code,i=this.props.platformType.indexOf("LITV")>-1?{paddingBottom:"60%"}:{},r=this.props.platformType.indexOf("LITV")>-1?this.props.videoAd?"https://player.svc.litv.tv/index.html?s=ZWJj&i="+n:"https://player.svc.litv.tv/index.html?s=ZWJjMg==|ZWJj&i="+n:this.props.platformType==="FB"?"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fnews.ebc%2Fvideos%2F"+n+"%2F&show_text=0":"https://www.youtube.com/embed/"+n+"?autoplay="+t+"&enablejsapi=1&rel=0";return React.createElement("div",{className:"Flexible-container",style:i},React.createElement("iframe",{id:this.state.iframeId,src:r,scrolling:"no",frameBorder:"0",allowFullScreen:"true"}))}}]),t}(React.Component),EmbedVideoFrame,VideoPlayer,AdsenseComponent,SlickComponent;IframeVideoFrame.defaultProps={autoPlay:!1,videoAd:!0};IframeVideoFrame.propTypes={platformType:PropTypes.string.isRequired,code:PropTypes.string.isRequired,autoPlay:PropTypes.bool,videoAd:PropTypes.bool};EmbedVideoFrame=function(n){function t(n){return _classCallCheck(this,t),_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,n))}return _inherits(t,n),_createClass(t,[{key:"render",value:function(){var n=this.props.disabledDownload?"nodownload":"",t=this.props.disabledDownload?function(n){n.preventDefault()}:function(){};return React.createElement("video",{controls:"controls",autoPlay:this.props.autoPlay,style:{width:"100%"},type:this.props.mediaType,src:this.props.src,controlsList:n,muted:this.props.muted,onContextMenu:t,poster:this.props.poster})}}]),t}(React.Component);EmbedVideoFrame.defaultProps={mediaType:"video/mp4",autoPlay:!1,muted:!1,disabledDownload:!0,poster:""};EmbedVideoFrame.propTypes={src:PropTypes.string.isRequired,mediaType:PropTypes.string,autoPlay:PropTypes.bool,muted:PropTypes.bool,disabledDownload:PropTypes.bool,poster:PropTypes.string};VideoPlayer=function(n){function t(n){_classCallCheck(this,t);var i=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,n));return i._videoChoiceCallback=function(n,t,r,u,f,e,o){i.setState({currentVideoType:n,currentVideoCode:t,currentVideoTitle:r,currentShopLink:u,currentShopTitle:f==""?r:f,currentCloseAd:e,currentVideoAd:o})},i.state={isMobile:!1,currentVideoType:"",currentVideoCode:"",currentVideoTitle:"",currentShopLink:"",currentShopTitle:"",currentCloseAd:!0,currentVideoAd:!0},i}return _inherits(t,n),_createClass(t,[{key:"componentDidMount",value:function(){this.setState({isMobile:isMobileDevice()});this.props.models&&this.props.models.length>0&&this._videoChoiceCallback(this.props.models[0].platform,this.props.models[0].code,this.props.models[0].title,this.props.models[0].shop_link,this.props.models[0].shop_title,this.props.models[0].close_ad,this.props.models[0].video_ad)}},{key:"render",value:function(){var n=this.props.models&&this.props.models.length>0&&React.createElement("div",{id:"live-24hrs",className:"white-box"},React.createElement("div",{className:"box-title left"},"Live ",this.state.currentVideoTitle),React.createElement("span",{className:"clear"}),React.createElement("div",{className:"left",style:{width:"100%"}},this._createVideoFrame(),this.state.currentShopLink&&this.state.currentShopLink!=""&&React.createElement("div",{className:"live-link-div"},React.createElement("a",{href:this.state.currentShopLink,className:"livelinkover8-btn",target:"_blank",title:this.state.currentShopTitle},this.state.currentShopTitle))),React.createElement("div",{className:"clear"}));return React.createElement("div",null,n,React.createElement(SlickComponent,{models:this.props.models,videoChoiceCallback:this._videoChoiceCallback}))}},{key:"_createVideoFrame",value:function(){if(this.state.currentVideoType&&this.state.currentVideoCode){var n=this.state.currentVideoType.toUpperCase();return n==="YT"||n==="FB"||n.indexOf("LITV")>-1?React.createElement(IframeVideoFrame,{platformType:n,code:this.state.currentVideoCode,autoPlay:!1,videoAd:this.state.currentVideoAd}):React.createElement(EmbedVideoFrame,{src:this.state.currentVideoCode,autoPlay:!0,muted:!0,disabledDownload:!0})}}}]),t}(React.Component);VideoPlayer.propTypes={models:PropTypes.arrayOf(PropTypes.shape({platform:PropTypes.string.isRequired,code:PropTypes.string.isRequired,image:PropTypes.string.isRequired,title:PropTypes.string.isRequired,is_read:PropTypes.bool.isRequired,shop_link:PropTypes.string,shop_title:PropTypes.string,close_ad:PropTypes.bool.isRequired,video_ad:PropTypes.bool.isRequired}))};AdsenseComponent=function(n){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,Object.getPrototypeOf(t).apply(this,arguments))}return _inherits(t,n),_createClass(t,[{key:"componentDidMount",value:function(){var n=function(){var n=document.createElement("script");n.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";n.async=!0;document.body.insertBefore(n,document.body.firstChild)};n();(adsbygoogle=window.adsbygoogle||[]).push({})}},{key:"render",value:function(){return React.createElement("ins",{className:"adsbygoogle",style:{display:"block"},"data-ad-format":"fluid","data-ad-client":"ca-pub-4384384302576967","data-ad-slot":"9662193834"})}}]),t}(React.Component);SlickComponent=function(n){function t(n){_classCallCheck(this,t);var i=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,n));return i.state={currentVideoType:i.props.models[0].platform,currentVideoCode:i.props.models[0].code,currentVideoTitle:i.props.models[0].title,currentShopLink:i.props.models[0].shop_link,currentShopTitle:i.props.models[0].shop_title,currentCloseAd:i.props.models[0].close_ad,currentVideoAd:i.props.models[0].video_ad},i._videoChoice=i._videoChoice.bind(i),i._videoBoxBaseStyle={padding:10},i._videoBoxCurrentPlayStyle={backgroundColor:"rgb(238, 215, 75)"},i}return _inherits(t,n),_createClass(t,[{key:"componentDidMount",value:function(){this.props.models.length>1&&($(this.refs.slickHere).slick({infinite:!1,slidesToShow:3,slidesToScroll:3,prevArrow:$(this.refs.leftBtn),nextArrow:$(this.refs.rightBtn),responsive:[{breakpoint:600,settings:{slidesToShow:2,slidesToScroll:2}}]}),$(this.refs.slickWrapper).show())}},{key:"componentWillUnmount",value:function(){$(this.refs.slickWrapper).slick("unslick")}},{key:"render",value:function(){var n=React.createElement("div",{id:"live-else",className:"gray-box"},React.createElement("div",{ref:"leftBtn",id:"arrow-left-y"},React.createElement("img",{src:"/Images/arrow-left-w.gif",alt:"上一張"})),React.createElement("div",{ref:"rightBtn",id:"arrow-right-y"},React.createElement("img",{src:"/Images/arrow-right-w.gif",alt:"下一張"})),React.createElement("div",{ref:"slickHere"},this._bindImageModel()),React.createElement("span",{className:"clear"}));return React.createElement("section",{ref:"slickWrapper",style:{display:"none"}},n)}},{key:"_bindImageModel",value:function(){var n=this;return this.props.models.map(function(t,i){var r=t.code===n.state.currentVideoCode?Object.assign({},n._videoBoxBaseStyle,n._videoBoxCurrentPlayStyle):n._videoBoxBaseStyle;return React.createElement("div",{key:i,className:"live-else-little-box",style:r,onClick:function(){n._videoChoice(t.platform,t.code,t.title,t.shop_link,t.shop_title,t.close_ad,t.video_ad)}},React.createElement("a",{style:{display:"block"},title:t.title},React.createElement("div",{className:"pic"},React.createElement("div",{className:"target-img"},React.createElement("img",{src:t.image,style:{verticalAlign:"middle"},alt:t.title})),t.code!=n.state.currentVideoCode&&React.createElement("div",{className:"onair"},React.createElement("img",{src:"/Images/onair.gif"}))),React.createElement("div",{className:"title"},t.title)))})}},{key:"_videoChoice",value:function(n,t,i,r,u,f,e){this.setState({currentVideoType:n,currentVideoCode:t,currentVideoTitle:i,currentShopLink:r,currentShopTitle:u,currentCloseAd:f,currentVideoAd:e});this.props.videoChoiceCallback(n,t,i,r,u,f,e)}}]),t}(React.Component);SlickComponent.propTypes={models:PropTypes.arrayOf(PropTypes.shape({platform:PropTypes.string.isRequired,code:PropTypes.string.isRequired,image:PropTypes.string.isRequired,title:PropTypes.string.isRequired,is_read:PropTypes.bool.isRequired,shop_link:PropTypes.string,shop_title:PropTypes.string,close_ad:PropTypes.bool.isRequired,video_ad:PropTypes.bool.isRequired})),videoChoiceCallback:PropTypes.func.isRequired}