text: !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("@iota-pico/core/dist/helpers/arrayHelper"),require("@iota-pico/core/dist/helpers/numberHelper"),require("@iota-pico/core/dist/helpers/objectHelper"),require("@iota-pico/core/dist/helpers/stringHelper"),require("@iota-pico/core/dist/loggers/nullLogger"),require("@iota-pico/core/dist/error/coreError")):"function"==typeof define&&define.amd?define("@iota-pico/api",["@iota-pico/core/dist/helpers/arrayHelper","@iota-pico/core/dist/helpers/numberHelper","@iota-pico/core/dist/helpers/objectHelper","@iota-pico/core/dist/helpers/stringHelper","@iota-pico/core/dist/loggers/nullLogger","@iota-pico/core/dist/error/coreError"],r):"object"==typeof exports?exports["@iota-pico/api"]=r(require("@iota-pico/core/dist/helpers/arrayHelper"),require("@iota-pico/core/dist/helpers/numberHelper"),require("@iota-pico/core/dist/helpers/objectHelper"),require("@iota-pico/core/dist/helpers/stringHelper"),require("@iota-pico/core/dist/loggers/nullLogger"),require("@iota-pico/core/dist/error/coreError")):e.IotaPicoApi=r(e["@iota-pico/core/dist/helpers/arrayHelper"],e["@iota-pico/core/dist/helpers/numberHelper"],e["@iota-pico/core/dist/helpers/objectHelper"],e["@iota-pico/core/dist/helpers/stringHelper"],e["@iota-pico/core/dist/loggers/nullLogger"],e["@iota-pico/core/dist/error/coreError"])}("undefined"!=typeof self?self:this,function(e,r,t,n,o,i){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=2)}([function(e,r,t){"use strict";t.r(r),t.d(r,"__extends",function(){return o}),t.d(r,"__assign",function(){return i}),t.d(r,"__rest",function(){return s}),t.d(r,"__decorate",function(){return u}),t.d(r,"__param",function(){return a}),t.d(r,"__metadata",function(){return c}),t.d(r,"__awaiter",function(){return p}),t.d(r,"__generator",function(){return d}),t.d(r,"__exportStar",function(){return l}),t.d(r,"__values",function(){return f}),t.d(r,"__read",function(){return h}),t.d(r,"__spread",function(){return m}),t.d(r,"__await",function(){return y}),t.d(r,"__asyncGenerator",function(){return b}),t.d(r,"__asyncDelegator",function(){return w}),t.d(r,"__asyncValues",function(){return _}),t.d(r,"__makeTemplateObject",function(){return v}),t.d(r,"__importStar",function(){return g}),t.d(r,"__importDefault",function(){return E});
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation. All rights reserved.
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  this file except in compliance with the License. You may obtain a copy of the
  License at http://www.apache.org/licenses/LICENSE-2.0
  
  THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  MERCHANTABLITY OR NON-INFRINGEMENT.
  
  See the Apache Version 2.0 License for specific language governing permissions
  and limitations under the License.
  ***************************************************************************** */
  var n=function(e,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};function o(e,r){function t(){this.constructor=e}n(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}var i=function(){return(i=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function s(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&(t[n[o]]=e[n[o]])}return t}function u(e,r,t,n){var o,i=arguments.length,s=i<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(i<3?o(s):i>3?o(r,t,s):o(r,t))||s);return i>3&&s&&Object.defineProperty(r,t,s),s}function a(e,r){return function(t,n){r(t,n,e)}}function c(e,r){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,r)}function p(e,r,t,n){return new(t||(t=Promise))(function(o,i){function s(e){try{a(n.next(e))}catch(e){i(e)}}function u(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){e.done?o(e.value):new t(function(r){r(e.value)}).then(s,u)}a((n=n.apply(e,r||[])).next())})}function d(e,r){var t,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;s;)try{if(t=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=r.call(e,s)}catch(e){i=[6,e],n=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function l(e,r){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}function f(e){var r="function"==typeof Symbol&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}function h(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function m(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(h(arguments[r]));return e}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function b(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=t.apply(e,r||[]),i=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){o[e]&&(n[e]=function(r){return new Promise(function(t,n){i.push([e,r,t,n])>1||u(e,r)})})}function u(e,r){try{(t=o[e](r)).value instanceof y?Promise.resolve(t.value.v).then(a,c):p(i[0][2],t)}catch(e){p(i[0][3],e)}var t}function a(e){u("next",e)}function c(e){u("throw",e)}function p(e,r){e(r),i.shift(),i.length&&u(i[0][0],i[0][1])}}function w(e){var r,t;return r={},n("next"),n("throw",function(e){throw e}),n("return"),r[Symbol.iterator]=function(){return this},r;function n(n,o){r[n]=e[n]?function(r){return(t=!t)?{value:y(e[n](r)),done:"return"===n}:o?o(r):r}:o}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,t=e[Symbol.asyncIterator];return t?t.call(e):(e=f(e),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(t){r[t]=e[t]&&function(r){return new Promise(function(n,o){(function(e,r,t,n){Promise.resolve(n).then(function(r){e({value:r,done:t})},r)})(n,o,(r=e[t](r)).done,r.value)})}}}function v(e,r){return Object.defineProperty?Object.defineProperty(e,"raw",{value:r}):e.raw=r,e}function g(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function E(e){return e&&e.__esModule?e:{default:e}}},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});const n=t(9);r.ApiError=class extends n.CoreError{constructor(e,r,t){super(e,r,t),this.domain="API"}}},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});const n=t(0);n.__exportStar(t(3),r),n.__exportStar(t(1),r)},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});const n=t(0),o=t(4),i=t(5),s=t(6),u=t(7),a=t(8),c=t(1);r.ApiClient=class{constructor(e,r="1",t,n){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The networkClient must be defined");if(u.StringHelper.isEmpty(r))throw new c.ApiError("The apiVersion must not be empty");this._networkClient=e,this._apiVersion=r,this._additionalHeaders=t,this._logger=n||new a.NullLogger}getNodeInfo(){return n.__awaiter(this,void 0,void 0,function*(){return this.sendCommand("getNodeInfo",{})})}getNeighbors(){return n.__awaiter(this,void 0,void 0,function*(){return this.sendCommand("getNeighbors",{})})}addNeighbors(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.uris))throw new c.ApiError("The request.uris must not be empty");return this.sendCommand("addNeighbors",e)})}removeNeighbors(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.uris))throw new c.ApiError("The request.uris must not be empty");return this.sendCommand("removeNeighbors",e)})}getTips(){return n.__awaiter(this,void 0,void 0,function*(){return this.sendCommand("getTips",{})})}findTransactions(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");const r=o.ArrayHelper.isEmpty(e.bundles),t=o.ArrayHelper.isEmpty(e.addresses),n=o.ArrayHelper.isEmpty(e.tags),i=o.ArrayHelper.isEmpty(e.approvees);if(r&&t&&n&&i)throw new c.ApiError("One of the bundle, addresses, tags or approvees must not be empty");return this.sendCommand("findTransactions",e)})}getTrytes(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.hashes))throw new c.ApiError("The request.hashes must not be empty");return this.sendCommand("getTrytes",e)})}getInclusionStates(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.transactions))throw new c.ApiError("The request.transactions must not be empty");if(o.ArrayHelper.isEmpty(e.tips))throw new c.ApiError("The request.tips must not be empty");return this.sendCommand("getInclusionStates",e)})}getBalances(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.addresses))throw new c.ApiError("The request.addresses must not be empty");if(!i.NumberHelper.isInteger(e.threshold))throw new c.ApiError("The request.threshold must be a valid number");return this.sendCommand("getBalances",e)})}getTransactionsToApprove(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(!i.NumberHelper.isInteger(e.depth))throw new c.ApiError("The request.depth must be a valid number");if(!s.ObjectHelper.isEmpty(e.reference)&&u.StringHelper.isEmpty(e.reference))throw new c.ApiError("The request.reference must be a non empty string");if(!s.ObjectHelper.isEmpty(e.numWalks)&&!i.NumberHelper.isInteger(e.numWalks))throw new c.ApiError("The request.numWalks must be a valid number");return this.sendCommand("getTransactionsToApprove",e)})}attachToTangle(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(u.StringHelper.isEmpty(e.trunkTransaction))throw new c.ApiError("The request.trunkTransaction must not be empty");if(u.StringHelper.isEmpty(e.branchTransaction))throw new c.ApiError("The request.branchTransaction must not be empty");if(!i.NumberHelper.isInteger(e.minWeightMagnitude))throw new c.ApiError("The request.minWeightMagnitude must be a valid number");if(o.ArrayHelper.isEmpty(e.trytes))throw new c.ApiError("The request.trytes must not be empty");return this.sendCommand("attachToTangle",e)})}interruptAttachingToTangle(){return n.__awaiter(this,void 0,void 0,function*(){return this.sendCommand("interruptAttachingToTangle",{})})}broadcastTransactions(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.trytes))throw new c.ApiError("The request.trytes must not be empty");return this.sendCommand("broadcastTransactions",e)})}storeTransactions(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.trytes))throw new c.ApiError("The request.trytes must not be empty");return this.sendCommand("storeTransactions",e)})}getMissingTransactions(){return n.__awaiter(this,void 0,void 0,function*(){return this.sendCommand("getMissingTransactions",{})})}checkConsistency(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.tails))throw new c.ApiError("The request.tails must not be empty");return this.sendCommand("checkConsistency",e)})}wereAddressesSpentFrom(e){return n.__awaiter(this,void 0,void 0,function*(){if(s.ObjectHelper.isEmpty(e))throw new c.ApiError("The request must be defined");if(o.ArrayHelper.isEmpty(e.addresses))throw new c.ApiError("The request.addresses must not be empty");return this.sendCommand("wereAddressesSpentFrom",e)})}sendCommand(e,r){return n.__awaiter(this,void 0,void 0,function*(){return this._logger.info(`===> ApiClient::${e}`,r),Object.defineProperty(r,"command",{value:e,enumerable:!0}),this._networkClient.json(r,"POST",void 0,this.createHeaders()).then(r=>(this._logger.info(`===> ${e}`,r),r)).catch(r=>{if(this._logger.error(`===> ${e} Error`,r),r.additional&&r.additional.errorResponse)try{const e=JSON.parse(r.additional.errorResponse);e.error?(delete r.additional.errorResponse,r.additional.apiError=e.error):e.exception&&(delete r.additional.errorResponse,r.additional.apiError=e.exception)}catch(e){}throw r})})}createHeaders(){const e=this._additionalHeaders||{};return e["X-IOTA-API-Version"]=this._apiVersion,e}}},function(r,t){r.exports=e},function(e,t){e.exports=r},function(e,r){e.exports=t},function(e,r){e.exports=n},function(e,r){e.exports=o},function(e,r){e.exports=i}])});