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 _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,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 n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}(()=>{function e(a,n,e){var o,m=this,u=d3.scale.category10();function r(e){var t=e.currentValue,e=e.previousValue;return!_.isEmpty(t)&&!_.isEmpty(e)&&!_.isEqual(t,e)}function i(e){m.fragmentSeriesPairs=_.groupBy(e,"fragment")}function c(){m.channel="/measurements/".concat(o)}function f(){var n,r,i,e=_.get(m.fragmentSeriesPairs,m.fragment),e=_.reduce(e,function(e,t){var n=t.series;return _.assign(e,_defineProperty({},n,{unit:t.unit}))},{}),e=(n=0,r=m.fragment,i={__target:{id:o},fragment:r,lineType:"line",renderType:"area"},_.map(e,function(e,t){return _.assign({series:t,unit:e.unit,label:a.humanizeFragment("".concat(r," => ").concat(t)),color:u(n++),__active:!0},i)}));_.set(m,"dataPoints",e)}m.aggregation="MINUTELY",m.interval=e._defaultDuration,_.assign(m,{$onChanges:function(e){var t=e.device,e=e.fragment;m.device&&m.fragment&&((r(t)||r(e))&&(m.fragmentSeriesPairs=void 0),o=a.getId(m.device),m.fragmentSeriesPairs?(c(),f()):n.getSupportedSeries(o).then(i).then(function(){c(),f()}))},$onInit:function(){m.dateFrom=moment().subtract(1,"hour").toDate(),m.dateTo=new Date},onUpdateDates:function(e,t){m.dateFrom=e;e=moment().diff(moment(t),"seconds")<5;m.realtime&&!e&&(m.realtime=!1);m.dateTo=t},updateScale:function(e){_.forEach(e.series,function(e){var t,n=e.dataPoint,r=_.find(m.dataPoints,function(e){return e.fragment===n.fragment&&e.series===n.series});r&&(e=e.values,(t=_.minBy(e,"val.min").val.min)===(e=_.maxBy(e,"val.max").val.max)&&(--t,e+=1),r.min=t,r.max=e)})}})}e.$inject=["c8yBase","c8yDevices","INTERVAL_CONSTANTS"],angular.module("c8y.core.measurements2").component("c8yMeasurementsFragmentChart",{templateUrl:":::PLUGIN_PATH:::/fragmentChart/fragmentChart.html",controllerAs:"vm",controller:e,bindings:{fragment:"<",device:"<",dateFrom:"=",dateTo:"=",realtime:"=?",hideRealtimeButton:"=?"}})})();