function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ownKeys(e,t){var o,r=Object.keys(e);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(e),t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)),r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach(function(t){_defineProperty(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0===o)return("string"===e?String:Number)(t);o=o.call(t,e||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}(()=>{function t(u,n,a,o,r,i){var c="application/applications",s="application/vnd.com.nsn.cumulocity.applicationLogs+json;charset=UTF-8;ver=0.9";return{downloadAndSaveAs:function(t,o,r,n){return e(t,o,r,n).then(function(t){var e,t=t.logs;_.isEmpty(t)?i.info(p(r,n)):(t=t,e="".concat(e=o,".log"),t=new Blob([t],{type:"text/plain"}),window.saveAs(t,e))})},shouldShowLogsTab:function(t){var t="c8y_Application_".concat(t),e=new Date;return o.list({type:t,nocache:e.getTime()}).then(function(t){var e;return _.isEqual(_.get(t,"length"),1)&&(t=_.head(t),e=_.get(t,"c8y_SupportedLogs"),t=_.get(t,"c8y_Status.instances"),e=_.some(e,function(t){return"syslog"===t})&&!_.isEmpty(t)),e})},getAllLogs:e,getLogs:l,formatDateChosenByUser:function(t){t=moment(t).format("YYYY-MM-DDTHH:mm:ss.SSS");return moment("".concat(t,"Z")).toISOString()},getWarningMessageForMissingLogs:p};function e(o,r,n,a){function i(t){var e=m(t.dateTo);return c.push(t.logs),moment(e).isValid()&&t.truncated&&t.dateFrom!==t.dateTo?l(o,r,{dateFrom:e,dateTo:a}).then(i):u.resolve(c)}var c=[];return l(o,r,{dateFrom:n,dateTo:a}).then(i).then(function(t){var e=n,o=a,r=t;return r=t.join(""),{dateFrom:e,dateTo:o,logs:r}})}function l(t,e){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=3<arguments.length?arguments[3]:void 0,t=a.url("".concat(c,"/").concat(t,"/logs/").concat(e)),e=_objectSpread({headers:{Accept:s},params:o},r);return o.dateFrom&&(o.dateFrom=m(o.dateFrom)),o.dateTo&&(o.dateTo=m(o.dateTo)),n.get(t,e).then(a.getResData)}function m(t){return moment(t).format(a.dateFullFormatWithMs)}function p(t,e){var o;return!t&&e&&(o=r.getString("No logs available before {{dateTo | absoluteDateTimeFormat:'LL, LTS':'+0000'}}.",{dateTo:e})),t&&e&&(o=r.getString("No logs available in time range {{dateFrom | absoluteDateTimeFormat:'LL, LTS':'+0000'}} - {{dateTo | absoluteDateTimeFormat:'LL, LTS':'+0000'}}.",{dateFrom:t,dateTo:e})),t&&!e&&(o=r.getString("No logs available after {{dateFrom | absoluteDateTimeFormat:'LL, LTS':'+0000'}}.",{dateFrom:t})),o=t||e?o:r.getString("No logs available.")}}t.$inject=["$q","$http","c8yBase","c8yInventory","gettextCatalog","c8yAlert"],angular.module("c8y.appLogs").factory("c8yApplicationLogs",t)})();