UNPKG

@builton/core-sdk

Version:
1 lines 108 kB
var Builton=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(r,!0).forEach(function(e){u(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],0<=e.indexOf(r)||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],0<=e.indexOf(r)||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var c=r(4),f=r(9);t.exports=function t(){var e=this,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.constructor===t)throw new c.AbstractClass;var o=function(t){var r=t.type,n=void 0===r?"get":r,o=t.urlParams,i=void 0===o?{}:o,u=t.body,s=t.apiPath,c=void 0===s?e.apiPath:s,f=t.action,l=void 0===f?"":f,p=t.ResConstructor,h=void 0===p?e.ResConstructor:p,y=t.isJsonBody,b=void 0===y||y,d=t.json,v=l&&"/"!==l[0]?"/".concat(l):l,g="".concat(c).concat(v);try{return e.request.query({type:n,path:g,body:u,urlParams:i,isJsonBody:b}).then(function(t){var r=function(t,r,n){var o=t.body;if(n||null===r)return o;if(Array.isArray(o)){var i=[];return o.forEach(function(t){i.push(new r(e.request,t))}),i}return"object"===a(o)&&r?new r(e.request,o):o}(t,h,d);return Promise.resolve({res:t,obj:r})}).catch(function(t){return Promise.reject(t)})}catch(t){return Promise.reject(t)}};this.paginate=function(t,r){var n=t.page,u=void 0===n?0:n,a=t.size,c=void 0===a?100:a,l=t.urlParams,p=s(t,["page","size","urlParams"]);return o(i({},p,{urlParams:i({},l,{page:u,size:c})})).then(function(t){var n=t.res,o=t.obj,i=new f(u,c,o,n.headers["x-pagination-total"],e.query,l,p);return r&&r(null,i),i}).catch(function(t){return r&&r(t),Promise.reject(t)})},this.query=function(t,e){var r=n({},t);return o(i({},r)).then(function(t){var r=t.res,n=t.obj;return e&&e(null,n,r),n}).catch(function(t){return e&&e(t),Promise.reject(t)})},r.forEach(function(t){e[t.name]=t})}},function(t,e,r){function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(r,!0).forEach(function(e){u(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],0<=e.indexOf(r)||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],0<=e.indexOf(r)||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var c=r(4),f=r(9);t.exports=function t(e,r){var o=this,u=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.constructor===t)throw new c.AbstractClass;this.id=null,"string"==typeof r?this.id=r:(Object.assign(this,r),r&&!r.id&&r._id&&r._id.$oid&&(this.id=r._id.$oid));var l=function(t){var r=t.type,n=void 0===r?"get":r,i=t.urlParams,u=void 0===i?{}:i,s=t.fullPath,f=void 0===s?null:s,l=t.resource,p=void 0===l?"":l,h=t.body,y=t.apiPath,b=void 0===y?o.apiPath:y,d=t.ResConstructor,v=void 0===d?o.constructor:d,g=t.json;if(!o.id&&!f)throw new c.MethodNeedsId;var m=p&&"/"!==p[0]?"/".concat(p):p,w=f||"".concat(b,"/").concat(o.id).concat(m);try{return e.query({type:n,path:w,body:h,urlParams:u}).then(function(t){var r=function(t,r,n){var i=t.body;if(n||null===r||"object"!==a(i))return i;if(r){if(Array.isArray(i)){var u=[];return i.forEach(function(t){u.push(new r(e,t))}),u}return new r(e,i)}return!o.id&&i._id&&i._id.$oid&&(o.id=i._id.$oid),Object.assign(o,i)}(t,v,g);return Promise.resolve({res:t,obj:r})}).catch(function(t){return Promise.reject(t)})}catch(t){return Promise.reject(t)}};this.paginate=function(t,e){var r=t.page,n=void 0===r?0:r,u=t.size,a=void 0===u?100:u,c=t.urlParams,p=s(t,["page","size","urlParams"]);return l(i({},p,{urlParams:i({},c,{page:n,size:a})})).then(function(t){var r=t.res,i=t.obj,u=new f(n,a,i,r.headers["x-pagination-total"],o.query,c,p);return e&&e(null,u),u}).catch(function(t){return e&&e(t),Promise.reject(t)})},this.query=function(t,e){var r=n({},t);return l(i({},r)).then(function(t){var r=t.res,n=t.obj;return e&&e(null,n,r),n}).catch(function(t){return e&&e(t),Promise.reject(t)})},u.forEach(function(t){o[t.name]=t})}},function(t,e){t.exports={get:function(t,e){var r=0<arguments.length&&void 0!==t?t:{},n=r.urlParams,o=r.json,i=void 0!==o&&o,u=1<arguments.length?e:void 0;return this.query({type:"get",id:this.id,urlParams:n,json:i},u)},refresh:function(t,e){var r=0<arguments.length&&void 0!==t?t:{},n=r.urlParams,o=r.json,i=void 0!==o&&o,u=1<arguments.length?e:void 0;return this.get({urlParams:n,json:i},u)},update:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"put",id:this.id,urlParams:o,body:t,json:u},s)},del:function(t,e){var r=0<arguments.length&&void 0!==t?t:{},n=r.urlParams,o=r.json,i=void 0!==o&&o,u=1<arguments.length?e:void 0;return this.query({type:"del",id:this.id,urlParams:n,json:i},u)}}},function(t,e){function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(n,!0).forEach(function(e){o(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}t.exports=function(t){return{getAll:function(t,e){var r=0<arguments.length&&void 0!==t?t:{},o=r.page,i=r.size,u=r.urlParams,s=r.tags,a=r.json,c=void 0!==a&&a,f=1<arguments.length?e:void 0;return this.paginate({page:o,size:i,type:"get",urlParams:n({},u,{},s&&{tags:s.toString()}),json:c},f)},getFromId:function(e){for(var r=new t(this.request,e),n=arguments.length,o=new Array(1<n?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.get.apply(r,o)},get:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if("string"!=typeof e[0])return this.getAll.apply(this,e);var n=e.splice(0,1)[0];return this.getFromId.apply(this,[n].concat(e))},del:function(e){for(var r=new t(this.request,e),n=arguments.length,o=new Array(1<n?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.del.apply(r,o)},update:function(e){for(var r=new t(this.request,e),n=arguments.length,o=new Array(1<n?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.update.apply(r,o)},create:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"post",urlParams:o,body:t,json:u},s)},search:function(t,e,r){var o=1<arguments.length&&void 0!==e?e:{},i=o.page,u=void 0===i?0:i,s=o.size,a=void 0===s?100:s,c=o.tags,f=o.urlParams,l=o.json,p=void 0!==l&&l,h=2<arguments.length?r:void 0;return this.paginate({page:u,size:a,type:"get",action:"search",urlParams:n({},f,{query:t},c&&{tags:c.toString()}),json:p},h)},set:function(e){var r=this;if(Array.isArray(e)){var n=[];return e.forEach(function(e){n.push(new t(r.request,e))}),n}return new t(this.request,e)}}}},function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,r){return(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var c=function(){function t(e){var r;return n(this,t),(r=o(this,a(t).call(this))).message=e,r.name=r.constructor.name,r}return i(t,u(Error)),t}(),f=function(){function t(){return n(this,t),o(this,a(t).call(this,"You need to construct this object with an ID to access that method"))}return i(t,c),t}(),l=function(){function t(e){return n(this,t),o(this,a(t).call(this,'This method requires the argument "'.concat(e,'" to be executed')))}return i(t,c),t}(),p=function(){function t(){return n(this,t),o(this,a(t).call(this,"This method is not implemented for this Object"))}return i(t,c),t}(),h=function(){function t(){return n(this,t),o(this,a(t).call(this,"Cannot construct Abstract instances"))}return i(t,c),t}(),y=function(){function t(){return n(this,t),o(this,a(t).call(this,"Data needs to be an object { buffer: Buffer, filename: String } or an instance File(client)."))}return i(t,c),t}();t.exports={MethodNeedsId:f,AbstractClass:h,MethodNeedsArg:l,NotImplemented:p,ImageUpload:y}},function(t,e,r){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var s=r(1),a=r(6),c=r(2),f=c.get,l=c.refresh,p=c.update,h=function(){function t(e,r){var o;return function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),(o=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}(this,i(t).call(this,e,r,[f,l,p]))).apiPath="orders",o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(t,s),e=t,(r=[{key:"getPayments",value:function(t,e){var r=0<arguments.length&&void 0!==t?t:{},n=r.page,o=r.size,i=r.urlParams,u=r.json,s=void 0!==u&&u,c=1<arguments.length?e:void 0;return this.paginate({page:n,size:o,type:"get",resource:"payments",urlParams:i,ResConstructor:a,json:s},c)}},{key:"cancel",value:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"post",resource:"cancel",body:t,urlParams:o,json:u},s)}}])&&o(e.prototype,r),t;var e,r}();t.exports=h},function(t,e,r){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var s=r(1),a=r(2),c=a.get,f=a.refresh,l=function(){function t(e,r){var o;return function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),(o=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}(this,i(t).call(this,e,r,[c,f]))).apiPath="payments",o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(t,s),e=t,(r=[{key:"pay",value:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"post",resource:"pay",body:t,urlParams:o,json:u},s)}},{key:"confirm",value:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"post",resource:"confirm",body:t,urlParams:o,json:u},s)}}])&&o(e.prototype,r),t;var e,r}();t.exports=l},function(t,e,r){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var s=r(1),a=r(6),c=r(2),f=c.get,l=c.refresh,p=c.update,h=function(){function t(e,r){var o;return function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),(o=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}(this,i(t).call(this,e,r,[f,l,p]))).apiPath="subscriptions",o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(t,s),e=t,(r=[{key:"getPayments",value:function(t,e){var r=0<arguments.length&&void 0!==t?t:{},n=r.urlParams,o=r.json,i=1<arguments.length?e:void 0;return this.query({type:"get",resource:"payments",urlParams:n,json:o,ResConstructor:a},i)}},{key:"start",value:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"post",id:this.id,resource:"start",body:t,urlParams:o,json:u},s)}},{key:"stop",value:function(t,e,r){var n=1<arguments.length&&void 0!==e?e:{},o=n.urlParams,i=n.json,u=void 0!==i&&i,s=2<arguments.length?r:void 0;return this.query({type:"post",id:this.id,resource:"stop",body:t,urlParams:o,json:u},s)}}])&&o(e.prototype,r),t;var e,r}();t.exports=h},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}t.exports=function(t){return null!==t&&"object"===n(t)}},function(t,e){function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(n,!0).forEach(function(e){o(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}t.exports=function t(e,r,o,i,u,s,a){var c=this;!function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.page=e,this.size=r,this.current=o,this.paginationTotal=i,this._query=function(t){return u(n({},a,{urlParams:n({},s,{page:c.page,size:c.size})}),t).then(function(t){return c.current=t,c.current}).catch(function(t){return Promise.reject(t)})},this.next=function(t){return c.page>=Math.floor(c.paginationTotal/c.size)?Promise.resolve(c.current):(c.page+=1,c._query(t))},this.previous=function(t){return c.page<=0?Promise.resolve(c.current):(c.page-=1,c._query(t))},this.goToPage=function(t,e){return c.page=t,c._query(e)}}},function(t,e,r){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var s=r(0),a=r(5),c=r(3)(a),f=c.getFromId,l=c.getAll,p=c.get,h=c.create,y=c.update,b=c.set,d=c.search,v=function(){function t(e){var r;return function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),(r=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}(this,i(t).call(this,[f,l,p,h,y,b,d]))).request=e,r.apiPath="orders",r.ResConstructor=a,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(t,s),e=t,(r=[{key:"getPayments",value:function(t){for(var e=new a(this.request,t),r=arguments.length,n=new Array(1<r?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return e.getPayments.apply(e,n)}},{key:"cancel",value:function(t){for(var e=new a(this.request,t),r=arguments.length,n=new Array(1<r?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return e.cancel.apply(e,n)}}])&&o(e.prototype,r),t;var e,r}();t.exports=v},function(t,e,r){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var s=r(0),a=r(6),c=r(3)(a),f=c.create,l=c.getFromId,p=c.getAll,h=c.get,y=c.set,b=c.search,d=function(){function t(e){var r;return function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),(r=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}(this,i(t).call(this,[f,l,p,h,y,b]))).request=e,r.apiPath="payments",r.ResConstructor=a,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(t,s),e=t,(r=[{key:"pay",value:function(t){for(var e=new a(this.request,t),r=arguments.length,n=new Array(1<r?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return e.pay.apply(e,n)}},{key:"confirm",value:function(t){for(var e=new a(this.request,t),r=arguments.length,n=new Array(1<r?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return e.confirm.apply(e,n)}}])&&o(e.prototype,r),t;var e,r}();t.exports=d},function(t,e,r){t.exports=r(13)},function(t,e,r){function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var o,i=r(14),u=r(4),s=r(25),a=r(27),c=r(10),f=r(11),l=r(28),p=r(30),h=r(32),y=r(34),b=r(36),d=r(37),v=r(39),g=r(46),m=function(){function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=e.apiKey,n=e.bearerToken,m=e.endpoint,w=void 0===m?"https://api.builton.dev":m,_=e.singleton,O=void 0!==_&&_,P=e.refreshTokenFn,j=void 0===P?null:P;if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),O&&o)return o;if(!r)throw new u.MethodNeedsArg("apiKey");this.endpoint=w,this.request=new i(this.endpoint,{apiKey:r,bearerToken:n},j),this.aiModels=new s(this.request),this.company=new a(this.request),this.orders=new c(this.request),this.payments=new f(this.request),this.paymentMethods=new l(this.request),this.plans=new p(this.request),this.products=new h(this.request),this.resources=new y(this.request),this.subscriptions=new b(this.request),this.users=new d(this.request),this.images=new v(this.request),this.cart=new g(this.request),O&&(o=this)}return e=t,(r=[{key:"refreshBearerToken",value:function(t){this.request.bearerToken=t}},{key:"authenticate",value:function(t){var e=t.bearerToken,r=t.refreshTokenFn,n=t.body;return e&&(this.request.bearerToken=e),r&&(this.request.refreshBearerFn=r),this.users.authenticate(n||{})}}])&&n(e.prototype,r),t;var e,r}();t.exports=m},function(t,e,r){function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(r,!0).forEach(function(e){i(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var s=r(15),a=r(22),c=function(){function t(e,r,n){var o=r.apiKey,i=r.bearerToken;!function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.apiKey=o,this.bearerToken=i,this.endpoint=e,this.refreshBearerFn=n,this.refreshTokenPromise=null}return e=t,n=[{key:"isJWTAlive",value:function(t){try{var e=a(t),r=Date.now().valueOf()/1e3;return!(void 0!==e.exp&&e.exp<r||void 0!==e.nbf&&e.nbf>r)}catch(t){return!1}}},{key:"serialize",value:function(t){var e=[];return Object.keys(t).forEach(function(r){void 0!==t[r]&&e.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(t[r])))}),e.length?"?".concat(e.join("&")):""}}],(r=[{key:"_constructHeaders",value:function(){var t={"X-Builton-API-Key":this.apiKey};return this.bearerToken&&(t.Authorization="Bearer ".concat(this.bearerToken)),t}},{key:"getHeaders",value:function(){var e=this;return this.bearerToken&&!t.isJWTAlive(this.bearerToken)&&this.refreshBearerFn?(this.refreshTokenPromise||(this.refreshTokenPromise=this.refreshBearerFn().then(function(t){return e.bearerToken=t,e.refreshTokenPromise=null,e._constructHeaders()}).catch(function(t){throw t})),this.refreshTokenPromise):Promise.resolve(this._constructHeaders())}},{key:"query",value:function(e){var r=0<arguments.length&&void 0!==e?e:{},n=r.type,i=void 0===n?"get":n,u=r.path,a=void 0===u?"":u,c=r.urlParams,f=void 0===c?{}:c,l=r.body,p=void 0===l?void 0:l,h=r.headers,y=void 0===h?{}:h,b=r.endpoint,d=void 0===b?this.endpoint:b,v="".concat(d,"/").concat(a).concat(t.serialize(o({},f)));return this.getHeaders().then(function(t){var e=s[i](v).set(o({},t,{},y));return p&&p.isFile?(void 0!==p.isPublic&&e.field("public",p.isPublic),e.attach("image",p.data,p.filename)):e.send(p),e})}}])&&u(e.prototype,r),n&&u(e,n),t;var e,r,n}();t.exports=c},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o;o="undefined"!=typeof window?window:"undefined"==typeof self?void console.warn("Using browser-only version of superagent in non-browser environment"):self;var i=r(16),u=r(17),s=r(18),a=r(8),c=r(19),f=r(21);function l(){}t.exports=function(t,r){return"function"==typeof r?new e.Request("GET",t).end(r):1===arguments.length?new e.Request("GET",t):new e.Request(t,r)};var p=e=t.exports;e.Request=m,p.getXHR=function(){if(o.XMLHttpRequest&&(!o.location||"file:"!==o.location.protocol||!o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw new Error("Browser-only version of superagent could not find XHR")};var h="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function y(t){if(!a(t))return t;var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&b(e,r,t[r]);return e.join("&")}function b(t,e,r){if(void 0!==r)if(null!==r)if(Array.isArray(r))r.forEach(function(r){b(t,e,r)});else if(a(r))for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&b(t,"".concat(e,"[").concat(n,"]"),r[n]);else t.push(encodeURIComponent(e)+"="+encodeURIComponent(r));else t.push(encodeURIComponent(e))}function d(t){for(var e,r,n={},o=t.split("&"),i=0,u=o.length;i<u;++i)-1===(r=(e=o[i]).indexOf("="))?n[decodeURIComponent(e)]="":n[decodeURIComponent(e.slice(0,r))]=decodeURIComponent(e.slice(r+1));return n}function v(t){return/[\/+]json($|[^-\w])/.test(t)}function g(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!==this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223===e&&(e=204),this._setStatusProperties(e),this.headers=function(t){for(var e,r,n,o,i=t.split(/\r?\n/),u={},s=0,a=i.length;s<a;++s)-1!==(e=(r=i[s]).indexOf(":"))&&(n=r.slice(0,e).toLowerCase(),o=h(r.slice(e+1)),u[n]=o);return u}(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&t._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function m(t,e){var r=this;this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t,e=null,n=null;try{n=new g(r)}catch(t){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=t,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",n);try{r._isResponseOK(n)||(t=new Error(n.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=e,t.response=n,t.status=n.status,r.callback(t,n)):r.callback(null,n)})}function w(t,e,r){var n=p("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}p.serializeObject=y,p.parseString=d,p.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},p.serialize={"application/x-www-form-urlencoded":y,"application/json":u},p.parse={"application/x-www-form-urlencoded":d,"application/json":JSON.parse},c(g.prototype),g.prototype._parseBody=function(t){var e=p.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&v(this.type)&&(e=p.parse["application/json"]),e&&t&&(0<t.length||t instanceof Object)?e(t):null)},g.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot ".concat(e," ").concat(r," (").concat(this.status,")"),o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},p.Response=g,i(m.prototype),s(m.prototype),m.prototype.type=function(t){return this.set("Content-Type",p.types[t]||t),this},m.prototype.accept=function(t){return this.set("Accept",p.types[t]||t),this},m.prototype.auth=function(t,e,r){return 1===arguments.length&&(e=""),"object"===n(e)&&null!==e&&(r=e,e=""),r=r||{type:"function"==typeof btoa?"basic":"auto"},this._auth(t,e,r,function(t){if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")})},m.prototype.query=function(t){return"string"!=typeof t&&(t=y(t)),t&&this._query.push(t),this},m.prototype.attach=function(t,e,r){if(e){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},m.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();var r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},m.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.buffer=m.prototype.ca,m.prototype.ca=m.prototype.agent,m.prototype.pipe=m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype._isHost=function(t){return t&&"object"===n(t)&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},m.prototype.end=function(t){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||l,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var t=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){t._timeoutError("Upload timeout of ",t._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var t=this;this.xhr=p.getXHR();var e=this.xhr,r=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var r=e.readyState;if(2<=r&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4===r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){0<r.total&&(r.percent=r.loaded/r.total*100,100===r.percent&&clearTimeout(t._uploadTimeoutTimer)),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.addEventListener("progress",n.bind(null,"download")),e.upload&&e.upload.addEventListener("progress",n.bind(null,"upload"))}catch(t){}e.upload&&this._setUploadTimeout();try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||p.serialize[o?o.split(";")[0]:""];!i&&v(o)&&(i=p.serialize["application/json"]),i&&(r=i(r))}for(var u in this.header)null!==this.header[u]&&Object.prototype.hasOwnProperty.call(this.header,u)&&e.setRequestHeader(u,this.header[u]);this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0===r?null:r)},p.agent=function(){return new f},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){f.prototype[t.toLowerCase()]=function(e,r){var n=new p.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),f.prototype.del=f.prototype.delete,p.get=function(t,e,r){var n=p("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},p.head=function(t,e,r){var n=p("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},p.options=function(t,e,r){var n=p("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},p.del=w,p.delete=w,p.patch=function(t,e,r){var n=p("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},p.post=function(t,e,r){var n=p("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},p.put=function(t,e,r){var n=p("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}(t.exports=n).prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){((t.exports=n).default=n).stable=i,n.stableStringify=i;var r=[];function n(t,e,n){!function t(e,n,o,i){var u;if("object"==typeof e&&null!==e){for(u=0;u<o.length;u++)if(o[u]===e)return i[n]="[Circular]",void r.push([i,n,e]);if(o.push(e),Array.isArray(e))for(u=0;u<e.length;u++)t(e[u],u,o,e);else{var s=Object.keys(e);for(u=0;u<s.length;u++){var a=s[u];t(e[a],a,o,e)}}o.pop()}}(t,"",[],void 0);for(var o=JSON.stringify(t,e,n);0!==r.length;){var i=r.pop();i[0][i[1]]=i[2]}return o}function o(t,e){return t<e?-1:e<t?1:0}function i(t,e,n){for(var i=function t(e,n,i,u){var s;if("object"==typeof e&&null!==e){for(s=0;s<i.length;s++)if(i[s]===e)return u[n]="[Circular]",void r.push([u,n,e]);if("function"==typeof e.toJSON)return;if(i.push(e),Array.isArray(e))for(s=0;s<e.length;s++)t(e[s],s,i,e);else{var a={},c=Object.keys(e).sort(o);for(s=0;s<c.length;s++){var f=c[s];t(e[f],f,i,e),a[f]=e[f]}if(void 0===u)return a;r.push([u,n,e]),u[n]=a}i.pop()}}(t,"",[],void 0)||t,u=JSON.stringify(i,e,n);0!==r.length;){var s=r.pop();s[0][s[1]]=s[2]}return u}},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=r(8);function i(t){if(t)return function(t){for(var e in i.prototype)Object.prototype.hasOwnProperty.call(i.prototype,e)&&(t[e]=i.prototype[e]);return t}(t)}(t.exports=i).prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!==n(t))return this._timeout=t,this._responseTimeout=0,this._uploadTimeout=0,this;for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;case"upload":this._uploadTimeout=t.upload;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var u=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&500<=e.status&&501!==e.status)return!0;if(t){if(t.code&&-1!==u.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"===t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){var r=this;if(!this._fullfilledPromise){var n=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){n.on("abort",function(){var t=new Error("Aborted");t.code="ABORTED",t.status=r.status,t.method=r.method,t.url=r.url,e(t)}),n.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw new Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):200<=t.status&&t.status<300)},i.prototype.getHeader=i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.set=function(t,e){if(o(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(o(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(r,t[r]);return this}if(Array.isArray(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(t,e[n]);return this}if(null==e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=String(e)),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic ".concat(n("".concat(t,":").concat(e))));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer ".concat(t))}return this},i.prototype.withCredentials=function(t){return void 0===t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw new TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=o(t),r=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(e&&o(this._data))for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(this._data[n]=t[n]);else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"===r?this._data?"".concat(this._data,"&").concat(t):t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)||r||this.type("json"),this},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(0<=this.url.indexOf("?")?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(0<=e){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.warn("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error("".concat(t+e,"ms exceeded"));n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},function(t,e,r){"use strict";var n=r(20);function o(t){if(t)return function(t){for(var e in o.prototype)Object.prototype.hasOwnProperty.call(o.prototype,e)&&(t[e]=o.prototype[e]);return t}(t)}(t.exports=o).prototype.get=function(t){return this.header[t.toLowerCase()]},o.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(this[o]=r[o]);this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},o.prototype._setStatusProperties=function(t){var e=t/100|0;this.statusCode=t,this.status=this.statusCode,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201===t,this.accepted=202===t,this.noContent=204===t,this.badRequest=400===t,this.unauthorized=401===t,this.notAcceptable=406===t,this.forbidden=403===t,this.notFound=404===t,this.unprocessableEntity=422===t}},function(t,e,r){"use strict";e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(t[n]=o),t},{})},e.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},function(t,e,r){"use strict";function n(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(t){n.prototype[t]=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return this._defaults.push({fn:t,args:r}),this}}),n.prototype._setDefaults=function(t){this._defaults.forEach(function(e){var r;t[e.fn].apply(t,function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(r=e.args)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}())})},t.exports=n},function(t,e,r){"use strict";var n=r(23);function o(t){this.message=t}(o.prototype=new Error).name="InvalidTokenError",t.exports=function(t,e){if("string"!=typeof t)throw new o("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(n(t.split(".")[r]))}catch(t){throw new o("Invalid token specified: "+t.message)}},t.exports.InvalidTokenError=o},function(t,e,r){var n=r(24);t.exports=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(n(e).replace(/(.)/g,function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}catch(t){return n(e)}}},function(t,e){function r(t){this.message=t}(r.prototype=new Error).name="InvalidCharacterError",t.exports="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,u=0,s="";o=e.charAt(u++);~o&&(n=i%4?64*n+o:o,i++%4)&&(s+=String.fromCharCode(255&n>>(-2*i&6))))o="ABCDEFGHIJKLMNOPQRS