Socket
Socket
Sign inDemoInstall

crypto-convert

Package Overview
Dependencies
27
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.4 to 2.0.5

2

cdn/crypto-convert.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("FormData"),require("fetch")):"function"==typeof define&&define.amd?define(["FormData","fetch"],e):"object"==typeof exports?exports.convert=e(require("FormData"),require("fetch")):t.convert=e(t.FormData,t.fetch)}(this,((__WEBPACK_EXTERNAL_MODULE__88__,__WEBPACK_EXTERNAL_MODULE__265__)=>(()=>{"use strict";var __webpack_modules__={945:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))};function n(t,e){const o="undefined"!=typeof window?null===window||void 0===window?void 0:window.fetch:r(265),a="undefined"!=typeof window?null===window||void 0===window?void 0:window.FormData:r(88);if(!o)throw new Error("Fetch API is not installed. If you are using Node please run `npm install node-fetch`");if(!a)throw new Error("FormData is not installed. If you are using Node please run `npm install form-data`");const s=t=>Object.assign(Object.assign({},t),{headers:Object.assign({},t.headers),params:Object.assign({},t.params),values:Object.assign({},t.values)}),l=t=>{var e,r;if("Object"!=(null===(r=null===(e=null==t?void 0:t.__proto__)||void 0===e?void 0:e.constructor)||void 0===r?void 0:r.name))throw new Error("Invalid $options object.");let i=s(t.$options||{});return delete t.$options,Object.assign(Object.assign({},i),{values:Object.assign(Object.assign({},i.values),t)})},c=(t,e,r=!1)=>{let i=r?t||{}:s(t||{}),n=s(e||{});return n.headers=Object.assign(Object.assign({},i.headers),n.headers),n.params=Object.assign(Object.assign({},i.params),n.params),n.values=Object.assign(Object.assign({},i.values),n.values),Object.assign(i,n),i};t=Object.assign({},t);let u={base:"",headers:{"User-Agent":"Rests JS (v1.1.0)"},params:{},values:{},on_error:void 0,on_success:void 0,on_request:void 0,fetch_agent:null};c(u,(null==t?void 0:t.$options)||{},!0),c(u,e,!0);const d={json:"application/json",form:"multipart/form-data",urlencoded:"application/x-www-form-urlencoded",text:"text/plain"},p=Object.values(d),y=["headers","body","query","path"],f={POST:"body",GET:"query"},h={"multipart/form-data":function(){var t=new a;return t.toString=function(){return this},t},"application/x-www-form-urlencoded":function(){return new URLSearchParams},"application/json":function(){return{append:function(t,e){this.data=this.data||{},this.data[t]=e},toString:function(){return JSON.stringify(this.data)},isEmpty:function(){return!this.data||0==Object.keys(this.data).length}}},"text/plain":function(){return{append:function(t,e){return this.data=this.data||[],this.data.push(e)},toString:function(){return this.data.join("")},isEmpty:function(){return!this.data||0==this.data.length}}}},m=t=>null==t,b=(...t)=>{for(var e=0;e<t.length;e++)if(null!==t[e]&&void 0!==t[e])return t[e];return null},_=(t,e,r,n)=>i(this,void 0,void 0,(function*(){return o(t,e).then((function(t){var e;return i(this,void 0,void 0,(function*(){try{var i=t.headers.get("Content-Type")||"";let o;try{o=t.type}catch(t){}let a={statusCode:t.status,statusText:t.statusText,headers:t.headers,type:o,ok:t.ok},s={"application/json":"json","text/plain":"text","(multipart/form-data|application/x-www-form-urlencoded)":"formData",blob:"blob",text:"text"},l=Object.keys(s).find((t=>new RegExp(t).test(i)))||"text";if(a[s[l]]=yield t[s[l]](),a.message=(null===(e=null==a?void 0:a.json)||void 0===e?void 0:e.message)||(t.ok?"Success.":"Something went wrong."),!t.ok)throw a;if(r.on_success){let t=r.on_success(a,n);if(void 0!==t)return t}return a}catch(t){if(r.on_error){let e=r.on_error(t,n);if(void 0!==e)return e}return Promise.reject(t)}}))}))}));function k(t,e,r){t.method=(t.method||"get").toUpperCase(),t.params=t.params||{};const n=function(o){var a,s,l,v,w,g;return i(this,void 0,void 0,(function*(){if(this instanceof n)throw new Error("This is an endpoint, you can't initialize this.");var i=c(u,e);i.on_request=t.on_request||i.on_request,i.on_success=t.on_success||i.on_success,i.on_error=t.on_error||i.on_error;var O=`${i.base}${t.path}`;((null==o?void 0:o.$sandbox)||(null===(a=null==i?void 0:i.values)||void 0===a?void 0:a.$sandbox))&&(O=`${i.sandboxBase||i.base}${t.path}`);var T,C,A={method:t.method,headers:Object.assign({},i.headers),agent:i.fetch_agent},S=p.includes(t.enctype)?t.enctype:d[t.enctype||"json"],E=Object.assign({},i.params,t.params),N=h[S](),D=new URLSearchParams;for(var x in"FormData"==(null===(s=null==o?void 0:o.constructor)||void 0===s?void 0:s.name)?(T=o,o=Object.fromEntries(Array.from(T.keys(),(t=>t.endsWith("[]")?[t.slice(0,-2),T.getAll(t)]:[t,T.get(t)])))):o=o||{},E){var R=E[x],P=o[x],j=null===(l=null==i?void 0:i.values)||void 0===l?void 0:l[x],U=R.default,M=(null==o?void 0:o.$sandbox)||(null===(v=null==i?void 0:i.values)||void 0===v?void 0:v.$sandbox)?R.example:void 0,B=b(P,j,M,U),X=R.name||x,L=R.help||`The '${x}' field is invalid.`;if(R.required&&m(B))throw(I=new Error(L)).field=x,I;if(!m(B)){if("function"==typeof R.format)try{B=R.format(B)}catch(t){throw(I=new Error(t.message||L)).field=x,I}if(R.type&&"any"!==R.type&&((I=new Error(L)).field=x,["string","boolean","number"].includes(R.type)&&typeof B!=R.type||"array"==R.type&&!Array.isArray(B)||"object"==R.type&&(!B||"Object"!==B.__proto__.constructor.name)))throw I;if(R.validate&&("RegExp"==(null===(g=null===(w=R.validate)||void 0===w?void 0:w.constructor)||void 0===g?void 0:g.name)&&(R.validate.toJSON=function(){return R.validate.toString().replace(/^\//g,"").replace(/\/$/g,"")}),!new RegExp(R.validate).test(B)))throw(I=new Error(L)).field=x,I;if("number"==R.type){var I;if(R.hasOwnProperty("max")&&!isNaN(R.max)&&Number(B)>Number(R.max))throw(I=new Error(`The maximum allowed value allowed for the ${X} parameter is ${R.max}`)).field=x,I;if(R.hasOwnProperty("min")&&!isNaN(R.min)&&Number(B)<Number(R.min))throw(I=new Error(`The minimum allowed value allowed for the ${X} parameter is ${R.min}`)).field=x,I}if(R.in&&Array.isArray(R.in)&&!R.in.includes(B))throw(I=new Error(`The ${X} parameter should be one of these values: ${R.in}`)).field=x,I;var $="string"==typeof R.location?R.location.toLowerCase():f[A.method];if(!$||!y.includes($))throw new Error(`Invalid location for '${x}' field.`);"headers"!=$?"body"!=$?"query"!=$?"path"==$&&(O=O.replace(new RegExp(`{${(C=X,C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).trim()}}`),B)):D.append(X,B):N.append(X,B):(A.headers=A.headers||{},A.headers[X]=B)}}var F=D.toString();F&&(O=`${O}?${F}`),N.keys&&(t=>{for(var e of t)return!1;return!0})(N.keys())||N.getLengthSync&&0==N.getLengthSync()||N.isEmpty&&N.isEmpty()||(A.body=N.toString()),A.body&&"multipart/form-data"!==S&&(A.headers=A.headers||{},A.headers["Content-Type"]=S);let H={url:O,options:A,params:o,key:r,instance:u.__$root_instance__,self:k(t,e,r)};if(i.on_request){var G=yield Promise.resolve(i.on_request(H));if(G){if(!(null==G?void 0:G.url)&&!(null==G?void 0:G.options))return G;O=G.url||O,A=G.options||A}if(!1===G)return!1}return _(O,A,i,H)}))};return n}function v(e,r,i,o){var a={[e=e||"Rests"]:function(s){if(!(this instanceof a[e]))throw new Error("This is a category, you can initalize this category to update values using 'new' command.");if(o)throw new Error("This is already initialized, you can use 'set' instead.");let d=c(u,r),p=l(s),y=c(d,p);return n(i?(f=t,i.split(".").reduce(((t,e)=>null==t?void 0:t[e]),f)):t,y);var f}};return o&&(a[e].set=function(t){if(this instanceof a[e].set)throw new Error("The set object can't be initialized.");let r=l(t);return c(u,r,!0),a[e]}),a[e]}const w=Object.defineProperty(v("Rests",u,void 0,!0),"__schema__",{value:{schema:t,options:u},writable:!1,enumerable:!1});return u.__$root_instance__=w,function t(e,r,i,n){for(var o in r){var a=r[o];if(!a||"object"!=typeof a)continue;if(void 0!==e[o]){console.warn(`Skipping ${o} as it confilicts with another key in the object`);continue}let l=`${n?n+".":""}${o}`;if(a.hasOwnProperty("path")){var s=a;e[o]=k(s,i,l)}else{if("$"===o.substr(0,1))continue;let r=i;(null==a?void 0:a.$options)&&(r=c(i,null==a?void 0:a.$options)),e[o]=t(v(o,r,l),a,r,l)}}return e}(w,t,{})}Object.defineProperty(e,"__esModule",{value:!0}),n.default=n,e.default=n,t.exports=n},203:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(945)),a=r(382);let s,l;const c=(0,o.default)({binance:{$options:{base:"https://api.binance.com/api/v3"},bookTicker:{path:"/ticker/bookTicker",on_success:t=>t.json},ticker:{path:"/ticker/price",on_request(t){return i(this,void 0,void 0,(function*(){if(!l){const e=yield t.instance.binance.bookTicker();l=e.map((t=>parseFloat(t.askPrice)<=0&&t.symbol)).filter((t=>t))}}))},on_success(t,e){const r={USDT:"USD",USDC:"USD",BUSD:"USD"},i=t.json;if(!i||!Array.isArray(i))throw new Error(`Invalid response from Binance: ${JSON.stringify(i)}`);return i.reduce(((t,e)=>{if(l&&-1!==l.indexOf(e.symbol))return t;const i=(0,a.symbolMap)(e.symbol,r),n=parseFloat(e.price);return t[i]=n,t}),{})}}},bitfinex:{$options:{base:"https://api-pub.bitfinex.com/v2"},ticker:{path:"/tickers",params:{symbols:{help:"The symbols you want information about as a comma separated list, or ALL for every symbol. (Examples of possible symbols: tBTCUSD, tETHUSD, fUSD, fBTC)",default:"ALL",type:"string"}},on_success:function(t){const e={BAB:"BCH",DSH:"DASH"},r=t.json;if(!r||!Array.isArray(r))throw new Error(`Invalid response from Bitfinex: ${JSON.stringify(r)}`);return r.reduce(((t,r)=>{if(!r[0].startsWith("t"))return t;const i=(0,a.symbolMap)(r[0].replace(/^t/,""),e,!0).replace(":",""),n=parseFloat(r[7]);return t[i]=n,t}),{})}}},coinbase:{$options:{base:"https://api.coinbase.com/v2"},ticker:{path:"/exchange-rates",params:{currency:{help:"The exchange currency (default USD)"}},on_success:t=>{var e;const r=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.data;if(!r)throw new Error(`Invalid response from Coinbase: ${r}`);return Object.keys(r.rates).reduce(((t,e,i)=>{const n=e+r.currency,o=(0,a.formatNumber)(1/parseFloat(r.rates[e]),8);return t[n]=o,t}),{})}}},kraken:{$options:{base:"https://api.kraken.com/0/public"},pairs:{path:"/AssetPairs",on_success:t=>Object.keys(t.json.result)},ticker:{path:"/Ticker",on_request:t=>i(void 0,void 0,void 0,(function*(){if(!s){const e=yield t.instance.kraken.pairs();s=e}return{url:t.url+"?pair="+s}})),on_success:t=>{var e;const r={XETC:"ETC",XETH:"ETH",XLTC:"LTC",XMLN:"MLN",XREP:"REP",XXBT:"BTC",XXDG:"XDG",XXLM:"XLM",XXMR:"XMR",XXRP:"XRP",XZEC:"ZEC",XBT:"BTC",ZAUD:"AUD",ZEUR:"EUR",ZGBP:"GBP",ZUSD:"USD",ZCAD:"CAD",ZJPY:"JPY"},i=null===(e=t.json)||void 0===e?void 0:e.result;if(!i)throw new Error(`Invalid response from Kraken: ${JSON.stringify(i)}`);return Object.keys(i).reduce(((t,e)=>{const n=(0,a.symbolMap)(e,r,!0),o=parseFloat(i[e].c[0]);return t[n]=o,t}),{})}}},coinmarketcap:{$options:{base:"https://api.coinmarketcap.com/data-api/v3"},top:{path:"/map/all",params:{limit:{default:"150"},listing_status:{default:"active"}},on_success:function(t){const e=t.json;if(!e||!e.data||!Array.isArray(e.data.cryptoCurrencyMap))throw new Error(`Invalid response from CoinMarketCap: ${JSON.stringify(e)}`);return e.data.cryptoCurrencyMap.reduce(((t,e)=>(t[e.symbol]={id:e.id,title:e.name,symbol:e.symbol,logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`,rank:e.rank},t)),{})}}},fiat:{all:{path:"https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml",on_success:function(t){var e=t.text,r=e.match(/(?<=currency=["'])([A-Za-z]+)/gi),i=e.match(/(?<=rate=["'])([.0-9]+)/gi),n=r.reduce(((t,e,r)=>Object.assign(Object.assign({},t),{[e]:i[r]})),{});return n.EUR=1,n}}},coinconvert:{$options:{base:"https://api.coinconvert.net"},ticker:{path:"/v2/ticker",params:{v:{default:"2.0.4"},filterExchanges:{type:"array"},noAverage:{type:"boolean"}},on_success:t=>t.json},list:{path:"/v2/list?v=2.0.4",on_success:t=>t.json}}});e.default=c},866:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(827));e.default=class{constructor(){this.ticker={},this.list=[],this.workers={},this.workersPromises=[]}ready(){return i(this,void 0,void 0,(function*(){return Promise.all(this.workersPromises)}))}addCurrency(t,e,r,n){return i(this,void 0,void 0,(function*(){if("string"!=typeof t||"string"!=typeof e||!o.default.list.fiat.includes(e))throw new Error("Invalid currency pair.");if("function"!=typeof r)throw new Error("No function specified.");if(t=t.toUpperCase(),e=e.toUpperCase(),(this.ticker[t+e]||this.ticker[e+t]||-1!=this.list.indexOf(t))&&(console.warn("This custom currency already exists, it will be overriden."),this.removeCurrency(t)),this.list.push(t),n){if("number"!=typeof n)throw new Error("Invalid interval specfied.");this.workers[t+e]=setInterval((()=>Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}))),n)}const i=Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}));return this.workersPromises.push(i),i}))}removeCurrency(t,e){t=t.toUpperCase(),e=e?e.toUpperCase():"";for(const r in this.workers)r.includes(t+e)&&(clearInterval(this.workers[r]),delete this.ticker[r]);this.list=this.list.filter((e=>e!==t))}}},382:(t,e)=>{function r(t,e){if("number"!=typeof t&&(t=Number(t),isNaN(t)))return NaN;let r="number"==typeof e?t.toFixed(e):t+"",i=r.match(/\./)?r.replace(/0+$/g,"").replace(/\.+$/g,""):r;return parseFloat(i)}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNumber=e.getAverage=e.symbolMap=void 0,e.symbolMap=function t(e,r,i=!1){const n=Object.keys(r);for(var o=0;o<n.length;o++)if(e.length>=n[o].length+3&&(e.endsWith(n[o])||e.startsWith(n[o]))){const a=e.replace(n[o],r[n[o]]);return i?t(a,r,!1):a}return e},e.getAverage=function(t){return t.length?t.flatMap((t=>Object.keys(t))).filter(((t,e,r)=>r.indexOf(t)==e)).reduce(((e,i)=>{let n=t.map((t=>t[i])).filter((t=>t)),o=r(n.reduce(((t,e)=>t+e),0)/n.length,8);return e[i]=o,e}),{}):{}},e.formatNumber=r},607:function(module,exports,__webpack_require__){var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const helpers_1=__webpack_require__(382),worker_1=__importStar(__webpack_require__(827)),custom_1=__importDefault(__webpack_require__(866)),CustomWorkers=new custom_1.default;function isEmpty(t){if(!t)return!0;for(var e in t)return!1;return!0}function getPrice(t,e="USD"){var r=CustomWorkers.ticker[t+e]||(CustomWorkers.ticker[e+t]?1/CustomWorkers.ticker[e+t]:null),i=worker_1.default.data.crypto.current[t+e]||(worker_1.default.data.crypto.current[e+t]?1/worker_1.default.data.crypto.current[e+t]:null);return r||i}const exchangeWrap=function(){const exchange={get isReady(){return worker_1.default.isReady},get list(){return{crypto:worker_1.default.list.crypto,fiat:worker_1.default.list.fiat}},get cryptoInfo(){return worker_1.default.cryptoInfo},get lastUpdated(){return worker_1.default.data.crypto.last_updated},get ticker(){return worker_1.default.data}},wrapper=function(t,e){var r=e;return function(e){if(isEmpty(worker_1.default.data.crypto.current)||isEmpty(worker_1.default.data.fiat.current))return console.warn("[~] Prices are loading.\nYou should use `await convert.ready()` to make sure prices are loaded before calling convert."),!1;if(!e)return!1;if(e=(0,helpers_1.formatNumber)(e),isNaN(e))return!1;const i=worker_1.default.data.fiat.current,n=worker_1.default.list.crypto.concat(CustomWorkers.list);if(r==t)return e;if(n.includes(t)&&n.includes(r)){let i=getPrice(t,r)||wrapper("USD",r)(wrapper(t,"USD")(1));return(0,helpers_1.formatNumber)(i*e,8)}if(i[t]&&i[r])return(0,helpers_1.formatNumber)(e/i[t]*i[r],4);var o=function(t){return getPrice(t)||wrapper("BTC","USD")(getPrice(t,"BTC"))||wrapper("ETH","USD")(getPrice(t,"ETH"))};if(i[r]){let n=o(t)/i.USD*i[r];return(0,helpers_1.formatNumber)(n*e,8)}if(i[t]){let n=o(r)/i.USD*i[t];return(0,helpers_1.formatNumber)(e/n,8)}return null}},initialize=function(){let types="";types+="type amount = (amount: number | string) => number | false | null;",types+="\nexport interface Pairs {";const all_currencies=worker_1.default.list.crypto.concat(worker_1.default.list.fiat,CustomWorkers.list);for(var i=0;i<all_currencies.length;i++){var coin=all_currencies[i];if(coin&&"string"==typeof coin){exchange[coin]||(exchange[coin]={}),types+=`\n\t'${coin.replace(/\'/g,"\\'")}': {`;for(var a=0;a<all_currencies.length;a++){var currency=all_currencies[a];currency&&"string"==typeof currency&&(exchange[coin][currency]=wrapper(coin,currency),types+=`\n\t\t'${currency.replace(/\'/g,"\\'")}': amount,`)}types+="\n},"}}types+="\n}","undefined"==typeof window&&"undefined"!=typeof process&&function(){__awaiter(this,void 0,void 0,(function*(){try{eval("\n\t\t\t\t\t\tconst fs = require('fs');\n\t\t\t\t\t\tconst path = require('path');\n\t\t\t\t\t\tconst isDist = path.basename(__dirname) == 'dist';\n\t\t\t\t\t\tconst typesFile = path.join(__dirname, isDist ? 'paris.d.ts' : 'paris.ts');\n\n\t\t\t\t\t\tfs.writeFileSync(typesFile, types, 'utf-8');\n\t\t\t\t\t")}catch(t){console.warn(t)}}))}()};return exchange.setOptions=function(t){let e=worker_1.default.setOptions(t);if((t.crypto_interval||t.fiat_interval)&&(t.crypto_interval!==worker_1.default.options.crypto_interval||t.fiat_interval!==worker_1.default.options.fiat_interval)){let t=e.restart();return exchange.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(t),exchange}))},t}return e},exchange.stop=function(){return worker_1.default.stop()},exchange.start=function(){let t=worker_1.default.restart();return exchange.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(t),exchange}))},t},exchange.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(worker_1.WorkerReady),yield Promise.resolve(CustomWorkers.ready()),exchange}))},exchange.addCurrency=(t,...e)=>{if(exchange.hasOwnProperty(t))throw new Error("This property already exists.");return Promise.resolve(CustomWorkers.addCurrency.apply(CustomWorkers,[t,...e])).then((()=>{worker_1.default.isReady&&initialize()}))},exchange.removeCurrency=(t,e)=>{var r,i;if(CustomWorkers.list.includes(t)){delete exchange[t];const e=worker_1.default.list.crypto.concat(worker_1.default.list.fiat,CustomWorkers.list);for(const n of e)(null===(r=exchange[n])||void 0===r?void 0:r[t])&&(null===(i=exchange[n])||void 0===i||delete i[t])}return CustomWorkers.removeCurrency(t,e)},Promise.resolve(worker_1.WorkerReady).then((()=>initialize())),exchange}(),convert=exchangeWrap;convert.default=convert,module.exports&&(module.exports=convert),exports.default=convert},827:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerReady=void 0;const o=n(r(203)),a=r(382),s="undefined"!=typeof window&&window.document;function l(t={}){this.exchanges=["binance","bitfinex","coinbase","kraken"],this.list={crypto:["BTC","ETH","USDT","USDC","BNB","XRP","BUSD","ADA","SOL","DOGE","DOT","DAI","MATIC","SHIB","TRX","AVAX","UNI","WBTC","LEO","LTC","ETC","LINK","ATOM","FTT","XLM","NEAR","CRO","XMR","ALGO","BCH","LUNC","FLOW","QNT","VET","TON","FIL","APE","ICP","CHZ","HBAR","MANA","XTZ","SAND","EOS","EGLD","THETA","AAVE","AXS","OKB","USDP","BSV","KCS","TUSD","ZEC","MIOTA","XEC","USDD","MKR","BTT","HT","GRT","USDN","HNT","CAKE","NEO","KLAY","FTM","SNX","PAXG","RUNE","NEXO","LDO","CRV","GT","DASH","ENJ","BAT","COMP","STX","KAVA","RVN","ZIL","WAVES","FEI","MINA","RSR","XDC","LRC","GMT","DCR","TWT","CELO","XEM","BTG","KSM","HOT","1INCH","CEL","CVX","BNX","AR","GNO","LUNA","ROSE","ENS","USTC","GUSD","QTUM","YFI","ANKR","TFUEL","GALA","GLM","IOTX","KDA","BTRST","ONE","OMG","BAL","ZRX","LPT","POLY","JST","FLUX","ICX","BORA","IOST","HIVE","AMP","OP","KNC","XYM","SRM","ONT","WAXP","STORJ","MXC","CSPR","IMX","SC","ZEN","AUDIO","GLMR","SXP","XCH","ABBC","CHSB","VGX","UMA","WOO"],fiat:["USD","JPY","BGN","CZK","DKK","GBP","HUF","PLN","RON","SEK","CHF","ISK","NOK","HRK","RUB","TRY","AUD","BRL","CAD","CNY","HKD","IDR","ILS","INR","KRW","MXN","MYR","NZD","PHP","SGD","THB","ZAR","EUR"]},this.cryptoInfo=[{id:1,title:"Bitcoin",symbol:"BTC",rank:1},{id:1027,title:"Ethereum",symbol:"ETH",rank:2},{id:825,title:"Tether",symbol:"USDT",rank:3},{id:3408,title:"USD Coin",symbol:"USDC",rank:4},{id:1839,title:"BNB",symbol:"BNB",rank:5},{id:52,title:"XRP",symbol:"XRP",rank:6},{id:4687,title:"Binance USD",symbol:"BUSD",rank:7},{id:2010,title:"Cardano",symbol:"ADA",rank:8},{id:5426,title:"Solana",symbol:"SOL",rank:9},{id:74,title:"Dogecoin",symbol:"DOGE",rank:10},{id:6636,title:"Polkadot",symbol:"DOT",rank:11},{id:4943,title:"Dai",symbol:"DAI",rank:12},{id:3890,title:"Polygon",symbol:"MATIC",rank:13},{id:5994,title:"Shiba Inu",symbol:"SHIB",rank:14},{id:1958,title:"TRON",symbol:"TRX",rank:15},{id:5805,title:"Avalanche",symbol:"AVAX",rank:16},{id:7083,title:"Uniswap",symbol:"UNI",rank:17},{id:3717,title:"Wrapped Bitcoin",symbol:"WBTC",rank:18},{id:3957,title:"UNUS SED LEO",symbol:"LEO",rank:19},{id:2,title:"Litecoin",symbol:"LTC",rank:20},{id:1321,title:"Ethereum Classic",symbol:"ETC",rank:21},{id:1975,title:"Chainlink",symbol:"LINK",rank:22},{id:3794,title:"Cosmos",symbol:"ATOM",rank:23},{id:4195,title:"FTX Token",symbol:"FTT",rank:24},{id:512,title:"Stellar",symbol:"XLM",rank:25},{id:6535,title:"NEAR Protocol",symbol:"NEAR",rank:26},{id:3635,title:"Cronos",symbol:"CRO",rank:27},{id:328,title:"Monero",symbol:"XMR",rank:28},{id:4030,title:"Algorand",symbol:"ALGO",rank:29},{id:1831,title:"Bitcoin Cash",symbol:"BCH",rank:30},{id:4172,title:"Terra Classic",symbol:"LUNC",rank:31},{id:4558,title:"Flow",symbol:"FLOW",rank:32},{id:3155,title:"Quant",symbol:"QNT",rank:33},{id:3077,title:"VeChain",symbol:"VET",rank:34},{id:11419,title:"Toncoin",symbol:"TON",rank:35},{id:2280,title:"Filecoin",symbol:"FIL",rank:36},{id:18876,title:"ApeCoin",symbol:"APE",rank:37},{id:8916,title:"Internet Computer",symbol:"ICP",rank:38},{id:4066,title:"Chiliz",symbol:"CHZ",rank:39},{id:4642,title:"Hedera",symbol:"HBAR",rank:40},{id:1966,title:"Decentraland",symbol:"MANA",rank:41},{id:2011,title:"Tezos",symbol:"XTZ",rank:42},{id:6210,title:"The Sandbox",symbol:"SAND",rank:43},{id:1765,title:"EOS",symbol:"EOS",rank:44},{id:6892,title:"Elrond",symbol:"EGLD",rank:45},{id:2416,title:"Theta Network",symbol:"THETA",rank:46},{id:7278,title:"Aave",symbol:"AAVE",rank:47},{id:6783,title:"Axie Infinity",symbol:"AXS",rank:48},{id:3897,title:"OKB",symbol:"OKB",rank:49},{id:3330,title:"Pax Dollar",symbol:"USDP",rank:50},{id:3602,title:"Bitcoin SV",symbol:"BSV",rank:51},{id:2087,title:"KuCoin Token",symbol:"KCS",rank:52},{id:2563,title:"TrueUSD",symbol:"TUSD",rank:53},{id:1437,title:"Zcash",symbol:"ZEC",rank:54},{id:1720,title:"IOTA",symbol:"MIOTA",rank:55},{id:10791,title:"eCash",symbol:"XEC",rank:56},{id:19891,title:"USDD",symbol:"USDD",rank:57},{id:1518,title:"Maker",symbol:"MKR",rank:58},{id:16086,title:"BitTorrent-New",symbol:"BTT",rank:59},{id:2502,title:"Huobi Token",symbol:"HT",rank:60},{id:6719,title:"The Graph",symbol:"GRT",rank:61},{id:5068,title:"Neutrino USD",symbol:"USDN",rank:62},{id:5665,title:"Helium",symbol:"HNT",rank:63},{id:7186,title:"PancakeSwap",symbol:"CAKE",rank:64},{id:1376,title:"Neo",symbol:"NEO",rank:65},{id:4256,title:"Klaytn",symbol:"KLAY",rank:66},{id:3513,title:"Fantom",symbol:"FTM",rank:67},{id:2586,title:"Synthetix",symbol:"SNX",rank:68},{id:4705,title:"PAX Gold",symbol:"PAXG",rank:69},{id:4157,title:"THORChain",symbol:"RUNE",rank:70},{id:2694,title:"Nexo",symbol:"NEXO",rank:71},{id:8e3,title:"Lido DAO",symbol:"LDO",rank:72},{id:6538,title:"Curve DAO Token",symbol:"CRV",rank:73},{id:4269,title:"GateToken",symbol:"GT",rank:74},{id:131,title:"Dash",symbol:"DASH",rank:75},{id:2130,title:"Enjin Coin",symbol:"ENJ",rank:76},{id:1697,title:"Basic Attention Token",symbol:"BAT",rank:77},{id:5692,title:"Compound",symbol:"COMP",rank:78},{id:4847,title:"Stacks",symbol:"STX",rank:79},{id:4846,title:"Kava",symbol:"KAVA",rank:80},{id:2577,title:"Ravencoin",symbol:"RVN",rank:81},{id:2469,title:"Zilliqa",symbol:"ZIL",rank:82},{id:1274,title:"Waves",symbol:"WAVES",rank:83},{id:8642,title:"Fei USD",symbol:"FEI",rank:84},{id:8646,title:"Mina",symbol:"MINA",rank:85},{id:3964,title:"Reserve Rights",symbol:"RSR",rank:86},{id:2634,title:"XDC Network",symbol:"XDC",rank:87},{id:1934,title:"Loopring",symbol:"LRC",rank:88},{id:18069,title:"STEPN",symbol:"GMT",rank:89},{id:1168,title:"Decred",symbol:"DCR",rank:90},{id:5964,title:"Trust Wallet Token",symbol:"TWT",rank:91},{id:5567,title:"Celo",symbol:"CELO",rank:92},{id:873,title:"NEM",symbol:"XEM",rank:93},{id:2083,title:"Bitcoin Gold",symbol:"BTG",rank:94},{id:5034,title:"Kusama",symbol:"KSM",rank:95},{id:2682,title:"Holo",symbol:"HOT",rank:96},{id:8104,title:"1inch Network",symbol:"1INCH",rank:97},{id:2700,title:"Celsius",symbol:"CEL",rank:98},{id:9903,title:"Convex Finance",symbol:"CVX",rank:99},{id:9891,title:"BinaryX",symbol:"BNX",rank:100},{id:5632,title:"Arweave",symbol:"AR",rank:101},{id:1659,title:"Gnosis",symbol:"GNO",rank:102},{id:20314,title:"Terra",symbol:"LUNA",rank:103},{id:7653,title:"Oasis Network",symbol:"ROSE",rank:104},{id:13855,title:"Ethereum Name Service",symbol:"ENS",rank:105},{id:7129,title:"TerraClassicUSD",symbol:"USTC",rank:106},{id:3306,title:"Gemini Dollar",symbol:"GUSD",rank:107},{id:1684,title:"Qtum",symbol:"QTUM",rank:108},{id:5864,title:"yearn.finance",symbol:"YFI",rank:109},{id:3783,title:"Ankr",symbol:"ANKR",rank:110},{id:3822,title:"Theta Fuel",symbol:"TFUEL",rank:111},{id:7080,title:"Gala",symbol:"GALA",rank:112},{id:1455,title:"Golem",symbol:"GLM",rank:113},{id:2777,title:"IoTeX",symbol:"IOTX",rank:114},{id:5647,title:"Kadena",symbol:"KDA",rank:115},{id:11584,title:"Braintrust",symbol:"BTRST",rank:116},{id:3945,title:"Harmony",symbol:"ONE",rank:117},{id:1808,title:"OMG Network",symbol:"OMG",rank:118},{id:5728,title:"Balancer",symbol:"BAL",rank:119},{id:1896,title:"0x",symbol:"ZRX",rank:120},{id:3640,title:"Livepeer",symbol:"LPT",rank:121},{id:2496,title:"Polymath",symbol:"POLY",rank:122},{id:5488,title:"JUST",symbol:"JST",rank:123},{id:3029,title:"Flux",symbol:"FLUX",rank:124},{id:2099,title:"ICON",symbol:"ICX",rank:125},{id:3801,title:"BORA",symbol:"BORA",rank:126},{id:2405,title:"IOST",symbol:"IOST",rank:127},{id:5370,title:"Hive",symbol:"HIVE",rank:128},{id:6945,title:"Amp",symbol:"AMP",rank:129},{id:11840,title:"Optimism",symbol:"OP",rank:130},{id:9444,title:"Kyber Network Crystal v2",symbol:"KNC",rank:131},{id:8677,title:"Symbol",symbol:"XYM",rank:132},{id:6187,title:"Serum",symbol:"SRM",rank:133},{id:2566,title:"Ontology",symbol:"ONT",rank:134},{id:2300,title:"WAX",symbol:"WAXP",rank:135},{id:1772,title:"Storj",symbol:"STORJ",rank:136},{id:3628,title:"MXC",symbol:"MXC",rank:137},{id:5899,title:"Casper",symbol:"CSPR",rank:138},{id:10603,title:"Immutable X",symbol:"IMX",rank:139},{id:1042,title:"Siacoin",symbol:"SC",rank:140},{id:1698,title:"Horizen",symbol:"ZEN",rank:141},{id:7455,title:"Audius",symbol:"AUDIO",rank:142},{id:6836,title:"Moonbeam",symbol:"GLMR",rank:143},{id:4279,title:"SXP",symbol:"SXP",rank:144},{id:9258,title:"Chia",symbol:"XCH",rank:145},{id:3437,title:"ABBC Coin",symbol:"ABBC",rank:146},{id:2499,title:"SwissBorg",symbol:"CHSB",rank:147},{id:1817,title:"Voyager Token",symbol:"VGX",rank:148},{id:5617,title:"UMA",symbol:"UMA",rank:149},{id:7501,title:"WOO Network",symbol:"WOO",rank:150}].reduce(((t,e)=>(t[e.symbol]=Object.assign(Object.assign({},t),{logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`}),t)),{}),this.data={crypto:{last_updated:null,current:null},fiat:{last_updated:null,current:null}},this.options=Object.assign(Object.assign({crypto_interval:s?15e3:5e3,fiat_interval:36e5,calculateAverage:!0,onUpdate:void 0},this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:!0})),{})),t),this.log=function(){var t,e;!s&&(null===(e=null===(t=null===process||void 0===process?void 0:process.env)||void 0===t?void 0:t.NODE_ENV)||void 0===e?void 0:e.startsWith("dev"))&&Array.from(arguments).forEach((t=>{console.log(t)}))},this.isReady=!1}l.prototype.setOptions=function(t){let e="function"==typeof t?t(Object.assign({},this.options)):t||{};s&&!isNaN(e.crypto_interval)&&e.crypto_interval<1e4&&console.warn("The minimum allowed interval on frontend is 10s.");let r=!1,i=e.hasOwnProperty("calculateAverage")&&e.calculateAverage!==this.options.calculateAverage;for(const t of this.exchanges)if(e.hasOwnProperty(t)&&e[t]!==this.options[t]){r=!0;break}if(this.options=Object.assign(Object.assign(Object.assign({},this.options),e),{crypto_interval:isNaN(e.crypto_interval)?this.options.crypto_interval:Math.max(s?1e4:1e3,e.crypto_interval),fiat_interval:isNaN(e.fiat_interval)?this.options.fiat_interval:Math.max(18e5,e.fiat_interval)}),s){if(r||i)return this.browserTicker()}else this.data.crypto.current=this.joinPrices(this.data);return this},l.prototype.updateCrypto=function(){return i(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating crypto...");const t=this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:o.default[e].ticker})),{});let e=[],r={};for(const i in t)try{this.data.crypto[i]=yield t[i](),this.options[i]&&(e.push(this.data.crypto[i]),r=Object.assign(Object.assign({},r),this.data.crypto[i]),this.data.crypto.last_updated=+new Date)}catch(t){this.data.crypto[i]=null,console.error(`Failed fetching prices from ${i}`,t)}return e.length&&(this.data.crypto.current=this.options.calculateAverage?Object.assign(Object.assign({},r),(0,a.getAverage)(e)):r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.crypto)),this}))},l.prototype.updateFiat=function(){return i(this,void 0,void 0,(function*(){this.log("Updating fiat...");try{this.data.fiat.current=yield o.default.fiat.all(),this.data.fiat.last_updated=+new Date,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.fiat,!0)}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},l.prototype.updateLists=function(){return i(this,void 0,void 0,(function*(){this.log("Updating top currency list...");try{const t=yield o.default.coinmarketcap.top();this.list.crypto=Object.keys(t),this.cryptoInfo=t}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},l.prototype.joinPrices=function(t){const e=this.exchanges.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:t.crypto[r]})),{});let r=[],i={};for(const t in e)this.options[t]&&e[t]&&(r.push(e[t]),i=Object.assign(Object.assign({},i),e[t]));return this.options.calculateAverage?Object.assign(Object.assign({},i),(0,a.getAverage)(r)):i},l.prototype.browserTicker=function(){return i(this,void 0,void 0,(function*(){try{const t=this.options,e=this.exchanges.filter((e=>!t[e])),r=yield o.default.coinconvert.ticker(e.length?{filterExchanges:e,noAverage:!this.options.calculateAverage||void 0}:{});this.data=r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data)}catch(t){console.error("Failed fetching prices from API",t)}return this}))},l.prototype.runBrowser=function(){var t,e;return i(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&window.__ccRunning)throw new Error("The crypto-convert worker seems to be already running. \n\t\t\t- There might be an issue with the way your app imports javascript dependencies. \n\t\t\t- Make sure to call 'convert.stop()' on component unmounts if you are using SPA frameworks (e.g React).");if(!(null===(e=null===(t=this.data)||void 0===t?void 0:t.crypto)||void 0===e?void 0:e.current)){yield this.browserTicker();const t=yield o.default.coinconvert.list();this.list.crypto=Object.keys(t.crypto),this.list.fiat=t.fiat,this.cryptoInfo=t.crypto}return this.isReady=!0,this.crypto_worker&&clearInterval(this.crypto_worker),this.crypto_worker=setInterval(this.browserTicker.bind(this),this.options.crypto_interval),"undefined"!=typeof window&&(window.__ccRunning=!0,window.__ccRunID&&clearInterval(window.__ccRunID),window.__ccRunID=this.crypto_worker),this}))},l.prototype.runServer=function(){return i(this,void 0,void 0,(function*(){return yield this.updateLists(),yield this.updateFiat(),yield this.updateCrypto(),this.isReady=!0,this.crypto_worker=setInterval(this.updateCrypto.bind(this),this.options.crypto_interval),this.fiat_worker=setInterval(this.updateFiat.bind(this),this.options.fiat_interval),this}))},l.prototype.run=function(){return this.isRunning=!0,s?this.runBrowser():this.runServer()},l.prototype.stop=function(){return clearInterval(this.crypto_worker),clearInterval(this.fiat_worker),this.isRunning=!1,"undefined"!=typeof window&&(window.__ccRunning=!1),this},l.prototype.restart=function(){return this.stop().run()};const c=new l;e.WorkerReady=c.run(),e.default=c},88:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__88__},265:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__265__}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(607);return __webpack_exports__})()));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("FormData"),require("fetch")):"function"==typeof define&&define.amd?define(["FormData","fetch"],e):"object"==typeof exports?exports.convert=e(require("FormData"),require("fetch")):t.convert=e(t.FormData,t.fetch)}(this,((__WEBPACK_EXTERNAL_MODULE__88__,__WEBPACK_EXTERNAL_MODULE__265__)=>(()=>{"use strict";var __webpack_modules__={945:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))};function n(t,e){const o="undefined"!=typeof window?null===window||void 0===window?void 0:window.fetch:r(265),a="undefined"!=typeof window?null===window||void 0===window?void 0:window.FormData:r(88);if(!o)throw new Error("Fetch API is not installed. If you are using Node please run `npm install node-fetch`");if(!a)throw new Error("FormData is not installed. If you are using Node please run `npm install form-data`");const s=t=>Object.assign(Object.assign({},t),{headers:Object.assign({},t.headers),params:Object.assign({},t.params),values:Object.assign({},t.values)}),l=t=>{var e,r;if("Object"!=(null===(r=null===(e=null==t?void 0:t.__proto__)||void 0===e?void 0:e.constructor)||void 0===r?void 0:r.name))throw new Error("Invalid $options object.");let i=s(t.$options||{});return delete t.$options,Object.assign(Object.assign({},i),{values:Object.assign(Object.assign({},i.values),t)})},c=(t,e,r=!1)=>{let i=r?t||{}:s(t||{}),n=s(e||{});return n.headers=Object.assign(Object.assign({},i.headers),n.headers),n.params=Object.assign(Object.assign({},i.params),n.params),n.values=Object.assign(Object.assign({},i.values),n.values),Object.assign(i,n),i};t=Object.assign({},t);let u={base:"",headers:{"User-Agent":"Rests JS (v1.1.0)"},params:{},values:{},on_error:void 0,on_success:void 0,on_request:void 0,fetch_agent:null};c(u,(null==t?void 0:t.$options)||{},!0),c(u,e,!0);const d={json:"application/json",form:"multipart/form-data",urlencoded:"application/x-www-form-urlencoded",text:"text/plain"},p=Object.values(d),y=["headers","body","query","path"],f={POST:"body",GET:"query"},m={"multipart/form-data":function(){var t=new a;return t.toString=function(){return this},t},"application/x-www-form-urlencoded":function(){return new URLSearchParams},"application/json":function(){return{append:function(t,e){this.data=this.data||{},this.data[t]=e},toString:function(){return JSON.stringify(this.data)},isEmpty:function(){return!this.data||0==Object.keys(this.data).length}}},"text/plain":function(){return{append:function(t,e){return this.data=this.data||[],this.data.push(e)},toString:function(){return this.data.join("")},isEmpty:function(){return!this.data||0==this.data.length}}}},h=t=>null==t,b=(...t)=>{for(var e=0;e<t.length;e++)if(null!==t[e]&&void 0!==t[e])return t[e];return null},v=(t,e,r,n)=>i(this,void 0,void 0,(function*(){return o(t,e).then((function(t){var e;return i(this,void 0,void 0,(function*(){try{var i=t.headers.get("Content-Type")||"";let o;try{o=t.type}catch(t){}let a={statusCode:t.status,statusText:t.statusText,headers:t.headers,type:o,ok:t.ok},s={"application/json":"json","text/plain":"text","(multipart/form-data|application/x-www-form-urlencoded)":"formData",blob:"blob",text:"text"},l=Object.keys(s).find((t=>new RegExp(t).test(i)))||"text";if(a[s[l]]=yield t[s[l]](),a.message=(null===(e=null==a?void 0:a.json)||void 0===e?void 0:e.message)||(t.ok?"Success.":"Something went wrong."),!t.ok)throw a;if(r.on_success){let t=r.on_success(a,n);if(void 0!==t)return t}return a}catch(t){if(r.on_error){let e=r.on_error(t,n);if(void 0!==e)return e}return Promise.reject(t)}}))}))}));function _(t,e,r){t.method=(t.method||"get").toUpperCase(),t.params=t.params||{};const n=function(o){var a,s,l,k,w,g;return i(this,void 0,void 0,(function*(){if(this instanceof n)throw new Error("This is an endpoint, you can't initialize this.");var i=c(u,e);i.on_request=t.on_request||i.on_request,i.on_success=t.on_success||i.on_success,i.on_error=t.on_error||i.on_error;var O=`${i.base}${t.path}`;((null==o?void 0:o.$sandbox)||(null===(a=null==i?void 0:i.values)||void 0===a?void 0:a.$sandbox))&&(O=`${i.sandboxBase||i.base}${t.path}`);var T,C,A={method:t.method,headers:Object.assign({},i.headers),agent:i.fetch_agent},E=p.includes(t.enctype)?t.enctype:d[t.enctype||"json"],S=Object.assign({},i.params,t.params),N=m[E](),D=new URLSearchParams;for(var R in"FormData"==(null===(s=null==o?void 0:o.constructor)||void 0===s?void 0:s.name)?(T=o,o=Object.fromEntries(Array.from(T.keys(),(t=>t.endsWith("[]")?[t.slice(0,-2),T.getAll(t)]:[t,T.get(t)])))):o=o||{},S){var P=S[R],j=o[R],U=null===(l=null==i?void 0:i.values)||void 0===l?void 0:l[R],x=P.default,M=(null==o?void 0:o.$sandbox)||(null===(k=null==i?void 0:i.values)||void 0===k?void 0:k.$sandbox)?P.example:void 0,B=b(j,U,M,x),X=P.name||R,L=P.help||`The '${R}' field is invalid.`;if(P.required&&h(B))throw(I=new Error(L)).field=R,I;if(!h(B)){if("function"==typeof P.format)try{B=P.format(B)}catch(t){throw(I=new Error(t.message||L)).field=R,I}if(P.type&&"any"!==P.type&&((I=new Error(L)).field=R,["string","boolean","number"].includes(P.type)&&typeof B!=P.type||"array"==P.type&&!Array.isArray(B)||"object"==P.type&&(!B||"Object"!==B.__proto__.constructor.name)))throw I;if(P.validate&&("RegExp"==(null===(g=null===(w=P.validate)||void 0===w?void 0:w.constructor)||void 0===g?void 0:g.name)&&(P.validate.toJSON=function(){return P.validate.toString().replace(/^\//g,"").replace(/\/$/g,"")}),!new RegExp(P.validate).test(B)))throw(I=new Error(L)).field=R,I;if("number"==P.type){var I;if(P.hasOwnProperty("max")&&!isNaN(P.max)&&Number(B)>Number(P.max))throw(I=new Error(`The maximum allowed value allowed for the ${X} parameter is ${P.max}`)).field=R,I;if(P.hasOwnProperty("min")&&!isNaN(P.min)&&Number(B)<Number(P.min))throw(I=new Error(`The minimum allowed value allowed for the ${X} parameter is ${P.min}`)).field=R,I}if(P.in&&Array.isArray(P.in)&&!P.in.includes(B))throw(I=new Error(`The ${X} parameter should be one of these values: ${P.in}`)).field=R,I;var $="string"==typeof P.location?P.location.toLowerCase():f[A.method];if(!$||!y.includes($))throw new Error(`Invalid location for '${R}' field.`);"headers"!=$?"body"!=$?"query"!=$?"path"==$&&(O=O.replace(new RegExp(`{${(C=X,C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).trim()}}`),B)):D.append(X,B):N.append(X,B):(A.headers=A.headers||{},A.headers[X]=B)}}var F=D.toString();F&&(O=`${O}?${F}`),N.keys&&(t=>{for(var e of t)return!1;return!0})(N.keys())||N.getLengthSync&&0==N.getLengthSync()||N.isEmpty&&N.isEmpty()||(A.body=N.toString()),A.body&&"multipart/form-data"!==E&&(A.headers=A.headers||{},A.headers["Content-Type"]=E);let H={url:O,options:A,params:o,key:r,instance:u.__$root_instance__,self:_(t,e,r)};if(i.on_request){var G=yield Promise.resolve(i.on_request(H));if(G){if(!(null==G?void 0:G.url)&&!(null==G?void 0:G.options))return G;O=G.url||O,A=G.options||A}if(!1===G)return!1}return v(O,A,i,H)}))};return n}function k(e,r,i,o){var a={[e=e||"Rests"]:function(s){if(!(this instanceof a[e]))throw new Error("This is a category, you can initalize this category to update values using 'new' command.");if(o)throw new Error("This is already initialized, you can use 'set' instead.");let d=c(u,r),p=l(s),y=c(d,p);return n(i?(f=t,i.split(".").reduce(((t,e)=>null==t?void 0:t[e]),f)):t,y);var f}};return o&&(a[e].set=function(t){if(this instanceof a[e].set)throw new Error("The set object can't be initialized.");let r=l(t);return c(u,r,!0),a[e]}),a[e]}const w=Object.defineProperty(k("Rests",u,void 0,!0),"__schema__",{value:{schema:t,options:u},writable:!1,enumerable:!1});return u.__$root_instance__=w,function t(e,r,i,n){for(var o in r){var a=r[o];if(!a||"object"!=typeof a)continue;if(void 0!==e[o]){console.warn(`Skipping ${o} as it confilicts with another key in the object`);continue}let l=`${n?n+".":""}${o}`;if(a.hasOwnProperty("path")){var s=a;e[o]=_(s,i,l)}else{if("$"===o.substr(0,1))continue;let r=i;(null==a?void 0:a.$options)&&(r=c(i,null==a?void 0:a.$options)),e[o]=t(k(o,r,l),a,r,l)}}return e}(w,t,{})}Object.defineProperty(e,"__esModule",{value:!0}),n.default=n,e.default=n,t.exports=n},203:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(945)),a=r(382);let s,l;const c=(0,o.default)({binance:{$options:{base:"https://api.binance.com/api/v3"},bookTicker:{path:"/ticker/bookTicker",on_success:t=>t.json},ticker:{path:"/ticker/price",on_request(t){return i(this,void 0,void 0,(function*(){if(!l){const e=yield t.instance.binance.bookTicker();l=e.map((t=>parseFloat(t.askPrice)<=0&&t.symbol)).filter((t=>t))}}))},on_success(t,e){const r={USDT:"USD",USDC:"USD",BUSD:"USD"},i=t.json;if(!i||!Array.isArray(i))throw new Error(`Invalid response from Binance: ${JSON.stringify(i)}`);return i.reduce(((t,e)=>{if(l&&-1!==l.indexOf(e.symbol))return t;const i=(0,a.symbolMap)(e.symbol,r),n=parseFloat(e.price);return t[i]=n,t}),{})}}},bitfinex:{$options:{base:"https://api-pub.bitfinex.com/v2"},ticker:{path:"/tickers",params:{symbols:{help:"The symbols you want information about as a comma separated list, or ALL for every symbol. (Examples of possible symbols: tBTCUSD, tETHUSD, fUSD, fBTC)",default:"ALL",type:"string"}},on_success:function(t){const e={BAB:"BCH",DSH:"DASH"},r=t.json;if(!r||!Array.isArray(r))throw new Error(`Invalid response from Bitfinex: ${JSON.stringify(r)}`);return r.reduce(((t,r)=>{if(!r[0].startsWith("t"))return t;const i=(0,a.symbolMap)(r[0].replace(/^t/,""),e,!0).replace(":",""),n=parseFloat(r[7]);return t[i]=n,t}),{})}}},coinbase:{$options:{base:"https://api.coinbase.com/v2"},ticker:{path:"/exchange-rates",params:{currency:{help:"The exchange currency (default USD)"}},on_success:t=>{var e;const r=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.data;if(!r)throw new Error(`Invalid response from Coinbase: ${r}`);return Object.keys(r.rates).reduce(((t,e,i)=>{const n=e+r.currency,o=(0,a.formatNumber)(1/parseFloat(r.rates[e]),8);return t[n]=o,t}),{})}}},kraken:{$options:{base:"https://api.kraken.com/0/public"},pairs:{path:"/AssetPairs",on_success:t=>Object.keys(t.json.result)},ticker:{path:"/Ticker",on_request:t=>i(void 0,void 0,void 0,(function*(){if(!s){const e=yield t.instance.kraken.pairs();s=e}return{url:t.url+"?pair="+s}})),on_success:t=>{var e;const r={XETC:"ETC",XETH:"ETH",XLTC:"LTC",XMLN:"MLN",XREP:"REP",XXBT:"BTC",XXDG:"XDG",XXLM:"XLM",XXMR:"XMR",XXRP:"XRP",XZEC:"ZEC",XBT:"BTC",ZAUD:"AUD",ZEUR:"EUR",ZGBP:"GBP",ZUSD:"USD",ZCAD:"CAD",ZJPY:"JPY"},i=null===(e=t.json)||void 0===e?void 0:e.result;if(!i)throw new Error(`Invalid response from Kraken: ${JSON.stringify(i)}`);return Object.keys(i).reduce(((t,e)=>{const n=(0,a.symbolMap)(e,r,!0),o=parseFloat(i[e].c[0]);return t[n]=o,t}),{})}}},coinmarketcap:{$options:{base:"https://api.coinmarketcap.com/data-api/v3"},top:{path:"/map/all",params:{limit:{default:"150"},listing_status:{default:"active"}},on_success:function(t){const e=t.json;if(!e||!e.data||!Array.isArray(e.data.cryptoCurrencyMap))throw new Error(`Invalid response from CoinMarketCap: ${JSON.stringify(e)}`);return e.data.cryptoCurrencyMap.reduce(((t,e)=>(t[e.symbol]={id:e.id,title:e.name,symbol:e.symbol,logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`,rank:e.rank},t)),{})}}},fiat:{all:{path:"https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml",on_success:function(t){var e=t.text,r=e.match(/(?<=currency=["'])([A-Za-z]+)/gi),i=e.match(/(?<=rate=["'])([.0-9]+)/gi),n=r.reduce(((t,e,r)=>Object.assign(Object.assign({},t),{[e]:i[r]})),{});return n.EUR=1,n}}},coinconvert:{$options:{base:"https://api.coinconvert.net"},ticker:{path:"/v2/ticker",params:{v:{default:"2.0.5"},filterExchanges:{type:"array"},noAverage:{type:"boolean"}},on_success:t=>t.json},list:{path:"/v2/list?v=2.0.5",on_success:t=>t.json}}});e.default=c},866:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(827));e.default=class{constructor(){this.ticker={},this.list=[],this.workers={},this.workersPromises=[]}ready(){return i(this,void 0,void 0,(function*(){return Promise.all(this.workersPromises)}))}addCurrency(t,e,r,n){return i(this,void 0,void 0,(function*(){if("string"!=typeof t||"string"!=typeof e||!o.default.list.fiat.includes(e))throw new Error("Invalid currency pair.");if("function"!=typeof r)throw new Error("No function specified.");if(t=t.toUpperCase(),e=e.toUpperCase(),(this.ticker[t+e]||this.ticker[e+t]||-1!=this.list.indexOf(t))&&(console.warn("This custom currency already exists, it will be overriden."),this.removeCurrency(t)),this.list.push(t),n){if("number"!=typeof n)throw new Error("Invalid interval specfied.");this.workers[t+e]=setInterval((()=>Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}))),n)}const i=Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}));return this.workersPromises.push(i),i}))}removeCurrency(t,e){t=t.toUpperCase(),e=e?e.toUpperCase():"";for(const r in this.workers)r.includes(t+e)&&(clearInterval(this.workers[r]),delete this.ticker[r]);this.list=this.list.filter((e=>e!==t))}}},382:(t,e)=>{function r(t,e){if("number"!=typeof t&&(t=Number(t),isNaN(t)))return NaN;let r="number"==typeof e?t.toFixed(e):t+"",i=r.match(/\./)?r.replace(/0+$/g,"").replace(/\.+$/g,""):r;return parseFloat(i)}Object.defineProperty(e,"__esModule",{value:!0}),e.isEmpty=e.formatNumber=e.getAverage=e.symbolMap=void 0,e.symbolMap=function t(e,r,i=!1){const n=Object.keys(r);for(var o=0;o<n.length;o++)if(e.length>=n[o].length+3&&(e.endsWith(n[o])||e.startsWith(n[o]))){const a=e.replace(n[o],r[n[o]]);return i?t(a,r,!1):a}return e},e.getAverage=function(t){return t.length?t.flatMap((t=>Object.keys(t))).filter(((t,e,r)=>r.indexOf(t)==e)).reduce(((e,i)=>{let n=t.map((t=>t[i])).filter((t=>t)),o=r(n.reduce(((t,e)=>t+e),0)/n.length,8);return e[i]=o,e}),{}):{}},e.formatNumber=r,e.isEmpty=function(t){if(!t)return!0;for(var e in t)return!1;return!0}},607:function(module,exports,__webpack_require__){var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const helpers_1=__webpack_require__(382),worker_1=__importStar(__webpack_require__(827)),custom_1=__importDefault(__webpack_require__(866)),CustomWorkers=new custom_1.default,ConvertObject=function(){const convert={get isReady(){return worker_1.default.isReady},get list(){return{crypto:worker_1.default.list.crypto.concat(CustomWorkers.list),fiat:worker_1.default.list.fiat}},get cryptoInfo(){return worker_1.default.cryptoInfo},get lastUpdated(){return worker_1.default.data.crypto.last_updated},get ticker(){return worker_1.default.data}},getPrice=function(t,e="USD"){var r=CustomWorkers.ticker[t+e]||(CustomWorkers.ticker[e+t]?1/CustomWorkers.ticker[e+t]:null),i=worker_1.default.data.crypto.current[t+e]||(worker_1.default.data.crypto.current[e+t]?1/worker_1.default.data.crypto.current[e+t]:null);return r||i},wrapper=function(t,e){var r=e;return function(e){if((0,helpers_1.isEmpty)(worker_1.default.data.crypto.current)||(0,helpers_1.isEmpty)(worker_1.default.data.fiat.current))return console.warn("[~] Prices are loading.\nYou should use `await convert.ready()` to make sure prices are loaded before calling convert."),!1;if(!e)return!1;if(e=(0,helpers_1.formatNumber)(e),isNaN(e))return!1;const i=worker_1.default.data.fiat.current,n=worker_1.default.list.crypto.concat(CustomWorkers.list);if(r==t)return e;if(n.includes(t)&&n.includes(r)){let i=getPrice(t,r)||wrapper("USD",r)(wrapper(t,"USD")(1));return(0,helpers_1.formatNumber)(i*e,8)}if(i[t]&&i[r])return(0,helpers_1.formatNumber)(e/i[t]*i[r],4);var o=function(t){return getPrice(t)||wrapper("BTC","USD")(getPrice(t,"BTC"))||wrapper("ETH","USD")(getPrice(t,"ETH"))};if(i[r]){let n=o(t)/i.USD*i[r];return(0,helpers_1.formatNumber)(n*e,8)}if(i[t]){let n=o(r)/i.USD*i[t];return(0,helpers_1.formatNumber)(e/n,8)}return null}},initialize=function(){let types="";types+="type amount = (amount: number | string) => number | false | null;",types+="\nexport interface Pairs {";const all_currencies=worker_1.default.list.crypto.concat(worker_1.default.list.fiat,CustomWorkers.list);for(var i=0;i<all_currencies.length;i++){var coin=all_currencies[i];if(coin&&"string"==typeof coin){convert[coin]||(convert[coin]={}),types+=`\n\t'${coin.replace(/\'/g,"\\'")}': {`;for(var a=0;a<all_currencies.length;a++){var currency=all_currencies[a];currency&&"string"==typeof currency&&(convert[coin][currency]=wrapper(coin,currency),types+=`\n\t\t'${currency.replace(/\'/g,"\\'")}': amount,`)}types+="\n},"}}types+="\n}","undefined"==typeof window&&"undefined"!=typeof process&&function(){__awaiter(this,void 0,void 0,(function*(){try{eval("\n\t\t\t\t\t\tconst fs = require('fs');\n\t\t\t\t\t\tconst path = require('path');\n\t\t\t\t\t\tconst isDist = path.basename(__dirname) == 'dist';\n\t\t\t\t\t\tconst typesFile = path.join(__dirname, isDist ? 'paris.d.ts' : 'paris.ts');\n\n\t\t\t\t\t\tfs.writeFileSync(typesFile, types, 'utf-8');\n\t\t\t\t\t")}catch(t){console.warn(t)}}))}()};return convert.setOptions=function(t){let e=worker_1.default.setOptions(t);if((t.crypto_interval||t.fiat_interval)&&(t.crypto_interval!==worker_1.default.options.crypto_interval||t.fiat_interval!==worker_1.default.options.fiat_interval)){let t=e.restart();return convert.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(t),yield Promise.resolve(CustomWorkers.ready()),convert}))},t}return e},convert.stop=function(){return worker_1.default.stop()},convert.start=function(){let t=worker_1.default.restart();return convert.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(t),yield Promise.resolve(CustomWorkers.ready()),convert}))},t},convert.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(worker_1.WorkerReady),yield Promise.resolve(CustomWorkers.ready()),convert}))},convert.addCurrency=(t,...e)=>{if(convert.hasOwnProperty(t))throw new Error("This property already exists.");return Promise.resolve(CustomWorkers.addCurrency.apply(CustomWorkers,[t,...e])).then((()=>{worker_1.default.isReady&&initialize()}))},convert.removeCurrency=(t,e)=>{var r,i;if(CustomWorkers.list.includes(t)){delete convert[t];const e=worker_1.default.list.crypto.concat(worker_1.default.list.fiat,CustomWorkers.list);for(const n of e)(null===(r=convert[n])||void 0===r?void 0:r[t])&&(null===(i=convert[n])||void 0===i||delete i[t])}return CustomWorkers.removeCurrency(t,e)},Promise.resolve(worker_1.WorkerReady).then((()=>initialize())),convert}(),convert=ConvertObject;convert.default=convert,module.exports&&(module.exports=convert),exports.default=convert},827:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerReady=void 0;const o=n(r(203)),a=r(382),s="undefined"!=typeof window&&window.document;function l(t={}){this.exchanges=["binance","bitfinex","coinbase","kraken"],this.list={crypto:["BTC","ETH","USDT","USDC","BNB","XRP","BUSD","ADA","SOL","DOGE","DOT","DAI","MATIC","SHIB","TRX","AVAX","UNI","WBTC","LEO","LTC","ETC","LINK","ATOM","FTT","XLM","NEAR","CRO","XMR","ALGO","BCH","LUNC","FLOW","QNT","VET","TON","FIL","APE","ICP","CHZ","HBAR","MANA","XTZ","SAND","EOS","EGLD","THETA","AAVE","AXS","OKB","USDP","BSV","KCS","TUSD","ZEC","MIOTA","XEC","USDD","MKR","BTT","HT","GRT","USDN","HNT","CAKE","NEO","KLAY","FTM","SNX","PAXG","RUNE","NEXO","LDO","CRV","GT","DASH","ENJ","BAT","COMP","STX","KAVA","RVN","ZIL","WAVES","FEI","MINA","RSR","XDC","LRC","GMT","DCR","TWT","CELO","XEM","BTG","KSM","HOT","1INCH","CEL","CVX","BNX","AR","GNO","LUNA","ROSE","ENS","USTC","GUSD","QTUM","YFI","ANKR","TFUEL","GALA","GLM","IOTX","KDA","BTRST","ONE","OMG","BAL","ZRX","LPT","POLY","JST","FLUX","ICX","BORA","IOST","HIVE","AMP","OP","KNC","XYM","SRM","ONT","WAXP","STORJ","MXC","CSPR","IMX","SC","ZEN","AUDIO","GLMR","SXP","XCH","ABBC","CHSB","VGX","UMA","WOO"],fiat:["USD","JPY","BGN","CZK","DKK","GBP","HUF","PLN","RON","SEK","CHF","ISK","NOK","HRK","RUB","TRY","AUD","BRL","CAD","CNY","HKD","IDR","ILS","INR","KRW","MXN","MYR","NZD","PHP","SGD","THB","ZAR","EUR"]},this.cryptoInfo=[{id:1,title:"Bitcoin",symbol:"BTC",rank:1},{id:1027,title:"Ethereum",symbol:"ETH",rank:2},{id:825,title:"Tether",symbol:"USDT",rank:3},{id:3408,title:"USD Coin",symbol:"USDC",rank:4},{id:1839,title:"BNB",symbol:"BNB",rank:5},{id:52,title:"XRP",symbol:"XRP",rank:6},{id:4687,title:"Binance USD",symbol:"BUSD",rank:7},{id:2010,title:"Cardano",symbol:"ADA",rank:8},{id:5426,title:"Solana",symbol:"SOL",rank:9},{id:74,title:"Dogecoin",symbol:"DOGE",rank:10},{id:6636,title:"Polkadot",symbol:"DOT",rank:11},{id:4943,title:"Dai",symbol:"DAI",rank:12},{id:3890,title:"Polygon",symbol:"MATIC",rank:13},{id:5994,title:"Shiba Inu",symbol:"SHIB",rank:14},{id:1958,title:"TRON",symbol:"TRX",rank:15},{id:5805,title:"Avalanche",symbol:"AVAX",rank:16},{id:7083,title:"Uniswap",symbol:"UNI",rank:17},{id:3717,title:"Wrapped Bitcoin",symbol:"WBTC",rank:18},{id:3957,title:"UNUS SED LEO",symbol:"LEO",rank:19},{id:2,title:"Litecoin",symbol:"LTC",rank:20},{id:1321,title:"Ethereum Classic",symbol:"ETC",rank:21},{id:1975,title:"Chainlink",symbol:"LINK",rank:22},{id:3794,title:"Cosmos",symbol:"ATOM",rank:23},{id:4195,title:"FTX Token",symbol:"FTT",rank:24},{id:512,title:"Stellar",symbol:"XLM",rank:25},{id:6535,title:"NEAR Protocol",symbol:"NEAR",rank:26},{id:3635,title:"Cronos",symbol:"CRO",rank:27},{id:328,title:"Monero",symbol:"XMR",rank:28},{id:4030,title:"Algorand",symbol:"ALGO",rank:29},{id:1831,title:"Bitcoin Cash",symbol:"BCH",rank:30},{id:4172,title:"Terra Classic",symbol:"LUNC",rank:31},{id:4558,title:"Flow",symbol:"FLOW",rank:32},{id:3155,title:"Quant",symbol:"QNT",rank:33},{id:3077,title:"VeChain",symbol:"VET",rank:34},{id:11419,title:"Toncoin",symbol:"TON",rank:35},{id:2280,title:"Filecoin",symbol:"FIL",rank:36},{id:18876,title:"ApeCoin",symbol:"APE",rank:37},{id:8916,title:"Internet Computer",symbol:"ICP",rank:38},{id:4066,title:"Chiliz",symbol:"CHZ",rank:39},{id:4642,title:"Hedera",symbol:"HBAR",rank:40},{id:1966,title:"Decentraland",symbol:"MANA",rank:41},{id:2011,title:"Tezos",symbol:"XTZ",rank:42},{id:6210,title:"The Sandbox",symbol:"SAND",rank:43},{id:1765,title:"EOS",symbol:"EOS",rank:44},{id:6892,title:"Elrond",symbol:"EGLD",rank:45},{id:2416,title:"Theta Network",symbol:"THETA",rank:46},{id:7278,title:"Aave",symbol:"AAVE",rank:47},{id:6783,title:"Axie Infinity",symbol:"AXS",rank:48},{id:3897,title:"OKB",symbol:"OKB",rank:49},{id:3330,title:"Pax Dollar",symbol:"USDP",rank:50},{id:3602,title:"Bitcoin SV",symbol:"BSV",rank:51},{id:2087,title:"KuCoin Token",symbol:"KCS",rank:52},{id:2563,title:"TrueUSD",symbol:"TUSD",rank:53},{id:1437,title:"Zcash",symbol:"ZEC",rank:54},{id:1720,title:"IOTA",symbol:"MIOTA",rank:55},{id:10791,title:"eCash",symbol:"XEC",rank:56},{id:19891,title:"USDD",symbol:"USDD",rank:57},{id:1518,title:"Maker",symbol:"MKR",rank:58},{id:16086,title:"BitTorrent-New",symbol:"BTT",rank:59},{id:2502,title:"Huobi Token",symbol:"HT",rank:60},{id:6719,title:"The Graph",symbol:"GRT",rank:61},{id:5068,title:"Neutrino USD",symbol:"USDN",rank:62},{id:5665,title:"Helium",symbol:"HNT",rank:63},{id:7186,title:"PancakeSwap",symbol:"CAKE",rank:64},{id:1376,title:"Neo",symbol:"NEO",rank:65},{id:4256,title:"Klaytn",symbol:"KLAY",rank:66},{id:3513,title:"Fantom",symbol:"FTM",rank:67},{id:2586,title:"Synthetix",symbol:"SNX",rank:68},{id:4705,title:"PAX Gold",symbol:"PAXG",rank:69},{id:4157,title:"THORChain",symbol:"RUNE",rank:70},{id:2694,title:"Nexo",symbol:"NEXO",rank:71},{id:8e3,title:"Lido DAO",symbol:"LDO",rank:72},{id:6538,title:"Curve DAO Token",symbol:"CRV",rank:73},{id:4269,title:"GateToken",symbol:"GT",rank:74},{id:131,title:"Dash",symbol:"DASH",rank:75},{id:2130,title:"Enjin Coin",symbol:"ENJ",rank:76},{id:1697,title:"Basic Attention Token",symbol:"BAT",rank:77},{id:5692,title:"Compound",symbol:"COMP",rank:78},{id:4847,title:"Stacks",symbol:"STX",rank:79},{id:4846,title:"Kava",symbol:"KAVA",rank:80},{id:2577,title:"Ravencoin",symbol:"RVN",rank:81},{id:2469,title:"Zilliqa",symbol:"ZIL",rank:82},{id:1274,title:"Waves",symbol:"WAVES",rank:83},{id:8642,title:"Fei USD",symbol:"FEI",rank:84},{id:8646,title:"Mina",symbol:"MINA",rank:85},{id:3964,title:"Reserve Rights",symbol:"RSR",rank:86},{id:2634,title:"XDC Network",symbol:"XDC",rank:87},{id:1934,title:"Loopring",symbol:"LRC",rank:88},{id:18069,title:"STEPN",symbol:"GMT",rank:89},{id:1168,title:"Decred",symbol:"DCR",rank:90},{id:5964,title:"Trust Wallet Token",symbol:"TWT",rank:91},{id:5567,title:"Celo",symbol:"CELO",rank:92},{id:873,title:"NEM",symbol:"XEM",rank:93},{id:2083,title:"Bitcoin Gold",symbol:"BTG",rank:94},{id:5034,title:"Kusama",symbol:"KSM",rank:95},{id:2682,title:"Holo",symbol:"HOT",rank:96},{id:8104,title:"1inch Network",symbol:"1INCH",rank:97},{id:2700,title:"Celsius",symbol:"CEL",rank:98},{id:9903,title:"Convex Finance",symbol:"CVX",rank:99},{id:9891,title:"BinaryX",symbol:"BNX",rank:100},{id:5632,title:"Arweave",symbol:"AR",rank:101},{id:1659,title:"Gnosis",symbol:"GNO",rank:102},{id:20314,title:"Terra",symbol:"LUNA",rank:103},{id:7653,title:"Oasis Network",symbol:"ROSE",rank:104},{id:13855,title:"Ethereum Name Service",symbol:"ENS",rank:105},{id:7129,title:"TerraClassicUSD",symbol:"USTC",rank:106},{id:3306,title:"Gemini Dollar",symbol:"GUSD",rank:107},{id:1684,title:"Qtum",symbol:"QTUM",rank:108},{id:5864,title:"yearn.finance",symbol:"YFI",rank:109},{id:3783,title:"Ankr",symbol:"ANKR",rank:110},{id:3822,title:"Theta Fuel",symbol:"TFUEL",rank:111},{id:7080,title:"Gala",symbol:"GALA",rank:112},{id:1455,title:"Golem",symbol:"GLM",rank:113},{id:2777,title:"IoTeX",symbol:"IOTX",rank:114},{id:5647,title:"Kadena",symbol:"KDA",rank:115},{id:11584,title:"Braintrust",symbol:"BTRST",rank:116},{id:3945,title:"Harmony",symbol:"ONE",rank:117},{id:1808,title:"OMG Network",symbol:"OMG",rank:118},{id:5728,title:"Balancer",symbol:"BAL",rank:119},{id:1896,title:"0x",symbol:"ZRX",rank:120},{id:3640,title:"Livepeer",symbol:"LPT",rank:121},{id:2496,title:"Polymath",symbol:"POLY",rank:122},{id:5488,title:"JUST",symbol:"JST",rank:123},{id:3029,title:"Flux",symbol:"FLUX",rank:124},{id:2099,title:"ICON",symbol:"ICX",rank:125},{id:3801,title:"BORA",symbol:"BORA",rank:126},{id:2405,title:"IOST",symbol:"IOST",rank:127},{id:5370,title:"Hive",symbol:"HIVE",rank:128},{id:6945,title:"Amp",symbol:"AMP",rank:129},{id:11840,title:"Optimism",symbol:"OP",rank:130},{id:9444,title:"Kyber Network Crystal v2",symbol:"KNC",rank:131},{id:8677,title:"Symbol",symbol:"XYM",rank:132},{id:6187,title:"Serum",symbol:"SRM",rank:133},{id:2566,title:"Ontology",symbol:"ONT",rank:134},{id:2300,title:"WAX",symbol:"WAXP",rank:135},{id:1772,title:"Storj",symbol:"STORJ",rank:136},{id:3628,title:"MXC",symbol:"MXC",rank:137},{id:5899,title:"Casper",symbol:"CSPR",rank:138},{id:10603,title:"Immutable X",symbol:"IMX",rank:139},{id:1042,title:"Siacoin",symbol:"SC",rank:140},{id:1698,title:"Horizen",symbol:"ZEN",rank:141},{id:7455,title:"Audius",symbol:"AUDIO",rank:142},{id:6836,title:"Moonbeam",symbol:"GLMR",rank:143},{id:4279,title:"SXP",symbol:"SXP",rank:144},{id:9258,title:"Chia",symbol:"XCH",rank:145},{id:3437,title:"ABBC Coin",symbol:"ABBC",rank:146},{id:2499,title:"SwissBorg",symbol:"CHSB",rank:147},{id:1817,title:"Voyager Token",symbol:"VGX",rank:148},{id:5617,title:"UMA",symbol:"UMA",rank:149},{id:7501,title:"WOO Network",symbol:"WOO",rank:150}].reduce(((t,e)=>(t[e.symbol]=Object.assign(Object.assign({},t),{logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`}),t)),{}),this.data={crypto:{last_updated:null,current:null},fiat:{last_updated:null,current:null}},this.options=Object.assign(Object.assign({crypto_interval:s?15e3:5e3,fiat_interval:36e5,calculateAverage:!0,onUpdate:void 0},this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:!0})),{})),t),this.log=function(){var t,e;!s&&(null===(e=null===(t=null===process||void 0===process?void 0:process.env)||void 0===t?void 0:t.NODE_ENV)||void 0===e?void 0:e.startsWith("dev"))&&Array.from(arguments).forEach((t=>{console.log(t)}))},this.isReady=!1}l.prototype.setOptions=function(t){let e="function"==typeof t?t(Object.assign({},this.options)):t||{};s&&!isNaN(e.crypto_interval)&&e.crypto_interval<1e4&&console.warn("The minimum allowed interval on frontend is 10s.");let r=!1,i=e.hasOwnProperty("calculateAverage")&&e.calculateAverage!==this.options.calculateAverage;for(const t of this.exchanges)if(e.hasOwnProperty(t)&&e[t]!==this.options[t]){r=!0;break}if(this.options=Object.assign(Object.assign(Object.assign({},this.options),e),{crypto_interval:isNaN(e.crypto_interval)?this.options.crypto_interval:Math.max(s?1e4:1e3,e.crypto_interval),fiat_interval:isNaN(e.fiat_interval)?this.options.fiat_interval:Math.max(18e5,e.fiat_interval)}),s){if(r||i)return this.browserTicker()}else this.data.crypto.current=this.joinPrices(this.data);return this},l.prototype.updateCrypto=function(){return i(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating crypto...");const t=this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:o.default[e].ticker})),{});let e=[],r={};for(const i in t)try{this.data.crypto[i]=yield t[i](),this.options[i]&&(e.push(this.data.crypto[i]),r=Object.assign(Object.assign({},r),this.data.crypto[i]),this.data.crypto.last_updated=+new Date)}catch(t){this.data.crypto[i]=null,console.error(`Failed fetching prices from ${i}`,t)}return e.length&&(this.data.crypto.current=this.options.calculateAverage?Object.assign(Object.assign({},r),(0,a.getAverage)(e)):r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.crypto)),this}))},l.prototype.updateFiat=function(){return i(this,void 0,void 0,(function*(){this.log("Updating fiat...");try{this.data.fiat.current=yield o.default.fiat.all(),this.data.fiat.last_updated=+new Date,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.fiat,!0)}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},l.prototype.updateLists=function(){return i(this,void 0,void 0,(function*(){this.log("Updating top currency list...");try{const t=yield o.default.coinmarketcap.top();this.list.crypto=Object.keys(t),this.cryptoInfo=t}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},l.prototype.joinPrices=function(t){const e=this.exchanges.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:t.crypto[r]})),{});let r=[],i={};for(const t in e)this.options[t]&&e[t]&&(r.push(e[t]),i=Object.assign(Object.assign({},i),e[t]));return this.options.calculateAverage?Object.assign(Object.assign({},i),(0,a.getAverage)(r)):i},l.prototype.browserTicker=function(){return i(this,void 0,void 0,(function*(){try{const t=this.options,e=this.exchanges.filter((e=>!t[e])),r=yield o.default.coinconvert.ticker(e.length?{filterExchanges:e,noAverage:!this.options.calculateAverage||void 0}:{});this.data=r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data)}catch(t){console.error("Failed fetching prices from API",t)}return this}))},l.prototype.runBrowser=function(){var t,e;return i(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&window.__ccRunning)throw new Error("The crypto-convert worker seems to be already running. \n\t\t\t- There might be an issue with the way your app imports javascript dependencies. \n\t\t\t- Make sure to call 'convert.stop()' on component unmounts if you are using SPA frameworks (e.g React).");if(!(null===(e=null===(t=this.data)||void 0===t?void 0:t.crypto)||void 0===e?void 0:e.current)){yield this.browserTicker();const t=yield o.default.coinconvert.list();this.list.crypto=Object.keys(t.crypto),this.list.fiat=t.fiat,this.cryptoInfo=t.crypto}return this.isReady=!0,this.crypto_worker&&clearInterval(this.crypto_worker),this.crypto_worker=setInterval(this.browserTicker.bind(this),this.options.crypto_interval),"undefined"!=typeof window&&(window.__ccRunning=!0,window.__ccRunID&&clearInterval(window.__ccRunID),window.__ccRunID=this.crypto_worker),this}))},l.prototype.runServer=function(){return i(this,void 0,void 0,(function*(){return yield this.updateLists(),yield this.updateFiat(),yield this.updateCrypto(),this.isReady=!0,this.crypto_worker=setInterval(this.updateCrypto.bind(this),this.options.crypto_interval),this.fiat_worker=setInterval(this.updateFiat.bind(this),this.options.fiat_interval),this}))},l.prototype.run=function(){return this.isRunning=!0,s?this.runBrowser():this.runServer()},l.prototype.stop=function(){return clearInterval(this.crypto_worker),clearInterval(this.fiat_worker),this.isRunning=!1,"undefined"!=typeof window&&(window.__ccRunning=!1),this},l.prototype.restart=function(){return this.stop().run()};const c=new l;e.WorkerReady=c.run(),e.default=c},88:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__88__},265:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__265__}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(607);return __webpack_exports__})()));

@@ -236,3 +236,3 @@ "use strict";

v: {
default: '2.0.4'
default: '2.0.5'
},

@@ -249,3 +249,3 @@ filterExchanges: {

list: {
path: "/v2/list?v=2.0.4",
path: "/v2/list?v=2.0.5",
on_success: (response) => (response.json)

@@ -252,0 +252,0 @@ }

@@ -15,1 +15,2 @@ export declare function symbolMap(symbol: string, map: {

export declare function formatNumber(n: number | string, decimals?: number): number;
export declare function isEmpty(obj: any): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatNumber = exports.getAverage = exports.symbolMap = void 0;
exports.isEmpty = exports.formatNumber = exports.getAverage = exports.symbolMap = void 0;
function symbolMap(symbol, map, recurisve = false) {

@@ -44,1 +44,11 @@ const mapKeys = Object.keys(map);

exports.formatNumber = formatNumber;
function isEmpty(obj) {
if (!obj) {
return true;
}
for (var _ in obj) {
return false;
}
return true;
}
exports.isEmpty = isEmpty;

@@ -42,18 +42,7 @@ "use strict";

const CustomWorkers = new custom_1.default();
function isEmpty(obj) {
if (!obj) {
return true;
}
for (var _ in obj) {
return false;
}
return true;
}
function getPrice(coin, to = 'USD') {
var customResult = CustomWorkers.ticker[coin + to] || (CustomWorkers.ticker[to + coin] ? 1 / CustomWorkers.ticker[to + coin] : null);
var result = worker_1.default.data.crypto.current[coin + to] || (worker_1.default.data.crypto.current[to + coin] ? 1 / worker_1.default.data.crypto.current[to + coin] : null);
return customResult || result;
}
const exchangeWrap = function () {
const exchange = {
/**
* This is the main object
*/
const ConvertObject = function () {
const convert = {
get isReady() {

@@ -64,3 +53,3 @@ return worker_1.default.isReady;

return {
'crypto': worker_1.default.list.crypto,
'crypto': worker_1.default.list.crypto.concat(CustomWorkers.list),
'fiat': worker_1.default.list.fiat

@@ -79,3 +68,9 @@ };

};
//Main conversion function
//Get symbol price from tickers
const getPrice = function (coin, to = 'USD') {
var customResult = CustomWorkers.ticker[coin + to] || (CustomWorkers.ticker[to + coin] ? 1 / CustomWorkers.ticker[to + coin] : null);
var result = worker_1.default.data.crypto.current[coin + to] || (worker_1.default.data.crypto.current[to + coin] ? 1 / worker_1.default.data.crypto.current[to + coin] : null);
return customResult || result;
};
//Conversion function
const wrapper = function (coin, currency) {

@@ -85,3 +80,3 @@ var coin = coin;

var doExchange = function (fromAmount) {
if (isEmpty(worker_1.default.data.crypto.current) || isEmpty(worker_1.default.data.fiat.current)) {
if ((0, helpers_1.isEmpty)(worker_1.default.data.crypto.current) || (0, helpers_1.isEmpty)(worker_1.default.data.fiat.current)) {
console.warn("[~] Prices are loading.\nYou should use `await convert.ready()` to make sure prices are loaded before calling convert.");

@@ -148,4 +143,4 @@ return false;

}
if (!exchange[coin]) {
exchange[coin] = {};
if (!convert[coin]) {
convert[coin] = {};
}

@@ -158,3 +153,3 @@ types += `\n\t'${coin.replace(/\'/g, "\\'")}': {`;

}
exchange[coin][currency] = wrapper(coin, currency);
convert[coin][currency] = wrapper(coin, currency);
types += `\n\t\t'${currency.replace(/\'/g, "\\'")}': amount,`;

@@ -187,11 +182,14 @@ }

};
exchange['setOptions'] = function (options) {
//These below here are just proxy methods to the worker object.
convert['setOptions'] = function (options) {
let update = worker_1.default.setOptions(options);
if ((options.crypto_interval || options.fiat_interval) && (options.crypto_interval !== worker_1.default.options.crypto_interval ||
options.fiat_interval !== worker_1.default.options.fiat_interval)) {
//Restart the worker in order to clear interval & update to new interval
let restart = update.restart();
exchange['ready'] = function () {
convert['ready'] = function () {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.resolve(restart);
return exchange;
yield Promise.resolve(CustomWorkers.ready());
return convert;
});

@@ -203,11 +201,12 @@ };

};
exchange['stop'] = function () {
convert['stop'] = function () {
return worker_1.default.stop();
};
exchange['start'] = function () {
convert['start'] = function () {
let restart = worker_1.default.restart();
exchange['ready'] = function () {
convert['ready'] = function () {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.resolve(restart);
return exchange;
yield Promise.resolve(CustomWorkers.ready());
return convert;
});

@@ -217,11 +216,11 @@ };

};
exchange['ready'] = function () {
convert['ready'] = function () {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.resolve(worker_1.WorkerReady);
yield Promise.resolve(CustomWorkers.ready());
return exchange;
return convert;
});
};
exchange['addCurrency'] = (base, ...rest) => {
if (exchange.hasOwnProperty(base)) {
convert['addCurrency'] = (base, ...rest) => {
if (convert.hasOwnProperty(base)) {
throw new Error("This property already exists.");

@@ -235,10 +234,10 @@ }

};
exchange['removeCurrency'] = (base, quote) => {
convert['removeCurrency'] = (base, quote) => {
var _a, _b;
if (CustomWorkers.list.includes(base)) {
delete exchange[base];
delete convert[base];
const all_currencies = worker_1.default.list.crypto.concat(worker_1.default.list.fiat, CustomWorkers.list);
for (const currency of all_currencies) {
if ((_a = exchange[currency]) === null || _a === void 0 ? void 0 : _a[base]) {
(_b = exchange[currency]) === null || _b === void 0 ? true : delete _b[base];
if ((_a = convert[currency]) === null || _a === void 0 ? void 0 : _a[base]) {
(_b = convert[currency]) === null || _b === void 0 ? true : delete _b[base];
}

@@ -251,3 +250,3 @@ }

Promise.resolve(worker_1.WorkerReady).then(() => (initialize()));
return exchange;
return convert;
}();

@@ -283,3 +282,3 @@ /**

*/
const convert = exchangeWrap;
const convert = ConvertObject;
//@ts-ignore

@@ -286,0 +285,0 @@ convert.default = convert;

{
"name": "crypto-convert",
"version": "2.0.4",
"version": "2.0.5",
"description": "Convert crypto to fiat and vice-versa instantly.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc