/*! grafana - v4.5.1 - 2017-09-19
 * Copyright (c) 2017 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["lodash","app/core/core"],function(a,b){"use strict";function c(){return{restrict:"E",controller:f,bindToController:!0,controllerAs:"ctrl",templateUrl:"public/app/features/annotations/partials/event_editor.html",scope:{panelCtrl:"=",event:"=",close:"&"}}}b&&b.id;a("eventEditor",c);var d,e,f;return{setters:[function(a){d=a},function(a){e=a}],execute:function(){f=function(){function a(a){this.annotationsSrv=a,this.event.panelId=this.panelCtrl.panel.id,this.event.dashboardId=this.panelCtrl.dashboard.id}return a.$inject=["annotationsSrv"],a.prototype.save=function(){var a=this;if(this.form.$valid){var b=d.default.cloneDeep(this.event);return b.time=b.time.valueOf(),b.timeEnd=0,b.isRegion&&(b.timeEnd=b.timeEnd.valueOf(),b.timeEnd<b.time)?void console.log("invalid time"):void this.annotationsSrv.saveAnnotationEvent(b).then(function(){a.panelCtrl.refresh(),a.close()})}},a.prototype.timeChanged=function(){this.panelCtrl.render()},a}(),a("EventEditorCtrl",f),e.coreModule.directive("eventEditor",c)}}});