diff --git a/client/asset/btc/btc.go b/client/asset/btc/btc.go index b3f0da7528..b0d266ce94 100644 --- a/client/asset/btc/btc.go +++ b/client/asset/btc/btc.go @@ -37,7 +37,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/wallet" "github.com/decred/dcrd/dcrec/secp256k1/v4" - "github.com/decred/dcrd/rpcclient/v7" + "github.com/decred/dcrd/rpcclient/v8" ) const ( diff --git a/client/asset/dcr/coin_selection_test.go b/client/asset/dcr/coin_selection_test.go index 3793f99b49..2f07e07163 100644 --- a/client/asset/dcr/coin_selection_test.go +++ b/client/asset/dcr/coin_selection_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" ) func Test_leastOverFund(t *testing.T) { diff --git a/client/asset/dcr/dcr.go b/client/asset/dcr/dcr.go index 1b02b03946..77ba2636c0 100644 --- a/client/asset/dcr/dcr.go +++ b/client/asset/dcr/dcr.go @@ -28,17 +28,17 @@ import ( "decred.org/dcrdex/dex/calc" "decred.org/dcrdex/dex/config" dexdcr "decred.org/dcrdex/dex/networks/dcr" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" - _ "decred.org/dcrwallet/v2/wallet/drivers/bdb" - "github.com/decred/dcrd/blockchain/stake/v4" - "github.com/decred/dcrd/blockchain/v4" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" + _ "decred.org/dcrwallet/v3/wallet/drivers/bdb" + "github.com/decred/dcrd/blockchain/stake/v5" + "github.com/decred/dcrd/blockchain/standalone/v2" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrec" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa" "github.com/decred/dcrd/dcrutil/v4" - chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v3" + chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/sign" "github.com/decred/dcrd/txscript/v4/stdaddr" @@ -2831,7 +2831,7 @@ func (dcr *ExchangeWallet) AuditContract(coinID, contract, txData dex.Bytes, reb if err != nil { return nil, fmt.Errorf("invalid contract tx data: %w", err) } - if err = blockchain.CheckTransactionSanity(contractTx, dcr.chainParams); err != nil { + if err = standalone.CheckTransactionSanity(contractTx, uint64(dcr.chainParams.MaxTxSize)); err != nil { return nil, fmt.Errorf("invalid contract tx data: %w", err) } if checkHash := contractTx.TxHash(); checkHash != *txHash { @@ -2888,23 +2888,7 @@ func (dcr *ExchangeWallet) AuditContract(coinID, contract, txData dex.Bytes, reb } func determineTxTree(msgTx *wire.MsgTx) int8 { - // stake.DetermineTxType will produce correct results if we pass true for - // isTreasuryEnabled regardless of whether the treasury vote has activated - // or not. - // The only possibility for wrong results is passing isTreasuryEnabled=false - // _after_ the treasury vote activates - some stake tree votes may identify - // as regular tree transactions. - // Could try with isTreasuryEnabled false, then true and if neither comes up - // as a stake transaction, then we infer regular, but that isn't necessary - // as explained above. - isTreasuryEnabled := true - // Consider the automatic ticket revocations agenda NOT active. Specifying - // true just adds the constraints that revocations must have an empty - // signature script for its input and must have zero fee. Thus, false will - // correctly identify consensus-validated transactions before OR after - // activation of this agenda. - isAutoRevocationsEnabled := false - if stake.DetermineTxType(msgTx, isTreasuryEnabled, isAutoRevocationsEnabled) != stake.TxTypeRegular { + if stake.DetermineTxType(msgTx) != stake.TxTypeRegular { return wire.TxTreeStake } return wire.TxTreeRegular diff --git a/client/asset/dcr/dcr_test.go b/client/asset/dcr/dcr_test.go index cf442fa5cd..c48402ed22 100644 --- a/client/asset/dcr/dcr_test.go +++ b/client/asset/dcr/dcr_test.go @@ -22,8 +22,8 @@ import ( "decred.org/dcrdex/dex/calc" "decred.org/dcrdex/dex/config" dexdcr "decred.org/dcrdex/dex/networks/dcr" - "decred.org/dcrwallet/v2/rpc/client/dcrwallet" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" + "decred.org/dcrwallet/v3/rpc/client/dcrwallet" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrec" @@ -31,9 +31,9 @@ import ( "github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa" "github.com/decred/dcrd/dcrjson/v4" "github.com/decred/dcrd/dcrutil/v4" - "github.com/decred/dcrd/gcs/v3" - "github.com/decred/dcrd/gcs/v3/blockcf2" - chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v3" + "github.com/decred/dcrd/gcs/v4" + "github.com/decred/dcrd/gcs/v4/blockcf2" + chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" diff --git a/client/asset/dcr/rpcwallet.go b/client/asset/dcr/rpcwallet.go index 3eca00305b..eea7e63eed 100644 --- a/client/asset/dcr/rpcwallet.go +++ b/client/asset/dcr/rpcwallet.go @@ -18,17 +18,17 @@ import ( "decred.org/dcrdex/client/asset" "decred.org/dcrdex/dex" - "decred.org/dcrwallet/v2/rpc/client/dcrwallet" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" + "decred.org/dcrwallet/v3/rpc/client/dcrwallet" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrjson/v4" "github.com/decred/dcrd/dcrutil/v4" - "github.com/decred/dcrd/gcs/v3" - "github.com/decred/dcrd/gcs/v3/blockcf2" - chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v3" - "github.com/decred/dcrd/rpcclient/v7" + "github.com/decred/dcrd/gcs/v4" + "github.com/decred/dcrd/gcs/v4/blockcf2" + chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4" + "github.com/decred/dcrd/rpcclient/v8" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" ) diff --git a/client/asset/dcr/spv.go b/client/asset/dcr/spv.go index 9e4e9abd3e..3eb01fa0c1 100644 --- a/client/asset/dcr/spv.go +++ b/client/asset/dcr/spv.go @@ -20,22 +20,22 @@ import ( "decred.org/dcrdex/client/asset" "decred.org/dcrdex/dex" - "decred.org/dcrwallet/v2/chain" - walleterrors "decred.org/dcrwallet/v2/errors" - "decred.org/dcrwallet/v2/p2p" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" - "decred.org/dcrwallet/v2/spv" - "decred.org/dcrwallet/v2/wallet" - "decred.org/dcrwallet/v2/wallet/udb" + "decred.org/dcrwallet/v3/chain" + walleterrors "decred.org/dcrwallet/v3/errors" + "decred.org/dcrwallet/v3/p2p" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" + "decred.org/dcrwallet/v3/spv" + "decred.org/dcrwallet/v3/wallet" + "decred.org/dcrwallet/v3/wallet/udb" "github.com/decred/dcrd/addrmgr/v2" - "github.com/decred/dcrd/blockchain/stake/v4" + "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/connmgr/v3" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrutil/v4" - "github.com/decred/dcrd/gcs/v3" - chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v3" + "github.com/decred/dcrd/gcs/v4" + chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" diff --git a/client/asset/dcr/spv_test.go b/client/asset/dcr/spv_test.go index 1c8bd72a06..7fa033d4b4 100644 --- a/client/asset/dcr/spv_test.go +++ b/client/asset/dcr/spv_test.go @@ -11,17 +11,17 @@ import ( "decred.org/dcrdex/client/asset" "decred.org/dcrdex/dex" "decred.org/dcrdex/dex/encode" - walleterrors "decred.org/dcrwallet/v2/errors" - "decred.org/dcrwallet/v2/p2p" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" - "decred.org/dcrwallet/v2/wallet" - "decred.org/dcrwallet/v2/wallet/udb" - "github.com/decred/dcrd/blockchain/stake/v4" + walleterrors "decred.org/dcrwallet/v3/errors" + "decred.org/dcrwallet/v3/p2p" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" + "decred.org/dcrwallet/v3/wallet" + "decred.org/dcrwallet/v3/wallet/udb" + "github.com/decred/dcrd/blockchain/stake/v5" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrutil/v4" - "github.com/decred/dcrd/gcs/v3" - chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v3" + "github.com/decred/dcrd/gcs/v4" + chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/txscript/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" diff --git a/client/asset/dcr/wallet.go b/client/asset/dcr/wallet.go index e562fbe4f9..e08b88105a 100644 --- a/client/asset/dcr/wallet.go +++ b/client/asset/dcr/wallet.go @@ -9,11 +9,11 @@ import ( "decred.org/dcrdex/client/asset" "decred.org/dcrdex/dex" - walletjson "decred.org/dcrwallet/v2/rpc/jsonrpc/types" + walletjson "decred.org/dcrwallet/v3/rpc/jsonrpc/types" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" "github.com/decred/dcrd/dcrec/secp256k1/v4" - chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v3" + chainjson "github.com/decred/dcrd/rpc/jsonrpc/types/v4" "github.com/decred/dcrd/txscript/v4/stdaddr" "github.com/decred/dcrd/wire" ) diff --git a/client/asset/zec/regnet_test.go b/client/asset/zec/regnet_test.go index 090f3bc4fc..22881a07b7 100644 --- a/client/asset/zec/regnet_test.go +++ b/client/asset/zec/regnet_test.go @@ -16,7 +16,7 @@ import ( "decred.org/dcrdex/dex" "decred.org/dcrdex/dex/config" dexzec "decred.org/dcrdex/dex/networks/zec" - "github.com/decred/dcrd/rpcclient/v7" + "github.com/decred/dcrd/rpcclient/v8" ) var ( diff --git a/client/webserver/site/dist/entry.js b/client/webserver/site/dist/entry.js index 591d5f0917..ea67adde1a 100644 --- a/client/webserver/site/dist/entry.js +++ b/client/webserver/site/dist/entry.js @@ -1,3 +1,3 @@ /*! For license information please see entry.js.LICENSE.txt */ -(()=>{var e={61:(e,t,n)=>{var r=n(698).default;function a(){"use strict";e.exports=a=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,o=n.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var a=t&&t.prototype instanceof m?t:m,o=Object.create(a.prototype),i=new I(r||[]);return s(o,"_invoke",{value:S(e,n,i)}),o}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var f={};function m(){}function v(){}function g(){}var y={};h(y,c,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(R([])));w&&w!==n&&o.call(w,c)&&(y=w);var k=g.prototype=m.prototype=Object.create(y);function x(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(a,s,i,c){var l=p(e[a],e,s);if("throw"!==l.type){var u=l.arg,h=u.value;return h&&"object"==r(h)&&o.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(h).then((function(e){u.value=e,i(u)}),(function(e){return n("throw",e,i,c)}))}c(l.arg)}var a;s(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,a){n(e,r,t,a)}))}return a=a?a.then(o,o):o()}})}function S(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var i=E(s,n);if(i){if(i===f)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=p(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function E(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=p(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function R(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var i=o.call(a,"catchLoc"),c=o.call(a,"finallyLoc");if(i&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),F(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;F(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:(e,t,n)=>{var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=n.left&&e.pageX<=n.right&&e.pageY>=n.top&&e.pageY<=n.bottom}},{key:"layoutMetrics",value:function(e){var t=e.getBoundingClientRect(),n=document.documentElement,r=t.top+n.scrollTop,a=t.left+n.scrollLeft,o=e.offsetWidth,s=e.offsetHeight;return{bodyTop:r,bodyLeft:a,width:o,height:s,centerX:a+o/2,centerY:r+s/2}}},{key:"descendentMetrics",value:function(t,n){var r=e.layoutMetrics(t),a=e.layoutMetrics(n);return{bodyTop:a.bodyTop-r.bodyTop,bodyLeft:a.bodyLeft-r.bodyLeft,width:a.width,height:a.height,centerX:a.centerX-r.bodyLeft,centerY:a.centerY-r.bodyTop}}},{key:"empty",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),a=1;a1?n-1:0),a=1;a"),e),document.createElement("div"))}},{key:"idDescendants",value:function(t){var n,r={},a=Dt(e.applySelector(t,"[id]"));try{for(a.s();!(n=a.n()).done;){var o=n.value;r[o.id]=o}}catch(e){a.e(e)}finally{a.f()}return r}},{key:"formatCoinValue",value:function(e,t){var n=r(zt(e,t),2),a=n[0],o=n[1];return Number.isInteger(a)?Mt.format(a):function(e){return _t(qt,2,e)}(o).format(a)}},{key:"formatThreeSigFigs",value:function(e){return e>=1e3?Mt.format(Math.round(e)):Bt.format(e)}},{key:"formatFiveSigFigs",value:function(e,t){return e>=1e4?Mt.format(Math.round(e)):e<1e5?Ut(null!=t?t:8).format(e):Wt.format(e)}},{key:"formatFullPrecision",value:function(e,t){var n=r(zt(e,t),2),a=n[0];return Ut(n[1]).format(a)}},{key:"formatFiatConversion",value:function(e,t,n){if(!t||0===t)return Rt(yt);var a=r(zt(e,n),1)[0]*t;return Ut(2).format(a)}},{key:"logoPath",value:function(e){return-1===Lt.indexOf(e)&&(e=e.substring(0,1)),"/img/coins/".concat(e,".png")}},{key:"bipSymbol",value:function(e){return Pt[e]}},{key:"logoPathFromID",value:function(t){return e.logoPath(Pt[t])}},{key:"symbolize",value:function(e){var t=e.split("."),n=document.createElement("span");if(n.textContent=t[0].toUpperCase(),1===t.length)return n;var r=document.createElement("span");r.classList.add("token-aware-symbol"),r.appendChild(n);var a=document.createElement("sup");return a.textContent=t[1].toUpperCase(),r.appendChild(a),r}},{key:"shortSymbol",value:function(e){return e.split(".")[0].toUpperCase()}},{key:"cleanTemplates",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n0||u>0)&&u++,e>0&&(l+="".concat(e," ").concat(t," ")),u>=2},d=r($t(c,Xt),2);if(t=d[0],c=d[1],h(t,"y"))return l;var p=r($t(c,Qt),2);if(n=p[0],c=p[1],h(n,"mo"))return l;var f=r($t(c,Yt),2);if(a=f[0],c=f[1],h(a,"d"))return l;var m=r($t(c,Jt),2);if(o=m[0],c=m[1],h(o,"h"))return l;var v=r($t(c,Zt),2);if(s=v[0],c=v[1],h(s,"m"))return l;var g=r($t(c,1e3),2);return i=g[0],c=g[1],h(i,"s"),l||"0 s"}},{key:"disableMouseWheel",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n=0?n:31536e7,o=a?Ht[a]:Ht.linear,s=(new Date).getTime(),i=n===e.Forever?Number.MAX_SAFE_INTEGER:s+n,c=i-s,l=1e3/30,u=s,this.endAnimation=!1;case 8:if(!(ue.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(document.cookie.split(";"));try{for(n.s();!(t=n.n()).done;){var a=r(t.value.split("="),2),o=a[0],s=a[1];if(o.trim()===e)return s}}catch(e){n.e(e)}finally{n.f()}return null}},{key:"removeCookie",value:function(e){document.cookie="".concat(e,"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;")}},{key:"isDark",value:function(){return document.cookie.split(";").filter((function(t){return t.includes("".concat(e.darkModeCK,"=1"))})).length}},{key:"passwordIsCached",value:function(){return!!this.getCookie(e.pwKeyCK)}},{key:"storeLocal",value:function(e,t){window.localStorage.setItem(e,JSON.stringify(t))}},{key:"fetchLocal",value:function(e){var t=window.localStorage.getItem(e);return null!==t?JSON.parse(t):null}},{key:"removeLocal",value:function(e){window.localStorage.removeItem(e)}}]),e}();function nn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function rn(e,t){return rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},rn(e,t)}function an(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&rn(e,t)}function on(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return nn(e)}function sn(e){return sn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},sn(e)}h(tn,"darkModeCK","darkMode"),h(tn,"authCK","dexauth"),h(tn,"pwKeyCK","sessionkey"),h(tn,"popupsLK","popups"),h(tn,"loggersLK","loggers"),h(tn,"recordersLK","recorders"),h(tn,"lastMarketLK","selectedMarket"),h(tn,"depthZoomLK","depthZoom"),h(tn,"lastMMMarketLK","mmMarket"),h(tn,"optionsExpansionLK","mmOptsExpand"),h(tn,"leftMarketDockLK","leftmarketdock"),h(tn,"selectedAssetLK","selectedasset"),h(tn,"notificationsLK","notifications"),h(tn,"orderDisclaimerAckedLK","ordAck"),h(tn,"lastCandleDurationLK","lastCandleDuration"),null===tn.getCookie(tn.darkModeCK)&&tn.setCookie(tn.darkModeCK,"1"),null===tn.fetchLocal(tn.popupsLK)&&tn.storeLocal(tn.popupsLK,"1"),null===tn.fetchLocal(tn.leftMarketDockLK)&&tn.storeLocal(tn.leftMarketDockLK,"1");var cn,ln,un,hn,dn,pn,fn,mn=function(){function e(){s(this,e)}return u(e,[{key:"unload",value:function(){}}]),e}();function vn(e,t,n){return gn.apply(this,arguments)}function gn(){return(gn=o(w().mark((function e(t,n,r){var a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,window.fetch(n,{method:t,headers:new window.Headers({"content-type":"application/json"}),body:r});case 3:if(200===(a=e.sent).status){e.next=6;break}throw a;case 6:return e.next=8,a.json();case 8:return(o=e.sent).requestSuccessful=!0,e.abrupt("return",o);case 13:return e.prev=13,e.t0=e.catch(0),e.t0.requestSuccessful=!1,e.next=18,e.t0.text();case 18:return e.t0.msg=e.sent,e.abrupt("return",e.t0);case 20:case"end":return e.stop()}}),e,null,[[0,13]])})))).apply(this,arguments)}function yn(e,t){return bn.apply(this,arguments)}function bn(){return(bn=o(w().mark((function e(t,n){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",vn("POST",t,JSON.stringify(n)));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wn(e){return kn.apply(this,arguments)}function kn(){return(kn=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",vn("GET",t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xn(n){return function(t){if(Array.isArray(t))return e(t)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||t(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Cn(){return hn}function Sn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=sn(e);if(t){var a=sn(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return on(this,n)}}function En(e){var t=[e.booleanOptTmpl,e.rangeOptTmpl,e.orderOptTmpl];pn=t[0],fn=t[1],dn=t[2]}!function(e){e[e.walletErr=0]="walletErr",e[e.walletAuthErr=1]="walletAuthErr",e[e.walletBalanceErr=2]="walletBalanceErr",e[e.dupeDEXErr=3]="dupeDEXErr",e[e.assetSupportErr=4]="assetSupportErr",e[e.registerErr=5]="registerErr",e[e.signatureErr=6]="signatureErr",e[e.zeroFeeErr=7]="zeroFeeErr",e[e.feeMismatchErr=8]="feeMismatchErr",e[e.feeSendErr=9]="feeSendErr",e[e.passwordErr=10]="passwordErr",e[e.emptyHostErr=11]="emptyHostErr",e[e.connectionErr=12]="connectionErr",e[e.acctKeyErr=13]="acctKeyErr",e[e.unknownOrderErr=14]="unknownOrderErr",e[e.orderParamsErr=15]="orderParamsErr",e[e.dbErr=16]="dbErr",e[e.authErr=17]="authErr",e[e.connectWalletErr=18]="connectWalletErr",e[e.missingWalletErr=19]="missingWalletErr",e[e.encryptionErr=20]="encryptionErr",e[e.decodeErr=21]="decodeErr",e[e.accountVerificationErr=22]="accountVerificationErr",e[e.accountProofErr=23]="accountProofErr",e[e.parseKeyErr=24]="parseKeyErr",e[e.marketErr=25]="marketErr",e[e.addressParseErr=26]="addressParseErr",e[e.addrErr=27]="addrErr",e[e.fileReadErr=28]="fileReadErr",e[e.unknownDEXErr=29]="unknownDEXErr",e[e.accountRetrieveErr=30]="accountRetrieveErr",e[e.accountDisableErr=31]="accountDisableErr",e[e.suspendedAcctErr=32]="suspendedAcctErr",e[e.existenceCheckErr=33]="existenceCheckErr",e[e.createWalletErr=34]="createWalletErr",e[e.activeOrdersErr=35]="activeOrdersErr",e[e.newAddrErr=36]="newAddrErr"}(cn||(cn={})),function(e){e[e.Disconnected=0]="Disconnected",e[e.Connected=1]="Connected",e[e.InvalidCert=2]="InvalidCert"}(ln||(ln={})),function(e){e[e.WalletDefault=0]="WalletDefault",e[e.UserAdded=1]="UserAdded",e[e.Discovered=2]="Discovered"}(un||(un={}));var An=new Intl.NumberFormat(navigator.languages,{minimumSignificantDigits:3,maximumSignificantDigits:3}),Fn=u((function e(t,n,r){var a=this;s(this,e),h(this,"opt",void 0),h(this,"node",void 0),h(this,"tmpl",void 0),h(this,"on",void 0),this.opt=t;var o=this.node=dn.cloneNode(!0),i=this.tmpl=Vt.parseTemplate(o);i.optName.textContent=t.displayname,i.tooltip.dataset.tooltip=t.description,n?i.chainIcon.src=Vt.logoPath(n):Vt.hide(i.chainIcon),this.on=!1,Vt.bind(o,"click",(function(){a.on||(a.on=!0,o.classList.add("selected"),r.enable())})),Vt.bind(i.toggle,"click",(function(e){a.on&&(e.stopPropagation(),a.on=!1,o.classList.remove("selected"),r.disable())}))})),In=function(e){an(n,e);var t=Sn(n);function n(e,r,a,o){var i;if(s(this,n),h(nn(i=t.call(this,e,r,{enable:function(){return i.enable()},disable:function(){return i.disable()}})),"control",void 0),h(nn(i),"changed",void 0),h(nn(i),"dict",void 0),i.dict=a,i.changed=function(){return o()},void 0===e.boolean)throw Error("not a boolean opt");var c=e.boolean,l=i.control=pn.cloneNode(!0);return i.tmpl.controls.appendChild(l),Vt.parseTemplate(l).reason.textContent=c.reason,i.on=void 0!==a[e.key]?a[e.key]:e.default,i.on&&i.node.classList.add("selected"),i}return u(n,[{key:"store",value:function(){this.on===this.opt.default?delete this.dict[this.opt.key]:this.dict[this.opt.key]=this.on,this.changed()}},{key:"enable",value:function(){this.store()}},{key:"disable",value:function(){this.store()}}]),n}(Fn),Rn=function(e){an(n,e);var t=Sn(n);function n(e,r,a,o){var i;if(s(this,n),h(nn(i=t.call(this,e,r,{enable:function(){return i.enable()},disable:function(){return i.disable()}})),"handler",void 0),h(nn(i),"x",void 0),h(nn(i),"changed",void 0),h(nn(i),"dict",void 0),i.dict=a,i.changed=o,void 0===e.xyRange)throw Error("not an xy range opt");var c=e.xyRange,l=a[e.key];return i.on=void 0!==l,i.on?(i.node.classList.add("selected"),i.x=l):i.x=e.default,i.handler=new Dn(c,i.x,(function(e){i.x=e,i.dict[i.opt.key]=e}),(function(){i.changed()}),(function(){i.node.classList.add("selected")})),i.tmpl.controls.appendChild(i.handler.control),i}return u(n,[{key:"enable",value:function(){this.dict[this.opt.key]=this.x,this.changed()}},{key:"disable",value:function(){delete this.dict[this.opt.key],this.changed()}},{key:"setValue",value:function(e){this.handler.setValue(e),this.on=!0,this.node.classList.add("selected")}}]),n}(Fn),Dn=function(){function e(t,n,r,a,o,i){var c=this;s(this,e),h(this,"control",void 0),h(this,"cfg",void 0),h(this,"tmpl",void 0),h(this,"x",void 0),h(this,"scrollingX",void 0),h(this,"y",void 0),h(this,"r",void 0),h(this,"roundY",void 0),h(this,"updated",void 0),h(this,"changed",void 0),h(this,"selected",void 0),h(this,"setConfig",void 0);var l=this.control=fn.cloneNode(!0),u=this.tmpl=Vt.parseTemplate(l);this.roundY=Boolean(i),this.cfg=t,this.changed=a,this.selected=o,this.updated=r;var d=u.slider,p=u.handle,f=t.end.x-t.start.x,m=t.end.y-t.start.y,v=function(e){return(e-t.start.x)/f},g=function(e){f=e.end.x-e.start.x,m=e.end.y-e.start.y,t=c.cfg=e,u.rangeLblStart.textContent=t.start.label,u.rangeLblEnd.textContent=t.end.label,u.xUnit.textContent=t.xUnit,u.yUnit.textContent=t.yUnit,c.y=c.r*m+t.start.y,c.r=(c.y-t.start.y)/m,c.scrollingX=c.r*f+t.start.x};g(t),this.setConfig=function(e){g(e),c.accept(c.scrollingX)},this.r=v(n),this.scrollingX=this.x=n,this.y=this.r*m+t.start.y;var y=function e(n){if("change"===n.type||n.target!==u.xInput){var r=u.xInput.value;if(r){var a=parseFloat(r);isNaN(a)||(c.scrollingX=On(a,t.start.x,t.end.x),c.r=v(c.scrollingX),c.y=c.r*m+t.start.y,c.accept(c.scrollingX))}Vt.hide(u.xInput),Vt.show(u.x),Vt.unbind(document,"click",e),c.changed()}};Vt.bind(u.x,"click",(function(e){Vt.hide(u.x),Vt.show(u.xInput),u.xInput.focus(),u.xInput.value=An.format(c.scrollingX),Vt.bind(document,"click",y),e.stopPropagation()})),Vt.bind(u.xInput,"change",y);var b=function e(n){if("change"===n.type||n.target!==u.yInput){var r=u.yInput.value;if(r){var a=parseFloat(r);isNaN(a)||(c.y=On(a,t.start.y,t.end.y),c.r=(c.y-t.start.y)/m,c.scrollingX=t.start.x+c.r*f,c.accept(c.scrollingX))}Vt.hide(u.yInput),Vt.show(u.y),Vt.unbind(document,"click",e),c.changed()}};Vt.bind(u.y,"click",(function(e){Vt.hide(u.y),Vt.show(u.yInput),u.yInput.focus(),u.yInput.value=An.format(c.y),Vt.bind(document,"click",b),e.stopPropagation()})),Vt.bind(u.yInput,"change",b),Vt.bind(p,"mousedown",(function(e){if(0===e.button){e.preventDefault(),c.selected();var n=e.pageX,r=d.clientWidth-p.offsetWidth,a=v(c.scrollingX)*r,o=function(e){e.preventDefault(),c.r=function(e){return Math.max(Math.min(a+(e.pageX-n),r),0)}(e)/r,c.scrollingX=c.r*f+t.start.x,c.y=c.r*m+t.start.y,c.accept(c.scrollingX)};Vt.bind(document,"mousemove",o),Vt.bind(document,"mouseup",(function e(t){o(t),Vt.unbind(document,"mousemove",o),Vt.unbind(document,"mouseup",e),c.changed()}))}})),this.accept(this.scrollingX,!0)}return u(e,[{key:"accept",value:function(e,t){var n=this.tmpl;this.roundY&&(this.y=Math.round(this.y)),n.x.textContent=An.format(e),n.y.textContent=An.format(this.y),this.roundY&&(n.y.textContent="".concat(this.y)),n.handle.style.left="calc(".concat(100*this.r,"% - ").concat(14*this.r,"px)"),this.x=e,this.scrollingX=e,t||this.updated(e,this.y)}},{key:"setValue",value:function(e){var t=this.cfg;this.r=(e-t.start.x)/(t.end.x-t.start.x),this.y=t.start.y+this.r*(t.end.y-t.start.y),this.accept(e,!0)}}]),e}(),On=function(e,t,n){return en?n:e};function Tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(e.matches);try{for(n.s();!(t=n.n()).done;)if(t.value.active)return!0}catch(e){n.e(e)}finally{n.f()}return!1}function qn(e){if(!e.id)return Rt(te);var t=Wn(e);switch(e.status){case 0:return Rt($);case 1:return Rt(ee);case 2:return e.cancelling?Rt(G):t?"".concat(Rt(H),"/").concat(Rt(ne)):Rt(H);case 3:return t?Rt(ne):0===e.filled&&3!==e.type?Rt(re):Rt(j);case 4:return t?"".concat(Rt(ae),"/").concat(Rt(ne)):Rt(ae);case 5:return t?"".concat(Rt(oe),"/").concat(Rt(ne)):Rt(oe)}return Rt($)}function Nn(e){if(!e.matches)return 0;var t=Bn(e)?function(e){return e.qty*e.rate/Pn}:function(e){return e.qty};return e.matches.reduce((function(e,n){return n.isCancel?e:e+t(n)}),0)}function Un(e){if(!e.matches)return 0;var t=Bn(e)?function(e){return e.qty*e.rate/Pn}:function(e){return e.qty};return e.matches.reduce((function(e,n){return n.isCancel?e:0===n.side&&n.status>=3||1===n.side&&n.status>=4?e+t(n):e}),0)}function _n(e,t){return e*t/Pn}function zn(e){return Rt(tt,{status:Rt(e)})}function Vn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=sn(e);if(t){var a=sn(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return on(this,n)}}function jn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Hn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hn(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Hn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=c&&i=i&&s=h&&v.push([C.rate,k]),!C.epoch)for(w+=C.qty,m.push([C.rate,w]),b.buyBase+=C.qty,b.buyQuote+=C.qty*C.rate;d.length&&hr(d[0].rate,C.rate);){var S=d.shift();S&&f.push({rate:S.rate,qty:C.epoch?k:w,sell:C.sell,active:S.active})}}var E=m.length?sr(m)[1]:0;m.push([h,E]);var A=v.length?sr(v)[1]:0;v.push([h,A]),k=w=0;for(var F=0;Fu||e=P},N=e.theme.sellLine;Pthis.data.candles.length)return;this.numToShow=this.zoomLevels[t+1]}this.draw()}},{key:"render",value:function(){var e=this,t=this.data;if(t&&this.visible&&0!==this.canvas.width){var n=t.ms,r=this.mousePos,a=t.candles||[],o=Math.min(this.numToShow,a.length),s=a.slice(a.length-o);if(this.clear(),0!==o){var i,c=function(e){return pr(e.endStamp,n)},l=function(e){return c(e)+n},u=function(e){return c(e)+.2*n},h=.6*n,d=s[0],p=s[o-1],f=[d.highRate,d.lowRate,d.matchVolume],m=f[0],v=f[1],g=f[2],y=jn(s);try{for(y.s();!(i=y.n()).done;){var b=i.value;b.highRate>m&&(m=b.highRate),b.lowRateg&&(g=b.matchVolume)}}catch(e){y.e(e)}finally{y.f()}var w=this.market.ratestep,k=new nr(c(d),l(p),v,m);v===m&&(k.y.min-=w,k.y.max+=w),this.dataExtents=k;var x=this.rateConversionFactor;this.doYLabels(this.candleRegion,w,this.market.quotesymbol,(function(e){return ur(e/x)})),this.candleRegion.extents.x.min=this.yRegion.extents.x.max,this.volumeRegion.extents.x.min=this.yRegion.extents.x.max;var C=function(e,t,n,r){var a=e[0],o=e[e.length-1],s=pr(a.endStamp,t),i=pr(o.endStamp,t)+t,c=i-s,l=Math.min(e.length,n/100),u=pr(c/l,t);if(0===u)return console.error("zero tick",t,c,l),{lbls:[]};var h=s,d=(new Date).getTimezoneOffset(),p=function(e){return(e-=6e4*d)-e%864e5},f=p(s),m=0;p(a.endStamp)===p(o.endStamp)&&(f=0);var v,g=[];for(v=t<864e5?function(e,t){return p(t)!==f?"".concat(or[e.getMonth()]).concat(e.getDate()," ").concat(e.getHours(),":").concat(String(e.getMinutes()).padStart(2,"0")):"".concat(e.getHours(),":").concat(String(e.getMinutes()).padStart(2,"0"))}:function(e){var t=e.getFullYear();return t!==m?"".concat(or[e.getMonth()]).concat(e.getDate()," '").concat(String(t).slice(2,4)):"".concat(or[e.getMonth()]).concat(e.getDate())};h<=i;){var y=new Date(h);g.push({val:h,txt:v(y,h)}),f=p(h),m=y.getFullYear(),h+=u}return{lbls:g}}(s,n,this.plotRegion.width());this.plotXLabels(C,c(d),l(p),[]),this.drawFrame();var S=null;if(r&&(this.plotRegion.plot(new nr(k.x.min,k.x.max,0,1),(function(t,a){var o,i=pr(a.unx(r.x),n),l=jn(s);try{for(l.s();!(o=l.n()).done;){var u=o.value;if(c(u)===i){S=u,t.fillStyle=e.theme.gridLines,t.fillRect(a.x(c(u)),a.y(0),a.w(n),a.h(1));break}}}catch(e){l.e(e)}finally{l.f()}})),S)){var E=this.xRegion.extents.y;this.xRegion.plot(new nr(k.x.min,k.x.max,E.min,E.max),(function(t,n){if(S){e.applyLabelStyle();var r="".concat(new Date(c(S)).toLocaleString()," - ").concat(new Date(l(S)).toLocaleString()),a=t.measureText(r).width+50,o=n.x((c(S)+l(S))/2),s=o-a/2,i=e.xRegion.extents.x;si.max&&(s=i.max-a),o=s+a/2;var u=E.min+(e.xRegion.height()-16)/2;t.fillStyle=e.theme.legendFill,t.strokeStyle=e.theme.gridBorder;var h=[s-25,u-2,a+50,20];t.fillRect.apply(t,h),t.strokeRect.apply(t,h),e.applyLabelStyle(),t.fillText(r,o,e.xRegion.extents.midY,a)}}))}var A=new nr(c(d),l(p),0,g);this.volumeRegion.plot(A,(function(t,n){t.fillStyle=e.theme.gridBorder;var r,a=jn(s);try{for(a.s();!(r=a.n()).done;){var o=r.value;t.fillRect(n.x(u(o)),n.y(0),n.w(h),n.h(o.matchVolume))}}catch(e){a.e(e)}finally{a.f()}})),this.candleRegion.plot(k,(function(t,n){t.lineWidth=1;var r,a=jn(s);try{for(a.s();!(r=a.n()).done;){var o=r.value,i=o.startRate>o.endRate,c=[n.x(u(o)),n.y(o.startRate),n.w(h),n.h(o.endRate-o.startRate)],l=c[0],d=c[1],p=c[2],f=c[3],m=[n.y(o.highRate),n.y(o.lowRate),p/2+l],v=m[0],g=m[1],y=m[2];t.strokeStyle=i?e.theme.sellLine:e.theme.buyLine,t.fillStyle=i?e.theme.sellFill:e.theme.buyFill,t.beginPath(),t.moveTo(y,v),t.lineTo(y,g),t.stroke(),t.fillRect(l,d,p,f),t.strokeRect(l,d,p,f)}}catch(e){a.e(e)}finally{a.f()}})),this.reporters.mouse(S)}}else this.renderScheduled=!0}},{key:"setCandles",value:function(e,t,n,r){if(this.data=e,e.candles){this.market=t;var a=[r.conventional.conversionFactor,n.conventional.conversionFactor],o=a[0],s=a[1];this.rateConversionFactor=Pn*o/s;var i=25;this.zoomLevels=[];for(var c=Math.max(e.candles.length,1e3);i150&&(a=150),o>100&&(o=100);var s=(n-a)/2,i=(r-o)/2;if(e.message){this.fontSize=cr(.15*o,10,14),this.applyLabelStyle(this.fontSize);var c=.5*this.fontSize,l=this.fontSize/2+c;i-=l,this.msgRegion=new rr(this.ctx,new nr(0,n,i+o,i+o+2*l))}this.region=new rr(this.ctx,new nr(s,s+a,i,i+o))}},{key:"drawValues",value:function(e){var t=this;if(this.region){this.clear();var n=function(e){return"hsl(".concat(e,", 35%, 50%)")},r=this.region,a=this.msgRegion,o=this.canvas,s=o.width,i=o.height,c=this.opts,l=c.backgroundColor,u=c.message,h=this.colorShift,d=this.ctx;l&&(d.fillStyle=!0===l?window.getComputedStyle(document.body,null).getPropertyValue("background-color"):l,d.fillRect(0,0,s,i)),r.plot(new nr(0,1,-1,1),(function(t,r){t.lineWidth=4,t.lineCap="round";var a=h+(new Date).getTime()%2e3/2e3*360,o=t.createLinearGradient(r.x(0),0,r.x(1),0);o.addColorStop(0,n(a)),t.strokeStyle=o,t.beginPath(),t.moveTo(r.x(0),r.y(e[0]));for(var s=1;sn.x.min&&tn.y.min}},{key:"translator",value:function(e){var t=this.extents,n=e.x.min,r=e.y.min,a=e.yRange,o=e.xRange,s=t.x.min,i=t.x.max-s,c=t.y.max,l=c-t.y.min,u=i/o,h=l/a;return{x:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return(e-n)*u+s})),y:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return c-(e-r)*h})),unx:function(e){return(e-s)/u+n},uny:function(e){return r-(e-c)/h},w:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return e/o*i})),h:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return-e/a*l})),dataCoords:function(){}}}},{key:"clear",value:function(){var e=this.extents;this.context.clearRect(e.x.min,e.y.min,e.xRange,e.yRange)}},{key:"plot",value:function(e,t,n){var r=this.context,a=this.extents;r.save(),n||(r.beginPath(),r.rect(a.x.min,a.y.min,a.xRange,a.yRange),r.clip());var o=this.translator(e),s=e.yRange,i=a.xRange/e.xRange,c=a.yRange/s,l=e.x.min,u=e.y.min,h=a.x.min+l-l*i,d=-a.y.min-(s-u)*c;o.dataCoords=function(e){r.save(),r.transform(1,0,0,-1,-l,u),r.transform(i,0,0,c,h,d),e(),r.restore()},t(this.context,o),r.restore()}}]),e}();function ar(e,t,n,r,a,o,s,i){i=i||ur;var c=t/a,l=r-n;if(c<1||l<=0)return{lbls:[]};for(var u=l/c,h=u+o-u%o,d=n+h-n%h,p=Math.max(Math.abs(r),Math.abs(n)),f=Math.round(Math.log10(p/h))+2,m=[],v=0;dv&&(v=y),{widest:v,lbls:m}}var or=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];function sr(e){return e[e.length-1]}function ir(e,t,n,r,a,o){e.beginPath(),e.moveTo(t,n),e.lineTo(r,a),o||e.stroke()}function cr(e,t,n){return en?n:e}var lr={minimumSignificantDigits:4,maximumSignificantDigits:5};function ur(e){return e.toLocaleString("en-us",lr)}function hr(e,t){return dr(e,t,1e-8)}function dr(e,t,n){return Math.abs(e-t)=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function mr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1)){e.next=34;break}Vt.show(r),u=fr(l),e.prev=16,d=w().mark((function e(){var t,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=h.value,(a=n.walletTabTmpl.cloneNode(!0)).dataset.tooltip=t.description,a.textContent=t.tab,r.appendChild(a),Vt.bind(a,"click",(function(){var e,n=fr(Vt.kids(r));try{for(n.s();!(e=n.n()).done;)e.value.classList.remove("selected")}catch(e){n.e(e)}finally{n.f()}a.classList.add("selected"),p.update(t)}));case 6:case"end":return e.stop()}}),e)})),u.s();case 19:if((h=u.n()).done){e.next=23;break}return e.delegateYield(d(),"t0",21);case 21:e.next=19;break;case 23:e.next=28;break;case 25:e.prev=25,e.t1=e.catch(16),u.e(e.t1);case 28:return e.prev=28,u.f(),e.finish(28);case 31:Cn().bindTooltips(r),r.firstChild.classList.add("selected");case 34:return e.next=36,this.update(this.current.selectedDef);case 36:if(!s.walletCreationPending){e.next=39;break}return e.next=39,this.runParentSync();case 39:case"end":return e.stop()}}),e,this,[[16,25,28,31]])}))),function(e){return a.apply(this,arguments)})},{key:"parseAsset",value:function(e){if(this.current&&this.current.asset.id===e)return!1;var t=Cn().assets[e],n=t.token;if(!n){if(!t.info)throw Error("this non-token asset has no wallet info!");return this.current={asset:t,winfo:t.info,selectedDef:t.info.availablewallets[0]},!0}var r=Cn().user.assets[n.parentID];if(r.wallet)return this.current={asset:t,winfo:n,selectedDef:n.definition},!0;if(!r.info)throw Error("this parent has no wallet info!");return this.current={asset:t,parentAsset:r,winfo:n,selectedDef:r.info.availablewallets[0]},!0}},{key:"update",value:(r=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u,h,d,p,f,m,v,g,y,b,k;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.page,this.current.selectedDef=t,r=tn.passwordIsCached()||this.pwCache&&this.pwCache.pw,Vt.hide(n.auth,n.oneBttnBox,n.newWalletPassBox),a=t.guidelink,(o=t.configopts||[]).map((function(e){return e.isBirthdayConfig&&Cn().seedGenTime>0&&(e.default=Pr(new Date)),e})),s=!1,i=fr(o),e.prev=9,i.s();case 11:if((c=i.n()).done){e.next=18;break}if(!c.value.required){e.next=16;break}return s=!0,e.abrupt("break",18);case 16:e.next=11;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(9),i.e(e.t0);case 23:return e.prev=23,i.f(),e.finish(23);case 26:if(l=!s&&(t.seeded||Boolean(this.current.asset.token)),r&&l?Vt.show(n.oneBttnBox):l?(Vt.show(n.auth),n.newWalletPass.value="",n.submitAdd.textContent=Rt(he)):(Vt.show(n.auth),t.noauth||Vt.show(n.newWalletPassBox),n.submitAdd.textContent=Rt(ue)),u=this.current,h=u.asset,d=u.parentAsset,p=u.winfo,d){f=JSON.parse(JSON.stringify(o)),m=fr(f);try{for(m.s();!(v=m.n()).done;)v.value.regAsset=d.id}catch(e){m.e(e)}finally{m.f()}if((g=p.definition.configopts||[]).length>0){y=JSON.parse(JSON.stringify(g)),b=fr(y);try{for(b.s();!(k=b.n()).done;)k.value.regAsset=h.id}catch(e){b.e(e)}finally{b.f()}f.push.apply(f,xn(y))}this.subform.update(f,!1)}else this.subform.update(o,!1);return this.setGuideLink(a),this.subform.dynamicOpts.children.length||this.subform.defaultSettings.children.length?Vt.show(n.walletSettingsHeader):Vt.hide(n.walletSettingsHeader),t.seeded||Boolean(this.current.asset.token)?Vt.hide(this.subform.fileSelector):Vt.show(this.subform.fileSelector),this.refresh(),e.next=36,this.loadDefaults();case 36:case"end":return e.stop()}}),e,this,[[9,20,23,26]])}))),function(e){return r.apply(this,arguments)})},{key:"setGuideLink",value:function(e){Vt.hide(this.walletCfgGuide),""!==e&&(this.walletCfgGuide.href=e,Vt.show(this.walletCfgGuide))}},{key:"setError",value:(n=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.page.newWalletErr.textContent=t,Vt.show(this.page.newWalletErr);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"loadDefaults",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.current,n=t.asset,r=t.parentAsset,(a=t.selectedDef).configpath){e.next=3;break}return e.abrupt("return");case 3:if(o=n.id,!r){e.next=8;break}if(!a.seeded){e.next=7;break}return e.abrupt("return");case 7:o=r.id;case 8:return s=Cn().loading(this.form),e.next=11,yn("/api/defaultwalletcfg",{assetID:o,type:a.type});case 11:if(i=e.sent,s(),Cn().checkResponse(i)){e.next=16;break}return this.setError(i.msg),e.abrupt("return");case 16:this.subform.setLoadedConfig(i.config);case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),gr=0,yr=function(){function e(t,n){var r=this;s(this,e),h(this,"page",void 0),h(this,"form",void 0),h(this,"configElements",void 0),h(this,"configOpts",void 0),h(this,"sectionize",void 0),h(this,"allSettings",void 0),h(this,"dynamicOpts",void 0),h(this,"textInputTmpl",void 0),h(this,"dateInputTmpl",void 0),h(this,"checkboxTmpl",void 0),h(this,"repeatableTmpl",void 0),h(this,"fileSelector",void 0),h(this,"fileInput",void 0),h(this,"errMsg",void 0),h(this,"showOther",void 0),h(this,"showIcon",void 0),h(this,"hideIcon",void 0),h(this,"showHideMsg",void 0),h(this,"otherSettings",void 0),h(this,"loadedSettingsMsg",void 0),h(this,"loadedSettings",void 0),h(this,"defaultSettingsMsg",void 0),h(this,"defaultSettings",void 0),h(this,"assetHasActiveOrders",void 0),this.page=Vt.idDescendants(t),this.form=t,this.configElements=[],this.configOpts=[],this.sectionize=n,this.allSettings=Vt.tmplElement(t,"allSettings"),this.dynamicOpts=Vt.tmplElement(t,"dynamicOpts"),this.textInputTmpl=Vt.tmplElement(t,"textInput"),this.textInputTmpl.remove(),this.dateInputTmpl=Vt.tmplElement(t,"dateInput"),this.dateInputTmpl.remove(),this.checkboxTmpl=Vt.tmplElement(t,"checkbox"),this.checkboxTmpl.remove(),this.repeatableTmpl=Vt.tmplElement(t,"repeatableInput"),this.repeatableTmpl.remove(),this.fileSelector=Vt.tmplElement(t,"fileSelector"),this.fileInput=Vt.tmplElement(t,"fileInput"),this.errMsg=Vt.tmplElement(t,"errMsg"),this.showOther=Vt.tmplElement(t,"showOther"),this.showIcon=Vt.tmplElement(t,"showIcon"),this.hideIcon=Vt.tmplElement(t,"hideIcon"),this.showHideMsg=Vt.tmplElement(t,"showHideMsg"),this.otherSettings=Vt.tmplElement(t,"otherSettings"),this.loadedSettingsMsg=Vt.tmplElement(t,"loadedSettingsMsg"),this.loadedSettings=Vt.tmplElement(t,"loadedSettings"),this.defaultSettingsMsg=Vt.tmplElement(t,"defaultSettingsMsg"),this.defaultSettings=Vt.tmplElement(t,"defaultSettings"),n||Vt.hide(this.showOther),Vt.bind(this.fileSelector,"click",(function(){return r.fileInput.click()})),Vt.bind(this.fileInput,"change",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.fileInputChanged());case 1:case"end":return e.stop()}}),e)})))),Vt.bind(this.showOther,"click",(function(){r.setOtherSettingsViz(r.hideIcon.classList.contains("d-hide"))}))}var t;return u(e,[{key:"fileInputChanged",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Vt.hide(this.errMsg),this.fileInput.value){e.next=3;break}return e.abrupt("return");case 3:if((n=this.fileInput.files)&&0!==n.length){e.next=6;break}return e.abrupt("return");case 6:return r=Cn().loading(this.form),e.next=9,n[0].text();case 9:if(a=e.sent){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,yn("/api/parseconfig",{configtext:a});case 14:if(o=e.sent,r(),Cn().checkResponse(o)){e.next=20;break}return this.errMsg.textContent=o.msg,Vt.show(this.errMsg),e.abrupt("return");case 20:if(0!==Object.keys(o.map).length){e.next=22;break}return e.abrupt("return");case 22:(t=this.dynamicOpts).append.apply(t,xn(this.setConfig(o.map))),this.reorder(this.dynamicOpts),s=[this.loadedSettings.children.length,this.defaultSettings.children.length],c=s[1],0===(i=s[0])&&Vt.hide(this.loadedSettings,this.loadedSettingsMsg),0===c&&Vt.hide(this.defaultSettings,this.defaultSettingsMsg),i+c===0&&Vt.hide(this.showOther,this.otherSettings);case 28:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"addOpt",value:function(e,t,n,r){var a,o=this;if(t.isboolean)a=this.checkboxTmpl.cloneNode(!0);else if(t.isdate)a=this.dateInputTmpl.cloneNode(!0);else if(t.repeatable){if((a=this.repeatableTmpl.cloneNode(!0)).classList.add("repeatable"),Vt.bind(Vt.tmplElement(a,"add"),"click",(function(){o.addOpt(e,t,a,!0)})),!r)for(var s=0;s<(t.repeatN?t.repeatN-1:0);s++)this.addOpt(e,t,n,!0)}else a=this.textInputTmpl.cloneNode(!0);this.configElements.push([t,a]);var i=a.querySelector("input");i.dataset.configKey=t.key,gr++;var c="wcfg-"+String(gr);i.id=c;var l=Vt.safeSelector(a,"label");if(l.htmlFor=c,l.prepend(t.displayname),void 0!==t.regAsset){var u=new window.Image(15,15);u.src=Vt.logoPathFromID(t.regAsset||-1),l.prepend(u)}if(n?n.after(a):e.appendChild(a),t.noecho&&(i.type="password",i.autocomplete="off"),t.description&&(l.dataset.tooltip=t.description),t.isboolean)i.checked=t.default;else if(t.isdate){var h=function(e){return e?Lr("now"===e?new Date:new Date(1e3*e)):""};i.max=h(t.max),i.min=h(t.min);var d=t.default?new Date(1e3*t.default):new Date;i.value=Lr(d)}else i.value=null!==t.default?t.default:"";return i.disabled=Boolean(t.disablewhenactive&&this.assetHasActiveOrders),a}},{key:"update",value:function(e,t){if(this.assetHasActiveOrders=t,this.configElements=[],this.configOpts=e||[],Vt.empty(this.dynamicOpts,this.defaultSettings,this.loadedSettings),0===this.configOpts.length)return Vt.hide(this.form);Vt.show(this.form),this.setOtherSettingsViz(!1),Vt.hide(this.loadedSettingsMsg,this.loadedSettings,this.defaultSettingsMsg,this.defaultSettings,this.errMsg);var n,r=[],a=fr(this.configOpts);try{for(a.s();!(n=a.n()).done;){var o=n.value;this.sectionize&&null!==o.default?r.push(o):this.addOpt(this.dynamicOpts,o)}}catch(e){a.e(e)}finally{a.f()}if(r.length){var s,i=fr(r);try{for(i.s();!(s=i.n()).done;){var c=s.value;this.addOpt(this.defaultSettings,c)}}catch(e){i.e(e)}finally{i.f()}Vt.show(this.showOther,this.defaultSettingsMsg,this.defaultSettings)}else Vt.hide(this.showOther);Cn().bindTooltips(this.allSettings),this.dynamicOpts.children.length?Vt.show(this.dynamicOpts):Vt.hide(this.dynamicOpts)}},{key:"setOtherSettingsViz",value:function(e){if(e)return Vt.hide(this.showIcon),Vt.show(this.hideIcon,this.otherSettings),void(this.showHideMsg.textContent=Rt(D));Vt.hide(this.hideIcon,this.otherSettings),Vt.show(this.showIcon),this.showHideMsg.textContent=Rt(O)}},{key:"setConfig",value:function(e){for(var t,n=[],a={},o=[],s=0,i=xn(this.configElements);s=0&&this.configElements.splice(x,1)}return n}},{key:"setLoadedConfig",value:function(e){var t,n=this.setConfig(e);this.sectionize&&0!==n.length&&((t=this.loadedSettings).append.apply(t,xn(n)),this.reorder(this.loadedSettings),Vt.show(this.loadedSettings,this.loadedSettingsMsg),0===this.defaultSettings.children.length&&Vt.hide(this.defaultSettings,this.defaultSettingsMsg))}},{key:"map",value:function(e){var t,n={},a=fr(this.configElements);try{for(a.s();!(t=a.n()).done;){var o=r(t.value,2),s=o[0],i=o[1],c=Vt.safeSelector(i,"input");if(void 0===s.regAsset||s.regAsset===e)if(s.isboolean&&s.key)n[s.key]=c.checked?"1":"0";else if(s.isdate&&s.key){var l=c.min?Pr(new Date(c.min+"T00:00")):Number.MIN_SAFE_INTEGER,u=c.max?Pr(new Date(c.max+"T00:00")):Number.MAX_SAFE_INTEGER,h=c.value?Pr(new Date(c.value+"T00:00")):0;hu&&(h=u),n[s.key]=""+h}else c.value&&(s.repeatable&&n[s.key]?n[s.key]+=s.repeatable+c.value:n[s.key]=c.value)}}catch(e){a.e(e)}finally{a.f()}return n}},{key:"reorder",value:function(e){var t=this,n={};e.querySelectorAll("input").forEach((function(e){var a=e.dataset.configKey;if(a){var o,s=[],i=fr(t.configElements);try{for(i.s();!(o=i.n()).done;){var c=r(o.value,2),l=c[0],u=c[1];l.key===a&&s.push(u)}}catch(e){i.e(e)}finally{i.f()}n[a]=s}}));var a,o=fr(this.configOpts);try{for(o.s();!(a=o.n()).done;){var s,i=a.value,c=fr(n[i.key]||[]);try{for(c.s();!(s=c.n()).done;){var l=s.value;e.append(l)}}catch(e){c.e(e)}finally{c.f()}}}catch(e){o.e(e)}finally{o.f()}}}]),e}(),br=function(){function e(t,n,r,a){var o=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"page",void 0),h(this,"xc",void 0),h(this,"certFile",void 0),h(this,"bondAssetID",void 0),h(this,"pwCache",void 0),this.form=t,this.success=n,this.page=Vt.parseTemplate(t),this.certFile="",this.pwCache=a,Vt.bind(this.page.goBack,"click",(function(){return r()})),Vt.bind(this.page.bondStrengthField,"input",(function(){var e=Cn().assets[o.bondAssetID];if(e){var t=e.unitInfo,n=o.xc.bondAssets[e.symbol];o.page.bondAmt.textContent=Vt.formatCoinValue(o.totalBondAmount(n.amount),t)}})),Tr(t,this.page.submit,(function(){return o.submitForm()}))}var t,n;return u(e,[{key:"setExchange",value:function(e,t){this.xc=e,this.certFile=t;var n=this.page;tn.passwordIsCached()||this.pwCache&&this.pwCache.pw?Vt.hide(n.passBox):Vt.show(n.passBox),n.host.textContent=e.host}},{key:"setAsset",value:function(e){var t=Cn().assets[e],n=t.unitInfo;this.bondAssetID=t.id;var r=this.page,a=this.xc.bondAssets[t.symbol];r.bondAmt.textContent=Vt.formatCoinValue(this.totalBondAmount(a.amount),n),r.bondUnit.textContent=n.conventional.unit.toUpperCase(),r.logo.src=Vt.logoPath(t.symbol)}},{key:"totalBondAmount",value:function(e){var t;return+(null!==(t=this.page.bondStrengthField.value)&&void 0!==t?t:1)*e}},{key:"animate",value:(n=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(400,(function(e){t.style.transform="scale(".concat(e,")"),t.style.opacity=String(Math.pow(e,4));var n="".concat(500*(1-e),"px");t.style.top=n,t.style.left=n}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"submitForm",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((t=this.page).submit.classList.contains("selected")){e.next=3;break}return e.abrupt("return");case 3:if(n=Cn().assets[this.bondAssetID]){e.next=8;break}return t.regErr.innerText=Rt(gt),Vt.show(t.regErr),e.abrupt("return");case 8:return Vt.hide(t.regErr),r=this.xc.bondAssets[n.wallet.symbol],e.next=12,this.certFile;case 12:return a=e.sent,o=this.xc.host,s=t.appPass.value||(this.pwCache?this.pwCache.pw:""),i={addr:o,cert:a,pass:s,bond:this.totalBondAmount(r.amount),asset:r.id},t.appPass.value="",c=Cn().loading(this.form),e.next=20,yn("/api/postbond",i);case 20:if(l=e.sent,c(),Cn().checkResponse(l)){e.next=26;break}return t.regErr.textContent=l.msg,Vt.show(t.regErr),e.abrupt("return");case 26:this.success();case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),wr=function(){function e(t,n){var r=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"xc",void 0),h(this,"page",void 0),h(this,"assetTmpls",void 0),this.form=t,this.success=n,this.page=Vt.parseTemplate(t),Vt.cleanTemplates(this.page.marketTmpl,this.page.assetTmpl),Cn().registerNoteFeeder({createwallet:function(e){"QueuedCreationSuccess"===e.topic&&r.walletCreated(e.assetID)}})}var t;return u(e,[{key:"setExchange",value:function(e){var t=this;this.xc=e,this.assetTmpls={};var n=this.page;Vt.empty(n.assets,n.allMarkets);for(var a=function(e){return e.conventional.conversionFactor},o=function(t,r){var o=n.marketTmpl.cloneNode(!0),s=Vt.parseTemplate(o),i=e.assets[t.baseid],c=Cn().unitInfo(t.baseid,e),l=e.assets[t.quoteid],u=Cn().unitInfo(t.quoteid,e);if(0===a(c)||0===a(u))return null;if(void 0!==r){var h=r===t.baseid,d=e.assets[h?t.quoteid:t.baseid].symbol;s.logo.src=Vt.logoPath(d)}else{var p=s.logo.cloneNode(!0);s.logo.src=Vt.logoPath(i.symbol),p.src=Vt.logoPath(l.symbol);var f=s.logo.parentNode;f&&f.insertBefore(p,s.logo.nextSibling)}var m=i.symbol.toUpperCase(),v=l.symbol.toUpperCase();if(s.baseName.replaceWith(Vt.symbolize(m)),s.quoteName.replaceWith(Vt.symbolize(v)),s.lotSize.textContent=Vt.formatCoinValue(t.lotsize,c),s.lotSizeSymbol.replaceWith(Vt.symbolize(m)),t.spot){Vt.show(s.quoteLotSize);var g=a(u)/a(c),y=t.lotsize*t.spot.rate/Pn*g,b=Vt.formatCoinValue(y,u);s.quoteLotSize.textContent="(~".concat(b," ").concat(v,")")}return o},s=function(){var a=r(c[i],2),s=a[0],l=a[1],u=Cn().assets[l.id];if(!u)return"continue";var h=u.unitInfo,d=n.assetTmpl.cloneNode(!0);Vt.bind(d,"click",(function(){t.success(l.id)}));var p=t.assetTmpls[l.id]=Vt.parseTemplate(d);n.assets.appendChild(d),p.logo.src=Vt.logoPath(s);var f=Vt.formatCoinValue(l.amount,h);p.feeAmt.textContent=String(f),p.feeSymbol.replaceWith(Vt.symbolize(u.symbol)),p.confs.textContent=String(l.confs),kr(p.ready,u);for(var m=0,v=0,g=Object.values(e.markets);v0)if(r.totalForBond.textContent=Vt.formatCoinValue(2*s.amount+t,a.unitInfo),Vt.hide(r.sendEnough),Vt.hide(r.txFeeBox,r.sendEnoughForToken,r.txFeeBalanceBox),Vt.hide(r.sendEnoughWithEst),a.token){Vt.show(r.txFeeBox,r.sendEnoughForToken,r.txFeeBalanceBox);var l=Cn().assets[a.token.parentID];r.txFee.textContent=Vt.formatCoinValue(t,l.unitInfo),r.parentFees.textContent=Vt.formatCoinValue(t,l.unitInfo),r.tokenFees.textContent=Vt.formatCoinValue(s.amount,a.unitInfo),i(r.txFeeUnit,l.symbol),i(r.parentUnit,l.symbol),i(r.parentBalUnit,l.symbol),r.parentBal.textContent=l.wallet?Vt.formatCoinValue(l.wallet.balance.available,l.unitInfo):"0"}else Vt.show(r.sendEnoughWithEst);else Vt.show(r.sendEnough);Vt.show(e.synced?r.syncCheck:e.syncProgress>=1?r.syncSpinner:r.syncUncheck),Vt.show(e.balance.available>=2*s.amount+t?r.balCheck:r.balUncheck),r.progress.textContent=(100*e.syncProgress).toFixed(1),e.synced&&(this.progressed=!0),this.reportBalance(e.assetID)}},{key:"reportWalletState",value:function(e){this.progressed&&this.funded||(e.assetID===this.assetID&&this.reportProgress(e.synced,e.syncProgress),this.reportBalance(e.assetID))}},{key:"reportBalance",value:function(e){if(!this.funded&&-1!==this.assetID&&(e===this.assetID||e===this.parentID)){var t=this.page,n=Cn().assets[this.assetID],r=n.wallet.balance.available;if(t.balance.textContent=Vt.formatCoinValue(r,n.unitInfo),n.token){var a=Cn().assets[n.token.parentID],o=a.wallet.balance.available;if(t.parentBal.textContent=Vt.formatCoinValue(o,a.unitInfo),o=.999)return Vt.hide(n.syncRemaining),Vt.show(n.syncFinishingUp),Vt.show(n.syncRemainBox),void(n.syncFinishingUp.textContent=Rt(bt));var r=this.progressCache;if(r.push({stamp:(new Date).getTime(),progress:t}),!(r.length<2)){for(;r.length>20;)r.shift();var a=[r[0],r[r.length-1]],o=a[0],s=a[1],i=s.progress-o.progress;if(0!==i){Vt.hide(n.syncFinishingUp),Vt.show(n.syncRemaining),Vt.show(n.syncRemainBox);var c=i/(s.stamp-o.stamp),l=(1-s.progress)/c;n.syncRemain.textContent=Vt.formatDuration(l)}}}}]),e}(),Cr=function(){function e(t,n,r){var a=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"page",void 0),h(this,"currentAsset",void 0),this.page=Vt.idDescendants(t),this.form=t,this.pwCache=r||null,this.success=n,Tr(t,this.page.submitUnlock,(function(){return a.submit()}))}var t;return u(e,[{key:"refresh",value:function(e){var t=this.page;this.currentAsset=e,t.uwAssetLogo.src=Vt.logoPath(e.symbol),t.uwAssetName.textContent=e.name,t.uwAppPass.value="",t.unlockErr.textContent="",Vt.hide(t.unlockErr),tn.passwordIsCached()||this.pwCache&&this.pwCache.pw?Vt.hide(t.uwAppPassBox):Vt.show(t.uwAppPassBox)}},{key:"setError",value:function(e){this.page.unlockErr.textContent=e,Vt.show(this.page.unlockErr)}},{key:"showErrorOnly",value:function(e){this.setError(e),Vt.hide(this.page.uwAppPassBox),Vt.hide(this.page.submitUnlockDiv)}},{key:"submit",value:(t=o(w().mark((function e(){var t,n,r,a,o,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,(n=t.uwAppPass.value||(this.pwCache?this.pwCache.pw:""))||tn.passwordIsCached()){e.next=6;break}return t.unlockErr.textContent=Rt(x),Vt.show(t.unlockErr),e.abrupt("return");case 6:return r=this.currentAsset.id,Vt.hide(this.page.unlockErr),a={assetID:r,pass:n},t.uwAppPass.value="",o=Cn().loading(this.form),e.next=13,yn("/api/openwallet",a);case 13:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=18;break}return this.setError(s.msg),e.abrupt("return");case 18:this.pwCache&&(this.pwCache.pw=n),this.success(r);case 20:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Sr=function(){function e(t,n){var r=this;s(this,e),h(this,"form",void 0),h(this,"page",void 0),h(this,"order",void 0),h(this,"acceleratedRate",void 0),h(this,"earlyAcceleration",void 0),h(this,"currencyUnit",void 0),h(this,"success",void 0),this.form=t,this.success=n;var a=this.page=Vt.idDescendants(t);Vt.bind(a.accelerateSubmit,"click",(function(){r.submit()})),Vt.bind(a.submitEarlyConfirm,"click",(function(){r.sendAccelerateRequest()}))}var t,n,r,a;return u(e,[{key:"displayEarlyAccelerationMsg",value:function(){var e=this.page;this.earlyAcceleration&&(e.recentAccelerationTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60)),e.recentSwapTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60)),this.earlyAcceleration.wasAcceleration?(Vt.show(e.recentAccelerationMsg),Vt.hide(e.recentSwapMsg),e.recentAccelerationTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60))):(Vt.show(e.recentSwapMsg),Vt.hide(e.recentAccelerationMsg),e.recentSwapTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60))),Vt.hide(e.configureAccelerationDiv,e.accelerateErr),Vt.show(e.earlyAccelerationDiv))}},{key:"sendAccelerateRequest",value:(a=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.order,n=this.page,r={pw:n.acceleratePass.value,orderID:t.id,newRate:this.acceleratedRate},n.acceleratePass.value="",a=Cn().loading(n.accelerateMainDiv),e.next=7,yn("/api/accelerateorder",r);case 7:o=e.sent,a(),Cn().checkResponse(o)?(n.accelerateTxID.textContent=o.txID,Vt.hide(n.accelerateMainDiv,n.preAccelerateErr,n.accelerateErr),Vt.show(n.accelerateMsgDiv,n.accelerateSuccess),this.success()):(n.accelerateErr.textContent=Rt(lt,{msg:o.msg}),Vt.hide(n.earlyAccelerationDiv),Vt.show(n.accelerateErr,n.configureAccelerationDiv));case 10:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"submit",value:(r=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.earlyAcceleration?this.displayEarlyAccelerationMsg():this.sendAccelerateRequest();case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"refresh",value:(n=o(w().mark((function e(t){var n,r,a,o,s,i,c=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.order=t,e.next=4,yn("/api/preaccelerate",t.id);case 4:if(r=e.sent,Cn().checkResponse(r)){e.next=10;break}return n.preAccelerateErr.textContent=Rt(lt,{msg:r.msg}),Vt.hide(n.accelerateMainDiv,n.accelerateSuccess),Vt.show(n.accelerateMsgDiv,n.preAccelerateErr),e.abrupt("return");case 10:Vt.hide(n.accelerateMsgDiv,n.preAccelerateErr,n.accelerateErr,n.feeEstimateDiv,n.earlyAccelerationDiv),Vt.show(n.accelerateMainDiv,n.accelerateSuccess,n.configureAccelerationDiv),a=r.preAccelerate,this.earlyAcceleration=a.earlyAcceleration,this.currencyUnit=a.suggestedRange.yUnit,n.accelerateAvgFeeRate.textContent="".concat(a.swapRate," ").concat(a.suggestedRange.yUnit),n.accelerateCurrentFeeRate.textContent="".concat(a.suggestedRate," ").concat(a.suggestedRange.yUnit),this.acceleratedRate=a.suggestedRange.start.y,o=function(){},s=function(e,t){c.acceleratedRate=t},i=new Dn(a.suggestedRange,a.suggestedRange.start.x,s,(function(){return c.updateAccelerationEstimate()}),o,!0),Vt.empty(n.sliderContainer),n.sliderContainer.appendChild(i.control),this.updateAccelerationEstimate();case 25:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"updateAccelerationEstimate",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=this.order,r={orderID:n.id,newRate:this.acceleratedRate},a=Cn().loading(t.sliderContainer),e.next=6,yn("/api/accelerationestimate",r);case 6:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=12;break}return t.accelerateErr.textContent=Rt(ct,{msg:o.msg}),Vt.show(t.accelerateErr),e.abrupt("return");case 12:t.feeRateEstimate.textContent="".concat(this.acceleratedRate," ").concat(this.currencyUnit),n.sell?(s=n.baseID,i=n.baseSymbol):(s=n.quoteID,i=n.quoteSymbol),c=Cn().unitInfo(s),t.feeEstimate.textContent="".concat(o.fee/c.conventional.conversionFactor," ").concat(i),Vt.show(t.feeEstimateDiv);case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Er=function(){function e(t,n,r,a){var o=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"page",void 0),h(this,"knownExchanges",void 0),h(this,"dexToUpdate",void 0),this.form=t,this.success=n,this.pwCache=r||null;var i=this.page=Vt.parseTemplate(t);i.selectedCert.textContent=Rt(ie),Vt.bind(i.skipRegistration,"change",(function(){return o.showOrHidePWBox()})),Vt.bind(i.certFile,"change",(function(){return o.onCertFileChange()})),Vt.bind(i.removeCert,"click",(function(){return o.clearCertFile()})),Vt.bind(i.addCert,"click",(function(){return i.certFile.click()})),Vt.bind(i.showCustom,"click",(function(){Vt.hide(i.showCustom),Vt.show(i.customBox,i.auth)})),this.knownExchanges=Array.from(i.knownXCs.querySelectorAll(".known-exchange"));var c,l=fr(this.knownExchanges);try{var u=function(){var e=c.value;Vt.bind(e,"click",(function(){var t,n=e.dataset.host,a=fr(o.knownExchanges);try{for(a.s();!(t=a.n()).done;)t.value.classList.remove("selected")}catch(e){a.e(e)}finally{a.f()}if(o.skipRegistration()||tn.passwordIsCached()||r&&r.pw)return o.checkDEX(n);e.classList.add("selected"),i.appPW.focus(),i.addr.value=n}))};for(l.s();!(c=l.n()).done;)u()}catch(e){l.e(e)}finally{l.f()}Tr(t,i.submit,(function(){return o.checkDEX()})),a&&(Vt.hide(i.addDexHdr,i.skipRegistrationBox),Vt.show(i.updateDexHdr),this.dexToUpdate=a),this.refresh()}var t,n,r;return u(e,[{key:"refresh",value:function(){var e=this.page;e.addr.value="",e.appPW.value="",this.clearCertFile(),Vt.hide(e.err),0===this.knownExchanges.length||this.dexToUpdate?(Vt.show(e.customBox,e.auth),Vt.hide(e.showCustom,e.knownXCs,e.pickServerMsg,e.addCustomMsg)):(Vt.hide(e.customBox),Vt.show(e.showCustom));var t,n=fr(this.knownExchanges);try{for(n.s();!(t=n.n()).done;)t.value.classList.remove("selected")}catch(e){n.e(e)}finally{n.f()}this.showOrHidePWBox()}},{key:"showOrHidePWBox",value:function(){var e=!(tn.passwordIsCached()||this.pwCache&&this.pwCache.pw||this.skipRegistration()),t=this.page;e?Vt.show(t.appPWBox,t.auth):(Vt.hide(t.appPWBox),Vt.setVis(Vt.isDisplayed(t.customBox),t.auth))}},{key:"skipRegistration",value:function(){var e;return null!==(e=this.page.skipRegistration.checked)&&void 0!==e&&e}},{key:"animate",value:(r=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(550,(function(e){t.style.transform="scale(".concat(.9+.1*e,")"),t.style.opacity=String(Math.pow(e,4))}),"easeOut");case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"checkDEX",value:(n=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.page,Vt.hide(n.err),""!==(t=t||n.addr.value)){e.next=7;break}return n.err.textContent=Rt(vt),Vt.show(n.err),e.abrupt("return");case 7:if(r="",!n.certFile.value){e.next=14;break}if(!(a=n.certFile.files)||!a.length){e.next=14;break}return e.next=13,a[0].text();case 13:r=e.sent;case 14:return o=this.skipRegistration(),s="",o||tn.passwordIsCached()||(s=n.appPW.value||(this.pwCache?this.pwCache.pw:"")),this.dexToUpdate?(i="/api/updatedexhost",c={newHost:t,cert:r,pw:s,oldHost:this.dexToUpdate}):(i=o?"/api/adddex":"/api/discoveracct",c={addr:t,cert:r,pass:s}),l=Cn().loading(this.form),e.next=21,yn(i,c);case 21:if(u=e.sent,l(),Cn().checkResponse(u)){e.next=26;break}return String(u.msg).includes("certificate required")?Vt.show(n.needCert):(n.err.textContent=u.msg,Vt.show(n.err)),e.abrupt("return");case 26:if(this.dexToUpdate||!(o||u.paid||Object.keys(u.xc.pendingBonds).length>0)){e.next=32;break}return e.next=29,Cn().fetchUser();case 29:return e.next=31,Cn().loadPage("markets");case 31:return e.abrupt("return");case 32:this.pwCache&&(this.pwCache.pw=s),this.success(u.xc,r);case 34:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"onCertFileChange",value:(t=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,(n=t.certFile.files)&&n.length){e.next=4;break}return e.abrupt("return");case 4:t.selectedCert.textContent=n[0].name,Vt.show(t.removeCert),Vt.hide(t.addCert);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"clearCertFile",value:function(){var e=this.page;e.certFile.value="",e.selectedCert.textContent=Rt(ie),Vt.hide(e.removeCert),Vt.show(e.addCert)}}]),e}(),Ar=function(){function e(t,n,r,a){var o=this;s(this,e),h(this,"form",void 0),h(this,"addr",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"page",void 0),this.form=t,this.addr=n,this.success=r,this.pwCache=a||null;var i=this.page=Vt.parseTemplate(t);i.dexHost.textContent=n,Tr(t,i.submit,(function(){return o.checkDEX()})),this.refresh()}var t,n;return u(e,[{key:"refresh",value:function(){var e=this.page;e.appPW.value="",Vt.hide(e.err),tn.passwordIsCached()||this.pwCache&&this.pwCache.pw?Vt.hide(e.appPWBox):Vt.show(e.appPWBox)}},{key:"animate",value:(n=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(550,(function(e){t.style.transform="scale(".concat(.9+.1*e,")"),t.style.opacity=String(Math.pow(e,4))}),"easeOut");case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"checkDEX",value:(t=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.err),n="",tn.passwordIsCached()||(n=t.appPW.value||(this.pwCache?this.pwCache.pw:"")),r={addr:this.addr,pass:n},a=Cn().loading(this.form),e.next=8,yn("/api/discoveracct",r);case 8:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=14;break}return t.err.textContent=o.msg,Vt.show(t.err),e.abrupt("return");case 14:if(!o.paid){e.next=20;break}return e.next=17,Cn().fetchUser();case 17:return e.next=19,Cn().loadPage("markets");case 19:return e.abrupt("return");case 20:this.pwCache&&(this.pwCache.pw=n),this.success(o.xc);case 22:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Fr=function(){function e(t,n,r){var a=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"headerTxt",void 0),h(this,"page",void 0),this.success=n,this.form=t,this.pwCache=r||null;var o=this.page=Vt.parseTemplate(t);this.headerTxt=o.header.textContent||"",Tr(t,o.submit,(function(){a.submit()})),Cn().registerNoteFeeder({login:function(e){a.handleLoginNote(e)}})}var t,n;return u(e,[{key:"handleLoginNote",value:function(e){if(""!==e.details){var t=Vt.idel(this.form,"loaderMsg");t&&(t.textContent=e.details)}}},{key:"focus",value:function(){this.page.pw.focus()}},{key:"submit",value:(n=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.errMsg),n=t.pw.value||"",t.pw.value="",r=t.rememberPass.checked,""!==n){e.next=9;break}return t.errMsg.textContent=Rt(k),Vt.show(t.errMsg),e.abrupt("return");case 9:return a=Cn().loading(this.form),e.next=12,yn("/api/login",{pass:n,rememberPass:r});case 12:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=18;break}return t.errMsg.textContent=o.msg,Vt.show(t.errMsg),e.abrupt("return");case 18:o.notes&&(o.notes.reverse(),Cn().setNotes(o.notes)),this.pwCache&&(this.pwCache.pw=n),this.success();case 21:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"animate",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(550,(function(e){t.style.transform="scale(".concat(.9+.1*e,")"),t.style.opacity=String(Math.pow(e,4))}),"easeOut");case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Ir=function(){function e(t){var n=this;s(this,e),h(this,"form",void 0),h(this,"page",void 0),h(this,"assetID",void 0),this.form=t;var r=this.page=Vt.idDescendants(t);Vt.bind(r.newDepAddrBttn,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.newDepositAddress();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(r.copyAddressBtn,"click",(function(){n.copyAddress()}))}var t,n,r;return u(e,[{key:"setAsset",value:(r=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.assetID=t,n=this.page,Vt.hide(n.depositErr),r=Cn().assets[t],n.depositLogo.src=Vt.logoPath(r.symbol),a=Cn().walletMap[t],n.depositName.textContent=r.name,n.depositAddress.textContent=a.address,n.qrcode.src="/generateqrcode?address=".concat(a.address),0!=(2&a.traits)?Vt.show(n.newDepAddrBttn):Vt.hide(n.newDepAddrBttn);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"newDepositAddress",value:(n=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.depositErr),n=Cn().loading(this.form),e.next=5,yn("/api/depositaddress",{assetID:this.assetID});case 5:if(r=e.sent,n(),Cn().checkResponse(r)){e.next=11;break}return t.depositErr.textContent=r.msg,Vt.show(t.depositErr),e.abrupt("return");case 11:t.depositAddress.textContent=r.address,t.qrcode.src="/generateqrcode?address=".concat(r.address);case 13:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"copyAddress",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,navigator.clipboard.writeText(t.depositAddress.textContent||"").then((function(){Vt.show(t.copyAlert),setTimeout((function(){Vt.hide(t.copyAlert)}),800)})).catch((function(e){console.error("Unable to copy: ",e)}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Rr=300;function Dr(e,t){return Or.apply(this,arguments)}function Or(){return(Or=o(w().mark((function e(t,n){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=document.body.offsetWidth/2,e.next=3,Vt.animate(Rr,(function(e){t.style.right="".concat(e*r,"px")}),"easeInHard");case 3:return Vt.hide(t),t.style.right="0",n.style.right=String(-r),Vt.show(n),n.querySelector("input")&&Vt.safeSelector(n,"input").focus(),e.next=10,Vt.animate(Rr,(function(e){n.style.right="".concat(e*r-r,"px")}),"easeOutHard");case 10:n.style.right="0";case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Tr(e,t,n){var r=function(e){e.preventDefault&&e.preventDefault(),n(e)};Vt.bind(t,"click",r),Vt.bind(e,"submit",r)}function Pr(e){return Math.floor(e.getTime()/1e3)}function Lr(e){return function(e){return new Date(e.getTime()-60*e.getTimezoneOffset()*1e3)}(e).toISOString().split("T")[0]}var Mr=function(e){an(g,e);var t,n,r,a,i,c,l,d,p,f,m,v=(f=g,m=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(f);if(m){var n=sn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return on(this,e)});function g(e,t){var n;s(this,g),h(nn(n=v.call(this)),"body",void 0),h(nn(n),"pwCache",void 0),h(nn(n),"currentDEX",void 0),h(nn(n),"page",void 0),h(nn(n),"loginForm",void 0),h(nn(n),"dexAddrForm",void 0),h(nn(n),"discoverAcctForm",void 0),h(nn(n),"newWalletForm",void 0),h(nn(n),"regAssetForm",void 0),h(nn(n),"walletWaitForm",void 0),h(nn(n),"confirmRegisterForm",void 0),n.body=e,n.pwCache={pw:""};var r=n.page=Vt.idDescendants(e);t.host&&r.dexAddrForm.classList.contains("selected")&&(r.dexAddrForm.classList.remove("selected"),r.discoverAcctForm.classList.add("selected"),r.discoverAcctForm.dataset.host=t.host),e.querySelectorAll(".form-closer").forEach((function(e){return Vt.hide(e)})),Tr(r.appPWForm,r.appPWSubmit,(function(){return n.setAppPass()})),Vt.bind(r.showSeedRestore,"click",(function(){Vt.show(r.seedRestore),Vt.hide(r.showSeedRestore)})),n.loginForm=new Fr(r.loginForm,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:n.discoverAcctForm?(n.discoverAcctForm.refresh(),Dr(r.loginForm,r.discoverAcctForm)):(n.dexAddrForm.refresh(),Dr(r.loginForm,r.dexAddrForm));case 3:case"end":return e.stop()}}),e)}))),n.pwCache),n.newWalletForm=new vr(r.newWalletForm,(function(e){return n.newWalletCreated(e)}),n.pwCache,(function(){return n.animateRegAsset(r.newWalletForm)})),n.dexAddrForm=new Er(r.dexAddrForm,function(){var e=o(w().mark((function e(t,a){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.requestFeepayment(r.dexAddrForm,t,a);case 1:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),n.pwCache);var a=r.discoverAcctForm.dataset.host;a&&(n.discoverAcctForm=new Ar(r.discoverAcctForm,a,function(){var e=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.requestFeepayment(r.discoverAcctForm,t,"");case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.pwCache)),n.regAssetForm=new wr(r.regAssetForm,function(){var e=o(w().mark((function e(t){var a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.confirmRegisterForm.setAsset(t),a=Cn().assets[t],!(o=a.wallet)){e.next=14;break}if(s=n.currentDEX.bondAssets[a.symbol],!(o.synced&&o.balance.available>s.amount)){e.next=8;break}return n.animateConfirmForm(r.regAssetForm),e.abrupt("return");case 8:return e.next=10,n.getBondsFeeBuffer(t,r.regAssetForm);case 10:return i=e.sent,n.walletWaitForm.setWallet(o,i),Dr(r.regAssetForm,r.walletWait),e.abrupt("return");case 14:n.newWalletForm.setAsset(t),Dr(r.regAssetForm,r.newWalletForm);case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),n.walletWaitForm=new xr(r.walletWait,(function(){n.animateConfirmForm(r.walletWait)}),(function(){n.animateRegAsset(r.walletWait)})),n.confirmRegisterForm=new br(r.confirmRegForm,(function(){n.registerDEXSuccess()}),(function(){n.animateRegAsset(r.confirmRegForm)}),n.pwCache);var i=Vt.safeSelector(r.forms,":scope > form.selected");switch(i.classList.remove("selected"),i){case r.loginForm:n.loginForm.animate();break;case r.dexAddrForm:n.dexAddrForm.animate();break;case r.discoverAcctForm:n.discoverAcctForm.animate()}return Vt.show(i),Cn().authed()&&n.auth(),n}return u(g,[{key:"unload",value:function(){this.pwCache.pw=""}},{key:"auth",value:(p=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:case"end":return e.stop()}}),e)}))),function(){return p.apply(this,arguments)})},{key:"requestFeepayment",value:(d=o(w().mark((function e(t,n,r){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.currentDEX=n,this.confirmRegisterForm.setExchange(n,r),this.walletWaitForm.setExchange(n),this.regAssetForm.setExchange(n),this.animateRegAsset(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"animateRegAsset",value:(l=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vt.hide(t),this.regAssetForm.animate(),Vt.show(this.page.regAssetForm);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"animateConfirmForm",value:(c=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.confirmRegisterForm.animate(),Vt.hide(t),Vt.show(this.page.confirmRegForm);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"getBondsFeeBuffer",value:(i=o(w().mark((function e(t,n){var r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Cn().loading(n),e.next=3,yn("/api/bondsfeebuffer",{assetID:t});case 3:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=7;break}return e.abrupt("return",0);case 7:return e.abrupt("return",a.feeBuffer);case 8:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"setAppPass",value:(a=o(w().mark((function e(){var t,n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.appPWErrMsg),n=t.appPW.value||"",r=t.appPWAgain.value,""!==n){e.next=8;break}return t.appPWErrMsg.textContent=Rt(k),Vt.show(t.appPWErrMsg),e.abrupt("return");case 8:if(n===r){e.next=12;break}return t.appPWErrMsg.textContent=Rt(K),Vt.show(t.appPWErrMsg),e.abrupt("return");case 12:return Cn().setNotes([]),t.appPW.value="",t.appPWAgain.value="",a=Cn().loading(t.appPWForm),o=t.seedInput.value,s=t.rememberPass.checked,e.next=20,yn("/api/init",{pass:n,seed:o,rememberPass:s});case 20:if(i=e.sent,a(),Cn().checkResponse(i)){e.next=26;break}return t.appPWErrMsg.textContent=i.msg,Vt.show(t.appPWErrMsg),e.abrupt("return");case 26:return this.pwCache.pw=n,this.auth(),Cn().updateMenuItemsDisplay(),this.newWalletForm.refresh(),this.dexAddrForm.refresh(),e.next=33,Dr(t.appPWForm,t.dexAddrForm);case 33:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getCertFile",value:(r=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="",!this.dexAddrForm.page.certFile.value){e.next=7;break}if(!(n=this.dexAddrForm.page.certFile.files)||!n.length){e.next=7;break}return e.next=6,n[0].text();case 6:t=e.sent;case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"registerDEXSuccess",value:(n=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:return e.next=4,Cn().loadPage("markets");case 4:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"newWalletCreated",value:(t=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.regAssetForm.refresh(),e.next=3,Cn().fetchUser();case 3:if(n=e.sent){e.next=6;break}return e.abrupt("return");case 6:if(r=this.page,a=n.assets[t],o=a.wallet,s=this.currentDEX.bondAssets[a.symbol].amount,!(o.synced&&o.balance.available>s)){e.next=14;break}return e.next=13,this.animateConfirmForm(r.newWalletForm);case 13:return e.abrupt("return");case 14:return e.next=16,this.getBondsFeeBuffer(t,r.newWalletForm);case 16:return i=e.sent,this.walletWaitForm.setWallet(o,i),e.next=20,Dr(r.newWalletForm,r.walletWait);case 20:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),g}(mn);var Br=function(e){an(i,e);var t,n,r,a=(n=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(n);if(r){var a=sn(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return on(this,e)});function i(e){var t;return s(this,i),h(nn(t=a.call(this)),"form",void 0),h(nn(t),"loginForm",void 0),t.form=Vt.idel(e,"loginForm"),Vt.show(t.form),t.loginForm=new Fr(t.form,(function(){t.loggedIn()})),t.loginForm.focus(),t}return u(i,[{key:"loggedIn",value:(t=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:return e.next=4,Cn().loadPage("markets");case 4:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),i}(mn);function Wr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return qr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function qr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n form"),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){t.closePopups()}))})),Vt.bind(n.cancelForce,"click",(function(){t.closePopups()})),t.selectedAssetID=-1,Vt.cleanTemplates(n.iconSelectTmpl,n.balanceDetailRow,n.recentOrderTmpl),Vt.bind(n.createWallet,"click",(function(){return t.showNewWallet(t.selectedAssetID)})),Vt.bind(n.connectBttn,"click",(function(){return t.doConnect(t.selectedAssetID)})),Vt.bind(n.send,"click",(function(){return t.showSendForm(t.selectedAssetID)})),Vt.bind(n.receive,"click",(function(){return t.showDeposit(t.selectedAssetID)})),Vt.bind(n.unlockBttn,"click",(function(){return t.openWallet(t.selectedAssetID)})),Vt.bind(n.lockBttn,"click",(function(){return t.lock(t.selectedAssetID)})),Vt.bind(n.reconfigureBttn,"click",(function(){return t.showReconfig(t.selectedAssetID)})),Vt.bind(n.rescanWallet,"click",(function(){return t.rescanWallet(t.selectedAssetID)})),t.newWalletForm=new vr(n.newWalletForm,(function(e){var r={assetName:Cn().assets[e].name};t.assetUpdated(e,n.newWalletForm,Rt(xe,r)),t.sortAssetButtons()})),t.reconfigForm=new yr(n.reconfigInputs,!1),t.walletCfgGuide=Vt.tmplElement(n.reconfigForm,"walletCfgGuide"),t.unlockForm=new Cr(n.unlockWalletForm,(function(e){return t.openWalletSuccess(e,n.unlockWalletForm)})),Tr(n.sendForm,n.submitSendForm,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.stepSend();case 1:case"end":return e.stop()}}),e)})))),Tr(n.vSendForm,n.vSend,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.send();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.vCancelSend,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.cancelSend();case 1:case"end":return e.stop()}}),e)})))),Tr(n.reconfigForm,n.submitReconfig,(function(){return t.reconfig()})),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){return t.closePopups()}))})),Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||t.closePopups()})),t.keyup=function(e){"Escape"===e.key&&Vt.isDisplayed(t.page.forms)&&t.closePopups()},Vt.bind(document,"keyup",t.keyup),Vt.bind(n.downloadLogs,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.downloadLogs();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.exportWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.displayExportWalletAuth();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.recoverWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showRecoverWallet();case 1:case"end":return e.stop()}}),e)})))),Tr(n.exportWalletAuth,n.exportWalletAuthSubmit,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.exportWalletAuthSubmit();case 1:case"end":return e.stop()}}),e)})))),Tr(n.recoverWalletConfirm,n.recoverWalletSubmit,(function(){t.recoverWallet()})),Tr(n.confirmForce,n.confirmForceSubmit,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.confirmForceSubmit();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.disableWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showToggleWalletStatus(!0);case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.enableWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showToggleWalletStatus(!1);case 1:case"end":return e.stop()}}),e)})))),Tr(n.toggleWalletStatusConfirm,n.toggleWalletStatusSubmit,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.toggleWalletStatus();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.managePeers,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showManagePeersForm();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.addPeerSubmit,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.submitAddPeer();case 1:case"end":return e.stop()}}),e)})))),t.depositAddrForm=new Ir(n.deposit),Vt.bind(n.walletBal,"click",(function(){t.populateMaxSend()})),Vt.bind(n.sendAmt,"input",(function(){var e=Cn().assets[t.selectedAssetID].unitInfo,r=parseFloat(n.sendAmt.value||"0"),a=e.conventional.conversionFactor;t.showFiatValue(t.selectedAssetID,r*a,n.sendValue)})),Vt.bind(n.maxSend,"click",(function(){t.populateMaxSend()})),Vt.bind(n.sendAddr,"input",o(w().mark((function e(){var r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Cn().assets[t.selectedAssetID],Vt.hide(n.validAddr),n.sendAddr.classList.remove("invalid"),a=n.sendAddr.value||"",r&&""!==a){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,t.validateSendAddress(a,r.id);case 8:e.sent?Vt.show(n.validAddr):n.sendAddr.classList.add("invalid");case 10:case"end":return e.stop()}}),e)})))),Vt.bind(n.showChangePW,"click",(function(){t.changeWalletPW=!t.changeWalletPW,t.setPWSettingViz(t.changeWalletPW)})),Vt.bind(n.changeWalletTypeSelect,"change",(function(){t.changeWalletType()})),Vt.bind(n.showChangeType,"click",(function(){Vt.isHidden(n.changeWalletType)?(Vt.show(n.changeWalletType,n.changeTypeHideIcon),Vt.hide(n.changeTypeShowIcon),n.changeTypeMsg.textContent=Rt(me)):t.showReconfig(t.selectedAssetID,!0)})),Cn().registerNoteFeeder({fiatrateupdate:function(e){t.handleRatesNote(e)},balance:function(e){t.handleBalanceNote(e)},walletstate:function(e){t.handleWalletStateNote(e)},walletconfig:function(e){t.handleWalletStateNote(e)},createwallet:function(e){t.handleCreateWalletNote(e)}});var r=t.sortAssetButtons().id,a=tn.fetchLocal(tn.selectedAssetLK);return a&&(r=Number(a)),t.setSelectedAsset(r),t}return u(V,[{key:"closePopups",value:function(){Vt.hide(this.page.forms),this.animation&&this.animation.stop()}},{key:"stepSend",value:(N=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d,p,f,m,v,g,y,b,k,x;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.vSendErr,t.sendErr,t.vSendEstimates,t.txFeeNotAvailable),n=parseInt(t.sendForm.dataset.assetID||""),r=Cn().assets[n].token,a=t.subtractCheckBox.checked||!1,o=Cn().unitInfo(n).conventional.conversionFactor,s=Math.round(parseFloat(t.sendAmt.value||"")*o),""!==(i=t.sendAddr.value||"")){e.next=10;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Me,{address:i})));case 10:if(c=Cn().assets[n],l=c.wallet,u=c.unitInfo,h=c.symbol,d=0,0==(1024&l.traits)){e.next=36;break}return p={addr:t.sendAddr.value,assetID:n,subtract:a,value:s},f=Cn().loading(t.sendForm),e.next=17,yn("/api/txfee",p);case 17:if(m=e.sent,f(),Cn().checkResponse(m)){e.next=29;break}return t.txFeeNotAvailable.dataset.tooltip=Rt(Be,{err:m.msg}),Vt.show(t.txFeeNotAvailable),e.next=24,this.validateSendAddress(i,n);case 24:if(e.sent){e.next=27;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Me,{address:i||""})));case 27:e.next=34;break;case 29:if(!m.ok){e.next=34;break}if(m.validaddress){e.next=32;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Me,{address:t.sendAddr.value||""})));case 32:d=m.txfee,Vt.show(t.vSendEstimates);case 34:e.next=41;break;case 36:return e.next=38,this.validateSendAddress(i,n);case 38:if(e.sent){e.next=41;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Me,{address:i||""})));case 41:return t.vSendSymbol.textContent=h.toUpperCase(),t.vSendLogo.src=Vt.logoPath(h),r?(v=Cn().assets[r.parentID],g=v.unitInfo,y=v.symbol,t.vSendFee.textContent=Vt.formatFullPrecision(d,g)+" "+y):t.vSendFee.textContent=Vt.formatFullPrecision(d,u),this.showFiatValue(n,d,t.vSendFeeFiat),t.vSendDestinationAmt.textContent=Vt.formatFullPrecision(s-d,u),t.vTotalSend.textContent=Vt.formatFullPrecision(s,u),this.showFiatValue(n,s,t.vTotalSendFiat),t.vSendAddr.textContent=t.sendAddr.value||"",b=l.balance.available-s,t.balanceAfterSend.textContent=Vt.formatFullPrecision(b,u),this.showFiatValue(n,b,t.balanceAfterSendFiat),Vt.show(t.approxSign),a||(Vt.hide(t.approxSign),t.vSendDestinationAmt.textContent=Vt.formatFullPrecision(s,u),k=s,r||(k+=d),t.vTotalSend.textContent=Vt.formatFullPrecision(k,u),this.showFiatValue(n,k,t.vTotalSendFiat),x=l.balance.available-s,r||(x-=d),x<=0?(t.balanceAfterSend.textContent=Vt.formatFullPrecision(0,u),this.showFiatValue(n,0,t.balanceAfterSendFiat)):(t.balanceAfterSend.textContent=Vt.formatFullPrecision(x,u),this.showFiatValue(n,x,t.balanceAfterSendFiat))),Vt.hide(t.sendForm),e.next=57,this.showForm(t.vSendForm);case 57:case"end":return e.stop()}}),e,this)}))),function(){return N.apply(this,arguments)})},{key:"cancelSend",value:(q=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.vSendForm,t.sendErr),e.next=4,this.showForm(t.sendForm);case 4:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"validateSendAddress",value:(W=o(w().mark((function e(t,n){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,yn("/api/validateaddress",{addr:t,assetID:n});case 2:return r=e.sent,e.abrupt("return",Cn().checkResponse(r));case 4:case"end":return e.stop()}}),e)}))),function(e,t){return W.apply(this,arguments)})},{key:"setPWSettingViz",value:function(e){if(e)return Vt.hide(this.page.showIcon),Vt.show(this.page.hideIcon,this.page.changePW),void(this.page.switchPWMsg.textContent=Rt(Q));Vt.hide(this.page.hideIcon,this.page.changePW),Vt.show(this.page.showIcon),this.page.switchPWMsg.textContent=Rt(Y)}},{key:"updateWalletPeersTable",value:(B=o(w().mark((function e(){var t,n,r,a,s,i,c=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.peerSpinner),e.next=4,yn("/api/getwalletpeers",{assetID:this.selectedAssetID});case 4:if(n=e.sent,Cn().checkResponse(n)){e.next=9;break}return t.managePeersErr.textContent=n.msg,Vt.show(t.managePeersErr),e.abrupt("return");case 9:for(;t.peersTableBody.firstChild;)t.peersTableBody.removeChild(t.peersTableBody.firstChild);(r=n.peers||[]).sort((function(e,t){return e.source-t.source})),a=Rt(ze),s=Rt(Ve),i=Rt(je),r.forEach((function(e){var n,r=t.peerTableRow.cloneNode(!0),l=Vt.parseTemplate(r);switch(l.addr.textContent=e.addr,e.source){case un.WalletDefault:l.source.textContent=a;break;case un.UserAdded:l.source.textContent=s;break;case un.Discovered:l.source.textContent=i}if(n=e.connected?c.page.connectedIconTmpl.cloneNode(!0):c.page.disconnectedIconTmpl.cloneNode(!0),l.connected.appendChild(n),e.source===un.UserAdded){var u=c.page.removeIconTmpl.cloneNode(!0);Vt.bind(u,"click",o(w().mark((function n(){var r;return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return Vt.hide(t.managePeersErr),n.next=3,yn("/api/removewalletpeer",{assetID:c.selectedAssetID,addr:e.addr});case 3:if(r=n.sent,Cn().checkResponse(r)){n.next=8;break}return t.managePeersErr.textContent=r.msg,Vt.show(t.managePeersErr),n.abrupt("return");case 8:c.spinUntilPeersUpdate();case 9:case"end":return n.stop()}}),n)})))),l.remove.appendChild(u)}t.peersTableBody.appendChild(r)}));case 16:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"showManagePeersForm",value:(M=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,e.next=3,this.updateWalletPeersTable();case 3:Vt.hide(t.managePeersErr),this.showForm(t.managePeersForm);case 5:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"submitAddPeer",value:(L=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.managePeersErr),e.next=4,yn("/api/addwalletpeer",{assetID:this.selectedAssetID,addr:t.addPeerInput.value});case 4:if(n=e.sent,Cn().checkResponse(n)){e.next=9;break}return t.managePeersErr.textContent=n.msg,Vt.show(t.managePeersErr),e.abrupt("return");case 9:this.spinUntilPeersUpdate(),t.addPeerInput.value="";case 11:case"end":return e.stop()}}),e,this)}))),function(){return L.apply(this,arguments)})},{key:"spinUntilPeersUpdate",value:(P=o(w().mark((function e(){var t,n=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,Vt.show(t.peerSpinner),setTimeout((function(){Vt.isDisplayed(t.peerSpinner)&&n.updateWalletPeersTable()}),1e4);case 3:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"showToggleWalletStatus",value:function(e){var t=this.page;Vt.hide(t.toggleWalletStatusErr,t.walletStatusDisable,t.disableWalletMsg,t.walletStatusEnable,t.enableWalletMsg),e?Vt.show(t.walletStatusDisable,t.disableWalletMsg):Vt.show(t.walletStatusEnable,t.enableWalletMsg),this.showForm(t.toggleWalletStatusConfirm)}},{key:"toggleWalletStatus",value:(T=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.toggleWalletStatusErr),n=Cn().assets[this.selectedAssetID],r=!n.wallet.disabled,a={assetID:this.selectedAssetID,disable:r},o={assetName:n.name},s=Cn().loading(t.toggleWalletStatusConfirm),e.next=10,yn("/api/togglewalletstatus",a);case 10:if(i=e.sent,s(),Cn().checkResponse(i)){e.next=16;break}return i.code===cn.activeOrdersErr?t.toggleWalletStatusErr.textContent=Rt(Ie,o):t.toggleWalletStatusErr.textContent=i.msg,Vt.show(t.toggleWalletStatusErr),e.abrupt("return");case 16:c=Rt(Ae,o),r||(c=Rt(Fe,o)),this.assetUpdated(this.selectedAssetID,t.toggleWalletStatusConfirm,c);case 19:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"showBox",value:(O=o(w().mark((function e(t,n){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.style.opacity="0",Vt.show(t),n&&n.focus(),e.next=5,Vt.animate(300,(function(e){t.style.opacity="".concat(e)}),"easeOut");case 5:t.style.opacity="1",this.displayed=t;case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"showForm",value:(D=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.currentForm=t,this.forms.forEach((function(e){return Vt.hide(e)})),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(300,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"showSuccess",value:(R=o(w().mark((function e(t){var n,a,o,s,i,c,l,u,h,d=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.page).successMessage.textContent=t,this.currentForm=n.checkmarkForm,this.forms.forEach((function(e){return Vt.hide(e)})),Vt.show(n.forms,n.checkmarkForm),n.checkmarkForm.style.right="0",n.checkmark.style.fontSize="0px",a=tn.isDark()?[223,226,225]:[51,51,51],o=r(a,3),s=o[0],i=o[1],c=o[2],l=16-s,u=163-i,h=16-c,this.animation=new jt(1200,(function(e){n.checkmark.style.fontSize="".concat(80*e,"px"),n.checkmark.style.color="rgb(".concat(s+e*l,", ").concat(i+e*u,", ").concat(c+e*h,")")}),"easeOutElastic",(function(){d.animation=new jt(1500,(function(){}),"",(function(){d.currentForm===n.checkmarkForm&&d.closePopups()}))}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"showNewWallet",value:(I=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=n.newWalletForm,this.newWalletForm.setAsset(t),a=this.newWalletForm.loadDefaults(),e.next=6,this.showForm(r);case 6:return e.next=8,a;case 8:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"sortAssetButtons",value:function(){var e=this,t=this.page;this.assetButtons={},Vt.empty(t.assetSelect);var n=xn(Object.values(Cn().assets));n.sort((function(e,t){return e.wallet&&!t.wallet?-1:!e.wallet&&t.wallet?1:e.symbol.localeCompare(t.symbol)}));var r,a=Wr(n);try{var o=function(){var n=r.value,a=t.iconSelectTmpl.cloneNode(!0);t.assetSelect.appendChild(a);var o=Vt.parseTemplate(a);e.assetButtons[n.id]={tmpl:o,bttn:a},e.updateAssetButton(n.id),Vt.bind(a,"click",(function(){e.setSelectedAsset(n.id),tn.storeLocal(tn.selectedAssetLK,String(n.id))}))};for(a.s();!(r=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}return t.assetSelect.classList.remove("invisible"),n[0]}},{key:"updateAssetButton",value:function(e){var t,n=Cn().assets[e],r=this.assetButtons[e],a=r.bttn,o=r.tmpl;if(Vt.hide(o.fiat,o.noWallet),a.classList.add("nowallet"),(t=o.img).src||(t.src=Vt.logoPath(n.symbol)),o.name.textContent=n.name,n.wallet){a.classList.remove("nowallet");var s=n.wallet.balance,i=n.unitInfo,c=s.available+s.locked+s.immature;o.balance.textContent=Vt.formatCoinValue(c,i);var l=Cn().fiatRatesMap[n.id];l&&(Vt.show(o.fiat),o.fiat.textContent=Vt.formatFiatConversion(c,l,i))}else Vt.show(o.noWallet)}},{key:"setSelectedAsset",value:function(e){var t,n=Wr(this.page.assetSelect.children);try{for(n.s();!(t=n.n()).done;)t.value.classList.remove("selected")}catch(e){n.e(e)}finally{n.f()}this.assetButtons[e].bttn.classList.add("selected"),this.selectedAssetID=e,this.updateDisplayedAsset(e),this.showAvailableMarkets(e),this.showRecentActivity(e)}},{key:"updateDisplayedAsset",value:function(e){if(e===this.selectedAssetID){var t,n=Cn().assets[e],r=n.symbol,a=n.wallet,o=n.name,s=this.page,i=Wr(document.querySelectorAll("[data-asset-name]"));try{for(i.s();!(t=i.n()).done;)t.value.textContent=o}catch(e){i.e(e)}finally{i.f()}if(s.assetLogo.src=Vt.logoPath(r),Vt.hide(s.balanceBox,s.fiatBalanceBox,s.createWalletBox,s.walletDetails,s.sendReceive,s.connectBttnBox,s.statusLocked,s.statusReady,s.statusOff,s.unlockBttnBox,s.lockBttnBox,s.connectBttnBox,s.peerCountBox,s.syncProgressBox,s.statusDisabled),a){this.updateDisplayedAssetBalance();var c=Cn().walletDefinition(e,a.type);s.walletType.textContent=c.tab;var l=function(e){var t=Cn().assets[e];if(t.token){var n=t.token.definition.configopts;return n&&n.length>0}if(!t.info)throw Error("this asset isn't an asset, I guess");var r=t.info.availablewallets,a=r[0].configopts;return r.length>1||a&&a.length>0}(e);Vt.setVis(l,s.passwordWrapper),a.disabled?Vt.show(s.statusDisabled):a.running?(Vt.show(s.sendReceive,s.peerCountBox,s.syncProgressBox),s.peerCount.textContent=String(a.peerCount),s.syncProgress.textContent="".concat((100*a.syncProgress).toFixed(1),"%"),a.open?(Vt.show(s.statusReady),!Cn().haveActiveOrders(e)&&a.encrypted&&Vt.show(s.lockBttnBox)):Vt.show(s.statusLocked,s.unlockBttnBox)):Vt.show(s.statusOff,s.connectBttnBox)}else Vt.show(s.createWalletBox);s.walletDetailsBox.classList.remove("invisible")}}},{key:"updateDisplayedAssetBalance",value:function(){var e=this.page,t=Cn().assets[this.selectedAssetID],n=t.wallet,a=t.unitInfo,o=t.symbol,s=t.id,i=n.balance;Vt.show(e.balanceBox,e.walletDetails);var c=i.locked+i.contractlocked+i.bondlocked,l=i.available+c+i.immature;e.balance.textContent=Vt.formatCoinValue(l,a),Vt.empty(e.balanceUnit),e.balanceUnit.appendChild(Vt.symbolize(o));var u=Cn().fiatRatesMap[s];u&&(Vt.show(e.fiatBalanceBox),e.fiatBalance.textContent=Vt.formatFiatConversion(l,u,a));var h=!1;Vt.empty(e.balanceDetailBox);var d=function(t,n){var r=e.balanceDetailRow.cloneNode(!0);h&&(r.classList.add("first-other"),h=!1),e.balanceDetailBox.appendChild(r);var o=Vt.parseTemplate(r);o.category.textContent=t,o.subBalance.textContent=Vt.formatCoinValue(n,a)};d("Available",i.available),d("Locked",c),d("Immature",i.immature);var p=Object.entries(i.other||{});p.sort((function(e,t){return e[0].localeCompare(t[0])})),h=!0,i.contractlocked>0&&d("Swapping (locked)",i.contractlocked),i.bondlocked>0&&d("Bonded (locked)",i.bondlocked);for(var f=0,m=p;f1){Vt.empty(r.changeWalletTypeSelect),Vt.show(r.showChangeType,r.changeTypeShowIcon),r.changeTypeMsg.textContent=Rt(fe),i=Wr(s);try{for(i.s();!(c=i.n()).done;)l=c.value,u=document.createElement("option"),l.type===o.type&&(u.selected=!0),u.value=u.textContent=l.type,r.changeWalletTypeSelect.appendChild(u)}catch(e){i.e(e)}finally{i.f()}}else Vt.hide(r.showChangeType);return h=Cn().walletMap[t],Vt.setVis(4&h.traits,r.downloadLogs),Vt.setVis(32&h.traits,r.recoverWallet),Vt.setVis(256&h.traits,r.exportWallet),Vt.setVis(1&h.traits,r.rescanWallet),Vt.setVis(2048&h.traits,r.managePeers),Vt.setVis(0&h.traits,r.otherActionsLabel),h.disabled?Vt.show(r.enableWallet):Vt.show(r.disableWallet),r.recfgAssetLogo.src=Vt.logoPath(a.symbol),r.recfgAssetName.textContent=a.name,n||this.showForm(r.reconfigForm),d=Cn().loading(r.reconfigForm),e.next=24,yn("/api/walletsettings",{assetID:t});case 24:if(p=e.sent,d(),Cn().checkResponse(p)){e.next=29;break}return Vt.showFormError(r.reconfigErr,p.msg),e.abrupt("return");case 29:f=Cn().haveActiveOrders(t),this.reconfigForm.update(o.configopts||[],f),this.setGuideLink(o.guidelink),this.reconfigForm.setConfig(p.map),this.updateDisplayedReconfigFields(o);case 34:case"end":return e.stop()}}),e,this)}))),function(e,t){return C.apply(this,arguments)})},{key:"changeWalletType",value:function(){var e=this.page.changeWalletTypeSelect.value||"",t=Cn().walletDefinition(this.selectedAssetID,e);this.reconfigForm.update(t.configopts||[],!1),this.setGuideLink(t.guidelink),this.updateDisplayedReconfigFields(t)}},{key:"setGuideLink",value:function(e){Vt.hide(this.walletCfgGuide),""!==e&&(this.walletCfgGuide.href=e,Vt.show(this.walletCfgGuide))}},{key:"updateDisplayedReconfigFields",value:function(e){e.seeded||"token"===e.type?(Vt.hide(this.page.showChangePW,this.reconfigForm.fileSelector),this.changeWalletPW=!1,this.setPWSettingViz(!1)):Vt.show(this.page.showChangePW,this.reconfigForm.fileSelector)}},{key:"showDeposit",value:(b=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.depositAddrForm.setAsset(t),this.showForm(this.page.deposit);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"showSendForm",value:(y=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u,h,d,p,f,m,v,g;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.page,r=n.sendForm,a=Cn().assets[t],o=a.wallet,s=a.name,i=a.unitInfo,c=a.symbol,l=a.token,Vt.hide(n.toggleSubtract),n.subtractCheckBox.checked=!1,(u=0!=(64&o.traits))&&Vt.show(n.toggleSubtract),Vt.hide(n.validAddr,n.sendErr,n.maxSendDisplay),n.sendAddr.classList.remove("invalid"),n.sendAddr.value="",n.sendAmt.value="",this.showFiatValue(t,0,n.sendValue),n.walletBal.textContent=Vt.formatFullPrecision(o.balance.available,i),n.sendLogo.src=Vt.logoPath(c),n.sendName.textContent=s,!(o.balance.available>0&&0!=(1024&o.traits))){e.next=23;break}return h={assetID:t,subtract:u,value:o.balance.available},d=Cn().loading(this.body),e.next=20,yn("/api/txfee",h);case 20:p=e.sent,d(),Cn().checkResponse(p)&&(f=o.balance.available,l||(f-=p.txfee)<0&&(f=0),this.maxSend=f,n.maxSend.textContent=Vt.formatFullPrecision(f,i),this.showFiatValue(t,f,n.maxSendFiat),l?(m=Cn().assets[l.parentID],v=m.unitInfo,g=m.symbol,n.maxSendFee.textContent=Vt.formatFullPrecision(p.txfee,v)+" "+g,this.showFiatValue(l.parentID,p.txfee,n.maxSendFeeFiat)):(n.maxSendFee.textContent=Vt.formatFullPrecision(p.txfee,i),this.showFiatValue(t,p.txfee,n.maxSendFeeFiat)),Vt.show(n.maxSendDisplay));case 23:this.showFiatValue(t,0,n.sendValue),n.walletBal.textContent=Vt.formatFullPrecision(o.balance.available,i),n.sendLogo.src=Vt.logoPath(o.symbol),n.sendName.textContent=s,r.dataset.assetID=String(t),this.showForm(r);case 29:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"doConnect",value:(g=o(w().mark((function e(t){var n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Cn().loading(this.body),e.next=3,yn("/api/connectwallet",{assetID:t});case 3:r=e.sent,n(),Cn().checkResponse(r)||(a=Cn().assets[t].symbol,(o=this.page).errorModalMsg.textContent=Rt(wt,{assetName:a,errMsg:r.msg}),this.showForm(o.errorModal)),this.updateDisplayedAsset(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"openWalletSuccess",value:(v=o(w().mark((function e(t,n){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.assetUpdated(t,n,Rt(Ce));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"assetUpdated",value:function(e,t,n){e===this.selectedAssetID&&(this.updateDisplayedAsset(e),t&&Object.is(this.currentForm,t)&&(n?this.showSuccess(n):this.closePopups()))}},{key:"populateMaxSend",value:(m=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,n=Cn().assets[this.selectedAssetID]){e.next=4;break}return e.abrupt("return");case 4:0==(64&n.wallet.traits)?(t.sendAmt.value=String(this.maxSend/n.unitInfo.conventional.conversionFactor),this.showFiatValue(n.id,this.maxSend,t.sendValue),t.subtractCheckBox.checked=!1):(r=n.wallet.balance.available,t.sendAmt.value=String(r/n.unitInfo.conventional.conversionFactor),this.showFiatValue(n.id,r,t.sendValue),t.subtractCheckBox.checked=!0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"send",value:(f=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this.page,o=parseInt(null!==(t=a.sendForm.dataset.assetID)&&void 0!==t?t:""),s=null!==(n=a.subtractCheckBox.checked)&&void 0!==n&&n,i=Cn().unitInfo(o).conventional.conversionFactor,c=a.vSendPw.value||"",a.vSendPw.value="",""!==c){e.next=9;break}return Vt.showFormError(a.vSendErr,Rt(k)),e.abrupt("return");case 9:return l={assetID:o,address:a.sendAddr.value,subtract:s,value:Math.round(parseFloat(null!==(r=a.sendAmt.value)&&void 0!==r?r:"")*i),pw:c},u=Cn().loading(a.vSendForm),e.next=13,yn("/api/send",l);case 13:if(h=e.sent,u(),Cn().checkResponse(h)){e.next=18;break}return Vt.showFormError(a.vSendErr,h.msg),e.abrupt("return");case 18:d=Cn().assets[o].name,this.assetUpdated(o,a.vSendForm,Rt(be,{assetName:d}));case 20:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"reconfig",value:(p=o(w().mark((function e(){var t,n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.page,r=this.selectedAssetID,Vt.hide(n.reconfigErr),n.appPW.value||tn.passwordIsCached()){e.next=6;break}return Vt.showFormError(n.reconfigErr,Rt(x)),e.abrupt("return");case 6:return a=Cn().currentWalletDefinition(r).type,Vt.isHidden(n.changeWalletType)||(a=n.changeWalletTypeSelect.value||""),o=Cn().loading(n.reconfigForm),s={assetID:r,config:this.reconfigForm.map(r),appPW:null!==(t=n.appPW.value)&&void 0!==t?t:"",walletType:a},this.changeWalletPW&&(s.newWalletPW=n.newPW.value),e.next=13,yn("/api/reconfigurewallet",s);case 13:if(i=e.sent,n.appPW.value="",n.newPW.value="",o(),Cn().checkResponse(i)){e.next=20;break}return Vt.showFormError(n.reconfigErr,i.msg),e.abrupt("return");case 20:this.assetUpdated(r,n.reconfigForm,Rt(we));case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"lock",value:(d=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=Cn().loading(n.newWalletForm),e.next=4,yn("/api/closewallet",{assetID:t});case 4:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=8;break}return e.abrupt("return");case 8:this.updateDisplayedAsset(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"downloadLogs",value:(l=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(t=new URLSearchParams("")).append("assetid","".concat(this.selectedAssetID)),(n=new URL(window.location.href)).search=t.toString(),n.pathname="/wallets/logfile",window.open(n.toString());case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"displayExportWalletAuth",value:(c=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,Vt.hide(t.exportWalletErr),t.exportWalletPW.value="",this.showForm(t.exportWalletAuth);case 4:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"exportWalletAuthSubmit",value:(i=o(w().mark((function e(){var t,n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n={assetID:this.selectedAssetID,pass:t.exportWalletPW.value},r=Cn().loading(t.forms),e.next=6,yn("/api/restorewalletinfo",n);case 6:a=e.sent,r(),Cn().checkResponse(a)?(t.exportWalletPW.value="",this.displayRestoreWalletInfo(a.restorationinfo)):Vt.showFormError(t.exportWalletErr,a.msg);case 9:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"displayRestoreWalletInfo",value:(a=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.page,Vt.empty(n.restoreInfoCardsList),r=Wr(t);try{for(r.s();!(a=r.n()).done;)o=a.value,s=this.restoreInfoCard.cloneNode(!0),(i=Vt.parseTemplate(s)).name.textContent=o.target,i.seed.textContent=o.seed,i.seedName.textContent="".concat(o.seedName,":"),i.instructions.textContent=o.instructions,n.restoreInfoCardsList.appendChild(s)}catch(e){r.e(e)}finally{r.f()}this.showForm(n.restoreWalletInfo);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"recoverWallet",value:(n=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.recoverWalletErr),n={assetID:this.selectedAssetID,appPW:t.recoverWalletPW.value},t.recoverWalletPW.value="",r="/api/recoverwallet",a=Cn().loading(t.forms),e.next=8,yn(r,n);case 8:o=e.sent,a(),o.code===cn.activeOrdersErr?(this.forceUrl=r,this.forceReq=n,this.showConfirmForce()):Cn().checkResponse(o)?this.closePopups():Vt.showFormError(t.recoverWalletErr,o.msg);case 11:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"confirmForceSubmit",value:(t=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,this.forceReq.force=!0,n=Cn().loading(t.forms),e.next=5,yn(this.forceUrl,this.forceReq);case 5:r=e.sent,n(),Cn().checkResponse(r)?this.closePopups():Vt.showFormError(t.confirmForceErr,r.msg);case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"handleBalanceNote",value:function(e){this.updateAssetButton(e.assetID),e.assetID===this.selectedAssetID&&this.updateDisplayedAssetBalance()}},{key:"handleRatesNote",value:function(e){this.updateAssetButton(this.selectedAssetID),e.fiatRates[this.selectedAssetID]&&this.updateDisplayedAssetBalance()}},{key:"showFiatValue",value:function(e,t,n){var r=Cn().fiatRatesMap[e];r?(n.textContent=Vt.formatFiatConversion(t,r,Cn().unitInfo(e)),Vt.show(n.parentElement)):Vt.hide(n.parentElement)}},{key:"handleWalletStateNote",value:function(e){this.updateAssetButton(e.wallet.assetID),this.assetUpdated(e.wallet.assetID),"WalletPeersUpdate"===e.topic&&e.wallet.assetID===this.selectedAssetID&&Vt.isDisplayed(this.page.managePeersForm)&&this.updateWalletPeersTable()}},{key:"handleCreateWalletNote",value:function(e){this.updateAssetButton(e.assetID),this.assetUpdated(e.assetID)}},{key:"unload",value:function(){Vt.unbind(document,"keyup",this.keyup)}}]),V}(mn),Ur=new Intl.NumberFormat(navigator.languages,{maximumSignificantDigits:4}),_r=new Intl.NumberFormat(navigator.languages,{minimumFractionDigits:1,maximumFractionDigits:1});function zr(e){return e>=1e3||Math.round(e)===e?_r.format(e):Ur.format(e)}function Vr(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var jr=["bonds"];var Hr=function(e){an(k,e);var t,n,r,a,i,c,l,d,p,f,m,v,g,y,b=(g=k,y=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(g);if(y){var n=sn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return on(this,e)});function k(e){var t;s(this,k),h(nn(t=b.call(this)),"body",void 0),h(nn(t),"currentDEX",void 0),h(nn(t),"page",void 0),h(nn(t),"forms",void 0),h(nn(t),"fiatRateSources",void 0),h(nn(t),"regAssetForm",void 0),h(nn(t),"confirmRegisterForm",void 0),h(nn(t),"newWalletForm",void 0),h(nn(t),"walletWaitForm",void 0),h(nn(t),"dexAddrForm",void 0),h(nn(t),"currentForm",void 0),h(nn(t),"pwCache",void 0),h(nn(t),"keyup",void 0),t.body=e;var n=t.page=Vt.idDescendants(e);t.forms=Vt.applySelector(n.forms,":scope > form"),t.fiatRateSources=Vt.applySelector(n.fiatRateSources,"input[type=checkbox]"),Vt.bind(n.darkMode,"click",(function(){tn.setCookie(tn.darkModeCK,n.darkMode.checked?"1":"0"),n.darkMode.checked?document.body.classList.add("dark"):document.body.classList.remove("dark")})),n.showPokes.checked="1"===tn.fetchLocal(tn.popupsLK),Vt.bind(n.showPokes,"click",(function(){var e=n.showPokes.checked||!1;tn.storeLocal(tn.popupsLK,e?"1":"0"),Cn().showPopups=e})),n.commitHash.textContent=Cn().commitHash.substring(0,7),Vt.bind(n.addADex,"click",(function(){t.dexAddrForm.refresh(),t.showForm(n.dexAddrForm)})),t.fiatRateSources.forEach((function(e){Vt.bind(e,"change",o(w().mark((function t(){var n;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,yn("/api/toggleratesource",{disable:!e.checked,source:e.value});case 2:return n=t.sent,Cn().checkResponse(n)||(e.checked=!e.checked),t.next=6,Cn().fetchUser();case 6:case"end":return t.stop()}}),t)}))))})),t.regAssetForm=new wr(n.regAssetForm,function(){var e=o(w().mark((function e(r){var a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.confirmRegisterForm.setAsset(r),a=Cn().assets[r],!(o=a.wallet)){e.next=14;break}if(s=t.currentDEX.bondAssets[a.symbol],!(o.synced&&o.balance.available>s.amount)){e.next=8;break}return t.animateConfirmForm(n.regAssetForm),e.abrupt("return");case 8:return e.next=10,t.getRegistrationTxFeeEstimate(r,n.regAssetForm);case 10:return i=e.sent,t.walletWaitForm.setWallet(o,i),Dr(n.regAssetForm,n.walletWait),e.abrupt("return");case 14:t.newWalletForm.setAsset(r),t.currentForm=n.newWalletForm,Dr(n.regAssetForm,n.newWalletForm);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),t.confirmRegisterForm=new br(n.confirmRegForm,(function(){t.registerDEXSuccess()}),(function(){t.animateRegAsset(n.confirmRegForm)}),t.pwCache),t.newWalletForm=new vr(n.newWalletForm,(function(e){return t.newWalletCreated(e)}),t.pwCache,(function(){return t.animateRegAsset(n.newWalletForm)})),t.walletWaitForm=new xr(n.walletWait,(function(){t.animateConfirmForm(n.walletWait)}),(function(){t.animateRegAsset(n.walletWait)})),t.dexAddrForm=new Er(n.dexAddrForm,function(){var e=o(w().mark((function e(r,a){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.currentDEX=r,t.confirmRegisterForm.setExchange(r,a),t.walletWaitForm.setExchange(r),t.regAssetForm.setExchange(r),t.animateRegAsset(n.dexAddrForm);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),Vt.bind(n.importAccount,"click",(function(){return t.prepareAccountImport(n.authorizeAccountImportForm)})),Tr(n.authorizeAccountImportForm,n.authorizeImportAccountConfirm,(function(){return t.importAccount()})),Vt.bind(n.changeAppPW,"click",(function(){return t.showForm(n.changeAppPWForm)})),Tr(n.changeAppPWForm,n.submitNewPW,(function(){return t.changeAppPW()})),Vt.bind(n.accountFile,"change",(function(){return t.onAccountFileChange()})),Vt.bind(n.removeAccount,"click",(function(){return t.clearAccountFile()})),Vt.bind(n.addAccount,"click",(function(){return n.accountFile.click()})),Vt.bind(n.exportSeed,"click",(function(){return t.showForm(n.exportSeedAuth)})),Tr(n.exportSeedAuth,n.exportSeedSubmit,(function(){return t.submitExportSeedReq()}));var r=function(){Vt.hide(n.forms),n.exportSeedPW.value="",n.seedDiv.textContent=""};return Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||r()})),t.keyup=function(e){"Escape"===e.key&&r()},Vt.bind(document,"keyup",t.keyup),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){r()}))})),t}return u(k,[{key:"getRegistrationTxFeeEstimate",value:(v=o(w().mark((function e(t,n){var r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getCertFile();case 2:return r=e.sent,a=Cn().loading(n),e.next=6,yn("/api/regtxfee",{addr:this.currentDEX.host,cert:r,asset:t});case 6:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=10;break}return e.abrupt("return",0);case 10:return e.abrupt("return",o.txfee);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"newWalletCreated",value:(m=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:if(n=e.sent){e.next=5;break}return e.abrupt("return");case 5:if(r=this.page,a=n.assets[t],o=a.wallet,s=this.currentDEX.bondAssets[a.symbol].amount,!(o.synced&&o.balance.available>s)){e.next=13;break}return e.next=12,this.animateConfirmForm(r.newWalletForm);case 12:return e.abrupt("return");case 13:return e.next=15,this.getRegistrationTxFeeEstimate(t,r.newWalletForm);case 15:return i=e.sent,this.walletWaitForm.setWallet(o,i),this.currentForm=r.walletWait,e.next=20,Dr(r.newWalletForm,r.walletWait);case 20:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"onAccountFileChange",value:(f=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,(n=t.accountFile.files)&&n.length){e.next=4;break}return e.abrupt("return");case 4:t.selectedAccount.textContent=n[0].name,Vt.show(t.removeAccount),Vt.hide(t.addAccount);case 7:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"clearAccountFile",value:function(){var e=this.page;e.accountFile.value="",e.selectedAccount.textContent=Rt(ie),Vt.hide(e.removeAccount),Vt.show(e.addAccount)}},{key:"prepareAccountImport",value:(p=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.page.importAccountErr.textContent="",this.showForm(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"importAccount",value:(d=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,n=t.importAccountAppPass.value,t.importAccountAppPass.value="",r="",!t.accountFile.value){e.next=12;break}if((a=t.accountFile.files)&&a.length){e.next=9;break}return console.error("importAccount: no file specified"),e.abrupt("return");case 9:return e.next=11,a[0].text();case 11:r=e.sent;case 12:e.prev=12,o=JSON.parse(r),e.next=21;break;case 16:return e.prev=16,e.t0=e.catch(12),t.importAccountErr.textContent=e.t0.message,Vt.show(t.importAccountErr),e.abrupt("return");case 21:if(void 0!==o){e.next=25;break}return t.importAccountErr.textContent=Rt(X),Vt.show(t.importAccountErr),e.abrupt("return");case 25:return i=(s=o).bonds,c=void 0===i?[]:i,l=Vr(s,jr),u={pw:n,account:l,bonds:c},h=Cn().loading(this.body),e.next=30,yn("/api/importaccount",u);case 30:if(d=e.sent,h(),Cn().checkResponse(d)){e.next=36;break}return t.importAccountErr.textContent=d.msg,Vt.show(t.importAccountErr),e.abrupt("return");case 36:return e.next=38,Cn().fetchUser();case 38:Vt.hide(t.forms),window.location.reload();case 40:case"end":return e.stop()}}),e,this,[[12,16]])}))),function(){return d.apply(this,arguments)})},{key:"submitExportSeedReq",value:(l=o(w().mark((function e(){var t,n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=t.exportSeedPW.value,r=Cn().loading(this.body),e.next=5,yn("/api/exportseed",{pass:n});case 5:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=11;break}return t.exportAccountErr.textContent=a.msg,Vt.show(t.exportSeedE),e.abrupt("return");case 11:t.exportSeedPW.value="",t.seedDiv.textContent=a.seed,this.showForm(t.authorizeSeedDisplay);case 14:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"showForm",value:(c=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.currentForm=t,this.forms.forEach((function(e){return Vt.hide(e)})),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(300,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"getCertFile",value:(i=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="",!this.dexAddrForm.page.certFile.value){e.next=7;break}if(!(n=this.dexAddrForm.page.certFile.files)||!n.length){e.next=7;break}return e.next=6,n[0].text();case 6:t=e.sent;case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"registerDEXSuccess",value:(a=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.forms),e.next=4,Cn().fetchUser();case 4:window.location.reload();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"changeAppPW",value:(r=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.changePWErrMsg),n=function(){t.appPW.value="",t.newAppPW.value="",t.confirmNewPW.value=""},t.appPW.value&&t.newAppPW.value&&t.confirmNewPW.value){e.next=8;break}return t.changePWErrMsg.textContent=Rt(x),Vt.show(t.changePWErrMsg),n(),e.abrupt("return");case 8:if(t.newAppPW.value===t.confirmNewPW.value){e.next=13;break}return t.changePWErrMsg.textContent=Rt(K),Vt.show(t.changePWErrMsg),n(),e.abrupt("return");case 13:return r=Cn().loading(t.changeAppPW),a={appPW:t.appPW.value,newAppPW:t.newAppPW.value},n(),e.next=18,yn("/api/changeapppass",a);case 18:if(o=e.sent,r(),Cn().checkResponse(o)){e.next=24;break}return t.changePWErrMsg.textContent=o.msg,Vt.show(t.changePWErrMsg),e.abrupt("return");case 24:Vt.hide(t.forms);case 25:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"unload",value:function(){Vt.unbind(document,"keyup",this.keyup)}},{key:"animateRegAsset",value:(n=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vt.hide(t),n=this.page.regAssetForm,this.currentForm=n,this.regAssetForm.animate(),Vt.show(n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"animateConfirmForm",value:(t=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.confirmRegisterForm.animate(),n=this.page.confirmRegForm,this.currentForm=n,Vt.hide(t),Vt.show(n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),k}(mn);function Gr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(!a.epoch)return a;n||(n=a)}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"bestGapBuy",value:function(){return this.bestGapOrder(this.buys)}},{key:"bestGapSell",value:function(){return this.bestGapOrder(this.sells)}}]),e}();function Xr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nthis.maxQlength-1;)this.queue.shift();this.queue.push([e,t])}}},{key:"close",value:function(e){window.log("ws","close, reason:",e,this.handlers),this.handlers={},this.connection&&this.connection.close()}},{key:"connect",value:function(e,t){var n=this;this.uri=e,this.reloader=t;var a=0;!function o(){window.log("ws","connecting to ".concat(e));var s=n.connection=new window.WebSocket(e);if(s){var i=setTimeout((function(){s&&s.close()}),500);s.onmessage=function(e){var t=JSON.parse(e.data);Qr(t.route,t.payload,n.handlers)},s.onclose=function(e){window.log("ws","onclose"),clearTimeout(i),s=n.connection=null,Qr("close",null,n.handlers),a++;var t=Math.min(Math.pow(1.25,a),10);console.error("websocket disconnected (".concat(e.code,"), trying again in ").concat(t.toFixed(1)," seconds")),setTimeout((function(){o()}),1e3*t)},s.onopen=function(){window.log("ws","onopen"),clearTimeout(i),a>0&&(a=0,t()),Qr("open",null,n.handlers);var e=n.queue;n.queue=[];var o,s=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Xr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(e);try{for(s.s();!(o=s.n()).done;){var c=r(o.value,2),l=c[0],u=c[1];n.request(l,u)}}catch(e){s.e(e)}finally{s.f()}},s.onerror=function(e){window.log("ws","onerror:",e),Qr("error",e,n.handlers)}}}()}}]),e}());function Zr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $r(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function ta(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0}},{key:"setCurrMarketPrice",value:function(){var e=this.market;if(e){var t=Cn().exchanges[e.dex.host],n=t.markets[e.cfg.name];if(n.spot){var r,a=ea(this.stats);try{for(a.s();!(r=a.n()).done;){var o=r.value,s=t.assets[n.baseid].unitInfo.conventional.conversionFactor;o.tmpl.volume.textContent=Ia(n.spot.vol24/s),Ra(o.tmpl,t,n)}}catch(e){a.e(e)}finally{a.f()}this.page.obPrice.textContent=Vt.formatFullPrecision(n.spot.rate/this.market.rateConversionFactor),this.page.obPrice.classList.remove("sellcolor","buycolor"),this.page.obPrice.classList.add(n.spot.change24>=0?"buycolor":"sellcolor"),Vt.setVis(n.spot.change24>=0,this.page.obUp),Vt.setVis(n.spot.change24<0,this.page.obDown)}}}},{key:"setMarketDetails",value:function(){if(this.market){var e,t=ea(this.stats);try{for(t.s();!(e=t.n()).done;){var n=e.value;n.tmpl.baseIcon.src=Vt.logoPath(this.market.cfg.basesymbol),n.tmpl.quoteIcon.src=Vt.logoPath(this.market.cfg.quotesymbol),Vt.empty(n.tmpl.baseSymbol,n.tmpl.quoteSymbol),n.tmpl.baseSymbol.appendChild(Vt.symbolize(this.market.cfg.basesymbol)),n.tmpl.quoteSymbol.appendChild(Vt.symbolize(this.market.cfg.quotesymbol))}}catch(e){t.e(e)}finally{t.f()}}}},{key:"setHighLow",value:function(){var e=0,t=0,n=this.market.cfg.spot;if(n&&n.low24&&n.high24)e=n.high24,t=n.low24;else{var r,a=null===(r=this.market)||void 0===r?void 0:r.candleCaches[pa];if(!a){if(this.candleDur!==pa)return void this.requestCandles(pa);var o,s=ea(this.stats);try{for(s.s();!(o=s.n()).done;){var i=o.value;i.tmpl.high.textContent="-",i.tmpl.low.textContent="-"}}catch(e){s.e(e)}finally{s.f()}return}for(var c=(new Date).getTime()-864e5,l=a.candles.length-1;l>=0;l--){var u=a.candles[l];if(u.endStamp0&&u.lowRatee&&(e=u.highRate)}}var h,d=Cn().unitInfo(this.market.cfg.quoteid,this.market.dex).conventional.conversionFactor,p=ea(this.stats);try{for(p.s();!(h=p.n()).done;){var f=h.value;f.tmpl.high.textContent=e>0?Ia(e/d):"-",f.tmpl.low.textContent=t>0?Ia(t/d):"-"}}catch(e){p.e(e)}finally{p.f()}}},{key:"assetsAreSupported",value:function(){var e,t,n,r,a=this.market,o=a.base,s=a.quote,i=a.baseCfg,c=a.quoteCfg;if(!o||!s){var l=o?c.symbol:i.symbol;return{isSupported:!1,text:Rt(L,{asset:l.toUpperCase()})}}var u=o.token?null===(e=Cn().assets[o.token.parentID].info)||void 0===e?void 0:e.versions:null===(t=o.info)||void 0===t?void 0:t.versions,h=s.token?null===(n=Cn().assets[s.token.parentID].info)||void 0===n?void 0:n.versions:null===(r=s.info)||void 0===r?void 0:r.versions,d="";return u.includes(i.version)?h.includes(c.version)||(d=Rt(M,{asset:s.symbol.toUpperCase(),version:c.version+""})):d=Rt(M,{asset:o.symbol.toUpperCase(),version:i.version+""}),{isSupported:u.includes(i.version)&&h.includes(c.version),text:d}}},{key:"setOrderVisibility",value:function(){var e=this.page;this.isLimit()?(Vt.show(e.priceBox,e.tifBox,e.qtyBox,e.maxBox),Vt.hide(e.mktBuyBox),this.previewQuoteAmt(!0)):(Vt.hide(e.tifBox,e.maxBox,e.priceBox),this.isSell()?(Vt.hide(e.mktBuyBox),Vt.show(e.qtyBox),this.previewQuoteAmt(!0)):(Vt.show(e.mktBuyBox),Vt.hide(e.qtyBox),this.previewQuoteAmt(!1)))}},{key:"resolveOrderFormVisibility",value:function(){var e=this.page;if(Vt.hide(e.orderForm,e.orderTypeBttns),this.assetsAreSupported().isSupported&&!(this.market.dex.tier<1)){var t=this.market,n=t.base,r=t.quote;n&&Cn().assets[n.id].wallet&&r&&Cn().assets[r.id].wallet&&Vt.show(e.orderForm,e.orderTypeBttns)}}},{key:"setLoaderMsgVisibility",value:function(){var e=this.page,t=this.assetsAreSupported(),n=t.isSupported,r=t.text;n?Vt.hide(e.loaderMsg):(e.loaderMsg.textContent=r,Vt.show(e.loaderMsg),Vt.hide(e.notRegistered),Vt.hide(e.noWallet))}},{key:"setRegistrationStatusView",value:function(e,t,n){var r=this.page;r.regStatusTitle.textContent=e,r.regStatusConfsDisplay.textContent=t,r.registrationStatus.classList.remove("completed","error","waiting"),r.registrationStatus.classList.add(n)}},{key:"updateRegistrationStatusView",value:function(){var e=this.page,t=this.market.dex;if(e.regStatusDex.textContent=t.host,t.tier>=1)this.setRegistrationStatusView(Rt(ce),"","completed");else{var n=Object.values(t.pendingBonds).map((function(e){var n=t.bondAssets[e.symbol].confs;return"".concat(e.confs," / ").concat(n)})).join(", ");this.setRegistrationStatusView(Rt(se),n,"waiting")}}},{key:"setRegistrationStatusVisibility",value:function(){var e=this,t=this.page,n=this.market;if(n&&n.dex&&n.dex.connectionStatus===ln.Connected)if(this.updateRegistrationStatusView(),n.dex.tier>=1){var r=function(){Vt.hide(t.registrationStatus,t.bondRequired),e.resolveOrderFormVisibility()};if(Vt.isHidden(t.orderForm))return void setTimeout(r,5e3);r()}else n.dex.viewOnly?(t.unregisteredDex.textContent=n.dex.host,Vt.show(t.notRegistered)):this.hasPendingBonds()?Vt.show(t.registrationStatus):(t.acctTier.textContent="".concat(n.dex.tier),t.dexSettingsLink.href="/dexsettings/".concat(n.dex.host),Vt.show(t.bondRequired))}},{key:"setOrderBttnText",value:function(){this.isSell()?this.page.submitBttn.textContent=Rt(S,{asset:Vt.shortSymbol(this.market.baseCfg.symbol)}):this.page.submitBttn.textContent=Rt(C,{asset:Vt.shortSymbol(this.market.baseCfg.symbol)})}},{key:"setCandleDurBttns",value:function(){var e=this,t=this.page,n=this.market;Vt.empty(t.durBttnBox);var r,a=ea(n.dex.candleDurs);try{var o=function(){var n=r.value,a=t.durBttnTemplate.cloneNode(!0);a.textContent=n,Vt.bind(a,"click",(function(){return e.candleDurationSelected(n)})),t.durBttnBox.appendChild(a)};for(a.s();!(r=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}this.loadCandles()}},{key:"setMarket",value:(x=o(w().mark((function e(t,n,r){var a,o,s,i,c,l,u,h,d,p,f,m,v,g;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Cn().user.exchanges[t],(o=this.page).lotField.value="",o.qtyField.value="",o.rateField.value="",Vt.hide(o.notRegistered,o.bondRequired,o.noWallet),a&&a.markets&&a.connectionStatus===ln.Connected){e.next=10;break}return o.chartErrMsg.textContent=Rt(B),Vt.show(o.chartErrMsg),e.abrupt("return");case 10:s=ea(this.stats);try{for(s.s();!(i=s.n()).done;)c=i.value,Vt.show(c.row)}catch(e){s.e(e)}finally{s.f()}l=a.assets[n],u=a.assets[r],h=[Cn().unitInfo(n,a),Cn().unitInfo(r,a)],p=h[1],f=Pn/(d=h[0]).conventional.conversionFactor*p.conventional.conversionFactor,Vt.hide(o.maxOrd,o.chartErrMsg),this.maxEstimateTimer&&(window.clearTimeout(this.maxEstimateTimer),this.maxEstimateTimer=null),m=ka(l.symbol,u.symbol),v=Cn().assets[n],g=Cn().assets[r],this.market={dex:a,sid:m,cfg:a.markets[m],base:v,quote:g,baseUnitInfo:d,quoteUnitInfo:p,maxSell:null,maxBuys:{},maxSellRequested:!1,candleCaches:{},baseCfg:l,quoteCfg:u,rateConversionFactor:f,sellBalance:0,buyBalance:0},Vt.setVis(!(v&&g&&v.wallet&&g.wallet),o.noWallet),this.setMarketDetails(),this.setCurrMarketPrice(),this.refreshRecentMatchesTable(),Jr.request("loadmarket",wa(t,n,r)),this.setLoaderMsgVisibility(),this.setRegistrationStatusVisibility(),this.resolveOrderFormVisibility(),this.setOrderBttnText(),this.setCandleDurBttns(),this.previewQuoteAmt(!1);case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return x.apply(this,arguments)})},{key:"reportDepthClick",value:function(e){this.page.rateField.value=String(e),this.rateFieldChanged()}},{key:"reportDepthVolume",value:function(e){var t=this.page,n=this.market,r=n.baseUnitInfo,a=n.quoteUnitInfo;t.sellBookedBase.textContent=Vt.formatCoinValue(e.sellBase*r.conventional.conversionFactor,r),t.sellBookedQuote.textContent=Vt.formatCoinValue(e.sellQuote*a.conventional.conversionFactor,a),t.buyBookedBase.textContent=Vt.formatCoinValue(e.buyBase*r.conventional.conversionFactor,r),t.buyBookedQuote.textContent=Vt.formatCoinValue(e.buyQuote*a.conventional.conversionFactor,a)}},{key:"reportDepthMouse",value:function(e){for(;this.hovers.length;)this.hovers.shift().classList.remove("hover");var t=this.page;if(e){Vt.show(t.hoverData,t.depthHoverData);for(var n=0,r=Object.values(this.metaOrders);n-1&&(o.classList.add("hover"),this.hovers.push(o))}t.hoverPrice.textContent=Vt.formatCoinValue(e.rate),t.hoverVolume.textContent=Vt.formatCoinValue(e.depth),t.hoverVolume.style.color=e.dotColor}else Vt.hide(t.hoverData,t.depthHoverData)}},{key:"reportDepthZoom",value:function(e){tn.storeLocal(tn.depthZoomLK,e)}},{key:"reportMouseCandle",value:function(e){var t=this.page;e?(Vt.show(t.hoverData,t.candleHoverData),t.candleStart.textContent=Vt.formatCoinValue(e.startRate/this.market.rateConversionFactor),t.candleEnd.textContent=Vt.formatCoinValue(e.endRate/this.market.rateConversionFactor),t.candleHigh.textContent=Vt.formatCoinValue(e.highRate/this.market.rateConversionFactor),t.candleLow.textContent=Vt.formatCoinValue(e.lowRate/this.market.rateConversionFactor),t.candleVol.textContent=Vt.formatCoinValue(e.matchVolume,this.market.baseUnitInfo)):Vt.hide(t.hoverData,t.candleHoverData)}},{key:"parseOrder",value:function(){var e=this.page,t=e.qtyField,n=this.isLimit(),r=this.isSell(),a=this.market,o=a.baseUnitInfo.conventional.conversionFactor;return n||r||(t=e.mktBuyField,o=a.quoteUnitInfo.conventional.conversionFactor),{host:a.dex.host,isLimit:n,sell:r,base:a.base.id,quote:a.quote.id,qty:xa(t.value||"",o),rate:xa(e.rateField.value||"",a.rateConversionFactor),tifnow:e.tifNow.checked||!1,options:{}}}},{key:"previewQuoteAmt",value:function(e){var t=this.page;if(this.market.base&&this.market.quote){var n=this.parseOrder(),r=this.adjustedRate();if(t.orderErr.textContent="",r&&(n.sell?this.preSell():this.preBuy()),this.depthLines.input=[],r&&this.isLimit()&&(this.depthLines.input=[{rate:n.rate/this.market.rateConversionFactor,color:n.sell?this.depthChart.theme.sellLine:this.depthChart.theme.buyLine}]),this.drawChartLines(),!e||!r||!n.qty)return t.orderPreview.textContent="",void this.drawChartLines();var a=Cn().assets[n.quote],o=n.qty*n.rate/Pn,s=Vt.formatCoinValue(o,this.market.quoteUnitInfo);t.orderPreview.textContent=Rt(W,{total:s,asset:a.symbol.toUpperCase()}),this.isSell()?this.preSell():this.preBuy()}}},{key:"preSell",value:function(){var e=this,t=this.market,n=Cn().assets[t.base.id].wallet;n.balance.available0&&this.book.add(u),this.addTableOrder(u)}}catch(e){l.e(e)}finally{l.f()}if(!this.book)return this.depthChart.clear(),Vt.empty(this.page.buyRows),void Vt.empty(this.page.sellRows);Vt.show(this.page.epochLine),this.loadingAnimations.depth&&this.loadingAnimations.depth.stop(),this.depthChart.canvas.classList.remove("invisible"),this.depthChart.set(this.book,r.lotsize,r.ratestep,a,o),this.recentMatches=null!==(t=e.book.recentMatches)&&void 0!==t?t:[],this.refreshRecentMatchesTable()}},{key:"midGapConventional",value:function(){var e=this.midGap();if(!e)return e;var t=this.market,n=t.baseUnitInfo,r=t.quoteUnitInfo;return e*n.conventional.conversionFactor/r.conventional.conversionFactor}},{key:"midGap",value:function(){var e=this.book;if(e)return e.buys&&e.buys.length?e.sells&&e.sells.length?(e.buys[0].msgRate+e.sells[0].msgRate)/2/Pn:e.buys[0].msgRate/Pn:e.sells&&e.sells.length?e.sells[0].msgRate/Pn:null}},{key:"setMarketBuyOrderEstimate",value:function(){var e=this.market,t=e.cfg.lotsize,n=Cn().user.exchanges[e.dex.host].markets[e.sid].buybuffer,r=this.midGapConventional();r&&(this.page.minMktBuy.textContent=Vt.formatCoinValue(t*n*r,e.baseUnitInfo))}},{key:"refreshActiveOrders",value:function(){var e=this,t=this.page,n=this.metaOrders,r=this.market;for(var a in n)delete n[a];var o=Cn().orders(r.dex.host,ka(r.baseCfg.symbol,r.quoteCfg.symbol));o.sort((function(e,t){return t.submitTime-e.submitTime})),Vt.empty(t.userOrders),Vt.setVis(null==o?void 0:o.length,t.userOrders),Vt.setVis(!(null!=o&&o.length),t.userNoOrders);var s,i=!1,c=ea(o);try{var l=function(){var r=s.value,a=t.userOrderTmpl.cloneNode(!0);t.userOrders.appendChild(a);var o=Vt.tmplElement(a,"header"),c=Vt.parseTemplate(o),l=Vt.tmplElement(a,"details"),u=Vt.parseTemplate(l),h={div:a,header:c,details:u,ord:r};r.id&&(n[r.id]=h),r.readyToTick||(o.classList.add("unready-user-order"),i=!0),c.sideLight.classList.add(r.sell?"sell":"buy"),u.side.textContent=c.side.textContent=Ln(r),u.side.classList.add(r.sell?"sellcolor":"buycolor"),c.side.classList.add(r.sell?"sellcolor":"buycolor"),u.qty.textContent=c.qty.textContent=Ia(r.qty/e.market.baseUnitInfo.conventional.conversionFactor),u.rate.textContent=c.rate.textContent=Ia(r.rate/e.market.rateConversionFactor),c.baseSymbol.textContent=r.baseSymbol.toUpperCase(),u.type.textContent=Mn(r),e.updateMetaOrder(h),Vt.bind(a,"mouseenter",(function(){e.activeMarkerRate=r.rate,e.setDepthMarkers()})),r.id?(1===r.type&&1===r.tif&&r.status<3&&(Vt.show(u.cancelBttn),na(u.cancelBttn,"click",(function(t){t.stopPropagation(),e.showCancel(a,r.id)}))),na(u.accelerateBttn,"click",(function(t){t.stopPropagation(),e.showAccelerate(r)})),Cn().canAccelerateOrder(r)&&Vt.show(u.accelerateBttn),u.link.href="order/".concat(r.id),Cn().bindInternalNavigation(a)):(Vt.hide(u.accelerateBttn),Vt.hide(u.cancelBttn),Vt.hide(u.link)),Vt.bind(o,"click",(function(){if(Vt.isDisplayed(l))return Vt.hide(l),c.expander.classList.add("ico-arrowdown"),void c.expander.classList.remove("ico-arrowup");Vt.show(l),c.expander.classList.remove("ico-arrowdown"),c.expander.classList.add("ico-arrowup")})),Cn().bindTooltips(a)};for(c.s();!(s=c.n()).done;)l()}catch(e){c.e(e)}finally{c.f()}Vt.setVis(i,t.unreadyOrdersMsg),this.setDepthMarkers()}},{key:"updateMetaOrder",value:function(e){var t=e.header,n=e.details,r=e.ord;r.status<=2||Wn(r)?t.activeLight.classList.add("active"):t.activeLight.classList.remove("active"),n.status.textContent=t.status.textContent=qn(r),n.age.textContent=Vt.timeSince(r.submitTime),n.filled.textContent="".concat((Nn(r)/r.qty*100).toFixed(1),"%"),n.settled.textContent="".concat((Un(r)/r.qty*100).toFixed(1),"%")}},{key:"setDepthMarkers",value:function(){for(var e={buys:[],sells:[]},t=this.market.rateConversionFactor,n=0,r=Object.values(this.metaOrders);n0&&this.book.add(t),this.addTableOrder(t),this.updateTitle(),this.depthChart.draw()}}},{key:"handleUnbookOrderRoute",value:function(e){if(Cn().log("book","handleUnbookOrderRoute:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){var t=e.payload;this.book.remove(t.token),this.removeTableOrder(t),this.updateTitle(),this.depthChart.draw()}}},{key:"handleUpdateRemainingRoute",value:function(e){if(Cn().log("book","handleUpdateRemainingRoute:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){var t=e.payload;this.book.updateRemaining(t.token,t.qty,t.qtyAtomic),this.updateTableOrder(t),this.depthChart.draw()}}},{key:"handleEpochOrderRoute",value:function(e){if(Cn().log("book","handleEpochOrderRoute:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){var t=e.payload;t.msgRate>0&&this.book.add(t),t.qtyAtomic>0&&this.addTableOrder(t),this.depthChart.draw()}}},{key:"handleCandlesRoute",value:function(e){if(this.candlesLoading&&(clearTimeout(this.candlesLoading.timer),this.candlesLoading.loaded(),this.candlesLoading=null),e.host===this.market.dex.host&&e.marketID===this.market.cfg.name){var t=e.payload.dur;this.market.candleCaches[t]=e.payload,this.setHighLow(),this.candleDur===t&&(this.loadingAnimations.candles&&this.loadingAnimations.candles.stop(),this.candleChart.canvas.classList.remove("invisible"),this.candleChart.setCandles(e.payload,this.market.cfg,this.market.baseUnitInfo,this.market.quoteUnitInfo))}}},{key:"handleEpochMatchSummary",value:function(e){this.addRecentMatches(e.payload),this.refreshRecentMatchesTable()}},{key:"handleCandleUpdateRoute",value:function(e){if(e.host===this.market.dex.host){var t=e.payload,n=t.dur,r=t.candle,a=this.market.candleCaches[n];if(a){var o=a.candles;0===o.length?o.push(r):o[o.length-1].startStamp===r.startStamp?o[o.length-1]=r:o.push(r),this.candleDur===n&&this.candleChart.draw()}}}},{key:"showForm",value:(k=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentForm=t,n=this.page,Vt.hide.apply(Vt,xn(Array.from(n.forms.children))),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(500,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"showOpen",value:(b=o(w().mark((function e(t,n){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this.page,this.openAsset=t,this.openFunc=n,this.unlockForm.refresh(Cn().assets[t.id]),this.showForm(r.unlockWalletForm),r.uwAppPass.focus();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"showToggleWalletStatus",value:function(e){var t=this.page;this.openAsset=e,Vt.hide(t.toggleWalletStatusErr,t.walletStatusDisable,t.disableWalletMsg),Vt.show(t.walletStatusEnable,t.enableWalletMsg),this.showForm(t.toggleWalletStatusConfirm)}},{key:"toggleWalletStatus",value:(y=o(w().mark((function e(){var t,n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.toggleWalletStatusErr),n={assetID:this.openAsset.id,disable:!1},r=Cn().loading(t.toggleWalletStatusConfirm),e.next=7,yn("/api/togglewalletstatus",n);case 7:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=13;break}return t.toggleWalletStatusErr.textContent=a.msg,Vt.show(t.toggleWalletStatusErr),e.abrupt("return");case 13:Vt.hide(this.page.forms),this.balanceWgt.updateAsset(this.openAsset.id);case 15:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"showVerify",value:function(){this.preorderCache={};var e,t=this.page,n=this.currentOrder=this.parseOrder(),r=n.sell,a=Cn().assets[n.base],o=Cn().assets[n.quote],s=r?o:a,i=r?a:o,c=function(e){switch(e.dataset.icon){case"from":if(i.token){var t=Cn().assets[i.token.parentID];e.src=Vt.logoPath(t.symbol)}else e.src=Vt.logoPath(i.symbol);break;case"to":if(s.token){var n=Cn().assets[s.token.parentID];e.src=Vt.logoPath(n.symbol)}else e.src=Vt.logoPath(s.symbol)}},l=ea(Vt.applySelector(t.vDetailPane,"[data-icon]"));try{for(l.s();!(e=l.n()).done;)c(e.value)}catch(e){l.e(e)}finally{l.f()}var u,h=ea(Vt.applySelector(t.vFeeSummary,"[data-icon]"));try{for(h.s();!(u=h.n()).done;)c(u.value)}catch(e){h.e(e)}finally{h.f()}Vt.hide(t.vUnlockPreorder,t.vPreorderErr),Vt.show(t.vPreorder),t.vBuySell.textContent=Rt(r?Se:Ee);var d=Rt(r?P:T);if(t.vSideSubmit.textContent=d,t.vOrderHost.textContent=n.host,n.isLimit){Vt.show(t.verifyLimit),Vt.hide(t.verifyMarket);var p="Limit ".concat(d," Order");t.vOrderType.textContent=n.tifnow?p+" (immediate)":p,t.vRate.textContent=Vt.formatCoinValue(n.rate/this.market.rateConversionFactor),t.vQty.textContent=Vt.formatCoinValue(n.qty,a.unitInfo);var f=n.rate/Pn*n.qty;t.vTotal.textContent=Vt.formatCoinValue(f,o.unitInfo),this.showFiatValue(o.id,f,t.vFiatTotal)}else{Vt.hide(t.verifyLimit),Vt.show(t.verifyMarket),t.vOrderType.textContent="Market ".concat(d," Order");var m=n.sell?this.market.baseUnitInfo:this.market.quoteUnitInfo;t.vmFromTotal.textContent=Vt.formatCoinValue(n.qty,m),t.vmFromAsset.textContent=i.symbol.toUpperCase(),this.showFiatValue(i.id,n.qty,t.vmFromTotalFiat);var v=this.midGap();if(v){Vt.show(t.vMarketEstimate);var g=n.sell?n.qty*v:n.qty/v;t.vmToTotal.textContent=Vt.formatCoinValue(g,s.unitInfo),t.vmToAsset.textContent=s.symbol.toUpperCase(),this.showFiatValue(s.id,g,t.vmTotalFiat)}else Vt.hide(t.vMarketEstimate)}r?(t.vHeader.classList.add(da),t.vHeader.classList.remove(ha),t.vSubmit.classList.add(da),t.vSubmit.classList.remove(ha)):(t.vHeader.classList.add(ha),t.vHeader.classList.remove(da),t.vSubmit.classList.add(ha),t.vSubmit.classList.remove(da)),this.showVerifyForm(),t.vPass.focus(),a.wallet.open&&o.wallet.open?this.preOrder(n):(Vt.hide(t.vPreorder),tn.passwordIsCached()?this.unlockWalletsForEstimates(""):Vt.show(t.vUnlockPreorder))}},{key:"showFiatValue",value:function(e,t,n){if(n){var r=Cn().fiatRatesMap[e];n.textContent=Vt.formatFiatConversion(t,r,Cn().unitInfo(e)),r?Vt.show(n.parentElement):Vt.hide(n.parentElement)}}},{key:"showVerifyForm",value:(g=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,Vt.hide(t.vErr),this.showForm(t.verifyForm);case 3:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"submitEstimateUnlock",value:(v=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page.vUnlockPass.value||"",e.next=3,this.unlockWalletsForEstimates(t);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"unlockWalletsForEstimates",value:(m=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=Cn().loading(n.verifyForm),e.next=4,this.attemptWalletUnlock(t);case 4:if(a=e.sent,r(),!a){e.next=8;break}return e.abrupt("return",this.setPreorderErr(a));case 8:Vt.show(n.vPreorder),Vt.hide(n.vUnlockPreorder),this.preOrder(this.parseOrder());case 11:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"attemptWalletUnlock",value:(f=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.market,r=n.base,a=n.quote,o=[],r.wallet.open||o.push(r.id),a.wallet.open||o.push(a.id),s={pass:t,assetID:-1},i=0,c=o;case 6:if(!(i0?E/x:E,F=e.estimate.realisticBestCase/A*100;r.vSwapFeesLowPct.textContent=x<=0?"":"(".concat(c(F),"%)"),r.vSwapFeesLow.textContent=Vt.formatCoinValue(e.estimate.realisticBestCase,w);var I=e.estimate.realisticWorstCase/A*100;r.vSwapFeesHighPct.textContent=x<=0?"":"(".concat(c(I),"%)"),r.vSwapFeesHigh.textContent=Vt.formatCoinValue(e.estimate.realisticWorstCase,w);var R=e.estimate.maxFees/A*100;r.vSwapFeesMaxPct.textContent=x<=0?"":"(".concat(c(R),"%)"),r.vSwapFeesMax.textContent=Vt.formatCoinValue(e.estimate.maxFees,w);var D=this.midGap()||n.rate/i,O=n.sell?E*D:E/D,T=k>0?O/k:O,P=t.estimate.realisticBestCase/T*100;r.vRedeemFeesLowPct.textContent=k<=0?"":"(".concat(c(P),"%)"),r.vRedeemFeesLow.textContent=Vt.formatCoinValue(t.estimate.realisticBestCase,b);var L=t.estimate.realisticWorstCase/T*100;r.vRedeemFeesHighPct.textContent=k<=0?"":"(".concat(c(L),"%)"),r.vRedeemFeesHigh.textContent=Vt.formatCoinValue(t.estimate.realisticWorstCase,b),l&&u?(Vt.show(r.vFeeSummaryPct),Vt.hide(r.vFeeSummary),r.vFeeSummaryLow.textContent=c(F+P),r.vFeeSummaryHigh.textContent=c(I+L)):(Vt.hide(r.vFeeSummaryPct),Vt.show(r.vFeeSummary),r.summarySwapFeesLow.textContent=r.vSwapFeesLow.textContent,r.summarySwapFeesHigh.textContent=r.vSwapFeesHigh.textContent,r.summaryRedeemFeesLow.textContent=r.vRedeemFeesLow.textContent,r.summaryRedeemFeesHigh.textContent=r.vRedeemFeesHigh.textContent)}else Vt.hide(r.vPreorderEstimates)}},{key:"submitCancel",value:(l=o(w().mark((function e(){var t,n,r,a,o,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=this.cancelData,r=n.order,a={orderID:r.id,pw:t.cancelPass.value},t.cancelPass.value="",o=Cn().loading(t.cancelSubmit),e.next=8,yn("/api/cancel",a);case 8:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=14;break}return t.cancelErr.textContent=s.msg,Vt.show(t.cancelErr),e.abrupt("return");case 14:Vt.hide(n.bttn,t.forms),r.cancelling=!0;case 16:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"showCancel",value:function(e,t){var n=this.metaOrders[t].ord,r=this.page,a=n.qty-n.filled,o=Bn(n)?this.market.quote:this.market.base;r.cancelRemain.textContent=Vt.formatCoinValue(a,o.unitInfo),r.cancelUnit.textContent=o.symbol.toUpperCase(),Vt.hide(r.cancelErr),this.showForm(r.cancelForm),r.cancelPass.focus(),this.cancelData={bttn:Vt.tmplElement(e,"cancelBttn"),order:n}}},{key:"showAccelerate",value:function(e){var t=Cn().loading(this.main);this.accelerateOrderForm.refresh(e),t(),this.showForm(this.page.accelerateForm)}},{key:"showCreate",value:function(e){var t=this.page;this.currentCreate=e,this.newWalletForm.setAsset(e.id),this.showForm(t.newWalletForm)}},{key:"stepSubmit",value:function(){var e=this.page,t=this.market;if(Vt.hide(e.orderErr),this.validateOrder(this.parseOrder())){var n=Cn().walletMap[t.base.id],r=Cn().walletMap[t.quote.id];return n?r?void this.showVerify():(e.orderErr.textContent=Rt(V,{asset:t.quote.symbol}),void Vt.show(e.orderErr)):(e.orderErr.textContent=Rt(V,{asset:t.base.symbol}),void Vt.show(e.orderErr))}}},{key:"showDeposit",value:(c=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.depositAddrForm.setAsset(t),this.showForm(this.page.deposit);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"handlePriceUpdate",value:function(e){e.host===this.market.dex.host&&e.spots[this.market.cfg.name]&&this.setCurrMarketPrice(),this.marketList.updateSpots(e)}},{key:"handleBondUpdate",value:(i=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.dex)===this.market.dex.host){e.next=3;break}return e.abrupt("return");case 3:if("AccountRegistered"!==t.topic){e.next=6;break}return e.next=6,Cn().fetchUser();case 6:this.market.dex=Cn().exchanges[n],this.setRegistrationStatusVisibility();case 8:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"handleMatchNote",value:function(e){var t=this.metaOrders[e.orderID];if(!t)return this.refreshActiveOrders();Cn().canAccelerateOrder(t.ord)?Vt.show(t.details.accelerateBttn):Vt.hide(t.details.accelerateBttn)}},{key:"handleOrderNote",value:function(e){var t=e.order,n=this.metaOrders[t.id];if(!n||"AsyncOrderFailure"===e.topic||"OrderLoaded"===e.topic&&t.readyToTick)return this.refreshActiveOrders();var r=n.status;n.ord=t,"MissedCancel"===e.topic&&Vt.show(n.details.cancelBttn),t.filled===t.qty&&Vt.hide(n.details.cancelBttn),Cn().canAccelerateOrder(t)?Vt.show(n.details.accelerateBttn):Vt.hide(n.details.accelerateBttn),this.updateMetaOrder(n),(1===r&&2===t.status||2===r&&t.status>2)&&this.setDepthMarkers()}},{key:"handleEpochNote",value:function(e){if(Cn().log("book","handleEpochNote:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){this.book&&(this.book.setEpoch(e.epoch),this.depthChart.draw()),this.clearOrderTableEpochs();for(var t=0,n=Object.values(this.metaOrders);ta.epoch;switch(!0){case 1===a.type&&1===a.status&&i:var c=0===a.tif?Rt(j):Rt(H);o.status.textContent=s.status.textContent=c,a.status=0===a.tif?3:2;break;case 2===a.type&&1===a.status:o.status.textContent=s.status.textContent=Rt(j),a.status=3}}}}},{key:"recentMatchesSortCompare",value:function(){var e=this;switch(this.recentMatchesSortKey){case"rate":return function(t,n){return e.recentMatchesSortDirection*(t.rate-n.rate)};case"qty":return function(t,n){return e.recentMatchesSortDirection*(t.qty-n.qty)};case"age":return function(t,n){return e.recentMatchesSortDirection*(t.stamp-n.stamp)}}}},{key:"refreshRecentMatchesTable",value:function(){var e=this.page,t=this.recentMatches;if(Vt.empty(e.recentMatchesLiveList),t){var n=this.recentMatchesSortCompare();t.sort(n);var r,a=ea(t);try{for(a.s();!(r=a.n()).done;){var o=r.value,s=e.recentMatchesTemplate.cloneNode(!0),i=Vt.parseTemplate(s);Cn().bindTooltips(s),i.rate.textContent=Vt.formatCoinValue(o.rate/this.market.rateConversionFactor),i.qty.textContent=Vt.formatCoinValue(o.qty,this.market.baseUnitInfo),i.age.textContent=Vt.timeSince(o.stamp),i.age.dataset.sinceStamp=String(o.stamp),s.classList.add(o.sell?"sellcolor":"buycolor"),e.recentMatchesLiveList.append(s)}}catch(e){a.e(e)}finally{a.f()}}}},{key:"addRecentMatches",value:function(e){this.recentMatches=[].concat(xn(e),xn(this.recentMatches)).slice(0,100)}},{key:"setBalanceVisibility",value:function(){var e=this.market;e&&e.dex&&this.balanceWgt.setBalanceVisibility(e.dex.connectionStatus===ln.Connected)}},{key:"handleBalanceNote",value:function(e){this.setBalanceVisibility(),this.preorderCache={};var t=this.market;if(t&&t.dex&&t.dex.connectionStatus===ln.Connected){var n=e.balance.available;switch(e.assetID){case t.baseCfg.id:if(!t.maxSell)break;"number"==typeof t.sellBalance&&t.sellBalance!==n&&(t.maxSell=null),this.isSell()&&this.preSell();break;case t.quoteCfg.id:if(!Object.keys(t.maxBuys).length)break;"number"==typeof t.buyBalance&&t.buyBalance!==n&&(t.maxBuys={}),this.isSell()||this.preBuy()}}}},{key:"submitOrder",value:(a=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.orderErr,t.vErr),n=this.currentOrder,r=t.vPass.value,t.vPass.value="",a={order:Sa(n),pw:r},this.validateOrder(n)){e.next=8;break}return e.abrupt("return");case 8:return t.vSubmit.classList.add("d-hide"),t.vLoader.classList.remove("d-hide"),e.next=12,yn("/api/tradeasync",a);case 12:if(o=e.sent,t.vSubmit.classList.remove("d-hide"),t.vLoader.classList.add("d-hide"),Cn().checkResponse(o)){e.next=19;break}return t.vErr.textContent=o.msg,Vt.show(t.vErr),e.abrupt("return");case 19:Vt.hide(t.forms),this.refreshActiveOrders();case 21:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"createWallet",value:(r=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:if(t=e.sent){e.next=5;break}return e.abrupt("return");case 5:n=t.assets[this.currentCreate.id],Vt.hide(this.page.forms),this.balanceWgt.updateAsset(n.id),Vt.setVis(!(this.market.base.wallet&&this.market.quote.wallet),this.page.noWallet),this.resolveOrderFormVisibility();case 10:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"walletUnlocked",value:(n=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vt.hide(this.page.forms),this.balanceWgt.updateAsset(this.openAsset.id);case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"lotChanged",value:function(){var e=this.page,t=parseInt(e.lotField.value||"0");if(t<=0)return e.lotField.value="0",e.qtyField.value="",void this.previewQuoteAmt(!1);var n=this.market.cfg.lotsize;e.lotField.value=String(t),e.qtyField.value=String(t*n/this.market.baseUnitInfo.conventional.conversionFactor),this.previewQuoteAmt(!0)}},{key:"quantityChanged",value:function(e){var t=this.page,n=this.parseOrder();if(n.qty<0)return t.lotField.value="0",t.qtyField.value="",void this.previewQuoteAmt(!1);var r=this.market.cfg.lotsize,a=Math.floor(n.qty/r),o=a*r;t.lotField.value=String(a),(n.isLimit||n.sell)&&(e&&(t.qtyField.value=String(o/this.market.baseUnitInfo.conventional.conversionFactor)),this.previewQuoteAmt(!0))}},{key:"marketBuyChanged",value:function(){var e=this.page,t=xa(e.mktBuyField.value||"",this.market.quoteUnitInfo.conventional.conversionFactor),n=this.midGap();if(!n||!t)return e.mktBuyLots.textContent="0",void(e.mktBuyScore.textContent="0");var r=this.market.cfg.lotsize,a=t/n;e.mktBuyLots.textContent=(a/r).toFixed(1),e.mktBuyScore.textContent=Vt.formatCoinValue(a,this.market.baseUnitInfo)}},{key:"rateFieldChanged",value:function(){var e=this.adjustedRate();if(e<=0)return this.depthLines.input=[],this.drawChartLines(),void(this.page.rateField.value="0");var t=this.parseOrder(),n=e/this.market.rateConversionFactor;this.page.rateField.value=String(n),this.depthLines.input=[{rate:n,color:t.sell?this.depthChart.theme.sellLine:this.depthChart.theme.buyLine}],this.drawChartLines(),this.previewQuoteAmt(!0)}},{key:"adjustedRate",value:function(){var e=this.page.rateField.value;if(!e)return NaN;var t=xa(e,this.market.rateConversionFactor);return t-t%this.market.cfg.ratestep}},{key:"loadTable",value:function(){this.loadTableSide(!0),this.loadTableSide(!1)}},{key:"binOrdersByRateAndEpoch",value:function(e){if(!e||!e.length)return[];var t=[],n=[],r=[],a=e[0].msgRate;e[0].epoch?n.push(e[0]):r.push(e[0]);for(var o=1;o0}))}},{key:"loadTableSide",value:function(e){var t=this,n=e?this.book.sells:this.book.buys,r=e?this.page.sellRows:this.page.buyRows;Vt.empty(r),n&&n.length&&this.binOrdersByRateAndEpoch(n).forEach((function(e){r.appendChild(t.orderTableRow(e))}))}},{key:"addTableOrder",value:function(e){var t=e.sell?this.page.sellRows:this.page.buyRows,n=t.firstChild;if(0!==e.rate){for(n&&0===n.manager.getRate()&&(n=n.nextSibling);n;){if(0===n.manager.compare(e))return void n.manager.insertOrder(e);if(n.manager.compare(e)>0){var r=this.orderTableRow([e]);return void t.insertBefore(r,n)}n=n.nextSibling}var a=this.orderTableRow([e]);t.appendChild(a)}else{if(0===e.qtyAtomic)return;n&&0===n.manager.getRate()?n.manager.insertOrder(e):(n=this.orderTableRow([e]),t.insertBefore(n,t.firstChild))}}},{key:"removeTableOrder",value:function(e){for(var t=e.token,n=0,r=[this.page.sellRows,this.page.buyRows];n36e5&&!i.disabled?(Vt.show(n.expired),i.running&&Cn().fetchBalance(o)):Vt.hide(n.expired)}else Vt.show(n.connect)}else Vt.show(n.unsupported)}}},{key:"updateParent",value:function(e){var t,n=Cn().assets[e.parentID],r=n.wallet.balance,a=n.unitInfo;null!==(t=e.parentBal)&&void 0!==t&&t.firstChild&&(e.parentBal.firstChild.textContent=Vt.formatCoinValue(r.available,a))}},{key:"updateAsset",value:function(e){e===this.base.id?this.updateWallet(this.base):e===this.quote.id&&this.updateWallet(this.quote),e===this.base.parentID&&this.updateParent(this.base),e===this.quote.parentID&&this.updateParent(this.quote)}}]),e}();function wa(e,t,n){return{host:e,base:t,quote:n}}function ka(e,t){return"".concat(e,"_").concat(t)}function xa(e,t){return e?Math.round(parseFloat(e)*t):0}function Ca(e,t){e.classList.remove("selected"),t.classList.add("selected")}function Sa(e){for(var t={},n=0,a=Object.entries(e.options);n1?(r.removeAttribute("hidden"),r.innerText=String(t),r.title="quantity is comprised of ".concat(t," orders")):r.setAttribute("hidden","true")}},{key:"insertOrder",value:function(e){this.orderBin.push(e),this.updateQtyNumOrdersEl()}},{key:"updateOrderQty",value:function(e){for(var t=e.token,n=e.qty,r=e.qtyAtomic,a=0;ae.msgRate===e.sell?1:-1:this.isEpoch()?1:-1}}]),e}(),Aa=new Intl.NumberFormat(navigator.languages,{maximumSignificantDigits:4}),Fa=new Intl.NumberFormat(navigator.languages,{minimumFractionDigits:1,maximumFractionDigits:1});function Ia(e){return e>=1e3||Math.round(e)===e?Fa.format(e):Aa.format(e)}function Ra(e,t,n){if(n.spot){e.price.textContent=Ia(Cn().conventionalRate(n.baseid,n.quoteid,n.spot.rate,t));var r=n.spot.change24>0?"+":"";e.change.classList.remove("buycolor","sellcolor"),e.change.classList.add(n.spot.change24>=0?"buycolor":"sellcolor"),e.change.textContent="".concat(r).concat((100*n.spot.change24).toFixed(1),"%")}}var Da=[.5,1/4,3/4,1/8,5/8,3/8,7/8];function Oa(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Ta(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ta(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Ta(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&(e.checked=!0)}))}};o(n.hostFilter,"hosts"),o(n.assetFilter,"assets"),o(n.statusFilter,"statuses");var i=[],c=function(e,n){var a=e.querySelector(".apply-bttn");i.push(a),Vt.bind(a,"click",(function(){t.submitFilter(),i.forEach((function(e){return Vt.hide(e)}))})),e.querySelectorAll("input").forEach((function(t){Vt.bind(t,"change",(function(){!function(e,t){if(e.length!==t.length)return!1;var n,r=Oa(e);try{for(r.s();!(n=r.n()).done;){var a=n.value;if(-1===t.indexOf(a))return!1}}catch(e){r.e(e)}finally{r.f()}return!0}(za(e),r[n])?Vt.show(a):Vt.hide(a)}))}))};return c(n.hostFilter,"hosts"),c(n.assetFilter,"assets"),c(n.statusFilter,"statuses"),Vt.bind(t.main,"scroll",(function(){t.loading||n.ordersTable.offsetHeight-t.main.offsetHeight-t.main.scrollTop<0&&t.nextPage()})),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){Vt.hide(n.forms)}))})),Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||Vt.hide(n.forms)})),Vt.bind(n.exportOrders,"click",(function(){t.exportOrders()})),n.showArchivedDateField.addEventListener("change",(function(){n.showArchivedDateField.checked?Vt.show(n.archivedDateField):Vt.hide(n.archivedDateField,n.deleteArchivedRecordsErr)})),Vt.bind(n.deleteArchivedRecords,"click",(function(){var e=t.page;e.showArchivedDateField.checked=!1,e.saveMatchesToFile.checked=!1,e.saveOrdersToFile.checked=!1,e.deleteArchivedRecordsErr.textContent="",e.archivedRecordsLocation.textContent="",e.deleteArchivedRecordsMsg.textContent="",Vt.hide(e.deleteArchivedResult,e.deleteArchivedRecordsErr,e.deleteArchivedRecordsMsg,e.archivedRecordsLocation,e.archivedDateField),t.showForm(e.deleteArchivedRecordsForm)})),Vt.bind(n.deleteArchivedRecordsSubmit,"click",(function(){var e=0;n.showArchivedDateField.checked&&(e=Date.parse(n.olderThan.value||""),isNaN(e)||e<=0)?Vt.showFormError(n.deleteArchivedRecordsErr,Rt(qe)):t.deleteArchivedRecords(e)})),t.submitFilter(),t}return u(p,[{key:"showForm",value:(i=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentForm=t,n=this.page,Vt.hide(n.deleteArchivedRecordsForm),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(500,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0px";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setOrders",value:function(e){Vt.empty(this.page.tableBody),this.appendOrders(e)}},{key:"appendOrders",value:function(e){var t,n=this,r=this.page.tableBody,a=Oa(e);try{var o=function(){var e,a,o,s=t.value,i=n.orderTmpl.cloneNode(!0),c=function(e,t){Vt.tmplElement(i,e).textContent=t},l="".concat(s.baseSymbol.toUpperCase(),"-").concat(s.quoteSymbol.toUpperCase());c("host","".concat(l," @ ").concat(s.host));var u="",h=[Cn().unitInfo(s.baseID),Cn().unitInfo(s.quoteID)],d=h[0],p=h[1];if(s.sell){var f=[s.baseSymbol,s.quoteSymbol];e=f[0],a=f[1],o=Vt.formatCoinValue(s.qty,d),1===s.type&&(u=Vt.formatCoinValue(s.qty/Pn*s.rate,p))}else{var m=[s.quoteSymbol,s.baseSymbol];e=m[0],a=m[1],2===s.type?o=Vt.formatCoinValue(s.qty,d):(o=Vt.formatCoinValue(s.qty/Pn*s.rate,p),u=Vt.formatCoinValue(s.qty,d))}c("fromQty",o),Vt.tmplElement(i,"fromLogo").src=Vt.logoPath(e),c("fromSymbol",e),c("toQty",u),Vt.tmplElement(i,"toLogo").src=Vt.logoPath(a),c("toSymbol",a),c("type","".concat(Mn(s)," ").concat(Ln(s))),c("rate",Vt.formatCoinValue(Cn().conventionalRate(s.baseID,s.quoteID,s.rate))),c("status",qn(s)),c("filled","".concat((Nn(s)/s.qty*100).toFixed(1),"%")),c("settled","".concat((Un(s)/s.qty*100).toFixed(1),"%"));var v=new Date(s.submitTime).toLocaleString();c("time","".concat(Vt.timeSince(s.submitTime)," ago, ").concat(v)),Vt.tmplElement(i,"link").href="order/".concat(s.id),Cn().bindInternalNavigation(i),r.appendChild(i)};for(a.s();!(t=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}50===e.length?this.offset=e[e.length-1].id:this.offset=""}},{key:"submitFilter",value:(a=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,this.offset="",(n=this.filterState).hosts=za(t.hostFilter),n.assets=za(t.assetFilter).map((function(e){return parseInt(e)})),n.statuses=za(t.statusFilter).map((function(e){return parseInt(e)})),e.t0=this,e.next=9,this.fetchOrders();case 9:e.t1=e.sent,e.t0.setOrders.call(e.t0,e.t1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"fetchOrders",value:(r=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cn().loading(this.main),e.next=3,yn("/api/orders",this.currentFilter());case 3:return n=e.sent,t(),e.abrupt("return",n.orders);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"exportOrders",value:function(){this.offset="";var e=this.currentFilter(),t=new URL(window.location.href),n=new URLSearchParams(""),r=function(t){e[t].forEach((function(e){n.append(t,e)}))};r("hosts"),r("assets"),r("statuses"),t.search=n.toString(),t.pathname="/orders/export",window.open(t.toString())}},{key:"deleteArchivedRecords",value:(n=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=n.saveMatchesToFile.checked||!1,a=n.saveOrdersToFile.checked||!1,o={olderThanMs:t,saveMatchesToFile:r,saveOrdersToFile:a},s=Cn().loading(this.main),e.next=7,yn("/api/deletearchivedrecords",o);case 7:if(i=e.sent,s(),Cn().checkResponse(i)){e.next=11;break}return e.abrupt("return",Vt.showFormError(n.deleteArchivedRecordsErr,i.msg));case 11:i.archivedRecordsDeleted>0?(n.deleteArchivedRecordsMsg.textContent=Rt(Ue,{nRecords:i.archivedRecordsDeleted}),(r||a)&&(n.archivedRecordsLocation.textContent=Rt(_e,{path:i.archivedRecordsPath}),Vt.show(n.archivedRecordsLocation)),this.submitFilter()):n.deleteArchivedRecordsMsg.textContent=Rt(Ne),Vt.show(n.deleteArchivedResult,n.deleteArchivedRecordsMsg);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"currentFilter",value:function(){var e=this.filterState;return{hosts:e.hosts,assets:e.assets.map((function(e){return parseInt(e)})),statuses:e.statuses.map((function(e){return parseInt(e)})),n:50,offset:this.offset}}},{key:"nextPage",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==this.offset&&!this.loading){e.next=2;break}return e.abrupt("return");case 2:return this.loading=!0,Vt.show(this.page.orderLoader),e.next=6,this.fetchOrders();case 6:t=e.sent,this.loading=!1,Vt.hide(this.page.orderLoader),this.appendOrders(t);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),p}(mn);function za(e){var t=[];return e.querySelectorAll("input").forEach((function(e){e.checked&&t.push(e.value)})),t}function Va(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return ja(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ja(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function ja(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=3}(t)||t.revoked||t.refund?!function(e){return e.status<5&&1===e.side&&e.status>=4}(t)||t.revoked||t.refund?Vt.hide(n.makerSwapMsg,n.takerSwapMsg,n.makerRedeemMsg,n.takerRedeemMsg):(n.takerRedeemMsg.textContent=Xa(t.redeem),Vt.hide(n.makerSwapMsg,n.takerSwapMsg,n.makerRedeemMsg),Vt.show(n.takerRedeemMsg)):(n.makerRedeemMsg.textContent=Xa(t.redeem),Vt.hide(n.makerSwapMsg,n.takerSwapMsg,n.takerRedeemMsg),Vt.show(n.makerRedeemMsg));else{var a=Ya(t);n.takerSwapMsg.textContent=Xa(a),Vt.hide(n.makerSwapMsg,n.makerRedeemMsg,n.takerRedeemMsg),Vt.show(n.takerSwapMsg)}else{var o=Qa(t);n.makerSwapMsg.textContent=Xa(o),Vt.hide(n.takerSwapMsg,n.makerRedeemMsg,n.takerRedeemMsg),Vt.show(n.makerSwapMsg)}Vt.setVis(!t.isCancel&&(Qa(t)||!t.revoked),n.makerSwap),Vt.setVis(!t.isCancel&&(Ya(t)||!t.revoked),n.takerSwap),Vt.setVis(!t.isCancel&&(Ja(t)||!t.revoked),n.makerRedeem),Vt.setVis(!t.isCancel&&(Za(t)||!t.revoked&&t.active||1===t.side&&t.active&&(t.counterRedeem||!t.refund)),n.takerRedeem),Vt.setVis(!t.isCancel&&(t.refund||t.revoked&&t.active&&!t.counterRedeem),n.refund)}}},{key:"addNewMatchCard",value:function(e){var t=this.page,n=t.matchCardTmpl.cloneNode(!0);n.dataset.matchID=e.matchID,this.setImmutableMatchCardElements(n,e),this.setMutableMatchCardElements(n,e),t.matchBox.appendChild(n)}},{key:"showMatchCards",value:function(){var e=this,t=this.order;t&&t.matches&&(t.matches.sort((function(e,t){return e.stamp-t.stamp})),t.matches.forEach((function(t){return e.addNewMatchCard(t)})))}},{key:"showCancel",value:function(){var e=this.order,t=this.page,n=e.qty-e.filled,r=Bn(e)?Cn().assets[e.quoteID]:Cn().assets[e.baseID];t.cancelRemain.textContent=Vt.formatCoinValue(n,r.unitInfo),t.cancelUnit.textContent=r.unitInfo.conventional.unit.toUpperCase(),this.showForm(t.cancelForm)}},{key:"showForm",value:(r=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentForm=t,n=this.page,Vt.hide(n.cancelForm,n.accelerateForm),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(500,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0px";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"submitCancel",value:(n=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=this.order,r={orderID:n.id,pw:t.cancelPass.value},t.cancelPass.value="",a=Cn().loading(t.cancelForm),e.next=7,yn("/api/cancel",r);case 7:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=11;break}return e.abrupt("return");case 11:t.status.textContent=Rt(G),Vt.hide(t.forms),n.cancelling=!0;case 14:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setAccelerationButtonVis",value:function(){var e=this.order;if(e){var t=this.page;Vt.setVis(Cn().canAccelerateOrder(e),t.accelerateBttn,t.actionsLabel)}}},{key:"showAccelerateForm",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Cn().loading(this.page.accelerateBttn),this.accelerateOrderForm.refresh(this.order),t(),this.showForm(this.page.accelerateForm);case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"handleOrderNote",value:function(e){var t=this.page,n=e.order;if(n.id===this.orderID){this.order=n;var r=t.cancelBttn;r&&n.status>2&&Vt.hide(r),t.status.textContent=qn(n);var a,o=Va(n.matches||[]);try{for(o.s();!(a=o.n()).done;){var s=a.value;this.processMatch(s)}}catch(e){o.e(e)}finally{o.f()}this.setAccelerationButtonVis()}}},{key:"handleMatchNote",value:function(e){e.orderID===this.orderID&&(this.processMatch(e.match),this.setAccelerationButtonVis())}},{key:"processMatch",value:function(e){var t,n=null,r=Va(Vt.applySelector(this.page.matchBox,".match-card"));try{for(r.s();!(t=r.n()).done;){var a=t.value;if(a.dataset.matchID===e.matchID){n=a;break}}}catch(e){r.e(e)}finally{r.f()}n?this.setMutableMatchCardElements(n,e):this.addNewMatchCard(e)}}]),p}(mn);function Xa(e){return e.confs&&0!==e.confs.required?"".concat(e.confs.count," / ").concat(e.confs.required," ").concat(Rt(pt)):""}function Qa(e){return 0===e.side?e.swap:e.counterSwap}function Ya(e){return 0===e.side?e.counterSwap:e.swap}function Ja(e){return 0===e.side?e.redeem:e.counterRedeem}function Za(e){return 0===e.side?e.counterRedeem:e.redeem}function $a(e,t){var n=to[e];if(n){var r=n[Ha];r&&(t.classList.remove("plainlink"),t.classList.add("subtlelink"),t.href=r(t.dataset.explorerCoin||""))}}var eo=(h(Pa={},0,(function(e){if(e.startsWith(Ga)){var t=e.substring(Ga.length);return"https://etherscan.io/address/".concat(t)}return 42===e.length?"https://etherscan.io/address/".concat(e):"https://etherscan.io/tx/".concat(e)})),h(Pa,1,(function(e){if(e.startsWith(Ga)){var t=e.substring(Ga.length);return"https://goerli.etherscan.io/address/".concat(t)}return 42===e.length?"https://goerli.etherscan.io/address/".concat(e):"https://goerli.etherscan.io/tx/".concat(e)})),Pa),to={42:(La={},h(La,0,(function(e){var t=r(e.split(":"),2),n=t[0],a=t[1];return"https://explorer.dcrdata.org/tx/".concat(n,"/out/").concat(a)})),h(La,1,(function(e){var t=r(e.split(":"),2),n=t[0],a=t[1];return"https://testnet.dcrdata.org/tx/".concat(n,"/out/").concat(a)})),La),0:(Ma={},h(Ma,0,(function(e){return"https://mempool.space/tx/".concat(e.split(":")[0])})),h(Ma,1,(function(e){return"https://mempool.space/testnet/tx/".concat(e.split(":")[0])})),Ma),2:(Ba={},h(Ba,0,(function(e){return"https://ltc.bitaps.com/".concat(e.split(":")[0])})),h(Ba,1,(function(e){return"https://sochain.com/tx/LTCTEST/".concat(e.split(":")[0])})),Ba),20:(Wa={},h(Wa,0,(function(e){return"https://digiexplorer.info/tx/".concat(e.split(":")[0])})),h(Wa,1,(function(e){return"https://testnetexplorer.digibyteservers.io/tx/".concat(e.split(":")[0])})),Wa),60:eo,60001:eo,3:(qa={},h(qa,0,(function(e){return"https://dogeblocks.com/tx/".concat(e.split(":")[0])})),h(qa,1,(function(e){return"https://blockexplorer.one/dogecoin/testnet/tx/".concat(e.split(":")[0])})),qa),133:(Na={},h(Na,0,(function(e){return"https://zcashblockexplorer.com/transactions/".concat(e.split(":")[0])})),h(Na,1,(function(e){return"https://blockexplorer.one/zcash/testnet/tx/".concat(e.split(":")[0])})),Na),145:(Ua={},h(Ua,0,(function(e){return"https://bch.loping.net/tx/".concat(e.split(":")[0])})),h(Ua,1,(function(e){return"https://tbch4.loping.net/tx/".concat(e.split(":")[0])})),Ua)};var no=function(e){an(y,e);var t,n,a,i,c,l,d,p,f,m,v,g=(m=y,v=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(m);if(v){var n=sn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return on(this,e)});function y(e){var t;s(this,y),h(nn(t=g.call(this)),"body",void 0),h(nn(t),"forms",void 0),h(nn(t),"currentForm",void 0),h(nn(t),"page",void 0),h(nn(t),"host",void 0),h(nn(t),"keyup",void 0),h(nn(t),"dexAddrForm",void 0),t.body=e,t.host=e.dataset.host?e.dataset.host:"";var n=t.page=Vt.idDescendants(e);t.forms=Vt.applySelector(n.forms,":scope > form"),Vt.bind(n.exportDexBtn,"click",(function(){return t.prepareAccountExport(n.authorizeAccountExportForm)})),Vt.bind(n.disableAcctBtn,"click",(function(){return t.prepareAccountDisable(n.disableAccountForm)})),Vt.bind(n.updateBondOptionsBtn,"click",(function(){return t.prepareUpdateBondOptions()})),Vt.bind(n.updateCertBtn,"click",(function(){return n.certFileInput.click()})),Vt.bind(n.updateHostBtn,"click",(function(){return t.prepareUpdateHost()})),Vt.bind(n.certFileInput,"change",(function(){return t.onCertFileChange()})),t.dexAddrForm=new Er(n.dexAddrForm,function(){var e=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:window.location.assign("/dexsettings/".concat(t.host));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),void 0,t.host),Tr(n.updateBondOptionsForm,n.updateBondOptionsConfirm,(function(){return t.updateBondOptions()})),Tr(n.authorizeAccountExportForm,n.authorizeExportAccountConfirm,(function(){return t.exportAccount()})),Tr(n.disableAccountForm,n.disableAccountConfirm,(function(){return t.disableAccount()}));var r=function(){Vt.hide(n.forms)};return Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||r()})),t.keyup=function(e){"Escape"===e.key&&r()},Vt.bind(document,"keyup",t.keyup),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){r()}))})),Cn().registerNoteFeeder({conn:function(){t.setConnectionStatus()}}),t.setConnectionStatus(),t}return u(y,[{key:"unload",value:function(){Vt.unbind(document,"keyup",this.keyup)}},{key:"showForm",value:(f=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.currentForm=t,this.forms.forEach((function(e){return Vt.hide(e)})),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(300,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"exportAccount",value:(p=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=t.exportAccountAppPass.value,r=t.exportAccountHost.textContent,t.exportAccountAppPass.value="",a={pw:n,host:r},o=Cn().loading(this.body),e.next=8,yn("/api/exportaccount",a);case 8:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=14;break}return t.exportAccountErr.textContent=s.msg,Vt.show(t.exportAccountErr),e.abrupt("return");case 14:s.account.bonds=s.bonds,i=JSON.parse(JSON.stringify(s.account)),(c=document.createElement("a")).setAttribute("download","dcrAccount-"+r+".json"),c.setAttribute("href","data:text/json,"+JSON.stringify(i,null,2)),c.click(),Vt.hide(t.forms);case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"disableAccount",value:(d=o(w().mark((function e(){var t,n,r,a,o,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=t.disableAccountAppPW.value,r=t.disableAccountHost.textContent,t.disableAccountAppPW.value="",a={pw:n,host:r},o=Cn().loading(this.body),e.next=8,yn("/api/disableaccount",a);case 8:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=14;break}return t.disableAccountErr.textContent=s.msg,Vt.show(t.disableAccountErr),e.abrupt("return");case 14:Vt.hide(t.forms),window.location.assign("/settings");case 16:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"prepareAccountExport",value:(l=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.page).exportAccountHost.textContent=this.host,n.exportAccountErr.textContent="",tn.passwordIsCached()?this.exportAccount():this.showForm(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"prepareAccountDisable",value:(c=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.page).disableAccountHost.textContent=this.host,n.disableAccountErr.textContent="",this.showForm(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"prepareUpdateBondOptions",value:(i=o(w().mark((function e(){var t,n,a,o,s,i,c,l;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=this.page,n=Cn().user.exchanges[this.host],t.bondTargetTier.setAttribute("placeholder",n.bondOptions.targetTier.toString()),Vt.empty(t.bondAssetSelect),a=0,o=Object.entries(n.bondAssets);a=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function so(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0)this.fetchMaxBuy(Math.round(e.basisPrice/this.currentMarket.atomToConv*Pn)),t.basisPrice.textContent=Vt.formatFiveSigFigs(e.basisPrice),Vt.show(t.absMaxBox,t.basisPrice),Vt.hide(t.manualPriceInput,t.noFiatBox),this.page.gapFactorMax.textContent=Vt.formatFiveSigFigs(e.basisPrice);else{t.lotEstQuoteLots.textContent="[no rate]",t.basisPrice.textContent="must set manually",Vt.hide(t.basisPrice,t.absMaxBox),Vt.show(t.manualPriceInput),t.manualPriceInput.focus();var n=Cn().user;0===Object.keys(n.fiatRates).length&&Vt.show(t.noFiatBox)}e&&e.breakEvenSpread>0?(Vt.show(t.breakEvenGapBox),t.breakEvenGap.textContent=Vt.formatFiveSigFigs(e.breakEvenSpread)):Vt.hide(t.breakEvenGapBox)}},{key:"updateGapStrategyInputVisibility",value:function(){var e=this.page;switch(e.gapStrategySelect.value){case io:Vt.show(this.gapMultiplierOpt.node),Vt.hide(e.absInputBox,e.absMaxBox,this.gapPercentOpt.node);break;case uo:case ho:Vt.show(this.gapPercentOpt.node),Vt.hide(e.absInputBox,e.absMaxBox,this.gapMultiplierOpt.node);break;case co:case lo:Vt.hide(this.gapMultiplierOpt.node,this.gapPercentOpt.node),Vt.show(e.absInputBox,e.absMaxBox)}}},{key:"updateGapStrategyInputs",value:function(e){switch(this.updateGapStrategyInputVisibility(),this.page.gapStrategySelect.value){case io:e&&e.breakEvenSpread>0?(ko.start.y=e.breakEvenSpread,ko.end.y=100*e.breakEvenSpread,ko.yUnit=this.rateUnit()):(ko.start.y=100,ko.end.y=1e4,ko.yUnit="%"),this.gapMultiplierOpt.handler.setConfig(ko);break;case uo:case ho:e&&e.breakEvenSpread>0?(So.end.y=e.basisPrice,So.yUnit=this.rateUnit(),this.gapPercentOpt.handler.setConfig(So)):(So.end.y=10,So.yUnit="%")}}},{key:"setCurrentBasisPrice",value:function(e){if(e>0){var t=this.rateUnit();vo.start.y=-.01*e,vo.end.y=.01*e,vo.yUnit=t,yo.start.y=0,yo.end.y=.01*e,yo.yUnit=t}else vo.start.y=-1,vo.end.y=1,vo.yUnit="%",yo.start.y=0,yo.end.y=1,yo.yUnit="%";this.biasOpt.handler.setConfig(vo),this.driftToleranceOpt.handler.setConfig(yo)}},{key:"rateUnit",value:function(){var e=this.currentMarket.quotesymbol.split(".")[0],t=this.currentMarket.basesymbol.split(".")[0];return"".concat(e,"/").concat(t)}},{key:"setMarket",value:(c=o(w().mark((function e(t,n){var r,a,o,s,i,c,l,u,h,d,p,f,m,v;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.page,a=t[0],this.currentMarket=a,this.specifiedPrice=0,this.setCurrentReport(null),r.manualPriceInput.value="",tn.storeLocal(tn.lastMMMarketLK,a),Vt.empty(r.baseSelect,r.quoteSelect),r.baseSelect.appendChild(this.assetRow(a.basesymbol)),r.quoteSelect.appendChild(this.assetRow(a.quotesymbol)),this.hideAssetDropdown(),o=function(e,t){Vt.setContent(t,Vt.symbolize(e.basesymbol),new Text("-"),Vt.symbolize(e.quotesymbol),new Text(" @ "),new Text(e.host))},Vt.hide(r.marketSelect,r.marketOneChoice),1===t.length)Vt.show(r.marketOneChoice),o(a,r.marketOneChoice);else{Vt.show(r.marketSelect),Vt.empty(r.marketSelect),s=oo(t);try{for(s.s();!(i=s.n()).done;)c=i.value,l=document.createElement("option"),r.marketSelect.appendChild(l),l.value="".concat(c.host," ").concat(c.name),o(c,l)}catch(e){s.e(e)}finally{s.f()}}if(!n){e.next=16;break}return e.abrupt("return");case 16:if(Vt.setContent(r.lotEstBaseSymbol,Vt.symbolize(a.basesymbol)),Vt.setContent(r.lotEstQuoteSymbol,Vt.symbolize(a.quotesymbol)),u=function(e,t){Vt.show(t);var n=Vt.parseTemplate(t);return n.assetLogo.src=Vt.logoPath(e.symbol),n.assetName.textContent=e.name,!1},Vt.hide(r.lotEstQuoteBox,r.lotEstQuoteNoWallet,r.lotEstBaseBox,r.lotEstBaseNoWallet,r.availHeader,r.lotEstimateBox,r.marketInfo,r.oraclesBox,r.lotsBox,r.options,r.advancedBox),h=[Cn().assets[a.baseid],Cn().assets[a.quoteid]],p=h[1],!(d=h[0]).wallet||!p.wallet){e.next=35;break}return Vt.show(r.lotEstQuoteBox,r.lotEstBaseBox,r.availHeader,r.fetchingMarkets,r.lotsBox,r.advancedBox),tn.fetchLocal(tn.optionsExpansionLK)&&Vt.show(r.options),f=Cn().loading(r.options),m=this.fetchOracleAndMaxBuy(),v=this.fetchMaxSell(),e.next=29,m;case 29:return e.next=31,v;case 31:return f(),Vt.show(r.lotEstimateBox,r.marketInfo,r.oraclesBox),Vt.hide(r.fetchingMarkets),e.abrupt("return");case 35:Vt.show(r.lotEstimateBox),p.wallet?r.lotEstQuoteLots.textContent="0":u(p,r.lotEstQuoteNoWallet),d.wallet?r.lotEstBaseLots.textContent="0":u(d,r.lotEstBaseNoWallet);case 38:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"fetchMaxSell",value:(i=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.currentMarket,n=this.page,e.next=3,yn("/api/maxsell",{host:t.host,base:t.baseid,quote:t.quoteid});case 3:if(r=e.sent,this.currentMarket===t){e.next=6;break}return e.abrupt("return");case 6:if(Cn().checkResponse(r)){e.next=10;break}return n.lotEstBaseLots.textContent="0",console.error(r),e.abrupt("return");case 10:n.lotEstBaseLots.textContent=String(r.maxSell.swap.lots);case 11:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"fetchOracleAndMaxBuy",value:(a=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d,p;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.currentMarket,r=this.page,e.next=3,yn("/api/marketreport",{host:n.host,baseID:n.baseid,quoteID:n.quoteid});case 3:if(a=e.sent,Cn().checkResponse(a)){e.next=8;break}return r.lotEstQuoteLots.textContent="0",console.error(a),e.abrupt("return");case 8:if(o=a.report,Vt.hide(r.manualPriceBttn),this.setCurrentReport(o),o.oracles&&0!==o.oracles.length){e.next=13;break}return e.abrupt("return");case 13:Vt.empty(r.oracles),s=0,i=0,c=oo(null!==(t=o.oracles)&&void 0!==t?t:[]);try{for(c.s();!(l=c.n()).done;)u=l.value,h=r.oracleTmpl.cloneNode(!0),r.oracles.appendChild(h),(d=Vt.parseTemplate(h)).logo.src="img/"+u.host+".png",d.host.textContent=Do[u.host],d.volume.textContent=Vt.formatThreeSigFigs(u.usdVol),p=(u.bestBuy+u.bestSell)/2,i+=u.usdVol*p,s+=u.usdVol,d.price.textContent=Vt.formatThreeSigFigs((u.bestBuy+u.bestSell)/2)}catch(e){c.e(e)}finally{c.f()}r.avgPrice.textContent=Vt.formatFiveSigFigs(i/s);case 19:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"fetchMaxBuy",value:(n=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.currentMarket,r=this.page,e.next=3,yn("/api/maxbuy",{host:n.host,base:n.baseid,quote:n.quoteid,rate:null!=t?t:0});case 3:if(a=e.sent,this.currentMarket===n){e.next=6;break}return e.abrupt("return");case 6:r.lotEstQuoteLots.textContent=String(a.maxBuy.swap.lots);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setEditProgram",value:function(e){var t=this,n=this.createOpts,r=this.page,a=e.program,o=[Cn().assets[a.baseID],Cn().assets[a.quoteID]],s=o[0],i=o[1],c=Cn().exchanges[a.host].markets["".concat(s.symbol,"_").concat(i.symbol)];this.setMarket([ao({host:a.host},c)],!0);for(var l=0,u=Object.values(this.programs);l0?(Vt.show(e.programsHeader),Vt.hide(e.noProgramsMessage)):(Vt.hide(e.programsHeader),Vt.show(e.noProgramsMessage))}},{key:"programDiv",value:function(e){var t=this,n=this.page.runningProgramTmpl.cloneNode(!0),r=Vt.parseTemplate(n),a=function(){var t=o(w().mark((function t(a,o){var s,i;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Vt.hide(r.startErr),s=Cn().loading(n),t.next=4,yn(a,{programID:e.programID,appPW:o});case 4:i=t.sent,s(),Cn().checkResponse(i)||(r.startErr.textContent=i.msg,Vt.show(r.startErr));case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}();Vt.bind(r.pauseBttn,"click",(function(){return a("/api/stopbot")})),Vt.bind(r.startBttn,"click",this.authedRoute(function(){var e=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a("/api/startbot",t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())),Vt.bind(r.retireBttn,"click",(function(){return a("/api/retirebot")})),Vt.bind(r.configureBttn,"click",(function(n){n.stopPropagation(),t.setEditProgram(t.programs[e.programID])}));var s=[Cn().assets[e.program.baseID],Cn().assets[e.program.quoteID]],i=s[0],c=s[1];return r.base.appendChild(this.assetRow(i.symbol)),r.quote.appendChild(this.assetRow(c.symbol)),r.baseSymbol.textContent=i.symbol.toUpperCase(),r.quoteSymbol.textContent=c.symbol.toUpperCase(),r.host.textContent=e.program.host,this.updateProgramDiv(r,e),this.programs[e.programID]=Object.assign({tmpl:r,div:n},e),n}},{key:"authedRoute",value:function(e){var t=this;return o(w().mark((function n(){return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!tn.passwordIsCached()){n.next=4;break}return n.next=3,e("");case 3:return n.abrupt("return",n.sent);case 4:return t.pwHandler=e,n.next=7,t.showForm(t.page.pwForm);case 7:case"end":return n.stop()}}),n)})))}},{key:"updateProgramDiv",value:function(e,t){var n=t.program;Vt.hide(e.programRunning,e.programPaused),t.running?Vt.show(e.programRunning):Vt.show(e.programPaused),e.lots.textContent=String(n.lots),e.boost.textContent="".concat((100*n.gapFactor).toFixed(1),"%"),e.driftTolerance.textContent="".concat((100*n.driftTolerance).toFixed(2),"%"),e.oracleWeight.textContent="".concat((100*n.oracleWeighting).toFixed(0),"%"),e.oracleBias.textContent="".concat((100*n.oracleBias).toFixed(1),"%")}},{key:"setMarketSubchoice",value:function(e,t){e===this.currentMarket.host&&t===this.currentMarket.name||this.leaveEditMode(),this.currentMarket=Object.assign({host:e},Cn().exchanges[e].markets[t])}},{key:"createOptsUpdated",value:function(){this.createOpts.oracleWeighting?Vt.show(this.biasOpt.node):Vt.hide(this.biasOpt.node)}},{key:"handleBotNote",value:function(e){var t=this.page,n=e.report;switch(e.topic){case"BotCreated":t.runningPrograms.prepend(this.programDiv(n)),this.setProgramsHeader();break;case"BotRetired":this.programs[n.programID].div.remove(),delete this.programs[n.programID],this.setProgramsHeader();break;default:var r=this.programs[n.programID];Object.assign(r,n),this.updateProgramDiv(r.tmpl,n)}}},{key:"setCreationBase",value:function(e){for(var t=this.currentMarket.quotesymbol,n=Fo(),r=[],a=0,o=n;a0)return this.setMarket(r);for(var u=0,h=n;u0)return this.setMarket(r);for(var u=0,h=n;u 0 lots"));case 6:i=Object.assign({host:r.host,baseID:r.baseid,quoteID:r.quoteid},this.createOpts,{lots:s,gapStrategy:""}),c=n.gapStrategySelect.value,i.gapStrategy=null!=c?c:"",l={botType:"MakerV0",program:i,programID:0,appPW:t,manualRate:0},e.t0=c,e.next=e.t0===co||e.t0===lo?13:e.t0===uo||e.t0===ho?22:24;break;case 13:if(0!==(u=parseFloat(n.absInput.value||"0"))){e.next=18;break}return e.abrupt("return",o("gap must be specified for strategy = absolute"));case 18:if(!(null!=a&&a.basisPrice&&u>=a.basisPrice)){e.next=20;break}return e.abrupt("return",o("gap width cannot be > current spot price"));case 20:return i.gapFactor=u,e.abrupt("break",25);case 22:return i.gapFactor=this.gapRanges.gapPercent,e.abrupt("break",25);case 24:i.gapFactor=this.gapRanges.gapMultiplier;case 25:if(h="/api/createbot",null===this.editProgram){e.next=31;break}l.programID=this.editProgram.programID,h="/api/updatebotprogram",e.next=36;break;case 31:if(this.currentReport&&0!==this.currentReport.basisPrice){e.next=36;break}if(0!==this.specifiedPrice){e.next=35;break}return o("price must be set manually"),e.abrupt("return");case 35:l.program.manualRate=this.specifiedPrice;case 36:return d=Cn().loading(n.botCreator),e.next=39,yn(h,l);case 39:if(p=e.sent,d(),Cn().checkResponse(p)){e.next=45;break}return n.createErr.textContent=p.msg,Vt.show(n.createErr),e.abrupt("return");case 45:this.leaveEditMode(),n.lotsInput.value="";case 47:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"newWalletCreated",value:function(e){var t=this.currentMarket;if(e===t.baseid)this.setCreationBase(t.basesymbol);else{if(e!==t.quoteid)return;this.setCreationQuote(t.quotesymbol)}this.closePopups()}}]),m}(mn);function Fo(){for(var e=[],t=function(e){return Object.values(e.markets).map((function(t){return Object.assign({host:e.host},t)}))},n=0,r=Object.values(Cn().user.exchanges);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Lo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?n-1:0),a=1;adocument.body.offsetWidth&&(r=document.body.offsetWidth-t.tooltip.offsetWidth-5),t.tooltip.style.left="".concat(r,"px"),t.tooltip.style.top="".concat(n.bodyTop-t.tooltip.offsetHeight-5,"px")})),Bo(e,"mouseleave",(function(){t.tooltip.style.left="-10000px"}))}))}},{key:"attachHeader",value:function(){var e=this;this.header=Mo(document.body,"header"),this.headerSpace=Vt.idel(this.header,"headerSpace"),this.popupNotes=Mo(document.body,"popupNotes"),this.popupTmpl=Vt.tmplElement(this.popupNotes,"note"),this.popupTmpl?this.popupTmpl.remove():console.error("popupTmpl element not found"),this.tooltip=Mo(document.body,"tooltip");var t=this.page=Vt.idDescendants(this.header);t.noteTmpl.removeAttribute("id"),t.noteTmpl.remove(),t.pokeTmpl.removeAttribute("id"),t.pokeTmpl.remove(),t.loader.remove(),Vt.show(t.loader),Bo(t.noteBell,"click",o(w().mark((function n(){var r,a,o;return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:Vt.hide(t.pokeList),Vt.show(t.noteList),e.ackNotes(),t.noteCat.classList.add("active"),t.pokeCat.classList.remove("active"),e.showDropdown(t.noteBell,t.noteBox),Vt.hide(t.noteIndicator),r=Po(e.notes);try{for(r.s();!(a=r.n()).done;)(o=a.value).acked&&o.el.classList.remove("firstview")}catch(e){r.e(e)}finally{r.f()}e.setNoteTimes(t.noteList),e.setNoteTimes(t.pokeList),e.storeNotes();case 12:case"end":return n.stop()}}),n)})))),Bo(t.burgerIcon,"click",(function(){Vt.hide(t.logoutErr),e.showDropdown(t.burgerIcon,t.profileBox)})),Bo(t.innerNoteIcon,"click",(function(){Vt.hide(t.noteBox)})),Bo(t.innerBurgerIcon,"click",(function(){Vt.hide(t.profileBox)})),Bo(t.profileSignout,"click",o(w().mark((function t(){return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.signOut();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),Bo(t.pokeCat,"click",(function(){e.setNoteTimes(t.pokeList),t.pokeCat.classList.add("active"),t.noteCat.classList.remove("active"),Vt.hide(t.noteList),Vt.show(t.pokeList),e.ackNotes()})),Bo(t.noteCat,"click",(function(){e.setNoteTimes(t.noteList),t.noteCat.classList.add("active"),t.pokeCat.classList.remove("active"),Vt.hide(t.pokeList),Vt.show(t.noteList),e.ackNotes()}))}},{key:"showDropdown",value:function(e,t){var n=this,r=e.getBoundingClientRect();Vt.hide(this.page.noteBox,this.page.profileBox),Vt.show(t),t.style.right="".concat(window.innerWidth-r.left-r.width+5,"px"),t.style.top="".concat(r.top-4,"px"),Bo(document,"click",(function e(r){Vt.mouseInElement(r,t)||(Vt.hide(t),Wo(document,"click",e),t===n.page.noteBox&&Vt.isDisplayed(n.page.noteList)&&n.ackNotes())}))}},{key:"ackNotes",value:function(){var e,t=[],n=Po(this.notes);try{for(n.s();!(e=n.n()).done;){var r=e.value;r.acked?r.el.classList.remove("firstview"):(r.acked=!0,r.id&&r.severity>2&&t.push(r.id))}}catch(e){n.e(e)}finally{n.f()}t.length&&Jr.request("acknotes",t),Vt.hide(this.page.noteIndicator)}},{key:"setNoteTimes",value:function(e){for(var t=0,n=Array.from(e.children);t0?Vt.show(e.marketsMenuEntry):Vt.hide(e.marketsMenuEntry)}}},{key:"attachCommon",value:function(e){this.bindInternalNavigation(e)}},{key:"updateBondConfs",value:function(e,t,n,r){var a=this.exchanges[e],o=this.assets[r].symbol;a.pendingBonds[t]={confs:n,assetID:r,symbol:o}}},{key:"updateTier",value:function(e,t){this.exchanges[e].tier=t}},{key:"handleBondNote",value:function(e){switch(e.topic){case"RegUpdate":null!==e.coinID&&this.updateBondConfs(e.dex,e.coinID,e.confirmations,e.asset);break;case"BondConfirmed":null!==e.tier&&this.updateTier(e.dex,e.tier)}}},{key:"setNotes",value:function(e){this.log("notes","setNotes",e),this.notes=[],Vt.empty(this.page.noteList);for(var t=0;t=0&&R.splice(D,1):D>=0?R[D]=A.report:R.push(A.report)}}else this.fiatRatesMap=e.fiatRates}},{key:"notify",value:function(e){this.log("notes","notify",e),this.updateUser(e);var t,n=Po(this.noteReceivers);try{for(n.s();!(t=n.n()).done;){var r=t.value[e.type];if(r)try{r(e)}catch(t){console.error("note feeder error:",t.message?t.message:t),console.log(e),console.log(t.stack)}}}catch(e){n.e(e)}finally{n.f()}if(!(e.severity<2)){var a=this.popupTmpl,s=this.popupNotes;if(this.showPopups){var i=a.cloneNode(!0);Vt.tmplElement(i,"text").textContent="".concat(e.subject,": ").concat(e.details);var c=Vt.tmplElement(i,"indicator");for(2===e.severity?Vt.hide(c):Vo(c,e.severity),s.appendChild(i);s.children.length>5;)s.removeChild(s.firstChild);setTimeout(o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Vt.animate(500,(function(e){i.style.opacity=String(1-e)}));case 2:i.remove();case 3:case"end":return e.stop()}}),e)}))),6e3)}2===e.severity?this.prependPokeElement(e):this.prependNoteElement(e)}}},{key:"registerNoteFeeder",value:function(e){this.noteReceivers.push(e)}},{key:"log",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a100;)this.pokes.shift();this.prependListElement(this.page.pokeList,a,n)}},{key:"prependNoteElement",value:function(e,t){var n=r(this.makeNote(e),2),a=n[0],o=n[1];for(this.notes.push(o);this.notes.length>100;)this.notes.shift();var s=this.page.noteList;if(this.prependListElement(s,o,a),t||this.storeNotes(),!(0===this.notes.length||Vt.isDisplayed(this.page.noteBox)&&Vt.isDisplayed(s))){var i=0,c=this.notes.reduce((function(e,t){return t.acked||i++,!t.acked&&t.severity>e?t.severity:e}),0),l=this.page.noteIndicator;Vo(l,c),i?(l.textContent=String(i>99?"".concat(99,"+"):i),Vt.show(l)):Vt.hide(l)}}},{key:"prependListElement",value:function(e,t,n){for(n.note=t,e.prepend(n);e.children.length>100;)e.removeChild(e.lastChild);this.setNoteTimes(e)}},{key:"makeNote",value:function(e){var t=this.page.noteTmpl.cloneNode(!0);if(e.severity>2){var n=3===e.severity?"good":4===e.severity?"warn":"bad";Vt.safeSelector(t,"div.note-indicator").classList.add(n)}return Vt.safeSelector(t,"div.note-subject").textContent=e.subject,Vt.safeSelector(t,"div.note-details").textContent=e.details,[t,To({el:t},e)]}},{key:"makePoke",value:function(e){var t=this.page.pokeTmpl.cloneNode(!0),n=new Date(e.stamp);return Vt.tmplElement(t,"dateTime").textContent="".concat(n.toLocaleDateString(),", ").concat(n.toLocaleTimeString()),Vt.tmplElement(t,"details").textContent="".concat(e.subject,": ").concat(e.details),[t,To({el:t},e)]}},{key:"loading",value:function(e){var t=this.page.loader.cloneNode(!0);return e.appendChild(t),function(){t.remove()}}},{key:"orders",value:function(e,t){var n=[],r=this.user.exchanges[e].markets[t];return r.orders&&(n=n.concat(r.orders)),r.inflight&&(n=n.concat(r.inflight)),n}},{key:"haveActiveOrders",value:function(e){for(var t=0,n=Object.values(this.user.exchanges);t{var e={61:(e,t,n)=>{var r=n(698).default;function a(){"use strict";e.exports=a=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,o=n.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var a=t&&t.prototype instanceof m?t:m,o=Object.create(a.prototype),i=new I(r||[]);return s(o,"_invoke",{value:S(e,n,i)}),o}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var f={};function m(){}function v(){}function g(){}var y={};h(y,c,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(R([])));w&&w!==n&&o.call(w,c)&&(y=w);var k=g.prototype=m.prototype=Object.create(y);function x(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(a,s,i,c){var l=p(e[a],e,s);if("throw"!==l.type){var u=l.arg,h=u.value;return h&&"object"==r(h)&&o.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(h).then((function(e){u.value=e,i(u)}),(function(e){return n("throw",e,i,c)}))}c(l.arg)}var a;s(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,a){n(e,r,t,a)}))}return a=a?a.then(o,o):o()}})}function S(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var i=E(s,n);if(i){if(i===f)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=p(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function E(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=p(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function R(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var i=o.call(a,"catchLoc"),c=o.call(a,"finallyLoc");if(i&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),F(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;F(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:(e,t,n)=>{var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=n.left&&e.pageX<=n.right&&e.pageY>=n.top&&e.pageY<=n.bottom}},{key:"layoutMetrics",value:function(e){var t=e.getBoundingClientRect(),n=document.documentElement,r=t.top+n.scrollTop,a=t.left+n.scrollLeft,o=e.offsetWidth,s=e.offsetHeight;return{bodyTop:r,bodyLeft:a,width:o,height:s,centerX:a+o/2,centerY:r+s/2}}},{key:"descendentMetrics",value:function(t,n){var r=e.layoutMetrics(t),a=e.layoutMetrics(n);return{bodyTop:a.bodyTop-r.bodyTop,bodyLeft:a.bodyLeft-r.bodyLeft,width:a.width,height:a.height,centerX:a.centerX-r.bodyLeft,centerY:a.centerY-r.bodyTop}}},{key:"empty",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),a=1;a1?n-1:0),a=1;a"),e),document.createElement("div"))}},{key:"idDescendants",value:function(t){var n,r={},a=Dt(e.applySelector(t,"[id]"));try{for(a.s();!(n=a.n()).done;){var o=n.value;r[o.id]=o}}catch(e){a.e(e)}finally{a.f()}return r}},{key:"formatCoinValue",value:function(e,t){var n=r(zt(e,t),2),a=n[0],o=n[1];return Number.isInteger(a)?Bt.format(a):function(e){return _t(qt,2,e)}(o).format(a)}},{key:"formatThreeSigFigs",value:function(e){return e>=1e3?Bt.format(Math.round(e)):Mt.format(e)}},{key:"formatFiveSigFigs",value:function(e,t){return e>=1e4?Bt.format(Math.round(e)):e<1e5?Ut(null!=t?t:8).format(e):Wt.format(e)}},{key:"formatFullPrecision",value:function(e,t){var n=r(zt(e,t),2),a=n[0];return Ut(n[1]).format(a)}},{key:"formatFiatConversion",value:function(e,t,n){if(!t||0===t)return Rt(yt);var a=r(zt(e,n),1)[0]*t;return Ut(2).format(a)}},{key:"logoPath",value:function(e){return-1===Lt.indexOf(e)&&(e=e.substring(0,1)),"/img/coins/".concat(e,".png")}},{key:"bipSymbol",value:function(e){return Pt[e]}},{key:"logoPathFromID",value:function(t){return e.logoPath(Pt[t])}},{key:"symbolize",value:function(e){var t=e.split("."),n=document.createElement("span");if(n.textContent=t[0].toUpperCase(),1===t.length)return n;var r=document.createElement("span");r.classList.add("token-aware-symbol"),r.appendChild(n);var a=document.createElement("sup");return a.textContent=t[1].toUpperCase(),r.appendChild(a),r}},{key:"shortSymbol",value:function(e){return e.split(".")[0].toUpperCase()}},{key:"cleanTemplates",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n0||u>0)&&u++,e>0&&(l+="".concat(e," ").concat(t," ")),u>=2},d=r($t(c,Xt),2);if(t=d[0],c=d[1],h(t,"y"))return l;var p=r($t(c,Qt),2);if(n=p[0],c=p[1],h(n,"mo"))return l;var f=r($t(c,Yt),2);if(a=f[0],c=f[1],h(a,"d"))return l;var m=r($t(c,Jt),2);if(o=m[0],c=m[1],h(o,"h"))return l;var v=r($t(c,Zt),2);if(s=v[0],c=v[1],h(s,"m"))return l;var g=r($t(c,1e3),2);return i=g[0],c=g[1],h(i,"s"),l||"0 s"}},{key:"disableMouseWheel",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n=0?n:31536e7,o=a?Ht[a]:Ht.linear,s=(new Date).getTime(),i=n===e.Forever?Number.MAX_SAFE_INTEGER:s+n,c=i-s,l=1e3/30,u=s,this.endAnimation=!1;case 8:if(!(ue.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(document.cookie.split(";"));try{for(n.s();!(t=n.n()).done;){var a=r(t.value.split("="),2),o=a[0],s=a[1];if(o.trim()===e)return s}}catch(e){n.e(e)}finally{n.f()}return null}},{key:"removeCookie",value:function(e){document.cookie="".concat(e,"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;")}},{key:"isDark",value:function(){return document.cookie.split(";").filter((function(t){return t.includes("".concat(e.darkModeCK,"=1"))})).length}},{key:"passwordIsCached",value:function(){return!!this.getCookie(e.pwKeyCK)}},{key:"storeLocal",value:function(e,t){window.localStorage.setItem(e,JSON.stringify(t))}},{key:"fetchLocal",value:function(e){var t=window.localStorage.getItem(e);return null!==t?JSON.parse(t):null}},{key:"removeLocal",value:function(e){window.localStorage.removeItem(e)}}]),e}();function nn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function rn(e,t){return rn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},rn(e,t)}function an(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&rn(e,t)}function on(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return nn(e)}function sn(e){return sn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},sn(e)}h(tn,"darkModeCK","darkMode"),h(tn,"authCK","dexauth"),h(tn,"pwKeyCK","sessionkey"),h(tn,"popupsLK","popups"),h(tn,"loggersLK","loggers"),h(tn,"recordersLK","recorders"),h(tn,"lastMarketLK","selectedMarket"),h(tn,"depthZoomLK","depthZoom"),h(tn,"lastMMMarketLK","mmMarket"),h(tn,"optionsExpansionLK","mmOptsExpand"),h(tn,"leftMarketDockLK","leftmarketdock"),h(tn,"selectedAssetLK","selectedasset"),h(tn,"notificationsLK","notifications"),h(tn,"orderDisclaimerAckedLK","ordAck"),h(tn,"lastCandleDurationLK","lastCandleDuration"),null===tn.getCookie(tn.darkModeCK)&&tn.setCookie(tn.darkModeCK,"1"),null===tn.fetchLocal(tn.popupsLK)&&tn.storeLocal(tn.popupsLK,"1"),null===tn.fetchLocal(tn.leftMarketDockLK)&&tn.storeLocal(tn.leftMarketDockLK,"1");var cn,ln,un,hn,dn,pn,fn,mn=function(){function e(){s(this,e)}return u(e,[{key:"unload",value:function(){}}]),e}();function vn(e,t,n){return gn.apply(this,arguments)}function gn(){return(gn=o(w().mark((function e(t,n,r){var a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,window.fetch(n,{method:t,headers:new window.Headers({"content-type":"application/json"}),body:r});case 3:if(200===(a=e.sent).status){e.next=6;break}throw a;case 6:return e.next=8,a.json();case 8:return(o=e.sent).requestSuccessful=!0,e.abrupt("return",o);case 13:return e.prev=13,e.t0=e.catch(0),e.t0.requestSuccessful=!1,e.next=18,e.t0.text();case 18:return e.t0.msg=e.sent,e.abrupt("return",e.t0);case 20:case"end":return e.stop()}}),e,null,[[0,13]])})))).apply(this,arguments)}function yn(e,t){return bn.apply(this,arguments)}function bn(){return(bn=o(w().mark((function e(t,n){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",vn("POST",t,JSON.stringify(n)));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wn(e){return kn.apply(this,arguments)}function kn(){return(kn=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",vn("GET",t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xn(n){return function(t){if(Array.isArray(t))return e(t)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||t(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Cn(){return hn}function Sn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=sn(e);if(t){var a=sn(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return on(this,n)}}function En(e){var t=[e.booleanOptTmpl,e.rangeOptTmpl,e.orderOptTmpl];pn=t[0],fn=t[1],dn=t[2]}!function(e){e[e.walletErr=0]="walletErr",e[e.walletAuthErr=1]="walletAuthErr",e[e.walletBalanceErr=2]="walletBalanceErr",e[e.dupeDEXErr=3]="dupeDEXErr",e[e.assetSupportErr=4]="assetSupportErr",e[e.registerErr=5]="registerErr",e[e.signatureErr=6]="signatureErr",e[e.zeroFeeErr=7]="zeroFeeErr",e[e.feeMismatchErr=8]="feeMismatchErr",e[e.feeSendErr=9]="feeSendErr",e[e.passwordErr=10]="passwordErr",e[e.emptyHostErr=11]="emptyHostErr",e[e.connectionErr=12]="connectionErr",e[e.acctKeyErr=13]="acctKeyErr",e[e.unknownOrderErr=14]="unknownOrderErr",e[e.orderParamsErr=15]="orderParamsErr",e[e.dbErr=16]="dbErr",e[e.authErr=17]="authErr",e[e.connectWalletErr=18]="connectWalletErr",e[e.missingWalletErr=19]="missingWalletErr",e[e.encryptionErr=20]="encryptionErr",e[e.decodeErr=21]="decodeErr",e[e.accountVerificationErr=22]="accountVerificationErr",e[e.accountProofErr=23]="accountProofErr",e[e.parseKeyErr=24]="parseKeyErr",e[e.marketErr=25]="marketErr",e[e.addressParseErr=26]="addressParseErr",e[e.addrErr=27]="addrErr",e[e.fileReadErr=28]="fileReadErr",e[e.unknownDEXErr=29]="unknownDEXErr",e[e.accountRetrieveErr=30]="accountRetrieveErr",e[e.accountDisableErr=31]="accountDisableErr",e[e.suspendedAcctErr=32]="suspendedAcctErr",e[e.existenceCheckErr=33]="existenceCheckErr",e[e.createWalletErr=34]="createWalletErr",e[e.activeOrdersErr=35]="activeOrdersErr",e[e.newAddrErr=36]="newAddrErr"}(cn||(cn={})),function(e){e[e.Disconnected=0]="Disconnected",e[e.Connected=1]="Connected",e[e.InvalidCert=2]="InvalidCert"}(ln||(ln={})),function(e){e[e.WalletDefault=0]="WalletDefault",e[e.UserAdded=1]="UserAdded",e[e.Discovered=2]="Discovered"}(un||(un={}));var An=new Intl.NumberFormat(navigator.languages,{minimumSignificantDigits:3,maximumSignificantDigits:3}),Fn=u((function e(t,n,r){var a=this;s(this,e),h(this,"opt",void 0),h(this,"node",void 0),h(this,"tmpl",void 0),h(this,"on",void 0),this.opt=t;var o=this.node=dn.cloneNode(!0),i=this.tmpl=Vt.parseTemplate(o);i.optName.textContent=t.displayname,i.tooltip.dataset.tooltip=t.description,n?i.chainIcon.src=Vt.logoPath(n):Vt.hide(i.chainIcon),this.on=!1,Vt.bind(o,"click",(function(){a.on||(a.on=!0,o.classList.add("selected"),r.enable())})),Vt.bind(i.toggle,"click",(function(e){a.on&&(e.stopPropagation(),a.on=!1,o.classList.remove("selected"),r.disable())}))})),In=function(e){an(n,e);var t=Sn(n);function n(e,r,a,o){var i;if(s(this,n),h(nn(i=t.call(this,e,r,{enable:function(){return i.enable()},disable:function(){return i.disable()}})),"control",void 0),h(nn(i),"changed",void 0),h(nn(i),"dict",void 0),i.dict=a,i.changed=function(){return o()},void 0===e.boolean)throw Error("not a boolean opt");var c=e.boolean,l=i.control=pn.cloneNode(!0);return i.tmpl.controls.appendChild(l),Vt.parseTemplate(l).reason.textContent=c.reason,i.on=void 0!==a[e.key]?a[e.key]:e.default,i.on&&i.node.classList.add("selected"),i}return u(n,[{key:"store",value:function(){this.on===this.opt.default?delete this.dict[this.opt.key]:this.dict[this.opt.key]=this.on,this.changed()}},{key:"enable",value:function(){this.store()}},{key:"disable",value:function(){this.store()}}]),n}(Fn),Rn=function(e){an(n,e);var t=Sn(n);function n(e,r,a,o){var i;if(s(this,n),h(nn(i=t.call(this,e,r,{enable:function(){return i.enable()},disable:function(){return i.disable()}})),"handler",void 0),h(nn(i),"x",void 0),h(nn(i),"changed",void 0),h(nn(i),"dict",void 0),i.dict=a,i.changed=o,void 0===e.xyRange)throw Error("not an xy range opt");var c=e.xyRange,l=a[e.key];return i.on=void 0!==l,i.on?(i.node.classList.add("selected"),i.x=l):i.x=e.default,i.handler=new Dn(c,i.x,(function(e){i.x=e,i.dict[i.opt.key]=e}),(function(){i.changed()}),(function(){i.node.classList.add("selected")})),i.tmpl.controls.appendChild(i.handler.control),i}return u(n,[{key:"enable",value:function(){this.dict[this.opt.key]=this.x,this.changed()}},{key:"disable",value:function(){delete this.dict[this.opt.key],this.changed()}},{key:"setValue",value:function(e){this.handler.setValue(e),this.on=!0,this.node.classList.add("selected")}}]),n}(Fn),Dn=function(){function e(t,n,r,a,o,i){var c=this;s(this,e),h(this,"control",void 0),h(this,"cfg",void 0),h(this,"tmpl",void 0),h(this,"x",void 0),h(this,"scrollingX",void 0),h(this,"y",void 0),h(this,"r",void 0),h(this,"roundY",void 0),h(this,"updated",void 0),h(this,"changed",void 0),h(this,"selected",void 0),h(this,"setConfig",void 0);var l=this.control=fn.cloneNode(!0),u=this.tmpl=Vt.parseTemplate(l);this.roundY=Boolean(i),this.cfg=t,this.changed=a,this.selected=o,this.updated=r;var d=u.slider,p=u.handle,f=t.end.x-t.start.x,m=t.end.y-t.start.y,v=function(e){return(e-t.start.x)/f},g=function(e){f=e.end.x-e.start.x,m=e.end.y-e.start.y,t=c.cfg=e,u.rangeLblStart.textContent=t.start.label,u.rangeLblEnd.textContent=t.end.label,u.xUnit.textContent=t.xUnit,u.yUnit.textContent=t.yUnit,c.y=c.r*m+t.start.y,c.r=(c.y-t.start.y)/m,c.scrollingX=c.r*f+t.start.x};g(t),this.setConfig=function(e){g(e),c.accept(c.scrollingX)},this.r=v(n),this.scrollingX=this.x=n,this.y=this.r*m+t.start.y;var y=function e(n){if("change"===n.type||n.target!==u.xInput){var r=u.xInput.value;if(r){var a=parseFloat(r);isNaN(a)||(c.scrollingX=On(a,t.start.x,t.end.x),c.r=v(c.scrollingX),c.y=c.r*m+t.start.y,c.accept(c.scrollingX))}Vt.hide(u.xInput),Vt.show(u.x),Vt.unbind(document,"click",e),c.changed()}};Vt.bind(u.x,"click",(function(e){Vt.hide(u.x),Vt.show(u.xInput),u.xInput.focus(),u.xInput.value=An.format(c.scrollingX),Vt.bind(document,"click",y),e.stopPropagation()})),Vt.bind(u.xInput,"change",y);var b=function e(n){if("change"===n.type||n.target!==u.yInput){var r=u.yInput.value;if(r){var a=parseFloat(r);isNaN(a)||(c.y=On(a,t.start.y,t.end.y),c.r=(c.y-t.start.y)/m,c.scrollingX=t.start.x+c.r*f,c.accept(c.scrollingX))}Vt.hide(u.yInput),Vt.show(u.y),Vt.unbind(document,"click",e),c.changed()}};Vt.bind(u.y,"click",(function(e){Vt.hide(u.y),Vt.show(u.yInput),u.yInput.focus(),u.yInput.value=An.format(c.y),Vt.bind(document,"click",b),e.stopPropagation()})),Vt.bind(u.yInput,"change",b),Vt.bind(p,"mousedown",(function(e){if(0===e.button){e.preventDefault(),c.selected();var n=e.pageX,r=d.clientWidth-p.offsetWidth,a=v(c.scrollingX)*r,o=function(e){e.preventDefault(),c.r=function(e){return Math.max(Math.min(a+(e.pageX-n),r),0)}(e)/r,c.scrollingX=c.r*f+t.start.x,c.y=c.r*m+t.start.y,c.accept(c.scrollingX)};Vt.bind(document,"mousemove",o),Vt.bind(document,"mouseup",(function e(t){o(t),Vt.unbind(document,"mousemove",o),Vt.unbind(document,"mouseup",e),c.changed()}))}})),this.accept(this.scrollingX,!0)}return u(e,[{key:"accept",value:function(e,t){var n=this.tmpl;this.roundY&&(this.y=Math.round(this.y)),n.x.textContent=An.format(e),n.y.textContent=An.format(this.y),this.roundY&&(n.y.textContent="".concat(this.y)),n.handle.style.left="calc(".concat(100*this.r,"% - ").concat(14*this.r,"px)"),this.x=e,this.scrollingX=e,t||this.updated(e,this.y)}},{key:"setValue",value:function(e){var t=this.cfg;this.r=(e-t.start.x)/(t.end.x-t.start.x),this.y=t.start.y+this.r*(t.end.y-t.start.y),this.accept(e,!0)}}]),e}(),On=function(e,t,n){return en?n:e};function Tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(e.matches);try{for(n.s();!(t=n.n()).done;)if(t.value.active)return!0}catch(e){n.e(e)}finally{n.f()}return!1}function qn(e){if(!e.id)return Rt(te);var t=Wn(e);switch(e.status){case 0:return Rt($);case 1:return Rt(ee);case 2:return e.cancelling?Rt(G):t?"".concat(Rt(H),"/").concat(Rt(ne)):Rt(H);case 3:return t?Rt(ne):0===e.filled&&3!==e.type?Rt(re):Rt(j);case 4:return t?"".concat(Rt(ae),"/").concat(Rt(ne)):Rt(ae);case 5:return t?"".concat(Rt(oe),"/").concat(Rt(ne)):Rt(oe)}return Rt($)}function Nn(e){if(!e.matches)return 0;var t=Mn(e)?function(e){return e.qty*e.rate/Pn}:function(e){return e.qty};return e.matches.reduce((function(e,n){return n.isCancel?e:e+t(n)}),0)}function Un(e){if(!e.matches)return 0;var t=Mn(e)?function(e){return e.qty*e.rate/Pn}:function(e){return e.qty};return e.matches.reduce((function(e,n){return n.isCancel?e:0===n.side&&n.status>=3||1===n.side&&n.status>=4?e+t(n):e}),0)}function _n(e,t){return e*t/Pn}function zn(e){return Rt(tt,{status:Rt(e)})}function Vn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=sn(e);if(t){var a=sn(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return on(this,n)}}function jn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Hn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hn(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Hn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=c&&i=i&&s=h&&v.push([C.rate,k]),!C.epoch)for(w+=C.qty,m.push([C.rate,w]),b.buyBase+=C.qty,b.buyQuote+=C.qty*C.rate;d.length&&hr(d[0].rate,C.rate);){var S=d.shift();S&&f.push({rate:S.rate,qty:C.epoch?k:w,sell:C.sell,active:S.active})}}var E=m.length?sr(m)[1]:0;m.push([h,E]);var A=v.length?sr(v)[1]:0;v.push([h,A]),k=w=0;for(var F=0;Fu||e=P},N=e.theme.sellLine;Pthis.data.candles.length)return;this.numToShow=this.zoomLevels[t+1]}this.draw()}},{key:"render",value:function(){var e=this,t=this.data;if(t&&this.visible&&0!==this.canvas.width){var n=t.ms,r=this.mousePos,a=t.candles||[],o=Math.min(this.numToShow,a.length),s=a.slice(a.length-o);if(this.clear(),0!==o){var i,c=function(e){return pr(e.endStamp,n)},l=function(e){return c(e)+n},u=function(e){return c(e)+.2*n},h=.6*n,d=s[0],p=s[o-1],f=[d.highRate,d.lowRate,d.matchVolume],m=f[0],v=f[1],g=f[2],y=jn(s);try{for(y.s();!(i=y.n()).done;){var b=i.value;b.highRate>m&&(m=b.highRate),b.lowRateg&&(g=b.matchVolume)}}catch(e){y.e(e)}finally{y.f()}var w=this.market.ratestep,k=new nr(c(d),l(p),v,m);v===m&&(k.y.min-=w,k.y.max+=w),this.dataExtents=k;var x=this.rateConversionFactor;this.doYLabels(this.candleRegion,w,this.market.quotesymbol,(function(e){return ur(e/x)})),this.candleRegion.extents.x.min=this.yRegion.extents.x.max,this.volumeRegion.extents.x.min=this.yRegion.extents.x.max;var C=function(e,t,n,r){var a=e[0],o=e[e.length-1],s=pr(a.endStamp,t),i=pr(o.endStamp,t)+t,c=i-s,l=Math.min(e.length,n/100),u=pr(c/l,t);if(0===u)return console.error("zero tick",t,c,l),{lbls:[]};var h=s,d=(new Date).getTimezoneOffset(),p=function(e){return(e-=6e4*d)-e%864e5},f=p(s),m=0;p(a.endStamp)===p(o.endStamp)&&(f=0);var v,g=[];for(v=t<864e5?function(e,t){return p(t)!==f?"".concat(or[e.getMonth()]).concat(e.getDate()," ").concat(e.getHours(),":").concat(String(e.getMinutes()).padStart(2,"0")):"".concat(e.getHours(),":").concat(String(e.getMinutes()).padStart(2,"0"))}:function(e){var t=e.getFullYear();return t!==m?"".concat(or[e.getMonth()]).concat(e.getDate()," '").concat(String(t).slice(2,4)):"".concat(or[e.getMonth()]).concat(e.getDate())};h<=i;){var y=new Date(h);g.push({val:h,txt:v(y,h)}),f=p(h),m=y.getFullYear(),h+=u}return{lbls:g}}(s,n,this.plotRegion.width());this.plotXLabels(C,c(d),l(p),[]),this.drawFrame();var S=null;if(r&&(this.plotRegion.plot(new nr(k.x.min,k.x.max,0,1),(function(t,a){var o,i=pr(a.unx(r.x),n),l=jn(s);try{for(l.s();!(o=l.n()).done;){var u=o.value;if(c(u)===i){S=u,t.fillStyle=e.theme.gridLines,t.fillRect(a.x(c(u)),a.y(0),a.w(n),a.h(1));break}}}catch(e){l.e(e)}finally{l.f()}})),S)){var E=this.xRegion.extents.y;this.xRegion.plot(new nr(k.x.min,k.x.max,E.min,E.max),(function(t,n){if(S){e.applyLabelStyle();var r="".concat(new Date(c(S)).toLocaleString()," - ").concat(new Date(l(S)).toLocaleString()),a=t.measureText(r).width+50,o=n.x((c(S)+l(S))/2),s=o-a/2,i=e.xRegion.extents.x;si.max&&(s=i.max-a),o=s+a/2;var u=E.min+(e.xRegion.height()-16)/2;t.fillStyle=e.theme.legendFill,t.strokeStyle=e.theme.gridBorder;var h=[s-25,u-2,a+50,20];t.fillRect.apply(t,h),t.strokeRect.apply(t,h),e.applyLabelStyle(),t.fillText(r,o,e.xRegion.extents.midY,a)}}))}var A=new nr(c(d),l(p),0,g);this.volumeRegion.plot(A,(function(t,n){t.fillStyle=e.theme.gridBorder;var r,a=jn(s);try{for(a.s();!(r=a.n()).done;){var o=r.value;t.fillRect(n.x(u(o)),n.y(0),n.w(h),n.h(o.matchVolume))}}catch(e){a.e(e)}finally{a.f()}})),this.candleRegion.plot(k,(function(t,n){t.lineWidth=1;var r,a=jn(s);try{for(a.s();!(r=a.n()).done;){var o=r.value,i=o.startRate>o.endRate,c=[n.x(u(o)),n.y(o.startRate),n.w(h),n.h(o.endRate-o.startRate)],l=c[0],d=c[1],p=c[2],f=c[3],m=[n.y(o.highRate),n.y(o.lowRate),p/2+l],v=m[0],g=m[1],y=m[2];t.strokeStyle=i?e.theme.sellLine:e.theme.buyLine,t.fillStyle=i?e.theme.sellFill:e.theme.buyFill,t.beginPath(),t.moveTo(y,v),t.lineTo(y,g),t.stroke(),t.fillRect(l,d,p,f),t.strokeRect(l,d,p,f)}}catch(e){a.e(e)}finally{a.f()}})),this.reporters.mouse(S)}}else this.renderScheduled=!0}},{key:"setCandles",value:function(e,t,n,r){if(this.data=e,e.candles){this.market=t;var a=[r.conventional.conversionFactor,n.conventional.conversionFactor],o=a[0],s=a[1];this.rateConversionFactor=Pn*o/s;var i=25;this.zoomLevels=[];for(var c=Math.max(e.candles.length,1e3);i150&&(a=150),o>100&&(o=100);var s=(n-a)/2,i=(r-o)/2;if(e.message){this.fontSize=cr(.15*o,10,14),this.applyLabelStyle(this.fontSize);var c=.5*this.fontSize,l=this.fontSize/2+c;i-=l,this.msgRegion=new rr(this.ctx,new nr(0,n,i+o,i+o+2*l))}this.region=new rr(this.ctx,new nr(s,s+a,i,i+o))}},{key:"drawValues",value:function(e){var t=this;if(this.region){this.clear();var n=function(e){return"hsl(".concat(e,", 35%, 50%)")},r=this.region,a=this.msgRegion,o=this.canvas,s=o.width,i=o.height,c=this.opts,l=c.backgroundColor,u=c.message,h=this.colorShift,d=this.ctx;l&&(d.fillStyle=!0===l?window.getComputedStyle(document.body,null).getPropertyValue("background-color"):l,d.fillRect(0,0,s,i)),r.plot(new nr(0,1,-1,1),(function(t,r){t.lineWidth=4,t.lineCap="round";var a=h+(new Date).getTime()%2e3/2e3*360,o=t.createLinearGradient(r.x(0),0,r.x(1),0);o.addColorStop(0,n(a)),t.strokeStyle=o,t.beginPath(),t.moveTo(r.x(0),r.y(e[0]));for(var s=1;sn.x.min&&tn.y.min}},{key:"translator",value:function(e){var t=this.extents,n=e.x.min,r=e.y.min,a=e.yRange,o=e.xRange,s=t.x.min,i=t.x.max-s,c=t.y.max,l=c-t.y.min,u=i/o,h=l/a;return{x:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return(e-n)*u+s})),y:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return c-(e-r)*h})),unx:function(e){return(e-s)/u+n},uny:function(e){return r-(e-c)/h},w:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return e/o*i})),h:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return-e/a*l})),dataCoords:function(){}}}},{key:"clear",value:function(){var e=this.extents;this.context.clearRect(e.x.min,e.y.min,e.xRange,e.yRange)}},{key:"plot",value:function(e,t,n){var r=this.context,a=this.extents;r.save(),n||(r.beginPath(),r.rect(a.x.min,a.y.min,a.xRange,a.yRange),r.clip());var o=this.translator(e),s=e.yRange,i=a.xRange/e.xRange,c=a.yRange/s,l=e.x.min,u=e.y.min,h=a.x.min+l-l*i,d=-a.y.min-(s-u)*c;o.dataCoords=function(e){r.save(),r.transform(1,0,0,-1,-l,u),r.transform(i,0,0,c,h,d),e(),r.restore()},t(this.context,o),r.restore()}}]),e}();function ar(e,t,n,r,a,o,s,i){i=i||ur;var c=t/a,l=r-n;if(c<1||l<=0)return{lbls:[]};for(var u=l/c,h=u+o-u%o,d=n+h-n%h,p=Math.max(Math.abs(r),Math.abs(n)),f=Math.round(Math.log10(p/h))+2,m=[],v=0;dv&&(v=y),{widest:v,lbls:m}}var or=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];function sr(e){return e[e.length-1]}function ir(e,t,n,r,a,o){e.beginPath(),e.moveTo(t,n),e.lineTo(r,a),o||e.stroke()}function cr(e,t,n){return en?n:e}var lr={minimumSignificantDigits:4,maximumSignificantDigits:5};function ur(e){return e.toLocaleString("en-us",lr)}function hr(e,t){return dr(e,t,1e-8)}function dr(e,t,n){return Math.abs(e-t)=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function mr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1)){e.next=34;break}Vt.show(r),u=fr(l),e.prev=16,d=w().mark((function e(){var t,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=h.value,(a=n.walletTabTmpl.cloneNode(!0)).dataset.tooltip=t.description,a.textContent=t.tab,r.appendChild(a),Vt.bind(a,"click",(function(){var e,n=fr(Vt.kids(r));try{for(n.s();!(e=n.n()).done;)e.value.classList.remove("selected")}catch(e){n.e(e)}finally{n.f()}a.classList.add("selected"),p.update(t)}));case 6:case"end":return e.stop()}}),e)})),u.s();case 19:if((h=u.n()).done){e.next=23;break}return e.delegateYield(d(),"t0",21);case 21:e.next=19;break;case 23:e.next=28;break;case 25:e.prev=25,e.t1=e.catch(16),u.e(e.t1);case 28:return e.prev=28,u.f(),e.finish(28);case 31:Cn().bindTooltips(r),r.firstChild.classList.add("selected");case 34:return e.next=36,this.update(this.current.selectedDef);case 36:if(!s.walletCreationPending){e.next=39;break}return e.next=39,this.runParentSync();case 39:case"end":return e.stop()}}),e,this,[[16,25,28,31]])}))),function(e){return a.apply(this,arguments)})},{key:"parseAsset",value:function(e){if(this.current&&this.current.asset.id===e)return!1;var t=Cn().assets[e],n=t.token;if(!n){if(!t.info)throw Error("this non-token asset has no wallet info!");return this.current={asset:t,winfo:t.info,selectedDef:t.info.availablewallets[0]},!0}var r=Cn().user.assets[n.parentID];if(r.wallet)return this.current={asset:t,winfo:n,selectedDef:n.definition},!0;if(!r.info)throw Error("this parent has no wallet info!");return this.current={asset:t,parentAsset:r,winfo:n,selectedDef:r.info.availablewallets[0]},!0}},{key:"update",value:(r=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u,h,d,p,f,m,v,g,y,b,k;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.page,this.current.selectedDef=t,r=tn.passwordIsCached()||this.pwCache&&this.pwCache.pw,Vt.hide(n.auth,n.oneBttnBox,n.newWalletPassBox),a=t.guidelink,(o=t.configopts||[]).map((function(e){return e.isBirthdayConfig&&Cn().seedGenTime>0&&(e.default=Pr(new Date)),e})),s=!1,i=fr(o),e.prev=9,i.s();case 11:if((c=i.n()).done){e.next=18;break}if(!c.value.required){e.next=16;break}return s=!0,e.abrupt("break",18);case 16:e.next=11;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(9),i.e(e.t0);case 23:return e.prev=23,i.f(),e.finish(23);case 26:if(l=!s&&(t.seeded||Boolean(this.current.asset.token)),r&&l?Vt.show(n.oneBttnBox):l?(Vt.show(n.auth),n.newWalletPass.value="",n.submitAdd.textContent=Rt(he)):(Vt.show(n.auth),t.noauth||Vt.show(n.newWalletPassBox),n.submitAdd.textContent=Rt(ue)),u=this.current,h=u.asset,d=u.parentAsset,p=u.winfo,d){f=JSON.parse(JSON.stringify(o)),m=fr(f);try{for(m.s();!(v=m.n()).done;)v.value.regAsset=d.id}catch(e){m.e(e)}finally{m.f()}if((g=p.definition.configopts||[]).length>0){y=JSON.parse(JSON.stringify(g)),b=fr(y);try{for(b.s();!(k=b.n()).done;)k.value.regAsset=h.id}catch(e){b.e(e)}finally{b.f()}f.push.apply(f,xn(y))}this.subform.update(f,!1)}else this.subform.update(o,!1);return this.setGuideLink(a),this.subform.dynamicOpts.children.length||this.subform.defaultSettings.children.length?Vt.show(n.walletSettingsHeader):Vt.hide(n.walletSettingsHeader),t.seeded||Boolean(this.current.asset.token)?Vt.hide(this.subform.fileSelector):Vt.show(this.subform.fileSelector),this.refresh(),e.next=36,this.loadDefaults();case 36:case"end":return e.stop()}}),e,this,[[9,20,23,26]])}))),function(e){return r.apply(this,arguments)})},{key:"setGuideLink",value:function(e){Vt.hide(this.walletCfgGuide),""!==e&&(this.walletCfgGuide.href=e,Vt.show(this.walletCfgGuide))}},{key:"setError",value:(n=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.page.newWalletErr.textContent=t,Vt.show(this.page.newWalletErr);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"loadDefaults",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.current,n=t.asset,r=t.parentAsset,(a=t.selectedDef).configpath){e.next=3;break}return e.abrupt("return");case 3:if(o=n.id,!r){e.next=8;break}if(!a.seeded){e.next=7;break}return e.abrupt("return");case 7:o=r.id;case 8:return s=Cn().loading(this.form),e.next=11,yn("/api/defaultwalletcfg",{assetID:o,type:a.type});case 11:if(i=e.sent,s(),Cn().checkResponse(i)){e.next=16;break}return this.setError(i.msg),e.abrupt("return");case 16:this.subform.setLoadedConfig(i.config);case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),gr=0,yr=function(){function e(t,n){var r=this;s(this,e),h(this,"page",void 0),h(this,"form",void 0),h(this,"configElements",void 0),h(this,"configOpts",void 0),h(this,"sectionize",void 0),h(this,"allSettings",void 0),h(this,"dynamicOpts",void 0),h(this,"textInputTmpl",void 0),h(this,"dateInputTmpl",void 0),h(this,"checkboxTmpl",void 0),h(this,"repeatableTmpl",void 0),h(this,"fileSelector",void 0),h(this,"fileInput",void 0),h(this,"errMsg",void 0),h(this,"showOther",void 0),h(this,"showIcon",void 0),h(this,"hideIcon",void 0),h(this,"showHideMsg",void 0),h(this,"otherSettings",void 0),h(this,"loadedSettingsMsg",void 0),h(this,"loadedSettings",void 0),h(this,"defaultSettingsMsg",void 0),h(this,"defaultSettings",void 0),h(this,"assetHasActiveOrders",void 0),this.page=Vt.idDescendants(t),this.form=t,this.configElements=[],this.configOpts=[],this.sectionize=n,this.allSettings=Vt.tmplElement(t,"allSettings"),this.dynamicOpts=Vt.tmplElement(t,"dynamicOpts"),this.textInputTmpl=Vt.tmplElement(t,"textInput"),this.textInputTmpl.remove(),this.dateInputTmpl=Vt.tmplElement(t,"dateInput"),this.dateInputTmpl.remove(),this.checkboxTmpl=Vt.tmplElement(t,"checkbox"),this.checkboxTmpl.remove(),this.repeatableTmpl=Vt.tmplElement(t,"repeatableInput"),this.repeatableTmpl.remove(),this.fileSelector=Vt.tmplElement(t,"fileSelector"),this.fileInput=Vt.tmplElement(t,"fileInput"),this.errMsg=Vt.tmplElement(t,"errMsg"),this.showOther=Vt.tmplElement(t,"showOther"),this.showIcon=Vt.tmplElement(t,"showIcon"),this.hideIcon=Vt.tmplElement(t,"hideIcon"),this.showHideMsg=Vt.tmplElement(t,"showHideMsg"),this.otherSettings=Vt.tmplElement(t,"otherSettings"),this.loadedSettingsMsg=Vt.tmplElement(t,"loadedSettingsMsg"),this.loadedSettings=Vt.tmplElement(t,"loadedSettings"),this.defaultSettingsMsg=Vt.tmplElement(t,"defaultSettingsMsg"),this.defaultSettings=Vt.tmplElement(t,"defaultSettings"),n||Vt.hide(this.showOther),Vt.bind(this.fileSelector,"click",(function(){return r.fileInput.click()})),Vt.bind(this.fileInput,"change",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.fileInputChanged());case 1:case"end":return e.stop()}}),e)})))),Vt.bind(this.showOther,"click",(function(){r.setOtherSettingsViz(r.hideIcon.classList.contains("d-hide"))}))}var t;return u(e,[{key:"fileInputChanged",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Vt.hide(this.errMsg),this.fileInput.value){e.next=3;break}return e.abrupt("return");case 3:if((n=this.fileInput.files)&&0!==n.length){e.next=6;break}return e.abrupt("return");case 6:return r=Cn().loading(this.form),e.next=9,n[0].text();case 9:if(a=e.sent){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,yn("/api/parseconfig",{configtext:a});case 14:if(o=e.sent,r(),Cn().checkResponse(o)){e.next=20;break}return this.errMsg.textContent=o.msg,Vt.show(this.errMsg),e.abrupt("return");case 20:if(0!==Object.keys(o.map).length){e.next=22;break}return e.abrupt("return");case 22:(t=this.dynamicOpts).append.apply(t,xn(this.setConfig(o.map))),this.reorder(this.dynamicOpts),s=[this.loadedSettings.children.length,this.defaultSettings.children.length],c=s[1],0===(i=s[0])&&Vt.hide(this.loadedSettings,this.loadedSettingsMsg),0===c&&Vt.hide(this.defaultSettings,this.defaultSettingsMsg),i+c===0&&Vt.hide(this.showOther,this.otherSettings);case 28:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"addOpt",value:function(e,t,n,r){var a,o=this;if(t.isboolean)a=this.checkboxTmpl.cloneNode(!0);else if(t.isdate)a=this.dateInputTmpl.cloneNode(!0);else if(t.repeatable){if((a=this.repeatableTmpl.cloneNode(!0)).classList.add("repeatable"),Vt.bind(Vt.tmplElement(a,"add"),"click",(function(){o.addOpt(e,t,a,!0)})),!r)for(var s=0;s<(t.repeatN?t.repeatN-1:0);s++)this.addOpt(e,t,n,!0)}else a=this.textInputTmpl.cloneNode(!0);this.configElements.push([t,a]);var i=a.querySelector("input");i.dataset.configKey=t.key,gr++;var c="wcfg-"+String(gr);i.id=c;var l=Vt.safeSelector(a,"label");if(l.htmlFor=c,l.prepend(t.displayname),void 0!==t.regAsset){var u=new window.Image(15,15);u.src=Vt.logoPathFromID(t.regAsset||-1),l.prepend(u)}if(n?n.after(a):e.appendChild(a),t.noecho&&(i.type="password",i.autocomplete="off"),t.description&&(l.dataset.tooltip=t.description),t.isboolean)i.checked=t.default;else if(t.isdate){var h=function(e){return e?Lr("now"===e?new Date:new Date(1e3*e)):""};i.max=h(t.max),i.min=h(t.min);var d=t.default?new Date(1e3*t.default):new Date;i.value=Lr(d)}else i.value=null!==t.default?t.default:"";return i.disabled=Boolean(t.disablewhenactive&&this.assetHasActiveOrders),a}},{key:"update",value:function(e,t){if(this.assetHasActiveOrders=t,this.configElements=[],this.configOpts=e||[],Vt.empty(this.dynamicOpts,this.defaultSettings,this.loadedSettings),0===this.configOpts.length)return Vt.hide(this.form);Vt.show(this.form),this.setOtherSettingsViz(!1),Vt.hide(this.loadedSettingsMsg,this.loadedSettings,this.defaultSettingsMsg,this.defaultSettings,this.errMsg);var n,r=[],a=fr(this.configOpts);try{for(a.s();!(n=a.n()).done;){var o=n.value;this.sectionize&&null!==o.default?r.push(o):this.addOpt(this.dynamicOpts,o)}}catch(e){a.e(e)}finally{a.f()}if(r.length){var s,i=fr(r);try{for(i.s();!(s=i.n()).done;){var c=s.value;this.addOpt(this.defaultSettings,c)}}catch(e){i.e(e)}finally{i.f()}Vt.show(this.showOther,this.defaultSettingsMsg,this.defaultSettings)}else Vt.hide(this.showOther);Cn().bindTooltips(this.allSettings),this.dynamicOpts.children.length?Vt.show(this.dynamicOpts):Vt.hide(this.dynamicOpts)}},{key:"setOtherSettingsViz",value:function(e){if(e)return Vt.hide(this.showIcon),Vt.show(this.hideIcon,this.otherSettings),void(this.showHideMsg.textContent=Rt(D));Vt.hide(this.hideIcon,this.otherSettings),Vt.show(this.showIcon),this.showHideMsg.textContent=Rt(O)}},{key:"setConfig",value:function(e){for(var t,n=[],a={},o=[],s=0,i=xn(this.configElements);s=0&&this.configElements.splice(x,1)}return n}},{key:"setLoadedConfig",value:function(e){var t,n=this.setConfig(e);this.sectionize&&0!==n.length&&((t=this.loadedSettings).append.apply(t,xn(n)),this.reorder(this.loadedSettings),Vt.show(this.loadedSettings,this.loadedSettingsMsg),0===this.defaultSettings.children.length&&Vt.hide(this.defaultSettings,this.defaultSettingsMsg))}},{key:"map",value:function(e){var t,n={},a=fr(this.configElements);try{for(a.s();!(t=a.n()).done;){var o=r(t.value,2),s=o[0],i=o[1],c=Vt.safeSelector(i,"input");if(void 0===s.regAsset||s.regAsset===e)if(s.isboolean&&s.key)n[s.key]=c.checked?"1":"0";else if(s.isdate&&s.key){var l=c.min?Pr(new Date(c.min+"T00:00")):Number.MIN_SAFE_INTEGER,u=c.max?Pr(new Date(c.max+"T00:00")):Number.MAX_SAFE_INTEGER,h=c.value?Pr(new Date(c.value+"T00:00")):0;hu&&(h=u),n[s.key]=""+h}else c.value&&(s.repeatable&&n[s.key]?n[s.key]+=s.repeatable+c.value:n[s.key]=c.value)}}catch(e){a.e(e)}finally{a.f()}return n}},{key:"reorder",value:function(e){var t=this,n={};e.querySelectorAll("input").forEach((function(e){var a=e.dataset.configKey;if(a){var o,s=[],i=fr(t.configElements);try{for(i.s();!(o=i.n()).done;){var c=r(o.value,2),l=c[0],u=c[1];l.key===a&&s.push(u)}}catch(e){i.e(e)}finally{i.f()}n[a]=s}}));var a,o=fr(this.configOpts);try{for(o.s();!(a=o.n()).done;){var s,i=a.value,c=fr(n[i.key]||[]);try{for(c.s();!(s=c.n()).done;){var l=s.value;e.append(l)}}catch(e){c.e(e)}finally{c.f()}}}catch(e){o.e(e)}finally{o.f()}}}]),e}(),br=function(){function e(t,n,r,a){var o=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"page",void 0),h(this,"xc",void 0),h(this,"certFile",void 0),h(this,"bondAssetID",void 0),h(this,"pwCache",void 0),this.form=t,this.success=n,this.page=Vt.parseTemplate(t),this.certFile="",this.pwCache=a,Vt.bind(this.page.goBack,"click",(function(){return r()})),Vt.bind(this.page.bondStrengthField,"input",(function(){var e=Cn().assets[o.bondAssetID];if(e){var t=e.unitInfo,n=o.xc.bondAssets[e.symbol];o.page.bondAmt.textContent=Vt.formatCoinValue(o.totalBondAmount(n.amount),t)}})),Tr(t,this.page.submit,(function(){return o.submitForm()}))}var t,n;return u(e,[{key:"setExchange",value:function(e,t){this.xc=e,this.certFile=t;var n=this.page;tn.passwordIsCached()||this.pwCache&&this.pwCache.pw?Vt.hide(n.passBox):Vt.show(n.passBox),n.host.textContent=e.host}},{key:"setAsset",value:function(e){var t=Cn().assets[e],n=t.unitInfo;this.bondAssetID=t.id;var r=this.page,a=this.xc.bondAssets[t.symbol];r.bondAmt.textContent=Vt.formatCoinValue(this.totalBondAmount(a.amount),n),r.bondUnit.textContent=n.conventional.unit.toUpperCase(),r.logo.src=Vt.logoPath(t.symbol)}},{key:"totalBondAmount",value:function(e){var t;return+(null!==(t=this.page.bondStrengthField.value)&&void 0!==t?t:1)*e}},{key:"animate",value:(n=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(400,(function(e){t.style.transform="scale(".concat(e,")"),t.style.opacity=String(Math.pow(e,4));var n="".concat(500*(1-e),"px");t.style.top=n,t.style.left=n}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"submitForm",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((t=this.page).submit.classList.contains("selected")){e.next=3;break}return e.abrupt("return");case 3:if(n=Cn().assets[this.bondAssetID]){e.next=8;break}return t.regErr.innerText=Rt(gt),Vt.show(t.regErr),e.abrupt("return");case 8:return Vt.hide(t.regErr),r=this.xc.bondAssets[n.wallet.symbol],e.next=12,this.certFile;case 12:return a=e.sent,o=this.xc.host,s=t.appPass.value||(this.pwCache?this.pwCache.pw:""),i={addr:o,cert:a,pass:s,bond:this.totalBondAmount(r.amount),asset:r.id},t.appPass.value="",c=Cn().loading(this.form),e.next=20,yn("/api/postbond",i);case 20:if(l=e.sent,c(),Cn().checkResponse(l)){e.next=26;break}return t.regErr.textContent=l.msg,Vt.show(t.regErr),e.abrupt("return");case 26:this.success();case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),wr=function(){function e(t,n){var r=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"xc",void 0),h(this,"page",void 0),h(this,"assetTmpls",void 0),this.form=t,this.success=n,this.page=Vt.parseTemplate(t),Vt.cleanTemplates(this.page.marketTmpl,this.page.assetTmpl),Cn().registerNoteFeeder({createwallet:function(e){"QueuedCreationSuccess"===e.topic&&r.walletCreated(e.assetID)}})}var t;return u(e,[{key:"setExchange",value:function(e){var t=this;this.xc=e,this.assetTmpls={};var n=this.page;Vt.empty(n.assets,n.allMarkets);for(var a=function(e){return e.conventional.conversionFactor},o=function(t,r){var o=n.marketTmpl.cloneNode(!0),s=Vt.parseTemplate(o),i=e.assets[t.baseid],c=Cn().unitInfo(t.baseid,e),l=e.assets[t.quoteid],u=Cn().unitInfo(t.quoteid,e);if(0===a(c)||0===a(u))return null;if(void 0!==r){var h=r===t.baseid,d=e.assets[h?t.quoteid:t.baseid].symbol;s.logo.src=Vt.logoPath(d)}else{var p=s.logo.cloneNode(!0);s.logo.src=Vt.logoPath(i.symbol),p.src=Vt.logoPath(l.symbol);var f=s.logo.parentNode;f&&f.insertBefore(p,s.logo.nextSibling)}var m=i.symbol.toUpperCase(),v=l.symbol.toUpperCase();if(s.baseName.replaceWith(Vt.symbolize(m)),s.quoteName.replaceWith(Vt.symbolize(v)),s.lotSize.textContent=Vt.formatCoinValue(t.lotsize,c),s.lotSizeSymbol.replaceWith(Vt.symbolize(m)),t.spot){Vt.show(s.quoteLotSize);var g=a(u)/a(c),y=t.lotsize*t.spot.rate/Pn*g,b=Vt.formatCoinValue(y,u);s.quoteLotSize.textContent="(~".concat(b," ").concat(v,")")}return o},s=function(){var a=r(c[i],2),s=a[0],l=a[1],u=Cn().assets[l.id];if(!u)return"continue";var h=u.unitInfo,d=n.assetTmpl.cloneNode(!0);Vt.bind(d,"click",(function(){t.success(l.id)}));var p=t.assetTmpls[l.id]=Vt.parseTemplate(d);n.assets.appendChild(d),p.logo.src=Vt.logoPath(s);var f=Vt.formatCoinValue(l.amount,h);p.feeAmt.textContent=String(f),p.feeSymbol.replaceWith(Vt.symbolize(u.symbol)),p.confs.textContent=String(l.confs),kr(p.ready,u);for(var m=0,v=0,g=Object.values(e.markets);v0)if(r.totalForBond.textContent=Vt.formatCoinValue(2*s.amount+t,a.unitInfo),Vt.hide(r.sendEnough),Vt.hide(r.txFeeBox,r.sendEnoughForToken,r.txFeeBalanceBox),Vt.hide(r.sendEnoughWithEst),a.token){Vt.show(r.txFeeBox,r.sendEnoughForToken,r.txFeeBalanceBox);var l=Cn().assets[a.token.parentID];r.txFee.textContent=Vt.formatCoinValue(t,l.unitInfo),r.parentFees.textContent=Vt.formatCoinValue(t,l.unitInfo),r.tokenFees.textContent=Vt.formatCoinValue(s.amount,a.unitInfo),i(r.txFeeUnit,l.symbol),i(r.parentUnit,l.symbol),i(r.parentBalUnit,l.symbol),r.parentBal.textContent=l.wallet?Vt.formatCoinValue(l.wallet.balance.available,l.unitInfo):"0"}else Vt.show(r.sendEnoughWithEst);else Vt.show(r.sendEnough);Vt.show(e.synced?r.syncCheck:e.syncProgress>=1?r.syncSpinner:r.syncUncheck),Vt.show(e.balance.available>=2*s.amount+t?r.balCheck:r.balUncheck),r.progress.textContent=(100*e.syncProgress).toFixed(1),e.synced&&(this.progressed=!0),this.reportBalance(e.assetID)}},{key:"reportWalletState",value:function(e){this.progressed&&this.funded||(e.assetID===this.assetID&&this.reportProgress(e.synced,e.syncProgress),this.reportBalance(e.assetID))}},{key:"reportBalance",value:function(e){if(!this.funded&&-1!==this.assetID&&(e===this.assetID||e===this.parentID)){var t=this.page,n=Cn().assets[this.assetID],r=n.wallet.balance.available;if(t.balance.textContent=Vt.formatCoinValue(r,n.unitInfo),n.token){var a=Cn().assets[n.token.parentID],o=a.wallet.balance.available;if(t.parentBal.textContent=Vt.formatCoinValue(o,a.unitInfo),o=.999)return Vt.hide(n.syncRemaining),Vt.show(n.syncFinishingUp),Vt.show(n.syncRemainBox),void(n.syncFinishingUp.textContent=Rt(bt));var r=this.progressCache;if(r.push({stamp:(new Date).getTime(),progress:t}),!(r.length<2)){for(;r.length>20;)r.shift();var a=[r[0],r[r.length-1]],o=a[0],s=a[1],i=s.progress-o.progress;if(0!==i){Vt.hide(n.syncFinishingUp),Vt.show(n.syncRemaining),Vt.show(n.syncRemainBox);var c=i/(s.stamp-o.stamp),l=(1-s.progress)/c;n.syncRemain.textContent=Vt.formatDuration(l)}}}}]),e}(),Cr=function(){function e(t,n,r){var a=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"page",void 0),h(this,"currentAsset",void 0),this.page=Vt.idDescendants(t),this.form=t,this.pwCache=r||null,this.success=n,Tr(t,this.page.submitUnlock,(function(){return a.submit()}))}var t;return u(e,[{key:"refresh",value:function(e){var t=this.page;this.currentAsset=e,t.uwAssetLogo.src=Vt.logoPath(e.symbol),t.uwAssetName.textContent=e.name,t.uwAppPass.value="",t.unlockErr.textContent="",Vt.hide(t.unlockErr),tn.passwordIsCached()||this.pwCache&&this.pwCache.pw?Vt.hide(t.uwAppPassBox):Vt.show(t.uwAppPassBox)}},{key:"setError",value:function(e){this.page.unlockErr.textContent=e,Vt.show(this.page.unlockErr)}},{key:"showErrorOnly",value:function(e){this.setError(e),Vt.hide(this.page.uwAppPassBox),Vt.hide(this.page.submitUnlockDiv)}},{key:"submit",value:(t=o(w().mark((function e(){var t,n,r,a,o,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,(n=t.uwAppPass.value||(this.pwCache?this.pwCache.pw:""))||tn.passwordIsCached()){e.next=6;break}return t.unlockErr.textContent=Rt(x),Vt.show(t.unlockErr),e.abrupt("return");case 6:return r=this.currentAsset.id,Vt.hide(this.page.unlockErr),a={assetID:r,pass:n},t.uwAppPass.value="",o=Cn().loading(this.form),e.next=13,yn("/api/openwallet",a);case 13:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=18;break}return this.setError(s.msg),e.abrupt("return");case 18:this.pwCache&&(this.pwCache.pw=n),this.success(r);case 20:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Sr=function(){function e(t,n){var r=this;s(this,e),h(this,"form",void 0),h(this,"page",void 0),h(this,"order",void 0),h(this,"acceleratedRate",void 0),h(this,"earlyAcceleration",void 0),h(this,"currencyUnit",void 0),h(this,"success",void 0),this.form=t,this.success=n;var a=this.page=Vt.idDescendants(t);Vt.bind(a.accelerateSubmit,"click",(function(){r.submit()})),Vt.bind(a.submitEarlyConfirm,"click",(function(){r.sendAccelerateRequest()}))}var t,n,r,a;return u(e,[{key:"displayEarlyAccelerationMsg",value:function(){var e=this.page;this.earlyAcceleration&&(e.recentAccelerationTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60)),e.recentSwapTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60)),this.earlyAcceleration.wasAcceleration?(Vt.show(e.recentAccelerationMsg),Vt.hide(e.recentSwapMsg),e.recentAccelerationTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60))):(Vt.show(e.recentSwapMsg),Vt.hide(e.recentAccelerationMsg),e.recentSwapTime.textContent="".concat(Math.floor(this.earlyAcceleration.timePast/60))),Vt.hide(e.configureAccelerationDiv,e.accelerateErr),Vt.show(e.earlyAccelerationDiv))}},{key:"sendAccelerateRequest",value:(a=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.order,n=this.page,r={pw:n.acceleratePass.value,orderID:t.id,newRate:this.acceleratedRate},n.acceleratePass.value="",a=Cn().loading(n.accelerateMainDiv),e.next=7,yn("/api/accelerateorder",r);case 7:o=e.sent,a(),Cn().checkResponse(o)?(n.accelerateTxID.textContent=o.txID,Vt.hide(n.accelerateMainDiv,n.preAccelerateErr,n.accelerateErr),Vt.show(n.accelerateMsgDiv,n.accelerateSuccess),this.success()):(n.accelerateErr.textContent=Rt(lt,{msg:o.msg}),Vt.hide(n.earlyAccelerationDiv),Vt.show(n.accelerateErr,n.configureAccelerationDiv));case 10:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"submit",value:(r=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.earlyAcceleration?this.displayEarlyAccelerationMsg():this.sendAccelerateRequest();case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"refresh",value:(n=o(w().mark((function e(t){var n,r,a,o,s,i,c=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.order=t,e.next=4,yn("/api/preaccelerate",t.id);case 4:if(r=e.sent,Cn().checkResponse(r)){e.next=10;break}return n.preAccelerateErr.textContent=Rt(lt,{msg:r.msg}),Vt.hide(n.accelerateMainDiv,n.accelerateSuccess),Vt.show(n.accelerateMsgDiv,n.preAccelerateErr),e.abrupt("return");case 10:Vt.hide(n.accelerateMsgDiv,n.preAccelerateErr,n.accelerateErr,n.feeEstimateDiv,n.earlyAccelerationDiv),Vt.show(n.accelerateMainDiv,n.accelerateSuccess,n.configureAccelerationDiv),a=r.preAccelerate,this.earlyAcceleration=a.earlyAcceleration,this.currencyUnit=a.suggestedRange.yUnit,n.accelerateAvgFeeRate.textContent="".concat(a.swapRate," ").concat(a.suggestedRange.yUnit),n.accelerateCurrentFeeRate.textContent="".concat(a.suggestedRate," ").concat(a.suggestedRange.yUnit),this.acceleratedRate=a.suggestedRange.start.y,o=function(){},s=function(e,t){c.acceleratedRate=t},i=new Dn(a.suggestedRange,a.suggestedRange.start.x,s,(function(){return c.updateAccelerationEstimate()}),o,!0),Vt.empty(n.sliderContainer),n.sliderContainer.appendChild(i.control),this.updateAccelerationEstimate();case 25:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"updateAccelerationEstimate",value:(t=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=this.order,r={orderID:n.id,newRate:this.acceleratedRate},a=Cn().loading(t.sliderContainer),e.next=6,yn("/api/accelerationestimate",r);case 6:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=12;break}return t.accelerateErr.textContent=Rt(ct,{msg:o.msg}),Vt.show(t.accelerateErr),e.abrupt("return");case 12:t.feeRateEstimate.textContent="".concat(this.acceleratedRate," ").concat(this.currencyUnit),n.sell?(s=n.baseID,i=n.baseSymbol):(s=n.quoteID,i=n.quoteSymbol),c=Cn().unitInfo(s),t.feeEstimate.textContent="".concat(o.fee/c.conventional.conversionFactor," ").concat(i),Vt.show(t.feeEstimateDiv);case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Er=function(){function e(t,n,r,a){var o=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"page",void 0),h(this,"knownExchanges",void 0),h(this,"dexToUpdate",void 0),this.form=t,this.success=n,this.pwCache=r||null;var i=this.page=Vt.parseTemplate(t);i.selectedCert.textContent=Rt(ie),Vt.bind(i.skipRegistration,"change",(function(){return o.showOrHidePWBox()})),Vt.bind(i.certFile,"change",(function(){return o.onCertFileChange()})),Vt.bind(i.removeCert,"click",(function(){return o.clearCertFile()})),Vt.bind(i.addCert,"click",(function(){return i.certFile.click()})),Vt.bind(i.showCustom,"click",(function(){Vt.hide(i.showCustom),Vt.show(i.customBox,i.auth)})),this.knownExchanges=Array.from(i.knownXCs.querySelectorAll(".known-exchange"));var c,l=fr(this.knownExchanges);try{var u=function(){var e=c.value;Vt.bind(e,"click",(function(){var t,n=e.dataset.host,a=fr(o.knownExchanges);try{for(a.s();!(t=a.n()).done;)t.value.classList.remove("selected")}catch(e){a.e(e)}finally{a.f()}if(o.skipRegistration()||tn.passwordIsCached()||r&&r.pw)return o.checkDEX(n);e.classList.add("selected"),i.appPW.focus(),i.addr.value=n}))};for(l.s();!(c=l.n()).done;)u()}catch(e){l.e(e)}finally{l.f()}Tr(t,i.submit,(function(){return o.checkDEX()})),a&&(Vt.hide(i.addDexHdr,i.skipRegistrationBox),Vt.show(i.updateDexHdr),this.dexToUpdate=a),this.refresh()}var t,n,r;return u(e,[{key:"refresh",value:function(){var e=this.page;e.addr.value="",e.appPW.value="",this.clearCertFile(),Vt.hide(e.err),0===this.knownExchanges.length||this.dexToUpdate?(Vt.show(e.customBox,e.auth),Vt.hide(e.showCustom,e.knownXCs,e.pickServerMsg,e.addCustomMsg)):(Vt.hide(e.customBox),Vt.show(e.showCustom));var t,n=fr(this.knownExchanges);try{for(n.s();!(t=n.n()).done;)t.value.classList.remove("selected")}catch(e){n.e(e)}finally{n.f()}this.showOrHidePWBox()}},{key:"showOrHidePWBox",value:function(){var e=!(tn.passwordIsCached()||this.pwCache&&this.pwCache.pw||this.skipRegistration()),t=this.page;e?Vt.show(t.appPWBox,t.auth):(Vt.hide(t.appPWBox),Vt.setVis(Vt.isDisplayed(t.customBox),t.auth))}},{key:"skipRegistration",value:function(){var e;return null!==(e=this.page.skipRegistration.checked)&&void 0!==e&&e}},{key:"animate",value:(r=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(550,(function(e){t.style.transform="scale(".concat(.9+.1*e,")"),t.style.opacity=String(Math.pow(e,4))}),"easeOut");case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"checkDEX",value:(n=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.page,Vt.hide(n.err),""!==(t=t||n.addr.value)){e.next=7;break}return n.err.textContent=Rt(vt),Vt.show(n.err),e.abrupt("return");case 7:if(r="",!n.certFile.value){e.next=14;break}if(!(a=n.certFile.files)||!a.length){e.next=14;break}return e.next=13,a[0].text();case 13:r=e.sent;case 14:return o=this.skipRegistration(),s="",o||tn.passwordIsCached()||(s=n.appPW.value||(this.pwCache?this.pwCache.pw:"")),this.dexToUpdate?(i="/api/updatedexhost",c={newHost:t,cert:r,pw:s,oldHost:this.dexToUpdate}):(i=o?"/api/adddex":"/api/discoveracct",c={addr:t,cert:r,pass:s}),l=Cn().loading(this.form),e.next=21,yn(i,c);case 21:if(u=e.sent,l(),Cn().checkResponse(u)){e.next=26;break}return String(u.msg).includes("certificate required")?Vt.show(n.needCert):(n.err.textContent=u.msg,Vt.show(n.err)),e.abrupt("return");case 26:if(this.dexToUpdate||!(o||u.paid||Object.keys(u.xc.pendingBonds).length>0)){e.next=32;break}return e.next=29,Cn().fetchUser();case 29:return e.next=31,Cn().loadPage("markets");case 31:return e.abrupt("return");case 32:this.pwCache&&(this.pwCache.pw=s),this.success(u.xc,r);case 34:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"onCertFileChange",value:(t=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,(n=t.certFile.files)&&n.length){e.next=4;break}return e.abrupt("return");case 4:t.selectedCert.textContent=n[0].name,Vt.show(t.removeCert),Vt.hide(t.addCert);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"clearCertFile",value:function(){var e=this.page;e.certFile.value="",e.selectedCert.textContent=Rt(ie),Vt.hide(e.removeCert),Vt.show(e.addCert)}}]),e}(),Ar=function(){function e(t,n,r,a){var o=this;s(this,e),h(this,"form",void 0),h(this,"addr",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"page",void 0),this.form=t,this.addr=n,this.success=r,this.pwCache=a||null;var i=this.page=Vt.parseTemplate(t);i.dexHost.textContent=n,Tr(t,i.submit,(function(){return o.checkDEX()})),this.refresh()}var t,n;return u(e,[{key:"refresh",value:function(){var e=this.page;e.appPW.value="",Vt.hide(e.err),tn.passwordIsCached()||this.pwCache&&this.pwCache.pw?Vt.hide(e.appPWBox):Vt.show(e.appPWBox)}},{key:"animate",value:(n=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(550,(function(e){t.style.transform="scale(".concat(.9+.1*e,")"),t.style.opacity=String(Math.pow(e,4))}),"easeOut");case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"checkDEX",value:(t=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.err),n="",tn.passwordIsCached()||(n=t.appPW.value||(this.pwCache?this.pwCache.pw:"")),r={addr:this.addr,pass:n},a=Cn().loading(this.form),e.next=8,yn("/api/discoveracct",r);case 8:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=14;break}return t.err.textContent=o.msg,Vt.show(t.err),e.abrupt("return");case 14:if(!o.paid){e.next=20;break}return e.next=17,Cn().fetchUser();case 17:return e.next=19,Cn().loadPage("markets");case 19:return e.abrupt("return");case 20:this.pwCache&&(this.pwCache.pw=n),this.success(o.xc);case 22:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Fr=function(){function e(t,n,r){var a=this;s(this,e),h(this,"form",void 0),h(this,"success",void 0),h(this,"pwCache",void 0),h(this,"headerTxt",void 0),h(this,"page",void 0),this.success=n,this.form=t,this.pwCache=r||null;var o=this.page=Vt.parseTemplate(t);this.headerTxt=o.header.textContent||"",Tr(t,o.submit,(function(){a.submit()})),Cn().registerNoteFeeder({login:function(e){a.handleLoginNote(e)}})}var t,n;return u(e,[{key:"handleLoginNote",value:function(e){if(""!==e.details){var t=Vt.idel(this.form,"loaderMsg");t&&(t.textContent=e.details)}}},{key:"focus",value:function(){this.page.pw.focus()}},{key:"submit",value:(n=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.errMsg),n=t.pw.value||"",t.pw.value="",r=t.rememberPass.checked,""!==n){e.next=9;break}return t.errMsg.textContent=Rt(k),Vt.show(t.errMsg),e.abrupt("return");case 9:return a=Cn().loading(this.form),e.next=12,yn("/api/login",{pass:n,rememberPass:r});case 12:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=18;break}return t.errMsg.textContent=o.msg,Vt.show(t.errMsg),e.abrupt("return");case 18:o.notes&&(o.notes.reverse(),Cn().setNotes(o.notes)),this.pwCache&&(this.pwCache.pw=n),this.success();case 21:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"animate",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.form,Vt.animate(550,(function(e){t.style.transform="scale(".concat(.9+.1*e,")"),t.style.opacity=String(Math.pow(e,4))}),"easeOut");case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Ir=function(){function e(t){var n=this;s(this,e),h(this,"form",void 0),h(this,"page",void 0),h(this,"assetID",void 0),this.form=t;var r=this.page=Vt.idDescendants(t);Vt.bind(r.newDepAddrBttn,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.newDepositAddress();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(r.copyAddressBtn,"click",(function(){n.copyAddress()}))}var t,n,r;return u(e,[{key:"setAsset",value:(r=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.assetID=t,n=this.page,Vt.hide(n.depositErr),r=Cn().assets[t],n.depositLogo.src=Vt.logoPath(r.symbol),a=Cn().walletMap[t],n.depositName.textContent=r.name,n.depositAddress.textContent=a.address,n.qrcode.src="/generateqrcode?address=".concat(a.address),0!=(2&a.traits)?Vt.show(n.newDepAddrBttn):Vt.hide(n.newDepAddrBttn);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"newDepositAddress",value:(n=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.depositErr),n=Cn().loading(this.form),e.next=5,yn("/api/depositaddress",{assetID:this.assetID});case 5:if(r=e.sent,n(),Cn().checkResponse(r)){e.next=11;break}return t.depositErr.textContent=r.msg,Vt.show(t.depositErr),e.abrupt("return");case 11:t.depositAddress.textContent=r.address,t.qrcode.src="/generateqrcode?address=".concat(r.address);case 13:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"copyAddress",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,navigator.clipboard.writeText(t.depositAddress.textContent||"").then((function(){Vt.show(t.copyAlert),setTimeout((function(){Vt.hide(t.copyAlert)}),800)})).catch((function(e){console.error("Unable to copy: ",e)}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Rr=300;function Dr(e,t){return Or.apply(this,arguments)}function Or(){return(Or=o(w().mark((function e(t,n){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=document.body.offsetWidth/2,e.next=3,Vt.animate(Rr,(function(e){t.style.right="".concat(e*r,"px")}),"easeInHard");case 3:return Vt.hide(t),t.style.right="0",n.style.right=String(-r),Vt.show(n),n.querySelector("input")&&Vt.safeSelector(n,"input").focus(),e.next=10,Vt.animate(Rr,(function(e){n.style.right="".concat(e*r-r,"px")}),"easeOutHard");case 10:n.style.right="0";case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Tr(e,t,n){var r=function(e){e.preventDefault&&e.preventDefault(),n(e)};Vt.bind(t,"click",r),Vt.bind(e,"submit",r)}function Pr(e){return Math.floor(e.getTime()/1e3)}function Lr(e){return function(e){return new Date(e.getTime()-60*e.getTimezoneOffset()*1e3)}(e).toISOString().split("T")[0]}var Br=function(e){an(g,e);var t,n,r,a,i,c,l,d,p,f,m,v=(f=g,m=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(f);if(m){var n=sn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return on(this,e)});function g(e,t){var n;s(this,g),h(nn(n=v.call(this)),"body",void 0),h(nn(n),"pwCache",void 0),h(nn(n),"currentDEX",void 0),h(nn(n),"page",void 0),h(nn(n),"loginForm",void 0),h(nn(n),"dexAddrForm",void 0),h(nn(n),"discoverAcctForm",void 0),h(nn(n),"newWalletForm",void 0),h(nn(n),"regAssetForm",void 0),h(nn(n),"walletWaitForm",void 0),h(nn(n),"confirmRegisterForm",void 0),n.body=e,n.pwCache={pw:""};var r=n.page=Vt.idDescendants(e);t.host&&r.dexAddrForm.classList.contains("selected")&&(r.dexAddrForm.classList.remove("selected"),r.discoverAcctForm.classList.add("selected"),r.discoverAcctForm.dataset.host=t.host),e.querySelectorAll(".form-closer").forEach((function(e){return Vt.hide(e)})),Tr(r.appPWForm,r.appPWSubmit,(function(){return n.setAppPass()})),Vt.bind(r.showSeedRestore,"click",(function(){Vt.show(r.seedRestore),Vt.hide(r.showSeedRestore)})),n.loginForm=new Fr(r.loginForm,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:n.discoverAcctForm?(n.discoverAcctForm.refresh(),Dr(r.loginForm,r.discoverAcctForm)):(n.dexAddrForm.refresh(),Dr(r.loginForm,r.dexAddrForm));case 3:case"end":return e.stop()}}),e)}))),n.pwCache),n.newWalletForm=new vr(r.newWalletForm,(function(e){return n.newWalletCreated(e)}),n.pwCache,(function(){return n.animateRegAsset(r.newWalletForm)})),n.dexAddrForm=new Er(r.dexAddrForm,function(){var e=o(w().mark((function e(t,a){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.requestFeepayment(r.dexAddrForm,t,a);case 1:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),n.pwCache);var a=r.discoverAcctForm.dataset.host;a&&(n.discoverAcctForm=new Ar(r.discoverAcctForm,a,function(){var e=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.requestFeepayment(r.discoverAcctForm,t,"");case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.pwCache)),n.regAssetForm=new wr(r.regAssetForm,function(){var e=o(w().mark((function e(t){var a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.confirmRegisterForm.setAsset(t),a=Cn().assets[t],!(o=a.wallet)){e.next=14;break}return s=n.currentDEX.bondAssets[a.symbol],e.next=7,n.getBondsFeeBuffer(t,r.regAssetForm);case 7:if(i=e.sent,!(o.synced&&o.balance.available>=2*s.amount+i)){e.next=11;break}return n.animateConfirmForm(r.regAssetForm),e.abrupt("return");case 11:return n.walletWaitForm.setWallet(o,i),Dr(r.regAssetForm,r.walletWait),e.abrupt("return");case 14:n.newWalletForm.setAsset(t),Dr(r.regAssetForm,r.newWalletForm);case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),n.walletWaitForm=new xr(r.walletWait,(function(){n.animateConfirmForm(r.walletWait)}),(function(){n.animateRegAsset(r.walletWait)})),n.confirmRegisterForm=new br(r.confirmRegForm,(function(){n.registerDEXSuccess()}),(function(){n.animateRegAsset(r.confirmRegForm)}),n.pwCache);var i=Vt.safeSelector(r.forms,":scope > form.selected");switch(i.classList.remove("selected"),i){case r.loginForm:n.loginForm.animate();break;case r.dexAddrForm:n.dexAddrForm.animate();break;case r.discoverAcctForm:n.discoverAcctForm.animate()}return Vt.show(i),Cn().authed()&&n.auth(),n}return u(g,[{key:"unload",value:function(){this.pwCache.pw=""}},{key:"auth",value:(p=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:case"end":return e.stop()}}),e)}))),function(){return p.apply(this,arguments)})},{key:"requestFeepayment",value:(d=o(w().mark((function e(t,n,r){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.currentDEX=n,this.confirmRegisterForm.setExchange(n,r),this.walletWaitForm.setExchange(n),this.regAssetForm.setExchange(n),this.animateRegAsset(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"animateRegAsset",value:(l=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vt.hide(t),this.regAssetForm.animate(),Vt.show(this.page.regAssetForm);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"animateConfirmForm",value:(c=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.confirmRegisterForm.animate(),Vt.hide(t),Vt.show(this.page.confirmRegForm);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"getBondsFeeBuffer",value:(i=o(w().mark((function e(t,n){var r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Cn().loading(n),e.next=3,yn("/api/bondsfeebuffer",{assetID:t});case 3:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=7;break}return e.abrupt("return",0);case 7:return e.abrupt("return",a.feeBuffer);case 8:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"setAppPass",value:(a=o(w().mark((function e(){var t,n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.appPWErrMsg),n=t.appPW.value||"",r=t.appPWAgain.value,""!==n){e.next=8;break}return t.appPWErrMsg.textContent=Rt(k),Vt.show(t.appPWErrMsg),e.abrupt("return");case 8:if(n===r){e.next=12;break}return t.appPWErrMsg.textContent=Rt(K),Vt.show(t.appPWErrMsg),e.abrupt("return");case 12:return Cn().setNotes([]),t.appPW.value="",t.appPWAgain.value="",a=Cn().loading(t.appPWForm),o=t.seedInput.value,s=t.rememberPass.checked,e.next=20,yn("/api/init",{pass:n,seed:o,rememberPass:s});case 20:if(i=e.sent,a(),Cn().checkResponse(i)){e.next=26;break}return t.appPWErrMsg.textContent=i.msg,Vt.show(t.appPWErrMsg),e.abrupt("return");case 26:return this.pwCache.pw=n,this.auth(),Cn().updateMenuItemsDisplay(),this.newWalletForm.refresh(),this.dexAddrForm.refresh(),e.next=33,Dr(t.appPWForm,t.dexAddrForm);case 33:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getCertFile",value:(r=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="",!this.dexAddrForm.page.certFile.value){e.next=7;break}if(!(n=this.dexAddrForm.page.certFile.files)||!n.length){e.next=7;break}return e.next=6,n[0].text();case 6:t=e.sent;case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"registerDEXSuccess",value:(n=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:return e.next=4,Cn().loadPage("markets");case 4:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"newWalletCreated",value:(t=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.regAssetForm.refresh(),e.next=3,Cn().fetchUser();case 3:if(n=e.sent){e.next=6;break}return e.abrupt("return");case 6:return r=this.page,a=n.assets[t],o=a.wallet,s=this.currentDEX.bondAssets[a.symbol].amount,e.next=12,this.getBondsFeeBuffer(t,r.newWalletForm);case 12:if(i=e.sent,!(o.synced&&o.balance.available>=2*s+i)){e.next=17;break}return e.next=16,this.animateConfirmForm(r.newWalletForm);case 16:return e.abrupt("return");case 17:return this.walletWaitForm.setWallet(o,i),e.next=20,Dr(r.newWalletForm,r.walletWait);case 20:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),g}(mn);var Mr=function(e){an(i,e);var t,n,r,a=(n=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(n);if(r){var a=sn(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return on(this,e)});function i(e){var t;return s(this,i),h(nn(t=a.call(this)),"form",void 0),h(nn(t),"loginForm",void 0),t.form=Vt.idel(e,"loginForm"),Vt.show(t.form),t.loginForm=new Fr(t.form,(function(){t.loggedIn()})),t.loginForm.focus(),t}return u(i,[{key:"loggedIn",value:(t=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:return e.next=4,Cn().loadPage("markets");case 4:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),i}(mn);function Wr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return qr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function qr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n form"),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){t.closePopups()}))})),Vt.bind(n.cancelForce,"click",(function(){t.closePopups()})),t.selectedAssetID=-1,Vt.cleanTemplates(n.iconSelectTmpl,n.balanceDetailRow,n.recentOrderTmpl),Vt.bind(n.createWallet,"click",(function(){return t.showNewWallet(t.selectedAssetID)})),Vt.bind(n.connectBttn,"click",(function(){return t.doConnect(t.selectedAssetID)})),Vt.bind(n.send,"click",(function(){return t.showSendForm(t.selectedAssetID)})),Vt.bind(n.receive,"click",(function(){return t.showDeposit(t.selectedAssetID)})),Vt.bind(n.unlockBttn,"click",(function(){return t.openWallet(t.selectedAssetID)})),Vt.bind(n.lockBttn,"click",(function(){return t.lock(t.selectedAssetID)})),Vt.bind(n.reconfigureBttn,"click",(function(){return t.showReconfig(t.selectedAssetID)})),Vt.bind(n.rescanWallet,"click",(function(){return t.rescanWallet(t.selectedAssetID)})),t.newWalletForm=new vr(n.newWalletForm,(function(e){var r={assetName:Cn().assets[e].name};t.assetUpdated(e,n.newWalletForm,Rt(xe,r)),t.sortAssetButtons()})),t.reconfigForm=new yr(n.reconfigInputs,!1),t.walletCfgGuide=Vt.tmplElement(n.reconfigForm,"walletCfgGuide"),t.unlockForm=new Cr(n.unlockWalletForm,(function(e){return t.openWalletSuccess(e,n.unlockWalletForm)})),Tr(n.sendForm,n.submitSendForm,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.stepSend();case 1:case"end":return e.stop()}}),e)})))),Tr(n.vSendForm,n.vSend,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.send();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.vCancelSend,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.cancelSend();case 1:case"end":return e.stop()}}),e)})))),Tr(n.reconfigForm,n.submitReconfig,(function(){return t.reconfig()})),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){return t.closePopups()}))})),Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||t.closePopups()})),t.keyup=function(e){"Escape"===e.key&&Vt.isDisplayed(t.page.forms)&&t.closePopups()},Vt.bind(document,"keyup",t.keyup),Vt.bind(n.downloadLogs,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.downloadLogs();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.exportWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.displayExportWalletAuth();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.recoverWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showRecoverWallet();case 1:case"end":return e.stop()}}),e)})))),Tr(n.exportWalletAuth,n.exportWalletAuthSubmit,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.exportWalletAuthSubmit();case 1:case"end":return e.stop()}}),e)})))),Tr(n.recoverWalletConfirm,n.recoverWalletSubmit,(function(){t.recoverWallet()})),Tr(n.confirmForce,n.confirmForceSubmit,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.confirmForceSubmit();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.disableWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showToggleWalletStatus(!0);case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.enableWallet,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showToggleWalletStatus(!1);case 1:case"end":return e.stop()}}),e)})))),Tr(n.toggleWalletStatusConfirm,n.toggleWalletStatusSubmit,o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.toggleWalletStatus();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.managePeers,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.showManagePeersForm();case 1:case"end":return e.stop()}}),e)})))),Vt.bind(n.addPeerSubmit,"click",o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.submitAddPeer();case 1:case"end":return e.stop()}}),e)})))),t.depositAddrForm=new Ir(n.deposit),Vt.bind(n.walletBal,"click",(function(){t.populateMaxSend()})),Vt.bind(n.sendAmt,"input",(function(){var e=Cn().assets[t.selectedAssetID].unitInfo,r=parseFloat(n.sendAmt.value||"0"),a=e.conventional.conversionFactor;t.showFiatValue(t.selectedAssetID,r*a,n.sendValue)})),Vt.bind(n.maxSend,"click",(function(){t.populateMaxSend()})),Vt.bind(n.sendAddr,"input",o(w().mark((function e(){var r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Cn().assets[t.selectedAssetID],Vt.hide(n.validAddr),n.sendAddr.classList.remove("invalid"),a=n.sendAddr.value||"",r&&""!==a){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,t.validateSendAddress(a,r.id);case 8:e.sent?Vt.show(n.validAddr):n.sendAddr.classList.add("invalid");case 10:case"end":return e.stop()}}),e)})))),Vt.bind(n.showChangePW,"click",(function(){t.changeWalletPW=!t.changeWalletPW,t.setPWSettingViz(t.changeWalletPW)})),Vt.bind(n.changeWalletTypeSelect,"change",(function(){t.changeWalletType()})),Vt.bind(n.showChangeType,"click",(function(){Vt.isHidden(n.changeWalletType)?(Vt.show(n.changeWalletType,n.changeTypeHideIcon),Vt.hide(n.changeTypeShowIcon),n.changeTypeMsg.textContent=Rt(me)):t.showReconfig(t.selectedAssetID,!0)})),Cn().registerNoteFeeder({fiatrateupdate:function(e){t.handleRatesNote(e)},balance:function(e){t.handleBalanceNote(e)},walletstate:function(e){t.handleWalletStateNote(e)},walletconfig:function(e){t.handleWalletStateNote(e)},createwallet:function(e){t.handleCreateWalletNote(e)}});var r=t.sortAssetButtons().id,a=tn.fetchLocal(tn.selectedAssetLK);return a&&(r=Number(a)),t.setSelectedAsset(r),t}return u(V,[{key:"closePopups",value:function(){Vt.hide(this.page.forms),this.animation&&this.animation.stop()}},{key:"stepSend",value:(N=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d,p,f,m,v,g,y,b,k,x;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.vSendErr,t.sendErr,t.vSendEstimates,t.txFeeNotAvailable),n=parseInt(t.sendForm.dataset.assetID||""),r=Cn().assets[n].token,a=t.subtractCheckBox.checked||!1,o=Cn().unitInfo(n).conventional.conversionFactor,s=Math.round(parseFloat(t.sendAmt.value||"")*o),""!==(i=t.sendAddr.value||"")){e.next=10;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Be,{address:i})));case 10:if(c=Cn().assets[n],l=c.wallet,u=c.unitInfo,h=c.symbol,d=0,0==(1024&l.traits)){e.next=36;break}return p={addr:t.sendAddr.value,assetID:n,subtract:a,value:s},f=Cn().loading(t.sendForm),e.next=17,yn("/api/txfee",p);case 17:if(m=e.sent,f(),Cn().checkResponse(m)){e.next=29;break}return t.txFeeNotAvailable.dataset.tooltip=Rt(Me,{err:m.msg}),Vt.show(t.txFeeNotAvailable),e.next=24,this.validateSendAddress(i,n);case 24:if(e.sent){e.next=27;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Be,{address:i||""})));case 27:e.next=34;break;case 29:if(!m.ok){e.next=34;break}if(m.validaddress){e.next=32;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Be,{address:t.sendAddr.value||""})));case 32:d=m.txfee,Vt.show(t.vSendEstimates);case 34:e.next=41;break;case 36:return e.next=38,this.validateSendAddress(i,n);case 38:if(e.sent){e.next=41;break}return e.abrupt("return",Vt.showFormError(t.sendErr,Rt(Be,{address:i||""})));case 41:return t.vSendSymbol.textContent=h.toUpperCase(),t.vSendLogo.src=Vt.logoPath(h),r?(v=Cn().assets[r.parentID],g=v.unitInfo,y=v.symbol,t.vSendFee.textContent=Vt.formatFullPrecision(d,g)+" "+y):t.vSendFee.textContent=Vt.formatFullPrecision(d,u),this.showFiatValue(n,d,t.vSendFeeFiat),t.vSendDestinationAmt.textContent=Vt.formatFullPrecision(s-d,u),t.vTotalSend.textContent=Vt.formatFullPrecision(s,u),this.showFiatValue(n,s,t.vTotalSendFiat),t.vSendAddr.textContent=t.sendAddr.value||"",b=l.balance.available-s,t.balanceAfterSend.textContent=Vt.formatFullPrecision(b,u),this.showFiatValue(n,b,t.balanceAfterSendFiat),Vt.show(t.approxSign),a||(Vt.hide(t.approxSign),t.vSendDestinationAmt.textContent=Vt.formatFullPrecision(s,u),k=s,r||(k+=d),t.vTotalSend.textContent=Vt.formatFullPrecision(k,u),this.showFiatValue(n,k,t.vTotalSendFiat),x=l.balance.available-s,r||(x-=d),x<=0?(t.balanceAfterSend.textContent=Vt.formatFullPrecision(0,u),this.showFiatValue(n,0,t.balanceAfterSendFiat)):(t.balanceAfterSend.textContent=Vt.formatFullPrecision(x,u),this.showFiatValue(n,x,t.balanceAfterSendFiat))),Vt.hide(t.sendForm),e.next=57,this.showForm(t.vSendForm);case 57:case"end":return e.stop()}}),e,this)}))),function(){return N.apply(this,arguments)})},{key:"cancelSend",value:(q=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.vSendForm,t.sendErr),e.next=4,this.showForm(t.sendForm);case 4:case"end":return e.stop()}}),e,this)}))),function(){return q.apply(this,arguments)})},{key:"validateSendAddress",value:(W=o(w().mark((function e(t,n){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,yn("/api/validateaddress",{addr:t,assetID:n});case 2:return r=e.sent,e.abrupt("return",Cn().checkResponse(r));case 4:case"end":return e.stop()}}),e)}))),function(e,t){return W.apply(this,arguments)})},{key:"setPWSettingViz",value:function(e){if(e)return Vt.hide(this.page.showIcon),Vt.show(this.page.hideIcon,this.page.changePW),void(this.page.switchPWMsg.textContent=Rt(Q));Vt.hide(this.page.hideIcon,this.page.changePW),Vt.show(this.page.showIcon),this.page.switchPWMsg.textContent=Rt(Y)}},{key:"updateWalletPeersTable",value:(M=o(w().mark((function e(){var t,n,r,a,s,i,c=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.peerSpinner),e.next=4,yn("/api/getwalletpeers",{assetID:this.selectedAssetID});case 4:if(n=e.sent,Cn().checkResponse(n)){e.next=9;break}return t.managePeersErr.textContent=n.msg,Vt.show(t.managePeersErr),e.abrupt("return");case 9:for(;t.peersTableBody.firstChild;)t.peersTableBody.removeChild(t.peersTableBody.firstChild);(r=n.peers||[]).sort((function(e,t){return e.source-t.source})),a=Rt(ze),s=Rt(Ve),i=Rt(je),r.forEach((function(e){var n,r=t.peerTableRow.cloneNode(!0),l=Vt.parseTemplate(r);switch(l.addr.textContent=e.addr,e.source){case un.WalletDefault:l.source.textContent=a;break;case un.UserAdded:l.source.textContent=s;break;case un.Discovered:l.source.textContent=i}if(n=e.connected?c.page.connectedIconTmpl.cloneNode(!0):c.page.disconnectedIconTmpl.cloneNode(!0),l.connected.appendChild(n),e.source===un.UserAdded){var u=c.page.removeIconTmpl.cloneNode(!0);Vt.bind(u,"click",o(w().mark((function n(){var r;return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return Vt.hide(t.managePeersErr),n.next=3,yn("/api/removewalletpeer",{assetID:c.selectedAssetID,addr:e.addr});case 3:if(r=n.sent,Cn().checkResponse(r)){n.next=8;break}return t.managePeersErr.textContent=r.msg,Vt.show(t.managePeersErr),n.abrupt("return");case 8:c.spinUntilPeersUpdate();case 9:case"end":return n.stop()}}),n)})))),l.remove.appendChild(u)}t.peersTableBody.appendChild(r)}));case 16:case"end":return e.stop()}}),e,this)}))),function(){return M.apply(this,arguments)})},{key:"showManagePeersForm",value:(B=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,e.next=3,this.updateWalletPeersTable();case 3:Vt.hide(t.managePeersErr),this.showForm(t.managePeersForm);case 5:case"end":return e.stop()}}),e,this)}))),function(){return B.apply(this,arguments)})},{key:"submitAddPeer",value:(L=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.managePeersErr),e.next=4,yn("/api/addwalletpeer",{assetID:this.selectedAssetID,addr:t.addPeerInput.value});case 4:if(n=e.sent,Cn().checkResponse(n)){e.next=9;break}return t.managePeersErr.textContent=n.msg,Vt.show(t.managePeersErr),e.abrupt("return");case 9:this.spinUntilPeersUpdate(),t.addPeerInput.value="";case 11:case"end":return e.stop()}}),e,this)}))),function(){return L.apply(this,arguments)})},{key:"spinUntilPeersUpdate",value:(P=o(w().mark((function e(){var t,n=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,Vt.show(t.peerSpinner),setTimeout((function(){Vt.isDisplayed(t.peerSpinner)&&n.updateWalletPeersTable()}),1e4);case 3:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"showToggleWalletStatus",value:function(e){var t=this.page;Vt.hide(t.toggleWalletStatusErr,t.walletStatusDisable,t.disableWalletMsg,t.walletStatusEnable,t.enableWalletMsg),e?Vt.show(t.walletStatusDisable,t.disableWalletMsg):Vt.show(t.walletStatusEnable,t.enableWalletMsg),this.showForm(t.toggleWalletStatusConfirm)}},{key:"toggleWalletStatus",value:(T=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.toggleWalletStatusErr),n=Cn().assets[this.selectedAssetID],r=!n.wallet.disabled,a={assetID:this.selectedAssetID,disable:r},o={assetName:n.name},s=Cn().loading(t.toggleWalletStatusConfirm),e.next=10,yn("/api/togglewalletstatus",a);case 10:if(i=e.sent,s(),Cn().checkResponse(i)){e.next=16;break}return i.code===cn.activeOrdersErr?t.toggleWalletStatusErr.textContent=Rt(Ie,o):t.toggleWalletStatusErr.textContent=i.msg,Vt.show(t.toggleWalletStatusErr),e.abrupt("return");case 16:c=Rt(Ae,o),r||(c=Rt(Fe,o)),this.assetUpdated(this.selectedAssetID,t.toggleWalletStatusConfirm,c);case 19:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"showBox",value:(O=o(w().mark((function e(t,n){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.style.opacity="0",Vt.show(t),n&&n.focus(),e.next=5,Vt.animate(300,(function(e){t.style.opacity="".concat(e)}),"easeOut");case 5:t.style.opacity="1",this.displayed=t;case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"showForm",value:(D=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.currentForm=t,this.forms.forEach((function(e){return Vt.hide(e)})),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(300,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return D.apply(this,arguments)})},{key:"showSuccess",value:(R=o(w().mark((function e(t){var n,a,o,s,i,c,l,u,h,d=this;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.page).successMessage.textContent=t,this.currentForm=n.checkmarkForm,this.forms.forEach((function(e){return Vt.hide(e)})),Vt.show(n.forms,n.checkmarkForm),n.checkmarkForm.style.right="0",n.checkmark.style.fontSize="0px",a=tn.isDark()?[223,226,225]:[51,51,51],o=r(a,3),s=o[0],i=o[1],c=o[2],l=16-s,u=163-i,h=16-c,this.animation=new jt(1200,(function(e){n.checkmark.style.fontSize="".concat(80*e,"px"),n.checkmark.style.color="rgb(".concat(s+e*l,", ").concat(i+e*u,", ").concat(c+e*h,")")}),"easeOutElastic",(function(){d.animation=new jt(1500,(function(){}),"",(function(){d.currentForm===n.checkmarkForm&&d.closePopups()}))}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return R.apply(this,arguments)})},{key:"showNewWallet",value:(I=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=n.newWalletForm,this.newWalletForm.setAsset(t),a=this.newWalletForm.loadDefaults(),e.next=6,this.showForm(r);case 6:return e.next=8,a;case 8:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"sortAssetButtons",value:function(){var e=this,t=this.page;this.assetButtons={},Vt.empty(t.assetSelect);var n=xn(Object.values(Cn().assets));n.sort((function(e,t){return e.wallet&&!t.wallet?-1:!e.wallet&&t.wallet?1:e.symbol.localeCompare(t.symbol)}));var r,a=Wr(n);try{var o=function(){var n=r.value,a=t.iconSelectTmpl.cloneNode(!0);t.assetSelect.appendChild(a);var o=Vt.parseTemplate(a);e.assetButtons[n.id]={tmpl:o,bttn:a},e.updateAssetButton(n.id),Vt.bind(a,"click",(function(){e.setSelectedAsset(n.id),tn.storeLocal(tn.selectedAssetLK,String(n.id))}))};for(a.s();!(r=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}return t.assetSelect.classList.remove("invisible"),n[0]}},{key:"updateAssetButton",value:function(e){var t,n=Cn().assets[e],r=this.assetButtons[e],a=r.bttn,o=r.tmpl;if(Vt.hide(o.fiat,o.noWallet),a.classList.add("nowallet"),(t=o.img).src||(t.src=Vt.logoPath(n.symbol)),o.name.textContent=n.name,n.wallet){a.classList.remove("nowallet");var s=n.wallet.balance,i=n.unitInfo,c=s.available+s.locked+s.immature;o.balance.textContent=Vt.formatCoinValue(c,i);var l=Cn().fiatRatesMap[n.id];l&&(Vt.show(o.fiat),o.fiat.textContent=Vt.formatFiatConversion(c,l,i))}else Vt.show(o.noWallet)}},{key:"setSelectedAsset",value:function(e){var t,n=Wr(this.page.assetSelect.children);try{for(n.s();!(t=n.n()).done;)t.value.classList.remove("selected")}catch(e){n.e(e)}finally{n.f()}this.assetButtons[e].bttn.classList.add("selected"),this.selectedAssetID=e,this.updateDisplayedAsset(e),this.showAvailableMarkets(e),this.showRecentActivity(e)}},{key:"updateDisplayedAsset",value:function(e){if(e===this.selectedAssetID){var t,n=Cn().assets[e],r=n.symbol,a=n.wallet,o=n.name,s=this.page,i=Wr(document.querySelectorAll("[data-asset-name]"));try{for(i.s();!(t=i.n()).done;)t.value.textContent=o}catch(e){i.e(e)}finally{i.f()}if(s.assetLogo.src=Vt.logoPath(r),Vt.hide(s.balanceBox,s.fiatBalanceBox,s.createWalletBox,s.walletDetails,s.sendReceive,s.connectBttnBox,s.statusLocked,s.statusReady,s.statusOff,s.unlockBttnBox,s.lockBttnBox,s.connectBttnBox,s.peerCountBox,s.syncProgressBox,s.statusDisabled),a){this.updateDisplayedAssetBalance();var c=Cn().walletDefinition(e,a.type);s.walletType.textContent=c.tab;var l=function(e){var t=Cn().assets[e];if(t.token){var n=t.token.definition.configopts;return n&&n.length>0}if(!t.info)throw Error("this asset isn't an asset, I guess");var r=t.info.availablewallets,a=r[0].configopts;return r.length>1||a&&a.length>0}(e);Vt.setVis(l,s.passwordWrapper),a.disabled?Vt.show(s.statusDisabled):a.running?(Vt.show(s.sendReceive,s.peerCountBox,s.syncProgressBox),s.peerCount.textContent=String(a.peerCount),s.syncProgress.textContent="".concat((100*a.syncProgress).toFixed(1),"%"),a.open?(Vt.show(s.statusReady),!Cn().haveActiveOrders(e)&&a.encrypted&&Vt.show(s.lockBttnBox)):Vt.show(s.statusLocked,s.unlockBttnBox)):Vt.show(s.statusOff,s.connectBttnBox)}else Vt.show(s.createWalletBox);s.walletDetailsBox.classList.remove("invisible")}}},{key:"updateDisplayedAssetBalance",value:function(){var e=this.page,t=Cn().assets[this.selectedAssetID],n=t.wallet,a=t.unitInfo,o=t.symbol,s=t.id,i=n.balance;Vt.show(e.balanceBox,e.walletDetails);var c=i.locked+i.contractlocked+i.bondlocked,l=i.available+c+i.immature;e.balance.textContent=Vt.formatCoinValue(l,a),Vt.empty(e.balanceUnit),e.balanceUnit.appendChild(Vt.symbolize(o));var u=Cn().fiatRatesMap[s];u&&(Vt.show(e.fiatBalanceBox),e.fiatBalance.textContent=Vt.formatFiatConversion(l,u,a));var h=!1;Vt.empty(e.balanceDetailBox);var d=function(t,n){var r=e.balanceDetailRow.cloneNode(!0);h&&(r.classList.add("first-other"),h=!1),e.balanceDetailBox.appendChild(r);var o=Vt.parseTemplate(r);o.category.textContent=t,o.subBalance.textContent=Vt.formatCoinValue(n,a)};d("Available",i.available),d("Locked",c),d("Immature",i.immature);var p=Object.entries(i.other||{});p.sort((function(e,t){return e[0].localeCompare(t[0])})),h=!0,i.contractlocked>0&&d("Swapping (locked)",i.contractlocked),i.bondlocked>0&&d("Bonded (locked)",i.bondlocked);for(var f=0,m=p;f1){Vt.empty(r.changeWalletTypeSelect),Vt.show(r.showChangeType,r.changeTypeShowIcon),r.changeTypeMsg.textContent=Rt(fe),i=Wr(s);try{for(i.s();!(c=i.n()).done;)l=c.value,u=document.createElement("option"),l.type===o.type&&(u.selected=!0),u.value=u.textContent=l.type,r.changeWalletTypeSelect.appendChild(u)}catch(e){i.e(e)}finally{i.f()}}else Vt.hide(r.showChangeType);return h=Cn().walletMap[t],Vt.setVis(4&h.traits,r.downloadLogs),Vt.setVis(32&h.traits,r.recoverWallet),Vt.setVis(256&h.traits,r.exportWallet),Vt.setVis(1&h.traits,r.rescanWallet),Vt.setVis(2048&h.traits,r.managePeers),Vt.setVis(0&h.traits,r.otherActionsLabel),h.disabled?Vt.show(r.enableWallet):Vt.show(r.disableWallet),r.recfgAssetLogo.src=Vt.logoPath(a.symbol),r.recfgAssetName.textContent=a.name,n||this.showForm(r.reconfigForm),d=Cn().loading(r.reconfigForm),e.next=24,yn("/api/walletsettings",{assetID:t});case 24:if(p=e.sent,d(),Cn().checkResponse(p)){e.next=29;break}return Vt.showFormError(r.reconfigErr,p.msg),e.abrupt("return");case 29:f=Cn().haveActiveOrders(t),this.reconfigForm.update(o.configopts||[],f),this.setGuideLink(o.guidelink),this.reconfigForm.setConfig(p.map),this.updateDisplayedReconfigFields(o);case 34:case"end":return e.stop()}}),e,this)}))),function(e,t){return C.apply(this,arguments)})},{key:"changeWalletType",value:function(){var e=this.page.changeWalletTypeSelect.value||"",t=Cn().walletDefinition(this.selectedAssetID,e);this.reconfigForm.update(t.configopts||[],!1),this.setGuideLink(t.guidelink),this.updateDisplayedReconfigFields(t)}},{key:"setGuideLink",value:function(e){Vt.hide(this.walletCfgGuide),""!==e&&(this.walletCfgGuide.href=e,Vt.show(this.walletCfgGuide))}},{key:"updateDisplayedReconfigFields",value:function(e){e.seeded||"token"===e.type?(Vt.hide(this.page.showChangePW,this.reconfigForm.fileSelector),this.changeWalletPW=!1,this.setPWSettingViz(!1)):Vt.show(this.page.showChangePW,this.reconfigForm.fileSelector)}},{key:"showDeposit",value:(b=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.depositAddrForm.setAsset(t),this.showForm(this.page.deposit);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"showSendForm",value:(y=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u,h,d,p,f,m,v,g;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.page,r=n.sendForm,a=Cn().assets[t],o=a.wallet,s=a.name,i=a.unitInfo,c=a.symbol,l=a.token,Vt.hide(n.toggleSubtract),n.subtractCheckBox.checked=!1,(u=0!=(64&o.traits))&&Vt.show(n.toggleSubtract),Vt.hide(n.validAddr,n.sendErr,n.maxSendDisplay),n.sendAddr.classList.remove("invalid"),n.sendAddr.value="",n.sendAmt.value="",this.showFiatValue(t,0,n.sendValue),n.walletBal.textContent=Vt.formatFullPrecision(o.balance.available,i),n.sendLogo.src=Vt.logoPath(c),n.sendName.textContent=s,!(o.balance.available>0&&0!=(1024&o.traits))){e.next=23;break}return h={assetID:t,subtract:u,value:o.balance.available},d=Cn().loading(this.body),e.next=20,yn("/api/txfee",h);case 20:p=e.sent,d(),Cn().checkResponse(p)&&(f=o.balance.available,l||(f-=p.txfee)<0&&(f=0),this.maxSend=f,n.maxSend.textContent=Vt.formatFullPrecision(f,i),this.showFiatValue(t,f,n.maxSendFiat),l?(m=Cn().assets[l.parentID],v=m.unitInfo,g=m.symbol,n.maxSendFee.textContent=Vt.formatFullPrecision(p.txfee,v)+" "+g,this.showFiatValue(l.parentID,p.txfee,n.maxSendFeeFiat)):(n.maxSendFee.textContent=Vt.formatFullPrecision(p.txfee,i),this.showFiatValue(t,p.txfee,n.maxSendFeeFiat)),Vt.show(n.maxSendDisplay));case 23:this.showFiatValue(t,0,n.sendValue),n.walletBal.textContent=Vt.formatFullPrecision(o.balance.available,i),n.sendLogo.src=Vt.logoPath(o.symbol),n.sendName.textContent=s,r.dataset.assetID=String(t),this.showForm(r);case 29:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"doConnect",value:(g=o(w().mark((function e(t){var n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Cn().loading(this.body),e.next=3,yn("/api/connectwallet",{assetID:t});case 3:r=e.sent,n(),Cn().checkResponse(r)||(a=Cn().assets[t].symbol,(o=this.page).errorModalMsg.textContent=Rt(wt,{assetName:a,errMsg:r.msg}),this.showForm(o.errorModal)),this.updateDisplayedAsset(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"openWalletSuccess",value:(v=o(w().mark((function e(t,n){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.assetUpdated(t,n,Rt(Ce));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"assetUpdated",value:function(e,t,n){e===this.selectedAssetID&&(this.updateDisplayedAsset(e),t&&Object.is(this.currentForm,t)&&(n?this.showSuccess(n):this.closePopups()))}},{key:"populateMaxSend",value:(m=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,n=Cn().assets[this.selectedAssetID]){e.next=4;break}return e.abrupt("return");case 4:0==(64&n.wallet.traits)?(t.sendAmt.value=String(this.maxSend/n.unitInfo.conventional.conversionFactor),this.showFiatValue(n.id,this.maxSend,t.sendValue),t.subtractCheckBox.checked=!1):(r=n.wallet.balance.available,t.sendAmt.value=String(r/n.unitInfo.conventional.conversionFactor),this.showFiatValue(n.id,r,t.sendValue),t.subtractCheckBox.checked=!0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"send",value:(f=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this.page,o=parseInt(null!==(t=a.sendForm.dataset.assetID)&&void 0!==t?t:""),s=null!==(n=a.subtractCheckBox.checked)&&void 0!==n&&n,i=Cn().unitInfo(o).conventional.conversionFactor,c=a.vSendPw.value||"",a.vSendPw.value="",""!==c){e.next=9;break}return Vt.showFormError(a.vSendErr,Rt(k)),e.abrupt("return");case 9:return l={assetID:o,address:a.sendAddr.value,subtract:s,value:Math.round(parseFloat(null!==(r=a.sendAmt.value)&&void 0!==r?r:"")*i),pw:c},u=Cn().loading(a.vSendForm),e.next=13,yn("/api/send",l);case 13:if(h=e.sent,u(),Cn().checkResponse(h)){e.next=18;break}return Vt.showFormError(a.vSendErr,h.msg),e.abrupt("return");case 18:d=Cn().assets[o].name,this.assetUpdated(o,a.vSendForm,Rt(be,{assetName:d}));case 20:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"reconfig",value:(p=o(w().mark((function e(){var t,n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.page,r=this.selectedAssetID,Vt.hide(n.reconfigErr),n.appPW.value||tn.passwordIsCached()){e.next=6;break}return Vt.showFormError(n.reconfigErr,Rt(x)),e.abrupt("return");case 6:return a=Cn().currentWalletDefinition(r).type,Vt.isHidden(n.changeWalletType)||(a=n.changeWalletTypeSelect.value||""),o=Cn().loading(n.reconfigForm),s={assetID:r,config:this.reconfigForm.map(r),appPW:null!==(t=n.appPW.value)&&void 0!==t?t:"",walletType:a},this.changeWalletPW&&(s.newWalletPW=n.newPW.value),e.next=13,yn("/api/reconfigurewallet",s);case 13:if(i=e.sent,n.appPW.value="",n.newPW.value="",o(),Cn().checkResponse(i)){e.next=20;break}return Vt.showFormError(n.reconfigErr,i.msg),e.abrupt("return");case 20:this.assetUpdated(r,n.reconfigForm,Rt(we));case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"lock",value:(d=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=Cn().loading(n.newWalletForm),e.next=4,yn("/api/closewallet",{assetID:t});case 4:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=8;break}return e.abrupt("return");case 8:this.updateDisplayedAsset(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"downloadLogs",value:(l=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(t=new URLSearchParams("")).append("assetid","".concat(this.selectedAssetID)),(n=new URL(window.location.href)).search=t.toString(),n.pathname="/wallets/logfile",window.open(n.toString());case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"displayExportWalletAuth",value:(c=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,Vt.hide(t.exportWalletErr),t.exportWalletPW.value="",this.showForm(t.exportWalletAuth);case 4:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"exportWalletAuthSubmit",value:(i=o(w().mark((function e(){var t,n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n={assetID:this.selectedAssetID,pass:t.exportWalletPW.value},r=Cn().loading(t.forms),e.next=6,yn("/api/restorewalletinfo",n);case 6:a=e.sent,r(),Cn().checkResponse(a)?(t.exportWalletPW.value="",this.displayRestoreWalletInfo(a.restorationinfo)):Vt.showFormError(t.exportWalletErr,a.msg);case 9:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"displayRestoreWalletInfo",value:(a=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.page,Vt.empty(n.restoreInfoCardsList),r=Wr(t);try{for(r.s();!(a=r.n()).done;)o=a.value,s=this.restoreInfoCard.cloneNode(!0),(i=Vt.parseTemplate(s)).name.textContent=o.target,i.seed.textContent=o.seed,i.seedName.textContent="".concat(o.seedName,":"),i.instructions.textContent=o.instructions,n.restoreInfoCardsList.appendChild(s)}catch(e){r.e(e)}finally{r.f()}this.showForm(n.restoreWalletInfo);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"recoverWallet",value:(n=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.recoverWalletErr),n={assetID:this.selectedAssetID,appPW:t.recoverWalletPW.value},t.recoverWalletPW.value="",r="/api/recoverwallet",a=Cn().loading(t.forms),e.next=8,yn(r,n);case 8:o=e.sent,a(),o.code===cn.activeOrdersErr?(this.forceUrl=r,this.forceReq=n,this.showConfirmForce()):Cn().checkResponse(o)?this.closePopups():Vt.showFormError(t.recoverWalletErr,o.msg);case 11:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"confirmForceSubmit",value:(t=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,this.forceReq.force=!0,n=Cn().loading(t.forms),e.next=5,yn(this.forceUrl,this.forceReq);case 5:r=e.sent,n(),Cn().checkResponse(r)?this.closePopups():Vt.showFormError(t.confirmForceErr,r.msg);case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"handleBalanceNote",value:function(e){this.updateAssetButton(e.assetID),e.assetID===this.selectedAssetID&&this.updateDisplayedAssetBalance()}},{key:"handleRatesNote",value:function(e){this.updateAssetButton(this.selectedAssetID),e.fiatRates[this.selectedAssetID]&&this.updateDisplayedAssetBalance()}},{key:"showFiatValue",value:function(e,t,n){var r=Cn().fiatRatesMap[e];r?(n.textContent=Vt.formatFiatConversion(t,r,Cn().unitInfo(e)),Vt.show(n.parentElement)):Vt.hide(n.parentElement)}},{key:"handleWalletStateNote",value:function(e){this.updateAssetButton(e.wallet.assetID),this.assetUpdated(e.wallet.assetID),"WalletPeersUpdate"===e.topic&&e.wallet.assetID===this.selectedAssetID&&Vt.isDisplayed(this.page.managePeersForm)&&this.updateWalletPeersTable()}},{key:"handleCreateWalletNote",value:function(e){this.updateAssetButton(e.assetID),this.assetUpdated(e.assetID)}},{key:"unload",value:function(){Vt.unbind(document,"keyup",this.keyup)}}]),V}(mn),Ur=new Intl.NumberFormat(navigator.languages,{maximumSignificantDigits:4}),_r=new Intl.NumberFormat(navigator.languages,{minimumFractionDigits:1,maximumFractionDigits:1});function zr(e){return e>=1e3||Math.round(e)===e?_r.format(e):Ur.format(e)}function Vr(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var jr=["bonds"];var Hr=function(e){an(k,e);var t,n,r,a,i,c,l,d,p,f,m,v,g,y,b=(g=k,y=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(g);if(y){var n=sn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return on(this,e)});function k(e){var t;s(this,k),h(nn(t=b.call(this)),"body",void 0),h(nn(t),"currentDEX",void 0),h(nn(t),"page",void 0),h(nn(t),"forms",void 0),h(nn(t),"fiatRateSources",void 0),h(nn(t),"regAssetForm",void 0),h(nn(t),"confirmRegisterForm",void 0),h(nn(t),"newWalletForm",void 0),h(nn(t),"walletWaitForm",void 0),h(nn(t),"dexAddrForm",void 0),h(nn(t),"currentForm",void 0),h(nn(t),"pwCache",void 0),h(nn(t),"keyup",void 0),t.body=e;var n=t.page=Vt.idDescendants(e);t.forms=Vt.applySelector(n.forms,":scope > form"),t.fiatRateSources=Vt.applySelector(n.fiatRateSources,"input[type=checkbox]"),Vt.bind(n.darkMode,"click",(function(){tn.setCookie(tn.darkModeCK,n.darkMode.checked?"1":"0"),n.darkMode.checked?document.body.classList.add("dark"):document.body.classList.remove("dark")})),n.showPokes.checked="1"===tn.fetchLocal(tn.popupsLK),Vt.bind(n.showPokes,"click",(function(){var e=n.showPokes.checked||!1;tn.storeLocal(tn.popupsLK,e?"1":"0"),Cn().showPopups=e})),n.commitHash.textContent=Cn().commitHash.substring(0,7),Vt.bind(n.addADex,"click",(function(){t.dexAddrForm.refresh(),t.showForm(n.dexAddrForm)})),t.fiatRateSources.forEach((function(e){Vt.bind(e,"change",o(w().mark((function t(){var n;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,yn("/api/toggleratesource",{disable:!e.checked,source:e.value});case 2:return n=t.sent,Cn().checkResponse(n)||(e.checked=!e.checked),t.next=6,Cn().fetchUser();case 6:case"end":return t.stop()}}),t)}))))})),t.regAssetForm=new wr(n.regAssetForm,function(){var e=o(w().mark((function e(r){var a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.confirmRegisterForm.setAsset(r),a=Cn().assets[r],!(o=a.wallet)){e.next=15;break}return s=t.currentDEX.bondAssets[a.symbol],e.next=7,t.getBondsFeeBuffer(r,n.regAssetForm);case 7:if(i=e.sent,!(o.synced&&o.balance.available>=2*s.amount+i)){e.next=11;break}return t.animateConfirmForm(n.regAssetForm),e.abrupt("return");case 11:return t.walletWaitForm.setWallet(o,i),t.currentForm=n.walletWait,Dr(n.regAssetForm,n.walletWait),e.abrupt("return");case 15:t.newWalletForm.setAsset(r),t.currentForm=n.newWalletForm,Dr(n.regAssetForm,n.newWalletForm);case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),t.confirmRegisterForm=new br(n.confirmRegForm,(function(){t.registerDEXSuccess()}),(function(){t.animateRegAsset(n.confirmRegForm)}),t.pwCache),t.newWalletForm=new vr(n.newWalletForm,(function(e){return t.newWalletCreated(e)}),t.pwCache,(function(){return t.animateRegAsset(n.newWalletForm)})),t.walletWaitForm=new xr(n.walletWait,(function(){t.animateConfirmForm(n.walletWait)}),(function(){t.animateRegAsset(n.walletWait)})),t.dexAddrForm=new Er(n.dexAddrForm,function(){var e=o(w().mark((function e(r,a){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.currentDEX=r,t.confirmRegisterForm.setExchange(r,a),t.walletWaitForm.setExchange(r),t.regAssetForm.setExchange(r),t.animateRegAsset(n.dexAddrForm);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()),Vt.bind(n.importAccount,"click",(function(){return t.prepareAccountImport(n.authorizeAccountImportForm)})),Tr(n.authorizeAccountImportForm,n.authorizeImportAccountConfirm,(function(){return t.importAccount()})),Vt.bind(n.changeAppPW,"click",(function(){return t.showForm(n.changeAppPWForm)})),Tr(n.changeAppPWForm,n.submitNewPW,(function(){return t.changeAppPW()})),Vt.bind(n.accountFile,"change",(function(){return t.onAccountFileChange()})),Vt.bind(n.removeAccount,"click",(function(){return t.clearAccountFile()})),Vt.bind(n.addAccount,"click",(function(){return n.accountFile.click()})),Vt.bind(n.exportSeed,"click",(function(){return t.showForm(n.exportSeedAuth)})),Tr(n.exportSeedAuth,n.exportSeedSubmit,(function(){return t.submitExportSeedReq()}));var r=function(){Vt.hide(n.forms),n.exportSeedPW.value="",n.seedDiv.textContent=""};return Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||r()})),t.keyup=function(e){"Escape"===e.key&&r()},Vt.bind(document,"keyup",t.keyup),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){r()}))})),t}return u(k,[{key:"getBondsFeeBuffer",value:(v=o(w().mark((function e(t,n){var r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Cn().loading(n),e.next=3,yn("/api/bondsfeebuffer",{assetID:t});case 3:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=7;break}return e.abrupt("return",0);case 7:return e.abrupt("return",a.feeBuffer);case 8:case"end":return e.stop()}}),e)}))),function(e,t){return v.apply(this,arguments)})},{key:"newWalletCreated",value:(m=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:if(n=e.sent){e.next=5;break}return e.abrupt("return");case 5:return r=this.page,a=n.assets[t],o=a.wallet,s=this.currentDEX.bondAssets[a.symbol].amount,e.next=11,this.getBondsFeeBuffer(t,r.newWalletForm);case 11:if(i=e.sent,!(o.synced&&o.balance.available>=2*s+i)){e.next=16;break}return e.next=15,this.animateConfirmForm(r.newWalletForm);case 15:return e.abrupt("return");case 16:return this.walletWaitForm.setWallet(o,i),this.currentForm=r.walletWait,e.next=20,Dr(r.newWalletForm,r.walletWait);case 20:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"onAccountFileChange",value:(f=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,(n=t.accountFile.files)&&n.length){e.next=4;break}return e.abrupt("return");case 4:t.selectedAccount.textContent=n[0].name,Vt.show(t.removeAccount),Vt.hide(t.addAccount);case 7:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"clearAccountFile",value:function(){var e=this.page;e.accountFile.value="",e.selectedAccount.textContent=Rt(ie),Vt.hide(e.removeAccount),Vt.show(e.addAccount)}},{key:"prepareAccountImport",value:(p=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.page.importAccountErr.textContent="",this.showForm(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"importAccount",value:(d=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,n=t.importAccountAppPass.value,t.importAccountAppPass.value="",r="",!t.accountFile.value){e.next=12;break}if((a=t.accountFile.files)&&a.length){e.next=9;break}return console.error("importAccount: no file specified"),e.abrupt("return");case 9:return e.next=11,a[0].text();case 11:r=e.sent;case 12:e.prev=12,o=JSON.parse(r),e.next=21;break;case 16:return e.prev=16,e.t0=e.catch(12),t.importAccountErr.textContent=e.t0.message,Vt.show(t.importAccountErr),e.abrupt("return");case 21:if(void 0!==o){e.next=25;break}return t.importAccountErr.textContent=Rt(X),Vt.show(t.importAccountErr),e.abrupt("return");case 25:return i=(s=o).bonds,c=void 0===i?[]:i,l=Vr(s,jr),u={pw:n,account:l,bonds:c},h=Cn().loading(this.body),e.next=30,yn("/api/importaccount",u);case 30:if(d=e.sent,h(),Cn().checkResponse(d)){e.next=36;break}return t.importAccountErr.textContent=d.msg,Vt.show(t.importAccountErr),e.abrupt("return");case 36:return e.next=38,Cn().fetchUser();case 38:Vt.hide(t.forms),window.location.reload();case 40:case"end":return e.stop()}}),e,this,[[12,16]])}))),function(){return d.apply(this,arguments)})},{key:"submitExportSeedReq",value:(l=o(w().mark((function e(){var t,n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=t.exportSeedPW.value,r=Cn().loading(this.body),e.next=5,yn("/api/exportseed",{pass:n});case 5:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=11;break}return t.exportAccountErr.textContent=a.msg,Vt.show(t.exportSeedE),e.abrupt("return");case 11:t.exportSeedPW.value="",t.seedDiv.textContent=a.seed,this.showForm(t.authorizeSeedDisplay);case 14:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"showForm",value:(c=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.currentForm=t,this.forms.forEach((function(e){return Vt.hide(e)})),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(300,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"getCertFile",value:(i=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="",!this.dexAddrForm.page.certFile.value){e.next=7;break}if(!(n=this.dexAddrForm.page.certFile.files)||!n.length){e.next=7;break}return e.next=6,n[0].text();case 6:t=e.sent;case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"registerDEXSuccess",value:(a=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.forms),e.next=4,Cn().fetchUser();case 4:window.location.reload();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"changeAppPW",value:(r=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.changePWErrMsg),n=function(){t.appPW.value="",t.newAppPW.value="",t.confirmNewPW.value=""},t.appPW.value&&t.newAppPW.value&&t.confirmNewPW.value){e.next=8;break}return t.changePWErrMsg.textContent=Rt(x),Vt.show(t.changePWErrMsg),n(),e.abrupt("return");case 8:if(t.newAppPW.value===t.confirmNewPW.value){e.next=13;break}return t.changePWErrMsg.textContent=Rt(K),Vt.show(t.changePWErrMsg),n(),e.abrupt("return");case 13:return r=Cn().loading(t.changeAppPW),a={appPW:t.appPW.value,newAppPW:t.newAppPW.value},n(),e.next=18,yn("/api/changeapppass",a);case 18:if(o=e.sent,r(),Cn().checkResponse(o)){e.next=24;break}return t.changePWErrMsg.textContent=o.msg,Vt.show(t.changePWErrMsg),e.abrupt("return");case 24:Vt.hide(t.forms);case 25:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"unload",value:function(){Vt.unbind(document,"keyup",this.keyup)}},{key:"animateRegAsset",value:(n=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vt.hide(t),n=this.page.regAssetForm,this.currentForm=n,this.regAssetForm.animate(),Vt.show(n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"animateConfirmForm",value:(t=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.confirmRegisterForm.animate(),n=this.page.confirmRegForm,this.currentForm=n,Vt.hide(t),Vt.show(n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),k}(mn);function Gr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(!a.epoch)return a;n||(n=a)}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"bestGapBuy",value:function(){return this.bestGapOrder(this.buys)}},{key:"bestGapSell",value:function(){return this.bestGapOrder(this.sells)}}]),e}();function Xr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nthis.maxQlength-1;)this.queue.shift();this.queue.push([e,t])}}},{key:"close",value:function(e){window.log("ws","close, reason:",e,this.handlers),this.handlers={},this.connection&&this.connection.close()}},{key:"connect",value:function(e,t){var n=this;this.uri=e,this.reloader=t;var a=0;!function o(){window.log("ws","connecting to ".concat(e));var s=n.connection=new window.WebSocket(e);if(s){var i=setTimeout((function(){s&&s.close()}),500);s.onmessage=function(e){var t=JSON.parse(e.data);Qr(t.route,t.payload,n.handlers)},s.onclose=function(e){window.log("ws","onclose"),clearTimeout(i),s=n.connection=null,Qr("close",null,n.handlers),a++;var t=Math.min(Math.pow(1.25,a),10);console.error("websocket disconnected (".concat(e.code,"), trying again in ").concat(t.toFixed(1)," seconds")),setTimeout((function(){o()}),1e3*t)},s.onopen=function(){window.log("ws","onopen"),clearTimeout(i),a>0&&(a=0,t()),Qr("open",null,n.handlers);var e=n.queue;n.queue=[];var o,s=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Xr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}(e);try{for(s.s();!(o=s.n()).done;){var c=r(o.value,2),l=c[0],u=c[1];n.request(l,u)}}catch(e){s.e(e)}finally{s.f()}},s.onerror=function(e){window.log("ws","onerror:",e),Qr("error",e,n.handlers)}}}()}}]),e}());function Zr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $r(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function ta(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0}},{key:"setCurrMarketPrice",value:function(){var e=this.market;if(e){var t=Cn().exchanges[e.dex.host],n=t.markets[e.cfg.name];if(n.spot){var r,a=ea(this.stats);try{for(a.s();!(r=a.n()).done;){var o=r.value,s=t.assets[n.baseid].unitInfo.conventional.conversionFactor;o.tmpl.volume.textContent=Ia(n.spot.vol24/s),Ra(o.tmpl,t,n)}}catch(e){a.e(e)}finally{a.f()}this.page.obPrice.textContent=Vt.formatFullPrecision(n.spot.rate/this.market.rateConversionFactor),this.page.obPrice.classList.remove("sellcolor","buycolor"),this.page.obPrice.classList.add(n.spot.change24>=0?"buycolor":"sellcolor"),Vt.setVis(n.spot.change24>=0,this.page.obUp),Vt.setVis(n.spot.change24<0,this.page.obDown)}}}},{key:"setMarketDetails",value:function(){if(this.market){var e,t=ea(this.stats);try{for(t.s();!(e=t.n()).done;){var n=e.value;n.tmpl.baseIcon.src=Vt.logoPath(this.market.cfg.basesymbol),n.tmpl.quoteIcon.src=Vt.logoPath(this.market.cfg.quotesymbol),Vt.empty(n.tmpl.baseSymbol,n.tmpl.quoteSymbol),n.tmpl.baseSymbol.appendChild(Vt.symbolize(this.market.cfg.basesymbol)),n.tmpl.quoteSymbol.appendChild(Vt.symbolize(this.market.cfg.quotesymbol))}}catch(e){t.e(e)}finally{t.f()}}}},{key:"setHighLow",value:function(){var e=0,t=0,n=this.market.cfg.spot;if(n&&n.low24&&n.high24)e=n.high24,t=n.low24;else{var r,a=null===(r=this.market)||void 0===r?void 0:r.candleCaches[pa];if(!a){if(this.candleDur!==pa)return void this.requestCandles(pa);var o,s=ea(this.stats);try{for(s.s();!(o=s.n()).done;){var i=o.value;i.tmpl.high.textContent="-",i.tmpl.low.textContent="-"}}catch(e){s.e(e)}finally{s.f()}return}for(var c=(new Date).getTime()-864e5,l=a.candles.length-1;l>=0;l--){var u=a.candles[l];if(u.endStamp0&&u.lowRatee&&(e=u.highRate)}}var h,d=Cn().unitInfo(this.market.cfg.quoteid,this.market.dex).conventional.conversionFactor,p=ea(this.stats);try{for(p.s();!(h=p.n()).done;){var f=h.value;f.tmpl.high.textContent=e>0?Ia(e/d):"-",f.tmpl.low.textContent=t>0?Ia(t/d):"-"}}catch(e){p.e(e)}finally{p.f()}}},{key:"assetsAreSupported",value:function(){var e,t,n,r,a=this.market,o=a.base,s=a.quote,i=a.baseCfg,c=a.quoteCfg;if(!o||!s){var l=o?c.symbol:i.symbol;return{isSupported:!1,text:Rt(L,{asset:l.toUpperCase()})}}var u=o.token?null===(e=Cn().assets[o.token.parentID].info)||void 0===e?void 0:e.versions:null===(t=o.info)||void 0===t?void 0:t.versions,h=s.token?null===(n=Cn().assets[s.token.parentID].info)||void 0===n?void 0:n.versions:null===(r=s.info)||void 0===r?void 0:r.versions,d="";return u.includes(i.version)?h.includes(c.version)||(d=Rt(B,{asset:s.symbol.toUpperCase(),version:c.version+""})):d=Rt(B,{asset:o.symbol.toUpperCase(),version:i.version+""}),{isSupported:u.includes(i.version)&&h.includes(c.version),text:d}}},{key:"setOrderVisibility",value:function(){var e=this.page;this.isLimit()?(Vt.show(e.priceBox,e.tifBox,e.qtyBox,e.maxBox),Vt.hide(e.mktBuyBox),this.previewQuoteAmt(!0)):(Vt.hide(e.tifBox,e.maxBox,e.priceBox),this.isSell()?(Vt.hide(e.mktBuyBox),Vt.show(e.qtyBox),this.previewQuoteAmt(!0)):(Vt.show(e.mktBuyBox),Vt.hide(e.qtyBox),this.previewQuoteAmt(!1)))}},{key:"resolveOrderFormVisibility",value:function(){var e=this.page;if(Vt.hide(e.orderForm,e.orderTypeBttns),this.assetsAreSupported().isSupported&&!(this.market.dex.tier<1)){var t=this.market,n=t.base,r=t.quote;n&&Cn().assets[n.id].wallet&&r&&Cn().assets[r.id].wallet&&Vt.show(e.orderForm,e.orderTypeBttns)}}},{key:"setLoaderMsgVisibility",value:function(){var e=this.page,t=this.assetsAreSupported(),n=t.isSupported,r=t.text;n?Vt.hide(e.loaderMsg):(e.loaderMsg.textContent=r,Vt.show(e.loaderMsg),Vt.hide(e.notRegistered),Vt.hide(e.noWallet))}},{key:"setRegistrationStatusView",value:function(e,t,n){var r=this.page;r.regStatusTitle.textContent=e,r.regStatusConfsDisplay.textContent=t,r.registrationStatus.classList.remove("completed","error","waiting"),r.registrationStatus.classList.add(n)}},{key:"updateRegistrationStatusView",value:function(){var e=this.page,t=this.market.dex;if(e.regStatusDex.textContent=t.host,t.tier>=1)this.setRegistrationStatusView(Rt(ce),"","completed");else{var n=Object.values(t.pendingBonds).map((function(e){var n=t.bondAssets[e.symbol].confs;return"".concat(e.confs," / ").concat(n)})).join(", ");this.setRegistrationStatusView(Rt(se),n,"waiting")}}},{key:"setRegistrationStatusVisibility",value:function(){var e=this,t=this.page,n=this.market;if(n&&n.dex&&n.dex.connectionStatus===ln.Connected)if(this.updateRegistrationStatusView(),n.dex.tier>=1){var r=function(){Vt.hide(t.registrationStatus,t.bondRequired),e.resolveOrderFormVisibility()};if(Vt.isHidden(t.orderForm))return void setTimeout(r,5e3);r()}else n.dex.viewOnly?(t.unregisteredDex.textContent=n.dex.host,Vt.show(t.notRegistered)):this.hasPendingBonds()?Vt.show(t.registrationStatus):(t.acctTier.textContent="".concat(n.dex.tier),t.dexSettingsLink.href="/dexsettings/".concat(n.dex.host),Vt.show(t.bondRequired))}},{key:"setOrderBttnText",value:function(){this.isSell()?this.page.submitBttn.textContent=Rt(S,{asset:Vt.shortSymbol(this.market.baseCfg.symbol)}):this.page.submitBttn.textContent=Rt(C,{asset:Vt.shortSymbol(this.market.baseCfg.symbol)})}},{key:"setCandleDurBttns",value:function(){var e=this,t=this.page,n=this.market;Vt.empty(t.durBttnBox);var r,a=ea(n.dex.candleDurs);try{var o=function(){var n=r.value,a=t.durBttnTemplate.cloneNode(!0);a.textContent=n,Vt.bind(a,"click",(function(){return e.candleDurationSelected(n)})),t.durBttnBox.appendChild(a)};for(a.s();!(r=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}this.loadCandles()}},{key:"setMarket",value:(x=o(w().mark((function e(t,n,r){var a,o,s,i,c,l,u,h,d,p,f,m,v,g;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Cn().user.exchanges[t],(o=this.page).lotField.value="",o.qtyField.value="",o.rateField.value="",Vt.hide(o.notRegistered,o.bondRequired,o.noWallet),a&&a.markets&&a.connectionStatus===ln.Connected){e.next=10;break}return o.chartErrMsg.textContent=Rt(M),Vt.show(o.chartErrMsg),e.abrupt("return");case 10:s=ea(this.stats);try{for(s.s();!(i=s.n()).done;)c=i.value,Vt.show(c.row)}catch(e){s.e(e)}finally{s.f()}l=a.assets[n],u=a.assets[r],h=[Cn().unitInfo(n,a),Cn().unitInfo(r,a)],p=h[1],f=Pn/(d=h[0]).conventional.conversionFactor*p.conventional.conversionFactor,Vt.hide(o.maxOrd,o.chartErrMsg),this.maxEstimateTimer&&(window.clearTimeout(this.maxEstimateTimer),this.maxEstimateTimer=null),m=ka(l.symbol,u.symbol),v=Cn().assets[n],g=Cn().assets[r],this.market={dex:a,sid:m,cfg:a.markets[m],base:v,quote:g,baseUnitInfo:d,quoteUnitInfo:p,maxSell:null,maxBuys:{},maxSellRequested:!1,candleCaches:{},baseCfg:l,quoteCfg:u,rateConversionFactor:f,sellBalance:0,buyBalance:0},Vt.setVis(!(v&&g&&v.wallet&&g.wallet),o.noWallet),this.setMarketDetails(),this.setCurrMarketPrice(),this.refreshRecentMatchesTable(),Jr.request("loadmarket",wa(t,n,r)),this.setLoaderMsgVisibility(),this.setRegistrationStatusVisibility(),this.resolveOrderFormVisibility(),this.setOrderBttnText(),this.setCandleDurBttns(),this.previewQuoteAmt(!1);case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return x.apply(this,arguments)})},{key:"reportDepthClick",value:function(e){this.page.rateField.value=String(e),this.rateFieldChanged()}},{key:"reportDepthVolume",value:function(e){var t=this.page,n=this.market,r=n.baseUnitInfo,a=n.quoteUnitInfo;t.sellBookedBase.textContent=Vt.formatCoinValue(e.sellBase*r.conventional.conversionFactor,r),t.sellBookedQuote.textContent=Vt.formatCoinValue(e.sellQuote*a.conventional.conversionFactor,a),t.buyBookedBase.textContent=Vt.formatCoinValue(e.buyBase*r.conventional.conversionFactor,r),t.buyBookedQuote.textContent=Vt.formatCoinValue(e.buyQuote*a.conventional.conversionFactor,a)}},{key:"reportDepthMouse",value:function(e){for(;this.hovers.length;)this.hovers.shift().classList.remove("hover");var t=this.page;if(e){Vt.show(t.hoverData,t.depthHoverData);for(var n=0,r=Object.values(this.metaOrders);n-1&&(o.classList.add("hover"),this.hovers.push(o))}t.hoverPrice.textContent=Vt.formatCoinValue(e.rate),t.hoverVolume.textContent=Vt.formatCoinValue(e.depth),t.hoverVolume.style.color=e.dotColor}else Vt.hide(t.hoverData,t.depthHoverData)}},{key:"reportDepthZoom",value:function(e){tn.storeLocal(tn.depthZoomLK,e)}},{key:"reportMouseCandle",value:function(e){var t=this.page;e?(Vt.show(t.hoverData,t.candleHoverData),t.candleStart.textContent=Vt.formatCoinValue(e.startRate/this.market.rateConversionFactor),t.candleEnd.textContent=Vt.formatCoinValue(e.endRate/this.market.rateConversionFactor),t.candleHigh.textContent=Vt.formatCoinValue(e.highRate/this.market.rateConversionFactor),t.candleLow.textContent=Vt.formatCoinValue(e.lowRate/this.market.rateConversionFactor),t.candleVol.textContent=Vt.formatCoinValue(e.matchVolume,this.market.baseUnitInfo)):Vt.hide(t.hoverData,t.candleHoverData)}},{key:"parseOrder",value:function(){var e=this.page,t=e.qtyField,n=this.isLimit(),r=this.isSell(),a=this.market,o=a.baseUnitInfo.conventional.conversionFactor;return n||r||(t=e.mktBuyField,o=a.quoteUnitInfo.conventional.conversionFactor),{host:a.dex.host,isLimit:n,sell:r,base:a.base.id,quote:a.quote.id,qty:xa(t.value||"",o),rate:xa(e.rateField.value||"",a.rateConversionFactor),tifnow:e.tifNow.checked||!1,options:{}}}},{key:"previewQuoteAmt",value:function(e){var t=this.page;if(this.market.base&&this.market.quote){var n=this.parseOrder(),r=this.adjustedRate();if(t.orderErr.textContent="",r&&(n.sell?this.preSell():this.preBuy()),this.depthLines.input=[],r&&this.isLimit()&&(this.depthLines.input=[{rate:n.rate/this.market.rateConversionFactor,color:n.sell?this.depthChart.theme.sellLine:this.depthChart.theme.buyLine}]),this.drawChartLines(),!e||!r||!n.qty)return t.orderPreview.textContent="",void this.drawChartLines();var a=Cn().assets[n.quote],o=n.qty*n.rate/Pn,s=Vt.formatCoinValue(o,this.market.quoteUnitInfo);t.orderPreview.textContent=Rt(W,{total:s,asset:a.symbol.toUpperCase()}),this.isSell()?this.preSell():this.preBuy()}}},{key:"preSell",value:function(){var e=this,t=this.market,n=Cn().assets[t.base.id].wallet;n.balance.available0&&this.book.add(u),this.addTableOrder(u)}}catch(e){l.e(e)}finally{l.f()}if(!this.book)return this.depthChart.clear(),Vt.empty(this.page.buyRows),void Vt.empty(this.page.sellRows);Vt.show(this.page.epochLine),this.loadingAnimations.depth&&this.loadingAnimations.depth.stop(),this.depthChart.canvas.classList.remove("invisible"),this.depthChart.set(this.book,r.lotsize,r.ratestep,a,o),this.recentMatches=null!==(t=e.book.recentMatches)&&void 0!==t?t:[],this.refreshRecentMatchesTable()}},{key:"midGapConventional",value:function(){var e=this.midGap();if(!e)return e;var t=this.market,n=t.baseUnitInfo,r=t.quoteUnitInfo;return e*n.conventional.conversionFactor/r.conventional.conversionFactor}},{key:"midGap",value:function(){var e=this.book;if(e)return e.buys&&e.buys.length?e.sells&&e.sells.length?(e.buys[0].msgRate+e.sells[0].msgRate)/2/Pn:e.buys[0].msgRate/Pn:e.sells&&e.sells.length?e.sells[0].msgRate/Pn:null}},{key:"setMarketBuyOrderEstimate",value:function(){var e=this.market,t=e.cfg.lotsize,n=Cn().user.exchanges[e.dex.host].markets[e.sid].buybuffer,r=this.midGapConventional();r&&(this.page.minMktBuy.textContent=Vt.formatCoinValue(t*n*r,e.baseUnitInfo))}},{key:"refreshActiveOrders",value:function(){var e=this,t=this.page,n=this.metaOrders,r=this.market;for(var a in n)delete n[a];var o=Cn().orders(r.dex.host,ka(r.baseCfg.symbol,r.quoteCfg.symbol));o.sort((function(e,t){return t.submitTime-e.submitTime})),Vt.empty(t.userOrders),Vt.setVis(null==o?void 0:o.length,t.userOrders),Vt.setVis(!(null!=o&&o.length),t.userNoOrders);var s,i=!1,c=ea(o);try{var l=function(){var r=s.value,a=t.userOrderTmpl.cloneNode(!0);t.userOrders.appendChild(a);var o=Vt.tmplElement(a,"header"),c=Vt.parseTemplate(o),l=Vt.tmplElement(a,"details"),u=Vt.parseTemplate(l),h={div:a,header:c,details:u,ord:r};r.id&&(n[r.id]=h),r.readyToTick||(o.classList.add("unready-user-order"),i=!0),c.sideLight.classList.add(r.sell?"sell":"buy"),u.side.textContent=c.side.textContent=Ln(r),u.side.classList.add(r.sell?"sellcolor":"buycolor"),c.side.classList.add(r.sell?"sellcolor":"buycolor"),u.qty.textContent=c.qty.textContent=Ia(r.qty/e.market.baseUnitInfo.conventional.conversionFactor),u.rate.textContent=c.rate.textContent=Ia(r.rate/e.market.rateConversionFactor),c.baseSymbol.textContent=r.baseSymbol.toUpperCase(),u.type.textContent=Bn(r),e.updateMetaOrder(h),Vt.bind(a,"mouseenter",(function(){e.activeMarkerRate=r.rate,e.setDepthMarkers()})),r.id?(1===r.type&&1===r.tif&&r.status<3&&(Vt.show(u.cancelBttn),na(u.cancelBttn,"click",(function(t){t.stopPropagation(),e.showCancel(a,r.id)}))),na(u.accelerateBttn,"click",(function(t){t.stopPropagation(),e.showAccelerate(r)})),Cn().canAccelerateOrder(r)&&Vt.show(u.accelerateBttn),u.link.href="order/".concat(r.id),Cn().bindInternalNavigation(a)):(Vt.hide(u.accelerateBttn),Vt.hide(u.cancelBttn),Vt.hide(u.link)),Vt.bind(o,"click",(function(){if(Vt.isDisplayed(l))return Vt.hide(l),c.expander.classList.add("ico-arrowdown"),void c.expander.classList.remove("ico-arrowup");Vt.show(l),c.expander.classList.remove("ico-arrowdown"),c.expander.classList.add("ico-arrowup")})),Cn().bindTooltips(a)};for(c.s();!(s=c.n()).done;)l()}catch(e){c.e(e)}finally{c.f()}Vt.setVis(i,t.unreadyOrdersMsg),this.setDepthMarkers()}},{key:"updateMetaOrder",value:function(e){var t=e.header,n=e.details,r=e.ord;r.status<=2||Wn(r)?t.activeLight.classList.add("active"):t.activeLight.classList.remove("active"),n.status.textContent=t.status.textContent=qn(r),n.age.textContent=Vt.timeSince(r.submitTime),n.filled.textContent="".concat((Nn(r)/r.qty*100).toFixed(1),"%"),n.settled.textContent="".concat((Un(r)/r.qty*100).toFixed(1),"%")}},{key:"setDepthMarkers",value:function(){for(var e={buys:[],sells:[]},t=this.market.rateConversionFactor,n=0,r=Object.values(this.metaOrders);n0&&this.book.add(t),this.addTableOrder(t),this.updateTitle(),this.depthChart.draw()}}},{key:"handleUnbookOrderRoute",value:function(e){if(Cn().log("book","handleUnbookOrderRoute:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){var t=e.payload;this.book.remove(t.token),this.removeTableOrder(t),this.updateTitle(),this.depthChart.draw()}}},{key:"handleUpdateRemainingRoute",value:function(e){if(Cn().log("book","handleUpdateRemainingRoute:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){var t=e.payload;this.book.updateRemaining(t.token,t.qty,t.qtyAtomic),this.updateTableOrder(t),this.depthChart.draw()}}},{key:"handleEpochOrderRoute",value:function(e){if(Cn().log("book","handleEpochOrderRoute:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){var t=e.payload;t.msgRate>0&&this.book.add(t),t.qtyAtomic>0&&this.addTableOrder(t),this.depthChart.draw()}}},{key:"handleCandlesRoute",value:function(e){if(this.candlesLoading&&(clearTimeout(this.candlesLoading.timer),this.candlesLoading.loaded(),this.candlesLoading=null),e.host===this.market.dex.host&&e.marketID===this.market.cfg.name){var t=e.payload.dur;this.market.candleCaches[t]=e.payload,this.setHighLow(),this.candleDur===t&&(this.loadingAnimations.candles&&this.loadingAnimations.candles.stop(),this.candleChart.canvas.classList.remove("invisible"),this.candleChart.setCandles(e.payload,this.market.cfg,this.market.baseUnitInfo,this.market.quoteUnitInfo))}}},{key:"handleEpochMatchSummary",value:function(e){this.addRecentMatches(e.payload),this.refreshRecentMatchesTable()}},{key:"handleCandleUpdateRoute",value:function(e){if(e.host===this.market.dex.host){var t=e.payload,n=t.dur,r=t.candle,a=this.market.candleCaches[n];if(a){var o=a.candles;0===o.length?o.push(r):o[o.length-1].startStamp===r.startStamp?o[o.length-1]=r:o.push(r),this.candleDur===n&&this.candleChart.draw()}}}},{key:"showForm",value:(k=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentForm=t,n=this.page,Vt.hide.apply(Vt,xn(Array.from(n.forms.children))),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(500,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"showOpen",value:(b=o(w().mark((function e(t,n){var r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this.page,this.openAsset=t,this.openFunc=n,this.unlockForm.refresh(Cn().assets[t.id]),this.showForm(r.unlockWalletForm),r.uwAppPass.focus();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"showToggleWalletStatus",value:function(e){var t=this.page;this.openAsset=e,Vt.hide(t.toggleWalletStatusErr,t.walletStatusDisable,t.disableWalletMsg),Vt.show(t.walletStatusEnable,t.enableWalletMsg),this.showForm(t.toggleWalletStatusConfirm)}},{key:"toggleWalletStatus",value:(y=o(w().mark((function e(){var t,n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,Vt.hide(t.toggleWalletStatusErr),n={assetID:this.openAsset.id,disable:!1},r=Cn().loading(t.toggleWalletStatusConfirm),e.next=7,yn("/api/togglewalletstatus",n);case 7:if(a=e.sent,r(),Cn().checkResponse(a)){e.next=13;break}return t.toggleWalletStatusErr.textContent=a.msg,Vt.show(t.toggleWalletStatusErr),e.abrupt("return");case 13:Vt.hide(this.page.forms),this.balanceWgt.updateAsset(this.openAsset.id);case 15:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"showVerify",value:function(){this.preorderCache={};var e,t=this.page,n=this.currentOrder=this.parseOrder(),r=n.sell,a=Cn().assets[n.base],o=Cn().assets[n.quote],s=r?o:a,i=r?a:o,c=function(e){switch(e.dataset.icon){case"from":if(i.token){var t=Cn().assets[i.token.parentID];e.src=Vt.logoPath(t.symbol)}else e.src=Vt.logoPath(i.symbol);break;case"to":if(s.token){var n=Cn().assets[s.token.parentID];e.src=Vt.logoPath(n.symbol)}else e.src=Vt.logoPath(s.symbol)}},l=ea(Vt.applySelector(t.vDetailPane,"[data-icon]"));try{for(l.s();!(e=l.n()).done;)c(e.value)}catch(e){l.e(e)}finally{l.f()}var u,h=ea(Vt.applySelector(t.vFeeSummary,"[data-icon]"));try{for(h.s();!(u=h.n()).done;)c(u.value)}catch(e){h.e(e)}finally{h.f()}Vt.hide(t.vUnlockPreorder,t.vPreorderErr),Vt.show(t.vPreorder),t.vBuySell.textContent=Rt(r?Se:Ee);var d=Rt(r?P:T);if(t.vSideSubmit.textContent=d,t.vOrderHost.textContent=n.host,n.isLimit){Vt.show(t.verifyLimit),Vt.hide(t.verifyMarket);var p="Limit ".concat(d," Order");t.vOrderType.textContent=n.tifnow?p+" (immediate)":p,t.vRate.textContent=Vt.formatCoinValue(n.rate/this.market.rateConversionFactor),t.vQty.textContent=Vt.formatCoinValue(n.qty,a.unitInfo);var f=n.rate/Pn*n.qty;t.vTotal.textContent=Vt.formatCoinValue(f,o.unitInfo),this.showFiatValue(o.id,f,t.vFiatTotal)}else{Vt.hide(t.verifyLimit),Vt.show(t.verifyMarket),t.vOrderType.textContent="Market ".concat(d," Order");var m=n.sell?this.market.baseUnitInfo:this.market.quoteUnitInfo;t.vmFromTotal.textContent=Vt.formatCoinValue(n.qty,m),t.vmFromAsset.textContent=i.symbol.toUpperCase(),this.showFiatValue(i.id,n.qty,t.vmFromTotalFiat);var v=this.midGap();if(v){Vt.show(t.vMarketEstimate);var g=n.sell?n.qty*v:n.qty/v;t.vmToTotal.textContent=Vt.formatCoinValue(g,s.unitInfo),t.vmToAsset.textContent=s.symbol.toUpperCase(),this.showFiatValue(s.id,g,t.vmTotalFiat)}else Vt.hide(t.vMarketEstimate)}r?(t.vHeader.classList.add(da),t.vHeader.classList.remove(ha),t.vSubmit.classList.add(da),t.vSubmit.classList.remove(ha)):(t.vHeader.classList.add(ha),t.vHeader.classList.remove(da),t.vSubmit.classList.add(ha),t.vSubmit.classList.remove(da)),this.showVerifyForm(),t.vPass.focus(),a.wallet.open&&o.wallet.open?this.preOrder(n):(Vt.hide(t.vPreorder),tn.passwordIsCached()?this.unlockWalletsForEstimates(""):Vt.show(t.vUnlockPreorder))}},{key:"showFiatValue",value:function(e,t,n){if(n){var r=Cn().fiatRatesMap[e];n.textContent=Vt.formatFiatConversion(t,r,Cn().unitInfo(e)),r?Vt.show(n.parentElement):Vt.hide(n.parentElement)}}},{key:"showVerifyForm",value:(g=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.page,Vt.hide(t.vErr),this.showForm(t.verifyForm);case 3:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"submitEstimateUnlock",value:(v=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page.vUnlockPass.value||"",e.next=3,this.unlockWalletsForEstimates(t);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"unlockWalletsForEstimates",value:(m=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=Cn().loading(n.verifyForm),e.next=4,this.attemptWalletUnlock(t);case 4:if(a=e.sent,r(),!a){e.next=8;break}return e.abrupt("return",this.setPreorderErr(a));case 8:Vt.show(n.vPreorder),Vt.hide(n.vUnlockPreorder),this.preOrder(this.parseOrder());case 11:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"attemptWalletUnlock",value:(f=o(w().mark((function e(t){var n,r,a,o,s,i,c,l,u;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.market,r=n.base,a=n.quote,o=[],r.wallet.open||o.push(r.id),a.wallet.open||o.push(a.id),s={pass:t,assetID:-1},i=0,c=o;case 6:if(!(i0?E/x:E,F=e.estimate.realisticBestCase/A*100;r.vSwapFeesLowPct.textContent=x<=0?"":"(".concat(c(F),"%)"),r.vSwapFeesLow.textContent=Vt.formatCoinValue(e.estimate.realisticBestCase,w);var I=e.estimate.realisticWorstCase/A*100;r.vSwapFeesHighPct.textContent=x<=0?"":"(".concat(c(I),"%)"),r.vSwapFeesHigh.textContent=Vt.formatCoinValue(e.estimate.realisticWorstCase,w);var R=e.estimate.maxFees/A*100;r.vSwapFeesMaxPct.textContent=x<=0?"":"(".concat(c(R),"%)"),r.vSwapFeesMax.textContent=Vt.formatCoinValue(e.estimate.maxFees,w);var D=this.midGap()||n.rate/i,O=n.sell?E*D:E/D,T=k>0?O/k:O,P=t.estimate.realisticBestCase/T*100;r.vRedeemFeesLowPct.textContent=k<=0?"":"(".concat(c(P),"%)"),r.vRedeemFeesLow.textContent=Vt.formatCoinValue(t.estimate.realisticBestCase,b);var L=t.estimate.realisticWorstCase/T*100;r.vRedeemFeesHighPct.textContent=k<=0?"":"(".concat(c(L),"%)"),r.vRedeemFeesHigh.textContent=Vt.formatCoinValue(t.estimate.realisticWorstCase,b),l&&u?(Vt.show(r.vFeeSummaryPct),Vt.hide(r.vFeeSummary),r.vFeeSummaryLow.textContent=c(F+P),r.vFeeSummaryHigh.textContent=c(I+L)):(Vt.hide(r.vFeeSummaryPct),Vt.show(r.vFeeSummary),r.summarySwapFeesLow.textContent=r.vSwapFeesLow.textContent,r.summarySwapFeesHigh.textContent=r.vSwapFeesHigh.textContent,r.summaryRedeemFeesLow.textContent=r.vRedeemFeesLow.textContent,r.summaryRedeemFeesHigh.textContent=r.vRedeemFeesHigh.textContent)}else Vt.hide(r.vPreorderEstimates)}},{key:"submitCancel",value:(l=o(w().mark((function e(){var t,n,r,a,o,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=this.cancelData,r=n.order,a={orderID:r.id,pw:t.cancelPass.value},t.cancelPass.value="",o=Cn().loading(t.cancelSubmit),e.next=8,yn("/api/cancel",a);case 8:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=14;break}return t.cancelErr.textContent=s.msg,Vt.show(t.cancelErr),e.abrupt("return");case 14:Vt.hide(n.bttn,t.forms),r.cancelling=!0;case 16:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"showCancel",value:function(e,t){var n=this.metaOrders[t].ord,r=this.page,a=n.qty-n.filled,o=Mn(n)?this.market.quote:this.market.base;r.cancelRemain.textContent=Vt.formatCoinValue(a,o.unitInfo),r.cancelUnit.textContent=o.symbol.toUpperCase(),Vt.hide(r.cancelErr),this.showForm(r.cancelForm),r.cancelPass.focus(),this.cancelData={bttn:Vt.tmplElement(e,"cancelBttn"),order:n}}},{key:"showAccelerate",value:function(e){var t=Cn().loading(this.main);this.accelerateOrderForm.refresh(e),t(),this.showForm(this.page.accelerateForm)}},{key:"showCreate",value:function(e){var t=this.page;this.currentCreate=e,this.newWalletForm.setAsset(e.id),this.showForm(t.newWalletForm)}},{key:"stepSubmit",value:function(){var e=this.page,t=this.market;if(Vt.hide(e.orderErr),this.validateOrder(this.parseOrder())){var n=Cn().walletMap[t.base.id],r=Cn().walletMap[t.quote.id];return n?r?void this.showVerify():(e.orderErr.textContent=Rt(V,{asset:t.quote.symbol}),void Vt.show(e.orderErr)):(e.orderErr.textContent=Rt(V,{asset:t.base.symbol}),void Vt.show(e.orderErr))}}},{key:"showDeposit",value:(c=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.depositAddrForm.setAsset(t),this.showForm(this.page.deposit);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"handlePriceUpdate",value:function(e){e.host===this.market.dex.host&&e.spots[this.market.cfg.name]&&this.setCurrMarketPrice(),this.marketList.updateSpots(e)}},{key:"handleBondUpdate",value:(i=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.dex)===this.market.dex.host){e.next=3;break}return e.abrupt("return");case 3:if("AccountRegistered"!==t.topic){e.next=6;break}return e.next=6,Cn().fetchUser();case 6:this.market.dex=Cn().exchanges[n],this.setRegistrationStatusVisibility();case 8:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"handleMatchNote",value:function(e){var t=this.metaOrders[e.orderID];if(!t)return this.refreshActiveOrders();Cn().canAccelerateOrder(t.ord)?Vt.show(t.details.accelerateBttn):Vt.hide(t.details.accelerateBttn)}},{key:"handleOrderNote",value:function(e){var t=e.order,n=this.metaOrders[t.id];if(!n||"AsyncOrderFailure"===e.topic||"OrderLoaded"===e.topic&&t.readyToTick)return this.refreshActiveOrders();var r=n.status;n.ord=t,"MissedCancel"===e.topic&&Vt.show(n.details.cancelBttn),t.filled===t.qty&&Vt.hide(n.details.cancelBttn),Cn().canAccelerateOrder(t)?Vt.show(n.details.accelerateBttn):Vt.hide(n.details.accelerateBttn),this.updateMetaOrder(n),(1===r&&2===t.status||2===r&&t.status>2)&&this.setDepthMarkers()}},{key:"handleEpochNote",value:function(e){if(Cn().log("book","handleEpochNote:",e),e.host===this.market.dex.host&&e.marketID===this.market.sid){this.book&&(this.book.setEpoch(e.epoch),this.depthChart.draw()),this.clearOrderTableEpochs();for(var t=0,n=Object.values(this.metaOrders);ta.epoch;switch(!0){case 1===a.type&&1===a.status&&i:var c=0===a.tif?Rt(j):Rt(H);o.status.textContent=s.status.textContent=c,a.status=0===a.tif?3:2;break;case 2===a.type&&1===a.status:o.status.textContent=s.status.textContent=Rt(j),a.status=3}}}}},{key:"recentMatchesSortCompare",value:function(){var e=this;switch(this.recentMatchesSortKey){case"rate":return function(t,n){return e.recentMatchesSortDirection*(t.rate-n.rate)};case"qty":return function(t,n){return e.recentMatchesSortDirection*(t.qty-n.qty)};case"age":return function(t,n){return e.recentMatchesSortDirection*(t.stamp-n.stamp)}}}},{key:"refreshRecentMatchesTable",value:function(){var e=this.page,t=this.recentMatches;if(Vt.empty(e.recentMatchesLiveList),t){var n=this.recentMatchesSortCompare();t.sort(n);var r,a=ea(t);try{for(a.s();!(r=a.n()).done;){var o=r.value,s=e.recentMatchesTemplate.cloneNode(!0),i=Vt.parseTemplate(s);Cn().bindTooltips(s),i.rate.textContent=Vt.formatCoinValue(o.rate/this.market.rateConversionFactor),i.qty.textContent=Vt.formatCoinValue(o.qty,this.market.baseUnitInfo),i.age.textContent=Vt.timeSince(o.stamp),i.age.dataset.sinceStamp=String(o.stamp),s.classList.add(o.sell?"sellcolor":"buycolor"),e.recentMatchesLiveList.append(s)}}catch(e){a.e(e)}finally{a.f()}}}},{key:"addRecentMatches",value:function(e){this.recentMatches=[].concat(xn(e),xn(this.recentMatches)).slice(0,100)}},{key:"setBalanceVisibility",value:function(){var e=this.market;e&&e.dex&&this.balanceWgt.setBalanceVisibility(e.dex.connectionStatus===ln.Connected)}},{key:"handleBalanceNote",value:function(e){this.setBalanceVisibility(),this.preorderCache={};var t=this.market;if(t&&t.dex&&t.dex.connectionStatus===ln.Connected){var n=e.balance.available;switch(e.assetID){case t.baseCfg.id:if(!t.maxSell)break;"number"==typeof t.sellBalance&&t.sellBalance!==n&&(t.maxSell=null),this.isSell()&&this.preSell();break;case t.quoteCfg.id:if(!Object.keys(t.maxBuys).length)break;"number"==typeof t.buyBalance&&t.buyBalance!==n&&(t.maxBuys={}),this.isSell()||this.preBuy()}}}},{key:"submitOrder",value:(a=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.page,Vt.hide(t.orderErr,t.vErr),n=this.currentOrder,r=t.vPass.value,t.vPass.value="",a={order:Sa(n),pw:r},this.validateOrder(n)){e.next=8;break}return e.abrupt("return");case 8:return t.vSubmit.classList.add("d-hide"),t.vLoader.classList.remove("d-hide"),e.next=12,yn("/api/tradeasync",a);case 12:if(o=e.sent,t.vSubmit.classList.remove("d-hide"),t.vLoader.classList.add("d-hide"),Cn().checkResponse(o)){e.next=19;break}return t.vErr.textContent=o.msg,Vt.show(t.vErr),e.abrupt("return");case 19:Vt.hide(t.forms),this.refreshActiveOrders();case 21:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"createWallet",value:(r=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Cn().fetchUser();case 2:if(t=e.sent){e.next=5;break}return e.abrupt("return");case 5:n=t.assets[this.currentCreate.id],Vt.hide(this.page.forms),this.balanceWgt.updateAsset(n.id),Vt.setVis(!(this.market.base.wallet&&this.market.quote.wallet),this.page.noWallet),this.resolveOrderFormVisibility();case 10:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"walletUnlocked",value:(n=o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Vt.hide(this.page.forms),this.balanceWgt.updateAsset(this.openAsset.id);case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"lotChanged",value:function(){var e=this.page,t=parseInt(e.lotField.value||"0");if(t<=0)return e.lotField.value="0",e.qtyField.value="",void this.previewQuoteAmt(!1);var n=this.market.cfg.lotsize;e.lotField.value=String(t),e.qtyField.value=String(t*n/this.market.baseUnitInfo.conventional.conversionFactor),this.previewQuoteAmt(!0)}},{key:"quantityChanged",value:function(e){var t=this.page,n=this.parseOrder();if(n.qty<0)return t.lotField.value="0",t.qtyField.value="",void this.previewQuoteAmt(!1);var r=this.market.cfg.lotsize,a=Math.floor(n.qty/r),o=a*r;t.lotField.value=String(a),(n.isLimit||n.sell)&&(e&&(t.qtyField.value=String(o/this.market.baseUnitInfo.conventional.conversionFactor)),this.previewQuoteAmt(!0))}},{key:"marketBuyChanged",value:function(){var e=this.page,t=xa(e.mktBuyField.value||"",this.market.quoteUnitInfo.conventional.conversionFactor),n=this.midGap();if(!n||!t)return e.mktBuyLots.textContent="0",void(e.mktBuyScore.textContent="0");var r=this.market.cfg.lotsize,a=t/n;e.mktBuyLots.textContent=(a/r).toFixed(1),e.mktBuyScore.textContent=Vt.formatCoinValue(a,this.market.baseUnitInfo)}},{key:"rateFieldChanged",value:function(){var e=this.adjustedRate();if(e<=0)return this.depthLines.input=[],this.drawChartLines(),void(this.page.rateField.value="0");var t=this.parseOrder(),n=e/this.market.rateConversionFactor;this.page.rateField.value=String(n),this.depthLines.input=[{rate:n,color:t.sell?this.depthChart.theme.sellLine:this.depthChart.theme.buyLine}],this.drawChartLines(),this.previewQuoteAmt(!0)}},{key:"adjustedRate",value:function(){var e=this.page.rateField.value;if(!e)return NaN;var t=xa(e,this.market.rateConversionFactor);return t-t%this.market.cfg.ratestep}},{key:"loadTable",value:function(){this.loadTableSide(!0),this.loadTableSide(!1)}},{key:"binOrdersByRateAndEpoch",value:function(e){if(!e||!e.length)return[];var t=[],n=[],r=[],a=e[0].msgRate;e[0].epoch?n.push(e[0]):r.push(e[0]);for(var o=1;o0}))}},{key:"loadTableSide",value:function(e){var t=this,n=e?this.book.sells:this.book.buys,r=e?this.page.sellRows:this.page.buyRows;Vt.empty(r),n&&n.length&&this.binOrdersByRateAndEpoch(n).forEach((function(e){r.appendChild(t.orderTableRow(e))}))}},{key:"addTableOrder",value:function(e){var t=e.sell?this.page.sellRows:this.page.buyRows,n=t.firstChild;if(0!==e.rate){for(n&&0===n.manager.getRate()&&(n=n.nextSibling);n;){if(0===n.manager.compare(e))return void n.manager.insertOrder(e);if(n.manager.compare(e)>0){var r=this.orderTableRow([e]);return void t.insertBefore(r,n)}n=n.nextSibling}var a=this.orderTableRow([e]);t.appendChild(a)}else{if(0===e.qtyAtomic)return;n&&0===n.manager.getRate()?n.manager.insertOrder(e):(n=this.orderTableRow([e]),t.insertBefore(n,t.firstChild))}}},{key:"removeTableOrder",value:function(e){for(var t=e.token,n=0,r=[this.page.sellRows,this.page.buyRows];n36e5&&!i.disabled?(Vt.show(n.expired),i.running&&Cn().fetchBalance(o)):Vt.hide(n.expired)}else Vt.show(n.connect)}else Vt.show(n.unsupported)}}},{key:"updateParent",value:function(e){var t,n=Cn().assets[e.parentID],r=n.wallet.balance,a=n.unitInfo;null!==(t=e.parentBal)&&void 0!==t&&t.firstChild&&(e.parentBal.firstChild.textContent=Vt.formatCoinValue(r.available,a))}},{key:"updateAsset",value:function(e){e===this.base.id?this.updateWallet(this.base):e===this.quote.id&&this.updateWallet(this.quote),e===this.base.parentID&&this.updateParent(this.base),e===this.quote.parentID&&this.updateParent(this.quote)}}]),e}();function wa(e,t,n){return{host:e,base:t,quote:n}}function ka(e,t){return"".concat(e,"_").concat(t)}function xa(e,t){return e?Math.round(parseFloat(e)*t):0}function Ca(e,t){e.classList.remove("selected"),t.classList.add("selected")}function Sa(e){for(var t={},n=0,a=Object.entries(e.options);n1?(r.removeAttribute("hidden"),r.innerText=String(t),r.title="quantity is comprised of ".concat(t," orders")):r.setAttribute("hidden","true")}},{key:"insertOrder",value:function(e){this.orderBin.push(e),this.updateQtyNumOrdersEl()}},{key:"updateOrderQty",value:function(e){for(var t=e.token,n=e.qty,r=e.qtyAtomic,a=0;ae.msgRate===e.sell?1:-1:this.isEpoch()?1:-1}}]),e}(),Aa=new Intl.NumberFormat(navigator.languages,{maximumSignificantDigits:4}),Fa=new Intl.NumberFormat(navigator.languages,{minimumFractionDigits:1,maximumFractionDigits:1});function Ia(e){return e>=1e3||Math.round(e)===e?Fa.format(e):Aa.format(e)}function Ra(e,t,n){if(n.spot){e.price.textContent=Ia(Cn().conventionalRate(n.baseid,n.quoteid,n.spot.rate,t));var r=n.spot.change24>0?"+":"";e.change.classList.remove("buycolor","sellcolor"),e.change.classList.add(n.spot.change24>=0?"buycolor":"sellcolor"),e.change.textContent="".concat(r).concat((100*n.spot.change24).toFixed(1),"%")}}var Da=[.5,1/4,3/4,1/8,5/8,3/8,7/8];function Oa(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Ta(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ta(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Ta(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&(e.checked=!0)}))}};o(n.hostFilter,"hosts"),o(n.assetFilter,"assets"),o(n.statusFilter,"statuses");var i=[],c=function(e,n){var a=e.querySelector(".apply-bttn");i.push(a),Vt.bind(a,"click",(function(){t.submitFilter(),i.forEach((function(e){return Vt.hide(e)}))})),e.querySelectorAll("input").forEach((function(t){Vt.bind(t,"change",(function(){!function(e,t){if(e.length!==t.length)return!1;var n,r=Oa(e);try{for(r.s();!(n=r.n()).done;){var a=n.value;if(-1===t.indexOf(a))return!1}}catch(e){r.e(e)}finally{r.f()}return!0}(za(e),r[n])?Vt.show(a):Vt.hide(a)}))}))};return c(n.hostFilter,"hosts"),c(n.assetFilter,"assets"),c(n.statusFilter,"statuses"),Vt.bind(t.main,"scroll",(function(){t.loading||n.ordersTable.offsetHeight-t.main.offsetHeight-t.main.scrollTop<0&&t.nextPage()})),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){Vt.hide(n.forms)}))})),Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||Vt.hide(n.forms)})),Vt.bind(n.exportOrders,"click",(function(){t.exportOrders()})),n.showArchivedDateField.addEventListener("change",(function(){n.showArchivedDateField.checked?Vt.show(n.archivedDateField):Vt.hide(n.archivedDateField,n.deleteArchivedRecordsErr)})),Vt.bind(n.deleteArchivedRecords,"click",(function(){var e=t.page;e.showArchivedDateField.checked=!1,e.saveMatchesToFile.checked=!1,e.saveOrdersToFile.checked=!1,e.deleteArchivedRecordsErr.textContent="",e.archivedRecordsLocation.textContent="",e.deleteArchivedRecordsMsg.textContent="",Vt.hide(e.deleteArchivedResult,e.deleteArchivedRecordsErr,e.deleteArchivedRecordsMsg,e.archivedRecordsLocation,e.archivedDateField),t.showForm(e.deleteArchivedRecordsForm)})),Vt.bind(n.deleteArchivedRecordsSubmit,"click",(function(){var e=0;n.showArchivedDateField.checked&&(e=Date.parse(n.olderThan.value||""),isNaN(e)||e<=0)?Vt.showFormError(n.deleteArchivedRecordsErr,Rt(qe)):t.deleteArchivedRecords(e)})),t.submitFilter(),t}return u(p,[{key:"showForm",value:(i=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentForm=t,n=this.page,Vt.hide(n.deleteArchivedRecordsForm),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(500,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0px";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setOrders",value:function(e){Vt.empty(this.page.tableBody),this.appendOrders(e)}},{key:"appendOrders",value:function(e){var t,n=this,r=this.page.tableBody,a=Oa(e);try{var o=function(){var e,a,o,s=t.value,i=n.orderTmpl.cloneNode(!0),c=function(e,t){Vt.tmplElement(i,e).textContent=t},l="".concat(s.baseSymbol.toUpperCase(),"-").concat(s.quoteSymbol.toUpperCase());c("host","".concat(l," @ ").concat(s.host));var u="",h=[Cn().unitInfo(s.baseID),Cn().unitInfo(s.quoteID)],d=h[0],p=h[1];if(s.sell){var f=[s.baseSymbol,s.quoteSymbol];e=f[0],a=f[1],o=Vt.formatCoinValue(s.qty,d),1===s.type&&(u=Vt.formatCoinValue(s.qty/Pn*s.rate,p))}else{var m=[s.quoteSymbol,s.baseSymbol];e=m[0],a=m[1],2===s.type?o=Vt.formatCoinValue(s.qty,d):(o=Vt.formatCoinValue(s.qty/Pn*s.rate,p),u=Vt.formatCoinValue(s.qty,d))}c("fromQty",o),Vt.tmplElement(i,"fromLogo").src=Vt.logoPath(e),c("fromSymbol",e),c("toQty",u),Vt.tmplElement(i,"toLogo").src=Vt.logoPath(a),c("toSymbol",a),c("type","".concat(Bn(s)," ").concat(Ln(s))),c("rate",Vt.formatCoinValue(Cn().conventionalRate(s.baseID,s.quoteID,s.rate))),c("status",qn(s)),c("filled","".concat((Nn(s)/s.qty*100).toFixed(1),"%")),c("settled","".concat((Un(s)/s.qty*100).toFixed(1),"%"));var v=new Date(s.submitTime).toLocaleString();c("time","".concat(Vt.timeSince(s.submitTime)," ago, ").concat(v)),Vt.tmplElement(i,"link").href="order/".concat(s.id),Cn().bindInternalNavigation(i),r.appendChild(i)};for(a.s();!(t=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}50===e.length?this.offset=e[e.length-1].id:this.offset=""}},{key:"submitFilter",value:(a=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,this.offset="",(n=this.filterState).hosts=za(t.hostFilter),n.assets=za(t.assetFilter).map((function(e){return parseInt(e)})),n.statuses=za(t.statusFilter).map((function(e){return parseInt(e)})),e.t0=this,e.next=9,this.fetchOrders();case 9:e.t1=e.sent,e.t0.setOrders.call(e.t0,e.t1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"fetchOrders",value:(r=o(w().mark((function e(){var t,n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Cn().loading(this.main),e.next=3,yn("/api/orders",this.currentFilter());case 3:return n=e.sent,t(),e.abrupt("return",n.orders);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"exportOrders",value:function(){this.offset="";var e=this.currentFilter(),t=new URL(window.location.href),n=new URLSearchParams(""),r=function(t){e[t].forEach((function(e){n.append(t,e)}))};r("hosts"),r("assets"),r("statuses"),t.search=n.toString(),t.pathname="/orders/export",window.open(t.toString())}},{key:"deleteArchivedRecords",value:(n=o(w().mark((function e(t){var n,r,a,o,s,i;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,r=n.saveMatchesToFile.checked||!1,a=n.saveOrdersToFile.checked||!1,o={olderThanMs:t,saveMatchesToFile:r,saveOrdersToFile:a},s=Cn().loading(this.main),e.next=7,yn("/api/deletearchivedrecords",o);case 7:if(i=e.sent,s(),Cn().checkResponse(i)){e.next=11;break}return e.abrupt("return",Vt.showFormError(n.deleteArchivedRecordsErr,i.msg));case 11:i.archivedRecordsDeleted>0?(n.deleteArchivedRecordsMsg.textContent=Rt(Ue,{nRecords:i.archivedRecordsDeleted}),(r||a)&&(n.archivedRecordsLocation.textContent=Rt(_e,{path:i.archivedRecordsPath}),Vt.show(n.archivedRecordsLocation)),this.submitFilter()):n.deleteArchivedRecordsMsg.textContent=Rt(Ne),Vt.show(n.deleteArchivedResult,n.deleteArchivedRecordsMsg);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"currentFilter",value:function(){var e=this.filterState;return{hosts:e.hosts,assets:e.assets.map((function(e){return parseInt(e)})),statuses:e.statuses.map((function(e){return parseInt(e)})),n:50,offset:this.offset}}},{key:"nextPage",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==this.offset&&!this.loading){e.next=2;break}return e.abrupt("return");case 2:return this.loading=!0,Vt.show(this.page.orderLoader),e.next=6,this.fetchOrders();case 6:t=e.sent,this.loading=!1,Vt.hide(this.page.orderLoader),this.appendOrders(t);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),p}(mn);function za(e){var t=[];return e.querySelectorAll("input").forEach((function(e){e.checked&&t.push(e.value)})),t}function Va(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return ja(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ja(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function ja(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=3}(t)||t.revoked||t.refund?!function(e){return e.status<5&&1===e.side&&e.status>=4}(t)||t.revoked||t.refund?Vt.hide(n.makerSwapMsg,n.takerSwapMsg,n.makerRedeemMsg,n.takerRedeemMsg):(n.takerRedeemMsg.textContent=Xa(t.redeem),Vt.hide(n.makerSwapMsg,n.takerSwapMsg,n.makerRedeemMsg),Vt.show(n.takerRedeemMsg)):(n.makerRedeemMsg.textContent=Xa(t.redeem),Vt.hide(n.makerSwapMsg,n.takerSwapMsg,n.takerRedeemMsg),Vt.show(n.makerRedeemMsg));else{var a=Ya(t);n.takerSwapMsg.textContent=Xa(a),Vt.hide(n.makerSwapMsg,n.makerRedeemMsg,n.takerRedeemMsg),Vt.show(n.takerSwapMsg)}else{var o=Qa(t);n.makerSwapMsg.textContent=Xa(o),Vt.hide(n.takerSwapMsg,n.makerRedeemMsg,n.takerRedeemMsg),Vt.show(n.makerSwapMsg)}Vt.setVis(!t.isCancel&&(Qa(t)||!t.revoked),n.makerSwap),Vt.setVis(!t.isCancel&&(Ya(t)||!t.revoked),n.takerSwap),Vt.setVis(!t.isCancel&&(Ja(t)||!t.revoked),n.makerRedeem),Vt.setVis(!t.isCancel&&(Za(t)||!t.revoked&&t.active||1===t.side&&t.active&&(t.counterRedeem||!t.refund)),n.takerRedeem),Vt.setVis(!t.isCancel&&(t.refund||t.revoked&&t.active&&!t.counterRedeem),n.refund)}}},{key:"addNewMatchCard",value:function(e){var t=this.page,n=t.matchCardTmpl.cloneNode(!0);n.dataset.matchID=e.matchID,this.setImmutableMatchCardElements(n,e),this.setMutableMatchCardElements(n,e),t.matchBox.appendChild(n)}},{key:"showMatchCards",value:function(){var e=this,t=this.order;t&&t.matches&&(t.matches.sort((function(e,t){return e.stamp-t.stamp})),t.matches.forEach((function(t){return e.addNewMatchCard(t)})))}},{key:"showCancel",value:function(){var e=this.order,t=this.page,n=e.qty-e.filled,r=Mn(e)?Cn().assets[e.quoteID]:Cn().assets[e.baseID];t.cancelRemain.textContent=Vt.formatCoinValue(n,r.unitInfo),t.cancelUnit.textContent=r.unitInfo.conventional.unit.toUpperCase(),this.showForm(t.cancelForm)}},{key:"showForm",value:(r=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentForm=t,n=this.page,Vt.hide(n.cancelForm,n.accelerateForm),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(500,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0px";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"submitCancel",value:(n=o(w().mark((function e(){var t,n,r,a,o;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=this.order,r={orderID:n.id,pw:t.cancelPass.value},t.cancelPass.value="",a=Cn().loading(t.cancelForm),e.next=7,yn("/api/cancel",r);case 7:if(o=e.sent,a(),Cn().checkResponse(o)){e.next=11;break}return e.abrupt("return");case 11:t.status.textContent=Rt(G),Vt.hide(t.forms),n.cancelling=!0;case 14:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setAccelerationButtonVis",value:function(){var e=this.order;if(e){var t=this.page;Vt.setVis(Cn().canAccelerateOrder(e),t.accelerateBttn,t.actionsLabel)}}},{key:"showAccelerateForm",value:(t=o(w().mark((function e(){var t;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Cn().loading(this.page.accelerateBttn),this.accelerateOrderForm.refresh(this.order),t(),this.showForm(this.page.accelerateForm);case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"handleOrderNote",value:function(e){var t=this.page,n=e.order;if(n.id===this.orderID){this.order=n;var r=t.cancelBttn;r&&n.status>2&&Vt.hide(r),t.status.textContent=qn(n);var a,o=Va(n.matches||[]);try{for(o.s();!(a=o.n()).done;){var s=a.value;this.processMatch(s)}}catch(e){o.e(e)}finally{o.f()}this.setAccelerationButtonVis()}}},{key:"handleMatchNote",value:function(e){e.orderID===this.orderID&&(this.processMatch(e.match),this.setAccelerationButtonVis())}},{key:"processMatch",value:function(e){var t,n=null,r=Va(Vt.applySelector(this.page.matchBox,".match-card"));try{for(r.s();!(t=r.n()).done;){var a=t.value;if(a.dataset.matchID===e.matchID){n=a;break}}}catch(e){r.e(e)}finally{r.f()}n?this.setMutableMatchCardElements(n,e):this.addNewMatchCard(e)}}]),p}(mn);function Xa(e){return e.confs&&0!==e.confs.required?"".concat(e.confs.count," / ").concat(e.confs.required," ").concat(Rt(pt)):""}function Qa(e){return 0===e.side?e.swap:e.counterSwap}function Ya(e){return 0===e.side?e.counterSwap:e.swap}function Ja(e){return 0===e.side?e.redeem:e.counterRedeem}function Za(e){return 0===e.side?e.counterRedeem:e.redeem}function $a(e,t){var n=to[e];if(n){var r=n[Ha];r&&(t.classList.remove("plainlink"),t.classList.add("subtlelink"),t.href=r(t.dataset.explorerCoin||""))}}var eo=(h(Pa={},0,(function(e){if(e.startsWith(Ga)){var t=e.substring(Ga.length);return"https://etherscan.io/address/".concat(t)}return 42===e.length?"https://etherscan.io/address/".concat(e):"https://etherscan.io/tx/".concat(e)})),h(Pa,1,(function(e){if(e.startsWith(Ga)){var t=e.substring(Ga.length);return"https://goerli.etherscan.io/address/".concat(t)}return 42===e.length?"https://goerli.etherscan.io/address/".concat(e):"https://goerli.etherscan.io/tx/".concat(e)})),Pa),to={42:(La={},h(La,0,(function(e){var t=r(e.split(":"),2),n=t[0],a=t[1];return"https://explorer.dcrdata.org/tx/".concat(n,"/out/").concat(a)})),h(La,1,(function(e){var t=r(e.split(":"),2),n=t[0],a=t[1];return"https://testnet.dcrdata.org/tx/".concat(n,"/out/").concat(a)})),La),0:(Ba={},h(Ba,0,(function(e){return"https://mempool.space/tx/".concat(e.split(":")[0])})),h(Ba,1,(function(e){return"https://mempool.space/testnet/tx/".concat(e.split(":")[0])})),Ba),2:(Ma={},h(Ma,0,(function(e){return"https://ltc.bitaps.com/".concat(e.split(":")[0])})),h(Ma,1,(function(e){return"https://sochain.com/tx/LTCTEST/".concat(e.split(":")[0])})),Ma),20:(Wa={},h(Wa,0,(function(e){return"https://digiexplorer.info/tx/".concat(e.split(":")[0])})),h(Wa,1,(function(e){return"https://testnetexplorer.digibyteservers.io/tx/".concat(e.split(":")[0])})),Wa),60:eo,60001:eo,3:(qa={},h(qa,0,(function(e){return"https://dogeblocks.com/tx/".concat(e.split(":")[0])})),h(qa,1,(function(e){return"https://blockexplorer.one/dogecoin/testnet/tx/".concat(e.split(":")[0])})),qa),133:(Na={},h(Na,0,(function(e){return"https://zcashblockexplorer.com/transactions/".concat(e.split(":")[0])})),h(Na,1,(function(e){return"https://blockexplorer.one/zcash/testnet/tx/".concat(e.split(":")[0])})),Na),145:(Ua={},h(Ua,0,(function(e){return"https://bch.loping.net/tx/".concat(e.split(":")[0])})),h(Ua,1,(function(e){return"https://tbch4.loping.net/tx/".concat(e.split(":")[0])})),Ua)};var no=function(e){an(y,e);var t,n,a,i,c,l,d,p,f,m,v,g=(m=y,v=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=sn(m);if(v){var n=sn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return on(this,e)});function y(e){var t;s(this,y),h(nn(t=g.call(this)),"body",void 0),h(nn(t),"forms",void 0),h(nn(t),"currentForm",void 0),h(nn(t),"page",void 0),h(nn(t),"host",void 0),h(nn(t),"keyup",void 0),h(nn(t),"dexAddrForm",void 0),t.body=e,t.host=e.dataset.host?e.dataset.host:"";var n=t.page=Vt.idDescendants(e);t.forms=Vt.applySelector(n.forms,":scope > form"),Vt.bind(n.exportDexBtn,"click",(function(){return t.prepareAccountExport(n.authorizeAccountExportForm)})),Vt.bind(n.disableAcctBtn,"click",(function(){return t.prepareAccountDisable(n.disableAccountForm)})),Vt.bind(n.updateBondOptionsBtn,"click",(function(){return t.prepareUpdateBondOptions()})),Vt.bind(n.updateCertBtn,"click",(function(){return n.certFileInput.click()})),Vt.bind(n.updateHostBtn,"click",(function(){return t.prepareUpdateHost()})),Vt.bind(n.certFileInput,"change",(function(){return t.onCertFileChange()})),t.dexAddrForm=new Er(n.dexAddrForm,function(){var e=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:window.location.assign("/dexsettings/".concat(t.host));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),void 0,t.host),Tr(n.updateBondOptionsForm,n.updateBondOptionsConfirm,(function(){return t.updateBondOptions()})),Tr(n.authorizeAccountExportForm,n.authorizeExportAccountConfirm,(function(){return t.exportAccount()})),Tr(n.disableAccountForm,n.disableAccountConfirm,(function(){return t.disableAccount()}));var r=function(){Vt.hide(n.forms)};return Vt.bind(n.forms,"mousedown",(function(e){Vt.mouseInElement(e,t.currentForm)||r()})),t.keyup=function(e){"Escape"===e.key&&r()},Vt.bind(document,"keyup",t.keyup),n.forms.querySelectorAll(".form-closer").forEach((function(e){Vt.bind(e,"click",(function(){r()}))})),Cn().registerNoteFeeder({conn:function(){t.setConnectionStatus()}}),t.setConnectionStatus(),t}return u(y,[{key:"unload",value:function(){Vt.unbind(document,"keyup",this.keyup)}},{key:"showForm",value:(f=o(w().mark((function e(t){var n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.page,this.currentForm=t,this.forms.forEach((function(e){return Vt.hide(e)})),t.style.right="10000px",Vt.show(n.forms,t),r=(n.forms.offsetWidth+t.offsetWidth)/2,e.next=8,Vt.animate(300,(function(e){t.style.right="".concat((1-e)*r,"px")}),"easeOutHard");case 8:t.style.right="0";case 9:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"exportAccount",value:(p=o(w().mark((function e(){var t,n,r,a,o,s,i,c;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=t.exportAccountAppPass.value,r=t.exportAccountHost.textContent,t.exportAccountAppPass.value="",a={pw:n,host:r},o=Cn().loading(this.body),e.next=8,yn("/api/exportaccount",a);case 8:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=14;break}return t.exportAccountErr.textContent=s.msg,Vt.show(t.exportAccountErr),e.abrupt("return");case 14:s.account.bonds=s.bonds,i=JSON.parse(JSON.stringify(s.account)),(c=document.createElement("a")).setAttribute("download","dcrAccount-"+r+".json"),c.setAttribute("href","data:text/json,"+JSON.stringify(i,null,2)),c.click(),Vt.hide(t.forms);case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"disableAccount",value:(d=o(w().mark((function e(){var t,n,r,a,o,s;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.page,n=t.disableAccountAppPW.value,r=t.disableAccountHost.textContent,t.disableAccountAppPW.value="",a={pw:n,host:r},o=Cn().loading(this.body),e.next=8,yn("/api/disableaccount",a);case 8:if(s=e.sent,o(),Cn().checkResponse(s)){e.next=14;break}return t.disableAccountErr.textContent=s.msg,Vt.show(t.disableAccountErr),e.abrupt("return");case 14:Vt.hide(t.forms),window.location.assign("/settings");case 16:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"prepareAccountExport",value:(l=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.page).exportAccountHost.textContent=this.host,n.exportAccountErr.textContent="",tn.passwordIsCached()?this.exportAccount():this.showForm(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"prepareAccountDisable",value:(c=o(w().mark((function e(t){var n;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(n=this.page).disableAccountHost.textContent=this.host,n.disableAccountErr.textContent="",this.showForm(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"prepareUpdateBondOptions",value:(i=o(w().mark((function e(){var t,n,a,o,s,i,c,l;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=this.page,n=Cn().user.exchanges[this.host],t.bondTargetTier.setAttribute("placeholder",n.bondOptions.targetTier.toString()),Vt.empty(t.bondAssetSelect),a=0,o=Object.entries(n.bondAssets);a=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){throw e})),f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){i=!0,o=e})),f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function so(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0)this.fetchMaxBuy(Math.round(e.basisPrice/this.currentMarket.atomToConv*Pn)),t.basisPrice.textContent=Vt.formatFiveSigFigs(e.basisPrice),Vt.show(t.absMaxBox,t.basisPrice),Vt.hide(t.manualPriceInput,t.noFiatBox),this.page.gapFactorMax.textContent=Vt.formatFiveSigFigs(e.basisPrice);else{t.lotEstQuoteLots.textContent="[no rate]",t.basisPrice.textContent="must set manually",Vt.hide(t.basisPrice,t.absMaxBox),Vt.show(t.manualPriceInput),t.manualPriceInput.focus();var n=Cn().user;0===Object.keys(n.fiatRates).length&&Vt.show(t.noFiatBox)}e&&e.breakEvenSpread>0?(Vt.show(t.breakEvenGapBox),t.breakEvenGap.textContent=Vt.formatFiveSigFigs(e.breakEvenSpread)):Vt.hide(t.breakEvenGapBox)}},{key:"updateGapStrategyInputVisibility",value:function(){var e=this.page;switch(e.gapStrategySelect.value){case io:Vt.show(this.gapMultiplierOpt.node),Vt.hide(e.absInputBox,e.absMaxBox,this.gapPercentOpt.node);break;case uo:case ho:Vt.show(this.gapPercentOpt.node),Vt.hide(e.absInputBox,e.absMaxBox,this.gapMultiplierOpt.node);break;case co:case lo:Vt.hide(this.gapMultiplierOpt.node,this.gapPercentOpt.node),Vt.show(e.absInputBox,e.absMaxBox)}}},{key:"updateGapStrategyInputs",value:function(e){switch(this.updateGapStrategyInputVisibility(),this.page.gapStrategySelect.value){case io:e&&e.breakEvenSpread>0?(ko.start.y=e.breakEvenSpread,ko.end.y=100*e.breakEvenSpread,ko.yUnit=this.rateUnit()):(ko.start.y=100,ko.end.y=1e4,ko.yUnit="%"),this.gapMultiplierOpt.handler.setConfig(ko);break;case uo:case ho:e&&e.breakEvenSpread>0?(So.end.y=e.basisPrice,So.yUnit=this.rateUnit(),this.gapPercentOpt.handler.setConfig(So)):(So.end.y=10,So.yUnit="%")}}},{key:"setCurrentBasisPrice",value:function(e){if(e>0){var t=this.rateUnit();vo.start.y=-.01*e,vo.end.y=.01*e,vo.yUnit=t,yo.start.y=0,yo.end.y=.01*e,yo.yUnit=t}else vo.start.y=-1,vo.end.y=1,vo.yUnit="%",yo.start.y=0,yo.end.y=1,yo.yUnit="%";this.biasOpt.handler.setConfig(vo),this.driftToleranceOpt.handler.setConfig(yo)}},{key:"rateUnit",value:function(){var e=this.currentMarket.quotesymbol.split(".")[0],t=this.currentMarket.basesymbol.split(".")[0];return"".concat(e,"/").concat(t)}},{key:"setMarket",value:(c=o(w().mark((function e(t,n){var r,a,o,s,i,c,l,u,h,d,p,f,m,v;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.page,a=t[0],this.currentMarket=a,this.specifiedPrice=0,this.setCurrentReport(null),r.manualPriceInput.value="",tn.storeLocal(tn.lastMMMarketLK,a),Vt.empty(r.baseSelect,r.quoteSelect),r.baseSelect.appendChild(this.assetRow(a.basesymbol)),r.quoteSelect.appendChild(this.assetRow(a.quotesymbol)),this.hideAssetDropdown(),o=function(e,t){Vt.setContent(t,Vt.symbolize(e.basesymbol),new Text("-"),Vt.symbolize(e.quotesymbol),new Text(" @ "),new Text(e.host))},Vt.hide(r.marketSelect,r.marketOneChoice),1===t.length)Vt.show(r.marketOneChoice),o(a,r.marketOneChoice);else{Vt.show(r.marketSelect),Vt.empty(r.marketSelect),s=oo(t);try{for(s.s();!(i=s.n()).done;)c=i.value,l=document.createElement("option"),r.marketSelect.appendChild(l),l.value="".concat(c.host," ").concat(c.name),o(c,l)}catch(e){s.e(e)}finally{s.f()}}if(!n){e.next=16;break}return e.abrupt("return");case 16:if(Vt.setContent(r.lotEstBaseSymbol,Vt.symbolize(a.basesymbol)),Vt.setContent(r.lotEstQuoteSymbol,Vt.symbolize(a.quotesymbol)),u=function(e,t){Vt.show(t);var n=Vt.parseTemplate(t);return n.assetLogo.src=Vt.logoPath(e.symbol),n.assetName.textContent=e.name,!1},Vt.hide(r.lotEstQuoteBox,r.lotEstQuoteNoWallet,r.lotEstBaseBox,r.lotEstBaseNoWallet,r.availHeader,r.lotEstimateBox,r.marketInfo,r.oraclesBox,r.lotsBox,r.options,r.advancedBox),h=[Cn().assets[a.baseid],Cn().assets[a.quoteid]],p=h[1],!(d=h[0]).wallet||!p.wallet){e.next=35;break}return Vt.show(r.lotEstQuoteBox,r.lotEstBaseBox,r.availHeader,r.fetchingMarkets,r.lotsBox,r.advancedBox),tn.fetchLocal(tn.optionsExpansionLK)&&Vt.show(r.options),f=Cn().loading(r.options),m=this.fetchOracleAndMaxBuy(),v=this.fetchMaxSell(),e.next=29,m;case 29:return e.next=31,v;case 31:return f(),Vt.show(r.lotEstimateBox,r.marketInfo,r.oraclesBox),Vt.hide(r.fetchingMarkets),e.abrupt("return");case 35:Vt.show(r.lotEstimateBox),p.wallet?r.lotEstQuoteLots.textContent="0":u(p,r.lotEstQuoteNoWallet),d.wallet?r.lotEstBaseLots.textContent="0":u(d,r.lotEstBaseNoWallet);case 38:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"fetchMaxSell",value:(i=o(w().mark((function e(){var t,n,r;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.currentMarket,n=this.page,e.next=3,yn("/api/maxsell",{host:t.host,base:t.baseid,quote:t.quoteid});case 3:if(r=e.sent,this.currentMarket===t){e.next=6;break}return e.abrupt("return");case 6:if(Cn().checkResponse(r)){e.next=10;break}return n.lotEstBaseLots.textContent="0",console.error(r),e.abrupt("return");case 10:n.lotEstBaseLots.textContent=String(r.maxSell.swap.lots);case 11:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"fetchOracleAndMaxBuy",value:(a=o(w().mark((function e(){var t,n,r,a,o,s,i,c,l,u,h,d,p;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.currentMarket,r=this.page,e.next=3,yn("/api/marketreport",{host:n.host,baseID:n.baseid,quoteID:n.quoteid});case 3:if(a=e.sent,Cn().checkResponse(a)){e.next=8;break}return r.lotEstQuoteLots.textContent="0",console.error(a),e.abrupt("return");case 8:if(o=a.report,Vt.hide(r.manualPriceBttn),this.setCurrentReport(o),o.oracles&&0!==o.oracles.length){e.next=13;break}return e.abrupt("return");case 13:Vt.empty(r.oracles),s=0,i=0,c=oo(null!==(t=o.oracles)&&void 0!==t?t:[]);try{for(c.s();!(l=c.n()).done;)u=l.value,h=r.oracleTmpl.cloneNode(!0),r.oracles.appendChild(h),(d=Vt.parseTemplate(h)).logo.src="img/"+u.host+".png",d.host.textContent=Do[u.host],d.volume.textContent=Vt.formatThreeSigFigs(u.usdVol),p=(u.bestBuy+u.bestSell)/2,i+=u.usdVol*p,s+=u.usdVol,d.price.textContent=Vt.formatThreeSigFigs((u.bestBuy+u.bestSell)/2)}catch(e){c.e(e)}finally{c.f()}r.avgPrice.textContent=Vt.formatFiveSigFigs(i/s);case 19:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"fetchMaxBuy",value:(n=o(w().mark((function e(t){var n,r,a;return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.currentMarket,r=this.page,e.next=3,yn("/api/maxbuy",{host:n.host,base:n.baseid,quote:n.quoteid,rate:null!=t?t:0});case 3:if(a=e.sent,this.currentMarket===n){e.next=6;break}return e.abrupt("return");case 6:r.lotEstQuoteLots.textContent=String(a.maxBuy.swap.lots);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setEditProgram",value:function(e){var t=this,n=this.createOpts,r=this.page,a=e.program,o=[Cn().assets[a.baseID],Cn().assets[a.quoteID]],s=o[0],i=o[1],c=Cn().exchanges[a.host].markets["".concat(s.symbol,"_").concat(i.symbol)];this.setMarket([ao({host:a.host},c)],!0);for(var l=0,u=Object.values(this.programs);l0?(Vt.show(e.programsHeader),Vt.hide(e.noProgramsMessage)):(Vt.hide(e.programsHeader),Vt.show(e.noProgramsMessage))}},{key:"programDiv",value:function(e){var t=this,n=this.page.runningProgramTmpl.cloneNode(!0),r=Vt.parseTemplate(n),a=function(){var t=o(w().mark((function t(a,o){var s,i;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Vt.hide(r.startErr),s=Cn().loading(n),t.next=4,yn(a,{programID:e.programID,appPW:o});case 4:i=t.sent,s(),Cn().checkResponse(i)||(r.startErr.textContent=i.msg,Vt.show(r.startErr));case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}();Vt.bind(r.pauseBttn,"click",(function(){return a("/api/stopbot")})),Vt.bind(r.startBttn,"click",this.authedRoute(function(){var e=o(w().mark((function e(t){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a("/api/startbot",t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())),Vt.bind(r.retireBttn,"click",(function(){return a("/api/retirebot")})),Vt.bind(r.configureBttn,"click",(function(n){n.stopPropagation(),t.setEditProgram(t.programs[e.programID])}));var s=[Cn().assets[e.program.baseID],Cn().assets[e.program.quoteID]],i=s[0],c=s[1];return r.base.appendChild(this.assetRow(i.symbol)),r.quote.appendChild(this.assetRow(c.symbol)),r.baseSymbol.textContent=i.symbol.toUpperCase(),r.quoteSymbol.textContent=c.symbol.toUpperCase(),r.host.textContent=e.program.host,this.updateProgramDiv(r,e),this.programs[e.programID]=Object.assign({tmpl:r,div:n},e),n}},{key:"authedRoute",value:function(e){var t=this;return o(w().mark((function n(){return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!tn.passwordIsCached()){n.next=4;break}return n.next=3,e("");case 3:return n.abrupt("return",n.sent);case 4:return t.pwHandler=e,n.next=7,t.showForm(t.page.pwForm);case 7:case"end":return n.stop()}}),n)})))}},{key:"updateProgramDiv",value:function(e,t){var n=t.program;Vt.hide(e.programRunning,e.programPaused),t.running?Vt.show(e.programRunning):Vt.show(e.programPaused),e.lots.textContent=String(n.lots),e.boost.textContent="".concat((100*n.gapFactor).toFixed(1),"%"),e.driftTolerance.textContent="".concat((100*n.driftTolerance).toFixed(2),"%"),e.oracleWeight.textContent="".concat((100*n.oracleWeighting).toFixed(0),"%"),e.oracleBias.textContent="".concat((100*n.oracleBias).toFixed(1),"%")}},{key:"setMarketSubchoice",value:function(e,t){e===this.currentMarket.host&&t===this.currentMarket.name||this.leaveEditMode(),this.currentMarket=Object.assign({host:e},Cn().exchanges[e].markets[t])}},{key:"createOptsUpdated",value:function(){this.createOpts.oracleWeighting?Vt.show(this.biasOpt.node):Vt.hide(this.biasOpt.node)}},{key:"handleBotNote",value:function(e){var t=this.page,n=e.report;switch(e.topic){case"BotCreated":t.runningPrograms.prepend(this.programDiv(n)),this.setProgramsHeader();break;case"BotRetired":this.programs[n.programID].div.remove(),delete this.programs[n.programID],this.setProgramsHeader();break;default:var r=this.programs[n.programID];Object.assign(r,n),this.updateProgramDiv(r.tmpl,n)}}},{key:"setCreationBase",value:function(e){for(var t=this.currentMarket.quotesymbol,n=Fo(),r=[],a=0,o=n;a0)return this.setMarket(r);for(var u=0,h=n;u0)return this.setMarket(r);for(var u=0,h=n;u 0 lots"));case 6:i=Object.assign({host:r.host,baseID:r.baseid,quoteID:r.quoteid},this.createOpts,{lots:s,gapStrategy:""}),c=n.gapStrategySelect.value,i.gapStrategy=null!=c?c:"",l={botType:"MakerV0",program:i,programID:0,appPW:t,manualRate:0},e.t0=c,e.next=e.t0===co||e.t0===lo?13:e.t0===uo||e.t0===ho?22:24;break;case 13:if(0!==(u=parseFloat(n.absInput.value||"0"))){e.next=18;break}return e.abrupt("return",o("gap must be specified for strategy = absolute"));case 18:if(!(null!=a&&a.basisPrice&&u>=a.basisPrice)){e.next=20;break}return e.abrupt("return",o("gap width cannot be > current spot price"));case 20:return i.gapFactor=u,e.abrupt("break",25);case 22:return i.gapFactor=this.gapRanges.gapPercent,e.abrupt("break",25);case 24:i.gapFactor=this.gapRanges.gapMultiplier;case 25:if(h="/api/createbot",null===this.editProgram){e.next=31;break}l.programID=this.editProgram.programID,h="/api/updatebotprogram",e.next=36;break;case 31:if(this.currentReport&&0!==this.currentReport.basisPrice){e.next=36;break}if(0!==this.specifiedPrice){e.next=35;break}return o("price must be set manually"),e.abrupt("return");case 35:l.program.manualRate=this.specifiedPrice;case 36:return d=Cn().loading(n.botCreator),e.next=39,yn(h,l);case 39:if(p=e.sent,d(),Cn().checkResponse(p)){e.next=45;break}return n.createErr.textContent=p.msg,Vt.show(n.createErr),e.abrupt("return");case 45:this.leaveEditMode(),n.lotsInput.value="";case 47:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"newWalletCreated",value:function(e){var t=this.currentMarket;if(e===t.baseid)this.setCreationBase(t.basesymbol);else{if(e!==t.quoteid)return;this.setCreationQuote(t.quotesymbol)}this.closePopups()}}]),m}(mn);function Fo(){for(var e=[],t=function(e){return Object.values(e.markets).map((function(t){return Object.assign({host:e.host},t)}))},n=0,r=Object.values(Cn().user.exchanges);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){i=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(i)throw o}}}}function Lo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?n-1:0),a=1;adocument.body.offsetWidth&&(r=document.body.offsetWidth-t.tooltip.offsetWidth-5),t.tooltip.style.left="".concat(r,"px"),t.tooltip.style.top="".concat(n.bodyTop-t.tooltip.offsetHeight-5,"px")})),Mo(e,"mouseleave",(function(){t.tooltip.style.left="-10000px"}))}))}},{key:"attachHeader",value:function(){var e=this;this.header=Bo(document.body,"header"),this.headerSpace=Vt.idel(this.header,"headerSpace"),this.popupNotes=Bo(document.body,"popupNotes"),this.popupTmpl=Vt.tmplElement(this.popupNotes,"note"),this.popupTmpl?this.popupTmpl.remove():console.error("popupTmpl element not found"),this.tooltip=Bo(document.body,"tooltip");var t=this.page=Vt.idDescendants(this.header);t.noteTmpl.removeAttribute("id"),t.noteTmpl.remove(),t.pokeTmpl.removeAttribute("id"),t.pokeTmpl.remove(),t.loader.remove(),Vt.show(t.loader),Mo(t.noteBell,"click",o(w().mark((function n(){var r,a,o;return w().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:Vt.hide(t.pokeList),Vt.show(t.noteList),e.ackNotes(),t.noteCat.classList.add("active"),t.pokeCat.classList.remove("active"),e.showDropdown(t.noteBell,t.noteBox),Vt.hide(t.noteIndicator),r=Po(e.notes);try{for(r.s();!(a=r.n()).done;)(o=a.value).acked&&o.el.classList.remove("firstview")}catch(e){r.e(e)}finally{r.f()}e.setNoteTimes(t.noteList),e.setNoteTimes(t.pokeList),e.storeNotes();case 12:case"end":return n.stop()}}),n)})))),Mo(t.burgerIcon,"click",(function(){Vt.hide(t.logoutErr),e.showDropdown(t.burgerIcon,t.profileBox)})),Mo(t.innerNoteIcon,"click",(function(){Vt.hide(t.noteBox)})),Mo(t.innerBurgerIcon,"click",(function(){Vt.hide(t.profileBox)})),Mo(t.profileSignout,"click",o(w().mark((function t(){return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.signOut();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),Mo(t.pokeCat,"click",(function(){e.setNoteTimes(t.pokeList),t.pokeCat.classList.add("active"),t.noteCat.classList.remove("active"),Vt.hide(t.noteList),Vt.show(t.pokeList),e.ackNotes()})),Mo(t.noteCat,"click",(function(){e.setNoteTimes(t.noteList),t.noteCat.classList.add("active"),t.pokeCat.classList.remove("active"),Vt.hide(t.pokeList),Vt.show(t.noteList),e.ackNotes()}))}},{key:"showDropdown",value:function(e,t){var n=this,r=e.getBoundingClientRect();Vt.hide(this.page.noteBox,this.page.profileBox),Vt.show(t),t.style.right="".concat(window.innerWidth-r.left-r.width+5,"px"),t.style.top="".concat(r.top-4,"px"),Mo(document,"click",(function e(r){Vt.mouseInElement(r,t)||(Vt.hide(t),Wo(document,"click",e),t===n.page.noteBox&&Vt.isDisplayed(n.page.noteList)&&n.ackNotes())}))}},{key:"ackNotes",value:function(){var e,t=[],n=Po(this.notes);try{for(n.s();!(e=n.n()).done;){var r=e.value;r.acked?r.el.classList.remove("firstview"):(r.acked=!0,r.id&&r.severity>2&&t.push(r.id))}}catch(e){n.e(e)}finally{n.f()}t.length&&Jr.request("acknotes",t),Vt.hide(this.page.noteIndicator)}},{key:"setNoteTimes",value:function(e){for(var t=0,n=Array.from(e.children);t0?Vt.show(e.marketsMenuEntry):Vt.hide(e.marketsMenuEntry)}}},{key:"attachCommon",value:function(e){this.bindInternalNavigation(e)}},{key:"updateBondConfs",value:function(e,t,n,r){var a=this.exchanges[e],o=this.assets[r].symbol;a.pendingBonds[t]={confs:n,assetID:r,symbol:o}}},{key:"updateTier",value:function(e,t){this.exchanges[e].tier=t}},{key:"handleBondNote",value:function(e){switch(e.topic){case"RegUpdate":null!==e.coinID&&this.updateBondConfs(e.dex,e.coinID,e.confirmations,e.asset);break;case"BondConfirmed":null!==e.tier&&this.updateTier(e.dex,e.tier)}}},{key:"setNotes",value:function(e){this.log("notes","setNotes",e),this.notes=[],Vt.empty(this.page.noteList);for(var t=0;t=0&&R.splice(D,1):D>=0?R[D]=A.report:R.push(A.report)}}else this.fiatRatesMap=e.fiatRates}},{key:"notify",value:function(e){this.log("notes","notify",e),this.updateUser(e);var t,n=Po(this.noteReceivers);try{for(n.s();!(t=n.n()).done;){var r=t.value[e.type];if(r)try{r(e)}catch(t){console.error("note feeder error:",t.message?t.message:t),console.log(e),console.log(t.stack)}}}catch(e){n.e(e)}finally{n.f()}if(!(e.severity<2)){var a=this.popupTmpl,s=this.popupNotes;if(this.showPopups){var i=a.cloneNode(!0);Vt.tmplElement(i,"text").textContent="".concat(e.subject,": ").concat(e.details);var c=Vt.tmplElement(i,"indicator");for(2===e.severity?Vt.hide(c):Vo(c,e.severity),s.appendChild(i);s.children.length>5;)s.removeChild(s.firstChild);setTimeout(o(w().mark((function e(){return w().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Vt.animate(500,(function(e){i.style.opacity=String(1-e)}));case 2:i.remove();case 3:case"end":return e.stop()}}),e)}))),6e3)}2===e.severity?this.prependPokeElement(e):this.prependNoteElement(e)}}},{key:"registerNoteFeeder",value:function(e){this.noteReceivers.push(e)}},{key:"log",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a100;)this.pokes.shift();this.prependListElement(this.page.pokeList,a,n)}},{key:"prependNoteElement",value:function(e,t){var n=r(this.makeNote(e),2),a=n[0],o=n[1];for(this.notes.push(o);this.notes.length>100;)this.notes.shift();var s=this.page.noteList;if(this.prependListElement(s,o,a),t||this.storeNotes(),!(0===this.notes.length||Vt.isDisplayed(this.page.noteBox)&&Vt.isDisplayed(s))){var i=0,c=this.notes.reduce((function(e,t){return t.acked||i++,!t.acked&&t.severity>e?t.severity:e}),0),l=this.page.noteIndicator;Vo(l,c),i?(l.textContent=String(i>99?"".concat(99,"+"):i),Vt.show(l)):Vt.hide(l)}}},{key:"prependListElement",value:function(e,t,n){for(n.note=t,e.prepend(n);e.children.length>100;)e.removeChild(e.lastChild);this.setNoteTimes(e)}},{key:"makeNote",value:function(e){var t=this.page.noteTmpl.cloneNode(!0);if(e.severity>2){var n=3===e.severity?"good":4===e.severity?"warn":"bad";Vt.safeSelector(t,"div.note-indicator").classList.add(n)}return Vt.safeSelector(t,"div.note-subject").textContent=e.subject,Vt.safeSelector(t,"div.note-details").textContent=e.details,[t,To({el:t},e)]}},{key:"makePoke",value:function(e){var t=this.page.pokeTmpl.cloneNode(!0),n=new Date(e.stamp);return Vt.tmplElement(t,"dateTime").textContent="".concat(n.toLocaleDateString(),", ").concat(n.toLocaleTimeString()),Vt.tmplElement(t,"details").textContent="".concat(e.subject,": ").concat(e.details),[t,To({el:t},e)]}},{key:"loading",value:function(e){var t=this.page.loader.cloneNode(!0);return e.appendChild(t),function(){t.remove()}}},{key:"orders",value:function(e,t){var n=[],r=this.user.exchanges[e].markets[t];return r.orders&&(n=n.concat(r.orders)),r.inflight&&(n=n.concat(r.inflight)),n}},{key:"haveActiveOrders",value:function(e){for(var t=0,n=Object.values(this.user.exchanges);t= 0; --i) {\n var entry = this.tryEntries[i],\n record = entry.completion;\n if (\"root\" === entry.tryLoc) return handle(\"end\");\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\"),\n hasFinally = hasOwn.call(entry, \"finallyLoc\");\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);\n if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);\n } else {\n if (!hasFinally) throw new Error(\"try statement without catch or finally\");\n if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);\n }\n }\n }\n },\n abrupt: function abrupt(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);\n var record = finallyEntry ? finallyEntry.completion : {};\n return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);\n },\n complete: function complete(record, afterLoc) {\n if (\"throw\" === record.type) throw record.arg;\n return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;\n },\n finish: function finish(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;\n }\n },\n \"catch\": function _catch(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (\"throw\" === record.type) {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n throw new Error(\"illegal catch attempt\");\n },\n delegateYield: function delegateYield(iterable, resultName, nextLoc) {\n return this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel;\n }\n }, exports;\n}\nmodule.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return (module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports), _typeof(obj);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","// TODO(Babel 8): Remove this file.\n\nvar runtime = require(\"../helpers/regeneratorRuntime\")();\nmodule.exports = runtime;\n\n// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n if (typeof globalThis === \"object\") {\n globalThis.regeneratorRuntime = runtime;\n } else {\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _iterableToArrayLimit(arr, i) {\n var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"];\n if (null != _i) {\n var _s,\n _e,\n _x,\n _r,\n _arr = [],\n _n = !0,\n _d = !1;\n try {\n if (_x = (_i = _i.call(arr)).next, 0 === i) {\n if (Object(_i) !== _i) return;\n _n = !1;\n } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);\n } catch (err) {\n _d = !0, _e = err;\n } finally {\n try {\n if (!_n && null != _i[\"return\"] && (_r = _i[\"return\"](), Object(_r) !== _r)) return;\n } finally {\n if (_d) throw _e;\n }\n }\n return _arr;\n }\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nexport default function _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(undefined);\n });\n };\n}","export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","export default function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof(obj);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);\n }\n}\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}","import toPropertyKey from \"./toPropertyKey.js\";\nexport default function _defineProperty(obj, key, value) {\n key = toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","type Locale = Record\n\nexport const ID_NO_PASS_ERROR_MSG = 'ID_NO_PASS_ERROR_MSG'\nexport const ID_NO_APP_PASS_ERROR_MSG = 'ID_NO_APP_PASS_ERROR_MSG'\nexport const ID_SET_BUTTON_BUY = 'ID_SET_BUTTON_BUY'\nexport const ID_SET_BUTTON_SELL = 'ID_SET_BUTTON_SELL'\nexport const ID_OFF = 'ID_OFF'\nexport const ID_READY = 'ID_READY'\nexport const ID_NO_WALLET = 'ID_NO_WALLET'\nexport const ID_DISABLED_MSG = 'ID_DISABLED_MSG'\nexport const ID_WALLET_SYNC_PROGRESS = 'ID_WALLET_SYNC_PROGRESS'\nexport const ID_HIDE_ADDITIONAL_SETTINGS = 'ID_HIDE_ADDITIONAL_SETTINGS'\nexport const ID_SHOW_ADDITIONAL_SETTINGS = 'ID_SHOW_ADDITIONAL_SETTINGS'\nexport const ID_BUY = 'ID_BUY'\nexport const ID_SELL = 'ID_SELL'\nexport const ID_NOT_SUPPORTED = 'ID_NOT_SUPPORTED'\nexport const ID_VERSION_NOT_SUPPORTED = 'ID_VERSION_NOT_SUPPORTED'\nexport const ID_CONNECTION_FAILED = 'ID_CONNECTION_FAILED'\nexport const ID_ORDER_PREVIEW = 'ID_ORDER_PREVIEW'\nexport const ID_CALCULATING = 'ID_CALCULATING'\nexport const ID_ESTIMATE_UNAVAILABLE = 'ID_ESTIMATE_UNAVAILABLE'\nexport const ID_NO_ZERO_RATE = 'ID_NO_ZERO_RATE'\nexport const ID_NO_ZERO_QUANTITY = 'ID_NO_ZERO_QUANTITY'\nexport const ID_TRADE = 'ID_TRADE'\nexport const ID_NO_ASSET_WALLET = 'ID_NO_ASSET_WALLET'\nexport const ID_EXECUTED = 'ID_EXECUTED'\nexport const ID_BOOKED = 'ID_BOOKED'\nexport const ID_CANCELING = 'ID_CANCELING'\nexport const ID_PASSWORD_NOT_MATCH = 'ID_PASSWORD_NOT_MATCH'\nexport const ID_ACCT_UNDEFINED = 'ID_ACCT_UNDEFINED'\nexport const ID_KEEP_WALLET_PASS = 'ID_KEEP_WALLET_PASS'\nexport const ID_NEW_WALLET_PASS = 'ID_NEW_WALLET_PASS'\nexport const ID_LOT = 'ID_LOT'\nexport const ID_LOTS = 'ID_LOTS'\nexport const ID_UNKNOWN = 'ID_UNKNOWN'\nexport const ID_EPOCH = 'ID_EPOCH'\nexport const ID_ORDER_SUBMITTING = 'ID_ORDER_SUBMITTING'\nexport const ID_SETTLING = 'ID_SETTLING'\nexport const ID_NO_MATCH = 'ID_NO_MATCH'\nexport const ID_CANCELED = 'ID_CANCELED'\nexport const ID_REVOKED = 'ID_REVOKED'\nexport const ID_WAITING_FOR_CONFS = 'ID_WAITING_FOR_CONFS'\nexport const ID_NONE_SELECTED = 'ID_NONE_SELECTED' // unused?\nexport const ID_REGISTRATION_FEE_SUCCESS = 'ID_REGISTRATION_FEE_SUCCESS'\nexport const ID_API_ERROR = 'ID_API_ERROR'\nexport const ID_ADD = 'ID_ADD'\nexport const ID_CREATE = 'ID_CREATE'\nexport const ID_SETUP_WALLET = 'ID_SETUP_WALLET'\nexport const ID_WALLET_READY = 'ID_WALLET_READY'\nexport const ID_CHANGE_WALLET_TYPE = 'ID_CHANGE_WALLET_TYPE'\nexport const ID_KEEP_WALLET_TYPE = 'ID_KEEP_WALLET_TYPE'\nexport const WALLET_READY = 'WALLET_READY'\nexport const WALLET_PENDING = 'WALLET_PENDING'\nexport const SETUP_NEEDED = 'SETUP_NEEDED'\nexport const ID_SEND_SUCCESS = 'SEND_SUCCESS'\nexport const ID_RECONFIG_SUCCESS = 'RECONFIG_SUCCESS'\nexport const ID_RESCAN_STARTED = 'RESCAN_STARTED'\nexport const ID_NEW_WALLET_SUCCESS = 'NEW_WALLET_SUCCESS'\nexport const ID_WALLET_UNLOCKED = 'WALLET_UNLOCKED'\nexport const ID_SELLING = 'ID_SELLING'\nexport const ID_BUYING = 'ID_BUYING'\nexport const ID_WALLET_DISABLED_MSG = 'WALLET_DISABLED'\nexport const ID_WALLET_ENABLED_MSG = 'WALLET_ENABLED'\nexport const ID_ACTIVE_ORDERS_ERR_MSG = 'ACTIVE_ORDERS_ERR_MSG'\nexport const ID_AVAILABLE = 'AVAILABLE'\nexport const ID_LOCKED = 'LOCKED'\nexport const ID_IMMATURE = 'IMMATURE'\nexport const ID_FEE_BALANCE = 'FEE_BALANCE'\nexport const ID_CANDLES_LOADING = 'CANDLES_LOADING'\nexport const ID_DEPTH_LOADING = 'DEPTH_LOADING'\nexport const ID_INVALID_ADDRESS_MSG = 'INVALID_ADDRESS_MSG'\nexport const ID_TXFEE_UNSUPPORTED = 'TXFEE_UNSUPPORTED'\nexport const ID_TXFEE_ERR_MSG = 'TXFEE_ERR_MSG'\nexport const ID_ACTIVE_ORDERS_LOGOUT_ERR_MSG = 'ACTIVE_ORDERS_LOGOUT_ERR_MSG'\nexport const ID_INVALID_DATE_ERR_MSG = 'INVALID_DATE_ERR_MSG'\nexport const ID_NO_ARCHIVED_RECORDS = 'NO_ARCHIVED_RECORDS'\nexport const ID_DELETE_ARCHIVED_RECORDS_RESULT = 'DELETE_ARCHIVED_RECORDS_RESULT'\nexport const ID_ARCHIVED_RECORDS_PATH = 'ARCHIVED_RECORDS_PATH'\nexport const ID_DEFAULT = 'DEFAULT'\nexport const ID_ADDED = 'USER_ADDED'\nexport const ID_DISCOVERED = 'DISCOVERED'\nexport const ID_UNSUPPORTED_ASSET_INFO_ERR_MSG = 'UNSUPPORTED_ASSET_INFO_ERR_MSG'\nexport const ID_LIMIT_ORDER = 'LIMIT_ORDER'\nexport const ID_LIMIT_ORDER_IMMEDIATE_TIF = 'LIMIT_ORDER_IMMEDIATE_TIF'\nexport const ID_MARKET_ORDER = 'MARKET_ORDER'\nexport const ID_MATCH_STATUS_NEWLY_MATCHED = 'MATCH_STATUS_NEWLY_MATCHED'\nexport const ID_MATCH_STATUS_MAKER_SWAP_CAST = 'MATCH_STATUS_MAKER_SWAP_CAST'\nexport const ID_MATCH_STATUS_TAKER_SWAP_CAST = 'MATCH_STATUS_TAKER_SWAP_CAST'\nexport const ID_MATCH_STATUS_MAKER_REDEEMED = 'MATCH_STATUS_MAKER_REDEEMED'\nexport const ID_MATCH_STATUS_REDEMPTION_SENT = 'MATCH_STATUS_REDEMPTION_SENT'\nexport const ID_MATCH_STATUS_REDEMPTION_CONFIRMED = 'MATCH_REDEMPTION_CONFIRMED'\nexport const ID_MATCH_STATUS_REVOKED = 'MATCH_STATUS_REVOKED'\nexport const ID_MATCH_STATUS_REFUNDED = 'MATCH_STATUS_REFUNDED'\nexport const ID_MATCH_STATUS_REFUND_PENDING = 'MATCH_STATUS_REFUND_PENDING'\nexport const ID_MATCH_STATUS_REDEEM_PENDING = 'MATCH_STATUS_REDEEM_PENDING'\nexport const ID_MATCH_STATUS_COMPLETE = 'MATCH_STATUS_COMPLETE'\nexport const ID_TAKER_FOUND_MAKER_REDEMPTION = 'TAKER_FOUND_MAKER_REDEMPTION'\nexport const ID_OPEN_WALLET_ERR_MSG = 'OPEN_WALLET_ERR_MSG'\nexport const ID_ORDER_ACCELERATION_FEE_ERR_MSG = 'ORDER_ACCELERATION_FEE_ERR_MSG'\nexport const ID_ORDER_ACCELERATION_ERR_MSG = 'ORDER_ACCELERATION_FEE_ERR_MSG'\nexport const ID_CONNECTED = 'CONNECTED'\nexport const ID_DISCONNECTED = 'DISCONNECTED'\nexport const ID_INVALID_CERTIFICATE = 'INVALID_CERTIFICATE'\nexport const ID_CONFIRMATIONS = 'ID_CONFIRMATIONS'\nexport const ID_TAKER = 'TAKER'\nexport const ID_MAKER = 'MAKER'\nexport const ID_EMPTY_DEX_ADDRESS_MSG = 'EMPTY_DEX_ADDRESS_MSG'\nexport const ID_SELECT_WALLET_FOR_FEE_PAYMENT = 'SELECT_WALLET_FOR_FEE_PAYMENT'\nexport const ID_UNAVAILABLE = 'UNAVAILABLE'\nexport const ID_WALLET_SYNC_FINISHING_UP = 'WALLET_SYNC_FINISHING_UP'\nexport const ID_CONNECT_WALLET_ERR_MSG = 'CONNECTING_WALLET_ERR_MSG'\n\nexport const enUS: Locale = {\n [ID_NO_PASS_ERROR_MSG]: 'password cannot be empty',\n [ID_NO_APP_PASS_ERROR_MSG]: 'app password cannot be empty',\n [ID_PASSWORD_NOT_MATCH]: 'passwords do not match',\n [ID_SET_BUTTON_BUY]: 'Place order to buy {{ asset }}',\n [ID_SET_BUTTON_SELL]: 'Place order to sell {{ asset }}',\n [ID_OFF]: 'off',\n [ID_READY]: 'ready',\n [ID_LOCKED]: 'locked',\n [ID_NO_WALLET]: 'no wallet',\n [ID_WALLET_SYNC_PROGRESS]: 'wallet is {{ syncProgress }}% synced',\n [ID_HIDE_ADDITIONAL_SETTINGS]: 'hide additional settings',\n [ID_SHOW_ADDITIONAL_SETTINGS]: 'show additional settings',\n [ID_BUY]: 'Buy',\n [ID_SELL]: 'Sell',\n [ID_NOT_SUPPORTED]: '{{ asset }} is not supported',\n [ID_VERSION_NOT_SUPPORTED]: '{{ asset }} (v{{version}}) is not supported',\n [ID_CONNECTION_FAILED]: 'Connection to dex server failed. You can close dexc and try again later or wait for it to reconnect.',\n [ID_ORDER_PREVIEW]: 'Total: {{ total }} {{ asset }}',\n [ID_CALCULATING]: 'calculating...',\n [ID_ESTIMATE_UNAVAILABLE]: 'estimate unavailable',\n [ID_NO_ZERO_RATE]: 'zero rate not allowed',\n [ID_NO_ZERO_QUANTITY]: 'zero quantity not allowed',\n [ID_TRADE]: 'trade',\n [ID_NO_ASSET_WALLET]: 'No {{ asset }} wallet',\n [ID_EXECUTED]: 'executed',\n [ID_BOOKED]: 'booked',\n [ID_CANCELING]: 'canceling',\n [ID_ACCT_UNDEFINED]: 'Account undefined.',\n [ID_KEEP_WALLET_PASS]: 'keep current wallet password',\n [ID_NEW_WALLET_PASS]: 'set a new wallet password',\n [ID_LOT]: 'lot',\n [ID_LOTS]: 'lots',\n [ID_UNKNOWN]: 'unknown',\n [ID_EPOCH]: 'epoch',\n [ID_SETTLING]: 'settling',\n [ID_NO_MATCH]: 'no match',\n [ID_CANCELED]: 'canceled',\n [ID_REVOKED]: 'revoked',\n [ID_WAITING_FOR_CONFS]: 'Waiting for confirmations...',\n [ID_NONE_SELECTED]: 'none selected',\n [ID_REGISTRATION_FEE_SUCCESS]: 'Fidelity bond accepted!',\n [ID_API_ERROR]: 'API error',\n [ID_ADD]: 'Add',\n [ID_CREATE]: 'Create',\n [ID_WALLET_READY]: 'Ready',\n [ID_SETUP_WALLET]: 'Setup',\n [ID_CHANGE_WALLET_TYPE]: 'change the wallet type',\n [ID_KEEP_WALLET_TYPE]: 'don\\'t change the wallet type',\n [WALLET_READY]: 'Wallet Ready',\n [SETUP_NEEDED]: 'Setup Needed',\n [WALLET_PENDING]: 'Creating Wallet',\n [ID_SEND_SUCCESS]: '{{ assetName }} Sent!',\n [ID_RECONFIG_SUCCESS]: 'Wallet Reconfigured!',\n [ID_RESCAN_STARTED]: 'Wallet Rescan Running',\n [ID_NEW_WALLET_SUCCESS]: '{{ assetName }} Wallet Created!',\n [ID_WALLET_UNLOCKED]: 'Wallet Unlocked',\n [ID_SELLING]: 'Selling',\n [ID_BUYING]: 'Buying',\n [ID_WALLET_ENABLED_MSG]: '{{ assetName }} Wallet Enabled',\n [ID_WALLET_DISABLED_MSG]: '{{ assetName }} Wallet Disabled',\n [ID_DISABLED_MSG]: 'wallet is disabled',\n [ID_ACTIVE_ORDERS_ERR_MSG]: '{{ assetName }} wallet is actively managing orders',\n [ID_AVAILABLE]: 'available',\n [ID_IMMATURE]: 'immature',\n [ID_FEE_BALANCE]: 'fee balance',\n [ID_CANDLES_LOADING]: 'waiting for candlesticks',\n [ID_DEPTH_LOADING]: 'retrieving depth data',\n [ID_INVALID_ADDRESS_MSG]: 'invalid address: {{ address }}',\n [ID_TXFEE_UNSUPPORTED]: 'fee estimation is not supported for this wallet type',\n [ID_TXFEE_ERR_MSG]: 'fee estimation failed: {{ err }}',\n [ID_ACTIVE_ORDERS_LOGOUT_ERR_MSG]: 'cannot logout with active orders',\n [ID_INVALID_DATE_ERR_MSG]: 'error: invalid date or time',\n [ID_NO_ARCHIVED_RECORDS]: 'No archived records found',\n [ID_DELETE_ARCHIVED_RECORDS_RESULT]: 'Message: {{ nRecords }} archived records has been deleted',\n [ID_ARCHIVED_RECORDS_PATH]: 'File Location: {{ path }}',\n [ID_ORDER_SUBMITTING]: 'submitting',\n [ID_DEFAULT]: 'Default',\n [ID_ADDED]: 'Added',\n [ID_DISCOVERED]: 'Discovered',\n [ID_UNSUPPORTED_ASSET_INFO_ERR_MSG]: 'no supported asset info for id = {{ assetID }}, and no exchange info provided',\n [ID_LIMIT_ORDER]: 'limit',\n [ID_LIMIT_ORDER_IMMEDIATE_TIF]: 'limit (i)',\n [ID_MARKET_ORDER]: 'market',\n [ID_MATCH_STATUS_NEWLY_MATCHED]: 'Newly Matched',\n [ID_MATCH_STATUS_MAKER_SWAP_CAST]: 'Maker Swap Sent',\n [ID_MATCH_STATUS_TAKER_SWAP_CAST]: 'Taker Swap Sent',\n [ID_MATCH_STATUS_MAKER_REDEEMED]: 'Maker Redeemed',\n [ID_MATCH_STATUS_REDEMPTION_SENT]: 'Redemption Sent',\n [ID_MATCH_STATUS_REVOKED]: 'Revoked - {{ status }}',\n [ID_MATCH_STATUS_REFUND_PENDING]: 'Refund PENDING',\n [ID_MATCH_STATUS_REFUNDED]: 'Refunded',\n [ID_MATCH_STATUS_REDEEM_PENDING]: 'Redeem PENDING',\n [ID_MATCH_STATUS_REDEMPTION_CONFIRMED]: 'Redemption Confirmed',\n [ID_MATCH_STATUS_COMPLETE]: 'Complete',\n [ID_TAKER_FOUND_MAKER_REDEMPTION]: 'redeemed by {{ makerAddr }}',\n [ID_OPEN_WALLET_ERR_MSG]: 'Error opening wallet: {{ msg }}',\n [ID_ORDER_ACCELERATION_FEE_ERR_MSG]: 'Error estimating acceleration fee: {{ msg }}',\n [ID_ORDER_ACCELERATION_ERR_MSG]: 'Error accelerating order: {{ msg }}',\n [ID_CONNECTED]: 'Connected',\n [ID_DISCONNECTED]: 'Disconnected',\n [ID_INVALID_CERTIFICATE]: 'Invalid Certificate',\n [ID_CONFIRMATIONS]: 'confirmations',\n [ID_TAKER]: 'Taker',\n [ID_MAKER]: 'Maker',\n [ID_UNAVAILABLE]: 'unavailable',\n [ID_EMPTY_DEX_ADDRESS_MSG]: 'DEX address cannot be empty',\n [ID_SELECT_WALLET_FOR_FEE_PAYMENT]: 'Select a valid wallet to post a bond',\n [ID_WALLET_SYNC_FINISHING_UP]: 'finishing up',\n [ID_CONNECT_WALLET_ERR_MSG]: 'Failed to connect {{ assetName }} wallet: {{ errMsg }}'\n}\n\nexport const ptBR: Locale = {\n [ID_NO_PASS_ERROR_MSG]: 'senha não pode ser vazia',\n [ID_NO_APP_PASS_ERROR_MSG]: 'senha do app não pode ser vazia',\n [ID_PASSWORD_NOT_MATCH]: 'senhas diferentes',\n [ID_SET_BUTTON_BUY]: 'Ordem de compra de {{ asset }}',\n [ID_SET_BUTTON_SELL]: 'Ordem de venda de {{ asset }}',\n [ID_OFF]: 'desligar',\n [ID_READY]: 'pronto',\n [ID_LOCKED]: 'trancado',\n [ID_NO_WALLET]: 'sem carteira',\n [ID_WALLET_SYNC_PROGRESS]: 'carteira está {{ syncProgress }}% sincronizada',\n [ID_HIDE_ADDITIONAL_SETTINGS]: 'esconder configurações adicionais',\n [ID_SHOW_ADDITIONAL_SETTINGS]: 'mostrar configurações adicionais',\n [ID_BUY]: 'Comprar',\n [ID_SELL]: 'Vender',\n [ID_NOT_SUPPORTED]: '{{ asset }} não tem suporte',\n [ID_CONNECTION_FAILED]: 'Conexão ao server dex falhou. Pode fechar dexc e tentar novamente depois ou esperar para tentar se reconectar.',\n [ID_ORDER_PREVIEW]: 'Total: {{ total }} {{ asset }}',\n [ID_CALCULATING]: 'calculando...',\n [ID_ESTIMATE_UNAVAILABLE]: 'estimativa indisponível',\n [ID_NO_ZERO_RATE]: 'taxa não pode ser zero',\n [ID_NO_ZERO_QUANTITY]: 'quantidade não pode ser zero',\n [ID_TRADE]: 'troca',\n [ID_NO_ASSET_WALLET]: 'Sem carteira {{ asset }}',\n [ID_EXECUTED]: 'executado',\n [ID_BOOKED]: 'reservado',\n [ID_CANCELING]: 'cancelando',\n [ID_ACCT_UNDEFINED]: 'conta não definida.',\n [ID_KEEP_WALLET_PASS]: 'manter senha da carteira',\n [ID_NEW_WALLET_PASS]: 'definir nova senha para carteira',\n [ID_LOT]: 'lote',\n [ID_LOTS]: 'lotes',\n [ID_UNKNOWN]: 'desconhecido',\n [ID_EPOCH]: 'epoque',\n [ID_SETTLING]: 'assentando',\n [ID_NO_MATCH]: 'sem combinações',\n [ID_CANCELED]: 'cancelado',\n [ID_REVOKED]: 'revocado',\n [ID_WAITING_FOR_CONFS]: 'Esperando confirmações...',\n [ID_NONE_SELECTED]: 'nenhuma selecionado',\n [ID_REGISTRATION_FEE_SUCCESS]: 'Sucesso no pagamento da taxa de registro!', // TODO: reword from fee => bond\n [ID_API_ERROR]: 'Erro de API',\n [ID_ADD]: 'Adicionar',\n [ID_CREATE]: 'Criar',\n [ID_WALLET_READY]: 'Escolher',\n [ID_SETUP_WALLET]: 'Configurar',\n [ID_CHANGE_WALLET_TYPE]: 'trocar o tipo de carteira',\n [ID_KEEP_WALLET_TYPE]: 'Não trocara tipo de carteira',\n [WALLET_READY]: 'Carteira Pronta',\n [SETUP_NEEDED]: 'Configuração Necessária',\n [ID_AVAILABLE]: 'disponível',\n [ID_IMMATURE]: 'imaturo'\n}\n\nexport const zhCN: Locale = {\n [ID_NO_PASS_ERROR_MSG]: '密码不能为空',\n [ID_NO_APP_PASS_ERROR_MSG]: '应用密码不能为空',\n [ID_PASSWORD_NOT_MATCH]: '密码不相同',\n [ID_SET_BUTTON_BUY]: '来自{{ asset }}的买入订单',\n [ID_SET_BUTTON_SELL]: '来自{{ asset }}的卖出订单',\n [ID_OFF]: '关闭',\n [ID_READY]: '准备就绪', // alt. 准备好\n [ID_LOCKED]: '锁',\n [ID_NO_WALLET]: '未连接钱包', // alt. 没有钱包\n [ID_WALLET_SYNC_PROGRESS]: '钱包同步进度{{ syncProgress }}%',\n [ID_HIDE_ADDITIONAL_SETTINGS]: '隐藏其它设置',\n [ID_SHOW_ADDITIONAL_SETTINGS]: '显示其它设置',\n [ID_BUY]: '买入',\n [ID_SELL]: '卖出',\n [ID_NOT_SUPPORTED]: '{{ asset }}不受支持',\n [ID_CONNECTION_FAILED]: '连接到服务器 dex 失败。您可以关闭 dexc 并稍后重试或等待尝试重新连接。',\n [ID_ORDER_PREVIEW]: '总计: {{ total }} {{ asset }}',\n [ID_CALCULATING]: '计算中...',\n [ID_ESTIMATE_UNAVAILABLE]: '估计不可用',\n [ID_NO_ZERO_RATE]: '汇率不能为零',\n [ID_NO_ZERO_QUANTITY]: '数量不能为零',\n [ID_TRADE]: '交易',\n [ID_NO_ASSET_WALLET]: '没有钱包 {{ asset }}',\n [ID_EXECUTED]: '执行',\n [ID_BOOKED]: '保留',\n [ID_CANCELING]: '取消',\n [ID_ACCT_UNDEFINED]: '帐户未定义。',\n [ID_KEEP_WALLET_PASS]: '保留钱包密码',\n [ID_NEW_WALLET_PASS]: '设置新的钱包密码',\n [ID_LOT]: '批处理',\n [ID_LOTS]: '批', // alt. 很多\n [ID_EPOCH]: '时间',\n [ID_API_ERROR]: '接口错误',\n [ID_ADD]: '添加',\n [ID_CREATE]: '创建',\n [ID_AVAILABLE]: '可用',\n [ID_IMMATURE]: '不成熟'\n}\n\nexport const plPL: Locale = {\n [ID_NO_PASS_ERROR_MSG]: 'hasło nie może być puste',\n [ID_NO_APP_PASS_ERROR_MSG]: 'hasło aplikacji nie może być puste',\n [ID_PASSWORD_NOT_MATCH]: 'hasła nie są jednakowe',\n [ID_SET_BUTTON_BUY]: 'Złóż zlecenie, aby kupić {{ asset }}',\n [ID_SET_BUTTON_SELL]: 'Złóż zlecenie, aby sprzedać {{ asset }}',\n [ID_OFF]: 'wyłączony',\n [ID_READY]: 'gotowy',\n [ID_LOCKED]: 'zablokowany',\n [ID_NO_WALLET]: 'brak portfela',\n [ID_WALLET_SYNC_PROGRESS]: 'portfel zsynchronizowany w {{ syncProgress }}%',\n [ID_HIDE_ADDITIONAL_SETTINGS]: 'ukryj dodatkowe ustawienia',\n [ID_SHOW_ADDITIONAL_SETTINGS]: 'pokaż dodatkowe ustawienia',\n [ID_BUY]: 'Kup',\n [ID_SELL]: 'Sprzedaj',\n [ID_NOT_SUPPORTED]: '{{ asset }} nie jest wspierany',\n [ID_CONNECTION_FAILED]: 'Połączenie z serwerem dex nie powiodło się. Możesz zamknąć dexc i spróbować ponownie później, lub poczekać na wznowienie połączenia.',\n [ID_ORDER_PREVIEW]: 'W sumie: {{ total }} {{ asset }}',\n [ID_CALCULATING]: 'obliczanie...',\n [ID_ESTIMATE_UNAVAILABLE]: 'brak szacunkowego wyliczenia',\n [ID_NO_ZERO_RATE]: 'zero nie może być ceną',\n [ID_NO_ZERO_QUANTITY]: 'zero nie może być ilością',\n [ID_TRADE]: 'handluj',\n [ID_NO_ASSET_WALLET]: 'Brak portfela {{ asset }}',\n [ID_EXECUTED]: 'wykonano',\n [ID_BOOKED]: 'zapisano',\n [ID_CANCELING]: 'anulowanie',\n [ID_ACCT_UNDEFINED]: 'Niezdefiniowane konto.',\n [ID_KEEP_WALLET_PASS]: 'zachowaj obecne hasło portfela',\n [ID_NEW_WALLET_PASS]: 'ustaw nowe hasło portfela',\n [ID_LOT]: 'lot',\n [ID_LOTS]: 'loty(ów)',\n [ID_UNKNOWN]: 'nieznane',\n [ID_EPOCH]: 'epoka',\n [ID_SETTLING]: 'rozliczanie',\n [ID_NO_MATCH]: 'brak spasowania',\n [ID_CANCELED]: 'anulowano',\n [ID_REVOKED]: 'unieważniono',\n [ID_WAITING_FOR_CONFS]: 'Oczekiwanie na potwierdzenia...',\n [ID_NONE_SELECTED]: 'brak zaznaczenia',\n [ID_REGISTRATION_FEE_SUCCESS]: 'Płatność rejestracyjna powiodła się!', // TODO: reword from fee => bond\n [ID_API_ERROR]: 'błąd API',\n [ID_ADD]: 'Dodaj',\n [ID_CREATE]: 'Utwórz',\n [ID_WALLET_READY]: 'Gotowy',\n [ID_SETUP_WALLET]: 'Konfiguracja',\n [ID_CHANGE_WALLET_TYPE]: 'zmień typ portfela',\n [ID_KEEP_WALLET_TYPE]: 'nie zmieniaj typu portfela',\n [WALLET_READY]: 'Portfel jest gotowy',\n [SETUP_NEEDED]: 'Potrzebna konfiguracja',\n [ID_AVAILABLE]: 'dostępne',\n [ID_IMMATURE]: 'niedojrzałe'\n}\n\nexport const deDE: Locale = {\n [ID_NO_PASS_ERROR_MSG]: 'Passwort darf nicht leer sein',\n [ID_NO_APP_PASS_ERROR_MSG]: 'App-Passwort darf nicht leer sein',\n [ID_PASSWORD_NOT_MATCH]: 'Passwörter stimmen nicht überein',\n [ID_SET_BUTTON_BUY]: 'Platziere Auftrag zum Kauf von {{ asset }}',\n [ID_SET_BUTTON_SELL]: 'Platziere Auftrag zum Verkauf von {{ asset }}',\n [ID_OFF]: 'aus',\n [ID_READY]: 'bereit',\n [ID_LOCKED]: 'gesperrt',\n [ID_NO_WALLET]: 'kein Wallet',\n [ID_WALLET_SYNC_PROGRESS]: 'Wallet ist zu {{ syncProgress }}% synchronisiert',\n [ID_HIDE_ADDITIONAL_SETTINGS]: 'zusätzliche Einstellungen ausblenden',\n [ID_SHOW_ADDITIONAL_SETTINGS]: 'zusätzliche Einstellungen anzeigen',\n [ID_BUY]: 'Kaufen',\n [ID_SELL]: 'Verkaufen',\n [ID_NOT_SUPPORTED]: '{{ asset }} wird nicht unterstützt',\n [ID_CONNECTION_FAILED]: 'Die Verbindung zum Dex-Server fehlgeschlagen. Du kannst dexc schließen und es später erneut versuchen oder warten bis die Verbindung wiederhergestellt ist.',\n [ID_ORDER_PREVIEW]: 'Insgesamt: {{ total }} {{ asset }}',\n [ID_CALCULATING]: 'kalkuliere...',\n [ID_ESTIMATE_UNAVAILABLE]: 'Schätzung nicht verfügbar',\n [ID_NO_ZERO_RATE]: 'Null-Satz nicht erlaubt',\n [ID_NO_ZERO_QUANTITY]: 'Null-Menge nicht erlaubt',\n [ID_TRADE]: 'Handel',\n [ID_NO_ASSET_WALLET]: 'Kein {{ asset }} Wallet',\n [ID_EXECUTED]: 'ausgeführt',\n [ID_BOOKED]: 'gebucht',\n [ID_CANCELING]: 'Abbruch',\n [ID_ACCT_UNDEFINED]: 'Account undefiniert.',\n [ID_KEEP_WALLET_PASS]: 'aktuelles Passwort für das Wallet behalten',\n [ID_NEW_WALLET_PASS]: 'ein neues Passwort für das Wallet festlegen',\n [ID_LOT]: 'Lot',\n [ID_LOTS]: 'Lots',\n [ID_UNKNOWN]: 'unbekannt',\n [ID_EPOCH]: 'Epoche',\n [ID_SETTLING]: 'Abwicklung',\n [ID_NO_MATCH]: 'kein Match',\n [ID_CANCELED]: 'abgebrochen',\n [ID_REVOKED]: 'widerrufen',\n [ID_WAITING_FOR_CONFS]: 'Warten auf Bestätigungen...',\n [ID_NONE_SELECTED]: 'keine ausgewählt',\n [ID_REGISTRATION_FEE_SUCCESS]: 'Zahlung der Registrierungsgebühr erfolgreich!', // TODO: reword from fee => bond\n [ID_API_ERROR]: 'API Fehler',\n [ID_ADD]: 'Hinzufügen',\n [ID_CREATE]: 'Erstellen',\n [ID_WALLET_READY]: 'Bereit',\n [ID_SETUP_WALLET]: 'Einrichten',\n [ID_CHANGE_WALLET_TYPE]: 'den Wallet-Typ ändern',\n [ID_KEEP_WALLET_TYPE]: 'den Wallet-Typ nicht ändern',\n [WALLET_READY]: 'Wallet bereit',\n [SETUP_NEEDED]: 'Einrichtung erforderlich',\n [WALLET_PENDING]: 'Erstelle Wallet',\n [ID_SEND_SUCCESS]: '{{ assetName }} gesendet!',\n [ID_RECONFIG_SUCCESS]: 'Wallet neu konfiguriert!',\n [ID_RESCAN_STARTED]: 'Wallet Rescan läuft',\n [ID_NEW_WALLET_SUCCESS]: '{{ assetName }} Wallet erstellt!',\n [ID_WALLET_UNLOCKED]: 'Wallet entsperrt'\n}\n\nexport const ar: Locale = {\n [ID_NO_PASS_ERROR_MSG]: 'لا يمكن أن تكون كلمة المرور فارغة',\n [ID_NO_APP_PASS_ERROR_MSG]: 'لا يمكن أن تكون كلمة مرور التطبيق فارغة',\n [ID_PASSWORD_NOT_MATCH]: 'كلمات المرور غير متطابقة',\n [ID_SET_BUTTON_BUY]: 'ضع طلبًا للشراء {{ asset }}',\n [ID_SET_BUTTON_SELL]: 'ضع طلبًا للبيع {{ asset }}',\n [ID_OFF]: 'إيقاف',\n [ID_READY]: 'متوقف',\n [ID_LOCKED]: 'مقفل',\n [ID_NO_WALLET]: 'لا توجد أي محفظة',\n [ID_WALLET_SYNC_PROGRESS]: 'تمت مزامنة {{ syncProgress }}% المحفظة',\n [ID_HIDE_ADDITIONAL_SETTINGS]: 'إخفاء الإعدادات الإضافية',\n [ID_SHOW_ADDITIONAL_SETTINGS]: 'عرض الإعدادات الإضافية',\n [ID_BUY]: 'شراء',\n [ID_SELL]: 'بيع',\n [ID_NOT_SUPPORTED]: '{{ asset }} غير مدعوم',\n [ID_CONNECTION_FAILED]: 'فشل الاتصال بخادم dex. يمكنك إغلاق dexc والمحاولة مرة أخرى لاحقًا أو انتظار إعادة الاتصال.',\n [ID_ORDER_PREVIEW]: 'إجمالي: {{ total }} {{ asset }}',\n [ID_CALCULATING]: 'جاري الحساب ...',\n [ID_ESTIMATE_UNAVAILABLE]: 'التقديرات غير متاحة',\n [ID_NO_ZERO_RATE]: 'معدل الصفر غير مسموح به',\n [ID_NO_ZERO_QUANTITY]: 'غير مسموح بالكمية الصفرية',\n [ID_TRADE]: 'التداول',\n [ID_NO_ASSET_WALLET]: 'لا توجد {{ asset }} محفظة',\n [ID_EXECUTED]: 'تم تنفيذها',\n [ID_BOOKED]: 'تم الحجز',\n [ID_CANCELING]: 'جارٍ الإلغاء',\n [ID_ACCT_UNDEFINED]: 'حساب غير محدد.',\n [ID_KEEP_WALLET_PASS]: 'احتفظ بكلمة مرور المحفظة الحالية',\n [ID_NEW_WALLET_PASS]: 'قم بتعيين كلمة مرور جديدة للمحفظة',\n [ID_LOT]: 'الحصة',\n [ID_LOTS]: 'الحصص',\n [ID_UNKNOWN]: 'غير معروف',\n [ID_EPOCH]: 'الحقبة الزمنية',\n [ID_SETTLING]: 'الإعدادات',\n [ID_NO_MATCH]: 'غير متطابقة',\n [ID_CANCELED]: 'ملغاة',\n [ID_REVOKED]: 'مستعادة',\n [ID_WAITING_FOR_CONFS]: 'في انتظار التأكيدات ...',\n [ID_NONE_SELECTED]: 'لم يتم تحديد أي شيء',\n [ID_REGISTRATION_FEE_SUCCESS]: 'تم دفع رسوم التسجيل بنجاح!', // TODO: reword from fee => bond\n [ID_API_ERROR]: 'خطأ في واجهة برمجة التطبيقات',\n [ID_ADD]: 'إضافة',\n [ID_CREATE]: 'إنشاء',\n [ID_WALLET_READY]: 'جاهزة',\n [ID_SETUP_WALLET]: 'إعداد',\n [ID_CHANGE_WALLET_TYPE]: 'تغيير نوع المحفظة',\n [ID_KEEP_WALLET_TYPE]: 'لا تغير نوع المحفظة',\n [WALLET_READY]: 'المحفظة جاهزة',\n [SETUP_NEEDED]: 'الإعداد مطلوب',\n [WALLET_PENDING]: 'إنشاء المحفظة',\n [ID_SEND_SUCCESS]: '{{ assetName }} تم الإرسال!',\n [ID_RECONFIG_SUCCESS]: 'تمت إعادة تهيئة المحفظة!!',\n [ID_RESCAN_STARTED]: 'إعادة فحص المحفظة قيد التشغيل',\n [ID_NEW_WALLET_SUCCESS]: '{{ assetName }} تم إنشاء المحفظة!',\n [ID_WALLET_UNLOCKED]: 'المحفظة غير مقفلة',\n [ID_SELLING]: 'البيع',\n [ID_BUYING]: 'Bالشراء',\n [ID_WALLET_ENABLED_MSG]: '{{ assetName }} المحفظة ممكنة',\n [ID_WALLET_DISABLED_MSG]: '{{ assetName }} المحفظة معطلة',\n [ID_DISABLED_MSG]: 'تم تعطيل المحفظة',\n [ID_ACTIVE_ORDERS_ERR_MSG]: '{{ assetName }} تدير المحفظة الطلبات بفعالية'\n}\n\nconst localesMap: Record = {\n 'en-us': enUS,\n 'pt-br': ptBR,\n 'zh-cn': zhCN,\n 'pl-pl': plPL,\n 'de-de': deDE,\n 'ar': ar\n}\n\n/* locale will hold the locale loaded via setLocale. */\nlet locale: Locale\n\nconst defaultLocale = enUS\n\n/*\n * setLocale read the language tag from the current document's html element lang\n * attribute and sets the locale. setLocale should be called once by the\n * application before prep is used.\n*/\nexport function setLocale () { locale = localesMap[document.documentElement.lang.toLowerCase()] }\n\n/* prep will format the message to the current locale. */\nexport function prep (k: string, args?: Record) {\n return stringTemplateParser(locale[k] || defaultLocale[k], args || {})\n}\n\n/*\n * stringTemplateParser is a template string matcher, where expression is any\n * text. It switches what is inside double brackets (e.g. 'buy {{ asset }}')\n * for the value described into args. args is an object with keys\n * equal to the placeholder keys. (e.g. {\"asset\": \"dcr\"}).\n * So that will be switched for: 'asset dcr'.\n */\nfunction stringTemplateParser (expression: string, args: Record) {\n // templateMatcher matches any text which:\n // is some {{ text }} between two brackets, and a space between them.\n // It is global, therefore it will change all occurrences found.\n // text can be anything, but brackets '{}' and space '\\s'\n const templateMatcher = /{{\\s?([^{}\\s]*)\\s?}}/g\n return expression.replace(templateMatcher, (_, value) => args[value])\n}\n\nwindow.localeDiscrepancies = () => {\n const ref = enUS\n for (const [lang, dict] of Object.entries(localesMap)) {\n if (dict === ref) continue\n for (const [k, s] of Object.entries(ref)) {\n if (!dict[k]) console.log(`${lang} needs a tranlation for: ${s}`)\n }\n }\n}\n","import * as intl from './locales'\nimport {\n UnitInfo,\n LayoutMetrics,\n WalletState,\n PageElement\n} from './registry'\n\nconst parser = new window.DOMParser()\n\nconst FPS = 30\n\nconst BipIDs: Record = {\n 0: 'btc',\n 42: 'dcr',\n 2: 'ltc',\n 20: 'dgb',\n 22: 'mona',\n 28: 'vtc',\n 3: 'doge',\n 145: 'bch',\n 60: 'eth',\n 133: 'zec',\n 60000: 'dextt.eth',\n 60001: 'usdc.eth'\n}\n\nconst BipSymbols = Object.values(BipIDs)\n\nconst intFormatter = new Intl.NumberFormat((navigator.languages as string[]))\n\nconst threeSigFigs = new Intl.NumberFormat((navigator.languages as string[]), {\n minimumSignificantDigits: 3,\n maximumSignificantDigits: 3\n})\n\nconst fiveSigFigs = new Intl.NumberFormat((navigator.languages as string[]), {\n minimumSignificantDigits: 5,\n maximumSignificantDigits: 5\n})\n\n/* A cache for formatters used for Doc.formatCoinValue. */\nconst decimalFormatters = {}\n\n/*\n * decimalFormatter gets the formatCoinValue formatter for the specified decimal\n * precision.\n */\nfunction decimalFormatter (prec: number) {\n return formatter(decimalFormatters, 2, prec)\n}\n\n/* A cache for formatters used for Doc.formatFullPrecision. */\nconst fullPrecisionFormatters = {}\n\n/*\n * fullPrecisionFormatter gets the formatFullPrecision formatter for the\n * specified decimal precision.\n */\nfunction fullPrecisionFormatter (prec: number) {\n return formatter(fullPrecisionFormatters, prec, prec)\n}\n\n/*\n * formatter gets the formatter from the supplied cache if it already exists,\n * else creates it.\n */\nfunction formatter (formatters: Record, min: number, max: number): Intl.NumberFormat {\n const k = `${min}-${max}`\n let fmt = formatters[k]\n if (!fmt) {\n fmt = new Intl.NumberFormat((navigator.languages as string[]), {\n minimumFractionDigits: min,\n maximumFractionDigits: max\n })\n formatters[k] = fmt\n }\n return fmt\n}\n\n/*\n * convertToConventional converts the value in atomic units to conventional\n * units.\n */\nfunction convertToConventional (v: number, unitInfo?: UnitInfo) {\n let prec = 8\n if (unitInfo) {\n const f = unitInfo.conventional.conversionFactor\n v /= f\n prec = Math.round(Math.log10(f))\n }\n return [v, prec]\n}\n\n// Helpers for working with the DOM.\nexport default class Doc {\n /*\n * idel is the element with the specified id that is the descendent of the\n * specified node.\n */\n static idel (el: Document | Element, id: string): HTMLElement {\n return el.querySelector(`#${id}`) as HTMLElement\n }\n\n /* bind binds the function to the event for the element. */\n static bind (el: EventTarget, ev: string, f: EventListenerOrEventListenerObject): void {\n el.addEventListener(ev, f)\n }\n\n /* unbind removes the handler for the event from the element. */\n static unbind (el: EventTarget, ev: string, f: (e: Event) => void): void {\n el.removeEventListener(ev, f)\n }\n\n /* noderize creates a Document object from a string of HTML. */\n static noderize (html: string): Document {\n return parser.parseFromString(html, 'text/html')\n }\n\n /*\n * mouseInElement returns true if the position of mouse event, e, is within\n * the bounds of the specified element or any of its descendents.\n */\n static mouseInElement (e: MouseEvent, el: HTMLElement): boolean {\n if (el.contains(e.target as Node)) return true\n const rect = el.getBoundingClientRect()\n return e.pageX >= rect.left && e.pageX <= rect.right &&\n e.pageY >= rect.top && e.pageY <= rect.bottom\n }\n\n /*\n * layoutMetrics gets information about the elements position on the page.\n */\n static layoutMetrics (el: HTMLElement): LayoutMetrics {\n const box = el.getBoundingClientRect()\n const docEl = document.documentElement\n const top = box.top + docEl.scrollTop\n const left = box.left + docEl.scrollLeft\n const w = el.offsetWidth\n const h = el.offsetHeight\n return {\n bodyTop: top,\n bodyLeft: left,\n width: w,\n height: h,\n centerX: left + w / 2,\n centerY: top + h / 2\n }\n }\n\n static descendentMetrics (parent: PageElement, kid: PageElement): LayoutMetrics {\n const parentMetrics = Doc.layoutMetrics(parent)\n const kidMetrics = Doc.layoutMetrics(kid)\n return {\n bodyTop: kidMetrics.bodyTop - parentMetrics.bodyTop,\n bodyLeft: kidMetrics.bodyLeft - parentMetrics.bodyLeft,\n width: kidMetrics.width,\n height: kidMetrics.height,\n centerX: kidMetrics.centerX - parentMetrics.bodyLeft,\n centerY: kidMetrics.centerY - parentMetrics.bodyTop\n }\n }\n\n /* empty removes all child nodes from the specified element. */\n static empty (...els: Element[]) {\n for (const el of els) while (el.firstChild) el.removeChild(el.firstChild)\n }\n\n /*\n * setContent removes all child nodes from the specified element and appends\n * passed elements.\n */\n static setContent (ancestor: PageElement, ...kids: PageElement[]) {\n Doc.empty(ancestor)\n for (const k of kids) ancestor.appendChild(k)\n }\n\n /*\n * hide hides the specified elements. This is accomplished by adding the\n * bootstrap d-hide class to the element. Use Doc.show to undo.\n */\n static hide (...els: Element[]) {\n for (const el of els) el.classList.add('d-hide')\n }\n\n /*\n * show shows the specified elements. This is accomplished by removing the\n * bootstrap d-hide class as added with Doc.hide.\n */\n static show (...els: Element[]) {\n for (const el of els) el.classList.remove('d-hide')\n }\n\n /*\n * show or hide the specified elements, based on value of the truthiness of\n * vis.\n */\n static setVis (vis: any, ...els: Element[]) {\n if (vis) Doc.show(...els)\n else Doc.hide(...els)\n }\n\n /* isHidden returns true if the specified element is hidden */\n static isHidden (el: Element): boolean {\n return el.classList.contains('d-hide')\n }\n\n /* isDisplayed returns true if the specified element is not hidden */\n static isDisplayed (el: Element): boolean {\n return !el.classList.contains('d-hide')\n }\n\n /*\n * animate runs the supplied function, which should be a \"progress\" function\n * accepting one argument. The progress function will be called repeatedly\n * with the argument varying from 0.0 to 1.0. The exact path that animate\n * takes from 0.0 to 1.0 will vary depending on the choice of easing\n * algorithm. See the Easing object for the available easing algo choices. The\n * default easing algorithm is linear.\n */\n static async animate (duration: number, f: (progress: number) => void, easingAlgo?: string) {\n await new Animation(duration, f, easingAlgo).wait()\n }\n\n static applySelector (ancestor: HTMLElement, k: string): PageElement[] {\n return Array.from(ancestor.querySelectorAll(k)) as PageElement[]\n }\n\n static kids (ancestor: HTMLElement): PageElement[] {\n return Array.from(ancestor.children) as PageElement[]\n }\n\n static safeSelector (ancestor: HTMLElement, k: string): PageElement {\n const el = ancestor.querySelector(k)\n if (el) return el as PageElement\n console.warn(`no element found for selector '${k}' on element ->`, ancestor)\n return document.createElement('div')\n }\n\n /*\n * idDescendants creates an object mapping to elements which are descendants\n * of the ancestor and have id attributes. Elements are keyed by their id\n * value.\n */\n static idDescendants (ancestor: HTMLElement): Record {\n const d: Record = {}\n for (const el of Doc.applySelector(ancestor, '[id]')) d[el.id] = el\n return d\n }\n\n /*\n * formatCoinValue formats the value in atomic units into a string\n * representation in conventional units. If the value happens to be an\n * integer, no decimals are displayed. Trailing zeros may be truncated.\n */\n static formatCoinValue (vAtomic: number, unitInfo?: UnitInfo): string {\n const [v, prec] = convertToConventional(vAtomic, unitInfo)\n if (Number.isInteger(v)) return intFormatter.format(v)\n return decimalFormatter(prec).format(v)\n }\n\n static formatThreeSigFigs (v: number): string {\n if (v >= 1000) return intFormatter.format(Math.round(v))\n return threeSigFigs.format(v)\n }\n\n static formatFiveSigFigs (v: number, prec?: number): string {\n if (v >= 10000) return intFormatter.format(Math.round(v))\n else if (v < 1e5) return fullPrecisionFormatter(prec ?? 8 /* rate encoding factor */).format(v)\n return fiveSigFigs.format(v)\n }\n\n /*\n * formatFullPrecision formats the value in atomic units into a string\n * representation in conventional units using the full decimal precision\n * associated with the conventional unit's conversion factor.\n */\n static formatFullPrecision (vAtomic: number, unitInfo?: UnitInfo): string {\n const [v, prec] = convertToConventional(vAtomic, unitInfo)\n return fullPrecisionFormatter(prec).format(v)\n }\n\n /*\n * formatFiatConversion formats the value in atomic units to its representation in\n * conventional units and returns the fiat value as a string.\n */\n static formatFiatConversion (vAtomic: number, rate: number, unitInfo?: UnitInfo): string {\n if (!rate || rate === 0) return intl.prep(intl.ID_UNAVAILABLE)\n const prec = 2\n const [v] = convertToConventional(vAtomic, unitInfo)\n const value = v * rate\n return fullPrecisionFormatter(prec).format(value)\n }\n\n /*\n * logoPath creates a path to a png logo for the specified ticker symbol. If\n * the symbol is not a supported asset, the generic letter logo will be\n * requested instead.\n */\n static logoPath (symbol: string): string {\n if (BipSymbols.indexOf(symbol) === -1) symbol = symbol.substring(0, 1)\n return `/img/coins/${symbol}.png`\n }\n\n static bipSymbol (assetID: number): string {\n return BipIDs[assetID]\n }\n\n static logoPathFromID (assetID: number): string {\n return Doc.logoPath(BipIDs[assetID])\n }\n\n /*\n * symbolize creates a token-aware symbol element for the asset's symbol. For\n * non-token assets, this is simply a SYMBOL. For tokens, it'll\n * be SYMBOLPARENT.\n */\n static symbolize (symbol: string): PageElement {\n const parts = symbol.split('.')\n const assetSymbol = document.createElement('span')\n assetSymbol.textContent = parts[0].toUpperCase()\n if (parts.length === 1) return assetSymbol\n const span = document.createElement('span')\n span.classList.add('token-aware-symbol')\n span.appendChild(assetSymbol)\n const parent = document.createElement('sup')\n parent.textContent = parts[1].toUpperCase()\n span.appendChild(parent)\n return span\n }\n\n /*\n * shortSymbol removes the short format of a symbol, with any parent chain\n * identifier removed\n */\n static shortSymbol (symbol: string): string {\n return symbol.split('.')[0].toUpperCase()\n }\n\n /*\n * cleanTemplates removes the elements from the DOM and deletes the id\n * attribute.\n */\n static cleanTemplates (...tmpls: HTMLElement[]) {\n tmpls.forEach(tmpl => {\n tmpl.remove()\n tmpl.removeAttribute('id')\n })\n }\n\n /*\n * tmplElement is a helper function for grabbing sub-elements of the market list\n * template.\n */\n static tmplElement (ancestor: Document | HTMLElement, s: string): PageElement {\n return ancestor.querySelector(`[data-tmpl=\"${s}\"]`) || document.createElement('div')\n }\n\n /*\n * parseTemplate returns an object of data-tmpl elements, keyed by their\n * data-tmpl values.\n */\n static parseTemplate (ancestor: HTMLElement): Record {\n const d: Record = {}\n for (const el of Doc.applySelector(ancestor, '[data-tmpl]')) d[el.dataset.tmpl || ''] = el\n return d\n }\n\n /*\n * timeSince returns a string representation of the duration since the\n * specified unix timestamp.\n */\n static timeSince (t: number): string {\n return Doc.formatDuration((new Date().getTime()) - t)\n }\n\n /* formatDuration returns a string representation of the duration */\n static formatDuration (dur: number): string {\n let seconds = Math.floor(dur)\n let result = ''\n let count = 0\n const add = (n: number, s: string) => {\n if (n > 0 || count > 0) count++\n if (n > 0) result += `${n} ${s} `\n return count >= 2\n }\n let y, mo, d, h, m, s\n [y, seconds] = timeMod(seconds, aYear)\n if (add(y, 'y')) { return result }\n [mo, seconds] = timeMod(seconds, aMonth)\n if (add(mo, 'mo')) { return result }\n [d, seconds] = timeMod(seconds, aDay)\n if (add(d, 'd')) { return result }\n [h, seconds] = timeMod(seconds, anHour)\n if (add(h, 'h')) { return result }\n [m, seconds] = timeMod(seconds, aMinute)\n if (add(m, 'm')) { return result }\n [s, seconds] = timeMod(seconds, 1000)\n add(s, 's')\n return result || '0 s'\n }\n\n /*\n * disableMouseWheel can be used to disable the mouse wheel for any\n * input. It is very easy to unknowingly scroll up on a number input\n * and then submit an unexpected value. This function prevents the\n * scroll increment/decrement behavior for a wheel action on a\n * number input.\n */\n static disableMouseWheel (...inputFields: Element[]) {\n for (const inputField of inputFields) {\n inputField.addEventListener('wheel', (ev) => {\n ev.preventDefault()\n })\n }\n }\n\n // showFormError can be used to set and display error message on forms.\n static showFormError (el: PageElement, msg: any) {\n el.textContent = msg\n Doc.show(el)\n }\n}\n\n/*\n * Animation is a handler for starting and stopping animations.\n */\nexport class Animation {\n done: (() => void) | undefined\n endAnimation: boolean\n thread: Promise\n static Forever: number\n\n constructor (duration: number, f: (progress: number) => void, easingAlgo?: string, done?: () => void) {\n this.done = done\n this.thread = this.run(duration, f, easingAlgo)\n }\n\n /*\n * run runs the animation function, increasing progress from 0 to 1 in a\n * manner dictated by easingAlgo.\n */\n async run (duration: number, f: (progress: number) => void, easingAlgo?: string) {\n duration = duration >= 0 ? duration : 1000 * 86400 * 365 * 10 // 10 years, in ms\n const easer = easingAlgo ? Easing[easingAlgo] : Easing.linear\n const start = new Date().getTime()\n const end = (duration === Animation.Forever) ? Number.MAX_SAFE_INTEGER : start + duration\n const range = end - start\n const frameDuration = 1000 / FPS\n let now = start\n this.endAnimation = false\n while (now < end) {\n if (this.endAnimation) return this.runCompletionFunction()\n f(easer((now - start) / range))\n await sleep(frameDuration)\n now = new Date().getTime()\n }\n f(1)\n this.runCompletionFunction()\n }\n\n /* wait returns a promise that will resolve when the animation completes. */\n async wait () {\n await this.thread\n }\n\n /* stop schedules the animation to exit at its next frame. */\n stop () {\n this.endAnimation = true\n }\n\n /*\n * stopAndWait stops the animations and returns a promise that will resolve\n * when the animation exits.\n */\n async stopAndWait () {\n this.stop()\n await this.wait()\n }\n\n /* runCompletionFunction runs any registered callback function */\n runCompletionFunction () {\n if (this.done) this.done()\n }\n}\nAnimation.Forever = -1\n\n/* Easing algorithms for animations. */\nexport const Easing: Record number> = {\n linear: t => t,\n easeIn: t => t * t,\n easeOut: t => t * (2 - t),\n easeInHard: t => t * t * t,\n easeOutHard: t => (--t) * t * t + 1,\n easeOutElastic: t => {\n const c4 = (2 * Math.PI) / 3\n return t === 0\n ? 0\n : t === 1\n ? 1\n : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1\n }\n}\n\n/* WalletIcons are used for controlling wallets in various places. */\nexport class WalletIcons {\n icons: Record\n status: Element\n\n constructor (box: HTMLElement) {\n const stateElement = (name: string) => box.querySelector(`[data-state=${name}]`) as HTMLElement\n this.icons = {}\n this.icons.sleeping = stateElement('sleeping')\n this.icons.locked = stateElement('locked')\n this.icons.unlocked = stateElement('unlocked')\n this.icons.nowallet = stateElement('nowallet')\n this.icons.syncing = stateElement('syncing')\n this.icons.nopeers = stateElement('nopeers')\n this.icons.disabled = stateElement('disabled')\n this.status = stateElement('status')\n }\n\n /* sleeping sets the icons to indicate that the wallet is not connected. */\n sleeping () {\n const i = this.icons\n Doc.hide(i.locked, i.unlocked, i.nowallet, i.syncing, i.disabled)\n Doc.show(i.sleeping)\n if (this.status) this.status.textContent = intl.prep(intl.ID_OFF)\n }\n\n /*\n * locked sets the icons to indicate that the wallet is connected, but locked.\n */\n locked () {\n const i = this.icons\n Doc.hide(i.unlocked, i.nowallet, i.sleeping, i.disabled)\n Doc.show(i.locked)\n if (this.status) this.status.textContent = intl.prep(intl.ID_LOCKED)\n }\n\n /*\n * unlocked sets the icons to indicate that the wallet is connected and\n * unlocked.\n */\n unlocked () {\n const i = this.icons\n Doc.hide(i.locked, i.nowallet, i.sleeping, i.disabled)\n Doc.show(i.unlocked)\n if (this.status) this.status.textContent = intl.prep(intl.ID_READY)\n }\n\n /* nowallet sets the icons to indicate that no wallet exists. */\n nowallet () {\n const i = this.icons\n Doc.hide(i.locked, i.unlocked, i.sleeping, i.syncing, i.disabled)\n Doc.show(i.nowallet)\n if (this.status) this.status.textContent = intl.prep(intl.ID_NO_WALLET)\n }\n\n /* set the icons to indicate that the wallet is disabled */\n disabled () {\n const i = this.icons\n Doc.hide(i.locked, i.unlocked, i.sleeping, i.syncing, i.nowallet, i.nopeers)\n Doc.show(i.disabled)\n i.disabled.dataset.tooltip = intl.prep(intl.ID_DISABLED_MSG)\n }\n\n setSyncing (wallet: WalletState | null) {\n const syncIcon = this.icons.syncing\n if (!wallet || !wallet.running || wallet.disabled) {\n Doc.hide(syncIcon)\n return\n }\n\n if (wallet.peerCount === 0) {\n Doc.show(this.icons.nopeers)\n Doc.hide(syncIcon) // potentially misleading with no peers\n return\n }\n Doc.hide(this.icons.nopeers)\n\n if (!wallet.synced) {\n Doc.show(syncIcon)\n syncIcon.dataset.tooltip = intl.prep(intl.ID_WALLET_SYNC_PROGRESS, { syncProgress: (wallet.syncProgress * 100).toFixed(1) })\n return\n }\n Doc.hide(syncIcon)\n }\n\n /* reads the core.Wallet state and sets the icon visibility. */\n readWallet (wallet: WalletState | null) {\n this.setSyncing(wallet)\n if (!wallet) return this.nowallet()\n switch (true) {\n case (wallet.disabled):\n this.disabled()\n break\n case (!wallet.running):\n this.sleeping()\n break\n case (!wallet.open):\n this.locked()\n break\n case (wallet.open):\n this.unlocked()\n break\n default:\n console.error('wallet in unknown state', wallet)\n }\n }\n}\n\n/* sleep can be used by async functions to pause for a specified period. */\nfunction sleep (ms: number) {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\nconst aYear = 31536000000\nconst aMonth = 2592000000\nconst aDay = 86400000\nconst anHour = 3600000\nconst aMinute = 60000\n\n/* timeMod returns the quotient and remainder of t / dur. */\nfunction timeMod (t: number, dur: number) {\n const n = Math.floor(t / dur)\n return [n, t - n * dur]\n}\n","// State is a set of static methods for working with the user state. It has\n// utilities for setting and retrieving cookies and storing user configuration\n// to localStorage.\nexport default class State {\n // Cookie keys.\n static darkModeCK = 'darkMode'\n static authCK = 'dexauth'\n static pwKeyCK = 'sessionkey'\n // Local storage keys (for data that we don't need at the server).\n static popupsLK = 'popups'\n static loggersLK = 'loggers'\n static recordersLK = 'recorders'\n static lastMarketLK = 'selectedMarket'\n static depthZoomLK = 'depthZoom'\n static lastMMMarketLK = 'mmMarket'\n static optionsExpansionLK = 'mmOptsExpand'\n static leftMarketDockLK = 'leftmarketdock'\n static selectedAssetLK = 'selectedasset'\n static notificationsLK = 'notifications'\n static orderDisclaimerAckedLK = 'ordAck'\n static lastCandleDurationLK = 'lastCandleDuration'\n\n static setCookie (cname: string, cvalue: string) {\n const d = new Date()\n // Set cookie to expire in ten years.\n d.setTime(d.getTime() + (86400 * 365 * 10 * 1000))\n const expires = 'expires=' + d.toUTCString()\n document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'\n }\n\n /*\n * getCookie returns the value at the specified cookie name, otherwise null.\n */\n static getCookie (cname: string) {\n for (const cstr of document.cookie.split(';')) {\n const [k, v] = cstr.split('=')\n if (k.trim() === cname) return v\n }\n return null\n }\n\n /*\n * removeCookie tells the browser to stop using cookie. It's not enough to simply\n * erase cookie value because browser will still send it to the server (with empty\n * value), and that's not what server expects.\n */\n static removeCookie (cKey: string) {\n document.cookie = `${cKey}=;expires=Thu, 01 Jan 1970 00:00:01 GMT;`\n }\n\n /*\n * isDark returns true if the dark-mode cookie is currently set to '1' = true.\n */\n static isDark () {\n return document.cookie.split(';').filter((item) => item.includes(`${State.darkModeCK}=1`)).length\n }\n\n /* passwordIsCached returns whether or not there is a cached password in the cookies. */\n static passwordIsCached () {\n return !!this.getCookie(State.pwKeyCK)\n }\n\n /* storeLocal puts the key-value pair into Window.localStorage. */\n static storeLocal (k: string, v: any) {\n window.localStorage.setItem(k, JSON.stringify(v))\n }\n\n /*\n * fetchLocal the value associated with the key in Window.localStorage, or\n * null if the no value exists for the key.\n */\n static fetchLocal (k: string) {\n const v = window.localStorage.getItem(k)\n if (v !== null) {\n return JSON.parse(v)\n }\n return null\n }\n\n /* removeLocal removes the key-value pair from Window.localStorage. */\n static removeLocal (k: string) {\n window.localStorage.removeItem(k)\n }\n}\n\n// Setting defaults here, unless specific cookie (or local storage) value was already chosen by the user.\nif (State.getCookie(State.darkModeCK) === null) State.setCookie(State.darkModeCK, '1')\nif (State.fetchLocal(State.popupsLK) === null) State.storeLocal(State.popupsLK, '1')\nif (State.fetchLocal(State.leftMarketDockLK) === null) State.storeLocal(State.leftMarketDockLK, '1')\n","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n}","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}","import _typeof from \"./typeof.js\";\nimport assertThisInitialized from \"./assertThisInitialized.js\";\nexport default function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n return assertThisInitialized(self);\n}","export default function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}","/*\n * requestJSON encodes the object and sends the JSON to the specified address.\n */\nexport async function requestJSON (method: string, addr: string, reqBody?: any): Promise {\n try {\n const response = await window.fetch(addr, {\n method: method,\n headers: new window.Headers({ 'content-type': 'application/json' }),\n // credentials: \"same-origin\",\n body: reqBody\n })\n if (response.status !== 200) { throw response }\n const obj = await response.json()\n obj.requestSuccessful = true\n return obj\n } catch (response) {\n response.requestSuccessful = false\n response.msg = await response.text()\n return response\n }\n}\n\n/*\n * postJSON sends a POST request with JSON-formatted data and returns the\n * response.\n */\nexport async function postJSON (addr: string, data?: any) {\n return requestJSON('POST', addr, JSON.stringify(data))\n}\n\n/*\n * getJSON sends a GET request and returns the response.\n */\nexport async function getJSON (addr: string): Promise {\n return requestJSON('GET', addr)\n}\n\nexport enum Errors {\n walletErr,\n walletAuthErr,\n walletBalanceErr,\n dupeDEXErr,\n assetSupportErr,\n registerErr,\n signatureErr,\n zeroFeeErr,\n feeMismatchErr,\n feeSendErr,\n passwordErr,\n emptyHostErr,\n connectionErr,\n acctKeyErr,\n unknownOrderErr,\n orderParamsErr,\n dbErr,\n authErr,\n connectWalletErr,\n missingWalletErr,\n encryptionErr,\n decodeErr,\n accountVerificationErr,\n accountProofErr,\n parseKeyErr,\n marketErr,\n addressParseErr,\n addrErr,\n fileReadErr,\n unknownDEXErr,\n accountRetrieveErr,\n accountDisableErr,\n suspendedAcctErr,\n existenceCheckErr,\n createWalletErr,\n activeOrdersErr,\n newAddrErr,\n}\n","declare global {\n interface Window {\n log: (...args: any) => void\n enableLogger: (loggerID: string, enable: boolean) => void\n recordLogger: (loggerID: string, enable: boolean) => void\n dumpLogger: (loggerID: string) => void\n localeDiscrepancies: () => void\n }\n}\n\nexport enum ConnectionStatus {\n Disconnected = 0,\n Connected = 1,\n InvalidCert = 2,\n}\n\nexport interface BondOptions {\n bondAsset: number\n targetTier: number\n maxBondedAmt: number\n}\n\nexport interface Exchange {\n host: string\n acctID: string\n markets: Record\n assets: Record\n connectionStatus: ConnectionStatus\n viewOnly: boolean\n bondAssets: Record\n tier: number\n bondOptions: BondOptions\n pendingBonds: Record\n candleDurs: string[]\n}\n\nexport interface Candle {\n startStamp: number\n endStamp: number\n matchVolume: number\n quoteVolume: number\n highRate: number\n lowRate: number\n startRate: number\n endRate: number\n}\n\nexport interface CandlesPayload {\n dur: string\n ms: number\n candles: Candle[]\n}\n\nexport interface Market {\n name: string\n baseid: number\n basesymbol: string\n quoteid: number\n quotesymbol: string\n lotsize: number\n ratestep: number\n epochlen: number\n startepoch: number\n buybuffer: number\n orders: Order[]\n spot: Spot | undefined\n atomToConv: number\n inflight: InFlightOrder[]\n}\n\nexport interface InFlightOrder extends Order {\n tempID: number\n}\n\nexport interface Order {\n host: string\n baseID: number\n baseSymbol: string\n quoteID: number\n quoteSymbol: string\n market: string\n type: number\n id: string\n stamp: number\n submitTime: number\n sig: string\n status: number\n epoch: number\n qty: number\n sell: boolean\n filled: number\n matches: Match[]\n cancelling: boolean\n canceled: boolean\n feesPaid: FeeBreakdown\n fundingCoins: Coin[]\n accelerationCoins: Coin[]\n lockedamt: number\n rate: number // limit only\n tif: number // limit only\n targetOrderID: string // cancel only\n readyToTick: boolean\n}\n\nexport interface Match {\n matchID: string\n status: number\n active: boolean\n revoked: boolean\n rate: number\n qty: number\n side: number\n feeRate: number\n swap: Coin\n counterSwap: Coin\n redeem: Coin\n counterRedeem: Coin\n refund: Coin\n stamp: number\n isCancel: boolean\n}\n\nexport interface Spot {\n stamp: number\n baseID: number\n quoteID: number\n rate: number\n bookVolume: number // Unused?\n change24: number\n vol24: number\n low24: number\n high24: number\n}\n\nexport interface Asset {\n id: number\n symbol: string\n version: number\n maxFeeRate: number\n swapSize: number\n swapSizeBase: number\n redeemSize: number\n swapConf: number\n unitInfo: UnitInfo\n}\n\nexport interface BondAsset {\n ver: number\n id: number\n confs: number\n amount: number\n}\n\nexport interface PendingBondState {\n symbol: string\n assetID: number\n confs: number\n}\n\nexport interface FeeBreakdown {\n swap: number\n redemption: number\n}\n\nexport interface SupportedAsset {\n id: number\n symbol: string\n name: string\n wallet: WalletState\n info?: WalletInfo\n token?: Token\n unitInfo: UnitInfo\n walletCreationPending: boolean\n}\n\nexport interface Token {\n parentID: number\n name: string\n unitInfo: UnitInfo\n definition: WalletDefinition\n}\n\nexport interface WalletState {\n symbol: string\n assetID: number\n version: number\n type: string\n traits: number\n open: boolean\n running: boolean\n disabled: boolean\n balance: WalletBalance\n address: string\n units: string\n encrypted: boolean\n peerCount: number\n synced: boolean\n syncProgress: number\n}\n\nexport interface WalletInfo {\n name: string\n version: number\n availablewallets: WalletDefinition[]\n versions: number[]\n emptyidx: number\n unitinfo: UnitInfo\n}\n\nexport interface WalletBalance {\n available: number\n immature: number\n locked: number\n stamp: string // time.Time\n orderlocked: number\n contractlocked: number\n bondlocked: number\n other: Record\n}\n\nexport interface WalletDefinition {\n seeded: boolean\n type: string\n tab: string\n description: string\n configpath: string\n configopts: ConfigOption[]\n noauth: boolean\n guidelink: string\n}\n\nexport interface ConfigOption {\n key: string\n displayname: string\n description: string\n default: any\n max: any\n min: any\n noecho: boolean\n isboolean: boolean\n isdate: boolean\n disablewhenactive: boolean\n isBirthdayConfig: boolean\n repeatable?: string\n repeatN?: number\n noauth: boolean\n regAsset?: number\n required?: boolean\n}\n\nexport interface Coin {\n id: string\n stringID: string\n assetID: number\n symbol: string\n confs: Confirmations\n}\n\nexport interface Confirmations {\n required: number\n count: number\n}\n\nexport interface UnitInfo {\n atomicUnit: string\n conventional: Denomination\n denominations: Denomination[]\n}\n\nexport interface Denomination {\n unit: string\n conversionFactor: number\n}\n\nexport interface User {\n exchanges: Record\n inited: boolean\n seedgentime: number\n assets: Record\n fiatRates: Record\n authed: boolean // added by webserver\n ok: boolean // added by webserver\n bots: BotReport[]\n}\n\nexport interface CoreNote {\n type: string\n topic: string\n subject: string\n details: string\n severity: number\n stamp: number\n acked: boolean\n id: string\n}\n\nexport interface BondNote extends CoreNote {\n asset: number\n confirmations: number\n dex: string\n coinID: string | null\n tier: number | null\n}\n\nexport interface BalanceNote extends CoreNote {\n assetID: number\n balance: WalletBalance\n}\n\nexport interface RateNote extends CoreNote {\n fiatRates: Record\n}\n\nexport interface WalletConfigNote extends CoreNote {\n wallet: WalletState\n}\n\nexport type WalletStateNote = WalletConfigNote\n\nexport interface WalletCreationNote extends CoreNote {\n assetID: number\n}\n\nexport interface SpotPriceNote extends CoreNote {\n host: string\n spots: Record\n}\n\nexport interface BotNote extends CoreNote {\n report: BotReport\n}\n\nexport interface MatchNote extends CoreNote {\n orderID: string\n match: Match\n host: string\n marketID: string\n}\n\nexport interface ConnEventNote extends CoreNote {\n host: string\n connectionStatus: ConnectionStatus\n}\n\nexport interface OrderNote extends CoreNote {\n order: Order\n tempID: number\n}\n\nexport interface RecentMatch {\n rate: number\n qty: number\n stamp: number\n sell: boolean\n}\n\nexport interface EpochNote extends CoreNote {\n host: string\n marketID: string\n epoch: number\n}\n\nexport interface APIResponse {\n requestSuccessful: boolean\n ok: boolean\n msg: string\n err?: string\n}\n\nexport interface LogMessage {\n time: string\n msg: string\n}\n\nexport interface NoteElement extends HTMLElement {\n note: CoreNote\n}\n\nexport interface BalanceResponse extends APIResponse {\n balance: WalletBalance\n}\n\nexport interface LayoutMetrics {\n bodyTop: number\n bodyLeft: number\n width: number\n height: number\n centerX: number\n centerY: number\n}\n\nexport interface PasswordCache {\n pw: string\n}\n\nexport interface PageElement extends HTMLElement {\n value?: string\n src?: string\n files?: FileList\n checked?: boolean\n href?: string\n htmlFor?: string\n}\n\nexport interface BooleanConfig {\n reason: string\n}\n\nexport interface XYRangePoint {\n label: string\n x: number\n y: number\n}\n\nexport interface XYRange {\n start: XYRangePoint\n end: XYRangePoint\n xUnit: string\n yUnit: string\n}\n\nexport interface OrderOption extends ConfigOption {\n boolean?: BooleanConfig\n xyRange?: XYRange\n showByDefault?: boolean\n}\n\nexport interface SwapEstimate {\n lots: number\n value: number\n maxFees: number\n realisticWorstCase: number\n realisticBestCase: number\n}\n\nexport interface RedeemEstimate {\n realisticBestCase: number\n realisticWorstCase: number\n}\n\nexport interface PreSwap {\n estimate: SwapEstimate\n options: OrderOption[]\n}\n\nexport interface PreRedeem {\n estimate: RedeemEstimate\n options: OrderOption[]\n}\n\nexport interface OrderEstimate {\n swap: PreSwap\n redeem: PreRedeem\n}\n\nexport interface MaxOrderEstimate {\n swap: SwapEstimate\n redeem: RedeemEstimate\n}\n\nexport interface MaxSell {\n maxSell: MaxOrderEstimate\n}\n\nexport interface MaxBuy {\n maxBuy: MaxOrderEstimate\n}\n\nexport interface TradeForm {\n host: string\n isLimit: boolean\n sell: boolean\n base: number\n quote: number\n qty: number\n rate: number\n tifnow: boolean\n options: Record\n}\n\nexport interface BookUpdate {\n action: string\n host: string\n marketID: string\n matchesSummary: RecentMatch[]\n payload: any\n}\n\nexport interface MiniOrder {\n qty: number\n qtyAtomic: number\n rate: number\n msgRate: number\n epoch: number\n sell: boolean\n token: string\n}\n\nexport interface CoreOrderBook {\n sells: MiniOrder[]\n buys: MiniOrder[]\n epoch: MiniOrder[]\n recentMatches: RecentMatch[]\n}\n\nexport interface MarketOrderBook {\n base: number\n quote: number\n book: CoreOrderBook\n}\n\nexport interface RemainderUpdate {\n token: string\n qty: number\n qtyAtomic: number\n}\n\nexport interface OrderFilter {\n n?: number\n offset?: string\n hosts: string[]\n assets: number[]\n statuses: number[]\n}\n\nexport interface MakerProgram {\n host: string\n baseID: number\n quoteID: number\n lots: number\n oracleWeighting: number\n oracleBias: number\n driftTolerance: number\n gapFactor: number\n gapStrategy: string\n}\n\nexport interface BotOrder {\n host: string\n marketID: string\n orderID: string\n}\n\nexport interface BotReport {\n programID: number\n program: MakerProgram\n running: boolean\n orders: BotOrder\n}\n\nexport interface MarketReport {\n basisPrice: number\n price: number\n oracles: OracleReport[]\n breakEvenSpread: number\n}\n\nexport interface OracleReport {\n host: string\n usdVol: number\n bestBuy: number\n bestSell: number\n}\n\n// changing the order of the elements in this enum will affect\n// the sorting of the peers table in wallets.ts.\nexport enum PeerSource {\n WalletDefault,\n UserAdded,\n Discovered,\n}\n\nexport interface WalletPeer {\n addr: string\n source: PeerSource\n connected: boolean\n}\n\nexport interface Application {\n assets: Record\n seedGenTime: number\n user: User\n header: HTMLElement\n headerSpace: HTMLElement\n walletMap: Record\n exchanges: Record\n fiatRatesMap: Record\n showPopups: boolean\n commitHash: string\n authed(): boolean\n start (): Promise\n reconnected (): void\n fetchUser (): Promise\n loadPage (page: string, data?: any, skipPush?: boolean): Promise\n attach (data: any): void\n bindTooltips (ancestor: HTMLElement): void\n attachHeader (): void\n showDropdown (icon: HTMLElement, dialog: HTMLElement): void\n ackNotes (): void\n setNoteTimes (noteList: HTMLElement): void\n bindInternalNavigation (ancestor: HTMLElement): void\n storeNotes (): void\n updateMenuItemsDisplay (): void\n attachCommon (node: HTMLElement): void\n updateBondConfs (dexAddr: string, coinID: string, confs: number, assetID: number): void\n handleBondNote (note: BondNote): void\n setNotes (notes: CoreNote[]): void\n notify (note: CoreNote): void\n log (loggerID: string, ...msg: any): void\n prependPokeElement (note: CoreNote): void\n prependNoteElement (note: CoreNote, skipSave?: boolean): void\n prependListElement (noteList: HTMLElement, note: CoreNote, el: NoteElement): void\n loading (el: HTMLElement): () => void\n orders (host: string, mktID: string): Order[]\n haveActiveOrders (assetID: number): boolean\n order (oid: string): Order | null\n canAccelerateOrder(order: Order): boolean\n unitInfo (assetID: number, xc?: Exchange): UnitInfo\n conventionalRate (baseID: number, quoteID: number, encRate: number, xc?: Exchange): number\n walletDefinition (assetID: number, walletType: string): WalletDefinition\n currentWalletDefinition (assetID: number): WalletDefinition\n fetchBalance (assetID: number): Promise\n checkResponse (resp: APIResponse): boolean\n signOut (): Promise\n registerNoteFeeder (receivers: Record void>): void\n}\n\n// TODO: Define an interface for Application?\nlet application: Application\n\nexport function registerApplication (a: Application) {\n application = a\n}\n\nexport function app (): Application {\n return application\n}\n","import Doc from './doc'\nimport {\n PageElement,\n XYRange,\n OrderOption\n} from './registry'\n\ninterface OptionsReporters {\n enable: () => void\n disable: () => void\n}\n\n// Having the caller set these vars on load using an exported function makes\n// life easier.\nlet orderOptTmpl: HTMLElement, booleanOptTmpl: HTMLElement, rangeOptTmpl: HTMLElement\n\n// setOptionTemplates sets the package vars for the templates and application.\nexport function setOptionTemplates (page: Record): void {\n [booleanOptTmpl, rangeOptTmpl, orderOptTmpl] = [page.booleanOptTmpl, page.rangeOptTmpl, page.orderOptTmpl]\n}\n\nconst threeSigFigs = new Intl.NumberFormat((navigator.languages as string[]), {\n minimumSignificantDigits: 3,\n maximumSignificantDigits: 3\n})\n\n/*\n * Option is a base class for option elements. Option stores some common\n * parameters and monitors the toggle switch, calling the child class's\n * enable/disable methods when the user manually turns the option on or off.\n */\nexport class Option {\n opt: OrderOption\n node: HTMLElement\n tmpl: Record\n on: boolean\n\n constructor (opt: OrderOption, symbol: string, report: OptionsReporters) {\n this.opt = opt\n const node = this.node = orderOptTmpl.cloneNode(true) as HTMLElement\n const tmpl = this.tmpl = Doc.parseTemplate(node)\n\n tmpl.optName.textContent = opt.displayname\n tmpl.tooltip.dataset.tooltip = opt.description\n\n // const isBaseChain = (isSwapOption && order.sell) || (!isSwapOption && !order.sell)\n // const symbol = isBaseChain ? this.baseSymbol() : this.quoteSymbol()\n if (symbol) tmpl.chainIcon.src = Doc.logoPath(symbol)\n else Doc.hide(tmpl.chainIcon)\n\n this.on = false\n Doc.bind(node, 'click', () => {\n if (this.on) return\n this.on = true\n node.classList.add('selected')\n report.enable()\n })\n Doc.bind(tmpl.toggle, 'click', e => {\n if (!this.on) return\n e.stopPropagation()\n this.on = false\n node.classList.remove('selected')\n report.disable()\n })\n }\n}\n\n/*\n * BooleanOption is a simple on/off option with a short summary of it's effects.\n * BooleanOrderOption is the handler for a *BooleanConfig from client/asset.\n */\nexport class BooleanOption extends Option {\n control: HTMLElement\n changed: () => void\n dict: Record\n\n constructor (opt: OrderOption, symbol: string, dict: Record, changed: () => void) {\n super(opt, symbol, {\n enable: () => this.enable(),\n disable: () => this.disable()\n })\n this.dict = dict\n this.changed = () => changed()\n if (opt.boolean === undefined) throw Error('not a boolean opt')\n const cfg = opt.boolean\n const control = this.control = booleanOptTmpl.cloneNode(true) as HTMLElement\n // Append to parent's options div.\n this.tmpl.controls.appendChild(control)\n const tmpl = Doc.parseTemplate(control)\n tmpl.reason.textContent = cfg.reason\n this.on = typeof dict[opt.key] !== 'undefined' ? dict[opt.key] : opt.default\n if (this.on) this.node.classList.add('selected')\n }\n\n store (): void {\n if (this.on === this.opt.default) delete this.dict[this.opt.key]\n else this.dict[this.opt.key] = this.on\n this.changed()\n }\n\n enable (): void {\n this.store()\n }\n\n disable (): void {\n this.store()\n }\n}\n\n/*\n * XYRangeOption is an order option that contains an XYRangeHandler. The logic\n * for handling the slider to is defined in XYRangeHandler so that the slider\n * can be used without being contained in an order option.\n */\nexport class XYRangeOption extends Option {\n handler: XYRangeHandler\n x: number\n changed: () => void\n dict: Record\n\n constructor (opt: OrderOption, symbol: string, dict: Record, changed: () => void) {\n super(opt, symbol, {\n enable: () => this.enable(),\n disable: () => this.disable()\n })\n this.dict = dict\n this.changed = changed\n if (opt.xyRange === undefined) throw Error('not an xy range opt')\n const cfg = opt.xyRange\n const setVal = dict[opt.key]\n this.on = typeof setVal !== 'undefined'\n if (this.on) {\n this.node.classList.add('selected')\n this.x = setVal\n } else {\n this.x = opt.default\n }\n const onUpdate = (x: number) => {\n this.x = x\n this.dict[this.opt.key] = x\n }\n const onChange = () => { this.changed() }\n const selected = () => { this.node.classList.add('selected') }\n this.handler = new XYRangeHandler(cfg, this.x, onUpdate, onChange, selected)\n this.tmpl.controls.appendChild(this.handler.control)\n }\n\n enable (): void {\n this.dict[this.opt.key] = this.x\n this.changed()\n }\n\n disable (): void {\n delete this.dict[this.opt.key]\n this.changed()\n }\n\n setValue (x: number): void {\n this.handler.setValue(x)\n this.on = true\n this.node.classList.add('selected')\n }\n}\n\n/*\n * XYRangeHandler is the handler for an *XYRange from client/asset. XYRange\n * has a slider which allows adjusting the x and y, linearly between two limits.\n * The user can also manually enter values for x or y.\n */\nexport class XYRangeHandler {\n control: HTMLElement\n cfg: XYRange\n tmpl: Record\n x: number\n scrollingX: number\n y: number\n r: number\n roundY: boolean\n updated: (x:number, y:number) => void\n changed: () => void\n selected: () => void\n setConfig: (cfg: XYRange) => void\n\n constructor (cfg: XYRange, initVal: number, updated: (x:number, y:number) => void, changed: () => void, selected: () => void, roundY?: boolean) {\n const control = this.control = rangeOptTmpl.cloneNode(true) as HTMLElement\n const tmpl = this.tmpl = Doc.parseTemplate(control)\n this.roundY = Boolean(roundY)\n this.cfg = cfg\n\n this.changed = changed\n this.selected = selected\n this.updated = updated\n\n const { slider, handle } = tmpl\n\n let rangeX = cfg.end.x - cfg.start.x\n let rangeY = cfg.end.y - cfg.start.y\n const normalizeX = (x: number) => (x - cfg.start.x) / rangeX\n\n const setConfig = (newCfg: XYRange) => {\n rangeX = newCfg.end.x - newCfg.start.x\n rangeY = newCfg.end.y - newCfg.start.y\n cfg = this.cfg = newCfg\n tmpl.rangeLblStart.textContent = cfg.start.label\n tmpl.rangeLblEnd.textContent = cfg.end.label\n tmpl.xUnit.textContent = cfg.xUnit\n tmpl.yUnit.textContent = cfg.yUnit\n this.y = this.r * rangeY + cfg.start.y\n this.r = (this.y - cfg.start.y) / rangeY\n this.scrollingX = this.r * rangeX + cfg.start.x\n }\n setConfig(cfg)\n\n this.setConfig = (cfg: XYRange) => {\n setConfig(cfg)\n this.accept(this.scrollingX)\n }\n\n // r, x, and y will be updated by the various input event handlers. r is\n // x (or y) normalized on its range, e.g. [x_min, x_max] -> [0, 1]\n this.r = normalizeX(initVal)\n this.scrollingX = this.x = initVal\n this.y = this.r * rangeY + cfg.start.y\n\n // Set up the handlers for the x and y text input fields.\n const clickOutX = (e: MouseEvent) => {\n if (e.type !== 'change' && e.target === tmpl.xInput) return\n const s = tmpl.xInput.value\n if (s) {\n const xx = parseFloat(s)\n if (!isNaN(xx)) {\n this.scrollingX = clamp(xx, cfg.start.x, cfg.end.x)\n this.r = normalizeX(this.scrollingX)\n this.y = this.r * rangeY + cfg.start.y\n this.accept(this.scrollingX)\n }\n }\n Doc.hide(tmpl.xInput)\n Doc.show(tmpl.x)\n Doc.unbind(document, 'click', clickOutX)\n this.changed()\n }\n\n Doc.bind(tmpl.x, 'click', e => {\n Doc.hide(tmpl.x)\n Doc.show(tmpl.xInput)\n tmpl.xInput.focus()\n tmpl.xInput.value = threeSigFigs.format(this.scrollingX)\n Doc.bind(document, 'click', clickOutX)\n e.stopPropagation()\n })\n\n Doc.bind(tmpl.xInput, 'change', clickOutX)\n\n const clickOutY = (e: MouseEvent) => {\n if (e.type !== 'change' && e.target === tmpl.yInput) return\n const s = tmpl.yInput.value\n if (s) {\n const yy = parseFloat(s)\n if (!isNaN(yy)) {\n this.y = clamp(yy, cfg.start.y, cfg.end.y)\n this.r = (this.y - cfg.start.y) / rangeY\n this.scrollingX = cfg.start.x + this.r * rangeX\n this.accept(this.scrollingX)\n }\n }\n Doc.hide(tmpl.yInput)\n Doc.show(tmpl.y)\n Doc.unbind(document, 'click', clickOutY)\n this.changed()\n }\n\n Doc.bind(tmpl.y, 'click', e => {\n Doc.hide(tmpl.y)\n Doc.show(tmpl.yInput)\n tmpl.yInput.focus()\n tmpl.yInput.value = threeSigFigs.format(this.y)\n Doc.bind(document, 'click', clickOutY)\n e.stopPropagation()\n })\n\n Doc.bind(tmpl.yInput, 'change', clickOutY)\n\n // Read the slider.\n Doc.bind(handle, 'mousedown', (e: MouseEvent) => {\n if (e.button !== 0) return\n e.preventDefault()\n this.selected()\n const startX = e.pageX\n const w = slider.clientWidth - handle.offsetWidth\n const startLeft = normalizeX(this.scrollingX) * w\n const left = (ee: MouseEvent) => Math.max(Math.min(startLeft + (ee.pageX - startX), w), 0)\n const trackMouse = (ee: MouseEvent) => {\n ee.preventDefault()\n this.r = left(ee) / w\n this.scrollingX = this.r * rangeX + cfg.start.x\n this.y = this.r * rangeY + cfg.start.y\n this.accept(this.scrollingX)\n }\n const mouseUp = (ee: MouseEvent) => {\n trackMouse(ee)\n Doc.unbind(document, 'mousemove', trackMouse)\n Doc.unbind(document, 'mouseup', mouseUp)\n this.changed()\n }\n Doc.bind(document, 'mousemove', trackMouse)\n Doc.bind(document, 'mouseup', mouseUp)\n })\n\n this.accept(this.scrollingX, true)\n }\n\n accept (x: number, skipUpdate?: boolean): void {\n const tmpl = this.tmpl\n if (this.roundY) this.y = Math.round(this.y)\n tmpl.x.textContent = threeSigFigs.format(x)\n tmpl.y.textContent = threeSigFigs.format(this.y)\n if (this.roundY) tmpl.y.textContent = `${this.y}`\n tmpl.handle.style.left = `calc(${this.r * 100}% - ${this.r * 14}px)`\n this.x = x\n this.scrollingX = x\n if (!skipUpdate) this.updated(x, this.y)\n }\n\n setValue (x: number) {\n const cfg = this.cfg\n this.r = (x - cfg.start.x) / (cfg.end.x - cfg.start.x)\n this.y = cfg.start.y + this.r * (cfg.end.y - cfg.start.y)\n this.accept(x, true)\n }\n}\n\nconst clamp = (v: number, min: number, max: number): number => v < min ? min : v > max ? max : v\n","export default class BasePage {\n /* unload is called when the user navigates away from the page. */\n unload () {\n // should be implemented by inheriting class.\n }\n}\n","import arrayWithoutHoles from \"./arrayWithoutHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableSpread from \"./nonIterableSpread.js\";\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}","export default function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import * as intl from './locales'\nimport {\n app,\n Order,\n TradeForm,\n OrderOption,\n Match\n} from './registry'\nimport { BooleanOption, XYRangeOption } from './opts'\n\nexport const Limit = 1\nexport const Market = 2\nexport const Cancel = 3\n\n/* The time-in-force specifiers are a mirror of dex/order.TimeInForce. */\nexport const ImmediateTiF = 0\nexport const StandingTiF = 1\n\n/* The order statuses are a mirror of dex/order.OrderStatus. */\nexport const StatusUnknown = 0\nexport const StatusEpoch = 1\nexport const StatusBooked = 2\nexport const StatusExecuted = 3\nexport const StatusCanceled = 4\nexport const StatusRevoked = 5\n\n/* The match statuses are a mirror of dex/order.MatchStatus. */\nexport const NewlyMatched = 0\nexport const MakerSwapCast = 1\nexport const TakerSwapCast = 2\nexport const MakerRedeemed = 3\nexport const MatchComplete = 4\nexport const MatchConfirmed = 5\n\n/* The match sides are a mirror of dex/order.MatchSide. */\nexport const Maker = 0\nexport const Taker = 1\n\n/*\n * RateEncodingFactor is used when encoding an atomic exchange rate as an\n * integer. See docs on message-rate encoding @\n * https://github.com/decred/dcrdex/blob/master/spec/comm.mediawiki#Rate_Encoding\n */\nexport const RateEncodingFactor = 1e8\n\nexport function sellString (ord: Order) {\n const key = ord.sell ? intl.ID_SELL : intl.ID_BUY\n const lang = document.documentElement.lang.toLowerCase()\n return intl.prep(key).toLocaleLowerCase(lang)\n}\n\nexport function typeString (ord: Order) {\n return ord.type === Limit ? (ord.tif === ImmediateTiF ? intl.prep(intl.ID_LIMIT_ORDER_IMMEDIATE_TIF) : intl.prep(intl.ID_LIMIT_ORDER)) : intl.prep(intl.ID_MARKET_ORDER)\n}\n\n/* isMarketBuy will return true if the order is a market buy order. */\nexport function isMarketBuy (ord: Order) {\n return ord.type === Market && !ord.sell\n}\n\n/*\n * hasActiveMatches returns true if the order has matches that have not completed\n * settlement yet.\n */\nexport function hasActiveMatches (order: Order) {\n if (!order.matches) return false\n for (const match of order.matches) {\n if (match.active) return true\n }\n return false\n}\n\n/**\n * statusString converts the order status to a string.\n *\n * IMPORTANT: we have similar function in Golang, it must match this one exactly,\n * when updating make sure to update both!\n */\nexport function statusString (order: Order): string {\n if (!order.id) return intl.prep(intl.ID_ORDER_SUBMITTING) // order ID is empty.\n const isLive = hasActiveMatches(order)\n switch (order.status) {\n case StatusUnknown: return intl.prep(intl.ID_UNKNOWN)\n case StatusEpoch: return intl.prep(intl.ID_EPOCH)\n case StatusBooked:\n if (order.cancelling) return intl.prep(intl.ID_CANCELING)\n return isLive ? `${intl.prep(intl.ID_BOOKED)}/${intl.prep(intl.ID_SETTLING)}` : intl.prep(intl.ID_BOOKED)\n case StatusExecuted:\n if (isLive) return intl.prep(intl.ID_SETTLING)\n if (order.filled === 0 && order.type !== Cancel) return intl.prep(intl.ID_NO_MATCH)\n return intl.prep(intl.ID_EXECUTED)\n case StatusCanceled:\n return isLive ? `${intl.prep(intl.ID_CANCELED)}/${intl.prep(intl.ID_SETTLING)}` : intl.prep(intl.ID_CANCELED)\n case StatusRevoked:\n return isLive ? `${intl.prep(intl.ID_REVOKED)}/${intl.prep(intl.ID_SETTLING)}` : intl.prep(intl.ID_REVOKED)\n }\n return intl.prep(intl.ID_UNKNOWN)\n}\n\n/* filled sums the quantities of non-cancel matches available. */\nexport function filled (order: Order) {\n if (!order.matches) return 0\n const qty = isMarketBuy(order) ? (m: Match) => m.qty * m.rate / RateEncodingFactor : (m: Match) => m.qty\n return order.matches.reduce((filled, match) => {\n if (match.isCancel) return filled\n return filled + qty(match)\n }, 0)\n}\n\n/* settled sums the quantities of the matches that have completed. */\nexport function settled (order: Order) {\n if (!order.matches) return 0\n const qty = isMarketBuy(order) ? (m: Match) => m.qty * m.rate / RateEncodingFactor : (m: Match) => m.qty\n return order.matches.reduce((settled, match) => {\n if (match.isCancel) return settled\n const redeemed = (match.side === Maker && match.status >= MakerRedeemed) ||\n (match.side === Taker && match.status >= MatchComplete)\n return redeemed ? settled + qty(match) : settled\n }, 0)\n}\n\n/* baseToQuote returns the quantity of the quote asset. */\nexport function baseToQuote (rate: number, base: number) : number {\n return rate * base / RateEncodingFactor\n}\n\n/* orderPortion returns a string stating the percentage of the order a match\n makes up. */\nexport function orderPortion (order: Order, match: Match) : string {\n let matchQty = match.qty\n if (isMarketBuy(order)) {\n matchQty = baseToQuote(match.rate, match.qty)\n }\n return ((matchQty / order.qty) * 100).toFixed(1) + ' %'\n}\n\n/*\n * matchStatusString is a string used to create a displayable string describing\n * describing the match status.\n */\nexport function matchStatusString (m: Match) {\n if (m.revoked) {\n // When revoked, match status is less important than pending action if still\n // active, or the outcome if inactive.\n if (m.active) {\n if (m.redeem) return revokedMatchStatus(intl.ID_MATCH_STATUS_REDEMPTION_SENT) // must require confirmation if active\n // If maker and we have not redeemed, waiting to refund, assuming it's not\n // revoked while waiting for confs on an unspent/unexpired taker swap.\n if (m.side === Maker) return revokedMatchStatus(intl.ID_MATCH_STATUS_REFUND_PENDING)\n // As taker, resolution depends on maker's actions while waiting to refund.\n if (m.counterRedeem) return revokedMatchStatus(intl.ID_MATCH_STATUS_REDEEM_PENDING) // this should be very brief if we see the maker's redeem\n return revokedMatchStatus(intl.ID_MATCH_STATUS_REFUND_PENDING) // may switch to redeem if maker redeems on the sly\n }\n if (m.refund) {\n return revokedMatchStatus(intl.ID_MATCH_STATUS_REFUNDED)\n }\n if (m.redeem) {\n return revokedMatchStatus(intl.ID_MATCH_STATUS_REDEMPTION_CONFIRMED)\n }\n return revokedMatchStatus(intl.ID_MATCH_STATUS_COMPLETE) // i.e. we sent no swap\n }\n\n switch (m.status) {\n case NewlyMatched:\n return intl.prep(intl.ID_MATCH_STATUS_NEWLY_MATCHED)\n case MakerSwapCast:\n return intl.prep(intl.ID_MATCH_STATUS_MAKER_SWAP_CAST)\n case TakerSwapCast:\n return intl.prep(intl.ID_MATCH_STATUS_TAKER_SWAP_CAST)\n case MakerRedeemed:\n if (m.side === Maker) {\n return intl.prep(intl.ID_MATCH_STATUS_REDEMPTION_SENT)\n }\n return intl.prep(intl.ID_MATCH_STATUS_MAKER_REDEEMED)\n case MatchComplete:\n return intl.prep(intl.ID_MATCH_STATUS_REDEMPTION_SENT)\n case MatchConfirmed:\n return intl.prep(intl.ID_MATCH_STATUS_REDEMPTION_CONFIRMED)\n }\n return intl.prep(intl.ID_UNKNOWN)\n}\n\n// revokedMatchStatus is a helper function that returns the revoked match status\n// string.\nfunction revokedMatchStatus (matchStatus: string): string {\n return intl.prep(intl.ID_MATCH_STATUS_REVOKED, { status: intl.prep(matchStatus) })\n}\n\n/*\n * optionElement is a getter for an element matching the *OrderOption from\n * client/asset. change is a function with no arguments that is called when the\n * returned option's value has changed.\n */\nexport function optionElement (opt: OrderOption, order: TradeForm, change: () => void, isSwap: boolean): HTMLElement {\n const isBaseChain = (isSwap && order.sell) || (!isSwap && !order.sell)\n const symbol = isBaseChain ? dexAssetSymbol(order.host, order.base) : dexAssetSymbol(order.host, order.quote)\n\n switch (true) {\n case !!opt.boolean:\n return new BooleanOption(opt, symbol, order.options, change).node\n case !!opt.xyRange:\n return new XYRangeOption(opt, symbol, order.options, change).node\n default:\n console.error('no option type specified', opt)\n }\n console.error('unknown option type', opt)\n return document.createElement('div')\n}\n\nfunction dexAssetSymbol (host: string, assetID: number): string {\n return app().exchanges[host].assets[assetID].symbol\n}\n","import Doc, { Animation } from './doc'\nimport { RateEncodingFactor } from './orderutil'\nimport OrderBook from './orderbook'\nimport State from './state'\nimport { UnitInfo, Market, Candle, CandlesPayload } from './registry'\n\nconst bind = Doc.bind\nconst PIPI = 2 * Math.PI\nconst plusChar = String.fromCharCode(59914)\nconst minusChar = String.fromCharCode(59915)\n\ninterface Point {\n x: number\n y: number\n}\n\ninterface MinMax {\n min: number\n max: number\n}\n\ninterface Label {\n val: number\n txt: string\n}\n\ninterface LabelSet {\n widest?: number\n lbls: Label[]\n}\n\ninterface Translator {\n x: (x: number) => number\n y: (y: number) => number\n unx: (x: number) => number\n uny: (y: number) => number\n w: (w: number) => number\n h: (h: number) => number\n dataCoords: (f: () => void) => void\n}\n\nexport interface MouseReport {\n rate: number\n depth: number\n dotColor: string\n hoverMarkers: number[]\n}\n\nexport interface VolumeReport {\n buyBase: number\n buyQuote: number\n sellBase: number\n sellQuote: number\n}\n\nexport interface DepthReporters {\n mouse: (r: MouseReport | null) => void\n click: (x: number) => void\n volume: (r: VolumeReport) => void\n zoom: (z: number) => void\n}\n\nexport interface CandleReporters {\n mouse: (r: Candle | null) => void\n}\n\nexport interface ChartReporters {\n resize: () => void,\n click: (e: MouseEvent) => void,\n zoom: (bigger: boolean) => void\n}\n\nexport interface DepthLine {\n rate: number\n color: string\n}\n\nexport interface DepthMarker {\n rate: number\n active: boolean\n}\n\ninterface DepthMark extends DepthMarker {\n qty: number\n sell: boolean\n}\n\ninterface Theme {\n axisLabel: string\n gridBorder: string\n gridLines: string\n gapLine: string\n value: string\n zoom: string\n zoomHover: string\n sellLine: string\n buyLine: string\n sellFill: string\n buyFill: string\n crosshairs: string\n legendFill: string\n legendText: string\n}\n\nconst darkTheme: Theme = {\n axisLabel: '#b1b1b1',\n gridBorder: '#383f4b',\n gridLines: '#383f4b',\n gapLine: '#6b6b6b',\n value: '#9a9a9a',\n zoom: '#5b5b5b',\n zoomHover: '#aaa',\n sellLine: '#ae3333',\n buyLine: '#05a35a',\n sellFill: '#591a1a',\n buyFill: '#02572f',\n crosshairs: '#888',\n legendFill: 'black',\n legendText: '#d5d5d5'\n}\n\nconst lightTheme: Theme = {\n axisLabel: '#1b1b1b',\n gridBorder: '#ddd',\n gridLines: '#ddd',\n gapLine: '#595959',\n value: '#4d4d4d',\n zoom: '#777',\n zoomHover: '#333',\n sellLine: '#99302b',\n buyLine: '#207a46',\n sellFill: '#bd5959',\n buyFill: '#4cad75',\n crosshairs: '#595959',\n legendFill: '#e6e6e6',\n legendText: '#1b1b1b'\n}\n\n// Chart is the base class for charts.\nexport class Chart {\n parent: HTMLElement\n report: ChartReporters\n theme: Theme\n canvas: HTMLCanvasElement\n visible: boolean\n renderScheduled: boolean\n ctx: CanvasRenderingContext2D\n mousePos: Point | null\n rect: DOMRect\n wheelLimiter: number | null\n boundResizer: () => void\n plotRegion: Region\n xRegion: Region\n yRegion: Region\n dataExtents: Extents\n unattachers: (() => void)[]\n\n constructor (parent: HTMLElement, reporters: ChartReporters) {\n this.parent = parent\n this.report = reporters\n this.theme = State.isDark() ? darkTheme : lightTheme\n this.canvas = document.createElement('canvas')\n this.visible = true\n parent.appendChild(this.canvas)\n const ctx = this.canvas.getContext('2d')\n if (!ctx) {\n console.error('error getting canvas context')\n return\n }\n this.ctx = ctx\n this.ctx.textAlign = 'center'\n this.ctx.textBaseline = 'middle'\n // Mouse handling\n this.mousePos = null\n bind(this.canvas, 'mousemove', (e: MouseEvent) => {\n // this.rect will be set in resize().\n if (!this.rect) return\n this.mousePos = {\n x: e.clientX - this.rect.left,\n y: e.clientY - this.rect.y\n }\n this.draw()\n })\n bind(this.canvas, 'mouseleave', () => {\n this.mousePos = null\n this.draw()\n })\n\n // Bind resize.\n const resizeObserver = new ResizeObserver(() => this.resize())\n resizeObserver.observe(this.parent)\n\n // Scrolling by wheel is smoother when the rate is slightly limited.\n this.wheelLimiter = null\n bind(this.canvas, 'wheel', (e: WheelEvent) => { this.wheel(e) })\n bind(this.canvas, 'click', (e: MouseEvent) => { this.click(e) })\n const setVis = () => {\n this.visible = document.visibilityState !== 'hidden'\n if (this.visible && this.renderScheduled) {\n this.renderScheduled = false\n this.draw()\n }\n }\n bind(document, 'visibilitychange', setVis)\n this.unattachers = [() => { Doc.unbind(document, 'visibilitychange', setVis) }]\n }\n\n wheeled () {\n this.wheelLimiter = window.setTimeout(() => { this.wheelLimiter = null }, 100)\n }\n\n /* clear the canvas. */\n clear () {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n }\n\n /* draw calls the child class's render method. */\n draw () {\n this.render()\n }\n\n /* click is the handler for a click event on the canvas. */\n click (e: MouseEvent) {\n this.report.click(e)\n }\n\n /* wheel is a mousewheel event handler. */\n wheel (e: WheelEvent) {\n this.zoom(e.deltaY < 0)\n e.preventDefault()\n }\n\n /*\n * resize updates the chart size. The parentHeight is an argument to support\n * updating the height programmatically after the caller sets a style.height\n * but before the clientHeight has been updated.\n */\n resize () {\n this.canvas.width = this.parent.clientWidth\n this.canvas.height = this.parent.clientHeight\n const xLblHeight = 30\n const yGuess = 40 // y label width guess. Will be adjusted when drawn.\n const plotExtents = new Extents(yGuess, this.canvas.width, 10, this.canvas.height - xLblHeight)\n const xLblExtents = new Extents(yGuess, this.canvas.width, this.canvas.height - xLblHeight, this.canvas.height)\n const yLblExtents = new Extents(0, yGuess, 10, this.canvas.height - xLblHeight)\n this.plotRegion = new Region(this.ctx, plotExtents)\n this.xRegion = new Region(this.ctx, xLblExtents)\n this.yRegion = new Region(this.ctx, yLblExtents)\n // After changing the visibility, this.canvas.getBoundingClientRect will\n // return nonsense until a render.\n window.requestAnimationFrame(() => {\n this.rect = this.canvas.getBoundingClientRect()\n this.report.resize()\n })\n }\n\n /* zoom is called when the user scrolls the mouse wheel on the canvas. */\n zoom (bigger: boolean) {\n if (this.wheelLimiter) return\n this.report.zoom(bigger)\n }\n\n /* The market handler will call unattach when the markets page is unloaded. */\n unattach () {\n for (const u of this.unattachers) u()\n this.unattachers = []\n }\n\n /* render must be implemented by the child class. */\n render () {\n console.error('child class must override render method')\n }\n\n /* applyLabelStyle applies the style used for axis tick labels. */\n applyLabelStyle (fontSize?: number) {\n this.ctx.textAlign = 'center'\n this.ctx.textBaseline = 'middle'\n this.ctx.font = `${fontSize ?? '14'}px 'sans', sans-serif`\n this.ctx.fillStyle = this.theme.axisLabel\n }\n\n /* plotXLabels applies the provided labels to the x axis and draws the grid. */\n plotXLabels (labels: LabelSet, minX: number, maxX: number, unitLines: string[]) {\n const extents = new Extents(minX, maxX, 0, 1)\n this.xRegion.plot(extents, (ctx: CanvasRenderingContext2D, tools: Translator) => {\n this.applyLabelStyle()\n const centerX = (maxX + minX) / 2\n let lastX = minX\n let unitCenter = centerX\n labels.lbls.forEach(lbl => {\n ctx.fillText(lbl.txt, tools.x(lbl.val), tools.y(0.5))\n if (centerX >= lastX && centerX < lbl.val) {\n unitCenter = (lastX + lbl.val) / 2\n }\n lastX = lbl.val\n })\n ctx.font = '11px \\'sans\\', sans-serif'\n if (unitLines.length === 2) {\n ctx.fillText(unitLines[0], tools.x(unitCenter), tools.y(0.63))\n ctx.fillText(unitLines[1], tools.x(unitCenter), tools.y(0.23))\n } else if (unitLines.length === 1) {\n ctx.fillText(unitLines[0], tools.x(unitCenter), tools.y(0.5))\n }\n }, true)\n this.plotRegion.plot(extents, (ctx: CanvasRenderingContext2D, tools: Translator) => {\n ctx.lineWidth = 1\n ctx.strokeStyle = this.theme.gridLines\n labels.lbls.forEach(lbl => {\n line(ctx, tools.x(lbl.val), tools.y(0), tools.x(lbl.val), tools.y(1))\n })\n }, true)\n }\n\n /*\n * plotYLabels applies the y labels based on the provided plot region, and\n * draws the grid.\n */\n plotYLabels (region: Region, labels: LabelSet, minY: number, maxY: number, unit: string) {\n const extents = new Extents(0, 1, minY, maxY)\n this.yRegion.plot(extents, (ctx: CanvasRenderingContext2D, tools: Translator) => {\n this.applyLabelStyle()\n const centerY = maxY / 2\n let lastY = 0\n let unitCenter = centerY\n labels.lbls.forEach(lbl => {\n ctx.fillText(lbl.txt, tools.x(0.5), tools.y(lbl.val))\n if (centerY >= lastY && centerY < lbl.val) {\n unitCenter = (lastY + lbl.val) / 2\n }\n lastY = lbl.val\n })\n ctx.fillText(unit, tools.x(0.5), tools.y(unitCenter))\n }, true)\n region.plot(extents, (ctx: CanvasRenderingContext2D, tools: Translator) => {\n ctx.lineWidth = 1\n ctx.strokeStyle = this.theme.gridLines\n labels.lbls.forEach(lbl => {\n line(ctx, tools.x(0), tools.y(lbl.val), tools.x(1), tools.y(lbl.val))\n })\n }, true)\n }\n\n /*\n * doYLabels generates and applies the y-axis labels, based upon the\n * provided plot region.\n */\n doYLabels (region: Region, step: number, unit: string, valFmt?: (v: number) => string) {\n this.applyLabelStyle()\n const yLabels = makeLabels(this.ctx, region.height(), this.dataExtents.y.min,\n this.dataExtents.y.max, 50, step, unit, valFmt)\n\n // Reassign the width of the y-label column to accommodate the widest text.\n const yAxisWidth = (yLabels.widest || 0) + 20 /* x padding */\n this.yRegion.extents.x.max = yAxisWidth\n this.yRegion.extents.y.max = region.extents.y.max\n\n this.plotRegion.extents.x.min = yAxisWidth\n this.xRegion.extents.x.min = yAxisWidth\n // Print the y labels.\n this.plotYLabels(region, yLabels, this.dataExtents.y.min, this.dataExtents.y.max, unit)\n return yLabels\n }\n\n // drawFrame draws an outline around the plotRegion.\n drawFrame () {\n this.plotRegion.plot(new Extents(0, 1, 0, 1), (ctx: CanvasRenderingContext2D, tools: Translator) => {\n ctx.lineWidth = 1\n ctx.strokeStyle = this.theme.gridBorder\n ctx.beginPath()\n tools.dataCoords(() => {\n ctx.moveTo(0, 0)\n ctx.lineTo(0, 1)\n ctx.lineTo(1, 1)\n ctx.lineTo(1, 0)\n ctx.lineTo(0, 0)\n })\n ctx.stroke()\n })\n }\n}\n\n/* DepthChart is a javascript Canvas-based depth chart renderer. */\nexport class DepthChart extends Chart {\n reporters: DepthReporters\n book: OrderBook\n zoomLevel: number\n lotSize: number\n rateStep: number\n lines: DepthLine[]\n markers: Record\n zoomInBttn: Region\n zoomOutBttn: Region\n baseUnit: string\n quoteUnit: string\n\n constructor (parent: HTMLElement, reporters: DepthReporters, zoom: number) {\n super(parent, {\n resize: () => this.resized(),\n click: (e: MouseEvent) => this.clicked(e),\n zoom: (bigger: boolean) => this.zoomed(bigger)\n })\n this.reporters = reporters\n this.zoomLevel = zoom\n this.lines = []\n this.markers = {\n buys: [],\n sells: []\n }\n this.setZoomBttns() // can't wait for requestAnimationFrame -> resized\n this.resize()\n }\n\n // setZoomBttns creates new regions for zoom in and zoom out buttons. It is\n // used in initiation of the buttons and resizing.\n setZoomBttns () {\n this.zoomInBttn = new Region(this.ctx, new Extents(0, 0, 0, 0))\n this.zoomOutBttn = new Region(this.ctx, new Extents(0, 0, 0, 0))\n }\n\n /* resized is called when the window or parent element are resized. */\n resized () {\n // The button region extents are set during drawing.\n this.setZoomBttns()\n if (this.book) this.draw()\n }\n\n /* zoomed zooms the current view in or out. bigger=true is zoom in. */\n zoomed (bigger: boolean) {\n if (!this.zoomLevel) return\n if (!this.book.buys || !this.book.sells) return\n this.wheeled()\n // Zoom in to 66%, but out to 150% = 1 / (2/3) so that the same zoom levels\n // are hit when reversing direction.\n this.zoomLevel *= bigger ? 2 / 3 : 3 / 2\n this.zoomLevel = clamp(this.zoomLevel, 0.005, 2)\n this.draw()\n this.reporters.zoom(this.zoomLevel)\n }\n\n /* clicked is the canvas 'click' event handler. */\n clicked (e: MouseEvent) {\n if (!this.dataExtents) return\n const x = e.clientX - this.rect.left\n const y = e.clientY - this.rect.y\n if (this.zoomInBttn.contains(x, y)) { this.zoom(true); return }\n if (this.zoomOutBttn.contains(x, y)) { this.zoom(false); return }\n const translator = this.plotRegion.translator(this.dataExtents)\n this.reporters.click(translator.unx(x))\n }\n\n // clear the canvas.\n clear () {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n }\n\n // set sets the current data set and draws.\n set (book: OrderBook, lotSize: number, rateStep: number, baseUnitInfo: UnitInfo, quoteUnitInfo: UnitInfo) {\n this.book = book\n this.lotSize = lotSize / baseUnitInfo.conventional.conversionFactor\n const [qFactor, bFactor] = [quoteUnitInfo.conventional.conversionFactor, baseUnitInfo.conventional.conversionFactor]\n this.rateStep = rateStep / RateEncodingFactor * qFactor / bFactor\n this.baseUnit = baseUnitInfo.conventional.unit\n this.quoteUnit = quoteUnitInfo.conventional.unit\n if (!this.zoomLevel) {\n const [midGap, gapWidth] = this.gap()\n // Default to 5% zoom, but with a minimum of 5 * midGap, but still observing\n // the hard cap of 200%.\n const minZoom = Math.max(gapWidth / midGap * 5, 0.05)\n this.zoomLevel = Math.min(minZoom, 2)\n }\n this.draw()\n }\n\n /*\n * render draws the chart.\n * 1. Calculate the data extents and translate the order book data to a\n * cumulative form.\n * 2. Draw axis ticks and grid, mid-gap line and value, zoom buttons, mouse\n * position indicator...\n * 4. Tick labels.\n * 5. Data.\n * 6. Epoch line legend.\n * 7. Hover legend.\n */\n render () {\n // if connection fails it is not possible to get book.\n if (!this.book || !this.visible || this.canvas.width === 0) {\n this.renderScheduled = true\n return\n }\n\n this.clear()\n // if (!this.book || this.book.empty()) return\n const ctx = this.ctx\n const mousePos = this.mousePos\n const buys = this.book.buys\n const sells = this.book.sells\n const [midGap, gapWidth] = this.gap()\n\n const halfWindow = this.zoomLevel * midGap / 2\n const high = midGap + halfWindow\n const low = midGap - halfWindow\n\n // Get a sorted copy of the markers list.\n const buyMarkers = [...this.markers.buys]\n const sellMarkers = [...this.markers.sells]\n buyMarkers.sort((a, b) => b.rate - a.rate)\n sellMarkers.sort((a, b) => a.rate - b.rate)\n const markers: DepthMark[] = []\n\n const buyDepth: [number, number][] = []\n const buyEpoch: [number, number][] = []\n const sellDepth: [number, number][] = []\n const sellEpoch: [number, number][] = []\n const volumeReport = {\n buyBase: 0,\n buyQuote: 0,\n sellBase: 0,\n sellQuote: 0\n }\n let sum = 0\n // The epoch line is above the non-epoch region, so the epochSum y value\n // must account for non-epoch orders too.\n let epochSum = 0\n\n for (let i = 0; i < buys.length; i++) {\n const ord = buys[i]\n epochSum += ord.qty\n if (ord.rate >= low) buyEpoch.push([ord.rate, epochSum])\n if (ord.epoch) continue\n sum += ord.qty\n buyDepth.push([ord.rate, sum])\n volumeReport.buyBase += ord.qty\n volumeReport.buyQuote += ord.qty * ord.rate\n while (buyMarkers.length && floatCompare(buyMarkers[0].rate, ord.rate)) {\n const mark = buyMarkers.shift()\n if (!mark) continue\n markers.push({\n rate: mark.rate,\n qty: ord.epoch ? epochSum : sum,\n sell: ord.sell,\n active: mark.active\n })\n }\n }\n const buySum = buyDepth.length ? last(buyDepth)[1] : 0\n buyDepth.push([low, buySum])\n const epochBuySum = buyEpoch.length ? last(buyEpoch)[1] : 0\n buyEpoch.push([low, epochBuySum])\n\n epochSum = sum = 0\n for (let i = 0; i < sells.length; i++) {\n const ord = sells[i]\n epochSum += ord.qty\n if (ord.rate <= high) sellEpoch.push([ord.rate, epochSum])\n if (ord.epoch) continue\n sum += ord.qty\n sellDepth.push([ord.rate, sum])\n volumeReport.sellBase += ord.qty\n volumeReport.sellQuote += ord.qty * ord.rate\n while (sellMarkers.length && floatCompare(sellMarkers[0].rate, ord.rate)) {\n const mark = sellMarkers.shift()\n if (!mark) continue\n markers.push({\n rate: mark.rate,\n qty: ord.epoch ? epochSum : sum,\n sell: ord.sell,\n active: mark.active\n })\n }\n }\n // Add a data point going to the left so that the data doesn't end with a\n // vertical line.\n const sellSum = sellDepth.length ? last(sellDepth)[1] : 0\n sellDepth.push([high, sellSum])\n const epochSellSum = sellEpoch.length ? last(sellEpoch)[1] : 0\n sellEpoch.push([high, epochSellSum])\n\n // Add ~30px padding to the top of the chart.\n const h = this.xRegion.extents.y.min\n const growthFactor = (h + 30) / h\n const maxY = (epochSellSum && epochBuySum ? Math.max(epochBuySum, epochSellSum) : epochSellSum || epochBuySum || 1) * growthFactor\n\n const dataExtents = new Extents(low, high, 0, maxY)\n this.dataExtents = dataExtents\n\n this.doYLabels(this.plotRegion, this.lotSize, this.baseUnit)\n\n // Print the x labels\n const xLabels = makeLabels(ctx, this.plotRegion.width(), dataExtents.x.min,\n dataExtents.x.max, 100, this.rateStep, '')\n\n this.plotXLabels(xLabels, low, high, [`${this.quoteUnit}/`, this.baseUnit])\n\n // A function to be run at the end if there is legend data to display.\n let mouseData: MouseReport | null = null\n\n // Draw the grid.\n this.drawFrame()\n this.plotRegion.plot(dataExtents, (ctx, tools) => {\n ctx.lineWidth = 1\n // first, a square around the plot area.\n ctx.strokeStyle = this.theme.gridBorder\n // draw a line to indicate mid-gap\n ctx.lineWidth = 2.5\n ctx.strokeStyle = this.theme.gapLine\n line(ctx, tools.x(midGap), tools.y(0), tools.x(midGap), tools.y(0.3 * dataExtents.y.max))\n\n ctx.font = '30px \\'demi-sans\\', sans-serif'\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n ctx.fillStyle = this.theme.value\n const y = 0.5 * dataExtents.y.max\n ctx.fillText(formatLabelValue(midGap), tools.x(midGap), tools.y(y))\n ctx.font = '12px \\'sans\\', sans-serif'\n // ctx.fillText('mid-market price', tools.x(midGap), tools.y(y) + 24)\n ctx.fillText(`${(gapWidth / midGap * 100).toFixed(2)}% spread`,\n tools.x(midGap), tools.y(y) + 24)\n\n // Draw zoom buttons.\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n const topCenterX = this.plotRegion.extents.midX\n const topCenterY = tools.y(maxY * 0.9)\n const zoomPct = dataExtents.xRange / midGap * 100\n const zoomText = `${zoomPct.toFixed(1)}%`\n const w = ctx.measureText(zoomText).width\n ctx.font = '13px \\'sans\\', sans-serif'\n ctx.fillText(zoomText, topCenterX, topCenterY + 1)\n // define the region for the zoom button\n const bttnSize = 20\n const xPad = 10\n let bttnLeft = topCenterX - w / 2 - xPad - bttnSize\n const bttnTop = topCenterY - bttnSize / 2\n this.zoomOutBttn.setExtents(\n bttnLeft,\n bttnLeft + bttnSize,\n bttnTop,\n bttnTop + bttnSize\n )\n let hover = mousePos && this.zoomOutBttn.contains(mousePos.x, mousePos.y)\n this.zoomOutBttn.plot(new Extents(0, 1, 0, 1), ctx => {\n ctx.font = '12px \\'icomoon\\''\n ctx.fillStyle = this.theme.zoom\n if (hover) {\n ctx.fillStyle = this.theme.zoomHover\n ctx.font = '13px \\'icomoon\\''\n }\n ctx.fillText(minusChar, this.zoomOutBttn.extents.midX, this.zoomOutBttn.extents.midY)\n })\n bttnLeft = topCenterX + w / 2 + xPad\n this.zoomInBttn.setExtents(\n bttnLeft,\n bttnLeft + bttnSize,\n bttnTop,\n bttnTop + bttnSize\n )\n hover = mousePos && this.zoomInBttn.contains(mousePos.x, mousePos.y)\n this.zoomInBttn.plot(new Extents(0, 1, 0, 1), ctx => {\n ctx.font = '12px \\'icomoon\\''\n ctx.fillStyle = this.theme.zoom\n if (hover) {\n ctx.fillStyle = this.theme.zoomHover\n ctx.font = '14px \\'icomoon\\''\n }\n ctx.fillText(plusChar, this.zoomInBttn.extents.midX, this.zoomInBttn.extents.midY)\n })\n\n // Draw a dotted vertical line where the mouse is, and a dot at the level\n // of the depth line.\n const drawLine = (x: number, color: string) => {\n if (x > high || x < low) return\n ctx.save()\n ctx.setLineDash([3, 5])\n ctx.lineWidth = 1.5\n ctx.strokeStyle = color\n line(ctx, tools.x(x), tools.y(0), tools.x(x), tools.y(maxY))\n ctx.restore()\n }\n\n for (const line of this.lines || []) {\n drawLine(line.rate, line.color)\n }\n\n const tolerance = (high - low) * 0.005\n const hoverMarkers = []\n for (const marker of markers || []) {\n const hovered = (mousePos && withinTolerance(marker.rate, tools.unx(mousePos.x), tolerance))\n if (hovered) hoverMarkers.push(marker.rate)\n ctx.save()\n ctx.lineWidth = (hovered || marker.active) ? 5 : 3\n ctx.strokeStyle = marker.sell ? this.theme.sellLine : this.theme.buyLine\n ctx.fillStyle = marker.sell ? this.theme.sellFill : this.theme.buyFill\n const size = (hovered || marker.active) ? 10 : 8\n ctx.beginPath()\n const tip = {\n x: tools.x(marker.rate),\n y: tools.y(marker.qty) - 8\n }\n const top = tip.y - (Math.sqrt(3) * size / 2) // cos(30)\n ctx.moveTo(tip.x, tip.y)\n ctx.lineTo(tip.x - size / 2, top)\n ctx.lineTo(tip.x + size / 2, top)\n ctx.closePath()\n ctx.stroke()\n ctx.fill()\n ctx.restore()\n }\n\n // If the mouse is in the chart area, draw the crosshairs.\n if (!mousePos) return\n if (!this.plotRegion.contains(mousePos.x, mousePos.y)) return\n // The mouse is in the plot region. Get the data coordinates and find the\n // side and depth for the x value.\n const dataX = tools.unx(mousePos.x)\n let evalSide = sellDepth\n let trigger = (ptX: number) => ptX >= dataX\n let dotColor = this.theme.sellLine\n if (dataX < midGap) {\n evalSide = buyDepth\n trigger = (ptX) => ptX <= dataX\n dotColor = this.theme.buyLine\n }\n let bestDepth = evalSide[0]\n for (let i = 0; i < evalSide.length; i++) {\n const pt = evalSide[i]\n if (trigger(pt[0])) break\n bestDepth = pt\n }\n drawLine(dataX, this.theme.crosshairs)\n mouseData = {\n rate: dataX,\n depth: bestDepth[1],\n dotColor: dotColor,\n hoverMarkers: hoverMarkers\n }\n })\n\n // Draw the epoch lines\n ctx.lineWidth = 1.5\n ctx.setLineDash([3, 3])\n // epoch sells\n ctx.fillStyle = this.theme.sellFill\n ctx.strokeStyle = this.theme.sellLine\n this.drawDepth(sellEpoch)\n // epoch buys\n ctx.fillStyle = this.theme.buyFill\n ctx.strokeStyle = this.theme.buyLine\n this.drawDepth(buyEpoch)\n\n // Draw the book depth.\n ctx.lineWidth = 2.5\n ctx.setLineDash([])\n // book sells\n ctx.fillStyle = this.theme.sellFill\n ctx.strokeStyle = this.theme.sellLine\n this.drawDepth(sellDepth)\n // book buys\n ctx.fillStyle = this.theme.buyFill\n ctx.strokeStyle = this.theme.buyLine\n this.drawDepth(buyDepth)\n\n // Display the dot at the intersection of the mouse hover line and the depth\n // line. This should be drawn after the depths.\n if (mouseData) {\n this.plotRegion.plot(dataExtents, (ctx, tools) => {\n if (!mouseData) return // For TypeScript. Duh.\n dot(ctx, tools.x(mouseData.rate), tools.y(mouseData.depth), mouseData.dotColor, 5)\n })\n }\n\n // Report the book volumes.\n this.reporters.volume(volumeReport)\n this.reporters.mouse(mouseData)\n }\n\n /* drawDepth draws a single side's depth chart data. */\n drawDepth (depth: [number, number][]) {\n const firstPt = depth[0]\n let y = firstPt[1]\n let x: number\n this.plotRegion.plot(this.dataExtents, (ctx, tools) => {\n tools.dataCoords(() => {\n ctx.beginPath()\n ctx.moveTo(firstPt[0], firstPt[1])\n for (let i = 0; i < depth.length; i++) {\n // Set x, but don't set y until we draw the horizontal line.\n x = depth[i][0]\n ctx.lineTo(x, y)\n // If this is past the render edge, quit drawing.\n y = depth[i][1]\n ctx.lineTo(x, y)\n }\n })\n ctx.stroke()\n tools.dataCoords(() => {\n ctx.lineTo(x, 0)\n ctx.lineTo(firstPt[0], 0)\n })\n ctx.closePath()\n ctx.globalAlpha = 0.25\n ctx.fill()\n })\n }\n\n /* returns the mid-gap rate and gap width as a tuple. */\n gap () {\n const [b, s] = [this.book.bestGapBuy(), this.book.bestGapSell()]\n if (!b) {\n if (!s) return [1, 0]\n return [s.rate, 0]\n } else if (!s) return [b.rate, 0]\n return [(s.rate + b.rate) / 2, s.rate - b.rate]\n }\n\n /* setLines stores the indicator lines to draw. */\n setLines (lines: DepthLine[]) {\n this.lines = lines\n }\n\n /* setMarkers sets the indicator markers to draw. */\n setMarkers (markers: Record) {\n this.markers = markers\n }\n}\n\n/* CandleChart is a candlestick data renderer. */\nexport class CandleChart extends Chart {\n reporters: CandleReporters\n data: CandlesPayload\n zoomLevel: number\n numToShow: number\n candleRegion: Region\n volumeRegion: Region\n resizeTimer: number\n zoomLevels: number[]\n market: Market\n rateConversionFactor: number\n\n constructor (parent: HTMLElement, reporters: CandleReporters) {\n super(parent, {\n resize: () => this.resized(),\n click: (/* e: MouseEvent */) => { this.clicked() },\n zoom: (bigger: boolean) => this.zoomed(bigger)\n })\n this.reporters = reporters\n this.zoomLevel = 1\n this.numToShow = 100\n this.resize()\n }\n\n /* resized is called when the window or parent element are resized. */\n resized () {\n const ext = this.plotRegion.extents\n const candleExtents = new Extents(ext.x.min, ext.x.max, ext.y.min, ext.y.min + ext.yRange * 0.85)\n this.candleRegion = new Region(this.ctx, candleExtents)\n const volumeExtents = new Extents(ext.x.min, ext.x.max, ext.y.min + 0.85 * ext.yRange, ext.y.max)\n this.volumeRegion = new Region(this.ctx, volumeExtents)\n // Set a delay on the render to prevent lag.\n if (this.resizeTimer) clearTimeout(this.resizeTimer)\n this.resizeTimer = window.setTimeout(() => this.draw(), 100)\n }\n\n clicked (/* e: MouseEvent */) {\n // handle clicks\n }\n\n /* zoomed zooms the current view in or out. bigger=true is zoom in. */\n zoomed (bigger: boolean) {\n // bigger actually means fewer candles -> reduce zoomLevels index.\n const idx = this.zoomLevels.indexOf(this.numToShow)\n if (bigger) {\n if (idx === 0) return\n this.numToShow = this.zoomLevels[idx - 1]\n } else {\n if (this.zoomLevels.length <= idx + 1 || this.numToShow > this.data.candles.length) return\n this.numToShow = this.zoomLevels[idx + 1]\n }\n this.draw()\n }\n\n /* render draws the chart */\n render () {\n const data = this.data\n if (!data || !this.visible || this.canvas.width === 0) {\n this.renderScheduled = true\n return\n }\n const candleWidth = data.ms\n const mousePos = this.mousePos\n const allCandles = data.candles || []\n\n const n = Math.min(this.numToShow, allCandles.length)\n const candles = allCandles.slice(allCandles.length - n)\n\n this.clear()\n\n // If there are no candles. just don't draw anything.\n if (n === 0) return\n\n // padding definition and some helper functions to parse candles.\n const candleWidthPadding = 0.2\n const start = (c: Candle) => truncate(c.endStamp, candleWidth)\n const end = (c: Candle) => start(c) + candleWidth\n const paddedStart = (c: Candle) => start(c) + candleWidthPadding * candleWidth\n const paddedWidth = (1 - 2 * candleWidthPadding) * candleWidth\n\n const first = candles[0]\n const last = candles[n - 1]\n\n let [high, low, highVol] = [first.highRate, first.lowRate, first.matchVolume]\n for (const c of candles) {\n if (c.highRate > high) high = c.highRate\n if (c.lowRate < low) low = c.lowRate\n if (c.matchVolume > highVol) highVol = c.matchVolume\n }\n\n // Calculate data extents and store them. They are used to apply labels.\n const rateStep = this.market.ratestep\n const dataExtents = new Extents(start(first), end(last), low, high)\n if (low === high) {\n // If there is no price movement at all in the window, show a little more\n // top and bottom so things render nicely.\n dataExtents.y.min -= rateStep\n dataExtents.y.max += rateStep\n }\n this.dataExtents = dataExtents\n\n // Apply labels.\n const rFactor = this.rateConversionFactor\n this.doYLabels(this.candleRegion, rateStep, this.market.quotesymbol, v => formatLabelValue(v / rFactor))\n this.candleRegion.extents.x.min = this.yRegion.extents.x.max\n this.volumeRegion.extents.x.min = this.yRegion.extents.x.max\n\n const xLabels = makeCandleTimeLabels(candles, candleWidth, this.plotRegion.width(), 100)\n\n this.plotXLabels(xLabels, start(first), end(last), [])\n\n this.drawFrame()\n\n // Highlight the candle if the user mouse is over the canvas.\n let mouseCandle: Candle | null = null\n if (mousePos) {\n this.plotRegion.plot(new Extents(dataExtents.x.min, dataExtents.x.max, 0, 1), (ctx, tools) => {\n const selectedStartStamp = truncate(tools.unx(mousePos.x), candleWidth)\n for (const c of candles) {\n if (start(c) === selectedStartStamp) {\n mouseCandle = c\n ctx.fillStyle = this.theme.gridLines\n ctx.fillRect(tools.x(start(c)), tools.y(0), tools.w(candleWidth), tools.h(1))\n break\n }\n }\n })\n if (mouseCandle) {\n const yExt = this.xRegion.extents.y\n this.xRegion.plot(new Extents(dataExtents.x.min, dataExtents.x.max, yExt.min, yExt.max), (ctx, tools) => {\n if (!mouseCandle) return // For TypeScript. Duh.\n this.applyLabelStyle()\n const rangeTxt = `${new Date(start(mouseCandle)).toLocaleString()} - ${new Date(end(mouseCandle)).toLocaleString()}`\n const [xPad, yPad] = [25, 2]\n const rangeWidth = ctx.measureText(rangeTxt).width + 2 * xPad\n const rangeHeight = 16\n let centerX = tools.x((start(mouseCandle) + end(mouseCandle)) / 2)\n let left = centerX - rangeWidth / 2\n const xExt = this.xRegion.extents.x\n if (left < xExt.min) left = xExt.min\n else if (left + rangeWidth > xExt.max) left = xExt.max - rangeWidth\n centerX = left + rangeWidth / 2\n const top = yExt.min + (this.xRegion.height() - rangeHeight) / 2\n ctx.fillStyle = this.theme.legendFill\n ctx.strokeStyle = this.theme.gridBorder\n const rectArgs: [number, number, number, number] = [left - xPad, top - yPad, rangeWidth + 2 * xPad, rangeHeight + 2 * yPad]\n ctx.fillRect(...rectArgs)\n ctx.strokeRect(...rectArgs)\n this.applyLabelStyle()\n ctx.fillText(rangeTxt, centerX, this.xRegion.extents.midY, rangeWidth)\n })\n }\n }\n\n // Draw the volume bars.\n const volDataExtents = new Extents(start(first), end(last), 0, highVol)\n this.volumeRegion.plot(volDataExtents, (ctx, tools) => {\n ctx.fillStyle = this.theme.gridBorder\n for (const c of candles) {\n ctx.fillRect(tools.x(paddedStart(c)), tools.y(0), tools.w(paddedWidth), tools.h(c.matchVolume))\n }\n })\n\n // Draw the candles.\n this.candleRegion.plot(dataExtents, (ctx, tools) => {\n ctx.lineWidth = 1\n for (const c of candles) {\n const desc = c.startRate > c.endRate\n const [x, y, w, h] = [tools.x(paddedStart(c)), tools.y(c.startRate), tools.w(paddedWidth), tools.h(c.endRate - c.startRate)]\n const [high, low, cx] = [tools.y(c.highRate), tools.y(c.lowRate), w / 2 + x]\n ctx.strokeStyle = desc ? this.theme.sellLine : this.theme.buyLine\n ctx.fillStyle = desc ? this.theme.sellFill : this.theme.buyFill\n\n ctx.beginPath()\n ctx.moveTo(cx, high)\n ctx.lineTo(cx, low)\n ctx.stroke()\n\n ctx.fillRect(x, y, w, h)\n ctx.strokeRect(x, y, w, h)\n }\n })\n\n // Report the mouse candle.\n this.reporters.mouse(mouseCandle)\n }\n\n /* setCandles sets the candle data and redraws the chart. */\n setCandles (data: CandlesPayload, market: Market, baseUnitInfo: UnitInfo, quoteUnitInfo: UnitInfo) {\n this.data = data\n if (!data.candles) return\n this.market = market\n const [qFactor, bFactor] = [quoteUnitInfo.conventional.conversionFactor, baseUnitInfo.conventional.conversionFactor]\n this.rateConversionFactor = RateEncodingFactor * qFactor / bFactor\n let n = 25\n this.zoomLevels = []\n const maxCandles = Math.max(data.candles.length, 1000)\n while (n < maxCandles) {\n this.zoomLevels.push(n)\n n *= 2\n }\n this.numToShow = 100\n this.draw()\n }\n}\n\ninterface WaveOpts {\n message?: string\n backgroundColor?: string | boolean // true for background color\n}\n\n/* Wave is a loading animation that displays a colorful line that oscillates */\nexport class Wave extends Chart {\n ani: Animation\n size: [number, number]\n region: Region\n colorShift: number\n opts: WaveOpts\n msgRegion: Region\n fontSize: number\n\n constructor (parent: HTMLElement, opts?: WaveOpts) {\n super(parent, {\n resize: () => this.resized(),\n click: (/* e: MouseEvent */) => { /* pass */ },\n zoom: (/* bigger: boolean */) => { /* pass */ }\n })\n this.canvas.classList.add('fill-abs')\n this.canvas.style.zIndex = '5'\n\n this.opts = opts ?? {}\n\n const period = 1500 // ms\n const start = Math.random() * period\n this.colorShift = Math.random() * 360\n\n // y = A*cos(k*x + theta*t + c)\n // combine three waves with different periods and speeds and phases.\n const amplitudes = [1, 0.65, 0.75]\n const ks = [3, 3, 2]\n const speeds = [Math.PI, Math.PI * 10 / 9, Math.PI / 2.5]\n const phases = [0, 0, Math.PI * 1.5]\n const n = 75\n const single = (n: number, angularX: number, angularTime: number): number => {\n return amplitudes[n] * Math.cos(ks[n] * angularX + speeds[n] * angularTime + phases[n])\n }\n const value = (x: number, angularTime: number): number => {\n const angularX = x * Math.PI * 2\n return (single(0, angularX, angularTime) + single(1, angularX, angularTime) + single(2, angularX, angularTime)) / 3\n }\n this.resize()\n this.ani = new Animation(Animation.Forever, () => {\n const angularTime = (new Date().getTime() - start) / period * Math.PI * 2\n const values = []\n for (let i = 0; i < n; i++) {\n values.push(value(i / (n - 1), angularTime))\n }\n this.drawValues(values)\n })\n }\n\n resized () {\n const opts = this.opts\n const [maxW, maxH] = [150, 100]\n const [cw, ch] = [this.canvas.width, this.canvas.height]\n let [w, h] = [cw * 0.8, ch * 0.8]\n if (w > maxW) w = maxW\n if (h > maxH) h = maxH\n let [l, t] = [(cw - w) / 2, (ch - h) / 2]\n if (opts.message) {\n this.fontSize = clamp(h * 0.15, 10, 14)\n this.applyLabelStyle(this.fontSize)\n const ypad = this.fontSize * 0.5\n const halfH = (this.fontSize / 2) + ypad\n t -= halfH\n this.msgRegion = new Region(this.ctx, new Extents(0, cw, t + h, t + h + 2 * halfH))\n }\n this.region = new Region(this.ctx, new Extents(l, l + w, t, t + h))\n }\n\n drawValues (values: number[]) {\n if (!this.region) return\n this.clear()\n const hsl = (h: number) => `hsl(${h}, 35%, 50%)`\n\n const { region, msgRegion, canvas: { width: w, height: h }, opts: { backgroundColor: bg, message: msg }, colorShift, ctx } = this\n\n if (bg) {\n if (bg === true) ctx.fillStyle = window.getComputedStyle(document.body, null).getPropertyValue('background-color')\n else ctx.fillStyle = bg\n ctx.fillRect(0, 0, w, h)\n }\n\n region.plot(new Extents(0, 1, -1, 1), (ctx: CanvasRenderingContext2D, t: Translator) => {\n ctx.lineWidth = 4\n ctx.lineCap = 'round'\n\n const shift = colorShift + (new Date().getTime() % 2000) / 2000 * 360 // colors move with frequency 1 / 2s\n const grad = ctx.createLinearGradient(t.x(0), 0, t.x(1), 0)\n grad.addColorStop(0, hsl(shift))\n ctx.strokeStyle = grad\n\n ctx.beginPath()\n ctx.moveTo(t.x(0), t.y(values[0]))\n for (let i = 1; i < values.length; i++) {\n const prog = i / (values.length - 1)\n grad.addColorStop(prog, hsl(prog * 300 + shift))\n ctx.lineTo(t.x(prog), t.y(values[i]))\n }\n ctx.stroke()\n })\n if (!msg) return\n msgRegion.plot(new Extents(0, 1, 0, 1), (ctx: CanvasRenderingContext2D, t: Translator) => {\n ctx.fillText(msg, t.x(0.5), t.y(0.5), this.msgRegion.width())\n })\n }\n\n render () { /* pass */ }\n\n stop () {\n this.ani.stop()\n this.canvas.remove()\n }\n}\n\n/*\n * Extents holds a min and max in both the x and y directions, and provides\n * getters for related data.\n */\nclass Extents {\n x: MinMax\n y: MinMax\n\n constructor (xMin: number, xMax: number, yMin: number, yMax: number) {\n this.setExtents(xMin, xMax, yMin, yMax)\n }\n\n setExtents (xMin: number, xMax: number, yMin: number, yMax: number) {\n this.x = {\n min: xMin,\n max: xMax\n }\n this.y = {\n min: yMin,\n max: yMax\n }\n }\n\n get xRange (): number {\n return this.x.max - this.x.min\n }\n\n get midX (): number {\n return (this.x.max + this.x.min) / 2\n }\n\n get yRange (): number {\n return this.y.max - this.y.min\n }\n\n get midY (): number {\n return (this.y.max + this.y.min) / 2\n }\n}\n\n/*\n * Region applies an Extents to the canvas, providing utilities for coordinate\n * transformations and restricting drawing to a specified region of the canvas.\n */\nclass Region {\n context: CanvasRenderingContext2D\n extents: Extents\n\n constructor (context: CanvasRenderingContext2D, extents: Extents) {\n this.context = context\n this.extents = extents\n }\n\n setExtents (xMin: number, xMax: number, yMin: number, yMax: number) {\n this.extents.setExtents(xMin, xMax, yMin, yMax)\n }\n\n width (): number {\n return this.extents.xRange\n }\n\n height (): number {\n return this.extents.yRange\n }\n\n contains (x: number, y: number): boolean {\n const ext = this.extents\n return (x < ext.x.max && x > ext.x.min &&\n y < ext.y.max && y > ext.y.min)\n }\n\n /*\n * A translator provides 4 function for coordinate transformations. x and y\n * translate data coordinates to canvas coordinates for the specified data\n * Extents. unx and uny translate canvas coordinates to data coordinates.\n */\n translator (dataExtents: Extents): Translator {\n const region = this.extents\n const xMin = dataExtents.x.min\n // const xMax = dataExtents.x.max\n const yMin = dataExtents.y.min\n // const yMax = dataExtents.y.max\n const yRange = dataExtents.yRange\n const xRange = dataExtents.xRange\n const screenMinX = region.x.min\n const screenW = region.x.max - screenMinX\n const screenMaxY = region.y.max\n const screenH = screenMaxY - region.y.min\n const xFactor = screenW / xRange\n const yFactor = screenH / yRange\n return {\n x: (x: number) => (x - xMin) * xFactor + screenMinX,\n y: (y: number) => screenMaxY - (y - yMin) * yFactor,\n unx: (x: number) => (x - screenMinX) / xFactor + xMin,\n uny: (y: number) => yMin - (y - screenMaxY) / yFactor,\n w: (w: number) => w / xRange * screenW,\n h: (h: number) => -h / yRange * screenH,\n dataCoords: () => { /* Added when using plot() */ }\n }\n }\n\n /* clear clears the region. */\n clear () {\n const ext = this.extents\n this.context.clearRect(ext.x.min, ext.y.min, ext.xRange, ext.yRange)\n }\n\n /* plot prepares tools for drawing using data coordinates. */\n plot (dataExtents: Extents, drawFunc: (ctx: CanvasRenderingContext2D, tools: Translator) => void, skipMask?: boolean) {\n const ctx = this.context\n const region = this.extents\n ctx.save() // Save the original state\n if (!skipMask) {\n ctx.beginPath()\n ctx.rect(region.x.min, region.y.min, region.xRange, region.yRange)\n ctx.clip()\n }\n\n // The drawFunc will be passed a set of tool that can be used to assist\n // drawing. The tools start with the transformation functions.\n const tools = this.translator(dataExtents)\n\n // Create a transformation that allows drawing in data coordinates. It's\n // not advisable to stroke or add text with this transform in place, as the\n // result will be distorted. You can however use ctx.moveTo and ctx.lineTo\n // with this transform in place using data coordinates, and remove the\n // transform before stroking. The dataCoords method of the supplied tool\n // provides this functionality.\n const yRange = dataExtents.yRange\n const xFactor = region.xRange / dataExtents.xRange\n const yFactor = region.yRange / yRange\n const xMin = dataExtents.x.min\n const yMin = dataExtents.y.min\n // These translation factors are complicated because the (0, 0) of the\n // region is not necessarily the (0, 0) of the canvas.\n const tx = (region.x.min + xMin) - xMin * xFactor\n const ty = -region.y.min - (yRange - yMin) * yFactor\n const setTransform = () => {\n // Data coordinates are flipped about y. Flip the coordinates and\n // translate top left corner to canvas (0, 0).\n ctx.transform(1, 0, 0, -1, -xMin, yMin)\n // Scale to data coordinates and shift into place for the region's offset\n // on the canvas.\n ctx.transform(xFactor, 0, 0, yFactor, tx, ty)\n }\n // dataCoords allows some drawing to be performed directly in data\n // coordinates. Most actual drawing functions like ctx.stroke and\n // ctx.fillRect should not be called from inside dataCoords, but\n // ctx.moveTo and ctx.LineTo are fine.\n tools.dataCoords = f => {\n ctx.save()\n setTransform()\n f()\n ctx.restore()\n }\n\n drawFunc(this.context, tools)\n ctx.restore()\n }\n}\n\n/*\n * makeLabels attempts to create the appropriate labels for the specified\n * screen size, context, and label spacing.\n */\nfunction makeLabels (\n ctx: CanvasRenderingContext2D,\n screenW: number,\n min: number,\n max: number,\n spacingGuess: number,\n step: number,\n unit: string,\n valFmt?: (v: number) => string\n): LabelSet {\n valFmt = valFmt || formatLabelValue\n const n = screenW / spacingGuess\n const diff = max - min\n if (n < 1 || diff <= 0) return { lbls: [] }\n const tickGuess = diff / n\n // make the tick spacing a multiple of the step\n const tick = tickGuess + step - (tickGuess % step)\n let x = min + tick - (min % tick)\n const absMax = Math.max(Math.abs(max), Math.abs(min))\n // The Math.round part is the minimum precision required to see the change in the numbers.\n // The 2 accounts for the precision of the tick.\n const sigFigs = Math.round(Math.log10(absMax / tick)) + 2\n const pts: Label[] = []\n let widest = 0\n while (x < max) {\n x = Number(x.toPrecision(sigFigs))\n const lbl = valFmt(x)\n widest = Math.max(widest, ctx.measureText(lbl).width)\n pts.push({\n val: x,\n txt: lbl\n })\n x += tick\n }\n const unitW = ctx.measureText(unit).width\n if (unitW > widest) widest = unitW\n return {\n widest: widest,\n lbls: pts\n }\n}\n\nconst months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']\n\n/* makeCandleTimeLabels prepares labels for candlestick data. */\nfunction makeCandleTimeLabels (candles: Candle[], dur: number, screenW: number, spacingGuess: number): LabelSet {\n const first = candles[0]\n const last = candles[candles.length - 1]\n const start = truncate(first.endStamp, dur)\n const end = truncate(last.endStamp, dur) + dur\n const diff = end - start\n const n = Math.min(candles.length, screenW / spacingGuess)\n const tick = truncate(diff / n, dur)\n if (tick === 0) {\n console.error('zero tick', dur, diff, n) // probably won't happen, but it'd suck if it did\n return { lbls: [] }\n }\n let x = start\n const zoneOffset = new Date().getTimezoneOffset()\n const dayStamp = (x: number) => {\n x = x - zoneOffset * 60000\n return x - (x % 86400000)\n }\n let lastDay = dayStamp(start)\n let lastYear = 0 // new Date(start).getFullYear()\n if (dayStamp(first.endStamp) === dayStamp(last.endStamp)) lastDay = 0 // Force at least one day stamp.\n const pts = []\n let label\n if (dur < 86400000) {\n label = (d: Date, x: number) => {\n const day = dayStamp(x)\n if (day !== lastDay) return `${months[d.getMonth()]}${d.getDate()} ${d.getHours()}:${String(d.getMinutes()).padStart(2, '0')}`\n else return `${d.getHours()}:${String(d.getMinutes()).padStart(2, '0')}`\n }\n } else {\n label = (d: Date) => {\n const year = d.getFullYear()\n if (year !== lastYear) return `${months[d.getMonth()]}${d.getDate()} '${String(year).slice(2, 4)}`\n else return `${months[d.getMonth()]}${d.getDate()}`\n }\n }\n while (x <= end) {\n const d = new Date(x)\n pts.push({\n val: x,\n txt: label(d, x)\n })\n lastDay = dayStamp(x)\n lastYear = d.getFullYear()\n x += tick\n }\n return { lbls: pts }\n}\n\n/* The last element of an array. */\nfunction last (arr: any[]): any {\n return arr[arr.length - 1]\n}\n\n/* line draws a line with the provided context. */\nfunction line (ctx: CanvasRenderingContext2D, x0: number, y0: number, x1: number, y1: number, skipStroke?: boolean) {\n ctx.beginPath()\n ctx.moveTo(x0, y0)\n ctx.lineTo(x1, y1)\n if (!skipStroke) ctx.stroke()\n}\n\n/* dot draws a circle with the provided context. */\nfunction dot (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, radius: number) {\n ctx.fillStyle = color\n ctx.beginPath()\n ctx.arc(x, y, radius, 0, PIPI)\n ctx.fill()\n}\n\n/* clamp returns v if min <= v <= max, else min or max. */\nfunction clamp (v: number, min: number, max: number): number {\n if (v < min) return min\n if (v > max) return max\n return v\n}\n\n/* labelSpecs is specifications for axis tick labels. */\nconst labelSpecs = {\n minimumSignificantDigits: 4,\n maximumSignificantDigits: 5\n}\n\n/* formatLabelValue formats the provided value using the labelSpecs format. */\nfunction formatLabelValue (x: number) {\n return x.toLocaleString('en-us', labelSpecs)\n}\n\n/* floatCompare compares two floats to within a tolerance of 1e-8. */\nfunction floatCompare (a: number, b: number) {\n return withinTolerance(a, b, 1e-8)\n}\n\n/*\n * withinTolerance returns true if the difference between a and b are with\n * the specified tolerance.\n */\nfunction withinTolerance (a: number, b: number, tolerance: number) {\n return Math.abs(a - b) < Math.abs(tolerance)\n}\n\nfunction truncate (v: number, w: number): number {\n return v - (v % w)\n}\n","import Doc from './doc'\nimport { postJSON } from './http'\nimport State from './state'\nimport * as intl from './locales'\nimport * as OrderUtil from './orderutil'\nimport { Wave } from './charts'\nimport {\n app,\n PasswordCache,\n SupportedAsset,\n PageElement,\n WalletDefinition,\n ConfigOption,\n Exchange,\n Market,\n UnitInfo,\n BondAsset,\n WalletState,\n BalanceNote,\n Order,\n XYRange,\n WalletStateNote,\n WalletInfo,\n Token,\n WalletCreationNote,\n CoreNote\n} from './registry'\nimport { XYRangeHandler } from './opts'\n\ninterface ConfigOptionInput extends HTMLInputElement {\n configOpt: ConfigOption\n}\n\ninterface ProgressPoint {\n stamp: number\n progress: number\n}\n\ninterface CurrentAsset {\n asset: SupportedAsset\n parentAsset?: SupportedAsset\n winfo: WalletInfo | Token\n // selectedDef is used in a strange way for tokens. If a token's parent wallet\n // already exists, then selectedDef is going to be the Token.definition.\n // BUT, if the token's parent wallet doesn't exist yet, the NewWalletForm\n // operates in a combined configuration mode, and the selectedDef will be the\n // currently selected parent asset definition. There is no loss of info\n // in such a case, because the token wallet only has one definition.\n selectedDef: WalletDefinition\n}\n\ninterface WalletConfig {\n assetID: number\n config: Record\n walletType: string\n}\n\n/*\n * NewWalletForm should be used with the \"newWalletForm\" template. The enclosing\n *
element should be the first argument of the constructor.\n */\nexport class NewWalletForm {\n page: Record\n form: HTMLElement\n pwCache: PasswordCache | null\n success: (assetID: number) => void\n current: CurrentAsset\n pwHiders: HTMLElement[]\n subform: WalletConfigForm\n walletCfgGuide: PageElement\n parentSyncer: null | ((w: WalletState) => void)\n createUpdater: null | ((note: WalletCreationNote) => void)\n\n constructor (form: HTMLElement, success: (assetID: number) => void, pwCache?: PasswordCache, backFunc?: () => void) {\n this.form = form\n this.success = success\n this.pwCache = pwCache || null\n const page = this.page = Doc.parseTemplate(form)\n this.pwHiders = Array.from(form.querySelectorAll('.hide-pw'))\n this.refresh()\n\n if (backFunc) {\n Doc.show(page.goBack)\n Doc.bind(page.goBack, 'click', () => { backFunc() })\n }\n\n Doc.empty(page.walletTabTmpl)\n page.walletTabTmpl.removeAttribute('id')\n\n // WalletConfigForm will set the global app variable.\n this.subform = new WalletConfigForm(page.walletSettings, true)\n\n this.walletCfgGuide = Doc.tmplElement(form, 'walletCfgGuide')\n\n bind(form, page.submitAdd, () => this.submit())\n bind(form, page.oneBttn, () => this.submit())\n\n app().registerNoteFeeder({\n walletstate: (note: WalletStateNote) => { this.reportWalletState(note.wallet) },\n createwallet: (note: WalletCreationNote) => { this.reportCreationUpdate(note) }\n })\n }\n\n /*\n * reportWalletState should be called when a 'walletstate' notification is\n * received.\n * TODO: Let form classes register for notifications.\n */\n reportWalletState (w: WalletState): void {\n if (this.parentSyncer) this.parentSyncer(w)\n }\n\n /*\n * reportWalletState should be called when a 'createwallet' notification is\n * received.\n */\n reportCreationUpdate (note: WalletCreationNote) {\n if (this.createUpdater) this.createUpdater(note)\n }\n\n refresh () {\n const hidePWBox = State.passwordIsCached() || (this.pwCache && this.pwCache.pw)\n if (hidePWBox) Doc.hide(...this.pwHiders)\n else Doc.show(...this.pwHiders)\n }\n\n async createWallet (assetID: number, walletType: string, pw: string, parentForm?: WalletConfig) {\n const createForm = {\n assetID: assetID,\n pass: this.page.newWalletPass.value || '',\n config: this.subform.map(assetID),\n appPass: pw,\n walletType: walletType,\n parentForm: parentForm\n }\n\n const ani = new Wave(this.page.mainForm, { backgroundColor: true })\n const res = await postJSON('/api/newwallet', createForm)\n ani.stop()\n return res\n }\n\n async submit () {\n const page = this.page\n const appPass = page.appPass as HTMLInputElement\n const newWalletPass = page.newWalletPass as HTMLInputElement\n const pw = appPass.value || (this.pwCache ? this.pwCache.pw : '')\n if (!pw && !State.passwordIsCached()) {\n page.newWalletErr.textContent = intl.prep(intl.ID_NO_APP_PASS_ERROR_MSG)\n Doc.show(page.newWalletErr)\n return\n }\n Doc.hide(page.newWalletErr)\n\n const { asset, parentAsset } = this.current\n const selectedDef = this.current.selectedDef\n let parentForm\n if (parentAsset) {\n parentForm = {\n assetID: parentAsset.id,\n config: this.subform.map(parentAsset.id),\n walletType: selectedDef.type\n }\n }\n // Register the selected asset.\n const res = await this.createWallet(asset.id, selectedDef.type, pw, parentForm)\n if (!app().checkResponse(res)) {\n this.setError(res.msg)\n return\n }\n if (this.pwCache) this.pwCache.pw = pw\n page.appPass.value = ''\n newWalletPass.value = ''\n if (parentAsset) await this.runParentSync()\n else this.success(this.current.asset.id)\n }\n\n /*\n * runParentSync shows a syncing sub-dialog that tracks the parent asset's\n * syncProgress and informs the user that the token wallet will be created\n * after sync is complete.\n */\n async runParentSync () {\n const { page, current: { parentAsset, asset } } = this\n if (!parentAsset) return\n\n page.parentSyncPct.textContent = '0'\n page.parentName.textContent = parentAsset.name\n page.parentLogo.src = Doc.logoPath(parentAsset.symbol)\n page.childName.textContent = asset.name\n page.childLogo.src = Doc.logoPath(asset.symbol)\n Doc.hide(page.mainForm)\n Doc.show(page.parentSyncing)\n\n try {\n await this.syncParent(parentAsset)\n this.success(this.current.asset.id)\n } catch (error) {\n this.setError(error.message || error)\n }\n Doc.show(page.mainForm)\n Doc.hide(page.parentSyncing)\n }\n\n /*\n * syncParent monitors the sync progress of a token's parent asset, generating\n * an Error if the token wallet creation does not complete successfully.\n */\n syncParent (parentAsset: SupportedAsset): Promise {\n const { page, current: { asset } } = this\n return new Promise((resolve, reject) => {\n // First, check if it's already synced.\n const w = app().assets[parentAsset.id].wallet\n if (w && w.synced) return resolve()\n // Not synced, so create a syncer to update the parent sync pane.\n this.parentSyncer = (w: WalletState) => {\n if (w.assetID !== parentAsset.id) return\n page.parentSyncPct.textContent = (w.syncProgress * 100).toFixed(1)\n }\n // Handle the async result.\n this.createUpdater = (note: WalletCreationNote) => {\n if (note.assetID !== asset.id) return\n switch (note.topic) {\n case 'QueuedCreationFailed':\n reject(new Error(`${note.subject}: ${note.details}`))\n break\n case 'QueuedCreationSuccess':\n resolve()\n break\n default:\n return\n }\n this.parentSyncer = null\n this.createUpdater = null\n }\n })\n }\n\n /* setAsset sets the current asset of the NewWalletForm */\n async setAsset (assetID: number) {\n if (!this.parseAsset(assetID)) return // nothing to change\n const page = this.page\n const tabs = page.walletTypeTabs\n const { winfo, asset, parentAsset } = this.current\n page.assetName.textContent = winfo.name\n page.newWalletPass.value = ''\n\n Doc.empty(tabs)\n Doc.hide(tabs, page.newWalletErr)\n page.header.classList.remove('bordertop')\n this.page.assetLogo.src = Doc.logoPath(asset.symbol)\n\n const pinfo = parentAsset ? parentAsset.info : null\n const walletDefs = pinfo ? pinfo.availablewallets : (winfo as WalletInfo).availablewallets ? (winfo as WalletInfo).availablewallets : [(winfo as Token).definition]\n\n if (walletDefs.length > 1) {\n Doc.show(tabs)\n for (const wDef of walletDefs) {\n const tab = page.walletTabTmpl.cloneNode(true) as HTMLElement\n tab.dataset.tooltip = wDef.description\n tab.textContent = wDef.tab\n tabs.appendChild(tab)\n Doc.bind(tab, 'click', () => {\n for (const t of Doc.kids(tabs)) t.classList.remove('selected')\n tab.classList.add('selected')\n this.update(wDef)\n })\n }\n app().bindTooltips(tabs)\n const first = tabs.firstChild as HTMLElement\n first.classList.add('selected')\n }\n\n await this.update(this.current.selectedDef)\n if (asset.walletCreationPending) await this.runParentSync()\n }\n\n /*\n * parseAsset parses the current data for the asset ID.\n */\n parseAsset (assetID: number) {\n if (this.current && this.current.asset.id === assetID) return false\n const asset = app().assets[assetID]\n const token = asset.token\n if (!token) {\n if (!asset.info) throw Error('this non-token asset has no wallet info!')\n this.current = { asset, winfo: asset.info, selectedDef: asset.info.availablewallets[0] }\n return true\n }\n const parentAsset = app().user.assets[token.parentID]\n if (parentAsset.wallet) {\n // If the parent asset already has a wallet, there's no need to configure\n // the parent too. Just configure the token.\n this.current = { asset, winfo: token, selectedDef: token.definition }\n return true\n }\n if (!parentAsset.info) throw Error('this parent has no wallet info!')\n this.current = { asset, parentAsset, winfo: token, selectedDef: parentAsset.info.availablewallets[0] }\n return true\n }\n\n async update (walletDef: WalletDefinition) {\n const page = this.page\n this.current.selectedDef = walletDef\n const appPwCached = State.passwordIsCached() || (this.pwCache && this.pwCache.pw)\n Doc.hide(page.auth, page.oneBttnBox, page.newWalletPassBox)\n const guideLink = walletDef.guidelink\n const configOpts = walletDef.configopts || []\n // If a config represents a wallet's birthday, we update the default\n // selection to the current date if this installation of the client\n // generated a seed.\n configOpts.map((opt) => {\n if (opt.isBirthdayConfig && app().seedGenTime > 0) {\n opt.default = toUnixDate(new Date())\n }\n return opt\n })\n // Either this is a walletDef for a token's uncreated parent asset, or this\n // is the definition for the token.\n let containsRequired = false\n for (const opt of configOpts) {\n if (opt.required) {\n containsRequired = true\n break\n }\n }\n const noWalletPWNeeded = !containsRequired && (walletDef.seeded || Boolean(this.current.asset.token))\n if (appPwCached && noWalletPWNeeded) {\n Doc.show(page.oneBttnBox)\n } else if (noWalletPWNeeded) {\n Doc.show(page.auth)\n page.newWalletPass.value = ''\n page.submitAdd.textContent = intl.prep(intl.ID_CREATE)\n } else {\n Doc.show(page.auth)\n if (!walletDef.noauth) Doc.show(page.newWalletPassBox)\n page.submitAdd.textContent = intl.prep(intl.ID_ADD)\n }\n\n const { asset, parentAsset, winfo } = this.current\n\n if (parentAsset) {\n const parentAndTokenOpts = JSON.parse(JSON.stringify(configOpts))\n // Add the regAsset field to the configurations so proper logos will be displayed\n // next to them, and map can filter them out. The opts are copied here so the originals\n // do not have the regAsset field added to them.\n for (const opt of parentAndTokenOpts) opt.regAsset = parentAsset.id\n const tokenOpts = (winfo as Token).definition.configopts || []\n if (tokenOpts.length > 0) {\n const tokenOptsCopy = JSON.parse(JSON.stringify(tokenOpts))\n for (const opt of tokenOptsCopy) opt.regAsset = asset.id\n parentAndTokenOpts.push(...tokenOptsCopy)\n }\n this.subform.update(parentAndTokenOpts, false)\n } else this.subform.update(configOpts, false)\n this.setGuideLink(guideLink)\n\n if (this.subform.dynamicOpts.children.length || this.subform.defaultSettings.children.length) {\n Doc.show(page.walletSettingsHeader)\n } else Doc.hide(page.walletSettingsHeader)\n // A seeded or token wallet is internal to the dex client and as such does\n // not have an external config file to select.\n if (walletDef.seeded || Boolean(this.current.asset.token)) Doc.hide(this.subform.fileSelector)\n else Doc.show(this.subform.fileSelector)\n\n this.refresh()\n await this.loadDefaults()\n }\n\n setGuideLink (guideLink: string) {\n Doc.hide(this.walletCfgGuide)\n if (guideLink !== '') {\n this.walletCfgGuide.href = guideLink\n Doc.show(this.walletCfgGuide)\n }\n }\n\n /* setError sets and shows the in-form error message. */\n async setError (errMsg: string) {\n this.page.newWalletErr.textContent = errMsg\n Doc.show(this.page.newWalletErr)\n }\n\n /*\n * loadDefaults attempts to load the ExchangeWallet configuration from the\n * default wallet config path on the server and will auto-fill the page on\n * the subform if settings are found.\n */\n async loadDefaults () {\n // No default config files for seeded assets right now.\n const { asset, parentAsset, selectedDef } = this.current\n if (!selectedDef.configpath) return\n let configID = asset.id\n if (parentAsset) {\n if (selectedDef.seeded) return\n configID = parentAsset.id\n }\n const loaded = app().loading(this.form)\n const res = await postJSON('/api/defaultwalletcfg', {\n assetID: configID,\n type: selectedDef.type\n })\n loaded()\n if (!app().checkResponse(res)) {\n this.setError(res.msg)\n return\n }\n this.subform.setLoadedConfig(res.config)\n }\n}\n\nlet dynamicInputCounter = 0\n\n/*\n * WalletConfigForm is a dynamically generated sub-form for setting\n * asset-specific wallet configuration options.\n*/\nexport class WalletConfigForm {\n page: Record\n form: HTMLElement\n configElements: [ConfigOption, HTMLElement][]\n configOpts: ConfigOption[]\n sectionize: boolean\n allSettings: PageElement\n dynamicOpts: PageElement\n textInputTmpl: PageElement\n dateInputTmpl: PageElement\n checkboxTmpl: PageElement\n repeatableTmpl: PageElement\n fileSelector: PageElement\n fileInput: PageElement\n errMsg: PageElement\n showOther: PageElement\n showIcon: PageElement\n hideIcon: PageElement\n showHideMsg: PageElement\n otherSettings: PageElement\n loadedSettingsMsg: PageElement\n loadedSettings: PageElement\n defaultSettingsMsg: PageElement\n defaultSettings: PageElement\n assetHasActiveOrders: boolean\n\n constructor (form: HTMLElement, sectionize: boolean) {\n this.page = Doc.idDescendants(form)\n this.form = form\n // A configElement is a div containing an input and its label.\n this.configElements = []\n // configOpts is the wallet options provided by core.\n this.configOpts = []\n this.sectionize = sectionize\n\n // Get template elements\n this.allSettings = Doc.tmplElement(form, 'allSettings')\n this.dynamicOpts = Doc.tmplElement(form, 'dynamicOpts')\n this.textInputTmpl = Doc.tmplElement(form, 'textInput')\n this.textInputTmpl.remove()\n this.dateInputTmpl = Doc.tmplElement(form, 'dateInput')\n this.dateInputTmpl.remove()\n this.checkboxTmpl = Doc.tmplElement(form, 'checkbox')\n this.checkboxTmpl.remove()\n this.repeatableTmpl = Doc.tmplElement(form, 'repeatableInput')\n this.repeatableTmpl.remove()\n this.fileSelector = Doc.tmplElement(form, 'fileSelector')\n this.fileInput = Doc.tmplElement(form, 'fileInput')\n this.errMsg = Doc.tmplElement(form, 'errMsg')\n this.showOther = Doc.tmplElement(form, 'showOther')\n this.showIcon = Doc.tmplElement(form, 'showIcon')\n this.hideIcon = Doc.tmplElement(form, 'hideIcon')\n this.showHideMsg = Doc.tmplElement(form, 'showHideMsg')\n this.otherSettings = Doc.tmplElement(form, 'otherSettings')\n this.loadedSettingsMsg = Doc.tmplElement(form, 'loadedSettingsMsg')\n this.loadedSettings = Doc.tmplElement(form, 'loadedSettings')\n this.defaultSettingsMsg = Doc.tmplElement(form, 'defaultSettingsMsg')\n this.defaultSettings = Doc.tmplElement(form, 'defaultSettings')\n\n if (!sectionize) Doc.hide(this.showOther)\n\n Doc.bind(this.fileSelector, 'click', () => this.fileInput.click())\n\n // config file upload\n Doc.bind(this.fileInput, 'change', async () => this.fileInputChanged())\n\n Doc.bind(this.showOther, 'click', () => {\n this.setOtherSettingsViz(this.hideIcon.classList.contains('d-hide'))\n })\n }\n\n /*\n * fileInputChanged will read the selected file and attempt to load the\n * configuration settings. All loaded settings will be made visible for\n * inspection by the user.\n */\n async fileInputChanged () {\n Doc.hide(this.errMsg)\n if (!this.fileInput.value) return\n const files = this.fileInput.files\n if (!files || files.length === 0) return\n const loaded = app().loading(this.form)\n const config = await files[0].text()\n if (!config) return\n const res = await postJSON('/api/parseconfig', {\n configtext: config\n })\n loaded()\n if (!app().checkResponse(res)) {\n this.errMsg.textContent = res.msg\n Doc.show(this.errMsg)\n return\n }\n if (Object.keys(res.map).length === 0) return\n this.dynamicOpts.append(...this.setConfig(res.map))\n this.reorder(this.dynamicOpts)\n const [loadedOpts, defaultOpts] = [this.loadedSettings.children.length, this.defaultSettings.children.length]\n if (loadedOpts === 0) Doc.hide(this.loadedSettings, this.loadedSettingsMsg)\n if (defaultOpts === 0) Doc.hide(this.defaultSettings, this.defaultSettingsMsg)\n if (loadedOpts + defaultOpts === 0) Doc.hide(this.showOther, this.otherSettings)\n }\n\n addOpt (box: HTMLElement, opt: ConfigOption, insertAfter?: PageElement, skipRepeatN?: boolean): PageElement {\n let el: HTMLElement\n if (opt.isboolean) el = this.checkboxTmpl.cloneNode(true) as HTMLElement\n else if (opt.isdate) el = this.dateInputTmpl.cloneNode(true) as HTMLElement\n else if (opt.repeatable) {\n el = this.repeatableTmpl.cloneNode(true) as HTMLElement\n el.classList.add('repeatable')\n Doc.bind(Doc.tmplElement(el, 'add'), 'click', () => {\n this.addOpt(box, opt, el, true)\n })\n if (!skipRepeatN) for (let i = 0; i < (opt.repeatN ? opt.repeatN - 1 : 0); i++) this.addOpt(box, opt, insertAfter, true)\n } else el = this.textInputTmpl.cloneNode(true) as HTMLElement\n this.configElements.push([opt, el])\n const input = el.querySelector('input') as ConfigOptionInput\n input.dataset.configKey = opt.key\n // We need to generate a unique ID only for the =>