function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){var r;if(t)return"string"==typeof t?_arrayLikeToArray(t,e):"Map"===(r="Object"===(r={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,a,o,l=[],s=!0,u=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);s=!0);}catch(t){u=!0,i=t}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return l}}function _arrayWithHoles(t){if(Array.isArray(t))return t}angular.module("c8y.cockpit.export").factory("c8yExportApis",["SchemaPropertiesSvc","c8yPropertiesLibrary","c8yDataPointSvc","gettext",function(t,n,r,e){var i=["DEVICE_NAME"],a=["Alarms","Events","Measurements"];function o(t,e){this.name=t,this.onLoad(e)}function l(t){return _.map(t,function(t){return{column:t.label,path:t.keyPath.join(".")}})}function s(t){o.call(this,e("Measurements"),t)}return o.prototype.onLoad=function(t){t=_.find(t.apiList,{api:this.name});this.enabled=Boolean(t),this.fields=this.enabled&&t.fields||[]},o.prototype.toggle=function(t,e){var r;return e&&0===this.fields.length&&0<=a.indexOf(this.name)&&n.another(n.paths[(r=this).name]).list().then(function(t){var e=["time","DEVICE_NAME"],t=_.filter(t,function(t){t=_slicedToArray(t.keyPath,1)[0];return 0<=e.indexOf(t)});r.addAll(l(t))}),e},o.prototype.onSave=function(t){var e;this.enabled&&(e=this.fields,_.forEach(e,function(t){0<=i.indexOf(t.path)&&(t.type=t.path)}),t.apiList=t.apiList||[],t.apiList.push({api:this.name,fields:this.fields}))},o.prototype.add=function(t){this.fields.push(t||{})},o.prototype.addAll=function(t){var e=this;_.forEach(t,function(t){e.add(t)})},o.prototype.addPredefined=function(){var e=this;t.openSelector({type:this.name,showComputed:!1,includeTreeChildren:!0}).then(function(t){e.addAll(l(t))})},o.prototype.remove=function(t){this.fields.splice(t,1)},o.prototype.removeAll=function(){this.fields.length=0},(s.prototype=Object.create(o.prototype)).addFromDatapoint=function(){var e=this;r.addUI().then(function(t){t=_.map(t,function(t){return{column:t.label,path:"['".concat(t.fragment,"'].['").concat(t.series,"'].['value']")}});e.addAll(t)})},{Api:o,MeasurementsApi:s}}]);