(()=>{function e(i,o,a,g,r){return{restrict:"E",replace:!0,template:'<div>\n                  <div ng-show="loading" style="min-width: 100%; text-align: center;"><c8y-loading></c8y-loading></div>\n                  <pre ng-show="textFile && !loading" style="max-height: 300px; overflow:auto;">{{logFileData}}</pre>\n                  <div ng-show="!textFile && !loading" class="alert alert-warning" role= "alert">\n                    <span translate>\n                      No preview available for log files with MIME type other than <code>text/*</code>.\n                    </span><br>\n                    <button class="btn btn-default btn-sm m-t-16" ng-click="download(logOp)" type="button" translate> Download </button>\n                  </div></div>',link:function(l){l.download=i.download,l.$watch("selectedLog",function(t){var e,n;t&&t.c8y_LogfileRequest&&t.c8y_LogfileRequest.file&&(l.logOp=t,l.loading=!0,e=t.c8y_LogfileRequest.file,(g.isEventBinary(e)?(n=g.getEventIdFromUrl(e),g.getContentType(n)):(n=a.getIdFromUrl(e),a.getContentType(n))).then(function(e){e.match(/^text.*$/)?i.getLogfile(t).then(function(e){l.textFile=!0,l.logFileData=e.data}).catch(function(){o.danger(r("The file is no longer available."))}).finally(function(){l.loading=!1}):(l.textFile=!1,l.loading=!1)}))},!0)}}}e.$inject=["logViewer","c8yAlert","c8yBinary","c8yEvents","gettext"],angular.module("c8y.logViewer").directive("c8yLogViewer",e)})();