angular.module("c8y.parts.aclManagement").controller("permissionEditorCtrl",["$scope","$q","c8yDevices","c8yUser","c8yBase","c8yTenant","gettext",function(s,t,n,e,r,a,o){var c={},u=this,p=r.createEnum([o("READ"),o("ADMIN"),"*"]),i=o("Object's fragment type (for example, c8y_IsDevice) to which you grant permission. Note that to have access to an object, user must have access to all its fragments. Use an asterisk (*) to grant permission to any object's fragment type.");function h(e){return t.when((e=>g(c.MANAGED_OBJECT)?n.getFragments(e):g(c.OPERATION)?n.getSupportedOperations(e):!g(c.MEASUREMENT)||_.isUndefined(e.id)?[]:n.getSupportedMeasurements(e))(e||{})).then(function(e){return _.union(["*"],e)})}function g(e){var t=s.scope;return t&&t.name===e.name}function E(e){var t=[];t.push(o("ALARM")),t.push(o("AUDIT")),t.push(o("EVENT")),t.push(o("MANAGED_OBJECT")),t.push(o("MEASUREMENT")),t.push(o("OPERATION")),e&&t.push(o("SUPPORT")),t.push("*"),c=r.createEnum(t),s.scopeTypes=c.values()}a.isCurrentUserTopTenant().then(E),(s.properties=s).accessTypes=p.values(),s.typeTooltip=i,window.c8y_testing?s.getSuggestedTypes=h:s.$watchGroup(["device","scope"],function(){h(s.device).then(function(e){u.suggestedTypes=e})})}]);