function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _slicedToArray(r,t){return _arrayWithHoles(r)||_iterableToArrayLimit(r,t)||_unsupportedIterableToArray(r,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,t){var e;if(r)return"string"==typeof r?_arrayLikeToArray(r,t):"Map"===(e="Object"===(e={}.toString.call(r).slice(8,-1))&&r.constructor?r.constructor.name:e)||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_arrayLikeToArray(r,t):void 0}function _arrayLikeToArray(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function _iterableToArrayLimit(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,a,o,i,u=[],c=!0,l=!1;try{if(o=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=o.call(e)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(r){l=!0,a=r}finally{try{if(!c&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(l)throw a}}return u}}function _arrayWithHoles(r){if(Array.isArray(r))return r}(()=>{function r(r,t,e,n,a,o,u){h.$inject=["$routeParams","$injector"];var c,l,y,s,i="".concat("/group","/:groupId"),d="/group/:groupId",f={};return{init:function(){n.addTitle(i,{data:["$routeParams","c8yBase","c8yInventory","c8yUiUtil",function(r,t,e,n){var r=r.groupId,a=n.getContext();return r?e.detailCached(r,{withChildren:!1}).then(t.getResData).then(function(r){return r=r,{title:(t=a)&&t.contextData&&t.contextData.name||r.name};var t}):{}}]}),e.addBreadcrumbs(i,{data:h}),e.addBreadcrumbs(d,{data:h}),o.add({name:u("Search all"),path:function(r){return r&&"/assetsearch?s=".concat(window.encodeURIComponent(r))}})},$get:function(){}};function h(r,t){function e(r){return _.forEach(r,function(r){r.unshift({label:u("Groups"),icon:"c8y-group-open",path:"#/group",translate:!0})}),r=_.forEach(r,function(r){return r.pop()}),r=_.sortBy(r,function(r){return-1*r.length}),f[i]=r}var n=c=t.get("$q"),a=l=t.get("c8yBase"),o=y=t.get("c8yInventory"),t=(s=t.get("c8yGroups"),n.when([])),i=r.groupId;n.when(null);return i&&(r=o.detail(i,{withParents:!0}).then(a.getResData).then(function(r){return function n(a,o,r){if(!r)return c.when(a);o.unshift(p(r));return c.all([y.directParentDevices(r),y.directParentAssets(r)]).then(function(r){var r=_slicedToArray(r,2),t=r[0],r=r[1],t=[].concat(_toConsumableArray(t),_toConsumableArray(r)).filter(function(r){var t=r.id;return!o.some(function(r){r=r.path;return r.includes(t)})}),e=[];return 0===t.length?(a.push(o),c.when(a)):(_.forEach(t,function(r){r=y.detail(r.id,{withParents:!0}).then(l.getResData).then(function(r){return c.when(n(a,_.cloneDeep(o),r))});e.push(r)}),c.all(e).then(function(){return a}))})}([],[],r)}).then(e),t=n.when(_.get(f,i,r))),t}function p(r){return{icon:s.getIconSpecs(r).iconOpen,groupType:r.type,label:r.name||"".concat(u("Group")," ").concat(r.id),path:"#/group/".concat(r.id)}}}r.$inject=["$routeProvider","c8yViewsProvider","c8yBreadcrumbsProvider","c8yTitleProvider","c8yActionsProvider","c8ySearchProvider","gettext"],angular.module("c8y.groupsHierarchy").provider("c8yGroupsHierarchyUi",r)})();