angular.module("c8y.parts.applications").controller("applicationAccessEditorCtrl",["$scope","c8yUser","c8yApplication",function(t,n,i){function e(n){return _.uniqBy(n,function(n){return n.id})}function l(n){t.applications=n}function o(i){return!!_.find(t.allowedApplications,function(n){return parseInt(n.id,10)===parseInt(i.id,10)})}t.isAccessAllowed=o,t.toggleAccess=function(n){var i;o(n)?(i=n,t.allowedApplications=_.filter(t.allowedApplications,function(n){return parseInt(n.id,10)!==parseInt(i.id,10)})):(n=n,t.allowedApplications=t.allowedApplications||[],t.allowedApplications.push({id:n.id,type:n.type}))},n.current().then(function(n){return i.listByUser(n).then(e)}).then(l)}]);