(()=>{function n(t,n,e,i,a,o,r,l,c){var n=n.tenantId,u=[],p=null,s={},f=c("humanizeAppName");function m(n){s=n,t.tenant=s}function h(){return t.tenant.applications.references.map(function(n){return n.application})}function d(n){_.forEach(n,function(n){return u.push(n)}),t.owners=_(u).map("owner.tenant.id").uniq().map(function(n){return{value:n,label:n}}).concat({value:null,label:"- ".concat(l.getString("Show all"))}).value(),u.forEach(function(n){n.humanizedAppName=f(n)}),t.applications=u}t.filterOwner=function(n){return null===t.filter.owner||n.owner.tenant.id===t.filter.owner},t.filterText=function(n){return!t.filter.text||!t.filter.text.$||!!n.humanizedAppName&&n.humanizedAppName.toLowerCase().includes(t.filter.text.$.toLowerCase())},t.applications=u,t.associate=function(n){return a.addApplication(s,n).then(function(){t.associatedApplications.push(n)})},t.dissociate=function(n){return a.removeApplication(s,n).then(function(){return r.removeFromList(t.associatedApplications,n)})},t.openItem=function(n){p=p!==n?n:null},t.isOpen=function(n){return p===n},t.filter={owner:null,text:{}},t.popoverTemplateUrl=":::PLUGIN_PATH:::/views/popover.html",n&&"new"!==n&&a.detail(n).then(r.getResData).then(m).then(h).then(i.sortApps).then(function(n){t.associatedApplications=n}),i.listByTenant({pageSize:2e3}).then(function(n){return _.uniqBy(n,"id")}).then(d)}n.$inject=["$scope","$routeParams","$uibModal","c8yApplication","c8yTenant","c8yAlert","c8yBase","gettextCatalog","$filter"],angular.module("c8y.tenantApplications").controller("tenantAppAssignmentCtrl",n)})();