(()=>{function e(n,e){var u=e("Select or search group");return{link:function(r){var e=!1;function o(){r.groups||e||(e=!0,n.list({withChildren:!1}).then(function(e){r.groups=e}).finally(function(){e=!1}))}r.placeholder=r.customPlaceholder||u,r.getDynamicGroups=function(e){e=e.search;{var o;e&&r.groups&&!_.some(_.reject(r.groups,"newGroup"),{name:e})&&r.allowNonExistingGroup?(o=_.find(r.groups,{newGroup:!0}))?o.name=e:r.groups.push({newGroup:!0,name:e}):_.remove(r.groups,{newGroup:!0})}return r.groups},r.onOpenClose=function(e){e&&(r.lazyLoad&&o(),r.group=void 0)},r.orderBy=function(e){return(e.newGroup?"z":"a")+e.name},r.getFilterGroup=function(o){return function(e){return!o||_.includes(e.name,o)}},(r.scopeCopy=r).lazyLoad||o()},restrict:"EA",scope:{group:"=",groupAsId:"=?",customPlaceholder:"@placeholder",allowNonExistingGroup:"<?",lazyLoad:"<?",groups:"=?"},templateUrl:":::PLUGIN_PATH:::/ui/views/deviceGroupSelector.html"}}e.$inject=["c8yDeviceGroup","gettext"],angular.module("c8y.ui").directive("c8yDeviceGroupSelector",e)})();