angular.module("frontApp").controller("clientAreaController",clientAreaController);clientAreaController.$inject=["contentService","$scope","$timeout","siteLocale"];function clientAreaController(contentService,$scope,$timeout,siteLocale){var vm=this;vm.siteLocale=siteLocale.getLocale();vm.clientAreaMenu=true;var getPageByUri=function(uri){return uri.split("/").pop()};document.addEventListener("attachAccountEvent",function(e){contentService.attachAccountAction(getPageByUri(e.target.baseURI))});document.addEventListener("openAccountEvent",function(e){contentService.openAccountAction(getPageByUri(e.target.baseURI))});var slider=$("#accountBalanceSlider").lightSlider({autoWidth:false,item:1,slideMove:1,loop:false,onBeforeStart:function(el){},onSliderLoad:function(el){var count=el.getTotalSlideCount();if(1===count){$("#prev, #next").hide()}var activeSlideElement=$(el).find(".active");if(activeSlideElement!==null){var menuView=activeSlideElement.attr("data-ib_setup");if(menuView==1){var notIbAccountsCount=$(el).find("[data-ib_setup='0']").length;$timeout(function(){vm.clientAreaMenu=false;if(notIbAccountsCount===0){var pathname=window.location.pathname;if(pathname!=="/"+vm.siteLocale+"/account-withdraw"&&pathname!=="/"+vm.siteLocale+"/attach-account"){document.location.replace("/"+vm.siteLocale+"/account-withdraw")}}},100)}else{$timeout(function(){vm.clientAreaMenu=true},100)}}},onBeforeSlide:function(el){var currentSlideCount=el.getCurrentSlideCount();var activeSlideElement=el[0].querySelector('[data-slick-index="'+currentSlideCount+'"]');if(activeSlideElement!==null){var menuView=activeSlideElement.getAttribute("data-ib_setup");if(menuView==1){$timeout(function(){vm.clientAreaMenu=false},100)}else{$timeout(function(){vm.clientAreaMenu=true},100)}}},onAfterSlide:function(el){},onBeforeNextSlide:function(el){},onBeforePrevSlide:function(el){}});$("#prev").click(function(){slider.goToPrevSlide()});$("#next").click(function(){slider.goToNextSlide()})}
angular.module("frontApp").factory("popupClientArea",popupClientArea);popupClientArea.$inject=["$uibModal","siteLocale"];function popupClientArea($uibModal,siteLocale){var instance=[];var close=function(popupName){if(!popupName){closeAll();return true}if(instance[popupName]){instance[popupName].close();instance[popupName]=null}return true};var closeAll=function(){for(var popupName in instance){close(popupName)}};return{attachAccount:function(size){instance["attachAccount"]=$uibModal.open({templateUrl:"/"+siteLocale.getLocale()+"/get-attach-account-popup",animation:true,controller:"attachAccountController",controllerAs:"vm",windowClass:"modal-login-popup",size:size})},close:close}}
angular.module("frontApp").factory("contentService",contentService);contentService.$inject=["$http","siteLocale"];function contentService($http,siteLocale){var vm=this;var urlBuilder=function(){var route="/get-account-content";var page="";var urlParams=[];return{reset:function(){urlParams=[]},addPage:function(value){page=value},addAction:function(value){urlParams.push("actions[]="+value)},getItemCount:function(){return urlParams.length},getString:function(){if(urlParams.length){return route+(page?"/"+page:"")+"?"+urlParams.join("&")}return false}}}();vm.locale=siteLocale.getLocale();vm.updateAccountContent=function(config,callback){urlBuilder.reset();urlBuilder.addPage(config.page);for(var key in config.content){if(config.content.hasOwnProperty(key)&&config.content[key].length){urlBuilder.addAction(key)}}urlBuilder.getItemCount()&&$http({method:"GET",url:"/"+vm.locale+urlBuilder.getString()}).success(function(data){if(data){for(var key in data){if(data.hasOwnProperty(key)&&config.actions.indexOf(key)!==-1&&data[key].length){config.content[key].html(data[key])}}}callback(data)})};return{attachAccountAction:function(page){vm.updateAccountContent({page:page,actions:["accountBalanceMenu"],content:{accountBalanceMenu:angular.element(document.querySelector("#accountBalanceMenu"))}},function(data){return data.length>0})},openAccountAction:function(page){vm.updateAccountContent({page:page,actions:["accountBalance"],content:{accountBalance:angular.element(document.querySelector("#accountBalanceContent"))}},function(data){return data.length>0})}}}
angular.module("frontApp").factory("loggerService",loggerService);loggerService.$inject=["$http","siteLocale"];function loggerService($http,siteLocale){var vm=this;vm.locale=siteLocale.getLocale();vm.page=function(){var path=window.location.pathname;return path.split("/").pop()};return{sendErrorLog:function(msg){$http({method:"POST",data:{page:vm.page(),msg:msg},url:"/"+vm.locale+"/account-logger"})}}}