(()=>{function e(t,e,n,i,l,c){var s,o=this,a={},r={},d=null,f={open:!1},u={text:""};function h(e){a={},r={},_.forEach(e,function(e){a[e.id]=!0,r[e.id]=!0})}function g(e){return r[e.id]}function p(e){r[e.id]=!0}function C(){var e,t=S();t?(e=_.filter(t,g),o.allVisibleSelected=e.length===t.length):o.allVisibleSelected=!1}function S(){return e("filter")(s,u.text)}function A(e){r[e.id]=!1}o.allVisibleSelected=!1,o.isSelected=g,o.selectAllVisible=function(){_.forEach(S(),p),C()},o.select=p,o.deselectAllVisible=function(){_.forEach(S(),A),C()},o.deselect=A,o.toggle=function(e){r[e.id]=!r[e.id],C()},o.getSelectedStatusText=function(){var e=_.filter(a,_.identity).length;return e===d?c.getString("All children active`assets`"):0===e?c.getString("No children active`assets`"):c.getPlural(e,"1 child active`asset`","{{$count}} children active`asset`",{})},o.apply=function(){t.onSelectionConfirmed&&t.onSelectionConfirmed({selection:_.filter(s,g)}),f.open=!1},o.filterCfg=u,o.dropdownStatus=f,t.$watch("parentMo()",function(e){o.parentMoId=e.id||e,l.detail(o.parentMoId).then(i.getResData).then(function(e){o.childAssets=_.map(e.childAssets.references,"managedObject").concat(_.map(e.childDevices.references,"managedObject")),s=o.childAssets,o.allChildAssetsCount=o.childAssets.length,d=o.allChildAssetsCount,C()})}),t.$watch("selectedChildAssets()",h),t.$watch("ctrl.dropdownStatus.open",function(e){e&&h(t.selectedChildAssets()),n(function(){o.dropdownOpeningFinished=e})}),t.$watch("ctrl.filterCfg.text",C),t.$watchCollection(function(){return r},C)}e.$inject=["$scope","$filter","$timeout","c8yBase","c8yInventory","gettextCatalog"],angular.module("c8y.smartRules").controller("c8yChildAssetsSelectorCtrl",e)})();