-
Notifications
You must be signed in to change notification settings - Fork 1
/
deposit-withdraw.490c548fde948ece93a8.js
1 lines (1 loc) · 324 KB
/
deposit-withdraw.490c548fde948ece93a8.js
1
(this.webpackChunkBitShares2_light=this.webpackChunkBitShares2_light||[]).push([[25],{27082:(e,t,s)=>{"use strict";s.d(t,{Z:()=>c});var a=s(67294),i=s(99349),n=s(23037),o=s(82267),r=s(44015);class l extends a.Component{static propTypes={account:n.Z.ChainAccount.isRequired,asset:n.Z.ChainAsset.isRequired};static defaultProps={autosubscribe:!1};render(){let e=this.props.asset.get("id"),t=this.props.account.getIn(["balances",e]);return t?a.createElement(r.Z,{balance:t,replace:this.props.replace}):a.createElement("span",null,"0 ",a.createElement(i.Z,{name:this.props.asset.get("symbol"),replace:this.props.replace}))}}const c=(0,o.Z)(l)},22686:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>Ss});var a=s(67294),i=s(89449),n=s(36345),o=s(41737),r=s(13973),l=s(58074),c=s.n(l),p=s(23037),d=s(82267),u=s(30806),h=s(99111),m=s(44015),_=s(112),g=s.n(_),w=s(57351),y=s(82050),b=s(84224),E=s(81237),f=s(74366),v=s(76660),C=s(45697),S=s.n(C),A=s(39014),k=s(48764).Buffer;class N extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_name:S().string.isRequired,output_coin_symbol:S().string.isRequired,output_coin_type:S().string.isRequired,url:S().string,output_wallet_type:S().string,output_supports_memos:S().bool.isRequired,amount_to_withdraw:S().string,balance:p.Z.ChainObject};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:b.So.getLast(e.output_wallet_type),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,confirmation_is_valid:!1,withdraw_address_selected:b.So.getLast(e.output_wallet_type),memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{}},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},this._checkBalance)}onSelectChanged(e){let t=b.So.get(this.props.output_wallet_type)[e];b.So.setLast({wallet:this.props.output_wallet_type,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}_validateAddress(e,t=this.props){(0,b.YN)({url:t.url,walletType:t.output_wallet_type,newAddress:e}).then((t=>{this.state.withdraw_address===e&&this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:t})}))}_checkBalance(){const{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a}=this.props;if(!a||!e)return;const i=(0,E.cr)(t,s,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(b.So.has(this.props.output_wallet_type)){let e=b.So.get(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e})}b.So.setLast({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t}=this.state,s=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),a=void 0!==this.props.gateFee?parseFloat(String.prototype.replace.call(this.props.gateFee,/,/g,"")):0;let i=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:s}),n=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:0});void 0!==this.props.balance&&(n=i.clone(this.props.balance.get("balance")));const o=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a});i.plus(o),n.lt(i)&&(i=n),(0,b.AN)(this.props.input_coin_type,this.props.output_coin_type,this.state.withdraw_address).then((s=>{y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),i.getAmount(),e.get("id"),s.memo+(this.state.memo?":"+new k(this.state.memo,"utf-8"):""),null,t?t.asset_id:"1.3.0")})),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),b.So.has(this.props.output_wallet_type)){let e=b.So.get(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e})}b.So.setLast({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a,fee_asset_id:i}=this.state;(0,b.AN)(this.props.input_coin_type,this.props.output_coin_type,this.state.withdraw_address).then((n=>{y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),n.memo+(this.state.memo?":"+new k(this.state.memo,"utf-8"):""),null,a?a.asset_id:i)}))}onDropDownList(){b.So.has(this.props.output_wallet_type)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,memo:t}=this.state,s=b.So.get(this.props.output_wallet_type),i=null,n=this.props.account.get("balances").toJS(),o=Object.keys(n),r=null,l=null,p=null;this.state.options_is_valid&&(l=a.createElement("div",{className:s.length?"blocktrades-options":"blocktrades-disabled-options"},s.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(r=a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_type})),p=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let d=1,u=null;this.props.output_supports_memos&&(u=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:t,tabIndex:d++,onChange:this.onMemoChanged.bind(this)})));let{fee_asset_types:h}=this._getAvailableAssets();if(o.length>0){let e=this.props.asset.get("id");if(e){let t=n[e];i=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:n[e]}):0))}else i="No funds"}else i="No funds";const _=this.state.error||this.state.balanceError||!this.state.withdraw_amount;return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:0}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:i}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:h,tabIndex:d++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,this.props.gateFee?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:this.props.gateFee}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"blocktrades-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"blocktrades-position-options"},l),r),u,a.createElement("div",null,a.createElement(v.Button,{type:"primary",disabled:_,onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),p))}}N=(0,d.Z)(N);const x=(0,i.$)(N,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})});var T=s(27082),M=s(99349),Z=s(3841),I=s(21712),B=s(52531),D=s(73935);class F extends a.Component{static propTypes={disableCopy:S().bool,replaceCopyText:S().string};constructor(e){super(e),this._handleCopy=this._handleCopy.bind(this)}componentDidMount(){this.childRef&&(this.node=D.findDOMNode(this.childRef)),this.node&&this.node.addEventListener&&this.node.addEventListener("copy",this._handleCopy)}componentWillUnmount(){this.node&&this.node.removeEventListener&&this.node.removeEventListener("copy",this._handleCopy)}_handleCopy(e){!1!==this.props.disableCopy&&(this.props.replaceCopyText&&e.clipboardData.setData("text/plain",this.props.replaceCopyText),e.preventDefault())}render(){return a.createElement("span",{ref:e=>this.childRef=e},this.props.children)}}const O=F;var R=s(74855),W=s.n(R);class P extends a.Component{static propTypes={url:S().string,gateway:S().string,deposit_coin_type:S().string,deposit_asset_name:S().string,deposit_account:S().string,receive_coin_type:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,deposit_asset:S().string,deposit_wallet_type:S().string,receive_asset:p.Z.ChainAsset,deprecated_in_favor_of:p.Z.ChainAsset,deprecated_message:S().string,action:S().string,supports_output_memos:S().bool.isRequired};static defaultProps={autosubscribe:!1};constructor(e){super(e);let t={blocktrades:I.q.BASE,openledger:I.yP.BASE};this.state={isModalVisible:!1,receive_address:null,url:e.url||t[e.gateway],loading:!1,emptyAddressDeposit:!1},this.addDepositAddress=this.addDepositAddress.bind(this),this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}_getDepositObject(){return{inputCoinType:this.props.deposit_coin_type,outputCoinType:this.props.receive_coin_type,outputAddress:this.props.account.get("name"),url:this.state.url,stateCallback:this.addDepositAddress}}UNSAFE_componentWillMount(){(0,b.Pk)({coin:this.props.receive_coin_type,account:this.props.account.get("name"),stateCallback:this.addDepositAddress})}UNSAFE_componentWillReceiveProps(e){e.account!==this.props.account&&(0,b.Pk)({coin:e.receive_coin_type,account:e.account.get("name"),stateCallback:this.addDepositAddress})}addDepositAddress(e){e.error&&("no_address"===e.error.message?this.setState({emptyAddressDeposit:!0}):this.setState({emptyAddressDeposit:!1})),this.setState({receive_address:e}),this.setState({loading:!1}),this.setState({receive_address:e})}requestDepositAddressLoad(){this.setState({loading:!0,emptyAddressDeposit:!1}),(0,b.Eu)(this._getDepositObject())}getWithdrawModalId(){return"withdraw_asset_"+this.props.issuer_account.get("name")+"_"+this.props.receive_asset.get("symbol")}onWithdraw(){this.showModal()}render(){const e="deposit"===this.props.action;let t=a.createElement(B.Z,null);if(!this.props.account||!this.props.issuer_account||!this.props.receive_asset)return t;let s=this.props.account.get("balances");const{gateFee:i}=this.props;if(this.props.receive_asset.get("symbol"),this.props.deprecated_in_favor_of){let e=!1,a=s.get(this.props.receive_asset.get("id"));if(a){let t=u.ChainStore.getObject(a);t&&0!=t.get("balance")&&(e=!0)}if(!e)return t}let n=this.state.receive_address,{emptyAddressDeposit:o}=this.state,r=this.state.loading;if(!n)return a.createElement("div",{style:{margin:"3rem"}},a.createElement(B.Z,{type:"three-bounce"}));let l,p=this.getWithdrawModalId(),d=null,h=null,m=null,_="";if(this.props.deposit_account){d=a.createElement("span",null,this.props.deposit_account),h=this.props.deposit_account,_=this.props.receive_coin_type+":"+this.props.account.get("name"),m=a.createElement("span",null,_);var w=this.props.deposit_coin_type+":"}else h=n&&n.address||"",n.memo?(l=n.memo,_=n.address,d=a.createElement("span",null,n.address),m=a.createElement("span",null,n.memo)):(_=n.address,d=a.createElement("span",null,n.address)),w="";return!this.props.isAvailable||e&&!this.props.deposit_account&&!n||n&&"unknown"===n.address?a.createElement("div",null,a.createElement(c(),{className:"txtlabel cancel",content:"gateway.unavailable",component:"h4"})):e?a.createElement("div",{className:"Blocktrades__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.deposit_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_deposit"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.your_account"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.deposit_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.deposit_to",asset:this.props.deposit_asset}),":"),a.createElement("label",{className:"fz_12 left-label"},a.createElement(c(),{content:"gateway.deposit_notice_delay"})),a.createElement("div",null,o?a.createElement(c(),{content:"gateway.please_generate_address"}):a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},d),a.createElement("div",null,m&&a.createElement("span",null,"memo: ",m)),a.createElement("div",{className:"button-group",style:{paddingTop:10}},d?a.createElement(W(),{text:h},a.createElement("div",{className:"button"},a.createElement(c(),{content:"gateway.copy_address"}))):null,l?a.createElement(W(),{text:l},a.createElement("div",{className:"button"},a.createElement(c(),{content:"gateway.copy_memo"}))):null,a.createElement("button",{className:"button spinner-button-circle",onClick:this.requestDepositAddressLoad.bind(this)},r?a.createElement(B.Z,{type:"circle"}):null,a.createElement(c(),{content:"gateway.generate_new"}))),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_amount",minDeposit:2*this.props.gateFee,coin:this.props.deposit_asset}),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_asset",minDeposit:2*this.props.gateFee,coin:this.props.deposit_asset})))):a.createElement("div",{className:"Blocktrades__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_withdraw"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.withdraw_to",asset:this.props.deposit_asset}),":"),a.createElement("div",{className:"button-group",style:{paddingTop:20}},a.createElement("button",{className:"button success",style:{fontSize:"1.3rem"},onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:"gateway.withdraw_now"})," "))),a.createElement(v.Modal,{onCancel:this.hideModal,title:g().translate("gateway.withdraw_coin",{coin:this.props.deposit_asset_name,symbol:this.props.deposit_asset}),footer:null,visible:this.state.isModalVisible,id:p,overlay:!0},a.createElement(x,{hideModal:this.hideModal,showModal:this.showModal,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.props.receive_asset.get("symbol"),url:this.state.url,output_coin_name:this.props.deposit_asset_name,gateFee:i,output_coin_symbol:this.props.deposit_asset,output_coin_type:this.props.deposit_coin_type,output_wallet_type:this.props.deposit_wallet_type,output_supports_memos:this.props.supports_output_memos,memo_prefix:w,modal_id:p,balance:this.props.account.get("balances").toJS()[this.props.receive_asset.get("id")]})))}}const q=(0,d.Z)(P);var U=s(55294),j=s(32049),L=s(43393),V=s.n(L);class z extends a.Component{constructor(e){super();const t=e.viewSettings.get(`${e.provider}Action`,"deposit");this.state={activeCoin:this._getActiveCoin(e,{action:t}),action:t}}_getActiveCoin(e,t){let s=e.viewSettings.get(`activeCoin_${e.provider}_${t.action}`,null),a=null;return"blocktrades"==e.provider&&"deposit"==t.action&&(a="BTC"),"openledger"==e.provider&&"deposit"==t.action&&(a="BTC"),"blocktrades"==e.provider&&"withdraw"==t.action&&(a="TRADE.BTC"),"openledger"==e.provider&&"withdraw"==t.action&&(a="OPEN.BTC"),s||a}UNSAFE_componentWillReceiveProps(e){e.provider!==this.props.provider&&this.setState({activeCoin:this._getActiveCoin(e,this.state.action)})}onSelectCoin(e){this.setState({activeCoin:e.target.value});let t={};t[`activeCoin_${this.props.provider}_${this.state.action}`]=e.target.value,U.Z.changeViewSetting(t)}changeAction(e){let t=this._getActiveCoin(this.props,{action:e});this.setState({action:e,activeCoin:t}),U.Z.changeViewSetting({[`${this.props.provider}Action`]:e})}render(){let{coins:e,account:t,provider:s}=this.props,{activeCoin:i,action:n}=this.state;if(!e.length)return a.createElement(B.Z,null);let o=e.filter((e=>!(!e||!e.symbol)&&("deposit"===n?e.depositAllowed:e.withdrawalAllowed))),r=o.map((e=>{let t="deposit"===n?e.backingCoinType.toUpperCase():e.symbol;return a.createElement("option",{value:t,key:e.symbol},t)})).filter((e=>null!==e)),l=o.filter((e=>"deposit"===n?e.backingCoinType.toUpperCase()===i:e.symbol===i))[0];l||(l=o[0]);let p={blocktrades:{name:"blocktrades",id:"1.2.32567",support:"[email protected]"},openledger:{name:l.intermediateAccount,id:"1.2.96397",support:"https://dex.openledger.io"}}[s],d="deposit"===this.state.action;return a.createElement("div",{style:this.props.style},a.createElement("div",{className:"grid-block no-margin vertical medium-horizontal no-padding"},a.createElement("div",{className:"medium-4"},a.createElement("div",null,a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.choose_"+n}),":"," "),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:i},r))),a.createElement("div",{className:"medium-6 medium-offset-1"},a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.gateway_text"}),":"),a.createElement("div",{style:{paddingBottom:15}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{className:"deposit"===n?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"deposit")},a.createElement(c(),{content:"gateway.deposit"}))),a.createElement("li",{className:"withdraw"===n?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"withdraw")},a.createElement(c(),{content:"gateway.withdraw"}))))))),l?a.createElement("div",null,a.createElement("div",{style:{marginBottom:15}},a.createElement(q,{key:`${s}.${l.symbol}`,gateway:s,issuer_account:p.name,account:t,deposit_asset:l.backingCoinType.toUpperCase(),deposit_asset_name:l.name,deposit_coin_type:l.backingCoinType.toLowerCase(),deposit_account:l.depositAccount,deposit_wallet_type:l.walletType,gateFee:l.gateFee,receive_asset:l.symbol,receive_coin_type:l.symbol.toLowerCase(),supports_output_memos:l.supportsMemos,isAvailable:l.isAvailable,action:this.state.action}),a.createElement("label",{className:"left-label"},"Support"),a.createElement("div",null,a.createElement(c(),{content:"gateway.support_block"}),a.createElement("br",null),a.createElement("br",null),a.createElement("a",{href:(-1===p.support.indexOf("@")?"":"mailto:")+p.support,rel:"noopener noreferrer",className:-1===p.support.indexOf("@")?"external-link":""},p.support))),l&&l.symbol?a.createElement(j.k,{asset:l.symbol,fromAccount:d?p.id:this.props.account.get("id"),to:d?this.props.account.get("id"):p.id},(({asset:e,to:t,fromAccount:s})=>a.createElement(j.t,{accountsList:V().List([this.props.account.get("id")]),limit:10,compactView:!0,fullHeight:!0,filter:"transfer",title:a.createElement(c(),{content:"gateway.recent_"+this.state.action}),customFilter:{fields:["to","from","asset_id"],values:{to:t.get("id"),from:s.get("id"),asset_id:e.get("id")}}}))):null):null)}}const J=(0,i.$)(z,{listenTo:()=>[A.Z],getProps:()=>({viewSettings:A.Z.getState().viewSettings})});var X=s(41075);class H extends a.Component{render(){return a.createElement("div",null,"Base Modal was removed by task following below:",a.createElement("br",null),"https://github.com/bitshares/bitshares-ui/issues/1942")}}const K=H;var G=s(14169),Q=s.n(G),$=s(88209),Y=s.n($);class ee extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer_account:p.Z.ChainAccount.isRequired,deposit_asset:S().string,receive_asset:p.Z.ChainAsset.isRequired,rpc_url:S().string};constructor(e){super(e),this.state={deposit_amount:null,deposit_info:null,deposit_error:null}}onDepositAmountChange({amount:e,asset:t}){this.setState({deposit_amount:e})}onSubmitDeposit(){let e=this.props.receive_asset,t=(r.Z.get_asset_precision(e.get("precision")),this.state.deposit_amount.replace(/,/g,""));console.log("deposit_amount: ",t);let s={jsonrpc:"2.0",method:"getDepositAccount",params:{bitsharesAccountName:this.props.account.get("name"),currency:this.props.deposit_asset,amount:t},id:1};fetch(this.props.rpc_url,{method:"POST",headers:new Headers({Accept:"application/json","content-type":"application/x-www-form-urlencoded"}),body:"rq="+encodeURIComponent(JSON.stringify(s))}).then((e=>e.json())).then((e=>{"result"in e?this.setState({deposit_info:e.result}):"error"in json_reponse&&"message"in e.error?this.setState({deposit_error:e.error.message}):this.setState({deposit_error:"Unable to approve deposit, please contact OpenLedger or try again later"})})).catch((e=>{this.setState({deposit_error:"Unable to approve deposit, please contact OpenLedger or try again later"})}))}onClose(){this.setState({deposit_amount:null,deposit_info:null,deposit_error:null}),Y().publish(this.props.modal_id,"close")}render(){if(this.state.deposit_error)return a.createElement("form",{className:"grid-block vertical full-width-content"},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement("h3",null,"Deposit Error")),a.createElement("div",{className:"content-block"},a.createElement("p",null,this.state.deposit_error)),a.createElement("div",{className:"content-block"},a.createElement("input",{type:"submit",className:"button",onClick:this.onClose.bind(this),value:"Close"}))));if(this.state.deposit_info){if("link"in this.state.deposit_info)return a.createElement("form",{className:"grid-block vertical full-width-content"},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement("h3",null,"Deposit Information")),a.createElement("div",{className:"content-block"},a.createElement("p",null,"Click"," ",a.createElement("a",{href:this.state.deposit_info.link,rel:"noopener noreferrer",target:"_blank"},"here")," ","for deposit instructions")),a.createElement("div",{className:"content-block"},a.createElement("input",{type:"submit",className:"button",onClick:this.onClose.bind(this),value:"Close"}))));let t=[];for(var e in this.state.deposit_info)this.state.deposit_info.hasOwnProperty(e)&&t.push(a.createElement("tr",null,a.createElement("td",null,e),a.createElement("td",null,this.state.deposit_info[e])));return a.createElement("form",{className:"grid-block vertical full-width-content"},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement("h3",null,"Deposit Information")),a.createElement("div",{className:"content-block"},a.createElement("table",{className:"table"},a.createElement("tbody",null,t))),a.createElement("div",{className:"content-block"},a.createElement("input",{type:"submit",className:"button",onClick:this.onClose.bind(this),value:g().translate("account.perm.cancel")}))))}return a.createElement("form",{className:"grid-block vertical full-width-content"},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement("h3",null,"Deposit ",this.props.deposit_asset)),a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.deposit.amount",amount:this.state.deposit_amount,asset:this.props.receive_asset.get("id"),assets:[this.props.receive_asset.get("id")],placeholder:"0.0",onChange:this.onDepositAmountChange.bind(this),display_balance:null})),a.createElement("div",{className:"content-block"},a.createElement("input",{type:"submit",className:"button",onClick:this.onSubmitDeposit.bind(this),value:g().translate("modal.deposit.submit")}),a.createElement("input",{type:"submit",className:" button",onClick:this.onClose.bind(this),value:g().translate("account.perm.cancel")}))))}}const te=(0,d.Z)(ee);class se extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer_account:p.Z.ChainAccount.isRequired,deposit_asset:S().string,receive_asset:p.Z.ChainAsset.isRequired,rpc_url:S().string};constructor(e){super(e),this.state={withdraw_amount:null}}onWithdrawAmountChange({amount:e,asset:t}){this.setState({withdraw_amount:e})}onSubmit(){let e=this.props.receive_asset,t=r.Z.get_asset_precision(e.get("precision")),s=this.state.withdraw_amount.replace(/,/g,""),a={jsonrpc:"2.0",method:"getMemoForFiatWithdrawal",params:{bitsharesAccountName:this.props.account.get("name"),currency:this.props.deposit_asset,amount:s},id:1};fetch(this.props.rpc_url,{method:"POST",headers:new Headers({Accept:"application/json","content-type":"application/x-www-form-urlencoded"}),body:"rq="+encodeURIComponent(JSON.stringify(a))}).then((e=>e.json())).then((a=>{if(!("result"in a))throw"error"in a&&"message"in a.error?json_repsonse.error.message:"Unable to approve withdrawal, please contact OpenLedger or try again later";y.Z.transfer(this.props.account.get("id"),this.props.issuer_account.get("id"),parseInt(s*t,10),e.get("id"),a.result)})).catch((e=>{alert(e)}))}render(){let e=null,t=this.props.account.get("balances").toJS();if(Object.keys(t).length>0){let s=this.props.receive_asset.get("id");e=s?a.createElement("span",null,a.createElement(c(),{component:"span",content:"transfer.available"}),":"," ",a.createElement(m.Z,{balance:t[s]})):"No funds"}else e="No funds";return a.createElement("form",{className:"grid-block vertical full-width-content"},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement("h3",null,"Withdraw ",this.props.deposit_asset)),a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.receive_asset.get("id"),assets:[this.props.receive_asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:e})),a.createElement("div",{className:"content-block"},a.createElement("input",{type:"submit",className:"button",onClick:this.onSubmit.bind(this),value:g().translate("modal.withdraw.submit")}),a.createElement(Q(),{close:this.props.modal_id},a.createElement("div",{className:"button"},a.createElement(c(),{content:"account.perm.cancel"}))))))}}const ae=(0,d.Z)(se);class ie extends a.Component{static propTypes={url:S().string,gateway:S().string,deposit_coin_type:S().string,deposit_asset_name:S().string,deposit_account:S().string,receive_coin_type:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,deposit_asset:S().string,receive_asset:p.Z.ChainAsset,deposit_allowed:S().bool,withdraw_allowed:S().bool};constructor(e){super(e),this.state={}}getWithdrawModalId(){return"withdraw_fiat_openledger_"+this.props.receive_asset.get("symbol")}getDepositModalId(){return"deposit_fiat_openledger_"+this.props.receive_asset.get("symbol")}onWithdraw(){Y().publish(this.getWithdrawModalId(),"open")}onDeposit(){Y().publish(this.getDepositModalId(),"open")}render(){if(!this.props.account||!this.props.issuer_account||!this.props.receive_asset)return a.createElement("tr",{style:{display:"none"}},a.createElement("td",null),a.createElement("td",null),a.createElement("td",null),a.createElement("td",null));X.Z.getWallet();let e=this.props.account.get("balances"),t="0 "+this.props.receive_asset.get("symbol"),s=e.toJS();if(Object.keys(s).length>0){let e=this.props.receive_asset.get("id");e&&(t=a.createElement("span",null,a.createElement(c(),{component:"span",content:"transfer.available"}),":"," ",a.createElement(m.Z,{balance:s[e]})))}let i=this.getDepositModalId(),n=this.getWithdrawModalId(),o=null;o=this.props.deposit_allowed?a.createElement("td",null,a.createElement("button",{className:"button outline",onClick:this.onDeposit.bind(this)}," ",a.createElement(c(),{content:"gateway.deposit"})," "),a.createElement(K,{id:i,overlay:!0},a.createElement(Q(),{close:i},a.createElement("a",{href:"#",className:"close-button"},"×")),a.createElement("br",null),a.createElement("div",{className:"grid-block vertical"},a.createElement(te,{account:this.props.account.get("name"),issuer_account:this.props.issuer_account.get("name"),receive_asset:this.props.receive_asset.get("symbol"),rpc_url:this.props.rpc_url,deposit_asset:this.props.deposit_asset,modal_id:i})))):a.createElement("td",null,"Click"," ",a.createElement("a",{href:"https://openledger.info/v/",rel:"noopener noreferrer",target:"_blank",className:"external-link"},"here")," ","to register for deposits of ",this.props.deposit_asset);let r=null;return r=this.props.withdraw_allowed?a.createElement("td",null,a.createElement("button",{className:"button outline",onClick:this.onWithdraw.bind(this)}," ",a.createElement(c(),{content:"gateway.withdraw"})," "),a.createElement(K,{id:n,overlay:!0},a.createElement(Q(),{close:n},a.createElement("a",{href:"#",className:"close-button"},"×")),a.createElement("br",null),a.createElement("div",{className:"grid-block vertical"},a.createElement(ae,{account:this.props.account.get("name"),issuer_account:this.props.issuer_account.get("name"),receive_asset:this.props.receive_asset.get("symbol"),rpc_url:this.props.rpc_url,deposit_asset:this.props.deposit_asset,modal_id:n})))):a.createElement("td",null,"Click"," ",a.createElement("a",{href:"https://openledger.info/v/",rel:"noopener noreferrer",target:"_blank",className:"external-link"},"here")," ","to register for withdrawals of ",this.props.deposit_asset),a.createElement("tr",null,a.createElement("td",null,this.props.deposit_asset),o,a.createElement("td",null,a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol")})),r)}}ie=(0,d.Z)(ie);class ne extends a.Component{static propTypes={rpc_url:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount};constructor(e){super(e),this.state={allowedFiatCurrencies:{deposit:[],withdraw:[]}};let t={jsonrpc:"2.0",id:1,method:"isValidatedForFiat",params:{bitsharesAccountName:this.props.account.get("name")}};fetch(this.props.rpc_url,{method:"POST",headers:new Headers({Accept:"application/json","content-type":"application/x-www-form-urlencoded"}),body:"rq="+encodeURIComponent(JSON.stringify(t))}).then((e=>e.json())).then((e=>{"result"in e&&this.setState({allowedFiatCurrencies:e.result})})).catch((e=>{this.setState({allowedFiatCurrencies:{deposit:[],withdraw:[]}})}))}componentWillUnmount(){clearInterval(this.update_timer)}render(){return this.props.account&&this.props.issuer_account,a.createElement("div",null)}}const oe=ne=(0,d.Z)(ne);class re extends a.Component{static propTypes={rpc_url:S().string,account:p.Z.ChainAccount};constructor(e){super(e),this.state={current_status:"never_loaded",withdrawals:null,deposits:null,error:null}}onShowOpenLedgerTransactionHistory(){let e={jsonrpc:"2.0",method:"getRequestsList",params:{bitsharesAccountName:this.props.account.get("name")},id:1};fetch(this.props.rpc_url,{method:"POST",headers:new Headers({Accept:"application/json","content-type":"application/x-www-form-urlencoded"}),body:"rq="+encodeURIComponent(JSON.stringify(e))}).then((e=>e.json())).then((e=>{if(!("result"in e))throw"error"in e&&"message"in e.error?json_repsonse.error.message:"Unexpected response";this.setState({current_status:"loaded",withdrawals:e.result.withdrawals,deposits:e.result.deposits,error:null})})).catch((e=>{this.setState({current_status:"error",withdrawals:null,deposits:null,error:"Error getting transaction history: "+e})}))}render(){if(!this.props.account)return null;let e=null;if("loaded"===this.state.current_status){let s=[];if(this.state.withdrawals.length){for(var t=0;t<this.state.withdrawals.length;++t)s.push(a.createElement("tr",null,a.createElement("td",null,this.state.withdrawals[t].amount," ",this.state.withdrawals[t].currency),a.createElement("td",null,this.state.withdrawals[t].status)));e=a.createElement("table",{className:"table"},a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"openledger.withdraw_amount"})),a.createElement("th",null,a.createElement(c(),{content:"openledger.status"})))),a.createElement("tbody",null,s))}else e=a.createElement(c(),{component:"p",content:"openledger.withdraw_none"})}let s=null;if("loaded"===this.state.current_status)if(this.state.deposits.length){let e=[];for(t=0;t<this.state.deposits.length;++t)e.push(a.createElement("tr",null,a.createElement("td",null,this.state.deposits[t].amount," ",this.state.deposits[t].currency),a.createElement("td",null,a.createElement("a",{href:this.state.deposits[t].link,rel:"noopener noreferrer",target:"_blank"},"link")),a.createElement("td",null,this.state.deposits[t].status)));s=a.createElement("table",{className:"table"},a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"openledger.deposit_amount"})),a.createElement("th",null,a.createElement(c(),{content:"openledger.deposit_details"})),a.createElement("th",null,a.createElement(c(),{content:"openledger.status"})))),a.createElement("tbody",null,e))}else s=a.createElement(c(),{component:"p",content:"openledger.deposit_none"});let i=null;if("error"===this.state.current_status)i=a.createElement("div",{className:"content-block"},a.createElement("button",{className:"button outline",onClick:this.onShowOpenLedgerTransactionHistory.bind(this)},a.createElement(c(),{content:"openledger.retry"})),a.createElement("p",null,this.state.error));else if("loading"===this.state.current_status)i=a.createElement("div",{className:"content-block"},a.createElement("button",{className:"button outline",onClick:this.onShowOpenLedgerTransactionHistory.bind(this),disabled:"true"},a.createElement(c(),{content:"openledger.show_transaction_history"})),a.createElement(c(),{component:"p",content:"openledger.loading"}));else{let t="never_loaded"===this.state.current_status?a.createElement(c(),{content:"openledger.show_transaction_history"}):a.createElement(c(),{content:"openledger.refresh_transaction_history"});i=a.createElement("div",{className:"content-block"},a.createElement("br",null),a.createElement(c(),{component:"h4",content:"openledger.header_transaction_history"}),a.createElement("button",{className:"button outline",onClick:this.onShowOpenLedgerTransactionHistory.bind(this)},t),e,s)}return i}}const le=(0,d.Z)(re);var ce=s(49554),pe=s(69730),de=s(17563),ue=s(19602),he=s(64671),me=s(48764).Buffer;let _e=(0,ue.ZP)("__oauthBlocktrades__"),ge=(0,ue.ZP)("oidc.user:https://blocktrades.us/:10ecf048-b982-467b-9965-0b0926330869");const we=window.location.protocol+"//"+window.location.host+"/deposit-withdraw",ye="https://blocktrades.us/",be="10ecf048-b982-467b-9965-0b0926330869",Ee=we,fe="offline openid email profile create_new_mappings view_client_transaction_history view_price_estimates";class ve extends a.Component{static propTypes={balance:p.Z.ChainObject,input_coin_type:S().string.isRequired,output_coin_type:S().string.isRequired,account_name:S().string.isRequired,account_id:S().string.isRequired,url:S().string.isRequired};constructor(e){super(e),this.state={error:null,conversion_memo:null,feeStatus:{}},this._updateFee=(0,h.Z)(this._updateFee.bind(this),150),this._checkFeeStatus=this._checkFeeStatus.bind(this),this._checkBalance=this._checkBalance.bind(this)}_getFeeID(e=this.props){const t=this._getCurrentBalance(e),s=e.account.get("balances"),a=u.ChainStore.assets_by_symbol.get(A.Z.getState().settings.get("fee_asset"))||"1.3.0";return s.has(a)?a:t?t.get("asset_type"):"1.3.0"}UNSAFE_componentWillMount(){this._updateFee()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.amount.equals(this.props.amount)&&e.account_id===this.props.account_id||this._updateFee()}_updateFee(){const e=this._getFeeID();let t=null;!0===this.props.is_user_authorized&&(t=ge.get("").access_token),(0,b.Ob)(this.props,t).then((t=>{(0,E.rX)({accountID:this.props.account_id,feeID:e,options:["price_per_kbyte"],data:{type:"memo",content:t.inputMemo}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted?this._checkFeeStatus():this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkFeeStatus)})).catch((e=>{this._checkFeeStatus()}))}))}_checkFeeStatus(e=this.props.account){if(!e)return;let t=Object.keys(this.props.account.get("balances").toJS());t.length||(t=["1.3.0"]);let s={},a=[],i=null;!0===this.props.is_user_authorized&&(i=ge.get("").access_token),(0,b.Ob)(this.props,i).then((i=>{t.forEach((t=>{a.push((0,E.rX)({accountID:e.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:i.inputMemo}}))})),Promise.all(a).then((e=>{this.unMounted||(t.forEach(((t,a)=>{s[t]=e[a]})),r.Z.are_equal_shallow(this.state.feeStatus,s)||this.setState({feeStatus:s}),this._checkBalance())})).catch((e=>{console.error(e)}))}))}_getCurrentBalance(e=this.props){return e.balance}_checkBalance(){const{feeAmount:e}=this.state,{asset:t,amount:s}=this.props,a=this._getCurrentBalance();if(!a||!e)return;const i=(0,E.cr)(s.getAmount({real:!0}),t,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}onTrxIncluded(e){(e.included&&e.broadcasted_transaction||e.closed)&&(pe.Z.unlisten(this.onTrxIncluded),pe.Z.reset())}onConvert(){const{input_coin_type:e,output_coin_type:t,amount:s}=this.props,{balanceError:a}=this.state;let i=null;!0===this.props.is_user_authorized&&(i=ge.get("").access_token),(0,b.Ob)(this.props,i).then((i=>{if(i.inputCoinType!=e||i.outputCoinType!=t)throw new Error("unexpected reply from initiate-trade");e!=i.inputCoinType||t!=i.outputCoinType||a||(this.setState({conversion_memo:i.inputMemo}),this.setState({error:null}),y.Z.transfer(this.props.account_id,"1.2.32567",s.getAmount(),this.props.asset.get("id"),i.inputMemo?new me(i.inputMemo,"utf-8"):"",null,this._getFeeID()).then((()=>{pe.Z.unlisten(this.onTrxIncluded),pe.Z.listen(this.onTrxIncluded)})).catch((e=>{let t=e.message?e.message.split("\n")[1]:null;console.log("error: ",e,t),this.setState({error:t})})))})).catch((()=>{this.setState({conversion_memo:null})}))}render(){let e="button disabled";return Object.keys(this.props.account_balances.toJS()).includes(this.props.asset.get("id"))&&!this.state.balanceError&&this.state.hasBalance&&this.props.amount.getAmount()>0&&(e="button"),a.createElement("span",null,a.createElement("button",{className:e,onClick:this.onConvert.bind(this)},a.createElement(c(),{content:""}),a.createElement(c(),{content:"gateway.convert_now"})),this.state.balanceError?a.createElement("div",{style:{paddingTop:15},className:"has-error"},a.createElement(c(),{content:"transfer.errors.insufficient"})):null)}}ve=(0,d.Z)(ve);class Ce extends a.Component{static propTypes={asset:p.Z.ChainAsset.isRequired,input_coin_type:S().string.isRequired,output_coin_type:S().string.isRequired,account_name:S().string.isRequired,account_id:S().string.isRequired,url:S().string.isRequired};render(){let e=a.createElement(ve,{asset:this.props.asset,account:this.props.account,input_coin_type:this.props.input_coin_type,is_user_authorized:this.props.is_user_authorized,output_coin_type:this.props.output_coin_type,account_name:this.props.account_name,amount:new f.xR({real:this.props.amount,asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")}),account_id:this.props.account_id,account_balances:this.props.account_balances,url:this.props.url,balance:this.props.account.get("balances").toJS()[this.props.asset.get("id")]});return a.createElement("span",null,e)}}Ce=(0,d.Z)(Ce);class Se extends a.Component{static propTypes={balance:p.Z.ChainObject,url:S().string.isRequired};getWithdrawModalId(){return"withdraw_asset_"+this.props.gateway+"_bridge"}onWithdraw(){this.props.showModal()}render(){let e="button disabled";return Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))&&this.props.amount_to_withdraw&&!(this.props.amount_to_withdraw.indexOf(" ")>=0)&&!isNaN(this.props.amount_to_withdraw)&&this.props.amount_to_withdraw>0&&this.props.amount_to_withdraw<=this.props.balance.toJS().balance/r.Z.get_asset_precision(this.props.asset.get("precision"))&&(e="button"),a.createElement("span",null,a.createElement("span",null,a.createElement("button",{className:e,onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:""}),a.createElement(c(),{content:"gateway.withdraw_now"})," ")),a.createElement(v.Modal,{closable:!1,onCancel:this.props.hideModal,title:g().translate("gateway.withdraw_coin",{coin:this.props.output_coin_name,symbol:this.props.output_coin_symbol}),footer:null,visible:this.props.visible,overlay:!0},a.createElement(x,{hideModal:this.props.hideModal,key:`${this.props.key}`,account:this.props.account.get("name"),issuer:this.props.issuer,asset:this.props.asset.get("id"),output_coin_name:this.props.output_coin_name,output_coin_symbol:this.props.output_coin_symbol,input_coin_type:this.props.input_coin_type,output_coin_type:this.props.output_coin_type,output_supports_memos:this.props.output_supports_memos,amount_to_withdraw:this.props.amount_to_withdraw,url:this.props.url,output_wallet_type:this.props.output_wallet_type,balance:this.props.account.get("balances").toJS()[this.props.asset.get("id")]})))}}Se=(0,d.Z)(Se);class Ae extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_type:S().string.isRequired,url:S().string.isRequired};render(){let e=a.createElement(Se,{visible:this.props.visible,hideModal:this.props.hideModal,showModal:this.props.showModal,key:this.props.key,account:this.props.account,issuer:this.props.issuer,asset:this.props.asset,output_coin_name:this.props.output_coin_name,output_coin_symbol:this.props.output_coin_symbol,input_coin_type:this.props.input_coin_type,output_coin_type:this.props.output_coin_type,output_supports_memos:this.props.output_supports_memos,amount_to_withdraw:this.props.amount_to_withdraw,url:this.props.url,gateway:this.props.gateway,output_wallet_type:this.props.output_wallet_type,balance:this.props.account.get("balances").toJS()[this.props.asset.get("id")]});return a.createElement("span",null,e)}}Ae=(0,d.Z)(Ae);class ke extends a.Component{static propTypes={url:S().string,gateway:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,initial_deposit_input_coin_type:S().string,initial_deposit_output_coin_type:S().string,initial_deposit_estimated_input_amount:S().string,initial_withdraw_input_coin_type:S().string,initial_withdraw_output_coin_type:S().string,initial_withdraw_estimated_input_amount:S().string,initial_conversion_input_coin_type:S().string,initial_conversion_output_coin_type:S().string,initial_conversion_estimated_input_amount:S().string};constructor(e){super(e),this.refresh_interval=12e4,this.deposit_address_cache=new ce.Z,this.coin_info_request_states={request_in_progress:0,request_complete:1,request_failed:2},this.estimation_directions={output_from_input:0,input_from_output:1};let t=!1;!0===_e.get("is_refresh_token")&&(t=!0),this.manager=new he.UserManager({authority:ye,client_id:be,redirect_uri:Ee,response_type:"code",scope:fe,loadUserInfo:!0,automaticSilentRenew:t,userStore:new he.WebStorageStateStore({store:window.localStorage}),post_logout_redirect_uri:we}),this.state={isModalVisible:!1,coin_symbol:"btc",key_for_withdrawal_dialog:"btc",supports_output_memos:"",url:I.q.BASE,error:null,isUserAuthorized:!1,retrievingDataFromOauthApi:!0,deposit_input_coin_type:null,deposit_output_coin_type:null,input_address_and_memo:null,deposit_estimated_input_amount:this.props.initial_deposit_estimated_input_amount||"1.0",deposit_estimated_output_amount:null,deposit_limit:null,deposit_error:null,failed_calculate_deposit:null,withdraw_input_coin_type:null,withdraw_output_coin_type:null,withdraw_estimated_input_amount:this.props.initial_withdraw_estimated_input_amount||"1.0",withdraw_estimated_output_amount:null,withdraw_limit:null,withdraw_error:null,failed_calculate_withdraw:null,conversion_input_coin_type:null,conversion_output_coin_type:null,conversion_estimated_input_amount:this.props.initial_conversion_estimated_input_amount||"1.0",conversion_estimated_output_amount:null,conversion_limit:null,conversion_error:null,failed_calculate_conversion:null,coin_info_request_state:this.coin_info_request_states.request_in_progress,input_address_requests_in_progress:{},deposit_estimate_direction:this.estimation_directions.output_from_input,deposit_limit_cache:{},deposit_limit_requests_in_progress:{},coins_by_type:null,allowed_mappings_for_deposit:null,allowed_mappings_for_withdraw:null,allowed_mappings_for_conversion:null,conversion_memo:null,announcements:[]},this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}urlConnection(e,t){this.setState({url:e});let s=fetch(e+"/announcements/enabled/trade",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json()));if(Promise.resolve(s).then((e=>{e.sort(((e,t)=>e.priority<t.priority?-1:e.priority>t.priority?1:0)),this.setState({announcements:e,coin_info_request_state:this.coin_info_request_states.request_complete})})).catch((()=>{this.setState({announcements:[],coin_info_request_state:t})})),!1===this.state.isUserAuthorized)return;let a={Accept:"application/json"};this.state.isUserAuthorized&&(a={Accept:"application/json",Authorization:`Bearer ${ge.get("").access_token}`});let i=fetch(e+"/coins",{method:"get",headers:a}).then((e=>e.json())),n=fetch(e+"/wallets",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),o=fetch(e+"/trading-pairs",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),r=fetch(e+"/active-wallets",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json()));Promise.all([i,n,o,r]).then((e=>{let[t,s,a,i]=e,n={};t.forEach((e=>n[e.coinType]=e));let o={},r={},l={};a.forEach((e=>{let t=n[e.inputCoinType],s=n[e.outputCoinType];t.backingCoinType!=e.outputCoinType&&s&&s.backingCoinType!=e.inputCoinType&&t&&(0==t.restricted&&0==s.restricted||1==t.restricted&&1==t.authorized||1==s.restricted&&1==s.authorized)&&-1!=i.indexOf(t.walletType)&&-1!=i.indexOf(s.walletType)&&("bitshares"!=t.walletType&&"bitshares"==s.walletType?(o[e.inputCoinType]=o[e.inputCoinType]||[],o[e.inputCoinType].push(e.outputCoinType)):"bitshares"==t.walletType&&"bitshares"!=s.walletType?(r[e.inputCoinType]=r[e.inputCoinType]||[],r[e.inputCoinType].push(e.outputCoinType)):"bitshares"==t.walletType&&"bitshares"==s.walletType&&(l[e.inputCoinType]=l[e.inputCoinType]||[],l[e.inputCoinType].push(e.outputCoinType)))}));let c=null,p=null,d=Object.keys(o);if(d.forEach((e=>{o[e].sort()})),d.length){c=this.props.initial_deposit_input_coin_type&&this.props.initial_deposit_input_coin_type in o?this.props.initial_deposit_input_coin_type:d[0];let e=o[c];p=this.props.initial_deposit_output_coin_type&&-1!=e.indexOf(this.props.initial_deposit_output_coin_type)?this.props.initial_deposit_output_coin_type:e[0]}let u=null,h=null,m=null,_=null,g=Object.keys(r);if(g.forEach((e=>{r[e].sort()})),g.length){u=this.props.initial_withdraw_input_coin_type&&this.props.initial_withdraw_input_coin_type in r?this.props.initial_withdraw_input_coin_type:g[0];let e=r[u];h=this.props.initial_withdraw_output_coin_type&&-1!=e.indexOf(this.props.initial_withdraw_output_coin_type)?this.props.initial_withdraw_output_coin_type:e[0]}let w=Object.keys(l);if(w.forEach((e=>{l[e].sort()})),w.length){m=this.props.initial_conversion_input_coin_type&&this.props.initial_conversion_input_coin_type in l?this.props.initial_conversion_input_coin_type:w[0];let e=l[m];_=this.props.initial_conversion_output_coin_type&&-1!=e.indexOf(this.props.initial_conversion_output_coin_type)?this.props.initial_conversion_output_coin_type:e[0]}let y=this.getCachedOrGeneratedInputAddress(c,p),b=this.getCachedOrFreshDepositLimit("deposit",c,p),E=this.getAndUpdateOutputEstimate("deposit",c,p,this.state.deposit_estimated_input_amount),f=this.getAndUpdateOutputEstimate("withdraw",u,h,this.state.withdraw_estimated_input_amount),v=this.getCachedOrFreshDepositLimit("withdraw",u,h),C=this.getAndUpdateOutputEstimate("conversion",m,_,this.state.conversion_estimated_input_amount),S=this.getCachedOrFreshDepositLimit("conversion",m,_);this.unMounted||this.setState({coin_info_request_state:this.coin_info_request_states.request_complete,coins_by_type:n,allowed_mappings_for_deposit:o,allowed_mappings_for_withdraw:r,allowed_mappings_for_conversion:l,deposit_input_coin_type:c,deposit_output_coin_type:p,input_address_and_memo:y,deposit_limit:b,deposit_estimated_output_amount:E,deposit_estimate_direction:this.estimation_directions.output_from_input,withdraw_input_coin_type:u,withdraw_output_coin_type:h,withdraw_limit:v,withdraw_estimated_output_amount:f,conversion_input_coin_type:m,conversion_output_coin_type:_,conversion_limit:S,conversion_estimated_output_amount:C,withdraw_estimate_direction:this.estimation_directions.output_from_input,conversion_estimate_direction:this.estimation_directions.output_from_input,supports_output_memos:n.btc.supportsOutputMemos})})).catch((e=>{this.setState({coin_info_request_state:t,coins_by_type:null,allowed_mappings_for_deposit:null,allowed_mappings_for_withdraw:null,allowed_mappings_for_conversion:null})}))}updateEstimates(){if(this.state.deposit_input_coin_type&&this.state.deposit_output_coin_type){let e=this.getCachedOrGeneratedInputAddress(this.state.deposit_input_coin_type,this.state.deposit_output_coin_type),t=this.getCachedOrFreshDepositLimit("deposit",this.state.deposit_input_coin_type,this.state.deposit_output_coin_type),s=this.state.deposit_estimated_input_amount,a=this.state.deposit_estimated_output_amount;this.state.deposit_estimate_direction==this.estimation_directions.output_from_input?a=this.getAndUpdateOutputEstimate("deposit",this.state.deposit_input_coin_type,this.state.deposit_output_coin_type,s):s=this.getAndUpdateInputEstimate("deposit",this.state.deposit_input_coin_type,this.state.deposit_output_coin_type,a);let i=this.getCachedOrFreshDepositLimit("withdraw",this.state.withdraw_input_coin_type,this.state.withdraw_output_coin_type),n=this.state.withdraw_estimated_input_amount,o=this.state.withdraw_estimated_output_amount;this.state.withdraw_estimate_direction==this.estimation_directions.output_from_input?o=this.getAndUpdateOutputEstimate("withdraw",this.state.withdraw_input_coin_type,this.state.withdraw_output_coin_type,n):n=this.getAndUpdateinputEstimate("withdraw",this.state.withdraw_input_coin_type,this.state.withdraw_output_coin_type,o);let r=this.getCachedOrFreshDepositLimit("conversion",this.state.conversion_input_coin_type,this.state.conversion_output_coin_type),l=this.state.conversion_estimated_input_amount,c=this.state.conversion_estimated_output_amount;this.state.conversion_estimate_direction==this.estimation_directions.output_from_input?c=this.getAndUpdateOutputEstimate("conversion",this.state.conversion_input_coin_type,this.state.conversion_output_coin_type,l):l=this.getAndUpdateinputEstimate("conversion",this.state.conversion_input_coin_type,this.state.conversion_output_coin_type,c),this.setState({input_address_and_memo:e,deposit_limit:t,deposit_estimated_input_amount:s,deposit_estimated_output_amount:a,withdraw_limit:i,withdraw_estimated_input_amount:n,withdraw_estimated_output_amount:o,conversion_limit:r,conversion_estimated_input_amount:l,conversion_estimated_output_amount:c,key_for_withdrawal_dialog:n})}}handlingOauthUser(){this.manager.getUser().then((e=>{e?(!0===this.manager.settings.automaticSilentRenew?this.manager.signinSilent().then((()=>{this.setState({isUserAuthorized:!0,retrievingDataFromOauthApi:!1}),this.urlConnectionInit()})).catch((()=>{this.setState({isUserAuthorized:!1,retrievingDataFromOauthApi:!1}),this.manager.removeUser(),_e.set("is_refresh_token",!1),this.urlConnectionInit()})):(this.setState({isUserAuthorized:!0,retrievingDataFromOauthApi:!1}),this.urlConnectionInit()),this.manager.events.addAccessTokenExpired((()=>{this.unMounted||this.removeOauthUser()})),this.manager.events.addSilentRenewError((()=>{this.unMounted||this.removeOauthUser()}))):(this.setState({isUserAuthorized:!1,retrievingDataFromOauthApi:!1}),this.urlConnectionInit())}))}removeOauthUser(){!1===this.manager.settings.automaticSilentRenew&&(this.setState({isUserAuthorized:!1,retrievingDataFromOauthApi:!1}),this.manager.removeUser(),_e.set("is_refresh_token",!1))}UNSAFE_componentWillMount(){de.parse(this.props.params.search).code?(this.setState({isUserAuthorized:!0}),this.manager.signinRedirectCallback().then((e=>{let t=!1;void 0!==e.refresh_token?(t=!0,_e.set("is_refresh_token",!0)):_e.set("is_refresh_token",!1),this.manager=new he.UserManager({authority:ye,client_id:be,redirect_uri:Ee,response_type:"code",scope:fe,loadUserInfo:!0,automaticSilentRenew:t,userStore:new he.WebStorageStateStore({store:window.localStorage}),post_logout_redirect_uri:we}),this.setState({retrievingDataFromOauthApi:!1}),this.manager.events.addAccessTokenExpired((()=>{this.unMounted||this.removeOauthUser()})),this.manager.events.addSilentRenewError((()=>{this.unMounted||this.removeOauthUser()})),this.urlConnectionInit()})).catch((()=>{this.handlingOauthUser()}))):this.handlingOauthUser();try{this.manager.signoutRedirectCallback(location.href)}catch(e){}}componentDidMount(){this.update_timer=setInterval(this.updateEstimates.bind(this),this.refresh_interval)}componentWillUnmount(){clearInterval(this.update_timer),this.unMounted=!0}urlConnectionInit(){let e=this.state.url;this.urlConnection(e,0);let t={Accept:"application/json"};this.state.isUserAuthorized&&(t={Accept:"application/json",Authorization:`Bearer ${ge.get("").access_token}`});let s=fetch(e+"/coins",{method:"get",headers:t}).then((e=>e.json()));Promise.all([s]).then((e=>{let[t]=e,s={};t.forEach((e=>s[e.coinType]=e))})).catch((()=>{this.urlConnection("https://api.blocktrades.info/v2",2),this.setState({coin_info_request_state:0,coins_by_type:null,allowed_mappings_for_deposit:null,allowed_mappings_for_withdraw:null,allowed_mappings_for_conversion:null})}))}getCachedInputAddress(e,t,s){let a=this.props.account.get("name");return this.deposit_address_cache.getCachedInputAddress(this.props.gateway,a,e,t)}cacheInputAddress(e,t,s,a){let i=this.props.account.get("name");this.deposit_address_cache.cacheInputAddress(this.props.gateway,i,e,t,s,a)}getCachedOrGeneratedInputAddress(e,t){let s=this.getCachedInputAddress(e,t);if(s)return s;if(this.state.input_address_requests_in_progress[e]=this.state.input_address_requests_in_progress[e]||{},this.state.input_address_requests_in_progress[e][t])return null;let a=JSON.stringify({inputCoinType:e,outputCoinType:t,outputAddress:this.props.account.get("name")});this.state.input_address_requests_in_progress[e][t]=!0;let i={Accept:"application/json"};return this.state.isUserAuthorized&&(i={Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${ge.get("").access_token}`}),fetch(this.state.url+"/simple-api/initiate-trade",{method:"post",headers:i,body:a}).then((s=>{s.json().then((s=>{if(console.assert(s.inputCoinType==e,"unexpected reply from initiate-trade"),console.assert(s.outputCoinType==t,"unexpected reply from initiate-trade"),s.inputCoinType!=e||s.outputCoinType!=t)throw Error("unexpected reply from initiate-trade");this.cacheInputAddress(s.inputCoinType,s.outputCoinType,s.inputAddress,s.inputMemo),delete this.state.input_address_requests_in_progress[e][t],this.state.deposit_input_coin_type==s.inputCoinType&&this.state.deposit_output_coin_type==s.outputCoinType&&this.setState({input_address_and_memo:{address:s.inputAddress,memo:s.inputMemo}})}),(s=>{delete this.state.input_address_requests_in_progress[e][t],this.state.deposit_input_coin_type==e&&this.state.deposit_output_coin_type==t&&this.setState({input_address_and_memo:{address:"error generating address",memo:null}})}))}),(s=>{delete this.state.input_address_requests_in_progress[e][t],this.state.deposit_input_coin_type==e&&this.state.deposit_output_coin_type==t&&this.setState({input_address_and_memo:{address:"error generating address",memo:null}})})),null}makeState(e){for(var t="",s="abcdefghijklmnopqrstuvwxyz0123456789",a=s.length,i=0;i<e;i++)t+=s.charAt(Math.floor(Math.random()*a));return t}getCachedDepositLimit(e,t){if(this.state.deposit_limit_cache[e]=this.state.deposit_limit_cache[e]||{},this.state.deposit_limit_cache[e][t]){let s=this.state.deposit_limit_cache[e][t];if(new Date-s.timestamp<this.refresh_interval)return s;delete this.state.deposit_limit_cache[e][t]}return null}cacheDepositLimit(e,t,s){s.timestamp=new Date,this.state.deposit_limit_cache[e]=this.state.deposit_limit_cache[e]||{},this.state.deposit_limit_cache[e][t]=s}getCachedOrFreshDepositLimit(e,t,s){let a=this.getCachedDepositLimit(t,s);if(a)return a;this.state.deposit_limit_requests_in_progress[t]=this.state.input_address_requests_in_progress[t]||{},this.state.deposit_limit_requests_in_progress[t][s]=!0;let i={"Content-Type":"application/x-www-form-urlencoded"};this.state.isUserAuthorized&&(i={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${ge.get("").access_token}`});let n=this.state.url+"/deposit-limits?inputCoinType="+encodeURIComponent(t)+"&outputCoinType="+encodeURIComponent(s);return fetch(n,{method:"get",headers:i}).then((e=>e.json())).then((a=>{if(this.unMounted)return;if(console.assert(a.inputCoinType==t&&a.outputCoinType==s,"unexpected reply from deposit-limits"),a.inputCoinType!=t||a.outputCoinType!=s)throw Error("unexpected reply from deposit-limits");let i={timestamp:new Date,limit:a.depositLimit};this.cacheDepositLimit(t,s,i),delete this.state.deposit_limit_requests_in_progress[t][s],this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.setState({[e+"_limit"]:i})}),(e=>{delete this.state.deposit_limit_requests_in_progress[t][s]})),null}getAndUpdateOutputEstimate(e,t,s,a){if(this.unMounted)return;"deposit"==e&&this.setState({failed_calculate_deposit:null}),"withdraw"==e&&this.setState({failed_calculate_withdraw:null}),"conversion"==e&&this.setState({failed_calculate_conversion:null});let i={Accept:"application/json"};this.state.isUserAuthorized&&(i={Accept:"application/json",Authorization:`Bearer ${ge.get("").access_token}`});let n=this.state.url+"/estimate-output-amount?inputAmount="+encodeURIComponent(a)+"&inputCoinType="+encodeURIComponent(t)+"&outputCoinType="+encodeURIComponent(s);return fetch(n,{method:"get",headers:i}).then((e=>e.json())).then((i=>{if(!this.unMounted)if(i.error){if(this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.state[e+"_estimated_input_amount"]==a&&this.state[e+"_estimate_direction"]==this.estimation_directions.output_from_input){let t=i.error.message;"deposit"==e&&this.setState({failed_calculate_deposit:"Failed to calculate"}),"withdraw"==e&&this.setState({failed_calculate_withdraw:"Failed to calculate"}),"conversion"==e&&this.setState({failed_calculate_conversion:"Failed to calculate"});let s="Internal Server Error: ";t.startsWith(s)&&(t=t.substr(s.length)),this.setState({[e+"_error"]:t})}}else{if(console.assert(i.inputCoinType==t&&i.outputCoinType==s&&i.inputAmount==a,"unexpected reply from estimate-output-amount"),i.inputCoinType!=t||i.outputCoinType!=s||i.inputAmount!=a)throw Error("unexpected reply from estimate-output-amount");this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.state[e+"_estimated_input_amount"]==a&&this.state[e+"_estimate_direction"]==this.estimation_directions.output_from_input&&this.setState({[e+"_estimated_output_amount"]:i.outputAmount,[e+"_error"]:null})}}),(e=>{})),null}getAndUpdateInputEstimate(e,t,s,a){if(this.unMounted)return;"deposit"==e&&this.setState({failed_calculate_deposit:null}),"withdraw"==e&&this.setState({failed_calculate_withdraw:null}),"conversion"==e&&this.setState({failed_calculate_conversion:null});let i={Accept:"application/json"};this.state.isUserAuthorized&&(i={Accept:"application/json",Authorization:`Bearer ${ge.get("").access_token}`});let n=this.state.url+"/estimate-input-amount?outputAmount="+encodeURIComponent(a)+"&inputCoinType="+encodeURIComponent(t)+"&outputCoinType="+encodeURIComponent(s);return fetch(n,{method:"get",headers:i}).then((e=>e.json())).then((i=>{this.unMounted||(console.assert(i.inputCoinType==t&&i.outputCoinType==s&&i.outputAmount==a,"unexpected reply from estimate-input-amount"),i.inputCoinType==t&&i.outputCoinType==s&&i.outputAmount==a||("deposit"==e&&this.setState({failed_calculate_deposit:"Failed to calculate"}),"withdraw"==e&&this.setState({failed_calculate_withdraw:"Failed to calculate"}),"conversion"==e&&this.setState({failed_calculate_conversion:"Failed to calculate"})),this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.state[e+"_estimated_output_amount"]==a&&this.state[e+"_estimate_direction"]==this.estimation_directions.input_from_output&&this.setState({[e+"_estimated_input_amount"]:i.inputAmount,key_for_withdrawal_dialog:i.inputAmount}))}),(e=>{})),null}onInputAmountChanged(e,t){let s=t.target.value;""==s&&(s="0");let a=this.getAndUpdateOutputEstimate(e,this.state[e+"_input_coin_type"],this.state[e+"_output_coin_type"],s);this.setState({[e+"_estimated_input_amount"]:s,[e+"_estimated_output_amount"]:a,[e+"_estimate_direction"]:this.estimation_directions.output_from_input,key_for_withdrawal_dialog:s})}onOutputAmountChanged(e,t){let s=t.target.value;""==s&&(s="0");let a=this.getAndUpdateInputEstimate(e,this.state[e+"_input_coin_type"],this.state[e+"_output_coin_type"],s);this.setState({[e+"_estimated_output_amount"]:s,[e+"_estimated_input_amount"]:a,[e+"_estimate_direction"]:this.estimation_directions.input_from_output})}getWithdrawModalId(){return"withdraw_asset_"+this.props.gateway+"_bridge"}onInputCoinTypeChanged(e,t){let s=null,a="_estimated_output_amount",i=t.target.value,n=this.state["allowed_mappings_for_"+e][i],o=n[0];-1!=n.indexOf(this.state[e+"_output_coin_type"])&&(o=this.state[e+"_output_coin_type"]);let r=this.state.input_address_and_memo;"deposit"==e&&(r=this.getCachedOrGeneratedInputAddress(i,o));let l=this.getCachedOrFreshDepositLimit(e,i,o);this.state[e+"_estimated_input_amount"]?s=this.getAndUpdateOutputEstimate(e,i,o,this.state[e+"_estimated_input_amount"]):(s=this.getAndUpdateInputEstimate(e,i,o,this.state[e+"_estimated_output_amount"]),a="_estimated_input_amount"),"withdraw"==e&&n.forEach((e=>{o===e&&this.setState({coin_symbol:i+"input",supports_output_memos:this.state.coins_by_type[e].supportsOutputMemos})})),this.setState({[e+"_input_coin_type"]:i,[e+"_output_coin_type"]:o,input_address_and_memo:r,[e+"_limit"]:l,[e+a]:s,[e+"_estimate_direction"]:this.estimation_directions.output_from_input})}onOutputCoinTypeChanged(e,t){let s=null,a="_estimated_output_amount",i=t.target.value,n=this.state.allowed_mappings_for_withdraw[this.state.withdraw_input_coin_type];"withdraw"==e&&n.forEach((e=>{i===e&&this.setState({coin_symbol:i+"output",supports_output_memos:this.state.coins_by_type[e].supportsOutputMemos,key_for_withdrawal_dialog:i})}));let o=this.state.input_address_and_memo;"deposit"==e&&(o=this.getCachedOrGeneratedInputAddress(this.state[e+"_input_coin_type"],i));let r=this.getCachedOrFreshDepositLimit(e,this.state[e+"_input_coin_type"],i);this.state[e+"_estimated_input_amount"]?s=this.getAndUpdateOutputEstimate(e,this.state[e+"_input_coin_type"],i,this.state[e+"_estimated_input_amount"]):(s=this.getAndUpdateInputEstimate(e,this.state[e+"_input_coin_type"],i,this.state[e+"_estimated_output_amount"]),a="_estimated_input_amount"),this.setState({[e+"_output_coin_type"]:i,input_address_and_memo:o,[e+"_limit"]:r,[e+a]:s,[e+"_estimate_direction"]:this.estimation_directions.output_from_input})}registerBlocktradesAccount(){window.location.assign("https://blocktrades.us/register")}signin(){this.manager.signinRedirect()}async onLogout(){try{const{id_token:e}=await this.manager.getUser();await this.manager.signoutRedirect({id_token_hint:e,state:"logout",post_logout_redirect_uri:we})}catch(e){throw e}}render(){if(!this.props.account||!this.props.issuer_account||!this.props.gateway)return a.createElement("div",null);let e,t,s,i,n,o,l;if(this.state.coin_info_request_state==this.coin_info_request_states.request_failed)return a.createElement("div",null,a.createElement("p",null,"Error connecting to blocktrades.us, please try again later"));if(this.state.coin_info_request_state==this.coin_info_request_states.never_requested||this.state.coin_info_request_state==this.coin_info_request_states.request_in_progress||this.state.retrievingDataFromOauthApi)return a.createElement("div",null,a.createElement("p",null,"Retrieving current trade data from blocktrades.us"));{let p=null,d=a.createElement(c(),{content:"gateway.calc"});null!=this.state.failed_calculate_deposit&&(d=this.state.failed_calculate_deposit);let u=a.createElement(c(),{content:"gateway.calc"});null!=this.state.failed_calculate_withdraw&&(u=this.state.failed_calculate_withdraw);let h=a.createElement(c(),{content:"gateway.calc"});null!=this.state.failed_calculate_conversion&&(h=this.state.failed_calculate_conversion);let m=this.state.isUserAuthorized;if(m&&this.state.allowed_mappings_for_conversion&&this.state.allowed_mappings_for_deposit&&this.state.allowed_mappings_for_withdraw){if(Object.getOwnPropertyNames(this.state.allowed_mappings_for_deposit).length>0){let e=[];Object.keys(this.state.allowed_mappings_for_deposit).sort().forEach((t=>{e.push(a.createElement("option",{key:t,value:t||""},this.state.coins_by_type[t].symbol))}));let i=a.createElement("select",{style:{width:"11rem"},className:"external-coin-types",value:this.state.deposit_input_coin_type||"",onChange:this.onInputCoinTypeChanged.bind(this,"deposit")},e),n=[];this.state.allowed_mappings_for_deposit[this.state.deposit_input_coin_type].forEach((e=>{n.push(a.createElement("option",{key:e,value:e||""},this.state.coins_by_type[e].walletSymbol))}));let o=a.createElement("select",{style:{width:"11rem"},className:"native-coin-types",value:this.state.deposit_output_coin_type||"",onChange:this.onOutputCoinTypeChanged.bind(this,"deposit")},n),l=this.state.input_address_and_memo?this.state.input_address_and_memo:{address:"unknown",memo:null},p=this.state.deposit_estimated_input_amount,u=this.state.deposit_estimated_output_amount,h=p?a.createElement("input",{style:{width:"11rem"},type:"text",value:p||"",onChange:this.onInputAmountChanged.bind(this,"deposit")}):d,m=u?a.createElement("input",{style:{width:"11rem"},type:"text",value:u||"",onChange:this.onOutputAmountChanged.bind(this,"deposit")}):d,_=a.createElement("span",null,"updating");this.state.deposit_limit&&(_=this.state.deposit_limit.limit?a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},a.createElement(c(),{content:"gateway.limit",amount:r.Z.format_number(this.state.deposit_limit.limit,8),symbol:this.state.coins_by_type[this.state.deposit_input_coin_type].walletSymbol}))):null);let g=null;this.state.deposit_error&&(g=a.createElement("div",null,this.state.deposit_error)),s=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"gateway.deposit"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.balance"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.deposit_to",asset:this.state.deposit_input_coin_type}))));let w=null;w=l.memo?a.createElement(c(),{unsafe:!0,content:"gateway.address_with_memo",address:l.address,memo:l.memo}):a.createElement("span",null,l.address),t=a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement("div",{className:"blocktrades-bridge"},a.createElement("div",{className:"inline-block"},a.createElement("div",null,i),a.createElement("div",null,h)),"→",a.createElement("div",{className:"inline-block"},a.createElement("div",null,o),a.createElement("div",null,m)),a.createElement("div",null,g))),a.createElement("td",null,a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.state.coins_by_type[this.state.deposit_output_coin_type].walletSymbol})),a.createElement("td",null,w,a.createElement("br",null),_)))}if(Object.getOwnPropertyNames(this.state.allowed_mappings_for_withdraw).length>0){this.state.coins_by_type[this.state.withdraw_input_coin_type].symbol,p=this.state.withdraw_estimated_input_amount;let e=[];Object.keys(this.state.allowed_mappings_for_withdraw).sort().forEach((t=>{e.push(a.createElement("option",{key:t,value:t},this.state.coins_by_type[t].walletSymbol))}));let t=a.createElement("select",{style:{width:"11rem"},className:"native-coin-types",value:this.state.withdraw_input_coin_type,onChange:this.onInputCoinTypeChanged.bind(this,"withdraw")},e),s=[];this.state.allowed_mappings_for_withdraw[this.state.withdraw_input_coin_type].forEach((e=>{s.push(a.createElement("option",{key:e,value:e},this.state.coins_by_type[e].symbol))}));let o=a.createElement("select",{style:{width:"11rem"},className:"external-coin-types",value:this.state.withdraw_output_coin_type,onChange:this.onOutputCoinTypeChanged.bind(this,"withdraw")},s),l=this.state.withdraw_estimated_input_amount,d=l?a.createElement("input",{style:{width:"11rem"},type:"text",value:l||"",onChange:this.onInputAmountChanged.bind(this,"withdraw")}):u,h=this.state.withdraw_estimated_output_amount,m=h?a.createElement("input",{style:{width:"11rem"},type:"text",value:h||"",onChange:this.onOutputAmountChanged.bind(this,"withdraw")}):u,_=a.createElement(Ae,{visible:this.state.isModalVisible,hideModal:this.hideModal,showModal:this.showModal,key:this.state.key_for_withdrawal_dialog,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.state.coins_by_type[this.state.withdraw_input_coin_type].walletSymbol,output_coin_name:this.state.coins_by_type[this.state.withdraw_output_coin_type].name,output_coin_symbol:this.state.coins_by_type[this.state.withdraw_output_coin_type].symbol,input_coin_type:this.state.withdraw_input_coin_type,output_coin_type:this.state.withdraw_output_coin_type,output_supports_memos:this.state.supports_output_memos,amount_to_withdraw:p,url:this.state.url,gateway:this.props.gateway,output_wallet_type:this.state.coins_by_type[this.state.withdraw_output_coin_type].walletType}),g=null;this.state.withdraw_error&&(g=a.createElement("div",null,this.state.withdraw_error));let w=a.createElement("span",null,"...");this.state.withdraw_limit&&(w=this.state.withdraw_limit.limit?a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},a.createElement(c(),{content:"gateway.limit",amount:r.Z.format_number(this.state.withdraw_limit.limit,8),symbol:this.state.coins_by_type[this.state.withdraw_input_coin_type].walletSymbol}))):a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},"no limit"))),n=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"gateway.withdraw"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.balance"})),a.createElement("th",null))),i=a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement("div",{className:"blocktrades-bridge"},a.createElement("div",{className:"inline-block"},a.createElement("div",null,t),a.createElement("div",null,d)),"→",a.createElement("div",{className:"inline-block"},a.createElement("div",null,o),a.createElement("div",null,m)),a.createElement("div",null,g))),a.createElement("td",null,a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.state.coins_by_type[this.state.withdraw_input_coin_type].walletSymbol})),a.createElement("td",null,_,a.createElement("br",null),w)))}if(Object.getOwnPropertyNames(this.state.allowed_mappings_for_conversion).length>0){let e=[];Object.keys(this.state.allowed_mappings_for_conversion).sort().forEach((t=>{e.push(a.createElement("option",{key:t,value:t},this.state.coins_by_type[t].walletSymbol))}));let t=a.createElement("select",{style:{width:"11rem"},className:"native-coin-types",value:this.state.conversion_input_coin_type,onChange:this.onInputCoinTypeChanged.bind(this,"conversion")},e),s=[];this.state.allowed_mappings_for_conversion[this.state.conversion_input_coin_type].forEach((e=>{s.push(a.createElement("option",{key:e,value:e},this.state.coins_by_type[e].symbol))}));let i=a.createElement("select",{style:{width:"11rem"},className:"external-coin-types",value:this.state.conversion_output_coin_type,onChange:this.onOutputCoinTypeChanged.bind(this,"conversion")},s),n=this.state.conversion_estimated_input_amount,p=n?a.createElement("input",{style:{width:"11rem"},type:"text",value:n||"",onChange:this.onInputAmountChanged.bind(this,"conversion")}):h,d=this.state.conversion_estimated_output_amount,u=d?a.createElement("input",{style:{width:"11rem"},type:"text",value:d||"",onChange:this.onOutputAmountChanged.bind(this,"conversion")}):h,m=a.createElement(Ce,{asset:this.state.coins_by_type[this.state.conversion_input_coin_type].walletSymbol,account:this.props.account,is_user_authorized:this.state.isUserAuthorized,input_coin_type:this.state.conversion_input_coin_type,output_coin_type:this.state.conversion_output_coin_type,account_name:this.props.account.get("name"),amount:this.state.conversion_estimated_input_amount,account_id:this.props.account.get("id"),account_balances:this.props.account.get("balances"),url:this.state.url}),_=null;this.state.conversion_error&&(_=a.createElement("div",null,this.state.conversion_error));let g=a.createElement("span",null,"...");this.state.conversion_limit&&(g=this.state.conversion_limit.limit?a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},a.createElement(c(),{content:"gateway.limit",amount:r.Z.format_number(this.state.conversion_limit.limit,8),symbol:this.state.coins_by_type[this.state.conversion_input_coin_type].walletSymbol}))):a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},"no limit"))),l=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"gateway.convert"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.balance"})),a.createElement("th",null))),o=a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement("div",{className:"blocktrades-bridge"},a.createElement("div",{className:"inline-block"},a.createElement("div",null,t),a.createElement("div",null,p)),"→",a.createElement("div",{className:"inline-block"},a.createElement("div",null,i),a.createElement("div",null,u)),a.createElement("div",null,_))),a.createElement("td",null,a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.state.coins_by_type[this.state.conversion_input_coin_type].walletSymbol})),a.createElement("td",null,m,a.createElement("br",null),g)))}}this.state.announcements.length>0&&(e=a.createElement("div",{className:"blocktrades-announcements-container"},this.state.announcements.map((function(e,t){let s="txtann info";return 10===e.status?s="txtann error":20===e.status?s="txtann warning":30===e.status?s="txtann success":40===e.status&&(s="txtann info"),1===e.format&&e.message.replace(/\r\n|\r|\n/g,"<br />"),a.createElement("div",{className:"blocktrades-announcements "+s,key:t},e.message)}),this)));let _="button";return a.createElement("div",null,a.createElement("div",{style:{paddingBottom:15}},a.createElement(c(),{component:"h5",content:"gateway.bridge_text"})),e,m?a.createElement("div",null,a.createElement("span",{style:{float:"right"}},a.createElement("button",{className:_,onClick:this.onLogout.bind(this)},a.createElement(c(),{content:""}),a.createElement(c(),{content:"gateway.logout_now"})," ")),a.createElement("table",{className:"table"},s,t,n,i,l,o)):a.createElement("div",{style:{paddingTop:15}},a.createElement("div",{onClick:this.registerBlocktradesAccount.bind(this),className:"button"},"Register BlockTrades Account"),a.createElement("div",{onClick:this.signin.bind(this),className:"button"},"Sign in")))}}}const Ne=(0,d.Z)(ke);var xe=s(48764).Buffer;class Te extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_name:S().string.isRequired,output_coin_symbol:S().string.isRequired,output_coin_type:S().string.isRequired,url:S().string,output_wallet_type:S().string,output_supports_memos:S().bool.isRequired,amount_to_withdraw:S().string,balance:p.Z.ChainObject};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:b.So.getLast(e.output_wallet_type),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,confirmation_is_valid:!1,withdraw_address_selected:b.So.getLast(e.output_wallet_type),memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{}},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},this._checkBalance)}onSelectChanged(e){let t=b.So.get(this.props.output_wallet_type)[e];b.So.setLast({wallet:this.props.output_wallet_type,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}_validateAddress(e,t=this.props){(0,b.YN)({url:t.url,walletType:t.output_wallet_type,newAddress:e}).then((t=>{this.state.withdraw_address===e&&this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:t})}))}_checkBalance(){const{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a}=this.props;if(!a||!e)return;const i=(0,E.cr)(t,s,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(b.So.has(this.props.output_wallet_type)){let e=b.So.get(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e})}b.So.setLast({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t,fee_asset_id:s}=this.state,a=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),i=void 0!==this.props.gateFee?parseFloat(String.prototype.replace.call(this.props.gateFee,/,/g,"")):0;let n=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a}),o=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:0});void 0!==this.props.balance&&(o=n.clone(this.props.balance.get("balance")));const r=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:i});n.plus(r),o.lt(n)&&(n=o),y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),n.getAmount(),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new xe(this.state.memo,"utf-8"):""),null,t?t.asset_id:s),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),b.So.has(this.props.output_wallet_type)){let e=b.So.get(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e})}b.So.setLast({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a,fee_asset_id:i}=this.state;y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new xe(this.state.memo,"utf-8"):""),null,a?a.asset_id:i)}onDropDownList(){b.So.has(this.props.output_wallet_type)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,memo:t}=this.state,s=b.So.get(this.props.output_wallet_type),i=null,n=this.props.account.get("balances").toJS(),o=Object.keys(n),r=(this.getWithdrawModalId(),null),l=null,p=null;this.state.options_is_valid&&(l=a.createElement("div",{className:s.length?"blocktrades-options":"blocktrades-disabled-options"},s.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(r=a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_type})),p=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let d=1,u=null;this.props.output_supports_memos&&(u=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:t,tabIndex:d++,onChange:this.onMemoChanged.bind(this)})));let{fee_asset_types:h}=this._getAvailableAssets();if(o.length>0){let e=this.props.asset.get("id");if(e){let t=n[e];i=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:n[e]}):0))}else i="No funds"}else i="No funds";const _=this.state.error||this.state.balanceError||!this.state.withdraw_amount;return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:0}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:i}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:h,tabIndex:d++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,this.props.gateFee?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:this.props.gateFee}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"blocktrades-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"blocktrades-position-options"},l),r),u,a.createElement("div",null,a.createElement(v.Button,{type:"primary",disabled:_,onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),p))}}Te=(0,d.Z)(Te);const Me=(0,i.$)(Te,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})}),Ze=(0,ue.ZP)("__bts__");class Ie extends a.Component{static propTypes={balance:p.Z.ChainObject,url:S().string.isRequired};getWithdrawModalId(){return"withdraw_asset_"+this.props.gateway+"_bridge"}onWithdraw(){this.props.showModal()}render(){let e=this.getWithdrawModalId(),t="button disabled";return Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))&&this.props.amount_to_withdraw&&!(this.props.amount_to_withdraw.indexOf(" ")>=0)&&!isNaN(this.props.amount_to_withdraw)&&this.props.amount_to_withdraw>0&&this.props.amount_to_withdraw<=this.props.balance.toJS().balance/r.Z.get_asset_precision(this.props.asset.get("precision"))&&(t="button"),a.createElement("span",null,a.createElement("span",null,a.createElement("button",{className:t,onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:""}),a.createElement(c(),{content:"gateway.withdraw_now"})," ")),a.createElement(v.Modal,{title:g().translate("gateway.withdraw_coin",{coin:this.props.output_coin_name,symbol:this.props.output_coin_symbol}),visible:this.props.visible,onCancel:this.props.hideModal,footer:null},a.createElement(Me,{showModal:this.props.showModal,hideModal:this.props.hideModal,key:`${this.props.key}`,account:this.props.account.get("name"),issuer:this.props.issuer,asset:this.props.asset.get("id"),output_coin_name:this.props.output_coin_name,output_coin_symbol:this.props.output_coin_symbol,output_coin_type:this.props.output_coin_type,output_supports_memos:this.props.output_supports_memos,amount_to_withdraw:this.props.amount_to_withdraw,modal_id:e,url:this.props.url,output_wallet_type:this.props.output_wallet_type,balance:this.props.account.get("balances").toJS()[this.props.asset.get("id")]})))}}Ie=(0,d.Z)(Ie);class Be extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_type:S().string.isRequired,url:S().string.isRequired};render(){let e=a.createElement(Ie,{showModal:this.props.showModal,hideModal:this.props.hideModal,visible:this.props.visible,key:this.props.key,account:this.props.account,issuer:this.props.issuer,asset:this.props.asset,output_coin_name:this.props.output_coin_name,output_coin_symbol:this.props.output_coin_symbol,output_coin_type:this.props.output_coin_type,output_supports_memos:this.props.output_supports_memos,amount_to_withdraw:this.props.amount_to_withdraw,url:this.props.url,gateway:this.props.gateway,output_wallet_type:this.props.output_wallet_type,balance:this.props.account.get("balances").toJS()[this.props.asset.get("id")]});return a.createElement("span",null,e)}}Be=(0,d.Z)(Be);class De extends a.Component{static propTypes={url:S().string,gateway:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,initial_deposit_input_coin_type:S().string,initial_deposit_output_coin_type:S().string,initial_deposit_estimated_input_amount:S().string,initial_withdraw_input_coin_type:S().string,initial_withdraw_output_coin_type:S().string,initial_withdraw_estimated_input_amount:S().string};constructor(e){super(e),this.refresh_interval=12e4,this.deposit_address_cache=new class{constructor(){this.current_citadel_address_cache_version_string="2"}getIndexForDepositKeyInExchange(e,t,s){return[this.current_citadel_address_cache_version_string,e,t,s].reduce((function(e,t){return e.concat("[",t,"]")}),"")}getCachedInputAddress(e,t,s,a){let i=X.Z.getWallet();const n=this.getIndexForDepositKeyInExchange(t,s,a);if(i){i.deposit_keys=i.deposit_keys||{},i.deposit_keys[e]=i.deposit_keys[e]||{},i.deposit_keys[e][n]=i.deposit_keys[e][n]||[];let t=i.deposit_keys[e][n].length;return t?i.deposit_keys[e][n][t-1]:null}{let t=Ze.get("deposit_keys",{});t[e]=t[e]||{},t[e][n]=t[e][n]||[];let s=t[e][n].length;return s?t[e][n][s-1]:null}}cacheInputAddress(e,t,s,a,i,n){if(!i)return;let o=X.Z.getWallet();const r=this.getIndexForDepositKeyInExchange(t,s,a);if(o)delete o.deposit_keys.undefined,Object.keys(o.deposit_keys||{}).forEach((e=>{for(let t in o.deposit_keys[e])if(o.deposit_keys[e][t]&&o.deposit_keys[e][t].length)for(let s=o.deposit_keys[e][t].length-1;s>=0;s--)o.deposit_keys[e][t][s]&&"unknown"===o.deposit_keys[e][t][s].address&&o.deposit_keys[e][t].splice(s,1)})),o.deposit_keys=o.deposit_keys||{},o.deposit_keys[e]=o.deposit_keys[e]||{},o.deposit_keys[e][r]=o.deposit_keys[e][r]||[],o.deposit_keys[e][r].push({address:i,memo:n}),X.Z._updateWallet();else{let t=Ze.get("deposit_keys",{});t[e]=t[e]||{},t[e][r]=t[e][r]||[],t[e][r].push({address:i,memo:n}),Ze.set("deposit_keys",t)}}},this.coin_info_request_states={request_in_progress:0,request_complete:1,request_failed:2},this.estimation_directions={output_from_input:0,input_from_output:1},this.state={isModalVisible:!1,coin_symbol:"xmr",key_for_withdrawal_dialog:"xmr",supports_output_memos:"",url:I.Ay.BASE,error:null,deposit_input_coin_type:null,deposit_output_coin_type:null,input_address_and_memo:null,deposit_estimated_input_amount:this.props.initial_deposit_estimated_input_amount||"1.0",deposit_estimated_output_amount:null,deposit_limit:null,deposit_error:null,failed_calculate_deposit:null,withdraw_input_coin_type:null,withdraw_output_coin_type:null,withdraw_estimated_input_amount:this.props.initial_withdraw_estimated_input_amount||"1.0",withdraw_estimated_output_amount:null,withdraw_limit:null,withdraw_error:null,failed_calculate_withdraw:null,coin_info_request_state:this.coin_info_request_states.request_in_progress,input_address_requests_in_progress:{},deposit_estimate_direction:this.estimation_directions.output_from_input,deposit_limit_cache:{},deposit_limit_requests_in_progress:{},coins_by_type:null,allowed_mappings_for_deposit:null,allowed_mappings_for_withdraw:null,announcements:[]},this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}urlConnection(e,t){this.setState({url:e});let s=fetch(e+"/coins",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),a=fetch(e+"/wallets",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),i=fetch(e+"/trading-pairs",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),n=fetch(e+"/active-wallets",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json()));Promise.all([s,a,i,n]).then((e=>{let[t,s,a,i]=e,n={};t.forEach((e=>n[e.coinType]=e));let o={},r={};a.forEach((e=>{let t=n[e.inputCoinType],s=n[e.outputCoinType];(t.backingCoinType!=e.outputCoinType||s.backingCoinType!=e.inputCoinType&&0==t.restricted&&0==s.restricted)&&-1!=i.indexOf(t.walletType)&&-1!=i.indexOf(s.walletType)&&("bitshares2"!=t.walletType&&"bitshares2"==s.walletType?(o[e.inputCoinType]=o[e.inputCoinType]||[],o[e.inputCoinType].push(e.outputCoinType)):(r[e.inputCoinType]=r[e.inputCoinType]||[],r[e.inputCoinType].push(e.outputCoinType)))}));let l=null,c=null,p=Object.keys(o);if(p.forEach((e=>{o[e].sort()})),p.length){l=this.props.initial_deposit_input_coin_type&&this.props.initial_deposit_input_coin_type in o?this.props.initial_deposit_input_coin_type:p[0];let e=o[l];c=this.props.initial_deposit_output_coin_type&&-1!=e.indexOf(this.props.initial_deposit_output_coin_type)?this.props.initial_deposit_output_coin_type:e[0]}let d=null,u=null,h=Object.keys(r);if(h.forEach((e=>{r[e].sort()})),h.length){d=this.props.initial_withdraw_input_coin_type&&this.props.initial_withdraw_input_coin_type in r?this.props.initial_withdraw_input_coin_type:h[0];let e=r[d];u=this.props.initial_withdraw_output_coin_type&&-1!=e.indexOf(this.props.initial_withdraw_output_coin_type)?this.props.initial_withdraw_output_coin_type:e[0]}let m=this.getCachedOrGeneratedInputAddress(l,c),_=this.getCachedOrFreshDepositLimit("deposit",l,c),g=this.getAndUpdateOutputEstimate("deposit",l,c,this.state.deposit_estimated_input_amount),w=this.getAndUpdateOutputEstimate("withdraw",d,u,this.state.withdraw_estimated_input_amount),y=this.getCachedOrFreshDepositLimit("withdraw",d,u);this.unMounted||this.setState({coin_info_request_state:this.coin_info_request_states.request_complete,coins_by_type:n,allowed_mappings_for_deposit:o,allowed_mappings_for_withdraw:r,deposit_input_coin_type:l,deposit_output_coin_type:c,input_address_and_memo:m,deposit_limit:_,deposit_estimated_output_amount:g,deposit_estimate_direction:this.estimation_directions.output_from_input,withdraw_input_coin_type:d,withdraw_output_coin_type:u,withdraw_limit:y,withdraw_estimated_output_amount:w,withdraw_estimate_direction:this.estimation_directions.output_from_input,supports_output_memos:n.xmr.supportsOutputMemos})})).catch((e=>{this.setState({coin_info_request_state:t,coins_by_type:null,allowed_mappings_for_deposit:null,allowed_mappings_for_withdraw:null})}))}updateEstimates(){if(this.state.deposit_input_coin_type&&this.state.deposit_output_coin_type){let e=this.getCachedOrGeneratedInputAddress(this.state.deposit_input_coin_type,this.state.deposit_output_coin_type),t=this.getCachedOrFreshDepositLimit("deposit",this.state.deposit_input_coin_type,this.state.deposit_output_coin_type),s=this.state.deposit_estimated_input_amount,a=this.state.deposit_estimated_output_amount;this.state.deposit_estimate_direction==this.estimation_directions.output_from_input?a=this.getAndUpdateOutputEstimate("deposit",this.state.deposit_input_coin_type,this.state.deposit_output_coin_type,s):s=this.getAndUpdateInputEstimate("deposit",this.state.deposit_input_coin_type,this.state.deposit_output_coin_type,a);let i=this.getCachedOrFreshDepositLimit("withdraw",this.state.withdraw_input_coin_type,this.state.withdraw_output_coin_type),n=this.state.withdraw_estimated_input_amount,o=this.state.withdraw_estimated_output_amount;this.state.withdraw_estimate_direction==this.estimation_directions.output_from_input?o=this.getAndUpdateOutputEstimate("withdraw",this.state.withdraw_input_coin_type,this.state.withdraw_output_coin_type,n):n=this.getAndUpdateinputEstimate("withdraw",this.state.withdraw_input_coin_type,this.state.withdraw_output_coin_type,o),this.setState({input_address_and_memo:e,deposit_limit:t,deposit_estimated_input_amount:s,deposit_estimated_output_amount:a,withdraw_limit:i,withdraw_estimated_input_amount:n,withdraw_estimated_output_amount:o,key_for_withdrawal_dialog:n})}}UNSAFE_componentWillMount(){let e=this.state.url;this.urlConnection(e,0);let t=fetch(e+"/coins",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),s=fetch(e+"/trading-pairs",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())),a=fetch(e+"/active-wallets",{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json()));Promise.all([t,s,a]).then((e=>{let[t,s,a]=e,i={};t.forEach((e=>i[e.coinType]=e)),s.forEach((e=>{let t=i[e.inputCoinType],s=i[e.outputCoinType];t.backingCoinType!=e.outputCoinType&&s.backingCoinType!=e.inputCoinType&&-1!=a.indexOf(t.walletType)&&a.indexOf(s.walletType)}))})).catch((e=>{this.urlConnection("https://citadel.li/trade",2),this.setState({coin_info_request_state:0,coins_by_type:null,allowed_mappings_for_deposit:null,allowed_mappings_for_withdraw:null})}))}componentDidMount(){this.update_timer=setInterval(this.updateEstimates.bind(this),this.refresh_interval)}componentWillUnmount(){clearInterval(this.update_timer),this.unMounted=!0}getCachedInputAddress(e,t,s){let a=this.props.account.get("name");return this.deposit_address_cache.getCachedInputAddress(this.props.gateway,a,e,t)}cacheInputAddress(e,t,s,a){let i=this.props.account.get("name");this.deposit_address_cache.cacheInputAddress(this.props.gateway,i,e,t,s,a)}getCachedOrGeneratedInputAddress(e,t){let s=this.getCachedInputAddress(e,t);if(s)return s;if(this.state.input_address_requests_in_progress[e]=this.state.input_address_requests_in_progress[e]||{},this.state.input_address_requests_in_progress[e][t])return null;let a=JSON.stringify({inputCoinType:e,outputCoinType:t,outputAddress:this.props.account.get("name")});return this.state.input_address_requests_in_progress[e][t]=!0,fetch(this.state.url+"/simple-api/initiate-trade",{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:a}).then((s=>{s.json().then((s=>{if(console.assert(s.inputCoinType==e,"unexpected reply from initiate-trade"),console.assert(s.outputCoinType==t,"unexpected reply from initiate-trade"),s.inputCoinType!=e||s.outputCoinType!=t)throw Error("unexpected reply from initiate-trade");this.cacheInputAddress(s.inputCoinType,s.outputCoinType,s.inputAddress,s.inputMemo),delete this.state.input_address_requests_in_progress[e][t],this.state.deposit_input_coin_type==s.inputCoinType&&this.state.deposit_output_coin_type==s.outputCoinType&&this.setState({input_address_and_memo:{address:s.inputAddress,memo:s.inputMemo}})}),(s=>{delete this.state.input_address_requests_in_progress[e][t],this.state.deposit_input_coin_type==e&&this.state.deposit_output_coin_type==t&&this.setState({input_address_and_memo:{address:"error generating address",memo:null}})}))}),(s=>{delete this.state.input_address_requests_in_progress[e][t],this.state.deposit_input_coin_type==e&&this.state.deposit_output_coin_type==t&&this.setState({input_address_and_memo:{address:"error generating address",memo:null}})})),null}getCachedDepositLimit(e,t){if(this.state.deposit_limit_cache[e]=this.state.deposit_limit_cache[e]||{},this.state.deposit_limit_cache[e][t]){let s=this.state.deposit_limit_cache[e][t];if(new Date-s.timestamp<this.refresh_interval)return s;delete this.state.deposit_limit_cache[e][t]}return null}cacheDepositLimit(e,t,s){s.timestamp=new Date,this.state.deposit_limit_cache[e]=this.state.deposit_limit_cache[e]||{},this.state.deposit_limit_cache[e][t]=s}getCachedOrFreshDepositLimit(e,t,s){let a=this.getCachedDepositLimit(t,s);if(a)return a;this.state.deposit_limit_requests_in_progress[t]=this.state.input_address_requests_in_progress[t]||{},this.state.deposit_limit_requests_in_progress[t][s]=!0;let i=this.state.url+"/deposit-limits?inputCoinType="+encodeURIComponent(t)+"&outputCoinType="+encodeURIComponent(s);return fetch(i,{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())).then((a=>{if(this.unMounted)return;if(console.assert(a.inputCoinType==t&&a.outputCoinType==s,"unexpected reply from deposit-limits"),a.inputCoinType!=t||a.outputCoinType!=s)throw Error("unexpected reply from deposit-limits");let i={timestamp:new Date,limit:a.depositLimit};this.cacheDepositLimit(t,s,i),delete this.state.deposit_limit_requests_in_progress[t][s],this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.setState({[e+"_limit"]:i})}),(e=>{delete this.state.deposit_limit_requests_in_progress[t][s]})),null}getAndUpdateOutputEstimate(e,t,s,a){if(this.unMounted)return;"deposit"==e&&this.setState({failed_calculate_deposit:null}),"withdraw"==e&&this.setState({failed_calculate_withdraw:null});let i=this.state.url+"/estimate-output-amount?inputAmount="+encodeURIComponent(a)+"&inputCoinType="+encodeURIComponent(t)+"&outputCoinType="+encodeURIComponent(s);return fetch(i,{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())).then((i=>{if(!this.unMounted)if(i.error){if(this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.state[e+"_estimated_input_amount"]==a&&this.state[e+"_estimate_direction"]==this.estimation_directions.output_from_input){let t=i.error.message;"deposit"==e&&this.setState({failed_calculate_deposit:"Failed to calculate"}),"withdraw"==e&&this.setState({failed_calculate_withdraw:"Failed to calculate"});let s="Internal Server Error: ";t.startsWith(s)&&(t=t.substr(s.length)),this.setState({[e+"_error"]:t})}}else console.assert(i.inputCoinType==t&&i.outputCoinType==s&&i.inputAmount==a,"unexpected reply from estimate-output-amount"),i.inputCoinType==t&&i.outputCoinType==s&&i.inputAmount==a||this.setState({[e+"_estimated_output_amount"]:i.outputAmount,[e+"_error"]:null}),this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.state[e+"_estimated_input_amount"]==a&&this.state[e+"_estimate_direction"]==this.estimation_directions.output_from_input&&this.setState({[e+"_estimated_output_amount"]:i.outputAmount,[e+"_error"]:null})}),(e=>{})),null}getAndUpdateInputEstimate(e,t,s,a){if(this.unMounted)return;"deposit"==e&&this.setState({failed_calculate_deposit:null}),"withdraw"==e&&this.setState({failed_calculate_withdraw:null});let i=this.state.url+"/estimate-input-amount?outputAmount="+encodeURIComponent(a)+"&inputCoinType="+encodeURIComponent(t)+"&outputCoinType="+encodeURIComponent(s);return fetch(i,{method:"get",headers:new Headers({Accept:"application/json"})}).then((e=>e.json())).then((i=>{this.unMounted||(console.assert(i.inputCoinType==t&&i.outputCoinType==s&&i.outputAmount==a,"unexpected reply from estimate-input-amount"),i.inputCoinType==t&&i.outputCoinType==s&&i.outputAmount==a||("deposit"==e&&this.setState({failed_calculate_deposit:"Failed to calculate"}),"withdraw"==e&&this.setState({failed_calculate_withdraw:"Failed to calculate"})),this.state[e+"_input_coin_type"]==t&&this.state[e+"_output_coin_type"]==s&&this.state[e+"_estimated_output_amount"]==a&&this.state[e+"_estimate_direction"]==this.estimation_directions.input_from_output&&this.setState({[e+"_estimated_input_amount"]:i.inputAmount,key_for_withdrawal_dialog:i.inputAmount}))}),(e=>{})),null}onInputAmountChanged(e,t){let s=t.target.value;""==s&&(s="0");let a=this.getAndUpdateOutputEstimate(e,this.state[e+"_input_coin_type"],this.state[e+"_output_coin_type"],s);this.setState({[e+"_estimated_input_amount"]:s,[e+"_estimated_output_amount"]:a,[e+"_estimate_direction"]:this.estimation_directions.output_from_input,key_for_withdrawal_dialog:s})}onOutputAmountChanged(e,t){let s=t.target.value;""==s&&(s="0");let a=this.getAndUpdateInputEstimate(e,this.state[e+"_input_coin_type"],this.state[e+"_output_coin_type"],s);this.setState({[e+"_estimated_output_amount"]:s,[e+"_estimated_input_amount"]:a,[e+"_estimate_direction"]:this.estimation_directions.input_from_output})}getWithdrawModalId(){return"withdraw_asset_"+this.props.gateway+"_bridge"}onWithdraw(){this.showModal()}onInputCoinTypeChanged(e,t){let s=null,a="_estimated_output_amount",i=t.target.value,n=this.state["allowed_mappings_for_"+e][i],o=n[0];-1!=n.indexOf(this.state[e+"_output_coin_type"])&&(o=this.state[e+"_output_coin_type"]);let r=this.state.input_address_and_memo;"deposit"==e&&(r=this.getCachedOrGeneratedInputAddress(i,o));let l=this.getCachedOrFreshDepositLimit(e,i,o);this.state[e+"_estimated_input_amount"]?s=this.getAndUpdateOutputEstimate(e,i,o,this.state[e+"_estimated_input_amount"]):(s=this.getAndUpdateInputEstimate(e,i,o,this.state[e+"_estimated_output_amount"]),a="_estimated_input_amount"),"withdraw"==e&&n.forEach((e=>{o===e&&this.setState({coin_symbol:i+"input",supports_output_memos:this.state.coins_by_type[e].supportsOutputMemos})})),this.setState({[e+"_input_coin_type"]:i,[e+"_output_coin_type"]:o,input_address_and_memo:r,[e+"_limit"]:l,[e+a]:s,[e+"_estimate_direction"]:this.estimation_directions.output_from_input})}onOutputCoinTypeChanged(e,t){let s=null,a="_estimated_output_amount",i=t.target.value,n=this.state.allowed_mappings_for_withdraw[this.state.withdraw_input_coin_type];"withdraw"==e&&n.forEach((e=>{i===e&&this.setState({coin_symbol:i+"output",supports_output_memos:this.state.coins_by_type[e].supportsOutputMemos,key_for_withdrawal_dialog:i})}));let o=this.state.input_address_and_memo;"deposit"==e&&(o=this.getCachedOrGeneratedInputAddress(this.state[e+"_input_coin_type"],i));let r=this.getCachedOrFreshDepositLimit(e,this.state[e+"_input_coin_type"],i);this.state[e+"_estimated_input_amount"]?s=this.getAndUpdateOutputEstimate(e,this.state[e+"_input_coin_type"],i,this.state[e+"_estimated_input_amount"]):(s=this.getAndUpdateInputEstimate(e,this.state[e+"_input_coin_type"],i,this.state[e+"_estimated_output_amount"]),a="_estimated_input_amount"),this.setState({[e+"_output_coin_type"]:i,input_address_and_memo:o,[e+"_limit"]:r,[e+a]:s,[e+"_estimate_direction"]:this.estimation_directions.output_from_input})}render(){if(!this.props.account||!this.props.issuer_account||!this.props.gateway)return a.createElement("div",null);let e,t,s,i,n,o;if(this.state.coin_info_request_state==this.coin_info_request_states.request_failed)return a.createElement("div",null,a.createElement("p",null,"Error connecting to citadel.li, please try again later"));if(this.state.coin_info_request_state==this.coin_info_request_states.never_requested||this.state.coin_info_request_state==this.coin_info_request_states.request_in_progress)return a.createElement("div",null,a.createElement("p",null,"Retrieving current trade data from citadel.li"));{let l=null,p=a.createElement(c(),{content:"gateway.calc"});null!=this.state.failed_calculate_deposit&&(p=this.state.failed_calculate_deposit);let d=a.createElement(c(),{content:"gateway.calc"});null!=this.state.failed_calculate_withdraw&&(d=this.state.failed_calculate_withdraw);let u=a.createElement(c(),{content:"gateway.calc"});if(null!=this.state.failed_calculate_conversion&&(u=this.state.failed_calculate_conversion),Object.getOwnPropertyNames(this.state.allowed_mappings_for_deposit).length>0){let e=[];Object.keys(this.state.allowed_mappings_for_deposit).sort().forEach((t=>{e.push(a.createElement("option",{key:t,value:t||""},this.state.coins_by_type[t].symbol))}));let i=a.createElement("select",{style:{width:"11rem"},className:"external-coin-types",value:this.state.deposit_input_coin_type||"",onChange:this.onInputCoinTypeChanged.bind(this,"deposit")},e),n=[];this.state.allowed_mappings_for_deposit[this.state.deposit_input_coin_type].forEach((e=>{n.push(a.createElement("option",{key:e,value:e||""},this.state.coins_by_type[e].walletSymbol))}));let o=a.createElement("select",{style:{width:"11rem"},className:"native-coin-types",value:this.state.deposit_output_coin_type||"",onChange:this.onOutputCoinTypeChanged.bind(this,"deposit")},n),l=this.state.input_address_and_memo?this.state.input_address_and_memo:{address:"unknown",memo:null},d=this.state.deposit_estimated_input_amount,u=this.state.deposit_estimated_output_amount,h=d?a.createElement("input",{style:{width:"11rem"},type:"text",value:d||"",onChange:this.onInputAmountChanged.bind(this,"deposit")}):p,m=u?a.createElement("input",{style:{width:"11rem"},type:"text",value:u||"",onChange:this.onOutputAmountChanged.bind(this,"deposit")}):p,_=a.createElement("span",null,"updating");this.state.deposit_limit&&(_=this.state.deposit_limit.limit?a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},a.createElement(c(),{content:"gateway.limit",amount:r.Z.format_number(this.state.deposit_limit.limit,8),symbol:this.state.coins_by_type[this.state.deposit_input_coin_type].walletSymbol}))):null);let g=null;this.state.deposit_error&&(g=a.createElement("div",null,this.state.deposit_error)),s=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"gateway.deposit"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.balance"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.deposit_to",asset:this.state.deposit_input_coin_type}))));let w=null;w=l.memo?a.createElement(c(),{unsafe:!0,content:"gateway.address_with_memo",address:l.address,memo:l.memo}):a.createElement("span",null,l.address),t=a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement("div",{className:"blocktrades-bridge",style:{display:"flex",alignItems:"center"}},a.createElement("div",{className:"inline-block"},a.createElement("div",null,i),a.createElement("div",null,h)),"→",a.createElement("div",{className:"inline-block"},a.createElement("div",null,o),a.createElement("div",null,m)),a.createElement("div",null,g))),a.createElement("td",null,a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.state.coins_by_type[this.state.deposit_output_coin_type].walletSymbol})),a.createElement("td",{style:{wordBreak:"break-all"}},w,a.createElement("br",null),_)))}if(Object.getOwnPropertyNames(this.state.allowed_mappings_for_withdraw).length>0){o=this.getWithdrawModalId(),this.state.coins_by_type[this.state.withdraw_input_coin_type].symbol,l=this.state.withdraw_estimated_input_amount;let e=[];Object.keys(this.state.allowed_mappings_for_withdraw).sort().forEach((t=>{e.push(a.createElement("option",{key:t,value:t},this.state.coins_by_type[t].walletSymbol))}));let t=a.createElement("select",{style:{width:"11rem"},className:"native-coin-types",value:this.state.withdraw_input_coin_type,onChange:this.onInputCoinTypeChanged.bind(this,"withdraw")},e),s=[];this.state.allowed_mappings_for_withdraw[this.state.withdraw_input_coin_type].forEach((e=>{s.push(a.createElement("option",{key:e,value:e},this.state.coins_by_type[e].symbol))}));let p=a.createElement("select",{style:{width:"11rem"},className:"external-coin-types",value:this.state.withdraw_output_coin_type,onChange:this.onOutputCoinTypeChanged.bind(this,"withdraw")},s),u=this.state.withdraw_estimated_input_amount,h=u?a.createElement("input",{style:{width:"11rem"},type:"text",value:u||"",onChange:this.onInputAmountChanged.bind(this,"withdraw")}):d,m=this.state.withdraw_estimated_output_amount,_=m?a.createElement("input",{style:{width:"11rem"},type:"text",value:m||"",onChange:this.onOutputAmountChanged.bind(this,"withdraw")}):d,g=a.createElement(Be,{showModal:this.showModal,hideModal:this.hideModal,visible:this.state.isModalVisible,key:this.state.key_for_withdrawal_dialog,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.state.coins_by_type[this.state.withdraw_input_coin_type].walletSymbol,output_coin_name:this.state.coins_by_type[this.state.withdraw_output_coin_type].name,output_coin_symbol:this.state.coins_by_type[this.state.withdraw_output_coin_type].symbol,output_coin_type:this.state.withdraw_output_coin_type,output_supports_memos:this.state.supports_output_memos,amount_to_withdraw:l,url:this.state.url,gateway:this.props.gateway,output_wallet_type:this.state.coins_by_type[this.state.withdraw_output_coin_type].walletType}),w=null;this.state.withdraw_error&&(w=a.createElement("div",null,this.state.withdraw_error));let y=a.createElement("span",null,"...");this.state.withdraw_limit&&(y=this.state.withdraw_limit.limit?a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},a.createElement(c(),{content:"gateway.limit",amount:r.Z.format_number(this.state.withdraw_limit.limit,8),symbol:this.state.coins_by_type[this.state.withdraw_input_coin_type].walletSymbol}))):a.createElement("div",{className:"blocktrades-bridge"},a.createElement("span",{className:"deposit-limit"},"no limit"))),n=a.createElement("thead",null,a.createElement("tr",null,a.createElement("th",null,a.createElement(c(),{content:"gateway.withdraw"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.balance"})),a.createElement("th",null))),i=a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement("div",{className:"blocktrades-bridge"},a.createElement("div",{className:"inline-block"},a.createElement("div",null,t),a.createElement("div",null,h)),"→",a.createElement("div",{className:"inline-block"},a.createElement("div",null,p),a.createElement("div",null,_)),a.createElement("div",null,w))),a.createElement("td",null,a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.state.coins_by_type[this.state.withdraw_input_coin_type].walletSymbol})),a.createElement("td",null,g,a.createElement("br",null),y)))}return this.state.announcements.length>0&&(e=a.createElement("div",{className:"blocktrades-announcements-container"},this.state.announcements.map((function(e,t){let s="txtann info";return 10===e.status?s="txtann error":20===e.status?s="txtann warning":30===e.status?s="txtann success":40===e.status&&(s="txtann info"),1===e.format&&e.message.replace(/\r\n|\r|\n/g,"<br />"),a.createElement("div",{className:"blocktrades-announcements "+s,key:t},e.message)}),this))),a.createElement("div",null,a.createElement("div",{style:{paddingBottom:15}},a.createElement(c(),{component:"h5",content:"gateway.bridge_text"})),e,a.createElement("table",{className:"table"},s,t,n,i))}}}const Fe=(0,d.Z)(De);var Oe=s(21660),Re=s(32793);const We=(0,ue.ZP)(""),Pe=function(e){return We.has(`history_address_${e}`)},qe=function({wallet:e,addresses:t}){We.set(`history_address_${e}`,t)},Ue=function(e){return We.get(`history_address_${e}`,[])},je=function({wallet:e,address:t}){We.set(`history_address_last_${e}`,t)},Le=function(e){return We.get(`history_address_last_${e}`,"")};var Ve=s(48764).Buffer;class ze extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_name:S().string.isRequired,output_coin_symbol:S().string.isRequired,output_coin_type:S().string.isRequired,url:S().string,output_wallet_type:S().string,output_supports_memos:S().bool.isRequired,output_supportsPublicKey:S().bool.isRequired,amount_to_withdraw:S().string,balance:p.Z.ChainObject,min_amount:S().number,gateFee:S().number};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:Le(e.output_wallet_type),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,confirmation_is_valid:!1,withdraw_address_selected:Le(e.output_wallet_type),withdraw_publicKey:"",withdraw_publicKey_not_empty:!this.props.output_supportsPublicKey,memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{}},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._checkMinAmount=this._checkMinAmount.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},(function(){this._checkBalance,this._checkMinAmount()}))}onSelectChanged(e){let t=Ue(this.props.output_wallet_type)[e];je({wallet:this.props.output_wallet_type,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawPublicKeyChanged(e){let t=e.target.value.trim();this.setState({withdraw_publicKey:t,withdraw_publicKey_not_empty:""!=t})}_validateAddress(e,t=this.props){(function({url:e=I.Eu.BASE,walletType:t,newAddress:s}){return s?fetch(e+"/wallets/"+t+"/check-address",{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:JSON.stringify({address:s})}).then((e=>e.json().then((e=>e)))).catch((e=>{console.log("validate error:",e)})):new Promise((e=>e()))})({url:t.url,walletType:t.output_wallet_type,newAddress:e}).then((t=>{void 0===t&&(t={isValid:!1}),this.state.withdraw_address===e&&this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:t.isValid,withdraw_publicKey:t.hasOwnProperty("publicKey")?t.publicKey:"",withdraw_publicKey_not_empty:!this.props.output_supportsPublicKey||!!t.hasOwnProperty("publicKey")})}))}_checkBalance(){const{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a}=this.props;if(!a||!e)return;const i=(0,E.cr)(t,s,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}_checkMinAmount(){const{withdraw_amount:e}=this.state;if(null===e)return;const t=e<this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision);return this.setState({minAmountError:t}),t}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(Pe(this.props.output_wallet_type)){let e=Ue(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),qe({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),qe({wallet:this.props.output_wallet_type,addresses:e})}je({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t,fee_asset_id:s}=this.state;let a=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),i=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a});y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),i.getAmount(),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.props.output_supportsPublicKey?":"+this.state.withdraw_publicKey:"")+(this.state.memo?":"+new Ve(this.state.memo,"utf-8"):""),null,t?t.asset_id:s),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),Pe(this.props.output_wallet_type)){let e=Ue(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),qe({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),qe({wallet:this.props.output_wallet_type,addresses:e})}je({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a,fee_asset_id:i}=this.state;y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.props.output_supportsPublicKey?":"+this.state.withdraw_publicKey:"")+(this.state.memo?":"+new Ve(this.state.memo,"utf-8"):""),null,a?a.asset_id:i)}onDropDownList(){Pe(this.props.output_wallet_type)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,withdraw_publicKey:t,memo:s}=this.state,i=Ue(this.props.output_wallet_type),n=null,o=this.props.account.get("balances").toJS(),l=Object.keys(o),p=(this.getWithdrawModalId(),null),d=null,u=null;this.state.options_is_valid&&(d=a.createElement("div",{className:i.length?"rudex-options":"rudex-disabled-options"},i.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(p=a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_type})),u=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let h=1,_=null;this.props.output_supports_memos&&(_=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:s,tabIndex:h++,onChange:this.onMemoChanged.bind(this)})));let{fee_asset_types:y}=this._getAvailableAssets();if(l.length>0){let e=this.props.asset.get("id");if(e){let t=o[e];n=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:o[e]}):0))}else n="No funds"}else n="No funds";return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:"0px"}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:n}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null,this.state.minAmountError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.rudex.min_amount_error"})):null,a.createElement("p",{className:"no-margin",style:{paddingTop:10}},a.createElement("b",null,a.createElement(c(),{content:"gateway.rudex.min_amount",minAmount:r.Z.format_number(this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1),symbol:this.props.output_coin_symbol})))),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:y,tabIndex:h++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,this.props.gateFee?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:this.props.gateFee}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"rudex-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"rudex-position-options"},d),p),this.props.output_supportsPublicKey?a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.public_key"})),a.createElement("div",{className:"rudex-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",value:t,tabIndex:"5",onChange:this.onWithdrawPublicKeyChanged.bind(this),onInput:this.onWithdrawPublicKeyChanged.bind(this),autoComplete:"off"})))):null,_,a.createElement("div",null,a.createElement(v.Button,{disabled:this.state.error||this.state.balanceError||this.state.minAmountError||!this.state.withdraw_publicKey_not_empty,type:"primary",onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),u))}}ze=(0,d.Z)(ze);const Je=(0,i.$)(ze,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})});var Xe=s(23316);class He extends a.Component{static propTypes={gateway:S().string,deposit_coin_type:S().string,deposit_asset_name:S().string,deposit_account:S().string,receive_coin_type:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,deposit_asset:S().string,deposit_wallet_type:S().string,receive_asset:p.Z.ChainAsset,deprecated_in_favor_of:p.Z.ChainAsset,deprecated_message:S().string,action:S().string,supports_output_memos:S().bool.isRequired,supportsPublicKey:S().bool.isRequired,memoType:S().string,min_amount:S().number,gateFee:S().number,confirmations:S().object,asset_precision:S().number};constructor(e){super(e),this.deposit_address_cache=new class{constructor(){this.current_rudex_address_cache_version_string="1"}getIndexForDepositKeyInExchange(e,t,s){return[this.current_rudex_address_cache_version_string,e,t,s].reduce((function(e,t){return e.concat("[",t,"]")}),"")}getCachedInputAddress(e,t,s,a){let i=X.Z.getWallet();if(!i)return null;i.deposit_keys=i.deposit_keys||{},i.deposit_keys[e]=i.deposit_keys[e]||{};let n=this.getIndexForDepositKeyInExchange(t,s,a);i.deposit_keys[e][n]=i.deposit_keys[e][n]||[];let o=i.deposit_keys[e][n].length;return o?i.deposit_keys[e][n][o-1]:null}cacheInputAddress(e,t,s,a,i,n){let o=X.Z.getWallet();if(!o)return null;o.deposit_keys=o.deposit_keys||{},o.deposit_keys[e]=o.deposit_keys[e]||{};let r=this.getIndexForDepositKeyInExchange(t,s,a);o.deposit_keys[e][r]=o.deposit_keys[e][r]||[],o.deposit_keys[e][r].push({address:i,memo:n}),X.Z._updateWallet()}},this.state={isModalVisible:!1,receive_address:null},this.addDepositAddress=this.addDepositAddress.bind(this),this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}_getDepositObject(){return{inputCoinType:this.props.deposit_coin_type,outputCoinType:this.props.receive_coin_type,outputAddress:this.props.account.get("name"),stateCallback:this.addDepositAddress}}addDepositAddress(e){let t=this.props.account.get("name");this.deposit_address_cache.cacheInputAddress(this.props.gateway,t,this.props.deposit_coin_type,this.props.receive_coin_type,e.address,e.memo),this.setState({account_name:t}),this.setState({receive_address:e})}getWithdrawModalId(){return"withdraw_asset_"+this.props.issuer_account.get("name")+"_"+this.props.receive_asset.get("symbol")}onWithdraw(){this.showModal()}render(){let e=a.createElement("div",{style:{display:"none",minHeight:150}});if(!this.props.account||!this.props.issuer_account||!this.props.receive_asset)return e;let t=this.props.account.get("balances");if(this.props.deprecated_in_favor_of){let s=!1,a=t.get(this.props.receive_asset.get("id"));if(a){let e=u.ChainStore.getObject(a);e&&0!=e.get("balance")&&(s=!0)}if(!s)return e}let s=this.state.receive_address;if(!s){let e=this.props.account.get("name");s=this.deposit_address_cache.getCachedInputAddress(this.props.gateway,e,this.props.deposit_coin_type,this.props.receive_coin_type)}let i=null;this.props.confirmations&&this.props.confirmations.type&&("irreversible"===this.props.confirmations.type?i=a.createElement(c(),{content:"gateway.gateway_deposit.confirmations.last_irreversible"}):"blocks"===this.props.confirmations.type&&this.props.confirmations.value&&(i=a.createElement(c(),{content:"gateway.gateway_deposit.confirmations.n_blocks",blocks:this.props.confirmations.value})));let n,o,l=this.getWithdrawModalId(),p=null,d=null,h="",m="RUDEX";if(Xe.bg[m].simpleAssetGateway&&this.props.deposit_account)p=a.createElement("span",null,this.props.deposit_account),h=this.props.deposit_account,n=this.props.memoType&&"btsid"===this.props.memoType?Xe.bg[m].fixedMemo.prepend_btsid+this.props.account.get("id").replace("1.2.","")+Xe.bg[m].fixedMemo.append:Xe.bg[m].fixedMemo.prepend_default+this.props.account.get("name")+Xe.bg[m].fixedMemo.append,d=a.createElement("span",null,n),o=this.props.deposit_coin_type+":";else{if(!s&&!this.props.supportsMemos)return function({inputCoinType:e,outputCoinType:t,outputAddress:s,url:a=I.Eu.BASE,stateCallback:i}){let n={inputCoinType:e,outputCoinType:t,outputAddress:s},o=JSON.stringify(n);fetch(a+I.Eu.NEW_DEPOSIT_ADDRESS,{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:o}).then((e=>{e.json().then((e=>{let t={address:e.inputAddress||"unknown",memo:e.inputMemo,error:e.error||null};i&&i(t)}),(e=>{i&&i({address:"unknown",memo:null})}))}),(e=>{i&&i({address:"unknown",memo:null})})).catch((e=>{console.log("fetch error:",e)}))}(this._getDepositObject()),e;s.memo?(n=s.memo,h=s.address,p=a.createElement("span",null,s.address),d=a.createElement("span",null,s.memo)):(h=s.address,p=a.createElement("span",null,s.address)),o=""}return"deposit"===this.props.action?a.createElement("div",{className:"rudex__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.deposit_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_deposit"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.your_account"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.deposit_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.deposit_to",asset:this.props.deposit_asset}),":"),a.createElement("label",{className:"left-label"},a.createElement("b",null,a.createElement(c(),{content:"gateway.rudex.min_amount",minAmount:r.Z.format_number(this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1),symbol:this.props.deposit_coin_type}))),i?a.createElement("span",null,"(",a.createElement("i",null,i),")"):null,a.createElement("div",{style:{padding:"10px 0",fontSize:"1.1rem"}},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,"ADDRESS:"," ",a.createElement("b",null,a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},p)))),d?a.createElement("tr",null,a.createElement("td",null,a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},"MEMO: ",a.createElement("b",null,d)))):null)),a.createElement("div",{className:"button-group",style:{paddingTop:10}},p?a.createElement(W(),{text:h},a.createElement("div",{className:"button"},"Copy address")):null,n?a.createElement(W(),{text:n},a.createElement("div",{className:"button"},"Copy memo")):null)))):a.createElement("div",{className:"rudex__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_withdraw"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.withdraw_to",asset:this.props.deposit_asset}),":"),a.createElement("div",{className:"button-group",style:{paddingTop:20}},a.createElement("button",{className:"button success",style:{fontSize:"1.3rem"},onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:"gateway.withdraw_now"})," "))),a.createElement(v.Modal,{onCancel:this.hideModal,title:g().translate("gateway.withdraw_coin",{coin:this.props.deposit_asset_name,symbol:this.props.deposit_asset}),footer:null,visible:this.state.isModalVisible},a.createElement(Je,{hideModal:this.hideModal,showModal:this.showModal,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.props.receive_asset.get("symbol"),output_coin_name:this.props.deposit_asset_name,output_coin_symbol:this.props.deposit_asset,output_coin_type:this.props.deposit_coin_type,output_wallet_type:this.props.deposit_wallet_type,output_supports_memos:this.props.supports_output_memos,output_supportsPublicKey:this.props.supportsPublicKey,memo_prefix:o,modal_id:l,min_amount:this.props.min_amount,gateFee:this.props.gateFee,asset_precision:this.props.asset_precision,balance:this.props.account.get("balances").toJS()[this.props.receive_asset.get("id")]})))}}const Ke=(0,d.Z)(He);var Ge=s(94184),Qe=s.n(Ge);class $e extends a.Component{constructor(e){super(),this.state={activeCoin:this._getActiveCoin(e,{action:"deposit"}),action:e.viewSettings.get("rudexAction","deposit")}}_getActiveCoin(e,t){let s=e.viewSettings.get(`activeCoin_rudex_${t.action}`,null),a=null;return"deposit"==t.action&&(a="PPY"),"withdraw"==t.action&&(a="PPY"),s||a}UNSAFE_componentWillReceiveProps(e){e.provider!==this.props.provider&&this.setState({activeCoin:this._getActiveCoin(e,this.state.action)})}onSelectCoin(e){this.setState({activeCoin:e.target.value});let t={};t[`activeCoin_rudex_${this.state.action}`]=e.target.value,U.Z.changeViewSetting(t)}changeAction(e){let t=this._getActiveCoin(this.props,{action:e});this.setState({action:e,activeCoin:t}),U.Z.changeViewSetting({rudexAction:e})}render(){let{coins:e,account:t}=this.props,{activeCoin:s,action:i}=this.state;if(!e.length)return a.createElement(B.Z,null);let n=e.filter((e=>!(!e||!e.symbol)&&("deposit"===i?e.depositAllowed:e.withdrawalAllowed))),o=n.map((e=>{let t="deposit"===i?e.backingCoin.toUpperCase():e.symbol;return a.createElement("option",{value:t,key:e.symbol},t)})).filter((e=>null!==e)),r=n.filter((e=>"deposit"===i?e.backingCoin.toUpperCase()===s:e.symbol===s))[0];r||(r=n[0]);let l="deposit"===this.state.action,p="https://rudex.freshdesk.com";return a.createElement("div",{style:this.props.style},a.createElement("div",{className:"grid-block no-margin vertical medium-horizontal no-padding"},a.createElement("div",{className:"medium-4"},a.createElement("div",null,a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.choose_"+i}),":"," "),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:s},o))),a.createElement("div",{className:"medium-6 medium-offset-1"},a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.gateway_text"}),":"),a.createElement("div",{style:{paddingBottom:15}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{className:"deposit"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"deposit")},a.createElement(c(),{content:"gateway.deposit"}))),a.createElement("li",{className:"withdraw"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"withdraw")},a.createElement(c(),{content:"gateway.withdraw"}))))))),r?a.createElement("div",null,a.createElement("div",{style:{marginBottom:15}},a.createElement(Ke,{key:`${r.symbol}`,gateway:r.gatewayWallet,issuer_account:r.issuer,account:t,deposit_asset:r.backingCoin.toUpperCase(),deposit_asset_name:r.name,deposit_coin_type:r.backingCoin.toLowerCase(),deposit_account:r.gatewayWallet,deposit_wallet_type:r.walletType,receive_asset:r.symbol,receive_coin_type:r.symbol.toLowerCase(),supports_output_memos:r.supportsMemos,supportsPublicKey:r.supportsPublicKey||!1,memoType:r.memoType,min_amount:r.minAmount,gateFee:r.gateFee,asset_precision:r.precision,confirmations:r.confirmations,action:this.state.action}),a.createElement("label",{className:"left-label"},"Support"),a.createElement("div",null,a.createElement(c(),{content:"gateway.rudex.support_block"}),a.createElement("br",null),a.createElement("br",null),a.createElement("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"external-link"},p))),r&&r.symbol?a.createElement(j.k,{asset:r.symbol,fromAccount:l?r.issuerId:this.props.account.get("id"),to:l?this.props.account.get("id"):r.issuerId},(({asset:e,to:t,fromAccount:s})=>a.createElement(j.t,{accountsList:V().List([this.props.account.get("id")]),limit:10,compactView:!0,fullHeight:!0,filter:"transfer",title:a.createElement(c(),{content:"gateway.recent_"+this.state.action}),customFilter:{fields:["to","from","asset_id"],values:{to:t.get("id"),from:s.get("id"),asset_id:e.get("id")}}}))):null):null)}}const Ye=(0,i.$)($e,{listenTo:()=>[A.Z],getProps:()=>({viewSettings:A.Z.getState().viewSettings})});var et=s(7437),tt=s(50379),st=s(48764).Buffer;class at extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_name:S().string.isRequired,output_coin_symbol:S().string.isRequired,output_coin_type:S().string.isRequired,url:S().string,output_wallet_type:S().string,output_supports_memos:S().bool.isRequired,amount_to_withdraw:S().string,balance:p.Z.ChainObject};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:b.So.getLast(e.output_wallet_type),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,confirmation_is_valid:!1,withdraw_address_selected:b.So.getLast(e.output_wallet_type),memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{}},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},fee_asset_id:"1.3.0",feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},this._checkBalance)}onSelectChanged(e){let t=b.So.get(this.props.output_wallet_type)[e];b.So.setLast({wallet:this.props.output_wallet_type,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}_validateAddress(e,t=this.props){(0,b.YN)({url:t.url,walletType:t.output_wallet_type,newAddress:e}).then((t=>{this.state.withdraw_address===e&&this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:t})}))}_checkBalance(){const{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a}=this.props;if(!a||!e)return;const i=(0,E.cr)(t,s,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(b.So.has(this.props.output_wallet_type)){let e=b.So.get(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e})}b.So.setLast({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t}=this.state,s=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),a=void 0!==this.props.gateFee?parseFloat(String.prototype.replace.call(this.props.gateFee,/,/g,"")):0;let i=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:s}),n=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:0});void 0!==this.props.balance&&(n=i.clone(this.props.balance.get("balance")));const o=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a});i.plus(o),n.lt(i)&&(i=n),y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),i.getAmount(),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new st(this.state.memo,"utf-8"):""),null,t?t.asset_id:"1.3.0"),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),b.So.has(this.props.output_wallet_type)){let e=b.So.get(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),b.So.set({wallet:this.props.output_wallet_type,addresses:e})}b.So.setLast({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a}=this.state;y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new st(this.state.memo,"utf-8"):""),null,a?a.asset_id:"1.3.0")}onDropDownList(){b.So.has(this.props.output_wallet_type)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,memo:t}=this.state,s=b.So.get(this.props.output_wallet_type),i=null,n=this.props.account.get("balances").toJS(),o=Object.keys(n),r=(this.getWithdrawModalId(),null),l=null,p=null;this.state.options_is_valid&&(l=a.createElement("div",{className:s.length?"blocktrades-options":"blocktrades-disabled-options"},s.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(r=a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_type})),p=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let d=1,u=null;this.props.output_supports_memos&&(u=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:t,tabIndex:d++,onChange:this.onMemoChanged.bind(this)})));let{fee_asset_types:h}=this._getAvailableAssets();if(o.length>0){let e=this.props.asset.get("id");if(e){let t=n[e];i=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:n[e]}):0))}else i="No funds"}else i="No funds";const _=this.state.error||this.state.balanceError||!this.state.withdraw_amount;return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:0}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:i}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:h,tabIndex:d++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,this.props.gateFee?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:this.props.gateFee}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"blocktrades-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"blocktrades-position-options"},l),r),u,a.createElement("div",null,a.createElement(v.Button,{type:"primary",disabled:_,onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),p))}}at=(0,d.Z)(at);const it=(0,i.$)(at,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})});function nt({coin:e,account:t,stateCallback:s}){let a={coin:e,account:t},i=JSON.stringify(a);fetch(I.Jt.BASE+"/simple-api/get-last-address",{method:"POST",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:i}).then((e=>{e.json().then((e=>{let t={address:e.address,memo:e.memo||null,error:e.error||null,loading:!1};s&&s(t)}),(e=>{console.log("error: ",e),s&&s({address:e.message,memo:null})}))}),(e=>{console.log("error: ",e),s&&s({address:e.message,memo:null})})).catch((e=>{console.log("fetch error:",e)}))}(0,ue.ZP)("");let ot={};class rt extends a.Component{static propTypes={url:S().string,gateway:S().string,deposit_coin_type:S().string,deposit_asset_name:S().string,deposit_account:S().string,receive_coin_type:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,deposit_asset:S().string,deposit_wallet_type:S().string,receive_asset:p.Z.ChainAsset,deprecated_in_favor_of:p.Z.ChainAsset,deprecated_message:S().string,action:S().string,supports_output_memos:S().bool.isRequired};static defaultProps={autosubscribe:!1};constructor(e){super(e),this.state={isModalVisible:!1,receive_address:null,url:e.url||I.Jt.BASE,loading:!1,emptyAddressDeposit:!1},this.addDepositAddress=this.addDepositAddress.bind(this),this._copy=this._copy.bind(this),this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this),document.addEventListener("copy",this._copy)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}_copy(e){try{this.state.clipboardText?e.clipboardData.setData("text/plain",this.state.clipboardText):e.clipboardData.setData("text/plain",g().translate("gateway.use_copy_button").toUpperCase()),e.preventDefault()}catch(e){console.error(e)}}_getDepositObject(){return{inputCoinType:this.props.deposit_coin_type,outputCoinType:this.props.receive_coin_type,outputAddress:this.props.account.get("name"),url:this.state.url,stateCallback:this.addDepositAddress}}UNSAFE_componentWillMount(){nt({coin:this.props.receive_coin_type,account:this.props.account.get("name"),stateCallback:this.addDepositAddress})}componentWillUnmount(){document.removeEventListener("copy",this._copy)}UNSAFE_componentWillReceiveProps(e){e.account!==this.props.account&&nt({coin:e.receive_coin_type,account:e.account.get("name"),stateCallback:this.addDepositAddress})}addDepositAddress(e){e.error&&("no_address"===e.error.message?this.setState({emptyAddressDeposit:!0}):this.setState({emptyAddressDeposit:!1})),this.setState({receive_address:e}),this.setState({loading:!1}),this.setState({receive_address:e})}requestDepositAddressLoad(){this.setState({loading:!0,emptyAddressDeposit:!1}),function({inputCoinType:e,outputCoinType:t,outputAddress:s,url:a=I.Jt.BASE,stateCallback:i,selectedGateway:n}){Xe.bg[n];let o={inputCoinType:e,outputCoinType:t,outputAddress:s},r=JSON.stringify(o);ot[r]||(ot[r]=!0,fetch(a+"/simple-api/initiate-trade",{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:r}).then((e=>{e.json().then((e=>{delete ot[r];let t={address:e.inputAddress||"unknown",memo:e.inputMemo,error:e.error||null};i&&i(t)}),(e=>{console.log("error: ",e),delete ot[r],i&&i(null)}))}),(e=>{console.log("error: ",e),delete ot[r],i&&i(null)})).catch((e=>{console.log("fetch error:",e),delete ot[r]})))}(this._getDepositObject())}getWithdrawModalId(){return"withdraw_asset_"+this.props.issuer_account.get("name")+"_"+this.props.receive_asset.get("symbol")}onWithdraw(){this.showModal()}toClipboard(e){try{this.setState({clipboardText:e},(()=>{document.execCommand("copy")}))}catch(e){console.error(e)}}render(){const e="deposit"===this.props.action;let t=a.createElement(B.Z,null);if(!this.props.account||!this.props.issuer_account||!this.props.receive_asset)return t;let s=this.props.account.get("balances");const{gateFee:i}=this.props;if(this.props.receive_asset.get("symbol"),this.props.deprecated_in_favor_of){let e=!1,a=s.get(this.props.receive_asset.get("id"));if(a){let t=u.ChainStore.getObject(a);t&&0!=t.get("balance")&&(e=!0)}if(!e)return t}let n=this.state.receive_address,{emptyAddressDeposit:o}=this.state,r=this.state.loading;if(!n)return a.createElement("div",{style:{margin:"3rem"}},a.createElement(B.Z,{type:"three-bounce"}));let l,p=this.getWithdrawModalId(),d=null,h=null,m="";if(this.props.deposit_account){d=a.createElement("span",null,this.props.deposit_account),m=this.props.receive_coin_type+":"+this.props.account.get("name"),h=a.createElement("span",null,m);var _=this.props.deposit_coin_type+":"}else n.memo?(l=n.memo,m=n.address,d=a.createElement("span",null,n.address),h=a.createElement("span",null,n.memo)):(m=n.address,d=a.createElement("span",null,n.address)),_="";return!this.props.isAvailable||e&&!this.props.deposit_account&&!n||n&&"unknown"===n.address?a.createElement("div",null,a.createElement(c(),{className:"txtlabel cancel",content:"gateway.unavailable",component:"h4"})):e?a.createElement("div",{className:"Blocktrades__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.deposit_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_deposit"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.your_account"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.deposit_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.deposit_to",asset:this.props.deposit_asset}),":"),a.createElement("label",{className:"fz_12 left-label"},a.createElement(c(),{content:"gateway.deposit_notice_delay"})),a.createElement("div",null,o?a.createElement(c(),{content:"gateway.please_generate_address"}):d,a.createElement("div",null,h&&a.createElement("span",null,"memo: ",h)),a.createElement("div",{className:"button-group",style:{paddingTop:10}},d?a.createElement("div",{className:"button",onClick:this.toClipboard.bind(this,m)},a.createElement(c(),{content:"gateway.copy_address"})):null,l?a.createElement("div",{className:"button",onClick:this.toClipboard.bind(this,l)},a.createElement(c(),{content:"gateway.copy_memo"})):null,a.createElement("button",{className:"button spinner-button-circle",onClick:this.requestDepositAddressLoad.bind(this)},r?a.createElement(B.Z,{type:"circle"}):null,a.createElement(c(),{content:"gateway.generate_new"}))),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_amount",minDeposit:2*this.props.gateFee,coin:this.props.deposit_asset}),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_asset",minDeposit:2*this.props.gateFee,coin:this.props.deposit_asset})))):a.createElement("div",{className:"Blocktrades__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_withdraw"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.withdraw_to",asset:this.props.deposit_asset}),":"),a.createElement("div",{className:"button-group",style:{paddingTop:20}},a.createElement("button",{className:"button success",style:{fontSize:"1.3rem"},onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:"gateway.withdraw_now"})," "))),a.createElement(v.Modal,{onCancel:this.hideModal,title:g().translate("gateway.withdraw_coin",{coin:this.props.deposit_asset_name,symbol:this.props.deposit_asset}),footer:null,visible:this.state.isModalVisible,id:p,overlay:!0},a.createElement(it,{hideModal:this.hideModal,showModal:this.showModal,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.props.receive_asset.get("symbol"),url:this.state.url,output_coin_name:this.props.deposit_asset_name,gateFee:i,output_coin_symbol:this.props.deposit_asset,output_coin_type:this.props.deposit_coin_type,output_wallet_type:this.props.deposit_wallet_type,output_supports_memos:this.props.supports_output_memos,memo_prefix:_,modal_id:p,balance:this.props.account.get("balances").toJS()[this.props.receive_asset.get("id")]})))}}const lt=(0,d.Z)(rt);class ct extends a.Component{constructor(e){super();const t=e.viewSettings.get(`${e.provider}Action`,"deposit");this.state={activeCoin:this._getActiveCoin(e,{action:t}),action:t}}_getActiveCoin(e,t){let s=e.viewSettings.get(`activeCoin_${e.provider}_${t.action}`,null),a=null;return"deposit"==t.action&&(a="BTC"),"withdraw"==t.action&&(a="SPARKDEX.BTC"),s||a}UNSAFE_componentWillReceiveProps(e){e.provider!==this.props.provider&&this.setState({activeCoin:this._getActiveCoin(e,this.state.action)})}onSelectCoin(e){this.setState({activeCoin:e.target.value});let t={};t[`activeCoin_${this.props.provider}_${this.state.action}`]=e.target.value,U.Z.changeViewSetting(t)}changeAction(e){let t=this._getActiveCoin(this.props,{action:e});this.setState({action:e,activeCoin:t}),U.Z.changeViewSetting({[`${this.props.provider}Action`]:e})}render(){let{coins:e,account:t,provider:s}=this.props,{activeCoin:i,action:n}=this.state;if(!e.length)return a.createElement(B.Z,null);let o=e.filter((e=>!(!e||!e.symbol)&&("deposit"===n?e.depositAllowed:e.withdrawalAllowed))),r=o.map((e=>{let t="deposit"===n?e.backingCoinType.toUpperCase():e.symbol;return a.createElement("option",{value:t,key:e.symbol},t)})).filter((e=>null!==e)),l=o.filter((e=>"deposit"===n?e.backingCoinType.toUpperCase()===i:e.symbol===i))[0];l||(l=o[0]);let p={bitspark:{name:l.intermediateAccount,id:"1.2.1070206",support:"[email protected]"}}[s],d="deposit"===this.state.action;return a.createElement("div",{style:this.props.style},a.createElement("div",{className:"grid-block no-margin vertical medium-horizontal no-padding"},a.createElement("div",{className:"medium-4"},a.createElement("div",null,a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.choose_"+n}),":"," "),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:i},r))),a.createElement("div",{className:"medium-6 medium-offset-1"},a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.gateway_text"}),":"),a.createElement("div",{style:{paddingBottom:15}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{className:"deposit"===n?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"deposit")},a.createElement(c(),{content:"gateway.deposit"}))),a.createElement("li",{className:"withdraw"===n?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"withdraw")},a.createElement(c(),{content:"gateway.withdraw"}))))))),l?a.createElement("div",null,a.createElement("div",{style:{marginBottom:15}},a.createElement(lt,{key:`${s}.${l.symbol}`,gateway:s,issuer_account:p.name,account:t,deposit_asset:l.backingCoinType.toUpperCase(),deposit_asset_name:l.name,deposit_coin_type:l.backingCoinType.toLowerCase(),deposit_account:l.depositAccount,deposit_wallet_type:l.walletType,gateFee:l.gateFee,receive_asset:l.symbol,receive_coin_type:l.symbol.toLowerCase(),supports_output_memos:l.supportsMemos,isAvailable:l.isAvailable,action:this.state.action}),a.createElement("label",{className:"left-label"},"Support"),a.createElement("div",null,a.createElement(c(),{content:"gateway.bitspark.support_block"}),a.createElement("br",null),a.createElement("br",null),a.createElement("a",{href:(-1===p.support.indexOf("@")?"":"mailto:")+p.support,rel:"noopener noreferrer"},p.support))),l&&l.symbol?a.createElement(j.k,{asset:l.symbol,fromAccount:d?p.id:this.props.account.get("id"),to:d?this.props.account.get("id"):p.id},(({asset:e,to:t,fromAccount:s})=>a.createElement(j.t,{accountsList:V().List([this.props.account.get("id")]),limit:10,compactView:!0,fullHeight:!0,filter:"transfer",title:a.createElement(c(),{content:"gateway.recent_"+this.state.action}),customFilter:{fields:["to","from","asset_id"],values:{to:t.get("id"),from:s.get("id"),asset_id:e.get("id")}}}))):null):null)}}const pt=(0,i.$)(ct,{listenTo:()=>[A.Z],getProps:()=>({viewSettings:A.Z.getState().viewSettings})}),dt=(0,ue.ZP)("");let ut={};function ht(e,t,s=-1){return-1==s?mt(e,t,1e4):0==s?function(e,t){e.requestChannel||(e.requestChannel=0),e.version||(e.version="1.0"),e.timestamp||(e.timestamp=(new Date).getTime()),e.outerChannel||(e.outerChannel="Bitshares");let s=JSON.stringify(e);ut[s]||(ut[s]=!0,new Promise(((e,a)=>{fetch(t,{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:s}).then((t=>{t.json().then((t=>{delete ut[s],0!==t.code&&(console.log(t),a({code:t.code,message:t.message})),e(t.data)})).catch((e=>{delete ut[s],a({code:-1,message:e.message})}))}))})))}(e,t):mt(e,t,s)}function mt(e,t,s){e.requestChannel||(e.requestChannel=0),e.version||(e.version="1.0"),e.timestamp||(e.timestamp=(new Date).getTime()),e.outerChannel||(e.outerChannel="Bitshares");let a=JSON.stringify(e);if(!ut[a])return ut[a]=!0,Promise.race([new Promise(((e,s)=>{fetch(t,{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:a}).then((t=>{t.json().then((t=>{delete ut[a],0!==t.code&&(console.log(t),s({code:t.code,message:t.message})),e(t.data)})).catch((e=>{delete ut[a],s({code:-1,message:e.message})}))}))})),new Promise((function(e,t){setTimeout((()=>{t({code:-2,message:"Request timeout."})}),s)}))])}const _t=function(e){return dt.has(`gdex_history_address_${e}`)},gt=function({wallet:e,addresses:t}){dt.set(`gdex_history_address_${e}`,t)},wt=function(e){return dt.get(`gdex_history_address_${e}`,[])},yt=function({wallet:e,address:t}){dt.set(`gdex_history_address_last_${e}`,t)},bt=function(e){return dt.get(`gdex_history_address_last_${e}`,"")},Et=(0,ue.ZP)("__gdex__user_"),ft=class{constructor(){this.current_gdex_address_cache_version_string="1",this.day=86400}getUserInfo(e){let t=Et.get(e,null);if(!t)return null;let s=Math.floor((new Date).getTime()/1e3);return Math.abs(t.ctime-s)>this.day?(Et.remove(e),null):t}cacheUserInfo(e,t,s){let a=Et.get(e,{});a!={}&&(a={user_id:t,status:s,ctime:Math.floor((new Date).getTime()/1e3)},Et.set(e,a))}delUserInfo(e){Et.has(e)&&Et.del(e)}getIndexForDepositKey(e,t,s){return[this.current_gdex_address_cache_version_string,e,t,s].reduce((function(e,t){return e.concat("[",t,"]")}),"")}getCachedInputAddress(e,t,s){const a=this.getIndexForDepositKey(e,t,s);let i=Et.get("deposit_keys",{})[a]||null;if(i){if(i.address){let a=Math.floor((new Date).getTime()/1e3);return Math.abs(i.ctime-a)>this.day?(this.clearInputAddress(e,t,s),null):i}return null}}cacheInputAddress(e,t,s,a,i){const n=this.getIndexForDepositKey(e,t,s);let o=Et.get("deposit_keys",{});o[n]={address:a,memo:i,ctime:Math.floor((new Date).getTime()/1e3)},Et.set("deposit_keys",o)}clearInputAddress(e,t,s){const a=this.getIndexForDepositKey(e,t,s);let i=Et.get("deposit_keys",null);i&&i[a]&&(i[a]={address:null,memo:null,ctime:null},Et.set("deposit_keys",i))}};var vt=s(79361),Ct=s.n(vt);class St extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,memo_rule:S().string.isRequired,balance:p.Z.ChainObject,output_supports_memos:S().bool.isRequired};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:bt(e.output_coin_name),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,withdraw_address_selected:bt(e.output_coin_name),memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,below_minumum_withdraw_value:!1,precision_error:!1,memo_error:!1,memo_length_error:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{},withdraw_address_error_code:null,withdraw_address_error_message:null},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.output_coin_name!=this.props.output_coin_name&&this.setState({withdraw_address:bt(e.output_coin_name),withdraw_address_selected:bt(e.output_coin_name)}),e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}_assembleMemo(){let e=this.props.memo_rule,t="";try{if(e)return e.split(";").forEach((e=>{switch(e[0]){case"C":case"B":t+=e.slice(2);break;case"D":t+=this.state.withdraw_address;break;case"S":t+=this.state.memo}})),t.length>100?(this.setState({memo_length_error:!0}),null):(this.setState({memo_length_error:!1}),this.setState({memo_error:!1}),t)}catch(e){console.log(e)}return this.setState({memo_error:!0}),null}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this._assembleMemo()}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_name+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},this._checkBalance)}onSelectChanged(e){let t=wt(this.props.output_coin_symbol)[e];yt({wallet:this.props.output_coin_symbol,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}_validateAddress(e,t=this.props){(function(e,t=-1){return e.address?ht(e,I.M1.BASE+I.M1.CHECK_WITHDRAY_ADDRESS,t):new Promise((e=>e()))})({assetId:t.output_coin_id,assetName:t.output_coin_name,address:e}).then((e=>{this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:e.valid,withdraw_address_error_code:null,withdraw_address_error_message:null})})).catch((e=>{let t=e.message;e.code<0&&(t="System error: please try again later"),this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:null,withdraw_address_error_code:e.code,withdraw_address_error_message:t})}))}_checkPrecision(){let{withdraw_amount:e}=this.state,{output_coin_precision:t}=this.props;"undefined"!==t&&("string"!=typeof e&&(e=e.toString()),e=e.trim(),-1!==e.indexOf(".")&&e.length-e.indexOf(".")-1>t?this.setState({precision_error:!0}):this.setState({precision_error:!1}))}_checkBalance(){let{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a,minWithdrawAmount:i}=this.props;if(!a)return void this.setState({balanceError:!0});if(!e)return;const n=(0,E.cr)(t,s,e,a);if(null!==n){if(this.setState({balanceError:!n}),"string"==typeof t&&(t=parseFloat(String.prototype.replace.call(t,/,/g,""))),"string"==typeof i&&(i=parseFloat(String.prototype.replace.call(i,/,/g,""))),!(t<i))return this.setState({below_minumum_withdraw_value:!1}),this._checkPrecision(),n;this.setState({below_minumum_withdraw_value:!0})}}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(_t(this.props.output_coin_symbol)){let e=wt(this.props.output_coin_symbol);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),gt({wallet:this.props.output_coin_symbol,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),gt({wallet:this.props.output_coin_symbol,addresses:e})}yt({wallet:this.props.output_coin_symbol,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t,fee_asset_id:s}=this.state;let a=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),i=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a});y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),i.getAmount(),e.get("id"),this._assembleMemo(),null,t?t.asset_id:s),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),_t(this.props.output_coin_symbol)){let e=wt(this.props.output_coin_symbol);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),gt({wallet:this.props.output_coin_symbol,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),gt({wallet:this.props.output_coin_symbol,addresses:e})}yt({wallet:this.props.output_coin_symbol,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a,fee_asset_id:i}=this.state;y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),this._assembleMemo(),null,a?a.asset_id:i)}onDropDownList(){_t(this.props.output_coin_symbol)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,memo:t}=this.state,s=wt(this.props.output_coin_symbol),i=null,n=this.props.account.get("balances").toJS(),o=Object.keys(n),r=(this.getWithdrawModalId(),null),l=null,p=null;this.state.options_is_valid&&(l=a.createElement("div",{className:s.length?"blocktrades-options":"blocktrades-disabled-options"},s.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(r=this.state.withdraw_address_error_code?a.createElement("div",{className:"has-error",style:{paddingTop:10}},this.state.withdraw_address_error_code,":"," ",this.state.withdraw_address_error_message):a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_name})),p=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let d=1,u=null;this.props.output_supports_memos&&(u=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:t,tabIndex:d++,onChange:this.onMemoChanged.bind(this)}),this.state.memo_error?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.memo_error"})):null,this.state.memo_length_error?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.memo_length_error"})):null));let{fee_asset_types:h}=this._getAvailableAssets();if(o.length>0){let e=this.props.asset.get("id");if(e){let t=n[e];i=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:n[e]}):0))}else i="No funds"}else i="No funds";const _=this.state.below_minumum_withdraw_value||this.state.memo_error||this.state.memo_length_error||this.state.error||this.state.balanceError||this.state.precision_error;return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:"0"}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:i}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null,this.state.below_minumum_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.minimum_amount",amount:this.props.minWithdrawAmount,symbol:this.props.asset.get("symbol")})):null,this.state.precision_error?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.precision",precision:this.props.output_coin_precision})):null),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:h,tabIndex:d++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,this.props.gateFee?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:this.props.gateFee}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"blocktrades-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"blocktrades-position-options"},l),r),u,a.createElement("div",null,a.createElement(v.Button,{type:"primary",disabled:_,onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),p))}}St=(0,d.Z)(St);const At=(0,i.$)(St,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})});class kt extends a.Component{static propTypes={account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,gateway:S().string,btsCoin:p.Z.ChainAsset,memo_rule:S().string};static defaultProps={autosubscribe:!1};constructor(){super(),this.state={isQrModalVisible:!1,isModalVisible:!1,receive_address:null,isAvailable:!0,qrcode:""},this.deposit_address_cache=new ft,this._copy=this._copy.bind(this),document.addEventListener("copy",this._copy),this.showQrModal=this.showQrModal.bind(this),this.hideQrModal=this.hideQrModal.bind(this),this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}showQrModal(){this.setState({isQrModalVisible:!0})}hideQrModal(){this.setState({isQrModalVisible:!1})}getDepositAddress(){this._getDepositAddress(this.props.user_id,this.props.account.get("name"),this.props.coin,this.props.action)}_getDepositAddress(e,t,s,a){if("deposit"!=a)return;let i=this.deposit_address_cache.getCachedInputAddress(t,s.outerSymbol,s.innerSymbol);if(i&&i!=this.state.receive_address)this.setState({receive_address:i});else{var n=this;(function(e,t=-1){return ht(e,I.M1.BASE+I.M1.GET_DEPOSIT_ADDRESS,t)})({btsAssetId:s.innerAssetId,outAssetId:s.outerAssetId,uid:e,userAccount:t}).then((e=>{if(e.address&&e.address.address){var a={address:e.address.address,memo:e.address.memo};n.deposit_address_cache.cacheInputAddress(t,s.outerSymbol,s.innerSymbol,a.address,a.memo),n.setState({receive_address:a})}else n.setState({receive_address:null})})).catch((e=>{n.setState({receive_address:null}),console.log(e)}))}}UNSAFE_componentWillMount(){this.getDepositAddress()}UNSAFE_componentWillReceiveProps(e){e.user_id===this.props.user_id&&e.action===this.props.action&&e.coin==this.props.coin||this._getDepositAddress(e.user_id,e.account.get("name"),e.coin,e.action)}componentWillUnmount(){document.removeEventListener("copy",this._copy)}getWithdrawModalId(){return"withdraw_asset_"+this.props.issuer_account.get("name")+"_"+this.props.coin.innerSymbol}onWithdraw(){this.showModal()}onShowQrcode(e){this.setState({qrcode:e},(()=>{this.showQrModal()}))}_copy(e){try{this.state.clipboardText?e.clipboardData.setData("text/plain",this.state.clipboardText):e.clipboardData.setData("text/plain",g().translate("gateway.use_copy_button").toUpperCase()),e.preventDefault()}catch(e){console.error(e)}}toClipboard(e){try{this.setState({clipboardText:e},(()=>{document.execCommand("copy")}))}catch(e){console.error(e)}}render(){let e=a.createElement("div",{style:{display:"none",minHeight:150}});if(!this.props.account||!this.props.issuer_account||!this.props.coin)return e;const{coin:t,btsCoin:s}=this.props;if(!s)return e;let i=this.state.receive_address,n=this.state.qrcode,o=this.getWithdrawModalId(),r=null,l="",p="",d=null;var u=t.outerSymbol+":";"deposit"===this.props.action&&(i&&(r=a.createElement("span",null,i.address),l=i.address,i.memo&&(a.createElement("span",null,i.memo),p=i.memo)),u="");let h=null,m=this.props.account.get("balances");return m&&(h=m.toJS()[s.get("id")]),"deposit"===this.props.action?a.createElement("div",{className:"Blocktrades__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.deposit_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_deposit"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},t.outerSymbol)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:t.innerSymbol,replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.your_account"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:t.innerSymbol,replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.deposit_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.deposit_to",asset:t.outerSymbol}),":"),a.createElement("p",{style:{color:"red"}},a.createElement(c(),{content:"gateway.deposit_warning",asset:t.outerSymbol})),p?a.createElement("p",{style:{color:"red"}},a.createElement(c(),{content:"gateway.deposit_warning_memo",asset:t.outerSymbol})):null,a.createElement("div",null,a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.address"}),":"),a.createElement("td",null,r),a.createElement("td",null,a.createElement("div",{style:{width:"125px"},className:"button",onClick:this.toClipboard.bind(this,l)},a.createElement(c(),{content:"transfer.copy_address"}))),a.createElement("td",null,a.createElement("div",{className:"button",onClick:this.onShowQrcode.bind(this,l)},a.createElement(c(),{content:"modal.qrcode.label"})))),p?a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.memo"}),":"),a.createElement("td",null,p),a.createElement("td",null,a.createElement("div",{style:{width:"125px"},className:"button",onClick:this.toClipboard.bind(this,p)},a.createElement(c(),{content:"transfer.copy_memo"}))),a.createElement("td",null,a.createElement("div",{className:"button",onClick:this.onShowQrcode.bind(this,p)},a.createElement(c(),{content:"modal.qrcode.label"})))):null)),a.createElement(v.Modal,{footer:[a.createElement(v.Button,{key:"close",type:"primary",onClick:this.hideQrModal},g().translate("modal.close"))],visible:this.state.isQrModalVisible,onCancel:this.hideQrModal},a.createElement(Nt,{text:n}))))):a.createElement("div",{className:"Blocktrades__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_withdraw"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:t.innerSymbol,replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},t.outerSymbol)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:t.innerSymbol,replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.withdraw_to",asset:this.props.deposit_asset}),":"),a.createElement("div",{className:"button-group",style:{paddingTop:20}},a.createElement("button",{className:"button success",style:{fontSize:"1.3rem"},onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:"gateway.withdraw_now"})," "))),a.createElement(v.Modal,{onCancel:this.hideModal,title:g().translate("gateway.withdraw_coin",{coin:t.outerAssetName,symbol:t.outerSymbol}),footer:null,visible:this.state.isModalVisible},a.createElement(At,{hideModal:this.hideModal,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:t.innerSymbol,output_coin_name:t.outerAssetName,gateFee:t.gateFee,output_coin_id:t.outerAssetId,output_coin_symbol:t.outerSymbol,output_supports_memos:1==t.needMemo,minWithdrawAmount:t.minTransactionAmount,output_coin_precision:t.relationPrecision,memo_prefix:u,memo_rule:this.props.memo_rule,modal_id:o,balance:h})))}}class Nt extends a.Component{constructor(e){super(e)}render(){let e=this.props.text;return a.createElement("div",{className:"small-12",style:{textAlign:"center"}},a.createElement(Ct(),{size:200,value:e}),a.createElement("br",null),a.createElement("br",null),a.createElement("label",{style:{textTransform:"none"}},e))}}const xt=(0,d.Z)(kt);var Tt=s(91684);const Mt={1:"confirming",2:"waiting",3:"transfering",4:"success",5:"fail"},Zt={1:"confirming",2:"auditing",3:"audited",4:"refused",5:"transfering",6:"success",7:"fail"};class It extends a.Component{static propTypes={compactView:S().bool,maxHeight:S().number,fullHeight:S().bool,userId:S().number,assetId:S().number,assetName:S().string,recordType:S().number,userAccount:S().string};static defaultProps={maxHeight:500,fullHeight:!1,pageSize:10};constructor(e){super(),this.state={headerHeight:85,pageNum:0,totalNum:0,nextPageEnabled:!1,allData:{},historyStatusType:1==e.recordType?"deposit_history_status":"withdraw_history_status",historyStatusValue:1==e.recordType?Mt:Zt}}UNSAFE_componentWillMount(){this.getTransactionHistory()}UNSAFE_componentWillReceiveProps(e){this.props.recordType==e.recordType&&this.props.assetId==e.assetId&&this.props.assetName==e.assetName&&this.props.userId==e.userId&&this.props.userAccount==e.userAccount||this._getTransactionHistory(e.userId,e.assetId,e.assetName,e.recordType,e.userAccount,!0)}shouldComponentUpdate(e,t){return!r.Z.are_equal_shallow(this.props.userId,e.userId)||this.state.allData!=t.allData||this.state.pageNum!=t.pageNum}_getTransactionHistory(e,t,s,a,i,n=!1){let o=this.props.pageSize,{pageNum:r,allData:l,historyStatusValue:c,historyStatusType:p}=this.state;1==n?(r=1,l={},p=1==a?"deposit_history_status":"withdraw_history_status",c=1==a?Mt:Zt):r+=1;var d=this;(function(e,t,s=-1){return 1==t?function(e,t=-1){return ht(e,I.M1.BASE+I.M1.DEPOSIT_RECORD_LIST,t)}(e,s):2==t?function(e,t=-1){return ht(e,I.M1.BASE+I.M1.WITHDRAW_RECORD_LIST,t)}(e,s):new Promise((e=>e()))})({uid:e,assetId:t,pageNum:r,pageSize:o,userAccount:i},a).then((e=>{e.records&&(e.records.forEach((e=>{l[e.txid]={txid:e.txid,amount:e.amount,time:e.ctime,unixtime:Date.parse(e.ctime),status:["gateway",p,c[e.status]].join("."),failReason:e.failReason,assetName:s}})),d.setState({totalNum:e.total,nextPageEnabled:e.total>r*o,allData:l,pageNum:r,historyStatusType:p,historyStatusValue:c}))})).catch((()=>{d.setState({totalNum:0,nextPageEnabled:!1,allData:{},pageNum:0})}))}getTransactionHistory(){let{userId:e,assetId:t,assetName:s,recordType:a,userAccount:i}=this.props;this._getTransactionHistory(e,t,s,a,i,!1)}render(){let{assetName:e,compactView:t,style:s,maxHeight:i}=this.props,{headerHeight:n,allData:o}=this.state,r=[];Object.keys(o).forEach((e=>{r.push(o[e])})),r.sort(((e,t)=>t.unixtime-e.unixtime)),s=s||{},s.width="100%",s.height="100%",o.length;let l=r.length?r.map((t=>a.createElement("tr",{key:t.txid},a.createElement("td",{style:{textAlign:"left"},className:"left-td column-hide-tiny"},a.createElement(c(),{content:t.status})),a.createElement("td",{style:{padding:"8px 5px",textAlign:"left",fontSize:14}},a.createElement(c(),{content:"gateway.transaction_history_info",amount:t.amount,assetName:e,txid:t.txid})),a.createElement("td",null,t.time)))):[a.createElement("tr",{key:"no_recent"},a.createElement("td",{colSpan:t?"2":"3"},a.createElement(c(),{content:"operation.no_recent"})))];return l.push(a.createElement("tr",{className:"total-value",key:"total_value"},a.createElement("td",{className:"column-hide-tiny"}),a.createElement("td",null),a.createElement("td",{style:{textAlign:"center"}}," ",this.state.nextPageEnabled?a.createElement("a",{onClick:this.getTransactionHistory.bind(this)},a.createElement(Tt.Z,{name:"chevron-down",title:"icons.chevron_down.transactions",className:"icon-14px"})):null))),a.createElement("div",{className:"recent-transactions no-overflow",style:s},a.createElement("div",{className:"generic-bordered-box"},this.props.dashboard?null:a.createElement("div",{ref:"header"},a.createElement("div",{className:"block-content-header"},a.createElement("span",null,this.props.title?this.props.title:a.createElement(c(),{content:"account.recent"})))),a.createElement("div",{className:"box-content grid-block no-margin",style:this.props.fullHeight?null:{maxHeight:i-n},ref:"transactions"},a.createElement("table",{className:"table"+(t?" compact":"")+(this.props.dashboard?" dashboard-table":"")},a.createElement("thead",null,a.createElement("tr",{key:"history_header"},a.createElement("th",null,a.createElement(c(),{content:"gateway.status"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.info"})),a.createElement("th",null,a.createElement(c(),{content:"gateway.time"})))),a.createElement("tbody",null,l)))))}}const Bt=It;var Dt=s(95891),Ft=s.n(Dt);class Ot extends a.Component{static propTypes={locale:S().string};constructor(e){super(),this.state={locale:e.settings.get("locale","en")}}componentDidMount(){if(this.refs.agreement){let e=this.refs.agreement;Ft().initialize(e)}}componentDidUpdate(){if(this.refs.agreement){let e=this.refs.agreement;Ft().update(e)}}_getAgreement(e){switch(e){case"zh":case"cn":return a.createElement("div",{className:"container",ref:"agreement",style:{height:"500px",overflow:"auto",position:"relative"}},a.createElement("h2",{style:{textAlign:"center"}},"用户服务协议"),a.createElement("p",null,"OBSIDIAN TECHNOLOGY CO. PTE. LTD. 是一家根据新加坡共和国法律成立的公司,GDEX是由该公司运营的比特股网关(以下称“GDEX”或“本网关”),主访问入口为 https://www.52bts.net ,GDEX是一个在比特股平台为用户提供数字资产充提服务(以下称“该服务”或“服务”)的平台。为了本协议表述之方便,公司和该网关在本协议中合称使用“我们”或其他第一人称称呼。使用该服务的自然人或其他主体均为本网关的用户,本协议为表述之便利,以下使用“您”或其他第二人称。我们和您在本协议中合称为“双方”,我们或您单称为“一方”。"),a.createElement("p",null,"重要提示:"),a.createElement("p",null,"我们在此特别提醒您:"),a.createElement("p",null," ","1. 数字资产本身不由任何金融机构或公司或本网关发行;"),a.createElement("p",null," ","2. 数字资产市场是全新的、未经确认的,而且可能不会增长;"),a.createElement("p",null," ","3. 数字资产主要由投机者大量使用,零售和商业市场使用相对较少,数字资产交易存在极高风险,其全天不间断交易,没有涨跌限制,价格容易受庄家、全球政府政策的影响而大幅波动;"),a.createElement("p",null," ","4. 因各国法律、法规和规范性文件的制定或者修改,数字资产交易随时可能被暂停或被禁止。"),a.createElement("p",null,"数字资产交易有极高风险,并不适合绝大部分人士。您了解和理解此投资有可能导致部分损失或全部损失,所以您应该以能承受的损失程度来决定投资的金额。您了解和理解数字资产会产生衍生风险,所以如有任何疑问,建议先寻求理财顾问的协助。此外,除了上述提及过的风险以外,还会有未能预测的风险存在。您应慎重考虑并用清晰的判断能力去评估自己的财政状况及上述各项风险而作出任何买卖数字资产的决定,并承担由此产生的全部损失,我们对此不承担任何责任。"),a.createElement("p",null,"敬告您:"),a.createElement("p",null,"1.您了解比特股是基于区块链的去中心化交易平台,其基础账号服务和交易撮合服务都由比特股平台提供。亦有其它机构或个人在比特股平台上发行资产及/或提供服务。您了解本网关仅作为您向比特股平台充提数字资产的工具。本网关只对自身发行的交易代币资产(名称以GDEX.为前缀)负责,不对比特股上其它机构或个人发行的资产负责,本网关不参与您的任何交易,您应自行谨慎判断确定相关数字资产及/或信息的真实性、合法性和有效性,并自行承担因此产生的责任与损失。"),a.createElement("p",null," ","2. 比特股去中心化交易系统存有风险,包括但不限于软件,硬件和互联网链结的失败,用户账户系统的安全风险等。由于我们不能控制互联网以及比特股平台的可靠性和可用性,我们不会对上述风险造成的用户损失承担任何责任。"),a.createElement("p",null," ","3. 禁止使用本网关从事洗钱、走私、商业贿赂等一切非法交易活动,若发现此类事件,本网关将采取各种可使用之手段,包括但不限于中止提供服务,通知相关权力机关等,我们不承担由此产生的所有责任并保留向相关人士追究责任的权利。"),a.createElement("p",null,"一、总则"),a.createElement("p",null," ","1.1 您在使用本网关提供的服务之前,应仔细阅读本协议,如有不理解之处或其他必要,请咨询专业律师。如您不同意本协议及/或随时对其的修改,请您立即停止使用本网关提供的服务。使用本网关的任何服务即表示您已了解并完全同意本协议各项内容,包括本网关对本协议随时所做的任何修改。"),a.createElement("p",null," ","1.2 使用本网关提供的服务和功能,您将被视为已阅读,理解并:"),a.createElement("p",null," 1.2.1 接受本协议所有条款及条件的约束。"),a.createElement("p",null," ","1.2.2 您确认您已年满21周岁或根据不同的可适用的法律规定的具有可订立合同的法定年龄,并有充分的能力接受这些条款,并订立交易,使用本网关进行数字资产交易。"),a.createElement("p",null," ","1.2.3 您保证交易中涉及到的属于您的数字资产均为合法取得并所有。"),a.createElement("p",null," ","1.2.4 您同意您为您自身的交易或非交易行为承担全部责任和任何收益或亏损。"),a.createElement("p",null," ","1.2.5 您同意遵守任何有关法律的规定,就税务目的而言,包括报告任何交易利润。"),a.createElement("p",null," ","1.2.6 本协议只是就您与我们之间达成的权利义务关系进行约束,而并不涉及本网关用户之间或其他网关和您之间因数字资产交易而产生的法律关系及法律纠纷。"),a.createElement("p",null,"二、协议修订"),a.createElement("p",null,"我们保留不时修订本协议、并以公示的方式进行公告、不再单独通知您的权利,变更后的协议会在本协议首页标注变更时间,一经在公布,立即自动生效。您应不时浏览及关注本协议的更新变更时间及更新内容,如您不同意相关变更,应当立即停止使用本网关服务;您继续使用本网关服务,即表示您接受并同意经修订的协议的约束。"),a.createElement("p",null,"三、服务"),a.createElement("p",null,"本网关只为您提供向比特股平台冲入和提取数字资产的服务,本网关并不作为买家或卖家参与买卖数字资产行为本身;本网关不提供任何国家法定货币充入和提取的相关服务。"),a.createElement("p",null," 3.1 服务内容"),a.createElement("p",null," ","3.1.1 您有权通过本网关向比特股平台冲入或提取数字资产。"),a.createElement("p",null," 3.1.2 本网关承诺为您提供的其他服务。"),a.createElement("p",null," 3.2.服务规则"),a.createElement("p",null," 您承诺遵守下列本网关服务规则:"),a.createElement("p",null," ","3.2.1 您应当遵守法律法规、规章、及政策要求的规定,保证账户中所有数字资产来源的合法性,不得在本网关或利用本网关服务从事非法或其他损害本网关或第三方权益的活动,如发送或接收任何违法、违规、侵犯他人权益的信息,发送或接收传销材料或存在其他危害的信息或言论,未经本网关授权使用或伪造本网关电子邮件题头信息等。"),a.createElement("p",null," ","3.2.2 您在使用本网关服务之前应充分了解比特股账号的使用常识,做好相应账号的备份及密码保存工作,对于比特股账户安全问题造成的损失,本网关不承担任何责任。"),a.createElement("p",null," ","3.2.3 您在使用本网关提供的服务过程中,所产生的应纳税赋,以及一切硬件、软件、服务及其它方面的费用,均由您独自承担。"),a.createElement("p",null," ","3.2.4 您应当遵守本网关不时发布和更新的本协议以及其他服务条款和操作规则,有权随时终止使用本网关提供的服务。"),a.createElement("p",null,"四、本网关的权利和义务"),a.createElement("p",null,"4.1 本网关有权在发现本网关上显示的任何信息存在明显错误时,对信息予以更正。"),a.createElement("p",null,"4.2 本网关保留随时修改、中止或终止本网关服务的权利,本网关行使修改或中止服务的权利不需事先告知您;本网关终止本网关一项或多项服务的,终止自本网关在网关上发布终止公告之日生效。"),a.createElement("p",null," ","4.3 本网关应当采取必要的技术手段和管理措施保障本网关的正常运行。"),a.createElement("p",null,"五、赔偿"),a.createElement("p",null," ","5.1 在任何情况下,我们对您的直接损害的赔偿责任均不会超过您从使用本网关服务产生的为期三( 3)个月的总费用。"),a.createElement("p",null,"六、寻求禁令救济的权利"),a.createElement("p",null,"我们和您均承认普通法对违约或可能违约情况的救济措施是可能是不足以弥补我们遭受的全部损失的,故非违约方有权在违约或可能违约情况下寻求禁令救济以及普通法或衡平法允许的其他所有的补救措施。"),a.createElement("p",null,"七、责任限制与免责"),a.createElement("p",null," ","7.1 您了解并同意,在任何情况下,我们不就以下各事项承担责任:"),a.createElement("p",null," 7.1.1 收入的损失;"),a.createElement("p",null," 7.1.2 交易利润或合同损失;"),a.createElement("p",null," 7.1.3 业务中断"),a.createElement("p",null," 7.1.4 预期可节省的货币的损失;"),a.createElement("p",null," 7.1.5 信息的损失;"),a.createElement("p",null," 7.1.6 机会、商誉或声誉的损失;"),a.createElement("p",null," 7.1.7 数据的损坏或损失;"),a.createElement("p",null," 7.1.8 购买替代产品或服务的成本;"),a.createElement("p",null," ","7.1.9 任何由于侵权(包括过失)、违约或其他任何原因产生的间接的、特殊的或附带性的损失或损害,不论这种损失或损害是否可以为我们合理预见;不论我们是否事先被告知存在此种损 失或损害的可能性。"),a.createElement("p",null," ","7.2 您了解并同意,我们不对因下述任一情况而导致您的任何损害赔偿承担责任:"),a.createElement("p",null," ","7.2.1 我们有合理的理由认为您的具体交易事项可能存在重大违法或违约情形。"),a.createElement("p",null," ","7.2.2 我们有合理的理由认为您在本网关的行为涉嫌违法或不当。"),a.createElement("p",null," ","7.2.3 通过本网关服务购买或获取任何数据、信息或进行交易等行为或替代行为产生的费用及损失。"),a.createElement("p",null," 7.2.4 您对本网关服务的误解。"),a.createElement("p",null," ","7.2.5 任何非因我们的原因而引起的与本网关提供的服务有关的其它损失。"),a.createElement("p",null," ","7.3 我们对由于信息网络设备维护、信息网络连接故障、电脑、通讯或其他系统的故障、电力故障、天气原因、意外事故、罢工、劳动争议、暴乱、起义、骚乱、生产力或生产资料不足、火灾、洪水、风暴、爆炸、战争、银行或其他合作方原因、数字资产市场崩溃、政府行为、 司法或行政机关的命令、其他不在我们可控范围内或我们无能力控制的行为或第三方的原因而造成的不能服务或延迟服务,以及造成的您的损失,我们不承担任何责任。"),a.createElement("p",null," ","7.4 我们不能保证本网关包含的全部信息、程序、文本等完全安全,不受任何病毒、木马等恶意程序的干扰和破坏,故您登陆、使用本网关任何服务或下载及使用该下载的任何程序、信息、数据等均是您个人的决定并自行承担风险及可能产生的损失。"),a.createElement("p",null," ","7.5 我们对本网关中链接的任何第三方网关的任何信息、产品及业务及其他任何形式的不属于我们的主体的内容等不做任何保证和承诺,您如果使用第三方网关提供的任何服务、信息及产品等均为您个人决定且承担由此产生的一切责任。"),a.createElement("p",null," ","7.6 我们对于您使用本网关服务不做任何明示或暗示的保证,包括但不限于本网关提供服务的适用性、没有错误或疏漏、持续性、准确性、可靠性、适用于某一特定用途。同时,我们也不对本网关提供的服务所涉及的技术及信息的有效性、准确性、正确性、可靠性、质量、稳定、完整和及时性作出任何承诺和保证。是否登陆或使用本网关提供的服务是您个人的决定且自行承担风险及可能产生的损失。我们对于数字资产的市场、价值及价格等不做任何明示或暗示的保证,您理解并了解数字资产市场是不稳定的,价格和价值随时会大幅波动或崩盘,交易数字资产是您个人的自由选择及决定且自行承担风险及可能产生的损失。"),a.createElement("p",null," ","7.7 本协议中规定的我们的保证和承诺是由我们就本协议和本网关提供的服务的唯一保证和陈述,并取代任何其他途径和方式产生的保证和承诺,无论是书面的或口头的,明示的或暗示的。所有这些保证和陈述仅仅代表我们自身的承诺和保证,并不保证任何第三方遵守本协议中的保证和承诺。"),a.createElement("p",null," ","7.8 我们并不放弃本协议中未提及的在法律适用的最大范围内我们享有的限制、免除或抵销我们损害赔偿责任的任何权利。"),a.createElement("p",null," ","7.9 使用本网关服务即表示认可我们按照本协议中规定的规则进行的任何操作,产生的任何风险均由您承担。"),a.createElement("p",null,"八、知识产权"),a.createElement("p",null," ","8.1 本网关所包含的全部智力成果包括但不限于网关标志、数据库、网关设计、文字和图表、软件、照片、录像、音乐、声音及其前述组合,软件编译、相关源代码和软件 (包括小应用程序和脚本) 的知识产权权利均归本网关所有。您不得为商业目的复制、更改、拷贝、发送或使用前述任何材料或内容。"),a.createElement("p",null," ","8.2 本网关名称中包含的所有权利 (包括但不限于商誉和商标、标志) 均归公司所有。"),a.createElement("p",null," ","8.3 您接受本协议即视为您主动将其在本网关发表的任何形式的信息的著作权, 包括但不限于:复制权、发行权、出租权、展览权、表演权、放映权、广播权、信息网络传播权、摄制权、改编权、翻译权、汇编权 以及应当由著作权人享有的其他可转让权利无偿独家转让给本网关所有,本网关有权利就任何主体侵权单独提起诉讼并获得全部赔偿。 本协议效力及于您在本网关发布的任何受著作权法保护的作品内容, 无论该内容形成于本协议签订前还是本协议签订后。"),a.createElement("p",null," ","8.4 您在使用本网关服务过程中不得非法使用或处分本网关或他人的知识产权权利。您不得将已发表于本网关的信息以任何形式发布或授权其它网关(及媒体)使用。"),a.createElement("p",null," ","8.5 您使用本网关提供的任何服务均不视为我们向您转让任何知识产权。"),a.createElement("p",null,"九、可分割性"),a.createElement("p",null,"如本协议中的任何条款被任何有管辖权的法院认定为不可执行的,无效的或非法的,并不影响本协议的其余条款的效力。"),a.createElement("p",null,"十、非代理关系"),a.createElement("p",null,"本协议中的任何规定均不可被认为创造了、暗示了或以其他方式将我们视为您的代理人、受托人或其他代表人,本协议有其他规定的除外。"),a.createElement("p",null,"十一、弃权"),a.createElement("p",null,"我们或您任何一方对追究本协议约定的违约责任或其他责任的弃权并不能认定或解释为对其他违约责任的弃权;未行使任何权利或救济不得以任何方式被解释为对该等权利或救济的放弃。"),a.createElement("p",null,"十二、标题"),a.createElement("p",null,"所有标题仅供协议表述方便,并不用于扩大或限制该协议条款的内容或范围。"),a.createElement("p",null,"十三、适用法律"),a.createElement("p",null,"本协议全部内容均为根据新加坡共和国法律订立的合同,其成立、解释、内容及执行均适用新加坡共和国相关法律规定;任何因或与本协议约定的服务有关而产生的索赔或诉讼,都应依照新加坡共和国的法律进行管辖并加以解释和执行。为避免疑义,这一条款明确适用于任何针对我们的侵权索赔。任何针对我们或者是和我们有关的索赔或诉讼的管辖法院或诉讼地均在新加坡共和国。您无条件地获得在新加坡共和国法院进行诉讼和上诉的排他性的管辖权。您也无条件地同意与本协议款有关的争议或问题或产生的任何索赔请求和诉讼的发生地或法院均排他性得在新加坡共和国。不方便法院的原则不适用于根据本服务条款的选择的法院。"),a.createElement("p",null,"十四、协议的生效和解释"),a.createElement("p",null,"14.1 本协议于您点击本网关注册页面的同意注册并完成注册程序、获得本网关账号和密码时生效,对本网关和您均具有约束力。"),a.createElement("p",null,"14.2 本协议的最终解释权归本网关所有。"));default:return a.createElement("div",{className:"container",ref:"agreement",style:{height:"500px",overflow:"auto",position:"relative"}},a.createElement("h2",{style:{textAlign:"center"}},"Service Agreement"),a.createElement("p",null,"OBSIDIAN TECHNOLOGY CO. PTE. LTD. (hereinafter referred to as the 'Company') is a company incorporated under the laws in Singapore Republic, GDEX (hereinafter referred to as 'GDEX' or 'the Gateway') is a cryptocurrency gateway to Bitshares which is operated by the company. The main access point for GDEX is https://www.52bts.net, GDEX is a gateway that provide cryptocurrency deposit and withdraw service (hereinafter referred to as 'the Service') to/from Bitshares. For the convenience of wording in this Agreement, the Company and the Gateway are referred to as 'We' or other applicable forms of first person pronouns in this Agreement. All natural persons or other subjects who use the Service shall be users of the Gateway. For the convenience of wording in this Agreement, the users are referred to as 'You' or any other applicable forms of the second-person pronouns. For the convenience of wording in this Agreement, you and us are collectively referred to as 'both parties', and individually as 'one party'."),a.createElement("p",null,"Important reminder:"),a.createElement("p",null,"We hereby remind you that:"),a.createElement("p",null,"1. The digital assets themselves are not offered by any financial institution, corporation or the Gateway;"),a.createElement("p",null,"2. The digital asset market is new and unconfirmed, and will not necessarily expand;"),a.createElement("p",null,"3. Digital assets are primarily used by speculators, and are used relatively less on retail and commercial markets; digital asset transactions are highly risky, due to the fact that they are traded throughout 24-hour a day without limits on the rise or fall in price, and market makers and global government policies may cause major fluctuations in their prices;"),a.createElement("p",null,"4. Digital asset transactions may be suspended or prohibited at any time due to the enactment or modification of national laws, regulations and regulatory documents. Digital assets trading is highly risky and therefore not suitable for the vast majority of people. You acknowledge and understand that investment in digital assets may result in partial or total loss of your investment and therefore you are advised to decide the amount of your investment on the basis of your loss-bearing capacity. You acknowledge and understand that digital assets may generate derivative risks. Therefore, if you have any doubt, you are advised to seek assistance from a financial adviser first. Furthermore, aside from the above-mentioned risks, there may also be unpredictable risks. Therefore, you are advised to carefully consider and use clear judgment to assess your financial position and the abovementioned risks before making any decisions on buying and selling digital assets; any and all losses arising therefrom will be borne by you and we shall not be held liable in any manner whatsoever."),a.createElement("p",null,"5. You understand that Bitshares is a decentralized exchange based on blockchain, the basic account service and the trade processing service are provided by Bitshares, there are also other institutions or single persons that issue assets and/or provide service on Bitshares. You understand that the Gateway is only used for you to deposit/withdraw cryptocurrency to/from Bitshares. The Gateway only undertake the due obligations for the availability of own issued assets (with 'GDEX.' as prefix of the name), do not undertake the due obligations for the account service and the trade processing service provided by Bitshares, do not undertake the due obligations for availability of the assets issued by other institutions or single persons."," "),a.createElement("p",null,"6. There are risk in both Internet and Bitshares, include but not limit to failure for software, hardware to connect to Internet, security risk for Bitshares accounting system. As the availability and reliability of Internet and Bitshares are not under our control, we do not undertake obligations for the loss caused by the risks mentioned above."),a.createElement("p",null,"7.it is prohibited to use the Gateway for money laundering, smuggling, bribery,if any user are found relevant to these actions, the Gateway will take various actions, include but not limited to terminating the Service to the user, informing relevant authority."))}}render(){let{locale:e}=this.props;return this._getAgreement(e)}}const Rt=(0,i.$)(Ot,{listenTo:()=>[A.Z],getProps:()=>({settings:A.Z.getState().settings})});let Wt=new(s(96807))("-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCH+QtHPKcWxdL25xL4pCuu16tKh6yPx/TFnd/8\ncSt2TC+sPuYsD0h/sy4VKNxhBb7F7U/TLXjMxNcSfPVPjPM3X2LvOlmU9LOEcJGrmlmOOiyO/kws\nyKKOhR4UyZ1NghhfHjuyDBj6V8fCL+xBZTJWsh/X61Z0wLCwOzXcQCsNJwIDAQAB\n-----END PUBLIC KEY-----");class Pt extends a.Component{constructor(e){super();const t=e.viewSettings.get(`${e.provider}Action`,"deposit");this.state={isAgreementVisible:!1,coins:null,activeCoinInfo:this._getActiveCoinInfo(e,{action:t}),action:t,down:!1,isAvailable:!0,user_info:null,isAgree:!1,agreeChecked:!0,agreeNotice:!1,locale:e.viewSettings.get("locale"),intermediate:null,memo_rule:null},this.user_info_cache=new ft,this.showAgreement=this.showAgreement.bind(this),this.hideAgreement=this.hideAgreement.bind(this)}showAgreement(){this.setState({isAgreementVisible:!0})}hideAgreement(){this.setState({isAgreementVisible:!1})}_getActiveCoinInfo(e,t){let s=e.viewSettings.get(`activeCoin_${e.provider}_${t.action}`,null),a=e.viewSettings.get(`activeCoinId_${e.provider}`,null),i=null;i="deposit"==t.action?"BTC":"GDEX.BTC";let n=s||i,o=a||1002;return this._getWithdrawRule(o),{name:n,id:o}}_transformCoin(e){var t=[];try{e.filter((e=>0!=e.status)).forEach((e=>{let s={};1==e.type?(s.innerAssetId=e.assetId,s.innerAssetName=e.assetName,s.innerSymbol=e.assetSymbol,s.outerAssetId=e.relationId,s.outerAssetName=e.relationSymbol,s.outerSymbol=e.relationSymbol,s.status=e.withdrawStatus,s.gateFee=e.withdrawFees,s.needMemo=e.needMemo,s.minTransactionAmount=e.minWithdrawAmount,s.type=e.type,s.relationPrecision=e.relationPrecision):2==e.type?(s.innerAssetId=e.relationId,s.innerAssetName=e.relationSymbol,s.innerSymbol=e.relationSymbol,s.outerAssetId=e.assetId,s.outerAssetName=e.assetName,s.outerSymbol=e.assetSymbol,s.status=e.depositStatus,s.gateFee=e.depositFees,s.needMemo=e.needMemo,s.minTransactionAmount=e.minDepositAmount,s.type=e.type,s.relationPrecision=e.relationPrecision):s=null,s&&t.push(s)}))}catch(e){console.log("Transform coin failed: ",e)}return t}_getUserInfo(e=null,t=null){if(e||(e=this.props.account.get("name")),t||(t=this.state.isAgree),!t)return;var s=function(e,t=-1){return ht(e,I.M1.BASE+I.M1.GET_USER_INFO,t)}({userAccount:e,isAgree:t});let a=this;s.then((function(t){var s=t.user;a.setState({isAgree:!0,user_info:{user_id:s.uid,status:s.status}}),0==s.status&&s.agreeAgreement?a.user_info_cache.cacheUserInfo(e,s.uid,s.status):a.user_info_cache.delUserInfo(e)})),s.catch((e=>{console.log("Exception in fetching user info: "+e)}))}_getCoins(){var e=function(e,t=-1){return e.requestType||(e.requestType=0),e.assetType||(e.assetType=0),e.version||(e.version="1.1"),ht(e,I.M1.BASE+I.M1.ASSET_LIST,t)}({userAccount:this.props.account.get("name")});let t=this;e.then((function(e){let s=t._transformCoin(e.assets);t.setState({isAvailable:!0,coins:s})}),(function(e){console.log("fail"+e)})),e.catch((e=>{console.log(e),t.setState({isAvailable:!1})}))}_checkIsAgree(e=null){e||(e=this.props.account.get("name"));var t=this.user_info_cache.getUserInfo(e);if(t)return void this.setState({user_info:t,isAgree:!0});var s=function(e,t=-1){return ht(e,I.M1.BASE+I.M1.USER_AGREEMENT,t)}({userAccount:e});let a=this;s.then((function(t){t.agree?(a.setState({isAgree:!0}),a._getUserInfo(e,!0)):a.setState({isAgree:!1})}),(function(e){console.log("fail"+e)})),s.catch((e=>{console.log(e),a.setState({isAvailable:!1})}))}UNSAFE_componentWillMount(){this._checkIsAgree(),this._getCoins()}_getWithdrawAssetId(e){let t=1,s="innerSymbol";return"deposit"==this.state.action&&(t=2,s="outerSymbol"),this.state.coins.filter((a=>a.type==t&&a[s]==e))[0].innerAssetId}onSelectCoin(e){let t=this.state.activeCoinInfo;t.name=e.target.value;let s=this._getWithdrawAssetId(e.target.value);t.id=s,this.setState({activeCoinInfo:t}),this._getWithdrawRule(s);let a={};a[`activeCoin_${this.props.provider}_${this.state.action}`]=e.target.value,a[`activeCoinId_${this.props.provider}`]=s,U.Z.changeViewSetting(a)}_getWithdrawRule(e){var t=function(e,t=-1){return ht(e,I.M1.BASE+I.M1.WITHDRAW_RULE,t)}({assetId:e});let s=this;t.then((function(e){var t=Wt.decryptPublic(e.transferToAccount,"utf-8");s.setState({intermediate:t,memo_rule:e.memoRule})}),(function(e){console.log("fail"+e),s.setState({intermediate:null})})),t.catch((e=>{console.log(e),s.setState({intermediate:null})}))}changeAction(e){let t=this._getActiveCoinInfo(this.props,{action:e});this.setState({action:e,activeCoinInfo:t}),U.Z.changeViewSetting({[`${this.props.provider}Action`]:e})}UNSAFE_componentWillReceiveProps(e){this.props.account!=e.account&&this._checkIsAgree(e.account.get("name"))}_updateCheck(){this.setState({agreeChecked:!this.state.agreeChecked}),this.setState({agreeNotice:!1})}_showUserAgreement(){this.showAgreement()}_registerUser(){this.state.agreeChecked?this._getUserInfo(null,!0):this.setState({agreeNotice:!0})}render(){let{account:e}=this.props,{coins:t,activeCoinInfo:s,action:i,isAvailable:n,user_info:o,isAgree:r,agreeChecked:l,agreeNotice:p,intermediate:d,memo_rule:u}=this.state,h="https://t.me/GDEXer",m=a.createElement("div",null,a.createElement("br",null),a.createElement("br",null),a.createElement(c(),{content:"gateway.support_gdex"}),a.createElement("br",null),a.createElement("br",null),a.createElement("p",null,"QQ:"," ",a.createElement("a",{target:"_blank",href:"//shang.qq.com/wpa/qunwpa?idkey=5d192c325146762cf5a9256038fed9faef4fcace21a36882854354dd1d599f11",rel:"noopener noreferrer"},"602573197")),a.createElement("p",null,"Telegram:"," ",a.createElement("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"external-link"},h)));if(!r)return a.createElement("div",null,a.createElement("span",null,a.createElement("input",{type:"checkbox",style:{marginRight:"10px"},checked:l,onChange:this._updateCheck.bind(this)}),a.createElement(c(),{className:"txtlabel",content:"gateway.agreement.hint"}),a.createElement("a",{onClick:this._showUserAgreement.bind(this)}," ",a.createElement(c(),{className:"txtlabel",content:"gateway.agreement.name"}))),p?a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{className:"txtlabel",content:"gateway.agreement.notice"})):null,a.createElement("div",{className:"buttonGroup"},a.createElement("span",{style:{marginTop:"20px"},onClick:this._registerUser.bind(this),className:" button"},a.createElement(c(),{className:"txtlabel",content:"gateway.agreement.register"}))),a.createElement(v.Modal,{footer:[a.createElement(v.Button,{type:"primary",key:"close",onClick:this.hideAgreement},g().translate("modal.close"))],visible:this.state.isAgreementVisible,onCancel:this.hideAgreement},a.createElement("br",null),a.createElement("div",{className:"grid-block vertical"},a.createElement(Rt,{onCancel:this.hideAgreement,locale:this.props.settings.get("locale","en")}))),m);if(!t&&n)return a.createElement(B.Z,null);if(!n)return a.createElement("div",null,a.createElement(c(),{className:"txtlabel cancel",content:"gateway.unavailable",component:"h4"}));var _=null,w=null,y=null;"deposit"==i?(w="outerAssetId",_="outerSymbol",y=2):(w="innerAssetId",_="innerSymbol",y=1),t=t.filter((e=>e.type==y));let b=t.map((e=>a.createElement("option",{value:e[_],key:e[_]},e[_]))).filter((e=>null!==e)),E=t.filter((e=>e[_]==s.name))[0],f=null;return E&&0==E.status?o?0!=o.status&&(f=a.createElement("label",{className:"left-label"},a.createElement(c(),{className:"txtlabel cancel",content:"gateway.frozen",account:e.get("name"),component:"h4"}))):f=a.createElement("label",{className:"left-label"},a.createElement(c(),{className:"txtlabel cancel",content:"gateway.user_unavailable",component:"h4"})):f=a.createElement("label",{className:"left-label"},a.createElement(c(),{className:"txtlabel cancel",content:"gateway.asset_unavailable",asset:s.name,component:"h4"})),a.createElement("div",{style:this.props.style},a.createElement("div",{className:"grid-block no-margin vertical medium-horizontal no-padding"},a.createElement("div",{className:"medium-4"},a.createElement("div",null,a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.choose_"+i}),":"," "),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:s.name},b))),a.createElement("div",{className:"medium-6 medium-offset-1"},a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.gateway_text"}),":"),a.createElement("div",{style:{paddingBottom:15}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{className:"deposit"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"deposit")},a.createElement(c(),{content:"gateway.deposit"}))),a.createElement("li",{className:"withdraw"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"withdraw")},a.createElement(c(),{content:"gateway.withdraw"}))))))),f||a.createElement("div",null,a.createElement("div",{style:{marginBottom:15}},a.createElement(xt,{account:e,coin:E,issuer_account:d,user_id:o.user_id,action:this.state.action,gateway:"gdex",btsCoin:E.innerSymbol,memo_rule:u})),a.createElement(Bt,{userId:o.user_id,userAccount:e.get("name"),assetId:E[w],assetName:E[_],compactView:!0,fullHeight:!0,recordType:"deposit"==i?1:2,filter:"transfer",title:a.createElement(c(),{content:"gateway.recent_"+this.state.action})})),m)}}const qt=(0,i.$)(Pt,{listenTo:()=>[A.Z],getProps:()=>({viewSettings:A.Z.getState().viewSettings,settings:A.Z.getState().settings})}),Ut=(0,ue.ZP)(""),jt=function(e){return Ut.has(`history_address_${e}`)},Lt=function({wallet:e,addresses:t}){Ut.set(`history_address_${e}`,t)},Vt=function(e){return Ut.get(`history_address_${e}`,[])},zt=function({wallet:e,address:t}){Ut.set(`history_address_last_${e}`,t)},Jt=function(e){return Ut.get(`history_address_last_${e}`,"")};var Xt=s(48764).Buffer;class Ht extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_name:S().string.isRequired,output_coin_symbol:S().string.isRequired,output_coin_type:S().string.isRequired,url:S().string,output_wallet_type:S().string,output_supports_memos:S().bool.isRequired,amount_to_withdraw:S().string,balance:p.Z.ChainObject,min_amount:S().number,withdraw_fee:S().number};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:Jt(e.output_wallet_type),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,confirmation_is_valid:!1,withdraw_address_selected:Jt(e.output_wallet_type),memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{}},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._checkMinAmount=this._checkMinAmount.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},(function(){this._checkBalance,this._checkMinAmount()}))}onSelectChanged(e){let t=Vt(this.props.output_wallet_type)[e];zt({wallet:this.props.output_wallet_type,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}_validateAddress(e,t=this.props){(function({url:e=I.GB.BASE,walletType:t,newAddress:s}){return s?fetch(e+"/wallets/"+t+"/check-address",{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:JSON.stringify({address:s})}).then((e=>e.json().then((e=>e.isValid)))).catch((e=>{console.log("validate error:",e)})):new Promise((e=>e()))})({url:t.url,walletType:t.output_wallet_type,newAddress:e}).then((t=>{this.state.withdraw_address===e&&this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:t})}))}_checkBalance(){const{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a}=this.props;if(!a||!e)return;const i=(0,E.cr)(t,s,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}_checkMinAmount(){const{withdraw_amount:e}=this.state;if(null===e)return;const t=e<this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision);return this.setState({minAmountError:t}),t}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(jt(this.props.output_wallet_type)){let e=Vt(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),Lt({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),Lt({wallet:this.props.output_wallet_type,addresses:e})}zt({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t,fee_asset_id:s}=this.state;let a=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),i=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a});y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),i.getAmount(),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new Xt(this.state.memo,"utf-8"):""),null,t?t.asset_id:s),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),jt(this.props.output_wallet_type)){let e=Vt(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),Lt({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),Lt({wallet:this.props.output_wallet_type,addresses:e})}zt({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a,fee_asset_id:i}=this.state;y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new Xt(this.state.memo,"utf-8"):""),null,a?a.asset_id:i)}onDropDownList(){jt(this.props.output_wallet_type)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,memo:t}=this.state,s=Vt(this.props.output_wallet_type),i=null,n=this.props.account.get("balances").toJS(),o=Object.keys(n),l=(this.getWithdrawModalId(),null),p=null,d=null;this.state.options_is_valid&&(p=a.createElement("div",{className:s.length?"rudex-options":"rudex-disabled-options"},s.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(l=a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_type})),d=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let u=1,h=null;this.props.output_supports_memos&&(h=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:t,tabIndex:u++,onChange:this.onMemoChanged.bind(this)})));let{fee_asset_types:_}=this._getAvailableAssets();if(o.length>0){let e=this.props.asset.get("id");if(e){let t=n[e];i=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:n[e]}):0))}else i="No funds"}else i="No funds";let y=r.Z.format_number(this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1),b=this.props.withdraw_fee?r.Z.format_number(this.props.withdraw_fee/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1):null;return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:0}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:i}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null,this.state.minAmountError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.xbtsx.min_amount_error"})):null,a.createElement("p",{className:"no-margin",style:{paddingTop:10}},a.createElement("b",null,a.createElement(c(),{content:"gateway.xbtsx.min_amount",minAmount:y,symbol:this.props.output_coin_symbol})))),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:_,tabIndex:u++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,b?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:b}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"rudex-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",spellcheck:"false",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"rudex-position-options"},p),l),h,a.createElement("div",null,a.createElement(v.Button,{type:"primary",disabled:this.state.error||this.state.balanceError||this.state.minAmountError,onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),d))}}Ht=(0,d.Z)(Ht);const Kt=(0,i.$)(Ht,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})});class Gt extends a.Component{static propTypes={gateway:S().string,deposit_coin_type:S().string,deposit_asset_name:S().string,deposit_account:S().string,receive_coin_type:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,deposit_asset:S().string,deposit_wallet_type:S().string,receive_asset:p.Z.ChainAsset,deprecated_in_favor_of:p.Z.ChainAsset,deprecated_message:S().string,action:S().string,supports_output_memos:S().bool.isRequired,min_amount:S().number,deposit_fee:S().number,withdraw_fee:S().number,asset_precision:S().number};constructor(e){super(e),this.deposit_address_cache=new class{constructor(){this.current_pirateCash_address_cache_version_string="1"}getIndexForDepositKeyInExchange(e,t,s){return[this.current_pirateCash_address_cache_version_string,e,t,s].reduce((function(e,t){return e.concat("[",t,"]")}),"")}getCachedInputAddress(e,t,s,a){let i=X.Z.getWallet();if(!i)return null;i.deposit_keys=i.deposit_keys||{},i.deposit_keys[e]=i.deposit_keys[e]||{};let n=this.getIndexForDepositKeyInExchange(t,s,a);i.deposit_keys[e][n]=i.deposit_keys[e][n]||[];let o=i.deposit_keys[e][n].length;return o?i.deposit_keys[e][n][o-1]:null}cacheInputAddress(e,t,s,a,i,n){let o=X.Z.getWallet();if(!o)return null;o.deposit_keys=o.deposit_keys||{},o.deposit_keys[e]=o.deposit_keys[e]||{};let r=this.getIndexForDepositKeyInExchange(t,s,a);o.deposit_keys[e][r]=o.deposit_keys[e][r]||[],o.deposit_keys[e][r].push({address:i,memo:n}),X.Z._updateWallet()}},this.state={isModalVisible:!1,account_name:null,receive_address:null},this.addDepositAddress=this.addDepositAddress.bind(this),this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}_getDepositObject(){return{walletType:this.props.deposit_wallet_type,inputCoinType:this.props.deposit_coin_type,outputCoinType:this.props.receive_coin_type,outputAddress:this.props.account.get("name"),stateCallback:this.addDepositAddress}}addDepositAddress(e){let t=this.props.account.get("name");this.setState({account_name:t}),this.setState({receive_address:e})}getWithdrawModalId(){return"withdraw_asset_"+this.props.issuer_account.get("name")+"_"+this.props.receive_asset.get("symbol")}onWithdraw(){this.showModal()}render(){let e=a.createElement("div",{style:{display:"none",minHeight:150}});if(!this.props.account||!this.props.issuer_account||!this.props.receive_asset)return e;let t=this.props.account.get("balances");if(this.props.deprecated_in_favor_of){let s=!1,a=t.get(this.props.receive_asset.get("id"));if(a){let e=u.ChainStore.getObject(a);e&&0!=e.get("balance")&&(s=!0)}if(!s)return e}let s=null;if(this.state.account_name===this.props.account.get("name")&&(s=this.state.receive_address),s||this.props.account.get("name"),!s)return function({walletType:e,inputCoinType:t,outputCoinType:s,outputAddress:a,url:i=I.GB.BASE,stateCallback:n}){let o={inputCoinType:t,outputCoinType:s,outputAddress:a},r=JSON.stringify(o);fetch(i+`/wallets/${e}/new-deposit-address`,{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:r}).then((e=>{e.json().then((e=>{let t={address:e.inputAddress||"unknown",memo:e.inputMemo,error:e.error||null};n&&n(t)}),(e=>{n&&n({address:"unknown",memo:null})}))}),(e=>{n&&n({address:"unknown",memo:null})})).catch((e=>{console.log("fetch error:",e)}))}(this._getDepositObject()),e;let i=this.getWithdrawModalId(),n=null,o=null,l="",p="sth:"+s.address+"?vendorField="+this.props.account.get("name");var d=!1;let h;if("STH"===this.props.deposit_asset&&(d=!0),this.props.deposit_account){n=a.createElement("span",null,this.props.deposit_account),l=this.props.deposit_account,h="dex:"+this.props.account.get("name"),o=a.createElement("span",null,h);var m=this.props.deposit_coin_type+":"}else s.memo?(h=s.memo,l=s.address,n=a.createElement("span",null,s.address),o=a.createElement("span",null,s.memo)):(l=s.address,n=a.createElement("span",null,s.address)),m="";let _=r.Z.format_number(this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1);return"deposit"===this.props.action?a.createElement("div",{className:"rudex__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.deposit_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_deposit"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.your_account"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1})))))),h?null:a.createElement("div",{className:"QR"},a.createElement(Ct(),{size:128,value:l}))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.deposit_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.deposit_to",asset:this.props.deposit_asset}),":"),a.createElement("label",{className:"left-label"},a.createElement("b",null,a.createElement(c(),{content:"gateway.xbtsx.min_amount",minAmount:_,symbol:this.props.deposit_coin_type}))),a.createElement("div",{style:{padding:"10px 0",fontSize:"1.1rem"}},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{style:{textTransform:"uppercase"},content:"gateway.address"}),":"," ",a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},a.createElement("b",null,n)))),o?a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{style:{textTransform:"uppercase"},content:"gateway.memo"}),":"," ",a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},a.createElement("b",null," ",o," ")))):null)),a.createElement("div",{className:"button-group",style:{paddingTop:10}},n?a.createElement(W(),{text:l},a.createElement("div",{className:"button"},a.createElement(c(),{content:"gateway.copy_address"}))):null,h?a.createElement(W(),{text:h},a.createElement("div",{className:"button"},a.createElement(c(),{content:"gateway.copy_memo"}))):null,d?a.createElement("a",{className:"button",href:p},a.createElement(c(),{content:"gateway.deposit_from_wallet"})," ",this.props.deposit_asset):null),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_amount",minDeposit:_,coin:this.props.deposit_asset}),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_asset",minDeposit:_,coin:this.props.deposit_asset})))):a.createElement("div",{className:"rudex__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_withdraw"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.withdraw_to",asset:this.props.deposit_asset}),":"),a.createElement("div",{className:"button-group",style:{paddingTop:20}},a.createElement("button",{className:"button success",style:{fontSize:"1.3rem"},onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:"gateway.withdraw_now"})," "))),a.createElement(v.Modal,{onCancel:this.hideModal,title:g().translate("gateway.withdraw_coin",{coin:this.props.deposit_asset_name,symbol:this.props.deposit_asset}),footer:null,visible:this.state.isModalVisible,id:i,overlay:!0},a.createElement(Kt,{hideModal:this.hideModal,showModal:this.showModal,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.props.receive_asset.get("symbol"),output_coin_name:this.props.deposit_asset_name,output_coin_symbol:this.props.deposit_asset,output_coin_type:this.props.deposit_coin_type,output_wallet_type:this.props.deposit_wallet_type,output_supports_memos:this.props.supports_output_memos,memo_prefix:m,modal_id:i,min_amount:this.props.min_amount,withdraw_fee:this.props.withdraw_fee,asset_precision:this.props.asset_precision,balance:this.props.account.get("balances").toJS()[this.props.receive_asset.get("id")]})))}}const Qt=(0,d.Z)(Gt,{keep_updating:!0});class $t extends a.Component{constructor(e){super(),this.state={activeCoin:this._getActiveCoin(e,{action:"deposit"}),action:e.viewSettings.get("pirateCashAction","deposit")}}_getActiveCoin(e,t){let s=e.viewSettings.get(`activeCoin_pirateCash_${t.action}`,null),a=null;return"deposit"==t.action&&(a="PIRATE"),"withdraw"==t.action&&(a="PIRATE"),s||a}UNSAFE_componentWillReceiveProps(e){e.provider!==this.props.provider&&this.setState({activeCoin:this._getActiveCoin(e,this.state.action)})}onSelectCoin(e){this.setState({activeCoin:e.target.value});let t={};t[`activeCoin_pirateCash_${this.state.action}`]=e.target.value,U.Z.changeViewSetting(t)}changeAction(e){let t=this._getActiveCoin(this.props,{action:e});this.setState({action:e,activeCoin:t}),U.Z.changeViewSetting({pirateCashAction:e})}render(){let{coins:e,account:t}=this.props,{activeCoin:s,action:i}=this.state;if(!e.length)return a.createElement(B.Z,null);let n=e.filter((e=>!(!e||!e.symbol)&&("deposit"===i?e.depositAllowed:e.withdrawalAllowed))),o=n.map((e=>{let t="deposit"===i?e.backingCoin.toUpperCase():e.symbol;return a.createElement("option",{value:t,key:e.symbol},t)})).filter((e=>null!==e)),r=n.filter((e=>"deposit"===i?e.backingCoin.toUpperCase()===s:e.symbol===s))[0];r||(r=n[0]);let l="deposit"===this.state.action,p="https://t.me/PirateCash_ENG";return a.createElement("div",{style:this.props.style},a.createElement("div",{className:"grid-block no-margin vertical medium-horizontal no-padding"},a.createElement("div",{className:"medium-4"},a.createElement("div",null,a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.choose_"+i}),":"," "),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:s},o))),a.createElement("div",{className:"medium-6 medium-offset-1"},a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.gateway_text"}),":"),a.createElement("div",{style:{paddingBottom:15}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{className:"deposit"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"deposit")},a.createElement(c(),{content:"gateway.deposit"}))),a.createElement("li",{className:"withdraw"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"withdraw")},a.createElement(c(),{content:"gateway.withdraw"}))))))),r?a.createElement("div",null,a.createElement("div",{style:{marginBottom:15}},a.createElement(Qt,{key:`${r.symbol}`,gateway:r.gatewayWallet,issuer_account:r.issuer,account:t,deposit_asset:r.backingCoin.toUpperCase(),deposit_asset_name:r.name,deposit_coin_type:r.backingCoin.toLowerCase(),deposit_account:r.gatewayWallet,deposit_wallet_type:r.walletType,receive_asset:r.symbol,receive_coin_type:r.symbol.toLowerCase(),supports_output_memos:r.memoSupport,min_amount:r.minAmount,asset_precision:r.precision,action:this.state.action}),a.createElement("label",{className:"left-label"},"Support"),a.createElement("div",null,a.createElement(c(),{content:"gateway.piratecash.support_block"}),a.createElement("br",null),a.createElement("br",null),a.createElement("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"external-link"},p))),r&&r.symbol?a.createElement(j.k,{asset:r.symbol,fromAccount:l?r.issuerId:this.props.account.get("id"),to:l?this.props.account.get("id"):r.issuerId},(({asset:e,to:t,fromAccount:s})=>a.createElement(j.t,{accountsList:V().List([this.props.account.get("id")]),limit:10,compactView:!0,fullHeight:!0,filter:"transfer",title:a.createElement(c(),{content:"gateway.recent_"+this.state.action}),customFilter:{fields:["to","from","asset_id"],values:{to:t.get("id"),from:s.get("id"),asset_id:e.get("id")}}}))):null):null)}}const Yt=(0,i.$)($t,{listenTo:()=>[A.Z],getProps:()=>({viewSettings:A.Z.getState().viewSettings})});var es=s(48764).Buffer;const ts="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAAkCAMAAAD7AIVVAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPSJyIj8+nhxg7wAAAARnQU1BAACxjwv8YQUAAAABc1JHQgCuzhzpAAAC8VBMVEX///8quOOT1e/v+PyF0e2s3/JgYGAAtOIAAADc8Pr6/f4suePz+v1BveWZ1++QkJABAQF+zuwfHx8DAwPNzc11dXX7+/tVwufa2tr+/v/Q7Ph0dHT+///9/f0FBQX8/PxtbW3k5OS5ubnZ2dmlpaXs7OxsbGxUVFTw8PD29vbt+Pyx4fMQEBDl5eWrq6twcHCqqqrf39+vr6+M0+6Bz+wLCwtYw+dixemE0O319fUrKyvN6/cbGxv5+fkJCQkTExPg4ODz8/MRERGPj4+YmJhkZGQgICACAgLU1NRqamp7e3sjIyPp9fs9PT14zevO7PgxuuR/f3/g8vq0tLTX19eEhIS65PT4/P6pqam2trbMzMxNTU3IyMixsbFRUVHt7e3o6OhJSUnLy8vu7u40NDQ2NjZ4eHiUlJSioqJHR0c7u+R+fn5IvuVsyerFxcXa8PojuOP39/e9vb1Kv+bq9vt/z+zd3d3y8vL7/v7b29vKysr0+/3S7fjU7vgZt+IAteF9fX3p6ekhISHB5/VoaGjQ0NBKSkrBwcGCgoL09PQeHh7j4+McHBzn5+cEBAS+vr6tra3R0dFPT084ODhXV1cZGRmVlZX6+voNDQ2Kioq1tbWJ0u6l3PFox+mSkpKDg4P4+PjP7fjPz89SUlJOTk73+/2j2/BcXFwEteJvyerV7/m04vNRweZFRUW14vP9/v+z4fN7zezs9/zZ7/nY2NiN1O6S1e+oqKj+/v634vTl9PqU1u6NjY1ZWVmu3/KgoKCHh4deXl4vLy9dXV0nJydjY2NWVlar3vKIiIhbW1ufn59ycnImJiZnZ2fV1dWdnZ07OzszMzNDQ0N6enpMTEzk9PoUtuKG0e2/5vV2dnbD6PZOwObR7fhmx+ni4uJFvuVyyuo8vORUwefj8/ry+v3J6vef2vCP1O4qKioWFhbH6fZfxOiRkZHd8fqX1+/w+Px2zOs4u+QQteKDz+2ampqZmZm6urq54/TDw8Ojo6OJiYmouvzmAAAGVUlEQVRYw92YZ0AURxSABxtrSTw5kRgDp9KUbotKM6EXRcAoimA7QLHFihJ7iQWN2Gs0GmPXaDTq2XuLii3N9N57M8mv7M57uzezt7sH0eOH7wfsKzM33+7MvDdDyEMjf8U3RIn/49Spwz3ySv0dg/wgYomsjzkOhgV8WEvo64cJhEy5VFtTgnOkQNsRbe+lKNpPTjBrPHnv3qzJR392BhIoqCV2WW8LH/MMepbKhpfR0M/Ghg3wAeueJoQccteR/VJkPTcd72u0o6BpDo5p9b22djUEqSNoyFlfLmYYms2hsuU0WtqyYbPBFiJFPaozUrcgCvKIjrsT7ahmfU3nqBerDCLEPceEtJ4pm6fLptGRYEhqbQ/LM4HNj7gIxN29XZVBhGhmpYQp1hXKuHNx1POUKO9CsHSzuQ7EfVaVQYRm9pA37dYeijEADCZfFa4PGPRApu43BGnvBOTTL5yB+DVuPLK8PD/BMwmHnNxCjvjIbAfZrLTrvxAsr3iDbvUA/TJhQfbVVcmPExmQsc+q3V1ZkB2S5cCmTR9E9TqUiSS9nIGkKLM/UWCmuiQNme/k00ZpuBZNYaDeAS0yhgOZov2jCPKkzpgQpD1j+hy/4XhnII3tc70bWGaj3hmWeiR8lzv2lmcgzoOumxL8bLmEA3ncEMTrCUOQRqztPeiwY+VBSD5YAuUsB+qYW/Rf2Wglzj+O2cr6wXM4cRVIEKQeryqA5IJlDqpX4L2TnmBeaw+8geu9gpA+8FhmdRlIzlDD2agFkoerGN97LNU8SYqJ+1DSJJwDkX1J52/gqSVxGUj2dmobUQWQDWA5B1oCaHmEFCrvX5ZSXBhjsMk2ogY5cD+LnQOpAR1+XXmQkg5geQne+nkly/UG+zCmMU63OGgSZ3UAyajBy0kOJFPlrbGTA+lk727SVtx+JzsDkfOapRzzgfQNRBkJygYpc8BwPTbaG1sK2Bw6hDiAqMWLA3GQYA5keDtR1tV6p33G+qEY8AlXpdo0QBKzsoYV3U3dLOdDYRkkhOswn2i9vk29EJT1BEvF2zlIR2OQV4lxZs8cp/xAStHNuNXpdSJszkqUkdQbuogqF9mNeCD7IsK1cqWrQIbvVLb+RGFF4JrBzQuF9JbGIJ7cUocSa340aKXMgDtHyy16kkqAfG8MsssI5O2DNeXeQ5PMQ+D7LxkorDQCuQtHK9tNqnV5GmLnsdsASg9sUbBRC2SUGy87OJDtKq9bL12Q4Z1qv6V0bk1PL1GUNKG3Lkgk1k+kAvSr8ouA7XZhK40j5lyiBfJdA162cCC7Vd4G9TiQoSM+7Pg+HhZ3RzGdX1kUShJuL7tVcDtNLG1Tk30ZkGQzFZ8O33ZLjLCoavW+zUA8ITniK0Apgu2gRBNk8v0WjU0PrMdv8pXirpAK2utCcVp4sZBkJTEhy5vYQfq0kCR0hjWG6bBViPYC2sP+qieAPKYJ8gAye9NGSLJOdl+IFv80p8fsVGkPPZ2cawdZotXhYZ0dzVRajSAk5zMkwSO7bUU4BZHOGWuEfOkq5F/NEsUuxTogQlZ1gpDsUUjyJVwhxA6mIKdWTShfWNZf3E1jA4xBSs16ICETqhOE1EaQj+n+O98ngYKYfZKFQunGZlWX2cYgzcDVxYMRvLqKqFaQvSPYI/2qkDUUJCDsjQBTqphOXjAVGYJgruswowkj8ZjdKwky5cFUv13lC73uklZQTEEWi3+XCuJuuZi+V30QPCyd4IxYs5jaVA5kV13N6wX58sHBW3eLdhl/BEHGThKVIcIAKTP40RSdItLM9DcEWQ6efN6qPtMagzhKI8PrIPconfNIBvp/kqbK6kBp4/1HfLwsDBIL1xvECASXulyeyNIWF04r14B01wEZh1XL1GwizaWVZEaKdPqxVlhKQuZYDEHw0JSqMsekc7dAVQYZ//9AyLty/bxXVI4LabJ97urz/YkRiPc1cDyvdmSplns1gSiTix6+BpuurfT1ty7oc1Hoi+fSEzCuQerx4g1opEXtwEJSkK+5m4P6Oh91TG+kGRQk03CNBP1Gn3/hehz3K06uo5LWZrlZMJkE4aySCG7UofKUerxtz1D7nw5TrnU4dZz7G/UIql4YwEfNqqUj+yTvxGN67mx6Qj9In4P5LoMh4nc4XVnDrgb2SzzuSx4y+Q93+os9y+9iswAAAABJRU5ErkJggg==",ss={"XBTSX.USD":{ticker:"usd",min:2,max:3e3,id:"1.3.5888"},"XBTSX.RUB":{ticker:"rub",min:100,max:1e5,id:"1.3.5887"},"XBTSX.EUR":{ticker:"eur",min:2,max:3e3,id:"1.3.5889"}},as={payeer:{placeholder:"P000000",fee:"2%",pattern:"[Pp]{1}[0-9]{7,15}"}};class is extends a.Component{static propTypes={XbtsFiat:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired};static defaultProps={XbtsFiat:"1.2.1003283",asset:"XBTSX.USD",provider:"payeer"};constructor(e){super(),this.state={action:e.viewSettings.get("xbtsFiatAction","deposit"),min:2,max:5e3,asset:"XBTSX.USD",provider:"payeer"}}_renderDeposits(){return a.createElement("div",{className:""},a.createElement("p",null,a.createElement("img",{onClick:()=>window.open("https://payeer.com/013901230","_blank"),src:ts})),a.createElement("p",null,a.createElement("a",{rel:"noreferrer",className:"button",target:"_blank",style:{color:"white"},href:"https://xbts.io/deposit/rub?account="+this.props.account.get("name")},"ADD RUBLE"),a.createElement("a",{rel:"noreferrer",className:"button",target:"_blank",style:{color:"white"},href:"https://xbts.io/deposit/usd?account="+this.props.account.get("name")},"ADD USD"),a.createElement("a",{rel:"noreferrer",className:"button",target:"_blank",style:{color:"white"},href:"https://xbts.io/deposit/eur?account="+this.props.account.get("name")},"ADD EURO")))}onSelectCoin(e){this.setState({asset:e.target.value,max:ss[e.target.value].max,provider:"payeer"})}onSelectProvider(e){this.setState({provider:e.currentTarget.value})}_renderWithdrawals(){let{asset:e,max:t,provider:s}=this.state;return a.createElement("div",null,a.createElement("p",null,a.createElement("img",{onClick:()=>window.open("https://payeer.com/013901230","_blank"),src:ts})),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:e},a.createElement("option",{value:"XBTSX.RUB",key:"XBTSX.RUB"},"RUBLE"),a.createElement("option",{value:"XBTSX.USD",key:"XBTSX.USD"},"USD"),a.createElement("option",{value:"XBTSX.EUR",key:"XBTSX.EUR"},"EUR")),a.createElement("div",null,a.createElement("br",null),a.createElement("p",null,a.createElement("input",{type:"radio",id:"payeer",name:"provider",value:"payeer",checked:"payeer"===s,onChange:this.onSelectProvider.bind(this)}),a.createElement("label",{htmlFor:"payeer"},"PAYEER ",e.substr(6,3),"(FEE 2%)"),a.createElement("small",null,"max. ",t),a.createElement("br",null),a.createElement("input",{type:"radio",id:"card",name:"provider",value:"card",checked:!1,disabled:!0,onChange:this.onSelectProvider.bind(this)}),a.createElement("label",{htmlFor:"card"},"Visa/Master ",e.substr(6,3),"(5$ + 5%)"),a.createElement("small",null,"max. ",t)),a.createElement("p",null,a.createElement("small",{style:{color:"pink"}},"Attention! Please check the number and number format before sending! In case of an error, money will not be returned!"))),a.createElement("form",{onSubmit:this._onSubmit.bind(this)},a.createElement("div",{style:{padding:"20px 0"}},a.createElement(c(),{content:"gateway.balance"}),": ",a.createElement("span",{style:{fontWeight:"bold",color:"#4A90E2",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:e}))),a.createElement("label",null,"WALLET ADDRESS",a.createElement("input",{required:!0,id:"iban",type:"text",placeholder:as[s].placeholder})),a.createElement("label",null,a.createElement(c(),{content:"exchange.quantity"}),a.createElement("input",{required:!0,id:"amount",type:"number",min:this.state.min,max:this.state.max})),a.createElement("button",{className:"button",type:"submit"},a.createElement(c(),{content:"gateway.withdraw_now"}))))}changeAction(e){this.setState({action:e}),U.Z.changeViewSetting({xbtsFiatAction:e})}_onSubmit(e){e.preventDefault();let{min:t,max:s,provider:a}=this.state,{asset:i,account:n,XbtsFiat:o}=this.props,l=parseInt(this.refs.amount.value,10),c=this.refs.iban.value;new RegExp("[Pp]{1}[0-9]{7,15}").test(c);let p=ss[this.state.asset].id,d=r.Z.get_asset_precision(i.get("precision"));l<t||l>s||y.Z.transfer(n.get("id"),o.get("id"),parseInt(l*d,10),p,new es(a+":"+ss[this.state.asset].ticker+":"+c.toUpperCase().trim(),"utf-8"),null,p).then((()=>{pe.Z.unlisten(this.onTrxIncluded),pe.Z.listen(this.onTrxIncluded)}))}onTrxIncluded(e){(e.included&&e.broadcasted_transaction||e.closed)&&(pe.Z.unlisten(this.onTrxIncluded),pe.Z.reset())}openUrl(e){window.open(e)}render(){let{action:e}=this.state;return a.createElement("div",{className:"XbtsFiat"},a.createElement("div",{className:"content-block"},a.createElement("div",{style:{paddingBottom:15}},a.createElement("div",{style:{marginRight:10},onClick:this.changeAction.bind(this,"deposit"),className:Qe()("button","deposit"===e?"active":"outline")},a.createElement(c(),{content:"gateway.deposit"})),a.createElement("div",{onClick:this.changeAction.bind(this,"withdraw"),className:Qe()("button","withdraw"===e?"active":"outline")},a.createElement(c(),{content:"gateway.withdraw"}))),"deposit"===e?this._renderDeposits():this._renderWithdrawals()))}}const ns=(0,d.Z)(is),os=(0,ue.ZP)(""),rs=function(e){return os.has(`history_address_${e}`)},ls=function({wallet:e,addresses:t}){os.set(`history_address_${e}`,t)},cs=function(e){return os.get(`history_address_${e}`,[])},ps=function({wallet:e,address:t}){os.set(`history_address_last_${e}`,t)},ds=function(e){return os.get(`history_address_last_${e}`,"")};var us=s(48764).Buffer;class hs extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,issuer:p.Z.ChainAccount.isRequired,asset:p.Z.ChainAsset.isRequired,output_coin_name:S().string.isRequired,output_coin_symbol:S().string.isRequired,output_coin_type:S().string.isRequired,url:S().string,output_wallet_type:S().string,output_supports_memos:S().bool.isRequired,amount_to_withdraw:S().string,balance:p.Z.ChainObject,min_amount:S().number,withdraw_fee:S().number};constructor(e){super(e),this.state={isConfirmationModalVisible:!1,withdraw_amount:this.props.amount_to_withdraw,withdraw_address:ds(e.output_wallet_type),withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null,options_is_valid:!1,confirmation_is_valid:!1,withdraw_address_selected:ds(e.output_wallet_type),memo:"",withdraw_address_first:!0,empty_withdraw_value:!1,from_account:e.account,fee_asset_id:u.ChainStore.assets_by_symbol.get(e.fee_asset_symbol)||"1.3.0",feeStatus:{}},this._validateAddress(this.state.withdraw_address,e),this._checkBalance=this._checkBalance.bind(this),this._checkMinAmount=this._checkMinAmount.bind(this),this._updateFee=(0,h.Z)(this._updateFee.bind(this),250),this.showConfirmationModal=this.showConfirmationModal.bind(this),this.hideConfirmationModal=this.hideConfirmationModal.bind(this)}UNSAFE_componentWillMount(){this._updateFee(),this._checkFeeStatus()}componentWillUnmount(){this.unMounted=!0}UNSAFE_componentWillReceiveProps(e){e.account!==this.state.from_account&&e.account!==this.props.account&&this.setState({from_account:e.account,feeStatus:{},feeAmount:new f.xR({amount:0})},(()=>{this._updateFee(),this._checkFeeStatus()}))}showConfirmationModal(){this.setState({isConfirmationModalVisible:!0})}hideConfirmationModal(){this.setState({isConfirmationModalVisible:!1})}_updateFee(e=this.state){let{fee_asset_id:t,from_account:s}=e;const{fee_asset_types:a}=this._getAvailableAssets(e);if(1===a.length&&a[0]!==t&&(t=a[0]),!s)return null;(0,E.rX)({accountID:s.get("id"),feeID:t,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}).then((({fee:e,hasBalance:t,hasPoolBalance:s})=>{this.unMounted||this.setState({feeAmount:e,hasBalance:t,hasPoolBalance:s,error:!t||!s},this._checkBalance)}))}_checkFeeStatus(e=this.state){let t=e.from_account;if(!t)return;const{fee_asset_types:s}=this._getAvailableAssets(e);let a={},i=[];s.forEach((s=>{i.push((0,E.rX)({accountID:t.get("id"),feeID:s,options:["price_per_kbyte"],data:{type:"memo",content:this.props.output_coin_type+":"+e.withdraw_address+(e.memo?":"+e.memo:"")}}))})),Promise.all(i).then((t=>{s.forEach(((e,s)=>{a[e]=t[s]})),r.Z.are_equal_shallow(e.feeStatus,a)||this.setState({feeStatus:a}),this._checkBalance()})).catch((e=>{console.error(e)}))}onMemoChanged(e){this.setState({memo:e.target.value},this._updateFee)}onWithdrawAmountChange({amount:e}){this.setState({withdraw_amount:e,empty_withdraw_value:void 0!==e&&!parseFloat(e)},(function(){this._checkBalance,this._checkMinAmount()}))}onSelectChanged(e){let t=cs(this.props.output_wallet_type)[e];ps({wallet:this.props.output_wallet_type,address:t}),this.setState({withdraw_address_selected:t,options_is_valid:!1,withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}onWithdrawAddressChanged(e){let t=e.target.value.trim();this.setState({withdraw_address:t,withdraw_address_check_in_progress:!0,withdraw_address_selected:t,withdraw_address_is_valid:null},this._updateFee),this._validateAddress(t)}_validateAddress(e,t=this.props){(function({url:e=I.V9.BASE,walletType:t,newAddress:s}){return s?fetch(e+"/wallets/"+t+"/check-address",{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:JSON.stringify({address:s})}).then((e=>e.json().then((e=>e.isValid)))).catch((e=>{console.log("validate error:",e)})):new Promise((e=>e()))})({url:t.url,walletType:t.output_wallet_type,newAddress:e}).then((t=>{this.state.withdraw_address===e&&this.setState({withdraw_address_check_in_progress:!1,withdraw_address_is_valid:t})}))}_checkBalance(){const{feeAmount:e,withdraw_amount:t}=this.state,{asset:s,balance:a}=this.props;if(!a||!e)return;const i=(0,E.cr)(t,s,e,a);return null!==i?(this.setState({balanceError:!i}),i):void 0}_checkMinAmount(){const{withdraw_amount:e}=this.state;if(null===e)return;const t=e<this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision);return this.setState({minAmountError:t}),t}onSubmit(){if(!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&null!==this.state.withdraw_amount)if(this.state.withdraw_address_is_valid)if(parseFloat(this.state.withdraw_amount)>0){if(rs(this.props.output_wallet_type)){let e=cs(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),ls({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),ls({wallet:this.props.output_wallet_type,addresses:e})}ps({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset;const{feeAmount:t,fee_asset_id:s}=this.state;let a=parseFloat(String.prototype.replace.call(this.state.withdraw_amount,/,/g,"")),i=new f.xR({asset_id:e.get("id"),precision:e.get("precision"),real:a});y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),i.getAmount(),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new us(this.state.memo,"utf-8"):""),null,t?t.asset_id:s),this.setState({empty_withdraw_value:!1})}else this.setState({empty_withdraw_value:!0});else this.showConfirmationModal()}onSubmitConfirmation(){if(this.hideConfirmationModal(),rs(this.props.output_wallet_type)){let e=cs(this.props.output_wallet_type);-1==e.indexOf(this.state.withdraw_address)&&(e.push(this.state.withdraw_address),ls({wallet:this.props.output_wallet_type,addresses:e}))}else{let e=[];e.push(this.state.withdraw_address),ls({wallet:this.props.output_wallet_type,addresses:e})}ps({wallet:this.props.output_wallet_type,address:this.state.withdraw_address});let e=this.props.asset,t=r.Z.get_asset_precision(e.get("precision")),s=String.prototype.replace.call(this.state.withdraw_amount,/,/g,"");const{feeAmount:a,fee_asset_id:i}=this.state;y.Z.transfer(this.props.account.get("id"),this.props.issuer.get("id"),parseInt(s*t,10),e.get("id"),this.props.output_coin_type+":"+this.state.withdraw_address+(this.state.memo?":"+new us(this.state.memo,"utf-8"):""),null,a?a.asset_id:i)}onDropDownList(){rs(this.props.output_wallet_type)&&(!1===this.state.options_is_valid&&(this.setState({options_is_valid:!0}),this.setState({withdraw_address_first:!1})),!0===this.state.options_is_valid&&this.setState({options_is_valid:!1}))}getWithdrawModalId(){return"confirmation"}onAccountBalance(){const{feeAmount:e}=this.state;if(Object.keys(this.props.account.get("balances").toJS()).includes(this.props.asset.get("id"))){let t=new f.xR({amount:this.props.balance.get("balance"),asset_id:this.props.asset.get("id"),precision:this.props.asset.get("precision")});t.asset_id===e.asset_id&&t.minus(e),this.setState({withdraw_amount:t.getAmount({real:!0}),empty_withdraw_value:!1},this._checkBalance)}}setNestedRef(e){this.nestedRef=e}onFeeChanged({asset:e}){this.setState({fee_asset_id:e.get("id")},this._updateFee)}_getAvailableAssets(e=this.state){const{from_account:t,feeStatus:s}=e;let a=[];if(!t||!t.get("balances"))return{fee_asset_types:a};let i=e.from_account.get("balances").toJS();a=Object.keys(i).sort(r.Z.sortID);for(let e in i){let t=u.ChainStore.getObject(e),s=u.ChainStore.getObject(i[e]);if(s&&0===s.get("balance")&&-1!==a.indexOf(e)&&a.splice(a.indexOf(e),1),t){let s,i=!1;try{s=new f.tA({base:new f.xR(t.getIn(["options","core_exchange_rate","base"]).toJS()),quote:new f.xR(t.getIn(["options","core_exchange_rate","quote"]).toJS())}),i=s.isValid()}catch(e){i=!1}"1.3.0"===t.get("id")||i||a.splice(a.indexOf(e),1)}}return a=a.filter((e=>{return(void 0===s[t=e]||s[t]&&s[t].hasPoolBalance)&&function(e){return void 0===s[e]||s[e]&&s[e].hasBalance}(e);var t})),{fee_asset_types:a}}render(){let{withdraw_address_selected:e,memo:t}=this.state,s=cs(this.props.output_wallet_type),i=null,n=this.props.account.get("balances").toJS(),o=Object.keys(n),l=(this.getWithdrawModalId(),null),p=null,d=null;this.state.options_is_valid&&(p=a.createElement("div",{className:s.length?"rudex-options":"rudex-disabled-options"},s.map((function(e,t){return a.createElement("a",{key:t,onClick:this.onSelectChanged.bind(this,t)},e)}),this))),!this.state.withdraw_address_check_in_progress&&this.state.withdraw_address&&this.state.withdraw_address.length&&(this.state.withdraw_address_is_valid||(l=a.createElement("div",{className:"has-error",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.valid_address",coin_type:this.props.output_coin_type})),d=a.createElement(v.Modal,{closable:!1,footer:[a.createElement(v.Button,{key:"submit",type:"primary",onClick:this.onSubmitConfirmation.bind(this)},g().translate("modal.confirmation.accept")),a.createElement(v.Button,{key:"cancel",style:{marginLeft:"8px"},onClick:this.hideConfirmationModal},g().translate("modal.confirmation.cancel"))],visible:this.state.isConfirmationModalVisible,onCancel:this.hideConfirmationModal},a.createElement("label",null,a.createElement(c(),{content:"modal.confirmation.title"})))));let u=1,h=null;this.props.output_supports_memos&&(h=a.createElement("div",{className:"content-block"},a.createElement("label",null,a.createElement(c(),{component:"span",content:"transfer.memo"})),a.createElement("textarea",{rows:"3",value:t,tabIndex:u++,onChange:this.onMemoChanged.bind(this)})));let{fee_asset_types:_}=this._getAvailableAssets();if(o.length>0){let e=this.props.asset.get("id");if(e){let t=n[e];i=a.createElement("span",{style:{borderBottom:"#A09F9F 1px dotted",cursor:"pointer"}},a.createElement(c(),{component:"span",content:"transfer.available"})," : ",a.createElement("span",{className:"set-cursor",onClick:this.onAccountBalance.bind(this)},t?a.createElement(m.Z,{balance:n[e]}):0))}else i="No funds"}else i="No funds";let y=r.Z.format_number(this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1),b=this.props.withdraw_fee?r.Z.format_number(this.props.withdraw_fee/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1):null;return a.createElement("form",{className:"grid-block vertical full-width-content",style:{paddingTop:0}},a.createElement("div",{className:"grid-container"},a.createElement("div",{className:"content-block"},a.createElement(w.Z,{label:"modal.withdraw.amount",amount:this.state.withdraw_amount,asset:this.props.asset.get("id"),assets:[this.props.asset.get("id")],placeholder:"0.0",onChange:this.onWithdrawAmountChange.bind(this),display_balance:i}),this.state.empty_withdraw_value?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.valid"})):null,this.state.balanceError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.insufficient"})):null,this.state.minAmountError?a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"gateway.xbtsx.min_amount_error"})):null,a.createElement("p",{className:"no-margin",style:{paddingTop:10}},a.createElement("b",null,a.createElement(c(),{content:"gateway.xbtsx.min_amount",minAmount:y,symbol:this.props.output_coin_symbol})))),this.state.feeAmount?a.createElement("div",{className:"content-block gate_fee"},a.createElement(w.Z,{refCallback:this.setNestedRef.bind(this),disabled:!0,amount:this.state.feeAmount.getAmount({real:!0}),onChange:this.onFeeChanged.bind(this),asset:this.state.feeAmount.asset_id,assets:_,tabIndex:u++}),this.state.hasBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noFeeBalance"})),this.state.hasPoolBalance?null:a.createElement("p",{className:"has-error no-margin",style:{paddingTop:10}},a.createElement(c(),{content:"transfer.errors.noPoolBalance"}))):null,b?a.createElement("div",{className:"amount-selector right-selector",style:{paddingBottom:20}},a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.fee"})),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{type:"text",disabled:!0,value:b}),a.createElement("div",{className:"form-label select floating-dropdown"},a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.output_coin_symbol))))):null,a.createElement("div",{className:"content-block"},a.createElement("label",{className:"left-label"},a.createElement(c(),{component:"span",content:"modal.withdraw.address"})),a.createElement("div",{className:"rudex-select-dropdown"},a.createElement("div",{className:"inline-label"},a.createElement("input",{type:"text",spellcheck:"false",value:e,tabIndex:"4",onChange:this.onWithdrawAddressChanged.bind(this),autoComplete:"off"}),a.createElement("span",{onClick:this.onDropDownList.bind(this)},"▼"))),a.createElement("div",{className:"rudex-position-options"},p),l),h,a.createElement("div",null,a.createElement(v.Button,{type:"primary",disabled:this.state.error||this.state.balanceError||this.state.minAmountError,onClick:this.onSubmit.bind(this)},g().translate("modal.withdraw.submit")),a.createElement(v.Button,{onClick:this.props.hideModal,style:{marginLeft:"8px"}},g().translate("account.perm.cancel"))),d))}}hs=(0,d.Z)(hs);const ms=(0,i.$)(hs,{listenTo:()=>[A.Z],getProps:e=>({fee_asset_symbol:A.Z.getState().settings.get("fee_asset")})});class _s extends a.Component{static propTypes={gateway:S().string,deposit_coin_type:S().string,deposit_asset_name:S().string,deposit_account:S().string,receive_coin_type:S().string,account:p.Z.ChainAccount,issuer_account:p.Z.ChainAccount,deposit_asset:S().string,deposit_wallet_type:S().string,receive_asset:p.Z.ChainAsset,deprecated_in_favor_of:p.Z.ChainAsset,deprecated_message:S().string,action:S().string,supports_output_memos:S().bool.isRequired,min_amount:S().number,deposit_fee:S().number,withdraw_fee:S().number,asset_precision:S().number};constructor(e){super(e),this.deposit_address_cache=new class{constructor(){this.current_xbtsx_address_cache_version_string="1"}getIndexForDepositKeyInExchange(e,t,s){return[this.current_xbtsx_address_cache_version_string,e,t,s].reduce((function(e,t){return e.concat("[",t,"]")}),"")}getCachedInputAddress(e,t,s,a){let i=X.Z.getWallet();if(!i)return null;i.deposit_keys=i.deposit_keys||{},i.deposit_keys[e]=i.deposit_keys[e]||{};let n=this.getIndexForDepositKeyInExchange(t,s,a);i.deposit_keys[e][n]=i.deposit_keys[e][n]||[];let o=i.deposit_keys[e][n].length;return o?i.deposit_keys[e][n][o-1]:null}cacheInputAddress(e,t,s,a,i,n){let o=X.Z.getWallet();if(!o)return null;o.deposit_keys=o.deposit_keys||{},o.deposit_keys[e]=o.deposit_keys[e]||{};let r=this.getIndexForDepositKeyInExchange(t,s,a);o.deposit_keys[e][r]=o.deposit_keys[e][r]||[],o.deposit_keys[e][r].push({address:i,memo:n}),X.Z._updateWallet()}},this.state={isModalVisible:!1,account_name:null,receive_address:null},this.addDepositAddress=this.addDepositAddress.bind(this),this.showModal=this.showModal.bind(this),this.hideModal=this.hideModal.bind(this)}showModal(){this.setState({isModalVisible:!0})}hideModal(){this.setState({isModalVisible:!1})}_getDepositObject(){return{walletType:this.props.deposit_wallet_type,inputCoinType:this.props.deposit_coin_type,outputCoinType:this.props.receive_coin_type,outputAddress:this.props.account.get("name"),stateCallback:this.addDepositAddress}}addDepositAddress(e){let t=this.props.account.get("name");this.setState({account_name:t}),this.setState({receive_address:e})}getWithdrawModalId(){return"withdraw_asset_"+this.props.issuer_account.get("name")+"_"+this.props.receive_asset.get("symbol")}onWithdraw(){this.showModal()}render(){let e=a.createElement("div",{style:{display:"none",minHeight:150}});if(!this.props.account||!this.props.issuer_account||!this.props.receive_asset)return e;let t=this.props.account.get("balances");if(this.props.deprecated_in_favor_of){let s=!1,a=t.get(this.props.receive_asset.get("id"));if(a){let e=u.ChainStore.getObject(a);e&&0!=e.get("balance")&&(s=!0)}if(!s)return e}let s=null;if(this.state.account_name===this.props.account.get("name")&&(s=this.state.receive_address),s||this.props.account.get("name"),!s)return function({walletType:e,inputCoinType:t,outputCoinType:s,outputAddress:a,url:i=I.V9.BASE,stateCallback:n}){let o={inputCoinType:t,outputCoinType:s,outputAddress:a},r=JSON.stringify(o);fetch(i+`/wallets/${e}/new-deposit-address`,{method:"post",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:r}).then((e=>{e.json().then((e=>{let t={address:e.inputAddress||"unknown",memo:e.inputMemo,error:e.error||null};n&&n(t)}),(e=>{n&&n({address:"unknown",memo:null})}))}),(e=>{n&&n({address:"unknown",memo:null})})).catch((e=>{console.log("fetch error:",e)}))}(this._getDepositObject()),e;let i=this.getWithdrawModalId(),n=null,o=null,l="",p="sth:"+s.address+"?vendorField="+this.props.account.get("name");var d=!1;let h;if("STH"===this.props.deposit_asset&&(d=!0),this.props.deposit_account){n=a.createElement("span",null,this.props.deposit_account),l=this.props.deposit_account,h="dex:"+this.props.account.get("name"),o=a.createElement("span",null,h);var m=this.props.deposit_coin_type+":"}else s.memo?(h=s.memo,l=s.address,n=a.createElement("span",null,s.address),o=a.createElement("span",null,s.memo)):(l=s.address,n=a.createElement("span",null,s.address)),m="";let _=r.Z.format_number(this.props.min_amount/r.Z.get_asset_precision(this.props.asset_precision),this.props.asset_precision,!1);return"deposit"===this.props.action?a.createElement("div",{className:"rudex__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.deposit_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_deposit"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.your_account"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1})))))),h?null:a.createElement("div",{className:"QR"},a.createElement(Ct(),{size:128,value:l}))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.deposit_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.deposit_to",asset:this.props.deposit_asset}),":"),a.createElement("label",{className:"left-label"},a.createElement("b",null,a.createElement(c(),{content:"gateway.xbtsx.min_amount",minAmount:_,symbol:this.props.deposit_coin_type}))),a.createElement("div",{style:{padding:"10px 0",fontSize:"1.1rem"}},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{style:{textTransform:"uppercase"},content:"gateway.address"}),":"," ",a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},a.createElement("b",null,n)))),o?a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{style:{textTransform:"uppercase"},content:"gateway.memo"}),":"," ",a.createElement(O,{replaceCopyText:g().translate("gateway.use_copy_button")},a.createElement("b",null," ",o," ")))):null)),a.createElement("div",{className:"button-group",style:{paddingTop:10}},n?a.createElement(W(),{text:l},a.createElement("div",{className:"button"},a.createElement(c(),{content:"gateway.copy_address"}))):null,h?a.createElement(W(),{text:h},a.createElement("div",{className:"button"},a.createElement(c(),{content:"gateway.copy_memo"}))):null,d?a.createElement("a",{className:"button",href:p},a.createElement(c(),{content:"gateway.deposit_from_wallet"})," ",this.props.deposit_asset):null),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_amount",minDeposit:_,coin:this.props.deposit_asset}),a.createElement(c(),{className:"has-error fz_14",component:"p",content:"gateway.min_deposit_warning_asset",minDeposit:_,coin:this.props.deposit_asset})))):a.createElement("div",{className:"rudex__gateway grid-block no-padding no-margin"},a.createElement("div",{className:"small-12 medium-5"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_summary"}),a.createElement("div",{className:"small-12 medium-10"},a.createElement("table",{className:"table"},a.createElement("tbody",null,a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_withdraw"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(M.Z,{name:this.props.receive_asset.get("symbol"),replace:!1}))),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.asset_to_receive"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},this.props.deposit_asset)),a.createElement("tr",null,a.createElement(c(),{component:"td",content:"gateway.intermediate"}),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(Z.Z,{account:this.props.issuer_account.get("id")}))),a.createElement("tr",null,a.createElement("td",null,a.createElement(c(),{content:"gateway.balance"}),":"),a.createElement("td",{style:{fontWeight:"bold",color:"#049cce",textAlign:"right"}},a.createElement(T.Z,{account:this.props.account.get("name"),asset:this.props.receive_asset.get("symbol"),replace:!1}))))))),a.createElement("div",{className:"small-12 medium-7"},a.createElement(c(),{component:"h4",content:"gateway.withdraw_inst"}),a.createElement("label",{className:"left-label"},a.createElement(c(),{content:"gateway.withdraw_to",asset:this.props.deposit_asset}),":"),a.createElement("div",{className:"button-group",style:{paddingTop:20}},a.createElement("button",{className:"button success",style:{fontSize:"1.3rem"},onClick:this.onWithdraw.bind(this)},a.createElement(c(),{content:"gateway.withdraw_now"})," "))),a.createElement(v.Modal,{onCancel:this.hideModal,title:g().translate("gateway.withdraw_coin",{coin:this.props.deposit_asset_name,symbol:this.props.deposit_asset}),footer:null,visible:this.state.isModalVisible,id:i,overlay:!0},a.createElement(ms,{hideModal:this.hideModal,showModal:this.showModal,account:this.props.account.get("name"),issuer:this.props.issuer_account.get("name"),asset:this.props.receive_asset.get("symbol"),output_coin_name:this.props.deposit_asset_name,output_coin_symbol:this.props.deposit_asset,output_coin_type:this.props.deposit_coin_type,output_wallet_type:this.props.deposit_wallet_type,output_supports_memos:this.props.supports_output_memos,memo_prefix:m,modal_id:i,min_amount:this.props.min_amount,withdraw_fee:this.props.withdraw_fee,asset_precision:this.props.asset_precision,balance:this.props.account.get("balances").toJS()[this.props.receive_asset.get("id")]})))}}const gs=(0,d.Z)(_s,{keep_updating:!0});class ws extends a.Component{constructor(e){super(),this.state={activeCoin:this._getActiveCoin(e,{action:"deposit"}),action:e.viewSettings.get("xbtsxAction","deposit")}}_getActiveCoin(e,t){let s=e.viewSettings.get(`activeCoin_xbtsx_${t.action}`,null),a=null;return"deposit"==t.action&&(a="PPY"),"withdraw"==t.action&&(a="PPY"),s||a}UNSAFE_componentWillReceiveProps(e){e.provider!==this.props.provider&&this.setState({activeCoin:this._getActiveCoin(e,this.state.action)})}onSelectCoin(e){this.setState({activeCoin:e.target.value});let t={};t[`activeCoin_xbtsx_${this.state.action}`]=e.target.value,U.Z.changeViewSetting(t)}changeAction(e){let t=this._getActiveCoin(this.props,{action:e});this.setState({action:e,activeCoin:t}),U.Z.changeViewSetting({xbtsxAction:e})}render(){let{coins:e,account:t}=this.props,{activeCoin:s,action:i}=this.state;if(!e.length)return a.createElement(B.Z,null);let n=e.filter((e=>!(!e||!e.symbol)&&("deposit"===i?e.depositAllowed:e.withdrawalAllowed))),o=n.map((e=>{let t="deposit"===i?e.backingCoin.toUpperCase():e.symbol;return a.createElement("option",{value:t,key:e.symbol},t)})).filter((e=>null!==e)),r=n.filter((e=>"deposit"===i?e.backingCoin.toUpperCase()===s:e.symbol===s))[0];r||(r=n[0]);let l="deposit"===this.state.action,p="https://t.me/xbtsio";return a.createElement("div",{style:this.props.style},a.createElement("div",{className:"grid-block no-margin vertical medium-horizontal no-padding"},a.createElement("div",{className:"medium-4"},a.createElement("div",null,a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.choose_"+i}),":"," "),a.createElement("select",{className:"external-coin-types bts-select",onChange:this.onSelectCoin.bind(this),value:s},o))),a.createElement("div",{className:"medium-6 medium-offset-1"},a.createElement("label",{style:{minHeight:"2rem"},className:"left-label"},a.createElement(c(),{content:"gateway.gateway_text"}),":"),a.createElement("div",{style:{paddingBottom:15}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{className:"deposit"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"deposit")},a.createElement(c(),{content:"gateway.deposit"}))),a.createElement("li",{className:"withdraw"===i?"is-active":""},a.createElement("a",{onClick:this.changeAction.bind(this,"withdraw")},a.createElement(c(),{content:"gateway.withdraw"}))))))),r?a.createElement("div",null,a.createElement("div",{style:{marginBottom:15}},a.createElement(gs,{key:`${r.symbol}`,gateway:r.gatewayWallet,issuer_account:r.issuer,account:t,deposit_asset:r.backingCoin.toUpperCase(),deposit_asset_name:r.name,deposit_coin_type:r.backingCoin.toLowerCase(),deposit_account:r.gatewayWallet,deposit_wallet_type:r.walletType,receive_asset:r.symbol,receive_coin_type:r.symbol.toLowerCase(),supports_output_memos:r.memoSupport,min_amount:r.minAmount,asset_precision:r.precision,action:this.state.action}),a.createElement("label",{className:"left-label"},"Support"),a.createElement("div",null,a.createElement(c(),{content:"gateway.xbtsx.support_block"}),a.createElement("br",null),a.createElement("br",null),a.createElement("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"external-link"},p))),r&&r.symbol?a.createElement(j.k,{asset:r.symbol,fromAccount:l?r.issuerId:this.props.account.get("id"),to:l?this.props.account.get("id"):r.issuerId},(({asset:e,to:t,fromAccount:s})=>a.createElement(j.t,{accountsList:V().List([this.props.account.get("id")]),limit:10,compactView:!0,fullHeight:!0,filter:"transfer",title:a.createElement(c(),{content:"gateway.recent_"+this.state.action}),customFilter:{fields:["to","from","asset_id"],values:{to:t.get("id"),from:s.get("id"),asset_id:e.get("id")}}}))):null):null)}}const ys=(0,i.$)(ws,{listenTo:()=>[A.Z],getProps:()=>({viewSettings:A.Z.getState().viewSettings})});var bs=s(70637),Es=s(64046),fs=s(58466);class vs extends a.Component{static propTypes={account:p.Z.ChainAccount.isRequired,contained:S().bool};static defaultProps={contained:!1};constructor(e){super(),this.state={olService:e.viewSettings.get("olService","gateway"),rudexService:e.viewSettings.get("rudexService","gateway"),bitsparkService:e.viewSettings.get("bitsparkService","gateway"),piratecashService:e.viewSettings.get("piratecashService","gateway"),xbtsxService:e.viewSettings.get("xbtsxService","gateway"),btService:e.viewSettings.get("btService","bridge"),citadelService:e.viewSettings.get("citadelService","bridge"),metaService:e.viewSettings.get("metaService","bridge"),activeService:e.viewSettings.get("activeService",0)}}shouldComponentUpdate(e,t){return e.account!==this.props.account||e.servicesDown!==this.props.servicesDown||!r.Z.are_equal_shallow(e.blockTradesBackedCoins,this.props.blockTradesBackedCoins)||!r.Z.are_equal_shallow(e.openLedgerBackedCoins,this.props.openLedgerBackedCoins)||!r.Z.are_equal_shallow(e.citadelBackedCoins,this.props.citadelBackedCoins)||t.olService!==this.state.olService||t.rudexService!==this.state.rudexService||t.bitsparkService!==this.state.bitsparkService||t.piratecashService!==this.state.piratecashService||t.xbtsxService!==this.state.xbtsxService||t.btService!==this.state.btService||t.citadelService!==this.state.citadelService||t.metaService!==this.state.metaService||t.activeService!==this.state.activeService}UNSAFE_componentWillMount(){n.Z.getFinalFeeAsset(this.props.account,"transfer")}toggleOLService(e){this.setState({olService:e}),U.Z.changeViewSetting({olService:e})}toggleRuDEXService(e){this.setState({rudexService:e}),U.Z.changeViewSetting({rudexService:e})}togglePiratecashService(e){this.setState({piratecashService:e}),U.Z.changeViewSetting({piratecashService:e})}toggleXbtsxService(e){this.setState({xbtsxService:e}),U.Z.changeViewSetting({xbtsxService:e})}toggleBitSparkService(e){this.setState({bitsparkService:e}),U.Z.changeViewSetting({bitsparkService:e})}toggleBTService(e){this.setState({btService:e}),U.Z.changeViewSetting({btService:e})}toggleCitadelService(e){this.setState({citadelService:e}),U.Z.changeViewSetting({citadelService:e})}toggleMetaService(e){this.setState({metaService:e}),U.Z.changeViewSetting({metaService:e})}onSetService(e){this.setState({activeService:parseInt(e.target.value)}),U.Z.changeViewSetting({activeService:parseInt(e.target.value)})}renderServices(e,t,s,i,n){let o=[],{account:r}=this.props,{olService:l,btService:p,rudexService:d,bitsparkService:u,piratecashService:h,xbtsxService:m,citadelService:_}=this.state;return o.push({name:"Openledger (OPEN.X)",identifier:"OPEN",template:a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.toggleOLService.bind(this,"gateway"),className:"gateway"===l?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.gateway"}))),a.createElement("li",{onClick:this.toggleOLService.bind(this,"fiat"),className:"fiat"===l?"is-active":""},a.createElement(c(),{component:"a",content:"gateway.fiat"})))),"gateway"===l&&e.length?a.createElement(J,{account:r,coins:e,provider:"openledger"}):null,"fiat"===l?a.createElement("div",null,a.createElement("div",{style:{paddingBottom:15}},a.createElement(c(),{component:"h5",content:"gateway.fiat_text",unsafe:!0})),a.createElement(oe,{rpc_url:I.yP.RPC_URL,account:r,issuer_account:"openledger-fiat"}),a.createElement(le,{rpc_url:I.yP.RPC_URL,account:r})):null)}),o.push({name:"RuDEX (RUDEX.X)",identifier:"RUDEX",template:a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.toggleRuDEXService.bind(this,"gateway"),className:"gateway"===d?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.gateway"}))),a.createElement("li",{onClick:this.toggleRuDEXService.bind(this,"fiat"),className:"fiat"===d?"is-active":""},a.createElement("a",null,"Fiat")))),"gateway"===d&&t.length?a.createElement(Ye,{account:r,coins:t}):null,"fiat"===d?a.createElement("div",null,a.createElement(c(),{content:"gateway.rudex.coming_soon"})):null)}),o.push({name:"BitSpark (SPARKDEX.X)",identifier:"SPARKDEX",template:a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.toggleBitSparkService.bind(this,"gateway"),className:"gateway"===u?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.gateway"}))))),"gateway"===u&&s.length?a.createElement(pt,{account:r,coins:s,provider:"bitspark"}):null)}),o.push({name:"Pirate DEX",identifier:"PIRATE",template:a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.togglePiratecashService.bind(this,"gateway"),className:"gateway"===h?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.gateway"}))))),"gateway"===h&&i.length?a.createElement(Yt,{account:r,coins:i}):null)}),o.push({name:"XBTS Native Chains",identifier:"XBTSX",template:a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.toggleXbtsxService.bind(this,"gateway"),className:"gateway"===m?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.gateway"}))),a.createElement("li",{onClick:this.toggleXbtsxService.bind(this,"fiat"),className:"fiat"===m?"is-active":""},a.createElement("a",null,"Fiat")))),"gateway"===m&&n.length?a.createElement(ys,{account:r,coins:n}):null,"fiat"===m?a.createElement(ns,{viewSettings:this.props.viewSettings,account:r}):null)}),o.push({name:"BlockTrades",identifier:"TRADE",template:a.createElement("div",null,a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.toggleBTService.bind(this,"bridge"),className:"bridge"===p?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.bridge"}))))),a.createElement(Ne,{gateway:"blocktrades",issuer_account:"blocktrades",account:r,initial_deposit_input_coin_type:"btc",initial_deposit_output_coin_type:"bts",initial_deposit_estimated_input_amount:"1.0",initial_withdraw_input_coin_type:"bts",initial_withdraw_output_coin_type:"btc",initial_withdraw_estimated_input_amount:"100000",initial_conversion_input_coin_type:"bts",initial_conversion_output_coin_type:"bitbtc",initial_conversion_estimated_input_amount:"1000",params:this.props.location})),a.createElement("div",{className:"content-block"}))}),o.push({name:"Citadel",identifier:"CITADEL",template:a.createElement("div",null,a.createElement("div",{className:"content-block"},a.createElement("div",{className:"service-selector",style:{marginBottom:"2rem"}},a.createElement("ul",{className:"button-group segmented no-margin"},a.createElement("li",{onClick:this.toggleCitadelService.bind(this,"bridge"),className:"bridge"===_?"is-active":""},a.createElement("a",null,a.createElement(c(),{content:"gateway.bridge"}))))),a.createElement(Fe,{gateway:"citadel",issuer_account:"citadel-wallet",account:r,initial_deposit_input_coin_type:"xmr",initial_deposit_output_coin_type:"citadel.monero",initial_deposit_estimated_input_amount:"1.0",initial_withdraw_input_coin_type:"citadel.monero",initial_withdraw_output_coin_type:"xmr",initial_withdraw_estimated_input_amount:"1.0"})),a.createElement("div",{className:"content-block"}))}),o.push({name:"GDEX",identifier:"GDEX",template:a.createElement("div",null,a.createElement(qt,{account:r,provider:"gdex"}))}),o}render(){let{account:e,servicesDown:t}=this.props,{activeService:s}=this.state,i=this.props.openLedgerBackedCoins.map((e=>e)).sort(((e,t)=>e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0)),n=this.props.rudexBackedCoins.map((e=>e)).sort(((e,t)=>e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0)),o=this.props.bitsparkBackedCoins.map((e=>e)).sort(((e,t)=>e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0)),r=this.props.piratecashBackedCoins.map((e=>e)).sort(((e,t)=>e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0)),l=this.props.xbtsxBackedCoins.map((e=>e)).sort(((e,t)=>e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0)),p=this.renderServices(i,n,o,r,l);const d=[];let u=p.map(((e,t)=>(d.push(e.identifier),a.createElement("option",{key:t,value:t},e.name))));const h=d[s],m=t.get(h);return a.createElement("div",{className:this.props.contained?"grid-content":"grid-container"},a.createElement("div",{className:this.props.contained?"":"grid-content",style:{paddingTop:"2rem"}},a.createElement("div",{className:"grid-block vertical medium-horizontal no-margin no-padding"},a.createElement("div",{style:{paddingBottom:"1rem"}},a.createElement(bs.Z,{ref:"deposit_modal",modalId:"deposit_modal_new",account:this.props.currentAccount,backedCoins:this.props.backedCoins}),a.createElement(Es.Z,{ref:"withdraw_modal",modalId:"withdraw_modal_new",backedCoins:this.props.backedCoins}),a.createElement(fs.Z,{string:"gateway.phase_out_warning",keys:[{arg:"deposit_modal_link",value:a.createElement("a",{onClick:()=>{this.refs.deposit_modal&&this.refs.deposit_modal.show()}},a.createElement(c(),{content:"modal.deposit.submit"}))},{arg:"withdraw_modal_link",value:a.createElement("a",{onClick:()=>{this.refs.withdraw_modal&&this.refs.withdraw_modal.show()}},a.createElement(c(),{content:"modal.withdraw.submit"}))}]}))),a.createElement(c(),{content:"gateway.title",component:"h2"}),a.createElement("div",{className:"grid-block vertical medium-horizontal no-margin no-padding"},a.createElement("div",{className:"medium-6 show-for-medium"},a.createElement(Oe.Z,{path:"components/DepositWithdraw",section:"deposit-short"})),a.createElement("div",{className:"medium-5 medium-offset-1"},a.createElement(Oe.Z,{account:e.get("name"),path:"components/DepositWithdraw",section:"receive"}))),a.createElement("div",null,a.createElement("div",{className:"grid-block vertical medium-horizontal no-margin no-padding"},a.createElement("div",{className:"medium-6 small-order-2 medium-order-1"},a.createElement(c(),{component:"label",className:"left-label",content:"gateway.service"}),a.createElement("select",{onChange:this.onSetService.bind(this),className:"bts-select",value:s},u),m?a.createElement(c(),{style:{color:"red",marginBottom:"1em",display:"block"},content:`gateway.unavailable_${h}`}):null),a.createElement("div",{className:"medium-5 medium-offset-1 small-order-1 medium-order-2",style:{paddingBottom:20}},a.createElement(c(),{component:"label",className:"left-label",content:"gateway.your_account"}),a.createElement("div",{className:"inline-label"},a.createElement(tt.Z,{size:{height:40,width:40},account:e.get("name"),custom_image:null}),a.createElement("input",{type:"text",value:e.get("name"),placeholder:null,disabled:!0,onChange:()=>{},onKeyDown:()=>{},tabIndex:1}))))),a.createElement("div",{className:"grid-content no-padding",style:{paddingTop:15}},m?null:s&&p[s]?p[s].template:p[0].template)))}}vs=(0,d.Z)(vs);class Cs extends a.Component{UNSAFE_componentWillMount(){(0,o.xA)()}render(){return a.createElement(vs,this.props)}}const Ss=(0,i.$)(Cs,{listenTo:()=>[Re.Z,A.Z,et.Z],getProps:()=>({currentAccount:Re.Z.getState().currentAccount||Re.Z.getState().passwordAccount,account:Re.Z.getState().currentAccount,viewSettings:A.Z.getState().viewSettings,backedCoins:et.Z.getState().backedCoins,openLedgerBackedCoins:et.Z.getState().backedCoins.get("OPEN",[]),rudexBackedCoins:et.Z.getState().backedCoins.get("RUDEX",[]),bitsparkBackedCoins:et.Z.getState().backedCoins.get("SPARKDEX",[]),blockTradesBackedCoins:et.Z.getState().backedCoins.get("TRADE",[]),citadelBackedCoins:et.Z.getState().backedCoins.get("CITADEL",[]),piratecashBackedCoins:et.Z.getState().backedCoins.get("PIRATE",[]),xbtsxBackedCoins:et.Z.getState().backedCoins.get("XBTSX",[]),servicesDown:et.Z.getState().down||{}})})},57351:(e,t,s)=>{"use strict";s.d(t,{Z:()=>b});var a=s(67294),i=s(58074),n=s.n(i),o=s(21019),r=s(57906),l=s(43393),c=s.n(l),p=s(112),d=s.n(p),u=s(52521),h=s(13973),m=s(45697),_=s.n(m),g=s(34961);class w extends a.Component{static propTypes={value:_().string,onChange:_().func,scroll_length:_().number};shouldComponentUpdate(e){return!h.Z.are_equal_shallow(e.assets,this.props.assets)||e.value!==this.props.value||e.scroll_length!==this.props.scroll_length}render(){return this.props.assets.length?a.createElement(r.Z,{entries:this.props.assets.map((e=>e&&e.get("symbol"))).filter((e=>!!e)),values:this.props.assets.reduce(((e,t)=>(t&&t.get("symbol")&&(e[t.get("symbol")]=t),e)),{}),singleEntry:this.props.assets[0]?a.createElement(o.Z,{asset:this.props.assets[0].get("id"),amount:0,hide_amount:!0}):null,value:this.props.value,onChange:this.props.onChange,scroll_length:this.props.scroll_length}):null}}w=(0,u.Z)(w,{asList:!0});class y extends g.C{static propTypes={label:_().string,assets:_().array,amount:_().any,placeholder:_().string,onChange:_().func,tabIndex:_().number,error:_().string,scroll_length:_().number};static defaultProps={disabled:!1,tabIndex:0};componentDidMount(){this.onAssetChange(this.props.asset)}formatAmount(e){return e||(e=""),"number"==typeof e&&(e=e.toString()),e.trim().replace(/,/g,"")}_onChange(e){this.props.onChange&&this.props.onChange({amount:this.getNumericEventValue(e),asset:this.props.asset})}onAssetChange(e){this.props.onChange&&this.props.onChange({amount:this.props.amount,asset:e})}render(){let e=this.props.error?d().translate(this.props.error):this.formatAmount(this.props.amount);return a.createElement("div",{className:"amount-selector",style:this.props.style},a.createElement("label",{className:"right-label"},this.props.display_balance),a.createElement(n(),{className:"left-label",component:"label",content:this.props.label}),a.createElement("div",{className:"inline-label input-wrapper"},a.createElement("input",{disabled:this.props.disabled,type:"text",value:e||"",placeholder:this.props.placeholder,onChange:this._onChange.bind(this),tabIndex:this.props.tabIndex,onPaste:this.props.onPaste||this.onPaste.bind(this),onKeyPress:this.onKeyPress.bind(this)}),a.createElement("div",{className:"form-label select floating-dropdown"},this.props.isPrice?a.createElement("div",{className:"dropdown-wrapper inactive"},a.createElement("div",null,this.props.asset.get("symbol"),"/",this.props.base)):a.createElement(w,{ref:this.props.refCallback,value:this.props.asset.get("symbol"),assets:c().List(this.props.assets),onChange:this.onAssetChange.bind(this),scroll_length:this.props.scroll_length}))))}}const b=y=(0,u.Z)(y)},57906:(e,t,s)=>{"use strict";s.d(t,{Z:()=>l});var a=s(67294),i=s(13973),n=s(45697),o=s.n(n);class r extends a.Component{static propTypes={scroll_length:o().number};static defaultProps={scroll_length:9};constructor(e){e.scroll_length,super(e),this.state={active:!1},this.listener=!1,this.onBodyClick=this.onBodyClick.bind(this)}componentDidMount(){this._setListener()}shouldComponentUpdate(e,t){return!i.Z.are_equal_shallow(e.entries,this.props.entries)||!i.Z.are_equal_shallow(t,this.state)||e.value!==this.props.value}_setListener(e=this.props){e.entries.length>1&&!this.listener&&(this.listener=!0,document.body.addEventListener("click",this.onBodyClick,{capture:!1,passive:!0}))}_removeListener(){document.body.removeEventListener("click",this.onBodyClick),this.listener=!1}UNSAFE_componentWillReceiveProps(e){1===e.entries.length?this._removeListener():e.entries.length>1&&this._setListener(e)}componentWillUnmount(){this._removeListener()}onBodyClick(e){let t=e.target,s=!1;do{if(t.classList&&t.classList.contains("dropdown")&&t.id===this.props.id){s=!0;break}}while(t=t.parentNode);s?e.stopPropagation():this.setState({active:!1})}onChange(e,t){t.preventDefault(),t.stopPropagation(),this.props.onChange(e),this.setState({active:!1})}_toggleDropdown(){this.setState({active:!this.state.active})}render(){const{entries:e,value:t}=this.props;let{active:s}=this.state;if(0===e.length)return null;if(1==e.length)return a.createElement("div",{className:"dropdown-wrapper inactive"+(this.props.upperCase?" upper-case":"")},a.createElement("div",null,this.props.singleEntry?this.props.singleEntry:e[0]));{let i=e.map((e=>a.createElement("li",{className:this.props.upperCase?"upper-case":"",key:e,onClick:this.onChange.bind(this,this.props.values[e])},a.createElement("span",null,e))));return a.createElement("div",{onClick:this._toggleDropdown.bind(this),className:"dropdown-wrapper"+(s?" active":"")+(this.props.upperCase?" upper-case":"")},a.createElement("div",{style:{paddingRight:15}},t||a.createElement("span",{className:"hidden"},"A")),a.createElement("ul",{className:"dropdown",style:{overflow:e.length>this.props.scroll_length?"auto":"hidden"}},i))}}}const l=r},46601:()=>{},89214:()=>{},71922:()=>{},2363:()=>{},96419:()=>{},56353:()=>{}}]);