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 _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 _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 _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 r(a,i,r,c,u){var l="/service/reporting/schedule";return{requestExport:function(r){r=(_.isArray(r)?r:[r]).map(function(r){return i({method:"GET",url:"/export/exports",params:{configurationId:r}})});return a.all(r)},convertToSchedules:function(n){function e(r){return(r||"").split(",")}function o(r){var t={timestamp:new Date(r.creationTime).getTime(),emailConfig:{to:e(r.config.to),cc:e(r.config.cc),bcc:e(r.config.bcc),replyTo:r.config.replyTo||"",subject:r.config.subject||"",text:r.config.text||""},cronConfig:{month:r.config.month||"*",day:r.config.day||"*",weekday:r.config.weekday||"*",hour:r.config.hour||"*",minute:r.config.minute||"*"}};return r.config.second&&(t.cronConfig.second=r.config.second),t}return a.all({exportObj:c.detail(n).then(r.getResData),rules:u.listByContext(n)}).then(function(r){var t=r.exportObj,e=r.rules,r=t.c8y_ScheduleConfiguration||[],r=[].concat(_toConsumableArray(r),_toConsumableArray(_.map(e,o)));return c.update({id:n,c8y_ScheduleConfiguration:r}).then(function(){return r=n,i.put("".concat(l,"/").concat(r),{});var r}).then(function(){return a.all(_.map(e,function(r){return u.remove(r)}))})})}}}r.$inject=["$q","$http","c8yBase","c8yInventory","smartRulesSvc"],angular.module("c8y.cockpit.export").factory("exportService",r)})();