function getOrElse(e,t,n){return e.hasOwnProperty(t)?e[t]:n}function propRename(e,t,n){e.hasOwnProperty(t)&&(e[n]=e[t],delete e[t])}function timeStringToMoment(e){var t=moment(e);return t.isValid()?t:moment(strtotime(e,moment().format("X")),"X")}"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e}),"function"!=typeof String.prototype.endsWith&&(String.prototype.endsWith=function(e){return this.slice(-e.length)===e}),"function"!=typeof String.prototype.contains&&(String.prototype.contains=function(e){return-1!=this.indexOf(e)}),Array.prototype.unique=function(){for(var e=[],t=0;t$&')))}}]).filter("reverse",function(){return function(e){return _.isArray(e)?e.slice().reverse():[]}}).filter("toArray",function(){return function(n,e){return angular.isObject(n)?!1===e?Object.keys(n).map(function(e){return n[e]}):Object.keys(n).map(function(e){var t=n[e];return angular.isObject(t)?Object.defineProperty(t,"$key",{enumerable:!1,value:e}):{$key:e,$value:t}}):n}}).filter("colorbar",["$sce",function(a){return function(e){if(null==e)return"-";for(var t="",n=0;n<5;n++){var r=6*n;t+=""}return a.trustAsHtml(t+="")}}]),toastr.options={closeButton:!0,positionClass:"toast-bottom-right",timeOut:"5000",extendedTimeOut:"5000",preventDuplicates:!0},toastrError={timeOut:"600000",extendedTimeOut:"600000"},angular.module("FulfillmentDashboard").config(["$routeProvider",function(e){e.when("/workflow/:workflowId/run/:runId",{controller:"workflowController",templateUrl:"partials/workflow.html",reloadOnSearch:!1}).when("/workflow/:workflowId/run/:runId/section/:section",{controller:"workflowController",templateUrl:"partials/workflow.html",reloadOnSearch:!1}).when("/initiate",{controller:"workflowInitiationController",templateUrl:"partials/workflowInitiate.html",reloadOnSearch:!1}).when("/initiate/:command",{controller:"workflowInitiationController",templateUrl:"partials/workflowInitiate.html",reloadOnSearch:!1}).when("/history/:filter",{controller:"historyController",templateUrl:"partials/history.html",reloadOnSearch:!1}).when("/history",{controller:"historyController",templateUrl:"partials/history.html",reloadOnSearch:!1}).when("/workers",{controller:"processController",templateUrl:"partials/workers.html",reloadOnSearch:!1}).when("/workers/instance/:instance",{controller:"processController",templateUrl:"partials/workers.html",reloadOnSearch:!1}).when("/summary/:filter",{controller:"summaryController",templateUrl:"partials/summary.html",reloadOnSearch:!1}).when("/triage",{controller:"triageController",templateUrl:"partials/triage.html",reloadOnSearch:!1}).when("/triage/:filter",{controller:"triageController",templateUrl:"partials/triage.html",reloadOnSearch:!1}).when("/",{controller:"summaryController",templateUrl:"partials/summary.html",reloadOnSearch:!1}).when("/start",{redirectTo:"/"}).when("/system",{controller:"systemController",templateUrl:"partials/system.html",reloadOnSearch:!1}).otherwise({redirectTo:"/"})}]),angular.module("FulfillmentDashboard").controller("envController",["$scope","$route","$http","$location","environment","formatUtil","common",function(n,e,t,r,a,o,i){n.common=i,n.$on("$routeChangeSuccess",function(e,t){n.init()}),n.init=function(){a.data||t.get("session/environment",{}).success(function(e){n.environment=e,a.data=e}).error(i.errorHandler())},n.login=function(){i.redirect("login")},n.logout=function(){i.redirect("logout")},n.go=function(e){r.path(e)}}]),angular.module("FulfillmentDashboard").controller("historyController",["$scope","$route","$http","$location","ngDialog","formatUtil","history","focus","environment","common",function(r,n,o,e,t,i,a,s,l,c){r.formatUtil=i,r.history=a,r.common=c,r.maxRows=500,r.history.max=500,r.tagWatch={},r.baseFilters={channel:[],brandkey:[],status:[],locationid:[],tacticid:[],campaignid:[],tacticname:[],campaignname:[],sweepphase:[]},r.blankVal="-CLICK-",r.mTypes={EXACT:"fa-crosshairs",CONTAINS:"fa-paperclip",STARTS:"fa-chevron-left",ENDS:"fa-chevron-right"},r.startPicker=null,r.endPicker=null,r._=_,r.$on("$routeChangeSuccess",function(e,t){r.params=n.current.params,_.has(r.params,"filter")&&a.initFilters(r.params.filter),l.data&&(r.maxRows=l.data.maxRows,r.history.max=l.data.maxRows),r.initializeDatePickers(),void 0!==r.params.filter&&a.getHistory()}),r.initializeDatePickers=function(){function e(e,t){$("#dateRange span").html(''+e.format("MM/DD/YYYY h:mm A")+' '+t.format("MM/DD/YYYY h:mm A")+"")}r.dateRange=$("#dateRange"),r.dateRange.daterangepicker({timePicker:!0,timePickerIncrement:5,locale:{format:"MM/DD/YYYY h:mm A"},opens:"left",startDate:a.startDate,endDate:a.endDate,autoApply:!0,ranges:{"Last Hour":[moment().subtract(1,"hours"),moment().add(10,"minutes")],"Last 12 Hours":[moment().subtract(12,"hours"),moment().add(10,"minutes")],"Last 24 Hours":[moment().subtract(24,"hours"),moment().add(10,"minutes")],"Last 7 Days":[moment().subtract(6,"days"),moment().add(10,"minutes")]}},e),e(a.startDate,a.endDate),r.dateRange.on("apply.daterangepicker",function(e,t){r.query()})},r.getStatus=function(e){return angular.isObject(e)?e.status:e},r.prepEntry=function(e,t,n){e.ctrlKey?"status"!==t?a.toggleExclude(t,n):a.toggleStatusExclude():(r.tagWatch[t+n]=!0,"status"===t?r.nstatus=n:(n===r.blankVal?r.nvalue="":r.nvalue=n,s("t_"+t+"_"+n)))},r.finishEntry=function(e,t){r.tagWatch[e+t]=!1,a.setFilters()},r.filterByTagClick=function(e,t,n){a.filterByTag(t,n),e.ctrlKey&&("status"==t?a.toggleStatusExclude():a.toggleExclude(t,n))},r.filterActive=function(e,t){return _.has(a.tags,e)?_.contains(a.tags[e],t)?"matchedTag":_.contains(a.tags[e],"~"+t)?"excludedTag":"":""},r.tagClass=function(e){return e==r.blankVal?"invalidTag":e.startsWith("~")?"excludedTag":"matchedTag"},r.sortBy=function(e){a.sortBy===e?a.reverse=!a.reverse:a.sortBy=e,a.setFilters()},r.promptCancelWorkflow=function(e){r.ex=e,t.open({template:"confirmCancel",controller:"historyController",scope:r})},r.cancelWorkflow=function(){var e={};e.runId=r.ex.runId,e.workflowId=r.ex.workflowId,o.post("workflow/cancel",e).success(function(e){toastr.info(e,"Cancel Requested!"),r.ex.status="CANCEL_REQUESTED"}).error(c.errorHandler())},r.promptTerminateWorkflow=function(e){r.ex=e,t.open({template:"confirmTerminate",controller:"historyController",scope:r})},r.terminateWorkflow=function(){var e={};e.runId=r.ex.runId,e.workflowId=r.ex.workflowId,e.reason=r.terminateReason,e.details=r.terminateDetails,o.post("workflow/terminate",e).success(function(e){toastr.info(e,"Workflow Terminated!"),r.ex.status="TERMINATED"}).error(c.errorHandler())},r.incrementRun=function(e,t){return e.replace(/\d+$/,parseInt(t)+1)},r.promptRerunWorkflow=function(e){(r.ex=e).workflowId.startsWith("Re-run of")?r.workflowId=e.workflowId.replace(/^Re-run of/,"Re-run x2 of"):e.workflowId.startsWith("Re-run x")?r.workflowId=e.workflowId.replace(/^Re-run x(\d+)/,r.incrementRun):r.workflowId="Re-run of "+e.workflowId,t.open({template:"confirmRerun",controller:"historyController",scope:r})},r.rerunWorkflow=function(r,a){var n={};n.runId=a.runId,n.workflowId=a.workflowId,n.id=r,n.tags=_.clone(a.tags),_.each(n.tags,function(e,t){n.tags[t]=c.makeTagLink(e)}),n.tags.original=c.makeTagLink(a.workflowId,c.workflowPath(a)),a.rerunning=!0,o.post("workflow/rerun",n).success(function(e){a.rerunning=!1;var t=c.workflowPath({workflowId:r,runId:e.runId}),n={};n.runId=a.runId,n.workflowId=a.workflowId,n.tags={},n.tags.RERUN=c.makeTagLink(r,t),o.post("workflow/addtags",n).success(function(e){}).error(c.errorHandler()),toastr.info(i.jsonFormat(e),"Fulfillment Created!")}).error(c.errorHandler(function(e){a.rerunning=!1}))},r.reconcileWorkflow=function(t){var e={};e.runId=t.runId,e.workflowId=t.workflowId,o.post("workflow/reconcile",e).success(function(e){toastr.info(e,"Scheduled for Reconciliation"),t.status="PENDING"}).error(c.errorHandler())},r.mTypeToIcon=function(e){return r.mTypes[e]},r.filterDrop=_.map(_.keys(r.baseFilters),function(e){return{text:""+e+"",click:"history.newFilterByTag('"+e+"')"}}).concat({text:"other",click:"history.newFilterByNewTag()"}),r.mTypeDrop=function(n){return _.map(r.mTypes,function(e,t){return{text:" "+t+"",click:"history.changeMType('"+n+"', '"+t+"')"}})},r.query=function(e){a.startDate=moment(r.dateRange.data("daterangepicker").startDate),a.endDate=moment(r.dateRange.data("daterangepicker").endDate),a.setFilters(e),a.setLocation()}}]),angular.module("FulfillmentDashboard").controller("processController",["$scope","$route","$http","$location","environment","formatUtil","workers","common",function(n,r,e,t,a,o,i,s){function l(){_.each(n.workers.crews,function(e,t){_.each(e,function(e){n.activeInstance==e._worker.instance&&(e.worker=e._worker)})})}n.showDefunct=!1,n.formatUtil=o,n.workers=i,n.activeInstance=null,n.example_json={example:"hi"},n.$on("$routeChangeSuccess",function(e,t){n.params=r.current.params,n.activeInstance=n.params.instance,1e4'+e.format("MM/DD/YYYY h:mm A")+' '+t.format("MM/DD/YYYY h:mm A")+"")}n.dateRange=$("#dateRange"),n.dateRange.daterangepicker({timePicker:!0,timePickerIncrement:5,locale:{format:"MM/DD/YYYY h:mm A"},opens:"left",startDate:i.startDate,endDate:i.endDate,autoApply:!0,ranges:{"Last Hour":[moment().subtract(1,"hours"),moment().add(10,"minutes")],"Last 12 Hours":[moment().subtract(12,"hours"),moment().add(10,"minutes")],"Last 24 Hours":[moment().subtract(24,"hours"),moment().add(10,"minutes")],"Last 7 Days":[moment().subtract(6,"days"),moment().add(10,"minutes")]}},e),e(i.startDate,i.endDate),n.dateRange.on("apply.daterangepicker",function(e,t){n.query()})},n.sortBy=function(e){n.predKey===e?n.reverse=!n.reverse:n.predKey=e},n.terminalStatii={FAILED:"label-danger",COMPLETED:"label-success",TIMED_OUT:"label-warning",TERMINATED:"label-danger",CANCELED:"label-warning",CONTINUED_AS_NEW:"label-default"},n.activeStatii={IN_PROGRESS:"label-info",BLOCKED:"label-warning",WAITING:"label-info",CANCEL_REQUESTED:"label-warning",UNKNOWN:"label-default",ORPHANED:"label-default"},n.statusMap=_.extend(_.clone(n.terminalStatii),n.activeStatii),n.figureStatusLabel=function(e){return null===e?"label-info":n.statusMap[e.toUpperCase()]},n.formatStatus=function(e){return null===e?"UNKNOWN":e.toUpperCase()},n.activeStatus=function(e){return _.contains(_.keys(n.activeStatii),e["|status|"].toUpperCase())},n.filterDrop=_.map(_.keys(n.baseFilters),function(e){return{text:""+e+"",click:"summary.newFilterByTag('"+e+"')"}}).concat({text:"other",click:"summary.newFilterByNewTag()"}),n.prepEntry=function(e,t){n.tagWatch[e+t]=!0,n.nvalue=t,focus("t_"+e+"_"+t)},n.finishEntry=function(e,t){n.tagWatch[e+t]=!1,i.setFilters()},n.query=function(e){i.startDate=moment(n.dateRange.data("daterangepicker").startDate),i.endDate=moment(n.dateRange.data("daterangepicker").endDate),i.setFilters(e),i.setLocation()},n.gatherTags=function(e){var n={};return _.each(e,function(e,t){"|"!=t[0]&&(n[t]=e)}),n},n.pingMultiple=function(e){i.pingMultiple(n.gatherTags(e),e["|status|"].toUpperCase(),n.pingMessage,n.pingNudge)},n.cancelMultiple=function(e){i.cancelMultiple(n.gatherTags(e),e["|status|"].toUpperCase())},n.terminateMultiple=function(e){i.terminateMultiple(n.gatherTags(e),e["|status|"].toUpperCase(),n.terminateReason,n.terminateDetails)},n.promptPingWorkflows=function(e){n.row=e,s.open({template:"confirmPingMultiple",controller:"summaryController",scope:n})},n.promptCancelWorkflows=function(e){n.row=e,s.open({template:"confirmCancel",controller:"summaryController",scope:n})},n.promptTerminateWorkflows=function(e){n.row=e,s.open({template:"confirmTerminate",controller:"summaryController",scope:n})}}]),angular.module("FulfillmentDashboard").controller("systemController",["$scope","$route","$http","$location","$q","systemService",function(a,e,t,n,r,o){a.$on("$routeChangeSuccess",function(){a.init()});function i(e){return(e=e.trim().toLowerCase()).startsWith("ko")?"label-danger":e.startsWith("ok")?"label-success":e.startsWith("busy")?"label-warning":"label-default"}a.init=function(){a.dependencies={},a.system={loading:!0},o.getSystemStatus().then(s),o.getDependencies().then(function(e){a.dependencies=e,angular.forEach(e,function(e,t){a.dependencies[t].meta={},o.getDependencyStatus(t).then(l)})})};var s=function(e){delete a.system.loading,a.system=e,a.system.statusClass=i(e.status),a.system.deciderCountClass=0'+e.format("MM/DD/YYYY h:mm A")+' '+t.format("MM/DD/YYYY h:mm A")+"")}n.dateRange=$("#dateRange"),n.dateRange.daterangepicker({timePicker:!0,timePickerIncrement:5,locale:{format:"MM/DD/YYYY h:mm A"},opens:"left",startDate:a.startDate,endDate:a.endDate,autoApply:!0,ranges:{"Last Hour":[moment().subtract(1,"hours"),moment().add(10,"minutes")],"Last 12 Hours":[moment().subtract(12,"hours"),moment().add(10,"minutes")],"Last 24 Hours":[moment().subtract(24,"hours"),moment().add(10,"minutes")],"Last 7 Days":[moment().subtract(6,"days"),moment().add(10,"minutes")]}},e),e(a.startDate,a.endDate),n.dateRange.on("apply.daterangepicker",function(e,t){n.query()})},n.sortBy=function(e){n.predKey===e?n.reverse=!n.reverse:n.predKey=e},n.terminalStatii={FAILED:"label-danger",COMPLETED:"label-success",TIMED_OUT:"label-warning",TERMINATED:"label-danger",CANCELED:"label-warning",CONTINUED_AS_NEW:"label-default"},n.activeStatii={IN_PROGRESS:"label-info",BLOCKED:"label-warning",WAITING:"label-info",CANCEL_REQUESTED:"label-warning",UNKNOWN:"label-default",ORPHANED:"label-default"},n.statusMap=_.extend(_.clone(n.terminalStatii),n.activeStatii),n.figureStatusLabel=function(e){return null===e?"label-info":n.statusMap[e.toUpperCase()]},n.formatStatus=function(e){return null===e?"UNKNOWN":e.toUpperCase()},n.activeStatus=function(e){return _.contains(_.keys(n.activeStatii),e["|status|"].toUpperCase())},n.filterDrop=_.map(_.keys(n.baseFilters),function(e){return{text:""+e+"",click:"triage.newFilterByTag('"+e+"')"}}).concat({text:"other",click:"triage.newFilterByNewTag()"}),n.prepEntry=function(e,t){n.tagWatch[e+t]=!0,n.nvalue=t,focus("t_"+e+"_"+t)},n.finishEntry=function(e,t){n.tagWatch[e+t]=!1,a.setFilters()},n.query=function(e){a.startDate=moment(n.dateRange.data("daterangepicker").startDate),a.endDate=moment(n.dateRange.data("daterangepicker").endDate),a.setFilters(e),a.setLocation()},n.gatherTags=function(e){var n={};return _.each(e,function(e,t){"|"!=t[0]&&(n[t]=[e])}),n},n.incrementRun=function(e,t){return e.replace(/\d+$/,parseInt(t)+1)},n.promptRerunWorkflow=function(e){(n.ex=e).workflowId.startsWith("Re-run of")?n.workflowId=e.workflowId.replace(/^Re-run of/,"Re-run x2 of"):e.workflowId.startsWith("Re-run x")?n.workflowId=e.workflowId.replace(/^Re-run x(\d+)/,n.incrementRun):n.workflowId="Re-run of "+e.workflowId,s.open({template:"confirmRerun",controller:"triageController",scope:n})},n.rerunWorkflow=function(r,a){var n={};n.runId=a.runId,n.workflowId=a.workflowId,n.id=r,n.tags=_.clone(a.tags),_.each(n.tags,function(e,t){n.tags[t]=l.makeTagLink(e)}),n.tags.original=l.makeTagLink(a.workflowId,l.workflowPath(a)),a.rerunning=!0,o.post("workflow/rerun",n).success(function(e){a.rerunning=!1;var t=l.workflowPath({workflowId:r,runId:e.runId}),n={};n.runId=a.runId,n.workflowId=a.workflowId,n.tags={},n.tags.RERUN=l.makeTagLink(r,t),o.post("workflow/addtags",n).success(function(e){}).error(l.errorHandler()),toastr.info(i.jsonFormat(e),"Fulfillment Created!")}).error(l.errorHandler(function(e){a.rerunning=!1}))},n.reconcileWorkflow=function(t){var e={};e.runId=t.runId,e.workflowId=t.workflowId,o.post("workflow/reconcile",e).success(function(e){toastr.info(e,"Scheduled for Reconciliation"),t.status="PENDING"}).error(l.errorHandler())},n.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},n.pingList=function(e){a.pingList(e,n.pingMessage,n.pingNudge)},n.cancelList=function(e){a.cancelList(e)},n.terminateList=function(e){a.terminateList(e,n.terminateReason,n.terminateDetails)},n.promptPingList=function(e){n.items=e,s.open({template:"confirmPingList",controller:"triageController",scope:n})},n.promptCancelList=function(e){n.items=e,s.open({template:"confirmCancelList",controller:"triageController",scope:n})},n.promptTerminateList=function(e){n.items=e,s.open({template:"confirmTerminateList",controller:"triageController",scope:n})}}]),angular.module("FulfillmentDashboard").controller("workflowInitiationController",["$scope","$route","$http","$location","formatUtil","environment","common",function(r,n,a,e,t,o,i){r.$on("$routeChangeSuccess",function(e,t){r.params=n.current.params,r.init()}),r.init=function(){r.mode="ace",r.loading=!1,r.tags=[{key:"source",val:["dashboard"]}],r.workflowId="Manual Run: "+moment().toISOString(),r.incrementRun=function(e,t){return e.replace(/\d+$/,parseInt(t)+1)},"fromExisting"===r.params.command&&null!==o.existingWorkflow&&(o.existingWorkflow.workflowId.startsWith("Re-run of")?r.workflowId=o.existingWorkflow.workflowId.replace(/^Re-run of/,"Re-run x2 of"):o.existingWorkflow.workflowId.startsWith("Re-run x")?r.workflowId=o.existingWorkflow.workflowId.replace(/^Re-run x(\d+)/,r.incrementRun):r.workflowId="Re-run of "+o.existingWorkflow.workflowId,r.tags.push({key:"sourceWorkflow",val:[o.existingWorkflow.workflowId+"",r.buildWorkflowLink(o.existingWorkflow.workflowId,o.existingWorkflow.runId)]}),r.inputJson=angular.toJson(o.existingWorkflow.input,4)),"fromSection"===r.params.command&&null!==o.existingSection&&(r.inputJson=angular.toJson(o.existingSection,4),r.workflowId="Running Section "+_.keys(o.existingSection.sections)[0]+" : "+moment().unix(),r.tags.push({key:"sourceWorkflow",val:[o.existingWorkflow.workflowId+"",r.buildWorkflowLink(o.existingWorkflow.workflowId,o.existingWorkflow.runId)]}))},r.aceLoaded=function(e){r.editor=e},r.setEditorMode=function(){r.editor.setKeyboardHandler("ace/keyboard/"+r.mode)},r.initiateWorkflow=function(){var e={};e.id=r.workflowId;try{var t=JSON.parse(r.inputJson),n=_.object(_.map(r.tags,function(e){return[e.key,i.makeTagLink(e.val)]}));t.hasOwnProperty("tags")||(t.tags={}),t.tags=$.extend(t.tags,n),e.input=angular.toJson(t)}catch(e){return void toastr.error(e.message,"Invalid JSON!",toastrError)}e.tags={},r.loading=!0,a.post("workflow/initiate",e).success(function(e){var t;r.loading=!1,r.runId=e.runId,null!==o.existingWorkflow&&(e=r.buildWorkflowLink(r.workflowId,e.runId),(t={}).runId=o.existingWorkflow.runId,t.workflowId=o.existingWorkflow.workflowId,t.tags={},t.tags["->"]=i.makeTagLink(r.workflowId,e),a.post("workflow/addtags",t).success(function(e){}).error(i.errorHandler()))}).error(i.errorHandler(function(e){r.loading=!1}))},r.addTag=function(){r.tags.push({text:"",val:[""],editing:!0})},r.removeTag=function(e){r.tags.splice(r.tags.indexOf(e),1)},r.restart=function(){r.runId=!1},r.buildWorkflowLink=function(e,t){return"workflow/"+encodeURIComponent(e)+"/run/"+encodeURIComponent(encodeURIComponent(t))},r.buildWorkflowPath=function(e,t){return"workflow/"+e+"/run/"+encodeURIComponent(t)},r.seeWorkflow=function(){e.path(r.buildWorkflowPath(r.workflowId,r.runId))}}]),angular.module("FulfillmentDashboard").controller("workflowController",["$scope","$route","$http","$location","$anchorScroll","formatUtil","formHelper","environment","ngDialog","workers","timeline","focus","common",function(o,n,r,a,t,i,s,l,e,c,u,d,m){o.formatUtil=i,o.formHelper=s,o.workers=c,o.timeline=u,o.common=m,o.selected="",o.rawJsonState={},o.maxSteps=99999,o.totalSteps=0,o.sections=[],o.workflow={},o.sectionOrder="name",o.sectionOrderReverse=!1,o.logs={decider:{loading:!1,messages:[],show:!0,start:moment(),end:moment()},reconciler:{loading:!1,messages:[],show:!1,start:moment(),end:moment()}},o.logFunction="decider",120'),t.html(a),o(t.contents())(e)}}}]),angular.module("FulfillmentDashboard").directive("jsonForm",["RecursionHelper","formatUtil","formHelper",function(t,r,a){return{templateUrl:"partials/jsonForm.html",scope:{schema:"=schema",param:"=param",value:"=value"},restrict:"E",replace:!0,compile:function(e){return t.compile(e,function(e,t,n){void 0!==e.schema&&angular.isArray(e.schema.type)&&_.contains(e.schema.type,"null")&&(e.schema.type=_.reject(e.schema.type,function(e){return"null"==e})[0]),e.formatUtil=r,e.formHelper=a})}}}]),angular.module("FulfillmentDashboard").directive("jsonReadable",["RecursionHelper","formatUtil",function(t,r){return{templateUrl:"partials/jsonReadable.html",scope:{json:"=json",ctrl:"=ctrl"},restrict:"E",replace:!0,compile:function(e){return t.compile(e,function(e,t,n){e.formatUtil=r})}}}]),angular.module("FulfillmentDashboard").directive("jsonSchema",["RecursionHelper","formatUtil",function(t,r){return{templateUrl:"partials/jsonSchema.html",scope:{schema:"=schema",root:"=root"},restrict:"E",replace:!0,compile:function(e){return t.compile(e,function(e,t,n){void 0!==e.schema&&angular.isArray(e.schema.type)&&_.contains(e.schema.type,"null")&&(e.schema.type=_.reject(e.schema.type,function(e){return"null"==e})[0]),e.formatUtil=r,e.pathFetch=function(e,t){var n=e,e=t.split("/");return e.shift(),_.each(e,function(e){n=n[e]}),n},e.labelType=function(e){return"object"==e?"primary":"array"==e?"warning":"info"}})}}}]),angular.module("FulfillmentDashboard").directive("ngEnter",function(){return function(t,e,n){e.bind("keydown keypress",function(e){13===e.which&&(t.$apply(function(){t.$eval(n.ngEnter,{event:e})}),e.preventDefault())})}}),angular.module("FulfillmentDashboard").directive("paramJson",["RecursionHelper","formatUtil",function(t,r){return{templateUrl:"partials/paramJson.html",scope:{json:"=json"},restrict:"E",replace:!0,compile:function(e){return t.compile(e,function(e,t,n){e.formatUtil=r,e.context={}})}}}]),angular.module("FulfillmentDashboard").directive("triageSection",["RecursionHelper","triage","common","formatUtil",function(t,r,a,o){return{templateUrl:"partials/triageSection.html",scope:{bundle:"=rows"},restrict:"E",replace:!0,compile:function(e){return t.compile(e,function(e,t,n){e.triage=r,e.common=a,e.formatUtil=o,e.context={}})}}}]),angular.module("FulfillmentDashboard").factory("RecursionHelper",["$compile",function(o){return{compile:function(e,n){angular.isFunction(n)&&(n={post:n});var r,a=e.contents().remove();return{pre:n&&n.pre?n.pre:null,post:function(e,t){(r=r||o(a))(e,function(e){t.append(e)}),n&&n.post&&n.post.apply(null,arguments)}}}}}]),angular.module("FulfillmentDashboard").factory("common",["$location","formatUtil",function(n,r){var a={statusMap:{FAILED:"label-danger",COMPLETED:"label-success",TIMED_OUT:"label-warning",TERMINATED:"label-danger",CANCELED:"label-warning",CONTINUED_AS_NEW:"label-default",INVALID:"label-default",IN_PROGRESS:"label-info",BLOCKED:"label-warning",WAITING:"label-info",CANCEL_REQUESTED:"label-warning",ORPHANED:"label-default",PENDING:"label-primary",UNKNOWN:"label-default"},sectionStatusMap:{READY:"label-info",PENDING:"label-info",SCHEDULED:"label-info",STARTED:"label-info",WAITING:"label-info",FAILED:"label-warning",BLOCKED:"label-warning",INVALID:"label-danger",TIMED_OUT:"label-warning",CANCELED:"label-warning",TERMINAL:"label-danger",COMPLETE:"label-success",CONTINGENT:"label-default",DEFERRED:"label-info",IMPOSSIBLE:"label-danger"},workflowPath:function(e){return"workflow/"+encodeURIComponent(e.workflowId)+"/run/"+encodeURIComponent(encodeURIComponent(e.runId))},workflowSectionPath:function(e,t){return"workflow/"+encodeURIComponent(e.workflowId)+"/run/"+encodeURIComponent(encodeURIComponent(e.runId))+"/section/"+encodeURIComponent(t)},seeWorkflow:function(e){n.path(a.workflowPath(e))},linkWorkflow:function(e){return"#/"+a.workflowPath(e)},linkWorkflowSection:function(e,t){return"#/"+a.workflowSectionPath(e,t)},formatStatus:function(e){return null===e?"UNKNOWN":e.toUpperCase()},figureStatusLabel:function(e){return null===e?"label-info":a.statusMap[e]},figureSectionStatusLabel:function(e){return null===(e=angular.isObject(e)?e.status:e)?"label-info":a.sectionStatusMap[e]},tagLinkDelimiter:"|!|",parseTag:function(e){return _.isNumber(e)||1<(e=e?e.split(a.tagLinkDelimiter):["NULL"]).length&&!e[1].includes("://")&&(e[1]="#/"+e[1]),e},makeTagLink:function(e,t){return _.isArray(e)?e.join(a.tagLinkDelimiter):void 0===t?e:e+a.tagLinkDelimiter+t}},o={timeOut:"600000",extendedTimeOut:"600000"};return a.toastError=function(e,t,n){details=e,void 0===t&&(t="Error!"),r.isObject(e)&&(_.has(e,"details")&&(details=e.details),_.has(e,"message"))&&(t=e.message),void 0!==details&&void 0!==n&&(details=r.htmlifyWhitespace(details.substr(0,100))),toastr.error(details,t,o)},a.redirect=function(e){var t=n.protocol()+"://"+location.host;location.href=t+"/"+e+"?dest="+encodeURIComponent(t+"/#"+n.path())},a.errorHandler=function(t){return function(e){e.hasOwnProperty("login_required")&&e.login_required?(a.toastError("","Not logged in!"),a.redirect("login")):"not authorized"==e.error?a.toastError("You don't have permission to use this Application!","Permission Denied!"):a.toastError(e.details,e.error),void 0!==t&&t(e)}},a.getGravatar=function(e,t){return"https://www.gravatar.com/avatar/"+md5(e)+"?d=mm&s="+t},a}]),angular.module("FulfillmentDashboard").factory("environment",function(){return{}}),angular.module("FulfillmentDashboard").factory("focus",["$timeout",function(e){return function(t){e(function(){var e=document.getElementById(t);e?e.focus():console.log("Didn't find the element: "+t)})}}]),angular.module("FulfillmentDashboard").factory("formHelper",["formatUtil","workers",function(t,n){function r(e){var t,n;return angular.isArray(e)?(t=_.uniq(e),n=[],_.each(_.range(t.length),function(e){n.push(r(t[e]))}),n):angular.isObject(e)?(n={},_.each(e,function(e,t){"$"!=t[0]&&(n[t]=r(e))}),n):{$jform:JSON.parse(JSON.stringify(e))}}function a(t){var n,r;return angular.isArray(t)?(n=[],_.each(_.range(t.length),function(e){n[e]=a(t[e])}),n):angular.isObject(t)?t.hasOwnProperty("$jform")?t.$jform:(r={},_.each(t,function(e,t){"$"!=t[0]&&(r[t]=a(e))}),r):(console.log(t),void console.error("WAsn't expecting '"+t+"'"))}function o(e){var t,n;return _.isArray(e.type)?1==(t=_.reject(e.type,function(e){return"null"==e})).length?o({type:t[0]}):(console.error("Don't know how to DIVINE: "+t),"BLAH"):"object"==e.type?(n={},_.map(e.properties,function(e,t){n[t]=o(e)}),n):"array"==e.type?[]:"string"==e.type?r(""):"number"==e.type||"integer"==e.type?r(0):"boolean"==e.type?r(!1):(console.log(e),console.log(e.type),"Don't know how to DIVINE: "+e.type)}return{makeBindable:r,arrayExtend:function(e,t){e.push(o(t))},change:function(e){e.editText=t.prettyJson(a(e.bindable))},unBind:a,schemaForParam:function(e,t){return e=e,!!(e=!!(e=n.getSpecification(e))&&e.params)&&e.properties[t]}}}]),angular.module("FulfillmentDashboard").factory("formatUtil",function(){function l(e,t){if(void 0===e)return"\x3c!-- undefined --\x3e";if(e.startsWith("FF-ZIP"))return"ZIPPED DATA";t||(e=d(e));var n={"\\n":"
","\\r":"
","\\t":"   ","\n":"
","\r":"
","\t":"   "};return void 0===e?"---":(e=e.replace(/^[ \t]+/gm,function(e){return new Array(e.length+1).join(" ")})).replace(/\\r|\\n|\\t|\r|\n|\t/g,function(e){return n[e]})}function c(e,t){return"
"+e+"
"}function u(e,t){return""+e+""}function t(e){if(void 0===e)return e;if(angular.isString(e))try{e=JSON.parse(e)}catch(e){}return angular.toJson(e,4)}function d(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return t[e]})}function m(e){var t;return null==e?"":(t=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;\(\)]*[-A-Z0-9+&@#\/%=~_|])/gi,e=e.split(" "),_.map(e,function(e){return e.match(t)?e.replace(t,function(e){return 0":''+e+"
"}):d(e)}).join(" "))}function f(e){return null!==e&&!!angular.isString(e)&&("{"===e[0]||"["===e[0])}return{htmlifyWhitespace:l,div:c,span:u,jsonFormat:function r(e,t){var n,a,o,i="";if(angular.isArray(e))return _.each(e,function(e,t,n){i+=c(r(e))}),c(i,t);if(angular.isObject(e))return(n=_.clone(e)).hasOwnProperty("runId")&&n.hasOwnProperty("workflowId")&&(a=n.workflowId,o=n.runId,a="#workflow/"+encodeURIComponent(a)+"/run/"+encodeURIComponent(encodeURIComponent(o)),i+=(o=n.workflowId,""+o+""),delete n.runId,delete n.workflowId),_.each(n,function(e,t,n){i+=c(u(""+d(t)+"")+" : "+r(e,"block"))}),c(i,t);if(f(e)){var s=e;try{s=JSON.parse(e)}catch(e){return s}return r(s,"json")}return angular.isString(e)&&-1=o.max&&toastr.warning("You've hit the maximum number of workflows! Filtering your query is recommended","MAX RESULTS"),o.loading=!1,o.lastLoad=moment().unix(),o.workflows=e,_.each(o.workflows,function(n){_.each(n.tags,function(e,t){n.tags[t]=a.parseTag(e)})})}).error(a.errorHandler(function(e){o.loading=!1,o.lastLoad=moment().unix()}))}function r(e,t){return _.has(o.tags,e)&&_.contains(o.tags[e],t)}function i(e,t){r(e,t)&&(o.tags[e].splice(o.tags[e].indexOf(t),1),0==o.tags[e].length)&&delete o.tags[e],d()}function s(e,t){_.has(o.tags,e)||(o.tags[e]=[]),r(e,t)?i(e,t):o.tags[e].push(t),d()}function l(e,t,n){n&&i(e,n),s(e,t)}function c(e){""===e?(o.tags[o.newTag].push(o.blankVal),o.newTag=""):(_.has(o.tags,e)||(o.tags[e]=[]),o.tags[e].push(o.blankVal)),d()}function u(){var n={};return _.each(o.tags,function(e,t){0",className:n[0]}):"WorkflowExecutionSignaled"===e.eventType&&("ping"===(r=e.workflowExecutionSignaledEventAttributes).signalName?a.vevents[e.eventId]={id:e.eventId,start:moment(e.eventTimestamp),content:"",className:r.signalName}:"sectionUpdates"===r.signalName?a.vevents[e.eventId]={id:e.eventId,start:moment(e.eventTimestamp),content:"",className:r.signalName}:a.vevents[e.eventId]={id:e.eventId,start:moment(e.eventTimestamp),content:"",className:"unknownSignal"})}),a.timeline.setGroups(new vis.DataSet(a.vsections)),a.timeline.setItems(new vis.DataSet(_.values(a.vevents)))},a.resetZoom=function(){a.timeline.fit()},a}),angular.module("FulfillmentDashboard").factory("triage",["$http","$location","formatUtil","common",function(a,t,o,i){var n={};function r(){n.loading=!0;var r={};r.startDate=n.startDate.toISOString(),r.endDate=n.endDate.toISOString(),r.tags={},_.each(n.tags,function(e,t,n){r.tags[t]=e}),a.get("workflow/triage",{params:r,cache:!1}).success(function(e){n.filterString=n.pendingFilterString,n.loading=!1,n.lastLoad=moment().unix(),n.triage={"-":{workflows:[],show:!1,active:[]}},n.triageMap={"-":{tags:{"--excluded--":[""]}}};var o=_.keys(n.tags);_.each(e,function(n){var r={},a={},e=getOrElse(n,"tags",{}),e=(_.each(e,function(e,t){val=i.parseTag(e),n.tags[t]=val,_.contains(o,t)&&(r[t]=val)}),getOrElse(n,"sections",{}));_.each(e,function(e,t){_.contains(["TERMINAL","FAILED","INVALID"],e.status)&&(e.problem=!0,a[t]=e.status)}),n.tags_object=r,n.sections_object=a}),n.rows=function r(e){var n={};_.each(e,function(e){_.each(e.tags_object,function(e,t){_.has(n,t)||(n[t]=[]),n[t].push(e)})});var a=!1;_.each(n,function(e,t){(!a||n[a].length>e.length)&&(a=t)});{var o;if(!a)return o={triage:{"-":{workflows:[],show:!1,active:[]}},triageMap:{"-":{tags:{"--excluded--":[""]}}}},_.each(e,function(e){var t={sections:e.sections_object};key=rison.encode_object(t),_.has(o.triage,key)||(o.triage[key]={workflows:[],show:!1,active:[]}),o.triage[key].workflows.push(e),null==e.closeTimestamp&&o.triage[key].active.push({runId:e.runId,workflowId:e.workflowId}),o.triageMap[key]=t}),o}var i={};_.each(e,function(e){var t;_.has(e.tags_object,a)?(t=a+"|"+rison.encode(e.tags_object[a]),_.has(i,t)||(i[t]=[]),i[t].push(e),e.tags_object=_.omit(e.tags_object,a)):(console.log("Didn't bin! ("+a+")"),console.log(e))});var s={};_.each(i,function(e,t){var n=t.split("|");n[1]=rison.decode(n[1]),s[t]={bucket:r(e),tagLabel:n[0],tagValue:n[1]}});return s}(e),n.data=e}).error(i.errorHandler(function(e){n.loading=!1,n.lastLoad=moment().unix()}))}function s(e){var t=n.tags;void 0!==e&&(t.startDate=n.startDate.toISOString(),t.endDate=n.endDate.toISOString()),n.pendingFilterString=rison.encode_object(t)}function e(e){_.has(n.tags,e)?n.tags[e].push("-CLICK-"):n.tags[e]=[],s()}function l(e,t){_.has(n.tags,e)||(n.tags[e]=[]),n.tags[e].push(t),s()}function c(e,t){_.has(n.tags,e)&&n.tags[e].splice(n.tags[e].indexOf(t),1),s()}return n.loading=!1,n.lastLoad=0,n.missed=0,n.triage={},n.triageMap={},n.exclude="-",n.tags={source:[],brandkey:[],channel:[]},n.startDate=moment().subtract(12,"hours"),n.endDate=moment().add(10,"minutes"),n.filterString="",n.pendingFilterString="",n.historyLink=function(e){var e=_.clone(e),t="INVALID",r=(void 0!==e["|status|"]&&(t=e["|status|"].toUpperCase()),delete e["|status|"],delete e["|total|"],{});return r.status=[t],_.each(e,function(e,t,n){r[t]=[e]}),_.each(n.tags,function(e,t,n){_.isArray(e)&&0<_.size(e)&&(r[t]=e)}),r.startDate=n.startDate.toISOString(),r.endDate=n.endDate.toISOString(),"#/history/"+rison.encode_object(r)},n.initFilters=function(e){n.tags=rison.decode_object(e),_.has(n.tags,"startDate")&&(n.startDate=timeStringToMoment(n.tags.startDate),delete n.tags.startDate),_.has(n.tags,"endDate")&&(n.endDate=timeStringToMoment(n.tags.endDate),delete n.tags.endDate),_.isEmpty(n.tags)&&(n.tags={source:[],brandkey:["dogtopia"],channel:[],campaignid:[]})},n.setFilters=s,n.newFilterByTag=e,n.newFilterByNewTag=function(){e(prompt("Please enter a new tag..","tag"))},n.addFilter=l,n.removeFilter=function(e){_.has(n.tags,e)&&delete n.tags[e],s()},n.removeSpecific=c,n.filterByTag=function(e,t,n){n&&c(e,n),l(e,t)},n.refresh=r,n.setLocation=function(){var e="triage/"+n.pendingFilterString;t.path()!="/"+e?t.path(e):r()},n.timeSinceLastLoad=function(){return moment().unix()-n.lastLoad},n.clear=function(){n.triage=[]},n.pingList=function(e,t,n){_.each(e,function(e){e.message=t,e.nudge=n});var r={};r.list=e,a.post("workflow/pinglist",r,{cache:!1}).success(function(e){toastr.info(o.jsonFormat(e),"Pinged Workflows...!")}).error(i.errorHandler())},n.cancelList=function(e){var t={};t.list=e,a.post("workflow/cancellist",t,{cache:!1}).success(function(e){toastr.info(o.jsonFormat(e),"Canceled Workflows...!")}).error(i.errorHandler())},n.terminateList=function(e,t,n){_.each(e,function(e){e.reason=t,e.details=n});var r={};r.list=e,a.post("workflow/terminatelist",r,{cache:!1}).success(function(e){toastr.info(o.jsonFormat(e),"Terminated Workflows...!")}).error(i.errorHandler())},n}]),angular.module("FulfillmentDashboard").factory("workers",["$http","formatUtil","$timeout","common","environment",function(e,a,t,r,o){var i={};return i.workers={},i.registry={},i.crews={},i.loading=!1,i.lastLoad=0,i.lastCount=-1,i.filter="",i.getWorkers=function(n){i.loading=!0,e.get("worker/status",{params:{},cache:!1}).success(function(e){var t=_.size(e);i.loading=!1,i.lastLoad=moment().unix(),i.workers=e,i.lastCount=t,i.crews={},i.registry={},_.each(i.workers,function(e){var r,t;e.showFormatted=!0,a.stringIsJSON(e.specification)&&(e.specification=JSON.parse(e.specification)),a.stringIsJSON(e.resolutionHistory)&&(e.resolutionHistory=JSON.parse(e.resolutionHistory)),e.hasOwnProperty("handler")?(e.lambda=!0,e.fullName=e.name,e.instance=e.name,t=e.name.split("_"),e.crew=t[1],e.crewMate=t[1],3