function GetTemplateUrl(n){return"Views/"+n}function ApteryxConfig(n){n.when("/Entities",{templateUrl:GetTemplateUrl("Entities"),modelName:"Entity",reloadOnSearch:!1});n.when("/Entities/:id",{templateUrl:GetTemplateUrl("EntitiesItem"),modelName:"Entity",reloadOnSearch:!1});n.when("/Entities/Setup/:id",{templateUrl:GetTemplateUrl("DirectInvestorEntityOnlySetup"),reloadOnSearch:!1});n.when("/Entities/:greatGreatGrandparentId/RelatedPortfolios/:greatGrandparentId/Roles/:grandparentId/Rights/:parentId/Config/:id",{templateUrl:GetTemplateUrl("PortfolioRightConfigItem"),modelName:"RightConfig",reloadOnSearch:!1});n.when("/Entities/:parentId/Relationships/:id",{templateUrl:GetTemplateUrl("EntityRelationshipsItem"),modelName:"EntityRelationship",reloadOnSearch:!1});n.when("/Entities/:parentId/RoleEntityLink/:id",{templateUrl:GetTemplateUrl("RoleEntityLinksItem"),modelName:"RoleEntityLink",reloadOnSearch:!1});n.when("/Entities/:parentId/EntityRoleTarget/:id",{templateUrl:GetTemplateUrl("EntityRoleTargetItem"),reloadOnSearch:!1});n.when("/System/Rights",{templateUrl:GetTemplateUrl("Rights"),modelName:"Right",reloadOnSearch:!1});n.when("/System/Rights/:id",{templateUrl:GetTemplateUrl("RightsItem"),modelName:"Right",reloadOnSearch:!1});n.when("/Roles",{templateUrl:GetTemplateUrl("Roles"),reloadOnSearch:!1});n.when("/Roles/:id",{templateUrl:GetTemplateUrl("RolesDetail"),reloadOnSearch:!1});n.when("/Roles/:parentId/Rights/:id",{templateUrl:GetTemplateUrl("RightRolesItem"),modelName:"RightRole",reloadOnSearch:!1});n.when("/MarketAssetTrades",{templateUrl:GetTemplateUrl("MarketAssetTrades"),reloadOnSearch:!1});n.when("/MarketAssetTrades/:id",{templateUrl:GetTemplateUrl("MarketAssetTradeItem"),reloadOnSearch:!1});n.when("/ContractNotes",{templateUrl:GetTemplateUrl("ContractNoteSearch"),reloadOnSearch:!1});n.when("/ContractNotes/:id",{templateUrl:GetTemplateUrl("ContractNoteDetail"),reloadOnSearch:!1});n.when("/MarketFXSwitches",{templateUrl:GetTemplateUrl("MarketFXSwitchSearch"),reloadOnSearch:!1});n.when("/MarketFXSwitches/:id",{templateUrl:GetTemplateUrl("MarketFXSwitchDetail"),reloadOnSearch:!1});n.when("/BulkTrades",{templateUrl:GetTemplateUrl("BulkTradeSearch"),reloadOnSearch:!1});n.when("/BulkTrades/:id",{templateUrl:GetTemplateUrl("BulkTradeDetail"),reloadOnSearch:!1});n.when("/OrderAuthorityQueue",{templateUrl:GetTemplateUrl("OrderAuthorityQueue"),reloadOnSearch:!1});n.when("/MarketCashTrades",{templateUrl:GetTemplateUrl("MarketCashTrades"),modelName:"MarketCashTrade",reloadOnSearch:!1});n.when("/System/Custodians",{templateUrl:GetTemplateUrl("Custodians"),modelName:"Custodian",reloadOnSearch:!1});n.when("/System/Custodians/:id",{templateUrl:GetTemplateUrl("CustodiansItem"),modelName:"Custodian",reloadOnSearch:!1});n.when("/System/Custodians/:parentId/Nominees/:id",{templateUrl:GetTemplateUrl("NomineesItem"),modelName:"Nominee",reloadOnSearch:!1});n.when("/System/Custodians/:grandparentId/Nominees/:parentId/Brokers/:id",{templateUrl:GetTemplateUrl("NomineeBrokerLinkItem"),modelName:"NomineeBrokerLink",reloadOnSearch:!1});n.when("/System/Custodians/:grandparentId/Nominees/:parentId/Currencies/:id",{templateUrl:GetTemplateUrl("NomineeCurrencyLinkItem"),modelName:"NomineeCurrencyLink",reloadOnSearch:!1});n.when("/System/Custodians/:grandparentId/Nominees/:parentId/Organisations/:id",{templateUrl:GetTemplateUrl("NomineeOrganisationLinkItem"),modelName:"NomineeOrganisationLink",reloadOnSearch:!1});n.when("/System/Organisations",{templateUrl:GetTemplateUrl("Organisations"),modelName:"Organisation",reloadOnSearch:!1});n.when("/System/Organisations/:id",{templateUrl:GetTemplateUrl("OrganisationsItem"),modelName:"Organisation",reloadOnSearch:!1});n.when("/System/Organisations/:parentId/OrganisationReportPackItems/:id",{templateUrl:GetTemplateUrl("OrganisationReportPackItem"),modelName:"OrganisationReportPack",reloadOnSearch:!1});n.when("/System/Organisations/:parentId/Services/:id",{templateUrl:GetTemplateUrl("ServicesItem"),modelName:"Service",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/RestrictedAssets/:id",{templateUrl:GetTemplateUrl("ServiceRestrictedAssetItem"),modelName:"ServiceRestrictedAsset",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/RestrictedEntityTypes/:id",{templateUrl:GetTemplateUrl("ServiceEntityTypeLinkItem"),modelName:"ServiceEntityTypeLink",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/RestrictedEntityTypeRelationships/:id",{templateUrl:GetTemplateUrl("ServiceEntityTypeRelationshipLinkItem"),reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceAuthorities/:id",{templateUrl:GetTemplateUrl("ServiceAuthorityItem"),modelName:"ServiceAuthority",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceBrokers/:id",{templateUrl:GetTemplateUrl("ServiceBrokerLinkItem"),modelName:"ServiceBrokerLink",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceCurrencies/:id",{templateUrl:GetTemplateUrl("ServiceCurrencyLinkItem"),reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceFileLinks/:id",{templateUrl:GetTemplateUrl("ServiceFileLinkDetail"),modelName:"ServiceFileLink",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceCustomSectorItems/:id",{templateUrl:GetTemplateUrl("ServiceCustomSectorItem"),modelName:"ServiceCustomSector",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceCustomStrategyItems/:id",{templateUrl:GetTemplateUrl("ServiceCustomStrategyItem"),modelName:"ServiceCustomStrategy",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceEmailTemplateItems/:id",{templateUrl:GetTemplateUrl("ServiceEmailTemplateItem"),modelName:"ServiceEmailTemplate",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceIndicesItems/:id",{templateUrl:GetTemplateUrl("ServiceIndicesItem"),modelName:"ServiceIndices",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceReportSettingItems/:id",{templateUrl:GetTemplateUrl("ServiceReportSettingItem"),modelName:"ServiceReportSetting",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/ServiceReportPackItems/:id",{templateUrl:GetTemplateUrl("ServiceReportPackItem"),modelName:"ServiceReportPack",reloadOnSearch:!1});n.when("/System/Organisations/:parentId/Staff/:id",{templateUrl:GetTemplateUrl("StaffsItem"),modelName:"Staff",reloadOnSearch:!1});n.when("/System/Organisations/:parentId/RoleStaffLink/:id",{templateUrl:GetTemplateUrl("RoleStaffLinksItem"),modelName:"RoleEntityLink",reloadOnSearch:!1});n.when("/System/Organisations/:parentId/RoleOrganisationLink/:id",{templateUrl:GetTemplateUrl("RoleOrganisationLinksItem"),modelName:"RoleOrganisationLink",reloadOnSearch:!1});n.when("/System/Organisations/:parentId/Roles/:id/Rights",{templateUrl:GetTemplateUrl("RolesItemRights"),reloadOnSearch:!1});n.when("/System/Organisations/:parentId/Roles/:id/WebApi",{templateUrl:GetTemplateUrl("RolesItemWebApi"),reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/Fees/:id",{templateUrl:GetTemplateUrl("FeeStructuresItem"),modelName:"FeeStructure",reloadOnSearch:!1});n.when("/System/Organisations/:greatGrandparentId/Services/:grandparentId/Fees/:parentId/Scales/:id",{templateUrl:GetTemplateUrl("FeeScalesItem"),modelName:"FeeScale",reloadOnSearch:!1});n.when("/System/Organisations/:grandparentId/Services/:parentId/SimpleTemplateModels/:id",{templateUrl:GetTemplateUrl("SimpleTemplateModelsItem"),modelName:"SimpleTemplateModel",reloadOnSearch:!1});n.when("/System/Fees/:feeStructureId/Rules/:id",{templateUrl:GetTemplateUrl("FeeRule"),reloadOnSearch:!1});n.when("/System/ControllerMetadata",{templateUrl:GetTemplateUrl("ControllerMetadata"),reloadOnSearch:!1});n.when("/System/TestSummaries",{templateUrl:GetTemplateUrl("ControllerSecurityTestSummaries"),reloadOnSearch:!1});n.when("/System/TestSummaries/:id",{templateUrl:GetTemplateUrl("ControllerSecurityTestResults"),modelName:"TestSummary",reloadOnSearch:!1});n.when("/System/TestSummaries/:parentId/TestResults/:id",{templateUrl:GetTemplateUrl("ControllerSecurityTestResultDetails"),modelName:"TestResult",reloadOnSearch:!1});n.when("/System/PerformanceMetrics/WebCallDuratation",{templateUrl:GetTemplateUrl("WebCallDurationMetrics"),reloadOnSearch:!1});n.when("/System/PerformanceMetrics/WebCallBatchDuratation",{templateUrl:GetTemplateUrl("WebCallBatchDurationMetrics"),reloadOnSearch:!1});n.when("/System/PerformanceMetrics/Jobs",{templateUrl:GetTemplateUrl("JobPerformanceMetrics"),modelName:"JobPerformanceMetrics",reloadOnSearch:!1});n.when("/System/PerformanceMetrics/Jobs/Detail",{templateUrl:GetTemplateUrl("JobPerformanceMetricsDetail"),modelName:"JobPerformanceMetrics",reloadOnSearch:!1});n.when("/System/EntityTypeRelationships",{templateUrl:GetTemplateUrl("EntityTypeRelationships"),modelName:"EntityTypeRelationship",reloadOnSearch:!1});n.when("/System/EntityTypeRelationships/:id",{templateUrl:GetTemplateUrl("EntityTypeRelationshipsItem"),modelName:"EntityTypeRelationship",reloadOnSearch:!1});n.when("/System/Assets",{templateUrl:GetTemplateUrl("AssetSearch"),reloadOnSearch:!1});n.when("/System/Assets/:id",{templateUrl:GetTemplateUrl("AssetDetail"),modelName:"Product",reloadOnSearch:!1});n.when("/System/Assets/:parentId/PrivateAssets/:id",{templateUrl:GetTemplateUrl("ServicePrivateAssetItem"),modelName:"ServicePrivateAsset",reloadOnSearch:!1});n.when("/System/Currencies",{templateUrl:GetTemplateUrl("CurrencySearch"),reloadOnSearch:!1});n.when("/System/Currencies/:id",{templateUrl:GetTemplateUrl("CurrencyDetail"),reloadOnSearch:!1});n.when("/System/FxDirection",{templateUrl:GetTemplateUrl("FxDirectionSearch"),reloadOnSearch:!1});n.when("/System/Variance",{templateUrl:GetTemplateUrl("VarianceSearch"),reloadOnSearch:!1});n.when("/System/ContractNoteEmails",{templateUrl:GetTemplateUrl("ContractNoteEmailSearch"),reloadOnSearch:!1});n.when("/System/ContractNoteEmails/:id",{templateUrl:GetTemplateUrl("ContractNoteEmailDetail"),reloadOnSearch:!1});n.when("/System/ContractNoteEmails/:parentId/Files/:id",{templateUrl:GetTemplateUrl("ContractNoteFileDetail"),reloadOnSearch:!1});n.when("/Portfolios",{templateUrl:GetTemplateUrl("Portfolios"),reloadOnSearch:!1});n.when("/Portfolios/:id",{templateUrl:GetTemplateUrl("PortfoliosItem"),reloadOnSearch:!1});n.when("/Portfolios/:portfolioId/RecurringReports/:id",{templateUrl:GetTemplateUrl("RecurringReport"),reloadOnSearch:!1});n.when("/Portfolios/:portfolioId/PortfolioIndicesItems/:id",{templateUrl:GetTemplateUrl("PortfolioIndicesItem"),modelName:"PortfolioIndices",reloadOnSearch:!1});n.when("/Portfolios/:portfolioId/PortfolioReportSettingItems/:id",{templateUrl:GetTemplateUrl("PortfolioReportSettingItem"),modelName:"PortfolioReportSetting",reloadOnSearch:!1});n.when("/Portfolios/:id/Link/New",{templateUrl:GetTemplateUrl("Link"),reloadOnSearch:!1});n.when("/System/Workflow",{templateUrl:GetTemplateUrl("Workflow"),controller:BasicSearchController,resolve:{modelName:function(){return"Workflow"},breadcrumbs:function(){return[{title:function(){return"Home"},icon:function(){return"home"},path:"#/"},{title:function(){return"Entities"},icon:function(){return"star"},path:""}]}},reloadOnSearch:!1});n.when("/Workflow/:id",{templateUrl:GetTemplateUrl("WorkflowItem"),controller:WorkflowController,modelName:"hehhe",reloadOnSearch:!1});n.when("/Workflow/NewClientLoadProcess",{templateUrl:GetTemplateUrl("NewClientLoadProcess"),controller:NewClientLoadProcessController,reloadOnSearch:!1});n.when("/System",{templateUrl:GetTemplateUrl("SystemHome")});n.when("/System/ApplicationErrors",{templateUrl:GetTemplateUrl("ApplicationErrors"),reloadOnSearch:!1});n.when("/System/ApplicationHealth",{templateUrl:GetTemplateUrl("ApplicationHealth"),reloadOnSearch:!1});n.when("/System/Audit",{templateUrl:GetTemplateUrl("AuditSearch"),reloadOnSearch:!1});n.when("/System/Banks",{templateUrl:GetTemplateUrl("BankSearch"),reloadOnSearch:!1});n.when("/System/Brands",{templateUrl:GetTemplateUrl("BrandSearch"),reloadOnSearch:!1});n.when("/System/Brands/:id",{templateUrl:GetTemplateUrl("BrandItem"),modelName:"Brand",reloadOnSearch:!1});n.when("/System/Brands/:parentId/BrandFileLinks/:id",{templateUrl:GetTemplateUrl("BrandFileLinkItem"),modelName:"BrandFileLink",reloadOnSearch:!1});n.when("/System/Brokers",{templateUrl:GetTemplateUrl("BrokerSearch"),reloadOnSearch:!1});n.when("/System/Brokers/:id",{templateUrl:GetTemplateUrl("BrokerItem"),modelName:"Broker",reloadOnSearch:!1});n.when("/System/Brokers/:parentId/Exchanges/:id",{templateUrl:GetTemplateUrl("BrokerExchangeLinkItem"),modelName:"BrokerExchangeLink",reloadOnSearch:!1});n.when("/System/Charts",{templateUrl:GetTemplateUrl("Charts"),reloadOnSearch:!1});n.when("/System/Country",{templateUrl:GetTemplateUrl("CountrySearch"),reloadOnSearch:!1});n.when("/System/Country/:id",{templateUrl:GetTemplateUrl("CountryDetail"),modelName:"UserCountry"});n.when("/System/EntityType",{templateUrl:GetTemplateUrl("EntityType"),reloadOnSearch:!1});n.when("/System/EntityType/:id",{templateUrl:GetTemplateUrl("EntityTypeDetail")});n.when("/System/Events",{templateUrl:GetTemplateUrl("Events"),reloadOnSearch:!1});n.when("/System/Log",{templateUrl:GetTemplateUrl("EventSearch"),reloadOnSearch:!1});n.when("/System/Log/:id",{templateUrl:GetTemplateUrl("EventDetail"),modelName:"Event"});n.when("/System/JobErrors",{templateUrl:GetTemplateUrl("JobErrors"),reloadOnSearch:!1});n.when("/System/JobMessageDetail/:id",{templateUrl:GetTemplateUrl("JobMessageDetail"),modelName:"JobMessage"});n.when("/System/Jobs",{templateUrl:GetTemplateUrl("Jobs"),reloadOnSearch:!1});n.when("/System/Jobs/:id",{templateUrl:GetTemplateUrl("JobDetail"),reloadOnSearch:!1});n.when("/System/JobSchedule",{templateUrl:GetTemplateUrl("JobSchedule"),reloadOnSearch:!1});n.when("/System/JobSchedule/:id",{templateUrl:GetTemplateUrl("JobScheduleDetail"),modelName:"JobSchedule",reloadOnSearch:!1});n.when("/System/Service",{templateUrl:GetTemplateUrl("ServiceSearch"),reloadOnSearch:!1});n.when("/System/Service/:id",{templateUrl:GetTemplateUrl("Service"),reloadOnSearch:!1});n.when("/System/Service/:serviceId/Reports/:id",{templateUrl:GetTemplateUrl("ServiceReportDetail"),reloadOnSearch:!1});n.when("/System/Nominee",{templateUrl:GetTemplateUrl("NomineeSearch"),reloadOnSearch:!1});n.when("/System/Nominee/:id",{templateUrl:GetTemplateUrl("NomineeDetail")});n.when("/System/RequiredDocument",{templateUrl:GetTemplateUrl("RequiredDocumentSearch"),reloadOnSearch:!1});n.when("/System/RequiredDocument/:id",{templateUrl:GetTemplateUrl("RequiredDocumentDetail")});n.when("/System/Organisations/:organisationId/LinkedReportDefinitions/:id",{templateUrl:GetTemplateUrl("OrganisationReportDefinitionLink"),reloadOnSearch:!1});n.when("/System/Users",{templateUrl:GetTemplateUrl("SystemUsers"),modelName:"User",reloadOnSearch:!1});n.when("/System/Users/:id",{templateUrl:GetTemplateUrl("SystemUser"),modelName:"User",reloadOnSearch:!1});n.when("/System/Workers",{templateUrl:GetTemplateUrl("Workers"),reloadOnSearch:!1});n.when("/System/Sessions",{templateUrl:GetTemplateUrl("Sessions"),reloadOnSearch:!1});n.when("/System/Tokens",{templateUrl:GetTemplateUrl("Tokens"),reloadOnSearch:!1});n.when("/System/Files",{templateUrl:GetTemplateUrl("Files"),reloadOnSearch:!1});n.when("/System/Settings",{templateUrl:GetTemplateUrl("SettingsSearch"),reloadOnSearch:!1});n.when("/System/Settings/:id",{templateUrl:GetTemplateUrl("SettingsDetail")});n.when("/System/Config",{templateUrl:GetTemplateUrl("ConfigSearch"),reloadOnSearch:!1});n.when("/System/Config/:id",{templateUrl:GetTemplateUrl("ConfigDetail")});n.when("/System/ReportPacks",{templateUrl:GetTemplateUrl("ReportPacks"),reloadOnSearch:!1});n.when("/System/ReportPackItems/:id",{templateUrl:GetTemplateUrl("ReportPacksItems"),modelName:"ReportPack",reloadOnSearch:!1});n.when("/System/ReportDefinitions",{templateUrl:GetTemplateUrl("ReportDefinitions"),reloadOnSearch:!1});n.when("/System/ReportDefinitions/:id",{templateUrl:GetTemplateUrl("ReportDefinition"),reloadOnSearch:!1});n.when("/System/ReportDefinitions/:reportDefinitionId/LinkedOrganisations/:id",{templateUrl:GetTemplateUrl("ReportDefinitionOrganisationLink"),reloadOnSearch:!1});n.when("/User",{templateUrl:GetTemplateUrl("User"),reloadOnSearch:!1});n.when("/ContactUs",{templateUrl:GetTemplateUrl("ContactUs"),reloadOnSearch:!1});n.when("/Notifications",{templateUrl:GetTemplateUrl("Notifications"),reloadOnSearch:!1});n.when("/About",{templateUrl:GetTemplateUrl("About")});n.when("/p/:id",{templateUrl:GetTemplateUrl("PortfolioDetail"),reloadOnSearch:!1});n.when("/p/Maintenance/:id",{templateUrl:GetTemplateUrl("PortfolioMaintenance"),reloadOnSearch:!1});n.when("/Summary/:id",{templateUrl:GetTemplateUrl("PortfolioDetail.Group"),reloadOnSearch:!1});n.when("/MyDashboard",{templateUrl:GetTemplateUrl("MyDashboard"),reloadOnSearch:!1});n.when("/MyDashboard/MyPortfolio/:id",{templateUrl:GetTemplateUrl("MyPortfolio"),reloadOnSearch:!1});n.when("/PortfolioEntityLink/:id",{templateUrl:GetTemplateUrl("PortfolioEntityLink"),reloadOnSearch:!1});n.when("/PortfolioBankAccounts/:id",{templateUrl:GetTemplateUrl("PortfolioBankAccount"),modelName:"PortfolioBankAccount",reloadOnSearch:!1});n.when("/0/:name",{templateUrl:function(n){return GetTemplateUrl(n.name)},reloadOnSearch:!1});n.when("/1/:name",{templateUrl:function(n){return GetTemplateUrl(n.name+"Search")},reloadOnSearch:!1});n.when("/1/:name/:id",{templateUrl:function(n){return GetTemplateUrl(n.name+"Detail")},reloadOnSearch:!1});n.when("/2/:parentName/:parentId/:name/:id",{templateUrl:function(n){return GetTemplateUrl(n.name+"Detail")},reloadOnSearch:!1});n.when("/3/:grandparentName/:grandparentId/:parentName/:parentId/:name/:id",{templateUrl:function(n){return GetTemplateUrl(n.name+"Detail")},reloadOnSearch:!1});n.when("/",{templateUrl:GetTemplateUrl("MyDashboard"),reloadOnSearch:!1});n.when(PAGE_NOT_FOUND_ROUTE_PATH,{templateUrl:GetTemplateUrl("PageNotFound")});n.otherwise({redirectTo:PAGE_NOT_FOUND_ROUTE_PATH})}function formatMessage(n){return"<small>"+getClockTime()+" <strong>"+n+"<\/strong><\/small>"}function generateMessage(n,t){return"<p class='"+t+"'>"+formatMessage(n)+"<\/p>"}function jsEngineLogMessage(n,t,i){var r=document.getElementById(n);r&&(r.innerHTML=generateMessage(t,i)+r.innerHTML)}function formatDuration(n){var t=(new Date).getTime()-n.getTime(),i="text-success";return t>1e3?i="text-error":t>100&&(i="text-warning"),"<span class='"+i+"'>"+t+" ms<\/span>"}function roundNumber(n,t){return Math.round(n*Math.pow(10,t))/Math.pow(10,t)}function calcPageSize(){var n=$("html").html().length,t=n/1024;return"Page Size: "+roundNumber(t,2)+" kB"}function formatDataReceived(){var n=bytesReceived/1024;return"Bytes Received: "+roundNumber(n,2)+" kB"}function formatDataSent(){var n=bytesSent/1024;return"Bytes Sent: "+roundNumber(n,2)+" kB"}function showSize(n,t,i){var f=document.getElementById(n),r,u;f&&(f.innerText=calcPageSize());r=document.getElementById(t);r&&(r.innerText=formatDataReceived());u=document.getElementById(i);u&&(u.innerText=formatDataSent());setTimeout("showSize('"+n+"','"+t+"','"+i+"')",100)}function isArray(n){return Object.prototype.toString.call(n)==="[object Array]"}function isDefined(n){return!(typeof n=="undefined")}function isNull(n){return!(n!=null)}function isNullOrUndefined(n){return isDefined(n)?isNull(n)?!0:!1:!0}function isUndefinedOrEmptyString(n){return isDefined(n)?n==""?!0:!1:!0}function pad(n,t,i){return i=i||"0",n=n+"",n.length>=t?n:new Array(t-n.length+1).join(i)+n}function showTime(n){var t=document.getElementById(n);t&&(t.innerText=getDateTime(),setTimeout("showTime('"+n+"')",100))}function getDateTime(){var n=getCalendarDate(),t=getClockTime();return n+" "+t}function getCalendarDate(){return getCalendarDateInt(new Date)}function getCalendarDateInt(n){var t=new Array(13);t[0]="January";t[1]="February";t[2]="March";t[3]="April";t[4]="May";t[5]="June";t[6]="July";t[7]="August";t[8]="September";t[9]="October";t[10]="November";t[11]="December";var i=n.getMonth(),r=t[i],u=n.getDate(),f=n.getFullYear();return u+" "+r+" "+f}function getISODate(n){var t=Date.UTC(n.getFullYear(),n.getMonth(),n.getDate());return new Date(t).toISOString()}function isValidDate(n){return Object.prototype.toString.call(n)!=="[object Date]"?!1:isNaN(n.getTime())?!1:!0}function getDebugTime(){var n=new Date;return getClockTimeInt(n)+"."+n.getMilliseconds()}function getClockTime(){return getClockTimeInt(new Date)}function getClockTimeInt(n){var n=new Date,t=n.getHours(),i=n.getMinutes(),r=n.getSeconds(),u="AM",f;return t>11&&(u="PM"),t>12&&(t=t-12),t==0&&(t=12),f=t<10?"0"+t.toString():t.toString(),f+=i<10?":0"+i.toString():":"+i.toString(),f+(r<10?":0"+r.toString()+" "+u:":"+r.toString()+" "+u)}function clearElement(n){var t=document.getElementById(n);t&&(t.innerHTML="")}function showHide(n,t){show(n);hide(t)}function toggle(n){var t=document.getElementById(n);t&&(t.style.display=="none"?(show(n),t.textContent=t.textContent.replace("Hide","Show")):(hide(n),t.textContent=t.textContent.replace("Show","Hide")))}function hide(n){var t=document.getElementById(n);t&&(t.style.display="none")}function show(n){var t=document.getElementById(n);t&&(t.style.display="block")}function getDefaultHttpConfig(n){var t=n?6e4:1e4;return{timeout:t,cache:!1}}function WaitReset(n,t,i,r){n.timeoutHandle&&t.cancel(n.timeoutHandle);n.timeoutHandle=t(r,i)}function LogStateToConsole(n){n?console.log(JSON.parse(JSON.stringify(n))):console.log(n)}function getSessionId(){return"header"}function parseDate(n){return moment(n).toDate()}function setIntersection(n,t){return n.filter(function(n){return t.indexOf(n)!=-1})}function addSpaceBetweenWords(n){return n.split(/(?=[A-Z])/).join(" ")}var UtilFactory=function(){function n(){}return n.prototype.InjectAnnotation=function(n,t){n.$inject=t},n}(),Util=new UtilFactory,App=angular.module("amadeus",["ngAnimate","ngRoute","ngSanitize","angularSpinner","ui.bootstrap","ui.utils","$strap.directives"],ApteryxConfig),bytesReceived,bytesSent,DurationMetricsInterceptor,BiService,ChartService,CommonService,DateService,DebugService,EventService,JobService,ModelServiceOptions,ModelService,ModelServiceFake,NotificationActionService,NotificationService,NotificationStateService,SearchService,SecureMailService,SignalrController,SignalrService,StateService,SessionService,SignInService,StaticDataService,TaskService,ToastService,UserService,ValidationService,widget,google,AddressFinder,AuthenticationData,AuthenticationController;angular.module("MyApp",[]).run(function(n,t,i){var r;for(var u in t.routes)(r=t.routes[u].templateUrl)&&i.get(r,{cache:n})});App.run(["$rootScope",function(){}]);Util.InjectAnnotation(ApteryxConfig,["$routeProvider","$locationProvider"]);bytesReceived=0;bytesSent=0;DurationMetricsInterceptor=function(){function n(n,t,i,r){var u=this;this.areDiagnosticsEnabled=!1;this.exchangeId_Key="ExchangeId";this.request=function(n){if(u.IsCallSupported(n)){u.LogDiagnosticsMessage("Request Interceptor EXECUTED for: "+n.method+" "+n.url);var t=u.CallSupportsCaching(n);u.LoadingService.StartWebCallTiming(n.url,t)}else u.LogDiagnosticsMessage("Request Interceptor IGNORED for: "+n.method+" "+n.url);return n||u.$q.when(n)};this.response=function(n){var t=n.config,i=n.headers;return u.HandleResponse(t,i,"Response"),n||u.$q.when(n)};this.responseError=function(n){var t=n.config,i=n.headers;return u.HandleResponse(t,i,"Response Error"),u.$q.reject(n)};this.HandleResponse=function(n,t,i){if(u.IsCallSupported(n)){u.LogDiagnosticsMessage(i+" Interceptor EXECUTED for: "+n.method+" "+n.url);var r=t(u.exchangeId_Key);u.LoadingService.StopWebCallTiming(n.url,r)}else u.LogDiagnosticsMessage(i+" Interceptor IGNORED for: "+n.method+" "+n.url)};this.LogDiagnosticsMessage=function(n){u.areDiagnosticsEnabled&&console.log(n)};this.IsCallSupported=function(n){return u.StateService.IsAuthenticated?n.method=="GET"&&n.url.indexOf("api/StaticData")==-1&&n.url.indexOf("api/Job")==-1:!1};this.CallSupportsCaching=function(n){var t=n.method.toUpperCase();return n.cache!=null&&n.cache!==!1&&t==="GET"};this.IsCallToPersistMetrics=function(n,t){return n==="POST"&&t.indexOf("api/PerformanceMetricsBatch")>-1};this.$q=n;this.$cacheFactory=t;this.LoadingService=i;this.StateService=r}return n.$inject=["$q","$cacheFactory","LoadingService","State"],n}();App.service("DurationMetricsInterceptor",DurationMetricsInterceptor);App.config(["$httpProvider",function(n){n.interceptors.push("DurationMetricsInterceptor")}]);App.config(["$provide",function(n){n.decorator("$exceptionHandler",["$delegate",function(n){return function(t,i){var u=t.toString(),r=getStackTrace(t),f=i?r+"\n\n"+i:r;logClientError(u,f);n(t,i)}}])}]);App.config(["$animateProvider",function(n){n.classNameFilter(/animate/)}]);App.config(["usSpinnerConfigProvider",function(n){n.setDefaults({lines:11,length:4,width:2,radius:4,corners:1,rotate:0,trail:75,speed:1.5})}]);BiService=function(){function n(n,t,i,r,u,f,e,o){this.$q=n;this.$route=t;this.Common=i;this.Model=r;this.Chart=u;this.eventService=f;this.Notification=e;this.sessionService=o}return n.prototype.GetBiStuff=function(n,t,i,r,u,f,e){var o=this,s=this.$q.defer(),h="";return angular.forEach(i,function(n){h+=n+","}),f?(n.isReloading=!0,this.Model.GetWithParams(this.Common,t,{Portfolios:h,Type:"Summary",Date:r},function(t){o.DumpBiStuffOnTheUI(n,i,t,u,!0,e);n.isReloading=!1;s.resolve()})):(n.hasValuation=!1,n.hasExposure=!1,n.isLoadingSummary=!0,n.isLoadingHistory=!0,this.Model.GetWithParams(this.Common,t,{Portfolios:h,Type:"Summary",Date:r},function(c){var l=new ModelServiceOptions,a,v;l.params={Portfolios:h,Type:"History",Date:r};l.useExtendedTimeout=!0;a=Number(o.sessionService.GetCurrentDateTimeOffset());v=moment().add(a,"milliseconds").startOf("day").add(-3,"months");!u||moment(u.CreatedDate)<v?(n.showHistory=!0,o.Model.LoadList2(t,l).then(function(t){o.DumpBiStuffOnTheUI(n,i,t,u,f,e);n.isLoadingHistory=!1;s.resolve()})):s.resolve();o.DumpBiStuffOnTheUI(n,i,c,u,f,e);n.isLoadingSummary=!1})),s.promise},n.prototype.DumpBiStuffOnTheUI=function(n,t,i,r,u,f){var e=this;i.Valuation.Date&&(i.Valuation.Date=moment(i.Valuation.Date).toDate());n.current=i;n.summary={valuation:i.Valuation,hideCashBalance:i.Valuation.HideCash,portfolio:r,isReloading:n.isReloading};n.jobId=null;n.areWaitingOnJob=!1;n.exposure={tab:"Sector",valuation:i.Valuation};n.hasValuation=i.Valuation.HasValuation;n.hasExposure=i.Valuation.HasExposure;n.valuation={summary:n.summary,exposure:n.exposure,hasExposure:n.hasExposure,tab:"Summary",bi:i,isCombinedValuation:f};u||(n.settings=this.Chart.GetPortfolioHistoryChartSettings(i.ValuationHistory,i.CapitalMovements,t,i.Valuation.CurrencySymbol,i.showPerformance,function(n){e.eventService.Broadcast("BiReload",n.date);$("html,body").animate({scrollTop:0},600)}));n.summary.summaryBalanceSettings=this.Chart.GetSummaryBalanceChartSettings(i.ValuationHistory,function(){});n.exposure.sectors=this.Chart.GetSectorChartSettings(i.Valuation.Sectors,function(t){e.Chart.GotoSplit(n,n.summary.valuation.Sectors,t)});n.exposure.strategies=this.Chart.GetStrategyChartSettings(i.Valuation.Strategies,function(t){e.Chart.GotoSplit(n,n.summary.valuation.Strategies,t)});n.exposure.cash=this.Chart.GetCashChartSettings(i.Valuation.Cash,function(t){e.Chart.GotoSplit(n,n.summary.valuation.Cash,t)})},n.$inject=["$q","$route","Common","Model","Chart","Event","Notification","Session"],n}();App.service("Bi",BiService);ChartService=function(){function n(n){this.$timeout=n}return n.prototype.GetCashChartSettings=function(n,t){var i=[];return angular.forEach(n,function(n){i.push([n.Name,n.PortfolioWeighting*100])}),{chart:{plotBackgroundColor:null,plotBorderWidth:null,plotShadow:!1},title:{text:null,style:{color:"#000000",fontFamily:"Helvetica, Arial, sans-serif"}},tooltip:{enabled:!1},plotOptions:{pie:{allowPointSelect:!0,cursor:"pointer",size:"66%",dataLabels:{enabled:!0,color:"#000000",connectorColor:"#000000",format:"<b>{point.name}<\/b>: {point.y:.0f}%"},point:{events:{click:function(){this.state!="select"&&t(this.color)}}}}},series:[{type:"pie",data:i}]}},n.prototype.GetSectorChartSettings=function(n,t){var i=[];return angular.forEach(n,function(n){i.push([n.Name,n.PortfolioWeighting*100])}),{chart:{plotBackgroundColor:null,plotBorderWidth:null,plotShadow:!1},title:{text:null,style:{color:"#000000",fontFamily:"Helvetica, Arial, sans-serif"}},tooltip:{enabled:!1},plotOptions:{pie:{allowPointSelect:!0,cursor:"pointer",size:"66%",dataLabels:{enabled:!0,color:"#000000",connectorColor:"#000000",format:"<b>{point.name}<\/b>: {point.y:.2f}%"},point:{events:{click:function(){this.state!="select"&&t(this.color)}}}}},series:[{type:"pie",data:i}]}},n.prototype.GetStrategyChartSettings=function(n,t){var i=[];return angular.forEach(n,function(n){i.push([n.Name,n.PortfolioWeighting*100])}),{chart:{plotBackgroundColor:null,plotBorderWidth:null,plotShadow:!1},title:{text:null,style:{color:"#000000",fontFamily:"Helvetica, Arial, sans-serif"}},tooltip:{enabled:!1},plotOptions:{pie:{allowPointSelect:!0,cursor:"pointer",size:"66%",dataLabels:{enabled:!0,color:"#000000",connectorColor:"#000000",format:"<b>{point.name}<\/b>: {point.y:.2f}%"},point:{events:{click:function(){this.state!="select"&&t(this.color)}}}}},series:[{type:"pie",data:i}]}},n.prototype.GetPortfolioHistoryChartSettings=function(n,t,i,r,u,f){var e={},o=[],s=[],c=[],l=[],h=[];return angular.forEach(n,function(n){var t=moment(n.Date).valueOf();e[t]=n;o.push([t,n.Balance]);c.push([t,n.CompoundingPAPerformance]);l.push([t,n.PeriodPerformance]);u&&h.push([t,n.SinceInceptionPerformance])}),angular.forEach(t,function(n){var t=moment(n.Date).valueOf();s.push([t,n.Amount])}),{chart:{spacing:[15,15,15,15],zoomType:"x"},rangeSelector:{enabled:!1},plotOptions:{series:{cursor:"pointer",point:{events:{click:function(){var n={portfolioId:i,date:e[this.x].Date};f(n)}}},pointRange:2592e6}},xAxis:{ordinal:!1},yAxis:[{opposite:!1,labels:{format:(r||"$")+" {value:,.0f}"}},{opposite:!0,alight:"Right",labels:{format:"{value} %"}}],tooltip:{valueDecimals:2,xDateFormat:"%d %b %Y"},series:[{name:"Valuation",animation:{complete:function(){$(window).resize()}},data:o,dataGrouping:{enabled:!1}},{name:"Net Capital Contribution",data:s,type:"column",dataGrouping:{enabled:!1}},{name:"Performance Since Inception",data:h,yAxis:1,dataGrouping:{enabled:!1}}]}},n.prototype.GetSummaryBalanceChartSettings=function(n){var t=[];return angular.forEach(n,function(n){var i=moment(n.Date).valueOf();t.push([i,n.Balance]);t.push([i,n.Performance])}),{chart:{type:"area",spacingTop:0,spacingBottom:0,spacingLeft:0,spacingRight:0,height:80},tooltip:{enabled:!1},title:{text:null},legend:{enabled:!1},xAxis:{labels:{enabled:!1},minorTickLength:0,tickLength:0,lineWidth:0},yAxis:{labels:{enabled:!1},title:{text:null},gridLineWidth:0,minorGridLineWidth:0,endOnTick:!1},plotOptions:{area:{size:"100%",marker:{enabled:!1,states:{hover:{enabled:!1}}},point:{events:{}}}},series:[{data:t}]}},n.prototype.GetSimpleTemplateModelChartSettingsBase=function(n){return this.GetSimpleTemplateModelChartSettings(n,"ModelPercentage",function(){})},n.prototype.GetSimpleTemplateModelChartSettingsRegularDeposit=function(n){return this.GetSimpleTemplateModelChartSettings(n,"RegularDepositPercentage",function(){})},n.prototype.GetSimpleTemplateModelChartSettingsAdHocDeposit=function(n){return this.GetSimpleTemplateModelChartSettings(n,"AdHocDepositPercentage",function(){})},n.prototype.GetSimpleTemplateModelChartSettingsRegularWithdrawal=function(n){return this.GetSimpleTemplateModelChartSettings(n,"RegularWithdrawalPercentage",function(){})},n.prototype.GetSimpleTemplateModelChartSettingsAdHocWithdrawal=function(n){return this.GetSimpleTemplateModelChartSettings(n,"AdHocWithdrawalPercentage",function(){})},n.prototype.GetSimpleTemplateModelChartSettings=function(n,t,i){var r=[];return angular.forEach(n,function(n){r.push([n.Product.ProductCode,n[t]])}),{chart:{plotBackgroundColor:null,plotBorderWidth:null,plotShadow:!1},title:{text:null,style:{color:"#000000",fontFamily:"Helvetica, Arial, sans-serif"}},tooltip:{enabled:!1},plotOptions:{pie:{allowPointSelect:!0,cursor:"pointer",size:"66%",dataLabels:{enabled:!0,color:"#000000",connectorColor:"#000000",format:"<b>{point.name}<\/b>: {point.y:.2f}%"},point:{events:{click:function(){this.state!="select"&&i(this.color)}}}}},series:[{type:"pie",data:r}]}},n.prototype.GotoSplit=function(n,t,i){angular.forEach(t,function(n){n.showDetails=n.Colour===i?!0:!1});this.$timeout(function(){var n=$("#Site").val()=="admin"?76:0;$("html,body").animate({scrollTop:$(i).position().top+n+"px"},600)},400)},n.prototype.GotoSplitInDialog=function(n,t,i){angular.forEach(t,function(n){n.showDetails=n.Colour===i?!0:!1});this.$timeout(function(){$(".modal-body").animate({scrollTop:$(".modal-body").find(i).offset().top-$(".modal-body").find(".table-wrap").offset().top+579+"px"},600)},300)},n.prototype.GetAssetTradeChartSettings=function(n){var t=[];return angular.forEach(n,function(n){t.push({name:n.Name,y:n.PortfolioWeighting*100,color:"#d3d3d3",productId:n.Product_Id})}),{chart:{plotBackgroundColor:null,plotBorderWidth:null,plotShadow:!1,margin:0},title:{text:null},tooltip:{enabled:!1},plotOptions:{pie:{slicedOffset:0,dataLabels:{enabled:!1}}},series:[{type:"pie",data:t}]}},n}();App.service("Chart",["$timeout",ChartService]);CommonService=function(){function n(n,t,i,r,u){var f=this;this.LOG_CLASS_INFO="text text-info";this.LOG_CLASS_VERBOSE="muted";this.SEARCH_DELAY=200;this.AUTOSAVE_DELAY=1e3;this.RESIDENTCOUNTRYCODE="N.Z";this.RESIDENTCURRENCYCODE="NZD";this.COMMONCOUNTRYCODES=["N.Z","AUS","U.K","USA"];this.COMMONCURRENCYCODES=["NZD","AUD","GBP","USD"];this.AuthoriserRemovalConfirmationMessage="Removing this authoriser will put the total number of authorisers for the account below the number required. Consider adding another authoriser before removing this one. Are you sure you want to continue?";this.IsEmptyOrNaN=function(n){return f.IsEmpty(n)||isNaN(n)};this.IsEmpty=function(n){return n===null||n===undefined};this.$modal=n;this.$location=t;this.$rootScope=i;this.Debug=r;this.Event=u;this.lastModelDuration=0}return n.prototype.RecordModelDuration=function(n){this.lastModelDuration=n},n.prototype.IsConnectionSlow=function(){return this.lastModelDuration>2e3?!0:!1},n.prototype.SessionId=function(){return getSessionId()},n.prototype.ModelRootUrl=function(){return $("#ModelRootUrl").val()},n.prototype.OnLoad=function(n){$(document).ready(n)},n.prototype.MomentInTime=function(n){return moment(n).fromNow()},n.prototype.LogInfo=function(n){this.Debug.JavascriptLogAdd({message:n,className:this.LOG_CLASS_INFO,time:getClockTime()})},n.prototype.LogVerbose=function(n){this.Debug.JavascriptLogAdd({message:n,className:this.LOG_CLASS_VERBOSE,time:getClockTime()})},n.prototype.LogJson=function(n){this.LogInfo(JSON.stringify(n))},n.prototype.DefaultHashParam=function(n,t){typeof this.$location.search()[n]=="undefined"&&this.$location.search(n,t)},n.prototype.HasHashParam=function(n){return typeof this.$location.search()[n]=="undefined"?!1:!0},n.prototype.GetHashParam=function(n){return this.$location.search()[n]},n.prototype.SetHashParam=function(n,t){this.$location.search(n,t)},n.prototype.RemoveHashParam=function(n){this.$location.search(n,null)},n.prototype.IsHashParam=function(n,t){return this.$location.search()[n]==t},n.prototype.IfHashParam=function(n,t,i,r){return this.IsHashParam(n,t)?i:r},n.prototype.CreateQueryString=function(n){var t,i,u,r;for(i in n)if(n.hasOwnProperty(i)&&n[i]!==undefined)if(t=t?t+"&":"",u=""+n[i],angular.isArray(n[i]))for(r=0;r<n[i].length;r++)r>0&&(t=t+"&"),t=t+i+"="+encodeURIComponent(n[i][r]);else t=t+i+"="+encodeURIComponent(u);return t},n.prototype.CreateUrl=function(n,t,i,r,u){var f,e;return f=n?n+"api/"+t+(u?"/"+u:"")+"/":"/api/"+t+(u?"/"+u:"")+"/",f=f+"?SessionId="+i,e=this.CreateQueryString(r),e&&(f=f+"&"+e),f},n.prototype.CreateUrlWithId=function(n,t,i,r,u,f){var e,o;return e=n?n+"api/"+t+(f?"/"+f:"")+"/"+i:"/api/"+t+(f?"/"+f:"")+"/"+i,e=e+"?SessionId="+r,o=this.CreateQueryString(u),o&&(e=e+"&"+o),e},n.prototype.GetParams=function(n){var i=[],t,r;return n&&(t=n.split("#"),r=t[0].split("?"),t.length===1&&r.length===1?this.SplitParams(i,t[0]):(this.SplitParams(i,t[1]),this.SplitParams(i,r[1]))),i},n.prototype.SplitParams=function(n,t){var r,i;if(t)for(r=t.split("&"),i=0;i<r.length;i++){var u=r[i].split("="),f=u[0],e=u[1];n[f]=e}},n.prototype.SetParam=function(n,t,i){var r=this.GetParams(n);return r[t]=i,this.CreateQueryString(r)},n.prototype.OpenConfirmationDialog=function(n,t,i,r){i===void 0&&(i="Confirmation");r===void 0&&(r="OKCancel");var u={templateUrl:"ConfirmationDialogContent",content:n,title:i,buttonOptions:r};this.OpenDialog("ConfirmationDialog",u,t)},n.prototype.OpenTwoStepVerificationDialog=function(n,t,i,r,u,f){if(t!="SmsCode"&&t!="Password")throw"Unable to perform two step verification. Unknown verificationType: "+t;var e={TokenKey:n,VerificationType:t,ActionType:i,Parameters:r,Message:u};this.OpenDialog("TwoStepVerificationDialog",e,f)},n.prototype.OpenDialog=function(n,t,i,r,u){n=="ConfirmationDialog"&&this.AugmentConfirmationDialogDefaults(t);var f={template:"<div data-ng-include src=\"'Views/"+n+"'\"><\/div>",controller:"BaseDialogController",backdrop:"static",windowClass:r,resolve:{data:function(){return angular.copy(t)}}};this.$modal.open(f).result.then(function(n){i&&i(n)},function(){u&&u()})},n.prototype.AugmentConfirmationDialogDefaults=function(n){n.title=n.title||"Confirmation";n.buttonOptions=n.buttonOptions||"OKCancel"},n.prototype.ResetFormField=function(n,t){n[t].$pristine===!1&&(n[t].$pristine=!0);n[t].$dirty===!0&&(n[t].$dirty=!1)},n.prototype.IsTab=function(n){return n?this.IsHashParam("t",n):!this.HasHashParam("t")},n.prototype.SetTab=function(n){n?this.SetHashParam("t",n):this.RemoveHashParam("t")},n.prototype.SetEntityDefaults=function(n){n.Title="";n.TaxResident=!0;n.TaxYearEnd=3;n.PostalAddessSameAsPhysical=!0;n.FDRStatus="FY"},n.prototype.BytesToSize=function(n){return n>>30&1023?(n>>>30)+" GB":n>>20&1023?(n>>>20)+" MB":n>>10&1023?(n>>>10)+" KB":n>>1&1023?(n>>>1)+" B":n+" B"},n.prototype.IsValidDate=function(n){var t=new Date(n);return n==null?!0:isNaN(t.getTime())?!1:!0},n.prototype.IsNewModel=function(n){return n.Id&&n.Id!==0?!1:!0},n.prototype.RedirectToHome=function(){this.$location.path("/")},n.prototype.RedirectToPageNotFound=function(){this.Event.Broadcast("PageNotFound");this.$location.url(PAGE_NOT_FOUND_ROUTE_PATH).replace()},n.prototype.IsAtPageNotFoundRoute=function(){return this.$location.path()===PAGE_NOT_FOUND_ROUTE_PATH},n.$inject=["$modal","$location","$rootScope","Debug","Event"],n}();App.service("Common",CommonService);DateService=function(){function n(n){this.sessionService=n}return n.prototype.GetToday=function(){var n=Number(this.sessionService.GetCurrentDateTimeOffset());return moment().add(n,"milliseconds").startOf("day").toDate()},n.$inject=["Session"],n}();App.service("Date",DateService);DebugService=function(){function n(){this.defaultCapacity=10;this.AjaxLog=[];this.JavascriptLog=[];this.SignalRLog=[]}return n.prototype.AjaxLogAdd=function(n){return this.AjaxLog.push(n),this.AjaxLog.length-1},n.prototype.JavascriptLogAdd=function(n){this.JavascriptLog.push(n);this.JavascriptLog.length>this.defaultCapacity&&this.JavascriptLog.shift()},n.prototype.SignalRLogAdd=function(n){this.SignalRLog.push(n);this.SignalRLog.length>this.defaultCapacity&&this.SignalRLog.shift()},n}();App.service("Debug",DebugService);EventService=function(){function n(n){var t=this;this.Broadcast=function(n,i){t.$rootScope.$broadcast(n,i)};this.OnBroadcast=function(n,t,i){return n.$on(t,function(n,t){i(t)})};this.BroadcastEntityLoaded=function(n,i){t.broadcastedEntity=i;t.broadcastedEntity&&n.$broadcast("EntityLoaded",t.broadcastedEntity)};this.OnEntityLoaded=function(n,i){n.$on("EntityLoaded",function(n,t){i(t)});t.broadcastedEntity&&i(t.broadcastedEntity)};this.$rootScope=n}return n}();App.service("Event",["$rootScope",EventService]);JobService=function(){function n(n,t,i,r,u){this.rootScope=n;this.Common=t;this.Event=i;this.Model=r;this.Notification=u}return n.prototype.QueueJob=function(n,t,i,r,u){this.Model.New(this.Common,"Job",{Type:n,Reference:t,Description:i,Params:r},function(n){n.Status==="Error"?this.Notification.DisplayToast("error",n.StatusMessage,n.Status):u?u(n):this.Notification.DisplayToast("success",n.StatusMessage,n.Status)})},n}();App.service("Job",["$rootScope","Common","Event","Model","Notification",JobService]);var __extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},LoadingService=function(){function n(n,t,i){var r=this;this.areDiagnosticsEnabled=!1;this.LOADING_INDICATOR_START_DELAY=50;this.NO_OUTSTANDING_WEB_CALLS_THRESHOLD=200;this.ResetAll=function(){r.LogDiagnosticsMessage("1-- ResetAll (start)");r.ResetBatch();r.webCallsOutstandingCount=0;r.webCallIdSeed=0;r.webCallsOutstandingDict={};r.webCallsCachedDict={};r.LogDiagnosticsMessage("1-- ResetAll (end)")};this.ResetBatch=function(){r.LogDiagnosticsMessage("2-- ResetBatch (start)");r.hasBatchStarted=!1;r.batchStartDate=null;r.batchFinishDate=null;r.parentDescriptor=null;r.calculatedMetrics.length=0;r.timeoutIdArray.length=0;r.LogDiagnosticsMessage("2-- ResetBatch (end)")};this.RouteChangeStart=function(n){r.areMetricsEnabled==!0&&(r.LogDiagnosticsMessage("3-- RouteChangeStart (start): pageRoute = "+n),r.StartBatchTimingIfNotStarted(n),r.LogDiagnosticsMessage("3-- RouteChangeStart (end): pageRoute = "+n))};this.RouteChangeSuccess=function(){r.areMetricsEnabled==!0&&(r.LogDiagnosticsMessage("8-- RouteChangeSuccess (start)"),r.LogDiagnosticsMessage("8-- RouteChangeSuccess (end)"))};this.StartBatchTimingIfNotStarted=function(n){if(r.LogDiagnosticsMessage("4-- StartBatchTimingIfNotStarted (start)"),!r.hasBatchStarted){r.LogDiagnosticsMessage("4-- FIRST call, starting UI Batch timing");r.batchStartDate=new Date;r.hasBatchStarted=!0;r.parentDescriptor=n;var t=setTimeout(function(){r.$rootScope.isLoading=!0},r.LOADING_INDICATOR_START_DELAY);r.timeoutIdArray.push(t)}r.LogDiagnosticsMessage("4-- StartBatchTimingIfNotStarted (end)")};this.StartWebCallTiming=function(n,t){var u,i;r.areMetricsEnabled==!0&&(r.LogDiagnosticsMessage("5-- StartWebCallTiming (start): url = "+n+", supportsCaching = "+t),r.webCallsOutstandingCount++,r.StartBatchTimingIfNotStarted(n),t&&r.webCallsCachedDict[n]?(r.LogDiagnosticsMessage("5-- Ignoring call to url: "+n+". This url supports caching and has already been called (and therefore cached) in this session"),r.LogCurrentState(4)):r.webCallsOutstandingDict[n]?(u="Unable to add call to webCallsOutstandingDict. An item for key: "+n+" is already present",r.RaiseError(4,u)):(i={Url:n,StartDate:new Date,SupportsCaching:t},r.webCallsOutstandingDict[n]=i,r.LogDiagnosticsMessage("5-- Added webCallInfo to webCallsOutstandingDict:"),r.LogDiagnosticsMessage(i),t&&(r.webCallsCachedDict[n]=!0,r.LogDiagnosticsMessage("5-- Caching supported and url not found in cache dictionary. Adding item to webCallsCachedDict for url: "+n)),r.LogCurrentState(4)),r.LogDiagnosticsMessage("5-- StartWebCallTiming (end): url = "+n+", supportsCaching = "+t))};this.StopWebCallTiming=function(n,t){if(r.areMetricsEnabled==!0){r.LogDiagnosticsMessage("6-- StopWebCallTiming (start): url = "+n+", exchangeId = "+t);var i=r.CalculateCallDuration(n,t);i!=null&&r.calculatedMetrics.push(i);r.AreWebCallsOutstanding()||(r.batchFinishDate=new Date,r.PersistMetricsWhenNoOutstandingCallsAfterThreshold(r.NO_OUTSTANDING_WEB_CALLS_THRESHOLD,!0));r.LogDiagnosticsMessage("6-- StopWebCallTiming (end): url = "+n+", exchangeId = "+t)}};this.CalculateCallDuration=function(n,t){var i,o,u,s,f,e;if(r.LogDiagnosticsMessage("7-- CalculateCallDuration (start): url = "+n),o=new Date,r.webCallsOutstandingDict[n])u=r.webCallsOutstandingDict[n],delete r.webCallsOutstandingDict[n],r.webCallsOutstandingCount--,r.LogDiagnosticsMessage("7-- webCallInfo was found in webCallsOutstandingDict for url: "+n),r.LogDiagnosticsMessage(u),r.LogCurrentState(6),s=u.StartDate,f=o.getTime()-s.getTime(),i=new DurationMetric(t,f);else if(r.webCallsCachedDict[n])r.webCallsOutstandingCount--,r.LogDiagnosticsMessage("7-- No webCallInfo was found, but a cache entry was found in webCallsCachedDict for url: "+n),r.LogCurrentState(6),i=null;else{e="No entries were found in webCallsOutstandingDict or webCallsCachedDict for url: "+n;r.RaiseError(6,e);throw e;}return r.LogDiagnosticsMessage("7-- CalculateCallDuration (end): url = "+n+", duration = "+f),i};this.AreWebCallsOutstanding=function(){return r.webCallsOutstandingCount>0};this.metricsLoadCount=0;this.PersistMetricsWhenNoOutstandingCallsAfterThreshold=function(n,t){var i,u;t||r.AreWebCallsOutstanding()?(i=setTimeout(function(){r.PersistMetricsWhenNoOutstandingCallsAfterThreshold(n,!1)},n),r.timeoutIdArray.push(i)):(r.timeoutIdArray.forEach(function(n){clearTimeout(n)}),u=r.GetMetricsForPersistence(r.calculatedMetrics),r.$timeout(function(){r.$rootScope.isLoading=!1;r.metricsLoadCount++;$("#MetricsLoadCount").val(r.metricsLoadCount.toString())}),r.PersistMetrics(u)["finally"](function(){r.ResetBatch()}))};this.GetMetricsForPersistence=function(n){var t=new PageLoadDurationMetrics(r.parentDescriptor);return t.callDurationMilliseconds=r.batchFinishDate.getTime()-r.batchStartDate.getTime(),t.childMetrics=n,t};this.PersistMetrics=function(n){var u="api/PerformanceMetricsBatch?sessionId="+getSessionId(),t,i;return r.areDiagnosticsEnabled&&(r.LogDiagnosticsMessage("No more web calls outstanding after "+r.NO_OUTSTANDING_WEB_CALLS_THRESHOLD+" ms threshold. Attempting to persist page load duration metrics..."),r.LogDiagnosticsMessage("Parent metric:"),LogStateToConsole(n),n.childMetrics.forEach(function(n,t){r.LogDiagnosticsMessage("Child metric "+(t+1)+":");LogStateToConsole(n)})),t=r.$injector.get("$http"),i=t.post(u,n).success(function(){r.LogDiagnosticsMessage("Metrics were persisted successfully")}).error(function(){r.LogDiagnosticsMessage("Error persisting metrics")}),i};this.LogDiagnosticsMessage("0-- ctor (start)");this.$rootScope=n;this.$timeout=t;this.$injector=i;this.calculatedMetrics=[];this.timeoutIdArray=[];this.ResetAll();n.$on("$routeChangeStart",function(n,t){var i=t.originalPath?t.originalPath:"Undefined Route";r.RouteChangeStart(i)});n.$on("$routeChangeSuccess",function(){r.RouteChangeSuccess()});this.LogDiagnosticsMessage("0-- ctor (end)")}return n.prototype.LogDiagnosticsMessage=function(n,t){t===void 0&&(t=!1);(this.areDiagnosticsEnabled||t)&&console.log(n)},n.prototype.LogCurrentState=function(n,t){t===void 0&&(t=!1);(this.areDiagnosticsEnabled||t)&&(this.LogDiagnosticsMessage(n+"-- webCallsOutstandingDict:",t),LogStateToConsole(this.webCallsOutstandingDict),this.LogDiagnosticsMessage(n+"-- webCallsCachedDict:",t),LogStateToConsole(this.webCallsCachedDict),this.LogDiagnosticsMessage(n+"-- calculatedMetrics:",t),LogStateToConsole(this.calculatedMetrics),this.LogDiagnosticsMessage(n+"-- webCallsOutstandingCount:",t),LogStateToConsole(this.webCallsOutstandingCount))},n.prototype.RaiseError=function(n,t){this.LogDiagnosticsMessage(t,!0);this.LogCurrentState(n,!0);throw t;},n.$inject=["$rootScope","$timeout","$injector"],n}(),DurationMetric=function(){function n(n,t){this.exchangeId=n;this.callDurationMilliseconds=t}return n}(),PageLoadDurationMetrics=function(n){function t(t){n.call(this);this.descriptor=t;this.childMetrics=[]}return __extends(t,n),t}(DurationMetric);App.service("LoadingService",LoadingService);ModelServiceOptions=function(){function n(){}return n}();ModelService=function(){function n(n,t,i,r,u,f,e){var o=this;this.HandleSuccessResponse=function(n,t,i,r,u,f){o.sessionService.IncreaseTimeout();o.ModelService_LogAjaxDone(t,i,r,u,JSON.stringify(n),o.debugService);f&&f(n)};this.HandleErrorResponse=function(n,t,i,r,u,f,e){var s="An error has occurred ("+r+")",h;r===401?o.sessionService.AutoSignOut(!1):r===404?o.commonService.RedirectToPageNotFound():r===503?f||o.toastService.DisplayToast("warning","The requested operation is unavailable at this time, please try again later."):f||o.toastService.DisplayToast("error",s);o.ModelService_LogAjaxFail(t,i,r,u,s,o.debugService);e&&(h=o.CreateError(n,r),e(h))};this.$cacheFactory=n;this.$http=t;this.$q=i;this.commonService=r;this.debugService=u;this.sessionService=f;this.toastService=e}return n.prototype.LoadUsingCache=function(n,t){var r=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,t,this.commonService.SessionId(),{}),i=getDefaultHttpConfig();return i.cache=!0,this.$http.get(r,i)},n.prototype.LoadItem=function(n,t,i){var r=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,t,this.commonService.SessionId(),{});this.Get(r,i)},n.prototype.LoadItemWithAction=function(n,t,i,r){var u=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,i,this.commonService.SessionId(),{},t);this.Get(u,r)},n.prototype.LoadItem2=function(n,t,i){i===void 0&&(i=new ModelServiceOptions);var r=this.$q.defer(),u=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,t,this.commonService.SessionId(),i.params,i.action),f=function(n){r.reject(n)},e=function(n){r.resolve(n)};return this.Get(u,e,f),r.promise},n.prototype.LoadList=function(n,t,i){var r=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),t);this.Get(r,i)},n.prototype.LoadList2=function(n,t){t===void 0&&(t=new ModelServiceOptions);var i=this.$q.defer(),r=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),t.params,t.action),u=function(n){i.reject(n)},f=function(n){i.resolve(n)};return this.Get(r,f,u,t.useExtendedTimeout,t.suppressErrorToast),i.promise},n.prototype.Add=function(n,t,i){this.AddWithParams(n,t,{},i)},n.prototype.AddWithParams=function(n,t,i,r,u){var f=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),i);this.POST(f,t,r,u)},n.prototype.Add2=function(n,t,i){i===void 0&&(i=new ModelServiceOptions);var r=this.$q.defer(),u=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),i.params,i.action),f=function(n){r.reject(n)},e=function(n){r.resolve(n)};return this.POST(u,t,e,f,i.useExtendedTimeout,i.suppressErrorToast),r.promise},n.prototype.Update2=function(n,t,i,r){r===void 0&&(r=new ModelServiceOptions);var u=this.$q.defer(),f=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,t,this.commonService.SessionId(),r.params,r.action),e=function(n){u.reject(n)},o=function(n){u.resolve(n)};return this.PUT(f,i,o,e,r.useExtendedTimeout,r.suppressErrorToast),u.promise},n.prototype.AddOrUpdate2=function(n,t,i){return i===void 0&&(i=new ModelServiceOptions),t.Id?this.Update2(n,t.Id,t,i):this.Add2(n,t,i)},n.prototype.Update=function(n,t,i,r){this.UpdateWithParams(n,t,i,{},r)},n.prototype.UpdateWithAction=function(n,t,i,r,u){u===void 0&&(u=new ModelServiceOptions);var f=this.$q.defer(),e=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,i,this.commonService.SessionId(),{},t),o=function(n){f.reject(n)},s=function(n){f.resolve(n)};return this.PUT(e,r,s,o,u.useExtendedTimeout,u.suppressErrorToast),f.promise},n.prototype.UpdateWithParams=function(n,t,i,r,u,f){var e=this.commonService.CreateUrlWithId(this.commonService.ModelRootUrl(),n,t,this.commonService.SessionId(),r),o;this.PUT(e,i,u,f);o=this.$cacheFactory.get("$http");o.get(e)&&o.put(e,i)},n.prototype.AddOrUpdate=function(n,t,i){t.Id?this.Update(n,t.Id,t,i):this.Add(n,t,i)},n.prototype.AddOrUpdateWithParams=function(n,t,i,r,u){t.Id?this.UpdateWithParams(n,t.Id,t,i,r,u):this.AddWithParams(n,t,i,r,u)},n.prototype.GetWithId=function(n,t,i,r,u){var f=n.CreateUrlWithId(n.ModelRootUrl(),t,i,n.SessionId(),r);this.Get(f,u)},n.prototype.GetWithParams=function(n,t,i,r){var u=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),i);this.Get(u,r)},n.prototype.GetPageWithParentId=function(n,t,i){var r={parentId:t,pageSize:100},u=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),r);this.Get(u,i)},n.prototype.SearchWithParams=function(n,t,i,r,u,f,e,o){f.page=i;f.pageSize=r;f.search=u;var s=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),f,o);this.Get(s,e)},n.prototype.Search=function(n,t,i,r,u){this.SearchWithParams(n,t,i,10,r,[],u)},n.prototype.FilterWithParams=function(n,t,i,r,u,f,e,o){n.LogJson(i);e.parentId=i;e.page=r;e.pageSize=u;e.search=f;var s=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),e);n.LogInfo(s);this.Get(s,o)},n.prototype.Filter=function(n,t,i,r,u,f,e){this.FilterWithParams(n,t,i,r,u,f,[],e)},n.prototype.New=function(n,t,i,r){var u=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),{});this.POST(u,i,r)},n.prototype.PostData2=function(n,t,i,r){var u=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),{});this.POST(u,i,r)},n.prototype.Put=function(n,t,i,r){var u=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),t);this.PUT(u,i,r)},n.prototype.PutData2=function(n,t,i,r){var u=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),{});this.PUT(u,i,r)},n.prototype.Load=function(n,t,i,r){var u=n.CreateUrlWithId(n.ModelRootUrl(),t,i,n.SessionId(),{});this.Get(u,r)},n.prototype.Save=function(n,t,i,r,u){var f=n.CreateUrlWithId(n.ModelRootUrl(),t,i,n.SessionId(),{});this.PUT(f,r,u)},n.prototype.CreateOrUpdate=function(n,t,i,r){this.CreateOrUpdateWithParams(n,t,i,{},r)},n.prototype.CreateOrUpdateWithParams=function(n,t,i,r,u){var f;i.Id?(f=n.CreateUrlWithId(n.ModelRootUrl(),t,i.Id,n.SessionId(),r),this.PUT(f,i,u)):(f=n.CreateUrl(n.ModelRootUrl(),t,n.SessionId(),r),this.POST(f,i,u))},n.prototype.Get=function(n,t,i,r,u){var f=this,s=new Date,e=getDefaultHttpConfig(r),o=this.ModelService_LogAjaxStart(n,e);this.$http.get(n,e).success(function(i,r,u,e){f.HandleSuccessResponse(i,n,e,o,s,t)}).error(function(t,r,e,s){f.HandleErrorResponse(t,n,s,r,o,u,i)})},n.prototype.POST=function(n,t,i,r,u,f){var e=this,h=new Date,o=getDefaultHttpConfig(u),s=this.ModelService_LogAjaxStart(n,o);this.$http.post(n,t,o).success(function(t,r,u,f){e.HandleSuccessResponse(t,n,f,s,h,i)}).error(function(t,i,u,o){e.HandleErrorResponse(t,n,o,i,s,f,r)})},n.prototype.PUT=function(n,t,i,r,u,f){var e=this,h=new Date,o=getDefaultHttpConfig(u),s=this.ModelService_LogAjaxStart(n,o);this.$http.put(n,t,o).success(function(t,r,u,f){t.DbUpdateConcurrencyException=u("DbUpdateConcurrencyException");e.HandleSuccessResponse(t,n,f,s,h,i)}).error(function(t,i,u,o){e.HandleErrorResponse(t,n,o,i,s,f,r)})},n.prototype.Delete=function(){throw new Error("Not Implemented");},n.prototype.CreateError=function(n,t){return{data:n||"Unexpected error occurred. Please try again later or contact your system administrator.",status:t}},n.prototype.ModelService_LogAjaxStart=function(n,t){var i=t.method+" "+t.responseType+" '"+n+"' ...";return this.debugService.AjaxLogAdd({message:i,className:"text-warning",time:getClockTime()})},n.prototype.ModelService_LogAjaxDone=function(n,t,i,r,u,f){var e;u?(bytesReceived+=u.length,e=t.method+" "+t.responseType+" '"+n+"' ("+u.length+" bytes received in "+formatDuration(r)+")"):e=t.method+" "+t.responseType+" '"+n+"' (0 bytes received in "+formatDuration(r)+")";f.AjaxLog[i]={message:e,className:"text-success",time:getClockTime()}},n.prototype.ModelService_LogAjaxFail=function(n,t,i,r,u,f){var e="JavaScript, "+t.method+", "+t.responseType,o=n+" ("+i+") "+u,s=e+", "+o;return f.AjaxLog[r]={message:s,className:"text-error",time:getClockTime()},!0},n.prototype.GetUnauthenticatedAsync=function(n,t){var i=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),{}),r=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),t);return this.HttpRequestUnauthenticatedAsync(i,r,"GET")},n.prototype.PostUnauthenticatedAsync=function(n,t){var i=this.commonService.CreateUrl(this.commonService.ModelRootUrl(),n,this.commonService.SessionId(),{});return this.HttpRequestUnauthenticatedAsync(i,i,"POST",t)},n.prototype.HttpRequestUnauthenticatedAsync=function(n,t,i,r){var u=this,f=this.$q.defer(),e=function(n){f.reject(n)},o=function(n){f.resolve(n)};return this.$http.get(n).success(function(n){switch(i){case"GET":var f="&challenge="+n.Challenge;t=t+f;u.Get(t,o,e);break;case"POST":r.Challenge=n.Challenge;u.POST(t,r,o,e);break;default:throw"Unknown HTTP Method: "+i;}}).error(function(n,t){var i=u.CreateError(n,t);e(i)}),f.promise},n.$inject=["$cacheFactory","$http","$q","Common","Debug","Session","Toast"],n}();App.service("Model",ModelService);ModelServiceFake=function(){function n(){this.cache={}}return n.prototype.AddMockData=function(n,t){this.cache[n]||(this.cache[n]=t)},n.prototype.SearchWithParams=function(n,t,i,r,u,f){this.cache[t]||(this.cache[t]=[]);var e={Info:{CurrentPage:1,Filter:null,HasNextPage:!1,HasPreviousPage:!1,ItemsOnPage:10,ItemsPerPage:10,ItemsToSkip:0,TotalItems:this.cache[t].length,TotalPages:1},Items:angular.copy(this.cache[t])};setTimeout(function(){f(e)},0)},n.prototype.CreateOrUpdate=function(n,t,i,r){this.cache[t]||(this.cache[t]=[]);i.Id?this.cache[t][i.Id-1]=i:(i.Id=this.cache[t].length+1,this.cache[t].push(i));setTimeout(function(){r(i)},0)},n.prototype.GetWithParams=function(n,t,i,r){this.cache[t]||(this.cache[t]=[]);var u=angular.copy(this.cache[t][i.Id-1]);setTimeout(function(){r(u)},0)},n}();App.service("ModelFake",ModelServiceFake);NotificationActionService=function(){function n(n,t,i,r,u,f){this.$location=n;this.$q=t;this.$window=i;this.Common=r;this.Model=u;this.isAdminPortal=f.IsAdminPortal}return n.prototype.HandleAction=function(n,t,i){var u=this,h=this.$q.defer(),r={Reference:"",Type:""},f,e,o,s;if(this.isAdminPortal)switch(n){case"Job":r.Type="page";r.Reference+="/System/Jobs/"+t;break;case"Portfolio":r.Type="page";r.Reference+="/Portfolios/"+t;break;case"PortfolioFile":i.length>0?(r.Type="page",angular.forEach(i,function(n){r.Reference+="/"+u.ResolveModelName(n.Group)+"/"+n.Reference}),r.Reference+="?t=reports&PortfolioFileCriteria="+t):(r.Type="api",r.Reference="api/PortfolioFileTransfer/"+t+"?SessionId="+this.Common.SessionId());break;case"Workflow":r.Type="wizard";r.Reference=t;break;case"RateRequestedFXTradeReadyForMarket":r.Type="page";r.Reference="/MarketFXSwitches/"+t;break;case"PortfolioOrderAuthorisation":r.Type="page";r.Reference="/OrderAuthorityQueue?PortfolioOrderAuthorityFilterBy=OrderAuthorityStatusFilterOptions(3)OrderAuthorityTypeFilterOptions(1)"}else switch(n){case"PortfolioOrderAuthorisation":f=Number(t);this.Model.LoadItem2("PortfolioOrder",f).then(function(n){u.LoadPortfolioRightsAsync(n.Portfolio_Id).then(function(n){var t={modelName:"PortfolioOrder",modelId:f,portfolioRights:n};u.Common.OpenDialog("PortfolioTradeReviewDialog",t,undefined,"xl")})});break;case"BankAccountAuthorisation":e=Number(t);this.Model.LoadItem2("PortfolioBankAccount",e).then(function(n){u.LoadPortfolioRightsAsync(n.Portfolio_Id).then(function(n){var t={modelName:"PortfolioBankAccount",modelId:e,portfolioRights:n,hideAccountType:!0,hideCurrency:!0};u.Common.OpenDialog("PortfolioBankAccountDialog",t,undefined)})});break;case"RegularDepositAuthorisation":o=Number(t);this.Model.LoadItem2("RegularDeposit",o).then(function(n){u.LoadPortfolioAsync(n.Portfolio_Id).then(function(n){var t={modelName:"RegularDeposit",modelId:o,portfolioId:n.Id,serviceId:n.Service_Id,depositRules:!n.SimpleTemplateModel?16:n.SimpleTemplateModel.RegularDepositRules,portfolioRights:n.PortfolioRights};u.Common.OpenDialog("PeriodicDialog",t,undefined)})});break;case"RegularWithdrawalAuthorisation":s=Number(t);this.Model.LoadItem2("RegularWithdrawal",s).then(function(n){u.LoadPortfolioAsync(n.Portfolio_Id).then(function(n){var t={modelName:"RegularWithdrawal",modelId:s,portfolioId:n.Id,serviceId:n.Service_Id,withdrawalRules:!n.SimpleTemplateModel?1024:n.SimpleTemplateModel.RegularWithdrawalRules,portfolioRights:n.PortfolioRights};u.Common.OpenDialog("PeriodicDialog",t,undefined)})});break;case"NewProductFiles":r.Type="page";r.Reference="/p/"+t+"?m=Manager%20Readings";break;case"NewPortfolioFiles":r.Type="page";r.Reference="/p/"+t+"?m=Document%20Library";break;case"NewServiceFiles":r.Type="page";r.Reference="/p/"+t+"?m=Service%20Documents"}return this.ProcessAction(r),h.promise},n.prototype.ProcessAction=function(n){switch(n.Type){case"api":this.$window.location=n.Reference;break;case"page":this.$location.url(n.Reference);break;case"wizard":var t={id:n.Reference};this.Common.OpenDialog("WorkflowDialog",t,undefined,"wizard")}},n.prototype.ResolveModelName=function(n){var t;switch(n){case"Portfolio":t="Portfolios"}return t},n.prototype.LoadPortfolioAsync=function(n){var t=this.$q.defer();return this.Model.LoadItem2("UserPortfolio",n).then(function(n){t.resolve(n)}),t.promise},n.prototype.LoadPortfolioRightsAsync=function(n){var t=this.$q.defer();return this.Model.LoadItem2("UserPortfolio",n).then(function(n){var i=n.PortfolioRights;t.resolve(i)}),t.promise},n.$inject=["$location","$q","$window","Common","Model","State"],n}();App.service("NotificationAction",NotificationActionService);NotificationService=function(){function n(n,t,i,r,u,f,e,o){var s=this;this.$q=n;this.$rootScope=t;this.Common=r;this.Event=u;this.Model=f;this.Toast=e;this.NOTIFICATIONS_TO_DISPLAY=5;this.NewNotificationCount=0;u.OnBroadcast(t,"Notification",function(n){s.NewNotificationCount=s.NewNotificationCount+1;s.DisplayToast("info",n.Message,undefined,function(){o.HandleAction(n.Group,n.Reference,n.Models,n.Id).then(function(){s.GetNewNotificationCount()})})})}return n.prototype.GetNewNotificationCount=function(){var n=this;this.Model.GetWithParams(this.Common,"Notification",{pageSize:1},function(t){n.NewNotificationCount=t.Info.TotalItems})},n.prototype.GetNotifications=function(){var t=this,n=this.$q.defer(),i={pageSize:this.NOTIFICATIONS_TO_DISPLAY};return this.Model.GetWithParams(this.Common,"Notification",i,function(i){t.NewNotificationCount=i.Info.TotalItems;n.resolve(i.Items)}),n.promise},n.prototype.RemoveNotification=function(n){var t=this.$q.defer();return this.Model.Update2("Notification",n,{}).then(function(){t.resolve()}),t.promise},n.prototype.RemoveAllNotifications=function(){var n=this.$q.defer(),t=new ModelServiceOptions,i;return t.params={doRemoveAll:!0},i=0,this.Model.Update2("Notification",i,{},t).then(function(){n.resolve()}),n.promise},n.prototype.DisplayToast=function(n,t,i,r){this.Toast.DisplayToast(n,t,i,r)},n.$inject=["$q","$rootScope","$window","Common","Event","Model","Toast","NotificationAction"],n}();App.service("Notification",NotificationService);NotificationStateService=function(){function n(){this.NOTIFICATIONS_TO_DISPLAY=5;this.NewNotificationCount=0;this.Recent=[]}return n.prototype.InitNotifcations=function(n,t){var i=this;this.NewNotificationCount=n-t.length;angular.forEach(t,function(n){var t=n;i.AddNotification(t)})},n.prototype.AddNotification=function(n){this.NewNotificationCount++;this.Recent.reverse();this.Recent.push(n);this.Recent.length>this.NOTIFICATIONS_TO_DISPLAY&&this.Recent.shift();this.Recent.reverse()},n}();App.service("NotificationState",NotificationStateService);SearchService=function(){function n(n){this.commonService=n}return n.prototype.GetFiltersFromUrl=function(n){var u={},f=this.commonService.GetHashParam(n),i,e,t,h;if(f){i=f.split(")");for(e in i)if(t=i[e],t&&t.length>0){var o=t.split("("),s=o[0],r=o[1];r&&r.length>0&&(h=r.split(","),u[s]={Name:s,Items:h})}}return u},n.prototype.UpdateFiltersInUrl=function(n,t,i){var r=this.GetFiltersFromUrl(n),u,e,f;r[t]===undefined&&(r[t]={Name:t,Items:i});r[t].Items=i;u="";for(e in r)f=r[e],f.Items&&(u=u+f.Name+"("+f.Items.toString()+")");u.length>0?this.commonService.SetHashParam(n,u):this.commonService.RemoveHashParam(n)},n.prototype.UpdateSearchFilters=function(n,t,i,r){this.UpdateFiltersInUrl(n,t,i);r&&(r.change(),i&&i.length==1&&(r.selectedFilterDataKey=i[0]))},n.prototype.SetListParam=function(n,t,i,r){i.length===0?this.UpdateSearchFilters(n,t,undefined,r):this.UpdateSearchFilters(n,t,i,r)},n.prototype.GetListParam=function(n,t,i){var r=this.GetFiltersFromUrl(n);for(var u in r)if(r[u].Name==t)return i&&r[u].Items.length==0&&(i.selectedFilterDataKey=r[u].Items[0]),r[u].Items;return[]},n.prototype.ToggleListParam=function(n,t,i,r){var u=this.GetListParam(n,t,r);this.InArray(i,u)?this.RemoveFromArray(i,u):u.push(i);this.SetListParam(n,t,u,r)},n.prototype.HasListParam=function(n,t,i,r){var u=this.GetListParam(n,t,i);return this.InArray(r,u)},n.prototype.ClearFilter=function(n,t,i){this.SetListParam(n,t,[],i)},n.prototype.ClearAllFilters=function(n){this.commonService.RemoveHashParam(n)},n.prototype.RemoveFromArray=function(n,t){for(var r=t.length,i=0;i<r;i++)t[i]==n&&t.splice(i,1)},n.prototype.InArray=function(n,t){for(var r=t.length,i=0;i<r;i++)if(t[i]==n)return!0;return!1},n.$inject=["Common"],n}();App.service("Search",SearchService);SecureMailService=function(){function n(n,t,i,r,u,f,e,o,s,h){var c=this;this.$q=n;this.$rootScope=t;this.$timeout=i;this.Common=u;this.Event=f;this.Model=e;this.Toast=o;this.User=h;this.SECUREMAIL_TO_DISPLAY=5;this.NewSecureMailCount=0;this.GetNewSecureMailCount();f.OnBroadcast(t,"SecureMail",function(n){switch(n.SecureMailStatus){case"New":c.NewSecureMailCount+=1;var t="New secure mail received from: "+n.SenderFirstName;c.DisplayToast("info",t,undefined,function(){var t={id:n.Id};u.OpenDialog("SecureMailDialog",t,undefined)});break;case"Read":c.NewSecureMailCount-=1}})}return n.prototype.GetNewSecureMailCount=function(){var n=this;this.User.GetUser().then(function(t){var i={pageSize:1,parentId:t.Id,secureMailStatus:"New",markAsRead:!1};n.Model.LoadList("Message",i,function(t){n.NewSecureMailCount=t.Info.TotalItems})})},n.prototype.DisplayToast=function(n,t,i,r){this.Toast.DisplayToast(n,t,i,r)},n.$inject=["$q","$rootScope","$timeout","$window","Common","Event","Model","Toast","NotificationAction","User"],n}();App.service("SecureMail",SecureMailService);SignalrController=function(){function n(n){n.SignalrController=this;n.$watch(function(){return $.hubConnection().connectionState},function(n){console.log(n);this.connectionState=n})}return n.$inject=["$scope"],n}();SignalrService=function(){function n(n,t,i,r,u,f,e){this.url=r.ModelRootUrl()+"signalr";this.$rootScope=n;this.$timeout=i;this.notification=f;this.event=u;this.modelService=e}return n.prototype.start=function(n){var t=this,i,r;this.stopped=!1;i=$.hubConnection();this.connection=i;i.url=this.url;i.qs={sessionId:n};i.stateChanged(function(){});i.reconnecting(function(){var n=new ModelServiceOptions;n.params={reference:"24fb163d659e4b4885817c4bfe0d929c"};n.suppressErrorToast=!0;t.modelService.LoadList2("Availability",n).then(undefined,function(){t.$timeout(function(){t.$rootScope.isDisconnected=!0})})});i.reconnected(function(){t.$timeout(function(){t.$rootScope.isDisconnected=!1})});i.disconnected(function(){t.stopped||t.$timeout(function(){i.start().done(function(){t.$timeout(function(){t.$rootScope.isDisconnected=!1})})},1e3)});r=i.createHubProxy("amadeus");r.on("Notification",function(n){return t.event.Broadcast("Notification",n),"Notification"});r.on("Job",function(n){t.event.Broadcast("Job",n)});r.on("Task",function(n){t.event.Broadcast("Task",n)});r.on("SecureMail",function(n){t.event.Broadcast("SecureMail",n)});i.start()},n.prototype.stop=function(){this.connection&&(this.stopped=!0,this.connection.stop(),this.connection=null)},n.$inject=["$rootScope","$location","$timeout","Common","Event","Notification","Model"],n}();App.service("Signalr",SignalrService);StateService=function(){function n(){this.IsAuthenticated=!1}return n}();App.service("State",[StateService]);SessionService=function(){function n(n,t,i,r,u){this.$http=n;this.$timeout=t;this.eventService=i;this.loadingService=r;this.stateService=u;this.$http.defaults.headers.common[SESSION_ID_KEY]=this.GetSessionID();this.loadingService.areMetricsEnabled=this.GetDoEnableMetrics()}return n.prototype.SetSessionValues=function(n){this.SetSessionID(n.SessionID);this.SetDoEnableMetrics(n.DoEnableClientMetrics);this.SetDoEnableEventLogging(n.DoEnableClientEventLogging);this.SetUsersPreviousSignInDate(n.PreviousSignInDateUtc);this.SetEntityFirstName(n.EntityFirstName);this.SetEntityLastName(n.EntityLastName);var t=moment(n.CurrentDateTime),i=moment(),r=t.diff(i);this.SetCurrentDateTimeOffset(r)},n.prototype.GetSessionID=function(){return sessionStorage[SESSION_ID_KEY]},n.prototype.SetSessionID=function(n){sessionStorage[SESSION_ID_KEY]=n;this.$http.defaults.headers.common[SESSION_ID_KEY]=n},n.prototype.SetDoEnableEventLogging=function(n){sessionStorage[DO_ENABLE_EVENT_LOGGING_KEY]=n},n.prototype.GetDoEnableMetrics=function(){return sessionStorage[DO_ENABLE_METRICS_KEY]},n.prototype.SetDoEnableMetrics=function(n){sessionStorage[DO_ENABLE_METRICS_KEY]=n;this.loadingService.areMetricsEnabled=n},n.prototype.GetUsersPreviousSignInDate=function(){var n=sessionStorage[USERS_PREVIOUS_SIGN_IN_DATE_KEY];return n?parseDate(n):null},n.prototype.SetUsersPreviousSignInDate=function(n){n&&(sessionStorage[USERS_PREVIOUS_SIGN_IN_DATE_KEY]=n)},n.prototype.GetCurrentDateTimeOffset=function(){return sessionStorage[CURRENT_DATE_TIME_OFFSET_KEY]},n.prototype.SetCurrentDateTimeOffset=function(n){n&&(sessionStorage[CURRENT_DATE_TIME_OFFSET_KEY]=n)},n.prototype.GetEntityFirstName=function(){return sessionStorage[ENTITY_FIRST_NAME_KEY]},n.prototype.SetEntityFirstName=function(n){sessionStorage[ENTITY_FIRST_NAME_KEY]=n},n.prototype.GetEntityLastName=function(){return sessionStorage[ENTITY_LAST_NAME_KEY]},n.prototype.SetEntityLastName=function(n){sessionStorage[ENTITY_LAST_NAME_KEY]=n},n.prototype.IncreaseTimeout=function(){var n=this,t=(this.stateService.SessionExpiryInMinutes-1)*6e4;this.CancelTimeout();this.sessionTimeout=this.$timeout(function(){n.AutoSignOut(!0)},t)},n.prototype.CancelTimeout=function(){this.sessionTimeout&&this.$timeout.cancel(this.sessionTimeout)},n.prototype.AutoSignOut=function(n){this.eventService.Broadcast("SignOut",n)},n.$inject=["$http","$timeout","Event","LoadingService","State"],n}();App.service("Session",SessionService);SignInService=function(){function n(n,t,i,r,u,f){this.$q=n;this.$http=t;this.stateService=i;this.commonService=r;this.sessionService=u;this.signalrService=f}return n.prototype.IsAuthenticated=function(){return!1},n.prototype.ClearSession=function(){this.sessionService.SetDoEnableMetrics(undefined);sessionStorage.clear()},n.prototype.SignInAsync=function(n,t,i,r){var e=this,u,f;return this.ClearSession(),u=this.$q.defer(),f=this.stateService.RootUrl+"api/SignIn",this.$http({method:"GET",url:f}).success(function(o){o.Portal=n;o.Site=t;o.Username=i;o.Password=r;e.$http({method:"POST",url:f,data:o}).success(function(n){n.SessionID!=null?u.resolve(n):n.TokenID!=null&&n.Username!=null&&u.resolve({TokenID:n.TokenID,Username:n.Username,Mobile:n.Mobile,LoginId:n.LoginId})}).error(function(){u.resolve(!1)})}).error(function(){u.resolve(!1)}),u.promise},n.prototype.SignOut=function(n){this.signalrService.stop();var t=this.stateService.RootUrl+"api/SignOut";this.$http({method:"POST",url:t,data:{SessionID:n}});this.ClearSession()},n.prototype.AccountActivationAsync=function(n,t,i){var f=this,r,u;return this.ClearSession(),r=this.$q.defer(),u=this.stateService.RootUrl+"api/Trouble",this.$http({method:"GET",url:u}).success(function(e){e.Action=3;e.Portal=n;e.Site=t;e.Key=i;f.$http({method:"POST",url:u,data:e}).success(function(n){r.resolve(n)}).error(function(){r.resolve(!1)})}).error(function(){r.resolve(!1)}),r.promise},n.prototype.RequestPasswordResetAsync=function(n,t,i){var f=this,r,u;return this.ClearSession(),r=this.$q.defer(),u=this.stateService.RootUrl+"api/Trouble",this.$http({method:"GET",url:u}).success(function(e){e.Action=4;e.Portal=n;e.Site=t;e.Key=i;f.$http({method:"POST",url:u,data:e}).success(function(n){r.resolve(n)}).error(function(){r.resolve(!1)})}).error(function(){r.resolve(!1)}),r.promise},n.prototype.TroubleSigningInAsync=function(n,t,i){var f=this,r,u;return this.ClearSession(),r=this.$q.defer(),u=this.stateService.RootUrl+"api/Trouble",this.$http({method:"GET",url:u}).success(function(e){e.Action=0;e.Portal=n;e.Site=t;e.Username=i;f.$http({method:"POST",url:u,data:e}).success(function(n){r.resolve(n)}).error(function(){r.resolve(!1)})}).error(function(){r.resolve(!1)}),r.promise},n.prototype.VerificationCodeAsync=function(n,t,i,r,u){var o=this,f,e;return this.ClearSession(),f=this.$q.defer(),e=this.stateService.RootUrl+"api/Trouble",this.$http({method:"GET",url:e}).success(function(s){s.Action=1;s.Portal=n;s.Site=t;s.Username=i;s.Key=r;s.Code=u;o.$http({method:"POST",url:e,data:s}).success(function(n){f.resolve(n)}).error(function(){f.resolve(!1)})}).error(function(){f.resolve(!1)}),f.promise},n.prototype.ResetPasswordAsync=function(n,t,i,r,u){var o=this,f,e;return this.ClearSession(),f=this.$q.defer(),e=this.stateService.RootUrl+"api/Trouble",this.$http({method:"GET",url:e}).success(function(s){s.Action=2;s.Portal=n;s.Site=t;s.Username=i;s.Key=r;s.Password=u;o.$http({method:"POST",url:e,data:s}).success(function(n){f.resolve(n)}).error(function(){f.resolve(!1)})}).error(function(){f.resolve(!1)}),f.promise},n}();App.service("SignIn",["$q","$http","State","Common","Session","Signalr",SignInService]);StaticDataService=function(){function n(n,t,i){this.staticDataCache=n("staticDataCache");this.$http=t;this.$q=i}return n.prototype.Get=function(n){var u=this,t=this.$q.defer(),i=this.staticDataCache.get(n),r;return i?t.resolve(i):(r="api/StaticData?sessionId="+getSessionId()+"&key="+n,this.$http.get(r).success(function(i){var e={},r,f;if(i)for(r=0;r<i.length;r++)e[i[r].Key]=i[r];f={array:i,dict:e};u.staticDataCache.put(n,f);t.resolve(f)})),t.promise},n}();App.service("StaticData",["$cacheFactory","$http","$q",StaticDataService]);TaskService=function(){function n(n,t,i,r,u,f,e){var o=this;this.$rootScope=n;this.Model=u;this.Toast=e;this.TASKS_TO_DISPLAY=5;this.TaskCount=0;this.GetTaskCount();r.OnBroadcast(n,"Task",function(n){o.GetTaskCount();switch(n.Status){case"New":var t="You have been assigned the following task: "+n.ProcessDescription;o.DisplayToast("info",t,undefined,function(){f.HandleAction("Workflow",n.Id,[])})}})}return n.prototype.GetTaskCount=function(){var n=this;this.Model.LoadList("UserWorkflow",{pageSize:1},function(t){n.TaskCount=t.Info.TotalItems})},n.prototype.DisplayToast=function(n,t,i,r){this.Toast.DisplayToast(n,t,i,r)},n.$inject=["$rootScope","$window","Common","Event","Model","NotificationAction","Toast"],n}();App.service("Task",TaskService);ToastService=function(){function n(n){this.$sanitize=n;toastr.options.positionClass="toast-bottom-right"}return n.prototype.DisplayToast=function(n,t,i,r){t=this.$sanitize(t);switch(n){case"success":toastr.success(t,i);break;case"info":toastr.info(t,i,{onclick:r});break;case"warning":toastr.warning(t,i);break;case"error":toastr.error(t,i)}},n.$inject=["$sanitize"],n}();App.service("Toast",ToastService);UserService=function(){function n(n,t,i){this.Common=n;this.Model=t;this.Event=i}return n.prototype.AddShortcut=function(n,t,i,r){var f=this,u;r===void 0&&(r=5);u=this.Common.PORTALCODE.toLowerCase();this.GetUser().then(function(e){var o,s;for(e.Settings||(e.Settings={}),e.Settings[u]||(e.Settings[u]={shortcuts:{}}),e.Settings[u].shortcuts[n]||(e.Settings[u].shortcuts[n]=[]),o=e.Settings[u].shortcuts[n],s=0;s<o.length;s++)o[s].url==t&&(o.splice(s,1),s--);o.push({url:t,title:i});o.length>r&&o.splice(0,1);f.Model.Update("UserProfile",undefined,e,function(){f.Event.Broadcast("Shortcuts",{})})})},n.prototype.GetUser=function(){return this.Model.LoadUsingCache("UserProfile",undefined).then(function(n){return n.data})},n.prototype.GetShortcuts=function(n){var t=this.Common.PORTALCODE.toLowerCase();return this.GetUser().then(function(i){if(i.Settings&&i.Settings[t]&&i.Settings[t].shortcuts[n])return i.Settings[t].shortcuts[n]})},n.prototype.HasRight=function(n){if(this.rights&&this.rights.indexOf(n)!=-1)return!0},n.prototype.RemoveShortcut=function(n,t){var i=this,r=this.Common.PORTALCODE.toLowerCase();this.GetUser().then(function(u){for(var e=u.Settings[r].shortcuts[n],f=0;f<e.length;f++)e[f].url==t&&(e.splice(f,1),f--);i.Model.Update("UserProfile",undefined,u,undefined)})},n.prototype.SetRights=function(n){this.rights=n},n}();App.service("User",["Common","Model","Event",UserService]);ValidationService=function(){function n(){}return n.prototype.CheckPasswordStrength=function(n){var i=0,t=0;return n&&(i=n.length,n.match("[a-z]")!=null&&t++,n.match("[A-Z]")!=null&&t++,n.match("[0-9]")!=null&&t++,n.match("[^a-zA-Z0-9]")!=null&&t++),i*t},n.prototype.IsValidIrdNumber=function(n){var r=!1,t,u,i;return n&&n.length!==0?/^\d+$/.test(n)&&n.length>=8&&n>=1e7&&n<=15e7&&(t=n.substring(0,n.length-1),u=n%10,t.length==7&&(t="0"+t),i=this.CalculateCheckDigit(t,[3,2,7,6,5,4,3,2]),i===10?(i=this.CalculateCheckDigit(t,[7,4,3,2,5,2,7,6]),i!==10&&(r=u===i)):r=u===i):r=!0,r},n.prototype.CalculateCheckDigit=function(n,t){for(var r=0,i=0;i<8;i++)r+=n.substring(i,i+1)*t[i];return r%11==0?0:11-r%11},n}();App.service("Validation",ValidationService);App.directive("axAddressFinder",function(){return{scope:{address:"=",defaultCountryId:"@"},link:function(n,t,i){t.wrap('<div id="af_results_container" style="position: relative; margin: 0 0 5px"><\/div>');var u=document.getElementById("af_results_container"),f=document.getElementById(t[0].id),r={container:u,show_locations:!1,empty_content:"No results found",address_params:{delivered:1}};i.excludePostBoxes&&i.excludePostBoxes.toLowerCase()=="true"&&(r.address_params.post_box=0);widget=new AddressFinder.Widget(f,"8RVHP3N79EKB6J4GUCXM",r);widget.on("result:select",function(t,r){var u,f,t;for(n[i.result]=r,n.address||(n.address={}),r.box_type?u=r.lobby_name!=r.city?r.lobby_name:undefined:r.rd_number?u="RD "+r.rd_number:r.suburb!=r.city&&(u=r.suburb),n.address.a=r.a,n.address.Address1=r.postal_line_1,f=2;f<=5;f++)if(t=r["postal_line_"+f],t)if(t.indexOf(u||r.suburb)==0)break;else n.address.Address1+=", "+t;else break;n.address.Suburb=u;n.address.City=r.rd_number?r.mailtown:r.city;n.address.PostCode=r.postcode;n.address.Country_Id=Number(n.defaultCountryId);n.$apply()})}}});App.directive("axAutoTab",function(){return{link:function(n,t,i){t.bind("keyup",function(n){if(n.keyCode!="9"&&n.keyCode!="16"&&this.value.length===this.maxLength){var t=document.getElementById(i.axAutoTab);t&&t.focus()}})}}});App.directive("axAutoTabOnSelection",function(){return{require:"ngModel",link:function(n,t,i,r){t.bind("change",function(){if(r.$viewValue&&r.$viewValue===i.selectionValue){var n=document.getElementById(i.axAutoTabOnSelection);n&&n.focus()}})}}});App.directive("axClickSelect",function(){return{link:function(n,t){t.bind("click",function(){this.select()})}}});App.directive("axDateToIso",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){r.$parsers.push(function(n){return moment(n).format("YYYY-MM-DD")})}}});App.directive("axDemand",["$animate","State",function(n,t){function f(n){var i=n[0],u=n[n.length-1],t,r;if(i===u)return $(i);t=i;r=[t];do{if(t=t.nextSibling,!t)break;r.push(t)}while(t!==u);return $(r)}function e(t,i,r,u,e,o,s,h){h?e||(e=t.$new(),u(e,function(t){t[t.length++]=document.createComment(" end axDemand: "+r.axDemand+" ");o={clone:t};n.enter(t,i.parent(),i)})):(s&&(s.remove(),s=null),e&&(e.$destroy(),e=null),o&&(s=f(o.clone),n.leave(s,function(){s=null}),o=null))}var i=function(n,t){var r=[],i,u,f;return t.axDemand?(i=n.$eval(t.axDemand),angular.isArray(i)?r=i:r.push({Action:i.Action,Resource:i.Resource})):(u=n.$eval(t.actionDynamic),f=n.$eval(t.resourceDynamic),r.push({Action:u,Resource:f})),r},r=function(n){var i,t;if(n.length==0)throw"No demands have been specified";for(i=0;i<n.length;i++)if(t=n[i],!t.Action||!t.Resource)throw"Invalid Action and / or Resource Demanded. Action = "+t.Action+", Resource = "+t.Resource;},u=function(n,t,i){for(var u,r=0;r<t.length;r++)if(u=t[r],n.Action==u.Action&&n.Resource==u.Resource){if(i)while(t.length>0)t.pop();else t.splice(r,1);break}};return{transclude:"element",priority:500,terminal:!0,$$tlb:!0,link:function(n,f,o,s,h){var rt=t.DoShowTestPage,ut,ft,et,l=i(n,o),y,p,w,v,b,k,c,d,tt,it;r(l);y=[];p=[];o.portfolioRights&&(y=n.$eval(o.portfolioRights));o.orgRights&&(p=n.$eval(o.orgRights));var g=n.$eval(o.inverse),ot=n.$eval(o.demandAny),nt=p.concat(y),a=!1;if(o.predicate&&(a=!0,w=n.$eval(o.predicate)),v=!1,!a||a&&w===!0)for(c=0;c<nt.length;c++)if(b=nt[c],b&&u(b,l,ot),l.length==0){v=!0;break}if(rt&&!v){if(console.log("ax-demand check failed"),a&&w!==!0)console.log("The following Predicate was not satisfied: "+o.predicate);else{for(k="",c=0;c<l.length;c++)d=l[c],k+="["+d.Action+", "+d.Resource+"] ";console.log("The following Right(s) were not present: "+k)}console.log("")}tt=angular.isDefined(g)&&g==!0;it=v==tt?!1:!0;e(n,f,o,h,ft,ut,et,it)}}}]);App.directive("axEmptyToNull",function(){return{require:"ngModel",link:function(n,t,i,r){r.$parsers.push(function(n){return n===""?null:n})}}});App.directive("axExcludeSeparator",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){r.$parsers.push(function(n){var t=!0;return n==-1&&(t=!1),r.$setValidity("separator",t),t?n:undefined})}}});App.directive("axExcludeSpecialCharacters",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){var u=new RegExp("^[^@#^`%&|><\"';.\\\\/!:,]+$");r.$parsers.push(function(n){var t=!0;return n&&(t=u.test(n)),r.$setValidity("specialCharacters",t),t?n:undefined})}}});App.directive("axExpandLoneMenu",["$location","Common",function(n,t){return{link:function(i,r){var o=$(r).find("> li"),e=[],f;if(angular.forEach(o,function(n){var t=$(n);t.attr("style")||e.push(n)}),e.length==1&&(f=$(e[0]),f.find("> a").hide(),f.find("> ul").removeClass().addClass("nav nav-pills nav-stacked-xs no-margin-b"),f.attr("ng-class").indexOf("isTab()")==-1)){var u=f.find("li").first().find("> a").attr("ng-click"),s=u.substring(u.indexOf("setTab('")+8,u.indexOf("')")),h=u.substring(u.indexOf("setMenuItem('")+13,u.indexOf("')",u.indexOf("')")+3));t.SetHashParam("t",s);t.SetHashParam("m",h);n.replace()}}}}]);App.directive("axGreaterThanZero",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){var u=function(n){return n?Number(n)>0?n:(r.$setViewValue(""),r.$render(),""):n};r.$parsers.push(u)}}});App.directive("axGroupBy",["$routeParams","$filter","$parse",function(n,t,i){return function(n,r,u){n.$watch(u.input,function(){var e=n.$eval(u.input),f,r,h,c,s;if(e){var v=u.groupBy,y=u.groupMin,p=u.groupState,l=u.groupFirstItemKey,o=u.orderBy,w=u.orderDirection,a=t("orderBy"),b=u.output;o&&(o=JSON.parse(o),e=a(e,o,w=="desc"));f=[];angular.forEach(e,function(n){var r=i(v)(n),e=i(p)(n),u=i(y)(n),t=f[r];t?(t.ids+=","+n.Id,t.items.push(n),t.min>u&&(t.min=u)):(t={},t.key=r,t.ids=""+n.Id,t.state=e,t.min=u,t.items=[],t.items.push(n),f[r]=t)});r=[];for(h in f)f.hasOwnProperty(h)&&r.push(f[h]);if(r=a(r,"key"),l){for(c=[],s=0;s<r.length;s++)c.push(r[s]);r=[];angular.forEach(c,function(n){n.key==l?r.unshift(n):r.push(n)})}n[b]=r}})}}]);App.directive("axHideEmptyMenu",function(){return{link:function(n,t){t=$(t);t.find("li").length==0&&t.hide()}}});App.directive("axJobProgress",["$timeout","Event",function(n,t){return{restrict:"A",templateUrl:"Views/JobProgress",scope:{inProgressCaption:"@",onComplete:"&",onError:"&",jobId:"=",percentComplete:"="},link:function(i){function f(n){return n!=null&&n!=""}function e(){console.log("startListeningToJobEvents");u=t.OnBroadcast(i,"Job",s);r=!0}function o(){console.log("stopListeningToJobEvents");u();u=null;r=!1}function s(t){console.log(t);t.Id==i.jobId&&n(function(){i.percentComplete=t.HasErrored?100:t.PercentageComplete;i.jobHasErrored=t.HasErrored;i.percentComplete>=100&&(i.jobHasErrored?i.onError():i.onComplete(),i.percentComplete=0,i.jobId=null)})}i.percentComplete=i.percentComplete?i.percentComplete:0;i.jobHasErrored=!1;var u=null,r=!1;i.$watch("jobId",function(n){f(n)&&!r?e():!f(n)&&r&&o()});i.getWidth=function(){return{width:i.percentComplete+"%"}};i.doShow=function(){return i.jobId!=null}}}}]);App.directive("axMatch",function(){return{require:"ngModel",restrict:"A",link:function(n,t,i,r){r.$parsers.push(function(t){return t==n.$eval(i.axMatch)?(r.$setValidity("match",!0),t):(r.$setValidity("match",!1),undefined)});n.$watch(i.axMatch,function(){n.$eval(i.axMatch)==r.$viewValue?r.$setValidity("match",!0):r.$setValidity("match",!1)})}}});App.directive("axMaxlength",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){var u=function(n){var t,u;return n?(t=i.axMaxlength,n.length<=Number(t)?n:(u=n.substr(0,t),r.$setViewValue(u),r.$render(),u)):n};r.$parsers.push(u)}}});App.directive("axModalStickyColumn",function(){return{link:function(n,t){var i=15;t.attr("style","position:relative;");$(".modal").scroll(function(){var n=$(t).parent().offset().top;n<0?$(t).css("top",Math.abs(n)+i+"px"):$(t).css("top","0px")})}}});App.directive("axNumericOnly",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){var u=function(n){var u,f,t;return n?(f=i.axNumericOnly,u=f=="decimal"?/[^0-9\.]/g:/[^0-9]/g,t=n.replace(u,""),t!==n?(r.$setViewValue(t),r.$render(),t):n):n};r.$parsers.push(u)}}});App.directive("axOptions",["$location","Common","Event","Model","StaticData",function(n,t,i,r,u){return{templateUrl:"Views/Options",scope:{options:"=",staticData:"@",edit:"@"},link:function(n){u.Get(n.staticData).then(function(t){n.allOptions=t});var i=function(n,t){for(var r=t.length,i=0;i<r;i++)t[i]==n&&t.splice(i,1)},r=function(n,t){t.push(n)},t=function(n,t){for(var r=t.length,i=0;i<r;i++)if(t[i]==n)return!0;return!1};n.isSelected=function(n,i){return t(n,i)};n.toggle=function(n,u){t(n,u)?i(n,u):r(n,u)}}}}]);App.directive("axSearchFilter",["$location","Common","Event","Model","Search",function(n,t,i,r,u){return{templateUrl:"Views/SearchFilter",scope:{hashParamSuffix:"@",orderType:"@",filterType:"@",filterApi:"@",filterParams:"=",filterData:"=",filterSingleSelect:"@",change:"&",selectedFilterDataKey:"=?",defaultFilterKey:"@"},link:function(f,e,o){function v(){var n=new ModelServiceOptions;n.params=p;o.filterPassCurrentFiltersToApi&&$.extend(!0,n.params,{filters:t.GetHashParam(h)});r.LoadList2(c,n).then(function(n){var e={},o,r,t,i;if(n)for(t=0;t<n.length;t++)i=n[t],o=i.Key,e[o]=i;if(f.availableFilterItems={},f.availableFilterItems.array=n,f.availableFilterItems.dict=e,r=u.GetFiltersFromUrl(h),r[s])for(t=0;t<r[s].Items.length;t++)i=r[s].Items[t],f.availableFilterItems.dict[i]||u.ToggleListParam(h,s,i,f)})}function y(n){u.SetListParam(h,s,[n],f)}function w(){var n=u.GetFiltersFromUrl(h);for(var t in n)if(n[t].Name==s)return!0;return!1}function b(n){var t=u.GetFiltersFromUrl(h),i,r;for(i in t)if(t[i].Name==s)for(r in t[i].Items)if(t[i].Items[r]==n)return!0;return!1}function k(){return t.GetHashParam(a)}function d(n){return k()===n}function g(n){t.SetHashParam(a,n);f.change()}function nt(){var r=u.GetFiltersFromUrl(h),t=[],n=r[s],i;if(n)for(i in n.Items)f.availableFilterItems?t.push(f.availableFilterItems.dict[n.Items[i]].Value):f.filterData&&t.push(f.filterData.dict[n.Items[i]].Value);return t}var a=f.hashParamSuffix+"OrderBy",tt=f.orderType,h=f.hashParamSuffix+"FilterBy",s=f.filterType,c=f.filterApi,p=f.filterParams,l;f.filterOrder=o.preserveFilterDataOrder?undefined:"Value";l=undefined;f.$watch(function(){return n.path()},function(n){if(n!=l){l=n;var t=u.GetListParam(h,s,f);t.length>0&&(f.selectedFilterDataKey=t[0])}});c&&v();o.filterPassCurrentFiltersToApi&&i.OnBroadcast(f,c,function(){v()});f.SetFilter=y;f.HasFilterBy=b;f.ClearFilter=function(){u.ClearFilter(h,s,f)};f.ToggleListParam=function(n){u.ToggleListParam(h,s,n,f)};f.HasOrderBy=d;f.OrderBy=g;f.GetListParam=function(){return u.GetListParam(h,s,f)};f.HasListParam=function(n){return u.HasListParam(h,s,f,n)};f.GetActiveFilterDescriptions=nt;f.defaultFilterKey&&!w()&&y(f.defaultFilterKey)}}}]);App.directive("axStopEvent",function(){return function(n,t){t.bind("click",function(n){n.stopPropagation()})}});App.directive("auditText",["Common","Model","Event","Notification",function(n,t,i,r){return{replace:!0,scope:{auditText:"="},link:function(u,f,e){u.goto=function(){var t={id:u.auditText.Id,modelName:e.modelName+"Audit"};n.OpenDialog("AuditHistoryDialog",t,undefined,"lg")};u.activate=function(){n.OpenDialog("ConfirmationDialog",{templateUrl:"AuditRecordStatusActivateConfirmation"},function(n){if(n){var f=u.auditText;f.RecordStatus="Active";t.Update(e.modelName,u.auditText.Id,f,function(n){i.Broadcast(e.modelName,n);r.DisplayToast("success","Record Activated")})}})};u.cancel=function(){n.OpenDialog("ConfirmationDialog",{templateUrl:"AuditRecordStatusCancelConfirmation"},function(n){if(n){var f=u.auditText;f.RecordStatus="Cancelled";t.Update(e.modelName,u.auditText.Id,f,function(n){i.Broadcast(e.modelName,n);r.DisplayToast("success","Record Cancelled")})}})};u.undo=function(){n.OpenDialog("ConfirmationDialog",{templateUrl:"AuditRecordStatusUndoConfirmation"},function(n){if(n){var f=u.auditText;f.RecordStatus="Pending";t.Update(e.modelName,u.auditText.Id,f,function(n){i.Broadcast(e.modelName,n);r.DisplayToast("success","Record Cancellation Undone")})}})}},templateUrl:"Views/AuditText"}}]);App.directive("bankAccountForm",function(){return{replace:!0,scope:{model:"=",readonly:"="},templateUrl:"Views/BankAccount"}});App.directive("capsLock",["$parse",function(n){return{link:function(t,i,r){i.bind("keypress",function(i){var o=n(r.capsLock),e=!1,u,f;i.which?u=i.which:i.keyCode&&(u=i.keyCode);f=!1;i.shiftKey?f=i.shiftKey:i.modifiers&&(f=!!(i.modifiers&4));u>=97&&u<=122&&f&&(e=!0);u>=65&&u<=90&&!f&&(e=!0);o.assign(t,e)})}}}]);App.directive("chart",["$timeout","Chart",function(n,t){return{restrict:"A",template:"<div><\/div>",replace:!0,scope:{settings:"=",afterChartRender:"&",data:"=",chart:"=?"},link:function(n,i,r){function u(t){$.extend(!0,t,f);n.chart=r.type=="stock"?new Highcharts.StockChart(t):new Highcharts.Chart(t);n.afterChartRender({data:n.chart.series})}Highcharts.setOptions({lang:{thousandsSep:","}});var f={chart:{renderTo:i[0]},credits:{enabled:!1}};n.$watch("data",function(n){if(n){var i=t[r.settingsMethodName](n);u(i)}});n.$watch("settings",function(n){n&&u(n)})}}}]);App.directive("disabledOnClick",function(){return{scope:{disabledOnClick:"&"},link:function(n,t){var i=function(){t.attr("disabled","false")};t.bind("click",function(){t.attr("disabled","true");var r=n.disabledOnClick();r?r.then(i,i):i()})}}});App.directive("dynamicData",["$routeParams","Model",function(n,t){return function(i,r,u){var f=u.dynamicData,s=i.$eval(u.parentId)||n.id,e=i.$eval(u.params)||{},o;e.parentId=s;e.pageSize=100;o=new ModelServiceOptions;o.params=e;t.LoadList2(f,o).then(function(n){var t=[],u,r,e,o;if(t=n.Info&&n.Items?n.Items:n,u={},t)for(r=0;r<t.length;r++)e=t[r],o=e.Id,u[o]=e;i[f]=t;i[f+"Dict"]=u})}}]);App.directive("fieldGroup",function(){return{require:["^form","^?fieldFormGroup"],scope:{},replace:!0,transclude:!0,template:'<div ng-class="getClass()" ng-transclude><\/div>',controller:["$scope","$attrs",function(n){this.setFieldName=function(t){n.fieldName||(n.fieldName=t)};this.setRequired=function(t){n.isRequired=t}}],link:function(n,t,i,r){n.getClass=function(){var t=n.$parent[r[0].$name],u,i;return t&&(u=t[n.fieldName]),i=t,r[1]&&(i=n.$parent[r[1].getParentFormName()]),t&&u&&u.$invalid&&i&&i.displayErrors?"form-group has-error":"form-group"}}}});App.directive("fieldFormGroup",function(){return{controller:["$scope","$attrs",function(n,t){this.getParentFormName=function(){return t.fieldFormGroup}}]}});App.directive("fieldLabel",function(){return{replace:!0,transclude:!0,template:'<label class="control-label" for="{{$parent.fieldName}}"><span ng-transclude><\/span><span ng-show="$parent.isRequired" class="mandatory"> *<\/span><\/label>'}});App.directive("fieldCheckbox",function(){return{require:"^form",compile:function(n,t){return t.helpText?n.replaceWith('<div class="checkbox '+t["class"]+'"><label><input type="checkbox" ng-model="'+t.ngModel+'"'+(t.ngChange?' ng-change="'+t.ngChange+'"':"")+(t.ngDisabled?' ng-disabled="'+t.ngDisabled+'"':"")+(t.ngChecked?' ng-checked="'+t.ngChecked+'"':"")+" />"+t.label+' <span popover="'+t.helpText+'" class="circle-icon" popover-trigger="mouseenter" popover-placement="right">?<\/span><\/label><\/div>'):n.replaceWith('<div class="checkbox '+t["class"]+'"><label><input type="checkbox" ng-model="'+t.ngModel+'"'+(t.ngChange?' ng-change="'+t.ngChange+'"':"")+(t.ngDisabled?' ng-disabled="'+t.ngDisabled+'"':"")+(t.ngChecked?' ng-checked="'+t.ngChecked+'"':"")+" />"+t.label+"<\/label><\/div>"),function(n,t,i,r){var u=n[r.$name],f;u.focusSet||(f=i.disabled||i.ngDisabled,f||($(t).focus(),u.focusSet=!0))}}}});App.directive("fieldInput",["$compile","$filter",function(n,t){return{require:["^form","^fieldGroup","ngModel","^?fieldFormGroup"],compile:function(i,r){var s=!1,h=$(i).is("select"),u,f,e,o,c;return h&&(r.required||$(i).prepend('<option value=""><\/option>'),u=jQuery.trim(r.ngOptions.split("|")[0]).split(" ").pop(),e=jQuery.trim(r.ngOptions.split("|")[1]).split(/:(?=[^\}]*(?:\{|$))/g),f=jQuery.trim(e[0]),o=jQuery.trim(r.ngOptions.split("|")[0]).split(" ").shift().split(".")[1]),function(i,r,l,a){var y,p,v,w;(l.disabled||l.ngDisabled)&&(s=!0);u&&i.$watch(u,function(n){var u,h,r;if(n){if(f){for(u=e.slice(1),r=0;r<u.length;r++)u[r]=i.$eval(jQuery.trim(u[r]));u.unshift(n);n=t(f).apply(null,u)}if(a[2].$modelValue){for(h=!1,r=0;r<n.length;r++)if(n[r][o]===a[2].$modelValue){h=!0;break}h||(a[2].$setViewValue(undefined),a[2].$render())}l.required&&!s&&(n.length==1?(a[2].$setViewValue(n[0][o]),a[2].$render(),l.$set("disabled","disabled"),a[1].setRequired(!1),c=!0):(l.$set("disabled",undefined),a[1].setRequired(!0)))}});l.required&&a[1].setRequired(!0);l.ngRequired&&i.$watch(function(){return i.$eval(l.ngRequired)},function(n){n?a[1].setRequired(!0):a[1].setRequired(!1)});a[1].setFieldName(l.name);l.$set("id",l.name);h||l.$set("type",l.type||"text");l.type!="checkbox"&&(l["class"]||l.$set("class","form-control"));y=i[a[0].$name];y.focusSet||(p=l.disabled||l.ngDisabled,p||($(r).focus(),y.focusSet=!0));l.ngMinlength&&(i.minlength=l.ngMinlength);l.ngMaxlength&&(i.maxlength=l.ngMaxlength);l.ngPattern&&(i.ngPatternFailureMessage=l.ngPatternFailureMessage);l.uiValidate&&(i.uiValidateFailureMessage=l.uiValidateFailureMessage);l.axMatchFailureMessage&&(i.axMatchFailureMessage=l.axMatchFailureMessage);v="";v+='<span ng-show="showError(\'required\')" class="help-block">This field is required<\/span>';v+='<span ng-show="showError(\'separator\')" class="help-block">This field is required<\/span>';v+='<span ng-show="showError(\'email\')" class="help-block">Please enter a valid email address<\/span>';v+='<span ng-show="showError(\'minlength\')" class="help-block">Minimum length is {{minlength}}<\/span>';v+='<span ng-show="showError(\'maxlength\')" class="help-block">Maximum length is {{maxlength}}<\/span>';v+='<span ng-show="showError(\'date\')" class="help-block">Please enter a valid date<\/span>';v+='<span ng-show="showError(\'pattern\')" class="help-block">{{ngPatternFailureMessage}}<\/span>';v+='<span ng-show="showError(\'specialCharacters\')" class="help-block">The following characters are not allowed: @ # ^ ` % & | > < " \' ; . \\ / ! : ,<\/span>';v+='<span ng-show="showError(\'validator\')" class="help-block">{{uiValidateFailureMessage}}<\/span>';v+='<span ng-show="showError(\'match\')" class="help-block">{{axMatchFailureMessage}}<\/span>';w=n(v)(i);r.parent().append(w);i.showSuccess=function(){if(c)return!1;var n=y[l.name];return y&&n&&n.$valid&&n.$dirty&&n.$viewValue!==""&&n.$viewValue!=null?!0:!1};i.showError=function(n){var t=y,r;return a[3]&&(t=i[a[3].getParentFormName()]),r=y[l.name],y&&r&&t&&t.displayErrors&&r.$error[n]?!0:!1}}}}}]);App.directive("fieldDefault",function(){return{require:"ngModel",link:function(n,t,i,r){n.$watch(function(){return n.$eval(i.fieldDefault)},function(n){n&&isNull(r.$modelValue)&&(r.$setViewValue(n),r.$render())})}}});App.directive("submitAction",function(){return{link:function(n,t,i){t.bind("submit",function(){var t=n[i.name];t.$valid?n.$apply(i.submitAction):(t.displayErrors=!0,n.$apply())})}}});App.directive("submitButton",function(){return{replace:!0,scope:{className:"@",isSubmitting:"=",label:"@",submittingLabel:"@",isDisabled:"=",darkSpinner:"@",buttonType:"@"},template:'<button type="{{buttonType || \'submit\'}}" class="{{className || \'btn btn-primary\'}}" ng-disabled="isDisabled || isSubmitting"><span ng-show="!isSubmitting">{{label || "Save"}}<\/span><span ng-show="isSubmitting" class="spinner"><span data-us-spinner="{color: darkSpinner ? \'#333\' : \'#fff\'}"><\/span><\/span><span ng-show="isSubmitting"> {{submittingLabel || "Saving"}}<\/span><\/button>'}});App.directive("fieldForceFocus",function(){return{require:"^form",link:function(n,t,i,r){var u=n[r.$name];u.forcedFocusSet||($(t).focus(),u.forcedFocusSet=!0)}}});App.directive("ngFocus",["$timeout",function(n){return{link:function(t,i,r){t.$watch(r.ngFocus,function(t){angular.isDefined(t)&&t&&n(function(){i[0].focus()})},!0);i.bind("blur",function(){angular.isDefined(r.ngFocusLost)&&t.$apply(r.ngFocusLost)})}}}]);App.directive("genericForm",["$compile","$http","$templateCache",function(n,t,i){return{replace:!0,scope:{model:"=",readonly:"="},compile:function(r,u){var f="Views/"+u.genericForm;return function(r,u){t.get(f,{cache:i}).success(function(t){u.html(t);n(u.contents())(r)})}}}}]);App.directive("loadModel",["$route","$routeParams","Model","Event",function(n,t,i,r){return function(u,f,e){var c=e.loadModel,s,h=e.model?e.model:e.loadModel,o;s=e.modelId?u.$eval(e.modelId):e.idParam?t[e.idParam]:t.id;u.params=n.current.params;o=new ModelServiceOptions;o.action=e.action;i.LoadItem2(c,s,o).then(function(n){u[h]={model:n}});r.OnBroadcast(u,e.loadModel,function(n){u[h]={model:n}})}}]);App.directive("noValuePlaceholder",function(){return{scope:{noValuePlaceholder:"="},transclude:!0,link:function(n,t,i){n.hasValue=!1;var r;r=i.noValuePlaceholder?"noValuePlaceholder":"$parent."+t[0].lastChild.firstChild.innerHTML.replace("{{","").replace("}}","");n.$watch(r,function(t){n.hasValue==!0&&(t==null||t==="")&&(n.hasValue=!1);angular.isDefined(t)&&t!=null&&t!==""&&(n.hasValue=!0)})},template:'<em ng-hide="hasValue">Not specified<\/em><span ng-show="hasValue" ng-transclude><\/span>'}});App.directive("pageTitle",["$location","User",function(n,t){return function(n,i,r){var u=r.pageTitle,f;document.title=u;r.bookmarkTitle?(f=r.bookmarkTitle,n.$watch(f,function(n){n&&(t.BookmarkTitle=u+" - "+n)})):t.BookmarkTitle=u}}]);App.directive("search",["$compile","$http","$route","$location","$templateCache","$timeout","$q","$filter","Common","Model","Event","User","Search",function(n,t,i,r,u,f,e,o,s,h,c,l,a){return{transclude:!0,replace:!0,scope:{dynamicParams:"=",dynamicModel:"=",linkModel:"@",linkParentId:"@",linkParentModel:"@",parentId:"=",grandparentId:"=",parentModel:"=",searchComplete:"&",selectedItems:"=",hideSearchCriteria:"@",itemClicked:"&",useInternalSearchAndPaging:"@"},compile:function(i,v,y){var b="Views/Search",p,w;return v.advancedOptionsView&&(p="Views/"+v.advancedOptionsView),v.resultsView&&(w="Views/"+v.resultsView),function(i,k,d){function ot(){i.isLoading=!0;nt.filters=s.GetHashParam(vt);nt.orderBy=s.GetHashParam(yt);h.SearchWithParams(s,g,i.page,i.pageSize,i.criteria,nt,function(n){var t,r,u;i.result=n;t=e.defer();i.linkModel?(r=[],angular.forEach(n.Items,function(n){r.push(n.Id)}),u={childIds:r,parentId:i.linkParentId,parentModel:i.linkParentModel},h.LoadList(i.linkModel,u,function(i){angular.forEach(i,function(t){for(var i=0;i<n.Items.length;i++)if(t[g].Id==n.Items[i].Id){n.Items[i].alreadyLinked=!0;break}});f(function(){t.resolve()})})):t.resolve();t.promise.then(function(){if(i.selectedItems)if(ft){var t=!0,n=!0;angular.forEach(i.result.Items,function(r){angular.forEach(i.selectedItems,function(n){r.Id==n.Id&&(r.Checked=!0)});r.alreadyLinked||(n=!1,r.Checked||(t=!1))});i.allItemsChecked=n?!1:t;i.noCheckableItems=n}else lt()});i.isInsideDialog==!1&&(isUndefinedOrEmptyString(i.criteria)?s.RemoveHashParam(it):s.SetHashParam(it,i.criteria));i.hasResults=i.result.Info.TotalItems>0;i.useInternalSearchAndPaging&&(i.result.InternalItems=i.result.Items,i.result.Info.TotalPages=Math.floor((i.result.Info.TotalItems+i.pageSize-1)/i.pageSize),i.result.Info.HasPreviousPage=i.internalPage>1,i.result.Info.HasNextPage=i.internalPage<i.result.Info.TotalPages);i.searchComplete&&i.searchComplete({criteria:i.criteria,hasResults:i.hasResults,results:i.result.Items,totalItems:i.result.Info.TotalItems});i.isFilter&&(i.showFilter=!isUndefinedOrEmptyString(i.criteria)||i.result.Info.TotalPages>1||v.advancedOptionsView!=undefined||v.alwaysShowSearchBox!=undefined||v.showRecordStatusFilter!=undefined);i.isLoading=!1},d.searchAction)}function lt(){i.selectedItems=[];i.result&&angular.forEach(i.result.Items,function(n){n.Checked=!1});i.allItemsChecked=!1}var tt,st,rt,g,nt,it,at;i.dialog=i.$parent.dialog;tt=[];tt.push(t.get(b,{cache:u}));p&&tt.push(t.get(p,{cache:u}));w?tt.push(t.get(w,{cache:u})):(st=!0,tt.push({}));e.all(tt).then(function(t){for(var f,r,e,o,s,u=0;u<t.length;u++)f=$("<div><\/div>"),u==t.length-1?st?y(i,function(n){k.append(n)}):(r=f.append(t[u].data),r.find("table").wrap("<div data-ng-show=\"hasResults\" ng-class=\"{ 'panel-padding-top': (isInsideDialog && isFilter && showFilter == false), 'filter-hidden': (isFilter && showFilter == false) }\" /><\/div>"),i.selectedItems&&(e=r.find("table").attr("data-ng-controller")||r.find("table").attr("ng-controller"),r.find("tr:first").prepend('<th style="width: 1px" class="checkbox-cell"><input type="checkbox" ng-model="'+(e?"$parent.":"")+'allItemsChecked" ng-click="checkAll()" ng-disabled="'+(e?"$parent.":"")+'noCheckableItems" /><\/th>'),o=r.find("tr:last").attr("ng-class",'{ "selectable-item": !item.alreadyLinked, warning: item.Checked }').attr("ng-click","checkedChange(item, $event)").prepend('<td class="checkbox-cell"><input type="checkbox" ng-model="item.Checked" ng-disabled="item.alreadyLinked" /><\/ td>'),i.linkModel&&o.find("td:eq(1)").append('<small class="muted" ng-show="item.alreadyLinked"> (Already Linked)<\/small>')),i.isInsideDialog&&(s=r.find("a").text(),r.find("a").replaceWith(s)),k.append(n(r.contents())(i))):(f.append(t[u].data),k.append(n(f.contents())(i)));i.hideSearchCriteria||d.preventInitialFocus||$(k).find("#criteria").focus()});rt=isDefined(p);g=d.search;g||(g=i.dynamicModel);var ht=g+"FilterBy",ut=d.eventName||g,ct=d.parentIdParamName||"parentId",ft=d.retainSelectedItemsAfterSearch||!1;i.canPoll=d.canPoll||!1;i.isFilter=d.isFilter||!1;i.isInsideDialog=d.isInsideDialog||!1;nt={};d.params?nt=i.$eval(d.params):i.dynamicParams&&(nt=i.dynamicParams);i.settings=i.$eval(d.settings);i.alwaysShowSearchBox=d.alwaysShowSearchBox;i.showRecordStatusFilter=d.showRecordStatusFilter;d.alwaysShowAdvancedOptions?i.showAdvancedOptions=!0:i.showAdvancedOptionsBtn=rt;i.isInsideDialog==!1&&(it=g+"Criteria");var vt=g+"FilterBy",yt=g+"OrderBy",et=g+"AdvancedSearch";i.pageSize=v.pageSize?Number(v.pageSize):10;i.page=1;i.useInternalSearchAndPaging&&(i.internalPage=1);i.searchableFields=i.$eval(d.searchableFields)||[];i.resetPaging=function(){i.page=1};i.setParam=function(n,t){nt[n]=t};i.getParams=function(){return nt};i.setFilter=function(n){n===!0?(i.isFilter=!0,i.showFilter=!0):(i.isFilter=!1,i.showFilter=!1)};i.onLoad=function(n){var t=r.path();i.$watch(function(){return r.search()},function(){r.path()==t&&(i.criteria=s.GetHashParam(it),i.showAdvancedOptions=s.GetHashParam(et),n())})};i.change=function(n){if(n)if(i.criteria){var t=i.$eval(d.internalSearchFilter);i.result.InternalItems=o("filter")(i.result.Items,t);i.internalPage=1;i.result.Info.CurrentPage=1;i.result.Info.TotalItems=i.result.InternalItems.length;i.result.Info.TotalPages=Math.floor((i.result.Info.TotalItems+i.pageSize-1)/i.pageSize);i.result.Info.HasPreviousPage=i.internalPage>1;i.result.Info.HasNextPage=i.internalPage<i.result.Info.TotalPages}else i.result.InternalItems=i.result.Items,i.internalPage=1,i.result.Info.CurrentPage=1,i.result.Info.TotalItems=i.result.InternalItems.length,i.result.Info.TotalPages=Math.floor((i.result.Info.TotalItems+i.pageSize-1)/i.pageSize),i.result.Info.HasPreviousPage=i.internalPage>1,i.result.Info.HasNextPage=i.internalPage<i.result.Info.TotalPages;else i.useInternalSearchAndPaging&&(i.criteria=undefined),i.isTyping=!0,WaitReset(i,f,s.SEARCH_DELAY,function(){i.isTyping=!1;i.page=1;i.search()})};i.gotoLink=function(n){r.url(n)};i.recordStatusOptions=[{Key:"0",Value:"Pending"},{Key:"1",Value:"Active"},{Key:"2",Value:"Cancelled"}];i.recordStatusFilterChanged=function(n){a.UpdateFiltersInUrl(ht,"RecordStatus",[n]);i.change()};i.search=function(){var n=a.GetFiltersFromUrl(ht);n.RecordStatus&&(i.recordStatusFilter=n.RecordStatus.Items[0]);i.isFilter||!isUndefinedOrEmptyString(i.criteria)?i.parentId?angular.isObject(i.parentId)?i.parentId.promise.then(function(n){nt[ct]=n;ot()}):(nt[ct]=i.parentId,ot()):ot():(i.isInsideDialog==!1&&s.RemoveHashParam(it),i.selectedItems&&ft==!1&&lt(),i.result={},i.hasResults=!1,i.searchComplete&&i.searchComplete({hasResults:i.hasResults}),i.isLoading=!1)};i.momentInTime=function(n){return n?moment(n).fromNow():""};i.checkedChange=function(n,t){var r,u;if(n&&!n.alreadyLinked){if(t.target.type!="checkbox"&&(n.Checked=n.Checked?!1:!0),n.Checked)i.selectedItems.push(n);else for(r=0;r<i.selectedItems.length;r++)i.selectedItems[r].Id==n.Id&&(i.selectedItems.splice(r,1),r--);u=!0;angular.forEach(i.result.Items,function(n){n.Checked||n.alreadyLinked||(u=!1)});i.allItemsChecked=u}};i.checkAll=function(){i.allItemsChecked?angular.forEach(i.result.Items,function(n){n.Checked||n.alreadyLinked||(n.Checked=!0,i.selectedItems.push(n))}):angular.forEach(i.result.Items,function(n){if(n.Checked){n.Checked=!1;for(var t=0;t<i.selectedItems.length;t++)i.selectedItems[t].Id==n.Id&&(i.selectedItems.splice(t,1),t--)}})};i.goto=function(n){r.url(n)};i.prev=function(){i.useInternalSearchAndPaging?(i.internalPage--,i.result.Info.CurrentPage--,i.result.Info.HasPreviousPage=i.internalPage>1,i.result.Info.HasNextPage=i.internalPage<i.result.Info.TotalPages):(i.page--,i.search())};i.next=function(){i.useInternalSearchAndPaging?(i.internalPage++,i.result.Info.CurrentPage++,i.result.Info.HasPreviousPage=i.internalPage>1,i.result.Info.HasNextPage=i.internalPage<i.result.Info.TotalPages):(i.page++,i.search())};d.bookmarkAs&&(i.bookmarkSearch=function(){s.OpenConfirmationDialog("Your "+d.bookmarkAs+" default search has been updated.",function(){return l.AddShortcut(d.bookmarkAs,r.url(),d.bookmarkAs,1)},d.bookmarkAs,"Close")});i.description=function(){var n="";return i.isLoading?n="Searching...":i.hasResults?(n=o("number")(i.result.Info.TotalItems)+" item"+(i.result.Info.TotalItems>1?"s":"")+" found",i.useInternalSearchAndPaging&&i.criteria&&(n+=", "+o("number")(i.result.Items.length)+" total items"),i.result.Info.TotalPages>1&&(n+=" (page "+o("number")(i.result.Info.CurrentPage)+" of "+o("number")(i.result.Info.TotalPages)+")")):(!isUndefinedOrEmptyString(i.criteria)&&i.isTyping===!1||i.showFilter&&v.advancedOptionsView!=undefined||i.showFilter&&v.showRecordStatusFilter!=undefined||i.showFilter&&i.hideSearchCriteria)&&(n="No items found"),n};i.selectedItemsDescription=function(){var n="";return!ft&&i.selectedItems&&i.selectedItems.length>0&&(n+=o("number")(i.selectedItems.length)+" item"+(i.selectedItems.length>1?"s":"")+" selected"),n};i.placeholder=function(){for(var t="",n=0;n<i.searchableFields.length;n++)t+=i.searchableFields[n],n<i.searchableFields.length-2?t+=", ":n<i.searchableFields.length-1&&(t+=" or ");return t};i.poll=function(){i.canPoll&&i.doPoll&&setTimeout(function(){i.search();i.poll()},1e3)};rt===!1&&(at=r.path(),i.$watch(function(){return r.search()},function(){r.path()==at&&(i.criteria=s.GetHashParam(it),i.search())}));i.$watch("showAdvancedOptions",function(n){n!==undefined&&(n===!0?s.SetHashParam(et,n):s.RemoveHashParam(et))});ut&&(c.OnBroadcast(i,ut,function(){i.change()}),i.useInternalSearchAndPaging&&c.OnBroadcast(i,ut+"RemoveCriteria",function(){i.criteria=undefined;i.change(!0)}))}}}}]);App.directive("searchableField",function(){return{link:function(n,t,i){n.searchableFields&&(i.searchableField?n.searchableFields.push(i.searchableField):n.searchableFields.push(t.text()))}}});App.directive("searchResultsView",function(){return{replace:!0,template:"<div data-ng-show=\"hasResults || alwaysShowSearchBox\" ng-class=\"{ 'panel-padding-top': (isInsideDialog && isFilter && showFilter == false), 'filter-hidden': (isFilter && showFilter == false) }\" ng-transclude><\/div>",transclude:!0}});App.directive("itemLink",["$location","$timeout",function(n,t){return{link:function(i,r,u){r=$(r);r.addClass("selectable-item");r.on("click",function(){var r=i.$eval(u.itemLink);t(function(){n.url(r)})});r.siblings().filter(":first").find("th:last").hasClass("iconplaceholder")||r.siblings().filter(":first").append('<th class="iconplaceholder"><\/th>');var f=u.itemLinkIcon?u.itemLinkIcon:"glyphicon glyphicon-chevron-right";r.append('<td><span class="drill-down '+f+'"><\/span><\/td>')}}}]);App.directive("searchFake",["$compile","$http","$location","$templateCache","$timeout","$q","Common","ModelFake","Event",function(n,t,i,r,u,f,e,o,s){return{replace:!0,scope:{selectedItems:"=",parentId:"=",searchComplete:"&"},compile:function(h,c){var v="Views/Search",l,a;return c.advancedOptionsView&&(l="Views/"+c.advancedOptionsView),a="Views/"+c.resultsView,function(h,y,p){function nt(){h.isLoading=!0;o.SearchWithParams(e,k,h.page,h.criteria,h.params,function(n){if(h.result=n,h.selectedItems)if(g){var t=!0;angular.forEach(h.result.Items,function(n){angular.forEach(h.selectedItems,function(t){n.Id==t.Id&&(n.Checked=!0)});n.Checked||(t=!1)});h.allItemsChecked=t}else rt();h.isInsideDialog==!1&&(h.criteria?e.SetHashParam(w,h.criteria):e.RemoveHashParam(w));h.hasResults=h.result.Info.TotalItems>0;h.searchComplete&&h.searchComplete({hasResults:h.hasResults});h.isFilter&&(h.showFilter=h.result.Info.Filter!==null||h.result.Info.TotalPages>1||c.advancedOptionsView!=undefined);h.isLoading=!1})}function rt(){h.selectedItems=[];h.result&&angular.forEach(h.result.Items,function(n){n.Checked=!1});h.allItemsChecked=!1}var b=[],w,d,ut;b.push(t.get(v,{cache:r}));l&&b.push(t.get(l,{cache:r}));b.push(t.get(a,{cache:r}));f.all(b).then(function(t){for(var u,i,f,e,r=0;r<t.length;r++)r==t.length-1?(u="<div><div data-ng-show=\"hasResults\" ng-class=\"{ 'panel-padding-top': (isInsideDialog && isFilter && showFilter == false), 'filter-hidden': (isFilter && showFilter == false) }\">",u+=t[r].data,u+="<\/div><\/div>",i=$(u),h.selectedItems&&(f=i.find("table").attr("data-ng-controller")||i.find("table").attr("ng-controller"),i.find("tr:first").prepend('<th style="width: 1px" class="checkbox-cell"><input type="checkbox" data-ng-model="'+(f?"$parent.":"")+'allItemsChecked" data-ng-click="checkAll()" /><\/th>'),i.find("tr:last").attr("ng-class","{ pointer: true, warning: item.Checked }").attr("ng-click","checkedChange(item, $event)").prepend('<td class="checkbox-cell"><input type="checkbox" data-ng-model="item.Checked" /><\/ td>')),h.isInsideDialog&&(e=i.find("a").text(),i.find("a").replaceWith(e)),y.append(i.html())):y.append(t[r].data);n(y.contents())(h)});var tt=isDefined(l),k=p.searchFake,it=p.eventName||k,g=p.retainSelectedItemsAfterSearch||!1;h.canPoll=p.canPoll||!1;h.isFilter=p.isFilter||!1;h.isInsideDialog=p.isInsideDialog||!1;h.params=p.params?h.$eval(p.params):{};h.settings=h.$eval(p.settings);h.showAdvancedOptionsBtn=tt;w=k+"Criteria";d=k+"AdvancedSearch";h.page=1;h.searchableFields=[];h.resetPaging=function(){h.page=1};h.setParam=function(n,t){h.params[n]=t};h.getParams=function(){return h.params};h.onLoad=function(n){var t=i.path();h.$watch(function(){return i.search()},function(){i.path()==t&&(h.criteria=e.GetHashParam(w),h.showAdvancedOptions=e.GetHashParam(d),n())})};h.change=function(){h.isTyping=!0;WaitReset(h,u,e.SEARCH_DELAY,function(){h.isTyping=!1;h.page=1;h.search()})};h.search=function(){h.isFilter||h.criteria?h.parentId?angular.isObject(h.parentId)?h.parentId.promise.then(function(n){h.params.parentId=n;nt()}):(h.params.parentId=h.parentId,nt()):nt():(h.isInsideDialog==!1&&e.RemoveHashParam(w),h.selectedItems&&g==!1&&rt(),h.result={},h.hasResults=!1,h.searchComplete&&h.searchComplete({hasResults:h.hasResults}),h.isLoading=!1)};h.checkedChange=function(n,t){var i,r;if(n){if(t.target.type!="checkbox"&&(n.Checked=n.Checked?!1:!0),n.Checked)h.selectedItems.push(n);else for(i=0;i<h.selectedItems.length;i++)h.selectedItems[i].Id==n.Id&&(h.selectedItems.splice(i,1),i--);r=!0;angular.forEach(h.result.Items,function(n){n.Checked||(r=!1)});h.allItemsChecked=r}};h.checkAll=function(){h.allItemsChecked?angular.forEach(h.result.Items,function(n){n.Checked||(n.Checked=!0,h.selectedItems.push(n))}):angular.forEach(h.result.Items,function(n){if(n.Checked){n.Checked=!1;for(var t=0;t<h.selectedItems.length;t++)h.selectedItems[t].Id==n.Id&&(h.selectedItems.splice(t,1),t--)}})};h.prev=function(){h.page--;h.search()};h.next=function(){h.page++;h.search()};h.description=function(){var n="";return h.isLoading?n="Searching...":h.hasResults?(n=h.result.Info.TotalItems+" item"+(h.result.Info.TotalItems>1?"s":"")+" found",h.result.Info.TotalPages>1&&(n+=" (page "+h.result.Info.CurrentPage+" of "+h.result.Info.TotalPages+")")):(h.criteria&&h.isTyping===!1||h.showFilter&&c.advancedOptionsView!=undefined)&&(n="No items found"),n};h.selectedItemsDescription=function(){var n="";return!g&&h.selectedItems&&h.selectedItems.length>0&&(n+=h.selectedItems.length+" item"+(h.selectedItems.length>1?"s":"")+" selected"),n};h.placeholder=function(){for(var t="",n=0;n<h.searchableFields.length;n++)t+=h.searchableFields[n],n<h.searchableFields.length-2?t+=", ":n<h.searchableFields.length-1&&(t+=" or ");return t};h.poll=function(){h.canPoll&&h.doPoll&&setTimeout(function(){h.search();h.poll()},1e3)};tt===!1&&(ut=i.path(),h.$watch(function(){return i.search()},function(){i.path()==ut&&(h.criteria=e.GetHashParam(w),h.search())}));h.$watch("showAdvancedOptions",function(n){n!==undefined&&(n===!0?e.SetHashParam(d,n):e.RemoveHashParam(d))});it&&s.OnBroadcast(h,it,function(){h.search()})}}}}]);App.directive("select",function(){return{restrict:"E",require:"?ngModel",scope:!1,link:function(n,t,i,r){r&&t.bind("keyup",function(){t.triggerHandler("change")})}}});App.directive("selectableSearchResults",["$compile","$http","$templateCache",function(n,t,i){return{replace:!0,controller:["$scope","$attrs",function(n,t){var i=n.$eval(t.items);n.allItemsChecked=!0;n.checkedChange=function(n,t){if(n)if(t.target.type!="checkbox"&&(n.Checked=n.Checked?!1:!0),n.Checked)i.push(n);else for(var r=0;r<i.length;r++)i[r].Id==n.Id&&(i.splice(r,1),r--)};n.checkAll=function(){for(var n=0;n<i.length;n++)i.splice(n,1),n--}}],link:function(r,u,f){var e="Views/"+f.selectableSearchResults;t.get(e,{cache:i}).then(function(t){var e="<div>",i,o;e+=t.data;e+="<\/div>";i=$(e);i.find("tr:first").prepend('<th style="width: 1px" class="checkbox-cell"><input type="checkbox" data-ng-model="allItemsChecked" data-ng-click="checkAll()" /><\/th>');i.find("tr:last").attr("ng-class",'{ "selectable-item": true, warning: item.Checked }').attr("ng-click","checkedChange(item, $event)").attr("ng-repeat","item in "+f.items).prepend('<td class="checkbox-cell"><input type="checkbox" data-ng-model="item.Checked" /><\/ td>');o=i.find("a").text();i.find("a").replaceWith(o);u.append(i.html());n(u.contents())(r)})}}}]);App.directive("setParentId",["$routeParams",function(n){return function(t,i,r){var o=r.setParentId,f=r.property,e,u;e=r.parentId?t.$eval(r.parentId):r.idParam?n[r.idParam]:n.id;u=t.$eval(o);u[f]||(u[f]=e)}}]);App.directive("addShortcut",["$location","User",function(n,t){return function(i,r,u){var f=u.addShortcut,e=n.path(),o=u.title;i.$watch(o,function(n){n&&t.AddShortcut(f,e,n)})}}]);App.directive("shortcuts",["User",function(n){return{replace:!0,scope:{},link:function(t,i,r){t.isLoading=!0;t.type=r.shortcuts;n.GetShortcuts(r.shortcuts).then(function(n){t.shortcuts=n;t.isLoading=!1})},templateUrl:"Views/Shortcuts"}}]);App.directive("shortcutsBasic",["User","Event",function(n,t){return{replace:!0,scope:{},link:function(i,r,u){i.isLoading=!0;i.type=u.shortcutsBasic;t.OnBroadcast(i,"Shortcuts",function(){n.GetShortcuts(u.shortcutsBasic).then(function(n){i.shortcuts=n;i.isLoading=!1})});t.Broadcast("Shortcuts",{})},templateUrl:"Views/ShortcutsBasic"}}]);App.directive("shortcutsTransclude",["User","Event",function(n,t){return{scope:{property:"="},transclude:!0,template:"<span ng-transclude><\/span>",link:function(i,r,u){i.isLoading=!0;i.type=u.shortcutsTransclude;t.OnBroadcast(i,"Shortcuts",function(){n.GetShortcuts(u.shortcutsTransclude).then(function(n){i.property=n;i.isLoading=!1})});t.Broadcast("Shortcuts",{})}}}]);App.directive("staticData",["StaticData",function(n){return function(t,i,r){n.Get(r.staticData).then(function(n){t[r.staticData]=n})}}]);App.directive("staticDataCopy",["StaticData",function(n){return function(t,i,r){n.Get(r.staticDataCopy).then(function(n){t[r.staticDataCopy]=n;r.dest1&&(t[r.dest1]={},angular.copy(n,t[r.dest1]));r.dest2&&(t[r.dest2]={},angular.copy(n,t[r.dest2]))})}}]);App.directive("staticDataArray",["StaticData",function(n){return function(t,i,r){n.Get(r.staticDataArray).then(function(n){t[r.staticDataArray]=n.array})}}]);App.directive("staticDataDict",["StaticData",function(n){return function(t,i,r){n.Get(r.staticDataDict).then(function(n){t[r.staticDataDict]=n.dict})}}]);App.directive("strength",["StaticData","Validation",function(n,t){return{replace:!0,restrict:"A",scope:{password:"=",isValid:"="},link:function(i,r,u){var e=u.passwordMinLength,f;e||(e=n.Get("ConfigList").then(function(n){return n.dict.PasswordMinLength.Value}));f={weak:{className:"progress-bar-warning",text:"Very Weak",width:25},good:{className:"progress-bar-warning",text:"Weak",width:50},strong:{className:"progress-bar-success",text:"Strong",width:75},veryStrong:{className:"progress-bar-success",text:"Very Strong",width:100}};i.$watch("password",function(){if(i.password)if(i.visible=!0,i.isValid=!1,i.password.length<e)i.result=f.weak;else{var n=t.CheckPasswordStrength(i.password);n<16?i.result=f.weak:n<24?i.result=f.good:n<32?(i.result=f.strong,i.isValid=!0):(i.result=f.veryStrong,i.isValid=!0)}else i.visible=!1,i.isValid=!1});i.getWidth=function(){if(i.result)return{width:i.result.width+"%"}};i.getClass=function(){if(i.result)return i.result.className};i.isVisible=function(){return i.visible}},template:'<div class="progress" data-ng-show="isVisible()"><div class="progress-bar" data-ng-class="getClass()" data-ng-style="getWidth()">{{result.text}}<\/div><\/div>'}}]);App.directive("taxDetailsForm",function(){return{replace:!0,scope:{model:"=",readonly:"="},templateUrl:"Views/TaxDetails"}});App.directive("uploader",["$window",function(n){return{link:function(t,i){i.attr("method","post");i.attr("enctype","multipart/form-data");i.attr("encoding","multipart/form-data");t.ajaxUploadsSupported=n.FormData!==undefined;t.uploadProgress=0;t.fileUploading=!1;t.$watch("beginUpload",function(){t.beginUpload&&t.beginUpload===!0&&(t.uploadFailed=!1,t.uploadSucceeded=!1,t.fileUploading=!0,$(i).ajaxSubmit({uploadProgress:function(n,i,r,u){t.uploadProgress=u;t.$apply()},error:function(){t.fileUploading=!1;t.uploadFailed=!0;t.$apply()},complete:function(n){t.fileUploading=!1;try{var i=$.parseJSON(n.responseText);t.uploadSucceeded=!0}catch(r){t.beginUpload=!1;t.uploadFailed=!0}t.$apply()}}))})}}}]);App.directive("wizard",function(){return{link:function(){}}});App.directive("wizardStep",function(){return{link:function(n,t,i){i.required}}});App.filter("axFileSize",function(){return function(n){return n>>30&1023?(n>>>30)+" GB":n>>20&1023?(n>>>20)+" MB":n>>10&1023?(n>>>10)+" KB":n>>1&1023?(n>>>1)+" B":n+" B"}});App.filter("boolean",function(){return function(n,t,i){return n?t:i}});App.filter("relatedPartyEntityTypes",function(){return function(n,t,i,r){var u,e,f,h,o,s;if(!angular.isArray(n))return n;for(u=[],e=0;e<n.length;e++)for(f=n[e],h=t[f.EntityType_Id],o=0;o<h.length;o++)if(s=h[o],!s.IsJointMember)if(r){u.push(f);break}else if(i){if(s.Value==i){u.push(f);break}}else if(s.DisplayInOwnGroup==!1){u.push(f);break}return u}});App.filter("excludeDefault",function(){return function(n){var r,t,i;if(!angular.isArray(n))return n;for(r=[],t=0;t<n.length;t++)i=n[t],(i.Default===undefined||i.Default===!1)&&r.push(i);return r}});App.filter("excludeItem",function(){return function(n,t,i){var u,r,f;if(!angular.isArray(n)||!i)return n;for(u=[],r=0;r<n.length;r++)f=n[r],f[t]!=i&&u.push(f);return u}});App.filter("excludeResidentCountry",["Common",function(n){return function(t){var r,i,u;if(!angular.isArray(t))return t;for(r=[],i=0;i<t.length;i++)u=t[i],u.Value.Code!==n.RESIDENTCOUNTRYCODE&&r.push(u);return r}}]);App.filter("flags",function(){return function(n,t){var u,i,r;if(!angular.isArray(n))return n;for(u=[],i=0;i<n.length;i++)r=n[i],(r.Key==0||t&r.Key)&&u.push(r);return u}});App.filter("forceFirst",["$parse",function(n){return function(t,i,r){var e,o,u,f,s;if(!angular.isArray(t)||!i||!r)return t;for(e=[],o=[],u=0;u<t.length;u++)f=t[u],s=n(i),s(f)==r?e.push(f):o.push(f);return e.concat(o)}}]);App.filter("includeItems",function(){return function(n,t,i,r){var f,e,o,u,s;if(!angular.isArray(n)||angular.isUndefined(t)||!angular.isArray(i))return n;if(angular.isDefined(r)){for(f=[],u=0;u<i.length;u++)e=i[u],f.indexOf(e[r])===-1&&f.push(e[r]);i=f}for(o=[],u=0;u<n.length;u++)s=n[u],i.indexOf(s[t])!==-1&&o.push(s);return o}});App.filter("newLines",function(){return function(n){if(n)return n.replace(/\n/g,"<br />")}});App.filter("numberCap",function(){return function(n,t,i){return isNaN(t)&&(t=99),i===undefined&&(i="+"),n<=t?n:t+i}});App.filter("options",function(){return function(n,t){var r,i,u;if(!angular.isArray(n))return n;for(r=[],i=0;i<n.length;i++)u=n[i],t&u.Key&&r.push(u);return r}});App.filter("precision",function(){return function(n,t){n||(n=0);t||(t=0);var i=String(n).replace(/^-?\d*\.?|0+$/g,"").length,r=Math.min(i,6),u=Math.max(t,r);return n.toFixed(u)}});App.filter("property",function(){function n(n){return n.split(".")}function t(n,t){var i=n;return angular.forEach(t,function(n){i=i[n]}),i}return function(i,r,u){var e=n(r),f=[];return angular.forEach(i,function(n){t(n,e)==u&&f.push(n)}),f}});App.filter("range",function(){return function(n,t,i){i||(i=0);t=parseInt(t);for(var r=i;r<t+i;r++)n.push(r);return n}});App.filter("removeTrailingZeros",function(){return function(n){return n=n.replace(/^|0+$/g,""),n.substr(n.length-1)=="."&&(n=n.substr(0,n.length-1)),n}});App.filter("reverse",function(){return function(n){return angular.isArray(n)?n.slice().reverse():n}});App.filter("startFrom",function(){return function(n,t){return angular.isArray(n)?(t=+t,n.slice(t)):n}});App.factory("nowTime",["$timeout",function(n){var t;return function i(){t=Date.now||function(){return+new Date};n(i,1e3)}(),function(){return t()}}]);App.filter("timeAgo",["nowTime","Session",function(n,t){return function(i){var r=Number(t.GetCurrentDateTimeOffset());return moment(i).add(r,"milliseconds").from(n())}}]);App.filter("trimStart",function(){return function(n,t){return!n||!t?n:n.substring(n.indexOf(t)+t.length)}});App.filter("truncate",function(){return function(n,t,i){return isNaN(t)&&(t=100),i===undefined&&(i="..."),n?n.length<=t||n.length-i.length<=t?n:String(n).substring(0,t-i.length)+i:n}});App.filter("msToMins",function(){return function(n){return isNaN(n)?0:n/6e4}});AuthenticationData=function(){function n(){}return n}();AuthenticationController=function(){function n(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y){var p=this,w;this.HomeView="Home";this.PageNotFoundView="PageNotFound";this.SignInView="SignIn";this.AuthView="EntityAuth";this.AccountActivationView="AccountActivation";this.RequestPasswordResetView="RequestPasswordReset";this.TroubleSigningInView="TroubleSigningIn";this.VerificationCodeView="VerificationCode";this.ResetPasswordView="ResetPassword";this.ResetPasswordCompleteView="ResetPasswordComplete";this.UnlockAccountCompleteView="UnlockAccountComplete";this.DirectInvestorRegistrationView="DirectInvestorRegistration";this.AccountActivationToken=null;this.RequestPasswordResetToken=null;this.Error=null;this.HasLoaded=!1;this.SignInError=!1;this.TokenValidationError=!1;this.EmailDuplicateError=!1;this.SessionTimeout=!1;this.IsSubmitting=!1;this.$scope=t;this.$scope.AuthenticationController=this;this.$q=i;this.$timeout=r;this.$http=u;this.$route=f;this.$location=e;this.$templateCache=o;this.$modalStack=s;this.StateService=h;this.SessionService=c;this.SignInService=l;this.CommonService=v;this.ModelService=y;this.View="Home";this.PasswordMinLength=this.StateService.PasswordMinLength;this.IsAdminPortal=this.StateService.IsAdminPortal;w=this.StateService.RootUrl+"api/Ping";this.SessionService.GetSessionID()?this.StateService.Portal&&this.$http({method:"GET",url:w,params:{portal:this.StateService.Portal,site:this.StateService.Site}}).success(function(){p.StateService.IsAuthenticated=!0;p.View=p.HomeView;p.HasLoaded=!0;p.$route.reload()}).error(function(){p.GotoDefaultUnauthenticatedView()}):this.GotoDefaultUnauthenticatedView();a.OnBroadcast(t,"SignOut",function(n){p.SessionTimeout=n;p.SignOut()});a.OnBroadcast(t,"PageNotFound",function(){p.View=p.IsAuthenticated()?p.HomeView:p.SignInView})}return n.prototype.GotoDefaultUnauthenticatedView=function(){var n=this.$location.search();n.st?this.Submit("BeginInviteEntity","EntityWelcome","FatalError"):n.DirectInvestorRegistration?this.Submit("BeginDirectInvestor","ServiceWelcome","FatalError"):n.activationToken?(this.AccountActivationToken=n.activationToken,this.View=this.AccountActivationView):n.resetToken?(this.RequestPasswordResetToken=n.resetToken,this.View=this.RequestPasswordResetView):this.View=this.SignInView;this.StateService.IsAuthenticated=!1;this.HasLoaded=!0;this.$route.reload()},n.prototype.IsAuthenticated=function(){return this.StateService.IsAuthenticated},n.prototype.SignIn=function(){var n=this,t;this.IsSubmitting=!0;this.$templateCache.removeAll();t=this.SignInService.SignInAsync(this.StateService.Portal,this.StateService.Site,this.Username,this.Password);t.then(function(t){n.IsSubmitting=!1;t?(n.SignInError=!1,n.Password="",n.StateService.IsAuthenticated=!0,n.Username="",n.View=n.HomeView,n.SessionService.SetSessionValues(t),n.SessionTimeout=!1,n.$route.reload(),n.SendPostSignInRequests()):(n.StateService.IsAuthenticated=!1,n.SignInError=!0,n.Password="")})},n.prototype.SignOut=function(){this.$modalStack.dismissAll();this.SignInService.SignOut(this.SessionService.GetSessionID());this.View=this.SignInView;this.$templateCache.removeAll();this.StateService.IsAuthenticated=!1;this.SessionService.CancelTimeout()},n.prototype.Submit=function(n,t,i){var r=this,u;this.IsSubmitting=!0;u=this.StateService.RootUrl+"api/"+n;this.$http({method:"GET",url:u}).then(function(n){var f=new AuthenticationData;f.Challenge=n.data.Challenge;f.Portal=r.StateService.Portal;f.Site=r.StateService.Site;f.ServiceGuid=r.$location.search().Service;f.EntitySecurityToken=r.$location.search().st;f.Key=r.Key;f.Code=r.Code;f.Username=r.Username;f.Mobile=r.Mobile;f.Password=r.Password;f.FirstName=r.FirstName;f.LastName=r.LastName;r.$http({method:"POST",url:u,data:f}).then(function(n){t=="SignIn"?r.SignIn():(r.Data=n.data,r.Key=n.data.Key,n.data.Username&&(r.Username=n.data.Username),r.Code="",r.Password="",r.ConfirmPassword="",r.View=t,r.IsSubmitting=!1)},function(n){n.status==400&&i?r.View=i:n.status===404?r.CommonService.RedirectToPageNotFound():(r.Error=n.status,r.View="FatalError");r.IsSubmitting=!1})},function(n){r.Error=n.status;r.View="FatalError";r.IsSubmitting=!1})},n.prototype.IsAtPageNotFoundRoute=function(){return this.CommonService.IsAtPageNotFoundRoute()},n.prototype.RedirectToHome=function(){this.CommonService.RedirectToHome()},n.prototype.SendPostSignInRequests=function(){if(!this.IsAdminPortal){var t={PreviousSignInDateUtc:this.SessionService.GetUsersPreviousSignInDate()},n=new ModelServiceOptions;n.useExtendedTimeout=!0;this.ModelService.Add2("InvestorNotification",t,n).then(function(){})}},n.$inject=["$rootScope","$scope","$q","$timeout","$http","$route","$location","$templateCache","$modalStack","State","Session","SignIn","Event","Common","Model"],n}();App.controller("AuthenticationController",AuthenticationController)