"use strict";define("siteBackground",["lodash","santaProps","core","utils","mediaCommon","backgroundCommon"],function(e,i,t,o,r,a){function s(e){return e.isExperimentOpen("sv_mobileBgFixed")?e.isMobileView?"viewport"!==e.compData.mediaSizing:!e.fixedSiteBackground:e.isMobileView||!e.fixedSiteBackground}function n(i,t){var o=e.get(i,"scrollType"),r=e.get(i,["mediaRef","type"]);return(!("Image"===r||"WixVideo"===r)||s(t)||t.isAndroidOldBrowser)&&(o="scroll"),o}function p(i,t){var o="absolute";return"WixVideo"!==e.get(i,["mediaRef","type"])&&"fixed"!==t&&"parallax"!==t||(o="fixed"),o}function d(e,i,t){var r=p(i,n(i,e)),a={top:0,height:f,width:y,backgroundColor:o.colorParser.getColor(e.colorsMap,i.color),display:t?"none":"",position:r};return e.isMobileView&&"fixed"===r&&(a.willChange="transform"),a}function c(e){var i=f;return"parallax"===e&&(i=P),i}function l(e){var i=k;return"parallax"===e&&(i=b),i}function u(e,i){var t=i.mediaRef,o=n(i,e),r={position:"absolute",top:l(o),height:c(o),width:y,opacity:t&&t.opacity};return e.isMobileView&&"fixed"===o&&(r.willChange="transform"),r}function g(i,t){var o=i.background,r=t.background,a=o.mediaRef||{},s=r.mediaRef||{},n=!o.mediaRef&&!r.mediaRef,p=n||a.type===s.type,d=i.mediaSizing===t.mediaSizing,c=["mediaRef","imageOverlay"],l=["type","alignType","fittingType","scrollType","colorOverlay","colorOverlayOpacity","color","videoId","uri","opacity"];return"WixVideo"===a.type&&p?l=e.without(l,"color"):n&&(l=["color"]),p&&d&&h(o,r,c,l)}function h(i,t,o,r){var a=e.every(r,function(e){return(i&&i[e])===(t&&t[e])});return a=a&&e.every(o,function(e){return!i||h(i[e],t[e],o,r)})}function m(e,i){var t=i.colorOverlay?o.colorParser.getColor(e.colorsMap,i.colorOverlay,i.colorOverlayOpacity):null,r=v(e,i.imageOverlay);return{position:"absolute",top:0,width:y,height:f,backgroundImage:r,backgroundColor:t}}function v(e,i){return i?"url("+o.urlUtils.joinURL(e.staticMediaUrl,i.uri)+")":null}var y="100%",f="100%",k=0,P="120%",b=0,B=o.mediaConsts;return{displayName:"SiteBackground",mixins:[r.mediaLogicMixins.fill,t.compMixins.skinBasedComp,t.compMixins.animationsMixin,a.mixins.backgroundDetectionMixin],propTypes:e.defaults({id:i.Types.Component.id,compData:i.Types.Media.SiteBackground.data,actionsAspect:i.Types.SiteAspects.actionsAspect.isRequired,currentUrlPageId:i.Types.Component.currentUrlPageId,isMobileView:i.Types.isMobileView.isRequired,isTouchDevice:i.Types.Device.isTouchDevice,isAndroidOldBrowser:i.Types.Browser.isAndroidOldBrowser,colorsMap:i.Types.Theme.colorsMap,staticMediaUrl:i.Types.ServiceTopology.staticMediaUrl,componentViewMode:i.Types.RenderFlags.componentViewMode.isRequired,fixedSiteBackground:i.Types.BrowserFlags.fixedSiteBackground.isRequired,mediaQuality:i.Types.Media.SiteBackground.mediaQuality,isExperimentOpen:i.Types.isExperimentOpen},i.santaTypesUtils.getSantaTypesByDefinition(a.components.html5Video)),statics:{useSantaTypes:!0,behaviors:r.mediaBehaviors.fill},previousScroll:null,getInitialState:function(){return this.size={},{resetAttachment:!1,hidePrevious:!1}},callForBackgroundChange:function(i){var t={onComplete:function(){this.isPageChanged()&&(e.result(this.refs,["previousVideo","kill"]),this.setState({previousPageBackground:null,resetAttachment:!1,hidePrevious:!0}))}.bind(this)};this.props.actionsAspect.registerNextBGPageTransition(this,"previous","current",t),this.setState({previousPageBackground:i,resetAttachment:!0,hidePrevious:!1,currentVisiblePageId:null})},componentWillReceiveProps:function(i){if(this.isPageChanged()){var t=this.props.compData;g(t,i.compData)?(e.result(this.refs,["previousVideo","kill"]),this.setState({previousPageBackground:null,currentVisiblePageId:this.state.currentVisiblePageId||this.props.compData.background.id})):this.callForBackgroundChange(t.background)}},handleParallaxBehavior:function(e){var i=n(e,this.props);("parallax"===this.previousScroll||"parallax"===i)&&(this.previousScroll=i,"parallax"===i?this.props.actionsAspect.registerBehaviors("currentImage","siteBackground",[{action:"bgScrub",name:"SiteBackgroundParallax",duration:1,delay:0}]):this.props.actionsAspect.unRegisterBehaviors("currentImage",[{action:"bgScrub",name:"SiteBackgroundParallax",duration:1,delay:0}]))},getClasses:function(){return""},isPageChanged:function(){return this.props.compData.background.id!==e.get(this.state,["previousPageBackground","id"])},createVideoComponent:function(i,t){var o={comp:"wysiwyg.viewer.components.background.html5Video",skin:"skins.viewer.bgVideo.html5VideoSkin",style:"bgVideo"},r=i.mediaRef,a="current"===t;return"WixVideo"!==e.get(r,"type")?(a&&this.setMediaAPI(null),null):this.createChildComponent(r,o.comp,{skin:o.skin,styleId:o.style},{id:this.props.id+t+"Video",key:"vid_"+r.videoId,notifyMediaState:this.onMediaChange,setMediaAPI:a?this.setMediaAPI:e.noop,mediaQuality:this.props.mediaQuality,className:"siteBackground"+t+"Video",compProp:e.pick(r,B.playback.SUPPORTED_MEDIA_ATTRIBUTES)})},getSkinProperties:function(){var i=this.state.currentVisiblePageId||this.props.compData.background.id,t=e.get(this.state.previousPageBackground,"id","noPrev");t=t===i?"noPrev":t;var o,r,a,s,p=null,c=!this.props.isTouchDevice,l=this.props.id,g=this.props.compData.background,h=u(this.props,g);s={id:l+"_currentImage_"+i,style:h,"data-type":B.balataConsts.BG_IMAGE,"data-height":h.height},c&&((r=this.createVideoComponent(g,"current"))||this.setMediaAPI(null)),this.state.previousPageBackground&&(a={id:l+"_previousImage_"+t,style:(p=this.state.previousPageBackground)?u(this.props,p):{}},c&&(o=this.createVideoComponent(p,"previous"))),this.handleParallaxBehavior(g);var v=d(this.props,g,!1);return{"":{id:l,className:this.getClasses()},current:{key:i+n(g,this.props)+this.props.componentViewMode,id:l+"_current_"+i,style:v,"data-position":v.position},currentImage:s,currentVideo:r,currentOverlay:{id:l+"_currentOverlay_"+i,style:m(this.props,g)},previous:{key:t+n(p,this.props)+this.props.componentViewMode,id:l+"_previous_"+t,style:p?d(this.props,p,this.state.hidePrevious):{}},previousImage:a,previousVideo:o,previousOverlay:{id:l+"_previousOverlay_"+t,style:p?m(this.props,p):{}}}}}}); //# sourceMappingURL=siteBackground.min.js.map