"use strict";angular.module("CCG.Shared",["MxGroup.Shared"]),angular.module("CCG.Shared").factory("accountService",["webServiceFactory",function(n){return n.create({refreshUser:function(){return this.get("resources/services/user/")},changePassword:function(n,t){return this.post("account/edit/change-password/",{oldPassword:n,password:t})},saveEmailSettings:function(n){return this.post("account/email-settings/",n)},saveANADate:function(n){return this.post("/account/membership/ana/",{date:n.toDateString()})},getVATInfo:function(){return this.get("/account/edit/data/vat/")},saveVATInfo:function(n,t,i,r){return this.post("/account/edit/data/vat/",{countryID:n,vatNumber:t,accountName:i,requestSource:r})}})}]),angular.module("CCG.Shared").controller("anaMembershipController",["accountService",function(n){var t=this;t.submitting=!1,t.dateIsInvalid=!1,t.submitForm=function(){t.submitting=!0,n.saveANADate(t.date).then(function(n){n?window.location="/account/membership/":(t.dateIsInvalid=!0,t.submitting=!1)})}}]),angular.module("CCG.Shared").controller("changePasswordController",["$scope","$window","accountService","urlService",function(n,t,i,r){var u=this;u.HasInvalidPassword=!1,u.HasUnknownError=!1,u.changePassword=function(){n.form.$submitting=!0;var t=i.changePassword(u.OldPassword,u.Password).then(function(n){n.Success?u.ShowPasswordSuccess=n.Success:(u.HasInvalidPassword=n.HasInvalidPassword,u.HasUnknownError=n.HasUnknownError)});t["finally"](function(){n.form.$submitting=!1})},u.goToAccount=function(){t.location=r.root+"account/"}}]),angular.module("CCG.Shared").controller("confirmResetPasswordController",["$window","urlService",function(n,t){var i=this;i.confirmResetPassword=function(r){i.submitting=!0,n.location="/token-service.axd/validate/?token="+r+"&redirect="+t.root+"link-expired/"}}]),angular.module("CCG.Shared").controller("editShippingController",["$scope","$window",function(n,t){angular.extend(n,t.bootstrap)}]),angular.module("CCG.Shared").controller("emailSettingsController",["$scope","$element","$window","accountService",function(n,t,i,r){var u=this;u.masterOptOut=t.find("[name=MasterOptOut]").length>0?t.find("[name=MasterOptOut]").is(":checked"):null,this.save=function(f){n.form.$submitting=!0,u.hasError=!1;var e=t.find("[name=AcceptMessages]").length>0?t.find("[name=AcceptMessages]").is(":checked"):null,o=_.map(t.find(":checkbox:checked").not("[disabled], [name=AcceptMessages]"),function(n){return parseInt($(n).val())}),s=r.saveEmailSettings({SelectedNewsletters:o,LanguageID:t.find("[name=Language]").val(),AcceptMessages:e,MasterOptOut:u.masterOptOut}).then(function(n){t.find(":checkbox:checked:disabled").prop("checked",!1),n.Success?f?i.location.href=f:u.showSaveSuccess=!0:u.hasError=!0}).finally(function(){n.form.$submitting=!1})},this.changeSubscription=function(n){n.target.checked&&(u.masterOptOut=!1)},this.unsubscribe=function(n){n.target.checked&&(t.find("[name=LegalAgreement]").length>0&&(u.acceptFirstPartyLegal=!1,u.acceptThirdPartyLegal=!1),_.map(t.find(".email"),function(n){n.checked=!1}))},this.closeModal=function(){u.showSaveSuccess=!1}}]),angular.module("CCG.Shared").controller("submissionDetail",["$attrs","$element","$rootScope","$scope","$timeout","domService","submissionDetailColumns","submissionDetailColumnsTC","submissionTrackingService","uiGridConstants","rollbarService",function(n,t,i,r,u,f,e,o,s,h,c){var l=this,v=new URI,a=v.segment(-2);c.enable(!1,!1),l.showError=!1,l.showGraderNotesModal=!1,l.isDesktop=f.isDesktop(),l.gradingCompany=n.gradingCompany,l.gridOptions={minRowsToShow:10,excessRows:50,enablePagination:!1,enablePaginationControls:!1,enableColumnMenus:!1,enableGridMenu:!1,enableHorizontalScrollbar:h.scrollbars.NEVER,enableVerticalScrollbar:h.scrollbars.NEVER,columnDefs:e};t.on("click",".js-grader-notes",function(n){var t=$(n.target).attr("line-number");r.$apply(function(){l.selectedComic=_.find(l.gridOptions.data,["LineNumber",t]),l.showGraderNotesModal=!0})});t.on("click",".js-add-coin",function(n){var t=$(n.target).attr("line-number");l.selectedItem=_.find(l.gridOptions.data,["LineNumber",t]),i.$broadcast("addCoin.openLookup",{grader:"NGC",certNumber:a+"-"+t})});l.isLoading=!0,s.getInvoice(a).then(function(n){l.invoice=n,l.invoice.IsTradingCard&&(l.gridOptions.columnDefs=o),l.gridOptions.data=n.LineItems,l.gradingCompany=="CGC"&&(l.gridOptions.data.forEach(function(n){l.invoice.AllowGradeView&&(n.Link="/certlookup/"+n.CertNum)}),l.invoice.IsTradingCard||s.fetchGraderNotes(a).then(function(n){n&&l.gridOptions.data.forEach(function(t){var i=n[t.LineNumber];i&&(t.HasGraderNotes=!0,t.GraderNotes=i)})}).catch(function(n){c.sendError(n,"Submission Tracking - fetchGraderNotes",{invoiceNumber:a})})),l.gradingCompany=="NGC"&&s.fetchImageUrls(a).then(function(n){n&&(l.hasImages=Object.keys(n).length>0,l.invoice.LineItems.forEach(function(t){t.GetImagesLink=n[t.LineNumber]}))})}).catch(function(n){l.showError=!0;switch(n.status){case 404:l.errorMessage="InvalidInvoice";break;case 400:l.errorMessage="ProIVDown";break;default:l.errorMessage="UnknownError"}c.sendError(n,"Submission Tracking - getInvoice",{invoiceNumber:a})}).finally(function(){l.isLoading=!1})}]),angular.module("CCG.Shared").controller("submissionTracking",["$timeout","$window","domService","submissionTrackingService","submissionTrackingColumns","uiGridConstants","urlService","rollbarService",function(n,t,i,r,u,f,e,o){var s=this,h,c;o.enable(!1,!1),s.isDesktop=i.isDesktop(),s.gridOptions={minRowsToShow:10,excessRows:500,paginationPageSize:50,enableColumnMenus:!1,enableGridMenu:!1,enableHorizontalScrollbar:f.scrollbars.NEVER,enableVerticalScrollbar:f.scrollbars.NEVER,columnDefs:u,onRegisterApi:function(n){s.gridApi=n}},h=(new URI).search(!0),c=parseInt(h.page)||1,s.refreshPage=function(n){var t=s.gridOptions.paginationPageSize,i=Math.ceil(s.gridOptions.data.length/t);s.currentPageData={Items:_.slice(s.gridOptions.data,(n-1)*t,n*t),TotalCount:s.gridOptions.data.length,Page:n,PageCount:i,PageSize:t,ShowPreviousPage:n>1,ShowNextPage:n<i,OutOfRange:n<1||n>i},e.replaceUrl(e.baseUrl+"?page="+n)},s.search=function(){!s.searchSubmissionNumber||/^[A-Za-z]/.test(s.searchSubmissionNumber)&&e.sharedCookieDomain.indexOf("cgccomics")!==-1?s.loadInvoices(s.searchSubmissionNumber):t.location.href="/account/my-submissions/tracking/"+s.searchSubmissionNumber+"/"},s.resetSearch=function(){s.searchSubmissionNumber="",s.search()},s.downloadInvoices=function(n){s.showDownloadForm=!1,t.location.href="/account/my-submissions/tracking/invoice/download/?days="+n},s.disablePagination=function(){s.showAllLoading=!0,n(function(){s.gridOptions.enablePagination=!1,s.gridOptions.enablePaginationControls=!1,s.gridApi.grid.refresh()},50)},s.loadInvoices=function(n,t){s.isLoading=!0,r.fetchInvoices(n).then(function(i){s.gridOptions.enablePagination=i.length>s.gridOptions.paginationPageSize,s.gridOptions.enablePaginationControls=s.gridOptions.enablePagination,s.gridOptions.data=i,s.hasInvoices=i.length>0,s.isFromSearch=!!n,s.isDesktop||s.refreshPage(t),s.isLoading=!1}).catch(function(t){t.status===400&&(s.isProIVDown=!0),s.isLoading=!1,o.sendError(t,"Submission Tracking - loadInvoices",{submissionNumber:n})})},s.loadInvoices(null,c)}]),angular.module("CCG.Shared").factory("submissionTrackingService",["webServiceFactory",function(n){return n.create({fetchInvoices:function(n){var t=n?"/account/my-submissions/api/submission/"+n+"/":"/account/my-submissions/api/invoice/";return this.get(t).then(function(n){return n.forEach(function(n){n.ReceivedDate=new Date(n.ReceivedDate),n.ShippedDate&&(n.ShippedDate=new Date(n.ShippedDate))}),n})},getInvoice:function(n){return this.get("/account/my-submissions/api/invoice/"+n+"/")},fetchGraderNotes:function(n){return this.get("/account/my-submissions/api/grader-notes/"+n+"/")},fetchImageUrls:function(n){return this.get("/account/my-submissions/api/invoice/"+n+"/checkForImages/")}})}]),angular.module("CCG.Shared").controller("vatController",["accountService","countryStateService",function(n,t){var i=this;i.vatInfoRequired=!1,i.saveFailed=!1,i.changeVATNumber=function(){i.vatNumber&&(i.noVATNumber=!1)},i.toggleNoVATNumber=function(){i.noVATNumber&&(i.vatNumber="")},i.save=function(){i.saveFailed=!1;var t=(new URI).search(!0),r=t.src||"";n.saveVATInfo(i.countryID,i.vatNumber,i.accountName,r).then(function(n){n.success?window.location=n.destinationUrl:i.saveFailed=!0})},t.fetchCountries().then(function(n){i.countries=n}),n.getVATInfo().then(function(n){n?(i.vatInfoRequired=!1,i.accountName=n.AccountName,i.countryID=n.VATCountryID,i.vatNumber=n.VATNumber,i.noVATNumber=!n.VATNumber):i.vatInfoRequired=!0})}]),angular.module("CCG.Shared").controller("dealerAPIAdminController",["$scope","$window","dealerAPIAdminService",function(n,t,i){var r=this;r.changeAPI=function(){r.result=null,n.form.$setPristine(),n.form.$setUntouched()},r.submitForm=function(){n.form.$invalid||(n.form.ApiToTest=r.apiToTest,n.form.DealerNumber=r.dealerNumber,n.form.$submitting=!0,i.testAPI(n.form).then(function(t){r.result=t,n.form.$submitting=!1}).catch(function(){r.submitErrorMessage="An unexpected error has occurred.",n.form.$submitting=!1}))}}]),angular.module("CCG.Shared").factory("dealerAPIAdminService",["webServiceFactory",function(n){return n.create({testAPI:function(n){return this.post("/admin/dealer-api/submit/",n)}})}]),angular.module("CCG.Shared").controller("dealerPortalArticlesController",["$scope","dealerPortalArticlesService",function(n,t){var i=this;i.dataLoaded=!1,t.getPageData().then(function(t){i.dataLoaded=!0,i.articles=t.Articles,n.form=t.Form}),i.submitForm=function(){i.saveFormSuccessMessage=null,i.saveFormErrorMessage=null,i.showDuplicateArticlesError=!1;var r=_.chain(n.form).toPairs().map(function(n){return{key:n[0],articleID:n[1]}}).groupBy(function(n){return i.collectionName(n.key)}).mapValues(function(n){return _.chain(n).map("articleID").compact().value()}).value(),u=_.chain(r).values().some(function(n){return _.uniq(n).length!==n.length}).value();if(u){i.showDuplicateArticlesError=!0;return}t.saveArticleForm(n.form).then(function(n){n.Success?i.saveFormSuccessMessage="Articles Saved":n.DuplicateArticles?i.showDuplicateArticlesError=!0:i.saveFormErrorMessage="Error saving articles."})},i.displayProperty=function(n){var t=n.replace("Article"," ").split(" ");return t[0]+" Article "+t[1]},i.collectionName=function(n){return n.replace(/[0-9]/g,"")+"s"}}]),angular.module("CCG.Shared").factory("dealerPortalArticlesService",["webServiceFactory",function(n){return n.create({getPageData:function(){return this.get("/admin/dealer-portal-articles/data/")},saveArticleForm:function(n){return this.post("/admin/dealer-portal-articles/data/save-form/",n)}})}]),angular.module("CCG.Shared").controller("eventsAdminController",["eventsAdminService","sessionService","urlService",function(n,t,i){var r=this,u;r.FILTER_KEY="events-filter",u=t.get(r.FILTER_KEY),r.search={SiteCompanyID:u?u.SiteCompanyID:null,Domain:u?u.Domain:null,Visibility:null,ShowPastEvents:!1,Month:null},r.newEvent={},r.addNewEvent=function(){n.addEvent(r.newEvent).then(function(n){n&&(window.location="/admin/events/edit/"+n)})},r.changeStartDate=function(){(!r.newEvent.EndDate||r.newEvent.EndDate<r.newEvent.StartDate)&&(r.newEvent.EndDate=new Date(r.newEvent.StartDate.getTime()))},r.getEvents=function(u,f){t.set(r.FILTER_KEY,r.search),r.search.Page=u,n.getEvents(r.search).then(function(n){r.search=n.Form,r.events=n.Events,r.allEventSites=n.AllEventSites,i.replaceUrl(i.baseUrl+"?page="+u),f&&(r.months=n.Months)})},r.getEvents(1,!0)}]),angular.module("CCG.Shared").controller("eventsAdminEditController",["eventsAdminService","countryStateService",function(n,t){var i=this;i.editEvent={},i.selectedSiteStr="",i.deleteImage=!1,t.fetchCountries().then(function(n){i.countries=n}),i.getEventDetails=function(t){i.editEvent.EventID=t,n.getEventDetails(t).then(function(n){i.editEvent=n.event,i.editEvent.StartDate=new Date(i.editEvent.StartDate),i.editEvent.EndDate=new Date(i.editEvent.EndDate),i.changeCountry(!0);var t={};n.siteIDs.forEach(function(n){t[n]=!0}),Object.keys(i.selectedSites).forEach(function(n){var r=i.selectedSites[n];Object.keys(r).forEach(function(n){t[n]&&(r[n]=!0,i.selectedSiteStr+=n+",")})}),n.tagIDs.forEach(function(n){i.tags[n]=!0})})},i.changeCountry=function(n){n||(i.editEvent.StateID=null),t.fetchStatesForCountryByID(i.editEvent.CountryID).then(function(n){i.states=n})},i.siteSelected=function(n,t){var r=t+",";i.selectedSites[n][t]?i.selectedSiteStr+=r:i.selectedSiteStr=i.selectedSiteStr.replace(r,"")},i.changeAllCompanySites=function(n){if(i.selectedSites[n]){var t=i.selectedSites[n];Object.keys(t).forEach(function(r){t[r]=i["selectAll"+n],i.selectedSiteStr+=r+","})}},i.changeStartDate=function(){i.editEvent.StartDate&&(!i.editEvent.EndDate||i.editEvent.EndDate<i.editEvent.StartDate)&&(i.editEvent.EndDate=new Date(i.editEvent.StartDate.getTime()))},i.saveEvent=function(){var t=i.editEvent;t.SiteIDs=[],t.TagIDs=[],Object.keys(i.selectedSites).forEach(function(n){var r=i.selectedSites[n];Object.keys(r).forEach(function(n){r[n]&&t.SiteIDs.push(n)})}),Object.keys(i.tags).forEach(function(n){i.tags[n]&&t.TagIDs.push(n)}),n.saveEvent(t,i.newImage,i.deleteImage).then(function(n){n?i.successMessage="All changes saved.":i.errorMessage="Error saving event."})},i.clearImage=function(){i.deleteImage=!0},i.deleteEvent=function(){n.deleteEvent(i.editEvent.EventID).then(function(){window.location="/admin/events/"})}}]),angular.module("CCG.Shared").factory("eventsAdminService",["webServiceFactory","Upload",function(n,t){return n.create({getEvents:function(n){var t="/admin/events/data/events/sites/"+n.SiteCompanyID+"/";return t+="?"+URI.buildQuery({domain:n.Domain,month:n.Month,visibility:n.Visibility,showPastEvents:n.ShowPastEvents,page:n.Page}),this.get(t)},addEvent:function(n){return this.post("/admin/events/data/events/",n)},getEventDetails:function(n){return this.get("/admin/events/data/events/"+n+"/")},saveEvent:function(n,i,r){var u="/admin/events/data/events/"+n.EventID+"/",f=_.merge({newImage:i,deleteImage:r},n);return t.upload({method:"PUT",url:u,data:_.omitBy(f,_.isNull)})},deleteEvent:function(n){return this.post("/admin/events/data/events/"+n+"/delete/")}})}]),angular.module("CCG.Shared").controller("expertReviewAdminController",["$scope","$window","expertReviewAdminService",function(n,t,i){function f(){i.getNextRequestInQueue(e,u).then(function(i){i?(r.item=i,n.form={},n.form.RequestID=i.ExpertReviewRequestID,window.scroll(0,0)):t.location.href="/admin/expert-review/"}).finally(function(){n.gradingForm.$submitting=!1})}var r=this,u,e;r.item=null,u=[],e=(new URI).segment(-2),r.changeCategory=function(){var t={RequestID:n.form.RequestID,NewCategory:r.newCategory};i.changeCategory(t).then(function(){location.reload(!0)})},r.submitForm=function(){n.gradingForm.$invalid||(n.gradingForm.$submitting=!0,i.submitReview(n.form).then(function(n){n.Success?f():(r.submitErrorModalVisible=!0,r.submitErrorMessage=n.ErrorMessage)}).catch(function(){r.submitErrorModalVisible=!0,r.submitErrorMessage="An unexpected error has occurred."}))},r.skip=function(){u.push(n.form.RequestID),n.gradingForm.$submitting=!0,f()},r.enableGrading=function(){n.gradingEnabled=!0,n.form.AuthInconclusive=!1},r.disableGrading=function(t){n.gradingEnabled=!1,n.form.Grade=null,n.form.AuthInconclusive=t},r.setGradeInconclusive=function(t){n.form.GradeInconclusive=t,n.labelingEnabled=!t,t&&(n.form.Label=null)},r.filterOutString=function(n){return function(t){return t!=n}},f()}]),angular.module("CCG.Shared").factory("expertReviewAdminService",["webServiceFactory",function(n){return n.create({submitReview:function(n){return this.post("/admin/expert-review/data/submit/",n)},changeCategory:function(n){return this.post("/admin/expert-review/data/change-category/",n)},getNextRequestInQueue:function(n,t){var i="?skipList="+t.join(",");return this.get("/admin/expert-review/data/review/"+n+"/"+i)}})}]),angular.module("CCG.Shared").controller("adminImagesController",["adminImagesService",function(n){function i(){switch(t.resolution){case"HiRes":return"High Resolution";case"LoRes":return"Low Resolution";case"all_resolutions":return"All Resolutions";default:return""}}var t=this;t.invoiceNumber=null,t.getImages=function(){t.invoiceNumber&&t.invoiceNumber.length===7?(t.loading=!0,t.hasHiRes=!1,t.hasLoRes=!1,t.allowGetAllImages=!1,t.displayImageEmailNotification=!1,t.displayGetAllError=!1,t.error="",n.fetchImageInfo(t.siteCompanyCode,t.invoiceNumber,t.resolution).then(function(n){t.loading=!1,t.hasHiRes=!_.isEmpty(n.hiRes),t.hasLoRes=!_.isEmpty(n.loRes),t.results=n,t.allowGetAllImages=t.hasHiRes||t.hasLoRes,t.hasHiRes||t.hasLoRes||(t.error="Your query for "+i(t.resolution)+" images for invoice "+t.invoiceNumber+" yielded no results.")}).catch(function(){t.loading=!1,t.error="An error occured"})):t.error="Please enter a 7-digit invoice number."},t.getAllImages=function(){t.loading=!0,t.allowGetAllImages=!1,t.displayGetAllError=!1,n.fetchAllImages(t.siteCompanyCode,t.invoiceNumber,t.resolution).then(function(){t.loading=!1,t.displayImageEmailNotification=!0}).catch(function(){t.loading=!1,t.error="An error occured",t.displayGetAllError=!0,t.allowGetAllImages=t.hasHiRes||t.hasLoRes})}}]),angular.module("CCG.Shared").factory("adminImagesService",["webServiceFactory",function(n){return n.create({fetchImageInfo:function(n,t,i){return this.get("/admin/images/"+n+"/"+t+"/info/"+i+"/")},fetchAllImages:function(n,t,i){return this.get("/admin/images/"+n+"/"+t+"/all/"+i+"/")}})}]),angular.module("CCG.Shared").controller("articleApprovalHistoryController",["articleApprovalHistoryList","uiGridConstants",function(n,t){var u=this,i=50,r=n.length>i;u.gridOptions={minRowsToShow:10,excessRows:500,paginationPageSize:i,enableColumnMenus:!1,enableGridMenu:!1,enableHorizontalScrollbar:t.scrollbars.NEVER,enableVerticalScrollbar:t.scrollbars.NEVER,columnDefs:[{name:"Public Name",field:"PublicName"},{name:"Email",field:"Email"},{name:"Date (UTC)",field:"DateUTC",displayName:"Date (UTC)",type:"date",cellFilter:"date: 'M/d/yy h:mm:ss a' : 'UTC'"},{name:"Status",field:"Status"},],enablePagination:r,enablePaginationControls:r,data:n}}]),angular.module("CCG.Shared").controller("membershipStatsController",["$window",function(n){var t=this;t.startDate=new Date(moment().utc().add(-7,"days").format(moment.HTML5_FMT.DATE)),t.endDate=new Date(moment().utc().format(moment.HTML5_FMT.DATE)),t.getMembershipReport=function(){var i=moment(t.startDate).format(moment.HTML5_FMT.DATE),r=moment(t.endDate).format(moment.HTML5_FMT.DATE);n.location.href="/admin/reports/api/report/membership-stats/?startDate="+i+"&endDate="+r},t.forceValidDates=function(){(!t.endDate||moment(t.endDate).isBefore(moment(t.startDate)))&&(t.endDate=new Date(moment(t.startDate).add(2,"days").format(moment.HTML5_FMT.DATE)))}}]),angular.module("CCG.Shared").controller("servicesAndFeesAdminController",["servicesAndFeesAdminService",function(n){var t=this;n.fetchSites().then(function(n){t.sites=n})}]),angular.module("CCG.Shared").factory("servicesAndFeesAdminService",["webServiceFactory","Upload",function(n,t){return n.create({fetchSites:function(){return this.get("/admin/services-and-fees/data/sites/")},fetchCategoriesForSite:function(n){return this.get("/admin/services-and-fees/data/sites/"+n+"/categories/")},getCategory:function(n){return this.get("/admin/services-and-fees/data/categories/"+n+"/")},saveCategory:function(n){return this.put("/admin/services-and-fees/data/categories/"+n.GradingServiceCategoryID+"/",n)},saveCategoryPDF:function(n,i,r){return t.upload({method:"PUT",url:"/admin/services-and-fees/data/categories/"+n+"/pdf/",data:{languageCode:i,PDF:r}}).then(function(n){return n.data})},deleteCategoryPDF:function(n,t){return this.post("/admin/services-and-fees/data/categories/"+n+"/pdf/delete/",{languageCode:t})},fetchSubcategoriesForCategory:function(n){return this.get("/admin/services-and-fees/data/categories/"+n+"/subcategories/")},saveSubcategories:function(n,t){return this.put("/admin/services-and-fees/data/categories/"+n+"/subcategories/",t)},createSubcategory:function(n,t){return this.post("/admin/services-and-fees/data/categories/"+n+"/subcategories/",{name:t})},getSubcategory:function(n){return this.get("/admin/services-and-fees/data/subcategories/"+n+"/")},saveSubcategory:function(n){return this.put("/admin/services-and-fees/data/subcategories/"+n.GradingServiceSubcategoryID+"/",n)},deleteSubcategory:function(n){return this.post("/admin/services-and-fees/data/subcategories/"+n+"/delete/")},fetchEntriesForSubcategory:function(n){return this.get("/admin/services-and-fees/data/subcategories/"+n+"/entries/")},saveEntriesForSubcategory:function(n,t){return this.put("/admin/services-and-fees/data/subcategories/"+n+"/entries/",t)},createEntryForSubcategory:function(n){return this.post("/admin/services-and-fees/data/subcategories/"+n+"/entries/")},deleteEntry:function(n){return this.post("/admin/services-and-fees/data/entries/"+n+"/delete/")}})}]),angular.module("CCG.Shared").controller("servicesAndFeesCategoryAdminController",["$window","$q","$scope","servicesAndFeesAdminService",function(n,t,i,r){var u=this,f=new URI,e=f.segment(-4);u.categoryID=parseInt(f.segment(-2)),t.all([r.fetchCategoriesForSite(e),r.getCategory(u.categoryID),r.fetchSubcategoriesForCategory(u.categoryID),]).then(function(n){u.categories=n[0],u.currentCategory=n[1],u.subcategories=n[2]}),u.changeCategory=function(){n.location.href="/admin/services-and-fees/"+e+"/category/"+u.categoryID+"/"},u.save=function(){r.saveCategory(u.currentCategory).then(function(n){u.successMessage="Saved",u.currentCategory=n})},u.uploadPDF=function(n,t){(n.preventDefault(),u.newPDF)&&r.saveCategoryPDF(u.categoryID,t,u.newPDF).then(function(n){n?(t==="en-US"?u.currentCategory.PDFPath=n:i.translationCtrl.updateTranslation("PDFPath",t,n),u.uploadSuccessMessage="Upload successful.",u.newPDF=null):u.uploadFailureMessage="Upload failed."})},u.deletePDF=function(n,t){n.preventDefault(),r.deleteCategoryPDF(u.categoryID,t,u.newPDF).then(function(){t==="en-US"?u.currentCategory.PDFPath=null:i.translationCtrl.updateTranslation("PDFPath",t,null)})},u.subcatMoved=function(n){u.subcategories.splice(n,1),u.subcategories.forEach(function(n,t){n.SortOrder=t}),r.saveSubcategories(u.categoryID,u.subcategories).then(function(n){u.subcategories=n})},u.createSubcategory=function(){r.createSubcategory(u.categoryID,u.newSubcategoryName).then(function(n){u.subcategories=n,u.newSubcategoryName=null,i.newSubcategoryForm.$setPristine(!0),i.newSubcategoryForm.$setUntouched(!0)})}}]),angular.module("CCG.Shared").controller("servicesAndFeesSubcategoryAdminController",["$window","$q","servicesAndFeesAdminService","translationAdminService",function(n,t,i,r){function o(n,t,i){return _.map(n,function(n){var r=_.clone(n);return _.forEach(r,function(n,f){if(_.includes(i,f)){var e={};_.forEach(u.languages,function(i){if(e[i.code]={},i.code=="en-US"){e[i.code].Value=n;return}var u=_.find(t,{EntityKey:r.LocalizationKey,Field:f,LanguageCode:i.code});u?(u.Saved=!0,e[i.code]=u):e[i.code]={LanguageCode:i.code,EntityKey:r.LocalizationKey,Field:f,Value:null}}),r[f]=e}}),r})}function c(n,t){var i=_.map(n,function(n){var i=_.clone(n);return _.forEach(i,function(n,r){t.includes(r)&&(i[r]=n["en-US"].Value)}),i}),r=_.flatMap(n,function(n){var i=[];return _.forEach(n,function(n,r){t.includes(r)&&_.forEach(n,function(n,t){t!="en-US"&&(n.Saved||n.Value)&&(_.unset(n,"Saved"),i.push(n))})}),i});return{entities:i,translations:r}}var u=this,e=new URI,s=e.segment(-6),h=e.segment(-4),f;u.subcategoryID=parseInt(e.segment(-2)),f=["Name","Note","Description","MaxValue","FeePerCollectible","VatExcludedFeePerCollectible","CurrentTurnaround"],t.all([i.getSubcategory(u.subcategoryID),r.fetchLanguagesForSite(s),i.fetchEntriesForSubcategory(u.subcategoryID),]).then(function(n){var t,i;u.subcategory=n[0],u.languages=n[1],u.entryLanguageCode=u.languages[0].code,t=n[2],t.length>0?(i=_.map(t,"GradingServiceEntryID"),r.fetchTranslations("CCG.Entities.Corporate.GradingServices.GradingServiceEntry",i).then(function(n){u.entries=o(t,n,f)})):u.entries=t}),u.save=function(){var n=c(u.entries,f);t.all([i.saveSubcategory(u.subcategory),i.saveEntriesForSubcategory(u.subcategoryID,n.entities),r.saveTranslations("CCG.Entities.Corporate.GradingServices.GradingServiceEntry",n.translations)]).then(function(n){u.successMessage="Saved",u.subcategory=n[0],u.entries=o(n[1],n[2],f)}).catch(function(){u.errorMessage="Error"})},u.deleteSubcategory=function(){i.deleteSubcategory(u.subcategoryID).then(function(){n.location.href="/admin/services-and-fees/"+s+"/category/"+h+"/"})},u.entryMoved=function(n){u.entries.splice(n,1),u.entries.forEach(function(n,t){n.SortOrder=t})},u.showSubcategoryDeleteModal=function(){u.deleteModalType="subcategory",u.showDeleteModal=!0},u.showEntryDeleteModalFor=function(n){u.showEntryDeleteIndex=n,u.deleteModalType="entry",u.showDeleteModal=!0},u.deleteEntry=function(){var n=u.entries[u.showEntryDeleteIndex];i.deleteEntry(n.GradingServiceEntryID).then(function(){u.entries.splice(u.showEntryDeleteIndex,1),u.showDeleteModal=!1})},u.addEntry=function(){i.createEntryForSubcategory(u.subcategoryID).then(function(n){var t=_.head(o([n],[],f));u.entries.push(t)})}}]),angular.module("CCG.Shared").controller("slideEditAdminController",["$timeout","$window","sliderAdminService",function(n,t,i){var r=this,f=new URI,u=f.segment(-4),e=f.segment(-2);i.getSlide(u,e).then(function(n){r.slide=n||[]}),r.save=function(){i.saveSlide(u,r.slide,r.newSlideImage,r.newMobileSlideImage).then(function(){r.successMessage="All changes saved."})},r.delete=function(){i.deleteSlide(u,r.slide.id).then(function(){t.location.href="/admin/sliders/"+u+"/"})}}]),angular.module("CCG.Shared").factory("sliderAdminService",["Upload","webServiceFactory",function(n,t){return t.create({fetchSliders:function(n){return this.get("~/admin/sliders/data/sliders/",n)},fetchVideoSliders:function(){return this.get("~/admin/videos/data/sliders/")},fetchAlternateVideoSliders:function(n){return this.get("~/admin/videos/data/"+n+"/alternate-sliders/")},getSlider:function(n){return this.get("~/admin/sliders/data/"+n+"/")},fetchSlides:function(n){return this.get("~/admin/sliders/data/"+n+"/slides/")},createSlide:function(n,t){return this.post("~/admin/sliders/data/"+n+"/slides/",t)},saveSlides:function(n,t){return this.put("~/admin/sliders/data/"+n+"/slides/",t)},getSlide:function(n,t){return this.get("~/admin/sliders/data/"+n+"/slides/"+t+"/")},saveSlide:function(t,i,r,u){var f=_.merge({slideImage:r,mobileSlideImage:u},i);return n.upload({method:"PUT",url:"/admin/sliders/data/"+t+"/slides/"+i.id+"/",data:_.omitBy(f,_.isNull)})},deleteSlide:function(n,t){return this.post("~/admin/sliders/data/"+n+"/slides/"+t+"/delete/")}})}]),angular.module("CCG.Shared").controller("sliderEditAdminController",["$window","sliderAdminService",function(n,t){function u(){i.oldSortOrder=_.map(i.slides,function(n){return{id:n.id,oldIndex:n.SortOrder}})}var i=this,f=new URI,r=f.segment(-2);i.publishedFilter="all",t.fetchSlides(r).then(function(n){i.allSlides=n||[],i.allSlides.forEach(function(n,t){n.SortOrder=t}),i.slides=i.allSlides,u()}),i.slideMoved=function(n){i.slides.splice(n,1),i.slides.forEach(function(n,t){n.SortOrder=i.oldSortOrder[t].oldIndex,i.allSlides.splice(n.SortOrder,1,n)}),t.saveSlides(r,i.allSlides)},i.createSlide=function(u){var f;f=i.allSlides.length>0?_.minBy(i.allSlides,"SortOrder").SortOrder-1:0,t.createSlide(r,{Title:u,SortOrder:f}).then(function(t){n.location.href="/admin/sliders/"+r+"/slide/"+t.id+"/"})},i.filterSlides=function(){i.slides=i.publishedFilter==="all"?i.allSlides:_.filter(i.allSlides,function(n){return n.Published&&i.publishedFilter==="published"||!n.Published&&i.publishedFilter==="unpublished"}),u()}}]),angular.module("CCG.Shared").controller("sliderListAdminController",["sliderAdminService",function(n){var t=this;n.fetchSliders({sliderType:"Slider"}).then(function(n){t.sliders=n||[]})}]),angular.module("CCG.Shared").controller("videoSlideEditAdminController",["$timeout","$q","$window","$sce","sliderAdminService",function(n,t,i,r,u){var f=this,o=new URI,e=o.segment(-4),s=o.segment(-2);t.all([u.getSlide(e,s),u.fetchAlternateVideoSliders(e),u.getSlider(e)]).then(function(n){f.slide=n[0]||[],f.slide.YouTubeEmbedLink=r.trustAsResourceUrl(f.slide.YouTubeEmbedLink),f.sliderOptions=n[1],f.embedded=n[2].TLD!="cn"}),f.updatePreview=function(){f.slide.YouTubeEmbedLink=f.slide.LinkUrl?r.trustAsResourceUrl("https://www.youtube.com/embed/"+f.slide.LinkUrl):null},f.save=function(){u.saveSlide(e,f.slide,f.newSlideImage).then(function(){e!=f.slide.SliderID?window.location.href="../../../"+f.slide.SliderID+"/slide/"+f.slide.id+"/":f.successMessage="All changes saved."})},f.delete=function(){u.deleteSlide(e,f.slide.id).then(function(){i.location.href="/admin/sliders/"+e+"/"})},f.deleteImage=function(){f.slide.ImageFileName=null}}]),angular.module("CCG.Shared").controller("videoSliderListAdminController",["sliderAdminService",function(n){var t=this;n.fetchVideoSliders().then(function(n){t.sliderGroups=n||[]})}]),angular.module("CCG.Shared").directive("ccgTranslationAdminForm",[function(){return{controllerAs:"translationCtrl",controller:["$attrs","translationAdminService","$q",function(n,t,i){var r=this,u;r.entityKey=parseInt(n.entityKey),r.entityType=n.entityType,u=n.siteId?t.fetchLanguagesForSite(n.siteId):i.when(t.languages),u.then(function(n){r.languages=n,r.languageCode=_.first(r.languages).code}),r.initialize=function(){t.fetchTranslations(r.entityType,r.entityKey).then(function(n){r.translations=n})},r.updateTranslation=function(n,t,i){var u=_.find(r.translations,{Field:n,LanguageCode:t});u?u.Value=i:r.translations.push({Field:n,LanguageCode:t,Value:i}),t===r.languageCode&&(r[n]=i)},r.changeLanguage=function(n,t){n!==t&&_.forEach(r.fieldNames,function(i){var f,u;t!=="en-US"&&(f=_.find(r.translations,{Field:i,LanguageCode:t}),f&&(f.Value=r[i])),n!=="en-US"&&(u=_.find(r.translations,{Field:i,LanguageCode:n}),u||(u={EntityKey:r.entityKey,Field:i,LanguageCode:n,Value:""},r.translations.push(u)),r[i]=u.Value)})},r.save=function(){r.languageCode!=="en-US"&&_.forEach(r.fieldNames,function(n){var t=_.find(r.translations,{Field:n,LanguageCode:r.languageCode});t.Value=r[n]}),t.saveTranslations(r.entityType,r.translations)}}],compile:function(n){var i=n.find("[ccg-translation-field]"),t=[];return _.forEach(i.toArray(),function(n){var i=$(n),r=i.clone(),u=_.find(["ng-model","ng-bind","ng-href","ccg-translation-field"],function(n){return i.attr(n)!==undefined}),f=_.last(i.attr(u).split("."));t.push(f),r.attr(u,"translationCtrl."+f).attr("ng-hide","translationCtrl.languageCode === 'en-US'").removeAttr("required"),i.attr("ng-hide","translationCtrl.languageCode !== 'en-US'").after(r)}),function(n,i,r,u){u.fieldNames=t,u.initialize(),n.$watch("translationCtrl.languageCode",u.changeLanguage)}}}}]),angular.module("CCG.Shared").factory("translationAdminService",["webServiceFactory",function(n){return n.create({languages:[{code:"en-US",name:"English"},{code:"zh-CN",name:"Simplified Chinese"},{code:"zh-TW",name:"Traditional Chinese"},{code:"de-DE",name:"German"},{code:"en-GB",name:"UK English"},{code:"en-IN",name:"Indian English"},],fetchLanguagesForSite:function(n){return this.get("/admin/translations/languages/"+n+"/")},fetchTranslations:function(n,t){return Array.isArray(t)||(t=[t]),this.get("/admin/translations/"+n+"/?entityKeys="+t.join(","))},saveTranslations:function(n,t){return this.post("/admin/translations/"+n+"/",t)}})}]),angular.module("CCG.Shared").factory("userAdminService",["webServiceFactory",function(n){return n.create({getUser:function(n){return this.get("~/admin/users/data/"+n+"/")},fetchUserAgreementsForCountry:function(n,t){return this.get("~/admin/users/data/"+n+"/"+t+"/")},fetchAgreementHistoryForUser:function(n){return this.get("~/admin/users/data/"+n+"/agreement-history/")},fetchCurrentAgreements:function(){return this.get("~/admin/users/data/current-agreements/")},fetchCountries:function(){return this.get("~/admin/users/data/countries/")},saveUser:function(n,t){return this.put("~/admin/users/data/"+n+"/",t)},saveUserAgreement:function(n,t){return this.post("~/admin/users/data/"+n+"/agreement/",{legalAgreementID:t})}})}]),angular.module("CCG.Shared").controller("userAgreementHistoryController",["$q","userAdminService",function(n,t){var i=this,r=new URI,u=r.segment(-3);n.all([t.fetchCountries(),t.fetchAgreementHistoryForUser(u),]).then(function(n){i.countries=n[0],i.agreementGroups=n[1],_.each(i.agreementGroups,function(n){n.ProIVAgreement&&(n.agreementClass=n.AgreementStatus?"icon-success":"icon-close")})})}]),angular.module("CCG.Shared").controller("userEditAdminController",["$scope","userAdminService","countryStateService",function(n,t,i){function f(){return t.getUser(u).then(function(n){r.user=n,r.user.VATInfo.PeopleVATNumberID&&(!r.user.VATInfo.VATNumber||r.user.VATInfo.VATNumber=="")&&(r.noVATNumber=!0)})}function o(){i.fetchCountries().then(function(n){r.countries=n})}var r=this,e=new URI,u=e.segment(-2);r.showAddAcceptanceModal=!1,f(),o(),r.addAcceptance=function(i){t.fetchUserAgreementsForCountry(u,i).then(function(t){r.AddAgreementForm=t,r.AddAgreementForm.NewAgreements.forEach(function(n){n.MajorVersion<r.AddAgreementForm.LatestMajorVersion&&(n.DisplayVersion+=" (cannot submit)")}),n.addAcceptanceForm.$setPristine(),n.addAcceptanceForm.$setUntouched(),r.showAddAcceptanceModal=!0})},r.changeVATNumber=function(){r.user.VATInfo.VATNumber&&(r.noVATNumber=!1)},r.toggleNoVATNumber=function(){r.noVATNumber&&(r.user.VATInfo.VATNumber="")},r.saveUser=function(){t.saveUser(u,r.user).then(function(){r.saveUserSuccessMessage="All changes saved."})},r.saveAgreement=function(){t.saveUserAgreement(u,r.NewLegalAgreementID).then(f).then(function(){r.showAddAcceptanceModal=!1})}}]),angular.module("CCG.Shared").animation(".ccg-animate-height",["$animateCss",function(n){function t(){return.3}return{enter:function(i){var r=$(i).height();return n(i,{event:"enter",easing:"ease-in-out",cleanupStyles:!0,duration:t(r),from:{height:0},to:{height:r}})},leave:function(i){var r=$(i).height();return n(i,{event:"leave",easing:"ease-in-out",cleanupStyles:!0,duration:t(r),from:{height:r},to:{height:0}})}}}]),angular.module("CCG.Shared").directive("ccgBannerSlide",["windowWatcher","domService",function(n,t){return{scope:{fullImageUrl:"@",mobileImageUrl:"@"},controller:["$scope","$element","$timeout",function(n,i,r){var u=this;u.updateImages=function(){r(function(){var r=t.isTabletUp()?n.fullImageUrl:n.mobileImageUrl;r||(r=n.fullImageUrl),i.css("background-image","url("+r+")")})}}],link:function(t,i,r,u){n.onResize(u.updateImages);u.updateImages()}}}]),angular.module("CCG.Shared").directive("ccgTabTo",[function(){return{link:function(n,t,i){if(n.tabToTarget=$("#"+i.ccgTabTo),n.tabToTarget){n.tabToTarget.attr("tabindex",999);t.on("keydown keypress",function(t){var i=t.keyCode||t.which;i===9&&(t.preventDefault(),t.stopPropagation(),n.tabToTarget.focus())})}}}}]),angular.module("CCG.Shared").directive("ccgDragToScroll",["$window","$rootScope","$interval",function(n,t,i){return{link:function(r,u){function c(n){if(n.preventDefault(),h){if(o&&!s){angular.element(o).on("click",a);s=!0}f.left=f.left+(e.x-n.pageX),f.top=f.top+(e.y-n.pageY),e.x=n.pageX,e.y=n.pageY,u.scrollLeft(f.left),u.scrollTop(f.top)}}function l(){h=!1,i(function(){o&&s&&(angular.element(o).off("click",a),s=!1)},0,100),angular.element(n).off("mousemove",c),angular.element(n).off("mouseup",l),t.$broadcast("ccgDragToScroll.endScroll")}function a(n){n.preventDefault()}var o,s,h=!1,e={x:0,y:0},f={top:0,left:0};u.on("mousedown",function(i){i.preventDefault(),h=!0,o=i.target,e.x=i.pageX,e.y=i.pageY,f.left=u.scrollLeft(),f.top=u.scrollTop();angular.element(n).on("mousemove",c);angular.element(n).on("mouseup",l);t.$broadcast("ccgDragToScroll.beginScroll")})}}}]),angular.module("CCG.Shared").directive("ccgFilterInput",["urlService",function(n){return{require:"ngModel",link:function(t,i,r,u){function e(t){switch(t){case"english":return/[\u0000-\u0080]+/;case"float":return/-?[1-9]\d*(\.\d+)?|-?0?\.\d+|0/;case"int":return/-?[1-9]\d*|0/;case"numbers":return/\d+/;case"creditcard":return/[\d\s]+/;case"price":switch(n.tld.toLowerCase()){case"de":return/\d+,?\d?\d?/;default:return/\d+\.?\d?\d?/}default:return new RegExp(t)}}var f=function(n){if(!r.ccgFilterInput)return n;var i=e(r.ccgFilterInput),t=n&&i?(n.match(i)||[""])[0]:n;return n!==t&&(u.$setViewValue(t),u.$render()),t};r.ccgFilterInput&&(u.$parsers.unshift(f),f(t[r.ngModel]))}}}]),angular.module("CCG.Shared").directive("ccgFocus",function(){var n;return{scope:{ccgFocusDisabled:"="},link:function(t,i){n&&clearTimeout(n),n=setTimeout(function(){t.ccgFocusDisabled||i.focus()},0)}}}),angular.module("CCG.Shared").directive("ccgFormatInput",["$filter","$window","$timeout",function(n,t,i){function r(n){var r=t.navigator.userAgent,u;r.indexOf("Android")!=-1&&((u=(new RegExp(/AppleWebKit\/([\d+.]+)/).exec(r)||[])[1],u>=538)||i(function(){var i=n[0],r=n.val().length;i.contentEditable==="true"?(i.focus(),t.getSelection().collapse(i.firstChild,r)):i.setSelectionRange(r,r)},0))}return{require:"ngModel",link:function(t,i,u,f){var e=function(t){var o,h,s,e;return u.ccgFormatInput?(o=[t],u.ccgFormatInputArgs&&(h=(u.ccgFormatInputArgs||"").split(","),h.forEach(function(n){o.push(n.trim())})),s=n(u.ccgFormatInput),e=s?s.apply(this,o):t,t!==e&&(f.$setViewValue(e),f.$render(),r(i)),e):t};u.ccgFormatInput&&(f.$parsers.unshift(e),e(t[u.ngModel]))}}}]),angular.module("CCG.Shared").directive("ngTranscludeInner",function(){return{link:function(n,t,i,r,u){function o(n,i){if(n.length&&s(n)){t.empty(),t.append(n);t.on("$destroy",function(){f.$destroy()})}else i.$destroy()}function s(n){for(var i,t=0,r=n.length;t<r;t++)if(i=n[t],i.nodeType!==Node.TEXT_NODE||i.nodeValue.trim())return!0}if(!u)throw ngTranscludeInnerMinErr("orphan","Illegal use of ngTranscludeInner directive in the template! No parent directive that requires a transclusion found. Element: {0}",startingTag(t));i.ngTranscludeInner===i.$attr.ngTranscludeInner&&(i.ngTranscludeInner="");var e=i.ngTranscludeInner||i.ngTranscludeInnerSlot,f=n.$new();u(f,o,null,e)}}}),angular.module("CCG.Shared").run(["$document","$window",function(n,t){n.on("contextmenu",".prevent-save img",function(n){t.alert("This image is copyrighted."),n.preventDefault()})}]),angular.module("CCG.Shared").directive("ccgPrice",[function(){return{require:"ngModel",restrict:"A",link:function(n,t,i,r){r.$parsers.unshift(function(n){return parseFloat(n.replace(",","."))})}}}]),angular.module("CCG.Shared").directive("ccgScrollTop",["$window",function(n){return{template:"",replace:!0,link:function(t,i){function r(){var t=n.pageYOffset;t>=400?$(i).fadeIn(200):t<400&&$(i).fadeOut(200)}angular.element(n).on("scroll",_.throttle(r,100));i.on("click",function(){document.body.scrollIntoView({behavior:"smooth",block:"start"})})}}}]),angular.module("CCG.Shared").directive("ccgUrlAwareClass",["urlService",function(n){return{link:function(t,i,r){var u=!1,f;r.ccgUrlAwareClass===""?u=n.path()==r.href:(f=new RegExp(r.ccgUrlAwareClass),u=n.path().match(f)!=null),u&&i.addClass(r.ccgUrlClass||"selected")}}}]),angular.module("CCG.Shared").directive("ccgAccordion",[function(){return{restrict:"C",link:function(n,t){t.on("click",".accordion-toggle",function(n){n.stopPropagation();var i=$(this).next();i.slideToggle("fast").toggleClass("open").parent().toggleClass("active"),t.find(".accordion-content").not(i).slideUp("fast").removeClass("open").parent().removeClass("active")})}}}]),angular.module("CCG.Shared").directive("ccgAnalyticsEvent",["analyticsService",function(n){return{link:function(t,i,r){i.on("click",function(){n.event(r.category,r.action,r.label)})}}}]),angular.module("CCG.Shared").service("analyticsService",["$window",function(n){return{event:function(t,i,r){n.ga?n.ga("send","event",t,i,r):!n._gaq||n._gaq.push(["_trackEvent",t,i,r])},pageview:function(t){n.ga?n.ga("send","pageview",t):!n._gaq||n._gaq.push(["_trackPageview",t])}}}]),angular.module("CCG.Shared").directive("ccgBanner",["urlService",function(n){return{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/banner/banner.html",transclude:!0,controllerAs:"banner",controller:["$attrs",function(t){var i=this;i.show=!$.cookie(t.cookieName),i.dismiss=function(){$.cookie(t.cookieName,1,{expires:365,path:"/",domain:n.sharedCookieDomain}),i.show=!1}}]}}]),angular.module("CCG.Shared").directive("ccgCards",[function(){return{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/cards/cards.html",scope:{data:"=",expanderDataUrl:"@?",expanderDataKey:"@?",parseExpanderData:"&",scopeData:"=?",sortCriteria:"=",showAltImages:"@?",imageLabel:"@?",altImageLabel:"@?"},transclude:{cardTemplate:"cardTemplate",expanderTemplate:"?expanderTemplate"},controllerAs:"$cardCtrl",controller:["$animate","$element","$filter","$http","$q","$scope","$timeout","urlService","windowWatcher",function(n,t,i,r,u,f,e,o,s){function p(n){var t=u.when(n),i;!n.expanderData&&f.expanderDataUrl&&(i=URI.expand(f.expanderDataUrl,{key:n[f.expanderDataKey],seoName:n.SEOFriendlyName}).toString(),t=r.get(i).then(function(t){return f.parseExpanderData({card:n,results:t.data})}).then(function(t){return n.expanderData=t,n})),t.then(v)}function l(){var n=_.find(h.data,{url:decodeURI(o.path())});n?p(n):c()}function w(n){var t=_.cloneDeep(n);return t.forEach(function(n){n.template="cardTemplate"}),a(t)}function a(n){n=i("orderBy")(n||[],f.sortCriteria);var t=0;return _.each(n,function(n){n.template=="cardTemplate"&&(n.sort=t,t++)}),n}function c(){var n=_.findIndex(h.data,{isExpander:!0});n!=-1&&(h.data[n].card.selected=!1,h.data.splice(n,1))}function v(n){c();var t=angular.copy(n);t.isExpander=!0,t.template="expanderTemplate",t.sort=b(n),t.card=n,t.card.selected=!0,h.data.push(t)}function y(){var t=_.find(h.data,{selected:!0});t&&(n.enabled(!1),f.$apply(c),f.$apply(function(){v(t)}),n.enabled(!0))}function b(n){var i=t.find(".card"),u=i.filter("[sort="+n.sort+"]"),f=$(u).offset().top,r=_.find(i,function(t){var i=$(t),r=parseFloat(i.attr("sort"));return r<n.sort?!1:i.offset().top>f});return r?parseFloat($(r).attr("sort"))-.25:i.length}var h=this;f.baseUrl=o.baseUrl,_.assignIn(f,f.scopeData);s.onResize(y,500);f.$on("ccgViewSwitch.viewSwitched",y),f.$on("$locationChangeSuccess",l),f.$watch("sortCriteria",function(n){n&&(h.data=a(h.data))}),f.$watchCollection("data",function(n){n&&(h.data=w(n),e(l))},!0);n.on("enter",t,function(n,i){if(n.is(".expander")&&i==="close"){var r=t.find(".card.selected");r.length!==0&&$("html, body").animate({scrollTop:r.offset().top},"fast")}})}]}}]),angular.module("CCG.Shared").directive("ccgCookieBanner",["urlService",function(n){return{templateUrl:"template-cache/cookie-banner.html",controllerAs:"cookieBanner",controller:[function(){var t=this;t.show=!$.cookie("cookie-policy"),t.dismiss=function(){$.cookie("cookie-policy",1,{expires:365,path:"/",domain:n.sharedCookieDomain}),t.show=!1}}]}}]),angular.module("CCG.Shared").directive("ccgCountdownClock",[function(){return{scope:{countdownName:"@"},transclude:!0,templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/countdown-clock/countdown-clock.html",controllerAs:"ctrl",controller:["$scope","$interval","countdownClockService",function(n,t,i){function e(){if(moment.utc().isSameOrAfter(moment.utc(f))){o();return}var n=moment.duration(Math.abs(moment.utc().diff(moment.utc(f))));r.days=_.padStart(Math.trunc(n.asDays()).toString(),2,"0"),r.daysLength=r.days.length,r.hours=_.padStart(n.hours().toString(),2,"0"),r.minutes=_.padStart(n.minutes().toString(),2,"0"),r.seconds=_.padStart(n.seconds().toString(),2,"0"),r.showCountdown=!0}function o(){angular.isDefined(u)&&(t.cancel(u),u=undefined,r.showCountdown=!1)}var r=this,u,f;r.showCountdown=!1,i.getCountdownTimer(n.countdownName).then(function(n){n&&n.ExpirationUTC&&(f=n.ExpirationUTC,moment.utc().isBefore(moment.utc(f))&&(e(),u=t(e,1e3)))}),n.$on("$destroy",o)}],link:function(n,t,i,r,u){u(n,function(n){t.children(".ccg-countdown-clock").append(n)})}}}]),"use strict";var googletag=googletag||{};googletag.cmd=googletag.cmd||[],angular.module("CCG.Shared").constant("DFP_URL","//www.googletagservices.com/tag/js/gpt.js").provider("DfpAdService",["DFP_URL",function(n){function e(n,t){var f=_.find(u,{name:n}),e,o;f&&(e=_.find(i,{name:f.sizeMapName}),o=googletag.defineSlot(r+f.name,f.size,t),e&&o.defineSizeMapping(e.googleSizeMap),o.addService(googletag.pubads()))}var t=this,r="",u=[],i=[],f=0;this.loadScript=function(t){var i=document.createElement("script"),u="https:"===document.location.protocol,r=document.getElementsByTagName("script")[0];i.async=!0,i.type="text/javascript",i.src=(u?"https:":"http:")+n,r.parentNode.insertBefore(i,r),i.onreadystatechange=function(){(this.readyState=="complete"||this.readyState=="loaded")&&t()},i.onload=t},this.initialize=function(){googletag.cmd.push(function(){_.forEach(i,function(n){var t=googletag.sizeMapping();_.forEach(n.sizes,function(n){t.addSize.apply(t,n)}),n.googleSizeMap=t.build()}),googletag.pubads().setTargeting("url",window.location.pathname.substr(0,40)),googletag.pubads().setTargeting("domain",window.location.host),googletag.pubads().setCentering(!0),googletag.pubads().enableSingleRequest(),googletag.enableServices(),googletag.pubads().addEventListener("slotRenderEnded",function(n){n.slot.attempts=n.slot.attempts||0,n.isEmpty&&n.slot.attempts===0?(googletag.pubads().refresh([n.slot]),n.slot.attempts=n.slot.attempts+1):n.slot.attempts=0})})},this.defineSlotPrefix=function(n){r=n},this.defineSlot=function(n,t,i){u.push({name:n,size:t,sizeMapName:i})},this.defineSizeMapping=function(n,t){i.push({name:n,sizes:t})},this.$get=["$q",function(n){var i=n.defer();return t.loadScript(function(){try{t.initialize(),i.resolve()}catch(n){i.reject(n)}}),{defineSlotPrefix:t.defineSlotPrefix,defineSlot:t.defineSlot,defineSizeMapping:t.defineSizeMapping,displayAd:function(n,t){i.promise.then(function(){googletag.cmd.push(function(){f++;var i="div-gpt-ad-"+f;n.attr("id",i),e(t,i),googletag.display(i)})},function(){var n=document.getElementById(id);n.innerHTML=""})},refreshAllAds:function(){googletag.cmd.push(function(){googletag.pubads().refresh()})}}}]}]),angular.module("CCG.Shared").directive("ccgDfpAd",["DfpAdService","$timeout",function(n,t){return{scope:{slotName:"@ccgDfpAd"},template:"<div class='dfp-ad'><\/div>",replace:!0,link:function(i,r){t(function(){n.displayAd(r,i.slotName)})}}}]),angular.module("CCG.Shared").component("ccgEditCoverImage",{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/edit-cover-image/edit-cover-image.html",bindings:{hasImage:"<",onImageSelected:"&",onImageDeleted:"&",addImageLabel:"@",addImageSubtext:"@",confirmDeleteLabel:"@",deleteImageLabel:"@",editImageLabel:"@",newImageLabel:"@"},controller:["$scope","$filter","imageResizer","notifier",function(n,t,i,r){var u=this;u.showEditMenu=function(){u.isEditing=!0},u.hideEditMenu=function(){u.isEditing=!1,u.isDeleting=!1},u.showConfirmDelete=function(){u.isDeleting=!0},u.uploadImage=function(f){var e=_.first(f);e&&(u.isLoading=!0,u.hideEditMenu(),i.resize(e,function(i){if(!i){u.isLoading=!1;return}u.onImageSelected({imageFile:i}).then(function(i){if(i.Success){n.$emit("bgImage.refresh");return}i.OverSizeLimit?r.showError(t("localize")("Error.OverSizeLimit"),5e3):r.showError(t("localize")("Error.UploadError"),5e3)}).finally(function(){u.isLoading=!1})}))},u.deleteImage=function(){u.hideEditMenu(),u.onImageDeleted().then(function(){n.$emit("bgImage.refresh")})}}]}),angular.module("CCG.Shared").directive("ccgFancyboxImages",[function(){return{link:function(n,t){var i;t.hasClass("prevent-save")&&(i={protect:!0,onUpdate:null}),t.find("a:not([onclick]):not([target]) > img").parent().attr("data-fancybox","group").fancybox(i)}}}]),angular.module("CCG.Shared").run([function(){$.fancybox&&($.extend(!0,$.fancybox.defaults,{animationEffect:"fade",hash:!1,spinnerTpl:'<div class="loading"><\/div>'}),$.extend(!0,$.fancybox.defaults.i18n.en,{ERROR:"The requested image is not currently available.  Please try again later."}))}]),angular.module("CCG.Shared").directive("ccgInlineAlert",[function(){return{replace:!0,templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/inline-alert/inline-alert.html",scope:{successMessage:"=?",errorMessage:"=?",duration:"=?"},controllerAs:"$ctrl",controller:["$scope","$timeout",function(n,t){function u(u){return function(f){f&&(n.successMessage="",n.errorMessage="",i.message=f,i.visible=!0,i.isSuccess=u,i.isError=!u,t.cancel(r),r=t(function(){i.visible=!1},n.duration||3e3))}}var i=this,r;n.$watch("successMessage",u(!0)),n.$watch("errorMessage",u(!1))}]}}]),angular.module("CCG.Shared").directive("ccgBackgroundLazyLoad",["lazyLoadService",function(n){return{link:function(t,i,r){n.register(i,function(){r.ccgBackgroundLazyLoad&&i.css("background-image","url("+r.ccgBackgroundLazyLoad+")")})}}}]),angular.module("CCG.Shared").directive("ccgImageLazyLoad",["lazyLoadService",function(n){return{link:function(t,i,r){n.register(i,function(){var n=i.attr("src");i.on("error",function(){n&&i.attr("src",n),i.off("error")}).attr("src",r.ccgImageLazyLoad)})}}}]),angular.module("CCG.Shared").directive("ccgModal",["$rootScope","keycodes",function(n,t){return{replace:!0,transclude:!0,templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/modal/modal-template.html",scope:{showModal:"=ccgModal",allowClose:"=",onClosing:"&",onClosed:"&"},controllerAs:"modal",controller:["$scope",function(n){this.open=function(){n.showModal=!0},this.close=function(t,i){var r=!n.allowClose||n.disableOverlayClose&&i;t!==!0&&r||(n.showModal=!1)}}],link:function(i,r,u,f,e){i.disableOverlayClose=u.disableOverlayClose!==undefined,i.showBackgroundContent=u.showBackgroundContent!==undefined;var o=e(i.$parent,function(n,t){angular.extend(t,{modal:f})});r.removeAttr("ccg-modal"),r.appendTo("body"),r.find(".modal-dialog-content").append(o),$("html").toggleClass("modal-is-visible",!!i.showModal),i.showBackgroundContent&&$("html").toggleClass("show-background-content",!!i.showModal),i.$on("ccgModal.resetScroll",function(){r.find(".modal-dialog-content").scrollTop(0)}),i.$watch("showModal",function(t,r){if(t!==r){if(!t){if(i.onClosing()===!1){i.showModal=!0;return}i.onClosed()}$("html").toggleClass("modal-is-visible",i.showModal),i.showBackgroundContent&&$("html").toggleClass("show-background-content",!!i.showModal),n.$broadcast("modal.visibilityChanged",i.showModal)}});$(document).on("keydown",function(n){n.keyCode===t.ESCAPE&&i.showModal&&i.$apply(f.close)})}}}]),angular.module("CCG.Shared").directive("ccgPreventOuterScroll",["domService",function(n){return{link:function(t,i){function u(n,t,i){var r;i.stopPropagation(),r=t,$(i.target).is("textarea")&&(r=i.target);var u=r.scrollTop===0,f=r.clientHeight+r.scrollTop===r.scrollHeight,e=r.scrollHeight<=r.clientHeight;(e||n&&f||!n&&u)&&i.preventDefault()}if(n.isTouch){var r=0;i.on("touchstart",function(n){r=n.originalEvent.touches[0].clientY}).on("touchmove",function(n){var t=n.originalEvent.touches[0].clientY,f=t<r;u(f,i[0],n)})}else i.on("mousewheel",function(n){var t=n.originalEvent.wheelDelta<0;u(t,i[0],n)})}}}]),angular.module("CCG.Shared").directive("ccgPreventScroll",[function(){return{link:function(n,t){t.on("mousewheel touchmove",function(n){n.stopPropagation(),n.preventDefault()})}}}]),angular.module("CCG.Shared").directive("ccgOverlay",["$rootScope","urlService","windowWatcher","keycodes",function(n,t,i,r){return{scope:{visible:"=ccgOverlay",eventKey:"@",onOpening:"=",onOpened:"=",onClosing:"=",onClosed:"=",offset:"@",duration:"@",closeDuration:"@"},templateUrl:t.root+"resources/ccg-shared/scripts/ccg.shared/components/overlay/overlay.html",transclude:!0,controllerAs:"overlayCtrl",controller:["$scope","$element","$compile","$timeout","domService","windowWatcher",function(t,i,r,u,f,e){function y(n){h&&h.$destroy(),l.empty(),h=t.$new(),o.content=r(n)(h),l.append(o.content),u(function(){t.$apply()})}function c(t){t&&(typeof t=="function"?t():(t=t.indexOf(",")>=0?t.split(","):[t],_.forEach(t,function(t){t&&n.$broadcast(t.trim())})))}function v(n){var r=n||!o.visible,f={translateX:0},i={duration:parseInt(t.duration)||300,easing:[.79,.24,.51,.95]};r?($("body").addClass("no-scroll"),o.resize(),c(t.onOpening),e.resizeWatcher.refresh(),f.translateX=-e.size().width,i.begin=function(){a.addClass("show"),s.addClass("show")},i.complete=function(){c(t.onOpened)}):($("body").removeClass("no-scroll"),c(t.onClosing),i.duration=parseInt(t.closeDuration)||200,i.begin=function(){a.removeClass("show")},i.complete=function(){s.removeClass("show"),o.content&&o.content.remove(),o.closeCallback&&o.closeCallback(),c(t.onClosed)}),o.visible=r,u(s.velocity.bind(s,f,i),0)}var o=this,h=null,s=i.find(".offcanvas-pane"),l=i.find(".offcanvas-pane-content"),a=i.find(".offcanvas-pane-overlay");o.close=function(){v(!1)},o.open=function(n){n&&y(n),v(!0)},o.resize=function(){var n=e.size(),i=f.isSmall()||f.isXSmall()?n.width:n.width-parseFloat(t.offset);s.css({width:i+"px",top:0,right:-n.width}),$.Velocity.hook(s,"translateX",(o.visible?-n.width:0)+"px")},o.content=null,o.visible=t.visible,o.visible&&o.open()}],link:function(n,t,i,u){n.$watch("visible",function(n){n!==u.visible&&(n?u.open():u.close())}),n.$on("ccgOverlay.open."+n.eventKey,function(t,i,r){n.visible||(u.open(i),u.closeCallback=r)});$(window).on("resize",u.resize);$(document).on("keydown",function(t){t.keyCode===r.ESCAPE&&u.visible&&n.$apply(u.close)})}}}]),angular.module("CCG.Shared").directive("pageTitleHeader",[function(){return{scope:{isLanding:"=",pageTitleText:"@",pageTitleLink:"@",descriptionText:"@",descriptionLinkText:"@",descriptionLink:"@",descriptionLinkModal:"@",tooltip:"@",modalContent:"@",modalClass:"@"},templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/page-title-header/page-title-header.html",transclude:!0,controllerAs:"ctrl",controller:["$scope",function(){this.showModal=!1,this.toggleModal=function(){this.showModal=!0}}],link:function(n,t,i,r){r.isLanding=!!n.isLanding}}}]),angular.module("CCG.Shared").directive("ccgPager",["urlService","keycodes",function(n){return{scope:{pagedList:"=ccgPager",pageRange:"@",onPageChanged:"&",scrollToSelector:"@"},templateUrl:n.root+"resources/ccg-shared/scripts/ccg.shared/components/pager/pager-template.html",bindToController:!0,controllerAs:"pagerCtrl",controller:["$element","$scope","domService","windowWatcher","pagerLinkText","scrollService","keycodes",function(t,i,r,u,f,e,o){var s=this,h=f||{};s.ofText=h.of,s.baseUrl=n.baseUrl,s.goToPage=function(n,t){if(n.keyCode==undefined||n.keyCode==o.ENTER||n.keyCode==o.TAB){n.preventDefault(),s.page=parseInt(t),s.page==0?s.page=1:s.page>s.pageCount&&(s.page=s.pageCount),s.refresh();s.onPageChanged({page:s.page});s.scrollToSelector&&e.scrollToElement(s.scrollToSelector)}},s.refresh=function(){s.showFirst=s.page>1,s.showLast=s.page<s.pageCount,s.showPrevious=s.page>1,s.showNext=s.page<s.pageCount},i.$watch("pagerCtrl.pagedList",function(){s.pageCount=s.pagedList!==undefined?s.pagedList.PageCount:1,s.visible=s.pageCount>1,s.page=s.pagedList!==undefined?parseInt(s.pagedList.Page):1,s.refresh()}),i.$watch("pagerCtrl.pagedList.Page",function(n,t){t!==undefined&&t!==n&&s.page!==n&&(s.page=parseInt(n),s.refresh())}),setTimeout(function(){s.pageCount>1&&($("html").addClass("pager-visible"),t.parent(".fixed-ccg-pager").appendTo("body"))})}]}}]),angular.module("CCG.Shared").component("ccgResourceCategories",{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/resource-cards/resource-categories.html",bindings:{expanderKey:"@",countryId:"@",countryName:"@",nameColumn:"@",countColumn:"@",countLabel:"@",subcategoryNameColumn:"@",subcategoryNameLabel:"@",subcategoryCountColumn:"@",subcategoryCountLabel:"@",imageUrlBase:"@",imagePathKey:"@",placeholderImageUrl:"@",viewAllEnabled:"@",viewAllLabel:"@"},controller:["urlService","ccgResourceService",function(n,t){var i=this;i.baseUrl=n.baseUrl,i.$onInit=function(){t.fetchCategoriesForCountry(i.countryId,i.countColumn).then(function(t){t.forEach(function(t){t.url=n.baseUrl+t.SeoName+"/",t[i.imagePathKey]&&(t.imageUrl=i.imageUrlBase+t[i.imagePathKey])}),i.gridItems=t})},i.parseExpanderData=function(n,t){var u={columns:[]},r=t.ResultSet||t,f=!!t.IsGroupings,o,e,s;return u.isGroupings=f,f?r.forEach(function(t){t.Subcategories.forEach(function(i){i.url=n.url+t.SeoName+"/"+i.SeoName+"/"})}):r.forEach(function(t){t.url=n.url+t.SeoName+"/"}),i.viewAllEnabled&&!f&&(o={url:n.url+"all/"},o[i.subcategoryNameColumn]=i.viewAllLabel,r.push(o)),e=r.length,e>5&&!f?(s=Math.ceil(e/2),u.columns.push(_.take(r,s)),u.columns.push(_.takeRight(r,e-s))):u.columns.push(r),u}}]}),angular.module("CCG.Shared").component("ccgResourceCountries",{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/resource-cards/resource-countries.html",bindings:{pageHeader:"@",alphaColumn:"@",alphaSortLabel:"@",countColumn:"@",countLabel:"@",countSortLabel:"@",sortByLabel:"@",imageUrlBase:"@",imagePathKey:"@",placeholderImageUrl:"@"},controller:["storageService","urlService","ccgResourceService",function(n,t,i){function u(t,i,u){r.orderBy=t,r.view=i,r.sortCriteria=u,n.set("resource-countries-orderby",r.orderBy)}var r=this;r.$onInit=function(){i.fetchAllCountries(r.countColumn).then(function(i){i.forEach(function(n){n.url=t.baseUrl+n.SeoName+"/",n[r.imagePathKey]&&(n.imageUrl=r.imageUrlBase+n[r.imagePathKey])}),r.orderBy=n.get("resource-countries-orderby"),r.gridItems=i;switch(r.orderBy){case"alpha":r.orderByAlpha();break;default:r.orderByCount()}})},r.orderByAlpha=function(){u("alpha","compact",[r.alphaColumn])},r.orderByCount=function(){u("count","expanded",["-"+r.countColumn,r.alphaColumn])}}]}),angular.module("CCG.Shared").factory("ccgResourceService",["webServiceFactory",function(n){return n.create({fetchAllCountries:function(n){return this.get("/resources/data/countries/?columnName="+n)},getCountry:function(n,t){return this.get("/resources/data/countries/"+n+"/?columnName="+t)},fetchCategoriesForCountry:function(n,t){return this.get("/resources/data/countries/"+n+"/categories/?columnName="+t)},fetchSubcategoriesForCategory:function(n,t,i){return this.get("/resources/data/countries/"+n+"/categories/"+t+"/subcategories/?columnName="+i)},getSubcategory:function(n,t,i,r){return this.get("/resources/data/countries/"+n+"/categories/"+t+"/subcategories/"+i+"/?columnName="+r)}})}]),angular.module("CCG.Shared").directive("ccgSimpleExpander",["$timeout",function(n){return{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/simple-expander/simple-expander.html",transclude:{expanderTitle:"expanderTitle",expanderContent:"expanderContent"},scope:{broadcastFunction:"<"},controllerAs:"expanderCtrl",controller:["$scope",function(n){var t=this;t.guid=UUID.generate(),t.toggleExpander=function(){n.broadcastFunction&&n.broadcastFunction("ccg-simple-expander.close-others",{target:t.guid}),t.open=!t.open},t.closeExpander=function(){t.open=!1}}],link:function(t,i,r,u){if(r.name){var f=new URI,e=f.fragment();e===r.name&&n(function(){$("html, body").animate({scrollTop:$(i).offset().top},1e3),u.toggleExpander()})}t.$on("ccg-simple-expander.close-others",function(n,t){t&&t.target!==u.guid&&u.closeExpander()})}}}]),angular.module("CCG.Shared").provider("siteSelectorService",function(){var t=this,n=[];this.addSites=function(t){n=n.concat(t)},this.setCurrentSite=function(t){var i=_.find(n,{className:t});_.set(i,"selected",!0)},this.$get=function(){function t(){var t=this;t.sites=n}return new t}}),angular.module("CCG.Shared").directive("ccgSiteSelector",["urlService",function(n){return{templateUrl:n.root+"resources/ccg-shared/scripts/ccg.shared/components/site-selector/site-selector.html",controllerAs:"siteSelectorCtrl",controller:["siteSelectorService",function(n){this.sites=n.sites,this.currentSite=_.find(this.sites,{selected:!0})}],link:function(){}}}]),angular.module("CCG.Shared").directive("ccgTooltip",["$rootScope","$timeout","windowWatcher","urlService","domService",function(n,t,i,r,u){return{scope:{content:"@ccgTooltip",tooltipClass:"@"},link:function(r,f,e){function c(i,r){var u,s;e.persistTooltip!=undefined&&o.hasClass("show")||(n.$broadcast("tooltips.hide"),u=f.offset(),u.top+=f.outerHeight()+8,u.left+=(f.outerWidth()-o.outerWidth())/2,u.left<0&&(u.left=0),o.css(u),s=r===!0?0:500,t.cancel(h),h=t(function(){o.addClass("show")},s),i.stopPropagation())}function s(n){t.cancel(h),t(function(){o.removeClass("show")}),n&&n.stopPropagation&&n.stopPropagation()}function l(n){e.persistTooltip==undefined&&s(n)}function a(n){o.hasClass("show")?s(n):c(n,!0)}var o,h;if(r.content){o=$("<div>").addClass("tooltip-element").html(r.content),r.tooltipClass&&o.addClass(r.tooltipClass),u.storePositionedElement("tooltips",o);f.on("click",a);o.on("click",s);r.$on("tooltips.hide",s),r.$on("mxToggle.open-menus",s);i.onResize(s);if(e.requireClick===undefined){f.on("mouseenter",c);f.on("mouseleave",l)}h=undefined}}}}]),angular.module("CCG.Shared").component("ccgTypeahead",{templateUrl:"/resources/ccg-shared/scripts/ccg.shared/components/typeahead/typeahead.html",bindings:{placeholder:"@",searchingLabel:"@",noResultsLabel:"@",searchUrl:"@",resultFields:"@"},controller:["$window",function(n){var t=this;t.onSelected=function(t){t.originalObject.URL&&(n.location.href=t.originalObject.URL)}}]}),angular.module("CCG.Shared").directive("ccgViewSwitch",["$injector","storageService",function(n,t){return{controllerAs:"viewSwitch",controller:["$element","$scope","$rootScope",function(n,i,r){this.currentView=null,this.changeView=function(n){n.preventDefault(),this.setView($(n.target).closest("[view]")),i.$apply()}.bind(this),this.refreshView=function(){var t=_.get(i[this.scopeKey],"view"),u=this.currentView?this.currentView.attr("view"):null,r;t&&t!==u&&(r=n.find("[view="+t+"]"),this.setView(r))}.bind(this),this.setView=function(n,u){n=angular.element(n),this.currentView=n,n.siblings("[view]").removeClass("selected"),n.addClass("selected");var f=n.attr("view"),e={};_.forEach(n[0].attributes,function(n){e[n.name]=n.value}),i[this.scopeKey]=e,n.attr("no-persist")===undefined&&this.storageKey&&t.set(this.storageKey,f),u||r.$broadcast("ccgViewSwitch.viewSwitched",f)}.bind(this),this.nextView=function(){if(this.currentView){var n=this.currentView.next();n.length===0&&(n=this.currentView.siblings("[view]")[0]),this.setView(n)}}.bind(this)}],link:function(i,r,u,f){var o,s,e;f.scopeKey=u.ccgViewSwitch,f.storageKey=u.persistAs;r.on("click","[view]",f.changeView);if(u.hotkeyCycleView)try{o=n.get("hotkeys"),o.add({combo:u.hotkeyCycleView,action:"keyup",description:"Cycle views",callback:f.nextView})}catch(h){console.log("hotkey service is not available")}s=t.get(u.persistAs)||u.defaultView,e=r.find("[view="+s+"]"),e.length===0&&(e=r.find("[view]:first")),f.setView(e,!0),i.$watch(f.scopeKey+".view",f.refreshView)}}}]),angular.module("CCG.Shared").directive("ccgWysiwygEditor",["$compile","$rootScope",function(n,t){return{restrict:"A",scope:{modalTitle:"@ccgWysiwygEditor"},require:["ccgWysiwygEditor","ngModel","?^ccgTranslationAdminForm"],controllerAs:"wysiwyg",controller:["$scope",function(t){function u(){i.model=r.$viewValue}var i=this,r=null;i.tinymceOptions={height:500,contextmenu:!1,menubar:!1,forced_root_block:"div",paste_as_text:!0,plugins:"code, lists, link, image, paste",toolbar:"formatselect | bold italic underline forecolor | link unlink | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | image | removeformat | code"},i.openEditor=function(){i.openModal=!0,i.newHtml=i.model;var r="<div id='wysiwygModal"+i.wysiwygID+"' class='ccg-form' ccg-modal='wysiwyg.openModal' allow-close='true' on-closed='wysiwyg.closeEditor'><h2>"+t.modalTitle+"<\/h2><textarea ui-tinymce='wysiwyg.tinymceOptions' ng-model='wysiwyg.newHtml' ccg-ignore-model-override><\/textarea><div class='next-steps'><a class='btn primary' ng-click='wysiwyg.save()'>Save<\/a><a class='cancel' ng-click='wysiwyg.closeEditor()'>Cancel<\/a><\/div><\/div>",u=angular.element("#wysiwygInputWrapper"+i.wysiwygID);u.append(n(r)(t)),$("html").toggleClass("wysiwyg",!0)},i.closeEditor=function(){i.openModal=!1,angular.element("#wysiwygModal"+i.wysiwygID).remove(),angular.element(".tox-tinymce-aux").remove(),$("html").toggleClass("wysiwyg",!1)},i.save=function(){i.model=i.newHtml,i.closeEditor()},i.setNgModelController=function(n){r=n,r.$render=u,u()},t.$watch("wysiwyg.model",function(){r.$setViewValue(i.model)})}],link:function(i,r,u,f){var h=f[0],s,e,o;h.setNgModelController(f[1]),s=f[2],s&&(i.translationCtrl=s),t.wysiwygID===undefined?t.wysiwygID=0:t.wysiwygID+=1,h.wysiwygID=t.wysiwygID,e=angular.element("<div id='wysiwygInputWrapper"+t.wysiwygID+"' class='wysiwyg-input-wrapper'><\/div>"),u.ngHide&&e.attr("ng-hide",u.ngHide),o=r.clone().removeAttr("ccg-wysiwyg-editor"),o.attr("ccg-ignore-model-override",""),o.attr("ng-model","wysiwyg.model"),e.append(o),e.append(angular.element("<span class='icon-edit' ng-click='wysiwyg.openEditor()'><\/span>")),r.replaceWith(n(e)(i))}}}]),angular.module("CCG.Shared").controller("consentController",["$scope","$window","consentService","urlService","translationDictionary",function(n,t,i,r,u){function e(){f.errorMessage=u.Error.WaiverSubmitFailed,f.disableControls=!1}var f=this;f.errorMessage=null,f.consent={},f.disableControls=!1,f.submitted=!1,f.submitConsent=function(){n.form.$invalid||(f.disableControls=!0,n.form.$submitting=!0,i.submitConsent(f.consent).then(function(n){n?f.submitted=!0:e()}).catch(function(){e()}).finally(function(){n.form.$submitting=!1}))},f.reloadPage=function(){t.location=r.baseUrl}}]),angular.module("CCG.Shared").factory("consentService",["webServiceFactory",function(n){return n.create({submitConsent:function(n){return this.post("/consent/api/submit/",n)}})}]),angular.module("CCG.Shared").controller("contactController",["$scope",function(n){n.$on("recaptcha.ready",function(){angular.element("#contact_captcha").length&&grecaptcha.render("contact_captcha",{sitekey:CCG.recaptchaSiteKey})})}]),angular.module("CCG.Shared").controller("dealerEditController",["$scope","countryStateService",function(n,t){var i=this;this.changeCountry=function(){t.fetchStatesForCountryByName(n.Country).then(function(n){i.StateList=n})},t.fetchCountries().then(function(n){i.CountryList=n}),$(document).ready(function(){i.changeCountry()})}]),angular.module("CCG.Shared").controller("eventsController",["eventsService","countryStateService","urlService","preselectedEventFilters",function(n,t,i,r){var u=this;u.initialized=!1,u.filter={hasTagFilter:!1,tags:{}},_.isArrayLike(r)&&r.length>0&&(_.forEach(r,function(n){u.filter.tags[n]=!0}),u.filter.hasTagFilter=!0,i.replaceUrl(i.path())),n.fetchEvents().then(function(n){u.initialized=!0,u.tags=n.Tags,u.months=n.Months,u.eventsByMonth=n.EventsByMonth,u.countries=n.Countries}),u.changeCountry=function(){t.fetchStatesForCountryByID(u.filter.countryID).then(function(n){u.states=n})},u.clearFilter=function(){u.filter={hasTagFilter:!1,tags:{}}},u.filterBy=function(n){u.filter.tags[n]=!u.filter.tags[n],u.filter.hasTagFilter=!1;for(var t in u.filter.tags)if(u.filter.tags[t]){u.filter.hasTagFilter=!0;break}},u.filterMonth=function(n){var t=!0,i;return u.filter.includePastEvents||(i=moment().startOf("month"),t=moment(n.Date).isSameOrAfter(i)),t&&u.filter.month&&(t=n.Display===u.filter.month.Display),t},u.filterEvent=function(n){var t=!0,i,r,f,e;if(u.filter.countryID&&(t=n.CountryID===u.filter.countryID),t&&u.filter.stateID&&(t=n.StateID===u.filter.stateID),t&&u.filter.hasTagFilter){i=!1;for(r in n.Tags)if(u.filter.tags[r]){i=!0;break}t=i}return t&&!u.filter.includePastEvents&&(f=moment(n.EndDate),e=moment().startOf("month"),t=f.isSameOrAfter(e)),t},u.checkNoEvents=function(){return _.every(u.filteredMonths,function(n){return!n.filteredEvents||!n.filteredEvents.length})}}]),angular.module("CCG.Shared").factory("eventsService",["webServiceFactory",function(n){return n.create({fetchEvents:function(){return this.get("/submit/events/data/events/")}})}]),angular.module("CCG.Shared").controller("expertReviewController",["$scope","$window","expertReviewService","expertReviewItemTypes",function(n,t,i,r){var u=this;u.item=null,u.itemError=!1,u.canSubmitForm=!1,u.purchaseSuccess=!1,u.expertReviewItemTypes=r,n.FormData={},n.FormData.CreditCard={ExpirationMonth:"",ExpirationYear:""},r.length===1&&(n.FormData.ItemType=r[0]),u.resetItemLookup=function(){u.itemError=!1,u.canSubmitForm=!1,u.item=null},u.lookupItem=function(){(u.resetItemLookup(),u.ebayItemNumber)&&(n.lookupForm.$submitting=!0,i.lookupItem(u.ebayItemNumber).then(function(t){if(t.Success){u.item=t,n.FormData.ItemID=u.ebayItemNumber,n.FormData.AuctionCategory=u.item.Category,n.FormData.AuctionItemDescription=u.item.ItemDescription,n.FormData.AuctionUrl=u.item.AuctionUrl,n.FormData.AuctionEndDate=u.item.AuctionEnd,n.FormData.SellerID=u.item.SellerID,u.canSubmitForm=!t.NotEnoughTime&&!t.AuctionEnded;var i=new Date(t.AuctionEnd),r=moment.tz.guess();u.item.AuctionEnd=moment.tz(i,r).format("MMMM DD, YYYY H:mm z")}else u.itemError=!0}).finally(function(){n.lookupForm.$submitting=!1}))},u.submitPurchase=function(){(u.showChargeFailed=!1,n.form.$invalid)||(n.form.$setPristine(!0),n.form.$submitting=!0,i.submitPurchase(n.FormData).then(function(n){n?(u.purchaseSuccess=!0,t.scrollTo(0,0)):u.showChargeFailed=!0}).finally(function(){n.form.$submitting=!1}))}}]),angular.module("CCG.Shared").factory("expertReviewService",["webServiceFactory",function(n){return n.create({lookupItem:function(n){return this.get("/expert-review-ebay/data/lookup/"+n+"/")},submitPurchase:function(n){return this.post("/expert-review-ebay/submit/",n)}})}]),angular.module("CCG.Shared").filter("creditcard",[function(){return function(n){var t=n||"";return t.length===0?t:(t=t.replace(/[^0-9]/g,""),t=t[0]=="3"?t.replace(/(\d{4})(\d{0,6})(\d{0,5})(?:.*)/,"$1 $2 $3"):t.replace(/(\d{4})(\d{0,4})(\d{0,4})(\d{0,4})(?:.*)/,"$1 $2 $3 $4"),t.trim())}}]),angular.module("CCG.Shared").filter("localize",["translationDictionary",function(n){function t(n,t){return n.replace(/{(\d+)}/g,function(n,i){return typeof t[i]!="undefined"?t[i]:n})}return function(i,r){var u=_.get(n,i);return u&&r&&(u=t(u,r)),u||(u="[["+text+"]]"),u}}]),angular.module("CCG.Shared").filter("truncate",[function(){return function(n,t,i){return n=n||"",i=i||"...",t=parseInt(t)||n.length,n.length<=t?n:n.substring(0,t)+i}}]),angular.module("CCG.Shared").filter("trustedHtml",["$sce",function(n){return function(t){return n.trustAsHtml(t)}}]),angular.module("CCG.Shared").filter("usCurrency",["$filter","urlService",function(n,t){return function(i){return _.isNil(i)?"":n("currency")(i,t.tld=="com"?"$":"US $")}}]),angular.module("CCG.Shared").controller("galleryController",["$element","$attrs","$q","$scope","galleryService","urlService",function(n,t,i,r,u,f){function o(){var n=(new URI).search(!0);_.isEmpty(n)||(e.filters=n,i.all([u.fetchItems(e.galleryID,e.filters),u.getFilterLists(e.galleryID,e.filters),]).then(function(n){n[0].Items.forEach(function(n){n.url=f.baseUrl+n.CoinGalleryItemID+"/"}),e.dropdownFilters=_.filter(n[1],{IsCheckbox:!1}),e.gallery=n[0],e.loaded=!0}))}var e=this;e.galleryID=t.galleryId,e.filters=(new URI).search(!0),e.filterLists=[],e.loaded=!1,i.all([u.getGallery(e.galleryID),u.getFilterLists(e.galleryID,e.filters)]).then(function(n){e.showAltImages=n[0].ShowAltImages,e.imageLabel=n[0].ImageLabel,e.altImageLabel=n[0].AltImageLabel,e.dropdownFilters=_.filter(n[1],{IsCheckbox:!1}),e.checkboxFilters=_.filter(n[1],{IsCheckbox:!0}),e.checkboxFilters.forEach(function(n){n.yesValue=_.find(n.Options,{Name:"Yes"}).CoinGalleryFilterOptionID})}),e.resetFilters=function(){e.filters={};for(var n=1;n<e.dropdownFilters.length;n++)e.dropdownFilters[n].Options=[];e.refreshGallery()},e.changeFilter=function(n){for(var t=n+1;t<e.dropdownFilters.length;t++)delete e.filters[e.dropdownFilters[t].Name];e.refreshGallery()},e.refreshGallery=function(){e.changePage(1)},e.changePage=function(n){e.filters.page=(n||"1").toString(),f.replaceUrl(f.baseUrl,e.filters)},r.$on("$locationChangeSuccess",o),e.filters.page=e.filters.page||"1",f.replaceUrl(f.baseUrl,e.filters)}]),angular.module("CCG.Shared").factory("graderNotesService",["webServiceFactory",function(n){return n.create({fetchGraderNotes:function(n){return this.get("/certlookup/data/"+n+"/grader-notes/")}})}]),angular.module("CCG.Shared").directive("graderNotes",function(){return{scope:{certNum:"@"},transclude:!0,controllerAs:"$ctrl",controller:["$scope","$rootScope","$element","$transclude","graderNotesService",function(n,t,i,r,u){var f=this;r(n,function(n){i.append(n)}),f.userOwnsNotes=!1,f.getGraderNotes=function(t){f.loaded=!1,t?(f.graderNotes=t,f.loaded=!0):u.fetchGraderNotes(n.certNum).then(function(n){!!n&&n.Success?f.graderNotes=n.GraderNotes:n.RequireLogin&&(f.requireLogin=!0),f.loaded=!0}).catch(function(){f.error=!0,f.loaded=!0})},t.$on("grader-notes-payment-successful",function(n,t){f.getGraderNotes(t.graderNotes)})}],link:function(n,t,i,r){r.getGraderNotes(null);var u=(new URI).search(!0),f=u.graderNotes;f&&n.$broadcast("payments.openModal",{modalName:"PurchaseGraderNotes"})}}}),angular.module("CCG.Shared").directive("affiliateCodeValidator",["$q","joinService",function(n,t){return{require:"ngModel",link:function(i,r,u,f){f.$asyncValidators.affiliateCode=function(i){return i?t.validateAffiliateCode(i).then(function(t){return t?n.resolve(!0):n.reject()}):n.resolve()}}}}]),angular.module("CCG.Shared").controller("autorenewController",["$scope","$window","$timeout","joinService",function(n,t,i,r){n=angular.extend(n,t.bootstrap),n.cache={CardNumber:n.FormData.CreditCard.CardNumber,AutorenewAccount:n.FormData.AutorenewAccount},n.modal={showAutorenewDetails:!1,showAutorenewEnabled:!1,showAutorenewDisabled:!1,showConfirmDisableAutorenew:!1},n.events={processAutorenew:function(){if(!n.form.$invalid){n.form.$submitting=!0,n.events.clearResults();var t=r.processAutorenew(n.FormData).then(function(t){t.Success?(n.HasSavedCard=t.Autorenew===!0,n.CardNumber=t.CardNumber,n.CardExpiration=t.CardExpiration,n.modal.showAutorenewEnabled=t.Autorenew===!0,n.modal.showAutorenewDisabled=t.Autorenew===!1,n.FormData.CreditCard=undefined,n.ShowChangeCard=!1):(n.HasSavedCard=!1,n.showFailure=!0)},function(){n.showFailure=!0});t["finally"](function(){n.form.$submitting=!1,n.form.reset(),n.modal.showConfirmDisableAutorenew=!1,n.cache.AutorenewAccount=n.FormData.AutorenewAccount})}},confirmDisableAutorenew:function(t){n.FormData.AutorenewAccount=!1,n.events.processAutorenew(t)},clearResults:function(){n.modal.showAutorenewEnabled=!1,n.modal.showAutorenewDisabled=!1,n.showFailure=!1},changeCard:function(){n.ShowChangeCard=!0}},n.$watch("FormData.AutorenewAccount",function(t,r){t||!n.cache.AutorenewAccount||n.modal.showConfirmDisableAutorenew||(n.FormData.AutorenewAccount=!0,t!=r&&(n.modal.showConfirmDisableAutorenew=!0)),t!=r&&i(function(){t==!0?n.FormData.CreditCard.CardNumber=n.cache.CardNumber:n.cache.CardNumber=n.FormData.CreditCard.CardNumber},0)})}]),angular.module("CCG.Shared").controller("autorenewErrorController",["$window","joinService",function(n,t){var i=this;i.showConfirmAutorenewRemovalModal=!1,i.cancelAutorenew=function(){t.cancelAutorenew().then(function(t){t?n.location.href="/":i.cancelAutorenewFailed=!0})}}]),angular.module("CCG.Shared").controller("billingController",["$scope","$window","joinService",function(n,t,i){angular.extend(n,t.bootstrap),n.events={clearErrors:function(){n.showChargeFailed=!1,n.invalidCode=!1},applyDiscount:function(){var t=n.discountCode,r,u;if(!t){n.invalidCode=!1,n.discountForm.DiscountCode.$setValidity("discountCode",!0);return}r=n.model.tier,u=n.model.mode,i.fetchDiscount(r,u,t).then(function(i){i?(n.discountPrice=n.price-i.Rate,n.currentDiscount='("'+t+'" discount applied)',n.FormData.DiscountCode=t,n.discountCode=null,n.nonEmptyCode=!1,n.invalidCode=!1,n.discountForm.DiscountCode.$setValidity("discountCode",!0)):(n.FormData.DiscountCode=null,n.invalidCode=!0,n.discountForm.DiscountCode.$setValidity("discountCode",!1))})},discountCodeChanged:function(){n.nonEmptyCode=n.discountCode===""||n===null?!1:!0,n.discountForm.DiscountCode.$setValidity("discountCode",!0),n.discountFailedSubmit=!1,n.invalidCode=!1},processBilling:function(){if(n.events.clearErrors(),n.form.$invalid||n.invalidCode||n.nonEmptyCode){n.failedSubmit=!0,(n.invalidCode||n.nonEmptyCode)&&(n.discountFailedSubmit=!0);return}n.form.$setPristine(!0),n.form.$submitting=!0;var r=i.processBilling(n.FormData).then(function(i){i.Success&&i.AutorenewSuccess?t.location.href=i.RedirectUrl:i.Success&&!i.AutorenewSuccess?(n.showAutorenewFailed=!0,n.autorenewFailedRedirectUrl=i.RedirectUrl):i.BillingSuccess&&!i.AccountSaveSuccess?(n.showCardChargedFailed=!0,n.cardChargedRedirectUrl=i.RedirectUrl):(n.showChargeFailed=!0,n.form.$submitting=!1)},function(){n.showChargeFailed=!0,n.showCardChargedFailed=!1,n.form.$submitting=!1})},redirect:function(n){t.location.href=n},copyBillingToShipping:function(){n.FormData.IsAddressSync&&(n.FormData.ShippingAddress.Address1=n.FormData.CreditCard.StreetAddress1,n.FormData.ShippingAddress.Address2=n.FormData.CreditCard.StreetAddress2,n.FormData.ShippingAddress.City=n.FormData.CreditCard.City,n.FormData.ShippingAddress.ZipCode=n.FormData.CreditCard.ZipCode,n.$broadcast("billingForm.syncAddresses"))}},n.$on("billingForm.addressFieldChanged",function(){n.FormData.IsAddressSync=!1})}]),angular.module("CCG.Shared").controller("createAccountController",["$scope","joinService",function(n,t){n=angular.extend(n,window.bootstrap),n.events={createAccount:function(){function i(){n.showErrorMessage=!0}if(n.showErrorMessage=!1,!n.form.$invalid){CCG.showRecaptcha&&(n.FormData["g-recaptcha-response"]=grecaptcha.getResponse(n.recaptchaWidgetId)),n.form.$submitting=!0;var r=t.createAccount(n.FormData).then(function(t){t.RedirectUrl?(n.redirectUrl=t.RedirectUrl,n.FormData.TierName=="free"?n.events.redirect():n.events.displayModal(!0)):i()},i);r["finally"](function(){n.form.$submitting=!1})}},displayModal:function(t){n.showModal=t},redirect:function(){window.location.href=n.redirectUrl}},n.$on("recaptcha.ready",function(){angular.element("#create_account_captcha").length&&(n.recaptchaWidgetId=grecaptcha.render("create_account_captcha",{sitekey:CCG.recaptchaSiteKey}))})}]),angular.module("CCG.Shared").controller("creditCardController",["$scope","countryStateService",function(n,t){function u(){var t=_.head(_.filter(n.CreditCardCountryList,{CountryCode:n.FormData.CreditCard.Country}));i.ZipCodeRegex=new RegExp(t?t.ZipCodeRegex:/.*/),i.RequireZipCode=t?t.ZipCodeRegex:!1,n.$parent.form.CardZipCode.$setViewValue(n.$parent.form.CardZipCode.$viewValue)}var i=this,r=!1;t.fetchCountries().then(function(t){n.CreditCardCountryList=t}),n.$watch("FormData.CreditCard.Country",function(f){u(),i.changeAddressField(),f&&t.fetchStatesForCountryByCountryCode(f).then(function(t){n.CreditCardStateList=t,r&&(n.FormData.CreditCard.State=""),r=!0})}),this.changeAddressField=function(){n.$emit("billingForm.addressFieldChanged")},$(document).ready(function(){u()})}]),angular.module("CCG.Shared").factory("joinService",["webServiceFactory",function(n){return n.create({createAccount:function(n){return this.post("resources/services/join/create-account/",n)},createShowJoinAccount:function(n){return this.post("resources/services/join/create-show-join-account/",n)},updateShowAccount:function(n){return this.post("resources/services/join/update-show-join-account/",n)},processBilling:function(n){return this.post("resources/services/join/billing/",n)},processAutorenew:function(n){return this.post("account/autorenew/",n)},cancelAutorenew:function(){return this.get("resources/services/join/autorenew/cancel/")},fetchDiscount:function(n,t,i){return this.get("resources/services/join/discount/"+n+"/"+t+"/"+i+"/")},validateAffiliateCode:function(n){return this.get("resources/services/join/affiliate-code/validate/"+n+"/")}})}]),angular.module("CCG.Shared").controller("shippingInfoController",["$scope","countryStateService",function(n,t){function r(){var t=_.head(_.filter(n.CountryList,{Name:n.FormData.ShippingAddress.Country}));i.ZipCodeRegex=new RegExp(t?t.ZipCodeRegex:/.*/),i.RequireZipCode=t?t.ZipCodeRegex:!1,n.$parent.form.ZipCode.$setViewValue(n.$parent.form.ZipCode.$viewValue)}var i=this;this.changeCountry=function(u,f){r(),f||i.changeAddressField(),t.fetchStatesForCountryByName(n.FormData.ShippingAddress.Country).then(function(t){n.StateList=t,n.FormData.ShippingAddress.State=u})},this.changeAddressField=function(){n.$emit("billingForm.addressFieldChanged")},$(document).ready(function(){r()}),n.$on("billingForm.syncAddresses",function(){var t=_.find(n.CountryList,["Code",n.FormData.CreditCard.Country]);n.FormData.ShippingAddress.Country=t?t.Name:"",i.changeCountry(n.FormData.CreditCard.State,!0)})}]),angular.module("CCG.Shared").directive("enewsSubscribe",function(){return{scope:{value:"@"},transclude:!0,controllerAs:"$ctrl",controller:["$scope","$element","$window","$transclude","newsService",function(n,t,i,r,u){var f=this;r(n,function(n){t.append(n)}),f.subscribeToENews=function(){f.enabled=!1,u.enewsSubscribe().then(function(n){n.Success?(f.isSubscribed=!0,f.newsletterName=n.NewsletterName,f.hasResults=!0):n.Redirect?i.location=n.Redirect:(f.enabled=!0,f.isSubscribed=!1,f.error=!0,f.hasResults=!0)},function(){f.hasResults=!0,f.isSubscribed=!1,f.error=!0,f.enabled=!0})},u.isEnewsSubscribed().then(function(n){f.display=n.display,f.isSubscribed=n.isSubscribed},function(){f.display=!1})}]}}),angular.module("CCG.Shared").controller("newsListingCtrl",["$window","newsService","urlService",function(n,t,i){function e(){var n="/news/";return r.filters.filter&&r.filters.filter!=="all"&&(n+="series/"+r.filters.filter+"/"),r.filters.page&&(n+="?page="+r.filters.page),n}var r=this,u,f;r.filters={},u=new URI,f=u.search(!0),r.filters.page=parseInt(f.page)||1,r.filters.filter=u.segment(-3)==="series"?u.segment(-2):"all",r.changeFilter=function(){r.filters.page=1,r.loadArticles();var n=e();i.replaceUrl(n)},r.refresh=function(n){r.filters.page=n||1,r.loadArticles();var t=e();i.replaceUrl(t)},r.loadArticles=function(){t.fetchArticles(r.filters).then(function(n){r.articles=n})},r.loadArticles()}]),angular.module("CCG.Shared").factory("newsService",["webServiceFactory",function(n){return n.create({fetchArticles:function(n){var t="/news/data/";return n.filter&&n.filter!=="all"&&(t+="series/"+n.filter+"/"),n.page&&(t+="?page="+n.page),this.get(t)},isEnewsSubscribed:function(){return this.get("/news/subscribe-to-enews/")},enewsSubscribe:function(){return this.post("/news/subscribe-to-enews/")}})}]),angular.module("CCG.Shared").directive("ccgModelOverride",function(){return{priority:-1,restrict:"A",require:"ngModel",compile:function(n,t){var i=n.val()||n.text();return i===t.placeholder&&(i=undefined),{pre:function(n,t,r,u){var f=n.$eval(r.ngModel);f!==undefined?u.$setViewValue(f):i!==undefined&&u.$setViewValue(i),u.$setPristine(!0)}}}}}),angular.module("CCG.Shared").controller("payController",["$scope","$window","$timeout","payService","saferpayService",function(n,t,i,r,u){function h(){for(var t=0;t<n.FormData.PaymentReferenceNumbers.length;t++)f.validateInvoice(t,!0)}function c(){return(f.showChargeFailed=!1,n.form.$invalid)?!1:!0}function s(t){n.form.$submitting=!0,t.then(function(n){switch(CCG.tld){case"uk":a(n);break;case"de":v(n);break;default:y(n)}}).catch(function(){f.showChargeFailed=!0,n.form.$submitting=!1})}function a(t){if(t.Success)n.onSuccess(t);else if(t.CardinalContinue){var i=f.createOrderObject();i.TransactionId=t.TransactionId,Cardinal.continue("cca",{AcsUrl:t.AcsURL,Payload:t.JWTPayload},{OrderDetails:i})}else f.showChargeFailed=!0,n.form.$submitting=!1,o()}function v(i){if(i.Success)n.onSuccess(i);else i.Redirect?i.Redirect.UseFancybox?n.$broadcast("payments.fancybox.open",{url:i.Redirect.URL}):t.location=i.Redirect.URL:(f.showChargeFailed=!0,n.form.$submitting=!1,u.init(n))}function y(i){if(i.Redirect)t.location=i.Redirect.URL;else if(i.Success)n.onSuccess(i);else f.showChargeFailed=!0,n.form.$submitting=!1}function o(){n.FormData.CreditCard.CardNumber="",r.generateToken().then(function(t){Cardinal.setup("init",{jwt:t.token}),n.FormData.CCGTransactionID=t.orderNumber})}function p(t,r){i(function(){n.modal[r.modalName]=!0},1e3)}var f=this,e={},l=[1003,1010,1020];if(f.paySuccess=!1,f.showChargeFailed=!1,f.validatingInvoiceInput={},f.invoiceValidated={},n.FormData={PaymentReferenceNumbers:[""],PaymentReferenceType:"Submission Number",CreditCard:{ExpirationMonth:"",ExpirationYear:""}},f.clearPaymentInfoFields=function(){n.FormData.Email="",n.FormData.ConfirmEmail="",n.FormData.FirstName="",n.FormData.LastName="",n.FormData.CreditCard.Country="",n.FormData.CreditCard.CardNumber="",n.FormData.CreditCard.ExpirationMonth="",n.FormData.CreditCard.ExpirationYear="",n.FormData.CreditCard.CVV="",n.FormData.CreditCard.Country="",n.FormData.CreditCard.StreetAddress1="",n.FormData.CreditCard.StreetAddress2="",n.FormData.CreditCard.City="",n.FormData.CreditCard.State="",n.FormData.CreditCard.ZipCode=""},f.changePaymentType=function(){CCG.tld!=="de"||n.FormData.PeoplePaymentProfileID||u.init(n)},r.fetchPeoplePaymentProfiles().then(function(n){f.paymentProfiles=n}),f.deleteRow=function(t){f.currentDeleteIdx=t,n.FormData.PaymentReferenceNumbers[t]===""?f.confirmDelete():f.showDeleteConfirm=!0},f.confirmDelete=function(){n.FormData.PaymentReferenceNumbers.splice(f.currentDeleteIdx,1),f.showDeleteConfirm=!1,h()},f.validateInvoice=function(t,i){var u=n.FormData.PaymentReferenceNumbers[t],o;if((f.invoiceValidated[t]=null,n.form&&n.form["PaymentReferenceNumber"+t])&&(n.form["PaymentReferenceNumber"+t].$setValidity("duplicate",!0),u))if(o=_.some(n.FormData.PaymentReferenceNumbers,function(n,i){return n===u&&i!==t}),o)n.form["PaymentReferenceNumber"+t].$setValidity("duplicate",!1);else if(n.FormData.PaymentReferenceType!=="Online Order Number"){if(i&&e[u]!==undefined){f.invoiceValidated[t]=e[u];return}f.validatingInvoiceInput[t]=!0,r.validateInvoice(u).then(function(n){f.invoiceValidated[t]=n,e[u]=n}).catch(function(){f.invoiceValidated[t]=!1,e[u]=!1}).finally(function(){f.validatingInvoiceInput[t]=!1})}},f.resetPaymentModal=function(){f.paymentProcessed=!1,f.showChargeFailed=!1},f.submitGraderNotes=function(){c()&&(n.onSuccess=function(t){f.paymentProcessed=!0,f.paymentSuccessful=t.Success,t.Success&&n.$emit("grader-notes-payment-successful",{graderNotes:t.GraderNotes})},s(r.submitGraderNotesPurchase(n.FormData)))},f.submitInvoice=function(){c()&&(n.onSuccess=function(n){t.location="/pay/result/?requestID="+n.TransactionId},CCG.tld!=="de"||n.FormData.PeoplePaymentProfileID?s(r.submitInvoice(n.FormData)):u.submit(function(t){n.FormData.SaferpayToken=t.token,s(r.submitInvoice(n.FormData))},function(){f.showChargeFailed=!0,n.form.$submitting=!1}))},CCG.tld==="uk"){Cardinal.on("payments.setupComplete",function(t){n.FormData.DFReferenceID=t.sessionId});Cardinal.on("payments.validated",function(t,i){t.ErrorNumber&&_.includes(l,t.ErrorNumber)||r.handleCCAResponse(i,n.FormData).then(function(t){if(t.Success)n.onSuccess(t);else f.showChargeFailed=!0,n.form.$submitting=!1,o()}).catch(function(){f.showChargeFailed=!0,n.form.$submitting=!1,o()})});o()}else CCG.tld==="de"&&u.init(n);f.createOrderObject=function(){var t=n.FormData.CreditCard.CardNumber;return t=t.replace(/\s+/g,""),t=Number(t),{Consumer:{Email1:n.FormData.Email,ShippingAddress:{FirstName:n.FormData.FirstName,LastName:n.FormData.LastName,Address1:n.FormData.CreditCard.StreetAddress1,Address2:n.FormData.CreditCard.StreetAddress2,City:n.FormData.CreditCard.City,State:n.FormData.CreditCard.City,PostalCode:n.FormData.CreditCard.ZipCode,CountryCode:n.FormData.CreditCard.Country},BillingAddress:{FirstName:n.FormData.FirstName,LastName:n.FormData.LastName,Address1:n.FormData.CreditCard.StreetAddress1,Address2:n.FormData.CreditCard.StreetAddress2,City:n.FormData.CreditCard.City,State:n.FormData.CreditCard.State,PostalCode:n.FormData.CreditCard.ZipCode,CountryCode:n.FormData.CreditCard.Country},Account:{AccountNumber:t,ExpirationMonth:Number(n.FormData.CreditCard.ExpirationMonth),ExpirationYear:Number(n.FormData.CreditCard.ExpirationYear),CardCode:Number(n.FormData.CreditCard.CVV)}},Options:{EnableCCA:!0},OrderDetails:{OrderNumber:n.FormData.PaymentReferenceNumbers.join(","),Amount:parseInt(Number(n.FormData.PaymentAmount)*100),CurrencyCode:"GBP",OrderChannel:"S"}}},n.$on("payments.openModal",p),n.$watch("FormData.PaymentReferenceType",h)}]),angular.module("CCG.Shared").factory("payService",["webServiceFactory",function(n){return n.create({fetchPeoplePaymentProfiles:function(){return this.get("/pay/api/profiles/")},submitInvoice:function(n){return this.post("/pay/api/submit/",n)},submitGraderNotesPurchase:function(n){return this.post("/pay/api/purchase-grader-notes/",n)},validateInvoice:function(n){return this.post("/pay/api/validate-invoice",{invoiceNumber:n})},generateToken:function(){return this.get("/pay/api/generate-token")},getPaymentStatus:function(n){return this.get("/pay/api/result/"+n+"/")},handleCCAResponse:function(n,t){return this.post("/pay/api/handle-cca-response",{jwt:n,form:t})},getPaymentProcessorInfo:function(){return this.get("/pay/api/payment-processor-info/")}})}]),angular.module("CCG.Shared").directive("paymentFancybox",[function(){return{link:function(n){n.$on("payments.fancybox.open",function(n,t){$.fancybox.open({src:t.url,type:"iframe",opts:{modal:!0}})})}}}]),angular.module("CCG.Shared").directive("paymentRedirectForm",["urlService","$timeout",function(n,t){return{scope:{redirect:"="},templateUrl:n.root+"resources/ccg-shared/scripts/ccg.shared/pay/payment-redirect-form.html",link:function(n){n.redirect&&t(function(){$("#paymentRedirectForm").submit()})}}}]),angular.module("CCG.Shared").directive("ccgPaymentResult",function(){return{scope:{transactionId:"@"},transclude:!0,controllerAs:"$ctrl",controller:["$scope","$element","$transclude","$window","payService",function(n,t,i,r,u){var f=this;f.loading=!0,r.self===r.top?(f.success=!1,f.error=!1,f.payResult=null,i(n,function(n){t.append(n)}),u.getPaymentStatus(n.transactionId).then(function(n){f.loading=!1,n.Success?(f.success=!0,f.payResult=n):f.error=!0})):top.location=self.location}]}}),angular.module("CCG.Shared").factory("saferpayService",["payService","rollbarService","translationDictionary",function(n,t,i){function f(){}function u(n){t.sendError(n,"Saferpay Service - Initialization Failure")}function e(){var t=angular.element(document).find("div.saferpay-css"),n=t.find(".saferpay-focus-color").html();return{".input-large":"font-size: 18.4px; padding: 8px; margin: 2px; -webkit-transition: box-shadow 300ms ease; transition: box-shadow 300ms ease; border-radius: 6px; height: 40px !important; border: 1px solid #c1c1c1; color: #333333; outline: none; width: calc(100% - 4px);",".input-large:focus":"box-shadow: 0 0 5px "+n+";",".input-group":"height: 50px !important;",".input-small":"font-size: 18.4px; padding: 8px; margin: 2px; -webkit-transition: box-shadow 300ms ease; transition: box-shadow 300ms ease; border-radius: 6px; height: 40px !important; border: 1px solid #c1c1c1; color: #333333; outline: none; width: 98% !important;",".input-small:focus":"box-shadow: 0 0 5px "+n+";",".input-large.is-invalid":"border: 1px solid #bf4040;",".input-small.is-invalid":"border: 1px solid #bf4040;",".expiration":"height: 50px; width: 100%;",".cvc":"height: 50px; width: 100%;",".input-large.is-invalid:focus":"box-shadow: 0 0 5px #bf4040;",".input-small.is-invalid:focus":"box-shadow: 0 0 5px #bf4040;"}}var r={};return r.init=function(t){n.getPaymentProcessorInfo().then(function(n){SaferpayFields.init({apiKey:n.ApiKey,url:n.Url,style:e(),paymentMethods:["visa","mastercard"],onValidated:function(n){var i=n.id.replace(/\-/g,"_");n.isValid?t.form[i].$setValidity("required",!0):t.form[i].$setValidity("required",!1),t.form[i].$setTouched(),t.$apply()},onSuccess:f,onError:u,placeholders:{holdername:i.Forms.Name,cardnumber:"0000 0000 0000 0000",expiration:"MM/YY",cvc:"CVV"}})},u)},r.submit=function(n,t){SaferpayFields.submit({onSuccess:n,onError:t})},r}]),angular.module("CCG.Shared").factory("countdownClockService",["webServiceFactory",function(n){return n.create({getCountdownTimer:function(n){return this.get("resources/services/countdown-clock/"+n+"/")}})}]),angular.module("CCG.Shared").factory("countryStateService",["$q","webServiceFactory",function(n,t){return t.create({fetchCountries:function(){return this.get("/resources/services/country/")},fetchStatesForCountryByName:function(t){return t?this.get("/resources/services/country/name/"+t.trim()+"/states/"):n.when([])},fetchStatesForCountryByCountryCode:function(t){return t?this.get("/resources/services/country/code/"+t.trim()+"/states/"):n.when([])},fetchStatesForCountryByID:function(n){return this.get("/resources/services/country/id/"+n+"/states/")}})}]),angular.module("CCG.Shared").factory("galleryService",["$sce","webServiceFactory",function(n,t){return t.create({getGallery:function(n){return this.get("/resources/services/gallery/"+n+"/")},fetchItems:function(t,i){return this.get("/resources/services/gallery/"+t+"/images/",i).then(function(t){return _.forEach(t.Items,function(t){t.Grade=(t.Grade||"").replace(/(\d)\+/g,"$1<i class='plus-grade'><\/i>").replace(/(\d)\*/g,"$1<i class='star-grade'><\/i>");var i=[t.Name,t.Grade];_.remove(i,_.isEmpty),t.Caption=i.join(", "),t.Text2=n.trustAsHtml(t.Text2)}),t})},getFilterLists:function(n,t){return this.get("/resources/services/gallery/"+n+"/filters/",t)}})}]),angular.module("CCG.Shared").controller("servicesFeesController",["$scope",function(n){var i=this,t=(new URI).search(!0);t.view==="posters"&&(t.view="concertposters"),i.selectedView=t.view||"all",n.$on("ccgViewSwitch.viewSwitched",function(n,t){i.selectedView=t})}]),angular.module("CCG.Shared").factory("batchRequestService",["$http",function(n){function f(){if(t.length!==0&&i!==u){var f=$(t.map(function(n){return n.element[0]})),e=f.filter(":visible").slice(0,u-i),o=_.remove(t,function(n){return e.index(n.element)>=0});o.forEach(function(t){i++,n[t.method.toLowerCase()](t.url).then(function(n){i--,t.callback(n.data),i==0&&r()})}),t.length>0&&r()}}var t=[],r=_.debounce(f,300),u=4,i=0;return{load:r,register:function(n,i,u,f){t.push({element:n,url:i,method:u,callback:f}),r()}}}]),angular.module("CCG.Shared").factory("dndBulkMoveService",[function(){var n={};return n.deselectAll=function(n){angular.forEach(n,function(n){n.selected=!1})},n.onDrop=function(t,i,r,u){return n.deselectAll(r),Array.prototype.splice.apply(i,[u,0].concat(r)),_.remove(i,function(n){return n.selected}),t.dragging=!1,!0},n.getSelectedItemsIncluding=function(n,t){return t.selected=!0,n.filter(function(n){return n.selected})},n.onDragStart=function(n,t){if(n.dragging=!0,t.dataTransfer.setDragImage){var i=new Image;i.src=CCG.rootUrl+"Resources/ccg-shared/images/template/stack_2x.png",t.dataTransfer.setDragImage(i,0,0)}},n.onSelected=function(n,t){t&&t.target.getAttribute("dnd-ignore-click")||(n.selected=!n.selected)},n.onDragEnd=function(n){n.dragging=!1},n.onCanceled=function(t){n.deselectAll(t)},n}]),angular.module("CCG.Shared").factory("DOMPosition",["$rootScope",function(n){function t(n){var i=$(n),r;i.length!==0&&(r=$.isWindow(n)?{top:i.scrollTop(),left:i.scrollLeft()}:i.offset(),this.minX=r.left,this.maxX=r.left+i.width(),this.minY=r.top,this.maxY=r.top+i.height(),this.loadedTime=t.refreshTime,i.data("DOMPosition",this))}t.prototype.contains=function(n,i){var r=t.getPosition(n),u=this.minX,f=this.maxX,e=this.minY,o=this.maxY,s,h;return i&&(i.x&&(u+=i.x,f+=i.x),i.y&&(e+=i.y,o+=i.y)),s=u<=r.minX&&r.minX<=f||u<=r.maxX&&r.maxX<=f,h=e<=r.minY&&r.minY<=o||e<=r.maxY&&r.maxY<=o,s&&h},t.prototype.fullyContains=function(n){var i=t.getPosition(n),r=this.minX<=i.minX&&i.maxX<=this.maxX,u=this.minY<=i.minY&&i.maxY<=this.maxY;return r&&u},t.prototype.partiallyContains=function(n,i){i=Math.min(Math.max(i,0),1);var r=t.getPosition(n),u=r.maxY-r.minY,f=u*i+r.minY;return this.maxY>f},t.refreshTime=Date.now(),t.needsRefresh=_.throttle(function(){t.refreshTime=Date.now()},150),t.getPosition=function(n){var r=$(n),i;if(r.length!==0)return i=r.data("DOMPosition"),i&&i.loadedTime===t.refreshTime||(i=new t(n),r.data("DOMPosition",i)),i},n.$on("DOMPosition.needsRefresh",t.needsRefresh),n.$on("ccgViewSwitch.viewSwitched",t.needsRefresh);$(window).on("resize",t.needsRefresh);return t}]),angular.module("CCG.Shared").factory("domService",["$window","$timeout",function(n,t){var i=angular.element(n.document.body);return{isTouch:Modernizr.touch,isXSmall:Modernizr.mq.bind(null,"(max-width: 400px)"),isSmall:Modernizr.mq.bind(null,"(min-width: 401px) and (max-width: 720px)"),isMedium:Modernizr.mq.bind(null,"(min-width: 721px) and (max-width: 1023px)"),isStandard:Modernizr.mq.bind(null,"(min-width: 1024px) and (max-width: 1365px)"),isLarge:Modernizr.mq.bind(null,"(min-width: 1366px) and (max-width: 1679px)"),isXLarge:Modernizr.mq.bind(null,"(min-width: 1680px)"),isMobile:navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/),isTabletUp:Modernizr.mq.bind(null,"(min-width: 501px)"),isDesktop:Modernizr.mq.bind(null,"(min-width: 720px)"),supportsFileReader:Modernizr.filereader,hasScroll:function(n){return n[0].scrollHeight>n[0].clientHeight},canScroll:function(n){var i=n[0].scrollHeight,t=n[0].clientHeight,r=n.scrollTop(),u=r+t>=i-5;return!u&&t!==0},storePositionedElement:function(n,t){var i=$("#"+n);i.length||(i=$("<div>").attr("id",n).prependTo("body")),i.append(t)},repositionTo:function(i,r,u){var f=r.offset(),e=r.outerHeight();t(function(){var t=-(2*u.yBuffer-e/2),o=f.top+t,r;u.useReverse&&(r=f.top>n.pageYOffset+n.innerHeight/2,r&&(t=-(e/2)-2*u.yBuffer,o=f.top-(i.outerHeight()+t)),i.find(".ebay-popover").toggleClass("reversed",r)),i.css({position:"absolute",left:u.useFixedX?u.xOffset:u.xOffset+f.left-u.yBuffer,top:o,visibility:"visible"})},0)}}}]),angular.module("CCG.Shared").factory("EventWatcher",[function(){function n(n,t,i){this.$element=angular.element(n),this.events=t,this.valueHandler=i,this.value=this.valueHandler.call(this.$element),this.handlers=[],this.isListening=!1,this.lastValue=null}return n.prototype.addHandler=function(n,t){this.isListening||this.startListening(),this.handlers.push(_.throttle(n,t||150))},n.prototype.startListening=function(){if(!this.isListening){this.$element.on(this.events,this.listener.bind(this));this.isListening=!0}},n.prototype.stopListening=function(){this.isListening&&this.$element.off(this.events,this.listener)},n.prototype.listener=function(n){(this.lastValue=this.value,this.value=this.valueHandler.call(this.$element),_.isEqual(this.lastValue,this.value))||this.handlers.forEach(function(t){t(n,this.value)}.bind(this))},n.prototype.refresh=function(){this.value=this.valueHandler.call(this.$element)},n}]),angular.module("CCG.Shared").directive("ccgIframeBuster",function(){return{controller:["$window",function(n){n.self!==n.top&&(n.top.location=n.self.location)}]}}),angular.module("CCG.Shared").constant("keycodes",{F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,_1:49,_2:50,_3:51,_4:52,_5:53,_6:54,_7:55,_8:56,_9:57,_0:48,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,ESCAPE:27,TILDE:192,MINUS:189,EQUALS:187,BACKSPACE:8,TAB:9,LEFT_BRACKET:219,RIGHT_BRACKET:221,BACK_SLASH:220,CAPS_LOCK:20,SEMI_COLON:186,QUOTE:222,ENTER:13,SHIFT:16,COMMA:188,PERIOD:190,FWD_SLASH:191,CTRL:17,ALT:18,LEFT_CMD:91,RIGHT_CMD:92,INSERT:45,HOME:36,PAGE_UP:33,DELETE:46,END:35,PAGE_DOWN:34,UP:38,LEFT:37,DOWN:40,RIGHT:39,SCROLL_LOCK:145,PAUSE:19,NUM_LOCK:144,NUM_MINUS:109,NUM_STAR:106,NUM_SLASH:111,NUM_7:103,NUM_8:104,NUM_9:105,NUM_PLUS:107,NUM_4:100,NUM_5:101,NUM_6:102,NUM_1:97,NUM_2:98,NUM_3:99,NUM_0:96}),angular.module("CCG.Shared").factory("lazyLoadService",["$rootScope","windowWatcher",function(n,t){function r(){if(i.length!==0){var r=t.size(),n=t.viewport();n.minX-=r.width,n.maxX+=r.width,n.minY-=r.height,n.maxY+=r.height*2,setTimeout(function(){var t=$(i.map(function(n){return n.element[0]})),r=t.filter(":visible"),u=_.remove(i,function(t){return r.index(t.element)>=0&&n.contains(t.element)});f(u)})}}function f(n){n.length!==0&&n.forEach(function(n){n.callback()})}var i=[],u=_.debounce(r,300);t.onResize(r);t.onScroll(r);return n.$on("ccgViewSwitch.viewSwitched",u),{register:function(n,t){i.push({element:n,callback:t}),u()}}}]),angular.module("CCG.Shared").factory("rollbarService",["Rollbar",function(n){return{enable:function(t,i){n.configure({enabled:!0,captureUncaught:!!t,captureUnhandledRejections:!!i})},disable:function(){n.disable()},sendError:function(t,i,r){if(t.status!==404){var u=i;t.xhrStatus==="error"&&(u+=": XHR Error - check ad blockers"),n.enable(),n.error(new Error(u),_.assign({},t,r))}}}}]),angular.module("CCG.Shared").service("scrollService",["$window","windowWatcher",function(n,t){function h(n,t){n&&n.length!==0&&n.forEach(function(n){n.callback(t)})}function l(){var n=t.scroll();h(s,n),c(o,n)}function a(){o=_.filter(u,{noDelay:undefined}),s=_.filter(u,{noDelay:!0})}function v(){f=_.sumBy(r,"offset")||0}var i=this,u=[],o,s,c,f,r,e;i.scrollToElement=function(n,t,r){n&&(r=r||0,window.requestAnimationFrame(function(){var u=$(n).offset().top,f=i.getGlobalOffset();$("html, body").animate({scrollTop:u-f+r},t)}))},i.registerOnScroll=function(n,t,i){u.push({element:n,callback:t,noDelay:i}),a()},i.deregisterOnScroll=function(n){_.remove(u,{element:n}),a()},c=_.throttle(function(n,t){h(n,t)},100),f=0,r=[],i.registerOffsetElement=function(n){_.some(r,{element:n})||(r.push({element:n,offset:n[0].offsetHeight}),v())},i.deregisterOffsetElement=function(n){_.remove(r,{element:n}),v()},i.getGlobalOffset=function(n){return n?_.sumBy(_.reject(r,{element:n}),"offset"):f},e=angular.element(n);e.on("resize scroll mousewheel",l);e.ready(l)}]),angular.module("CCG.Shared").factory("sessionService",["$window",function(n){return{get:function(t){if(t){var i=n.sessionStorage.getItem(t);return i?JSON.parse(i):i}},set:function(t,i){if(t)try{n.sessionStorage.setItem(t,JSON.stringify(i))}catch(r){}}}}]),angular.module("CCG.Shared").factory("storageService",["$window",function(n){return{get:function(t){if(t){var i=n.localStorage[t];return i?JSON.parse(i):i}},set:function(t,i){if(t)try{n.localStorage[t]=JSON.stringify(i)}catch(r){}}}}]),angular.module("CCG.Shared").factory("urlService",["$window","$rootScope",function(n,t){angular.element(n).on("popstate",function(n){n.state&&(n.state.eventKeys&&n.state.eventKeys.length>0&&n.state.eventKeys.forEach(function(n){t.$broadcast(n)}),n.state.callbacks&&n.state.callbacks.length>0&&n.state.callbacks.forEach(function(t){t(n)}),t.$apply())});return{root:CCG.rootUrl,baseUrl:CCG.basePageUrl,culture:CCG.culture,tld:CCG.tld,sharedCookieDomain:[""].concat(_.takeRight(n.location.hostname.split("."),2)).join("."),supportsHtml5History:Modernizr&&Modernizr.history,registrySet:function(n){return this.root+"registry/competitive-sets/"+n+"/"},path:function(){return n.location.pathname},fullPath:function(){return n.location.pathname+n.location.search+n.location.hash},updateUrl:function(t,i){t=this.buildUrl(t,i),n.history.pushState(null,null,t)},replaceUrl:function(t,i,r){t=this.buildUrl(t,i),n.history.replaceState(r,null,t)},updateWithState:function(n,t,i){this.replaceUrl(this.fullPath(),null,i),n&&this.updateUrl(n,t)},buildUrl:function(n,t){if(n.indexOf("http")!==0&&n.indexOf("/")!==0&&(n=this.root+n),t=_.pickBy(t,_.identity),t.length===0)return n;var i=new URI(n);return i.escapeQuerySpace(!1),i.setSearch(t),i.toString()},templateUrl:function(n){return this.buildUrl(n,{lang:this.culture})}}}]),angular.module("CCG.Shared").factory("webServiceFactory",["$http","$q","urlService",function(n,t,i){function r(){}return r.prototype.get=function(n,t,i){return this.callService({method:"GET",url:n,params:t},i)},r.prototype.post=function(n,t,i){return this.httpMethod("POST",n,t,i)},r.prototype.put=function(n,t,i){return this.httpMethod("PUT",n,t,i)},r.prototype["delete"]=function(n,t,i){return this.httpMethod("DELETE",n,t,i)},r.prototype.httpMethod=function(n,t,i,r){return this.callService({method:n,url:t,data:i},r)},r.prototype.callService=function(i,r){var f=t.defer(),u=t.defer();return u.promise.cancel=function(){f.resolve()},i.method=i.method.toUpperCase(),i.url=this.cleanUrl(i.url),i.cache=r||!1,i.timeout=f.promise,n(i).then(function(n){u.resolve(n.data)}).catch(function(n){u.reject(n)}),u.promise},r.prototype.cleanUrl=function(n){n=n||"";var t=n.indexOf("http")!==0;return t?(n.indexOf("~/")===0&&(n=n.replace("~/","")),n.indexOf("/")!==0&&t&&(n=i.root+n),n.match(/.*\/[^.?]*[^\/]$/)&&(n+="/"),n):n},{create:function(n){return angular.extend(new r,n)}}}]),angular.module("CCG.Shared").factory("windowWatcher",["$window","EventWatcher","DOMPosition",function(n,t,i){return{scrollWatcher:new t(n,"scroll",function(){return{top:n.pageYOffset,left:n.pageXOffset}}),resizeWatcher:new t(n,"resize",function(){return{height:this.height(),width:this.width()}}),size:function(){return this.resizeWatcher.value},scroll:function(){return{top:n.pageYOffset,left:n.pageXOffset}},viewport:function(){var r=this.resizeWatcher.value,t=this.scrollWatcher.value,n=new i;return n.minX=t.left,n.maxX=t.left+r.width,n.minY=t.top,n.maxY=t.top+r.height,n},withinViewport:function(n,t){var i=this.viewport();return i.contains(n,t)},fullyWithinViewport:function(n){var t=this.viewport();return t.fullyContains(n)},partiallyWithinViewport:function(n,t){var i=this.viewport();return i.partiallyContains(n,t)},onScroll:function(n,t){this.scrollWatcher.addHandler(n,t)},onResize:function(n,t){this.resizeWatcher.addHandler(n,t)}}}]),angular.module("CCG.Shared").directive("ccgValidateUnique",["validationService",function(n){return{require:"ngModel",link:function(t,i,r,u){function h(){var i,e;if(!u.$pristine&&(!u.$invalid||u.$error.unique)){if(f&&f.cancel(),i=u.$modelValue||"",i.length===0){o(!0);return}return e=t.$eval(r.uniqueException),f=n.validateUnique(c,l,i,e),f.then(function(n){o(n.Success)})}}function o(n){u.$setValidity("unique",n)}var s=r.ccgValidateUnique.split("."),c=s[0],l=s[1],e=i.parents("form:first").controller("form"),f;if(e&&e.registerValidator&&e.registerValidator(h),r.validateOn!==undefined)i.on(r.validateOn,h);i.on("keyup",function(){i.val()!==i.data("last-value")&&(i.data("last-value",i.val()),o(!0),t.$apply())})}}}]),angular.module("CCG.Shared").factory("validationService",["webServiceFactory",function(n){return n.create({validateUnique:function(n,t,i,r){var u=["resources/services/validate",n,t,""].join("/"),f={value:i,exceptionID:r};return this.post(u,f,!1)}})}])