var URL_API_BASE="api/",URL_API=function(n){return URL_API_BASE+n},EVENTS={CATEGORY_LOADED:"CATEGORY_LOADED",PROGRAMME_LOADED:"PROGRAMME_LOADED",REGION_LOADED:"REGION_LOADED",COUNTRY_LOADED:"COUNTRY_LOADED",COUNTRY_CATEGORY_LOADED:"COUNTRY_CATEGORY_LOADED",COUNTRY_PROGRAMME_LOADED:"COUNTRY_PROGRAMME_LOADED"},APP=angular.module("WhoPBPortal",["ngMessages","ui.router","ngAnimate","ngSanitize","sprintf","ngMap","bootstrap-tagsinput"]),DataState,REVIEW_CYCLE,RelationsFilters,RegionFilters;APP.config(["$stateProvider","$urlRouterProvider","$locationProvider","$httpProvider",function(n,t,i,r){i.html5Mode(!0);n.state("404",{url:"/:biennium/404?message",templateUrl:"Views/NotFoundView.html",controller:"notFoundViewController"}).state("404-global",{url:"/404",templateUrl:"Views/NotFoundView.html",controller:"notFoundViewController"}).state("default",{url:"/",templateUrl:"Views/HomeView.html",controller:"homeViewController"}).state("home",{url:"/:biennium/home",templateUrl:"Views/HomeView.html",controller:"homeViewController"}).state("our-work",{url:"/:biennium/our-work",templateUrl:"Views/CategoriesViews/OurWorkView.html",controller:"ourWorkViewController"}).state("category",{url:"/:biennium/our-work/category/:categoryId",templateUrl:"Views/CategoriesViews/CategoryView.html",controller:"categoryViewController"}).state("category.about",{url:"/about",views:{"category-tabs":{templateUrl:"Views/CategoriesViews/CategoryAboutView.html",controller:"categoryAboutViewController"}}}).state("category.about.about",{url:"/about"}).state("category.about.programme-outcomes",{url:"/programme-outcomes"}).state("category.about.key-figures",{url:"/key-figures"}).state("category.about.key-figures-by-level",{url:"/key-figures-by-level"}).state("category.about.key-figures-by-geography",{url:"/key-figures-by-geography"}).state("category.flow",{url:"/flow",views:{"category-tabs":{templateUrl:"Views/CategoriesViews/CategoryFinancialFlowView.html",controller:"categoryFinancialFlowViewController"}}}).state("category.mtr",{url:"/mtr",views:{"category-tabs":{templateUrl:"Views/CategoriesViews/CategoryMidTermReviewView.html",controller:"categoryMidTermReviewViewController"}}}).state("category.eba",{url:"/eba",views:{"category-tabs":{templateUrl:"Views/CategoriesViews/CategoryEndBienniumAssessmentView.html",controller:"categoryEndBienniumAssessmentViewController"}}}).state("programme",{url:"/:biennium/our-work/category/:categoryId/programme/:programmeId",templateUrl:"Views/ProgrammesViews/ProgrammeView.html",controller:"programmeViewController"}).state("programme.about",{url:"/about",views:{"programme-tabs":{templateUrl:"Views/ProgrammesViews/ProgrammeAboutView.html",controller:"programmeAboutViewController"}}}).state("programme.about.about",{url:"/about"}).state("programme.about.results-structure",{url:"/results-structure"}).state("programme.about.key-figures",{url:"/key-figures"}).state("programme.about.key-figures-by-level",{url:"/key-figures-by-level"}).state("programme.about.key-figures-by-geography",{url:"/key-figures-by-geography"}).state("programme.indicators",{url:"/indicators",views:{"programme-tabs":{templateUrl:"Views/ProgrammesViews/ProgrammeIndicatorsView.html",controller:"programmeIndicatorsViewController"}}}).state("programme.flow",{url:"/flow",views:{"programme-tabs":{templateUrl:"Views/ProgrammesViews/ProgrammeFinancialFlowView.html",controller:"programmeFinancialFlowViewController"}}}).state("programme.mtr",{url:"/mtr",views:{"programme-tabs":{templateUrl:"Views/ProgrammesViews/ProgrammeMidTermReviewView.html",controller:"programmeMidTermReviewViewController"}}}).state("programme.eba",{url:"/eba",views:{"programme-tabs":{templateUrl:"Views/ProgrammesViews/ProgrammeEndBienniumAssessmentView.html",controller:"programmeEndBienniumAssessmentViewController"}}}).state("programme.ts",{url:"/ts",views:{"programme-tabs":{templateUrl:"Views/ProgrammesViews/ProgrammeTopStoriesView.html",controller:"programmeTopStoriesViewController"}}}).state("budget-and-financing",{url:"/:biennium/budget-and-financing",controller:"budgetAndFinancingViewController",templateUrl:"Views/BudgetAndFinancingViews/BudgetAndFinancingView.html"}).state("budget-and-financing.gpw-overview",{url:"/gpw-overview",views:{"budget-and-financing-tabs":{templateUrl:"Views/BudgetAndFinancingViews/GPWOverviewView.html",controller:"gpwOverviewViewController"}}}).state("budget-and-financing.summary",{url:"/summary",views:{"budget-and-financing-tabs":{templateUrl:"Views/BudgetAndFinancingViews/BudgetAndFinanceSummaryView.html",controller:"budgetAndFinanceSummaryViewController"}}}).state("budget-and-financing.details",{url:"/details",views:{"budget-and-financing-tabs":{templateUrl:"Views/BudgetAndFinancingViews/BudgetAndFinanceDetailsView.html",controller:"budgetAndFinanceDetailsViewController"}}}).state("budget-and-financing.flow",{url:"/flow",views:{"budget-and-financing-tabs":{templateUrl:"Views/BudgetAndFinancingViews/FinancialFlowView.html",controller:"financialFlowViewController"}}}).state("regions",{url:"/:biennium/regions",templateUrl:"Views/RegionsViews/RegionsView.html",controller:"regionsViewController"}).state("region",{url:"/:biennium/regions/:regionCode",templateUrl:"Views/RegionsViews/RegionView.html",controller:"regionViewController"}).state("region.about",{url:"/about",views:{"region-tabs":{templateUrl:"Views/RegionsViews/RegionAboutView.html",controller:"regionAboutViewController"}}}).state("region.about.about",{url:"/about"}).state("region.about.key-figures",{url:"/key-figures"}).state("region.about.key-figures-by-level",{url:"/key-figures-by-level"}).state("region.about.key-figures-by-geography",{url:"/key-figures-by-geography"}).state("region.flow",{url:"/flow",views:{"region-tabs":{templateUrl:"Views/RegionsViews/RegionFinancialFlowView.html",controller:"regionFinancialFlowViewController"}}}).state("region-hq",{url:"/:biennium/regions-hq",templateUrl:"Views/RegionsViews/RegionHqView.html",controller:"RegionHqViewController"}).state("region-hq.about",{url:"/about",views:{"region-tabs":{templateUrl:"Views/RegionsViews/RegionHqAboutView.html",controller:"regionHqAboutViewController"}}}).state("region-hq.about.about",{url:"/about"}).state("region-hq.about.key-figures",{url:"/key-figures"}).state("region-hq.about.key-figures-by-programme",{url:"/key-figures-by-programme"}).state("region-hq.about.key-figures-by-output",{url:"/key-figures-by-output"}).state("region-hq.flow",{url:"/flow",views:{"region-tabs":{templateUrl:"Views/RegionsViews/RegionHqFinancialFlowView.html",controller:"regionHqFinancialFlowViewController"}}}).state("country",{url:"/:biennium/country/:countryCode",templateUrl:"Views/CountryViews/CountryView.html",controller:"countryViewController"}).state("country.keyAchievements",{views:{"country-tabs":{templateUrl:"Views/CountryViews/CountryKeyAchievementsView.html",controller:"countryKeyAchievementsViewController"}}}).state("country.summary",{views:{"country-tabs":{templateUrl:"Views/CountryViews/CountrySummaryView.html",controller:"countrySummaryViewController"}}}).state("country.homepage",{views:{"country-tabs":{templateUrl:"Views/CountryViews/CountryHomepageView.html",controller:"countryHomepageViewController"}}}).state("country.financialFlow",{views:{"country-tabs":{templateUrl:"Views/CountryViews/CountryFinancialFlowView.html",controller:"countryFinancialFlowViewController"}}}).state("country-category",{url:"/:biennium/country-category/:countryCode/:categorySerialNo",templateUrl:"Views/CountryCategoryViews/CountryCategoryView.html",controller:"countryCategoryViewController"}).state("country-category.summary",{views:{"country-category-tabs":{templateUrl:"Views/CountryCategoryViews/CountryCategorySummaryView.html",controller:"countryCategorySummaryViewController"}}}).state("country-category.homepage",{views:{"country-category-tabs":{templateUrl:"Views/CountryCategoryViews/CountryCategoryHomepageView.html",controller:"countryCategoryHomepageViewController"}}}).state("country-category.financialFlow",{views:{"country-category-tabs":{templateUrl:"Views/CountryCategoryViews/CountryCategoryFinancialFlowView.html",controller:"countryCategoryFinancialFlowViewController"}}}).state("country-programme",{url:"/:biennium/country-programme/:countryCode/:programmeSerialNo",templateUrl:"Views/CountryProgrammeViews/CountryProgrammeView.html",controller:"countryProgrammeViewController"}).state("country-programme.summary",{views:{"country-programme-tabs":{templateUrl:"Views/CountryProgrammeViews/CountryProgrammeSummaryView.html",controller:"countryProgrammeSummaryViewController"}}}).state("country-programme.homepage",{views:{"country-programme-tabs":{templateUrl:"Views/CountryProgrammeViews/CountryProgrammeHomepageView.html",controller:"countryProgrammeHomepageViewController"}}}).state("country-programme.financialFlow",{views:{"country-programme-tabs":{templateUrl:"Views/CountryProgrammeViews/CountryProgrammeFinancialFlowView.html",controller:"countryProgrammeFinancialFlowViewController"}}}).state("contributors",{url:"/:biennium/contributors?name",templateUrl:"Views/ContributorsViews/ContributorsView.html",controller:"contributorsViewController"}).state("contributors.contributor",{url:"/contributor",views:{"contributors-tabs":{templateUrl:"Views/ContributorsViews/ContributorView.html",controller:"contributorViewController"}}}).state("contributors.overview",{url:"/overview",views:{"contributors-tabs":{templateUrl:"Views/ContributorsViews/ContributorsOverviewView.html",controller:"contributorsOverviewViewController"}}}).state("contributors.overview.ac",{url:"/ac"}).state("contributors.overview.vcs",{url:"/vcs"}).state("contributors.overview.vct",{url:"/vct"}).state("contributors.overview.cvc",{url:"/cvc"}).state("contributors.overview.pip",{url:"/pip"}).state("contributors.overview.cfe",{url:"/cfe"}).state("contributors.overview.pf",{url:"/pf"}).state("cvc",{url:"/:biennium/cvc",templateUrl:"Views/ContributorsViews/CvcView.html",controller:"cvcViewController"}).state("pip",{url:"/:biennium/pip",templateUrl:"Views/ContributorsViews/PipView.html",controller:"pipViewController"}).state("cfe",{url:"/:biennium/cfe",templateUrl:"Views/ContributorsViews/CfeView.html",controller:"cfeViewController"}).state("ks",{url:"/:biennium/ks",templateUrl:"Views/ContributorsViews/KsView.html",controller:"ksViewController"}).state("indicators-default",{url:"/:biennium/indicators",templateUrl:"Views/IndicatorsViews/IndicatorsView.html",controller:"indicatorsViewController"}).state("indicators",{url:"/indicators",templateUrl:"Views/IndicatorsViews/IndicatorsView.html",controller:"indicatorsViewController"}).state("indicators-biennium-category",{url:"/indicators/biennium/:bienniumFilter/category/:categoryFilter",templateUrl:"Views/IndicatorsViews/IndicatorsView.html",controller:"indicatorsViewController"}).state("indicators-biennium-category-programme",{url:"/indicators/biennium/:bienniumFilter/category/:categoryFilter/programme/:programmeFilter",templateUrl:"Views/IndicatorsViews/IndicatorsView.html",controller:"indicatorsViewController"}).state("iati",{url:"/iati",templateUrl:"Views/IATIAboutView.html"}).state("iati.about",{url:"/about",templateUrl:"Views/IATIAboutView.html"}).state("iati-files",{url:"/iati/files",templateUrl:"Views/IATIFilesView.html",controller:"iatiFilesController"}).state("iati-data",{url:"/:biennium/iati/data",templateUrl:"Views/IATIDataView.html",controller:"iatiDataController"}).state("documents",{url:"/:biennium/documents",templateUrl:"Views/DocumentsView.html",controller:"keyDocumentsController"}).state("resolutions-and-decisions",{url:"/resolutions-and-decisions",templateUrl:"Views/ResolutionsAndDecisionsView.html",controller:"resolutionsAndDecisionsController"}).state("contact-us",{url:"/:biennium/contact-us",templateUrl:"Views/ContactUsView.html",controller:"contactUsController"}).state("search",{url:"/:biennium/search",templateUrl:"Views/SearchResultsView.html"});t.otherwise(function(n,t){var i=n.get("$state"),r=n.get("$rootScope");return i.go("404",{biennium:r.biennium}),t.path()});r.interceptors.push(["$rootScope","$q","$injector","$window",function(n,t,i,r){return{responseError:function(u){var f=i.get("$state");return u.status==404?f.go("404",{biennium:n.biennium,message:u.data.message}):u.status==503&&(r.location.href="views/maintenance.html"),t.reject(u)}}}])}]);APP.run(["$rootScope","$state","$browser","$location","uiService",function(n,t,i,r,u){n.biennium=BIENNIUMS.default;n.baseUrl=i.baseHref();n.scrollToTop=function(){$("html, body").animate({scrollTop:0},600)};n.$on("$stateChangeSuccess",function(t,i,f){u.activateTabsForCurrentState();var e=f.biennium;typeof e!="undefined"&&e&&(n.biennium=e);i&&i.url&&(ga("set","page",r.url()),ga("send","pageview"))});n.$on("$stateChangeStart",function(){n.scrollToTop();u.closeMegaMenu()})}]);APP.filter("ifNullOrEmpty",function(){return function(n,t){return angular.isUndefined(n)||n===null||n===""?t:n}});APP.filter("newLineToBr",function(){return function(n){return n&&n.replace?n.replace(/\n/g,"<br/>"):n}});APP.directive("postRender",["$timeout",function(n){return{restrict:"A",transclude:!1,link:function(t,i,r){n(t.$eval(r.postRender),0)}}}]);APP.directive("onClass",[function(){return{restrict:"A",link:function(n,t,i){var r=n.$eval(i.onClass);n.$watch(function(){return t.attr("class")},function(t){for(var i in r)t&&t.indexOf(i)!==-1&&n.$eval(r[i])})}}}]);DataState=function(){this.isLoaded=!1;this.data=null;this.error=null};REVIEW_CYCLE={MTR:"MTR",EBA:"EBA"};FILTER_TYPE_MO="MO";FILTER_TYPE_LEVEL="LEVEL";FILTER_TYPE_BUDGET_SEGMENT="BUDGET_SEGMENT";FILTER_TYPE_SEGMENT="SEGMENT";FILTER_TYPE_CATEGORY="CATEGORY";FILTER_TYPE_PROGRAMME="PROGRAMME";FILTER_TYPE_BIENNIUM="BIENNIUM";RelationsFilters=function(n,t,i){function u(n,t){return r.all==null?[]:(t=t||[],r.all.filter(function(i){if(i.type!=n||!f(n)&&i.value==="*")return!1;if(t.length==0||i.relationsValues.length==0)return!0;var r=!0;return t.forEach(function(n){$.inArray(n,i.relationsValues)<0&&(r=!1)}),r}))}function f(n){if(!r.config)return!0;var t=r.config[n];return t&&typeof t.filterAllEnabled!="undefined"?t.filterAllEnabled:!0}var r=this;r.config=t;r.eventsHandlers=i;r.all=null;r.groups={};r.selected={};n=n||[];n.forEach(function(n){r.groups[n]=[];r.selected[n]=null});r.buildGroups=function(t){t&&(r.all=t,n.forEach(function(n){r.groups[n]=[];r.selected[n]=null}),r.updateGroups())};r.updateGroups=function(){var t=[];if(r.eventsHandlers&&r.eventsHandlers.onRelationsBuild)r.eventsHandlers.onRelationsBuild(t);n.forEach(function(n){r.groups[n]=u(n,t);var i=r.selected[n];i||(i=r.groups[n][0],r.selected[n]=i);i.value!=="*"&&t.push(i.value)})};r.getSelectedValueForType=function(n){var t=r.selected[n];return t?t.value:"*"};r.setSelectedValueForType=function(n,t){t=t=="all"?"*":t;var i=r.all.filter(function(i){return i.type==n&&i.value==t});if(i.length>0){r.selected[n]=i[0];r.onChanged(n)}};r.exists=function(){return!!r.all};r.onChanged=function(t){var u=$.inArray(t,n),i,f;if(!(u<0)){for(i=u+1;i<n.length;i++)f=n[i],r.selected[f]=null;r.updateGroups()}}};APP.service("apiService",["$http","$rootScope",function(n,t){var i=this;this.loadDataByParams=function(i,r,u,f){f=typeof f=="undefined"?null:f;f=f||new DataState;r=$.extend({biennium:t.biennium},r);f.isLoaded=!1;n.get(URL_API(i),{params:r}).then(function(n){f.isLoaded=!0;var t=n.data;t.success&&(f.data=t.data);u&&u(f.data)},function(n){f.isLoaded=!0;f.error=n;console.log(n);u&&u(f.data)})};this.loadData=function(n,t,r){i.loadDataByParams(n,{},t,r)};this.loadDataById=function(n,t,r,u){i.loadDataByParams(n,{id:t},r,u)};this.sendData=function(t,i,r,u){u=typeof u=="undefined"?null:u;u=u||new DataState;u.isLoaded=!1;n.post(URL_API(t),i).then(function(n){u.isLoaded=!0;r&&r(n)},function(n){u.isLoaded=!0;u.error=n;r&&r(n)})}}]);APP.service("categoriesService",["apiService","$http","$rootScope","$interpolate",function(n,t,i,r){var u=this;this.loadCategories=function(n,r){var f,u,e;if(r=typeof r=="undefined"?null:r,r=r||new DataState,f=i.biennium,r.data=[],u=CACHE.getCacheForBiennium(f),u.ourWork){r.data=u.ourWork;n&&n(r.data);return}r.isLoaded=!1;e={biennium:f};t.get(URL_API("categories"),{params:e}).then(function(t){r.isLoaded=!0;var i=t.data;i.success&&(r.data=i.data,u.ourWork=r.data);n&&n(r.data)},function(t){r.isLoaded=!0;r.error=t;console.log(t);n&&n(r.data)})};this.loadAbout=function(t,i,r){n.loadDataById("categories/about",t,i,r)};this.loadBudgetSegments=function(t,i){n.loadData("categories/budget-segments",t,i)};this.loadOutcomes=function(t,i,r){n.loadDataById("categories/about-outcomes",t,i,r)};this.loadKeyFigures=function(t,i,r){n.loadDataById("categories/about-key-figures",t,i,r)};this.loadKeyFiguresByLevel=function(t,i,r){n.loadDataById("categories/about-key-figures-level",t,i,r)};this.loadKeyFiguresByGeography=function(t,i,r){n.loadDataById("categories/about-key-figures-geography",t,i,r)};this.loadFinancingFlow=function(t,i,r){n.loadDataByParams("categories/financing-flow",t,i,r)};this.loadReviewCycleTabs=function(t,i,r){n.loadDataByParams("categories/review-cycle-tabs",t,i,r)};this.loadReviewCycleKeyFigures=function(t,i,r){n.loadDataByParams("categories/review-cycle-key-figures",t,i,r)};this.getDetailedReportLink=function(n,t){if(!n||!t||!CONFIG)return null;try{return r(CONFIG.categoryDetailedReportLink)({categoryId:n,reviewCycle:t.toLowerCase(),biennium:i.biennium})}catch(u){return console.error(u),null}}}]);APP.service("chartsService",["$rootScope","$timeout",function(n,t){function r(n){var r=[n.baselineYear,n.achievedYear,n.achieved2Year,n.targetYear,n.target2Year],f,u,e,i,t;if(r=$.grep(r,function(n){return n!=null}),r.length==0)return console.log("Baseline, result and target years are all null.  Unable to create graph."),null;if(f=Math.min.apply(this,r),u=Math.max.apply(this,r),u-f<=1&&(u+=1),u<f)return console.log("End year is less than start year.  Unable to create graph."),null;for(e=[],i=f;i<=u;i++)t={},t.year=i.toString(),e.push(t),n.baselineYear==i&&(t.baseline=n.baselineValue,t.baselineText=n.baselineValueText),n.achievedYear==i&&(t.achieved=n.achievedValue,t.achievedComment=n.achievedComment),n.achieved2Year==i&&(t.achieved2=n.achieved2Value,t.achieved2Comment=n.achieved2Comment),n.targetYear==i&&(t.target=n.targetValue,t.targetText=n.targetValueText),n.target2Year==i&&(t.target2=n.target2Value,t.target2Text=n.target2ValueText);return e}function u(n){var t={};return n.baselineValue!=null&&n.baselineYear!=null?(t.initialValue=n.baselineValue,t.initialCategory=n.baselineYear):n.achievedValue!=null&&n.achievedYear!=null&&(t.initialValue=n.achievedValue,t.initialCategory=n.achievedYear),n.targetValue!=null&&n.targetYear!=null&&(t.finalValue=n.targetValue,t.finalCategory=n.targetYear),t.lineThickness=5,t.lineAlpha=1,t.lineColor="rgb(147,147,147)",t.dashLength=5,t}function f(n){var t={};return n.baselineValue!=null&&n.baselineYear!=null?(t.initialValue=n.baselineValue,t.initialCategory=n.baselineYear):n.achieved2Value!=null&&n.achieved2Year!=null&&(t.initialValue=n.achieved2Value,t.initialCategory=n.achieved2Year),n.target2Value!=null&&n.target2Year!=null&&(t.finalValue=n.target2Value,t.finalCategory=n.target2Year),t.lineThickness=5,t.lineAlpha=1,t.lineColor="rgb(147,147,147)",t.dashLength=5,t}function e(n){var t={};return n.baselineValue!=null&&n.baselineYear!=null&&n.achievedValue!=null&&n.achievedYear!=null&&(t.initialValue=n.baselineValue,t.initialCategory=n.baselineYear,t.finalValue=n.achievedValue,t.finalCategory=n.achievedYear),t.lineThickness=5,t.lineAlpha=.8,t.lineColor="#008dc9",t}function o(n){var t={};return n.baselineValue!=null&&n.baselineYear!=null&&n.achieved2Value!=null&&n.achieved2Year!=null&&(t.initialValue=n.baselineValue,t.initialCategory=n.baselineYear,t.finalValue=n.achieved2Value,t.finalCategory=n.achieved2Year),t.lineThickness=5,t.lineAlpha=.8,t.lineColor="#008dc9",t}function s(n,t){var r=document.getElementById(n);if(r==null){console.log("In resizeChart, chartDiv cannot be determined from chartId "+n);return}var i=75+90*t;i=Math.max(i,500);r.style.width=i+"px";return}function h(n){var t=[{name:"baseline",year:n.baselineYear,value:n.baselineValue},{name:"achieved",year:n.achievedYear,value:n.achievedValue},{name:"achieved2",year:n.achieved2Year,value:n.achieved2Value},{name:"target",year:n.targetYear,value:n.targetValue},{name:"target2",year:n.target2Year,value:n.target2Value}],s,h,u,r,f,e,o;t=$.grep(t,function(n){return n.value!=null});s=Math.max.apply(this,$.map(t,function(n){return n.value}));h=Math.ceil(s/20);const i=40;for(u={baseline:i,achieved:i,achieved2:i,target:i,target2:i},r=1;r<t.length;r++)for(f=t[r],e=0;e<r;e++)o=t[e],f.year==o.year&&Math.abs(f.value-o.value)<=h&&(u[f.name]=u[o.name]+20);return u}function i(n,t){return t?n+": "+t:n}var c=this;this.makeColumnChart=function(n,i,r){var o,s,u,e,f,h;if(i&&r){o=[];for(s in r.graphs)u=r.graphs[s],e={title:u.title,valueField:s,fillAlphas:1,lineAlpha:1,type:"column",showBalloon:!!u.showBalloon,newStack:u.newStack?u.newStack:!1,labelPosition:u.labelPosition?u.labelPosition:"middle",labelFunction:function(n){return Number(n.values.value/1e6).toLocaleString(undefined,{maximumFractionDigits:typeof r.maximumFractionDigits=="number"?r.maximumFractionDigits:1})+"M"},labelText:u.showLabel?"999":"",color:u.labelColor?u.labelColor:"#ffffff",fontSize:u.labelFontSize?u.labelFontSize:13,showAllValueLabels:!1},u.lineColor&&(e.lineColor=u.lineColor),u.fillColors&&(e.fillColors=u.fillColors),o.push(e);f=r.category;h={type:"serial",theme:"light",rotate:!!r.rotate,autoMargins:!0,color:"#376092",fontFamily:"'Roboto Condensed'",fontSize:18,responsive:{enabled:!0},startEffect:"bounce",startDuration:1,dataProvider:i,graphs:o,legend:{position:"bottom",autoMargins:!0,maxcolumns:2,align:"center",fontSize:16,useGraphSettings:!1,marginLeft:0,marginRight:0,valueText:"",equalWidths:!1},valueAxes:[{stackType:"regular",axisAlpha:0,gridAlpha:.1,labelsEnabled:!0,color:"#AAA",inside:!1,labelFunction:function(n){return Number(n/1e6).toLocaleString()+"M"},unit:"K"}],chartCursor:{fullWidth:!0,oneBalloonOnly:!0,cursorAlpha:.1,lineAlpha:1,cursorColor:"#736dba",categoryBalloonColor:"#736dba",categoryBalloonEnabled:!1},balloon:{adjustBorderColor:!0,borderAlpha:0,color:"#000000",cornerRadius:-100,pointerWidth:0,fillColor:"#fff",fillAlpha:1,showBullet:!1,pointerOrientation:"top"},categoryField:f.field,categoryAxis:{position:"bottom",gridAlpha:0,axisAlpha:0,color:"#69727c",tickLength:0,autoWrap:!0,boldLabels:!0,fontSize:13,labelsEnabled:f.labelsEnabled!=null&&typeof f.labelsEnabled!="undefined"?f.labelsEnabled:!0}};t(function(){AmCharts.makeChart(n,h)},0)}};this.makePieChart=function(n,i,r){if(i&&r){var u={type:"pie",titles:[{text:r.title}],dataProvider:i,valueField:r.valueField,titleField:r.titleField,theme:"light",precision:1,angle:0,depth3D:0,startEffect:"bounce",startDuration:1,addClassNames:!0,legend:{position:"bottom",marginRight:100,autoMargins:!0,maxColumns:5,equalWidths:!1,align:"center",valueFunction:function(n){return typeof r.valuesEnabled=="undefined"||r.valuesEnabled?Number(Math.round(n.value/1e4)/100).toLocaleString():""}},fontFamily:"'Roboto Condensed'",fontSize:14,innerRadius:"20%",defs:{filter:[{id:"shadow",width:"200%",height:"200%",feOffset:{result:"offOut","in":"SourceAlpha",dx:0,dy:0},feGaussianBlur:{result:"blurOut","in":"offOut",stdDeviation:5},feBlend:{"in":"SourceGraphic",in2:"blurOut",mode:"normal"}}]},"export":{enabled:!0}};typeof r.labelsEnabled!="undefined"&&(u.labelsEnabled=r.labelsEnabled);r.colors&&(u.colors=r.colors);r.radius&&(u.radius=r.radius);r.config&&(u=$.extend(!0,u,r.config));typeof r.legendsEnabled!="undefined"&&(u.legend.enabled=r.legendsEnabled);t(function(){AmCharts.makeChart(n,u)},100)}};this.makeIndicatorChart=function(n,t){function a(n,t,r){n!=null&&p.push({title:i(t,n+c),color:r})}var v,y,w;if(t&&n&&(v=r(t),v!=null)){var b=[u(t),f(t),e(t),o(t)],c=(t.dataType||"").toLowerCase()=="ratio"?"%":"",k=t.valueUnits?t.valueUnits.charAt(0).toUpperCase()+t.valueUnits.substr(1).toLowerCase():"",l=h(t),p=[];a(t.baselineValue,"Baseline","#DBEEF9");a(t.achievedValue,"Result","#008DC9");a(t.achieved2Value,"Result 2","#008DC9");a(t.targetValue,"Target","#939393");a(t.target2Value,"Target 2","#939393");s(n,v.length);y=AmCharts.makeChart(n,{type:"serial",addClassNames:!0,theme:"light",autoMarginOffset:30,balloon:{enabled:!1,adjustBorderColor:!1,horizontalPadding:10,verticalPadding:8,color:"#ffffff"},dataProvider:v,legend:{position:"bottom",markerType:"round",markerSize:20,maxColumns:3,data:p,valueWidth:15},valueAxes:[{axisAlpha:0,position:"left",minimum:0,maximum:1.1*Math.max(t.achievedValue,t.achieved2Value,t.baselineValue,t.targetValue,t.target2Value)}],categoryField:"year",categoryAxis:{gridPosition:"start",axisAlpha:0,autoWrap:!0},allLabels:[{text:"Year",color:"#888",x:"!20",y:"!20",width:"50%",size:15,bold:!0,align:"right"},{text:k,color:"#888",rotation:270,x:"10",y:"10",width:"50%",size:15,bold:!0,align:"right"}],trendLines:b,graphs:[{id:"target",title:"Target",valueField:"target",type:"line",balloonFunction:function(n){return i("TARGET",n.dataContext.targetText||n.dataContext.target)},lineThickness:5,lineAlpha:.8,lineColor:"rgb(147,147,147)",dashLength:5,bullet:"round",bulletSize:l.target,labelText:"[[value]]"+c,labelPosition:"middle",color:"#fff"},{id:"target2",title:"Target 2",valueField:"target2",type:"line",balloonFunction:function(n){return i("TARGET 2",n.dataContext.target2Text||n.dataContext.target2)},lineThickness:5,lineAlpha:.8,lineColor:"rgb(147,147,147)",dashLength:5,bullet:"round",bulletSize:l.target2,labelText:"[[value]]"+c,labelPosition:"middle",color:"#fff"},{id:"baseline",title:"Baseline",type:"line",valueField:"baseline",balloonColor:"#008dc9",balloonFunction:function(n){return i("BASELINE",n.dataContext.baselineText||n.dataContext.baseline)},lineColor:"#DBEEF9",lineThickness:5,lineAlpha:.8,bullet:"round",bulletSize:l.baseline,labelText:"[[value]]"+c,labelPosition:"middle",color:"#196AAA",bulletBorderColor:"#008dc9",bulletBorderThickness:5,bulletBorderAlpha:1},{id:"achieved",title:"Result",type:"line",valueField:"achieved",balloonFunction:function(n){return i("RESULT",n.dataContext.achievedComment||n.dataContext.achieved)},lineColor:"#008dc9",colorField:"color",lineThickness:5,lineAlpha:.8,bullet:"round",bulletSize:l.achieved,labelText:"[[value]]"+c,labelPosition:"middle",color:"#fff"},{id:"achieved2",title:"Result 2",type:"line",valueField:"achieved2",balloonFunction:function(n){return i("RESULT 2",n.dataContext.achieved2Comment||n.dataContext.achieved2)},lineColor:"#008dc9",colorField:"color",lineThickness:5,lineAlpha:.8,bullet:"round",bulletSize:l.achieved2,labelText:"[[value]]"+c,labelPosition:"middle",color:"#fff"}]});w=$(sprintf("#%s-tooltip",n));y.addListener("rollOverGraphItem",function(n){var t=n.item,f=t.graph,i,u,r;t.$customTooltip||(t.$customTooltip=$("<div><\/div>"),t.$customTooltip.appendTo(w));i=t.$customTooltip;u=f.balloonFunction(t,f);u&&(r=t.bulletGraphics.node.getBoundingClientRect(),i.attr("data-original-title",u),i.css("position","fixed"),i.css("top",sprintf("%spx",window.pageYOffset+r.top)),i.css("left",sprintf("%spx",window.pageXOffset+r.left+r.width/2)),i.tooltip("show"))});y.addListener("rollOutGraphItem",function(n){n.item.$customTooltip&&n.item.$customTooltip.tooltip("hide")})}}}]);APP.service("contributorsService",["$http","$rootScope","apiService",function(n,t,i){var r=this;r.loadAll=function(n,t){i.loadDataByParams("contributors/all",{},n,t)};r.loadPip=function(n,t){i.loadDataByParams("contributors/pip",{},n,t)};r.loadKs=function(n,t){i.loadDataByParams("contributors/ks",{},n,t)};r.loadCvc=function(n,t){i.loadDataByParams("contributors/cvc",{},n,t)};r.loadTopCvc=function(n,t){i.loadDataByParams("contributors/top-cvc",{},n,t)};r.loadCvcFinancingFlow=function(n,t,r){i.loadDataByParams("contributors/cvc-financing-flow",n,t,r)};r.loadFinancingFlow=function(n,t,r){i.loadDataByParams("contributors/financing-flow",n,t,r)};r.loadFund=function(n,t,r){i.loadDataByParams("contributors/fund",{groupCode:n},t,r)}}]);APP.service("countryCategoryService",["apiService","$http","$rootScope",function(n){var t=this;t.loadAbout=function(t,i,r){n.loadDataById("countryCategory/about",t,i,r)};t.loadKeyFigures=function(t,i,r){n.loadDataById("countryCategory/key-figures",t,i,r)};t.loadCharts=function(t,i,r){n.loadDataById("countryCategory/charts",t,i,r)}}]);APP.service("countryProgrammeService",["apiService","$http","$rootScope",function(n){var t=this;t.loadKeyFigures=function(t,i,r){n.loadDataById("countryProgramme/key-figures",t,i,r)};t.loadCharts=function(t,i,r){n.loadDataById("countryProgramme/charts",t,i,r)}}]);APP.service("countryService",["apiService","$http","$rootScope",function(n){var t=this;t.loadKeyFigures=function(t,i,r){n.loadDataById("country/key-figures",t,i,r)};t.loadExpensesByTypeChartData=function(t,i,r){n.loadDataById("country/expenses-by-type",t,i,r)};t.loadDocuments=function(t,i,r){n.loadDataById("country/documents",t,i,r)};t.loadFinancingFlow=function(t,i,r){n.loadDataByParams("country/financing-flow",t,i,r)};t.loadCountryReview=function(t,i,r){n.loadDataByParams("country/country-review",t,i,r)}}]);APP.service("documentsService",["apiService","$http","$rootScope",function(n){var t=this;t.loadSectionDocuments=function(t,i){n.loadData("documents/section-documents",t,i)}}]);APP.service("financingService",["$http","$rootScope","apiService",function(n,t,i){var r=this;this.loadGpwOverview=function(i){var f=t.biennium,r=[],u=CACHE.getCacheForBiennium(f),e;if(u.gpwOverview){r=u.gpwOverview;i&&i(r);return}e={biennium:f};n.get(URL_API("financing/gpw"),{params:e}).then(function(n){var t=n.data;t.success&&(r=t.data,u.gpwOverview=r);i&&i(r)},function(n){console.log(n);i&&i(r)})};this.loadBudgetAndFinanceDetailsFilters=function(i,r){var f=t.biennium,u=null,e={biennium:f,viewBy:i};n.get(URL_API("financing/details-filters"),{params:e}).then(function(n){var t=n.data;t.success&&(u=t.data);r&&r(u)},function(n){console.log(n);r&&r(u)})};this.loadDetails=function(i,r){var u=null,f=t.biennium;$.extend(i,{biennium:f});n.get(URL_API("financing/details"),{params:i}).then(function(n){var t=n.data;t.success&&(u=t.data);r&&r(u)},function(n){console.log(n);r&&r(u)})};this.loadFlowDonorCategoryRegionProgramme=function(n,t,r){i.loadDataByParams("financing/flow",n,t,r)};this.loadBudgetAndFinanceSummaryFilters=function(n,t){i.loadData("financing/summary-filters",n,t)};this.loadBudgetAndFinanceSummary=function(n,t,r){i.loadDataByParams("financing/summary",n,t,r)}}]);APP.service("iatiFilesService",["apiService","$http","$rootScope",function(n){var t=this;t.loadIatiFiles=function(t,i,r){n.loadDataById("iatiFiles/iati-files",t,i,r)};t.loadAllIatiFiles=function(t,i){n.loadData("iatiFiles/all-iati-files",t,i)}}]);APP.service("modalDialogsService",["$compile","$templateRequest","$rootScope","$controller",function(n,t,i,r){var u=this;this.show=function(u){t(u.templateUrl,!0).then(function(t){var e=i.$new(),f;u.scope&&(e=$.extend(e,u.scope));u.controller&&r(u.controller,{$scope:e});f=n(t)(e)[0];document.body.appendChild(f);$(f).on("hidden.bs.modal",function(){document.body.removeChild(f)});$(f).modal("show")},function(n){console.log(n)})}}]);APP.service("programmeBudgetService",["$http","$rootScope","apiService",function(n,t,i){var r=this;this.loadCategories=function(n,t){i.loadData("budget/categories",n,t)};this.loadRegions=function(i){var f=t.biennium,r=[],u=CACHE.getCacheForBiennium(f),e;if(u.regions){r=u.regions;i&&i(r);return}e={biennium:f};n.get(URL_API("budget/regions"),{params:e}).then(function(n){var t=n.data;t.success&&(r=t.data,u.regions=r);i&&i(r)},function(n){console.log(n);i&&i(r)})};this.loadStatuses=function(i){var r={categoriesGroups:[],categories:[]},f=t.biennium,u=CACHE.getCacheForBiennium(f),e;if(u.statuses){r=u.statuses;i&&i(r);return}e={biennium:f};n.get(URL_API("budget/statuses"),{params:e}).then(function(n){var o=n.data,e,t,f;if(o.success){for(r=o.data,r.categoriesGroups=[],e=r.categories,t=null,f=0;f<e.length;f++)t&&t.length>=4&&(t=null),t||(t=[],r.categoriesGroups.push(t)),t.push(e[f]);u.statuses=r}i&&i(r)},function(n){console.log(n);i&&i(r)})};this.loadLastContributions=function(i){var r=[],f=t.biennium,u=CACHE.getCacheForBiennium(f),e;if(u.lastContributions){r=u.lastContributions;i&&i(r);return}e={biennium:f};n.get(URL_API("budget/contributions"),{params:e}).then(function(n){var t=n.data;t.success&&(r=t.data,u.lastContributions=r);i&&i(r)},function(n){console.log(n);i&&i(r)})};this.loadCvcInfo=function(n,t){i.loadDataByParams("budget/cvc-info",{},n,t)};this.loadActiveQuarter=function(n,t){i.loadDataByParams("budget/active-quarter",{},n,t)};this.loadBudgetSettings=function(n,t){i.loadDataByParams("budget/budget-settings",{},n,t)};this.loadDocuments=function(i){var r=[],f=t.biennium,u=CACHE.getCacheForBiennium(f),e;if(u.documents){r=u.documents;i&&i(r);return}e={biennium:f};n.get(URL_API("budget/documents"),{params:e}).then(function(n){var t=n.data;t.success&&(r=t.data,u.documents=r);i&&i(r)},function(n){console.log(n);i&&i(r)})}}]);APP.service("programmesService",["apiService","$http","$rootScope","$interpolate",function(n,t,i,r){var u=this;this.loadAbout=function(t,i,r){n.loadDataById("programmes/about",t,i,r)};this.loadResults=function(t,i,r){n.loadDataById("programmes/results",t,i,r)};this.loadDeliverables=function(t,i,r){n.loadDataById("programmes/deliverables",t,i,r)};this.loadKeyFigures=function(t,i,r){n.loadDataById("programmes/about-key-figures",t,i,r)};this.loadKeyFiguresByLevel=function(t,i,r){n.loadDataById("programmes/about-key-figures-level",t,i,r)};this.loadKeyFiguresByGeography=function(t,i,r){n.loadDataById("programmes/about-key-figures-geography",t,i,r)};this.loadFinancingFlow=function(t,i,r){n.loadDataByParams("programmes/financing-flow",t,i,r)};this.loadTopStories=function(t,i,r){n.loadDataById("programmes/top-stories",t,i,r)};this.loadReviewCycleTabs=function(t,i,r){n.loadDataByParams("programmes/review-cycle-tabs",t,i,r)};this.loadReviewCycleKeyFigures=function(t,i,r){n.loadDataByParams("programmes/review-cycle-key-figures",t,i,r)};this.loadReviewCycleProgress=function(t,i,r){n.loadDataByParams("programmes/review-cycle-progress",t,i,r)};this.loadReviewCycleRating=function(t,i,r){n.loadDataByParams("programmes/review-cycle-rating",t,i,r)};this.loadReviewCycleIndicators=function(t,i,r){n.loadDataByParams("programmes/review-cycle-indicators",t,i,r)};this.loadIndicatorsGraph=function(t,i,r){n.loadDataByParams("programmes/indicators-graph",t,i,r)};this.loadIndicatorCountriesDetails=function(t,i,r){n.loadDataByParams("programmes/indicator-countries-details",t,i,r)};this.loadProgrammeInfo=function(t,i,r){n.loadDataById("programmes/programme-info",t,i,r)};this.loadIndicatorsFilters=function(t,i){n.loadData("programmes/indicators-filters",t,i)};this.loadIndicators=function(t,i,r){n.loadDataByParams("programmes/indicators",t,i,r)};this.getDetailedReportLink=function(n,t){if(!n||!t||!CONFIG)return null;try{return r(CONFIG.programmeDetailedReportLink)({programmeId:n,reviewCycle:t.toLowerCase(),biennium:i.biennium})}catch(u){return console.error(u),null}}}]);RegionFilters=function(n){function t(n,t,r){if(i.all==null)return[];var u=t?t.value:"*",f=r?r.value:"*";return i.all.filter(function(t){return t.type!=n?!1:t.value==="*"?!0:u!=="*"&&t.segmentValue!==u?!1:f!=="*"&&t.categoryValue!==f?!1:!0})}var i=this;this.eventsHandlers=n;this.all=null;this.groups={segments:[],categories:[],programmes:[]};this.selected={segment:null,category:null,programme:null};this.buildGroups=function(n){n&&(this.all=n,this.updateGroups())};this.updateGroups=function(){this.groups.segments=t("SEGMENT",null,null);this.selected.segment==null&&(this.selected.segment=this.groups.segments[0]);this.groups.categories=t("CATEGORY",this.selected.segment,null);this.selected.category==null&&(this.selected.category=this.groups.categories[0]);this.groups.programmes=t("PROGRAMME",this.selected.segment,this.selected.category);this.selected.programme==null&&(this.selected.programme=this.groups.programmes[0])};this.getSelected=function(){var n=this.selected.segment,t=this.selected.category,i=this.selected.programme;return{segment:n?n.value:"*",categoryId:t?t.value:"*",programmeId:i?i.value:"*"}};this.exists=function(){return!!this.all};this.onSegmentChanged=function(){this.selected.category=null;this.selected.programme=null;this.updateGroups();this.eventsHandlers&&this.eventsHandlers.onSegmentChanged&&this.eventsHandlers.onSegmentChanged()};this.onCategoryChanged=function(){this.selected.programme=null;this.updateGroups();this.eventsHandlers&&this.eventsHandlers.onCategoryChanged&&this.eventsHandlers.onCategoryChanged()}};APP.service("regionsService",["apiService","$http","$rootScope",function(n){var t=this;this.loadAbout=function(t,i,r){n.loadDataById("regions/about",t,i,r)};this.loadKeyFigures=function(t,i,r,u){n.loadDataByParams("regions/about-key-figures",{id:t,budgetSegment:i.budgetSegment,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadKeyFiguresByCategory=function(t,i,r,u){n.loadDataByParams("regions/about-key-figures-category",{id:t,budgetSegment:i.budgetSegment,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadKeyFiguresByProgramme=function(t,i,r,u){n.loadDataByParams("regions/about-key-figures-programme",{id:t,budgetSegment:i.budgetSegment,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadKeyFiguresFilters=function(t,i,r){n.loadDataById("regions/about-key-figures-filters",t,i,r)};this.loadKeyFiguresByLevel=function(t,i,r,u){n.loadDataByParams("regions/about-key-figures-level",{id:t,budgetSegment:i.budgetSegment,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadKeyFiguresByGeography=function(t,i,r,u){n.loadDataByParams("regions/about-key-figures-geography",{id:t,budgetSegment:i.budgetSegment,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadRegions=function(t,i){n.loadDataByParams("regions/all",{},t,i)};this.loadRegionsMaps=function(t,i){n.loadDataByParams("regions/maps",{},t,i)};this.loadHqKeyFigures=function(t,i){n.loadDataByParams("regions/hq-about-key-figures",{},t,i)};this.loadHqKeyFiguresByProgrammeFilters=function(t,i){n.loadDataByParams("regions/hq-about-key-figures-programme-filters",{},t,i)};this.loadHqKeyFiguresByProgramme=function(t,i,r,u){n.loadDataByParams("regions/hq-about-key-figures-programme",{id:t,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadHqKeyFiguresByOutput=function(t,i,r,u){n.loadDataByParams("regions/hq-about-key-figures-output",{id:t,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadOutputContributors=function(t,i,r,u){n.loadDataByParams("regions/hq-output-contributors",{id:t,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadOutputExpenditures=function(t,i,r,u){n.loadDataByParams("regions/hq-output-expenditures",{id:t,segment:i.segment,categoryId:i.categoryId,programmeId:i.programmeId},r,u)};this.loadFinancingFlow=function(t,i,r){n.loadDataByParams("regions/financing-flow",t,i,r)};this.loadHqFinancingFlow=function(t,i,r){n.loadDataByParams("regions/hq-financing-flow",t,i,r)}}]);APP.service("resolutionsAndDecisionsService",["apiService",function(n){var t=this;t.loadFilters=function(t,i){n.loadData("resolutionsAndDecisions/filters",t,i)};t.search=function(t,i,r){n.loadDataByParams("resolutionsAndDecisions/search",t,i,r)}}]);APP.service("textsService",["$rootScope",function(n){function r(n){n.Category="Category";n.Categories="Categories";n.Programme="Programme";n["Programme outcomes"]="Programme Outcomes";n["Programmes and outcomes"]="Programmes and outcomes";n["Deliverables for Outputs"]="Deliverables for Outputs";n["Programme area"]="Programme area";n["Figures by Category"]="Figures by Category";n["Figures by Programme"]="Figures by Programme";n["Category figures by level"]="Category figures by level";n["Programme figures by level"]="Programme figures by level";n["Category expenses"]="Category expenses";n["Category expenses by type"]="Category expenses by type";n["Select Category"]="Select Category";n["Category key figures"]="Category key figures";n["Click category photo or name to zoom into programmes"]="Click category photo or name to zoom into programmes";n["Category Summary"]="Category Summary";n["Contributions to the following programmes and outputs:"]="Contributions to the following programmes and outputs:";n["Category key figures by programme area"]="Category key figures by programme area";n["Programme expenses"]="Programme expenses";n["Programme expenses by type"]="Programme expenses by type";n["All categories"]="All categories";n["All programmes"]="All programmes";n["Budget by Programme (M)"]="Budget by Programme (M)";n["Financing by Category"]="Financing by Category";n["home/1"]="This is WHO's new Programme Budget Portal, providing further details of the Organization’s work, financing and implementation progress.";n["home/2"]="With quarterly updates this portal will present a better breakdown of our work, navigating through the different categories, programmes and outputs through which WHO’s work is delivered. Countries now specify the financial details at output level in order to meet WHO’s requirement for IATI compliance.";n["budget-and-financing.gpw-title"]="Financing of General Programme of Work 2014 - 2019";n["budget-and-financing.gpw-overview"]="Shows the overview of the Budget from 2014-2015 to 2018-2019 and related financing.  The Base segment of the budget is the WHA approved amount. For Polio, Outbreak and Crisis response, and Special programmes (TDR & HRP) this amount has been increased based on the financing and event driven nature of these programmes as per the respective WHA resolutions. All funding reflected in this section shows the distributed amounts across the Organization's results and structure."}function t(n){n.Category="Strategic Objective";n.Categories="Strategic Objectives";n.Programme="Outcome";n["Programme outcomes"]="Outcomes";n["Programmes and outcomes"]="Outcomes";n["Deliverables for Outputs"]="Outputs";n["Programme area"]="Outcome";n["Figures by Category"]="Figures by Strategic Objective";n["Figures by Programme"]="Figures by Outcome";n["Category figures by level"]="Strategic Objective figures by level";n["Programme figures by level"]="Outcome figures by level";n["Category expenses"]="Strategic objective expenses";n["Category expenses by type"]="Strategic objective expenses by type";n["Select Category"]="Select Strategic Objective";n["Category key figures"]="Strategic objective key figures";n["Click category photo or name to zoom into programmes"]="Click strategic objective photo or name to zoom into outcomes";n["Category Summary"]="Strategic Objective Summary";n["Contributions to the following programmes and outputs:"]="Contributions to the following outcomes and outputs:";n["Category key figures by programme area"]="Strategic objective key figures by outcome";n["Programme expenses"]="Outcome expenses";n["Programme expenses by type"]="Outcome expenses by type";n["All categories"]="All strategic objectives";n["All programmes"]="All outcomes";n["Budget by Programme (M)"]="Budget by Outcome (M)";n["Financing by Category"]="Financing by Strategic Objective";n["home/1"]="Welcome to WHO's Programme Budget Portal, providing further details of the Organization’s work, financing and implementation progress across its General Programme of Work.";n["home/2"]="With quarterly updates this portal presents a better breakdown of our work, navigating through the different strategic priorities, global outcomes and outputs through which WHO’s work is delivered. Countries specify any financial details at activity (output) level in order to meet WHO’s requirement for IATI compliance.";n["budget-and-financing.gpw-title"]="Financing of General Programme of Work 2020 - 2023";n["budget-and-financing.gpw-overview"]="Shows the overview of the Budget from 2020-2021 to 2022-2023 and related financing. The Base segment of the budget is the WHA approved amount. For Polio, Outbreak and Crisis response, and Special programmes (TDR, HRP and PIP Framework) this amount has been increased based on the financing and event driven nature of these programmes as per the respective WHA resolutions. All funding reflected in this section shows the distributed amounts across the Organization's results and structure."}function u(n){t(n);n["home/2"]="With monthly updates this portal presents a better breakdown of our work around the different strategic priorities, global outcomes and outputs through which WHO’s work is delivered. WHO organizational entities (Country Offices, Regional Offices and Headquarters' divisions) specify any financial details at activity (output) level in order to meet WHO’s requirement for IATI compliance."}var i=this;i.getTexts=function(){var i={},f=["2014-15","2016-17","2018-19"].includes(n.biennium)?r:["2020-21"].includes(n.biennium)?t:u;return f(i),i}}]);APP.service("uiService",["$timeout","$rootScope","$state",function(n,t,i){var r=this;r.initTooltips=function(){n(function(){$(".tooltips").tooltip()},0)};r.initCombobox=function(t){n(function(){$(sprintf("#%s",t)).combobox()})};r.initSelect2Combobox=function(t){n(function(){$(sprintf("#%s",t)).select2({dropdownAutoWidth:!0,width:"100%"})})};r.initBootstrapDropdowns=function(){n(function(){$(".dropdown-toggle").dropdown()})};r.initMegaMenu=function(){n(function(){LayoutMegaMenu.init()})};r.closeMegaMenu=function(){n(function(){var n=$(".c-hor-nav-toggler"),t=n.data("target");$(t).removeClass("c-shown")})};r.initTabs=function(){n(function(){$(".nav-tabs").tab()})};r.activateTabsForState=function(t){t&&t.name&&n(function(){$(sprintf(".nav li[active-state='%s'] a",t.name)).tab("show")})};r.activateTabsForCurrentState=function(){var t=i.$current.includes;t&&n(function(){for(var n in t)t[n]&&$(sprintf(".nav li[active-state='%s'] a",n)).tab("show")})};r.showFirstTab=function(t){n(function(){$(sprintf("#%s a:first",t)).tab("show")},0)};r.showGlobalPreloader=function(){NProgress.start()};r.hideGlobalPreloader=function(){NProgress.done()}}]);APP.service("whoService",["apiService","$http","$rootScope",function(n){var t=this;t.loadIatiFiles=function(t,i){alert(1);n.loadDataById("who/who-iati-files","0",t,i)}}]);APP.controller("homeViewController",["$scope","$rootScope","$http","$interval","$timeout","modalDialogsService","programmeBudgetService","uiService","textsService",function(n,t,i,r,u,f,e,o,s){var h=this;o.initTooltips();n.regions=[];n.statuses=[];n.lastContributions=[];n.documents=[];n.topCvc=null;n.texts=s.getTexts();n.initSliders=function(){u(function(){LayoutRevoSliders.init()})};n.selectBiennium=function(){f.show({templateUrl:"Views/ModalViews/SelectBienniumModalView.html",controller:"selectBienniumModalViewController"})};n.loadRegions=function(){e.loadRegions(function(t){n.regions=t;u(function(){$("#regions-tabs a:first").tab("show")},0)})};n.loadStatuses=function(){e.loadStatuses(function(t){n.statuses=t;u(function(){LayoutProgressBar.init()},0)})};n.loadContributions=function(){e.loadLastContributions(function(t){n.lastContributions=t;u(function(){ContentOwlcarousel.init()},0)})};n.loadDocuments=function(){e.loadDocuments(function(t){n.documents=t})};n.loadCvcInfo=function(){e.loadCvcInfo(function(t){n.cvcInfo=t})};n.loadActiveQuarter=function(){e.loadActiveQuarter(function(n){t.budget.quarter=n})};n.loadBudgetSettings=function(){e.loadBudgetSettings(function(n){t.budget.isMtrActive=n.isMtrActive;t.budget.mtrQuarter=n.mtrQuarter;t.budget.isEbaActive=n.isEbaActive;t.budget.ebaQuarter=n.ebaQuarter})}}]);APP.controller("masterViewController",["$scope","$rootScope","modalDialogsService","programmeBudgetService","uiService",function(n,t,i,r,u){t.categories=null;t.pbCategories=null;t.sgpCategories=null;t.budget=BUDGET;t.$watch("biennium",function(){n.loadCategories()});n.selectBiennium=function(){i.show({templateUrl:"Views/ModalViews/SelectBienniumModalView.html",controller:"selectBienniumModalViewController"})};n.loadCategories=function(){r.loadCategories(function(n){t.categories=n;t.pbCategories=n.filter(function(n){return n.budgetSegment=="Programme Budget"});t.sgpCategories=n.filter(function(n){return n.budgetSegment=="Special Global Projects"})})};n.initMegaMenu=function(){u.initMegaMenu()};n.$on("$stateChangeStart",function(){u.showGlobalPreloader()});n.$on("$stateChangeSuccess",function(){u.hideGlobalPreloader()})}]);APP.controller("notFoundViewController",["$scope","$state",function(n,t){n.message=t.params.message}]);APP.controller("budgetAndFinanceDetailsViewController",["$scope","$state","$timeout","financingService","chartsService","textsService",function(n,t,i,r,u,f){var o="ByCategory",s="ByOffice",e=this;n.details=null;n.texts=f.getTexts();n.selectedViewBy=o;n.quarters=[];n.budgetSegments=[];n.selectedQuarter=null;n.selectedBudgetSegment=null;n.byCategoryFilters=new RelationsFilters([FILTER_TYPE_MO,FILTER_TYPE_LEVEL,FILTER_TYPE_SEGMENT],null,{onRelationsBuild:function(t){t.push(n.selectedBudgetSegment)}});n.byMajorOfficeFilters=new RelationsFilters([FILTER_TYPE_LEVEL,FILTER_TYPE_SEGMENT,FILTER_TYPE_CATEGORY],null,{onRelationsBuild:function(t){t.push(n.selectedBudgetSegment)}});n.loadFilters=function(){r.loadBudgetAndFinanceDetailsFilters(n.selectedViewBy,function(t){n.quarters=t.quarters;n.quarters&&n.quarters.length>0&&(n.selectedQuarter=n.quarters[n.quarters.length-1].id);n.budgetSegments=t.budgetSegments;n.budgetSegments&&n.budgetSegments.length>0&&(n.selectedBudgetSegment=n.budgetSegments[0].value);n.byCategoryFilters.buildGroups(t.filters);n.byMajorOfficeFilters.buildGroups(t.filters);n.loadDetails()})};n.loadDetails=function(){var t=null;if(n.selectedViewBy===o)t=n.byCategoryFilters;else if(n.selectedViewBy===s)t=n.byMajorOfficeFilters;else throw new Error("Unknown value for parameter 'selectedViewBy'");r.loadDetails({viewBy:n.selectedViewBy,quarter:n.selectedQuarter,budgetSegment:n.selectedBudgetSegment,office:t.getSelectedValueForType(FILTER_TYPE_MO),segment:t.getSelectedValueForType(FILTER_TYPE_SEGMENT),level:t.getSelectedValueForType(FILTER_TYPE_LEVEL),category:t.getSelectedValueForType(FILTER_TYPE_CATEGORY)},function(t){n.details=t;n.selectedViewBy===o?e.showByCategoryDetails():n.selectedViewBy===s&&e.showByOfficeDetails()})};e.showByCategoryDetails=function(){u.makeColumnChart("ChartBienniumFinancingDetailsCategory",n.details,{graphs:{voluntaryContributionsSpecified:{lineColor:"#376092",fillColors:"#376092",title:"Voluntary Contributions Specified"},voluntaryContributionsThematic:{lineColor:"#ff0000",fillColors:"#ff0000",title:"Voluntary Contributions Thematic"},flexibleFunds:{lineColor:"#ffc000",fillColors:"#ffc000",title:"Flexible Funds"},projectedFunding:{lineColor:"#8eb4e3",fillColors:"#8eb4e3",title:"Projected"},shortfall:{lineColor:"#bfbfbf",fillColors:"#bfbfbf",title:"Shortfall"}},category:{field:"categoryLongText"}})};e.showByOfficeDetails=function(){u.makeColumnChart("ChartBienniumFinancingDetailsMO",n.details,{graphs:{voluntaryContributionsSpecified:{lineColor:"#376092",fillColors:"#376092",title:"Voluntary Contributions Specified"},voluntaryContributionsThematic:{lineColor:"#ff0000",fillColors:"#ff0000",title:"Voluntary Contributions Thematic"},flexibleFunds:{lineColor:"#ffc000",fillColors:"#ffc000",title:"Flexible Funds"},projectedFunding:{lineColor:"#8eb4e3",fillColors:"#8eb4e3",title:"Projected"},shortfall:{lineColor:"#bfbfbf",fillColors:"#bfbfbf",title:"Shortfall"}},category:{field:"majorOffice"}})}}]);APP.controller("budgetAndFinanceSummaryViewController",["$scope","$state","$timeout","financingService","chartsService",function(n,t,i,r,u){n.budgetAndFinanceSummaryState=new DataState;n.filtersState=new DataState;n.selectedQuarter=null;n.selectedBudgetSegment=null;n.loadFilters=function(){r.loadBudgetAndFinanceSummaryFilters(function(t){t&&t.quarters&&t.quarters.length>0&&(n.selectedQuarter=t.quarters[t.quarters.length-1].id);t&&t.budgetSegments&&t.budgetSegments.length>0&&(n.selectedBudgetSegment=t.budgetSegments[0].value);n.loadBudgetAndFinanceSummary()},n.filtersState)};n.loadBudgetAndFinanceSummary=function(){r.loadBudgetAndFinanceSummary({quarter:n.selectedQuarter,budgetSegment:n.selectedBudgetSegment},function(){n.showBudgetAndFinanceSummary()},n.budgetAndFinanceSummaryState)};n.showBudgetAndFinanceSummary=function(){n.budgetAndFinanceSummaryState.isLoaded&&u.makeColumnChart("ChartBienniumFinancingSummary",n.budgetAndFinanceSummaryState.data,{graphs:{voluntaryContributionsSpecified:{lineColor:"#376092",fillColors:"#376092",title:"Voluntary Contributions Specified"},voluntaryContributionsThematic:{lineColor:"#ff0000",fillColors:"#ff0000",title:"Voluntary Contributions Thematic"},flexibleFunds:{lineColor:"#ffc000",fillColors:"#ffc000",title:"Flexible Funds"},projectedFunding:{lineColor:"#8eb4e3",fillColors:"#8eb4e3",title:"Projected"},shortfall:{lineColor:"#bfbfbf",fillColors:"#bfbfbf",title:"Shortfall"}},category:{field:"segment"}})}}]);APP.controller("budgetAndFinancingViewController",["$scope","$state","uiService",function(n,t,i){console.log(t);t.current.name=="budget-and-financing"&&t.go("budget-and-financing.gpw-overview");i.initTooltips()}]);APP.controller("financialFlowViewController",["$scope","$state","$timeout","financingService","textsService",function(n,t,i,r,u){n.texts=u.getTexts();n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFlowDonorCategoryRegionProgramme(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_PROGRAMME&&(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME));r.loadFlowDonorCategoryRegionProgramme(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("gpwOverviewViewController",["$scope","$state","$timeout","financingService","chartsService","textsService",function(n,t,i,r,u,f){n.gpwOverview=null;n.selectedQuarter=null;n.financingOverviews=null;n.texts=f.getTexts();n.loadGpwOverview=function(){r.loadGpwOverview(function(t){n.gpwOverview=t;var i=n.gpwOverview.quarters;i&&i.length>0&&(n.selectedQuarter=i[i.length-1].id,n.showGpwOverview())})};n.showGpwOverview=function(){var t=n.selectedQuarter,i=n.gpwOverview;t&&i&&(n.financingOverviews=i.financingOverviews[t],n.financingOverviews)&&u.makeColumnChart("ChartGPWFinancing",n.financingOverviews,{graphs:{voluntaryContributionsSpecified:{lineColor:"#376092",fillColors:"#376092",title:"Voluntary Contributions Specified"},voluntaryContributionsThematic:{lineColor:"#ff0000",fillColors:"#ff0000",title:"Voluntary Contributions Thematic"},flexibleFunds:{lineColor:"#ffc000",fillColors:"#ffc000",title:"Flexible Funds"},projectedFunding:{lineColor:"#8eb4e3",fillColors:"#8eb4e3",title:"Projected"}},category:{field:"biennium"}})}}]);APP.controller("categoryAboutViewController",["$scope","$timeout","$state","$stateParams","categoriesService","textsService",function(n,t,i,r,u,f){var e=this;i.current.name=="category.about"&&i.go("category.about.about");n.categoryId=r.categoryId;n.aboutState=new DataState;n.about=null;n.outcomes=null;n.keyFigures=null;n.keyFiguresByLevel=null;n.keyFiguresByGeography=null;n.texts=f.getTexts();n.init=function(){switch(i.current.name){case"category.about.programme-outcomes":n.loadProgrammeOutcomes();break;case"category.about.key-figures":n.loadKeyFigures();break;case"category.about.key-figures-by-level":n.loadKeyFiguresByLevel();break;case"category.about.key-figures-by-geography":n.loadKeyFiguresByGeography();break;default:n.loadAbout()}};n.loadAbout=function(){u.loadAbout(n.categoryId,function(t){n.about=t;n.$emit(EVENTS.CATEGORY_LOADED,t)},n.aboutState)};n.loadProgrammeOutcomes=function(){u.loadOutcomes(n.categoryId,function(t){n.outcomes=t})};n.loadKeyFigures=function(){u.loadKeyFigures(n.categoryId,function(t){n.keyFigures=t})};n.loadKeyFiguresByLevel=function(){u.loadKeyFiguresByLevel(n.categoryId,function(t){n.keyFiguresByLevel=t})};n.loadKeyFiguresByGeography=function(){u.loadKeyFiguresByGeography(n.categoryId,function(i){(n.keyFiguresByGeography=i,n.keyFiguresByGeography!=null)&&t(function(){$("#RegionTabs a:first").tab("show")},0)})};n.showCountryBudgetPieChart=function(n,t){console.log(t)}}]);APP.controller("categoryEndBienniumAssessmentViewController",["$scope","$rootScope","$state","$timeout","categoriesService","chartsService","modalDialogsService","uiService",function(n,t,i,r,u,f,e,o){n.categoryId=i.params.categoryId;n.categoryDetailedReportLink=u.getDetailedReportLink(n.categoryId,REVIEW_CYCLE.EBA);n.tabs=null;n.keyFiguresState=new DataState;n.loadTabs=function(){u.loadReviewCycleTabs({id:n.categoryId,reviewCycle:REVIEW_CYCLE.EBA},function(t){n.tabs=t;o.showFirstTab("category-eba-tabs")})};n.loadKeyFigures=function(){u.loadReviewCycleKeyFigures({id:n.categoryId,reviewCycle:REVIEW_CYCLE.EBA},function(n){f.makeColumnChart("EBAChartBudgetExpenseFunding",n.byRegion,{graphs:{approvedBudget:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"WHA Approved Budget",newStack:!0},totalFinancing:{lineColor:"#79933C",fillColors:"#79933C",title:"Funds available",newStack:!0},expTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenditures",newStack:!0}},category:{field:"moName"}})},n.keyFiguresState)};n.showFinancialOverview=function(){e.show({templateUrl:"Views/ModalViews/ReviewCycleFinancialOverview.html",scope:{title:sprintf("Results Report: Financial Overview for Category: %s",n.keyFiguresState.data.categoryLongText),data:n.keyFiguresState.data.financialOverview}})}}]);APP.controller("categoryFinancialFlowViewController",["$scope","$state","$timeout","categoriesService","textsService",function(n,t,i,r,u){n.texts=u.getTexts();n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={categoryId:t.params.categoryId,donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_PROGRAMME&&(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME));r.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("categoryMidTermReviewViewController",["$scope","$rootScope","$state","$timeout","categoriesService","chartsService","modalDialogsService","uiService",function(n,t,i,r,u,f,e,o){n.staticContent=STATIC_CONTENT;n.categoryId=i.params.categoryId;n.categoryDetailedReportLink=u.getDetailedReportLink(n.categoryId,REVIEW_CYCLE.MTR);n.tabs=null;n.keyFiguresState=new DataState;n.categoryResultPdfUrl=null;n.$on("$destroy",function(){});n.canLoadResults=function(){if(!n.staticContent)return!1;var i=n.staticContent.get(t.biennium,"CategoryResultPdf",n.categoryId);return i?!0:!1};n.loadResults=function(){if(n.canLoadResults()){var i=n.staticContent.get(t.biennium,"CategoryResultPdf",n.categoryId);n.categoryResultPdfUrl=n.staticContent.pdfViewerUrl+encodeURI(i.url)}};n.loadTabs=function(){u.loadReviewCycleTabs({id:n.categoryId,reviewCycle:REVIEW_CYCLE.MTR},function(t){n.tabs=t;o.showFirstTab("category-mtr-tabs")})};n.loadKeyFigures=function(){u.loadReviewCycleKeyFigures({id:n.categoryId,reviewCycle:REVIEW_CYCLE.MTR},function(n){f.makeColumnChart("MTRChartBudgetExpenseFunding",n.byRegion,{graphs:{approvedBudget:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"WHA Approved Budget",newStack:!0},totalFinancing:{lineColor:"#79933C",fillColors:"#79933C",title:"Funds available",newStack:!0},expTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenditures",newStack:!0}},category:{field:"moName"}})},n.keyFiguresState)};n.showFinancialOverview=function(){e.show({templateUrl:"Views/ModalViews/ReviewCycleFinancialOverview.html",scope:{title:sprintf("Mid Term Review: Financial Overview for Category: %s",n.keyFiguresState.data.categoryLongText),data:n.keyFiguresState.data.financialOverview}})}}]);APP.controller("categoryViewController",["$scope","$rootScope","$timeout","$state","$interpolate","categoriesService","textsService",function(n,t,i,r,u,f,e){function o(n){if(!n||!CONFIG)return null;try{return u(CONFIG.categoryResultsReportLink)({categoryId:n,biennium:t.biennium})}catch(i){return console.error(i),null}}n.categoryId=r.params.categoryId;n.categoryResultsReportLink=o(n.categoryId);n.texts=e.getTexts();r.current.name=="category"&&r.go("category.about");n.$on(EVENTS.CATEGORY_LOADED,function(n,i){t.category=i})}]);APP.controller("ourWorkViewController",["$scope","$timeout","categoriesService",function(n,t,i){n.budgetSegments=[];n.loadBudgetSegments=function(){i.loadBudgetSegments(function(i){n.budgetSegments=i;t(function(){LayoutProgressBar.init()},0)})}}]);APP.controller("cfeViewController",["$scope","$timeout","contributorsService","uiService","chartsService","categoriesService",function(n,t,i,r,u,f){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={categoryId:20,donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null};n.contributorsState=new DataState;r.initTooltips();n.loadContributors=function(){i.loadPip(function(n){u.makeColumnChart("ChartFundingByContributor",n,{graphs:{cfeAmount:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"PIP Amount",showLabel:!0,showBalloon:!0,labelPosition:"right",labelColor:"#000000"}},category:{field:"donorName"},rotate:!0,maximumFractionDigits:2})},n.contributorsState)};n.onFlowChartInit=function(t){t.startLoading();f.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_PROGRAMME&&(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME));f.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("contributorsOverviewViewController",["$scope","$timeout","$state","contributorsService",function(n,t,i,r){i.current.name=="contributors.overview"&&i.go("contributors.overview.ac");n.acState=new DataState;n.vcsState=new DataState;n.vctState=new DataState;n.pfState=new DataState;n.cvcState=new DataState;n.pipState=new DataState;n.cfeState=new DataState;n.init=function(){switch(i.current.name){case"contributors.overview.vcs":n.loadFund("VCS",n.vcsState);break;case"contributors.overview.vct":n.loadFund("VCT",n.vctState);break;case"contributors.overview.cvc":n.loadFund("CVC",n.cvcState);break;case"contributors.overview.pip":n.loadFund("PIP",n.pipState);break;case"contributors.overview.pf":n.loadFund("PF",n.pfState);break;default:n.loadFund("AC",n.acState)}};n.loadFund=function(n,t){n&&t&&r.loadFund(n,function(){},t)}}]);APP.controller("contributorsViewController",["$scope","$timeout","$state","contributorsService",function(n,t,i){i.current.name=="contributors"&&i.go("contributors.contributor")}]);APP.controller("contributorViewController",["$scope","$timeout","$state","$rootScope","$location","contributorsService","uiService",function(n,t,i,r,u,f,e){function o(t){if(t&&n.contributorsState.data){t=t.toUpperCase();var i=_.find(n.contributorsState.data,function(n){return n.donorName&&n.donorName.toUpperCase()===t});i&&$("#select-contributors").val(i.$$hashKey).trigger("change")}}n.contributorName=i.params.name;n.contributorsState=new DataState;n.selectedContributor=null;n.contributorsColors=null;n.flowChartStateManager=null;n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={donorName:n.contributorName,donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null};e.initTooltips();n.loadContributors=function(){f.loadAll(function(){n.showContributorAndFunds();n.loadFlow()},n.contributorsState)};n.showContributorAndFunds=function(){var i=n.contributorsState.data,t,r,f;!i||i.length<=0||(n.contributorName&&!n.selectedContributor&&(n.selectedContributor=_.find(i,function(t){return t.donorName.toUpperCase()===n.contributorName.toUpperCase()})),n.selectedContributor||(n.selectedContributor=i[0]),t=n.selectedContributor,r=[{name:"Assessed contributions",color:"#c8d046",value:t.assessedAmount,valueFormatted:t.assessedAmountFormatted},{name:"Voluntary contributions - Specified ",color:"#5dc09c",value:t.vcsAmount,valueFormatted:t.vcsAmountFormatted},{name:"Voluntary contributions - Thematic",color:"#ff0000",value:t.vctAmount,valueFormatted:t.vctAmountFormatted},{name:"Core voluntary contributions",color:"#ac3773",value:t.cvcAmount,valueFormatted:t.cvcAmountFormatted},{name:"PIP Contributions",color:"#ac6537",value:t.pipAmount,valueFormatted:t.pipAmountFormatted},{name:"Projected funding*",color:"#5893dd",value:t.projectedAmount,valueFormatted:t.projectedAmountFormatted}],n.selectedContributor.funds=r,n.contributorsColors=[],n.selectedContributor.funds.forEach(function(t){n.contributorsColors.push(t.color)}),e.initSelect2Combobox("select-contributors"),f=n.selectedContributor==i[0],u.search("name",f?null:n.selectedContributor.donorName))};n.loadFlow=function(){var i=n.selectedContributor,t=n.flowChartStateManager;i&&t&&(t.startLoading(),n.flowChartParams={donorName:~i.donorName.toUpperCase().indexOf("ALL CONTRIBUTORS")?null:i.donorName,donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null},n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]),f.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes},!0);t.endLoading()}))};n.onFlowChartInit=function(t){n.flowChartStateManager=t};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR),o(t.name)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_PROGRAMME&&(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME));f.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("cvcViewController",["$scope","$timeout","contributorsService","uiService","chartsService",function(n,t,i,r,u){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY]);n.flowChartParams={donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null};n.contributorsState=new DataState;r.initTooltips();n.loadContributors=function(){i.loadCvc(function(n){u.makeColumnChart("ChartFundingByContributor",n,{graphs:{cvcAmount:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"CVC Amount",showLabel:!0,showBalloon:!0,labelPosition:"right",labelColor:"#000000"}},category:{field:"donorName"},rotate:!0,maximumFractionDigits:2})},n.contributorsState)};n.onFlowChartInit=function(t){t.startLoading();i.loadCvcFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,r){r.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_PROGRAMME&&(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME));i.loadCvcFinancingFlow(n.flowChartParams,function(t){r.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});r.endLoading()})}}]);APP.controller("ksViewController",["$scope","$timeout","contributorsService","uiService","chartsService","categoriesService",function(n,t,i,r,u){n.summaryState=new DataState;r.initTooltips();n.loadContributors=function(){i.loadKs(function(n){u.makeColumnChart("ChartFundingByContributor",n.total,{graphs:{amount:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"Amount",showLabel:!0,showBalloon:!0,labelPosition:"right",labelColor:"#000000"}},category:{field:"donorName"},rotate:!0,maximumFractionDigits:2})},n.summaryState)}}]);APP.controller("pipViewController",["$scope","$rootScope","$timeout","contributorsService","uiService","chartsService","categoriesService",function(n,t,i,r,u,f,e){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_PROGRAMME,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={categoryId:null,donorCategoryId:null,donorId:null,regionId:null,countryId:null,programmeId:null,programmeSerialNo:null,awardNumbers:[60478,61722,60856]};n.contributorsState=new DataState;u.initTooltips();n.loadContributors=function(){r.loadPip(function(n){f.makeColumnChart("ChartFundingByContributor",n,{graphs:{pipAmount:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"PIP Amount",showLabel:!0,showBalloon:!0,labelPosition:"right",labelColor:"#000000"}},category:{field:"donorName"},rotate:!0,maximumFractionDigits:2})},n.contributorsState)};n.onFlowChartInit=function(t){t.startLoading();e.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_PROGRAMME&&(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME));e.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("countryCategoryFinancialFlowViewController",["$scope","$state","$timeout","countryService","textsService",function(n,t,i,r,u){n.texts=u.getTexts();n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_DONOR,DATA_TYPE_CATEGORY,DATA_TYPE_PROGRAMME,DATA_TYPE_OUTPUT]);n.flowChartParams={countryCode:t.params.countryCode,categorySerialNo:t.params.categorySerialNo,donorCategoryId:null,donorId:null,categoryId:null,programmeId:null,outputId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_CATEGORY?(n.flowChartParams.categoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_CATEGORY)):t.dataType==DATA_TYPE_PROGRAMME?(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME)):t.dataType==DATA_TYPE_OUTPUT&&(n.flowChartParams.outputId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_OUTPUT));r.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("countryCategoryHomepageViewController",["$scope","$timeout","$state","$sce",function(n,t,i,r){n.iframeUrl=r.trustAsResourceUrl("https://www.who.int/countries/"+i.params.countryCode.toLowerCase())}]);APP.controller("countryCategorySummaryViewController",["$scope","$timeout","$state","countryCategoryService","chartsService","textsService",function(n,t,i,r,u,f){n.countryCode=i.params.countryCode;n.categorySerialNo=i.params.categorySerialNo;n.about=null;n.keyFigures=null;n.charts=null;n.texts=f.getTexts();n.loadAbout=function(){r.loadAbout({countryCode:n.countryCode,categorySerialNo:n.categorySerialNo},function(t){n.$emit(EVENTS.COUNTRY_CATEGORY_LOADED,t);n.about=t})};n.loadKeyFigures=function(){r.loadKeyFigures({countryCode:n.countryCode,categorySerialNo:n.categorySerialNo},function(t){n.keyFigures=t})};n.loadCharts=function(){r.loadCharts({countryCode:n.countryCode,categorySerialNo:n.categorySerialNo},function(t){n.charts=t;n.showKeyFiguresChart();n.showExpensesByTypeChart()})};n.showKeyFiguresChart=function(){u.makeColumnChart("ChartProgramme",n.charts.keyFiguresChart,{graphs:{budgetStaff:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"Staff",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},budgetActivity:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"Activity",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},financing:{lineColor:"#79933C",fillColors:"#79933C",title:"Financing",newStack:!0,labelColor:"#ffffff",labelFontSize:11,showLabel:!0},expTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenses",newStack:!0,labelColor:"#ffffff",labelFontSize:11,showLabel:!0}},category:{field:"programmeLongText"}})};n.showExpensesByTypeChart=function(){u.makeColumnChart("ChartExpensesByType",n.charts.programmeExpensesChart,{graphs:{staff:{title:"Staff and other personnel costs",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},medical:{title:"Medical supplies and materials",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},travel:{title:"Travel",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},contracting:{title:"Contracting services",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},transfers:{title:"Transfers and grants to counterparts",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},equipment:{title:"Equipment, vehicles and furniture",labelColor:"#ffffff",labelFontSize:11,showLabel:!0}},category:{field:"programmeLongText"}})}}]);APP.controller("countryCategoryViewController",["$scope","$timeout","$state","textsService",function(n,t,i,r){n.countryCode=i.params.countryCode;n.countryShortCode=null;n.country=null;n.regionName=null;n.categorySerialNo=null;n.categoryName=null;n.texts=r.getTexts();i.go("country-category.summary");n.$on(EVENTS.COUNTRY_CATEGORY_LOADED,function(t,i){n.country=i?i.countryName:n.countryCode;n.countryShortCode=i?i.countryIso2Code:n.countryCode.substring(0,2);n.regionName=i?i.regionName:"";n.categorySerialNo=i?i.categorySerialNo:"";n.categoryName=i?i.categoryLongText:""})}]);APP.controller("countryFinancialFlowViewController",["$scope","$state","$timeout","countryService",function(n,t,i,r){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_DONOR,DATA_TYPE_CATEGORY,DATA_TYPE_PROGRAMME,DATA_TYPE_OUTPUT]);n.flowChartParams={countryCode:t.params.countryCode,donorCategoryId:null,donorId:null,categoryId:null,programmeId:null,outputId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_CATEGORY?(n.flowChartParams.categoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_CATEGORY)):t.dataType==DATA_TYPE_PROGRAMME?(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME)):t.dataType==DATA_TYPE_OUTPUT&&(n.flowChartParams.outputId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_OUTPUT));r.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("countryHomepageViewController",["$scope","$timeout","$state","$sce",function(n,t,i,r){n.iframeUrl=r.trustAsResourceUrl("https://www.who.int/countries/"+i.params.countryCode.toLowerCase())}]);APP.controller("countryKeyAchievementsViewController",["$scope","$state","countryService","$sce",function(n,t,i,r){n.countryCode=t.params.countryCode;n.countryKeyAchievements=null;n.trustAsHtml=function(n){return r.trustAsHtml(n)};n.loadKeyAchievements=function(){i.loadCountryReview({CountryCode:n.countryCode},function(t){n.countryKeyAchievements=t.reviewText;n.$emit(EVENTS.COUNTRY_LOADED,t)})}}]);APP.controller("countrySummaryViewController",["$scope","$timeout","$state","countryService","iatiFilesService","chartsService","textsService",function(n,t,i,r,u,f,e){n.countryCode=i.params.countryCode;n.keyFigures=null;n.expensesByType=null;n.documents=null;n.iatiFiles=null;n.texts=e.getTexts();n.loadKeyFigures=function(){r.loadKeyFigures(n.countryCode,function(t){var i=t.items.length>0?t.items[0]:null;n.$emit(EVENTS.COUNTRY_LOADED,i);n.keyFigures=t.items})};n.loadExpensesByTypeChartData=function(){r.loadExpensesByTypeChartData(n.countryCode,function(t){n.expensesByType=t;n.showExpensesByTypeChart()})};n.loadDocuments=function(){r.loadDocuments(n.countryCode,function(t){n.documents=t})};n.loadIatiData=function(){u.loadIatiFiles(n.countryCode,function(t){n.iatiFiles=t})};n.showKeyFiguresChart=function(){f.makeColumnChart("ChartCategory",n.keyFigures,{graphs:{budgetStaff:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"Staff",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},budgetActivity:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"Activity",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},financing:{lineColor:"#79933C",fillColors:"#79933C",title:"Financing",newStack:!0,labelColor:"#ffffff",labelFontSize:11,showLabel:!0},expenditureTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenses",newStack:!0,labelColor:"#ffffff",labelFontSize:11,showLabel:!0}},category:{field:"categoryLongText"}})};n.showExpensesByTypeChart=function(){if(n.expensesByType){var t=[],i={};n.expensesByType.forEach(function(n){var r={name:n.name};n.items&&n.items.forEach(function(n){r[n.expenseClass]=n.expenseTotal;i[n.expenseClass]={title:n.expenseClass,labelFontSize:11,showLabel:!0}});t.push(r)});f.makeColumnChart("ChartExpensesByType",t,{graphs:i,category:{field:"name"}})}};n.showCharts=function(){n.loadExpensesByTypeChartData();n.showKeyFiguresChart()}}]);APP.config(["$compileProvider",function(n){n.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|sms|tel|data):/)}]);APP.controller("countryViewController",["$scope","$rootScope","$timeout","$state",function(n,t,i,r){n.countryCode=r.params.countryCode;n.countryShortCode=null;n.country=null;n.regionCode=null;n.regionName=null;t.budget.isEbaActive?r.go("country.keyAchievements"):r.go("country.summary");n.$on(EVENTS.COUNTRY_LOADED,function(t,i){n.countryShortCode=i?i.countryIso2Code:"";n.country=i?i.countryName:n.countryCode;n.regionCode=i?i.regionCode:"";n.regionName=i?i.regionName:""})}]);APP.controller("countryProgrammeFinancialFlowViewController",["$scope","$state","$timeout","countryService",function(n,t,i,r){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_DONOR,DATA_TYPE_OUTPUT]);n.flowChartParams={countryCode:t.params.countryCode,programmeSerialNo:t.params.programmeSerialNo,donorCategoryId:null,donorId:null,categoryId:null,programmeId:null,outputId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_OUTPUT&&(n.flowChartParams.outputId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_OUTPUT));r.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("countryProgrammeHomepageViewController",["$scope","$timeout","$state","$sce",function(n,t,i,r){n.iframeUrl=r.trustAsResourceUrl("https://www.who.int/countries/"+i.params.countryCode.toLowerCase())}]);APP.controller("countryProgrammeSummaryViewController",["$scope","$timeout","$state","countryProgrammeService","chartsService",function(n,t,i,r,u){n.countryCode=i.params.countryCode;n.programmeSerialNo=i.params.programmeSerialNo;n.keyFigures=null;n.charts=null;n.loadKeyFigures=function(){r.loadKeyFigures({countryCode:n.countryCode,programmeSerialNo:n.programmeSerialNo},function(t){n.$emit(EVENTS.COUNTRY_PROGRAMME_LOADED,t);n.keyFigures=t})};n.loadCharts=function(){r.loadCharts({countryCode:n.countryCode,programmeSerialNo:n.programmeSerialNo},function(t){n.charts=t;n.showKeyFiguresChart();n.showExpensesByTypeChart()})};n.clickTest=function(n){alert(n)};n.showKeyFiguresChart=function(){u.makeColumnChart("ChartProgramme",n.charts.keyFiguresChart,{graphs:{budgetStaff:{lineColor:"#3D3F96",fillColors:"#3D3F96",title:"Staff",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},budgetActivity:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"Activity",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},financing:{lineColor:"#79933C",fillColors:"#79933C",title:"Financing",newStack:!0,labelColor:"#ffffff",labelFontSize:11,showLabel:!0},expTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenses",newStack:!0,labelColor:"#ffffff",labelFontSize:11,showLabel:!0}},category:{field:"outputLongText"}})};n.showExpensesByTypeChart=function(){u.makeColumnChart("ChartExpensesByType",n.charts.programmeExpensesChart,{graphs:{staff:{title:"Staff and other personnel costs",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},medical:{title:"Medical supplies and materials",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},travel:{title:"Travel",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},contracting:{title:"Contracting services",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},transfers:{title:"Transfers and grants to counterparts",labelColor:"#ffffff",labelFontSize:11,showLabel:!0},equipment:{title:"Equipment, vehicles and furniture",labelColor:"#ffffff",labelFontSize:11,showLabel:!0}},category:{field:"outputLongText"}})}}]);APP.controller("countryProgrammeViewController",["$scope","$timeout","$state",function(n,t,i){n.countryCode=i.params.countryCode;n.countryShortCode=n.countryCode.substring(0,2);n.country=null;n.regionName=null;n.categorySerialNo=null;n.categoryName=null;n.programmeSerialNo=i.params.programmeSerialNo;n.programmeName=null;i.go("country-programme.summary");n.$on(EVENTS.COUNTRY_PROGRAMME_LOADED,function(t,i){n.country=i?i.countryLongText:n.countryCode;n.countryShortCode=i?i.countryIso2Code:n.countryCode.substring(0,2);n.regionName=i?i.regionLongText:"";n.categorySerialNo=i?i.categorySerialNo:"";n.categoryName=i?i.categoryLongText:"";n.programmeName=i?i.programmeLongText:""})}]);APP.controller("indicatorsViewController",["$scope","$timeout","$state","programmesService","modalDialogsService","uiService",function(n,t,i,r,u,f){console.log(i);n.defaultFiltersValues=null;i.params&&(n.defaultFiltersValues={biennium:i.params.bienniumFilter||i.params.biennium,categoryId:i.params.categoryFilter,programmeId:i.params.programmeFilter});n.indicatorsState=new DataState;n.filters=new RelationsFilters([FILTER_TYPE_BIENNIUM,FILTER_TYPE_CATEGORY,FILTER_TYPE_PROGRAMME],{BIENNIUM:{filterAllEnabled:!1},CATEGORY:{filterAllEnabled:!1}});n.loadFilters=function(){r.loadIndicatorsFilters(function(t){n.filters.buildGroups(t);n.defaultFiltersValues&&(n.defaultFiltersValues.biennium&&n.filters.setSelectedValueForType("BIENNIUM",n.defaultFiltersValues.biennium),n.defaultFiltersValues.categoryId&&n.filters.setSelectedValueForType("CATEGORY",n.defaultFiltersValues.categoryId),n.defaultFiltersValues.programmeId&&n.filters.setSelectedValueForType("PROGRAMME",n.defaultFiltersValues.programmeId),n.defaultFiltersValues=null);n.loadIndicators()})};n.loadIndicators=function(){r.loadIndicators({biennium:n.filters.getSelectedValueForType(FILTER_TYPE_BIENNIUM),categoryId:n.filters.getSelectedValueForType(FILTER_TYPE_CATEGORY),programmeId:n.filters.getSelectedValueForType(FILTER_TYPE_PROGRAMME)},function(){f.initTooltips()},n.indicatorsState)};n.showIndicatorDetails=function(n){u.show({templateUrl:"Views/ModalViews/IndicatorDetails.html",scope:{data:n}})};n.showIndicatorCountryDetails=function(i){u.show({templateUrl:"Views/ModalViews/IndicatorCountryDetails.html",scope:{isReady:!1,data:i,countriesState:new DataState,loadCountriesDetails:function(){var i=this;r.loadIndicatorCountriesDetails({biennium:n.filters.getSelectedValueForType(FILTER_TYPE_BIENNIUM),id:this.data.indicatorCode},function(){t(function(){$("#indicator-countries").DataTable({aLengthMenu:[[10,25,50,100,-1],[10,25,50,100,"All"]],bResetDisplay:!1});i.isReady=!0})},this.countriesState)}}})}}]);APP.controller("selectBienniumModalViewController",["$scope","$rootScope",function(n,t){n.allBienniums=BIENNIUMS.all;n.currentBiennium=t.biennium}]);APP.controller("programmeAboutViewController",["$scope","$timeout","$state","programmesService","textsService",function(n,t,i,r,u){i.current.name=="programme.about"&&i.go("programme.about.about");n.programmeId=i.params.programmeId;n.categoryId=i.params.categoryId;n.about=null;n.aboutState=new DataState;n.results=null;n.deliverables=null;n.keyFigures=null;n.keyFiguresByLevel=null;n.keyFiguresByGeography=null;n.texts=u.getTexts();n.init=function(){switch(i.current.name){case"programme.about.results-structure":n.loadDeliverables();break;case"programme.about.key-figures":n.loadKeyFigures();break;case"programme.about.key-figures-by-level":n.loadKeyFiguresByLevel();break;case"programme.about.key-figures-by-geography":n.loadKeyFiguresByGeography();break;default:n.loadAbout()}};n.loadAbout=function(){r.loadAbout(n.programmeId,function(t){n.about=t;n.$emit(EVENTS.PROGRAMME_LOADED,t)},n.aboutState)};n.loadResults=function(){r.loadResults(n.programmeId,function(t){n.results=t})};n.loadDeliverables=function(){r.loadDeliverables(n.programmeId,function(t){n.deliverables=t})};n.loadKeyFigures=function(){r.loadKeyFigures(n.programmeId,function(t){n.keyFigures=t})};n.loadKeyFiguresByLevel=function(){r.loadKeyFiguresByLevel(n.programmeId,function(t){n.keyFiguresByLevel=t})};n.loadKeyFiguresByGeography=function(){r.loadKeyFiguresByGeography(n.programmeId,function(i){(n.keyFiguresByGeography=i,n.keyFiguresByGeography!=null)&&t(function(){$("#RegionTabs a:first").tab("show")},0)})}}]);APP.controller("programmeEndBienniumAssessmentViewController",["$scope","$state","$timeout","programmesService","chartsService","modalDialogsService","uiService","$sce",function(n,t,i,r,u,f,e,o){n.categoryId=t.params.categoryId;n.programmeId=t.params.programmeId;n.programmeDetailedReportLink=r.getDetailedReportLink(n.programmeId,REVIEW_CYCLE.EBA);n.tabs=null;n.ratingState=new DataState;n.indicatorsState=new DataState;n.keyFiguresState=new DataState;n.indicatorsGraphState=new DataState;n.trustAsHtml=function(n){return o.trustAsHtml(n)};n.loadInfo=function(){r.loadProgrammeInfo(n.programmeId,function(t){n.$emit(EVENTS.PROGRAMME_LOADED,t)})};n.loadTabs=function(){n.loadInfo();r.loadReviewCycleTabs({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(t){n.tabs=t;e.showFirstTab("programme-eba-tabs")})};n.loadRating=function(){r.loadReviewCycleRating({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(){e.initTooltips()},n.ratingState)};n.loadIndicators=function(){r.loadReviewCycleIndicators({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(){e.initTooltips()},n.indicatorsState)};n.loadIndicatorsGraph=function(){r.loadIndicatorsGraph({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(){e.initTooltips()},n.indicatorsGraphState)};n.loadKeyFigures=function(){r.loadReviewCycleKeyFigures({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(n){u.makeColumnChart("EBAChartBudgetExpenseFunding",n.byRegion,{graphs:{approvedBudget:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"WHA Approved Budget",newStack:!0},totalFinancing:{lineColor:"#79933C",fillColors:"#79933C",title:"Funds available",newStack:!0},expTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenditures",newStack:!0}},category:{field:"moName"}})},n.keyFiguresState)};n.showFinancialOverview=function(){f.show({templateUrl:"Views/ModalViews/ReviewCycleFinancialOverview.html",scope:{title:sprintf("Results Report: Financial Overview for Programme: %s",n.keyFiguresState.data.programmeLongText),data:n.keyFiguresState.data.financialOverview}})};n.showIndicatorDetails=function(n){f.show({templateUrl:"Views/ModalViews/IndicatorDetails.html",scope:{data:n}})};n.showIndicatorCountryDetails=function(n){f.show({templateUrl:"Views/ModalViews/IndicatorCountryDetails.html",scope:{isReady:!1,data:n,countriesState:new DataState,loadCountriesDetails:function(){var n=this;r.loadIndicatorCountriesDetails({id:this.data.indicatorCode},function(){i(function(){$("#indicator-countries").DataTable({aLengthMenu:[[10,25,50,100,-1],[10,25,50,100,"All"]],bResetDisplay:!1});n.isReady=!0})},this.countriesState)}}})}}]);APP.controller("programmeFinancialFlowViewController",["$scope","$state","$timeout","programmesService",function(n,t,i,r){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_OUTPUT,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={programmeId:t.params.programmeId,donorCategoryId:null,donorId:null,regionId:null,countryId:null,outputId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_MAJOR_OFFICE?(n.flowChartParams.regionId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_MAJOR_OFFICE)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_OUTPUT&&(n.flowChartParams.outputId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_OUTPUT));r.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("programmeIndicatorsViewController",["$scope","$state","$timeout","programmesService","chartsService","modalDialogsService","uiService","$sce",function(n,t,i,r,u,f,e){n.categoryId=t.params.categoryId;n.programmeId=t.params.programmeId;n.indicatorsState=new DataState;n.indicatorsGraphState=new DataState;n.loadIndicators=function(){r.loadReviewCycleIndicators({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(){e.initTooltips()},n.indicatorsState)};n.loadIndicatorsGraph=function(){r.loadIndicatorsGraph({id:n.programmeId,reviewCycle:REVIEW_CYCLE.EBA},function(){e.initTooltips()},n.indicatorsGraphState)};n.showIndicatorDetails=function(n){f.show({templateUrl:"Views/ModalViews/IndicatorDetails.html",scope:{data:n}})};n.showIndicatorCountryDetails=function(n){f.show({templateUrl:"Views/ModalViews/IndicatorCountryDetails.html",scope:{isReady:!1,data:n,countriesState:new DataState,loadCountriesDetails:function(){var n=this;r.loadIndicatorCountriesDetails({id:this.data.indicatorCode},function(){i(function(){$("#indicator-countries").DataTable({aLengthMenu:[[10,25,50,100,-1],[10,25,50,100,"All"]],bResetDisplay:!1});n.isReady=!0})},this.countriesState)}}})}}]);APP.controller("programmeMidTermReviewViewController",["$scope","$rootScope","$state","$timeout","programmesService","chartsService","modalDialogsService","uiService",function(n,t,i,r,u,f,e,o){n.categoryId=i.params.categoryId;n.programmeId=i.params.programmeId;n.programmeDetailedReportLink=u.getDetailedReportLink(n.programmeId,REVIEW_CYCLE.MTR);n.tabs=null;n.progressState=new DataState;n.keyFiguresState=new DataState;n.loadTabs=function(){u.loadReviewCycleTabs({id:n.programmeId,reviewCycle:REVIEW_CYCLE.MTR},function(t){n.tabs=t;o.showFirstTab("programme-mtr-tabs")})};n.loadProgress=function(){u.loadReviewCycleProgress({id:n.programmeId,reviewCycle:REVIEW_CYCLE.MTR},function(){o.initTooltips()},n.progressState)};n.loadKeyFigures=function(){u.loadReviewCycleKeyFigures({id:n.programmeId,reviewCycle:REVIEW_CYCLE.MTR},function(n){f.makeColumnChart("MTRChartBudgetExpenseFunding",n.byRegion,{graphs:{approvedBudget:{lineColor:"#4F81BD",fillColors:"#4F81BD",title:"WHA Approved Budget",newStack:!0},totalFinancing:{lineColor:"#79933C",fillColors:"#79933C",title:"Funds available",newStack:!0},expTotal:{lineColor:"#F79646",fillColors:"#F79646",title:"Expenditures",newStack:!0}},category:{field:"moName"}})},n.keyFiguresState)};n.showFinancialOverview=function(){e.show({templateUrl:"Views/ModalViews/ReviewCycleFinancialOverview.html",scope:{title:sprintf("Mid Term Review: Financial Overview for Programme: %s",n.keyFiguresState.data.programmeLongText),data:n.keyFiguresState.data.financialOverview}})}}]);APP.controller("programmeTopStoriesViewController",["$scope","$state","programmesService",function(n,t,i){n.programmeId=t.params.programmeId;n.categoryId=t.params.categoryId;n.topStoriesState=new DataState;n.selectedStory=null;n.loadTopStories=function(){i.loadTopStories(n.programmeId,function(){var t=n.topStoriesState.data;t&&t.length>0&&(n.selectedStory=t[0])},n.topStoriesState)};n.showStory=function(t){n.selectedStory=t}}]);APP.controller("programmeViewController",["$scope","$timeout","$state","$rootScope","textsService",function(n,t,i,r,u){n.programmeId=i.params.programmeId;n.categoryId=i.params.categoryId;n.texts=u.getTexts();i.current.name=="programme"&&(r.budget.isEbaActive?i.go("programme.eba"):i.go("programme.about"));n.$on(EVENTS.PROGRAMME_LOADED,function(n,t){r.programme=t})}]);APP.controller("regionAboutViewController",["$scope","$timeout","$state","regionsService","textsService",function(n,t,i,r,u){i.current.name=="region.about"&&i.go("region.about.about");n.regionCode=i.params.regionCode;n.about=null;n.aboutState=new DataState;n.texts=u.getTexts();n.keyFiguresAllFilters=null;n.keyFiguresByCategoryState=new DataState;n.keyFiguresByProgrammeState=new DataState;n.keyFiguresFilters=new RelationsFilters([FILTER_TYPE_BUDGET_SEGMENT,FILTER_TYPE_SEGMENT,FILTER_TYPE_CATEGORY],{BUDGET_SEGMENT:{filterAllEnabled:!1},CATEGORY:{filterAllEnabled:!1}});n.keyFiguresByLevel=null;n.keyFiguresByLevelFilters=new RelationsFilters([FILTER_TYPE_BUDGET_SEGMENT,FILTER_TYPE_SEGMENT,FILTER_TYPE_CATEGORY,FILTER_TYPE_PROGRAMME],{BUDGET_SEGMENT:{filterAllEnabled:!1}});n.keyFiguresByGeographyState=new DataState;n.keyFiguresByGeographyFilters=new RelationsFilters([FILTER_TYPE_BUDGET_SEGMENT,FILTER_TYPE_SEGMENT,FILTER_TYPE_CATEGORY,FILTER_TYPE_PROGRAMME],{BUDGET_SEGMENT:{filterAllEnabled:!1}});n.init=function(){switch(i.current.name){case"region.about.key-figures":n.loadKeyFiguresFilters();break;case"region.about.key-figures-by-level":n.loadKeyFiguresByLevelFilters();break;case"region.about.key-figures-by-geography":n.loadKeyFiguresByGeographyFilters();break;default:n.loadAbout()}};n.loadAbout=function(){r.loadAbout(n.regionCode,function(t){n.about=t;n.$emit(EVENTS.REGION_LOADED,t)},n.aboutState)};n.loadKeyFiguresFilters=function(){if(n.keyFiguresAllFilters){n.keyFiguresFilters.buildGroups(n.keyFiguresAllFilters);n.loadKeyFigures();return}r.loadKeyFiguresFilters(n.regionCode,function(t){n.keyFiguresAllFilters=t;n.keyFiguresFilters.buildGroups(n.keyFiguresAllFilters);n.loadKeyFigures()})};n.loadKeyFigures=function(){n.loadKeyFiguresByCategory();n.loadKeyFiguresByProgramme()};n.loadKeyFiguresByCategory=function(){var t=f(n.keyFiguresFilters);r.loadKeyFiguresByCategory(n.regionCode,t,function(){},n.keyFiguresByCategoryState)};n.loadKeyFiguresByProgramme=function(){var t=f(n.keyFiguresFilters);r.loadKeyFiguresByProgramme(n.regionCode,t,function(){},n.keyFiguresByProgrammeState)};n.loadKeyFiguresByLevelFilters=function(){if(n.keyFiguresAllFilters){n.keyFiguresByLevelFilters.buildGroups(n.keyFiguresAllFilters);n.loadKeyFiguresByLevel();return}r.loadKeyFiguresFilters(n.regionCode,function(t){n.keyFiguresAllFilters=t;n.keyFiguresByLevelFilters.buildGroups(n.keyFiguresAllFilters);n.loadKeyFiguresByLevel()})};n.loadKeyFiguresByLevel=function(){var t=f(n.keyFiguresByLevelFilters);r.loadKeyFiguresByLevel(n.regionCode,t,function(t){n.keyFiguresByLevel=t})};n.loadKeyFiguresByGeographyFilters=function(){if(n.keyFiguresAllFilters){n.keyFiguresByGeographyFilters.buildGroups(n.keyFiguresAllFilters);n.loadKeyFiguresByGeography();return}r.loadKeyFiguresFilters(n.regionCode,function(t){n.keyFiguresAllFilters=t;n.keyFiguresByGeographyFilters.buildGroups(n.keyFiguresAllFilters);n.loadKeyFiguresByGeography()})};n.loadKeyFiguresByGeography=function(){var t=f(n.keyFiguresByGeographyFilters);r.loadKeyFiguresByGeography(n.regionCode,t,function(){},n.keyFiguresByGeographyState)};var f=function(n){return{budgetSegment:n.getSelectedValueForType(FILTER_TYPE_BUDGET_SEGMENT),segment:n.getSelectedValueForType(FILTER_TYPE_SEGMENT),categoryId:n.getSelectedValueForType(FILTER_TYPE_CATEGORY),programmeId:n.getSelectedValueForType(FILTER_TYPE_PROGRAMME)}}}]);APP.controller("regionFinancialFlowViewController",["$scope","$state","$timeout","regionsService","textsService",function(n,t,i,r,u){n.texts=u.getTexts();n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_MAJOR_OFFICE,DATA_TYPE_CATEGORY,DATA_TYPE_PROGRAMME,DATA_TYPE_OUTPUT,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={regionId:t.params.regionCode,donorCategoryId:null,donorId:null,categoryId:null,countryId:null,programmeId:null,outputId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_CATEGORY?(n.flowChartParams.categoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_CATEGORY)):t.dataType==DATA_TYPE_PROGRAMME?(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME)):t.dataType==DATA_TYPE_COUNTRY?(n.flowChartParams.countryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_COUNTRY)):t.dataType==DATA_TYPE_OUTPUT&&(n.flowChartParams.outputId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_OUTPUT));r.loadFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("regionHqAboutViewController",["$scope","$timeout","$state","regionsService","chartsService","modalDialogsService","textsService",function(n,t,i,r,u,f,e){i.current.name=="region-hq.about"&&i.go("region-hq.about.about");n.regionCode="HQ";n.aboutState=new DataState;n.texts=e.getTexts();n.keyFiguresState=new DataState;n.selectedKeyFiguresFilter=null;n.keyFiguresByCategory=null;n.keyFiguresByCategoryExpendinture=null;n.keyFiguresByProgrammeState=new DataState;n.keyFiguresByProgrammeFilters=new RelationsFilters([FILTER_TYPE_SEGMENT,FILTER_TYPE_CATEGORY]);n.keyFiguresByOutputState=new DataState;n.keyFiguresByOutputFilters=new RelationsFilters([FILTER_TYPE_SEGMENT,FILTER_TYPE_CATEGORY,FILTER_TYPE_PROGRAMME]);n.outputContributersState=new DataState;n.outputExpendituresState=new DataState;n.init=function(){switch(i.current.name){case"region-hq.about.key-figures":n.loadKeyFigures();break;case"region-hq.about.key-figures-by-programme":n.loadKeyFiguresByProgrammeFilters();break;case"region-hq.about.key-figures-by-output":n.loadKeyFiguresByOutputFilters();break;default:n.loadAbout()}};n.loadAbout=function(){r.loadAbout(n.regionCode,function(){},n.aboutState)};n.loadKeyFigures=function(){r.loadHqKeyFigures(function(){var t=n.keyFiguresState.data.filters;t&&t.length>0&&(n.selectedKeyFiguresFilter=t[0],n.showKeyFiguresByCategory())},n.keyFiguresState)};n.showKeyFiguresByCategory=function(){var t=n.selectedKeyFiguresFilter,i,r;t&&(i=n.keyFiguresState.data.byCategory,i&&(n.keyFiguresByCategory=i[t.value]),r=n.keyFiguresState.data.byCategoryExpenditure,r&&(n.keyFiguresByCategoryExpendinture=r[t.value]))};n.loadKeyFiguresByProgrammeFilters=function(){if(n.keyFiguresByProgrammeFilters.exists()){n.loadKeyFiguresByProgramme();return}r.loadHqKeyFiguresByProgrammeFilters(function(t){n.keyFiguresByProgrammeFilters.buildGroups(t);n.loadKeyFiguresByProgramme()})};n.loadKeyFiguresByProgramme=function(){var t=o(n.keyFiguresByProgrammeFilters);r.loadHqKeyFiguresByProgramme(n.regionCode,t,function(){},n.keyFiguresByProgrammeState)};n.loadKeyFiguresByOutputFilters=function(){if(n.keyFiguresByOutputFilters.exists()){n.loadKeyFiguresByOutput();return}r.loadKeyFiguresFilters(n.regionCode,function(t){n.keyFiguresByOutputFilters.buildGroups(t);n.loadKeyFiguresByOutput()})};n.loadKeyFiguresByOutput=function(){var t=o(n.keyFiguresByOutputFilters);r.loadHqKeyFiguresByOutput(n.regionCode,t,function(){},n.keyFiguresByOutputState)};n.loadOutputContributors=function(t){if(t){var i=o(n.keyFiguresByOutputFilters);r.loadOutputContributors(t.outputShortText,i,function(){},n.outputContributersState);f.show({templateUrl:"Views/RegionsViews/ModalViews/RegionOutputContributorsModalView.html",scope:{contributersState:n.outputContributersState}})}};n.loadOutputExpenditures=function(t){if(t){var i=o(n.keyFiguresByOutputFilters);r.loadOutputExpenditures(t.outputShortText,i,function(){},n.outputExpendituresState);f.show({templateUrl:"Views/RegionsViews/ModalViews/RegionOutputExpendituresModalView.html",scope:{expendituresState:n.outputExpendituresState}})}};var o=function(n){return{segment:n.getSelectedValueForType(FILTER_TYPE_SEGMENT),categoryId:n.getSelectedValueForType(FILTER_TYPE_CATEGORY),programmeId:n.getSelectedValueForType(FILTER_TYPE_PROGRAMME)}}}]);APP.controller("RegionHqViewController",["$scope","$timeout","$state","regionsService","chartsService",function(n,t,i){i.current.name=="region-hq"&&i.go("region-hq.about.about")}]);APP.controller("regionHqFinancialFlowViewController",["$scope","$state","$timeout","regionsService",function(n,t,i,r){n.flowChartClickableNodesTypes=new FlowChartClickableNodesTypes([DATA_TYPE_DONOR_CATEGORY,DATA_TYPE_CATEGORY,DATA_TYPE_PROGRAMME,DATA_TYPE_OUTPUT,DATA_TYPE_COUNTRY,DATA_TYPE_DONOR]);n.flowChartParams={donorCategoryId:null,donorId:null,categoryId:null,programmeId:null,outputId:null};n.onFlowChartInit=function(t){t.startLoading();r.loadHqFinancingFlow(n.flowChartParams,function(i){t.pushState(i,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});t.endLoading()})};n.onFlowChartStatePop=function(t){n.flowChartParams=t.params.flowChartParams;n.flowChartClickableNodesTypes=t.params.flowChartClickableNodesTypes};n.onFlowChartNodeClick=function(t,i){i.startLoading();t.dataType==DATA_TYPE_DONOR_CATEGORY?(n.flowChartParams.donorCategoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR_CATEGORY)):t.dataType==DATA_TYPE_DONOR?(n.flowChartParams.donorId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_DONOR)):t.dataType==DATA_TYPE_CATEGORY?(n.flowChartParams.categoryId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_CATEGORY)):t.dataType==DATA_TYPE_PROGRAMME?(n.flowChartParams.programmeId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_PROGRAMME)):t.dataType==DATA_TYPE_OUTPUT&&(n.flowChartParams.outputId=t.dataId,n.flowChartClickableNodesTypes.remove(DATA_TYPE_OUTPUT));r.loadHqFinancingFlow(n.flowChartParams,function(t){i.pushState(t,{flowChartParams:n.flowChartParams,flowChartClickableNodesTypes:n.flowChartClickableNodesTypes});i.endLoading()})}}]);APP.controller("regionsViewController",["$scope","$state","$timeout","regionsService",function(n,t,i,r){function u(){var t=n.regionsState.data;t&&t.length>0&&(n.selectedRegion=t[0],n.showRegionOnMap(n.selectedRegion),i(function(){$("#regions-accordion .collapse:not(:first)").collapse({toggle:!0,parent:"#regions-accordion"})},0))}n.regionsState=new DataState;n.selectedRegion=null;n.map=null;n.markers={};n.geocoder=null;n.init=function(){n.loadRegions()};n.loadRegions=function(){r.loadRegionsMaps(function(){u()},n.regionsState)};n.onMapReady=function(t){n.map=t;n.geocoder=new google.maps.Geocoder;n.showRegionOnMap(n.selectedRegion)};n.showRegionOnMap=function(t){if(n.selectedRegion=t,n.map&&n.geocoder&&n.selectedRegion){var i=function(i,r,u){var e=new google.maps.LatLng(i,r),f;n.map.setCenter(e);n.map.setZoom(u||13);f=n.markers[t.regionCode];f||(f=new google.maps.Marker({map:n.map,position:e,title:t.regionName,icon:IMAGE_PIN_MAJOR_OFFICE}),n.markers[t.regionCode]=f)};if(t.geoLatitude&&t.geoLongitude){i(t.geoLatitude,t.geoLongitude,t.zoom);return}n.geocoder.geocode({address:t.moPostalAddress},function(n,r){if(r==google.maps.GeocoderStatus.OK){var u=n[0].geometry.location.lat(),f=n[0].geometry.location.lng();i(u,f,t.zoom)}})}}}]);APP.controller("regionViewController",["$scope","$timeout","$state",function(n,t,i){n.region=null;i.current.name=="region"&&i.go("region.about.about");n.$on(EVENTS.REGION_LOADED,function(t,i){n.region=i})}]);APP.controller("contactUsController",["$scope","$timeout","$state","apiService",function(n,t,i,r){n.hideFeedbackLoader=!0;n.feedback={name:"",email:"",phone:"",comment:""};n.showHeadquarterOnMap=function(){var n=new GMaps({div:"#gmapbg",lat:46.232927,lng:6.134325,zoom:11,scrollwheel:!1});n.addMarker({lat:46.232927,lng:6.134325,title:"Headquarters",visible:!0,icon:"/content/img/layout/logos/Logo-Stamp-SM.png",infoWindow:{content:"<h3>World Health Organization<\/h3><p>Avenue Appia 20, 1211, Geneve 27, Switzerland<\/p>"}})};var u=function(){$("#feedbackForm").find("input,textarea").val("")};n.sendMessage=function(){n.feedbackForm.$valid&&(n.hideFeedbackLoader=null,r.sendData("contactUs/request-feedback",n.feedback,function(t){n.hideFeedbackLoader=!0;t&&t.status===200?($("#feedbackSuccessModal").modal(),u()):$("#feedbackFailureModal").modal()},i))}}]);APP.controller("iatiDataController",["$scope","$timeout","$state","iatiFilesService",function(){}]);APP.controller("iatiFilesController",["$scope","$timeout","$state","iatiFilesService",function(n,t,i,r){n.iatiFiles=null;n.loadIatiFiles=function(){r.loadAllIatiFiles(function(t){n.iatiFiles=t})};n.loadIatiFiles()}]);APP.config(["$compileProvider",function(n){n.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|sms|tel|data):/)}]);APP.controller("keyDocumentsController",["$scope","$timeout","$state","documentsService",function(n,t,i,r){n.documents=null;n.selectedSection="";n.loadDocuments=function(){r.loadSectionDocuments(function(t){n.documents=t})};n.showDocuments=function(t){n.selectedSection=t?t:""};n.loadDocuments()}]);APP.filter("unique",function(){return function(n,t){var i=[],r=[];return angular.forEach(n,function(n){var u=n[t];r.indexOf(u)===-1&&(r.push(u),i.push(n))}),i}});APP.controller("resolutionsAndDecisionsController",["$scope","$state","resolutionsAndDecisionsService",function(n,t,i){var r=this;n.data=null;n.filtersSource=null;n.selected={meetingType:null,meetingName:null,documentCode:null,year:null,keyword:null};n.filters={meetingTypes:[],meetingNames:[],documentCodes:[],years:[]};n.loadFilters=function(){i.loadFilters(function(t){n.filtersSource=t;n.updateFilters()})};n.updateFilters=function(){var i,t;n.filters.years=n.filtersSource.years;n.filters.meetingTypes=n.filtersSource.meetingTypes;i=n.filtersSource.meetingNames;n.selected.meetingType&&(i=i.filter(function(t){return t.meetingType==n.selected.meetingType}));n.filters.meetingNames=i.map(function(n){return n.meetingName}).filter(function(n,t,i){return i.indexOf(n)===t});t=n.filtersSource.documentCodes;n.selected.meetingName?t=t.filter(function(t){return t.meetingName==n.selected.meetingName}):n.selected.meetingType&&(t=t.filter(function(t){return n.filters.meetingNames.indexOf(t.meetingName)>-1}));n.filters.documentCodes=t.map(function(n){return n.documentCode}).filter(function(n,t,i){return i.indexOf(n)===t});n.selected.documentCode&&n.filters.documentCodes.indexOf(n.selected.documentCode)==-1&&(n.selected.documentCode=null)};n.search=function(){i.search(n.selected,function(t){n.data=t})}}]);APP.directive("budgetTable",["$timeout",function(){return{restrict:"E",templateUrl:"Views/Directives/BudgetTable.html",scope:{items:"=",footer:"=",itemsTitle:"@",nameField:"@",staffField:"@",activityField:"@",totalField:"@",financingField:"@",financingPercentField:"@",expField:"@",onFinancingDetailsClick:"&",onExpDetailsClick:"&"},link:function(){},controller:["$scope","uiService",function(n,t){t.initTooltips();n.isFinancingDetailsEnabled=function(){return!!n.onFinancingDetailsClick()};n.isExpDetailsEnabled=function(){return!!n.onExpDetailsClick()}}]}}]);APP.directive("countriesBudgetTable",["$timeout",function(){return{restrict:"E",templateUrl:"Views/Directives/CountriesBudgetTable.html",scope:{items:"=",footer:"=",itemsTitle:"@",nameField:"@",staffField:"@",activityField:"@",totalField:"@",financingField:"@",financingPercentField:"@",flagField:"@",expField:"@"},link:function(){},controller:["uiService","$scope","$rootScope",function(n,t,i){t.biennium=i.biennium;n.initTooltips()}]}}]);APP.directive("countryCategoryProgrammeTable",["$timeout",function(){return{restrict:"E",templateUrl:"Views/Directives/CountryCategoryProgrammeTable.html",scope:{items:"=",header:"@",itemsTitle:"@",total:"=",biennium:"@",countryCode:"@",nameField:"=categoryLongText",staffField:"=budgetStaffFormatted",activityField:"=budgetActivityFormatted",totalField:"=budgetTotalFormatted",financingField:"=financingFormatted",financingPercentField:"=financingPercent",expField:"=expenditureTotalFormatted"},link:function(){},controller:["uiService",function(n){n.initTooltips()}]}}]);APP.directive("countryCategoryTable",["$timeout",function(){return{restrict:"E",templateUrl:"Views/Directives/CountryCategoryTable.html",scope:{items:"=",itemsTitle:"@",nameField:"=categoryLongText",staffField:"=budgetStaffFormatted",activityField:"=budgetActivityFormatted",totalField:"=budgetTotalFormatted",financingField:"=financingFormatted",financingPercentField:"=financingPercent",expField:"=expenditureTotalFormatted"},link:function(){},controller:["$scope","uiService",function(n,t){n.$watch("items",function(){t.initTooltips()})}]}}]);APP.directive("countryProgrammeOutputTable",["$timeout",function(){return{restrict:"E",templateUrl:"Views/Directives/CountryProgrammeOutputTable.html",scope:{items:"=",header:"@",itemsTitle:"@",total:"=",biennium:"@",countryCode:"@",categorySerialNo:"@",nameField:"=categoryLongText",staffField:"=budgetStaffFormatted",activityField:"=budgetActivityFormatted",totalField:"=budgetTotalFormatted",financingField:"=financingFormatted",financingPercentField:"=financingPercent",expField:"=expenditureTotalFormatted"},link:function(){},controller:["uiService",function(n){n.initTooltips()}]}}]);var NODE_TYPE_DISTRIBUTION_SOURCE="DS",NODE_TYPE_DISTRIBUTION_TARGET="DT",NODE_TYPE_EXPENDITURE_SOURCE="ES",NODE_TYPE_EXPENDITURE_TARGET="ET",ALL_NODE_TYPES=[NODE_TYPE_DISTRIBUTION_SOURCE,NODE_TYPE_DISTRIBUTION_TARGET,NODE_TYPE_EXPENDITURE_SOURCE,NODE_TYPE_EXPENDITURE_TARGET],LINK_TYPE_DISTRIBUTION_TO_DISTRIBUTION="D2D",LINK_TYPE_DISTRIBUTION_TO_EXPENDITURE="D2E",LINK_TYPE_EXPENDITURE_TO_EXPENDITURE="E2E",ALL_LINK_TYPES=[LINK_TYPE_DISTRIBUTION_TO_DISTRIBUTION,LINK_TYPE_DISTRIBUTION_TO_EXPENDITURE,LINK_TYPE_EXPENDITURE_TO_EXPENDITURE],DATA_TYPE_DONOR_CATEGORY="DC",DATA_TYPE_DONOR="DN",DATA_TYPE_MAJOR_OFFICE="MO",DATA_TYPE_PROGRAMME="PM",DATA_TYPE_CATEGORY="CG",DATA_TYPE_COUNTRY="CT",DATA_TYPE_OUTPUT="OP",FlowChartClickableNodesTypes=function(n){this.types=n||[];this.remove=function(n){this.types&&(this.types=this.types.filter(function(t){return t!==n}))};this.isNodeClickable=function(n){return n&&this.types&&$.inArray(n.dataType,this.types)>=0}};APP.directive("flowChart",["$timeout",function(n){function tt(n,t){if(n){i=n;o={states:[],pushState:function(n,r,u){var f=this;y(n);u&&(f.states=[]);f.states.push({chartData:n,params:angular.copy(r)});i.isBackEnable=f.states.length>1;t(function(){h()})},popState:function(){var n=this,r,u;n.states.length<=1||(n.states.pop(),r=n.states[n.states.length-1],y(r.chartData),u=i.onChartStatePop(),u&&u({chartData:r.chartData,params:angular.copy(r.params)},n),i.isBackEnable=n.states.length>1,t(function(){h()}))},startLoading:function(){r=!1;at()},endLoading:function(){r=!0;vt()}};i.chartStateManager=o;i.isBackEnable=!1;i.onBackClick=function(){r&&(o.popState(),k())};var u=i.onChartInit();u&&u(i.chartStateManager);navigator.userAgent.match(/iPhone|iPad|iPod/i)?$(window).bind("touchend touchcancel touchleave",function(){h()}):$(window).scroll(function(){h()})}}function y(n){try{if(t=it(n),!t)return;rt();ut()}catch(i){console.log(i)}}function it(n){function f(){this.byId={};this.byType={};this.byTypeAndId={};this.byTypeAndDataId={};var n=this;ALL_NODE_TYPES.forEach(function(t){n.byType[t]=[];n.byTypeAndId[t]={};n.byTypeAndDataId[t]={}})}var u=d3.select("#"+i.chartId),t,r;return(u.selectAll("*").remove(),!n)?null:(t=new f,n.nodes.forEach(function(n){t.byId[n.id]=n;t.byType[n.type].push(n);t.byTypeAndId[n.type][n.id]=n;t.byTypeAndDataId[n.type][n.dataId]=n}),n.links=n.links.map(function(n){return typeof n.source!="object"&&(n.source=t.byId[n.source]),typeof n.target!="object"&&(n.target=t.byId[n.target]),n}),r={},ALL_NODE_TYPES.forEach(function(n){var i=0;t.byType[n].forEach(function(n){i=Math.max(n.percent,i)});r[n]=i}),{chartData:n,chartSankey:null,chartSvg:u.append("svg"),chartWidth:i.chartWidth,chartHeight:i.chartHeight,nodesMap:t,nodeMaxPercentByType:r,isNodeClickable:function(n){return i.clickableNodesTypes&&i.clickableNodesTypes.isNodeClickable(n)}})}function rt(){var r=t.chartData,o=t.chartWidth,n=t.chartHeight,i,f;n||(i=null,ALL_NODE_TYPES.forEach(function(n){var r=t.nodesMap.byType[n];(i==null||r.length>i.length)&&(i=r)}),n=0,i.forEach(function(t){n+=Math.max(v,t.percent)+l}));t.chartSvg.attr({width:+o+e.x*2,height:+n+e.y*2});t.chartSankey=d3.sankey().nodeWidth(c).nodePadding(l).size([o,n]);t.chartSankey.nodes(r.nodes).links(r.links).layout(nt);f=t.nodesMap;f.byType[NODE_TYPE_EXPENDITURE_SOURCE].forEach(function(n){n.y=f.byTypeAndDataId[NODE_TYPE_DISTRIBUTION_TARGET][n.dataId].y});r.nodes.forEach(function(n){var t=n.targetLinks,i;t&&t.length>0?(i=t[0].source,n.x=i.x+d+c):n.x=0});r.nodes.forEach(function(n){n.x+=e.x;n.y+=e.y;n.color=u[n.type];var i=n.percent,r=t.nodeMaxPercentByType[n.type];n.type==NODE_TYPE_EXPENDITURE_SOURCE&&n.targetLinks&&n.targetLinks.length>0&&(i=n.targetLinks[0].source.percent,r=t.nodeMaxPercentByType[NODE_TYPE_DISTRIBUTION_TARGET]);n.opacity=Math.max(g,i/r)})}function ut(){var n=t.chartSvg.append("g"),i;ft(n);et(n);i=n.node().getBBox();n.attr("transform",function(){var n=i.width>430?Math.max((t.chartSvg.attr("width")-i.width)/2,0):0,r=Math.max((t.chartSvg.attr("height")-i.height)/2,0);return sprintf("translate(%s, %s)",n,r)})}function ft(n){var i=n.append("g"),u=i.selectAll(".link").data(t.chartData.links).enter(),r=u.append("path").attr({"class":"link",d:t.chartSankey.link(),id:function(n){return n.id}}).style("stroke-width",function(n){return Math.max(2,n.dy)}).on({mouseover:ct,mouseout:lt});r.append("title").text(function(n){return n.subtitle});r.each(function(n){if(n.type==LINK_TYPE_DISTRIBUTION_TO_EXPENDITURE){var t=this.getBBox(),r=i.append("text").attr("x",t.x+t.width/2).attr("text-anchor","middle").text(n.title),u=r.node().getBBox();r.attr("y",t.y+Math.min(u.height/2,n.target.dy/2)-f);r.call(p,a)}})}function et(n){var i=n.append("g").selectAll(".node").data(t.chartData.nodes).enter().append("g").classed("clickable",t.isNodeClickable).classed("node",!0).attr({transform:function(n){return sprintf("translate(%(x)f, %(y)f)",n)}}).on({mouseover:ot,mouseout:st,click:function(n){ht(n,t)}});i.append("rect").attr({width:t.chartSankey.nodeWidth(),height:function(n){return Math.max(v,n.dy)}}).style({fill:function(n){return n.color},stroke:function(n){return n.color},opacity:function(n){return n.opacity}});i.append("title").text(function(n){return n.subtitle});i.append("text").attr("text-anchor",function(n){return n.type==NODE_TYPE_EXPENDITURE_TARGET?"start":"end"}).attr("transform",null).text(function(n){return n.type==NODE_TYPE_DISTRIBUTION_SOURCE||n.type==NODE_TYPE_EXPENDITURE_TARGET?n.title:null}).attr("x",function(n){return n.type==NODE_TYPE_DISTRIBUTION_SOURCE?-f:t.chartSankey.nodeWidth()+f}).attr("y",function(){return 0}).call(p,a).call(function(n){n.each(function(n){var r=this.getBBox(),t,i;r&&(t=n.dy/2-r.height/2+f,i=d3.select(this),i.attr("y",t),i.selectAll("tspan").attr("y",t))})})}function p(n,t){n.each(function(){for(var n=d3.select(this),s=n.text().split(/\s+/).reverse(),r,i=[],h=0,f=n.attr("x"),e=n.attr("y"),o=.35,u=n.text(null).append("tspan").attr("x",f).attr("y",e).attr("dy",o+"em");r=s.pop();)i.push(r),u.text(i.join(" ")),u.node().getComputedTextLength()>t&&(i.pop(),u.text(i.join(" ")),i=[r],u=n.append("tspan").attr("x",f).attr("y",e).attr("dy",++h*1.1+o+"em").text(r))})}function ot(n){r&&(s([n],function(n){return n.sourceLinks},function(n){return n.target}),s([n],function(n){return n.targetLinks},function(n){return n.source}))}function st(){b()}function ht(n){if(r&&t.isNodeClickable(n)){var u=i.onNodeClick();u&&u(n,o)}}function ct(n){r&&(w(n),s([n.target],function(n){return n.sourceLinks},function(n){return n.target}),s([n.source],function(n){return n.targetLinks},function(n){return n.source}))}function lt(){b()}function s(n,t,i){function r(n,t,i){n&&n.forEach(function(n){var u=t(n);u&&u.forEach(function(n){w(n);r([i(n)],t,i)})})}r(n,t,i);d3.selectAll("svg .link:not(.active)").classed("disabled",!0)}function w(n){d3.select("#"+n.id).classed("active",!0).classed("disabled",!1)}function b(){var n=t.chartSvg;n.selectAll(".active").classed("active",!1);n.selectAll(".disabled").classed("disabled",!1)}function at(){$("#preloader-"+i.chartId).show();$("#"+i.chartId).removeClass("disabled").addClass("disabled");k()}function vt(){$("#preloader-"+i.chartId).hide();$("#"+i.chartId).removeClass("disabled")}function k(){var r=i.autoscrollEnabled(),n,t;(typeof r=="undefined"||r)&&(n=0,t=$("#"+i.chartId).offset(),t&&(n=Math.max(0,t.top-300)),$("html, body").animate({scrollTop:n},600))}function h(){var u,f;if(i){var r=$(sprintf('[chart-id="%(chartId)s"]',i)),t=r.find(".flow-chart"),n=r.find(".btn-zoom-out");t&&n&&t.length!=0&&n.length!=0&&(u=t[0].getBoundingClientRect(),f=n[0].getBoundingClientRect(),u.top-100>f.top?n.fadeTo(0,0):n.fadeTo(0,1))}}var c=15,l=65,f=10,a=200,v=2,e={x:200,y:0},d=200,g=.25,nt=32,u={};u[NODE_TYPE_DISTRIBUTION_SOURCE]=d3.rgb(49,99,168);u[NODE_TYPE_DISTRIBUTION_TARGET]=d3.rgb(195,62,37);u[NODE_TYPE_EXPENDITURE_SOURCE]=d3.rgb(195,62,37);u[NODE_TYPE_EXPENDITURE_TARGET]=d3.rgb(81,168,44);var o=null,t=null,i=null,r=!1;return{restrict:"E",templateUrl:"Views/Directives/FlowChart.html",scope:{chartStateManager:"=?",clickableNodesTypes:"=?",chartId:"@",chartWidth:"@",chartHeight:"@",chartLeftTitle:"@",chartMiddleTitle:"@",chartRightTitle:"@",isBackEnable:"=?",autoscrollEnabled:"&",onChartInit:"&",onChartStatePop:"&",onNodeClick:"&",onBackClick:"&?"},link:function(){},controller:["$scope",function(t){tt(t,n)}]}}]);APP.directive("indicator",["chartsService",function(n){return{restrict:"E",templateUrl:"Views/Directives/Indicator.html",scope:{chartId:"=",chartData:"="},link:function(t){t.getChartId=function(){return t.chartId?t.chartId.replace(/\./g,"-"):t.chartId};t.$watch("chartData",function(i){n.makeIndicatorChart(t.getChartId(),i)})}}}]);var IMAGE_PIN_MAJOR_OFFICE="content/img/layout/logos/Logo-Stamp-SM.png",MAP_MEDIATOR=function(){return{isMapLoaded:!1,isMapApiLoaded:!1,loadMapAndApi:function(n,t,i){if(i)$(this).one(MAP_MEDIATOR_EVENTS.MAP_API_READY,function(){i()});if(google.maps&&(this.isMapApiLoaded=!0,this.isMapLoaded=!0),this.isMapApiLoaded){$(this).trigger(MAP_MEDIATOR_EVENTS.MAP_API_READY);return}if(!this.isMapLoaded){this.isMapLoaded=!0;var r=document.createElement("script");r.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(r);r.src=sprintf("http://maps.googleapis.com/maps/api/js?key=%s&v=%s&callback=MAP_MEDIATOR.loadMapCallback",n,t)}},loadMapCallback:function(){this.isMapApiLoaded=!0;$(this).trigger(MAP_MEDIATOR_EVENTS.MAP_API_READY)}}}(),MAP_MEDIATOR_EVENTS={MAP_API_READY:"MAP_API_READY"};APP.directive("googleMap",["$timeout",function(n){function t(t){MAP_MEDIATOR.loadMapAndApi(t.mapKey,t.mapVersion,function(){n(function(){i(t)},500)})}function i(n){var i=new google.maps.Map(document.getElementById(n.mapId),{zoom:13,center:n.mapCenter(),styles:[{featureType:"administrative",elementType:"labels.text.fill",stylers:[{color:"#444444"}]},{featureType:"landscape",elementType:"all",stylers:[{color:"#f2f2f2"}]},{featureType:"poi",elementType:"all",stylers:[{visibility:"off"}]},{featureType:"road",elementType:"all",stylers:[{saturation:-100},{lightness:45}]},{featureType:"road.highway",elementType:"all",stylers:[{visibility:"simplified"}]},{featureType:"road.arterial",elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"all",stylers:[{visibility:"off"}]},{featureType:"water",elementType:"all",stylers:[{color:"#46bcec"},{visibility:"on"}]}]}),t=n.onMapReady();t&&t(i)}return{restrict:"E",templateUrl:"Views/Directives/Map.html",scope:{mapId:"@",mapKey:"@",mapVersion:"@",mapCenter:"&",onMapReady:"&"},link:function(n){t(n)}}}]);APP.directive("pieChart",["chartsService",function(n){return{restrict:"E",templateUrl:"Views/Directives/PieChart.html",scope:{chartId:"@",chartHeight:"@",chartData:"=",chartConfig:"&",labelsEnabled:"&",valuesEnabled:"&",legendsEnabled:"&",radius:"&",colors:"&",title:"@",valueField:"@",titleField:"@"},link:function(t){t.$watch("chartData",function(i){n.makePieChart(t.chartId,i||[],{title:t.title,valueField:t.valueField,titleField:t.titleField,labelsEnabled:t.labelsEnabled(),valuesEnabled:t.valuesEnabled(),legendsEnabled:t.legendsEnabled(),config:t.chartConfig(),radius:t.radius(),colors:t.colors()})})}}}]);APP.directive("preloader",["$timeout",function(n){return{restrict:"E",templateUrl:"Views/Directives/Preloader.html",link:function(t,i,r){var u=r.contentId,e=function(){n(function(){i.hide();angular.element("#"+u).show()},0)},o=function(){n(function(){i.show();angular.element("#"+u).hide()},0)},f=function(n){typeof n!="undefined"&&n&&n.length>0&&t.$watch(n,function(n){typeof n!="undefined"&&n?e():o()})};f(r.watchData);f(r.watchState)}}}]);APP.directive("relationsFilters",["$timeout",function(){return{restrict:"E",templateUrl:"Views/Directives/RelationsFilters.html",scope:{filters:"=",type:"@",onFilterChange:"&"},link:function(){},controller:["$scope","textsService",function(n,t){n.onChange=function(){var t=n.onFilterChange();t&&t()};var i=t.getTexts();n.getOptionName=function(n){var t=n.name;return i[t]||t}}]}}])