text: var app=angular.module("app",["angular-jwt","ui.router","ui.calendar","ui.bootstrap","ui.bootstrap.datetimepicker","ui.sortable","app.auth","app.admin","app.admin.clubs","app.admin.invoices","app.admin.users","app.calendar","app.championships","app.clubs","app.clubs.invoices","app.competitions","app.dashboard","app.errorhandler","app.invoices","app.premium","app.settings","app.signups","app.teams","app.users"],["$interpolateProvider",function(e){e.startSymbol("<%"),e.endSymbol("%>")}]);app.run(["$rootScope","$state","$timeout","ErrorHandlerFactory","jwtHelper","AuthFactory","$window","$location",function(e,t,n,r,o,a,i,s){i.ga("create","UA-76221618-1","auto"),e.$on("$stateChangeStart",function(n,r){var o=localStorage.getItem("token");if(e.currentRoute=r.name,null!==o){e.authenticated=!0;var a=JSON.parse(localStorage.getItem("user"));e.currentUser=a}"auth"==r.name.split(".",1)[0]&&e.authenticated&&t.go("dashboard",{},{location:"replace"}),r.restricted&&(null===o&&(n.preventDefault(),t.go("auth.login",{},{location:"replace"})),e.datepickerOptions={showWeeks:!0,startingDay:1},e.timepickerOptions={showMeridian:!1,minuteStep:15}),e.loadingState=""}),e.$on("$stateChangeSuccess",function(e){i.ga("send","pageview",s.path())}),e.catchError=function(t){e.errorMessages=[],e.successMessages=[],"string"==typeof t?e.errorMessages.push(t):(console.log(t),t&&(angular.forEach(t,function(t){var n="string"==typeof t?t:t[0];e.errorMessages.push(n)}),console.log(e.errorMessages),n(function(){e.errorMessages=[]},5e3)))},e.displayFlashMessages=function(t,r){n.cancel(e.errorMessageTimer),e.errorMessages=[],e.successMessages=[],angular.isString(t)&&(t=[t]);var o=["token_not_provided"];angular.forEach(t,function(t){if(o.indexOf(t)<0){var n="string"==typeof t?t:t[0];"error"==r?e.errorMessages.push(n):e.successMessages.push(n)}}),e.errorMessageTimer=n(function(){e.errorMessages=[],e.successMessages=[]},5e3)},e.reportError=function(t,n){n||(n="Frontend"),t&&r.reportError(t,n).then(function(t){t.message?t.message&&e.displayFlashMessages([t.message],"warning"):t.data&&t.data.message&&e.displayFlashMessages([t.data.message],"warning")})}}]),angular.module("app.admin.clubs",[]).controller("AdminClubsController",["$rootScope","$stateParams","$state","AdminClubsFactory",function(e,t,n,r){function o(t){e.loadingState=!0,r.load(t).success(function(t){i.clubs=t.clubs,e.loadingState=!1})}function a(){}var i=this;i.filter={search:"",hide_without_users:1,hide_without_admins:null},i.hideClubsWithoutUsers=function(e){return i.filter.hide_without_users&&e.users_count?e:i.filter.hide_without_users?void 0:e},i.hideClubsWithoutAdmins=function(e){return i.filter.hide_without_admins&&e.admins_count?e:i.filter.hide_without_admins?void 0:e},this.page=parseInt(t.page,10),this.sort=t.sort,this.sortOptions=["upvotes","date","author"],a(),o(),this.nextPage=function(){i.page++,o(i.page),n.go(".",{page:i.page},{notify:!1})},this.prevPage=function(){i.page>0&&(i.page--,o(i.page),n.go(".",{page:i.page},{notify:!1}))},this.sortChanged=function(){a(),n.go(".",{sort:i.sort},{notify:!1})}}]).controller("AdminClubController",["$rootScope","$scope","$stateParams","$state","$timeout","AdminClubsFactory",function(e,t,n,r,o,a){function i(){a.find(n.id).success(function(e){s.club=e.club}).error(function(){r.go("admin.clubs",{},{location:"replace"})})}var s=this;s.searchQuery="",s.selectedclub={},n.id||r.go("admin.clubs"),s.updateClub=function(t){s.state="updating",a.updateClub(t).success(function(n){e.displayFlashMessages(n.message),s.clubs.clubs=n.clubs,s.state="updated",r.go("club",{id:t.id})}).error(function(t){e.displayFlashMessages(t.message,"error")})},s.deleteClub=function(e){a.deleteClub(e).success(function(e){r.go("clubs")})},s.searchForClubs=function(t,n){return a.searchForClubs(t).error(function(t){e.displayFlashMessages(t,"warning")}).then(function(e){return s.foundMatch=e.data.clubs.length>0,e.data.clubs.map(function(e){return e.alreadySelected=!1,n.id==e.id&&(e.alreadySelected=!0),e})})},s.selectClub=function(e){s.selectedclub=e},s.mergeClubs=function(t,n){t&&n&&a.mergeClubs(t,n).success(function(t){e.displayFlashMessages(t.message),r.go("admin.clubs.show",{id:n},{location:"replace"})}).success(function(t){e.displayFlashMessages(t.message,"error")})},i()}]).factory("AdminClubsFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){var o=t+"admin/clubs";return!angular.isUndefined(r)&&r>0&&(o+="/"+r),n&&(o+="?page="+n),e({method:"GET",url:o,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"admin/clubs/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createClub:function(n){return e({method:"POST",url:t+"admin/clubs",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},updateClub:function(n){return e({method:"PUT",url:t+"admin/clubs/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},deleteClub:function(n){return e({method:"DELETE",url:t+"admin/clubs/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},loadUserClub:function(){return e({method:"GET",url:t+"admin/clubs/getUserClub",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},addUserToClubs:function(n){return e({method:"POST",url:t+"admin/clubs/addUserToClubs",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({clubs_id:n})})},addNewClub:function(n){return e({method:"POST",url:t+"admin/clubs/addNewClub",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({clubs_nr:n.clubs_nr,name:n.name})})},searchForClubs:function(n){return e({method:"POST",url:t+"clubs/search",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({searchQuery:n})})},addUserAsAdmin:function(n){return e({method:"POST",url:t+"admin/clubs/addUserAsAdmin",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({admin:n})})},deleteUserAsAdmin:function(n){return e({method:"DELETE",url:t+"admin/clubs/deleteUserAsAdmin",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({admin:n})})},mergeClubs:function(n,r){return e({method:"POST",url:t+"admin/clubs/merge",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({clubsIdFrom:n,clubsIdTo:r})})}}}]),angular.module("app.admin.invoices",[]).controller("AdminInvoicesController",["$rootScope","$stateParams","$state","AdminInvoicesFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.load().success(function(t){a.invoices=t.invoices,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var a=this;o()}]).controller("AdminInvoiceController",["$rootScope","$stateParams","$state","AdminInvoicesFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.load(t.id).success(function(t){t.invoice||n.go("admin.invoices.index"),a.invoice=t.invoice,a.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var a=this;o()}]).factory("AdminInvoicesFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n){var r=n?"/"+n:"";return e({method:"GET",url:t+"admin/invoices"+r,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.admin",[]).controller("AdminDashboardController",["$rootScope","$scope","$timeout","AdminFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadDashboard().success(function(t){a.data=t,e.loadingState=!1})}var a=this;o()}]).factory("AdminFactory",["$http","ApiEndpointUrl",function(e,t){return{loadDashboard:function(){return e({method:"GET",url:t+"admin/dashboard",headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.admin.users",[]).controller("AdminUsersController",["$rootScope","$stateParams","$state","AdminUsersFactory",function(e,t,n,r){function o(t){e.loadingState=!0,r.load(t).success(function(t){i.users=t.users,e.loadingState=!1})}function a(){}var i=this;i.filter={search:"",active:1},this.page=parseInt(t.page,10),this.sort=t.sort,this.sortOptions=["upvotes","date","author"],a(),o(),this.nextPage=function(){i.page++,o(i.page),n.go(".",{page:i.page},{notify:!1})},this.prevPage=function(){i.page>0&&(i.page--,o(i.page),n.go(".",{page:i.page},{notify:!1}))},this.sortChanged=function(){a(),n.go(".",{sort:i.sort},{notify:!1})}}]).factory("AdminUsersFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){var o=t+"admin/users";return!angular.isUndefined(r)&&r>0&&(o+="/"+r),n&&(o+="?page="+n),e({method:"GET",url:o,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"admin/users/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.auth",["vcRecaptcha"]).controller("AuthController",["$rootScope","$scope","$state","$stateParams","AuthFactory","$uibModal","$timeout",function(e,t,n,r,o,a,i){t.auth={email:"",name:"",lastname:"",password:"",invite_token:r.invite_token},t.login=function(){t.loggingIn=!0;var r={email:t.auth.email,password:t.auth.password};o.authenticate(r).success(function(r){localStorage.setItem("token",r.token),o.getUser().success(function(t){i(function(){localStorage.setItem("user",JSON.stringify(t.user)),e.currentUser=t.user,e.authenticated=!0,n.go("dashboard",{},{location:"replace"})},1e3)}).error(function(r){localStorage.removeItem("user"),localStorage.removeItem("token"),e.authenticated=!1,e.currentUser=null,t.loggingIn=!1,"user_not_active"==r&&i(function(){n.go("auth.inactive",{},{location:"replace"})},50)})}).error(function(n){e.displayFlashMessages(n.message,"error"),t.loggingIn=!1,e.loadingState="",e.currentUser=!1,e.authenticated=!1})},t.register=function(){t.auth.recaptcharesponse&&(t.registerState="registrering",o.register(t.auth).success(function(){t.registerState="done",t.auth={}}).error(function(n){e.displayFlashMessages(n,"error"),e.loadingState="",t.registerState=!1}))},t.reset={email:""},t.requestPasswordReset=function(){o.requestPasswordReset({email:t.reset.email}).success(function(e){t.reset.email="",t.passwordRequested=!0}).error(function(n){e.displayFlashMessages(n,"error"),t.passwordRequested=!1}).then(function(e){"success"!==e.data.status&&(t.passwordRequested=!0)})},t.termsModalOpen=function(){self.termsModal=a.open({animation:t.animationsEnabled,templateUrl:"/publicviews/terms",size:"md",controller:["$uibModalInstance",function(e){this.close=function(){e.dismiss("cancel")}}],controllerAs:"modal"})}}]).controller("ActivationController",["$state","$rootScope","$scope","$http","$stateParams","AuthFactory","$timeout",function(e,t,n,r,o,a,i){localStorage.removeItem("user"),localStorage.removeItem("token"),t.authenticated=!1,t.currentUser=null,n.activate={token:o.token},n.no_password=!1,n.verifyToken=function(){a.activate(n.activate).success(function(e){n.activated=!0}).error(function(e){"invalid_code"==e.error?t.displayFlashMessages(e.message,"error"):"no_password"==e.error&&(n.no_password=!0,t.displayFlashMessages(e.message,"warning")),n.activated=!1})}}]).factory("AuthFactory",["$http","$filter","$timeout","$state","$rootScope","ApiEndpointUrl",function(e,t,n,r,o,a){return{authenticate:function(t){return e({method:"POST",url:a+"authenticate",data:t})},getUser:function(){return e({method:"GET",url:a+"authenticate/user"})},logout:function(){localStorage.removeItem("user"),localStorage.removeItem("token"),o.authenticated=!1,o.currentUser=null,r.go("auth.login",{},{location:"replace"})},requestPasswordReset:function(t){return e({method:"POST",url:a+"password/email",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(t)})},resetPassword:function(t){return e({method:"POST",url:a+"password/reset",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(t)})},register:function(t){return e({method:"POST",url:a+"register",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(t)})},activate:function(t){return e({method:"POST",url:a+"activate",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(t)})},attemptRefreshToken:function(t){return e({method:"POST",url:a+"refresh"}).success(function(e){return e.token?(localStorage.setItem("token",e.token),void location.reload(!0)):(t=void 0,localStorage.removeItem("user"),localStorage.removeItem("token"),o.authenticated=!1,o.currentUser=null,r.go("auth.login"),!1)}).error(function(){return t=void 0,localStorage.removeItem("user"),localStorage.removeItem("token"),o.authenticated=!1,o.currentUser=null,r.go("auth.login"),!1})}}}]),angular.module("app.calendar",[]).controller("CalendarController",["$scope","$http","$timeout","ApiEndpointUrl",function(e,t,n,r){function o(){$apiUrl=r+"calendar",e.calendarEvents=[{url:r+"calendar"}],e.uiConfig={calendar:{lang:"sv",buttonText:{today:"idag",month:"månad",week:"vecka",day:"dag"},firstDay:"1",weekNumbers:!0,header:{left:"prev,next today",center:"title",right:"month,agendaWeek,agendaDay"},columnFormat:{day:"ddd DD/MM",week:"ddd DD/MM",month:"ddd"},titleFormat:{month:"MMMM YYYY",week:"MMMM D YYYY",day:"MMMM D YYYY"},weekNumberTitle:"",axisFormat:"H:mm",timeFormat:"H:mm",minTime:"6:00",maxTime:"23:59",allDaySlot:!1,defaultView:"month",height:500,editable:!1,viewRender:function(t,n){var o=Date.parse(t.start._d),a=Date.parse(t.end._d);e.calendarEvents=[{url:r+"calendar?start="+o+"&end="+a}]},eventClick:e.alertOnEventClick,eventDrop:e.alertOnDrop,eventResize:function(e,t){console.log(e)}}},e.changeView=function(e,t){t.fullCalendar("changeView",e)},e.renderCalender=function(e){n(function(){console.log(123),e&&e.fullCalendar("render")},0)}}o()}]),angular.module("app.championships",[]).controller("ChampionshipsController",["$rootScope","$scope","$stateParams","$state","ChampionshipsFactory",function(e,t,n,r,o){function a(e){o.load(e).success(function(e){s.championships=e.championships})}function i(){}var s=this;this.page=parseInt(n.page,10),this.sort=n.sort,this.sortOptions=["upvotes","date","author"],i(),a()}]).controller("ChampionshipController",["$rootScope","$scope","$stateParams","$state","ChampionshipsFactory",function(e,t,n,r,o){}]).factory("ChampionshipsFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){var o=t+"championships";return!angular.isUndefined(r)&&r>0&&(o+="/"+r),n&&(o+="?page="+n),e({method:"GET",url:o,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"championships/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createSignup:function(n){return e({method:"POST",url:t+"signup",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},updateSignup:function(n){return e({method:"PUT",url:t+"signup/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},deleteSignup:function(n){return e({method:"DELETE",url:t+"signup/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.clubs.invoices",[]).controller("ClubGenerateInvoicesController",["$rootScope","$stateParams","$state","ClubInvoicesFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadPendingSignups().success(function(t){a.clubs=t.clubs,a.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var a=this;a.createInvoice=function(){e.loadingState=!0,r.createInvoices().success(function(t){e.displayFlashMessages(t.message,"success"),n.go("club.invoices.index"),e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})},o()}]).controller("ClubInvoicesController",["$rootScope","$stateParams","$state","ClubInvoicesFactory","$uibModal",function(e,t,n,r,o){function a(){e.loadingState=!0,r.load().success(function(t){i.invoices_incoming=t.invoices_incoming,i.invoices_outgoing=t.invoices_outgoing,i.invoices_generate=t.invoices_generate,i.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var i=this;i.openPaymentModal=function(e){var t=o.open({animation:!0,templateUrl:"ClubInvoicePaymentModal.html",controller:"ClubInvoicePaymentModalController as modalcontroller",size:"md",resolve:{invoice:function(){return e}}});t.result.then(function(){a()})},i.download=function(e){r.download(e).success(function(e){console.log(e)})},a()}]).controller("ClubInvoiceController",["$rootScope","$stateParams","$state","ClubInvoicesFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.load(t.id).success(function(t){t.invoice||n.go("club.invoices.index"),a.invoice=t.invoice,a.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var a=this;o()}]).controller("ClubInvoicePaymentModalController",["$scope","$uibModalInstance","invoice","ClubInvoicesFactory",function(e,t,n,r){var o=this;o.options={showWeeks:!0,startingDay:1,maxDate:new Date,minDate:moment(n.invoice_date).startOf("day")},o.invoice=angular.copy(n),o.registerPayment=function(e){e.paid_at&&!o.loadingState&&(o.loadingState=!0,r.registerPayment(e.id,e.paid_at).success(function(e){t.close()})["finally"](function(){o.loadingState=!1}))},o.cancel=function(){t.dismiss("cancel")}}]).factory("ClubInvoicesFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n){var r=n?"/"+n:"";return e({method:"GET",url:t+"clubinvoices"+r,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},loadPendingSignups:function(){return e({method:"GET",url:t+"clubinvoices/pendingsignups",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createInvoices:function(){return e({method:"POST",url:t+"clubinvoices",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"clubinvoices/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},registerPayment:function(n,r){return r=moment(new Date(r)).format("YYYY-MM-DD HH:mm:ss"),e({method:"PUT",url:t+"clubinvoices/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({paid_at:r})})},download:function(n){return n?e({method:"GET",url:t+"clubinvoices/"+n+"/download",headers:{"Content-Type":"application/x-www-form-urlencoded"}}):void 0}}}]),angular.module("app.clubs",[]).controller("ClubController",["$rootScope","$scope","$state","ClubsFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadUserClub().success(function(t){a.selectedClubs="",t.id||n.go("club.connect",{},{location:"replace"}),a.club=t,e.loadingState=!1})}var a=this;a.filter={users:{search:""},invoices:{search:""}},a.add_admin=null,a.updateClub=function(){r.updateClub(a.club).success(function(e){n.go("club.information",{},{location:"replace"})}).error(function(t){e.displayFlashMessages(t,"error")})},a.addUserAsAdmin=function(t){t&&r.addUserAsAdmin(t).success(function(){o()}).error(function(t){e.displayFlashMessages(t.message)})},a.deleteUserAsAdmin=function(t){t&&r.deleteUserAsAdmin(t).success(function(){o()}).error(function(t){e.displayFlashMessages(t.message)})},o()}]).controller("ClubConnectController",["$rootScope","$scope","$state","ClubsFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadUserClub().success(function(t){a.selectedClubs="",t.id&&n.go("club.information",{},{location:"replace"}),a.club=t,e.loadingState=!1})}var a=this;a.searchQuery="",a.selectedclub={},a.new_club=null,a.add_clubs_nr="",a.changeClub=!1,a.searchForClubs=function(t,n){return r.searchForClubs(t).error(function(t){e.displayFlashMessages(t,"warning")}).then(function(e){return a.foundMatch=e.data.clubs.length>0,e.data.clubs.map(function(e){return e.alreadySelected=!1,n.id==e.id&&(e.alreadySelected=!0),e})})},a.selectClub=function(e){return e.alreadySelected===!0?!1:(a.noMatchingClubs=null,void(a.new_club=e))},a.noClubsFound=function(){a.noMatchingClubs=!0,a.new_club=null},a.addUserToClubs=function(e){r.addUserToClubs(e.id).success(function(e){a.new_club=null,a.changeClub=!1,a.club=e,n.go("club.information",{},{location:"replace"})})},a.addNewClub=function(){if(!a.searchQuery||!a.add_clubs_nr)return!1;var e={name:a.searchQuery,clubs_nr:a.add_clubs_nr};r.addNewClub(e).success(function(e){a.searchQuery="",a.add_clubs_nr="",a.new_club=null,a.changeClub=!1,a.club=e,n.go("club.information",{},{location:"replace"})})},o()}]).factory("ClubsFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){var o=t+"clubs";return!angular.isUndefined(r)&&r>0&&(o+="/"+r),n&&(o+="?page="+n),e({method:"GET",url:o,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"clubs/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createClub:function(n){return e({method:"POST",url:t+"clubs",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},updateClub:function(n){return e({method:"PUT",url:t+"clubs",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},deleteClub:function(n){return e({method:"DELETE",url:t+"clubs/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},loadUserClub:function(){return e({method:"GET",url:t+"clubs/getUserClub",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},addUserToClubs:function(n){return e({method:"POST",url:t+"clubs/addUserToClubs",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({clubs_id:n})})},addNewClub:function(n){return e({method:"POST",url:t+"clubs/addNewClub",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({clubs_nr:n.clubs_nr,name:n.name})})},searchForClubs:function(n){return e({method:"POST",url:t+"clubs/search",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({searchQuery:n})})},addUserAsAdmin:function(n){return e({method:"POST",url:t+"clubs/addUserAsAdmin",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({admin:n})})},deleteUserAsAdmin:function(n){return e({method:"DELETE",url:t+"clubs/deleteUserAsAdmin",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({admin:n})})}}}]),angular.module("app.competitions",[]).controller("CompetitionsController",["$rootScope","$scope","$stateParams","$state","CompetitionsFactory",function(e,t,n,r,o){function a(t){e.loadingState=!0,o.load(t).success(function(t){s.competitions=t.competitions,e.loadingState=!1})}function i(){}var s=this;this.page=parseInt(n.page,10),this.sort=n.sort,this.sortOptions=["upvotes","date","author"],i(),a(),this.nextPage=function(){s.page++,a(s.page),r.go(".",{page:s.page},{notify:!1})},this.prevPage=function(){s.page>0&&(s.page--,a(s.page),r.go(".",{page:s.page},{notify:!1}))},this.sortChanged=function(){i(),r.go(".",{sort:s.sort},{notify:!1})}}]).controller("CompetitionController",["$rootScope","$scope","$stateParams","$state","$timeout","CompetitionsFactory","SignupsFactory",function(e,t,n,r,o,a,i){function s(){e.loadingState=!0,a.find(n.id).success(function(t){l.competitions=t.competitions,l.user=JSON.parse(localStorage.getItem("user")),e.loadingState=!1}).error(function(){r.go("competitions",{},{location:"replace"}),e.loadingState=!1})}var l=this;l.createSignup=function(t){if(l.loadingState)return!1;l.loadingState=!0;var n={competitions_id:l.competitions.id,weaponclasses_id:t,users_id:l.user.user_id};i.createSignup(n).success(function(e){e.weaponclasses_id=parseInt(e.weaponclasses_id),l.competitions.usersignups.push(e)}).error(function(t){e.displayFlashMessages(t,"error")})["finally"](function(){l.loadingState=!1})},l.deleteSignup=function(e){i.deleteSignup(e).success(function(t){angular.forEach(l.competitions.usersignups,function(t,n){t.id==e.id&&l.competitions.usersignups.splice(n,1)})})},s()}]).factory("CompetitionsFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){var o=t+"competitions";return!angular.isUndefined(r)&&r>0&&(o+="/"+r),n&&(o+="?page="+n),e({method:"GET",url:o,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"competitions/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.dashboard",[]).controller("DashboardController",["$rootScope","$scope","$timeout",function(e,t,n){e.loadingState=!0,t.$on("$viewContentLoaded",function(){n(function(){!function(e,t,n){FB=null;var r,o=e.getElementsByTagName(t)[0];r=e.createElement(t),r.id=n,r.src="//connect.facebook.net/sv_SE/sdk.js#xfbml=1&version=v2.6&appId=956867524398222",o.parentNode.insertBefore(r,o)}(document,"script","facebook-jssdk"),e.loadingState=!1},500)})}]),angular.module("app.errorhandler",[]).controller("ErrorHandlerController",["$rootScope","$scope","ErrorHandlerFactory",function(e,t,n){}]).factory("ErrorHandlerFactory",["$http","ApiEndpointUrl",function(e,t){return{reportError:function(n,r){return e({method:"POST",url:t+"error/report",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({error:n,cause:r})})}}}]),angular.module("app.invoices",[]).controller("GenerateInvoicesController",["$rootScope","$stateParams","$state","InvoicesFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadPendingSignups().success(function(t){a.signups=t.signups,a.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var a=this;a.createInvoice=function(){e.loadingState=!0,r.createInvoices().success(function(t){e.displayFlashMessages(t.message,"success"),n.go("invoices.index"),e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})},o()}]).controller("InvoicesController",["$rootScope","$stateParams","$state","InvoicesFactory","$uibModal",function(e,t,n,r,o){function a(){e.loadingState=!0,r.load().success(function(t){i.invoices_incoming=t.invoices_incoming,i.invoices_outgoing=t.invoices_outgoing,i.invoices_generate=t.invoices_generate,i.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var i=this;i.openPaymentModal=function(e){var t=o.open({animation:!0,templateUrl:"InvoicePaymentModal.html",controller:"InvoicePaymentModalController as modalcontroller",size:"md",resolve:{invoice:function(){return e}}});t.result.then(function(){a()})},i.download=function(e){r.download(e).success(function(e){console.log(e)})},a()}]).controller("InvoiceController",["$rootScope","$stateParams","$state","InvoicesFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.load(t.id).success(function(t){t.invoice||n.go("invoices.index"),a.invoice=t.invoice,a.hideSignups=!0,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var a=this;o()}]).controller("InvoicePaymentModalController",["$scope","$uibModalInstance","invoice","InvoicesFactory",function(e,t,n,r){var o=this;o.options={showWeeks:!0,startingDay:1,maxDate:new Date,minDate:moment(n.invoice_date).startOf("day")},o.invoice=angular.copy(n),o.registerPayment=function(e){e.paid_at&&!o.loadingState&&(o.loadingState=!0,r.registerPayment(e.id,e.paid_at).success(function(e){t.close()})["finally"](function(){o.loadingState=!1}))},o.cancel=function(){t.dismiss("cancel")}}]).factory("InvoicesFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n){var r=n?"/"+n:"";return e({method:"GET",url:t+"invoices"+r,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},loadPendingSignups:function(){return e({method:"GET",url:t+"invoices/pendingsignups",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createInvoices:function(){return e({method:"POST",url:t+"invoices",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"invoices/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},registerPayment:function(n,r){return r=moment(new Date(r)).format("YYYY-MM-DD HH:mm:ss"),e({method:"PUT",url:t+"invoices/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param({paid_at:r})})},download:function(n){return n?e({method:"GET",url:t+"invoices/"+n+"/download",headers:{"Content-Type":"application/x-www-form-urlencoded"}}):void 0}}}]),angular.module("app.premium",[]).controller("PremiumController",["$rootScope","$scope","$state","PremiumFactory",function(e,t,n,r){var o=this;o.loadPremium=function(){e.loadingState=!0,r.loadPremium().success(function(t){o.club=t,e.loadingState=!1})},o.registerPremium=function(){r.registerPremium().success(function(e){o.club=e}).error(function(t){e.displayFlashMessages(t,"error")})},o.loadPremium()}]).factory("PremiumFactory",["$http","ApiEndpointUrl",function(e,t){return{loadPremium:function(){return e({method:"GET",url:t+"premium",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},registerPremium:function(){return e({method:"POST",url:t+"premium",headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.settings",[]).controller("SettingsController",["$rootScope","$scope","$state","SettingsFactory",function(e,t,n,r){var o=this;o.cancelaccount=function(){e.loadingState=!0,r.cancelaccount().success(function(t){e.displayFlashMessages(t.message),e.loadingState=!1,n.go("auth.logout")}).error(function(t){e.displayFlashMessages(t.error),e.loadingState=!1})}}]).controller("PasswordController",["$rootScope","$scope","$state","SettingsFactory",function(e,t,n,r){var o=this;o.reset={current_password:"",password:"",password_confirmation:""},o.updatePassword=function(){r.updatePassword(o.reset).success(function(t){o.reset={current_password:"",password:"",password_confirmation:""},e.displayFlashMessages(t)}).error(function(t){e.displayFlashMessages(t,"error")})}}]).controller("UserProfileController",["$rootScope","$scope","$state","SettingsFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadUserprofile().success(function(t){a.userprofile=t.user,e.loadingState=!1})}var a=this;a.datePickerOptions={startingDay:1,start:{opened:!1},end:{opened:!1}},a.saveUserprofile=function(){e.loadingState=!0,r.saveUserprofile(a.userprofile).success(function(t){localStorage.setItem("user",JSON.stringify(t.user)),a.userprofile=t.user,e.loadingState=!1,n.go("settings.user")}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})},a.cancelUserprofile=function(){o(),n.go("settings.user")},o()}]).controller("UserClubsController",["$rootScope","$scope","$state","ClubsFactory",function(e,t,n,r){function o(){e.loadingState=!0,r.loadUserClubs().success(function(t){a.selectedClubs="",a.clubs=t.clubs,e.loadingState=!1})}var a=this;a.searchQuery="",a.new_club=null,a.add_clubs_nr="",a.changeClub=!1,a.searchForClubs=function(t,n){return r.searchForClubs(t).error(function(t){e.displayFlashMessages(t,"warning")}).then(function(e){return a.foundMatch=e.data.clubs.length>0,e.data.clubs.map(function(e){return e.alreadySelected=!1,angular.forEach(n,function(t){t.id==e.id&&(e.alreadySelected=!0)}),e})})},a.selectClub=function(e){return e.alreadySelected===!0?!1:(a.noMatchingClubs=null,void(a.new_club=e))},a.noClubsFound=function(){console.log(1234),a.noMatchingClubs=!0,a.new_club=null},a.addUserToClubs=function(e){r.addUserToClubs(e.id).success(function(e){a.new_club=null,a.changeClub=!1,a.clubs=e.clubs})},a.addNewClub=function(){if(!a.searchQuery||!a.add_clubs_nr)return!1;var e={name:a.searchQuery,clubs_nr:a.add_clubs_nr};r.addNewClub(e).success(function(e){a.searchQuery="",a.add_clubs_nr="",a.new_club=null,a.changeClub=!1,a.clubs=e.clubs})},o()}]).controller("InviteController",["$rootScope","$scope","$state","InviteFactory",function(e,t,n,r){var o=this;o.loadInvites=function(){r.loadInvites().success(function(e){o.invites=e.invites})},o.loadInvites(),o.invite=function(){e.loadingState=!0,r.invite(o.user).success(function(t){o.user={name:"",lastname:"",email:""},o.loadInvites(),e.displayFlashMessages(t.message),e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}}]).factory("InviteFactory",["$http","ApiEndpointUrl",function(e,t){
  return{loadInvites:function(){return e({method:"GET",url:t+"users/invite",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},invite:function(n){return e({method:"POST",url:t+"users/invite",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})}}}]).factory("SettingsFactory",["$http","ApiEndpointUrl",function(e,t){return{loadUserprofile:function(){return e({method:"GET",url:t+"authenticate/user",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},saveUserprofile:function(n){var r=angular.copy(n);return r.birthday=r.birthday+"-01-01",e({method:"PUT",url:t+"authenticate/user",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(r)})},updatePassword:function(n){return e({method:"PUT",url:t+"authenticate/updatePassword",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},cancelaccount:function(){return e({method:"POST",url:t+"authenticate/cancelAccount",headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.signups",[]).controller("SignupsController",["$rootScope","$scope","$stateParams","$state","SignupsFactory",function(e,t,n,r,o){function a(t){e.loadingState=!0,o.load(t).success(function(t){s.signups=t.signups,s.invoices_generate=t.invoices_generate,e.loadingState=!1})}function i(){}var s=this;this.page=parseInt(n.page,10),this.sort=n.sort,this.sortOptions=["upvotes","date","author"],i(),a()}]).controller("SignupController",["$rootScope","$scope","$stateParams","$state","$timeout","SignupsFactory",function(e,t,n,r,o,a){function i(){e.loadingState=!0,a.find(n.id).success(function(t){s.signups=t.signups,s.user=JSON.parse(localStorage.getItem("user")),e.loadingState=!1}).error(function(){e.loadingState=!1,r.go("signups",{},{location:"replace"})})}var s=this;s.updateSignup=function(t){s.state="updating",a.updateSignup(t).success(function(n){e.displayFlashMessages(n.message),n.signups.participate_out_of_competition=parseInt(n.signups.participate_out_of_competition),n.signups.weaponclasses_id=parseInt(n.signups.weaponclasses_id),s.signups.signups=n.signups,s.state="updated",r.go("signup",{id:t.id})}).error(function(t){e.displayFlashMessages(t.message,"error")})},s.deleteSignup=function(e){a.deleteSignup(e).success(function(e){r.go("signups")})},i()}]).controller("ClubSignupController",["$rootScope","$scope","$stateParams","$state","$timeout","SignupsFactory",function(e,t,n,r,o,a){function i(){e.loadingState=!0,a.loadClubSignups(n.id).success(function(t){s.competition=t.competition,s.club=t.club,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t.message,"error"),e.loadingState=!1})}var s=this;s.createSignup=function(t,r){if(s.loadingState)return!1;s.loadingState=!0;var o={competitions_id:n.id,weaponclasses_id:r,users_id:t};a.createSignup(o).success(function(e){e.weaponclasses_id=parseInt(e.weaponclasses_id),s.competition.signups.push(e)}).error(function(t){e.displayFlashMessages(t,"error")})["finally"](function(){s.loadingState=!1})},s.deleteSignup=function(t){return s.loadingState?!1:(s.loadingState=!0,void a.deleteSignup(t).success(function(e){angular.forEach(s.competition.signups,function(e,n){e.id==t.id&&s.competition.signups.splice(n,1)})}).error(function(t){e.displayFlashMessages(t,"error")})["finally"](function(){s.loadingState=!1}))},i()}]).factory("SignupsFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){var o=t+"signup";return!angular.isUndefined(r)&&r>0&&(o+="/"+r),n&&(o+="?page="+n),e({method:"GET",url:o,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"signup/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createSignup:function(n){return e({method:"POST",url:t+"signup",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},updateSignup:function(n){return e({method:"PUT",url:t+"signup/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(n)})},deleteSignup:function(n){return e({method:"DELETE",url:t+"signup/"+n.id,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},loadClubSignups:function(n){return e({method:"GET",url:t+"competitions/"+n+"/clubsignups",headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.teams",[]).controller("TeamSignupController",["$rootScope","$scope","$stateParams","$state","CompetitionsFactory","TeamsFactory",function(e,t,n,r,o,a){function i(){e.loadingState=!0,n.teams_id?a.load(n.id,n.teams_id).success(function(t){s.teams=t.teams,s.signups_ordinary_available=t.signups_ordinary_available,s.signups_reserve_available=t.signups_reserve_available,angular.forEach(s.teams.signups,function(e,t){1==e.pivot.position&&(s.teams.teams_signups_first=e.id),2==e.pivot.position&&(s.teams.teams_signups_second=e.id),3==e.pivot.position&&(s.teams.teams_signups_third=e.id),4==e.pivot.position&&(s.teams.teams_signups_fourth=e.id),5==e.pivot.position&&(s.teams.teams_signups_fifth=e.id)}),s.teams.signups=null,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1}):a.load(n.id,n.teams_id).success(function(t){s.addTeam={name:"",weaponclasses_id:"",teams_signups_first:null,teams_signups_second:null,teams_signups_third:null,teams_signups_fourth:null,teams_signups_fifth:null},s.teams=t.teams,s.signups_ordinary_available=t.signups_ordinary_available,s.signups_reserve_available=t.signups_reserve_available,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),e.loadingState=!1})}var s=this;s.createTeam=function(){s.addTeam.name&&s.addTeam.weaponclasses_id&&a.store(n.id,s.addTeam).success(function(t){e.displayFlashMessages(t.message),r.go("competition.teamsignups",{id:n.id},{reload:!0})}).error(function(t){e.displayFlashMessages(t.message,"error"),t.redirect_to_edit&&r.go("competition.teamsignups.edit",{id:n.id,teams_id:t.redirect_to_edit},{reload:!0})})},s.updateTeam=function(t){s.teams.name&&s.teams.weaponclasses_id&&a.update(n.id,s.teams.id,t).success(function(t){e.displayFlashMessages(t.message),r.go("competition.teamsignups",{id:n.id},{reload:!0})}).error(function(t){e.displayFlashMessages(t.message,"error"),t.redirect_to_edit&&r.go("competition.teamsignups.edit",{id:n.id,teams_id:t.redirect_to_edit},{reload:!0})})},s.cancelTeam=function(){r.go("competition.teamsignups",{id:n.id},{reload:!0})},s.deleteTeam=function(t){t&&a["delete"](n.id,t).success(function(t){e.displayFlashMessages(t),r.go("competition.teamsignups",{id:n.id},{reload:!0})}).error(function(t){e.displayFlashMessages(t.message,"error")})},i()}]).factory("TeamsFactory",["$http","ApiEndpointUrl",function(e,t){return{load:function(n,r){return n&&r?url=t+"competitions/"+n+"/teamsignups/"+r:url=t+"competitions/"+n+"/teamsignups",e({method:"GET",url:url,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},find:function(n){return e({method:"GET",url:t+"competitions/"+competitions_id+"/teamsignups",headers:{"Content-Type":"application/x-www-form-urlencoded"}})},store:function(n,r){return e({method:"POST",url:t+"competitions/"+n+"/teamsignups",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(r)})},update:function(n,r,o){return e({method:"PUT",url:t+"competitions/"+n+"/teamsignups/"+r,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(o)})},"delete":function(n,r){return e({method:"DELETE",url:t+"competitions/"+n+"/teamsignups/"+r,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}}}]),angular.module("app.users",[]).controller("UserController",["$rootScope","$stateParams","$state","UsersFactory",function(e,t,n,r){function o(){e.loadingState=!0,t.user_id?r.find(t.user_id).success(function(t){a.user=t,e.loadingState=!1}).error(function(t){e.displayFlashMessages(t,"error"),a.user="",e.loadingState=!1}):(a.user={},e.loadingState=!1)}var a=this;o(),a.saveUser=function(t){r.saveUser(t).success(function(t){e.displayFlashMessages(t),n.go("club.users.index",{},{location:"reload"})}).error(function(t){e.displayFlashMessages(t,"error")})},a.createUser=function(t){return a.loadingState?!1:(a.loadingState=!0,void r.createUser(t).success(function(t){e.displayFlashMessages(t),n.go("club.users.index",{},{location:"reload"})}).error(function(t){e.displayFlashMessages(t,"error")})["finally"](function(e){a.loadingState=!1}))}}]).factory("UsersFactory",["$http","ApiEndpointUrl",function(e,t){return{find:function(n){return e({method:"GET",url:t+"users/"+n,headers:{"Content-Type":"application/x-www-form-urlencoded"}})},createUser:function(n){var r=angular.copy(n);return r.birthday=r.birthday+"-01-01",e({method:"POST",url:t+"users",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(r)})},saveUser:function(n){var r=angular.copy(n);return r.birthday=r.birthday+"-01-01",e({method:"PUT",url:t+"users/"+r.user_id,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:$.param(r)})}}}]),app.config(["$provide",function(e){e.decorator("$exceptionHandler",["$delegate","$injector",function(e,t){return function(n,r){e(n,r);var o=t.get("$rootScope");return o.reportError(n,r)}}])}]),app.config(["$httpProvider",function(e){e.interceptors.push(["$q","$injector","$rootScope",function(e,t,n){return{request:function(e){var t=localStorage.getItem("token");return null!==t&&(e.headers.Authorization="Bearer "+t),e.headers["X-Requested-With"]="XMLHttpRequest",e},responseError:function(r){var o=t.get("AuthFactory"),a=t.get("$state");if(void 0!==r.data){if("token_expired"==r.data.error)return o.attemptRefreshToken(r.config);if("user_inactive"==r.data.error||"user_not_found"==r.data.error)n.displayFlashMessages(r.data.message,"error"),localStorage.removeItem("user"),localStorage.removeItem("token"),n.authenticated=!1,n.currentUser=null,a.go("auth.login",{},{location:"replace"});else{if("user_is_not_admin"==r.data.error)return n.displayFlashMessages(r.data.message,"error"),a.go("dashboard");if("api_version_update"==r.data.error)return n.displayFlashMessages(r.data.message,"error"),location.reload(!0)}}if(void 0!==r.error){if("token_expired"==r.error)return o.attemptRefreshToken(r.config);if("user_inactive"==r.error||"user_not_found"==r.error)n.displayFlashMessages(r.message,"error"),n.displayFlashMessages(r.data.message,"error"),localStorage.removeItem("user"),localStorage.removeItem("token"),n.authenticated=!1,n.currentUser=null,a.go("auth.login",{},{location:"replace"});else{if("user_is_not_admin"==r.error)return n.displayFlashMessages(r.message,"error"),a.go("dashboard");if("api_version_update"==r.error)return n.displayFlashMessages(r.message,"error"),location.reload(!0)}}return e.reject(r)}}}])}]),angular.module("ui.calendar",[]).constant("uiCalendarConfig",{}).controller("uiCalendarCtrl",["$scope","$timeout","$locale",function(e,t,n){var r=1,o=1,a=e.eventSources,i=e.calendarWatchEvent?e.calendarWatchEvent:angular.noop,s=function(e){var n;return e&&(n=function(){var n=arguments,r=this;t(function(){e.apply(r,n)})}),n};this.eventsFingerprint=function(e){return e._id||(e._id=o++),""+e._id+(e.id||"")+(e.title||"")+(e.url||"")+(+e.start||"")+(+e.end||"")+(e.allDay||"")+(e.className||"")+i(e)||""},this.sourcesFingerprint=function(e){return e.__id||(e.__id=r++)},this.allEvents=function(){for(var e=[],t=0,n=a.length;n>t;t++){var r=a[t];if(angular.isArray(r))e.push(r);else if(angular.isObject(r)&&angular.isArray(r.events)){var o={};for(var i in r)"_uiCalId"!==i&&"events"!==i&&(o[i]=r[i]);for(var s=0;s<r.events.length;s++)angular.extend(r.events[s],o);e.push(r.events)}}return Array.prototype.concat.apply([],e)},this.changeWatcher=function(e,t){var n,r=function(){for(var n,r,o=angular.isFunction(e)?e():e,i=[],s=0,l=o.length;l>s;s++)r=o[s],n=t(r),a[n]=r,i.push(n);return i},o=function(e,t){var n,r,o=[],a={};for(n=0,r=t.length;r>n;n++)a[t[n]]=!0;for(n=0,r=e.length;r>n;n++)a[e[n]]||o.push(e[n]);return o},a={},i=function(e,r){var i,s,l,c,u={},d=o(r,e);for(i=0,s=d.length;s>i;i++){var p=d[i];l=a[p],delete a[p];var m=t(l);m===p?n.onRemoved(l):(u[m]=p,n.onChanged(l))}var g=o(e,r);for(i=0,s=g.length;s>i;i++)c=g[i],l=a[c],u[c]||n.onAdded(l)};return n={subscribe:function(e,t){e.$watch(r,function(e,n){t&&t(e,n)===!1||i(e,n)},!0)},onAdded:angular.noop,onChanged:angular.noop,onRemoved:angular.noop}},this.getFullCalendarConfig=function(e,t){var n={};return angular.extend(n,t),angular.extend(n,e),angular.forEach(n,function(e,t){"function"==typeof e&&(n[t]=s(n[t]))}),n},this.getLocaleConfig=function(e){if(!e.lang||e.useNgLocale){var t=function(e){var t,n;t=[];for(n in e)t[n]=e[n];return t},r=n.DATETIME_FORMATS;return{monthNames:t(r.MONTH),monthNamesShort:t(r.SHORTMONTH),dayNames:t(r.DAY),dayNamesShort:t(r.SHORTDAY)}}return{}}}]).directive("uiCalendar",["uiCalendarConfig",function(e){return{restrict:"A",scope:{eventSources:"=ngModel",calendarWatchEvent:"&"},controller:"uiCalendarCtrl",link:function(t,n,r,o){function a(){var n,a=r.uiCalendar?t.$parent.$eval(r.uiCalendar):{};n=o.getFullCalendarConfig(a,e);var s=o.getLocaleConfig(n);angular.extend(s,n),u={eventSources:i},angular.extend(u,s);var l={};for(var c in u)"eventSources"!==c&&(l[c]=u[c]);return JSON.stringify(l)}var i=t.eventSources,s=!1,l=o.changeWatcher(i,o.sourcesFingerprint),c=o.changeWatcher(o.allEvents,o.eventsFingerprint),u=null;t.destroy=function(){t.calendar&&t.calendar.fullCalendar&&t.calendar.fullCalendar("destroy"),r.calendar?t.calendar=t.$parent[r.calendar]=$(n).html(""):t.calendar=$(n).html("")},t.init=function(){t.calendar.fullCalendar(u)},l.onAdded=function(e){t.calendar.fullCalendar("addEventSource",e),s=!0},l.onRemoved=function(e){t.calendar.fullCalendar("removeEventSource",e),s=!0},c.onAdded=function(e){t.calendar.fullCalendar("renderEvent",e)},c.onRemoved=function(e){t.calendar.fullCalendar("removeEvents",function(t){return t._id===e._id})},c.onChanged=function(e){e._start=$.fullCalendar.moment(e.start),e._end=$.fullCalendar.moment(e.end),t.calendar.fullCalendar("updateEvent",e)},l.subscribe(t),c.subscribe(t,function(e,t){return s===!0?(s=!1,!1):void 0}),t.$watch(a,function(e,n){t.destroy(),t.init()})}}}]),app.directive("ngEnter",function(){return function(e,t,n){t.bind("keydown keypress",function(t){t.altKey||t.shiftKey||t.ctrlKey||13!==t.which||(e.$apply(function(){e.$eval(n.ngEnter,{event:t})}),t.preventDefault())})}}),app.directive("ngInfiniteScroll",["$window",function(e){return function(t,n,r){angular.element(e).bind("scroll",function(){var e="innerHeight"in window?window.innerHeight:document.documentElement.offsetHeight,n=document.body,r=document.documentElement,o=Math.max(n.scrollHeight,n.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);windowBottom=e+window.pageYOffset,windowBottom>=o&&(t.offset=t.offset+t.limit,t.load())})}}]),app.directive("stringToNumber",function(){return{require:"ngModel",link:function(e,t,n,r){r.$parsers.push(function(e){return""+e}),r.$formatters.push(function(e){return parseFloat(e,10)})}}}),app.filter("cutString",function(){return function(e,t,n,r){if(!e)return"";if(n=parseInt(n,10),!n)return e;if(e.length<=n)return e;if(e=e.substr(0,n),t){var o=e.lastIndexOf(" ");-1!=o&&(e=e.substr(0,o))}return e+(r||"…")}}),app.filter("dateToISO",function(){return function(e){if(void 0!==e&&null!==e){var t=e.split(/[^0-9]/),n=new Date(t[0],t[1]-1,t[2],t[3],t[4],t[5]);return new Date(n).toISOString()}}}),app.filter("isEmpty",[function(){return function(e){return angular.equals({},e)}}]),app.filter("num",function(){return function(e){return parseInt(e,10)}}),app.filter("range",function(){return function(e,t,n){t=parseInt(t),n=parseInt(n);var r;if(n>t)for(r=t;n>r;r++)e.push(r);else for(r=t;r>n;r--)e.push(r);return e}}),app.filter("renderHTMLCorrectly",["$sce",function(e){return function(t){return e.trustAsHtml(t)}}]),app.filter("sumByKey",function(){return function(e,t){if("undefined"==typeof e||"undefined"==typeof t)return 0;for(var n=0,r=e.length-1;r>=0;r--)n+=parseInt(e[r][t]);return n}}),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("admin",{url:"/admin",parent:"root","abstract":!0,restricted:!0}),e.state("admin.dashboard",{url:"/dashboard",restricted:!0,views:{"content@":{templateUrl:"/views/partials.admin.dashboard",controller:"AdminDashboardController as dashboard"}}}),e.state("admin.users",{url:"/users",restricted:!0,views:{"content@":{templateUrl:"/views/partials.admin.users.index",controller:"AdminUsersController as users"}}}),e.state("admin.invoices",{url:"/invoices",restricted:!0,views:{"content@":{templateUrl:"/views/partials.admin.invoices.index",controller:"AdminInvoicesController as invoices"}}}),e.state("admin.invoices.show",{url:"/:id",restricted:!0,views:{"content@":{templateUrl:"/views/partials.admin.invoices.show",controller:"AdminInvoiceController as invoices"}}}),e.state("admin.clubs",{url:"/clubs",restricted:!0,views:{"content@":{templateUrl:"/views/partials.admin.clubs.index",controller:"AdminClubsController as clubs"}}}),e.state("admin.clubs.show",{url:"/:id",restricted:!0,views:{"content@":{templateUrl:"/views/partials.admin.clubs.show",controller:"AdminClubController as clubs"}}}),e.state("admin.clubs.show.users",{url:"/users",restricted:!0,views:{main:{templateUrl:"/views/partials.admin.clubs.users"}}}),e.state("admin.clubs.show.admins",{url:"/admins",restricted:!0,views:{main:{templateUrl:"/views/partials.admin.clubs.admins"}}}),e.state("admin.clubs.show.merge",{url:"/merge",restricted:!0,views:{main:{templateUrl:"/views/partials.admin.clubs.merge"}}})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("auth",{url:"/auth",parent:"public","abstract":!0,views:{"content@":{templateUrl:"/publicviews/index",controller:"AuthController"}}}),n.when("/auth","/auth/login"),e.state("auth.register",{url:"/register",templateUrl:"/publicviews/register"}),e.state("auth.invite",{url:"/register/:invite_token",templateUrl:"/publicviews/register",controller:"AuthController"}),e.state("auth.inactive",{url:"/inactive",templateUrl:"/publicviews/inactive"}),e.state("auth.activate",{url:"/activate/:token",templateUrl:"/publicviews/activate",controller:"ActivationController"}),e.state("auth.login",{url:"/login",templateUrl:"/publicviews/login"}),e.state("auth.password",{url:"/password",templateUrl:"/publicviews/password"}),e.state("auth.reset",{url:"/reset/:token",templateUrl:"/publicviews/reset",controller:["$rootScope","$scope","$stateParams","AuthFactory",function(e,t,n,r){t.reset={email:"",token:n.token},t.resetPassword=function(){r.resetPassword(t.reset).success(function(e){t.passwordRequested=!0,t.reset={email:"",token:n.token}}).error(function(n){e.displayFlashMessages(n,"error"),t.passwordRequested=!1}).then(function(e){"success"!==e.data.status&&(t.passwordRequested=!0)})}}]}),e.state("auth.logout",{url:"/logout",controller:["AuthFactory",function(e){e.logout()}],restricted:!0})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("championships",{url:"/championships",parent:"root",views:{"content@":{templateUrl:"/views/partials.championships.index",controller:"ChampionshipsController",controllerAs:"championships"}},restricted:!0}),e.state("championship",{url:"/championship/:id",parent:"root",views:{"content@":{templateUrl:"/views/partials.championships.show",controller:"ChampionshipController",controllerAs:"championships"}},restricted:!0}),e.state("championship.show",{url:"/:view",views:{main:{templateUrl:function(e){return"/views/partials.championships.show."+e.view},controller:["$rootScope","$stateParams",function(e,t){e.currentView=t.view}]}},restricted:!0})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("club",{url:"/club",parent:"root","abstract":!0,restricted:!0,views:{"content@":{templateUrl:"/views/partials.club.index",controller:"ClubController as club"}}}),e.state("club.connect",{url:"/club/connect",parent:"root",views:{"content@":{templateUrl:"/views/partials.club.connect",controller:"ClubConnectController as club"}}}),e.state("club.information",{url:"/information",views:{main:{templateUrl:"/views/partials.club.information",controller:"ClubController as club"}},restricted:!0}),e.state("club.edit",{url:"/edit",views:{main:{templateUrl:"/views/partials.club.edit",controller:"ClubController as club"}},restricted:!0}),e.state("club.admins",{url:"/admins",views:{main:{templateUrl:"/views/partials.club.admins"}},restricted:!0}),e.state("club.premium",{url:"/premium",views:{main:{templateUrl:"/views/partials.club.premium",controller:"PremiumController as premium"}}}),e.state("club.users",{"abstract":!0,url:"/users",restricted:!0}),e.state("club.users.index",{url:"",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.users.index",controller:"ClubController as club"}}}),e.state("club.users.edit",{url:"/:user_id/edit",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.users.edit",controller:"UserController as user"}}}),e.state("club.users.create",{url:"/create",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.users.create",controller:"UserController as user"}}}),e.state("club.users.show",{url:"/:user_id",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.users.show",controller:"UserController as user"}}}),e.state("club.invoices",{"abstract":!0,url:"/invoices",restricted:!0}),e.state("club.invoices.index",{url:"",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.invoices.index",controller:"ClubInvoicesController as invoices"}}}),e.state("club.invoices.incoming",{url:"/incoming",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.invoices.incoming",controller:"ClubInvoicesController as invoices"}}}),e.state("club.invoices.outgoing",{url:"/outgoing",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.invoices.outgoing",controller:"ClubInvoicesController as invoices"}}}),e.state("club.invoices.generate",{url:"/generate",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.invoices.generate",controller:"ClubGenerateInvoicesController as invoices"}}}),e.state("club.invoices.show",{url:"/:id",restricted:!0,views:{"main@club":{templateUrl:"/views/partials.club.invoices.show",controller:"ClubInvoiceController as invoices"}}})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("competitions",{url:"/competitions?page&sort",parent:"root",views:{"content@":{templateUrl:"/views/partials.competitions.index",controller:"CompetitionsController",controllerAs:"competitions"}},params:{page:{value:"0",squash:!0},sort:{value:"date",squash:!0}},restricted:!0}),e.state("competition",{url:"/competition/:id",parent:"root",views:{"content@":{templateUrl:"/views/partials.competitions.show",controller:"CompetitionController",controllerAs:"competitions"}},restricted:!0}),e.state("competition.clubsignups",{url:"/clubsignups",views:{main:{templateUrl:"/views/partials.competitions.show.clubsignups",controller:"ClubSignupController as clubsignups"}},restricted:!0}),e.state("competition.teamsignups",{url:"/teamsignups",views:{main:{templateUrl:"/views/partials.competitions.show.teamsignups.index",controller:"TeamSignupController as teamsignups"}},restricted:!0}),e.state("competition.teamsignups.create",{url:"/create",views:{"":{templateUrl:"/views/partials.competitions.show.teamsignups.create"}},restricted:!0}),e.state("competition.teamsignups.edit",{url:"/:teams_id",views:{"":{templateUrl:"/views/partials.competitions.show.teamsignups.edit",controller:"TeamSignupController as teamsignups"}},restricted:!0}),e.state("competition.signup",{url:"/signup",restricted:!0,views:{main:{templateUrl:"/views/partials.competitions.show.signup",controller:"CompetitionController as competitions"}}}),e.state("competition.signups",{url:"/signups",restricted:!0,views:{main:{templateUrl:"/views/partials.competitions.show.signups",controller:"CompetitionController as competitions"}}}),e.state("competition.show",{url:"/:view",views:{main:{templateUrl:function(e){return"/views/partials.competitions.show."+e.view},controller:["$rootScope","$stateParams",function(e,t){e.currentView=t.view}]}},restricted:!0})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("invoices",{parent:"root","abstract":!0,url:"/invoices",restricted:!0,views:{"content@":{templateUrl:"/views/partials.invoices.index"}}}),e.state("invoices.index",{url:"",restricted:!0,views:{"main@invoices":{templateUrl:"/views/partials.invoices.overview",controller:"InvoicesController as invoices"}}}),e.state("invoices.incoming",{url:"/incoming",restricted:!0,views:{"main@invoices":{templateUrl:"/views/partials.invoices.incoming",controller:"InvoicesController as invoices"}}}),e.state("invoices.outgoing",{url:"/outgoing",restricted:!0,views:{"main@invoices":{templateUrl:"/views/partials.invoices.outgoing",controller:"InvoicesController as invoices"}}}),e.state("invoices.generate",{url:"/generate",restricted:!0,views:{"main@invoices":{templateUrl:"/views/partials.invoices.generate",controller:"GenerateInvoicesController as invoices"}}}),e.state("invoices.show",{url:"/:id",restricted:!0,views:{"main@invoices":{templateUrl:"/views/partials.invoices.show",controller:"InvoiceController as invoices"}}})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("premium",{url:"/premium",parent:"root",restricted:!0,views:{"content@":{templateUrl:"/views/partials.premium.index",controller:"PremiumController as premium"}}})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){t.html5Mode(!0),n.otherwise("/competitions"),localStorage.getItem("user")?n.otherwise("/competitions"):n.otherwise("/auth/register"),e.state("root",{"abstract":!0,views:{"navigation@":{templateUrl:"/views/partials.navigation"}}}),e.state("public",{"abstract":!0,views:{"navigation@":{templateUrl:"/publicviews/navigation"}}}),e.state("dashboard",{url:"/",parent:"root",views:{"content@":{templateUrl:"/views/partials.dashboard",controller:"DashboardController"}},restricted:!0})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("settings",{url:"/settings",parent:"root","abstract":!0,restricted:!0,views:{"content@":{templateUrl:"/views/partials.settings.index",controller:"SettingsController",controllerAs:"settings"}}}),e.state("settings.index",{url:"/",views:{setting:{controller:["$state",function(e){e.go("settings.user")}]}},restricted:!0}),e.state("settings.user",{url:"/user",views:{setting:{templateUrl:"/views/partials.settings.user",controller:"UserProfileController as userprofile"}},restricted:!0}),e.state("settings.editprofile",{url:"/editprofile",views:{setting:{templateUrl:"/views/partials.settings.useredit",controller:"UserProfileController as userprofile"}},restricted:!0}),e.state("settings.cancelaccount",{url:"/cancelaccount",views:{setting:{templateUrl:"/views/partials.settings.cancelaccount"}},restricted:!0}),e.state("settings.password",{url:"/password",views:{setting:{templateUrl:"/views/partials.settings.password",controller:"PasswordController as password"}},restricted:!0}),e.state("settings.invite",{url:"/invite",views:{setting:{templateUrl:"/views/partials.settings.invite",controller:"InviteController as invite"}},restricted:!0})}]),app.config(["$stateProvider","$locationProvider","$urlRouterProvider",function(e,t,n){e.state("signups",{url:"/signups",parent:"root",views:{"content@":{templateUrl:"/views/partials.signups.index",controller:"SignupsController",controllerAs:"signups"}},restricted:!0}),e.state("signup",{url:"/signup/:id",parent:"root",views:{"content@":{templateUrl:"/views/partials.signups.show",controller:"SignupController",controllerAs:"signups"}},restricted:!0}),e.state("signup.edit",{url:"/edit",views:{"content@":{templateUrl:"/views/partials.signups.edit",controller:"SignupController",controllerAs:"signups"}},restricted:!0})}]);