function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(()=>{function e(t,e,r,n){var o=this,i=(_.assign(o,{onToggleDropdown:function(){delete o.textFilter,i=_.map(o.itemsSelected,_.clone)},allSelected:l,toggleSelectAll:function(){i=l()?[]:_.clone(u())},apply:function(){o.applying=!0;var e=u(i).map(function(e){return _.omit(e,"nameLabel")});t.when(o.onApply({items:e})).then(function(){o.isDropDownOpen=!1}).finally(function(){o.applying=!1})},toggle:function(e){c(e)?_.remove(i,{id:e.id}):i.push(e)},isSelected:c,$onChanges:function(e){e.items&&o.items&&(o.items=o.items.map(function(e){return _objectSpread({nameLabel:a(e)},e)}));e.itemsSelected&&(o.displayLabel=_(o.itemsSelected).sortBy(a).map(a).value().join(", "))},translateName:a,placeholder:function(){return _.isUndefined(o.textPlaceholder)?"----":o.textPlaceholder},filterItems:function(e){var t;return!o.textFilter||(t=o.textFilter.toLowerCase(),e.nameLabel.toLowerCase().includes(t))}}),[]);function l(){return _.every(u(),c)}function c(e){return _.some(i,{id:e.id})}function u(e){var t,e=e||o.items;return o.textFilter?(t=o.textFilter.toLowerCase(),e.filter(function(e){return e.nameLabel.toLowerCase().includes(t)})):e}function a(e){return r.getString(n.getName(e))}}e.$inject=["$q","$filter","gettextCatalog","c8yPropertyValueTransformService"],angular.module("c8y.ui").component("c8yItemSelector",{templateUrl:":::PLUGIN_PATH:::/ui/itemSelector/itemSelector.html",bindings:{textPlaceholder:"@",textApply:"@",styleButton:"<",items:"<",itemsSelected:"<",onApply:"&",dropdownMenuClasses:"<",disabled:"=ngDisabled"},controller:e,controllerAs:"vm"})})();