forked from jatchili/minimalist-ripple-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1608 lines (1380 loc) · 395 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>minimalist ripple client</title>
<style>
.hidden { visibility: hidden; }
.displaynone { display: none !important; }
#mysecret[disabled] { border: none; }
#myaddress:empty:before { content: "(no identity set)"; }
table:empty { display: none; }
td.centered { text-align: center; }
input[type="text"] { width: 240px; }
input[type="text"].wide { width: 280px; }
input[type="text"].narrow { width: 120px; }
button:not(.offline) {
/* buttons that query the network */
cursor: pointer;
font-weight: bold;
}
.editflagbutton { width: 60px; }
#sendbutton, .complexsendbutton, .cancelbutton { width: 72px; }
#trustbutton { width: 84px; }
#startpathfindingbutton, #rekeybutton { width: 100px; }
.tilde { width: 30px; }
.halfoffset {
position: relative;
top: 9px;
}
.pathsJSON div { display: none; }
.pathsJSON:hover div {
display: block;
position: absolute;
word-break: break-all;
width: 200px;
border: 1px solid black;
padding: 8px;
background-color: white;
}
.pathsJSON:after {
content: "hover to view";
font-style: italic;
}
.pathsJSON:after:hover { content: ""; }
</style>
</head>
<body>
<noscript><h2>you need to enable javascript to use this!</h2><hr/></noscript>
<h1>minimalist ripple client</h1>
<h3><span style="color:red">Note:</span> Some users have reported bugs when using this client in Safari. Please use a non-Safari browser.</h3>
<h2>identity</h2>
<span id="myaddress"></span><br/>
<button class="offline" onclick="toggleSecret()">show/hide secret</button>
<input id="mysecret" type="text" placeholder="secret" /><br/>
<button class="offline" onclick="pressSetIdentity()">set identity</button>
<button class="offline" onclick="pressClearIdentity()">clear identity</button>
<button class="offline" onclick="pressGenerateIdentity()">generate identity</button>
<button id="rekeybutton" onclick="pressRekey()">rekey account</button><br/>
<span class="displaynone" id="encryptshow">
<button class="offline" onclick="showEncryptor()">encrypt secret</button>
</span>
<input class="displaynone" id="passphrase" type="password" placeholder="passphrase" />
<input class="displaynone" id="confirmpassphrase" type="password" placeholder="confirm passphrase" />
<span class="displaynone" id="decryptbutton">
<button class="offline" onclick="pressDecrypt()">decrypt</button>
</span>
<span class="displaynone" id="encryptbutton">
<button class="offline" onclick="pressEncryptSecret()">encrypt</button>
</span>
<span class="hidden"> <!-- space-filler -->
<button>_</button><input type="password"/>
</span>
<h2>connect</h2>
<button onclick="connectToRipple()">connect to ripple</button>
<button onclick="disconnectFromRipple()">disconnect</button><br/><br/>
<input id="nameurl" type="text" value="id.ripple.com/v1/authinfo?username=" /><br/>
<label><input id="useripplenames" type="checkbox"/> resolve ripple names with ~ button</label>
<h2>account details</h2>
<button class="offline" onclick="useCurrentIdentity()">use current identity</button>
<button class="offline" onclick="clearAllInfo()">clear all</button><br/>
<input id="infoaccount" type="text" placeholder="account" />
<button tabindex="-1" class="tilde" onclick="pressResolve(this,['infoaccount'])">~</button>
<br/>
<button onclick="pressInfo()">view info</button><br/>
<table id="infotable" border="1"></table>
<button onclick="pressLines()">view trustlines</button><br/>
<table id="linestable" border="1"></table>
<button onclick="pressOffers()">view/edit offers</button><br/>
<table id="offerstable" border="1"></table>
<button onclick="pressFlags()">view/edit flags</button><br/>
<table border="1" id="flagstable"></table>
<h2>send payment</h2>
<input type="text" id="sendamount" placeholder="amount" /><br/>
<input type="text" id="sendcurrency" class="narrow" placeholder="currency" />
<label>
<input type="checkbox" id="directxrp" onclick="toggleDirectXRP(this)"/>direct xrp→xrp
</label><br/>
<input type="text" id="senddestination" placeholder="destination" />
<button tabindex="-1" class="tilde" onclick="pressResolve(this,['senddestination'])">~</button>
<br/>
<label><input id="useoptional" onclick="toggleOptionalFields(this)" type="checkbox"/>use optional fields</label><br/>
<div id="optionalfields" class="displaynone">
<input type="text" id="destinationtag" placeholder="destination tag (integer)" /><br/>
<input type="text" id="sourcetag" placeholder="source tag (integer)" /><br/>
<input type="text" id="invoiceid" placeholder="invoice id (at most 64 hex chars)" /><br/>
</div>
<div id="directsender" class="displaynone">
<button id="sendbutton" onclick="pressSend()">send</button>
<table border="1" class="hidden"></table> <!-- space-filler -->
</div>
<div id="complexsender">
<button onclick="pressPathfind()" id="startpathfindingbutton">find paths</button>
<button onclick="stopPathfinding()" id="stoppathfindingbutton" disabled="disabled">stop</button><br/>
<table border="1" id="pathstable"></table>
</div>
<h2>set trust</h2>
<input id="trustamount" type="text" placeholder="amount" /><br/>
<input id="trustcurrency" type="text" placeholder="currency" /><br/>
<input id="trustissuer" type="text" placeholder="issuer" />
<button tabindex="-1" class="tilde" onclick="pressResolve(this,['trustissuer'])">~</button><br/>
<label><input id="trustnoripple" type="checkbox" / >no ripple</label><br/>
<button id="trustbutton" onclick="pressTrust()">set trust</button>
<h2>trade</h2>
<input type="text" class="wide" id="curissuer1" placeholder="CUR/issuer #1" />
<button tabindex="-1" class="tilde halfoffset" onclick="pressResolve(this,['curissuer1','curissuer2'])">~</button><br/>
<input type="text" class="wide" id="curissuer2" placeholder="CUR/issuer #2" /><br/>
<button onclick="pressBook()">view order book</button>
<button class="offline" onclick="clearBooks()">clear</button><br/>
<table border="1" class="booktable" id="bidtable"></table>
<table border="1" class="booktable" id="asktable"></table><br/>
<input type="text" class="wide" id="tpamount" placeholder="TakerPays amount" /><br/>
<input type="text" class="wide" id="tpcurissuer" placeholder="TakerPays CUR/issuer" />
<button tabindex="-1" class="tilde halfoffset" onclick="pressResolve(this,['tpcurissuer','tgcurissuer'])">~</button><br/>
<input type="text" class="wide" id="tgamount" placeholder="TakerGets amount" /><br/>
<input type="text" class="wide" id="tgcurissuer" placeholder="TakerGets CUR/issuer" /><br/>
<button onclick="pressOffer()" id="offerbutton">submit offer</button>
<h2>disclaimer</h2>
<p>this product is provided "as is" without warranty of any kind and is not endorsed by ripple labs inc.</p>
<!-- ripple-0.12.5-rc2-min.js -->
<script>
var ripple=function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){var r=e[t];Object.keys(r.prototype).forEach(function(t){var e=/([A-Z]{1})[a-z]+/g;if(e.test(t)){var n=t.replace(e,function(t){return"_"+t.toLowerCase()});r.prototype[n]=r.prototype[t]}})}e.Remote=r(1).Remote,e.Request=r(2).Request,e.Amount=r(3).Amount,e.Account=r(4).Account,e.Transaction=r(5).Transaction,e.Currency=r(6).Currency,e.Base=r(7).Base,e.UInt128=r(8).UInt128,e.UInt160=r(9).UInt160,e.UInt256=r(10).UInt256,e.Seed=r(11).Seed,e.Meta=r(12).Meta,e.SerializedObject=r(13).SerializedObject,e.RippleError=r(14).RippleError,e.Message=r(15).Message,e.binformat=r(16),e.utils=r(17),e.Server=r(18).Server,e.Ledger=r(19).Ledger,e.TransactionQueue=r(20).TransactionQueue,e.RangeSet=r(21).RangeSet,e.convertBase=r(22),e.sjcl=r(17).sjcl,e.Wallet=r(36)({sjcl:e.sjcl}),e.types=r(23),["Remote","Request","Transaction","Account","Server"].forEach(n)},function(t,e,r){"use strict";function n(t){function e(t,e){if(c.contains(n.TRANSACTION_EVENTS,e))switch(t){case"add":1===++r._transaction_listeners&&r.requestSubscribe("transactions").request();break;case"remove":0===--r._transaction_listeners&&r.requestUnsubscribe("transactions").request()}}i.call(this);var r=this;if(t=t||{},Object.keys(n.DEFAULTS).forEach(function(e){this[e]=t.hasOwnProperty(e)?t[e]:n.DEFAULTS[e]},this),this.state="offline",this._server_fatal=!1,this._stand_alone=void 0,this._testnet=void 0,this._ledger_current_index=void 0,this._ledger_hash=void 0,this._ledger_time=void 0,this._connection_count=0,this._connected=!1,this._should_connect=!0,this._transaction_listeners=0,this._received_tx=new a({max:100}),this._cur_path_find=null,this.local_signing&&(this.local_sequence=!0,this.local_fee=!0),this._servers=[],this._primary_server=void 0,this.accounts={},this._accounts={},this._books={},this.secrets={},this.ledgers={current:{account_root:{}}},"boolean"!=typeof this.trusted)throw new TypeError("trusted must be a boolean");if("boolean"!=typeof this.trace)throw new TypeError("trace must be a boolean");if("boolean"!=typeof this.allow_partial_history)throw new TypeError("allow_partial_history must be a boolean");if("number"!=typeof this.max_fee)throw new TypeError("max_fee must be a number");if("number"!=typeof this.max_attempts)throw new TypeError("max_attempts must be a number");if("number"!=typeof this.fee_cushion)throw new TypeError("fee_cushion must be a number");if("boolean"!=typeof this.local_signing)throw new TypeError("local_signing must be a boolean");if("boolean"!=typeof this.local_fee)throw new TypeError("local_fee must be a boolean");if("boolean"!=typeof this.local_sequence)throw new TypeError("local_sequence must be a boolean");if("boolean"!=typeof this.canonical_signing)throw new TypeError("canonical_signing must be a boolean");if("number"!=typeof this.submission_timeout)throw new TypeError("submission_timeout must be a number");if("number"!=typeof this.last_ledger_offset)throw new TypeError("last_ledger_offset must be a number");if(!Array.isArray(this.servers))throw new TypeError("servers must be an array");this.setMaxListeners(this.max_listeners),this.servers.forEach(function(t){var e=r.addServer(t);e.setMaxListeners(r.max_listeners)}),this.on("newListener",function(t){e("add",t)}),this.on("removeListener",function(t){e("remove",t)})}var i=r(37).EventEmitter,o=r(38),s=r(39),a=r(44),u=r(45),c=r(40),f=r(18).Server,h=r(2).Request,l=r(3).Amount,p=r(6).Currency,d=r(9).UInt160,_=r(10).UInt256,y=r(5).Transaction,v=r(4).Account,g=r(12).Meta,m=r(24).OrderBook,b=r(25).PathFind,w=r(13).SerializedObject,E=r(14).RippleError,A=r(17),x=r(26),S=r(27).internal.sub("remote");o.inherits(n,i),n.DEFAULTS={trusted:!1,trace:!1,allow_partial_history:!0,local_sequence:!0,local_fee:!0,local_signing:!0,canonical_signing:!0,fee_cushion:1.2,max_fee:1e6,max_attempts:10,submission_timeout:2e4,last_ledger_offset:3,servers:[],max_listeners:0},n.TRANSACTION_EVENTS=["transaction","transaction_all"],n.flags={account_root:{PasswordSpent:65536,RequireDestTag:131072,RequireAuth:262144,DisallowXRP:524288,DisableMaster:1048576,DefaultRipple:8388608,NoFreeze:2097152,GlobalFreeze:4194304},offer:{Passive:65536,Sell:131072},state:{LowReserve:65536,HighReserve:131072,LowAuth:262144,HighAuth:524288,LowNoRipple:1048576,HighNoRipple:2097152}},n.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},n.isValidLedgerData=function(t){return"object"==typeof t&&"number"==typeof t.fee_base&&"number"==typeof t.fee_ref&&"string"==typeof t.ledger_hash&&"number"==typeof t.ledger_index&&"number"==typeof t.ledger_time&&"number"==typeof t.reserve_base&&"number"==typeof t.reserve_inc},n.isValidLoadStatus=function(t){return"number"==typeof t.load_base&&"number"==typeof t.load_factor},n.isValidated=function(t){return t&&"object"==typeof t&&t.validated===!0},n.prototype._setState=function(t){if(this.state!==t)switch(this.trace&&S.info("set_state:",t),this.state=t,this.emit("state",t),t){case"online":this._online_state="open",this._connected=!0,this.emit("connect"),this.emit("connected");break;case"offline":this._online_state="closed",this._connected=!1,this.emit("disconnect"),this.emit("disconnected")}},n.prototype.setServerFatal=function(){this._server_fatal=!0},n.prototype.setTrace=function(t){return this.trace=void 0===t||t,this},n.prototype._trace=function(){this.trace&&S.info.apply(S,arguments)},n.prototype.setSecret=function(t,e){this.secrets[t]=e},n.prototype.addServer=function(t){function e(t){i._handleMessage(t,o)}function r(){i._connection_count+=1,t.primary&&i._setPrimaryServer(o),1===i._connection_count&&i._setState("online"),i._connection_count===i._servers.length&&i.emit("ready")}function n(){i._connection_count--,0===i._connection_count&&i._setState("offline")}var i=this,o=new f(this,t);return o.on("message",e),o.on("connect",r),o.on("disconnect",n),this._servers.push(o),o},n.prototype.reconnect=function(){this._should_connect&&(S.info("reconnecting"),this._servers.forEach(function(t){t.reconnect()}))},n.prototype.connect=function(t){if(!this._servers.length)throw new Error("No servers available.");return"function"==typeof t&&this.once("connect",t),this._should_connect=!0,this._servers.forEach(function(t){t.connect()}),this},n.prototype.disconnect=function(t){if(!this._servers.length)throw new Error("No servers available, not disconnecting");return"function"!=typeof t&&(t=function(){}),this._should_connect=!1,this.isConnected()?(this.once("disconnect",t),this._servers.forEach(function(t){t.disconnect()}),this._set_state("offline"),this):(t(),this)},n.prototype._handleMessage=function(t,e){try{t=JSON.parse(t)}catch(r){console.error(r)}if(!n.isValidMessage(t))return void this.emit("error",new E("remoteUnexpected","Unexpected response from remote"));switch(t.type){case"ledgerClosed":this._handleLedgerClosed(t,e);break;case"serverStatus":this._handleServerStatus(t,e);break;case"transaction":this._handleTransaction(t,e);break;case"path_find":this._handlePathFind(t,e);break;default:this.trace&&S.info(t.type+": ",t)}},n.prototype.getLedgerSequence=function(){if(!this._ledger_current_index)throw new Error("Ledger sequence has not yet been initialized");return this._ledger_current_index},n.prototype._handleLedgerClosed=function(t,e){var r=this;if(n.isValidLedgerData(t)){var i=t.ledger_index>=this._ledger_current_index;(isNaN(this._ledger_current_index)||i)&&(this._ledger_time=t.ledger_time,this._ledger_hash=t.ledger_hash,this._ledger_current_index=t.ledger_index+1,this.isConnected()?this.emit("ledger_closed",t,e):this.once("connect",function(){r.emit("ledger_closed",t,e)}))}},n.prototype._handleServerStatus=function(t,e){this.emit("server_status",t,e)},n.prototype._handleTransaction=function(t,e){var r=t.transaction.hash;if(!this._received_tx.get(r)){t.validated&&this._received_tx.set(r,!0),this.trace&&S.info("tx:",t);var n=t.meta||t.metadata;n?(t.mmeta=new g(n),t.mmeta.getAffectedAccounts().forEach(function(e){this._accounts[e]&&this._accounts[e].notify(t)},this),t.mmeta.getAffectedBooks().forEach(function(e){this._books[e]&&this._books[e].notify(t)},this)):["Account","Destination"].forEach(function(e){this._accounts[t.transaction[e]]&&this._accounts[t.transaction[e]].notify(t)},this),this.emit("transaction",t,e),this.emit("transaction_all",t,e)}},n.prototype._handlePathFind=function(t,e){this._cur_path_find&&this._cur_path_find.notify_update(t),this.emit("path_find_all",t,e)},n.prototype.getLedgerHash=function(){return this._ledger_hash},n.prototype._setPrimaryServer=n.prototype.setPrimaryServer=function(t){this._primary_server&&(this._primary_server._primary=!1),this._primary_server=t,this._primary_server._primary=!0},n.prototype.isConnected=function(){return this._connected},n.prototype.getConnectedServers=function(){for(var t=[],e=0;e<this._servers.length;e++)this._servers[e].isConnected()&&t.push(this._servers[e]);return t},n.prototype._getServer=n.prototype.getServer=function(){if(this._primary_server&&this._primary_server.isConnected())return this._primary_server;if(!this._servers.length)return null;var t=this.getConnectedServers();if(0===t.length||!t[0])return null;for(var e=t[0],r=e._score+e._fee,n=1;n<t.length;n++){var i=t[n],o=i._score+i._fee;r>o&&(e=i,r=o)}return e},n.prototype.request=function(t){if("string"==typeof t){if(/^request_/.test(t)||(t="request_"+t),"function"==typeof this[t]){var e=Array.prototype.slice.call(arguments,1);return this[t].apply(this,e)}throw new Error("Command does not exist: "+t)}if(!(t instanceof h))throw new Error("Argument is not a Request");if(!this._servers.length)return t.emit("error",new Error("No servers available"));if(!this.isConnected())return this.once("connect",this.request.bind(this,t));if(null===t.server)return t.emit("error",new Error("Server does not exist"));var r=t.server||this.getServer();r?r._request(t):t.emit("error",new Error("No servers available"))},n.prototype.ping=n.prototype.requestPing=function(t,e){var r=new h(this,"ping");switch(typeof t){case"function":e=t;break;case"string":r.setServer(t)}var n=Date.now();return r.once("success",function(){r.emit("pong",Date.now()-n)}),r.callback(e,"pong"),r},n.prototype.requestServerInfo=function(t){return new h(this,"server_info").callback(t)},n.prototype.requestLedger=function(t,e){var r=new h(this,"ledger");switch(typeof t){case"undefined":break;case"function":e=t;break;case"object":if(!t)break;Object.keys(t).forEach(function(e){switch(e){case"full":case"expand":case"transactions":case"accounts":r.message[e]=t[e]?!0:!1;break;case"ledger":r.selectLedger(t.ledger);break;case"ledger_index":case"ledger_hash":r.message[e]=t[e];break;case"closed":case"current":case"validated":r.message.ledger_index=e}},t);break;default:r.selectLedger(t)}return r.callback(e),r},n.prototype.requestLedgerClosed=n.prototype.requestLedgerHash=function(t){return new h(this,"ledger_closed").callback(t)},n.prototype.requestLedgerHeader=function(t){return new h(this,"ledger_header").callback(t)},n.prototype.requestLedgerCurrent=function(t){return new h(this,"ledger_current").callback(t)},n.prototype.requestLedgerData=function(t,e){var r=new h(this,"ledger_data");return r.message.binary=t.binary!==!1,r.selectLedger(t.ledger),r.message.limit=t.limit,r.once("success",function(e){function i(t,e){u.setImmediate(function(){e(null,n.parseBinaryLedgerData(t))})}function o(t,n){t?r.emit("error",t):(e.state=n,r.emit("state",e))}return t.binary===!1?void r.emit("state",e):void u.mapSeries(e.state,i,o)}),r.callback(e,"state"),r},n.prototype.requestLedgerEntry=function(t,e){var r=this,n=new h(this,"ledger_entry");return"function"==typeof t&&(e=t),"account_root"===t&&(n.request_default=n.request,n.request=function(){var e=!0;if(!r._ledger_hash&&"account_root"===t){var i=r.ledgers.current.account_root;i||(i=r.ledgers.current.account_root={});var o=r.ledgers.current.account_root[n.message.account_root];if(o)n.emit("success",{node:o}),e=!1;else switch(t){case"account_root":n.once("success",function(t){r.ledgers.current.account_root[t.node.Account]=t.node})}}e&&n.request_default()}),n.callback(e),n},n.prototype.requestSubscribe=function(t,e){var r=new h(this,"subscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},n.prototype.requestUnsubscribe=function(t,e){var r=new h(this,"unsubscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},n.prototype.requestTransactionEntry=function(t,e,r){var n=new h(this,"transaction_entry");switch("object"==typeof t?(e=t.ledger||t.ledger_hash||t.ledger_index,t=t.hash||t.tx||t.transaction):S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties"),n.txHash(t),typeof e){case"string":case"number":n.selectLedger(e);break;case"undefined":case"function":n.ledgerIndex("validated"),r=e;break;default:throw new Error("Invalid ledger_hash type")}return n.callback(r),n},n.prototype.requestTransaction=n.prototype.requestTx=function(t,e){var r;"string"==typeof t?(r={hash:t},S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties")):r=t;var i=new h(this,"tx");return i.message.binary=r.binary!==!1,i.message.transaction=r.hash,i.once("success",function(t){return r.binary===!1?void i.emit("transaction",t):void i.emit("transaction",n.parseBinaryTransaction(t))}),i.callback(e,"transaction"),i},n.accountRequest=function(t,e,r){var n,i,o,s,a;if("object"==typeof e?(n=e.account,i=e.ledger,o=e.peer,s=e.limit,a=e.marker):S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties"),a&&!(Number(i)>0||_.is_valid(i)))throw new Error("A ledger_index or ledger_hash must be provided when using a marker");var u=arguments[arguments.length-1];"function"==typeof u&&(r=u);var c=new h(this,t);return n&&(n=d.json_rewrite(n),c.message.account=n),c.selectLedger(i),d.is_valid(o)&&(c.message.peer=d.json_rewrite(o)),isNaN(s)||(s=Number(s),s>1e9&&(s=1e9),0>s&&(s=0),c.message.limit=s),a&&(c.message.marker=a),c.callback(r),c},n.prototype.requestAccountInfo=function(){var t=Array.prototype.concat.apply(["account_info"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountCurrencies=function(){var t=Array.prototype.concat.apply(["account_currencies"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountLines=function(){var t=Array.prototype.concat.apply(["account_lines"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountOffers=function(){var t=Array.prototype.concat.apply(["account_offers"],arguments);return n.accountRequest.apply(this,t)},n.prototype.requestAccountTransactions=n.prototype.requestAccountTx=function(t,e){var r=new h(this,"account_tx");return t.binary=t.binary!==!1,void 0!==t.min_ledger&&(t.ledger_index_min=t.min_ledger),void 0!==t.max_ledger&&(t.ledger_index_max=t.max_ledger),t.binary&&void 0===t.parseBinary&&(t.parseBinary=!0),Object.keys(t).forEach(function(t){switch(t){case"account":case"ledger_index_min":case"ledger_index_max":case"binary":case"count":case"descending":case"offset":case"limit":case"forward":case"marker":r.message[t]=this[t]}},t),r.once("success",function(e){function i(t,e){u.setImmediate(function(){e(null,n.parseBinaryAccountTransaction(t))})}function o(t,n){t?r.emit("error",t):(e.transactions=n,r.emit("transactions",e))}return t.parseBinary?void u.mapSeries(e.transactions,i,o):void r.emit("transactions",e)}),r.callback(e,"transactions"),r},n.parseBinaryAccountTransaction=function(t){var e=new w(t.tx_blob),r=e.to_json(),n=new w(t.meta).to_json(),i={validated:t.validated};if(i.meta=n,i.tx=r,i.tx.hash=e.hash(x.HASH_TX_ID).to_hex(),i.tx.ledger_index=t.ledger_index,i.tx.inLedger=t.ledger_index,"object"==typeof n.DeliveredAmount)i.meta.delivered_amount=n.DeliveredAmount;else switch(typeof r.Amount){case"string":case"object":i.meta.delivered_amount=r.Amount}return i},n.parseBinaryTransaction=function(t){var e=new w(t.tx).to_json(),r=new w(t.meta).to_json(),n=e;switch(n.date=t.date,n.hash=t.hash,n.inLedger=t.inLedger,n.ledger_index=t.ledger_index,n.meta=r,n.validated=t.validated,typeof r.DeliveredAmount){case"string":case"object":n.meta.delivered_amount=r.DeliveredAmount;break;default:switch(typeof e.Amount){case"string":case"object":n.meta.delivered_amount=e.Amount}}return n},n.parseBinaryLedgerData=function(t){var e=new w(t.data),r=e.to_json();return r.index=t.index,r},n.prototype.requestTransactionHistory=n.prototype.requestTxHistory=function(t,e){var r=new h(this,"tx_history");return"object"==typeof t?t=t.start:S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties"),r.message.start=t,r.callback(e),r},n.prototype.requestBookOffers=function(t,e,r,n){var i,o,s=arguments[arguments.length-1];if(t.hasOwnProperty("gets")||t.hasOwnProperty("taker_gets")){var a=t;n=e,r=a.taker,e=a.pays||a.taker_pays,t=a.gets||a.taker_gets,i=a.ledger,o=a.limit}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");"function"==typeof s&&(n=s);var u=new h(this,"book_offers");return u.message.taker_gets={currency:p.json_rewrite(t.currency,{force_hex:!0})},p.from_json(u.message.taker_gets.currency).is_native()||(u.message.taker_gets.issuer=d.json_rewrite(t.issuer)),u.message.taker_pays={currency:p.json_rewrite(e.currency,{force_hex:!0})},p.from_json(u.message.taker_pays.currency).is_native()||(u.message.taker_pays.issuer=d.json_rewrite(e.issuer)),u.message.taker=r?r:d.ACCOUNT_ONE,u.selectLedger(i),isNaN(o)||(o=Number(o),o>1e9&&(o=1e9),0>o&&(o=0),u.message.limit=o),u.callback(n),u},n.prototype.requestWalletAccounts=function(t,e){A.assert(this.trusted);var r=new h(this,"wallet_accounts");return"object"==typeof t?t=t.seed:S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties"),r.message.seed=t,r.callback(e),r},n.prototype.requestSign=function(t,e,r){A.assert(this.trusted);var n=new h(this,"sign");return"object"==typeof t?(e=t.tx_json,t=t.secret):S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties"),n.message.secret=t,n.message.tx_json=e,n.callback(r),n},n.prototype.requestSubmit=function(t){return new h(this,"submit").callback(t)},n.prototype._serverPrepareSubscribe=function(t,e){function r(e){n._stand_alone=!!e.stand_alone,n._testnet=!!e.testnet,n._handleLedgerClosed(e,t),n.emit("subscribed")}var n=this,i=["ledger","server"];"function"==typeof t&&(e=t),this._transaction_listeners&&i.push("transactions");var o=this.requestSubscribe(i);return o.on("error",function(t){n.trace&&S.info("Initial server subscribe failed",t)}),o.once("success",r),n.emit("prepare_subscribe",o),o.callback(e,"subscribed"),o},n.prototype.ledgerAccept=n.prototype.requestLedgerAccept=function(t){var e=new h(this,"ledger_accept");return this._stand_alone?(this.once("ledger_closed",function(t){e.emit("ledger_closed",t)}),e.callback(t,"ledger_closed"),e.request(),e):void this.emit("error",new E("notStandAlone"))},n.accountRootRequest=function(t,e,r,n,i){"object"==typeof r?(i=n,n=r.ledger,r=r.account):S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");var o=arguments[arguments.length-1];"function"==typeof o&&(i=o);var s=this.requestLedgerEntry("account_root");return s.accountRoot(r),s.selectLedger(n),s.once("success",function(r){s.emit(t,e(r))}),s.callback(i,t),s},n.prototype.requestAccountBalance=function(){function t(t){return l.from_json(t.node.Balance)}var e=Array.prototype.concat.apply(["account_balance",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.requestAccountFlags=function(){function t(t){return t.node.Flags}var e=Array.prototype.concat.apply(["account_flags",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.requestOwnerCount=function(){function t(t){return t.node.OwnerCount}var e=Array.prototype.concat.apply(["owner_count",t],arguments),r=n.accountRootRequest.apply(this,e);return r},n.prototype.getAccount=function(t){return this._accounts[d.json_rewrite(t)]},n.prototype.addAccount=function(t){var e=new v(this,t);return e.isValid()&&(this._accounts[t]=e),e},n.prototype.account=n.prototype.findAccount=function(t){var e=this.getAccount(t);return e?e:this.addAccount(t)},n.prototype.pathFind=n.prototype.createPathFind=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.src_currencies,r=i.dst_amount,e=i.dst_account,t=i.src_account}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");var o=new b(this,t,e,r,n);return this._cur_path_find&&this._cur_path_find.notify_superceded(),o.create(),this._cur_path_find=o,o},n.prepareTrade=function(t,e){var r=p.from_json(t).is_native()?"":"/"+e;return t+r},n.prototype.book=n.prototype.createOrderBook=function(t,e,r,i){if("object"==typeof t){var o=t;i=o.issuer_pays,r=o.currency_pays,e=o.issuer_gets,t=o.currency_gets}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");var s=n.prepareTrade(t,e),a=n.prepareTrade(r,i),u=s+":"+a;if(this._books.hasOwnProperty(u))return this._books[u];var c=new m(this,t,e,r,i,u);return c.is_valid()&&(this._books[u]=c),c},n.prototype.accountSeq=n.prototype.getAccountSequence=function(t,e){t=d.json_rewrite(t);var r=this.accounts[t];if(!r)return 0/0;var n=r.seq,i={ADVANCE:1,REWIND:-1}[e.toUpperCase()]||0;return r.seq+=i,n},n.prototype.setAccountSequence=n.prototype.setAccountSeq=function(t,e){t=d.json_rewrite(t),this.accounts.hasOwnProperty(t)||(this.accounts[t]={}),this.accounts[t].seq=e},n.prototype.accountSeqCache=function(t,e,r){function n(t){delete s.caching_seq_request;var e=t.node.Sequence;s.seq=e,a.emit("success_cache",t)}function i(t){delete s.caching_seq_request,a.emit("error_cache",t)}if("object"==typeof t){var o=t;r=e,e=o.ledger,t=o.account}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");this.accounts.hasOwnProperty(t)||(this.accounts[t]={});var s=this.accounts[t],a=s.caching_seq_request;return a||(a=this.requestLedgerEntry("account_root"),a.accountRoot(t),a.selectLedger(e),a.once("success",n),a.once("error",i),s.caching_seq_request=a),a.callback(r,"success_cache","error_cache"),a},n.prototype.dirtyAccountRoot=function(t){t=d.json_rewrite(t),delete this.ledgers.current.account_root[t]},n.prototype.requestOffer=function(t,e){var r=this.requestLedgerEntry("offer");return t.account&&t.sequence?r.offerId(t.account,t.sequence):t.index&&r.offerIndex(t.index),r.ledgerSelect(t.ledger),r.once("success",function(t){r.emit("offer",t)}),r.callback(e,"offer"),r},n.prototype.requestRippleBalance=function(t,e,r,n,i){function o(r){var n=r.node,i=l.from_json(n.LowLimit),o=l.from_json(n.HighLimit),s=l.from_json(n.Balance),u=d.from_json(t).equals(o.issuer());a.emit("ripple_state",{account_balance:(u?s.negate():s.clone()).parse_issuer(t),peer_balance:(u?s.clone():s.negate()).parse_issuer(e),account_limit:(u?o:i).clone().parse_issuer(e),peer_limit:(u?i:o).clone().parse_issuer(t),account_quality_in:u?n.HighQualityIn:n.LowQualityIn,peer_quality_in:u?n.LowQualityIn:n.HighQualityIn,account_quality_out:u?n.HighQualityOut:n.LowQualityOut,peer_quality_out:u?n.LowQualityOut:n.HighQualityOut})}if("object"==typeof t){var s=t;i=e,n=s.ledger,r=s.currency,e=s.issuer,t=s.account}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");var a=this.requestLedgerEntry("ripple_state");return a.rippleState(t,e,r),a.selectLedger(n),a.once("success",o),a.callback(i,"ripple_state"),a},n.prepareCurrency=n.prepareCurrencies=function(t){var e={};return t.hasOwnProperty("issuer")&&(e.issuer=d.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=p.json_rewrite(t.currency,{force_hex:!0})),e},n.prototype.requestRipplePathFind=function(t,e,r,i,o){if("object"==typeof t){var s=t;o=e,i=s.src_currencies,r=s.dst_amount,e=s.dst_account,t=s.src_account}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");var a=new h(this,"ripple_path_find");return a.message.source_account=d.json_rewrite(t),a.message.destination_account=d.json_rewrite(e),a.message.destination_amount=l.json_rewrite(r),i&&(a.message.source_currencies=i.map(n.prepareCurrencies)),a.callback(o),a},n.prototype.requestPathFindCreate=function(t,e,r,i,o){if("object"==typeof t){var s=t;o=e,i=s.src_currencies,r=s.dst_amount,e=s.dst_account,t=s.src_account}else S.warn("DEPRECATED: First argument to request constructor should be an object containing request properties");var a=new h(this,"path_find");return a.message.subcommand="create",a.message.source_account=d.json_rewrite(t),a.message.destination_account=d.json_rewrite(e),a.message.destination_amount=l.json_rewrite(r),i&&(a.message.source_currencies=i.map(n.prepareCurrencies)),a.callback(o),a},n.prototype.requestPathFindClose=function(t){var e=new h(this,"path_find");return e.message.subcommand="close",e.callback(t),e},n.prototype.requestUnlList=function(t){return new h(this,"unl_list").callback(t)},n.prototype.requestUnlAdd=function(t,e,r){var n=new h(this,"unl_add");return n.message.node=t,e&&(n.message.comment=void 0),n.callback(r),n},n.prototype.requestUnlDelete=function(t,e){var r=new h(this,"unl_delete");return r.message.node=t,r.callback(e),r},n.prototype.requestPeers=function(t){return new h(this,"peers").callback(t)},n.prototype.requestConnect=function(t,e,r){var n=new h(this,"connect");return n.message.ip=t,e&&(n.message.port=e),n.callback(r),n},n.prototype.transaction=n.prototype.createTransaction=function(t,e){if(0===arguments.length)return new y(this);s.strictEqual(typeof t,"string","TransactionType must be a string"),s.strictEqual(typeof e,"object","Transaction options must be an object");var r=new y(this),n={payment:"payment",accountset:"accountSet",trustset:"trustSet",offercreate:"offerCreate",offercancel:"offerCancel",setregularkey:"setRegularKey",sign:"sign"},i=n[t.toLowerCase()];if(!i)throw new Error("Invalid transaction type: "+t);return r[i](e)},n.prototype.feeTx=function(t){var e=this.getServer();if(!e)throw new Error("No connected servers");return e._feeTx(t)},n.prototype.feeTxUnit=function(){var t=this.getServer();if(!t)throw new Error("No connected servers");return t._feeTxUnit()},n.prototype.reserve=function(t){var e=this.getServer();if(!e)throw new Error("No connected servers");return e._reserve(t)},e.Remote=n},function(t,e,r){function n(t,e){i.call(this),this.remote=t,this.requested=!1,this.reconnectTimeout=3e3,this.successEvent="success",this.errorEvent="error",this.message={command:e,id:void 0}}{var i=r(37).EventEmitter,o=r(38),s=r(45),a=r(9).UInt160,u=r(6).Currency,c=r(14).RippleError;r(18).Server}o.inherits(n,i),n.prototype.request=function(t,e){return this.emit("before"),"function"==typeof t&&(e=t),this.callback(e),this.requested?this:(this.requested=!0,this.on("error",function(){}),this.emit("request",this.remote),Array.isArray(t)?t.forEach(function(t){this.setServer(t),this.remote.request(this)},this):this.remote.request(this),this)},n.prototype.filter=n.prototype.addFilter=n.prototype.broadcast=function(t){function e(r,s){function a(){clearTimeout(o[u]),o[u]=null,e(r,s)}if(r.isConnected())return n.once("proposed",function(e){i=e,s(t(e))}),r._request(n);var u=r.getServerID();o[u]=setTimeout(function(){r.removeListener("connect",a),s(!1)},n.reconnectTimeout),r.once("connect",a)}function r(t){a.call(n,t?"success":"error",i)}var n=this;if(!this.requested)return this.once("before",function(){n.requested=!0,n.broadcast(t)}),this;var t="function"==typeof t?t:Boolean,i=new Error("No servers available"),o={},a=this.emit;this.emit=function(t,e,r){switch(t){case"success":case"error":a.call(n,"proposed",e,r);break;default:a.apply(n,arguments)}};var u=this.remote._servers.filter(function(t){return!(!t.isConnected()&&!t._shouldConnect||n.message.hasOwnProperty("ledger_index")&&!t.hasLedger(n.message.ledger_index)||n.message.hasOwnProperty("ledger_index_min")&&-1!==n.message.ledger_index_min&&!t.hasLedger(n.message.ledger_index_min)||n.message.hasOwnProperty("ledger_index_max")&&-1!==n.message.ledger_index_max&&!t.hasLedger(n.message.ledger_index_max))});return s.some(u,e,r),this},n.prototype.cancel=function(){return this.removeAllListeners(),this.on("error",function(){}),this},n.prototype.setCallback=function(t){return"function"==typeof t&&this.callback(t),this},n.prototype.setReconnectTimeout=function(t){return"number"!=typeof t||isNaN(t)||(this.reconnectTimeout=t),this},n.prototype.callback=function(t,e,r){function n(e){s||(s=!0,t.call(o,null,e))}function i(e){s||(s=!0,e instanceof c||(e=new c(e)),t.call(o,e))}var o=this;if("function"!=typeof t)return this;"string"==typeof e&&(this.successEvent=e),"string"==typeof r&&(this.errorEvent=r);var s=!1;return this.once(this.successEvent,n),this.once(this.errorEvent,i),this.request(),this},n.prototype.timeout=function(t,e){function r(){n.timeout(t,e)}var n=this;if(!this.requested)return this.once("request",r);var i=this.emit,o=!1,s=setTimeout(function(){o=!0,"function"==typeof e&&e(),i.call(n,"timeout"),n.cancel()},t);return this.emit=function(){o||(clearTimeout(s),i.apply(n,arguments))},this},n.prototype.setServer=function(t){var e=null;switch(typeof t){case"object":e=t;break;case"string":for(var r,n=this.remote._servers,i=0;r=n[i];i++)if(r._url===t){e=r;break}}return this.server=e,this},n.prototype.buildPath=function(t){if(this.remote.local_signing)throw new Error("`build_path` is completely ignored when doing local signing as `Paths` is a component of the signed blob. The `tx_blob` is signed,sealed and delivered, and the txn unmodified after");return t?this.message.build_path=!0:delete this.message.build_path,this},n.prototype.ledgerChoose=function(t){return t?this.message.ledger_index=this.remote._ledger_current_index:this.message.ledger_hash=this.remote._ledger_hash,this},n.prototype.ledgerHash=function(t){return this.message.ledger_hash=t,this},n.prototype.ledgerIndex=function(t){return this.message.ledger_index=t,this},n.prototype.selectLedger=n.prototype.ledgerSelect=function(t){switch(t){case"current":case"closed":case"validated":this.message.ledger_index=t;break;default:Number(t)&&isFinite(Number(t))?this.message.ledger_index=Number(t):/^[A-F0-9]{64}$/.test(t)&&(this.message.ledger_hash=t)}return this},n.prototype.accountRoot=function(t){return this.message.account_root=a.json_rewrite(t),this},n.prototype.index=function(t){return this.message.index=t,this},n.prototype.offerId=function(t,e){return this.message.offer={account:a.json_rewrite(t),seq:e},this},n.prototype.offerIndex=function(t){return this.message.offer=t,this},n.prototype.secret=function(t){return t&&(this.message.secret=t),this},n.prototype.txHash=function(t){return this.message.tx_hash=t,this},n.prototype.txJson=function(t){return this.message.tx_json=t,this},n.prototype.txBlob=function(t){return this.message.tx_blob=t,this},n.prototype.rippleState=function(t,e,r){return this.message.ripple_state={currency:r,accounts:[a.json_rewrite(t),a.json_rewrite(e)]},this},n.prototype.setAccounts=n.prototype.accounts=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return a.json_rewrite(t)});return e?this.message.accounts_proposed=r:this.message.accounts=r,this},n.prototype.addAccount=function(t,e){if(Array.isArray(t))return t.forEach(this.addAccount,this),this;var r=a.json_rewrite(t),n=e===!0?"accounts_proposed":"accounts";return this.message[n]=(this.message[n]||[]).concat(r),this},n.prototype.setAccountsProposed=n.prototype.rtAccounts=n.prototype.accountsProposed=function(t){return this.accounts(t,!0)},n.prototype.addAccountProposed=function(t){return Array.isArray(t)?(t.forEach(this.addAccountProposed,this),this):this.addAccount(t,!0)
},n.prototype.setBooks=n.prototype.books=function(t,e){this.message.books=[];for(var r=0,n=t.length;n>r;r++){var i=t[r];this.addBook(i,e)}return this},n.prototype.addBook=function(t,e){function r(e){if(!t[e])throw new Error("Missing "+e);var r=n[e]={currency:u.json_rewrite(t[e].currency,{force_hex:!0})};u.from_json(r.currency).is_native()||(r.issuer=a.json_rewrite(t[e].issuer))}if(Array.isArray(t))return t.forEach(this.addBook,this),this;var n={};return["taker_gets","taker_pays"].forEach(r),"boolean"!=typeof e?n.snapshot=!0:e?n.snapshot=!0:delete n.snapshot,t.both&&(n.both=!0),this.message.books=(this.message.books||[]).concat(n),this},n.prototype.addStream=function(t,e){if(Array.isArray(e))switch(t){case"accounts":this.addAccount(e);break;case"accounts_proposed":this.addAccountProposed(e);break;case"books":this.addBook(e)}else if(arguments.length>1){for(arg in arguments)this.addStream(arguments[arg]);return}return Array.isArray(this.message.streams)||(this.message.streams=[]),-1===this.message.streams.indexOf(t)&&this.message.streams.push(t),this},e.Request=n},function(t,e,r){"use strict";function n(t){return new l(t).toPower(-1)}function i(){this._value=new l(0/0),this._is_native=!0,this._currency=new f,this._issuer=new u}var o=r(39),s=r(41),a=r(17),u=r(9).UInt160,c=r(11).Seed,f=r(6).Currency,h=r(46),l=h.another({ROUNDING_MODE:h.ROUND_HALF_UP,DECIMAL_PLACES:40});i.strict_mode=!0;var p={currency_xns:0,currency_one:1,xns_precision:6,bi_5:new l(5),bi_7:new l(7),bi_10:new l(10),bi_1e14:new l(1e14),bi_1e16:new l(1e16),bi_1e17:new l(1e17),bi_1e32:new l(1e32),bi_man_max_value:new l("9999999999999999"),bi_man_min_value:new l(1e15),bi_xns_max:new l(1e17),bi_xns_min:new l(-1e17),bi_xns_unit:new l(1e6),cMinOffset:-96,cMaxOffset:80,max_value:"9999999999999999e80",min_value:"-1000000000000000e-96"},d=new l(1e11),_=new l(p.max_value),y=new l(p.min_value).abs();s(i,p),e.consts=p,i.text_full_rewrite=function(t){return i.from_json(t).to_text_full()},i.json_rewrite=function(t){return i.from_json(t).to_json()},i.from_number=function(t){return(new i).parse_number(t)},i.from_json=function(t){return(new i).parse_json(t)},i.from_quality=function(t,e,r,n){return(new i).parse_quality(t,e,r,n)},i.from_human=function(t,e){return(new i).parse_human(t,e)},i.is_valid=function(t){return i.from_json(t).is_valid()},i.is_valid_full=function(t){return i.from_json(t).is_valid_full()},i.NaN=function(){var t=new i;return t._value=new l(0/0),t},i.prototype._set_value=function(t,e){o(t instanceof l),this._value=t.isZero()&&t.isNegative()?t.negated():t,this.canonicalize(e),this._check_limits()},i.prototype.abs=function(){return this.clone(this.is_negative())},i.prototype.add=function(t){var e=i.from_json(t);return this.is_comparable(e)?this._copy(this._value.plus(e._value)):new i(0/0)},i.prototype.subtract=function(t){return this.add(i.from_json(t).negate())},i.prototype.multiply=function(t){var e=i.from_json(t),r=e.is_native()?e._value.times(i.bi_xns_unit):e._value;return this._copy(this._value.times(r))},i.prototype.scale=function(t){return this._copy(this._value.times(t))},i.prototype.divide=function(t){var e=i.from_json(t);if(!this.is_valid())throw new Error("Invalid dividend");if(!e.is_valid())throw new Error("Invalid divisor");if(e.is_zero())throw new Error("divide by zero");var r=e.is_native()?e._value.times(i.bi_xns_unit):e._value;return this._copy(this._value.dividedBy(r))},i.prototype.ratio_human=function(t,e){e=s({},e);var r=this.clone();return t=i.from_json(t),r.is_valid()&&t.is_valid()?t.is_zero()?new i(0/0):(e.reference_date&&(t=t.applyInterest(e.reference_date)),t._is_native&&r._set_value(r._value.times(i.bi_xns_unit)),r.divide(t)):new i(0/0)},i.prototype.product_human=function(t,e){if(e=e||{},t=i.from_json(t),!this.is_valid()||!t.is_valid())return new i(0/0);e.reference_date&&(t=t.applyInterest(e.reference_date));var r=this.multiply(t);return t._is_native&&r._set_value(r._value.dividedBy(i.bi_xns_unit)),r},i.prototype._invert=function(){return this._set_value(n(this._value)),this},i.prototype.invert=function(){return this.clone()._invert()},i.prototype.canonicalize=function(t){this._value=this._is_native?this._value.round(6,l.ROUND_DOWN):new l(t?this._value.toPrecision(16,t):this._value.toPrecision(16))},i.prototype._check_limits=function(){if(!i.strict_mode)return this;if(this._value.isNaN()||this._value.isZero())return this;var t=this._value.absoluteValue();if(this._is_native){if(t.greaterThan(d))throw new Error("Exceeding max value of "+d.toString())}else{if(t.lessThan(y))throw new Error("Exceeding min value of "+y.toString());if(t.greaterThan(_))throw new Error("Exceeding max value of "+_.toString())}return this},i.prototype.clone=function(t){return this.copyTo(new i,t)},i.prototype._copy=function(t){var e=this.clone();return e._set_value(t),e},i.prototype.compareTo=function(t){var e=i.from_json(t);return this.is_comparable(e)?this._value.comparedTo(e._value):new i(0/0)},i.prototype.copyTo=function(t,e){return t._value=e?this._value.negated():this._value,t._is_native=this._is_native,t._currency=this._currency,t._issuer=this._issuer,t},i.prototype.currency=function(){return this._currency},i.prototype.equals=function(t,e){return t instanceof i?this.is_valid()&&t.is_valid()&&this._is_native===t._is_native&&this._value.equals(t._value)&&(this._is_native||this._currency.equals(t._currency)&&(e||this._issuer.equals(t._issuer))):this.equals(i.from_json(t))},i.prototype.is_comparable=function(t){return this.is_valid()&&t.is_valid()&&this._is_native===t._is_native},i.prototype.is_native=function(){return this._is_native},i.prototype.is_negative=function(){return this._value.isNegative()},i.prototype.is_positive=function(){return!this.is_zero()&&!this.is_negative()},i.prototype.is_valid=function(){return!this._value.isNaN()},i.prototype.is_valid_full=function(){return this.is_valid()&&this._currency.is_valid()&&this._issuer.is_valid()},i.prototype.is_zero=function(){return this._value.isZero()},i.prototype.issuer=function(){return this._issuer},i.prototype.negate=function(){return this.clone("NEGATE")},i.prototype.parse_human=function(t,e){function r(t){return isFinite(t)&&""!==t&&null!==t}e=e||{};var n,o,s=/^[a-fA-F0-9]{40}$/,a=/^([a-zA-Z]{3}|[0-9]{3})$/,u=t.split(" ").filter(function(t){return""!==t});if(1===u.length){if(r(u[0]))n=u[0],o="XRP";else if(n=u[0].slice(0,-3),o=u[0].slice(-3),!r(n)||!o.match(a))return new i(0/0)}else{if(2!==u.length)return new i(0/0);if(r(u[0])&&u[1].match(s))n=u[0],o=u[1];else if(u[0].match(a)&&r(u[1]))n=u[1],o=u[0];else{if(!r(u[0])||!u[1].match(a))return new i(0/0);n=u[0],o=u[1]}}if(o=o.toUpperCase(),this.set_currency(o),this._is_native="XRP"===o,this._set_value(new l(n)),e.reference_date&&this._currency.has_interest()){var c=this._currency.get_interest_at(e.reference_date);this._set_value(this._value.dividedBy(c.toString()))}return this},i.prototype.parse_issuer=function(t){return this._issuer=u.from_json(t),this},i.prototype.parse_quality=function(t,e,r,o){o=o||{};var s=f.from_json(o.base_currency),a=t.substring(t.length-14),c=t.substring(t.length-16,t.length-14),h=new l(a,16),p=parseInt(c,16)-100,d=new l(h.toString()+"e"+p.toString());if(this._currency=f.from_json(e),this._issuer=u.from_json(r),this._is_native=this._currency.is_native(),this._is_native&&s.is_native())throw new Error("XRP/XRP quality is not allowed");var _=o.inverse?n(d):d,y=_;if(o.xrp_as_drops||(this._is_native?y=_.div(i.bi_xns_unit):s.is_valid()&&s.is_native()&&(y=_.times(i.bi_xns_unit))),this._set_value(y),o.reference_date&&s.is_valid()&&s.has_interest()){var v=s.get_interest_at(o.reference_date);this._set_value(this._value.dividedBy(v.toString()))}return this},i.prototype.parse_number=function(t){return this._is_native=!1,this._currency=f.from_json(1),this._issuer=u.from_json(1),this._set_value(new l(t)),this},i.prototype.parse_json=function(t){switch(typeof t){case"string":var e=t.match(/^([^/]+)\/([^/]+)(?:\/(.+))?$/);e?(this._currency=f.from_json(e[2]),this._issuer=u.from_json(e[3]?e[3]:"1"),this.parse_value(e[1])):(this.parse_native(t),this._currency=f.from_json("0"),this._issuer=u.from_json("0"));break;case"number":this.parse_json(String(t));break;case"object":if(null===t)break;t instanceof i?t.copyTo(this):t.hasOwnProperty("value")&&(this._currency.parse_json(t.currency,!0),"string"==typeof t.issuer&&this._issuer.parse_json(t.issuer),this.parse_value(t.value));break;default:this._set_value(new l(0/0))}return this},i.prototype.parse_native=function(t){if(t&&"string"==typeof t&&!isNaN(t)){if(t.indexOf(".")>=0)throw new Error("Native amounts must be specified in integer drops");var e=new l(t);this._is_native=!0,this._set_value(e.dividedBy(i.bi_xns_unit))}else this._set_value(new l(0/0));return this},i.prototype.parse_value=function(t){return this._is_native=!1,this._set_value(new l(t),l.ROUND_DOWN),this},i.prototype.set_currency=function(t){return this._currency=f.from_json(t),this._is_native=this._currency.is_native(),this},i.prototype.set_issuer=function(t){return this._issuer=t instanceof u?t:u.from_json(t),this},i.prototype.to_number=function(){return Number(this.to_text())},i.prototype.to_text=function(){if(!this.is_valid())return"NaN";if(this._is_native)return this._value.times(i.bi_xns_unit).toString();var t=this._value.e-15,e=this._value.isNegative()?"-":"",r=a.getMantissaDecimalString(this._value.absoluteValue());if(0!==t&&(-25>t||t>-4))return e+r.toString()+"e"+t.toString();var n="000000000000000000000000000"+r.toString()+"00000000000000000000000",o=n.substring(0,t+43),s=n.substring(t+43),u=o.match(/[1-9].*$/),c=s.match(/[1-9]0*$/);return e+(u?u[0]:"0")+(c?"."+s.substring(0,1+s.length-c[0].length):"")},i.prototype.applyInterest=function(t){if(!this._currency.has_interest())return this;var e=this._currency.get_interest_at(t);return this._copy(this._value.times(e.toString()))},i.prototype.to_human=function(t){if(t=t||{},!this.is_valid())return"NaN";var e=this;t.reference_date&&(e=this.applyInterest(t.reference_date));var r=e._value.isNegative(),n=e._value.abs().toFixed(),i=n.split("."),o=i[0],s=2===i.length?i[1]:"";if(o=o.replace(/^0*/,""),s=s.replace(/0*$/,""),s.length||!t.skip_empty_fraction){if("number"==typeof t.precision){var u=Math.max(0,t.precision);u=Math.min(u,s.length);var c=Number("0."+s).toFixed(u);for(1>c?s=c.substring(2):(o=(Number(o)+1).toString(),s="");s.length<u;)s="0"+s}if("number"==typeof t.max_sig_digits){var f=0===Number(o),h=f?0:o.length,l=f?s.replace(/^0*/,""):s;h+=l.length;var p=h-t.max_sig_digits;p=Math.max(p,0),p=Math.min(p,s.length),p>0&&(s=s.slice(0,-p))}if("number"==typeof t.min_precision)for(t.min_precision=Math.max(0,t.min_precision);s.length<t.min_precision;)s+="0"}if(t.group_sep!==!1){var d="string"==typeof t.group_sep?t.group_sep:",",_=a.chunkString(o,t.group_width||3,!0);o=_.join(d)}var y="";return r&&t.signed!==!1&&(y+="-"),y+=o.length?o:"0",y+=s.length?"."+s:""},i.prototype.to_human_full=function(t){t=t||{};var e=this.to_human(t),r=this._currency.to_human(),n=this._issuer.to_json(t),i=e+"/"+r;return this.is_native()?i:i+"/"+n},i.prototype.to_json=function(){if(this._is_native)return this.to_text();var t={value:this.to_text(),currency:this._currency.has_interest()?this._currency.to_hex():this._currency.to_json()};return this._issuer.is_valid()&&(t.issuer=this._issuer.to_json()),t},i.prototype.to_text_full=function(t){return this.is_valid()?this._is_native?this.to_human()+"/XRP":this.to_text()+"/"+this._currency.to_json()+"/"+this._issuer.to_json(t):"NaN"},i.prototype.not_equals_why=function(t,e){if("string"==typeof t)return this.not_equals_why(i.from_json(t));if(!(t instanceof i))return"Not an Amount";if(!this.is_valid()||!t.is_valid())return"Invalid amount.";if(this._is_native!==t._is_native)return"Native mismatch.";var r=this._is_native?"XRP":"Non-XRP";if(!this._value.isZero()&&this._value.negated().equals(t._value))return r+" sign differs.";if(!this._value.equals(t._value))return r+" value differs.";if(!this._is_native){if(!this._currency.equals(t._currency))return"Non-XRP currency differs.";if(!e&&!this._issuer.equals(t._issuer))return"Non-XRP issuer differs: "+t._issuer.to_json()+"/"+this._issuer.to_json()}},e.Amount=i,e.Currency=f,e.Seed=c,e.UInt160=u},function(t,e,r){function n(t,e){function r(t){~n.subscribeEvents.indexOf(t)&&(!h._subs&&h._remote._connected&&h._remote.request_subscribe().add_account(h._account_id).broadcast().request(),h._subs+=1)}function i(t){~n.subscribeEvents.indexOf(t)&&(h._subs-=1,!h._subs&&h._remote._connected&&h._remote.request_unsubscribe().add_account(h._account_id).broadcast().request())}function o(t){h._account.is_valid()&&h._subs&&t.add_account(h._account_id)}function f(t){if(t.mmeta){var e=!1;t.mmeta.each(function(t){var r=t.fields.Account===h._account_id,n=r&&"AccountRoot"===t.entryType;n&&(s(h._entry,t.fieldsNew,t.fieldsFinal),e=!0)}),e&&h.emit("entry",h._entry)}}a.call(this);var h=this;return this._remote=t,this._account=u.from_json(e),this._account_id=this._account.to_json(),this._subs=0,this._entry={},this.on("newListener",r),this.on("removeListener",i),this._remote.on("prepare_subscribe",o),this.on("transaction",f),this._transactionManager=new c(this),this}var i=r(45),o=r(38),s=r(41),a=r(37).EventEmitter,u=(r(3).Amount,r(9).UInt160),c=r(28).TransactionManager,f=r(17).sjcl,h=r(7).Base;o.inherits(n,a),n.subscribeEvents=["transaction","entry"],n.prototype.toJson=function(){return this._account.to_json()},n.prototype.isValid=function(){return this._account.is_valid()},n.prototype.getInfo=function(t){return this._remote.requestAccountInfo({account:this._account_id},t)},n.prototype.entry=function(t){function e(e,n){e?t(e):(s(r._entry,n.account_data),r.emit("entry",r._entry),t(null,n))}var r=this,t="function"==typeof t?t:function(){};return this.getInfo(e),this},n.prototype.getNextSequence=function(t){function e(t){return t&&"object"==typeof t&&"object"==typeof t.remote&&"actNotFound"===t.remote.error}function r(r,n){e(r)?t(null,1):r?t(r):t(null,n.account_data.Sequence)}var t="function"==typeof t?t:function(){};return this.getInfo(r),this},n.prototype.lines=function(t){function e(e,n){e?t(e):(r._lines=n.lines,r.emit("lines",r._lines),t(null,n))}var r=this,t="function"==typeof t?t:function(){};return this._remote.requestAccountLines({account:this._account_id},e),this},n.prototype.line=function(t,e,r){var n=this,r="function"==typeof r?r:function(){};return n.lines(function(n,i){if(n)return r(n);var o;t:for(var s=0;s<i.lines.length;s++){var a=i.lines[s];if(a.account===e&&a.currency===t){o=a;break t}}r(null,o)}),this},n.prototype.notify=n.prototype.notifyTx=function(t){if(this._subs){this.emit("transaction",t);var e=t.transaction.Account;if(e){var r=e===this._account_id;this.emit(r?"transaction-outbound":"transaction-inbound",t)}}},n.prototype.submit=function(t){this._transactionManager.submit(t)},n.prototype.publicKeyIsActive=function(t,e){function r(t){a.getInfo(function(e,r){e&&e.remote&&"actNotFound"===e.remote.error?t(null,null):t(e,r)})}function o(t,e){if(!t)return void(s===a._account_id?e(null,!0):e(null,!1));var r=t.account_data;r.RegularKey&&r.RegularKey===s?e(null,!0):r.Account===s&&0===(1048576&r.Flags)?e(null,!0):e(null,!1)}var s,a=this;try{s=n._publicKeyToAddress(t)}catch(u){return e(u)}var c=[r,o];i.waterfall(c,e)},n._publicKeyToAddress=function(t){function e(t){var e=f.codec.hex.toBits(t),r=f.hash.ripemd160.hash(f.hash.sha256.hash(e)),n=u.from_bits(r);return n.set_version(h.VER_ACCOUNT_ID),n.to_json()}if(u.is_valid(t))return t;if(/^[0-9a-fA-F]+$/.test(t))return e(t);throw new Error("Public key is invalid. Must be a UInt160 or a hex string")},e.Account=n},function(t,e,r){"use strict";function n(t){o.call(this);var e=this,r="object"==typeof t;this.remote=t,this.tx_json={Flags:0},this._secret=void 0,this._build_path=!1,this._maxFee=r?this.remote.max_fee:void 0,this.state="unsubmitted",this.finalized=!1,this.previousSigningHash=void 0,this.submitIndex=void 0,this.canonical=r?this.remote.canonical_signing:!0,this.submittedIDs=[],this.attempts=0,this.submissions=0,this.responses=0,this.once("success",function(t){e.setState("validated"),e.finalize(t),e._successHandler&&e._successHandler(t)}),this.once("error",function(t){e.setState("failed"),e.finalize(t),e._errorHandler&&e._errorHandler(t)}),this.once("submitted",function(){e.setState("submitted")}),this.once("proposed",function(){e.setState("pending")})}var i=r(38),o=r(37).EventEmitter,s=r(17),a=r(17).sjcl,u=r(3).Amount,c=r(3).Currency,f=r(3).UInt160,h=r(11).Seed,l=r(13).SerializedObject,p=r(14).RippleError,d=r(26),_=r(27).internal.sub("transaction");i.inherits(n,o),n.fee_units={"default":10},n.flags={Universal:{FullyCanonicalSig:2147483648},AccountSet:{RequireDestTag:65536,OptionalDestTag:131072,RequireAuth:262144,OptionalAuth:524288,DisallowXRP:1048576,AllowXRP:2097152},TrustSet:{SetAuth:65536,NoRipple:131072,SetNoRipple:131072,ClearNoRipple:262144,SetFreeze:1048576,ClearFreeze:2097152},OfferCreate:{Passive:65536,ImmediateOrCancel:131072,FillOrKill:262144,Sell:524288},Payment:{NoRippleDirect:65536,PartialPayment:131072,LimitQuality:262144}},n.set_clear_flags={AccountSet:{asfRequireDest:1,asfRequireAuth:2,asfDisallowXRP:3,asfDisableMaster:4,asfAccountTxnID:5,asfNoFreeze:6,asfGlobalFreeze:7,asfDefaultRipple:8}},n.MEMO_TYPES={},n.ASCII_REGEX=/^[\x00-\x7F]*$/,n.formats=r(16).tx,n.prototype.consts={telLOCAL_ERROR:-399,temMALFORMED:-299,tefFAILURE:-199,terRETRY:-99,tesSUCCESS:0,tecCLAIMED:100},n.prototype.isTelLocal=function(t){return t>=this.consts.telLOCAL_ERROR&&t<this.consts.temMALFORMED},n.prototype.isTemMalformed=function(t){return t>=this.consts.temMALFORMED&&t<this.consts.tefFAILURE},n.prototype.isTefFailure=function(t){return t>=this.consts.tefFAILURE&&t<this.consts.terRETRY},n.prototype.isTerRetry=function(t){return t>=this.consts.terRETRY&&t<this.consts.tesSUCCESS},n.prototype.isTepSuccess=function(t){return t>=this.consts.tesSUCCESS},n.prototype.isTecClaimed=function(t){return t>=this.consts.tecCLAIMED},n.prototype.isRejected=function(t){return this.isTelLocal(t)||this.isTemMalformed(t)||this.isTefFailure(t)},n.from_json=function(t){return(new n).parseJson(t)},n.prototype.parseJson=function(t){return this.tx_json=t,this},n.prototype.setState=function(t){this.state!==t&&(this.state=t,this.emit("state",t))},n.prototype.finalize=function(t){return this.finalized=!0,this.result?(this.result.ledger_index=t.ledger_index,this.result.ledger_hash=t.ledger_hash):(this.result=t,this.result.tx_json=this.tx_json),this.emit("cleanup"),this.emit("final",t),this.remote&&this.remote.trace&&_.info("transaction finalized:",this.tx_json,this.getManager()._pending.getLength()),this},n.prototype.getAccount=function(){return this.tx_json.Account},n.prototype.getTransactionType=function(){return this.tx_json.TransactionType},n.prototype.getManager=function(t){return this.remote?(t||(t=this.tx_json.Account),this.remote.account(t)._transactionManager):void 0},n.prototype.getSecret=n.prototype._accountSecret=function(t){return this.remote?(t||(t=this.tx_json.Account),this.remote.secrets[t]):void 0},n.prototype._getFeeUnits=n.prototype.feeUnits=function(){return n.fee_units["default"]},n.prototype._computeFee=function(){if(!this.remote)return void 0;for(var t=this.remote._servers,e=[],r=0;r<t.length;r++){var n=t[r];n._connected&&e.push(Number(n._computeFee(this._getFeeUnits())))}switch(e.length){case 0:return void 0;case 1:return String(e[0])}e.sort(function(t,e){return t>e?1:e>t?-1:0});var i=Math.floor(e.length/2),o=e.length%2===0?Math.floor(.5+(e[i]+e[i-1])/2):e[i];return String(o)},n.prototype.complete=function(){if(this.remote&&!this.remote.trusted&&!this.remote.local_signing)return this.emit("error",new p("tejServerUntrusted","Attempt to give secret to untrusted server")),!1;if(this._secret||(this._secret=this.getSecret()),!this._secret)return this.emit("error",new p("tejSecretUnknown","Missing secret")),!1;if("undefined"==typeof this.tx_json.SigningPubKey)try{var t=h.from_json(this._secret),e=t.get_key(this.tx_json.Account);this.tx_json.SigningPubKey=e.to_hex_pub()}catch(r){return this.emit("error",new p("tejSecretInvalid","Invalid secret")),!1}return!this.remote||"undefined"!=typeof this.tx_json.Fee||!this.remote.local_fee&&this.remote.trusted||(this.tx_json.Fee=this._computeFee(),this.tx_json.Fee)?Number(this.tx_json.Fee)>this._maxFee?(this.emit("error",new p("tejMaxFeeExceeded","Max fee exceeded")),!1):(this.remote&&this.remote.local_signing&&this.canonical&&(this.tx_json.Flags|=n.flags.Universal.FullyCanonicalSig,this.tx_json.Flags=this.tx_json.Flags>>>0),this.tx_json):(this.emit("error",new p("tejUnconnected")),!1)},n.prototype.serialize=function(){return l.from_json(this.tx_json)},n.prototype.signingHash=function(t){return this.hash(t?"HASH_TX_SIGN_TESTNET":"HASH_TX_SIGN")},n.prototype.hash=function(t,e,r){if("string"==typeof t){if("undefined"==typeof d[t])throw new Error("Unknown hashing prefix requested.");t=d[t]}else t||(t=d.HASH_TX_ID);var n=(r||this.serialize()).hash(t);return e?n:n.to_hex()},n.prototype.sign=function(t){var e=h.from_json(this._secret),r=this.tx_json.TxnSignature;delete this.tx_json.TxnSignature;var n=this.signingHash(t);if(r&&n===this.previousSigningHash)return this.tx_json.TxnSignature=r,this;var i=e.get_key(this.tx_json.Account),o=i.sign(n),s=a.codec.hex.fromBits(o).toUpperCase();return this.tx_json.TxnSignature=s,this.previousSigningHash=n,this},n.prototype.addId=function(t){-1===this.submittedIDs.indexOf(t)&&this.submittedIDs.unshift(t)},n.prototype.findId=function(t){for(var e,r=0;r<this.submittedIDs.length;r++){var n=this.submittedIDs[r];if(e=t[n])break}return e},n.prototype.setBuildPath=n.prototype.buildPath=function(t){return this._build_path=t,this},n.prototype.sourceTag=function(t){return"number"==typeof t&&isFinite(t)&&(this.tx_json.SourceTag=t),this},n.prototype.setDestinationTag=n.prototype.destinationTag=function(t){return"number"==typeof t&&isFinite(t)&&(this.tx_json.DestinationTag=t),this},n.prototype.setInvoiceID=n.prototype.invoiceID=function(t){if("string"==typeof t){for(;t.length<64;)t+="0";this.tx_json.InvoiceID=t}return this},n.prototype.setClientID=n.prototype.clientID=function(t){return"string"==typeof t&&(this._clientID=t),this},n.prototype.setLastLedger=n.prototype.lastLedger=function(t){return"number"==typeof t&&isFinite(t)&&(this._setLastLedger=!0,this.tx_json.LastLedgerSequence=t),this},n.prototype.maxFee=function(t){return"number"==typeof t&&t>=0&&(this._setMaxFee=!0,this._maxFee=t),this},n.prototype.setFixedFee=function(t){return"number"==typeof t&&t>=0&&(this._setFixedFee=!0,this.tx_json.Fee=String(t)),this},n._rewritePath=function(t){if(!Array.isArray(t))throw new Error("Path must be an array");var e=t.map(function(t){var e={};return t.hasOwnProperty("account")&&(e.account=f.json_rewrite(t.account)),t.hasOwnProperty("issuer")&&(e.issuer=f.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=c.json_rewrite(t.currency)),t.hasOwnProperty("type_hex")&&(e.type_hex=t.type_hex),e});return e},n.prototype.addPath=n.prototype.pathAdd=function(t){return Array.isArray(t)&&(this.tx_json.Paths=this.tx_json.Paths||[],this.tx_json.Paths.push(n._rewritePath(t))),this},n.prototype.setPaths=n.prototype.paths=function(t){if(Array.isArray(t))for(var e=0,r=t.length;r>e;e++)this.addPath(t[e]);return this},n.prototype.setSecret=n.prototype.secret=function(t){return"string"==typeof t&&(this._secret=t),this},n.prototype.setSendMax=n.prototype.sendMax=function(t){return t&&(this.tx_json.SendMax=u.json_rewrite(t)),this},n.prototype.transferRate=function(t){return"number"==typeof t&&t>=1e9&&(this.tx_json.TransferRate=t),this},n.prototype.setFlags=function(t){if(void 0===t)return this;if("number"==typeof t)return this.tx_json.Flags=t,this;for(var e=n.flags[this.getTransactionType()]||{},r=Array.isArray(t)?t:[].slice.call(arguments),i=0,o=r.length;o>i;i++){var s=r[i];if(!e.hasOwnProperty(s))return this.emit("error",new p("tejInvalidFlag"));this.tx_json.Flags+=e[s]}return this},n.prototype.addMemo=function(t,e,r){function i(t){var e=a.codec.utf8String.toBits(t);return a.codec.hex.fromBits(e).toUpperCase()}if("object"==typeof t){var o=t;t=o.memoType,e=o.memoFormat,r=o.memoData}if(!/(undefined|string)/.test(typeof t))throw new Error("MemoType must be a string");if(!n.ASCII_REGEX.test(t))throw new Error("MemoType must be valid ASCII");if(!/(undefined|string)/.test(typeof e))throw new Error("MemoFormat must be a string");if(!n.ASCII_REGEX.test(e))throw new Error("MemoFormat must be valid ASCII");var s={};if(t&&(n.MEMO_TYPES[t]&&(t=n.MEMO_TYPES[t]),s.MemoType=i(t)),e&&(s.MemoFormat=i(e)),r){if("string"!=typeof r){if("json"!==e)throw new Error("MemoData can only be a JSON object with a valid json MemoFormat");try{r=JSON.stringify(r)}catch(u){throw new Error("MemoFormat json with invalid JSON in MemoData field")}}s.MemoData=i(r)}return this.tx_json.Memos=(this.tx_json.Memos||[]).concat({Memo:s}),this},n.prototype.setAccountTxnID=n.prototype.accountTxnID=function(t){return"string"==typeof t&&(this.tx_json.AccountTxnID=t),this},n.prototype.accountSet=function(t,e,r){function i(t){return"number"==typeof t?t:a[t]||a["asf"+t]}if("object"==typeof t){var o=t;t=o.source||o.from||o.account,e=o.set_flag||o.set,r=o.clear_flag||o.clear}if(!f.is_valid(t))throw new Error("Source address invalid");this.tx_json.TransactionType="AccountSet",this.tx_json.Account=f.json_rewrite(t);var s,a=n.set_clear_flags.AccountSet;return e&&(s=i(e),s&&(this.tx_json.SetFlag=s)),r&&(s=i(r),s&&(this.tx_json.ClearFlag=s)),this},n.prototype.claim=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.signature,r=i.public_key,e=i.generator,t=i.source||i.from||i.account}return this.tx_json.TransactionType="Claim",this.tx_json.Generator=e,this.tx_json.PublicKey=r,this.tx_json.Signature=n,this},n.prototype.offerCancel=function(t,e){if("object"==typeof t){var r=t;e=r.sequence,t=r.source||r.from||r.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCancel",this.tx_json.Account=f.json_rewrite(t),this.tx_json.OfferSequence=Number(e),this},n.prototype.offerCreate=function(t,e,r,n,i){if("object"==typeof t){var o=t;i=o.cancel_sequence||o.sequence,n=o.expiration,r=o.taker_gets||o.sell,e=o.taker_pays||o.buy,t=o.source||o.from||o.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCreate",this.tx_json.Account=f.json_rewrite(t),this.tx_json.TakerPays=u.json_rewrite(e),this.tx_json.TakerGets=u.json_rewrite(r),n&&(this.tx_json.Expiration=s.time.toRipple(n)),i&&(this.tx_json.OfferSequence=Number(i)),this},n.prototype.setRegularKey=function(t,e){if("object"==typeof t){var r=t;t=r.address||r.account||r.from,e=r.regular_key}if(!f.is_valid(t))throw new Error("Source address invalid");if(!f.is_valid(e))throw new Error("RegularKey must be a valid Ripple Address");return this.tx_json.TransactionType="SetRegularKey",this.tx_json.Account=f.json_rewrite(t),this.tx_json.RegularKey=f.json_rewrite(e),this},n.prototype.payment=function(t,e,r){if("object"==typeof t){var n=t;r=n.amount,e=n.destination||n.to,t=n.source||n.from||n.account}if(!f.is_valid(t))throw new Error("Payment source address invalid");if(!f.is_valid(e))throw new Error("Payment destination address invalid");return this.tx_json.TransactionType="Payment",this.tx_json.Account=f.json_rewrite(t),this.tx_json.Amount=u.json_rewrite(r),this.tx_json.Destination=f.json_rewrite(e),this},n.prototype.trustSet=n.prototype.rippleLineSet=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.quality_out,r=i.quality_in,e=i.limit,t=i.source||i.from||i.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="TrustSet",this.tx_json.Account=f.json_rewrite(t),void 0!==e&&(this.tx_json.LimitAmount=u.json_rewrite(e)),r&&(this.tx_json.QualityIn=r),n&&(this.tx_json.QualityOut=n),this},n.prototype.submit=function(t){var e=this;return this.callback="function"==typeof t?t:function(){},this._errorHandler=function(t,r){t instanceof p||(t=new p(t,r)),e.callback(t)},this._successHandler=function(t){e.callback(null,t)},this.remote?(this.getManager().submit(this),this):(this.emit("error",new Error("No remote found")),this)},n.prototype.abort=function(){this.finalized||this.emit("error",new p("tejAbort","Transaction aborted"))},n.prototype.summary=function(){var t={tx_json:this.tx_json,clientID:this._clientID,submittedIDs:this.submittedIDs,submissionAttempts:this.attempts,submitIndex:this.submitIndex,initialSubmitIndex:this.initialSubmitIndex,lastLedgerSequence:this.lastLedgerSequence,state:this.state,server:this._server?this._server._opts.url:void 0,finalized:this.finalized};return this.result&&(t.result={engine_result:this.result.engine_result,engine_result_message:this.result.engine_result_message,ledger_hash:this.result.ledger_hash,ledger_index:this.result.ledger_index,transaction_hash:this.result.tx_json.hash}),t},e.Transaction=n},function(t,e,r){"use strict";var n=r(41),i=r(9).UInt160,o=r(17),s=r(29).Float,a=n(function(){this._value=0/0,this._update()},i);a.prototype=n({},i.prototype),a.prototype.constructor=a,a.HEX_CURRENCY_BAD="0000000000000000000000005852500000000000",a.prototype.human_RE=/^\s*([a-zA-Z0-9\<\>\(\)\{\}\[\]\|\?\!\@\#\$\%\^\&]{3})(\s*-\s*[- \w]+)?(\s*\(-?\d+\.?\d*%pa\))?\s*$/,a.from_json=function(t,e){return(new a).parse_json(t,e)},a.from_human=function(t,e){return(new a).parse_human(t,e)},a.prototype.parse_json=function(t,e){if(this._value=0/0,t instanceof a)return this._value=t.copyTo({})._value,this._update(),this;switch(typeof t){case"number":isNaN(t)||this.parse_number(t);break;case"string":if(!t||"0"===t){this.parse_hex(e?a.HEX_CURRENCY_BAD:a.HEX_ZERO);break}if("1"===t){this.parse_hex(a.HEX_ONE);break}if(/^[A-F0-9]{40}$/.test(t)){this.parse_hex(t);break}var r=t.match(this.human_RE);if(r){var n=r[1];if(!n||/^(0|XRP)$/.test(n)){this.parse_hex(e?a.HEX_CURRENCY_BAD:a.HEX_ZERO);break}var i=r[3]||"",u=i.match(/(-?\d+\.?\d+)/);n=n.toUpperCase();var c=o.arraySet(20,0);if(u){c[0]=1,c[1]=255&n.charCodeAt(0),c[2]=255&n.charCodeAt(1),c[3]=255&n.charCodeAt(2),u=parseFloat(u[0]);for(var f=31536e3,h=f/Math.log(1+u/100),l=s.toIEEE754Double(h),p=0;p<=l.length;p++)c[8+p]=255&l[p]}else c[12]=255&n.charCodeAt(0),c[13]=255&n.charCodeAt(1),c[14]=255&n.charCodeAt(2);this.parse_bytes(c)}}return this},a.prototype.parse_human=function(t){return this.parse_json(t)},a.prototype._update=function(){var t=this.to_bytes(),e=!0;if(t){this._native=!1,this._type=-1,this._interest_start=0/0,this._interest_period=0/0,this._iso_code="";for(var r=0;20>r;r++)e=e&&(12===r||13===r||14===r||0===t[r]);e?(this._iso_code=String.fromCharCode(t[12])+String.fromCharCode(t[13])+String.fromCharCode(t[14]),"\x00\x00\x00"===this._iso_code&&(this._native=!0,this._iso_code="XRP"),this._type=0):1===t[0]&&(this._iso_code=String.fromCharCode(t[1])+String.fromCharCode(t[2])+String.fromCharCode(t[3]),this._type=1,this._interest_start=(t[4]<<24)+(t[5]<<16)+(t[6]<<8)+t[7],this._interest_period=s.fromIEEE754Double(t.slice(8,16)))}},a.prototype.is_native=function(){return this._native},a.prototype.has_interest=function(){return 1===this._type&&!isNaN(this._interest_start)&&!isNaN(this._interest_period)},a.prototype.get_interest_at=function(t){return this.has_interest()?(t||(t=this._interest_start+31536e3),t instanceof Date&&(t=o.fromTimestamp(t.getTime())),Math.exp((t-this._interest_start)/this._interest_period)):0},a.prototype.get_interest_percentage_at=function(t,e){var r=this.get_interest_at(t,e);r=100*r-100;var n=e?Math.pow(10,e):100;return Math.round(r*n)/n},a.prototype.to_json=function(t){if(!this.is_valid())return"XRP";t||(t={});var e,r=t&&t.full_name?" - "+t.full_name:"";if(t.show_interest=void 0!==t.show_interest?t.show_interest:this.has_interest(),!t.force_hex&&/^[A-Z0-9]{3}$/.test(this._iso_code)){if(e=this._iso_code+r,t.show_interest){var n=isNaN(t.decimals)?void 0:t.decimals,i=this.has_interest()?this.get_interest_percentage_at(this._interest_start+31536e3,n):0;
e+=" ("+i+"%pa)"}}else e=this.to_hex(),e===a.HEX_ONE&&(e=1);return e},a.prototype.to_human=function(t){return this.to_json(t)},a.prototype.get_iso=function(){return this._iso_code},e.Currency=a},function(t,e,r){"use strict";function n(t){return u.codec.bytes.fromBits(u.hash.sha256.hash(u.codec.bytes.toBits(t)))}function i(t,e){if(0===e.length)return"";var r=a.takeWhile(e,function(t){return 0===t}),n=h(e,256,58).map(function(e){if(0>e||e>=t.length)throw new Error("Value "+e+" is out of bounds for encoding");return t[e]}),i=r.map(function(){return t[0]});return i.concat(n).join("")}function o(t,e){if(0===e.length)return[];var r=e.split("").map(function(e){var r=e.charCodeAt(0);if(r>=t.length||-1===t[r])throw new Error("Character "+e+" is not valid for encoding");return t[r]}),n=a.takeWhile(r,function(t){return 0===t}),i=h(r,58,256);return n.concat(i)}function s(t){for(var e=c.arraySet(128,-1),r=0;r<t.length;r++)e[t.charCodeAt(r)]=r;return{decode:o.bind(null,e),encode:i.bind(null,t)}}var a=r(40),u=r(17).sjcl,c=r(17),f=r(41),h=r(22),l={},p=l.alphabets={ripple:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",tipple:"RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"};f(l,{VER_NONE:1,VER_NODE_PUBLIC:28,VER_NODE_PRIVATE:32,VER_ACCOUNT_ID:0,VER_ACCOUNT_PUBLIC:35,VER_ACCOUNT_PRIVATE:34,VER_FAMILY_GENERATOR:41,VER_FAMILY_SEED:33}),l.encoders={},Object.keys(p).forEach(function(t){l.encoders[t]=new s(p[t])}),l.encode=function(t,e){return this.encoders[e||"ripple"].encode(t)},l.decode=function(t,e){if("string"!=typeof t)return void 0;try{return this.encoders[e||"ripple"].decode(t)}catch(r){return void 0}},l.verify_checksum=function(t){var e=n(n(t.slice(0,-4))).slice(0,4),r=t.slice(-4);return a.isEqual(e,r)},l.encode_check=function(t,e,r){var i=[].concat(t,e),o=n(n(i)).slice(0,4);return l.encode([].concat(i,o),r)},l.decode_check=function(t,e,r){var n=l.decode(e,r);return!n||n.length<5?0/0:"number"==typeof t&&n[0]!==t?0/0:Array.isArray(t)&&a.every(t,function(t){return t!==n[0]})?0/0:l.verify_checksum(n)?(n[0]=0,u.bn.fromBits(u.codec.bytes.toBits(n.slice(0,-4)))):0/0},e.Base=l},function(t,e,r){"use strict";var n=r(17),i=r(41),o=r(30).UInt,s=i(function(){this._value=0/0},o);s.width=16,s.prototype=i({},o.prototype),s.prototype.constructor=s;var a=s.HEX_ZERO="00000000000000000000000000000000",u=s.HEX_ONE="00000000000000000000000000000000";s.STR_ZERO=n.hexToString(a),s.STR_ONE=n.hexToString(u),e.UInt128=s},function(t,e,r){"use strict";var n=r(17),i=r(41),o=r(30).UInt,s=r(7).Base,a=i(function(){this._value=0/0,this._version_byte=void 0,this._update()},o);a.width=20,a.prototype=i({},o.prototype),a.prototype.constructor=a;var u=a.HEX_ZERO="0000000000000000000000000000000000000000",c=a.HEX_ONE="0000000000000000000000000000000000000001";a.ACCOUNT_ZERO="rrrrrrrrrrrrrrrrrrrrrhoLvTp",a.ACCOUNT_ONE="rrrrrrrrrrrrrrrrrrrrBZbvji",a.STR_ZERO=n.hexToString(u),a.STR_ONE=n.hexToString(c),a.prototype.set_version=function(t){return this._version_byte=t,this},a.prototype.get_version=function(){return this._version_byte},a.prototype.parse_json=function(t){return"number"!=typeof t||isNaN(t)?"string"!=typeof t?this._value=0/0:"r"===t[0]?(this._value=s.decode_check(s.VER_ACCOUNT_ID,t),this._version_byte=s.VER_ACCOUNT_ID):this.parse_hex(t):(this.parse_number(t),this._version_byte=s.VER_ACCOUNT_ID),this._update(),this},a.prototype.parse_generic=function(t){return o.prototype.parse_generic.call(this,t),isNaN(this._value)&&"string"==typeof t&&"r"===t[0]&&(this._value=s.decode_check(s.VER_ACCOUNT_ID,t)),this._update(),this},a.prototype.to_json=function(t){if(t=t||{},this.is_valid()){if("number"==typeof this._version_byte){var e=s.encode_check(this._version_byte,this.to_bytes());return t.gateways&&e in t.gateways&&(e=t.gateways[e]),e}return this.to_hex()}return 0/0},e.UInt160=a},function(t,e,r){"use strict";var n=r(17),i=r(41),o=r(30).UInt,s=i(function(){this._value=0/0},o);s.width=32,s.prototype=i({},o.prototype),s.prototype.constructor=s;var a=s.HEX_ZERO="0000000000000000000000000000000000000000000000000000000000000000",u=s.HEX_ONE="0000000000000000000000000000000000000000000000000000000000000001";s.STR_ZERO=n.hexToString(a),s.STR_ONE=n.hexToString(u),e.UInt256=s},function(t,e,r){"use strict";function n(t,e){return[].concat(t,e>>24,e>>16&255,e>>8&255,255&e)}function i(t){return a.bitArray.bitSlice(a.hash.sha512.hash(a.codec.bytes.toBits(t)),0,256)}var o=r(41),s=r(17),a=s.sjcl,u=r(7).Base,c=r(30).UInt,f=r(9).UInt160,h=r(31).KeyPair,l=o(function(){this._curve=a.ecc.curves.k256,this._value=0/0},c);l.width=16,l.prototype=o({},c.prototype),l.prototype.constructor=l,l.prototype.parse_json=function(t){return"string"==typeof t&&t.length?"s"===t[0]?this._value=u.decode_check(u.VER_FAMILY_SEED,t):/^[0-9a-fA-f]{32}$/.test(t)?this.parse_hex(t):this.parse_passphrase(t):this._value=0/0,this},l.prototype.parse_passphrase=function(t){if("string"!=typeof t)throw new Error("Passphrase must be a string");var e=a.hash.sha512.hash(a.codec.utf8String.toBits(t)),r=a.bitArray.bitSlice(e,0,128);return this.parse_bits(r),this},l.prototype.to_json=function(){if(!this.is_valid())return 0/0;var t=u.encode_check(u.VER_FAMILY_SEED,this.to_bytes());return t},l.prototype.get_key=function(t,e){var r,o=0,s=e||1;if(!this.is_valid())throw new Error("Cannot generate keys from invalid seed!");t&&("number"==typeof t?(o=t,s=o+1):r=f.from_json(t));var u,c,l=this._curve,p=0;do u=a.bn.fromBits(i(n(this.to_bytes(),p))),p++;while(!l.r.greaterEquals(u));c=l.G.mult(u);var d,_;do{p=0;do d=a.bn.fromBits(i(n(n(c.toBytesCompressed(),o),p))),p++;while(!l.r.greaterEquals(d));if(o++,d=d.add(u).mod(l.r),_=h.from_bn_secret(d),s--<=0)throw new Error("Too many loops looking for KeyPair yielding "+r.to_json()+" from "+this.to_json())}while(r&&!_.get_address().equals(r));return _},e.Seed=l},function(t,e,r){function n(t){if(this.nodes=[],"object"!=typeof t)throw new TypeError("Missing metadata");if(!Array.isArray(t.AffectedNodes))throw new TypeError("Metadata missing AffectedNodes");t.AffectedNodes.forEach(this.addNode,this)}var i=r(41),o=r(17),s=r(9).UInt160,a=r(3).Amount;n.NODE_TYPES=["CreatedNode","ModifiedNode","DeletedNode"],n.AMOUNT_FIELDS_AFFECTING_ISSUER=["LowLimit","HighLimit","TakerPays","TakerGets"],n.ACCOUNT_FIELDS=["Account","Owner","Destination","Issuer","Target"],n.prototype.getNodeType=function(t){for(var e=null,r=0;r<n.NODE_TYPES.length;r++){var i=n.NODE_TYPES[r];if(t.hasOwnProperty(i)){e=i;break}}return e},n.prototype.isAccountField=function(t){return-1!==n.ACCOUNT_FIELDS.indexOf(t)},n.prototype.addNode=function(t){this._affectedAccounts=void 0,this._affectedBooks=void 0;var e={};(e.nodeType=this.getNodeType(t))&&(t=t[e.nodeType],e.diffType=e.nodeType,e.entryType=t.LedgerEntryType,e.ledgerIndex=t.LedgerIndex,e.fields=i({},t.PreviousFields,t.NewFields,t.FinalFields),e.fieldsPrev=t.PreviousFields||{},e.fieldsNew=t.NewFields||{},e.fieldsFinal=t.FinalFields||{},this.nodes.push(e))},n.prototype.getNodes=function(t){return"object"==typeof t?this.nodes.filter(function(e){return t.nodeType&&t.nodeType!==e.nodeType?!1:t.entryType&&t.entryType!==e.entryType?!1:t.bookKey&&t.bookKey!==e.bookKey?!1:!0}):this.nodes},n.prototype.getAffectedAccounts=function(){if(this._affectedAccounts)return this._affectedAccounts;for(var t=[],e=0;e<this.nodes.length;e++){var r=this.nodes[e],i="CreatedNode"===r.nodeType?r.fieldsNew:r.fieldsFinal;for(var u in i){var c=i[u];if(this.isAccountField(u)&&s.is_valid(c))t.push(c);else if(~n.AMOUNT_FIELDS_AFFECTING_ISSUER.indexOf(u)){var f=a.from_json(c),h=f.issuer();h.is_valid()&&!h.is_zero()&&t.push(h.to_json())}}}return this._affectedAccounts=o.arrayUnique(t),this._affectedAccounts},n.prototype.getAffectedBooks=function(){if(this._affectedBooks)return this._affectedBooks;for(var t=[],e=0;e<this.nodes.length;e++){var r=this.nodes[e];if("Offer"===r.entryType){var n=a.from_json(r.fields.TakerGets),i=a.from_json(r.fields.TakerPays),s=n.currency().to_json(),u=i.currency().to_json();"XRP"!==s&&(s+="/"+n.issuer().to_json()),"XRP"!==u&&(u+="/"+i.issuer().to_json());var c=s+":"+u;r.bookKey=c,t.push(c)}}return this._affectedBooks=o.arrayUnique(t),this._affectedBooks},["forEach","map","filter","every","some","reduce"].forEach(function(t){n.prototype[t]=function(){return Array.prototype[t].apply(this.nodes,arguments)}}),n.prototype.each=n.prototype.forEach,e.Meta=n},function(t,e,r){(function(t){"use strict";function n(t){var e=t.slice(2),r=s.findIndex(e,function(t){return"0"!==t});return r>=0?e.slice(r):"0"}function i(e){if(Array.isArray(e)||t&&t.isBuffer(e))this.buffer=e;else if("string"==typeof e)this.buffer=p.codec.bytes.fromBits(p.codec.hex.toBits(e));else{if(e)throw new Error("Invalid buffer passed.");this.buffer=[]}this.pointer=0}function o(t){return function(e){var r=this.pointer,n=r+e;if(n>this.buffer.length)throw new Error("Buffer length exceeded");var i=this.buffer.slice(r,n);return t&&(this.pointer=n),i}}var s=r(40),a=r(39),u=r(41),c=r(16),f=r(23),h=r(17),l=r(10).UInt256,p=h.sjcl,d={};Object.keys(c.tx).forEach(function(t){d[c.tx[t][0]]=t});var _={};Object.keys(c.ledger).forEach(function(t){_[c.ledger[t][0]]=t});var y={};Object.keys(c.ter).forEach(function(t){y[c.ter[t]]=t}),i.from_json=function(t){t=u(!0,{},t);var e,r=new i;if("number"==typeof t.TransactionType&&(t.TransactionType=i.lookup_type_tx(t.TransactionType),!t.TransactionType))throw new Error("Transaction type ID is invalid.");if("number"==typeof t.LedgerEntryType&&(t.LedgerEntryType=i.lookup_type_le(t.LedgerEntryType),!t.LedgerEntryType))throw new Error("LedgerEntryType ID is invalid.");if("string"==typeof t.TransactionType){if(e=c.tx[t.TransactionType],!Array.isArray(e))throw new Error("Transaction type is invalid");e=e.slice(),t.TransactionType=e.shift()}else if("string"==typeof t.LedgerEntryType){if(e=c.ledger[t.LedgerEntryType],!Array.isArray(e))throw new Error("LedgerEntryType is invalid");e=e.slice(),t.LedgerEntryType=e.shift()}else{if("object"!=typeof t.AffectedNodes)throw new Error("Object to be serialized must contain either TransactionType, LedgerEntryType or AffectedNodes.");e=c.metadata}return i.check_no_missing_fields(e,t),r.serialize(e,t),r},i.check_no_missing_fields=function(t,e){for(var r=[],n=t.length-1;n>=0;n--){var o=t[n],s=o[0],a=o[1];c.REQUIRED===a&&void 0===e[s]&&r.push(s)}if(r.length>0){var u;throw u=void 0!==e.TransactionType?i.lookup_type_tx(e.TransactionType):void 0!==e.LedgerEntryType?i.lookup_type_le(e.LedgerEntryType):"TransactionMetaData",new Error(u+" is missing fields: "+JSON.stringify(r))}},i.prototype.append=function(t){t instanceof i&&(t=t.buffer),Array.isArray(this.buffer)&&Array.isArray(t)?Array.prototype.push.apply(this.buffer,t):this.buffer=this.buffer.concat(t),this.pointer+=t.length},i.prototype.resetPointer=function(){this.pointer=0},i.prototype.read=o(!0),i.prototype.peek=o(!1),i.prototype.to_bits=function(){return p.codec.bytes.toBits(this.buffer)},i.prototype.to_hex=function(){return p.codec.hex.fromBits(this.to_bits()).toUpperCase()},i.prototype.to_json=function(){var t=this.pointer;this.resetPointer();for(var e={};this.pointer<this.buffer.length;){var r=f.parse(this),n=r[0],o=r[1];e[n]=i.jsonify_structure(o,n)}return this.pointer=t,e},i.jsonify_structure=function(t,e){var r;switch(typeof t){case"number":switch(e){case"LedgerEntryType":r=_[t];break;case"TransactionResult":r=y[t];break;case"TransactionType":r=d[t];break;default:r=t}break;case"object":if(null===t)break;if("function"==typeof t.to_json)r=t.to_json();else if(t instanceof p.bn)r=("0000000000000000"+n(t.toString()).toUpperCase()).slice(-16);else{r=new t.constructor;for(var o=Object.keys(t),s=0,a=o.length;a>s;s++){var u=o[s];r[u]=i.jsonify_structure(t[u],u)}}break;default:r=t}return r},i.prototype.serialize=function(t,e){f.Object.serialize(this,e,!0)},i.prototype.hash=function(t){var e=new i;"undefined"!=typeof t&&f.Int32.serialize(e,t),e.append(this.buffer);var r=p.codec.bytes.toBits(e.buffer),n=p.codec.hex.fromBits(p.hash.sha512.hash(r));return l.from_hex(n.substr(0,64))},i.prototype.signing_hash=i.prototype.hash,i.prototype.serialize_field=function(t,e){var r=t[0],n=t[1];if("undefined"!=typeof e[r])try{f.serialize(this,r,e[r])}catch(i){throw i.message='Error serializing "'+r+'": '+i.message,i}else if(n===c.REQUIRED)throw new Error("Missing required field "+r)},i.get_field_header=function(t,e){var r=[0];return t>15?r.push(255&t):r[0]+=(15&t)<<4,e>15?r.push(255&e):r[0]+=15&e,r},i.sort_typedef=function(t){function e(t,e){return t[3]!==e[3]?f[t[3]].id-f[e[3]].id:t[2]-e[2]}return a(Array.isArray(t)),t.sort(e)},i.lookup_type_tx=function(t){return a.strictEqual(typeof t,"number"),d[t]},i.lookup_type_le=function(t){return a("number"==typeof t),_[t]},e.SerializedObject=i}).call(e,r(42).Buffer)},function(t,e,r){function n(t,e){switch(typeof t){case"object":o(this,t);break;case"string":this.result=t,this.result_message=e}this.engine_result=this.result=this.result||this.engine_result||this.error||"Error",this.engine_result_message=this.result_message=this.result_message||this.engine_result_message||this.error_message||"Error",this.result_message=this.message=this.result_message;var r;Error.captureStackTrace?Error.captureStackTrace(this,t||this):(r=(new Error).stack)&&(this.stack=r)}var i=r(38),o=r(41);i.inherits(n,Error),n.prototype.name="RippleError",e.RippleError=n},function(t,e,r){"use strict";var n=r(45),i=r(17).sjcl,o=r(1).Remote,s=r(11).Seed,a=r(31).KeyPair,u=r(4).Account,c=r(9).UInt160,f={};f.hashFunction=i.hash.sha512.hash,f.MAGIC_BYTES="Ripple Signed Message:\n";var h=/^[0-9a-fA-F]+$/,l=/^([A-Za-z0-9\+]{4})*([A-Za-z0-9\+]{2}==)|([A-Za-z0-9\+]{3}=)?$/;f.signMessage=function(t,e,r){return f.signHash(f.hashFunction(f.MAGIC_BYTES+t),e,r)},f.signHash=function(t,e,r){if("string"==typeof t&&/^[0-9a-fA-F]+$/.test(t)&&(t=i.codec.hex.toBits(t)),"object"!=typeof t||t.length<=0||"number"!=typeof t[0])throw new Error("Hash must be a bitArray or hex-encoded string");e instanceof i.ecc.ecdsa.secretKey||(e=s.from_json(e).get_key(r)._secret);var n=6,o=e.signWithRecoverablePublicKey(t,n),a=i.codec.base64.fromBits(o);return a},f.verifyMessageSignature=function(t,e,r){return"string"!=typeof t.message?r(new Error("Data object must contain message field to verify signature")):(t.hash=f.hashFunction(f.MAGIC_BYTES+t.message),f.verifyHashSignature(t,e,r))},f.verifyHashSignature=function(t,e,r){function s(t){var e;try{e=i.ecc.ecdsa.publicKey.recoverFromSignature(p,_)}catch(r){return t(r)}e?t(null,e):t(new Error("Could not recover public key from signature"))}function f(t,r){var n=new a;n._pubkey=t;var i=n.to_hex_pub(),o=new u(e,d);o.publicKeyIsActive(i,r)}var p,d,_;if("function"!=typeof r)throw new Error("Must supply callback function");if(p=t.hash,p&&"string"==typeof p&&h.test(p)&&(p=i.codec.hex.toBits(p)),"object"!=typeof p||p.length<=0||"number"!=typeof p[0])return r(new Error("Hash must be a bitArray or hex-encoded string"));if(d=t.account||t.address,!d||!c.from_json(d).is_valid())return r(new Error("Account must be a valid ripple address"));if(_=t.signature,"string"!=typeof _||!l.test(_))return r(new Error("Signature must be a Base64-encoded string"));if(_=i.codec.base64.toBits(_),!(e instanceof o)||"online"!==e.state)return r(new Error("Must supply connected Remote to verify signature"));var y=[s,f];n.waterfall(y,r)},e.Message=f},function(t,e){"use strict";e.types=[void 0,"Int16","Int32","Int64","Hash128","Hash256","Amount","VL","Account",void 0,void 0,void 0,void 0,void 0,"Object","Array","Int8","Hash160","PathSet","Vector256"];var r=e.fields={1:{1:"LedgerEntryType",2:"TransactionType"},2:{2:"Flags",3:"SourceTag",4:"Sequence",5:"PreviousTxnLgrSeq",6:"LedgerSequence",7:"CloseTime",8:"ParentCloseTime",9:"SigningTime",10:"Expiration",11:"TransferRate",12:"WalletSize",13:"OwnerCount",14:"DestinationTag",16:"HighQualityIn",17:"HighQualityOut",18:"LowQualityIn",19:"LowQualityOut",20:"QualityIn",21:"QualityOut",22:"StampEscrow",23:"BondAmount",24:"LoadFee",25:"OfferSequence",26:"FirstLedgerSequence",27:"LastLedgerSequence",28:"TransactionIndex",29:"OperationLimit",30:"ReferenceFeeUnits",31:"ReserveBase",32:"ReserveIncrement",33:"SetFlag",34:"ClearFlag"},3:{1:"IndexNext",2:"IndexPrevious",3:"BookNode",4:"OwnerNode",5:"BaseFee",6:"ExchangeRate",7:"LowNode",8:"HighNode"},4:{1:"EmailHash"},5:{1:"LedgerHash",2:"ParentHash",3:"TransactionHash",4:"AccountHash",5:"PreviousTxnID",6:"LedgerIndex",7:"WalletLocator",8:"RootIndex",9:"AccountTxnID",16:"BookDirectory",17:"InvoiceID",18:"Nickname",19:"Amendment",20:"TicketID"},6:{1:"Amount",2:"Balance",3:"LimitAmount",4:"TakerPays",5:"TakerGets",6:"LowLimit",7:"HighLimit",8:"Fee",9:"SendMax",16:"MinimumOffer",17:"RippleEscrow",18:"DeliveredAmount"},7:{1:"PublicKey",2:"MessageKey",3:"SigningPubKey",4:"TxnSignature",5:"Generator",6:"Signature",7:"Domain",8:"FundCode",9:"RemoveCode",10:"ExpireCode",11:"CreateCode",12:"MemoType",13:"MemoData",14:"MemoFormat"},8:{1:"Account",2:"Owner",3:"Destination",4:"Issuer",7:"Target",8:"RegularKey"},14:{1:void 0,2:"TransactionMetaData",3:"CreatedNode",4:"DeletedNode",5:"ModifiedNode",6:"PreviousFields",7:"FinalFields",8:"NewFields",9:"TemplateEntry",10:"Memo"},15:{1:void 0,2:"SigningAccounts",3:"TxnSignatures",4:"Signatures",5:"Template",6:"Necessary",7:"Sufficient",8:"AffectedNodes",9:"Memos"},16:{1:"CloseResolution",2:"TemplateEntryType",3:"TransactionResult"},17:{1:"TakerPaysCurrency",2:"TakerPaysIssuer",3:"TakerGetsCurrency",4:"TakerGetsIssuer"},18:{1:"Paths"},19:{1:"Indexes",2:"Hashes",3:"Amendments"}},n=e.fieldsInverseMap={};Object.keys(r).forEach(function(t){Object.keys(r[t]).forEach(function(e){n[r[t][e]]=[Number(t),Number(e)]})});var i=e.REQUIRED=0,o=e.OPTIONAL=1,s=e.DEFAULT=2,a=[["TransactionType",i],["Flags",o],["SourceTag",o],["LastLedgerSequence",o],["Account",i],["Sequence",i],["Fee",i],["OperationLimit",o],["SigningPubKey",i],["TxnSignature",o]];e.tx={AccountSet:[3].concat(a,[["EmailHash",o],["WalletLocator",o],["WalletSize",o],["MessageKey",o],["Domain",o],["TransferRate",o],["SetFlag",o],["ClearFlag",o]]),TrustSet:[20].concat(a,[["LimitAmount",o],["QualityIn",o],["QualityOut",o]]),OfferCreate:[7].concat(a,[["TakerPays",i],["TakerGets",i],["Expiration",o],["OfferSequence",o]]),OfferCancel:[8].concat(a,[["OfferSequence",i]]),SetRegularKey:[5].concat(a,[["RegularKey",o]]),Payment:[0].concat(a,[["Destination",i],["Amount",i],["SendMax",o],["Paths",s],["InvoiceID",o],["DestinationTag",o]]),Contract:[9].concat(a,[["Expiration",i],["BondAmount",i],["StampEscrow",i],["RippleEscrow",i],["CreateCode",o],["FundCode",o],["RemoveCode",o],["ExpireCode",o]]),RemoveContract:[10].concat(a,[["Target",i]]),EnableFeature:[100].concat(a,[["Feature",i]]),EnableAmendment:[100].concat(a,[["Amendment",i]]),SetFee:[101].concat(a,[["BaseFee",i],["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i]]),TicketCreate:[10].concat(a,[["Target",o],["Expiration",o]]),TicketCancel:[11].concat(a,[["TicketID",i]])};var u=[["LedgerIndex",o],["LedgerEntryType",i],["Flags",i]];e.ledger={AccountRoot:[97].concat(u,[["Sequence",i],["PreviousTxnLgrSeq",i],["TransferRate",o],["WalletSize",o],["OwnerCount",i],["EmailHash",o],["PreviousTxnID",i],["AccountTxnID",o],["WalletLocator",o],["Balance",i],["MessageKey",o],["Domain",o],["Account",i],["RegularKey",o]]),Contract:[99].concat(u,[["PreviousTxnLgrSeq",i],["Expiration",i],["BondAmount",i],["PreviousTxnID",i],["Balance",i],["FundCode",o],["RemoveCode",o],["ExpireCode",o],["CreateCode",o],["Account",i],["Owner",i],["Issuer",i]]),DirectoryNode:[100].concat(u,[["IndexNext",o],["IndexPrevious",o],["ExchangeRate",o],["RootIndex",i],["Owner",o],["TakerPaysCurrency",o],["TakerPaysIssuer",o],["TakerGetsCurrency",o],["TakerGetsIssuer",o],["Indexes",i]]),EnabledFeatures:[102].concat(u,[["Features",i]]),FeeSettings:[115].concat(u,[["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i],["BaseFee",i],["LedgerIndex",o]]),GeneratorMap:[103].concat(u,[["Generator",i]]),LedgerHashes:[104].concat(u,[["LedgerEntryType",i],["Flags",i],["FirstLedgerSequence",o],["LastLedgerSequence",o],["LedgerIndex",o],["Hashes",i]]),Nickname:[110].concat(u,[["LedgerEntryType",i],["Flags",i],["LedgerIndex",o],["MinimumOffer",o],["Account",i]]),Offer:[111].concat(u,[["LedgerEntryType",i],["Flags",i],["Sequence",i],["PreviousTxnLgrSeq",i],["Expiration",o],["BookNode",i],["OwnerNode",i],["PreviousTxnID",i],["LedgerIndex",o],["BookDirectory",i],["TakerPays",i],["TakerGets",i],["Account",i]]),RippleState:[114].concat(u,[["LedgerEntryType",i],["Flags",i],["PreviousTxnLgrSeq",i],["HighQualityIn",o],["HighQualityOut",o],["LowQualityIn",o],["LowQualityOut",o],["LowNode",o],["HighNode",o],["PreviousTxnID",i],["LedgerIndex",o],["Balance",i],["LowLimit",i],["HighLimit",i]])},e.metadata=[["TransactionIndex",i],["TransactionResult",i],["AffectedNodes",i]],e.ter={tesSUCCESS:0,tecCLAIM:100,tecPATH_PARTIAL:101,tecUNFUNDED_ADD:102,tecUNFUNDED_OFFER:103,tecUNFUNDED_PAYMENT:104,tecFAILED_PROCESSING:105,tecDIR_FULL:121,tecINSUF_RESERVE_LINE:122,tecINSUF_RESERVE_OFFER:123,tecNO_DST:124,tecNO_DST_INSUF_XRP:125,tecNO_LINE_INSUF_RESERVE:126,tecNO_LINE_REDUNDANT:127,tecPATH_DRY:128,tecUNFUNDED:129,tecMASTER_DISABLED:130,tecNO_REGULAR_KEY:131,tecOWNERS:132,tecNO_ISSUER:133,tecNO_AUTH:134,tecNO_LINE:135,tecINSUFF_FEE:136,tecFROZEN:137,tecNO_TARGET:138,tecNO_PERMISSION:139,tecNO_ENTRY:140,tecINSUFFICIENT_RESERVE:141,tecNEED_MASTER_KEY:142,tecDST_TAG_NEEDED:143,tecINTERNAL:144}},function(t,e,r){"use strict";function n(t){for(var e=t.toPrecision(16).replace(/\./,"").replace(/e.*/,"").replace(/^0*/,"");e.length<16;)e+="0";return e}function i(t,e){return function(){console.log("%s: %s",i,arguments.toString),e(arguments)}}function o(t,e){for(var r=new Array(t),n=0;t>n;n++)r[n]=e;return r}function s(t){var e=[],r=0;for(t.length%2&&(e.push(String.fromCharCode(parseInt(t.substring(0,1),16))),r=1);r<t.length;r+=2)e.push(String.fromCharCode(parseInt(t.substring(r,r+2),16)));return e.join("")}function a(t){for(var e="",r=0;r<t.length;r++){var n=t.charCodeAt(r);e+=16>n?"0"+n.toString(16):n.toString(16)}return e}function u(t){for(var e=new Array(t.length),r=0;r<e.length;r+=1)e[r]=t.charCodeAt(r);return e}function c(t){return u(s(t))}function f(t){return t.map(function(t){var e=t.toString(16);return e.length>1?e:"0"+e}).join("")}function h(t,e,r){var n=[],i=0,o=t.length;for(r&&(i=t.length%e,i&&n.push(t.slice(0,i)));o>i;i+=e)n.push(t.slice(i,e+i));return n}function l(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:"."))}function p(t){for(var e={},r=[],n=0,i=t.length;i>n;n++){var o=t[n];e[o]||(r.push(o),e[o]=!0)}return r}function d(t){return 1e3*(t+946684800)}function _(t){return t instanceof Date&&(t=t.getTime()),Math.round(t/1e3)-946684800}e.time={fromRipple:d,toRipple:_},e.trace=i,e.arraySet=o,e.hexToString=s,e.hexToArray=c,e.stringToArray=u,e.stringToHex=a,e.arrayToHex=f,e.chunkString=h,e.assert=l,e.arrayUnique=p,e.toTimestamp=d,e.fromTimestamp=_,e.getMantissaDecimalString=n,e.sjcl=r(32)},function(t,e,r){function n(t,e){function r(){var t=i._checkActivity.bind(i);i._activityInterval=setInterval(t,1e3)}a.call(this);var i=this;if("string"==typeof e){var u=o.parse(e);e={host:u.hostname,port:u.port,secure:"ws:"===u.protocol?!1:!0}}if("object"!=typeof e)throw new TypeError("Server configuration is not an Object");if(!n.DOMAIN_RE.test(e.host))throw new Error('Server host is malformed, use "host" and "port" server configuration');if(!(e.port=Number(e.port)))throw new TypeError("Server port must be a number");if(e.port<1||e.port>65535)throw new TypeError('Server "port" must be an integer in range 1-65535');"boolean"!=typeof e.secure&&(e.secure=!0),this._remote=t,this._opts=e,this._ws=void 0,this._connected=!1,this._shouldConnect=!1,this._state="offline",this._ledgerRanges=new c,this._ledgerMap=s({max:200}),this._id=0,this._retry=0,this._requests={},this._load_base=256,this._load_factor=256,this._fee=10,this._fee_ref=10,this._fee_base=10,this._reserve_base=void 0,this._reserve_inc=void 0,this._fee_cushion=this._remote.fee_cushion,this._lastLedgerIndex=0/0,this._lastLedgerClose=0/0,this._score=0,this._scoreWeights={ledgerclose:5,response:1},this._pubkey_node="",this._url=this._opts.url=(this._opts.secure?"wss://":"ws://")+this._opts.host+":"+this._opts.port,this.on("message",function(t){i._handleMessage(t)}),this.on("response_subscribe",function(t){i._handleResponseSubscribe(t)}),this.on("disconnect",function(){clearInterval(i._activityInterval),i.once("ledger_closed",r)}),this.once("ledger_closed",r),this._remote.on("ledger_closed",function(t){i._updateScore("ledgerclose",t)}),this.on("response_ping",function(t,e){i._updateScore("response",e)}),this.on("load_changed",function(t){i._updateScore("loadchange",t)}),this.on("connect",function(){i.requestServerID()})}var i=r(38),o=r(43),s=r(44),a=r(37).EventEmitter,u=r(3).Amount,c=r(21).RangeSet,f=r(27).internal.sub("server");i.inherits(n,a),n.DOMAIN_RE=/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|[-_]){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|[-_]){0,61}[0-9A-Za-z])?)*\.?$/,n.TLS_ERRORS=["UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"],n.onlineStates=["syncing","tracking","proposing","validating","full"],n.websocketConstructor=function(){return r(33)},n.prototype._setState=function(t){if(t!==this._state)switch(this._remote.trace&&f.info(this.getServerID(),"set_state:",t),this._state=t,this.emit("state",t),t){case"online":this._connected=!0,this._retry=0,this.emit("connect");break;case"offline":this._connected=!1,this.emit("disconnect")}},n.prototype._checkActivity=function(){if(this.isConnected()&&!isNaN(this._lastLedgerClose)){var t=Date.now()-this._lastLedgerClose;t>25e3&&(this._remote.trace&&f.info(this.getServerID(),"reconnect: activity delta:",t),this.reconnect())}},n.prototype.requestServerID=function(){var t=this;if(!this._pubkey_node){this.on("response_server_info",function(e){try{t._pubkey_node=e.info.pubkey_node}catch(r){}});var e=this._remote.requestServerInfo();e.on("error",function(){}),this._request(e)}},n.prototype._updateScore=function(t,e){if(this.isConnected()){var r=this._scoreWeights[t]||1;switch(t){case"ledgerclose":var n=e.ledger_index-this._lastLedgerIndex;n>0&&(this._score+=r*n);break;case"response":var n=Math.floor((Date.now()-e.time)/200);this._score+=r*n;break;case"loadchange":this._fee=Number(this._computeFee(10))}this._score>1e3&&(this._remote.trace&&f.info(this.getServerID(),"reconnect: score:",this._score),this.reconnect())}},n.prototype.getRemoteAddress=n.prototype._remoteAddress=function(){var t;try{t=this._ws._socket.remoteAddress}catch(e){}return t},n.prototype.getHostID=n.prototype.getServerID=function(){return this._url+" ("+(this._pubkey_node?this._pubkey_node:"")+")"},n.prototype.disconnect=function(){var t=this;return this.isConnected()?(this._lastLedgerIndex=0/0,this._lastLedgerClose=0/0,this._score=0,this._shouldConnect=!1,this._ledgerRanges.reset(),this._ledgerMap.reset(),this._setState("offline"),void(this._ws&&this._ws.close())):void this.once("socket_open",function(){t.disconnect()})},n.prototype.reconnect=function(){function t(){e._shouldConnect=!0,e._retry=0,e.connect()}var e=this;this._ws&&this._shouldConnect&&(this.isConnected()?(this.once("disconnect",t),this.disconnect()):t())},n.prototype.connect=function(){var t=this,e=n.websocketConstructor();if(!e)throw new Error("No websocket support detected!");if(!this.isConnected()){this._ws&&this._ws.close(),this._remote.trace&&f.info(this.getServerID(),"connect");var r=this._ws=new e(this._opts.url);this._shouldConnect=!0,t.emit("connecting"),r.onmessage=function(e){t.emit("message",e.data)},r.onopen=function(){r===t._ws&&(t.emit("socket_open"),t._request(t._remote._serverPrepareSubscribe(t)))},r.onerror=function(e){if(r===t._ws){if(t.emit("socket_error"),t._remote.trace&&f.info(t.getServerID(),"onerror:",e.data||e),-1!==n.TLS_ERRORS.indexOf(e.message))throw e;t._handleClose()}},r.onclose=function(){r===t._ws&&(t._remote.trace&&f.info(t.getServerID(),"onclose:",r.readyState),t._handleClose())}}},n.prototype._retryConnect=function(){function t(){e._shouldConnect&&(e._remote.trace&&f.info(e.getServerID(),"retry",e._retry),e.connect())}var e=this;this._retry+=1;var r=this._retry<40?50:this._retry<100?1e3:this._retry<160?1e4:3e4;this._retryTimer=setTimeout(t,r)},n.prototype._handleClose=function(){function t(){}var e=this._ws;e.onopen=e.onerror=e.onclose=e.onmessage=t,this.emit("socket_close"),this._setState("offline"),this._shouldConnect&&this._retryConnect()},n.prototype._handleMessage=function(t){try{t=JSON.parse(t)}catch(e){}if(!n.isValidMessage(t))return void this.emit("unexpected",t);switch(t.type){case"ledgerClosed":this._handleLedgerClosed(t);break;case"serverStatus":this._handleServerStatus(t);break;case"response":this._handleResponse(t);break;case"path_find":this._handlePathFind(t)}},n.prototype._handleLedgerClosed=function(t){this._lastLedgerIndex=t.ledger_index,this._lastLedgerClose=Date.now(),this._ledgerRanges.add(t.ledger_index),this._ledgerMap.set(t.ledger_hash,t.ledger_index),this.emit("ledger_closed",t)},n.prototype._handleServerStatus=function(t){var e=~n.onlineStates.indexOf(t.server_status);if(this._setState(e?"online":"offline"),n.isLoadStatus(t)){this.emit("load",t,this),this._remote.emit("load",t,this);var r=t.load_base!==this._load_base||t.load_factor!==this._load_factor;r&&(this._load_base=t.load_base,this._load_factor=t.load_factor,this.emit("load_changed",t,this),this._remote.emit("load_changed",t,this))}},n.prototype._handleResponse=function(t){var e=this._requests[t.id];if(delete this._requests[t.id],!e)return void(this._remote.trace&&f.info(this.getServerID(),"UNEXPECTED:",t));if("success"===t.status){this._remote.trace&&f.info(this.getServerID(),"response:",t);var r=e.message.command,n=t.result,i="response_"+r;e.emit("success",n),[this,this._remote].forEach(function(r){r.emit(i,n,e,t)})}else t.error&&(this._remote.trace&&f.info(this.getServerID(),"error:",t),e.emit("error",{error:"remoteError",error_message:"Remote reported an error.",remote:t}))},n.prototype._handlePathFind=function(t){this._remote.trace&&f.info(this.getServerID(),"path_find:",t)},n.prototype._handleResponseSubscribe=function(t){if(!this.isConnected()){if(!this._remote.allow_partial_history&&!n.hasFullLedgerHistory(t))return this.reconnect();t.pubkey_node&&(this._pubkey_node=t.pubkey_node),n.isLoadStatus(t)&&(this._load_base=t.load_base||256,this._load_factor=t.load_factor||256,this._fee_ref=t.fee_ref||10,this._fee_base=t.fee_base||10,this._reserve_base=t.reserve_base,this._reserve_inc=t.reserve_inc),t.validated_ledgers&&this._ledgerRanges.add(t.validated_ledgers),~n.onlineStates.indexOf(t.server_status)&&this._setState("online")}},n.hasFullLedgerHistory=function(t){return"object"==typeof t&&"full"===t.server_status&&"string"==typeof t.validated_ledgers&&2===t.validated_ledgers.split("-").length},n.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},n.isLoadStatus=function(t){return"object"==typeof t&&"number"==typeof t.load_base&&"number"==typeof t.load_factor},n.prototype._sendMessage=function(t){this._ws&&(this._remote.trace&&f.info(this.getServerID(),"request:",t),this._ws.send(JSON.stringify(t)))},n.prototype._request=function(t){function e(){r._sendMessage(t.message)}var r=this;if(!this._ws)return void(this._remote.trace&&f.info(this.getServerID(),"request: DROPPING:",t.message));
t.server=this,t.message.id=this._id,t.time=Date.now(),this._requests[t.message.id]=t,this._id++;var n=1===this._ws.readyState,i=t&&"subscribe"===t.message.command;this.isConnected()||n&&i?e():this.once("connect",e)},n.prototype.isConnected=n.prototype._isConnected=function(){return this._connected},n.prototype._computeFee=function(t){if(isNaN(t))throw new Error("Invalid argument");return this._feeTx(Number(t)).to_json()},n.prototype._feeTx=function(t){var e=this._feeTxUnit();return u.from_json(String(Math.ceil(t*e)))},n.prototype._feeTxUnit=function(){var t=this._fee_base/this._fee_ref;return t*=this._load_factor/this._load_base,t*=this._fee_cushion},n.prototype._reserve=function(t){var e=u.from_json(String(this._reserve_base)),r=u.from_json(String(this._reserve_inc)),n=t||0;if(0>n)throw new Error("Owner count must not be negative.");return e.add(r.product_human(n))},n.prototype.hasLedger=function(t){var e=!1;return"string"==typeof t&&/^[A-F0-9]{64}$/.test(t)?e=this._ledgerMap.has(t):null==t||isNaN(t)||(e=this._ledgerRanges.has(t)),e},n.prototype.getLastLedger=n.prototype.getLastLedgerIndex=function(){return this._lastLedgerIndex},e.Server=n},function(t,e,r){"use strict";function n(){this.ledger_json={}}var i=r(5).Transaction,o=r(34).SHAMap,s=r(34).SHAMapTreeNode,a=r(13).SerializedObject,u=r(23),c=r(9).UInt160,f=r(6).Currency;n.from_json=function(t){var e=new n;return e.parse_json(t),e},n.space=r(35),n.calcAccountRootEntryHash=n.prototype.calcAccountRootEntryHash=function(t){t=c.from_json(t);var e=new a;return e.append([0,n.space.account.charCodeAt(0)]),e.append(t.to_bytes()),e.hash()},n.calcOfferEntryHash=n.prototype.calcOfferEntryHash=function(t,e){t=c.from_json(t),e=parseInt(e,10);var r=new a;return r.append([0,n.space.offer.charCodeAt(0)]),r.append(t.to_bytes()),u.Int32.serialize(r,e),r.hash()},n.calcRippleStateEntryHash=n.prototype.calcRippleStateEntryHash=function(t,e,r){if(r=f.from_json(r),t=c.from_json(t),e=c.from_json(e),!t.is_valid())throw new Error("Invalid first account");if(!e.is_valid())throw new Error("Invalid second account");if(!r.is_valid())throw new Error("Invalid currency");if(t.to_bn().greaterEquals(e.to_bn())){var i=e;e=t,t=i}var o=new a;return o.append([0,n.space.rippleState.charCodeAt(0)]),o.append(t.to_bytes()),o.append(e.to_bytes()),o.append(r.to_bytes()),o.hash()},n.prototype.parse_json=function(t){this.ledger_json=t},n.prototype.calc_tx_hash=function(){var t=new o;return this.ledger_json.transactions.forEach(function(e){var r=i.from_json(e),n=a.from_json(e.metaData),o=new a;u.VariableLength.serialize(o,r.serialize().to_hex()),u.VariableLength.serialize(o,n.to_hex()),t.add_item(r.hash(),o,s.TYPE_TRANSACTION_MD)}),t.hash()},n.prototype.calc_account_hash=function(t){var e,r=new o;if(this.ledger_json.accountState.forEach(function(n){var i,o=a.from_json(n);if(t&&t.sanity_test)try{i=o.to_json(),o=a.from_json(i)}catch(u){console.log("account state item: ",n),console.log("to_json() ",i),console.log("exception: ",u),e=!0}r.add_item(n.index,o,s.TYPE_ACCOUNT_STATE)}),e)throw new Error("There were errors with sanity_test");return r.hash()},e.Ledger=n},function(t,e,r){"use strict";function n(){this._queue=[],this._idCache=new o({max:200}),this._sequenceCache=new o({max:200})}var i=r(40),o=r(44),s=r(5).Transaction;n.prototype.addReceivedSequence=function(t){this._sequenceCache.set(String(t),!0)},n.prototype.hasSequence=function(t){return this._sequenceCache.has(String(t))},n.prototype.addReceivedId=function(t,e){this._idCache.set(t,e)},n.prototype.getReceived=function(t){return this._idCache.get(t)},n.prototype.getSubmission=function(t){return i.find(this._queue,function(e){return i.contains(e.submittedIDs,t)})},n.prototype.getMinLedger=function(){if(this.length()<1)return-1;for(var t=1/0,e=0;e<this.length();e++)this._queue[e].initialSubmitIndex<t&&(t=this._queue[e].initialSubmitIndex);return isFinite(t)||(t=-1),t},n.prototype.remove=function(t){var e=this._queue.length;if("string"==typeof t&&(t=this.getSubmission(t)),t instanceof s)for(;e--;)if(this._queue[e]===t){this._queue.splice(e,1);break}},n.prototype.push=function(t){this._queue.push(t)},n.prototype.forEach=function(t){this._queue.forEach(t)},n.prototype.length=n.prototype.getLength=function(){return this._queue.length},n.prototype.getQueue=function(){return this._queue},e.TransactionQueue=n},function(t,e,r){function n(){this._ranges=[]}var i=r(39),o=r(40);n.prototype.add=function(t){if(i("number"!=typeof t||!isNaN(t),"Ledger range malformed"),t=String(t).split(","),t.length>1)return t.forEach(this.add,this);t=t[0].split("-").map(Number);var e={start:t[0],end:t[1===t.length?0:1]};i(e.start<=e.end,"Ledger range malformed");var r=o.sortedIndex(this._ranges,e,function(t){return t.start});this._ranges.splice(r,0,e)},n.prototype.has=n.prototype.contains=function(t){return i(null!=t&&!isNaN(t),"Ledger must be a number"),t=Number(t),this._ranges.some(function(e){return t>=e.start&&t<=e.end})},n.prototype.reset=function(){this._ranges=[]},e.RangeSet=n},function(t){"use strict";function e(t){for(;0===t[0];)t.shift();return t}function r(t,r,n){for(var i=0,o=[],s=0;s<t.length;s++){var a=i*r+parseInt(t[s],10);o.push(Math.floor(a/n)),i=a%n}return{quotient:e(o),remainder:i}}function n(t,n,i){for(var o=[],s=t;s.length>0;){var a=r(s,n,i);o.unshift(a.remainder),s=a.quotient}return e(o)}t.exports=n},function(t,e,r){"use strict";function n(t){v(this,t)}function i(t){return"number"==typeof t&&isFinite(t)}function o(t){return"string"==typeof t}function s(t){return o(t)&&/^[0-9A-F]{0,16}$/i.test(t)}function a(t,e,r){var i=A.codec.bytes.fromBits(e);r||n.serialize_varint(t,i.length),t.append(i)}function u(t,e,r){a(t,A.codec.hex.toBits(e),r)}function c(t){return A.codec.hex.fromBits(A.codec.bytes.toBits(t)).toUpperCase()}function f(t){var e=A.codec.hex.toBits(t);return A.codec.utf8String.fromBits(e)}function h(t){function e(t,e){var r=w.fieldsInverseMap[t],n=r[0],i=r[1],o=w.fieldsInverseMap[e],s=o[0],a=o[1];return n!==s?n-s:i-a}return t.sort(e)}function l(t,e){if(!i(t))throw new Error("Value is not a number",e);if(0>t||t>=Math.pow(256,e))throw new Error("Value out of bounds ");for(var r=[],n=0;e>n;n++)r.unshift(t>>>8*n&255);return r}function p(t,e){var r=0;if(e>4)throw new Error("This function only supports up to four bytes.");for(var n=0;e>n;n++){var i=t.read(1)[0];r+=i<<8*(e-n-1)}return r>>>0}function d(t,r,n){var i=w.fieldsInverseMap[r],o=i[0],s=i[1],a=(16>o?o<<4:0)|(16>s?s:0);"LedgerEntryType"===r&&"string"==typeof n&&(n=w.ledger[n][0]),"TransactionResult"===r&&"string"==typeof n&&(n=w.ter[n]),j.serialize(t,a),o>=16&&j.serialize(t,o),s>=16&&j.serialize(t,s);var u;u="Memo"===r&&"object"==typeof n?e.STMemo:e[w.types[o]];try{u.serialize(t,n)}catch(c){throw c.message+=" ("+r+")",c}}function _(t){var r=t.read(1)[0],n=r>>4;0===n&&(n=t.read(1)[0]);var i=15&r,o=o=0===i?w.fields[n][t.read(1)[0]]:w.fields[n][i];y(o,"Unknown field - header byte is 0x"+r.toString(16));var s="Memo"===o?e.STMemo:e[w.types[n]];return y(s,"Unknown type - header byte is 0x"+r.toString(16)),[o,s.parse(t)]}var y=r(39),v=r(41),g=r(46),m=r(3).Amount,b=r(6).Currency,w=r(16),E=r(17),A=E.sjcl,x=A.bn,S=r(8).UInt128,T=r(9).UInt160,k=r(10).UInt256,O=r(7).Base,I=g.another({ROUNDING_MODE:g.ROUND_HALF_UP,DECIMAL_PLACES:40});n.serialize_varint=function(t,e){if(0>e)throw new Error("Variable integers are unsigned.");if(192>=e)t.append([e]);else if(12480>=e)e-=193,t.append([193+(e>>>8),255&e]);else{if(!(918744>=e))throw new Error("Variable integer overflow.");e-=12481,t.append([241+(e>>>16),e>>>8&255,255&e])}},n.prototype.parse_varint=function(t){var e,r,n,i=t.read(1)[0];if(i>254)throw new Error("Invalid varint length indicator");return 192>=i?n=i:240>=i?(e=t.read(1)[0],n=193+256*(i-193)+e):254>=i&&(e=t.read(1)[0],r=t.read(1)[0],n=12481+65536*(i-241)+256*e+r),n};var j=e.Int8=new n({serialize:function(t,e){t.append(l(e,1))},parse:function(t){return p(t,1)}});j.id=16,e.serialize=e.serialize_whatever=d,e.parse=e.parse_whatever=_;var R=e.Int16=new n({serialize:function(t,e){t.append(l(e,2))},parse:function(t){return p(t,2)}});R.id=1;var C=e.Int32=new n({serialize:function(t,e){t.append(l(e,4))},parse:function(t){return p(t,4)}});C.id=2;var L=e.Int64=new n({serialize:function(t,e){var r;if(i(e)){if(e=Math.floor(e),0>e)throw new Error("Negative value for unsigned Int64 is invalid.");r=new x(e,10)}else if(o(e)){if(!s(e))throw new Error("Not a valid hex Int64.");r=new x(e,16)}else{if(!(e instanceof x))throw new Error("Invalid type for Int64");if(!e.greaterEquals(0))throw new Error("Negative value for unsigned Int64 is invalid.");r=e}a(t,r.toBits(64),!0)},parse:function(t){var e=t.read(8);return x.fromBits(A.codec.bytes.toBits(e))}});L.id=3;var B=e.Hash128=new n({serialize:function(t,e){var r=S.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash128");a(t,r.to_bits(),!0)},parse:function(t){return S.from_bytes(t.read(16))}});B.id=4;var F=e.Hash256=new n({serialize:function(t,e){var r=k.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash256");a(t,r.to_bits(),!0)},parse:function(t){return k.from_bytes(t.read(32))}});F.id=5;var N=e.Hash160=new n({serialize:function(t,e){var r=T.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash160");a(t,r.to_bits(),!0)},parse:function(t){return T.from_bytes(t.read(20))}});N.id=17;var q=new n({serialize:function(t,e){var r=e.to_bytes();if(!r)throw new Error("Tried to serialize invalid/unimplemented currency type.");t.append(r)},parse:function(t){var e=t.read(20),r=b.from_bytes(e);return r}});e.Quality=new n({serialize:function(t,e){var r=m.from_json(e);if(!r.is_valid())throw new Error("Not a valid Amount object.");var n=0,i=0,o=new I(r.to_text()),s=o.e-15;if(!r.is_zero()){n|=(100+s&255)<<24;var a=E.getMantissaDecimalString(o.abs()),u=new I(a).toString(16);y(u.length<=16,"Mantissa hex representation "+u+" exceeds the maximum length of 16"),n|=16777215&parseInt(u.slice(0,-8),16),i=parseInt(u.slice(-8),16)}var c=A.codec.bytes.fromBits([n,i]);t.append(c)}});var D=e.Amount=new n({serialize:function(t,e){var r=m.from_json(e);if(!r.is_valid())throw new Error("Not a valid Amount object.");var n=new I(r.to_text()),i=n.e-15,o=E.arraySet(8,0);if(r.is_native()){var s=n.abs().toString(16);if(m.strict_mode&&n.abs().greaterThan(m.bi_xns_max))throw new Error("Value out of bounds");if(m.strict_mode&&s.length>16)throw new Error("Value out of bounds");for(;s.length<16;)s="0"+s;o=A.codec.bytes.fromBits(A.codec.hex.toBits(s)),o[0]&=63,r.is_negative()||(o[0]|=64)}else{var a=0,u=0;if(a|=1<<31,!r.is_zero()){r.is_negative()||(a|=1<<30),a|=(97+i&255)<<22;var c=E.getMantissaDecimalString(n.abs()),f=new I(c).toString(16);y(f.length<=16,"Mantissa hex representation "+f+" exceeds the maximum length of 16"),a|=4194303&parseInt(f.slice(0,-8),16),u=parseInt(f.slice(-8),16)}o=A.codec.bytes.fromBits([a,u])}if(t.append(o),!r.is_native()){var h=r.currency();q.serialize(t,h,!0),t.append(r.issuer().to_bytes())}},parse:function(t){for(var e=t.read(8),r=!(127&e[0]),n=1;8>n;n++)r=r&&!e[n];var i=!(r||64&e[0]);if(128&e[0]){var o=q.parse(t),s=t.read(20),a=T.from_bytes(s);a.set_version(O.VER_ACCOUNT_ID);var u=((63&e[0])<<2)+(e[1]>>>6)-97,c=e.slice(1);c[0]&=63;var f=new I(E.arrayToHex(c),16),h=i?"-":"",l=h+f.toString()+"e"+u.toString();return m.from_json({currency:o,issuer:a.to_json(),value:l})}var p=e.slice();p[0]&=63;var d=E.arrayToHex(p),_=new I(d,16);return m.from_json((i?"-":"")+_.toString())}});D.id=6;var M=e.VariableLength=e.VL=new n({serialize:function(t,e){if("string"!=typeof e)throw new Error("Unknown datatype.");u(t,e)},parse:function(t){var e=this.parse_varint(t);return c(t.read(e))}});M.id=7;var P=e.Account=new n({serialize:function(t,e){var r=T.from_json(e);if(!r.is_valid())throw new Error("Invalid account!");a(t,r.to_bits())},parse:function(t){var e=this.parse_varint(t);if(20!==e)throw new Error("Non-standard-length account ID");var r=T.from_bytes(t.read(e));return r.set_version(O.VER_ACCOUNT_ID),r}});P.id=8;var U=e.PathSet=new n({typeBoundary:255,typeEnd:0,typeAccount:1,typeCurrency:16,typeIssuer:32,serialize:function(t,e){for(var r=0,n=e.length;n>r;r++){r&&j.serialize(t,this.typeBoundary);for(var i=0,o=e[r].length;o>i;i++){var s=e[r][i],a=0;if(s.account&&(a|=this.typeAccount),s.currency&&(a|=this.typeCurrency),s.issuer&&(a|=this.typeIssuer),j.serialize(t,a),s.account&&N.serialize(t,s.account),s.currency){var u=b.from_json(s.currency,s.non_native);q.serialize(t,u)}s.issuer&&N.serialize(t,s.issuer)}}j.serialize(t,this.typeEnd)},parse:function(t){for(var e,r=[],n=[];(e=t.read(1)[0])!==this.typeEnd;)if(e!==this.typeBoundary){var i={},o=0;if(e&this.typeAccount&&(i.account=N.parse(t),i.account.set_version(O.VER_ACCOUNT_ID),o|=this.typeAccount),e&this.typeCurrency&&(i.currency=q.parse(t),"XRP"!==i.currency.to_json()||i.currency.is_native()||(i.non_native=!0),o|=this.typeCurrency),e&this.typeIssuer&&(i.issuer=N.parse(t),i.issuer.set_version(O.VER_ACCOUNT_ID),o|=this.typeIssuer),!(i.account||i.currency||i.issuer))throw new Error("Invalid path entry");i.type=o,i.type_hex=("000000000000000"+o.toString(16)).slice(-16),n.push(i)}else n&&r.push(n),n=[];return n&&r.push(n),r}});U.id=18;var z=e.Vector256=new n({serialize:function(t,e){n.serialize_varint(t,32*e.length);for(var r=0,i=e.length;i>r;r++)F.serialize(t,e[r])},parse:function(t){for(var e=this.parse_varint(t),r=[],n=0;e/32>n;n++)r.push(F.parse(t));return r}});z.id=19,e.STMemo=new n({serialize:function(t,e,r){var n=[];Object.keys(e).forEach(function(t){if(t[0]!==t[0].toLowerCase()){if("undefined"==typeof w.fieldsInverseMap[t])throw new Error('JSON contains unknown field: "'+t+'"');n.push(t)}}),n=h(n),n.forEach(function(r){d(t,r,e[r])}),r||j.serialize(t,225)},parse:function(t){for(var e={};225!==t.peek(1)[0];){var r=_(t);e[r[0]]=r[1]}if(void 0!==e.MemoType)try{var n=f(e.MemoType);"unformatted_memo"!==n&&(e.parsed_memo_type=n)}catch(i){}if(void 0!==e.MemoFormat)try{e.parsed_memo_format=f(e.MemoFormat)}catch(i){}if(void 0!==e.MemoData)try{"json"===e.parsed_memo_format?e.parsed_memo_data=JSON.parse(f(e.MemoData)):"text"===e.parsed_memo_format&&(e.parsed_memo_data=f(e.MemoData))}catch(i){}return t.read(1),e}});var G=e.Object=new n({serialize:function(t,e,r){var n=[];Object.keys(e).forEach(function(t){if(t[0]!==t[0].toLowerCase()){if("undefined"==typeof w.fieldsInverseMap[t])throw new Error('JSON contains unknown field: "'+t+'"');n.push(t)}}),n=h(n);for(var i=0;i<n.length;i++)d(t,n[i],e[n[i]]);r||j.serialize(t,225)},parse:function(t){for(var e={};225!==t.peek(1)[0];){var r=_(t);e[r[0]]=r[1]}return t.read(1),e}});G.id=14;var H=e.Array=new n({serialize:function(t,e){for(var r=0,n=e.length;n>r;r++){var i=Object.keys(e[r]);if(1!==i.length)throw new Error("Cannot serialize an array containing non-single-key objects");var o=i[0],s=e[r][o];d(t,o,s)}j.serialize(t,241)},parse:function(t){for(var e=[];241!==t.peek(1)[0];){var r=_(t),n={};n[r[0]]=r[1],e.push(n)}return t.read(1),e}});H.id=15},function(t,e,r){"use strict";function n(t,e){u(!o.isNull(t)&&!isNaN(t),e)}function i(t,e,r,n,s,a){function u(){l.computeAutobridgedOffers(),l.mergeDirectAndAutobridgedBooks()}function c(t,e){if(o.contains(i.EVENTS,e))switch(t){case"add":1===++l._listeners&&l.subscribe();break;case"remove":0===--l._listeners&&l.unsubscribe()}}function h(t){l.updateFundedAmounts(t)}f.call(this);var l=this;return this._remote=t,this._currencyGets=p.from_json(e),this._issuerGets=r,this._currencyPays=p.from_json(n),this._issuerPays=s,this._key=a,this._subscribed=!1,this._shouldSubscribe=!0,this._listeners=0,this._offers=[],this._offersAutobridged=[],this._mergedOffers=[],this._offerCounts={},this._ownerFundsUnadjusted={},this._ownerFunds={},this._ownerOffersTotal={},this._synchronized=!1,this._issuerTransferRate=null,this._legOneBook=null,this._legTwoBook=null,this._isAutobridgeable=!this._currencyGets.is_native()&&!this._currencyPays.is_native(),this._isAutobridgeable&&(this._legOneBook=t.createOrderBook({currency_gets:"XRP",currency_pays:n,issuer_pays:s}),this._legOneBook.on("model",u),this._legTwoBook=t.createOrderBook({currency_gets:e,issuer_gets:r,currency_pays:"XRP"}),this._legTwoBook.on("model",u)),this.on("newListener",function(t){c("add",t)}),this.on("removeListener",function(t){c("remove",t)}),this._remote.on("transaction",h),this.on("unsubscribe",function(){l.resetCache(),l._remote.removeListener("transaction",h)}),this._remote.once("prepare_subscribe",function(){l.subscribe()}),this._remote.on("disconnect",function(){l.resetCache(),l._remote.once("prepare_subscribe",function(){l.subscribe()})}),this}var o=r(40),s=r(38),a=r(41),u=r(39),c=r(45),f=r(37).EventEmitter,h=r(3).Amount,l=r(9).UInt160,p=r(6).Currency,d=r(47),_=r(48),y=r(27).internal.sub("orderbook");s.inherits(i,f),i.EVENTS=["transaction","model","trade","offer_added","offer_removed","offer_changed","offer_funds_changed"],i.DEFAULT_TRANSFER_RATE=1e9,i.offerRewrite=function(t){for(var e={},r=Object.keys(t),n=0,i=r.length;i>n;n++){var o=r[n];switch(o){case"PreviousTxnID":case"PreviousTxnLgrSeq":break;default:e[o]=t[o]}}return e.Flags=e.Flags||0,e.OwnerNode=e.OwnerNode||new Array(17).join("0"),e.BookNode=e.BookNode||new Array(17).join("0"),e},i.prototype.subscribe=function(){var t=this;if(this._shouldSubscribe){this._remote.trace&&y.info("subscribing",this._key);var e=[function(e){t.requestTransferRate(e)},function(e){t.requestOffers(e)},function(e){t.subscribeTransactions(e)}];c.series(e)}},i.prototype.unsubscribe=function(){var t=this;this._remote.trace&&y.info("unsubscribing",this._key),this._subscribed=!1,this._shouldSubscribe=!1,i.EVENTS.forEach(function(e){t.listeners(e).length>0&&t.removeAllListeners(e)}),this.emit("unsubscribe")},i.prototype.requestOffers=function(t){function e(e){return Array.isArray(e.offers)?(n._remote.trace&&y.info("requested offers",n._key,"offers: "+e.offers.length),n.setOffers(e.offers),n._synchronized=!0,n.notifyDirectOffersChanged(),void t(null,n._offers)):t(new Error("Invalid response"))}function r(e){n._remote.trace&&y.info("failed to request offers",n._key,e),t(e)}var n=this;if("function"!=typeof t&&(t=function(){}),!this._shouldSubscribe)return t(new Error("Should not request offers"));this._remote.trace&&y.info("requesting offers",this._key);var i=this._remote.requestBookOffers(this.toJSON());return i.once("success",e),i.once("error",r),i.request(),i},i.prototype.requestTransferRate=function(t){function e(e,n){return e?t(e):(r._issuerTransferRate=n.account_data.TransferRate||i.DEFAULT_TRANSFER_RATE,void t(null,r._issuerTransferRate))}u.strictEqual(typeof t,"function");var r=this;return this._currencyGets.is_native()?(this._issuerTransferRate=i.DEFAULT_TRANSFER_RATE,t(null,i.DEFAULT_TRANSFER_RATE)):this._issuerTransferRate?t(null,this._issuerTransferRate):void this._remote.requestAccountInfo({account:this._issuerGets},e)},i.prototype.subscribeTransactions=function(t){function e(e){n._remote.trace&&y.info("subscribed to transactions"),n._subscribed=!0,t(null,e)}function r(e){n._remote.trace&&y.info("failed to subscribe to transactions",n._key,e),t(e)}var n=this;if("function"!=typeof t&&(t=function(){}),!this._shouldSubscribe)return t("Should not subscribe");this._remote.trace&&y.info("subscribing to transactions");var i=this._remote.requestSubscribe();return i.addStream("transactions"),i.once("success",e),i.once("error",r),i.request(),i},i.prototype.notifyDirectOffersChanged=function(){this._isAutobridgeable?this.mergeDirectAndAutobridgedBooks():this.emit("model",this._offers)},i.prototype.resetCache=function(){this._ownerFunds={},this._ownerOffersTotal={},this._offerCounts={},this._synchronized=!1},i.prototype.hasOwnerFunds=function(t){return u(l.is_valid(t),"Account is invalid"),void 0!==this._ownerFunds[t]},i.prototype.setOwnerFunds=function(t,e){u(l.is_valid(t),"Account is invalid"),u(!isNaN(e),"Funded amount is invalid"),this._ownerFundsUnadjusted[t]=e,this._ownerFunds[t]=this.applyTransferRate(e)},i.prototype.applyTransferRate=function(t){u(!isNaN(t),"Balance is invalid"),n(this._issuerTransferRate,"Transfer rate is invalid");var e=_.normalizeAmount(t).divide(this._issuerTransferRate).multiply(h.from_json(i.DEFAULT_TRANSFER_RATE)).to_json().value;return e},i.prototype.getOwnerFunds=function(t){u(l.is_valid(t),"Account is invalid");var e;return this.hasOwnerFunds(t)&&(e=this._currencyGets.is_native()?h.from_json(this._ownerFunds[t]):_.normalizeAmount(this._ownerFunds[t])),e},i.prototype.getUnadjustedOwnerFunds=function(t){return u(l.is_valid(t),"Account is invalid"),this._ownerFundsUnadjusted[t]},i.prototype.deleteOwnerFunds=function(t){u(l.is_valid(t),"Account is invalid"),this._ownerFunds[t]=void 0},i.prototype.getOwnerOfferCount=function(t){return u(l.is_valid(t),"Account is invalid"),this._offerCounts[t]||0},i.prototype.incrementOwnerOfferCount=function(t){u(l.is_valid(t),"Account is invalid");var e=(this._offerCounts[t]||0)+1;return this._offerCounts[t]=e,e},i.prototype.decrementOwnerOfferCount=function(t){u(l.is_valid(t),"Account is invalid");var e=(this._offerCounts[t]||1)-1;return this._offerCounts[t]=e,1>e&&this.deleteOwnerFunds(t),e},i.prototype.addOwnerOfferTotal=function(t,e){u(l.is_valid(t),"Account is invalid");var r=this.getOwnerOfferTotal(t),n=r.add(h.from_json(e));return this._ownerOffersTotal[t]=n,n},i.prototype.subtractOwnerOfferTotal=function(t,e){u(l.is_valid(t),"Account is invalid");var r=this.getOwnerOfferTotal(t),n=r.subtract(h.from_json(e));return this._ownerOffersTotal[t]=n,u(!n.is_negative(),"Offer total cannot be negative"),n},i.prototype.getOwnerOfferTotal=function(t){u(l.is_valid(t),"Account is invalid");var e=this._ownerOffersTotal[t];return e||(e=this._currencyGets.is_native()?h.from_json("0"):_.normalizeAmount("0")),e},i.prototype.resetOwnerOfferTotal=function(t){u(l.is_valid(t),"Account is invalid");var e;return e=this._currencyGets.is_native()?h.from_json("0"):_.normalizeAmount("0"),this._ownerOffersTotal[t]=e,e},i.prototype.setOfferFundedAmount=function(t){u.strictEqual(typeof t,"object","Offer is invalid");var e=this.getOwnerFunds(t.Account),r=this.getOwnerOfferTotal(t.Account),n=r.add(h.from_json(t.TakerGets));if(t.owner_funds=this.getUnadjustedOwnerFunds(t.Account),t.is_fully_funded=e.compareTo(n)>=0,t.is_fully_funded)t.taker_gets_funded=h.from_json(t.TakerGets).to_text(),t.taker_pays_funded=h.from_json(t.TakerPays).to_text();else if(r.compareTo(e)<0){t.taker_gets_funded=e.subtract(r).to_text();var i=_.getOfferQuality(t,this._currencyGets),o=i.multiply(_.getOfferTakerGetsFunded(t));t.taker_pays_funded=this._currencyPays.is_native()?String(Math.floor(o.to_number())):o.to_json().value}else t.taker_gets_funded="0",t.taker_pays_funded="0";return t},i.prototype.parseAccountBalanceFromNode=function(t){var e={account:void 0,balance:void 0};switch(t.entryType){case"AccountRoot":e.account=t.fields.Account,e.balance=t.fieldsFinal.Balance;break;case"RippleState":t.fields.HighLimit.issuer===this._issuerGets?(e.account=t.fields.LowLimit.issuer,e.balance=t.fieldsFinal.Balance.value):t.fields.LowLimit.issuer===this._issuerGets&&(e.account=t.fields.HighLimit.issuer,e.balance=h.from_json(t.fieldsFinal.Balance).negate().to_json().value)}return u(!isNaN(e.balance),"node has an invalid balance"),u(l.is_valid(e.account),"node has an invalid account"),e},i.prototype.isBalanceChangeNode=function(t){return t.fields&&t.fields.Balance&&t.fieldsPrev&&t.fieldsFinal&&t.fieldsPrev.Balance&&t.fieldsFinal.Balance?this._currencyGets.is_native()?!isNaN(t.fields.Balance):t.fields.Balance.currency!==this._currencyGets.to_json()?!1:t.fields.HighLimit.issuer!==this._issuerGets&&t.fields.LowLimit.issuer!==this._issuerGets?!1:!0:!1},i.prototype.updateFundedAmounts=function(t){var e=this;if(!this._currencyGets.is_native()&&!this._issuerTransferRate)return this._remote.trace&&y.info("waiting for transfer rate"),void this.requestTransferRate(function(){e.updateFundedAmounts(t)});var r=t.mmeta.getNodes({nodeType:"ModifiedNode",entryType:this._currencyGets.is_native()?"AccountRoot":"RippleState"});o.each(r,function(t){if(e.isBalanceChangeNode(t)){var r=e.parseAccountBalanceFromNode(t);e.hasOwnerFunds(r.account)&&(e.setOwnerFunds(r.account,r.balance),e.updateOwnerOffersFundedAmount(r.account))}})},i.prototype.updateOwnerOffersFundedAmount=function(t){u(l.is_valid(t),"Account is invalid");var e=this;if(this._remote.trace){var r=this.getOwnerFunds(t).to_text();y.info("updating offer funds",this._key,t,r)}this.resetOwnerOfferTotal(t),o.each(this._offers,function(r){if(r.Account===t){var n,i=a({},r);o.isString(r.taker_gets_funded)&&(n=_.getOfferTakerGetsFunded(r)),e.setOfferFundedAmount(r),e.addOwnerOfferTotal(r.Account,r.TakerGets);var s=_.getOfferTakerGetsFunded(r),u=n&&!s.equals(n);u&&(e.emit("offer_changed",i,r),e.emit("offer_funds_changed",r,i.taker_gets_funded,r.taker_gets_funded))}})},i.prototype.notify=function(t){function e(t){switch(t.nodeType){case"DeletedNode":r.deleteOffer(t,a),a||(i=i.add(t.fieldsFinal.TakerGets),s=s.add(t.fieldsFinal.TakerPays));break;case"ModifiedNode":r.modifyOffer(t),i=i.add(t.fieldsPrev.TakerGets).subtract(t.fieldsFinal.TakerGets),s=s.add(t.fieldsPrev.TakerPays).subtract(t.fieldsFinal.TakerPays);break;case"CreatedNode":r.setOwnerFunds(t.fields.Account,u),r.insertOffer(t)}}var r=this;if(this._subscribed){this._remote.trace&&y.info("notifying",this._key,t.transaction.hash);var n=t.mmeta.getNodes({entryType:"Offer",bookKey:this._key});if(!(n.length<1)){var i=h.from_json("0"+(p.from_json(this._currencyGets).is_native()?"":"/"+this._currencyGets.to_human()+"/"+this._issuerGets)),s=h.from_json("0"+(p.from_json(this._currencyPays).is_native()?"":"/"+this._currencyPays.to_human()+"/"+this._issuerPays)),a="OfferCancel"===t.transaction.TransactionType,u=t.transaction.owner_funds;o.each(n,e),this.emit("transaction",t),this.notifyDirectOffersChanged(),i.is_zero()||this.emit("trade",s,i)}}},i.prototype.insertOffer=function(t){this._remote.trace&&y.info("inserting offer",this._key,t.fields);var e=i.offerRewrite(t.fields),r=this.normalizeAmount(this._currencyGets,e.TakerGets),n=this.normalizeAmount(this._currencyPays,e.TakerPays);e.LedgerEntryType=t.entryType,e.index=t.ledgerIndex,e.quality=n.divide(r).to_text();for(var o=this._offers.length,s=0;o>s;s++){var a=_.getOfferQuality(e,this._currencyGets),u=_.getOfferQuality(this._offers[s],this._currencyGets);if(a.compareTo(u)<=0){this._offers.splice(s,0,e);break}}this._offers.length===o&&this._offers.push(e),this.incrementOwnerOfferCount(e.Account),this.updateOwnerOffersFundedAmount(e.Account),this.emit("offer_added",e)},i.prototype.normalizeAmount=function(t,e){var r=t.is_native()?e:e.value;return _.normalizeAmount(r)},i.prototype.modifyOffer=function(t){this._remote.trace&&y.info("modifying offer",this._key,t.fields);for(var e=0;e<this._offers.length;e++){var r=this._offers[e];if(r.index===t.ledgerIndex){a(r,t.fieldsFinal);break}}this.updateOwnerOffersFundedAmount(t.fields.Account)},i.prototype.deleteOffer=function(t,e){this._remote.trace&&y.info("deleting offer",this._key,t.fields);for(var r=0;r<this._offers.length;r++){var n=this._offers[r];if(n.index===t.ledgerIndex){this.subtractOwnerOfferTotal(n.Account,n.TakerGets),this._offers.splice(r,1),this.decrementOwnerOfferCount(n.Account),this.emit("offer_removed",n);break}}e&&this.updateOwnerOffersFundedAmount(t.fields.Account)},i.prototype.setOffers=function(t){u(Array.isArray(t),"Offers is not an array");var e=this;this.resetCache();var r=o.map(t,function(t){var r=i.offerRewrite(t);return r.hasOwnProperty("owner_funds")&&e.setOwnerFunds(r.Account,r.owner_funds),e.incrementOwnerOfferCount(r.Account),e.setOfferFundedAmount(r),e.addOwnerOfferTotal(r.Account,r.TakerGets),r});this._offers=r},i.prototype.offers=i.prototype.getOffers=function(t){return u.strictEqual(typeof t,"function","Callback missing"),this._synchronized?t(null,this._offers):this.once("model",function(e){t(null,e)}),this},i.prototype.offersSync=i.prototype.getOffersSync=function(){return this._offers},i.prototype.toJSON=i.prototype.to_json=function(){var t={taker_gets:{currency:this._currencyGets.to_hex()},taker_pays:{currency:this._currencyPays.to_hex()}};return this._currencyGets.is_native()||(t.taker_gets.issuer=this._issuerGets),this._currencyPays.is_native()||(t.taker_pays.issuer=this._issuerPays),t},i.prototype.isValid=i.prototype.is_valid=function(){return this._currencyPays&&this._currencyPays.is_valid()&&(this._currencyPays.is_native()||l.is_valid(this._issuerPays))&&this._currencyGets&&this._currencyGets.is_valid()&&(this._currencyGets.is_native()||l.is_valid(this._issuerGets))&&!(this._currencyPays.is_native()&&this._currencyGets.is_native())},i.prototype.computeAutobridgedOffers=function(){u(!this._currencyGets.is_native()&&!this._currencyPays.is_native(),"Autobridging is only for IOU:IOU orderbooks");var t=new d(this._currencyGets,this._currencyPays,this._legOneBook.getOffersSync(),this._legTwoBook.getOffersSync());this._offersAutobridged=t.calculate()},i.prototype.mergeDirectAndAutobridgedBooks=function(){var t=this;return o.isEmpty(this._offers)&&o.isEmpty(this._offersAutobridged)?null:(this._mergedOffers=this._offers.concat(this._offersAutobridged).sort(function(e,r){var n=_.getOfferQuality(e,t._currencyGets),i=_.getOfferQuality(r,t._currencyGets);return n.compareTo(i)}),this.emit("model",this._mergedOffers),this._mergedOffers)},e.OrderBook=i},function(t,e,r){function n(t,e,r,n,o){i.call(this),this.remote=t,this.src_account=e,this.dst_account=r,this.dst_amount=n,this.src_currencies=o}{var i=r(37).EventEmitter,o=r(38),s=r(3).Amount;r(41)}o.inherits(n,i),n.prototype.create=function(){var t=this,e=this.remote.request_path_find_create(this.src_account,this.dst_account,this.dst_amount,this.src_currencies);e.once("error",function(e){t.emit("error",e)}),e.once("success",function(e){t.notify_update(e)}),e.broadcast().request()},n.prototype.close=function(){this.remote.request_path_find_close().broadcast().request(),this.emit("end"),this.emit("close")},n.prototype.notify_update=function(t){var e=t.source_account,r=t.destination_account,n=s.from_json(t.destination_amount);this.src_account===e&&this.dst_account===r&&this.dst_amount.equals(n)&&this.emit("update",t)},n.prototype.notify_superceded=function(){this.emit("end"),this.emit("superceded")},e.PathFind=n},function(t,e){e.HASH_TX_ID=1415073280,e.HASH_TX_NODE=1397638144,e.HASH_INNER_NODE=1296649728,e.HASH_LEAF_NODE=1296846336,e.HASH_TX_SIGN=1398036480,e.HASH_TX_SIGN_TESTNET=1937012736},function(t){"use strict";function e(t){this._namespace=t?Array.isArray(t)?t:[String(t)]:[],this._prefix=this._namespace.concat([""]).join(": ")}function r(t,e){var r=(new Error).stack;return["["+(new Date).toISOString()+"]",t,"--","string"==typeof r?r.split("\n")[4].replace(/^\s+/,""):"","\n"].concat(e)}function n(t,e){switch(t){case 1:case 2:console.log.apply(console,e);break;case 3:console.warn.apply(console,e);break;case 4:console.error.apply(console,e)}}e.prototype.sub=function(t){var r=this._namespace.slice();t&&"string"==typeof t&&r.push(t);var n=new e(r);return n._setParent(this),n},e.prototype._setParent=function(t){this._parent=t},e.makeLevel=function(t){return function(){var r=Array.prototype.slice.apply(arguments);r[0]=this._prefix+r[0],e.engine.logObject.apply(e,[t].concat(r[0],[r.slice(2)]))}},e.prototype.debug=e.makeLevel(1),e.prototype.info=e.makeLevel(2),e.prototype.warn=e.makeLevel(3),e.prototype.error=e.makeLevel(4);var i={logObject:function(t,e,i){i=i.map(function(t){return JSON.stringify(t,null,2)}),n(t,r(e,i))}},o={logObject:function(t,e,i){i=i.map(function(t){return/MSIE/.test(navigator.userAgent)?JSON.stringify(t,null,2):t}),n(t,r(e,i))}},s={logObject:function(){}};e.engine="undefined"!=typeof window&&"undefined"!=typeof console?o:"undefined"!=typeof console&&console.log?i:s,t.exports=new e,t.exports.internal=t.exports.sub(),t.exports.Log=e},function(t,e,r){"use strict";function n(t){function e(t){n._updatePendingStatus(t)}function r(){n._handleReconnect(function(){n._remote.on("ledger_closed",e)})}a.call(this);var n=this;this._account=t,this._accountID=t._account_id,this._remote=t._remote,this._nextSequence=void 0,this._maxFee=this._remote.max_fee,this._maxAttempts=this._remote.max_attempts,this._submissionTimeout=this._remote.submission_timeout,this._lastLedgerOffset=this._remote.last_ledger_offset,this._pending=new f,this._account.on("transaction-outbound",function(t){n._transactionReceived(t)
}),this._remote.on("load_changed",function(t){n._adjustFees(t)}),this._remote.on("ledger_closed",e),this._remote.on("disconnect",function(){n._remote.removeListener("ledger_closed",e),n._remote.once("connect",r)}),this._loadSequence()}var i=r(38),o=r(39),s=r(45),a=r(37).EventEmitter,u=r(5).Transaction,c=r(14).RippleError,f=r(20).TransactionQueue,h=r(27).internal.sub("transactionmanager");i.inherits(n,a),n._isNoOp=function(t){return"object"==typeof t&&"object"==typeof t.tx_json&&"AccountSet"===t.tx_json.TransactionType&&0===t.tx_json.Flags},n._isRemoteError=function(t){return"object"==typeof t&&"remoteError"===t.error&&"object"==typeof t.remote},n._isNotFound=function(t){return n._isRemoteError(t)&&/^(txnNotFound|transactionNotFound)$/.test(t.remote.error)},n._isTooBusy=function(t){return n._isRemoteError(t)&&"tooBusy"===t.remote.error},n.normalizeTransaction=function(t){for(var e={},r=Object.keys(t),n=0;n<r.length;n++){var i=r[n];switch(i){case"transaction":e.tx_json=t[i];break;case"tx":e.engine_result=t.meta.TransactionResult,e.result=e.engine_result,e.tx_json=t[i],e.hash=t[i].hash,e.ledger_index=t[i].ledger_index,e.type="transaction",e.validated=t.validated;break;case"meta":case"metadata":e.metadata=t[i];break;case"mmeta":break;default:e[i]=t[i]}}return e},n.prototype._transactionReceived=function(t){var e=n.normalizeTransaction(t);if(e.validated&&e.tx_json.Account===this._accountID){this._remote.trace&&h.info("transaction received:",e.tx_json),this._pending.addReceivedSequence(e.tx_json.Sequence);var r=e.tx_json.hash,i=this._pending.getSubmission(r);if(!(i instanceof u))return void this._pending.addReceivedId(r,e);switch(e.engine_result){case"tesSUCCESS":i.emit("success",e);break;default:i.emit("error",e)}}},n.prototype._adjustFees=function(){function t(t){t.once("presubmit",function(){t.emit("error","tejMaxFeeExceeded")})}var e=this;this._remote.local_fee&&this._pending.forEach(function(r){if(!r._setFixedFee){var n=r.tx_json.Fee,i=r._computeFee();if(Number(i)>e._maxFee)return void t(r);r.tx_json.Fee=i,r.emit("fee_adjusted",n,i),e._remote.trace&&h.info("fee adjusted:",r.tx_json,n,i)}})},n.prototype.getPending=function(){return this._pending},n.prototype._updatePendingStatus=function(t){o.strictEqual(typeof t,"object"),o.strictEqual(typeof t.ledger_index,"number"),this._pending.forEach(function(e){if(!e.finalized){switch(t.ledger_index-e.submitIndex){case 4:e.emit("missing",t);break;case 8:e.emit("lost",t)}t.ledger_index>e.tx_json.LastLedgerSequence&&e.emit("error",new c("tejMaxLedger","Transaction LastLedgerSequence exceeded"))}})},n.prototype._fillSequence=function(t,e){function r(e,r){var n=i._remote.createTransaction("AccountSet",{account:i._accountID});n.tx_json.Sequence=e,t._secret&&n.secret(t._secret),n.once("submitted",r),n.submit()}function n(n,o){if("number"!=typeof o)return h.info("fill sequence: failed to fetch account transaction sequence"),e();var a=t.tx_json.Sequence-o,u=0;s.whilst(function(){return a>u},function(t){r(o,function(e){++u,"tesSUCCESS"===e.engine_result&&i.emit("sequence_filled",n),t()})},function(){e&&e()})}var i=this;this._loadSequence(n)},n.prototype._loadSequence=function(t){function e(e,n){return(e||"number"!=typeof n)&&r._remote.trace?void h.info("error requesting account transaction sequence",e):(r._nextSequence=n,r.emit("sequence_loaded",n),void t(e,n))}var r=this;t="function"==typeof t?t:function(){},this._account.getNextSequence(e)},n.prototype._handleReconnect=function(t){function e(e,n){return e||"object"!=typeof n?(r._remote.trace&&h.info("error requesting account_tx",e),void t()):(Array.isArray(n.transactions)&&n.transactions.forEach(r._transactionReceived,r),t(),void r._loadSequence(function(){r._resubmit()}))}var r=this;if(t="function"==typeof t?t:function(){},!this._pending.length())return void t();var n={account:this._accountID,ledger_index_min:this._pending.getMinLedger(),ledger_index_max:-1,binary:!0,parseBinary:!0,limit:20};this._remote.requestAccountTx(n,e)},n.prototype._waitLedgers=function(t,e){function r(){++i===t&&(n._remote.removeListener("ledger_closed",r),e())}if(o.strictEqual(typeof t,"number"),o.strictEqual(typeof e,"function"),1>t)return e();var n=this,i=0;this._remote.on("ledger_closed",r)},n.prototype._resubmit=function(t,e){function r(t,e){if(t&&!t.finalized){var r=t.findId(n._pending._idCache);if(r)switch(r.engine_result){case"tesSUCCESS":t.emit("success",r);break;default:t.emit("error",r)}for(;n._pending.hasSequence(t.tx_json.Sequence);)t.tx_json.Sequence+=1,n._remote.trace&&h.info("incrementing sequence:",t.tx_json);n._remote.trace&&h.info("resubmit:",t.tx_json),t.once("submitted",function(r){t.emit("resubmitted",r),e()}),n._request(t)}}var n=this;t&&"number"!=typeof t&&(e=t,t=0),t=t||0,e=e instanceof u?[e]:this.getPending().getQueue(),this._waitLedgers(t,function(){s.eachSeries(e,r)})},n.prototype._prepareRequest=function(t){var e=this._remote.requestSubmit();if(this._remote.local_signing){t.sign();var r=t.serialize();e.tx_blob(r.to_hex());var n=t.hash(null,null,r);t.addId(n)}else e.build_path(t._build_path),e.secret(t._secret),e.tx_json(t.tx_json);return e},n.prototype._request=function(t){function e(e){"tefPAST_SEQ"===e.engine_result&&u._resubmit(1,t)}function r(){u._fillSequence(t,function(){u._resubmit(1,t)})}function i(e){"telINSUF_FEE_P"===e.engine_result&&u._resubmit(1,t)}function o(e){n._isTooBusy(e)?u._resubmit(1,t):(u._nextSequence--,t.emit("error",e))}function s(n){if(!t.finalized)switch(n.tx_json&&n.tx_json.hash&&t.addId(n.tx_json.hash),n.result=n.engine_result||"",t.result=n,t.responses+=1,f.trace&&h.info("submit response:",n),t.emit("submitted",n),n.result.slice(0,3)){case"tes":t.emit("proposed",n);break;case"tec":break;case"ter":r(n);break;case"tef":e(n);break;case"tel":i(n);break;default:o(n)}}function a(){t.finalized||(t.emit("timeout"),f.isConnected()&&(f.trace&&h.info("timeout:",t.tx_json),u._resubmit(1,t)))}var u=this,f=this._remote;if(!t.finalized){if(t.attempts>this._maxAttempts)return void t.emit("error",new c("tejAttemptsExceeded"));if(t.attempts>0&&!f.local_signing){var l="Automatic resubmission requires local signing";return void t.emit("error",new c("tejLocalSigningRequired",l))}f.trace&&h.info("submit transaction:",t.tx_json),t.submitIndex=this._remote._ledger_current_index,0===t.attempts&&(t.initialSubmitIndex=t.submitIndex),t._setLastLedger||(t.tx_json.LastLedgerSequence=t.initialSubmitIndex+this._lastLedgerOffset),t.lastLedgerSequence=t.tx_json.LastLedgerSequence,f.local_signing&&t.sign();var p=this._prepareRequest(t);p.once("error",s),p.once("success",s),t.emit("presubmit"),p.broadcast().request(),t.attempts++,t.emit("postsubmit"),p.timeout(u._submissionTimeout,a)}},n.prototype.submit=function(t){var e=this;if("number"!=typeof this._nextSequence)return void this.once("sequence_loaded",function(){e.submit(t)});if(!t.finalized){if("number"!=typeof t.tx_json.Sequence&&(t.tx_json.Sequence=this._nextSequence++),t.once("cleanup",function(){e.getPending().remove(t)}),!t.complete())return void this._nextSequence--;this._pending.push(t),this._request(t)}},e.TransactionManager=n},function(t,e){var r=e.Float={};r.toIEEE754=function(t,e,r){var n,i,o,s=(1<<e-1)-1;if(isNaN(t))i=(1<<s)-1,o=1,n=0;else if(1/0===t||t===-1/0)i=(1<<s)-1,o=0,n=0>t?1:0;else if(0===t)i=0,o=0,n=1/t===-1/0?1:0;else if(n=0>t,t=Math.abs(t),t>=Math.pow(2,1-s)){var a=Math.min(Math.floor(Math.log(t)/Math.LN2),s);i=a+s,o=t*Math.pow(2,r-a)-Math.pow(2,r)}else i=0,o=t/Math.pow(2,1-s-r);var u,c=[];for(u=r;u;u-=1)c.push(o%2?1:0),o=Math.floor(o/2);for(u=e;u;u-=1)c.push(i%2?1:0),i=Math.floor(i/2);c.push(n?1:0),c.reverse();for(var f=c.join(""),h=[];f.length;)h.push(parseInt(f.substring(0,8),2)),f=f.substring(8);return h},r.fromIEEE754=function(t,e,r){for(var n=[],i=t.length;i;i-=1)for(var o=t[i-1],s=8;s;s-=1)n.push(o%2?1:0),o>>=1;n.reverse();var a=n.join(""),u=(1<<e-1)-1,c=parseInt(a.substring(0,1),2)?-1:1,f=parseInt(a.substring(1,1+e),2),h=parseInt(a.substring(1+e),2);return f===(1<<e)-1?0!==h?0/0:1/0*c:f>0?c*Math.pow(2,f-u)*(1+h/Math.pow(2,r)):0!==h?c*Math.pow(2,-(u-1))*(h/Math.pow(2,r)):0*c},r.fromIEEE754Double=function(t){return r.fromIEEE754(t,11,52)},r.toIEEE754Double=function(t){return r.toIEEE754(t,11,52)},r.fromIEEE754Single=function(t){return r.fromIEEE754(t,8,23)},r.toIEEE754Single=function(t){return r.toIEEE754(t,8,23)},r.toIEEE754DoubleString=function(t){return e.toIEEE754Double(t).map(function(t){for(t=t.toString(2);t.length<8;t="0"+t);return t}).join("").replace(/(.)(.{11})(.{52})/,"$1 $2 $3")}},function(t,e,r){"use strict";function n(){this._value=0/0,this._update()}var i=r(17),o=i.sjcl;n.json_rewrite=function(t,e){return this.from_json(t).to_json(e)},n.from_generic=function(t){return t instanceof this?t.clone():(new this).parse_generic(t)},n.from_hex=function(t){return t instanceof this?t.clone():(new this).parse_hex(t)},n.from_json=function(t){return t instanceof this?t.clone():(new this).parse_json(t)},n.from_bits=function(t){return t instanceof this?t.clone():(new this).parse_bits(t)},n.from_bytes=function(t){return t instanceof this?t.clone():(new this).parse_bytes(t)},n.from_bn=function(t){return t instanceof this?t.clone():(new this).parse_bn(t)},n.from_number=function(t){return t instanceof this?t.clone():(new this).parse_number(t)},n.is_valid=function(t){return this.from_json(t).is_valid()},n.prototype.clone=function(){return this.copyTo(new this.constructor)},n.prototype.copyTo=function(t){return t._value=this._value,void 0!==this._version_byte&&(t._version_byte=this._version_byte),"function"==typeof t._update&&t._update(),t},n.prototype.equals=function(t){return this.is_valid()&&t.is_valid()&&this._value.equals(t._value)},n.prototype.is_valid=function(){return this._value instanceof o.bn},n.prototype.is_zero=function(){return this.is_valid()&&this._value.equals(new o.bn(0))},n.prototype._update=function(){},n.prototype.parse_generic=function(t){switch(t){case void 0:case"0":case this.constructor.STR_ZERO:case this.constructor.ACCOUNT_ZERO:case this.constructor.HEX_ZERO:this._value=new o.bn(0);break;case"1":case this.constructor.STR_ONE:case this.constructor.ACCOUNT_ONE:case this.constructor.HEX_ONE:this._value=new o.bn(1);break;default:if("string"!=typeof t)this._value=0/0;else if(this.constructor.width===t.length){var e=i.arrayToHex(i.stringToArray(t));this._value=new o.bn(e,16)}else this._value=2*this.constructor.width===t.length?new o.bn(t,16):0/0}return this._update(),this},n.prototype.parse_hex=function(t){return this._value="string"==typeof t&&t.length===2*this.constructor.width?new o.bn(t,16):0/0,this._update(),this},n.prototype.parse_bits=function(t){return this._value=o.bitArray.bitLength(t)!==8*this.constructor.width?0/0:o.bn.fromBits(t),this._update(),this},n.prototype.parse_bytes=function(t){if(Array.isArray(t)&&t.length===this.constructor.width){var e=o.codec.bytes.toBits(t);this._value=o.bn.fromBits(e)}else this._value=0/0;return this._update(),this},n.prototype.parse_json=n.prototype.parse_hex,n.prototype.parse_bn=function(t){return this._value=t instanceof o.bn&&t.bitLength()<=8*this.constructor.width?new o.bn(t):0/0,this._update(),this},n.prototype.parse_number=function(t){return this._value=0/0,"number"==typeof t&&isFinite(t)&&t>=0&&(this._value=new o.bn(t)),this._update(),this},n.prototype.to_bytes=function(){return this.is_valid()?o.codec.bytes.fromBits(this.to_bits()):null},n.prototype.to_hex=function(){return this.is_valid()?o.codec.hex.fromBits(this.to_bits()).toUpperCase():null},n.prototype.to_json=n.prototype.to_hex,n.prototype.to_bits=function(){return this.is_valid()?this._value.toBits(8*this.constructor.width):null},n.prototype.to_bn=function(){if(!this.is_valid())return null;var t=this.to_bits();return o.bn.fromBits(t)},e.UInt=n},function(t,e,r){"use strict";function n(){this._curve=o.ecc.curves.k256,this._secret=null,this._pubkey=null}function i(t){return o.hash.ripemd160.hash(o.hash.sha256.hash(t))}var o=r(17).sjcl,s=r(9).UInt160,a=r(10).UInt256,u=r(7).Base;n.from_bn_secret=function(t){return t instanceof this?t.clone():(new this).parse_bn_secret(t)},n.prototype.parse_bn_secret=function(t){return this._secret=new o.ecc.ecdsa.secretKey(o.ecc.curves.k256,t),this},n.prototype._pub=function(){var t=this._curve;if(!this._pubkey&&this._secret){var e=this._secret._exponent;this._pubkey=new o.ecc.ecdsa.publicKey(t,t.G.mult(e))}return this._pubkey},n.prototype._pub_bits=function(){var t=this._pub();if(!t)return null;var e=t._point,r=e.y.mod(2).equals(0);return o.bitArray.concat([o.bitArray.partial(8,r?2:3)],e.x.toBits(this._curve.r.bitLength()))},n.prototype.to_hex_pub=function(){var t=this._pub_bits();return t?o.codec.hex.fromBits(t).toUpperCase():null},n.prototype.get_address=function(){var t=this._pub_bits();if(!t)return null;var e=i(t),r=s.from_bits(e);return r.set_version(u.VER_ACCOUNT_ID),r},n.prototype.sign=function(t){var e=6;t=a.from_json(t);var r=this._secret.sign(t.to_bits(),e);return r=this._secret.canonicalizeSignature(r),this._secret.encodeDER(r)},e.KeyPair=n},function(t,e,r){function n(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function i(t,e){var r=t.r.bitLength();return{r:f.bn.fromBits(f.bitArray.bitSlice(e,0,r)),s:f.bn.fromBits(f.bitArray.bitSlice(e,r,f.bitArray.bitLength(e)))}}function o(t,e,r,n,i){for(var o=i.toBits(),a=0;4>a;a++){var u;try{u=s(t,e,r,n,a)}catch(c){continue}if(f.bitArray.equal(u.toBits(),o))return a}throw new f.exception.bug("unable to calculate recovery factor from signature")}function s(t,e,r,n,i){var o=t.r,s=t.field.modulus;i=3&i;var u=1&i,c=i>>1;p||(p=s.add(1).div(4));var h;h=c?e.add(o):e;var l,d=h.mul(h).mul(h).add(t.a.mul(h)).add(t.b).mod(s),_=d.powermodMontgomery(p,s),y=_.mod(2).equals(0);l=y&&!u||!y&&u?_:s.sub(_);var v=new f.ecc.point(t,h,l);if(!v.isValidPoint())throw new f.exception.corrupt("point R. Not a valid point on the curve. Cannot recover public key");var g=f.bn.fromBits(n),m=new f.bn(0).sub(g).mod(o),b=e.inverseMod(o),w=v.mult2(r,m,t.G).mult(b);if(!w.isValidPoint())throw new f.exception.corrupt("public_key_point. Not a valid point on the curve. Cannot recover public key");if(!a(t,g,e,r,w))throw new f.exception.corrupt("cannot recover public key");return w}function a(t,e,r,n,i){var o=t.r;if(new f.bn(1).greaterEquals(r)||r.greaterEquals(new f.bn(o)))return!1;if(new f.bn(1).greaterEquals(n)||n.greaterEquals(new f.bn(o)))return!1;var s=n.inverseMod(o),a=e.mul(s).mod(o),u=r.mul(s).mod(o),c=t.G.mult2(a,u,i);return r.equals(c.x.mod(o))}var u,c,f={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};"undefined"!=typeof t&&t.exports&&(t.exports=f),u=[],c=function(){return f}.apply(e,u),!(void 0!==c&&(t.exports=c)),f.cipher.aes=function(t){this._tables[0][0][0]||this._precompute();var e,r,n,i,o,s=this._tables[0][4],a=this._tables[1],u=t.length,c=1;if(4!==u&&6!==u&&8!==u)throw new f.exception.invalid("invalid aes key size");for(this._key=[i=t.slice(0),o=[]],e=u;4*u+28>e;e++)n=i[e-1],(e%u===0||8===u&&e%u===4)&&(n=s[n>>>24]<<24^s[n>>16&255]<<16^s[n>>8&255]<<8^s[255&n],e%u===0&&(n=n<<8^n>>>24^c<<24,c=c<<1^283*(c>>7))),i[e]=i[e-u]^n;for(r=0;e;r++,e--)n=i[3&r?e:e-4],o[r]=4>=e||4>r?n:a[0][s[n>>>24]]^a[1][s[n>>16&255]]^a[2][s[n>>8&255]]^a[3][s[255&n]]},f.cipher.aes.prototype={encrypt:function(t){return this._crypt(t,0)},decrypt:function(t){return this._crypt(t,1)},_tables:[[[],[],[],[],[]],[[],[],[],[],[]]],_precompute:function(){var t,e,r,n,i,o,s,a,u,c=this._tables[0],f=this._tables[1],h=c[4],l=f[4],p=[],d=[];for(t=0;256>t;t++)d[(p[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!h[e];e^=n||1,r=d[r]||1)for(s=r^r<<1^r<<2^r<<3^r<<4,s=s>>8^255&s^99,h[e]=s,l[s]=e,o=p[i=p[n=p[e]]],u=16843009*o^65537*i^257*n^16843008*e,a=257*p[s]^16843008*s,t=0;4>t;t++)c[t][e]=a=a<<24^a>>>8,f[t][s]=u=u<<24^u>>>8;for(t=0;5>t;t++)c[t]=c[t].slice(0),f[t]=f[t].slice(0)},_crypt:function(t,e){if(4!==t.length)throw new f.exception.invalid("invalid aes block size");var r,n,i,o,s=this._key[e],a=t[0]^s[0],u=t[e?3:1]^s[1],c=t[2]^s[2],h=t[e?1:3]^s[3],l=s.length/4-2,p=4,d=[0,0,0,0],_=this._tables[e],y=_[0],v=_[1],g=_[2],m=_[3],b=_[4];for(o=0;l>o;o++)r=y[a>>>24]^v[u>>16&255]^g[c>>8&255]^m[255&h]^s[p],n=y[u>>>24]^v[c>>16&255]^g[h>>8&255]^m[255&a]^s[p+1],i=y[c>>>24]^v[h>>16&255]^g[a>>8&255]^m[255&u]^s[p+2],h=y[h>>>24]^v[a>>16&255]^g[u>>8&255]^m[255&c]^s[p+3],p+=4,a=r,u=n,c=i;for(o=0;4>o;o++)d[e?3&-o:o]=b[a>>>24]<<24^b[u>>16&255]<<16^b[c>>8&255]<<8^b[255&h]^s[p++],r=a,a=u,u=c,c=h,h=r;return d}},f.bitArray={bitSlice:function(t,e,r){return t=f.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:f.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n,i=Math.floor(-e-r&31);return n=-32&(e+r-1^e)?t[e/32|0]<<32-i^t[e/32+1|0]>>>i:t[e/32|0]>>>i,n&(1<<r)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var r=t[t.length-1],n=f.bitArray.getPartial(r);return 32===n?t.concat(e):f.bitArray._shiftRight(e,n,0|r,t.slice(0,t.length-1))},bitLength:function(t){var e,r=t.length;return 0===r?0:(e=t[r-1],32*(r-1)+f.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length<e)return t;t=t.slice(0,Math.ceil(e/32));var r=t.length;return e=31&e,r>0&&e&&(t[r-1]=f.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(f.bitArray.bitLength(t)!==f.bitArray.bitLength(e))return!1;var r,n=0;for(r=0;r<t.length;r++)n|=t[r]^e[r];return 0===n},_shiftRight:function(t,e,r,n){var i,o,s=0;for(void 0===n&&(n=[]);e>=32;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(i=0;i<t.length;i++)n.push(r|t[i]>>>e),r=t[i]<<32-e;return s=t.length?t[t.length-1]:0,o=f.bitArray.getPartial(s),n.push(f.bitArray.partial(e+o&31,e+o>32?r:n.pop(),1)),n},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]},byteswapM:function(t){var e,r,n=65280;for(e=0;e<t.length;++e)r=t[e],t[e]=r>>>24|r>>>8&n|(r&n)<<8|r<<24;return t}},f.codec.utf8String={fromBits:function(t){var e,r,n="",i=f.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(r=t[e/4]),n+=String.fromCharCode(r>>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e<t.length;e++)n=n<<8|t.charCodeAt(e),3===(3&e)&&(r.push(n),n=0);return 3&e&&r.push(f.bitArray.partial(8*(3&e),n)),r}},f.codec.hex={fromBits:function(t){var e,r="";for(e=0;e<t.length;e++)r+=((0|t[e])+0xf00000000000).toString(16).substr(4);return r.substr(0,f.bitArray.bitLength(t)/4)},toBits:function(t){var e,r,n=[];for(t=t.replace(/\s|0x/g,""),r=t.length,t+="00000000",e=0;e<t.length;e+=8)n.push(0^parseInt(t.substr(e,8),16));return f.bitArray.clamp(n,4*r)}},f.codec.base64={_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,r){var n,i="",o=0,s=f.codec.base64._chars,a=0,u=f.bitArray.bitLength(t);for(r&&(s=s.substr(0,62)+"-_"),n=0;6*i.length<u;)i+=s.charAt((a^t[n]>>>o)>>>26),6>o?(a=t[n]<<6-o,o+=26,n++):(a<<=6,o-=6);for(;3&i.length&&!e;)i+="=";return i},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,n,i=[],o=0,s=f.codec.base64._chars,a=0;for(e&&(s=s.substr(0,62)+"-_"),r=0;r<t.length;r++){if(n=s.indexOf(t.charAt(r)),0>n)throw new f.exception.invalid("this isn't base64!");o>26?(o-=26,i.push(a^n>>>o),a=n<<32-o):(o+=6,a^=n<<32-o)}return 56&o&&i.push(f.bitArray.partial(56&o,a,1)),i}},f.codec.base64url={fromBits:function(t){return f.codec.base64.fromBits(t,1,1)},toBits:function(t){return f.codec.base64.toBits(t,1)}},f.codec.bytes={fromBits:function(t){var e,r,n=[],i=f.bitArray.bitLength(t);for(e=0;i/8>e;e++)0===(3&e)&&(r=t[e/4]),n.push(r>>>24),r<<=8;return n},toBits:function(t){var e,r=[],n=0;for(e=0;e<t.length;e++)n=n<<8|t[e],3===(3&e)&&(r.push(n),n=0);return 3&e&&r.push(f.bitArray.partial(8*(3&e),n)),r}},f.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.sha256.hash=function(t){return(new f.hash.sha256).update(t).finalize()},f.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=512+n&-512;i>=e;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=f.bitArray.concat(e,[f.bitArray.partial(1,1)]),t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;n>=e*e;e++)if(n%e===0)continue t;8>r&&(this._init[r]=t(Math.pow(n,.5))),this._key[r]=t(Math.pow(n,1/3)),r++}},_block:function(t){var e,r,n,i,o=t.slice(0),s=this._h,a=this._key,u=s[0],c=s[1],f=s[2],h=s[3],l=s[4],p=s[5],d=s[6],_=s[7];for(e=0;64>e;e++)16>e?r=o[e]:(n=o[e+1&15],i=o[e+14&15],r=o[15&e]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+o[15&e]+o[e+9&15]|0),r=r+_+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(d^l&(p^d))+a[e],_=d,d=p,p=l,l=h+r|0,h=f,f=c,c=u,u=r+(c&f^h&(c^f))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;s[0]=s[0]+u|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+h|0,s[4]=s[4]+l|0,s[5]=s[5]+p|0,s[6]=s[6]+d|0,s[7]=s[7]+_|0}},f.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.sha512.hash=function(t){return(new f.hash.sha512).update(t).finalize()},f.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=1024+n&-1024;i>=e;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=f.bitArray.concat(e,[f.bitArray.partial(1,1)]),t=e.length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[],_keyr:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],_precompute:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;i>=r*r;r++)if(i%r===0)continue t;8>n&&(this._init[2*n]=t(Math.pow(i,.5)),this._init[2*n+1]=e(Math.pow(i,.5))<<24|this._initr[n]),this._key[2*n]=t(Math.pow(i,1/3)),this._key[2*n+1]=e(Math.pow(i,1/3))<<24|this._keyr[n],n++}},_block:function(t){var e,r,n,i=t.slice(0),o=this._h,s=this._key,a=o[0],u=o[1],c=o[2],f=o[3],h=o[4],l=o[5],p=o[6],d=o[7],_=o[8],y=o[9],v=o[10],g=o[11],m=o[12],b=o[13],w=o[14],E=o[15],A=a,x=u,S=c,T=f,k=h,O=l,I=p,j=d,R=_,C=y,L=v,B=g,F=m,N=b,q=w,D=E;for(e=0;80>e;e++){if(16>e)r=i[2*e],n=i[2*e+1];else{var M=i[2*(e-15)],P=i[2*(e-15)+1],U=(P<<31|M>>>1)^(P<<24|M>>>8)^M>>>7,z=(M<<31|P>>>1)^(M<<24|P>>>8)^(M<<25|P>>>7),G=i[2*(e-2)],H=i[2*(e-2)+1],K=(H<<13|G>>>19)^(G<<3|H>>>29)^G>>>6,V=(G<<13|H>>>19)^(H<<3|G>>>29)^(G<<26|H>>>6),Y=i[2*(e-7)],X=i[2*(e-7)+1],W=i[2*(e-16)],$=i[2*(e-16)+1];n=z+X,r=U+Y+(z>>>0>n>>>0?1:0),n+=V,r+=K+(V>>>0>n>>>0?1:0),n+=$,r+=W+($>>>0>n>>>0?1:0)}i[2*e]=r|=0,i[2*e+1]=n|=0;var J=R&L^~R&F,Q=C&B^~C&N,Z=A&S^A&k^S&k,te=x&T^x&O^T&O,ee=(x<<4|A>>>28)^(A<<30|x>>>2)^(A<<25|x>>>7),re=(A<<4|x>>>28)^(x<<30|A>>>2)^(x<<25|A>>>7),ne=(C<<18|R>>>14)^(C<<14|R>>>18)^(R<<23|C>>>9),ie=(R<<18|C>>>14)^(R<<14|C>>>18)^(C<<23|R>>>9),oe=s[2*e],se=s[2*e+1],ae=D+ie,ue=q+ne+(D>>>0>ae>>>0?1:0);ae+=Q,ue+=J+(Q>>>0>ae>>>0?1:0),ae+=se,ue+=oe+(se>>>0>ae>>>0?1:0),ae=ae+n|0,ue+=r+(n>>>0>ae>>>0?1:0);var ce=re+te,fe=ee+Z+(re>>>0>ce>>>0?1:0);q=F,D=N,F=L,N=B,L=R,B=C,C=j+ae|0,R=I+ue+(j>>>0>C>>>0?1:0)|0,I=k,j=O,k=S,O=T,S=A,T=x,x=ae+ce|0,A=ue+fe+(ae>>>0>x>>>0?1:0)|0}u=o[1]=u+x|0,o[0]=a+A+(x>>>0>u>>>0?1:0)|0,f=o[3]=f+T|0,o[2]=c+S+(T>>>0>f>>>0?1:0)|0,l=o[5]=l+O|0,o[4]=h+k+(O>>>0>l>>>0?1:0)|0,d=o[7]=d+j|0,o[6]=p+I+(j>>>0>d>>>0?1:0)|0,y=o[9]=y+C|0,o[8]=_+R+(C>>>0>y>>>0?1:0)|0,g=o[11]=g+B|0,o[10]=v+L+(B>>>0>g>>>0?1:0)|0,b=o[13]=b+N|0,o[12]=m+F+(N>>>0>b>>>0?1:0)|0,E=o[15]=E+D|0,o[14]=w+q+(D>>>0>E>>>0?1:0)|0}},f.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.sha1.hash=function(t){return(new f.hash.sha1).update(t).finalize()},f.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=this.blockSize+n&-this.blockSize;i>=e;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(e=f.bitArray.concat(e,[f.bitArray.partial(1,1)]),t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,n){return 19>=t?e&r|~e&n:39>=t?e^r^n:59>=t?e&r|e&n|r&n:79>=t?e^r^n:void 0},_S:function(t,e){return e<<t|e>>>32-t},_block:function(t){var e,r,n,i,o,s,a,u=t.slice(0),c=this._h;for(n=c[0],i=c[1],o=c[2],s=c[3],a=c[4],e=0;79>=e;e++)e>=16&&(u[e]=this._S(1,u[e-3]^u[e-8]^u[e-14]^u[e-16])),r=this._S(5,n)+this._f(e,i,o,s)+a+u[e]+this._key[Math.floor(e/20)]|0,a=s,s=o,o=this._S(30,i),i=n,n=r;c[0]=c[0]+n|0,c[1]=c[1]+i|0,c[2]=c[2]+o|0,c[3]=c[3]+s|0,c[4]=c[4]+a|0}},f.mode.ccm={name:"ccm",encrypt:function(t,e,r,n,i){var o,s,a=e.slice(0),u=f.bitArray,c=u.bitLength(r)/8,h=u.bitLength(a)/8;if(i=i||64,n=n||[],7>c)throw new f.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&h>>>8*o;o++);return 15-c>o&&(o=15-c),r=u.clamp(r,8*(15-o)),s=f.mode.ccm._computeTag(t,e,r,n,i,o),a=f.mode.ccm._ctrMode(t,a,r,s,i,o),u.concat(a.data,a.tag)},decrypt:function(t,e,r,n,i){i=i||64,n=n||[];var o,s,a=f.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),h=a.clamp(e,c-i),l=a.bitSlice(e,c-i);if(c=(c-i)/8,7>u)throw new f.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&c>>>8*o;o++);if(15-u>o&&(o=15-u),r=a.clamp(r,8*(15-o)),h=f.mode.ccm._ctrMode(t,h,r,l,i,o),s=f.mode.ccm._computeTag(t,h.data,r,n,i,o),!a.equal(h.tag,s))throw new f.exception.corrupt("ccm: tag doesn't match");return h.data},_computeTag:function(t,e,r,n,i,o){var s,a,u,c=[],h=f.bitArray,l=h._xor4;if(i/=8,i%2||4>i||i>16)throw new f.exception.invalid("ccm: invalid tag length");if(n.length>4294967295||e.length>4294967295)throw new f.exception.bug("ccm: can't deal with 4GiB or more data");if(s=[h.partial(8,(n.length?64:0)|i-2<<2|o-1)],s=h.concat(s,r),s[3]|=h.bitLength(e)/8,s=t.encrypt(s),n.length)for(a=h.bitLength(n)/8,65279>=a?c=[h.partial(16,a)]:4294967295>=a&&(c=h.concat([h.partial(16,65534)],[a])),c=h.concat(c,n),u=0;u<c.length;u+=4)s=t.encrypt(l(s,c.slice(u,u+4).concat([0,0,0])));for(u=0;u<e.length;u+=4)s=t.encrypt(l(s,e.slice(u,u+4).concat([0,0,0])));return h.clamp(s,8*i)},_ctrMode:function(t,e,r,n,i,o){var s,a,u,c=f.bitArray,h=c._xor4,l=e.length,p=c.bitLength(e);if(u=c.concat([c.partial(8,o-1)],r).concat([0,0,0]).slice(0,4),n=c.bitSlice(h(n,t.encrypt(u)),0,i),!l)return{tag:n,data:[]};for(a=0;l>a;a+=4)u[3]++,s=t.encrypt(u),e[a]^=s[0],e[a+1]^=s[1],e[a+2]^=s[2],e[a+3]^=s[3];return{tag:n,data:c.clamp(e,p)}}},f.misc.hmac=function(t,e){this._hash=e=e||f.hash.sha256;var r,n=[[],[]],i=e.prototype.blockSize/32;for(this._baseHash=[new e,new e],t.length>i&&(t=e.hash(t)),r=0;i>r;r++)n[0][r]=909522486^t[r],n[1][r]=1549556828^t[r];this._baseHash[0].update(n[0]),this._baseHash[1].update(n[1]),this._resultHash=new e(this._baseHash[0])},f.misc.hmac.prototype.encrypt=f.misc.hmac.prototype.mac=function(t){if(this._updated)throw new f.exception.invalid("encrypt on already updated hmac called!");return this.update(t),this.digest(t)},f.misc.hmac.prototype.reset=function(){this._resultHash=new this._hash(this._baseHash[0]),this._updated=!1},f.misc.hmac.prototype.update=function(t){this._updated=!0,this._resultHash.update(t)},f.misc.hmac.prototype.digest=function(){var t=this._resultHash.finalize(),e=new this._hash(this._baseHash[1]).update(t).finalize();return this.reset(),e},f.misc.pbkdf2=function(t,e,r,n,i){if(r=r||1e3,0>n||0>r)throw f.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=f.codec.utf8String.toBits(t)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),i=i||f.misc.hmac;var o,s,a,u,c,h=new i(t),l=[],p=f.bitArray;for(c=1;32*l.length<(n||1);c++){for(o=s=h.encrypt(p.concat(e,[c])),a=1;r>a;a++)for(s=h.encrypt(s),u=0;u<s.length;u++)o[u]^=s[u];l=l.concat(o)}return n&&(l=p.clamp(l,n)),l},f.prng=function(t){this._pools=[new f.hash.sha256],this._poolEntropy=[0],this._reseedCount=0,this._robins={},this._eventId=0,this._collectorIds={},this._collectorIdNext=0,this._strength=0,this._poolStrength=0,this._nextReseed=0,this._key=[0,0,0,0,0,0,0,0],this._counter=[0,0,0,0],this._cipher=void 0,this._defaultParanoia=t,this._collectorsStarted=!1,this._callbacks={progress:{},seeded:{}},this._callbackI=0,this._NOT_READY=0,this._READY=1,this._REQUIRES_RESEED=2,this._MAX_WORDS_PER_BURST=65536,this._PARANOIA_LEVELS=[0,48,64,96,128,192,256,384,512,768,1024],this._MILLISECONDS_PER_RESEED=3e4,this._BITS_PER_RESEED=80},f.prng.prototype={randomWords:function(t,e){var r,n,i=[],o=this.isReady(e);if(o===this._NOT_READY)throw new f.exception.notReady("generator isn't seeded");for(o&this._REQUIRES_RESEED&&this._reseedFromPools(!(o&this._READY)),r=0;t>r;r+=4)(r+1)%this._MAX_WORDS_PER_BURST===0&&this._gate(),n=this._gen4words(),i.push(n[0],n[1],n[2],n[3]);return this._gate(),i.slice(0,t)},setDefaultParanoia:function(t,e){if(0===t&&"Setting paranoia=0 will ruin your security; use it only for testing"!==e)throw"Setting paranoia=0 will ruin your security; use it only for testing";this._defaultParanoia=t},addEntropy:function(t,e,r){r=r||"user";var n,i,o,s,a=(new Date).valueOf(),u=this._robins[r],c=this.isReady(),h=0;switch(n=this._collectorIds[r],void 0===n&&(n=this._collectorIds[r]=this._collectorIdNext++),void 0===u&&(u=this._robins[r]=0),this._robins[r]=(this._robins[r]+1)%this._pools.length,typeof t){case"number":void 0===e&&(e=1),this._pools[u].update([n,this._eventId++,1,e,a,1,0|t]);break;case"object":if(s=Object.prototype.toString.call(t),"[object Uint32Array]"===s){for(o=[],i=0;i<t.length;i++)o.push(t[i]);t=o}else for("[object Array]"!==s&&(h=1),i=0;i<t.length&&!h;i++)"number"!=typeof t[i]&&(h=1);if(!h){if(void 0===e)for(e=0,i=0;i<t.length;i++)for(o=t[i];o>0;)e++,o>>>=1;
this._pools[u].update([n,this._eventId++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this._pools[u].update([n,this._eventId++,3,e,a,t.length]),this._pools[u].update(t);break;default:h=1}if(h)throw new f.exception.bug("random: addEntropy only supports number, array of numbers or string");this._poolEntropy[u]+=e,this._poolStrength+=e,c===this._NOT_READY&&(this.isReady()!==this._NOT_READY&&this._fireEvent("seeded",Math.max(this._strength,this._poolStrength)),this._fireEvent("progress",this.getProgress()))},isReady:function(t){var e=this._PARANOIA_LEVELS[void 0!==t?t:this._defaultParanoia];return this._strength&&this._strength>=e?this._poolEntropy[0]>this._BITS_PER_RESEED&&(new Date).valueOf()>this._nextReseed?this._REQUIRES_RESEED|this._READY:this._READY:this._poolStrength>=e?this._REQUIRES_RESEED|this._NOT_READY:this._NOT_READY},getProgress:function(t){var e=this._PARANOIA_LEVELS[t?t:this._defaultParanoia];return this._strength>=e?1:this._poolStrength>e?1:this._poolStrength/e},startCollectors:function(){if(!this._collectorsStarted){if(this._eventListener={loadTimeCollector:this._bind(this._loadTimeCollector),mouseCollector:this._bind(this._mouseCollector),keyboardCollector:this._bind(this._keyboardCollector),accelerometerCollector:this._bind(this._accelerometerCollector),touchCollector:this._bind(this._touchCollector)},window.addEventListener)window.addEventListener("load",this._eventListener.loadTimeCollector,!1),window.addEventListener("mousemove",this._eventListener.mouseCollector,!1),window.addEventListener("keypress",this._eventListener.keyboardCollector,!1),window.addEventListener("devicemotion",this._eventListener.accelerometerCollector,!1),window.addEventListener("touchmove",this._eventListener.touchCollector,!1);else{if(!document.attachEvent)throw new f.exception.bug("can't attach event");document.attachEvent("onload",this._eventListener.loadTimeCollector),document.attachEvent("onmousemove",this._eventListener.mouseCollector),document.attachEvent("keypress",this._eventListener.keyboardCollector)}this._collectorsStarted=!0}},stopCollectors:function(){this._collectorsStarted&&(window.removeEventListener?(window.removeEventListener("load",this._eventListener.loadTimeCollector,!1),window.removeEventListener("mousemove",this._eventListener.mouseCollector,!1),window.removeEventListener("keypress",this._eventListener.keyboardCollector,!1),window.removeEventListener("devicemotion",this._eventListener.accelerometerCollector,!1),window.removeEventListener("touchmove",this._eventListener.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this._eventListener.loadTimeCollector),document.detachEvent("onmousemove",this._eventListener.mouseCollector),document.detachEvent("keypress",this._eventListener.keyboardCollector)),this._collectorsStarted=!1)},addEventListener:function(t,e){this._callbacks[t][this._callbackI++]=e},removeEventListener:function(t,e){var r,n,i=this._callbacks[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r<o.length;r++)n=o[r],delete i[n]},_bind:function(t){var e=this;return function(){t.apply(e,arguments)}},_gen4words:function(){for(var t=0;4>t&&(this._counter[t]=this._counter[t]+1|0,!this._counter[t]);t++);return this._cipher.encrypt(this._counter)},_gate:function(){this._key=this._gen4words().concat(this._gen4words()),this._cipher=new f.cipher.aes(this._key)},_reseed:function(t){this._key=f.hash.sha256.hash(this._key.concat(t)),this._cipher=new f.cipher.aes(this._key);for(var e=0;4>e&&(this._counter[e]=this._counter[e]+1|0,!this._counter[e]);e++);},_reseedFromPools:function(t){var e,r=[],n=0;for(this._nextReseed=r[0]=(new Date).valueOf()+this._MILLISECONDS_PER_RESEED,e=0;16>e;e++)r.push(4294967296*Math.random()|0);for(e=0;e<this._pools.length&&(r=r.concat(this._pools[e].finalize()),n+=this._poolEntropy[e],this._poolEntropy[e]=0,t||!(this._reseedCount&1<<e));e++);this._reseedCount>=1<<this._pools.length&&(this._pools.push(new f.hash.sha256),this._poolEntropy.push(0)),this._poolStrength-=n,n>this._strength&&(this._strength=n),this._reseedCount++,this._reseed(r)},_keyboardCollector:function(){this._addCurrentTimeToEntropy(1)},_mouseCollector:function(t){var e,r;try{e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0}catch(n){e=0,r=0}0!=e&&0!=r&&f.random.addEntropy([e,r],2,"mouse"),this._addCurrentTimeToEntropy(0)},_touchCollector:function(t){var e=t.touches[0]||t.changedTouches[0],r=e.pageX||e.clientX,n=e.pageY||e.clientY;f.random.addEntropy([r,n],1,"touch"),this._addCurrentTimeToEntropy(0)},_loadTimeCollector:function(){this._addCurrentTimeToEntropy(2)},_addCurrentTimeToEntropy:function(t){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?f.random.addEntropy(window.performance.now(),t,"loadtime"):f.random.addEntropy((new Date).valueOf(),t,"loadtime")},_accelerometerCollector:function(t){var e=t.accelerationIncludingGravity.x||t.accelerationIncludingGravity.y||t.accelerationIncludingGravity.z;if(window.orientation){var r=window.orientation;"number"==typeof r&&f.random.addEntropy(r,1,"accelerometer")}e&&f.random.addEntropy(e,2,"accelerometer"),this._addCurrentTimeToEntropy(0)},_fireEvent:function(t,e){var r,n=f.random._callbacks[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;r<i.length;r++)i[r](e)}},f.random=new f.prng(6),function(){function e(){try{return r(53)}catch(t){return null}}try{var n,i,o;if("undefined"!=typeof t&&t.exports&&(i=e())&&i.randomBytes)n=i.randomBytes(128),n=new Uint32Array(new Uint8Array(n).buffer),f.random.addEntropy(n,1024,"crypto.randomBytes");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(o=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(o);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)return;window.msCrypto.getRandomValues(o)}f.random.addEntropy(o,1024,"crypto.getRandomValues")}}catch(s){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(s))}}(),f.json={defaults:{v:1,iter:1e3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},_encrypt:function(t,e,r,n){r=r||{},n=n||{};var i,o,s,a=f.json,u=a._add({iv:f.random.randomWords(4,0)},a.defaults);if(a._add(u,r),s=u.adata,"string"==typeof u.salt&&(u.salt=f.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=f.codec.base64.toBits(u.iv)),!f.mode[u.mode]||!f.cipher[u.cipher]||"string"==typeof t&&u.iter<=100||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||u.iv.length<2||u.iv.length>4)throw new f.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(i=f.misc.cachedPbkdf2(t,u),t=i.key.slice(0,u.ks/32),u.salt=i.salt):f.ecc&&t instanceof f.ecc.elGamal.publicKey&&(i=t.kem(),u.kemtag=i.tag,t=i.key.slice(0,u.ks/32)),"string"==typeof e&&(e=f.codec.utf8String.toBits(e)),"string"==typeof s&&(s=f.codec.utf8String.toBits(s)),o=new f.cipher[u.cipher](t),a._add(n,u),n.key=t,u.ct=f.mode[u.mode].encrypt(o,e,u.iv,s,u.ts),u},encrypt:function(){var t=f.json,e=t._encrypt.apply(t,arguments);return t.encode(e)},_decrypt:function(t,e,r,n){r=r||{},n=n||{};var i,o,s,a=f.json,u=a._add(a._add(a._add({},a.defaults),e),r,!0),c=u.adata;if("string"==typeof u.salt&&(u.salt=f.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=f.codec.base64.toBits(u.iv)),!f.mode[u.mode]||!f.cipher[u.cipher]||"string"==typeof t&&u.iter<=100||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||!u.iv||u.iv.length<2||u.iv.length>4)throw new f.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(o=f.misc.cachedPbkdf2(t,u),t=o.key.slice(0,u.ks/32),u.salt=o.salt):f.ecc&&t instanceof f.ecc.elGamal.secretKey&&(t=t.unkem(f.codec.base64.toBits(u.kemtag)).slice(0,u.ks/32)),"string"==typeof c&&(c=f.codec.utf8String.toBits(c)),s=new f.cipher[u.cipher](t),i=f.mode[u.mode].decrypt(s,u.ct,u.iv,c,u.ts),a._add(n,u),n.key=t,1===r.raw?i:f.codec.utf8String.fromBits(i)},decrypt:function(t,e,r,n){var i=f.json;return i._decrypt(t,i.decode(e),r,n)},encode:function(t){var e,r="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new f.exception.invalid("json encode: invalid property name");switch(r+=n+'"'+e+'":',n=",",typeof t[e]){case"number":case"boolean":r+=t[e];break;case"string":r+='"'+escape(t[e])+'"';break;case"object":r+='"'+f.codec.base64.fromBits(t[e],0)+'"';break;default:throw new f.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(t=t.replace(/\s/g,""),!t.match(/^\{.*\}$/))throw new f.exception.invalid("json decode: this isn't json!");var e,r,n=t.replace(/^\{|\}$/g,"").split(/,/),i={};for(e=0;e<n.length;e++){if(!(r=n[e].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new f.exception.invalid("json decode: this isn't json!");r[3]?i[r[2]]=parseInt(r[3],10):r[4]?i[r[2]]=r[2].match(/^(ct|salt|iv)$/)?f.codec.base64.toBits(r[4]):unescape(r[4]):r[5]&&(i[r[2]]="true"===r[5])}return i},_add:function(t,e,r){if(void 0===t&&(t={}),void 0===e)return t;var n;for(n in e)if(e.hasOwnProperty(n)){if(r&&void 0!==t[n]&&t[n]!==e[n])throw new f.exception.invalid("required parameter overridden");t[n]=e[n]}return t},_subtract:function(t,e){var r,n={};for(r in t)t.hasOwnProperty(r)&&t[r]!==e[r]&&(n[r]=t[r]);return n},_filter:function(t,e){var r,n={};for(r=0;r<e.length;r++)void 0!==t[e[r]]&&(n[e[r]]=t[e[r]]);return n}},f.encrypt=f.json.encrypt,f.decrypt=f.json.decrypt,f.misc._pbkdf2Cache={},f.misc.cachedPbkdf2=function(t,e){var r,n,i,o,s=f.misc._pbkdf2Cache;return e=e||{},o=e.iter||1e3,n=s[t]=s[t]||{},r=n[o]=n[o]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):f.random.randomWords(2,0)},i=void 0===e.salt?r.firstSalt:e.salt,r[i]=r[i]||f.misc.pbkdf2(t,i,e.iter),{key:r[i].slice(0),salt:i.slice(0)}},f.bn=function(t){this.initWith(t)},f.bn.prototype={radix:24,maxMul:8,_class:f.bn,copy:function(){return new this._class(this)},initWith:function(t){var e,r=0;switch(typeof t){case"object":this.limbs=t.limbs.slice(0);break;case"number":this.limbs=[t],this.normalize();break;case"string":for(t=t.replace(/^0x/,""),this.limbs=[],e=this.radix/4,r=0;r<t.length;r+=e)this.limbs.push(parseInt(t.substring(Math.max(t.length-r-e,0),t.length-r),16));break;default:this.limbs=[0]}return this},equals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r=0;for(this.fullReduce(),t.fullReduce(),e=0;e<this.limbs.length||e<t.limbs.length;e++)r|=this.getLimb(e)^t.getLimb(e);return 0===r},getLimb:function(t){return t>=this.limbs.length?0:this.limbs[t]},greaterEquals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=0,o=0;for(e=Math.max(this.limbs.length,t.limbs.length)-1;e>=0;e--)r=this.getLimb(e),n=t.getLimb(e),o|=n-r&~i,i|=r-n&~o;return(o|~i)>>>31},toString:function(){this.fullReduce();var t,e,r="",n=this.limbs;for(t=0;t<this.limbs.length;t++){for(e=n[t].toString(16);t<this.limbs.length-1&&e.length<6;)e="0"+e;r=e+r}return"0x"+r},addM:function(t){"object"!=typeof t&&(t=new this._class(t));var e,r=this.limbs,n=t.limbs;for(e=r.length;e<n.length;e++)r[e]=0;for(e=0;e<n.length;e++)r[e]+=n[e];return this},doubleM:function(){var t,e,r=0,n=this.radix,i=this.radixMask,o=this.limbs;for(t=0;t<o.length;t++)e=o[t],e=e+e+r,o[t]=e&i,r=e>>n;return r&&o.push(r),this},halveM:function(){var t,e,r=0,n=this.radix,i=this.limbs;for(t=i.length-1;t>=0;t--)e=i[t],i[t]=e+r>>1,r=(1&e)<<n;return i[i.length-1]||i.pop(),this},subM:function(t){"object"!=typeof t&&(t=new this._class(t));var e,r=this.limbs,n=t.limbs;for(e=r.length;e<n.length;e++)r[e]=0;for(e=0;e<n.length;e++)r[e]-=n[e];return this},mod:function(t){var e=!this.greaterEquals(new f.bn(0));t=new f.bn(t).normalize();var r=new f.bn(this).normalize(),n=0;for(e&&(r=new f.bn(0).subM(r).normalize());r.greaterEquals(t);n++)t.doubleM();for(e&&(r=t.sub(r).normalize());n>0;n--)t.halveM(),r.greaterEquals(t)&&r.subM(t).normalize();return r.trim()},inverseMod:function(t){var e,r,n=new f.bn(1),i=new f.bn(0),o=new f.bn(this),s=new f.bn(t),a=1;if(!(1&t.limbs[0]))throw new f.exception.invalid("inverseMod: p must be odd");do for(1&o.limbs[0]&&(o.greaterEquals(s)||(e=o,o=s,s=e,e=n,n=i,i=e),o.subM(s),o.normalize(),n.greaterEquals(i)||n.addM(t),n.subM(i)),o.halveM(),1&n.limbs[0]&&n.addM(t),n.normalize(),n.halveM(),r=a=0;r<o.limbs.length;r++)a|=o.limbs[r];while(a);if(!s.equals(1))throw new f.exception.invalid("inverseMod: p and x must be relatively prime");return i},add:function(t){return this.copy().addM(t)},sub:function(t){return this.copy().subM(t)},mul:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=this.limbs,o=t.limbs,s=i.length,a=o.length,u=new this._class,c=u.limbs,f=this.maxMul;for(e=0;e<this.limbs.length+t.limbs.length+1;e++)c[e]=0;for(e=0;s>e;e++){for(n=i[e],r=0;a>r;r++)c[e+r]+=n*o[r];--f||(f=this.maxMul,u.cnormalize())}return u.cnormalize().reduce()},square:function(){return this.mul(this)},power:function(t){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var e,r,n=new this._class(1),i=this;for(e=0;e<t.length;e++)for(r=0;r<this.radix;r++)t[e]&1<<r&&(n=n.mul(i)),i=i.square();return n},mulmod:function(t,e){return this.mod(e).mul(t.mod(e)).mod(e)},powermod:function(t,e){for(var r=new f.bn(1),n=new f.bn(this),i=new f.bn(t);;){if(1&i.limbs[0]&&(r=r.mulmod(n,e)),i.halveM(),i.equals(0))break;n=n.mulmod(n,e)}return r.normalize().reduce()},trim:function(){var t,e=this.limbs;do t=e.pop();while(e.length&&0===t);return e.push(t),this},reduce:function(){return this},fullReduce:function(){return this.normalize()},normalize:function(){var t,e,r,n=0,i=this.placeVal,o=this.ipv,s=this.limbs,a=s.length,u=this.radixMask;for(t=0;a>t||0!==n&&-1!==n;t++)e=(s[t]||0)+n,r=s[t]=e&u,n=(e-r)*o;return-1===n&&(s[t-1]-=i),this},cnormalize:function(){var t,e,r,n=0,i=this.ipv,o=this.limbs,s=o.length,a=this.radixMask;for(t=0;s-1>t;t++)e=o[t]+n,r=o[t]=e&a,n=(e-r)*i;return o[t]+=n,this},toBits:function(t){this.fullReduce(),t=t||this.exponent||this.bitLength();var e=Math.floor((t-1)/24),r=f.bitArray,n=(t+7&-8)%this.radix||this.radix,i=[r.partial(n,this.getLimb(e))];for(e--;e>=0;e--)i=r.concat(i,[r.partial(Math.min(this.radix,t),this.getLimb(e))]),t-=this.radix;return i},bitLength:function(){this.fullReduce();for(var t=this.radix*(this.limbs.length-1),e=this.limbs[this.limbs.length-1];e;e>>>=1)t++;return t+7&-8}},f.bn.fromBits=function(t){var e=this,r=new e,n=[],i=f.bitArray,o=this.prototype,s=Math.min(this.bitLength||4294967296,i.bitLength(t)),a=s%o.radix||o.radix;for(n[0]=i.extract(t,0,a);s>a;a+=o.radix)n.unshift(i.extract(t,a,o.radix));return r.limbs=n,r},f.bn.prototype.ipv=1/(f.bn.prototype.placeVal=Math.pow(2,f.bn.prototype.radix)),f.bn.prototype.radixMask=(1<<f.bn.prototype.radix)-1,f.bn.pseudoMersennePrime=function(t,e){function r(t){this.initWith(t)}var n,i,o,s=r.prototype=new f.bn;for(o=s.modOffset=Math.ceil(i=t/s.radix),s.exponent=t,s.offset=[],s.factor=[],s.minOffset=o,s.fullMask=0,s.fullOffset=[],s.fullFactor=[],s.modulus=r.modulus=new f.bn(Math.pow(2,t)),s.fullMask=0|-Math.pow(2,t%s.radix),n=0;n<e.length;n++)s.offset[n]=Math.floor(e[n][0]/s.radix-i),s.fullOffset[n]=Math.ceil(e[n][0]/s.radix-i),s.factor[n]=e[n][1]*Math.pow(.5,t-e[n][0]+s.offset[n]*s.radix),s.fullFactor[n]=e[n][1]*Math.pow(.5,t-e[n][0]+s.fullOffset[n]*s.radix),s.modulus.addM(new f.bn(Math.pow(2,e[n][0])*e[n][1])),s.minOffset=Math.min(s.minOffset,-s.offset[n]);return s._class=r,s.modulus.cnormalize(),s.reduce=function(){var t,e,r,n,i=this.modOffset,o=this.limbs,s=this.offset,a=this.offset.length,u=this.factor;for(t=this.minOffset;o.length>i;){for(r=o.pop(),n=o.length,e=0;a>e;e++)o[n+s[e]]-=u[e]*r;t--,t||(o.push(0),this.cnormalize(),t=this.minOffset)}return this.cnormalize(),this},s._strongReduce=-1===s.fullMask?s.reduce:function(){var t,e,r=this.limbs,n=r.length-1;if(this.reduce(),n===this.modOffset-1){for(e=r[n]&this.fullMask,r[n]-=e,t=0;t<this.fullOffset.length;t++)r[n+this.fullOffset[t]]-=this.fullFactor[t]*e;this.normalize()}},s.fullReduce=function(){var t,e;for(this._strongReduce(),this.addM(this.modulus),this.addM(this.modulus),this.normalize(),this._strongReduce(),e=this.limbs.length;e<this.modOffset;e++)this.limbs[e]=0;for(t=this.greaterEquals(this.modulus),e=0;e<this.limbs.length;e++)this.limbs[e]-=this.modulus.limbs[e]*t;return this.cnormalize(),this},s.inverse=function(){return this.power(this.modulus.sub(2))},r.fromBits=f.bn.fromBits,r};var h=f.bn.pseudoMersennePrime;f.bn.prime={p127:h(127,[[0,-1]]),p25519:h(255,[[0,-19]]),p192k:h(192,[[32,-1],[12,-1],[8,-1],[7,-1],[6,-1],[3,-1],[0,-1]]),p224k:h(224,[[32,-1],[12,-1],[11,-1],[9,-1],[7,-1],[4,-1],[1,-1],[0,-1]]),p256k:h(256,[[32,-1],[9,-1],[8,-1],[7,-1],[6,-1],[4,-1],[0,-1]]),p192:h(192,[[0,-1],[64,-1]]),p224:h(224,[[0,1],[96,-1]]),p256:h(256,[[0,-1],[96,1],[192,1],[224,-1]]),p384:h(384,[[0,-1],[32,1],[96,-1],[128,-1]]),p521:h(521,[[0,-1]])},f.bn.random=function(t,e){"object"!=typeof t&&(t=new f.bn(t));for(var r,n,i=t.limbs.length,o=t.limbs[i-1]+1,s=new f.bn;;){do r=f.random.randomWords(i,e),r[i-1]<0&&(r[i-1]+=4294967296);while(Math.floor(r[i-1]/o)===Math.floor(4294967296/o));for(r[i-1]%=o,n=0;i-1>n;n++)r[n]&=t.radixMask;if(s.limbs=r,!s.greaterEquals(t))return s}},f.ecc={},f.ecc.point=function(t,e,r){void 0===e?this.isIdentity=!0:(e instanceof f.bn&&(e=new t.field(e)),r instanceof f.bn&&(r=new t.field(r)),this.x=e,this.y=r,this.isIdentity=!1),this.curve=t},f.ecc.point.prototype={toJac:function(){return new f.ecc.pointJac(this.curve,this.x,this.y,new this.curve.field(1))},mult:function(t){return this.toJac().mult(t,this).toAffine()},mult2:function(t,e,r){return this.toJac().mult2(t,this,e,r).toAffine()},multiples:function(){var t,e,r;if(void 0===this._multiples)for(r=this.toJac().doubl(),t=this._multiples=[new f.ecc.point(this.curve),this,r.toAffine()],e=3;16>e;e++)r=r.add(this),t.push(r.toAffine());return this._multiples},isValid:function(){return this.y.square().equals(this.curve.b.add(this.x.mul(this.curve.a.add(this.x.square()))))},toBits:function(){return f.bitArray.concat(this.x.toBits(),this.y.toBits())}},f.ecc.pointJac=function(t,e,r,n){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.z=n,this.isIdentity=!1),this.curve=t},f.ecc.pointJac.prototype={add:function(t){var e,r,n,i,o,s,a,u,c,h,l,p=this;if(p.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";return p.isIdentity?t.toJac():t.isIdentity?p:(e=p.z.square(),r=t.x.mul(e).subM(p.x),r.equals(0)?p.y.equals(t.y.mul(e.mul(p.z)))?p.doubl():new f.ecc.pointJac(p.curve):(n=t.y.mul(e.mul(p.z)).subM(p.y),i=r.square(),o=n.square(),s=r.square().mul(r).addM(p.x.add(p.x).mul(i)),a=o.subM(s),u=p.x.mul(i).subM(a).mul(n),c=p.y.mul(r.square().mul(r)),h=u.subM(c),l=p.z.mul(r),new f.ecc.pointJac(this.curve,a,h,l)))},doubl:function(){if(this.isIdentity)return this;var t=this.y.square(),e=t.mul(this.x.mul(4)),r=t.square().mul(8),n=this.z.square(),i=this.curve.a.toString()==new f.bn(-3).toString()?this.x.sub(n).mul(3).mul(this.x.add(n)):this.x.square().mul(3).add(n.square().mul(this.curve.a)),o=i.square().subM(e).subM(e),s=e.sub(o).mul(i).subM(r),a=this.y.add(this.y).mul(this.z);return new f.ecc.pointJac(this.curve,o,s,a)},toAffine:function(){if(this.isIdentity||this.z.equals(0))return new f.ecc.point(this.curve);var t=this.z.inverse(),e=t.square();return new f.ecc.point(this.curve,this.x.mul(e).fullReduce(),this.y.mul(e.mul(t)).fullReduce())},mult:function(t,e){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var r,n,i=new f.ecc.point(this.curve).toJac(),o=e.multiples();for(r=t.length-1;r>=0;r--)for(n=f.bn.prototype.radix-4;n>=0;n-=4)i=i.doubl().doubl().doubl().doubl().add(o[t[r]>>n&15]);return i},mult2:function(t,e,r,n){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs),"number"==typeof r?r=[r]:void 0!==r.limbs&&(r=r.normalize().limbs);var i,o,s,a,u=new f.ecc.point(this.curve).toJac(),c=e.multiples(),h=n.multiples();for(i=Math.max(t.length,r.length)-1;i>=0;i--)for(s=0|t[i],a=0|r[i],o=f.bn.prototype.radix-4;o>=0;o-=4)u=u.doubl().doubl().doubl().doubl().add(c[s>>o&15]).add(h[a>>o&15]);return u},isValid:function(){var t=this.z.square(),e=t.square(),r=e.mul(t);return this.y.square().equals(this.curve.b.mul(r).add(this.x.mul(this.curve.a.mul(e).add(this.x.square()))))}},f.ecc.curve=function(t,e,r,n,i,o){this.field=t,this.r=new f.bn(e),this.a=new t(r),this.b=new t(n),this.G=new f.ecc.point(this,new t(i),new t(o))},f.ecc.curve.prototype.fromBits=function(t){var e=f.bitArray,r=this.field.prototype.exponent+7&-8,n=new f.ecc.point(this,this.field.fromBits(e.bitSlice(t,0,r)),this.field.fromBits(e.bitSlice(t,r,2*r)));if(!n.isValid())throw new f.exception.corrupt("not on the curve!");return n},f.ecc.curves={c192:new f.ecc.curve(f.bn.prime.p192,"0xffffffffffffffffffffffff99def836146bc9b1b4d22831",-3,"0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"),c224:new f.ecc.curve(f.bn.prime.p224,"0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",-3,"0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4","0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21","0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),c256:new f.ecc.curve(f.bn.prime.p256,"0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",-3,"0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),c384:new f.ecc.curve(f.bn.prime.p384,"0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973",-3,"0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef","0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7","0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),k192:new f.ecc.curve(f.bn.prime.p192k,"0xfffffffffffffffffffffffe26f2fc170f69466a74defd8d",0,3,"0xdb4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d","0x9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"),k224:new f.ecc.curve(f.bn.prime.p224k,"0x010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7",0,5,"0xa1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c","0x7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5"),k256:new f.ecc.curve(f.bn.prime.p256k,"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",0,7,"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},f.ecc.basicKey={publicKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._point=e instanceof Array?t.fromBits(e):e,this.get=function(){var t=this._point.toBits(),e=f.bitArray.bitLength(t),r=f.bitArray.bitSlice(t,0,e/2),n=f.bitArray.bitSlice(t,e/2);return{x:r,y:n}}},secretKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._exponent=e,this.get=function(){return this._exponent.toBits()}}},f.ecc.basicKey.generateKeys=function(t){return function(e,r,n){if(e=e||256,"number"==typeof e&&(e=f.ecc.curves["c"+e],void 0===e))throw new f.exception.invalid("no such curve");n=n||f.bn.random(e.r,r);var i=e.G.mult(n);return{pub:new f.ecc[t].publicKey(e,i),sec:new f.ecc[t].secretKey(e,n)}}},f.ecc.elGamal={generateKeys:f.ecc.basicKey.generateKeys("elGamal"),publicKey:function(){f.ecc.basicKey.publicKey.apply(this,arguments)},secretKey:function(){f.ecc.basicKey.secretKey.apply(this,arguments)}},f.ecc.elGamal.publicKey.prototype={kem:function(t){var e=f.bn.random(this._curve.r,t),r=this._curve.G.mult(e).toBits(),n=f.hash.sha256.hash(this._point.mult(e).toBits());return{key:n,tag:r}}},f.ecc.elGamal.secretKey.prototype={unkem:function(t){return f.hash.sha256.hash(this._curve.fromBits(t).mult(this._exponent).toBits())},dh:function(t){return f.hash.sha256.hash(t._point.mult(this._exponent).toBits())},dhJavaEc:function(t){return t._point.mult(this._exponent).x.toBits()}},f.ecc.ecdsa={generateKeys:f.ecc.basicKey.generateKeys("ecdsa")},f.ecc.ecdsa.publicKey=function(){f.ecc.basicKey.publicKey.apply(this,arguments)},f.ecc.ecdsa.publicKey.prototype={verify:function(t,e,r){f.bitArray.bitLength(t)>this._curveBitLength&&(t=f.bitArray.clamp(t,this._curveBitLength));var n=f.bitArray,i=this._curve.r,o=this._curveBitLength,s=f.bn.fromBits(n.bitSlice(e,0,o)),a=f.bn.fromBits(n.bitSlice(e,o,2*o)),u=r?a:a.inverseMod(i),c=f.bn.fromBits(t).mul(u).mod(i),h=s.mul(u).mod(i),l=this._curve.G.mult2(c,h,this._point).x;if(s.equals(0)||a.equals(0)||s.greaterEquals(i)||a.greaterEquals(i)||!l.equals(s)){if(void 0===r)return this.verify(t,e,!0);throw new f.exception.corrupt("signature didn't check out")}return!0}},f.ecc.ecdsa.secretKey=function(){f.ecc.basicKey.secretKey.apply(this,arguments)},f.ecc.ecdsa.secretKey.prototype={sign:function(t,e,r,n){f.bitArray.bitLength(t)>this._curveBitLength&&(t=f.bitArray.clamp(t,this._curveBitLength));var i=this._curve.r,o=i.bitLength(),s=n||f.bn.random(i.sub(1),e).add(1),a=this._curve.G.mult(s).x.mod(i),u=f.bn.fromBits(t).add(a.mul(this._exponent)),c=r?u.inverseMod(i).mul(s).mod(i):u.mul(s.inverseMod(i)).mod(i);return f.bitArray.concat(a.toBits(o),c.toBits(o))}},f.keyexchange.srp={makeVerifier:function(t,e,r,n){var i;return i=f.keyexchange.srp.makeX(t,e,r),i=f.bn.fromBits(i),n.g.powermod(i,n.N)},makeX:function(t,e,r){var n=f.hash.sha1.hash(t+":"+e);return f.hash.sha1.hash(f.bitArray.concat(r,n))},knownGroup:function(t){return"string"!=typeof t&&(t=t.toString()),f.keyexchange.srp._didInitKnownGroups||f.keyexchange.srp._initKnownGroups(),f.keyexchange.srp._knownGroups[t]},_didInitKnownGroups:!1,_initKnownGroups:function(){var t,e,r;for(t=0;t<f.keyexchange.srp._knownGroupSizes.length;t++)e=f.keyexchange.srp._knownGroupSizes[t].toString(),r=f.keyexchange.srp._knownGroups[e],r.N=new f.bn(r.N),r.g=new f.bn(r.g);f.keyexchange.srp._didInitKnownGroups=!0},_knownGroupSizes:[1024,1536,2048],_knownGroups:{1024:{N:"EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3",g:2},1536:{N:"9DEF3CAFB939277AB1F12A8617A47BBBDBA51DF499AC4C80BEEEA9614B19CC4D5F4F5F556E27CBDE51C6A94BE4607A291558903BA0D0F84380B655BB9A22E8DCDF028A7CEC67F0D08134B1C8B97989149B609E0BE3BAB63D47548381DBC5B1FC764E3F4B53DD9DA1158BFD3E2B9C8CF56EDF019539349627DB2FD53D24B7C48665772E437D6C7F8CE442734AF7CCB7AE837C264AE3A9BEB87F8A2FE9B8B5292E5A021FFF5E91479E8CE7A28C2442C6F315180F93499A234DCF76E3FED135F9BB",g:2},2048:{N:"AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73",g:2}}},f.ecc.point.prototype.isValidPoint=function(){var t=this,e=t.curve.field.modulus;return t.isIdentity?!1:new f.bn(1).greaterEquals(t.x)&&!t.x.equals(1)||t.x.greaterEquals(e.sub(1))&&!t.x.equals(1)?!1:new f.bn(1).greaterEquals(t.y)&&!t.y.equals(1)||t.y.greaterEquals(e.sub(1))&&!t.y.equals(1)?!1:t.isOnCurve()?!0:!1},f.ecc.point.prototype.isOnCurve=function(){var t=this,e=(t.curve.r,t.curve.a),r=t.curve.b,n=t.curve.field.modulus,i=t.y.mul(t.y).mod(n),o=t.x.mul(t.x).mul(t.x).add(e.mul(t.x)).add(r).mod(n);return i.equals(o)},f.ecc.point.prototype.toString=function(){return"("+this.x.toString()+", "+this.y.toString()+")"},f.ecc.pointJac.prototype.toString=function(){return"("+this.x.toString()+", "+this.y.toString()+", "+this.z.toString()+")"},f.ecc.point.prototype.toBytesCompressed=function(){var t="0x0"==this.y.mod(2).toString()?2:3;return[t].concat(f.codec.bytes.fromBits(this.x.toBits()))},f.ecc.pointJac.prototype.add=function(t){var e=this;if(e.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";if(e.isIdentity)return t.toJac();if(t.isIdentity)return e;var r=e.z.square(),n=t.x.mul(r).subM(e.x),i=t.y.mul(e.z).mul(r);if(n.equals(0))return e.y.equals(t.y.mul(r.mul(e.z)))?e.doubl():new f.ecc.pointJac(e.curve);var o=n.square(),s=o.copy().doubleM().doubleM(),a=n.mul(s),u=i.sub(e.y).doubleM(),c=e.x.mul(s),h=u.square().subM(a).subM(c.copy().doubleM()),l=u.mul(c.sub(h)).subM(e.y.mul(a).doubleM()),p=e.z.add(n).square().subM(r).subM(o);return new f.ecc.pointJac(this.curve,h,l,p)},f.ecc.pointJac.prototype.doubl=function(){if(this.isIdentity)return this;var t=this.x.square(),e=this.y.square(),r=e.square(),n=this.x.add(e).square().subM(t).subM(r).doubleM(),i=t.mul(3),o=i.square(),s=o.sub(n.copy().doubleM()),a=i.mul(n.sub(s)).subM(r.doubleM().doubleM().doubleM()),u=this.z.mul(this.y).doubleM();return new f.ecc.pointJac(this.curve,s,a,u)},f.ecc.curves.c256=f.ecc.curves.k256,function(){function t(t,e,r){return t^e^r}function e(t,e,r){return t&e|~t&r}function r(t,e,r){return(t|~e)^r}function n(t,e,r){return t&r|e&~r}function i(t,e,r){return t^(e|~r)}function o(t,e){return t<<e|t>>>32-e}function s(t){return(255&t)<<24|(65280&t)<<8|(t&255<<16)>>>8|(t&255<<24)>>>24}function a(s){for(var a,u=this._h[0],f=this._h[1],l=this._h[2],p=this._h[3],g=this._h[4],m=this._h[0],b=this._h[1],w=this._h[2],E=this._h[3],A=this._h[4],x=0;16>x;++x)a=o(u+t(f,l,p)+s[d[x]]+c[x],y[x])+g,u=g,g=p,p=o(l,10),l=f,f=a,a=o(m+i(b,w,E)+s[_[x]]+h[x],v[x])+A,m=A,A=E,E=o(w,10),w=b,b=a;for(;32>x;++x)a=o(u+e(f,l,p)+s[d[x]]+c[x],y[x])+g,u=g,g=p,p=o(l,10),l=f,f=a,a=o(m+n(b,w,E)+s[_[x]]+h[x],v[x])+A,m=A,A=E,E=o(w,10),w=b,b=a;for(;48>x;++x)a=o(u+r(f,l,p)+s[d[x]]+c[x],y[x])+g,u=g,g=p,p=o(l,10),l=f,f=a,a=o(m+r(b,w,E)+s[_[x]]+h[x],v[x])+A,m=A,A=E,E=o(w,10),w=b,b=a;for(;64>x;++x)a=o(u+n(f,l,p)+s[d[x]]+c[x],y[x])+g,u=g,g=p,p=o(l,10),l=f,f=a,a=o(m+e(b,w,E)+s[_[x]]+h[x],v[x])+A,m=A,A=E,E=o(w,10),w=b,b=a;for(;80>x;++x)a=o(u+i(f,l,p)+s[d[x]]+c[x],y[x])+g,u=g,g=p,p=o(l,10),l=f,f=a,a=o(m+t(b,w,E)+s[_[x]]+h[x],v[x])+A,m=A,A=E,E=o(w,10),w=b,b=a;a=this._h[1]+l+E,this._h[1]=this._h[2]+p+A,this._h[2]=this._h[3]+g+m,this._h[3]=this._h[4]+u+b,this._h[4]=this._h[0]+f+w,this._h[0]=a}f.hash.ripemd160=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},f.hash.ripemd160.hash=function(t){return(new f.hash.ripemd160).update(t).finalize()},f.hash.ripemd160.prototype={reset:function(){return this._h=u.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=f.codec.utf8String.toBits(t));var e,r=this._buffer=f.bitArray.concat(this._buffer,t),n=this._length,i=this._length=n+f.bitArray.bitLength(t);for(e=512+n&-512;i>=e;e+=512){for(var o=r.splice(0,16),u=0;16>u;++u)o[u]=s(o[u]);a.call(this,o)}return this},finalize:function(){var t=f.bitArray.concat(this._buffer,[f.bitArray.partial(1,1)]),e=(this._length+1)%512,r=(e>448?512:448)-e%448,n=r%32;for(n>0&&(t=f.bitArray.concat(t,[f.bitArray.partial(n,0)]));r>=32;r-=32)t.push(0);for(t.push(s(0|this._length)),t.push(s(Math.floor(this._length/4294967296)));t.length;){for(var i=t.splice(0,16),o=0;16>o;++o)i[o]=s(i[o]);a.call(this,i)}var u=this._h;this.reset();for(var o=0;5>o;++o)u[o]=s(u[o]);return u}};for(var u=[1732584193,4023233417,2562383102,271733878,3285377520],c=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0],l=4;l>=0;--l)for(var p=1;16>p;++p)c.splice(l,0,c[l]),h.splice(l,0,h[l]);var d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],_=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],v=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]
}(),f.bn.ZERO=new f.bn(0),f.bn.prototype.divRem=function(t){"object"!=typeof t&&(t=new this._class(t));var e=this.abs(),r=t.abs(),n=new this._class(0),i=0;if(!e.greaterEquals(r))return[new f.bn(0),this.copy()];if(e.equals(r))return[new f.bn(1),new f.bn(0)];for(;e.greaterEquals(r);i++)r.doubleM();for(;i>0;i--)n.doubleM(),r.halveM(),e.greaterEquals(r)&&(n.addM(1),e.subM(t).normalize());return[n,e]},f.bn.prototype.divRound=function(t){var e=this.divRem(t),r=e[0],n=e[1];return n.doubleM().greaterEquals(t)&&r.addM(1),r},f.bn.prototype.div=function(t){var e=this.divRem(t);return e[0]},f.bn.prototype.sign=function(){return this.greaterEquals(f.bn.ZERO)?1:-1},f.bn.prototype.neg=function(){return f.bn.ZERO.sub(this)},f.bn.prototype.abs=function(){return-1===this.sign()?this.neg():this},f.bn.prototype.shiftRight=function(t){if("number"!=typeof t)throw new Error("shiftRight expects a number");if(t=+t,0>t)return this.shiftLeft(t);for(var e=new f.bn(this);t>=this.radix;)e.limbs.shift(),t-=this.radix;for(;t--;)e.halveM();return e},f.bn.prototype.shiftLeft=function(t){if("number"!=typeof t)throw new Error("shiftLeft expects a number");if(t=+t,0>t)return this.shiftRight(t);for(var e=new f.bn(this);t>=this.radix;)e.limbs.unshift(0),t-=this.radix;for(;t--;)e.doubleM();return e},f.bn.prototype.toNumber=function(){return 0|this.limbs[0]},f.bn.prototype.testBit=function(t){var e=Math.floor(t/this.radix),r=t%this.radix;return e>=this.limbs.length?0:this.limbs[e]>>>r&1},f.bn.prototype.setBitM=function(t){for(var e=Math.floor(t/this.radix),r=t%this.radix;e>=this.limbs.length;)this.limbs.push(0);return this.limbs[e]|=1<<r,this.cnormalize(),this},f.bn.prototype.modInt=function(t){return this.toNumber()%t},f.bn.prototype.invDigit=function(){var t=1+this.radixMask;if(this.limbs.length<1)return 0;var e=this.limbs[0];if(0==(1&e))return 0;var r=3&e;return r=r*(2-(15&e)*r)&15,r=r*(2-(255&e)*r)&255,r=r*(2-((65535&e)*r&65535))&65535,r=r*(2-e*r%t)%t,r>0?t-r:-r},f.bn.prototype.am=function(t,e,r,n,i,o){for(var s=4095&e,a=e>>12;--o>=0;){var u=4095&this.limbs[t],c=this.limbs[t++]>>12,f=a*u+c*s;u=s*u+((4095&f)<<12)+r.limbs[n]+i,i=(u>>24)+(f>>12)+a*c,r.limbs[n++]=16777215&u}return i};var l=function(t){this.m=t,this.mt=t.limbs.length,this.mt2=2*this.mt,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.radix-15)-1};l.prototype.reduce=function(t){for(var e=t.radixMask+1;t.limbs.length<=this.mt2;)t.limbs[t.limbs.length]=0;for(var r=0;r<this.mt;++r){var n=32767&t.limbs[r],i=n*this.mpl+((n*this.mph+(t.limbs[r]>>15)*this.mpl&this.um)<<15)&t.radixMask;for(n=r+this.mt,t.limbs[n]+=this.m.am(0,i,t,r,0,this.mt);t.limbs[n]>=e;)t.limbs[n]-=e,t.limbs[++n]++}return t.trim(),t=t.shiftRight(this.mt*this.m.radix),t.greaterEquals(this.m)&&(t=t.sub(this.m)),t.trim().normalize().reduce()},l.prototype.square=function(t){return this.reduce(t.square())},l.prototype.multiply=function(t,e){return this.reduce(t.mul(e))},l.prototype.convert=function(t){return t.abs().shiftLeft(this.mt*this.m.radix).mod(this.m)},l.prototype.revert=function(t){return this.reduce(t.copy())},f.bn.prototype.powermodMontgomery=function(t,e){var r,i=t.bitLength(),o=new this._class(1);if(0>=i)return o;if(r=18>i?1:48>i?3:144>i?4:768>i?5:6,8>i||!e.testBit(0))return this.powermod(t,e);var s=new l(e);t.trim().normalize();var a=new Array,u=3,c=r-1,f=(1<<r)-1;if(a[1]=s.convert(this),r>1)for(var h=s.square(a[1]);f>=u;)a[u]=s.multiply(h,a[u-2]),u+=2;var p,d,_=t.limbs.length-1,y=!0,v=new this._class;for(i=n(t.limbs[_])-1;_>=0;){for(i>=c?p=t.limbs[_]>>i-c&f:(p=(t.limbs[_]&(1<<i+1)-1)<<c-i,_>0&&(p|=t.limbs[_-1]>>this.radix+i-c)),u=r;0==(1&p);)p>>=1,--u;if((i-=u)<0&&(i+=this.radix,--_),y)o=a[p].copy(),y=!1;else{for(;u>1;)v=s.square(o),o=s.square(v),u-=2;u>0?v=s.square(o):(d=o,o=v,v=d),o=s.multiply(v,a[p])}for(;_>=0&&0==(t.limbs[_]&1<<i);)v=s.square(o),d=o,o=v,v=d,--i<0&&(i=this.radix-1,--_)}return s.revert(o)},f.ecc.ecdsa.secretKey.prototype.sign=function(t,e,r){var n,i=this._curve.r,o=i.bitLength();n="object"==typeof r&&r.length>0&&"number"==typeof r[0]?r:"string"==typeof r&&/^[0-9a-fA-F]+$/.test(r)?f.bn.fromBits(f.codec.hex.toBits(r)):f.bn.random(i.sub(1),e).add(1);var s=this._curve.G.mult(n).x.mod(i),a=f.bn.fromBits(t).add(s.mul(this._exponent)).mul(n.inverseMod(i)).mod(i);return f.bitArray.concat(s.toBits(o),a.toBits(o))},f.ecc.ecdsa.publicKey.prototype.verify=function(t,e){var r=f.bitArray,n=this._curve.r,i=n.bitLength(),o=f.bn.fromBits(r.bitSlice(e,0,i)),s=f.bn.fromBits(r.bitSlice(e,i,2*i)),a=s.inverseMod(n),u=f.bn.fromBits(t).mul(a).mod(n),c=o.mul(a).mod(n),h=this._curve.G.mult2(u,c,this._point).x;if(o.equals(0)||s.equals(0)||o.greaterEquals(n)||s.greaterEquals(n)||!h.equals(o))throw new f.exception.corrupt("signature didn't check out");return!0},f.ecc.ecdsa.secretKey.prototype.canonicalizeSignature=function(t){var e=f.bitArray,r=this._curve.r,n=r.bitLength(),i=f.bn.fromBits(e.bitSlice(t,0,n)),o=f.bn.fromBits(e.bitSlice(t,n,2*n));return r.copy().halveM().greaterEquals(o)||(o=r.sub(o)),e.concat(i.toBits(n),o.toBits(n))},f.ecc.ecdsa.secretKey.prototype.signDER=function(t,e){return this.encodeDER(this.sign(t,e))},f.ecc.ecdsa.secretKey.prototype.encodeDER=function(t){for(var e=f.bitArray,r=this._curve.r,n=r.bitLength(),i=f.codec.bytes.fromBits(e.bitSlice(t,0,n)),o=f.codec.bytes.fromBits(e.bitSlice(t,n,2*n));!i[0]&&i.length;)i.shift();for(;!o[0]&&o.length;)o.shift();128&i[0]&&i.unshift(0),128&o[0]&&o.unshift(0);var s=[].concat(48,4+i.length+o.length,2,i.length,i,2,o.length,o);return f.codec.bytes.toBits(s)};var p;f.ecc.ecdsa.secretKey.prototype.signWithRecoverablePublicKey=function(t,e,r){var n,s=this;if(!("object"==typeof t&&t.length>0&&"number"==typeof t[0]))throw new f.exception.invalid("hash. Must be a bitArray");n=t;var a=s.sign(n,e,r),u=s.canonicalizeSignature(a),c=i(s._curve,u),h=s._curve.G.mult(f.bn.fromBits(s.get())),l=o(s._curve,c.r,c.s,n,h),p=l+27,d=f.bitArray.concat([p],u);return d},f.ecc.ecdsa.publicKey.recoverFromSignature=function(t,e,r){if(!e||e instanceof f.ecc.curve)throw new f.exception.invalid("must supply hash and signature to recover public key");r||(r=f.ecc.curves.k256);var n;if(!("object"==typeof t&&t.length>0&&"number"==typeof t[0]))throw new f.exception.invalid("hash. Must be a bitArray");n=t;var o;if(!("object"==typeof e&&e.length>0&&"number"==typeof e[0]))throw new f.exception.invalid("signature. Must be a bitArray");o=e;var a=o[0]-27;if(0>a||a>3)throw new f.exception.invalid("signature. Signature must be generated with algorithm that prepends the recovery factor in order to recover the public key");var u=i(r,o.slice(1)),c=u.r,h=u.s,l=s(r,c,h,n,a),p=new f.ecc.ecdsa.publicKey(r,l);return p},f.bn.prototype.jacobi=function(t){var e=this;if(t=new f.bn(t),-1!==t.sign()){if(e.equals(0))return 0;if(e.equals(1))return 1;for(var r=0,n=0;!e.testBit(n);)n++;var i=e.shiftRight(n);if(0===(1&n))r=1;else{var o=t.modInt(8);1===o||7===o?r=1:(3===o||5===o)&&(r=-1)}return 3===t.modInt(4)&&3===i.modInt(4)&&(r=-r),i.equals(1)?r:r*t.mod(i).jacobi(i)}}},function(t){try{t.exports=WebSocket}catch(e){t.exports=MozWebSocket}var r,n=/Version\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//;"object"==typeof navigator&&"string"==typeof navigator.userAgent&&(r=n.exec(navigator.userAgent))&&2===window.WebSocket.CLOSED&&(/iP(hone|od|ad)/.test(navigator.platform)?+r[1]<5&&(t.exports=void 0):-1!==navigator.appVersion.indexOf("Mac")&&+r[1]<6&&(t.exports=void 0))},function(t,e,r){"use strict";function n(){}function i(t){n.call(this),this.leaves={},this.type=n.INNER,this.depth=void 0===t?0:t,this.empty=!0}function o(t,e,r){if(n.call(this),"string"!=typeof t)throw new Error("Tag is unexpected type.");this.tag=t,this.tag_bytes=c.from_hex(this.tag).to_bytes(),this.type=r,this.node=e}function s(){this.root=new i(0)}var a=r(38),u=r(26),c=r(10).UInt256,f=r(13).SerializedObject;n.TYPE_INNER=1,n.TYPE_TRANSACTION_NM=2,n.TYPE_TRANSACTION_MD=3,n.TYPE_ACCOUNT_STATE=4,n.prototype.add_item=function(){throw new Error("Called unimplemented virtual method SHAMapTreeNode#add_item.")},n.prototype.hash=function(){throw new Error("Called unimplemented virtual method SHAMapTreeNode#hash.")},a.inherits(i,n),i.prototype.add_item=function(t,e){var r=this.depth,n=this.get_node(t[r]);if(n)if(n instanceof i)n.add_item(t,e);else{if(n.tag===t)throw new Error("Tried to add a node to a SHAMap that was already in there.");var o=new i(r+1);o.add_item(n.tag,n),o.add_item(t,e),this.set_node(t[r],o)}else this.set_node(t[r],e)},i.prototype.set_node=function(t,e){this.leaves[t]=e,this.empty=!1},i.prototype.get_node=function(t){return this.leaves[t]},i.prototype.hash=function(){if(this.empty)return c.from_hex(c.HEX_ZERO);for(var t=new f,e=0;16>e;e++){var r=c.from_hex(c.HEX_ZERO),n=e.toString(16).toUpperCase();"object"==typeof this.leaves[n]&&(r=this.leaves[n].hash()),t.append(r.to_bytes())}var i=t.hash(u.HASH_INNER_NODE);return c.from_bits(i)},a.inherits(o,n),o.prototype.hash=function(){var t=new f;switch(this.type){case n.TYPE_ACCOUNT_STATE:return t.append(this.node),t.append(this.tag_bytes),t.hash(u.HASH_LEAF_NODE);case n.TYPE_TRANSACTION_NM:return this.tag_bytes;case n.TYPE_TRANSACTION_MD:return t.append(this.node),t.append(this.tag_bytes),t.hash(u.HASH_TX_NODE);default:throw new Error("Tried to hash a SHAMap node of unknown type.")}},s.prototype.add_item=function(t,e,r){e=new o(t,e,r),this.root.add_item(t,e)},s.prototype.hash=function(){return this.root.hash()},e.SHAMap=s,e.SHAMapTreeNode=n,e.SHAMapTreeNodeInner=i,e.SHAMapTreeNodeLeaf=o},function(t){t.exports={account:"a",dirNode:"d",generatorMap:"g",nickname:"n",rippleState:"r",offer:"o",ownerDir:"O",bookDir:"B",contract:"c",skipList:"s",amendment:"f",feeSettings:"e"}},function(t,e,r){t.exports=function(t){function e(t){return o.bitArray.bitSlice(o.hash.sha512.hash(o.codec.bytes.toBits(t)),0,256)}function n(t,e){return[].concat(t,e>>24,e>>16&255,e>>8&255,255&e)}function i(t){if(this.secret=t,!this.secret)throw"Invalid secret."}var o=t.sjcl,s=r(49)({sjcl:t.sjcl}),a=r(50)({sjcl:t.sjcl}),u=r(51)({sjcl:t.sjcl}),c=r(52)({sjcl:t.sjcl});return i.prototype={getPrivateKey:function(){var t=this;return s.decode_base_check(33,t.secret)},getPrivateGenerator:function(t){var r=0;do privateGenerator=o.bn.fromBits(e(n(t,r))),r++;while(!o.ecc.curves.c256.r.greaterEquals(privateGenerator));return privateGenerator},getPublicGenerator:function(){var t=this.getPrivateKey(this.secret),e=this.getPrivateGenerator(t);return c.fromPrivateGenerator(e)},getPublicKey:function(t){var r,i=0;do r=o.bn.fromBits(e(n(n(t.toBytesCompressed(),0),i))),i++;while(!o.ecc.curves.c256.r.greaterEquals(r));return o.ecc.curves.c256.G.mult(r).toJac().add(t).toAffine()},getAddress:function(){var t=this.getPrivateKey(this.secret),e=this.getPrivateGenerator(t),r=c.fromPrivateGenerator(e).value,n=this.getPublicKey(r);return u.fromPublicKey(n)}},i.getRandom=function(){var t=a.getRandom().value;return new i(t)},i.generate=function(){var t=a.getRandom().value,e=new i(t);return{address:e.getAddress().value,secret:t}},i}},function(t){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function n(t){return"number"==typeof t}function i(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(t){if(!n(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},e.prototype.emit=function(t){var e,n,s,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],o(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,a=new Array(s-1),u=1;s>u;u++)a[u-1]=arguments[u];n.apply(this,a)}else if(i(n)){for(s=arguments.length,a=new Array(s-1),u=1;s>u;u++)a[u-1]=arguments[u];for(c=n.slice(),s=c.length,u=0;s>u;u++)c[u].apply(this,a)}return!0},e.prototype.addListener=function(t,n){var s;if(!r(n))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,r(n.listener)?n.listener:n),this._events[t]?i(this._events[t])?this._events[t].push(n):this._events[t]=[this._events[t],n]:this._events[t]=n,i(this._events[t])&&!this._events[t].warned){var s;s=o(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},e.prototype.removeListener=function(t,e){var n,o,s,a;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,o=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(a=s;a-->0;)if(n[a]===e||n[a].listener&&n[a].listener===e){o=a;break}if(0>o)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},e.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},e.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},e.listenerCount=function(t,e){var n;return n=t._events&&t._events[e]?r(t._events[e])?1:t._events[e].length:0}},function(t,e,r){(function(t,n){function i(t,r){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),_(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t){return t}function a(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function u(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return m(i)||(i=u(t,i,n)),i}var o=c(t,r);if(o)return o;var s=Object.keys(r),_=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),S(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(r);if(0===s.length){if(T(r)){var y=r.name?": "+r.name:"";return t.stylize("[Function"+y+"]","special")}if(E(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(x(r))return t.stylize(Date.prototype.toString.call(r),"date");if(S(r))return f(r)}var v="",g=!1,b=["{","}"];if(d(r)&&(g=!0,b=["[","]"]),T(r)){var w=r.name?": "+r.name:"";v=" [Function"+w+"]"}if(E(r)&&(v=" "+RegExp.prototype.toString.call(r)),x(r)&&(v=" "+Date.prototype.toUTCString.call(r)),S(r)&&(v=" "+f(r)),0===s.length&&(!g||0==r.length))return b[0]+v+b[1];if(0>n)return E(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r);var A;return A=g?h(t,r,n,_,s):s.map(function(e){return l(t,r,n,_,e,g)}),t.seen.pop(),p(A,v,b)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return g(e)?t.stylize(""+e,"number"):_(e)?t.stylize(""+e,"boolean"):y(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)o.push(R(e,String(s))?l(t,e,r,n,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(t,e,r,n,i,!0))}),o}function l(t,e,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),R(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=y(r)?u(t,c.value,null):u(t,c.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function _(t){return"boolean"==typeof t}function y(t){return null===t}function v(t){return null==t}function g(t){return"number"==typeof t}function m(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function E(t){return A(t)&&"[object RegExp]"===O(t)}function A(t){return"object"==typeof t&&null!==t}function x(t){return A(t)&&"[object Date]"===O(t)}function S(t){return A(t)&&("[object Error]"===O(t)||t instanceof Error)}function T(t){return"function"==typeof t}function k(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function O(t){return Object.prototype.toString.call(t)}function I(t){return 10>t?"0"+t.toString(10):t.toString(10)}function j(){var t=new Date,e=[I(t.getHours()),I(t.getMinutes()),I(t.getSeconds())].join(":");return[t.getDate(),F[t.getMonth()],e].join(" ")}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var C=/%[sdj%]/g;e.format=function(t){if(!m(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(i(arguments[r]));return e.join(" ")}for(var r=1,n=arguments,o=n.length,s=String(t).replace(C,function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=y(a)||!A(a)?" "+a:" "+i(a);return s},e.deprecate=function(r,i){function o(){if(!s){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),s=!0}return r.apply(this,arguments)}if(w(t.process))return function(){return e.deprecate(r,i).apply(this,arguments)};if(n.noDeprecation===!0)return r;var s=!1;return o};var L,B={};e.debuglog=function(t){if(w(L)&&(L=n.env.NODE_DEBUG||""),t=t.toUpperCase(),!B[t])if(new RegExp("\\b"+t+"\\b","i").test(L)){var r=n.pid;B[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else B[t]=function(){};return B[t]},e.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=d,e.isBoolean=_,e.isNull=y,e.isNullOrUndefined=v,e.isNumber=g,e.isString=m,e.isSymbol=b,e.isUndefined=w,e.isRegExp=E,e.isObject=A,e.isDate=x,e.isError=S,e.isFunction=T,e.isPrimitive=k,e.isBuffer=r(54);var F=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];e.log=function(){console.log("%s - %s",j(),e.format.apply(e,arguments))},e.inherits=r(62),e._extend=function(t,e){if(!e||!A(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(e,function(){return this}(),r(55))},function(t,e,r){function n(t,e){return p.isUndefined(e)?""+e:p.isNumber(e)&&!isFinite(e)?e.toString():p.isFunction(e)||p.isRegExp(e)?e.toString():e}function i(t,e){return p.isString(t)?t.length<e?t:t.slice(0,e):t}function o(t){return i(JSON.stringify(t.actual,n),128)+" "+t.operator+" "+i(JSON.stringify(t.expected,n),128)}function s(t,e,r,n,i){throw new y.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function a(t,e){t||s(t,!0,e,"==",y.ok)}function u(t,e){if(t===e)return!0;if(p.isBuffer(t)&&p.isBuffer(e)){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}return p.isDate(t)&&p.isDate(e)?t.getTime()===e.getTime():p.isRegExp(t)&&p.isRegExp(e)?t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase:p.isObject(t)||p.isObject(e)?f(t,e):t==e}function c(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function f(t,e){if(p.isNullOrUndefined(t)||p.isNullOrUndefined(e))return!1;if(t.prototype!==e.prototype)return!1;if(p.isPrimitive(t)||p.isPrimitive(e))return t===e;var r=c(t),n=c(e);if(r&&!n||!r&&n)return!1;if(r)return t=d.call(t),e=d.call(e),u(t,e);var i,o,s=v(t),a=v(e);if(s.length!=a.length)return!1;for(s.sort(),a.sort(),o=s.length-1;o>=0;o--)if(s[o]!=a[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!u(t[i],e[i]))return!1;return!0}function h(t,e){return t&&e?"[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function l(t,e,r,n){var i;p.isString(r)&&(n=r,r=null);try{e()}catch(o){i=o}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&s(i,r,"Missing expected exception"+n),!t&&h(i,r)&&s(i,r,"Got unwanted exception"+n),t&&i&&r&&!h(i,r)||!t&&i)throw i}var p=r(38),d=Array.prototype.slice,_=Object.prototype.hasOwnProperty,y=t.exports=a;y.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=o(this),this.generatedMessage=!0);var e=t.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=e.name,a=n.indexOf("\n"+i);if(a>=0){var u=n.indexOf("\n",a+1);n=n.substring(u+1)}this.stack=n}}},p.inherits(y.AssertionError,Error),y.fail=s,y.ok=a,y.equal=function(t,e,r){t!=e&&s(t,e,r,"==",y.equal)},y.notEqual=function(t,e,r){t==e&&s(t,e,r,"!=",y.notEqual)},y.deepEqual=function(t,e,r){u(t,e)||s(t,e,r,"deepEqual",y.deepEqual)},y.notDeepEqual=function(t,e,r){u(t,e)&&s(t,e,r,"notDeepEqual",y.notDeepEqual)},y.strictEqual=function(t,e,r){t!==e&&s(t,e,r,"===",y.strictEqual)},y.notStrictEqual=function(t,e,r){t===e&&s(t,e,r,"!==",y.notStrictEqual)},y["throws"]=function(){l.apply(this,[!0].concat(d.call(arguments)))},y.doesNotThrow=function(){l.apply(this,[!1].concat(d.call(arguments)))},y.ifError=function(t){if(t)throw t};var v=Object.keys||function(t){var e=[];for(var r in t)_.call(t,r)&&e.push(r);return e}},function(t,e,r){var n;(function(t,i){(function(){function o(t,e){if(t!==e){var r=t===t,n=e===e;if(t>e||!r||t===k&&n)return 1;if(e>t||!n||e===k&&r)return-1}return 0}function s(t,e,r){for(var n=t.length,i=r?n:-1;r?i--:++i<n;)if(e(t[i],i,t))return i;return-1}function a(t,e,r){if(e!==e)return g(t,r);for(var n=r-1,i=t.length;++n<i;)if(t[n]===e)return n;return-1}function u(t){return"function"==typeof t||!1}function c(t){return"string"==typeof t?t:null==t?"":t+""}function f(t){return t.charCodeAt(0)}function h(t,e){for(var r=-1,n=t.length;++r<n&&e.indexOf(t.charAt(r))>-1;);return r}function l(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function p(t,e){return o(t.criteria,e.criteria)||t.index-e.index}function d(t,e,r){for(var n=-1,i=t.criteria,s=e.criteria,a=i.length,u=r.length;++n<a;){var c=o(i[n],s[n]);if(c)return n>=u?c:c*(r[n]?1:-1)}return t.index-e.index}function _(t){return Ye[t]}function y(t){return Xe[t]}function v(t){return"\\"+Je[t]}function g(t,e,r){for(var n=t.length,i=e+(r?0:-1);r?i--:++i<n;){var o=t[i];if(o!==o)return i}return-1}function m(t){return!!t&&"object"==typeof t}function b(t){return 160>=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function w(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r<n;)t[r]===e&&(t[r]=V,o[++i]=r);return o}function E(t,e){for(var r,n=-1,i=t.length,o=-1,s=[];++n<i;){var a=t[n],u=e?e(a,n,t):a;n&&r===u||(r=u,s[++o]=a)}return s}function A(t){for(var e=-1,r=t.length;++e<r&&b(t.charCodeAt(e)););return e}function x(t){for(var e=t.length;e--&&b(t.charCodeAt(e)););return e}function S(t){return We[t]}function T(t){function e(t){if(m(t)&&!Au(t)&&!(t instanceof i)){if(t instanceof n)return t;if(Us.call(t,"__chain__")&&Us.call(t,"__wrapped__"))return ii(t)}return new n(t)}function r(){}function n(t,e,r){this.__wrapped__=t,this.__actions__=r||[],this.__chain__=!!e}function i(t){this.__wrapped__=t,this.__actions__=null,this.__dir__=1,this.__dropCount__=0,this.__filtered__=!1,this.__iteratees__=null,this.__takeCount__=ba,this.__views__=null}function b(){var t=this.__actions__,e=this.__iteratees__,r=this.__views__,n=new i(this.__wrapped__);return n.__actions__=t?tr(t):null,n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=e?tr(e):null,n.__takeCount__=this.__takeCount__,n.__views__=r?tr(r):null,n}function Z(){if(this.__filtered__){var t=new i(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function ne(){var t=this.__wrapped__.value();if(!Au(t))return tn(t,this.__actions__);var e=this.__dir__,r=0>e,n=Dn(0,t.length,this.__views__),i=n.start,o=n.end,s=o-i,a=r?o:i-1,u=da(s,this.__takeCount__),c=this.__iteratees__,f=c?c.length:0,h=0,l=[];t:for(;s--&&u>h;){a+=e;for(var p=-1,d=t[a];++p<f;){var _=c[p],y=_.iteratee,v=_.type;if(v==z){if(_.done&&(r?a>_.index:a<_.index)&&(_.count=0,_.done=!1),_.index=a,!_.done){var g=_.limit;if(!(_.done=g>-1?_.count++>=g:!y(d)))continue t}}else{var m=y(d);if(v==H)d=m;else if(!m){if(v==G)continue t;break t}}}l[h++]=d}return l}function oe(){this.__data__={}}function Ye(t){return this.has(t)&&delete this.__data__[t]}function Xe(t){return"__proto__"==t?k:this.__data__[t]}function We(t){return"__proto__"!=t&&Us.call(this.__data__,t)}function $e(t,e){return"__proto__"!=t&&(this.__data__[t]=e),this}function Je(t){var e=t?t.length:0;for(this.data={hash:fa(null),set:new ra};e--;)this.push(t[e])}function Qe(t,e){var r=t.data,n="string"==typeof e||Eo(e)?r.set.has(e):r.hash[e];return n?0:-1}function Ze(t){var e=this.data;"string"==typeof t||Eo(t)?e.set.add(t):e.hash[t]=!0}function tr(t,e){var r=-1,n=t.length;for(e||(e=Ts(n));++r<n;)e[r]=t[r];return e}function er(t,e){for(var r=-1,n=t.length;++r<n&&e(t[r],r,t)!==!1;);return t}function rr(t,e){for(var r=t.length;r--&&e(t[r],r,t)!==!1;);return t}function or(t,e){for(var r=-1,n=t.length;++r<n;)if(!e(t[r],r,t))return!1;return!0}function sr(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r<n;){var s=t[r];e(s,r,t)&&(o[++i]=s)}return o}function ar(t,e){for(var r=-1,n=t.length,i=Ts(n);++r<n;)i[r]=e(t[r],r,t);return i}function ur(t){for(var e=-1,r=t.length,n=ma;++e<r;){var i=t[e];i>n&&(n=i)}return n}function cr(t){for(var e=-1,r=t.length,n=ba;++e<r;){var i=t[e];n>i&&(n=i)}return n}function fr(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i<o;)r=e(r,t[i],i,t);return r}function hr(t,e,r,n){var i=t.length;for(n&&i&&(r=t[--i]);i--;)r=e(r,t[i],i,t);return r}function lr(t,e){for(var r=-1,n=t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function pr(t){for(var e=t.length,r=0;e--;)r+=+t[e]||0;return r}function dr(t,e){return t===k?e:t}function _r(t,e,r,n){return t!==k&&Us.call(n,r)?t:e}function yr(t,e,r){var n=Fu(e);Zs.apply(n,Pa(e));for(var i=-1,o=n.length;++i<o;){var s=n[i],a=t[s],u=r(a,e[s],s,t,e);(u===u?u===a:a!==a)&&(a!==k||s in t)||(t[s]=u)}return t}function vr(t,e){for(var r=-1,n=t.length,i=Yn(n),o=e.length,s=Ts(o);++r<o;){var a=e[r];s[r]=i?Gn(a,n)?t[a]:k:t[a]}return s}function gr(t,e,r){r||(r={});for(var n=-1,i=e.length;++n<i;){var o=e[n];r[o]=t[o]}return r}function mr(t,e,r){var n=typeof t;return"function"==n?e===k?t:nn(t,e,r):null==t?ps:"object"==n?qr(t):e===k?ms(t):Dr(t,e)}function br(t,e,r,n,i,o,s){var a;if(r&&(a=i?r(t,n,i):r(t)),a!==k)return a;if(!Eo(t))return t;var u=Au(t);if(u){if(a=Mn(t),!e)return tr(t,a)}else{var c=Gs.call(t),f=c==Q;if(c!=ee&&c!=Y&&(!f||i))return Ke[c]?Un(t,c,e):i?t:{};if(a=Pn(f?{}:t),!e)return Ia(a,t)}o||(o=[]),s||(s=[]);for(var h=o.length;h--;)if(o[h]==t)return s[h];return o.push(t),s.push(a),(u?er:Ir)(t,function(n,i){a[i]=br(n,e,r,i,t,o,s)}),a}function wr(t,e,r){if("function"!=typeof t)throw new Fs(K);return na(function(){t.apply(k,r)},e)}function Er(t,e){var r=t?t.length:0,n=[];if(!r)return n;var i=-1,o=qn(),s=o==a,u=s&&e.length>=200?Na(e):null,c=e.length;u&&(o=Qe,s=!1,e=u);t:for(;++i<r;){var f=t[i];if(s&&f===f){for(var h=c;h--;)if(e[h]===f)continue t;n.push(f)}else o(e,f,0)<0&&n.push(f)}return n}function Ar(t,e){var r=!0;return Ra(t,function(t,n,i){return r=!!e(t,n,i)}),r}function xr(t,e,r,n){var i=t.length;for(r=null==r?0:+r||0,0>r&&(r=-r>i?0:i+r),n=n===k||n>i?i:+n||0,0>n&&(n+=i),i=r>n?0:n>>>0,r>>>=0;i>r;)t[r++]=e;return t}function Sr(t,e){var r=[];return Ra(t,function(t,n,i){e(t,n,i)&&r.push(t)}),r}function Tr(t,e,r,n){var i;return r(t,function(t,r,o){return e(t,r,o)?(i=n?r:t,!1):void 0}),i}function kr(t,e,r){for(var n=-1,i=t.length,o=-1,s=[];++n<i;){var a=t[n];if(m(a)&&Yn(a.length)&&(Au(a)||_o(a))){e&&(a=kr(a,e,r));var u=-1,c=a.length;for(s.length+=c;++u<c;)s[++o]=a[u]}else r||(s[++o]=a)}return s}function Or(t,e){return La(t,e,Mo)}function Ir(t,e){return La(t,e,Fu)}function jr(t,e){return Ba(t,e,Fu)}function Rr(t,e){for(var r=-1,n=e.length,i=-1,o=[];++r<n;){var s=e[r];Su(t[s])&&(o[++i]=s)}return o}function Cr(t,e,r){if(null!=t){r!==k&&r in ri(t)&&(e=[r]);for(var n=-1,i=e.length;null!=t&&++n<i;)var o=t=t[e[n]];return o}}function Lr(t,e,r,n,i,o){if(t===e)return 0!==t||1/t==1/e;var s=typeof t,a=typeof e;return"function"!=s&&"object"!=s&&"function"!=a&&"object"!=a||null==t||null==e?t!==t&&e!==e:Br(t,e,Lr,r,n,i,o)}function Br(t,e,r,n,i,o,s){var a=Au(t),u=Au(e),c=X,f=X;a||(c=Gs.call(t),c==Y?c=ee:c!=ee&&(a=jo(t))),u||(f=Gs.call(e),f==Y?f=ee:f!=ee&&(u=jo(e)));var h=c==ee,l=f==ee,p=c==f;if(p&&!a&&!h)return Ln(t,e,c);if(!i){var d=h&&Us.call(t,"__wrapped__"),_=l&&Us.call(e,"__wrapped__");if(d||_)return r(d?t.value():t,_?e.value():e,n,i,o,s)}if(!p)return!1;o||(o=[]),s||(s=[]);for(var y=o.length;y--;)if(o[y]==t)return s[y]==e;o.push(t),s.push(e);var v=(a?Cn:Bn)(t,e,r,n,i,o,s);return o.pop(),s.pop(),v}function Fr(t,e,r,n,i){for(var o=-1,s=e.length,a=!i;++o<s;)if(a&&n[o]?r[o]!==t[e[o]]:!(e[o]in t))return!1;for(o=-1;++o<s;){var u=e[o],c=t[u],f=r[o];if(a&&n[o])var h=c!==k||u in t;else h=i?i(c,f,u):k,h===k&&(h=Lr(f,c,i,!0));if(!h)return!1}return!0}function Nr(t,e){var r=-1,n=Ma(t),i=Yn(n)?Ts(n):[];return Ra(t,function(t,n,o){i[++r]=e(t,n,o)}),i}function qr(t){var e=Fu(t),r=e.length;if(!r)return ls(!0);if(1==r){var n=e[0],i=t[n];if(Xn(i))return function(t){return null==t?!1:t[n]===i&&(i!==k||n in ri(t))}}for(var o=Ts(r),s=Ts(r);r--;)i=t[e[r]],o[r]=i,s[r]=Xn(i);return function(t){return null!=t&&Fr(ri(t),e,o,s)}}function Dr(t,e){var r=Au(t),n=Kn(t)&&Xn(e),i=t+"";return t=ni(t),function(o){if(null==o)return!1;
var s=i;if(o=ri(o),!(!r&&n||s in o)){if(o=1==t.length?o:Cr(o,Vr(t,0,-1)),null==o)return!1;s=gi(t),o=ri(o)}return o[s]===e?e!==k||s in o:Lr(e,o[s],null,!0)}}function Mr(t,e,r,n,i){if(!Eo(t))return t;var o=Yn(e.length)&&(Au(e)||jo(e));if(!o){var s=Fu(e);Zs.apply(s,Pa(e))}return er(s||e,function(a,u){if(s&&(u=a,a=e[u]),m(a))n||(n=[]),i||(i=[]),Pr(t,e,u,Mr,r,n,i);else{var c=t[u],f=r?r(c,a,u,t,e):k,h=f===k;h&&(f=a),!o&&f===k||!h&&(f===f?f===c:c!==c)||(t[u]=f)}}),t}function Pr(t,e,r,n,i,o,s){for(var a=o.length,u=e[r];a--;)if(o[a]==u)return void(t[r]=s[a]);var c=t[r],f=i?i(c,u,r,t,e):k,h=f===k;h&&(f=u,Yn(u.length)&&(Au(u)||jo(u))?f=Au(c)?c:Ma(c)?tr(c):[]:Tu(u)||_o(u)?f=_o(c)?Lo(c):Tu(c)?c:{}:h=!1),o.push(u),s.push(f),h?t[r]=n(f,u,i,o,s):(f===f?f!==c:c===c)&&(t[r]=f)}function Ur(t){return function(e){return null==e?k:e[t]}}function zr(t){var e=t+"";return t=ni(t),function(r){return Cr(r,t,e)}}function Gr(t,e){for(var r=e.length;r--;){var n=parseFloat(e[r]);if(n!=i&&Gn(n)){var i=n;ia.call(t,n,1)}}return t}function Hr(t,e){return t+$s(ga()*(e-t+1))}function Kr(t,e,r,n,i){return i(t,function(t,i,o){r=n?(n=!1,t):e(r,t,i,o)}),r}function Vr(t,e,r){var n=-1,i=t.length;e=null==e?0:+e||0,0>e&&(e=-e>i?0:i+e),r=r===k||r>i?i:+r||0,0>r&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ts(i);++n<i;)o[n]=t[n+e];return o}function Yr(t,e){var r;return Ra(t,function(t,n,i){return r=e(t,n,i),!r}),!!r}function Xr(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}function Wr(t,e,r){var n=Nn(),i=-1;e=ar(e,function(t){return n(t)});var o=Nr(t,function(t){var r=ar(e,function(e){return e(t)});return{criteria:r,index:++i,value:t}});return Xr(o,function(t,e){return d(t,e,r)})}function $r(t,e){var r=0;return Ra(t,function(t,n,i){r+=+e(t,n,i)||0}),r}function Jr(t,e){var r=-1,n=qn(),i=t.length,o=n==a,s=o&&i>=200,u=s?Na():null,c=[];u?(n=Qe,o=!1):(s=!1,u=e?[]:c);t:for(;++r<i;){var f=t[r],h=e?e(f,r,t):f;if(o&&f===f){for(var l=u.length;l--;)if(u[l]===h)continue t;e&&u.push(h),c.push(f)}else n(u,h,0)<0&&((e||s)&&u.push(h),c.push(f))}return c}function Qr(t,e){for(var r=-1,n=e.length,i=Ts(n);++r<n;)i[r]=t[e[r]];return i}function Zr(t,e,r,n){for(var i=t.length,o=n?i:-1;(n?o--:++o<i)&&e(t[o],o,t););return r?Vr(t,n?0:o,n?o+1:i):Vr(t,n?o+1:0,n?i:o)}function tn(t,e){var r=t;r instanceof i&&(r=r.value());for(var n=-1,o=e.length;++n<o;){var s=[r],a=e[n];Zs.apply(s,a.args),r=a.func.apply(a.thisArg,s)}return r}function en(t,e,r){var n=0,i=t?t.length:n;if("number"==typeof e&&e===e&&Aa>=i){for(;i>n;){var o=n+i>>>1,s=t[o];(r?e>=s:e>s)?n=o+1:i=o}return i}return rn(t,e,ps,r)}function rn(t,e,r,n){e=r(e);for(var i=0,o=t?t.length:0,s=e!==e,a=e===k;o>i;){var u=$s((i+o)/2),c=r(t[u]),f=c===c;if(s)var h=f||n;else h=a?f&&(n||c!==k):n?e>=c:e>c;h?i=u+1:o=u}return da(o,Ea)}function nn(t,e,r){if("function"!=typeof t)return ps;if(e===k)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 3:return function(r,n,i){return t.call(e,r,n,i)};case 4:return function(r,n,i,o){return t.call(e,r,n,i,o)};case 5:return function(r,n,i,o,s){return t.call(e,r,n,i,o,s)}}return function(){return t.apply(e,arguments)}}function on(t){return Ys.call(t,0)}function sn(t,e,r){for(var n=r.length,i=-1,o=pa(t.length-n,0),s=-1,a=e.length,u=Ts(o+a);++s<a;)u[s]=e[s];for(;++i<n;)u[r[i]]=t[i];for(;o--;)u[s++]=t[i++];return u}function an(t,e,r){for(var n=-1,i=r.length,o=-1,s=pa(t.length-i,0),a=-1,u=e.length,c=Ts(s+u);++o<s;)c[o]=t[o];for(var f=o;++a<u;)c[f+a]=e[a];for(;++n<i;)c[f+r[n]]=t[o++];return c}function un(t,e){return function(r,n,i){var o=e?e():{};if(n=Nn(n,i,3),Au(r))for(var s=-1,a=r.length;++s<a;){var u=r[s];t(o,u,n(u,s,r),r)}else Ra(r,function(e,r,i){t(o,e,n(e,r,i),i)});return o}}function cn(t){return uo(function(e,r){var n=-1,i=null==e?0:r.length,o=i>2&&r[i-2],s=i>2&&r[2],a=i>1&&r[i-1];for("function"==typeof o?(o=nn(o,a,5),i-=2):(o="function"==typeof a?a:null,i-=o?1:0),s&&Hn(r[0],r[1],s)&&(o=3>i?null:o,i=1);++n<i;){var u=r[n];u&&t(e,u,o)}return e})}function fn(t,e){return function(r,n){var i=r?Ma(r):0;if(!Yn(i))return t(r,n);for(var o=e?i:-1,s=ri(r);(e?o--:++o<i)&&n(s[o],o,s)!==!1;);return r}}function hn(t){return function(e,r,n){for(var i=ri(e),o=n(e),s=o.length,a=t?s:-1;t?a--:++a<s;){var u=o[a];if(r(i[u],u,i)===!1)break}return e}}function ln(t,e){function r(){var i=this&&this!==nr&&this instanceof r?n:t;return i.apply(e,arguments)}var n=dn(t);return r}function pn(t){return function(e){for(var r=-1,n=fs($o(e)),i=n.length,o="";++r<i;)o=t(o,n[r],r);return o}}function dn(t){return function(){var e=ja(t.prototype),r=t.apply(e,arguments);return Eo(r)?r:e}}function _n(t){function e(r,n,i){i&&Hn(r,n,i)&&(n=null);var o=Rn(r,t,null,null,null,null,null,n);return o.placeholder=e.placeholder,o}return e}function yn(t,e){return function(r,n,i){i&&Hn(r,n,i)&&(n=null);var o=Nn(),s=null==n;if(o===mr&&s||(s=!1,n=o(n,i,3)),s){var a=Au(r);if(a||!Io(r))return t(a?r:ei(r));n=f}return Fn(r,n,e)}}function vn(t,e){return function(r,n,i){if(n=Nn(n,i,3),Au(r)){var o=s(r,n,e);return o>-1?r[o]:k}return Tr(r,n,t)}}function gn(t){return function(e,r,n){return e&&e.length?(r=Nn(r,n,3),s(e,r,t)):-1}}function mn(t){return function(e,r,n){return r=Nn(r,n,3),Tr(e,r,t,!0)}}function bn(t){return function(){var e=arguments.length;if(!e)return function(){return arguments[0]};for(var r,i=t?e:-1,o=0,s=Ts(e);t?i--:++i<e;){var a=s[o++]=arguments[i];if("function"!=typeof a)throw new Fs(K);var u=r?"":Da(a);r="wrapper"==u?new n([]):r}for(i=r?-1:e;++i<e;){a=s[i],u=Da(a);var c="wrapper"==u?qa(a):null;r=c&&Vn(c[0])?r[Da(c[0])].apply(r,c[3]):1==a.length&&Vn(a)?r[u]():r.thru(a)}return function(){var t=arguments;if(r&&1==t.length&&Au(t[0]))return r.plant(t[0]).value();for(var n=0,i=s[n].apply(this,t);++n<e;)i=s[n].call(this,i);return i}}}function wn(t,e){return function(r,n,i){return"function"==typeof n&&i===k&&Au(r)?t(r,n):e(r,nn(n,i,3))}}function En(t){return function(e,r,n){return("function"!=typeof r||n!==k)&&(r=nn(r,n,3)),t(e,r,Mo)}}function An(t){return function(e,r,n){return("function"!=typeof r||n!==k)&&(r=nn(r,n,3)),t(e,r)}}function xn(t){return function(e,r,n){return e=c(e),e&&(t?e:"")+On(e,r,n)+(t?"":e)}}function Sn(t){var e=uo(function(r,n){var i=w(n,e.placeholder);return Rn(r,t,null,n,i)});return e}function Tn(t,e){return function(r,n,i,o){var s=arguments.length<3;return"function"==typeof n&&o===k&&Au(r)?t(r,n,i,s):Kr(r,Nn(n,o,4),i,s,e)}}function kn(t,e,r,n,i,o,s,a,u,c){function f(){for(var m=arguments.length,b=m,E=Ts(m);b--;)E[b]=arguments[b];if(n&&(E=sn(E,n,i)),o&&(E=an(E,o,s)),d||y){var A=f.placeholder,x=w(E,A);if(m-=x.length,c>m){var S=a?tr(a):null,T=pa(c-m,0),O=d?x:null,R=d?null:x,C=d?E:null,L=d?null:E;e|=d?B:F,e&=~(d?F:B),_||(e&=~(I|j));var N=[t,e,r,C,O,L,R,S,u,T],q=kn.apply(k,N);return Vn(t)&&Ua(q,N),q.placeholder=A,q}}var D=l?r:this;p&&(t=D[g]),a&&(E=Qn(E,a)),h&&u<E.length&&(E.length=u);var M=this&&this!==nr&&this instanceof f?v||dn(t):t;return M.apply(D,E)}var h=e&N,l=e&I,p=e&j,d=e&C,_=e&R,y=e&L,v=!p&&dn(t),g=t;return f}function On(t,e,r){var n=t.length;if(e=+e,n>=e||!ha(e))return"";var i=e-n;return r=null==r?" ":r+"",rs(r,Xs(i/r.length)).slice(0,i)}function In(t,e,r,n){function i(){for(var e=-1,a=arguments.length,u=-1,c=n.length,f=Ts(a+c);++u<c;)f[u]=n[u];for(;a--;)f[u++]=arguments[++e];var h=this&&this!==nr&&this instanceof i?s:t;return h.apply(o?r:this,f)}var o=e&I,s=dn(t);return i}function jn(t){return function(e,r,n,i){var o=Nn(n);return o===mr&&null==n?en(e,r,t):rn(e,r,o(n,i,1),t)}}function Rn(t,e,r,n,i,o,s,a){var u=e&j;if(!u&&"function"!=typeof t)throw new Fs(K);var c=n?n.length:0;if(c||(e&=~(B|F),n=i=null),c-=i?i.length:0,e&F){var f=n,h=i;n=i=null}var l=u?null:qa(t),p=[t,e,r,n,i,f,h,o,s,a];if(l&&(Wn(p,l),e=p[1],a=p[9]),p[9]=null==a?u?0:t.length:pa(a-c,0)||0,e==I)var d=ln(p[0],p[2]);else d=e!=B&&e!=(I|B)||p[4].length?kn.apply(k,p):In.apply(k,p);var _=l?Fa:Ua;return _(d,p)}function Cn(t,e,r,n,i,o,s){var a=-1,u=t.length,c=e.length,f=!0;if(u!=c&&!(i&&c>u))return!1;for(;f&&++a<u;){var h=t[a],l=e[a];if(f=k,n&&(f=i?n(l,h,a):n(h,l,a)),f===k)if(i)for(var p=c;p--&&(l=e[p],!(f=h&&h===l||r(h,l,n,i,o,s))););else f=h&&h===l||r(h,l,n,i,o,s)}return!!f}function Ln(t,e,r){switch(r){case W:case $:return+t==+e;case J:return t.name==e.name&&t.message==e.message;case te:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case re:case ie:return t==e+""}return!1}function Bn(t,e,r,n,i,o,s){var a=Fu(t),u=a.length,c=Fu(e),f=c.length;if(u!=f&&!i)return!1;for(var h=i,l=-1;++l<u;){var p=a[l],d=i?p in e:Us.call(e,p);if(d){var _=t[p],y=e[p];d=k,n&&(d=i?n(y,_,p):n(_,y,p)),d===k&&(d=_&&_===y||r(_,y,n,i,o,s))}if(!d)return!1;h||(h="constructor"==p)}if(!h){var v=t.constructor,g=e.constructor;if(v!=g&&"constructor"in t&&"constructor"in e&&!("function"==typeof v&&v instanceof v&&"function"==typeof g&&g instanceof g))return!1}return!0}function Fn(t,e,r){var n=r?ba:ma,i=n,o=i;return Ra(t,function(t,s,a){var u=e(t,s,a);((r?i>u:u>i)||u===n&&u===o)&&(i=u,o=t)}),o}function Nn(t,r,n){var i=e.callback||hs;return i=i===hs?mr:i,n?i(t,r,n):i}function qn(t,r,n){var i=e.indexOf||_i;return i=i===_i?a:i,t?i(t,r,n):i}function Dn(t,e,r){for(var n=-1,i=r?r.length:0;++n<i;){var o=r[n],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=da(e,t+s);break;case"takeRight":t=pa(t,e-s)}}return{start:t,end:e}}function Mn(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Us.call(t,"index")&&(r.index=t.index,r.input=t.input),r}function Pn(t){var e=t.constructor;return"function"==typeof e&&e instanceof e||(e=Cs),new e}function Un(t,e,r){var n=t.constructor;switch(e){case se:return on(t);case W:case $:return new n(+t);case ae:case ue:case ce:case fe:case he:case le:case pe:case de:case _e:var i=t.buffer;return new n(r?on(i):i,t.byteOffset,t.length);case te:case ie:return new n(t);case re:var o=new n(t.source,Be.exec(t));o.lastIndex=t.lastIndex}return o}function zn(t,e,r){null==t||Kn(e,t)||(e=ni(e),t=1==e.length?t:Cr(t,Vr(e,0,-1)),e=gi(e));var n=null==t?t:t[e];return null==n?k:n.apply(t,r)}function Gn(t,e){return t=+t,e=null==e?Sa:e,t>-1&&t%1==0&&e>t}function Hn(t,e,r){if(!Eo(r))return!1;var n=typeof e;if("number"==n)var i=Ma(r),o=Yn(i)&&Gn(e,i);else o="string"==n&&e in r;if(o){var s=r[e];return t===t?t===s:s!==s}return!1}function Kn(t,e){var r=typeof t;if("string"==r&&ke.test(t)||"number"==r)return!0;if(Au(t))return!1;var n=!Te.test(t);return n||null!=e&&t in ri(e)}function Vn(t){var r=Da(t);return!!r&&t===e[r]&&r in i.prototype}function Yn(t){return"number"==typeof t&&t>-1&&t%1==0&&Sa>=t}function Xn(t){return t===t&&(0===t?1/t>0:!Eo(t))}function Wn(t,e){var r=t[1],n=e[1],i=r|n,o=N>i,s=n==N&&r==C||n==N&&r==q&&t[7].length<=e[8]||n==(N|q)&&r==C;if(!o&&!s)return t;n&I&&(t[2]=e[2],i|=r&I?0:R);var a=e[3];if(a){var u=t[3];t[3]=u?sn(u,a,e[4]):tr(a),t[4]=u?w(t[3],V):tr(e[4])}return a=e[5],a&&(u=t[5],t[5]=u?an(u,a,e[6]):tr(a),t[6]=u?w(t[5],V):tr(e[6])),a=e[7],a&&(t[7]=tr(a)),n&N&&(t[8]=null==t[8]?e[8]:da(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=i,t}function $n(t,e){t=ri(t);for(var r=-1,n=e.length,i={};++r<n;){var o=e[r];o in t&&(i[o]=t[o])}return i}function Jn(t,e){var r={};return Or(t,function(t,n,i){e(t,n,i)&&(r[n]=t)}),r}function Qn(t,e){for(var r=t.length,n=da(e.length,r),i=tr(t);n--;){var o=e[n];t[n]=Gn(o,r)?i[o]:k}return t}function Zn(t){{var r;e.support}if(!m(t)||Gs.call(t)!=ee||!Us.call(t,"constructor")&&(r=t.constructor,"function"==typeof r&&!(r instanceof r)))return!1;var n;return Or(t,function(t,e){n=e}),n===k||Us.call(t,n)}function ti(t){for(var r=Mo(t),n=r.length,i=n&&t.length,o=e.support,s=i&&Yn(i)&&(Au(t)||o.nonEnumArgs&&_o(t)),a=-1,u=[];++a<n;){var c=r[a];(s&&Gn(c,i)||Us.call(t,c))&&u.push(c)}return u}function ei(t){return null==t?[]:Yn(Ma(t))?Eo(t)?t:Cs(t):Ko(t)}function ri(t){return Eo(t)?t:Cs(t)}function ni(t){if(Au(t))return t;var e=[];return c(t).replace(Oe,function(t,r,n,i){e.push(n?i.replace(Ce,"$1"):r||t)}),e}function ii(t){return t instanceof i?t.clone():new n(t.__wrapped__,t.__chain__,tr(t.__actions__))}function oi(t,e,r){e=(r?Hn(t,e,r):null==e)?1:pa(+e||1,1);for(var n=0,i=t?t.length:0,o=-1,s=Ts(Xs(i/e));i>n;)s[++o]=Vr(t,n,n+=e);return s}function si(t){for(var e=-1,r=t?t.length:0,n=-1,i=[];++e<r;){var o=t[e];o&&(i[++n]=o)}return i}function ai(t,e,r){var n=t?t.length:0;return n?((r?Hn(t,e,r):null==e)&&(e=1),Vr(t,0>e?0:e)):[]}function ui(t,e,r){var n=t?t.length:0;return n?((r?Hn(t,e,r):null==e)&&(e=1),e=n-(+e||0),Vr(t,0,0>e?0:e)):[]}function ci(t,e,r){return t&&t.length?Zr(t,Nn(e,r,3),!0,!0):[]}function fi(t,e,r){return t&&t.length?Zr(t,Nn(e,r,3),!0):[]}function hi(t,e,r,n){var i=t?t.length:0;return i?(r&&"number"!=typeof r&&Hn(t,e,r)&&(r=0,n=i),xr(t,e,r,n)):[]}function li(t){return t?t[0]:k}function pi(t,e,r){var n=t?t.length:0;return r&&Hn(t,e,r)&&(e=!1),n?kr(t,e):[]}function di(t){var e=t?t.length:0;return e?kr(t,!0):[]}function _i(t,e,r){var n=t?t.length:0;if(!n)return-1;if("number"==typeof r)r=0>r?pa(n+r,0):r;else if(r){var i=en(t,e),o=t[i];return(e===e?e===o:o!==o)?i:-1}return a(t,e,r||0)}function yi(t){return ui(t,1)}function vi(){for(var t=[],e=-1,r=arguments.length,n=[],i=qn(),o=i==a,s=[];++e<r;){var u=arguments[e];(Au(u)||_o(u))&&(t.push(u),n.push(o&&u.length>=120?Na(e&&u):null))}if(r=t.length,2>r)return s;var c=t[0],f=-1,h=c?c.length:0,l=n[0];t:for(;++f<h;)if(u=c[f],(l?Qe(l,u):i(s,u,0))<0){for(e=r;--e;){var p=n[e];if((p?Qe(p,u):i(t[e],u,0))<0)continue t}l&&l.push(u),s.push(u)}return s}function gi(t){var e=t?t.length:0;return e?t[e-1]:k}function mi(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(0>r?pa(n+r,0):da(r||0,n-1))+1;else if(r){i=en(t,e,!0)-1;var o=t[i];return(e===e?e===o:o!==o)?i:-1}if(e!==e)return g(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1}function bi(){var t=arguments,e=t[0];if(!e||!e.length)return e;for(var r=0,n=qn(),i=t.length;++r<i;)for(var o=0,s=t[r];(o=n(e,s,o))>-1;)ia.call(e,o,1);return e}function wi(t,e,r){var n=[];if(!t||!t.length)return n;var i=-1,o=[],s=t.length;for(e=Nn(e,r,3);++i<s;){var a=t[i];e(a,i,t)&&(n.push(a),o.push(i))}return Gr(t,o),n}function Ei(t){return ai(t,1)}function Ai(t,e,r){var n=t?t.length:0;return n?(r&&"number"!=typeof r&&Hn(t,e,r)&&(e=0,r=n),Vr(t,e,r)):[]}function xi(t,e,r){var n=t?t.length:0;return n?((r?Hn(t,e,r):null==e)&&(e=1),Vr(t,0,0>e?0:e)):[]}function Si(t,e,r){var n=t?t.length:0;return n?((r?Hn(t,e,r):null==e)&&(e=1),e=n-(+e||0),Vr(t,0>e?0:e)):[]}function Ti(t,e,r){return t&&t.length?Zr(t,Nn(e,r,3),!1,!0):[]}function ki(t,e,r){return t&&t.length?Zr(t,Nn(e,r,3)):[]}function Oi(t,e,r,n){var i=t?t.length:0;if(!i)return[];null!=e&&"boolean"!=typeof e&&(n=r,r=Hn(t,e,n)?null:e,e=!1);var o=Nn();return(o!==mr||null!=r)&&(r=o(r,n,3)),e&&qn()==a?E(t,r):Jr(t,r)}function Ii(t){for(var e=-1,r=(t&&t.length&&ur(ar(t,Ma)))>>>0,n=Ts(r);++e<r;)n[e]=ar(t,Ur(e));return n}function ji(){for(var t=-1,e=arguments.length;++t<e;){var r=arguments[t];if(Au(r)||_o(r))var n=n?Er(n,r).concat(Er(r,n)):r}return n?Jr(n):[]}function Ri(t,e){var r=-1,n=t?t.length:0,i={};for(!n||e||Au(t[0])||(e=[]);++r<n;){var o=t[r];e?i[o]=e[r]:o&&(i[o[0]]=o[1])}return i}function Ci(t){var r=e(t);return r.__chain__=!0,r}function Li(t,e,r){return e.call(r,t),t}function Bi(t,e,r){return e.call(r,t)}function Fi(){return Ci(this)}function Ni(){return new n(this.value(),this.__chain__)}function qi(t){for(var e,n=this;n instanceof r;){var i=ii(n);e?o.__wrapped__=i:e=i;var o=i;n=n.__wrapped__}return o.__wrapped__=t,e}function Di(){var t=this.__wrapped__;return t instanceof i?(this.__actions__.length&&(t=new i(this)),new n(t.reverse(),this.__chain__)):this.thru(function(t){return t.reverse()})}function Mi(){return this.value()+""}function Pi(){return tn(this.__wrapped__,this.__actions__)}function Ui(t,e,r){var n=Au(t)?or:Ar;return r&&Hn(t,e,r)&&(e=null),("function"!=typeof e||r!==k)&&(e=Nn(e,r,3)),n(t,e)}function zi(t,e,r){var n=Au(t)?sr:Sr;return e=Nn(e,r,3),n(t,e)}function Gi(t,e){return Za(t,qr(e))}function Hi(t,e,r,n){var i=t?Ma(t):0;return Yn(i)||(t=Ko(t),i=t.length),i?(r="number"!=typeof r||n&&Hn(e,r,n)?0:0>r?pa(i+r,0):r||0,"string"==typeof t||!Au(t)&&Io(t)?i>r&&t.indexOf(e,r)>-1:qn(t,e,r)>-1):!1}function Ki(t,e,r){var n=Au(t)?ar:Nr;return e=Nn(e,r,3),n(t,e)}function Vi(t,e){return Ki(t,ms(e))}function Yi(t,e,r){var n=Au(t)?sr:Sr;return e=Nn(e,r,3),n(t,function(t,r,n){return!e(t,r,n)})}function Xi(t,e,r){if(r?Hn(t,e,r):null==e){t=ei(t);var n=t.length;return n>0?t[Hr(0,n-1)]:k}var i=Wi(t);return i.length=da(0>e?0:+e||0,i.length),i}function Wi(t){t=ei(t);for(var e=-1,r=t.length,n=Ts(r);++e<r;){var i=Hr(0,e);e!=i&&(n[e]=n[i]),n[i]=t[e]}return n}function $i(t){var e=t?Ma(t):0;return Yn(e)?e:Fu(t).length}function Ji(t,e,r){var n=Au(t)?lr:Yr;return r&&Hn(t,e,r)&&(e=null),("function"!=typeof e||r!==k)&&(e=Nn(e,r,3)),n(t,e)}function Qi(t,e,r){if(null==t)return[];r&&Hn(t,e,r)&&(e=null);var n=-1;e=Nn(e,r,3);var i=Nr(t,function(t,r,i){return{criteria:e(t,r,i),index:++n,value:t}});return Xr(i,p)}function Zi(t,e,r,n){return null==t?[]:(n&&Hn(e,r,n)&&(r=null),Au(e)||(e=null==e?[]:[e]),Au(r)||(r=null==r?[]:[r]),Wr(t,e,r))}function to(t,e){return zi(t,qr(e))}function eo(t,e){if("function"!=typeof e){if("function"!=typeof t)throw new Fs(K);var r=t;t=e,e=r}return t=ha(t=+t)?t:0,function(){return--t<1?e.apply(this,arguments):void 0}}function ro(t,e,r){return r&&Hn(t,e,r)&&(e=null),e=t&&null==e?t.length:pa(+e||0,0),Rn(t,N,null,null,null,null,e)}function no(t,e){var r;if("function"!=typeof e){if("function"!=typeof t)throw new Fs(K);var n=t;t=e,e=n}return function(){return--t>0&&(r=e.apply(this,arguments)),1>=t&&(e=null),r}}function io(t,e,r){function n(){l&&Ws(l),u&&Ws(u),u=l=p=k}function i(){var r=e-(fu()-f);if(0>=r||r>e){u&&Ws(u);var n=p;u=l=p=k,n&&(d=fu(),c=t.apply(h,a),l||u||(a=h=null))}else l=na(i,r)}function o(){l&&Ws(l),u=l=p=k,(y||_!==e)&&(d=fu(),c=t.apply(h,a),l||u||(a=h=null))}function s(){if(a=arguments,f=fu(),h=this,p=y&&(l||!v),_===!1)var r=v&&!l;else{u||v||(d=f);var n=_-(f-d),s=0>=n||n>_;s?(u&&(u=Ws(u)),d=f,c=t.apply(h,a)):u||(u=na(o,n))}return s&&l?l=Ws(l):l||e===_||(l=na(i,e)),r&&(s=!0,c=t.apply(h,a)),!s||l||u||(a=h=null),c}var a,u,c,f,h,l,p,d=0,_=!1,y=!0;if("function"!=typeof t)throw new Fs(K);if(e=0>e?0:+e||0,r===!0){var v=!0;y=!1}else Eo(r)&&(v=r.leading,_="maxWait"in r&&pa(+r.maxWait||0,e),y="trailing"in r?r.trailing:y);return s.cancel=n,s}function oo(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new Fs(K);var r=function(){var n=arguments,i=r.cache,o=e?e.apply(this,n):n[0];if(i.has(o))return i.get(o);var s=t.apply(this,n);return i.set(o,s),s};return r.cache=new oo.Cache,r}function so(t){if("function"!=typeof t)throw new Fs(K);return function(){return!t.apply(this,arguments)}}function ao(t){return no(2,t)}function uo(t,e){if("function"!=typeof t)throw new Fs(K);return e=pa(e===k?t.length-1:+e||0,0),function(){for(var r=arguments,n=-1,i=pa(r.length-e,0),o=Ts(i);++n<i;)o[n]=r[e+n];switch(e){case 0:return t.call(this,o);case 1:return t.call(this,r[0],o);case 2:return t.call(this,r[0],r[1],o)}var s=Ts(e+1);for(n=-1;++n<e;)s[n]=r[n];return s[e]=o,t.apply(this,s)}}function co(t){if("function"!=typeof t)throw new Fs(K);return function(e){return t.apply(this,e)}}function fo(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new Fs(K);return r===!1?n=!1:Eo(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Ve.leading=n,Ve.maxWait=+e,Ve.trailing=i,io(t,e,Ve)}function ho(t,e){return e=null==e?ps:e,Rn(e,B,null,[t],[])}function lo(t,e,r,n){return e&&"boolean"!=typeof e&&Hn(t,e,r)?e=!1:"function"==typeof e&&(n=r,r=e,e=!1),r="function"==typeof r&&nn(r,n,1),br(t,e,r)}function po(t,e,r){return e="function"==typeof e&&nn(e,r,1),br(t,!0,e)}function _o(t){var e=m(t)?t.length:k;return Yn(e)&&Gs.call(t)==Y}function yo(t){return t===!0||t===!1||m(t)&&Gs.call(t)==W}function vo(t){return m(t)&&Gs.call(t)==$}function go(t){return!!t&&1===t.nodeType&&m(t)&&Gs.call(t).indexOf("Element")>-1}function mo(t){if(null==t)return!0;var e=Ma(t);return Yn(e)&&(Au(t)||Io(t)||_o(t)||m(t)&&Su(t.splice))?!e:!Fu(t).length}function bo(t,e,r,n){if(r="function"==typeof r&&nn(r,n,3),!r&&Xn(t)&&Xn(e))return t===e;var i=r?r(t,e):k;return i===k?Lr(t,e,r):!!i}function wo(t){return m(t)&&"string"==typeof t.message&&Gs.call(t)==J}function Eo(t){var e=typeof t;return"function"==e||!!t&&"object"==e}function Ao(t,e,r,n){var i=Fu(e),o=i.length;if(!o)return!0;if(null==t)return!1;if(r="function"==typeof r&&nn(r,n,3),t=ri(t),!r&&1==o){var s=i[0],a=e[s];if(Xn(a))return a===t[s]&&(a!==k||s in t)}for(var u=Ts(o),c=Ts(o);o--;)a=u[o]=e[i[o]],c[o]=Xn(a);return Fr(t,i,u,c,r)}function xo(t){return ko(t)&&t!=+t}function So(t){return null==t?!1:Gs.call(t)==Q?Ks.test(Ps.call(t)):m(t)&&Ne.test(t)}function To(t){return null===t}function ko(t){return"number"==typeof t||m(t)&&Gs.call(t)==te}function Oo(t){return m(t)&&Gs.call(t)==re||!1}function Io(t){return"string"==typeof t||m(t)&&Gs.call(t)==ie}function jo(t){return m(t)&&Yn(t.length)&&!!He[Gs.call(t)]}function Ro(t){return t===k}function Co(t){var e=t?Ma(t):0;return Yn(e)?e?tr(t):[]:Ko(t)}function Lo(t){return gr(t,Mo(t))}function Bo(t,e,r){var n=ja(t);return r&&Hn(t,e,r)&&(e=null),e?Ia(n,e):n}function Fo(t){return Rr(t,Mo(t))}function No(t,e,r){var n=null==t?k:Cr(t,ni(e),e+"");return n===k?r:n}function qo(t,e){if(null==t)return!1;var r=Us.call(t,e);return r||Kn(e)||(e=ni(e),t=1==e.length?t:Cr(t,Vr(e,0,-1)),e=gi(e),r=null!=t&&Us.call(t,e)),r}function Do(t,e,r){r&&Hn(t,e,r)&&(e=null);for(var n=-1,i=Fu(t),o=i.length,s={};++n<o;){var a=i[n],u=t[a];e?Us.call(s,u)?s[u].push(a):s[u]=[a]:s[u]=a}return s}function Mo(t){if(null==t)return[];Eo(t)||(t=Cs(t));var e=t.length;e=e&&Yn(e)&&(Au(t)||Oa.nonEnumArgs&&_o(t))&&e||0;for(var r=t.constructor,n=-1,i="function"==typeof r&&r.prototype===t,o=Ts(e),s=e>0;++n<e;)o[n]=n+"";for(var a in t)s&&Gn(a,e)||"constructor"==a&&(i||!Us.call(t,a))||o.push(a);return o}function Po(t,e,r){var n={};return e=Nn(e,r,3),Ir(t,function(t,r,i){n[r]=e(t,r,i)}),n}function Uo(t){for(var e=-1,r=Fu(t),n=r.length,i=Ts(n);++e<n;){var o=r[e];i[e]=[o,t[o]]}return i}function zo(t,e,r){var n=null==t?k:t[e];return n===k&&(null==t||Kn(e,t)||(e=ni(e),t=1==e.length?t:Cr(t,Vr(e,0,-1)),n=null==t?k:t[gi(e)]),n=n===k?r:n),Su(n)?n.call(t):n}function Go(t,e,r){if(null==t)return t;var n=e+"";e=null!=t[n]||Kn(e,t)?[n]:ni(e);for(var i=-1,o=e.length,s=o-1,a=t;null!=a&&++i<o;){var u=e[i];Eo(a)&&(i==s?a[u]=r:null==a[u]&&(a[u]=Gn(e[i+1])?[]:{})),a=a[u]}return t}function Ho(t,e,r,n){var i=Au(t)||jo(t);if(e=Nn(e,n,4),null==r)if(i||Eo(t)){var o=t.constructor;r=i?Au(t)?new o:[]:ja(Su(o)&&o.prototype)}else r={};return(i?er:Ir)(t,function(t,n,i){return e(r,t,n,i)}),r}function Ko(t){return Qr(t,Fu(t))}function Vo(t){return Qr(t,Mo(t))}function Yo(t,e,r){return e=+e||0,"undefined"==typeof r?(r=e,e=0):r=+r||0,t>=da(e,r)&&t<pa(e,r)}function Xo(t,e,r){r&&Hn(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=ga();return da(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Hr(t,e)}function Wo(t){return t=c(t),t&&t.charAt(0).toUpperCase()+t.slice(1)}function $o(t){return t=c(t),t&&t.replace(qe,_).replace(Re,"")}function Jo(t,e,r){t=c(t),e+="";var n=t.length;return r=r===k?n:da(0>r?0:+r||0,n),r-=e.length,r>=0&&t.indexOf(e,r)==r}function Qo(t){return t=c(t),t&&Ee.test(t)?t.replace(be,y):t}function Zo(t){return t=c(t),t&&je.test(t)?t.replace(Ie,"\\$&"):t}function ts(t,e,r){t=c(t),e=+e;var n=t.length;if(n>=e||!ha(e))return t;var i=(e-n)/2,o=$s(i),s=Xs(i);return r=On("",s,r),r.slice(0,o)+t+r}function es(t,e,r){return r&&Hn(t,e,r)&&(e=0),va(t,e)}function rs(t,e){var r="";if(t=c(t),e=+e,1>e||!t||!ha(e))return r;do e%2&&(r+=t),e=$s(e/2),t+=t;while(e);return r}function ns(t,e,r){return t=c(t),r=null==r?0:da(0>r?0:+r||0,t.length),t.lastIndexOf(e,r)==r}function is(t,r,n){var i=e.templateSettings;n&&Hn(t,r,n)&&(r=n=null),t=c(t),r=yr(Ia({},n||r),i,_r);var o,s,a=yr(Ia({},r.imports),i.imports,_r),u=Fu(a),f=Qr(a,u),h=0,l=r.interpolate||De,p="__p += '",d=Ls((r.escape||De).source+"|"+l.source+"|"+(l===Se?Le:De).source+"|"+(r.evaluate||De).source+"|$","g"),_="//# sourceURL="+("sourceURL"in r?r.sourceURL:"lodash.templateSources["+ ++Ge+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),p+=t.slice(h,u).replace(Me,v),r&&(o=!0,p+="' +\n__e("+r+") +\n'"),a&&(s=!0,p+="';\n"+a+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=u+e.length,e}),p+="';\n";var y=r.variable;y||(p="with (obj) {\n"+p+"\n}\n"),p=(s?p.replace(ye,""):p).replace(ve,"$1").replace(ge,"$1;"),p="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var g=Ku(function(){return Is(u,_+"return "+p).apply(k,f)});if(g.source=p,wo(g))throw g;return g}function os(t,e,r){var n=t;return(t=c(t))?(r?Hn(n,e,r):null==e)?t.slice(A(t),x(t)+1):(e+="",t.slice(h(t,e),l(t,e)+1)):t}function ss(t,e,r){var n=t;return t=c(t),t?t.slice((r?Hn(n,e,r):null==e)?A(t):h(t,e+"")):t}function as(t,e,r){var n=t;return t=c(t),t?(r?Hn(n,e,r):null==e)?t.slice(0,x(t)+1):t.slice(0,l(t,e+"")+1):t}function us(t,e,r){r&&Hn(t,e,r)&&(e=null);var n=D,i=M;if(null!=e)if(Eo(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?c(e.omission):i}else n=+e||0;if(t=c(t),n>=t.length)return t;var s=n-i.length;if(1>s)return i;var a=t.slice(0,s);if(null==o)return a+i;if(Oo(o)){if(t.slice(s).search(o)){var u,f,h=t.slice(0,s);for(o.global||(o=Ls(o.source,(Be.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(h);)f=u.index;a=a.slice(0,null==f?s:f)}}else if(t.indexOf(o,s)!=s){var l=a.lastIndexOf(o);l>-1&&(a=a.slice(0,l))}return a+i}function cs(t){return t=c(t),t&&we.test(t)?t.replace(me,S):t}function fs(t,e,r){return r&&Hn(t,e,r)&&(e=null),t=c(t),t.match(e||Pe)||[]}function hs(t,e,r){return r&&Hn(t,e,r)&&(e=null),mr(t,e)}function ls(t){return function(){return t}}function ps(t){return t}function ds(t){return qr(br(t,!0))}function _s(t,e){return Dr(t,br(e,!0))}function ys(t,e,r){if(null==r){var n=Eo(e),i=n&&Fu(e),o=i&&i.length&&Rr(e,i);(o?o.length:n)||(o=!1,r=e,e=t,t=this)}o||(o=Rr(e,Fu(e)));var s=!0,a=-1,u=Su(t),c=o.length;r===!1?s=!1:Eo(r)&&"chain"in r&&(s=r.chain);for(;++a<c;){var f=o[a],h=e[f];t[f]=h,u&&(t.prototype[f]=function(e){return function(){var r=this.__chain__;if(s||r){var n=t(this.__wrapped__),i=n.__actions__=tr(this.__actions__);return i.push({func:e,args:arguments,thisArg:t}),n.__chain__=r,n}var o=[this.value()];return Zs.apply(o,arguments),e.apply(t,o)}}(h))}return t}function vs(){return t._=Hs,this}function gs(){}function ms(t){return Kn(t)?Ur(t):zr(t)}function bs(t){return function(e){return Cr(t,ni(e),e+"")}}function ws(t,e,r){r&&Hn(t,e,r)&&(e=r=null),t=+t||0,r=null==r?1:+r||0,null==e?(e=t,t=0):e=+e||0;for(var n=-1,i=pa(Xs((e-t)/(r||1)),0),o=Ts(i);++n<i;)o[n]=t,t+=r;return o}function Es(t,e,r){if(t=$s(t),1>t||!ha(t))return[];var n=-1,i=Ts(da(t,wa));for(e=nn(e,r,1);++n<t;)wa>n?i[n]=e(n):e(n);return i}function As(t){var e=++zs;return c(t)+e}function xs(t,e){return(+t||0)+(+e||0)}function Ss(t,e,r){r&&Hn(t,e,r)&&(e=null);var n=Nn(),i=null==e;return n===mr&&i||(i=!1,e=n(e,r,3)),i?pr(Au(t)?t:ei(t)):$r(t,e)}t=t?ir.defaults(nr.Object(),t,ir.pick(nr,ze)):nr;var Ts=t.Array,ks=t.Date,Os=t.Error,Is=t.Function,js=t.Math,Rs=t.Number,Cs=t.Object,Ls=t.RegExp,Bs=t.String,Fs=t.TypeError,Ns=Ts.prototype,qs=Cs.prototype,Ds=Bs.prototype,Ms=(Ms=t.window)&&Ms.document,Ps=Is.prototype.toString,Us=qs.hasOwnProperty,zs=0,Gs=qs.toString,Hs=t._,Ks=Ls("^"+Zo(Gs).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Vs=So(Vs=t.ArrayBuffer)&&Vs,Ys=So(Ys=Vs&&new Vs(0).slice)&&Ys,Xs=js.ceil,Ws=t.clearTimeout,$s=js.floor,Js=So(Js=Cs.getOwnPropertySymbols)&&Js,Qs=So(Qs=Cs.getPrototypeOf)&&Qs,Zs=Ns.push,ta=So(Cs.preventExtensions=Cs.preventExtensions)&&ta,ea=qs.propertyIsEnumerable,ra=So(ra=t.Set)&&ra,na=t.setTimeout,ia=Ns.splice,oa=So(oa=t.Uint8Array)&&oa,sa=So(sa=t.WeakMap)&&sa,aa=function(){try{var e=So(e=t.Float64Array)&&e,r=new e(new Vs(10),0,1)&&e}catch(n){}return r}(),ua=function(){var t={1:0},e=ta&&So(e=Cs.assign)&&e;try{e(ta(t),"xo")}catch(r){}return!t[1]&&e}(),ca=So(ca=Ts.isArray)&&ca,fa=So(fa=Cs.create)&&fa,ha=t.isFinite,la=So(la=Cs.keys)&&la,pa=js.max,da=js.min,_a=So(_a=ks.now)&&_a,ya=So(ya=Rs.isFinite)&&ya,va=t.parseInt,ga=js.random,ma=Rs.NEGATIVE_INFINITY,ba=Rs.POSITIVE_INFINITY,wa=js.pow(2,32)-1,Ea=wa-1,Aa=wa>>>1,xa=aa?aa.BYTES_PER_ELEMENT:0,Sa=js.pow(2,53)-1,Ta=sa&&new sa,ka={},Oa=e.support={};!function(t){var e=function(){this.x=t},r=[];e.prototype={valueOf:t,y:t};for(var n in new e)r.push(n);Oa.funcDecomp=/\bthis\b/.test(function(){return this}),Oa.funcNames="string"==typeof Is.name;try{Oa.dom=11===Ms.createDocumentFragment().nodeType}catch(i){Oa.dom=!1}try{Oa.nonEnumArgs=!ea.call(arguments,1)}catch(i){Oa.nonEnumArgs=!0}}(1,0),e.templateSettings={escape:Ae,evaluate:xe,interpolate:Se,variable:"",imports:{_:e}};var Ia=ua||function(t,e){return null==e?t:gr(e,Pa(e),gr(e,Fu(e),t))},ja=function(){function e(){}return function(r){if(Eo(r)){e.prototype=r;var n=new e;e.prototype=null}return n||t.Object()}}(),Ra=fn(Ir),Ca=fn(jr,!0),La=hn(),Ba=hn(!0),Fa=Ta?function(t,e){return Ta.set(t,e),t}:ps;Ys||(on=Vs&&oa?function(t){var e=t.byteLength,r=aa?$s(e/xa):0,n=r*xa,i=new Vs(e);if(r){var o=new aa(i,0,r);o.set(new aa(t,0,r))}return e!=n&&(o=new oa(i,n),o.set(new oa(t,n))),i}:ls(null));var Na=fa&&ra?function(t){return new Je(t)}:ls(null),qa=Ta?function(t){return Ta.get(t)}:gs,Da=function(){return Oa.funcNames?"constant"==ls.name?Ur("name"):function(t){for(var e=t.name,r=ka[e],n=r?r.length:0;n--;){var i=r[n],o=i.func;if(null==o||o==t)return i.name}return e}:ls("")}(),Ma=Ur("length"),Pa=Js?function(t){return Js(ri(t))}:ls([]),Ua=function(){var t=0,e=0;return function(r,n){var i=fu(),o=U-(i-e);if(e=i,o>0){if(++t>=P)return r}else t=0;return Fa(r,n)}}(),za=uo(function(t,e){return Au(t)||_o(t)?Er(t,kr(e,!1,!0)):[]}),Ga=gn(),Ha=gn(!0),Ka=uo(function(t,e){t||(t=[]),e=kr(e);var r=vr(t,e);return Gr(t,e.sort(o)),r}),Va=jn(),Ya=jn(!0),Xa=uo(function(t){return Jr(kr(t,!1,!0))}),Wa=uo(function(t,e){return Au(t)||_o(t)?Er(t,e):[]}),$a=uo(Ii),Ja=uo(function(t,e){var r=t?Ma(t):0;return Yn(r)&&(t=ei(t)),vr(t,kr(e))}),Qa=un(function(t,e,r){Us.call(t,r)?++t[r]:t[r]=1}),Za=vn(Ra),tu=vn(Ca,!0),eu=wn(er,Ra),ru=wn(rr,Ca),nu=un(function(t,e,r){Us.call(t,r)?t[r].push(e):t[r]=[e]}),iu=un(function(t,e,r){t[r]=e}),ou=uo(function(t,e,r){var n=-1,i="function"==typeof e,o=Kn(e),s=Ma(t),a=Yn(s)?Ts(s):[];return Ra(t,function(t){var s=i?e:o&&null!=t&&t[e];a[++n]=s?s.apply(t,r):zn(t,e,r)}),a}),su=un(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),au=Tn(fr,Ra),uu=Tn(hr,Ca),cu=uo(function(t,e){if(null==t)return[];var r=e[2];return r&&Hn(e[0],e[1],r)&&(e.length=1),Wr(t,kr(e),[])}),fu=_a||function(){return(new ks).getTime()},hu=uo(function(t,e,r){var n=I;if(r.length){var i=w(r,hu.placeholder);n|=B}return Rn(t,n,e,r,i)}),lu=uo(function(t,e){e=e.length?kr(e):Fo(t);for(var r=-1,n=e.length;++r<n;){var i=e[r];t[i]=Rn(t[i],I,t)}return t}),pu=uo(function(t,e,r){var n=I|j;if(r.length){var i=w(r,pu.placeholder);n|=B}return Rn(e,n,t,r,i)}),du=_n(C),_u=_n(L),yu=uo(function(t,e){return wr(t,1,e)}),vu=uo(function(t,e,r){return wr(t,e,r)}),gu=bn(),mu=bn(!0),bu=Sn(B),wu=Sn(F),Eu=uo(function(t,e){return Rn(t,q,null,null,null,kr(e))}),Au=ca||function(t){return m(t)&&Yn(t.length)&&Gs.call(t)==X};Oa.dom||(go=function(t){return!!t&&1===t.nodeType&&m(t)&&!Tu(t)});var xu=ya||function(t){return"number"==typeof t&&ha(t)},Su=u(/x/)||oa&&!u(oa)?function(t){return Gs.call(t)==Q}:u,Tu=Qs?function(t){if(!t||Gs.call(t)!=ee)return!1;var e=t.valueOf,r=So(e)&&(r=Qs(e))&&Qs(r);return r?t==r||Qs(t)==r:Zn(t)}:Zn,ku=cn(function(t,e,r){return r?yr(t,e,r):Ia(t,e)}),Ou=uo(function(t){var e=t[0];return null==e?e:(t.push(dr),ku.apply(k,t))}),Iu=mn(Ir),ju=mn(jr),Ru=En(La),Cu=En(Ba),Lu=An(Ir),Bu=An(jr),Fu=la?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&Yn(r)?ti(t):Eo(t)?la(t):[]
}:ti,Nu=cn(Mr),qu=uo(function(t,e){if(null==t)return{};if("function"!=typeof e[0]){var e=ar(kr(e),Bs);return $n(t,Er(Mo(t),e))}var r=nn(e[0],e[1],3);return Jn(t,function(t,e,n){return!r(t,e,n)})}),Du=uo(function(t,e){return null==t?{}:"function"==typeof e[0]?Jn(t,nn(e[0],e[1],3)):$n(t,kr(e))}),Mu=pn(function(t,e,r){return e=e.toLowerCase(),t+(r?e.charAt(0).toUpperCase()+e.slice(1):e)}),Pu=pn(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),Uu=xn(),zu=xn(!0);8!=va(Ue+"08")&&(es=function(t,e,r){return(r?Hn(t,e,r):null==e)?e=0:e&&(e=+e),t=os(t),va(t,e||(Fe.test(t)?16:10))});var Gu=pn(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),Hu=pn(function(t,e,r){return t+(r?" ":"")+(e.charAt(0).toUpperCase()+e.slice(1))}),Ku=uo(function(t,e){try{return t.apply(k,e)}catch(r){return wo(r)?r:new Os(r)}}),Vu=uo(function(t,e){return function(r){return zn(r,t,e)}}),Yu=uo(function(t,e){return function(r){return zn(t,r,e)}}),Xu=yn(ur),Wu=yn(cr,!0);return e.prototype=r.prototype,n.prototype=ja(r.prototype),n.prototype.constructor=n,i.prototype=ja(r.prototype),i.prototype.constructor=i,oe.prototype["delete"]=Ye,oe.prototype.get=Xe,oe.prototype.has=We,oe.prototype.set=$e,Je.prototype.push=Ze,oo.Cache=oe,e.after=eo,e.ary=ro,e.assign=ku,e.at=Ja,e.before=no,e.bind=hu,e.bindAll=lu,e.bindKey=pu,e.callback=hs,e.chain=Ci,e.chunk=oi,e.compact=si,e.constant=ls,e.countBy=Qa,e.create=Bo,e.curry=du,e.curryRight=_u,e.debounce=io,e.defaults=Ou,e.defer=yu,e.delay=vu,e.difference=za,e.drop=ai,e.dropRight=ui,e.dropRightWhile=ci,e.dropWhile=fi,e.fill=hi,e.filter=zi,e.flatten=pi,e.flattenDeep=di,e.flow=gu,e.flowRight=mu,e.forEach=eu,e.forEachRight=ru,e.forIn=Ru,e.forInRight=Cu,e.forOwn=Lu,e.forOwnRight=Bu,e.functions=Fo,e.groupBy=nu,e.indexBy=iu,e.initial=yi,e.intersection=vi,e.invert=Do,e.invoke=ou,e.keys=Fu,e.keysIn=Mo,e.map=Ki,e.mapValues=Po,e.matches=ds,e.matchesProperty=_s,e.memoize=oo,e.merge=Nu,e.method=Vu,e.methodOf=Yu,e.mixin=ys,e.negate=so,e.omit=qu,e.once=ao,e.pairs=Uo,e.partial=bu,e.partialRight=wu,e.partition=su,e.pick=Du,e.pluck=Vi,e.property=ms,e.propertyOf=bs,e.pull=bi,e.pullAt=Ka,e.range=ws,e.rearg=Eu,e.reject=Yi,e.remove=wi,e.rest=Ei,e.restParam=uo,e.set=Go,e.shuffle=Wi,e.slice=Ai,e.sortBy=Qi,e.sortByAll=cu,e.sortByOrder=Zi,e.spread=co,e.take=xi,e.takeRight=Si,e.takeRightWhile=Ti,e.takeWhile=ki,e.tap=Li,e.throttle=fo,e.thru=Bi,e.times=Es,e.toArray=Co,e.toPlainObject=Lo,e.transform=Ho,e.union=Xa,e.uniq=Oi,e.unzip=Ii,e.values=Ko,e.valuesIn=Vo,e.where=to,e.without=Wa,e.wrap=ho,e.xor=ji,e.zip=$a,e.zipObject=Ri,e.backflow=mu,e.collect=Ki,e.compose=mu,e.each=eu,e.eachRight=ru,e.extend=ku,e.iteratee=hs,e.methods=Fo,e.object=Ri,e.select=zi,e.tail=Ei,e.unique=Oi,ys(e,e),e.add=xs,e.attempt=Ku,e.camelCase=Mu,e.capitalize=Wo,e.clone=lo,e.cloneDeep=po,e.deburr=$o,e.endsWith=Jo,e.escape=Qo,e.escapeRegExp=Zo,e.every=Ui,e.find=Za,e.findIndex=Ga,e.findKey=Iu,e.findLast=tu,e.findLastIndex=Ha,e.findLastKey=ju,e.findWhere=Gi,e.first=li,e.get=No,e.has=qo,e.identity=ps,e.includes=Hi,e.indexOf=_i,e.inRange=Yo,e.isArguments=_o,e.isArray=Au,e.isBoolean=yo,e.isDate=vo,e.isElement=go,e.isEmpty=mo,e.isEqual=bo,e.isError=wo,e.isFinite=xu,e.isFunction=Su,e.isMatch=Ao,e.isNaN=xo,e.isNative=So,e.isNull=To,e.isNumber=ko,e.isObject=Eo,e.isPlainObject=Tu,e.isRegExp=Oo,e.isString=Io,e.isTypedArray=jo,e.isUndefined=Ro,e.kebabCase=Pu,e.last=gi,e.lastIndexOf=mi,e.max=Xu,e.min=Wu,e.noConflict=vs,e.noop=gs,e.now=fu,e.pad=ts,e.padLeft=Uu,e.padRight=zu,e.parseInt=es,e.random=Xo,e.reduce=au,e.reduceRight=uu,e.repeat=rs,e.result=zo,e.runInContext=T,e.size=$i,e.snakeCase=Gu,e.some=Ji,e.sortedIndex=Va,e.sortedLastIndex=Ya,e.startCase=Hu,e.startsWith=ns,e.sum=Ss,e.template=is,e.trim=os,e.trimLeft=ss,e.trimRight=as,e.trunc=us,e.unescape=cs,e.uniqueId=As,e.words=fs,e.all=Ui,e.any=Ji,e.contains=Hi,e.detect=Za,e.foldl=au,e.foldr=uu,e.head=li,e.include=Hi,e.inject=au,ys(e,function(){var t={};return Ir(e,function(r,n){e.prototype[n]||(t[n]=r)}),t}(),!1),e.sample=Xi,e.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Xi(e,t)}):Xi(this.value())},e.VERSION=O,er(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){e[t].placeholder=e}),er(["dropWhile","filter","map","takeWhile"],function(t,e){var r=e!=H,n=e==z;i.prototype[t]=function(t,o){var s=this.__filtered__,a=s&&n?new i(this):this.clone(),u=a.__iteratees__||(a.__iteratees__=[]);return u.push({done:!1,count:0,index:0,iteratee:Nn(t,o,1),limit:-1,type:e}),a.__filtered__=s||r,a}}),er(["drop","take"],function(t,e){var r=t+"While";i.prototype[t]=function(r){var n=this.__filtered__,i=n&&!e?this.dropWhile():this.clone();if(r=null==r?1:pa($s(r)||0,0),n)e?i.__takeCount__=da(i.__takeCount__,r):gi(i.__iteratees__).limit=r;else{var o=i.__views__||(i.__views__=[]);o.push({size:r,type:t+(i.__dir__<0?"Right":"")})}return i},i.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},i.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[r](t,e).reverse()}}),er(["first","last"],function(t,e){var r="take"+(e?"Right":"");i.prototype[t]=function(){return this[r](1).value()[0]}}),er(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");i.prototype[t]=function(){return this[r](1)}}),er(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?qr:ms;i.prototype[t]=function(t){return this[r](n(t))}}),i.prototype.compact=function(){return this.filter(ps)},i.prototype.reject=function(t,e){return t=Nn(t,e,1),this.filter(function(e){return!t(e)})},i.prototype.slice=function(t,e){t=null==t?0:+t||0;var r=0>t?this.takeRight(-t):this.drop(t);return e!==k&&(e=+e||0,r=0>e?r.dropRight(-e):r.take(e-t)),r},i.prototype.toArray=function(){return this.drop(0)},Ir(i.prototype,function(t,r){var o=e[r];if(o){var s=/^(?:filter|map|reject)|While$/.test(r),a=/^(?:first|last)$/.test(r);e.prototype[r]=function(){var r=arguments,u=(r.length,this.__chain__),c=this.__wrapped__,f=!!this.__actions__.length,h=c instanceof i,l=r[0],p=h||Au(c);p&&s&&"function"==typeof l&&1!=l.length&&(h=p=!1);var d=h&&!f;if(a&&!u)return d?t.call(c):o.call(e,this.value());var _=function(t){var n=[t];return Zs.apply(n,r),o.apply(e,n)};if(p){var y=d?c:new i(this),v=t.apply(y,r);if(!a&&(f||v.__actions__)){var g=v.__actions__||(v.__actions__=[]);g.push({func:Bi,args:[_],thisArg:e})}return new n(v,u)}return this.thru(_)}}}),er(["concat","join","pop","push","replace","shift","sort","splice","split","unshift"],function(t){var r=(/^(?:replace|split)$/.test(t)?Ds:Ns)[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",i=/^(?:join|pop|replace|shift)$/.test(t);e.prototype[t]=function(){var t=arguments;return i&&!this.__chain__?r.apply(this.value(),t):this[n](function(e){return r.apply(e,t)})}}),Ir(i.prototype,function(t,r){var n=e[r];if(n){var i=n.name,o=ka[i]||(ka[i]=[]);o.push({name:r,func:n})}}),ka[kn(null,j).name]=[{name:"wrapper",func:null}],i.prototype.clone=b,i.prototype.reverse=Z,i.prototype.value=ne,e.prototype.chain=Fi,e.prototype.commit=Ni,e.prototype.plant=qi,e.prototype.reverse=Di,e.prototype.toString=Mi,e.prototype.run=e.prototype.toJSON=e.prototype.valueOf=e.prototype.value=Pi,e.prototype.collect=e.prototype.map,e.prototype.head=e.prototype.first,e.prototype.select=e.prototype.filter,e.prototype.tail=e.prototype.rest,e}var k,O="3.7.0",I=1,j=2,R=4,C=8,L=16,B=32,F=64,N=128,q=256,D=30,M="...",P=150,U=16,z=0,G=1,H=2,K="Expected a function",V="__lodash_placeholder__",Y="[object Arguments]",X="[object Array]",W="[object Boolean]",$="[object Date]",J="[object Error]",Q="[object Function]",Z="[object Map]",te="[object Number]",ee="[object Object]",re="[object RegExp]",ne="[object Set]",ie="[object String]",oe="[object WeakMap]",se="[object ArrayBuffer]",ae="[object Float32Array]",ue="[object Float64Array]",ce="[object Int8Array]",fe="[object Int16Array]",he="[object Int32Array]",le="[object Uint8Array]",pe="[object Uint8ClampedArray]",de="[object Uint16Array]",_e="[object Uint32Array]",ye=/\b__p \+= '';/g,ve=/\b(__p \+=) '' \+/g,ge=/(__e\(.*?\)|\b__t\)) \+\n'';/g,me=/&(?:amp|lt|gt|quot|#39|#96);/g,be=/[&<>"'`]/g,we=RegExp(me.source),Ee=RegExp(be.source),Ae=/<%-([\s\S]+?)%>/g,xe=/<%([\s\S]+?)%>/g,Se=/<%=([\s\S]+?)%>/g,Te=/\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,ke=/^\w*$/,Oe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,Ie=/[.*+?^${}()|[\]\/\\]/g,je=RegExp(Ie.source),Re=/[\u0300-\u036f\ufe20-\ufe23]/g,Ce=/\\(\\)?/g,Le=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Be=/\w*$/,Fe=/^0[xX]/,Ne=/^\[object .+?Constructor\]$/,qe=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,De=/($^)/,Me=/['\n\r\u2028\u2029\\]/g,Pe=function(){var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",e="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+e+")|"+t+"?"+e+"|"+t+"+|[0-9]+","g")}(),Ue=" \f \n\r\u2028\u2029 ",ze=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window"],Ge=-1,He={};He[ae]=He[ue]=He[ce]=He[fe]=He[he]=He[le]=He[pe]=He[de]=He[_e]=!0,He[Y]=He[X]=He[se]=He[W]=He[$]=He[J]=He[Q]=He[Z]=He[te]=He[ee]=He[re]=He[ne]=He[ie]=He[oe]=!1;var Ke={};Ke[Y]=Ke[X]=Ke[se]=Ke[W]=Ke[$]=Ke[ae]=Ke[ue]=Ke[ce]=Ke[fe]=Ke[he]=Ke[te]=Ke[ee]=Ke[re]=Ke[ie]=Ke[le]=Ke[pe]=Ke[de]=Ke[_e]=!0,Ke[J]=Ke[Q]=Ke[Z]=Ke[ne]=Ke[oe]=!1;var Ve={leading:!1,maxWait:0,trailing:!1},Ye={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Xe={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},We={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},$e={"function":!0,object:!0},Je={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Qe=$e[typeof e]&&e&&!e.nodeType&&e,Ze=$e[typeof t]&&t&&!t.nodeType&&t,tr=Qe&&Ze&&"object"==typeof i&&i&&i.Object&&i,er=$e[typeof self]&&self&&self.Object&&self,rr=$e[typeof window]&&window&&window.Object&&window,nr=(Ze&&Ze.exports===Qe&&Qe,tr||rr!==(this&&this.window)&&rr||er||this),ir=T();nr._=ir,n=function(){return ir}.call(e,r,e,t),!(n!==k&&(t.exports=n))}).call(this)}).call(e,r(57)(t),function(){return this}())},function(t){function e(t){if(!t||"[object Object]"!==n.call(t)||t.nodeType||t.setInterval)return!1;var e=r.call(t,"constructor"),i=r.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!e&&!i)return!1;var o;for(o in t);return void 0===o||r.call(t,o)}var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function i(){var t,r,n,o,s,a,u=arguments[0]||{},c=1,f=arguments.length,h=!1;for("boolean"==typeof u&&(h=u,u=arguments[1]||{},c=2),"object"!=typeof u&&"function"!=typeof u&&(u={});f>c;c++)if(null!=(t=arguments[c]))for(r in t)n=u[r],o=t[r],u!==o&&(h&&o&&(e(o)||(s=Array.isArray(o)))?(s?(s=!1,a=n&&Array.isArray(n)?n:[]):a=n&&e(n)?n:{},u[r]=i(h,a,o)):void 0!==o&&(u[r]=o));return u}},function(t,e,r){(function(t){function t(e){return this instanceof t?(this.length=0,this.parent=void 0,"number"==typeof e?n(this,e):"string"==typeof e?i(this,e,arguments.length>1?arguments[1]:"utf8"):o(this,e)):arguments.length>1?new t(e,arguments[1]):new t(e)}function n(e,r){if(e=h(e,0>r?0:0|l(r)),!t.TYPED_ARRAY_SUPPORT)for(var n=0;r>n;n++)e[n]=0;return e}function i(t,e,r){("string"!=typeof r||""===r)&&(r="utf8");var n=0|d(e,r);return t=h(t,n),t.write(e,r),t}function o(e,r){if(t.isBuffer(r))return s(e,r);if(K(r))return a(e,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");return"undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer?u(e,r):r.length?c(e,r):f(e,r)}function s(t,e){var r=0|l(e.length);return t=h(t,r),e.copy(t,0,0,r),t}function a(t,e){var r=0|l(e.length);t=h(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function u(t,e){var r=0|l(e.length);t=h(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function c(t,e){var r=0|l(e.length);t=h(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r,n=0;"Buffer"===e.type&&K(e.data)&&(r=e.data,n=0|l(r.length)),t=h(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function h(e,r){t.TYPED_ARRAY_SUPPORT?e=t._augment(new Uint8Array(r)):(e.length=r,e._isBuffer=!0);var n=0!==r&&r<=t.poolSize>>>1;return n&&(e.parent=Y),e}function l(t){if(t>=V)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+V.toString(16)+" bytes");return 0|t}function p(e,r){if(!(this instanceof p))return new p(e,r);var n=new t(e,r);return delete n.parent,n}function d(t,e){if("string"!=typeof t&&(t=String(t)),0===t.length)return 0;switch(e||"utf8"){case"ascii":case"binary":case"raw":return t.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t.length;case"hex":return t.length>>>1;case"utf8":case"utf-8":return q(t).length;case"base64":return P(t).length;default:return t.length}}function _(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function y(t,e,r,n){return U(q(e,t.length-r),t,r,n)}function v(t,e,r,n){return U(D(e),t,r,n)}function g(t,e,r,n){return v(t,e,r,n)}function m(t,e,r,n){return U(P(e),t,r,n)}function b(t,e,r,n){return U(M(e,t.length-r),t,r,n)}function w(t,e,r){return G.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function E(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=z(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+z(i)}function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function x(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=N(t[o]);return i}function T(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function k(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(r>o||s>r)throw new RangeError("value is out of bounds");if(n+i>e.length)throw new RangeError("index out of range")}function I(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function j(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function R(t,e,r,n,i,o){if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function C(t,e,r,n,i){return i||R(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),H.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,i){return i||R(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),H.write(t,e,r,n,52,8),r+8}function B(t){if(t=F(t).replace(W,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function F(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function N(t){return 16>t?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;n>s;s++){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((e-=3)>-1&&o.push(239,191,189),i=null);if(128>r){if((e-=1)<0)break;o.push(r)}else if(2048>r){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function M(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);s++)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function P(t){return G.toByteArray(B(t))}function U(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function z(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var G=r(63),H=r(58),K=r(59);e.Buffer=t,e.SlowBuffer=p,e.INSPECT_MAX_BYTES=50,t.poolSize=8192;var V=1073741823,Y={};t.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,o=0,s=Math.min(n,i);s>o&&e[o]===r[o];)++o;return o!==s&&(n=e[o],i=r[o]),i>n?-1:n>i?1:0},t.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(e,r){if(!K(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new t(0);if(1===e.length)return e[0];var n;if(void 0===r)for(r=0,n=0;n<e.length;n++)r+=e[n].length;var i=new t(r),o=0;for(n=0;n<e.length;n++){var s=e[n];s.copy(i,o),o+=s.length}return i},t.byteLength=d,t.prototype.length=void 0,t.prototype.parent=void 0,t.prototype.toString=function(t,e,r){var n=!1;if(e=0|e,r=void 0===r||1/0===r?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return A(this,e,r);case"binary":return x(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===t.compare(this,e)},t.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},t.prototype.compare=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:t.compare(this,e)},t.prototype.indexOf=function(e,r){function n(t,e,r){for(var n=-1,i=0;r+i<t.length;i++)if(t[r+i]===e[-1===n?0:i-n]){if(-1===n&&(n=i),i-n+1===e.length)return r+n}else n=-1;return-1}if(r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(0>r&&(r=Math.max(this.length+r,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,r);if(t.isBuffer(e))return n(this,e,r);if("number"==typeof e)return t.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,r):n(this,[e],r);throw new TypeError("val must be string, number or Buffer")},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},t.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return v(this,t,e,r);case"binary":return g(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>r?(r+=n,0>r&&(r=0)):r>n&&(r=n),e>r&&(r=e);var i;if(t.TYPED_ARRAY_SUPPORT)i=t._augment(this.subarray(e,r));else{var o=r-e;i=new t(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+e]}return i.length&&(i.parent=this.parent||this),i},t.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},t.prototype.readUIntBE=function(t,e,r){t=0|t,e=0|e,r||k(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},t.prototype.readUInt8=function(t,e){return e||k(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||k(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||k(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},t.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},t.prototype.readInt16LE=function(t,e){e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||k(t,4,this.length),H.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||k(t,4,this.length),H.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||k(t,8,this.length),H.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||k(t,8,this.length),H.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},t.prototype.writeUIntBE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},t.prototype.writeUInt8=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e,this[r+1]=e>>>8):I(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e):I(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e):j(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e):j(this,e,r,!1),r+4},t.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,s=1,a=0>t?1:0;for(this[e]=255&t;++o<r&&(s*=256);)this[e+o]=(t/s>>0)-a&255;return e+r},t.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0>t?1:0;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=(t/s>>0)-a&255;return e+r},t.prototype.writeInt8=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[r]=e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e,this[r+1]=e>>>8):I(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e):I(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):j(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e):j(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&n>i&&(i=n),i===n)return 0;if(0===e.length||0===this.length)return 0;if(0>r)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var o=i-n;if(1e3>o||!t.TYPED_ARRAY_SUPPORT)for(var s=0;o>s;s++)e[s+r]=this[s+n];else e._set(this.subarray(n,n+o),r);return o},t.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=q(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},t.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(t.TYPED_ARRAY_SUPPORT)return new t(this).buffer;for(var e=new Uint8Array(this.length),r=0,n=e.length;n>r;r+=1)e[r]=this[r];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var X=t.prototype;t._augment=function(e){return e.constructor=t,e._isBuffer=!0,e._set=e.set,e.get=X.get,e.set=X.set,e.write=X.write,e.toString=X.toString,e.toLocaleString=X.toString,e.toJSON=X.toJSON,e.equals=X.equals,e.compare=X.compare,e.indexOf=X.indexOf,e.copy=X.copy,e.slice=X.slice,e.readUIntLE=X.readUIntLE,e.readUIntBE=X.readUIntBE,e.readUInt8=X.readUInt8,e.readUInt16LE=X.readUInt16LE,e.readUInt16BE=X.readUInt16BE,e.readUInt32LE=X.readUInt32LE,e.readUInt32BE=X.readUInt32BE,e.readIntLE=X.readIntLE,e.readIntBE=X.readIntBE,e.readInt8=X.readInt8,e.readInt16LE=X.readInt16LE,e.readInt16BE=X.readInt16BE,e.readInt32LE=X.readInt32LE,e.readInt32BE=X.readInt32BE,e.readFloatLE=X.readFloatLE,e.readFloatBE=X.readFloatBE,e.readDoubleLE=X.readDoubleLE,e.readDoubleBE=X.readDoubleBE,e.writeUInt8=X.writeUInt8,e.writeUIntLE=X.writeUIntLE,e.writeUIntBE=X.writeUIntBE,e.writeUInt16LE=X.writeUInt16LE,e.writeUInt16BE=X.writeUInt16BE,e.writeUInt32LE=X.writeUInt32LE,e.writeUInt32BE=X.writeUInt32BE,e.writeIntLE=X.writeIntLE,e.writeIntBE=X.writeIntBE,e.writeInt8=X.writeInt8,e.writeInt16LE=X.writeInt16LE,e.writeInt16BE=X.writeInt16BE,e.writeInt32LE=X.writeInt32LE,e.writeInt32BE=X.writeInt32BE,e.writeFloatLE=X.writeFloatLE,e.writeFloatBE=X.writeFloatBE,e.writeDoubleLE=X.writeDoubleLE,e.writeDoubleBE=X.writeDoubleBE,e.fill=X.fill,e.inspect=X.inspect,e.toArrayBuffer=X.toArrayBuffer,e};var W=/[^+\/0-9A-z\-]/g}).call(e,r(42).Buffer)},function(t,e,r){function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(t,e,r){if(t&&c(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return u(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)}function s(t,e){return i(t,!1,!0).resolve(e)}function a(t,e){return t?i(t,!1,!0).resolveObject(e):e}function u(t){return"string"==typeof t}function c(t){return"object"==typeof t&&null!==t}function f(t){return null===t}function h(t){return null==t}var l=r(56);e.parse=i,e.resolve=s,e.resolveObject=a,e.format=o,e.Url=n;var p=/^([a-z0-9.+-]+:)/i,d=/:[0-9]*$/,_=["<",">",'"',"`"," ","\r","\n"," "],y=["{","}","|","\\","^","`"].concat(_),v=["'"].concat(y),g=["%","/","?",";","#"].concat(v),m=["/","?","#"],b=255,w=/^[a-z0-9A-Z_-]{0,63}$/,E=/^([a-z0-9A-Z_-]{0,63})(.*)$/,A={javascript:!0,"javascript:":!0},x={javascript:!0,"javascript:":!0},S={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},T=r(60);n.prototype.parse=function(t,e,r){if(!u(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var i=p.exec(n);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var s="//"===n.substr(0,2);!s||i&&x[i]||(n=n.substr(2),this.slashes=!0)}if(!x[i]&&(s||i&&!S[i])){for(var a=-1,c=0;c<m.length;c++){var f=n.indexOf(m[c]);-1!==f&&(-1===a||a>f)&&(a=f)}var h,d;d=-1===a?n.lastIndexOf("@"):n.lastIndexOf("@",a),-1!==d&&(h=n.slice(0,d),n=n.slice(d+1),this.auth=decodeURIComponent(h)),a=-1;for(var c=0;c<g.length;c++){var f=n.indexOf(g[c]);-1!==f&&(-1===a||a>f)&&(a=f)}-1===a&&(a=n.length),this.host=n.slice(0,a),n=n.slice(a),this.parseHost(),this.hostname=this.hostname||"";var _="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!_)for(var y=this.hostname.split(/\./),c=0,k=y.length;k>c;c++){var O=y[c];if(O&&!O.match(w)){for(var I="",j=0,R=O.length;R>j;j++)I+=O.charCodeAt(j)>127?"x":O[j];if(!I.match(w)){var C=y.slice(0,c),L=y.slice(c+1),B=O.match(E);B&&(C.push(B[1]),L.unshift(B[2])),L.length&&(n="/"+L.join(".")+n),this.hostname=C.join(".");break}}}if(this.hostname=this.hostname.length>b?"":this.hostname.toLowerCase(),!_){for(var F=this.hostname.split("."),N=[],c=0;c<F.length;++c){var q=F[c];N.push(q.match(/[^A-Za-z0-9_-]/)?"xn--"+l.encode(q):q)}this.hostname=N.join(".")}var D=this.port?":"+this.port:"",M=this.hostname||"";this.host=M+D,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==n[0]&&(n="/"+n))}if(!A[o])for(var c=0,k=v.length;k>c;c++){var P=v[c],U=encodeURIComponent(P);U===P&&(U=escape(P)),n=n.split(P).join(U)}var z=n.indexOf("#");-1!==z&&(this.hash=n.substr(z),n=n.slice(0,z));var G=n.indexOf("?");if(-1!==G?(this.search=n.substr(G),this.query=n.substr(G+1),e&&(this.query=T.parse(this.query)),n=n.slice(0,G)):e&&(this.search="",this.query={}),n&&(this.pathname=n),S[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var D=this.pathname||"",q=this.search||"";this.path=D+q}return this.href=this.format(),this
},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&c(this.query)&&Object.keys(this.query).length&&(o=T.stringify(this.query));var s=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||S[e])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),s=s.replace("#","%23"),e+i+r+s+n},n.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(u(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),S[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!S[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||x[t.protocol])r.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var o=r.pathname||"",s=r.search||"";r.path=o+s}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var a=r.pathname&&"/"===r.pathname.charAt(0),c=t.host||t.pathname&&"/"===t.pathname.charAt(0),l=c||a||r.host&&t.pathname,p=l,d=r.pathname&&r.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],_=r.protocol&&!S[r.protocol];if(_&&(r.hostname="",r.port=null,r.host&&(""===d[0]?d[0]=r.host:d.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),l=l&&(""===i[0]||""===d[0])),c)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,d=i;else if(i.length)d||(d=[]),d.pop(),d=d.concat(i),r.search=t.search,r.query=t.query;else if(!h(t.search)){if(_){r.hostname=r.host=d.shift();var y=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;y&&(r.auth=y.shift(),r.host=r.hostname=y.shift())}return r.search=t.search,r.query=t.query,f(r.pathname)&&f(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!d.length)return r.pathname=null,r.path=r.search?"/"+r.search:null,r.href=r.format(),r;for(var v=d.slice(-1)[0],g=(r.host||t.host)&&("."===v||".."===v)||""===v,m=0,b=d.length;b>=0;b--)v=d[b],"."==v?d.splice(b,1):".."===v?(d.splice(b,1),m++):m&&(d.splice(b,1),m--);if(!l&&!p)for(;m--;m)d.unshift("..");!l||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),g&&"/"!==d.join("/").substr(-1)&&d.push("");var w=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(_){r.hostname=r.host=w?"":d.length?d.shift():"";var y=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;y&&(r.auth=y.shift(),r.host=r.hostname=y.shift())}return l=l||r.host&&d.length,l&&!w&&d.unshift(""),d.length?r.pathname=d.join("/"):(r.pathname=null,r.path=null),f(r.pathname)&&f(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=d.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t){!function(){function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(){return 1}function n(t){return this instanceof n?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||r,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=r),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new n(t)}function i(t,e,r){var n=t._cache[e];return n&&(t._maxAge&&Date.now()-n.now>t._maxAge?(u(t,n),t._allowStale||(n=void 0)):r&&o(t,n),n&&(n=n.value)),n}function o(t,e){a(t,e),e.lu=t._mru++,t._maxAge&&(e.now=Date.now()),t._lruList[e.lu]=e}function s(t){for(;t._lru<t._mru&&t._length>t._max;)u(t,t._lruList[t._lru])}function a(t,e){for(delete t._lruList[e.lu];t._lru<t._mru&&!t._lruList[t._lru];)t._lru++}function u(t,e){e&&(t._dispose&&t._dispose(e.key,e.value),t._length-=e.length,t._itemCount--,delete t._cache[e.key],a(t,e))}function c(t,e,r,n,i){this.key=t,this.value=e,this.lu=r,this.length=n,this.now=i}"object"==typeof t&&t.exports?t.exports=n:this.LRUCache=n,Object.defineProperty(n.prototype,"max",{set:function(t){(!t||"number"!=typeof t||0>=t)&&(t=1/0),this._max=t,this._length>this._max&&s(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(n.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=r,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&s(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(n.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(n.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),n.prototype.forEach=function(t,e){e=e||this;for(var r=0,n=this._mru-1;n>=0&&r<this._itemCount;n--)if(this._lruList[n]){r++;var i=this._lruList[n];this._maxAge&&Date.now()-i.now>this._maxAge&&(u(this,i),this._allowStale||(i=void 0)),i&&t.call(e,i.value,i.key,this)}},n.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;r>=0&&e<this._itemCount;r--)if(this._lruList[r]){var n=this._lruList[r];t[e++]=n.key}return t},n.prototype.values=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;r>=0&&e<this._itemCount;r--)if(this._lruList[r]){var n=this._lruList[r];t[e++]=n.value}return t},n.prototype.reset=function(){if(this._dispose&&this._cache)for(var t in this._cache)this._dispose(t,this._cache[t].value);this._cache=Object.create(null),this._lruList=Object.create(null),this._mru=0,this._lru=0,this._length=0,this._itemCount=0},n.prototype.dump=function(){return this._cache},n.prototype.dumpLru=function(){return this._lruList},n.prototype.set=function(t,r){if(e(this._cache,t))return this._dispose&&this._dispose(t,this._cache[t].value),this._maxAge&&(this._cache[t].now=Date.now()),this._cache[t].value=r,this.get(t),!0;var n=this._lengthCalculator(r),i=this._maxAge?Date.now():0,o=new c(t,r,this._mru++,n,i);return o.length>this._max?(this._dispose&&this._dispose(t,r),!1):(this._length+=o.length,this._lruList[o.lu]=this._cache[t]=o,this._itemCount++,this._length>this._max&&s(this),!0)},n.prototype.has=function(t){if(!e(this._cache,t))return!1;var r=this._cache[t];return this._maxAge&&Date.now()-r.now>this._maxAge?!1:!0},n.prototype.get=function(t){return i(this,t,!0)},n.prototype.peek=function(t){return i(this,t,!1)},n.prototype.pop=function(){var t=this._lruList[this._lru];return u(this,t),t||null},n.prototype.del=function(t){u(this,this._cache[t])}}()},function(t,e,r){var n,i;(function(r,o){!function(){function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(a,arguments)}}var a,u,c={};a=this,null!=a&&(u=a.async),c.noConflict=function(){return a.async=u,c};var f=Object.prototype.toString,h=Array.isArray||function(t){return"[object Array]"===f.call(t)},l=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r<t.length;r+=1)e(t[r],r,t)},p=function(t,e){if(t.map)return t.map(e);var r=[];return l(t,function(t,n,i){r.push(e(t,n,i))}),r},d=function(t,e,r){return t.reduce?t.reduce(e,r):(l(t,function(t,n,i){r=e(r,t,n,i)}),r)},_=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e};"undefined"!=typeof r&&r.nextTick?(c.nextTick=r.nextTick,c.setImmediate="undefined"!=typeof o?function(t){o(t)}:c.nextTick):"function"==typeof o?(c.nextTick=function(t){o(t)},c.setImmediate=c.nextTick):(c.nextTick=function(t){setTimeout(t,0)},c.setImmediate=c.nextTick),c.each=function(t,e,r){function n(e){e?(r(e),r=function(){}):(i+=1,i>=t.length&&r())}if(r=r||function(){},!t.length)return r();var i=0;l(t,function(t){e(t,s(n))})},c.forEach=c.each,c.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1,n>=t.length?r():i())})};i()},c.forEachSeries=c.eachSeries,c.eachLimit=function(t,e,r,n){var i=y(e);i.apply(null,[t,r,n])},c.forEachLimit=c.eachLimit;var y=function(t){return function(e,r,n){if(n=n||function(){},!e.length||0>=t)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;t>s&&o<e.length;)o+=1,s+=1,r(e[o-1],function(t){t?(n(t),n=function(){}):(i+=1,s-=1,i>=e.length?n():a())})}()}},v=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[c.each].concat(e))}},g=function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[y(t)].concat(r))}},m=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[c.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=p(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};c.map=v(b),c.mapSeries=m(b),c.mapLimit=function(t,e,r,n){return w(e)(t,r,n)};var w=function(t){return g(t,b)};c.reduce=function(t,e,r,n){c.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},c.inject=c.reduce,c.foldl=c.reduce,c.reduceRight=function(t,e,r,n){var i=p(t,function(t){return t}).reverse();c.reduce(i,e,r,n)},c.foldr=c.reduceRight;var E=function(t,e,r,n){var i=[];e=p(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(){n(p(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};c.filter=v(E),c.filterSeries=m(E),c.select=c.filter,c.selectSeries=c.filterSeries;var A=function(t,e,r,n){var i=[];e=p(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(){n(p(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};c.reject=v(A),c.rejectSeries=m(A);var x=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(){n()})};c.detect=v(x),c.detectSeries=m(x),c.some=function(t,e,r){c.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(){r(!1)})},c.any=c.some,c.every=function(t,e,r){c.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(){r(!0)})},c.all=c.every,c.sortBy=function(t,e,r){c.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);var n=function(t,e){var r=t.criteria,n=e.criteria;return n>r?-1:r>n?1:0};r(null,p(e.sort(n),function(t){return t.value}))})},c.auto=function(t,e){e=e||function(){};var r=_(t),n=r.length;if(!n)return e();var i={},o=[],s=function(t){o.unshift(t)},a=function(t){for(var e=0;e<o.length;e+=1)if(o[e]===t)return void o.splice(e,1)},u=function(){n--,l(o.slice(0),function(t){t()})};s(function(){if(!n){var t=e;e=function(){},t(null,i)}}),l(r,function(r){var n=h(t[r])?t[r]:[t[r]],o=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var o={};l(_(i),function(t){o[t]=i[t]}),o[r]=n,e(t,o),e=function(){}}else i[r]=n,c.setImmediate(u)},f=n.slice(0,Math.abs(n.length-1))||[],p=function(){return d(f,function(t,e){return t&&i.hasOwnProperty(e)},!0)&&!i.hasOwnProperty(r)};if(p())n[n.length-1](o,i);else{var y=function(){p()&&(a(y),n[n.length-1](o,i))};s(y)}})},c.retry=function(t,e,r){var n=5,i=[];"function"==typeof t&&(r=e,e=t,t=n),t=parseInt(t,10)||n;var o=function(n,o){for(var s=function(t,e){return function(r){t(function(t,n){r(!t||e,{err:t,result:n})},o)}};t;)i.push(s(e,!(t-=1)));c.series(i,function(t,e){e=e[e.length-1],(n||r)(e.err,e.result)})};return r?o():o},c.waterfall=function(t,e){if(e=e||function(){},!h(t)){var r=new Error("First argument to waterfall must be an array of functions");return e(r)}if(!t.length)return e();var n=function(t){return function(r){if(r)e.apply(null,arguments),e=function(){};else{var i=Array.prototype.slice.call(arguments,1),o=t.next();i.push(o?n(o):e),c.setImmediate(function(){t.apply(null,i)})}}};n(c.iterator(t))()};var S=function(t,e,r){if(r=r||function(){},h(e))t.map(e,function(t,e){t&&t(function(t){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),e.call(null,t,r)})},r);else{var n={};t.each(_(e),function(t,r){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),n[t]=i,r(e)})},function(t){r(t,n)})}};c.parallel=function(t,e){S({map:c.map,each:c.each},t,e)},c.parallelLimit=function(t,e,r){S({map:w(e),each:y(e)},t,r)},c.series=function(t,e){if(e=e||function(){},h(t))c.mapSeries(t,function(t,e){t&&t(function(t){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),e.call(null,t,r)})},e);else{var r={};c.eachSeries(_(t),function(e,n){t[e](function(t){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[e]=i,n(t)})},function(t){e(t,r)})}},c.iterator=function(t){var e=function(r){var n=function(){return t.length&&t[r].apply(null,arguments),n.next()};return n.next=function(){return r<t.length-1?e(r+1):null},n};return e(0)},c.apply=function(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e.concat(Array.prototype.slice.call(arguments)))}};var T=function(t,e,r,n){var i=[];t(e,function(t,e){r(t,function(t,r){i=i.concat(r||[]),e(t)})},function(t){n(t,i)})};c.concat=v(T),c.concatSeries=m(T),c.whilst=function(t,e,r){t()?e(function(n){return n?r(n):void c.whilst(t,e,r)}):r()},c.doWhilst=function(t,e,r){t(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);e.apply(null,i)?c.doWhilst(t,e,r):r()})},c.until=function(t,e,r){t()?r():e(function(n){return n?r(n):void c.until(t,e,r)})},c.doUntil=function(t,e,r){t(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);e.apply(null,i)?r():c.doUntil(t,e,r)})},c.queue=function(t,e){function r(t,e,r,n){return t.started||(t.started=!0),h(e)||(e=[e]),0==e.length?c.setImmediate(function(){t.drain&&t.drain()}):void l(e,function(e){var i={data:e,callback:"function"==typeof n?n:null};r?t.tasks.unshift(i):t.tasks.push(i),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),c.setImmediate(t.process)})}void 0===e&&(e=1);var n=0,i={tasks:[],concurrency:e,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(t,e){r(i,t,!1,e)},kill:function(){i.drain=null,i.tasks=[]},unshift:function(t,e){r(i,t,!0,e)},process:function(){if(!i.paused&&n<i.concurrency&&i.tasks.length){var e=i.tasks.shift();i.empty&&0===i.tasks.length&&i.empty(),n+=1;var r=function(){n-=1,e.callback&&e.callback.apply(e,arguments),i.drain&&i.tasks.length+n===0&&i.drain(),i.process()},o=s(r);t(e.data,o)}},length:function(){return i.tasks.length},running:function(){return n},idle:function(){return i.tasks.length+n===0},pause:function(){i.paused!==!0&&(i.paused=!0,i.process())},resume:function(){i.paused!==!1&&(i.paused=!1,i.process())}};return i},c.priorityQueue=function(t,e){function r(t,e){return t.priority-e.priority}function n(t,e,r){for(var n=-1,i=t.length-1;i>n;){var o=n+(i-n+1>>>1);r(e,t[o])>=0?n=o:i=o-1}return n}function i(t,e,i,o){return t.started||(t.started=!0),h(e)||(e=[e]),0==e.length?c.setImmediate(function(){t.drain&&t.drain()}):void l(e,function(e){var s={data:e,priority:i,callback:"function"==typeof o?o:null};t.tasks.splice(n(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),c.setImmediate(t.process)})}var o=c.queue(t,e);return o.push=function(t,e,r){i(o,t,e,r)},delete o.unshift,o},c.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){h(t)||(t=[t]),l(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),c.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=p(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;l(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var k=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&l(r,function(e){console[t](e)}))}]))}};c.log=k("log"),c.dir=k("dir"),c.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),s=e.apply(null,i);s in r?c.nextTick(function(){o.apply(null,r[s])}):s in n?n[s].push(o):(n[s]=[o],t.apply(null,i.concat([function(){r[s]=arguments;var t=n[s];delete n[s];for(var e=0,i=t.length;i>e;e++)t[e].apply(null,arguments)}])))};return i.memo=r,i.unmemoized=t,i},c.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},c.times=function(t,e,r){for(var n=[],i=0;t>i;i++)n.push(i);return c.map(n,e,r)},c.timesSeries=function(t,e,r){for(var n=[],i=0;t>i;i++)n.push(i);return c.mapSeries(n,e,r)},c.seq=function(){var t=arguments;return function(){var e=this,r=Array.prototype.slice.call(arguments),n=r.pop();c.reduce(t,r,function(t,r,n){r.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);n(t,e)}]))},function(t,r){n.apply(e,[t].concat(r))})}},c.compose=function(){return c.seq.apply(null,Array.prototype.reverse.call(arguments))};var O=function(t,e){var r=function(){var r=this,n=Array.prototype.slice.call(arguments),i=n.pop();return t(e,function(t,e){t.apply(r,n.concat([e]))},i)};if(arguments.length>2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};c.applyEach=v(O),c.applyEachSeries=m(O),c.forever=function(t,e){function r(n){if(n){if(e)return e(n);throw n}t(r)}r()},"undefined"!=typeof t&&t.exports?t.exports=c:(n=[],i=function(){return c}.apply(e,n),!(void 0!==i&&(t.exports=i)))}()}).call(e,r(55),r(61).setImmediate)},function(t,e,r){var n;!function(i){"use strict";function o(t){function e(t,n){var i,o,s,a,u,c,f=this;if(!(f instanceof e))return H&&C(26,"constructor call without new",t),new e(t,n);if(null!=n&&K(n,2,64,F,"base")){if(n=0|n,c=t+"",10==n)return f=new e(t instanceof e?t:c),L(f,D+f.e+1,M);if((a="number"==typeof t)&&0*t!=0||!new RegExp("^-?"+(i="["+x.slice(0,n)+"]+")+"(?:\\."+i+")?$",37>n?"i":"").test(c))return v(f,c,a,n);a?(f.s=0>1/t?(c=c.slice(1),-1):1,H&&c.replace(/^0\.0*|\./,"").length>15&&C(F,A,t),a=!1):f.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1,c=r(c,10,n,f.s)}else{if(t instanceof e)return f.s=t.s,f.e=t.e,f.c=(t=t.c)?t.slice():t,void(F=0);if((a="number"==typeof t)&&0*t==0){if(f.s=0>1/t?(t=-t,-1):1,t===~~t){for(o=0,s=t;s>=10;s/=10,o++);return f.e=o,f.c=[t],void(F=0)}c=t+""}else{if(!g.test(c=t+""))return v(f,c,a);f.s=45===c.charCodeAt(0)?(c=c.slice(1),-1):1}}for((o=c.indexOf("."))>-1&&(c=c.replace(".","")),(s=c.search(/e/i))>0?(0>o&&(o=s),o+=+c.slice(s+1),c=c.substring(0,s)):0>o&&(o=c.length),s=0;48===c.charCodeAt(s);s++);for(u=c.length;48===c.charCodeAt(--u););if(c=c.slice(s,u+1))if(u=c.length,a&&H&&u>15&&C(F,A,f.s*t),o=o-s-1,o>G)f.c=f.e=null;else if(z>o)f.c=[f.e=0];else{if(f.e=o,f.c=[],s=(o+1)%T,0>o&&(s+=T),u>s){for(s&&f.c.push(+c.slice(0,s)),u-=T;u>s;)f.c.push(+c.slice(s,s+=T));c=c.slice(s),s=T-c.length}else s-=u;for(;s--;c+="0");f.c.push(+c)}else f.c=[f.e=0];F=0}function r(t,r,n,i){var o,s,u,c,f,l,d,_=t.indexOf("."),y=D,v=M;for(37>n&&(t=t.toLowerCase()),_>=0&&(u=X,X=0,t=t.replace(".",""),d=new e(n),f=d.pow(t.length-_),X=u,d.c=h(p(a(f.c),f.e),10,r),d.e=d.c.length),l=h(t,n,r),s=u=l.length;0==l[--u];l.pop());if(!l[0])return"0";if(0>_?--s:(f.c=l,f.e=s,f.s=i,f=B(f,d,y,v,r),l=f.c,c=f.r,s=f.e),o=s+y+1,_=l[o],u=r/2,c=c||0>o||null!=l[o+1],c=4>v?(null!=_||c)&&(0==v||v==(f.s<0?3:2)):_>u||_==u&&(4==v||c||6==v&&1&l[o-1]||v==(f.s<0?8:7)),1>o||!l[0])t=c?p("1",-y):"0";else{if(l.length=o,c)for(--r;++l[--o]>r;)l[o]=0,o||(++s,l.unshift(1));for(u=l.length;!l[--u];);for(_=0,t="";u>=_;t+=x.charAt(l[_++]));t=p(t,s)}return t}function n(t,r,n,i){var o,s,u,c,f;if(n=null!=n&&K(n,0,8,i,E)?0|n:M,!t.c)return t.toString();if(o=t.c[0],u=t.e,null==r)f=a(t.c),f=19==i||24==i&&P>=u?l(f,u):p(f,u);else if(t=L(new e(t),r,n),s=t.e,f=a(t.c),c=f.length,19==i||24==i&&(s>=r||P>=s)){for(;r>c;f+="0",c++);f=l(f,s)}else if(r-=u,f=p(f,s),s+1>c){if(--r>0)for(f+=".";r--;f+="0");}else if(r+=s-c,r>0)for(s+1==c&&(f+=".");r--;f+="0");return t.s<0&&o?"-"+f:f}function i(t,r){var n,i,o=0;for(f(t[0])&&(t=t[0]),n=new e(t[0]);++o<t.length;){if(i=new e(t[o]),!i.s){n=i;break}r.call(n,i)&&(n=i)}return n}function _(t,e,r,n,i){return(e>t||t>r||t!=d(t))&&C(n,(i||"decimal places")+(e>t||t>r?" out of range":" not an integer"),t),!0}function R(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*T-1)>G?t.c=t.e=null:z>r?t.c=[t.e=0]:(t.e=r,t.c=e),t}function C(t,e,r){var n=new Error(["new BigNumber","cmp","config","div","divToInt","eq","gt","gte","lt","lte","minus","mod","plus","precision","random","round","shift","times","toDigits","toExponential","toFixed","toFormat","toFraction","pow","toPrecision","toString","BigNumber"][t]+"() "+e+": "+r);throw n.name="BigNumber Error",F=0,n}function L(t,e,r,n){var i,o,s,a,u,c,f,h=t.c,l=O;if(h){t:{for(i=1,a=h[0];a>=10;a/=10,i++);if(o=e-i,0>o)o+=T,s=e,u=h[c=0],f=u/l[i-s-1]%10|0;else if(c=m((o+1)/T),c>=h.length){if(!n)break t;for(;h.length<=c;h.push(0));u=f=0,i=1,o%=T,s=o-T+1}else{for(u=a=h[c],i=1;a>=10;a/=10,i++);o%=T,s=o-T+i,f=0>s?0:u/l[i-s-1]%10|0}if(n=n||0>e||null!=h[c+1]||(0>s?u:u%l[i-s-1]),n=4>r?(f||n)&&(0==r||r==(t.s<0?3:2)):f>5||5==f&&(4==r||n||6==r&&(o>0?s>0?u/l[i-s]:0:h[c-1])%10&1||r==(t.s<0?8:7)),1>e||!h[0])return h.length=0,n?(e-=t.e+1,h[0]=l[e%T],t.e=-e||0):h[0]=t.e=0,t;if(0==o?(h.length=c,a=1,c--):(h.length=c+1,a=l[T-o],h[c]=s>0?b(u/l[i-s]%l[s])*a:0),n)for(;;){if(0==c){for(o=1,s=h[0];s>=10;s/=10,o++);for(s=h[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(t.e++,h[0]==S&&(h[0]=1));break}if(h[c]+=a,h[c]!=S)break;h[c--]=0,a=1}for(o=h.length;0===h[--o];h.pop());}t.e>G?t.c=t.e=null:t.e<z&&(t.c=[t.e=0])}return t}var B,F=0,N=e.prototype,q=new e(1),D=20,M=4,P=-7,U=21,z=-1e7,G=1e7,H=!0,K=_,V=!1,Y=1,X=100,W={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0};return e.another=o,e.ROUND_UP=0,e.ROUND_DOWN=1,e.ROUND_CEIL=2,e.ROUND_FLOOR=3,e.ROUND_HALF_UP=4,e.ROUND_HALF_DOWN=5,e.ROUND_HALF_EVEN=6,e.ROUND_HALF_CEIL=7,e.ROUND_HALF_FLOOR=8,e.EUCLID=9,e.config=function(){var t,e,r=0,n={},i=arguments,o=i[0],s=o&&"object"==typeof o?function(){return o.hasOwnProperty(e)?null!=(t=o[e]):void 0}:function(){return i.length>r?null!=(t=i[r++]):void 0};return s(e="DECIMAL_PLACES")&&K(t,0,j,2,e)&&(D=0|t),n[e]=D,s(e="ROUNDING_MODE")&&K(t,0,8,2,e)&&(M=0|t),n[e]=M,s(e="EXPONENTIAL_AT")&&(f(t)?K(t[0],-j,0,2,e)&&K(t[1],0,j,2,e)&&(P=0|t[0],U=0|t[1]):K(t,-j,j,2,e)&&(P=-(U=0|(0>t?-t:t)))),n[e]=[P,U],s(e="RANGE")&&(f(t)?K(t[0],-j,-1,2,e)&&K(t[1],1,j,2,e)&&(z=0|t[0],G=0|t[1]):K(t,-j,j,2,e)&&(0|t?z=-(G=0|(0>t?-t:t)):H&&C(2,e+" cannot be zero",t))),n[e]=[z,G],s(e="ERRORS")&&(t===!!t||1===t||0===t?(F=0,K=(H=!!t)?_:c):H&&C(2,e+w,t)),n[e]=H,s(e="CRYPTO")&&(t===!!t||1===t||0===t?(V=!(!t||!y||"object"!=typeof y),t&&!V&&H&&C(2,"crypto unavailable",y)):H&&C(2,e+w,t)),n[e]=V,s(e="MODULO_MODE")&&K(t,0,9,2,e)&&(Y=0|t),n[e]=Y,s(e="POW_PRECISION")&&K(t,0,j,2,e)&&(X=0|t),n[e]=X,s(e="FORMAT")&&("object"==typeof t?W=t:H&&C(2,e+" not an object",t)),n[e]=W,n},e.max=function(){return i(arguments,N.lt)},e.min=function(){return i(arguments,N.gt)},e.random=function(){var t=9007199254740992,r=Math.random()*t&2097151?function(){return b(Math.random()*t)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(t){var n,i,o,s,a,u=0,c=[],f=new e(q);if(t=null!=t&&K(t,0,j,14)?0|t:D,s=m(t/T),V)if(y&&y.getRandomValues){for(n=y.getRandomValues(new Uint32Array(s*=2));s>u;)a=131072*n[u]+(n[u+1]>>>11),a>=9e15?(i=y.getRandomValues(new Uint32Array(2)),n[u]=i[0],n[u+1]=i[1]):(c.push(a%1e14),u+=2);u=s/2}else if(y&&y.randomBytes){for(n=y.randomBytes(s*=7);s>u;)a=281474976710656*(31&n[u])+1099511627776*n[u+1]+4294967296*n[u+2]+16777216*n[u+3]+(n[u+4]<<16)+(n[u+5]<<8)+n[u+6],a>=9e15?y.randomBytes(7).copy(n,u):(c.push(a%1e14),u+=7);u=s/7}else H&&C(14,"crypto unavailable",y);if(!u)for(;s>u;)a=r(),9e15>a&&(c[u++]=a%1e14);for(s=c[--u],t%=T,s&&t&&(a=O[T-t],c[u]=b(s/a)*a);0===c[u];c.pop(),u--);if(0>u)c=[o=0];else{for(o=-1;0===c[0];c.shift(),o-=T);for(u=1,a=c[0];a>=10;a/=10,u++);T>u&&(o-=T-u)}return f.e=o,f.c=c,f}}(),B=function(){function t(t,e,r){var n,i,o,s,a=0,u=t.length,c=e%I,f=e/I|0;for(t=t.slice();u--;)o=t[u]%I,s=t[u]/I|0,n=f*o+s*c,i=c*o+n%I*I+a,a=(i/r|0)+(n/I|0)+f*s,t[u]=i%r;return a&&t.unshift(a),t}function r(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;r>i;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function n(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.shift());}return function(i,o,a,u,c){var f,h,l,p,d,_,y,v,g,m,w,E,A,x,k,O,I,j=i.s==o.s?1:-1,R=i.c,C=o.c;if(!(R&&R[0]&&C&&C[0]))return new e(i.s&&o.s&&(R?!C||R[0]!=C[0]:C)?R&&0==R[0]||!C?0*j:j/0:0/0);for(v=new e(j),g=v.c=[],h=i.e-o.e,j=a+h+1,c||(c=S,h=s(i.e/T)-s(o.e/T),j=j/T|0),l=0;C[l]==(R[l]||0);l++);if(C[l]>(R[l]||0)&&h--,0>j)g.push(1),p=!0;else{for(x=R.length,O=C.length,l=0,j+=2,d=b(c/(C[0]+1)),d>1&&(C=t(C,d,c),R=t(R,d,c),O=C.length,x=R.length),A=O,m=R.slice(0,O),w=m.length;O>w;m[w++]=0);I=C.slice(),I.unshift(0),k=C[0],C[1]>=c/2&&k++;do{if(d=0,f=r(C,m,O,w),0>f){if(E=m[0],O!=w&&(E=E*c+(m[1]||0)),d=b(E/k),d>1)for(d>=c&&(d=c-1),_=t(C,d,c),y=_.length,w=m.length;1==r(_,m,y,w);)d--,n(_,y>O?I:C,y,c),y=_.length,f=1;else 0==d&&(f=d=1),_=C.slice(),y=_.length;if(w>y&&_.unshift(0),n(m,_,w,c),w=m.length,-1==f)for(;r(C,m,O,w)<1;)d++,n(m,w>O?I:C,w,c),w=m.length}else 0===f&&(d++,m=[0]);g[l++]=d,m[0]?m[w++]=R[A]||0:(m=[R[A]],w=1)}while((A++<x||null!=m[0])&&j--);p=null!=m[0],g[0]||g.shift()}if(c==S){for(l=1,j=g[0];j>=10;j/=10,l++);L(v,a+(v.e=l+h*T-1)+1,u,p)}else v.e=h,v.r=+p;return v}}(),v=function(){var t=/^(-?)0([xbo])(?=\w[\w.]*$)/i,r=/^([^.]+)\.$/,n=/^\.([^.]+)$/,i=/^-?(Infinity|NaN)$/,o=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(s,a,u,c){var f,h=u?a:a.replace(o,"");if(i.test(h))s.s=isNaN(h)?null:0>h?-1:1;else{if(!u&&(h=h.replace(t,function(t,e,r){return f="x"==(r=r.toLowerCase())?16:"b"==r?2:8,c&&c!=f?t:e}),c&&(f=c,h=h.replace(r,"$1").replace(n,"0.$1")),a!=h))return new e(h,f);H&&C(F,"not a"+(c?" base "+c:"")+" number",a),s.s=null}s.c=s.e=null,F=0}}(),N.absoluteValue=N.abs=function(){var t=new e(this);return t.s<0&&(t.s=1),t},N.ceil=function(){return L(new e(this),this.e+1,2)},N.comparedTo=N.cmp=function(t,r){return F=1,u(this,new e(t,r))},N.decimalPlaces=N.dp=function(){var t,e,r=this.c;if(!r)return null;if(t=((e=r.length-1)-s(this.e/T))*T,e=r[e])for(;e%10==0;e/=10,t--);return 0>t&&(t=0),t},N.dividedBy=N.div=function(t,r){return F=3,B(this,new e(t,r),D,M)},N.dividedToIntegerBy=N.divToInt=function(t,r){return F=4,B(this,new e(t,r),0,1)},N.equals=N.eq=function(t,r){return F=5,0===u(this,new e(t,r))},N.floor=function(){return L(new e(this),this.e+1,3)},N.greaterThan=N.gt=function(t,r){return F=6,u(this,new e(t,r))>0},N.greaterThanOrEqualTo=N.gte=function(t,r){return F=7,1===(r=u(this,new e(t,r)))||0===r},N.isFinite=function(){return!!this.c},N.isInteger=N.isInt=function(){return!!this.c&&s(this.e/T)>this.c.length-2},N.isNaN=function(){return!this.s},N.isNegative=N.isNeg=function(){return this.s<0},N.isZero=function(){return!!this.c&&0==this.c[0]},N.lessThan=N.lt=function(t,r){return F=8,u(this,new e(t,r))<0},N.lessThanOrEqualTo=N.lte=function(t,r){return F=9,-1===(r=u(this,new e(t,r)))||0===r},N.minus=N.sub=function(t,r){var n,i,o,a,u=this,c=u.s;if(F=10,t=new e(t,r),r=t.s,!c||!r)return new e(0/0);if(c!=r)return t.s=-r,u.plus(t);var f=u.e/T,h=t.e/T,l=u.c,p=t.c;if(!f||!h){if(!l||!p)return l?(t.s=-r,t):new e(p?u:0/0);if(!l[0]||!p[0])return p[0]?(t.s=-r,t):new e(l[0]?u:3==M?-0:0)}if(f=s(f),h=s(h),l=l.slice(),c=f-h){for((a=0>c)?(c=-c,o=l):(h=f,o=p),o.reverse(),r=c;r--;o.push(0));o.reverse()}else for(i=(a=(c=l.length)<(r=p.length))?c:r,c=r=0;i>r;r++)if(l[r]!=p[r]){a=l[r]<p[r];break}if(a&&(o=l,l=p,p=o,t.s=-t.s),r=(i=p.length)-(n=l.length),r>0)for(;r--;l[n++]=0);for(r=S-1;i>c;){if(l[--i]<p[i]){for(n=i;n&&!l[--n];l[n]=r);--l[n],l[i]+=S}l[i]-=p[i]}for(;0==l[0];l.shift(),--h);return l[0]?R(t,l,h):(t.s=3==M?-1:1,t.c=[t.e=0],t)},N.modulo=N.mod=function(t,r){var n,i,o=this;return F=11,t=new e(t,r),!o.c||!t.s||t.c&&!t.c[0]?new e(0/0):!t.c||o.c&&!o.c[0]?new e(o):(9==Y?(i=t.s,t.s=1,n=B(o,t,0,3),t.s=i,n.s*=i):n=B(o,t,0,Y),o.minus(n.times(t)))},N.negated=N.neg=function(){var t=new e(this);return t.s=-t.s||null,t},N.plus=N.add=function(t,r){var n,i=this,o=i.s;if(F=12,t=new e(t,r),r=t.s,!o||!r)return new e(0/0);if(o!=r)return t.s=-r,i.minus(t);var a=i.e/T,u=t.e/T,c=i.c,f=t.c;if(!a||!u){if(!c||!f)return new e(o/0);if(!c[0]||!f[0])return f[0]?t:new e(c[0]?i:0*o)}if(a=s(a),u=s(u),c=c.slice(),o=a-u){for(o>0?(u=a,n=f):(o=-o,n=c),n.reverse();o--;n.push(0));n.reverse()}for(o=c.length,r=f.length,0>o-r&&(n=f,f=c,c=n,r=o),o=0;r;)o=(c[--r]=c[r]+f[r]+o)/S|0,c[r]%=S;return o&&(c.unshift(o),++u),R(t,c,u)},N.precision=N.sd=function(t){var e,r,n=this,i=n.c;if(null!=t&&t!==!!t&&1!==t&&0!==t&&(H&&C(13,"argument"+w,t),t!=!!t&&(t=null)),!i)return null;if(r=i.length-1,e=r*T+1,r=i[r]){for(;r%10==0;r/=10,e--);for(r=i[0];r>=10;r/=10,e++);}return t&&n.e+1>e&&(e=n.e+1),e},N.round=function(t,r){var n=new e(this);return(null==t||K(t,0,j,15))&&L(n,~~t+this.e+1,null!=r&&K(r,0,8,15,E)?0|r:M),n},N.shift=function(t){var r=this;return K(t,-k,k,16,"argument")?r.times("1e"+d(t)):new e(r.c&&r.c[0]&&(-k>t||t>k)?r.s*(0>t?0:1/0):r)},N.squareRoot=N.sqrt=function(){var t,r,n,i,o,u=this,c=u.c,f=u.s,h=u.e,l=D+4,p=new e("0.5");if(1!==f||!c||!c[0])return new e(!f||0>f&&(!c||c[0])?0/0:c?u:1/0);if(f=Math.sqrt(+u),0==f||f==1/0?(r=a(c),(r.length+h)%2==0&&(r+="0"),f=Math.sqrt(r),h=s((h+1)/2)-(0>h||h%2),f==1/0?r="1e"+h:(r=f.toExponential(),r=r.slice(0,r.indexOf("e")+1)+h),n=new e(r)):n=new e(f+""),n.c[0])for(h=n.e,f=h+l,3>f&&(f=0);;)if(o=n,n=p.times(o.plus(B(u,o,l,1))),a(o.c).slice(0,f)===(r=a(n.c)).slice(0,f)){if(n.e<h&&--f,r=r.slice(f-3,f+1),"9999"!=r&&(i||"4999"!=r)){(!+r||!+r.slice(1)&&"5"==r.charAt(0))&&(L(n,n.e+D+2,1),t=!n.times(n).eq(u));break}if(!i&&(L(o,o.e+D+2,0),o.times(o).eq(u))){n=o;break}l+=4,f+=4,i=1}return L(n,n.e+D+1,M,t)},N.times=N.mul=function(t,r){var n,i,o,a,u,c,f,h,l,p,d,_,y,v,g,m=this,b=m.c,w=(F=17,t=new e(t,r)).c;if(!(b&&w&&b[0]&&w[0]))return!m.s||!t.s||b&&!b[0]&&!w||w&&!w[0]&&!b?t.c=t.e=t.s=null:(t.s*=m.s,b&&w?(t.c=[0],t.e=0):t.c=t.e=null),t;for(i=s(m.e/T)+s(t.e/T),t.s*=m.s,f=b.length,p=w.length,p>f&&(y=b,b=w,w=y,o=f,f=p,p=o),o=f+p,y=[];o--;y.push(0));for(v=S,g=I,o=p;--o>=0;){for(n=0,d=w[o]%g,_=w[o]/g|0,u=f,a=o+u;a>o;)h=b[--u]%g,l=b[u]/g|0,c=_*h+l*d,h=d*h+c%g*g+y[a]+n,n=(h/v|0)+(c/g|0)+_*l,y[a--]=h%v;
y[a]=n}return n?++i:y.shift(),R(t,y,i)},N.toDigits=function(t,r){var n=new e(this);return t=null!=t&&K(t,1,j,18,"precision")?0|t:null,r=null!=r&&K(r,0,8,18,E)?0|r:M,t?L(n,t,r):n},N.toExponential=function(t,e){return n(this,null!=t&&K(t,0,j,19)?~~t+1:null,e,19)},N.toFixed=function(t,e){return n(this,null!=t&&K(t,0,j,20)?~~t+this.e+1:null,e,20)},N.toFormat=function(t,e){var r=n(this,null!=t&&K(t,0,j,21)?~~t+this.e+1:null,e,21);if(this.c){var i,o=r.split("."),s=+W.groupSize,a=+W.secondaryGroupSize,u=W.groupSeparator,c=o[0],f=o[1],h=this.s<0,l=h?c.slice(1):c,p=l.length;if(a&&(i=s,s=a,a=i,p-=i),s>0&&p>0){for(i=p%s||s,c=l.substr(0,i);p>i;i+=s)c+=u+l.substr(i,s);a>0&&(c+=u+l.slice(i)),h&&(c="-"+c)}r=f?c+W.decimalSeparator+((a=+W.fractionGroupSize)?f.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+W.fractionGroupSeparator):f):c}return r},N.toFraction=function(t){var r,n,i,o,s,u,c,f,h,l=H,p=this,d=p.c,_=new e(q),y=n=new e(q),v=c=new e(q);if(null!=t&&(H=!1,u=new e(t),H=l,(!(l=u.isInt())||u.lt(q))&&(H&&C(22,"max denominator "+(l?"out of range":"not an integer"),t),t=!l&&u.c&&L(u,u.e+1,1).gte(q)?u:null)),!d)return p.toString();for(h=a(d),o=_.e=h.length-p.e-1,_.c[0]=O[(s=o%T)<0?T+s:s],t=!t||u.cmp(_)>0?o>0?_:y:u,s=G,G=1/0,u=new e(h),c.c[0]=0;f=B(u,_,0,1),i=n.plus(f.times(v)),1!=i.cmp(t);)n=v,v=i,y=c.plus(f.times(i=y)),c=i,_=u.minus(f.times(i=_)),u=i;return i=B(t.minus(n),v,0,1),c=c.plus(i.times(y)),n=n.plus(i.times(v)),c.s=y.s=p.s,o*=2,r=B(y,v,o,M).minus(p).abs().cmp(B(c,n,o,M).minus(p).abs())<1?[y.toString(),v.toString()]:[c.toString(),n.toString()],G=s,r},N.toNumber=function(){var t=this;return+t||(t.s?0*t.s:0/0)},N.toPower=N.pow=function(t){var r,n,i=b(0>t?-t:+t),o=this;if(!K(t,-k,k,23,"exponent")&&(!isFinite(t)||i>k&&(t/=0)||parseFloat(t)!=t&&!(t=0/0)))return new e(Math.pow(+o,t));for(r=X?m(X/T+2):0,n=new e(q);;){if(i%2){if(n=n.times(o),!n.c)break;r&&n.c.length>r&&(n.c.length=r)}if(i=b(i/2),!i)break;o=o.times(o),r&&o.c&&o.c.length>r&&(o.c.length=r)}return 0>t&&(n=q.div(n)),r?L(n,X,M):n},N.toPrecision=function(t,e){return n(this,null!=t&&K(t,1,j,24,"precision")?0|t:null,e,24)},N.toString=function(t){var e,n=this,i=n.s,o=n.e;return null===o?i?(e="Infinity",0>i&&(e="-"+e)):e="NaN":(e=a(n.c),e=null!=t&&K(t,2,64,25,"base")?r(p(e,o),0|t,10,i):P>=o||o>=U?l(e,o):p(e,o),0>i&&n.c[0]&&(e="-"+e)),e},N.truncated=N.trunc=function(){return L(new e(this),this.e+1,1)},N.valueOf=N.toJSON=function(){return this.toString()},null!=t&&e.config(t),e}function s(t){var e=0|t;return t>0||t===e?e:e-1}function a(t){for(var e,r,n=1,i=t.length,o=t[0]+"";i>n;){for(e=t[n++]+"",r=T-e.length;r--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function u(t,e){var r,n,i=t.c,o=e.c,s=t.s,a=e.s,u=t.e,c=e.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=0>s,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;a>s;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function c(t,e,r){return(t=d(t))>=e&&r>=t}function f(t){return"[object Array]"==Object.prototype.toString.call(t)}function h(t,e,r){for(var n,i,o=[0],s=0,a=t.length;a>s;){for(i=o.length;i--;o[i]*=e);for(o[n=0]+=x.indexOf(t.charAt(s++));n<o.length;n++)o[n]>r-1&&(null==o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/r|0,o[n]%=r)}return o.reverse()}function l(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(0>e?"e":"e+")+e}function p(t,e){var r,n;if(0>e){for(n="0.";++e;n+="0");t=n+t}else if(r=t.length,++e>r){for(n="0",e-=r;--e;n+="0");t+=n}else r>e&&(t=t.slice(0,e)+"."+t.slice(e));return t}function d(t){return t=parseFloat(t),0>t?m(t):b(t)}var _,y,v,g=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,m=Math.ceil,b=Math.floor,w=" not a boolean or binary digit",E="rounding mode",A="number type has more than 15 significant digits",x="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",S=1e14,T=14,k=9007199254740991,O=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],I=1e7,j=1e9;_=o(),n=function(){return _}.call(e,r,e,t),!(void 0!==n&&(t.exports=n))}(this)},function(t,e,r){"use strict";function n(t,e){a(!s.isNull(t)&&!isNaN(t),e)}function i(t,e){a(t),a.strictEqual(typeof t,"object",e),a.strictEqual(typeof t.TakerPays,"object",e),n(t.TakerGets,e)}function o(t,e,r,n){this._currencyGets=t,this._currencyPays=e,this.legOneOffers=s.cloneDeep(r),this.legTwoOffers=s.cloneDeep(n),this._ownerFundsLeftover={}}var s=r(40),a=r(39),u=r(9).UInt160,c=r(3).Amount,f=r(48);o.prototype.calculate=function(){var t=0,e=0,r=[];for(this.clearOwnerFundsLeftover();this.legOneOffers[t]&&this.legTwoOffers[e];){var n,i=this.legOneOffers[t],o=this.legTwoOffers[e],s=this.getLeftoverOwnerFunds(i.Account);i.Account===o.Account?this.unclampLegOneOwnerFunds(i):i.is_fully_funded||s.is_zero()||this.adjustLegOneFundedAmount(i);var a=f.getOfferTakerGetsFunded(i),u=f.getOfferTakerPaysFunded(o);a.is_zero()?t++:u.is_zero()?e++:(a.compareTo(u)>0?(n=this.getAutobridgedOfferWithClampedLegOne(i,o),e++):u.compareTo(a)>0?(n=this.getAutobridgedOfferWithClampedLegTwo(i,o),t++):(n=this.getAutobridgedOfferWithoutClamps(i,o),t++,e++),r.push(n))}return r},o.prototype.getAutobridgedOfferWithClampedLegOne=function(t,e){var r=f.getOfferTakerGetsFunded(t),n=f.getOfferTakerPaysFunded(e),i=f.getOfferQuality(t,this._currencyGets),o=f.getOfferTakerGetsFunded(e),s=n.multiply(i);if(t.Account===e.Account){var a=f.getOfferTakerGets(t),u=a.subtract(n);this.setLegOneTakerGets(t,u),this.clampLegOneOwnerFunds(t)}else{var c=r.subtract(n);this.setLegOneTakerGetsFunded(t,c)}return this.formatAutobridgedOffer(o,s)},o.prototype.getAutobridgedOfferWithClampedLegTwo=function(t,e){var r=f.getOfferTakerGetsFunded(t),n=f.getOfferTakerPaysFunded(e),i=f.getOfferQuality(e,this._currencyGets),o=r.divide(i),s=f.getOfferTakerPaysFunded(t);return e.taker_gets_funded=f.getOfferTakerGetsFunded(e).subtract(o).to_text(),e.taker_pays_funded=n.subtract(r).to_text(),this.formatAutobridgedOffer(o,s)},o.prototype.getAutobridgedOfferWithoutClamps=function(t,e){var r=f.getOfferTakerGetsFunded(e),n=f.getOfferTakerPaysFunded(t);return this.formatAutobridgedOffer(r,n)},o.prototype.clearOwnerFundsLeftover=function(){this._ownerFundsLeftover={}},o.prototype.resetOwnerFundsLeftover=function(t){return a(u.is_valid(t),"Account is invalid"),this._ownerFundsLeftover[t]=f.normalizeAmount("0"),this._ownerFundsLeftover[t]},o.prototype.getLeftoverOwnerFunds=function(t){a(u.is_valid(t),"Account is invalid");var e=this._ownerFundsLeftover[t];return e||(e=f.normalizeAmount("0")),e},o.prototype.addLeftoverOwnerFunds=function(t,e){return a(u.is_valid(t),"Account is invalid"),a(e instanceof c,"Amount is invalid"),this._ownerFundsLeftover[t]=this.getLeftoverOwnerFunds(t).add(e),this._ownerFundsLeftover[t]},o.prototype.setLeftoverOwnerFunds=function(t,e){a(u.is_valid(t),"Account is invalid"),a(e instanceof c,"Amount is invalid"),this._ownerFundsLeftover[t]=e},o.prototype.formatAutobridgedOffer=function(t,e){a(t instanceof c,"Autobridged taker gets is invalid"),a(e instanceof c,"Autobridged taker pays is invalid");var r={},n=e.divide(t);return r.TakerGets={value:t.to_text(),currency:this._currencyGets.to_hex(),issuer:this._issuerGets},r.TakerPays={value:e.to_text(),currency:this._currencyPays.to_hex(),issuer:this._issuerPays},r.quality=n.to_text(),r.taker_gets_funded=r.TakerGets.value,r.taker_pays_funded=r.TakerPays.value,r.autobridged=!0,r.BookDirectory=f.convertOfferQualityToHex(n),r},o.prototype.unclampLegOneOwnerFunds=function(t){i(t,"Leg one offer is invalid"),t.initTakerGetsFunded=f.getOfferTakerGetsFunded(t),this.setLegOneTakerGetsFunded(t,f.getOfferTakerGets(t))},o.prototype.clampLegOneOwnerFunds=function(t){i(t,"Leg one offer is invalid");var e=f.getOfferTakerGets(t);if(e.compareTo(t.initTakerGetsFunded)>0)this.setLegOneTakerGetsFunded(t,t.initTakerGetsFunded);else{var r=t.initTakerGetsFunded.subtract(e);this.setLegOneTakerGetsFunded(t,e),this.addLeftoverOwnerFunds(t.Account,r)}},o.prototype.adjustLegOneFundedAmount=function(t){i(t,"Leg one offer is invalid"),a(!t.is_fully_funded,"Leg one offer cannot be fully funded");var e=f.getOfferTakerGetsFunded(t).add(this.getLeftoverOwnerFunds(t.Account));if(e.compareTo(f.getOfferTakerGets(t))>=0){var r=f.getOfferTakerGets(t),n=e.subtract(r);this.setLegOneTakerGetsFunded(t,r),this.setLeftoverOwnerFunds(t.Account,n)}else this.setLegOneTakerGetsFunded(t,e),this.resetOwnerFundsLeftover(t.Account)},o.prototype.setLegOneTakerGetsFunded=function(t,e){i(t,"Leg one offer is invalid"),a(e instanceof c,"Taker gets funded is invalid"),t.taker_gets_funded=e.to_text(),t.taker_pays_funded=e.multiply(f.getOfferQuality(t,this._currencyGets)).to_text(),t.taker_gets_funded===t.TakerGets.value&&(t.is_fully_funded=!0)},o.prototype.setLegOneTakerGets=function(t,e){i(t,"Leg one offer is invalid"),a(e instanceof c,"Taker gets funded is invalid");var r=f.getOfferQuality(t,this._currencyGets);t.TakerGets=e.to_text(),t.TakerPays=e.multiply(r)},t.exports=o},function(t,e,r){"use strict";function n(t,e){o(!i.isNull(t)&&!isNaN(t),e)}var i=r(40),o=r(39),s=r(13).SerializedObject,a=r(23),u=r(3).Amount,c="/000/rrrrrrrrrrrrrrrrrrrrrhoLvTp",f={};f.getOfferTakerGetsFunded=function(t){return n(t.taker_gets_funded,"Taker gets funded is invalid"),u.from_json(t.taker_gets_funded+c)},f.getOfferTakerPaysFunded=function(t){return n(t.taker_pays_funded,"Taker gets funded is invalid"),u.from_json(t.taker_pays_funded+c)},f.getOfferTakerGets=function(t){return o(typeof t,"object","Offer is invalid"),u.from_json(t.TakerGets+c)},f.getOfferQuality=function(t,e){var r;return r=e.has_interest()?u.from_json(t.TakerPays).ratio_human(t.TakerGets,{reference_date:new Date}):u.from_json(t.quality+c)},f.convertOfferQualityToHex=function(t){o(t instanceof u,"Quality is not an amount");var e=new s;return a.Quality.serialize(e,t.to_text()+c),e.to_hex()},f.normalizeAmount=function(t){return u.from_json(t+c)},t.exports=f},function(t){t.exports=function(t){var e=t.sjcl,r=function(){var t={ripple:"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"},n=function(t){return e.codec.bytes.fromBits(e.hash.sha256.hash(e.codec.bytes.toBits(t)))};return{encode_base:function(r,n){for(var i=t[n||"ripple"],o=new e.bn(i.length),s=e.bn.fromBits(e.codec.bytes.toBits(r)),a=[];s.greaterEquals(o);){var u=s.mod(o);a.push(i[u.limbs[0]]),s=s.div(o)}a.push(i[s.limbs[0]]);for(var c=0;c!=r.length&&!r[c];c+=1)a.push(i[0]);return a.reverse().join("")},decode_base:function(r,n){for(var i,o=t[n||"ripple"],s=new e.bn(o.length),a=new e.bn(0);i!=r.length&&r[i]===o[0];)i+=1;for(i=0;i!=r.length;i+=1){var u=o.indexOf(r[i]);if(0>u)return null;a=a.mul(s).addM(u)}for(var c=e.codec.bytes.fromBits(a.toBits()).reverse();0===c[c.length-1];)c.pop();for(i=0;r[i]===o[0];i++)c.push(0);return c.reverse(),c},encode_base_check:function(t,e,i){var o=[].concat(t,e),s=n(n(o)).slice(0,4);return r.encode_base([].concat(o,s),i)},decode_base_check:function(t,e,i){var o=r.decode_base(e,i);if(!o||o[0]!==t||o.length<5)return 0/0;var s,a=n(n(o.slice(0,-4))).slice(0,4),u=o.slice(-4);for(s=0;4!=s;s+=1)if(a[s]!==u[s])return 0/0;return o.slice(1,-4)}}}();return r}},function(t,e,r){t.exports=function(e){function n(t){this.value=t}var i=e.sjcl,o=r(49)({sjcl:i});return n.fromBytes=function(t){return new n(o.encode_base_check(33,t))},n.getRandom=function(){if("object"==typeof window&&window.crypto){var e=new Uint32Array(32);window.crypto.getRandomValues(e),i.random.addEntropy(e,1024,"crypto.getRandomValues")}else{if("object"!=typeof t||!t.exports)throw new Error("No secure source of entropy available");var e=r(53).randomBytes(128);e=new Uint32Array(new Uint8Array(e).buffer),i.random.addEntropy(e,1024,"crypto.randomBytes")}var o=6,s=i.random.randomWords(4,o),a=i.codec.bytes.fromBits(s);return n.fromBytes(a)},n}},function(t,e,r){t.exports=function(t){function e(t){return i.hash.ripemd160.hash(i.hash.sha256.hash(t))}function n(t){this.value=t}var i=t.sjcl,o=r(49)({sjcl:i});return n.fromPublicKey=function(t){var r=i.codec.bytes.fromBits(e(i.codec.bytes.toBits(t.toBytesCompressed())));return new this(o.encode_base_check(0,r))},n}},function(t){t.exports=function(t){function e(t){if(!(t instanceof r.ecc.point))throw new Error("eccPoint must be a sjcl.ecc.point");this.value=t}var r=t.sjcl;return e.fromPrivateGenerator=function(t){return new this(r.ecc.curves.c256.G.mult(t))},e.prototype={toString:function(){return this.value.toString()}},e}},function(t,e,r){(function(t){function n(){var t=[].slice.call(arguments).join(" ");throw new Error([t,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(t,e){for(var r in t)e(t[r],r)}var o=r(64);e.createHash=r(65),e.createHmac=r(66),e.randomBytes=function(e,r){if(!r||!r.call)return new t(o(e));try{r.call(this,void 0,new t(o(e)))}catch(n){r(n)}},e.getHashes=function(){return["sha1","sha256","sha512","md5","rmd160"]};var s=r(67)(e);e.pbkdf2=s.pbkdf2,e.pbkdf2Sync=s.pbkdf2Sync,i(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman"],function(t){e[t]=function(){n("sorry,",t,"is not implemented yet")}})}).call(e,r(42).Buffer)},function(t){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t){function e(){if(!o){o=!0;for(var t,e=i.length;e;){t=i,i=[];for(var r=-1;++r<e;)t[r]();e=i.length}o=!1}}function r(){}var n=t.exports={},i=[],o=!1;n.nextTick=function(t){i.push(t),o||setTimeout(e,0)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=r,n.addListener=r,n.once=r,n.off=r,n.removeListener=r,n.removeAllListeners=r,n.emit=r,n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(t,e,r){var n;(function(t,i){!function(o){function s(t){throw RangeError(C[t])}function a(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function u(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]),t=t.replace(R,".");var i=t.split("."),o=a(i,e).join(".");return n+o}function c(t){for(var e,r,n=[],i=0,o=t.length;o>i;)e=t.charCodeAt(i++),e>=55296&&56319>=e&&o>i?(r=t.charCodeAt(i++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--)):n.push(e);return n}function f(t){return a(t,function(t){var e="";return t>65535&&(t-=65536,e+=F(t>>>10&1023|55296),t=56320|1023&t),e+=F(t)}).join("")}function h(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:w}function l(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function p(t,e,r){var n=0;for(t=r?B(t/S):t>>1,t+=B(t/e);t>L*A>>1;n+=w)t=B(t/L);return B(n+(L+1)*t/(t+x))}function d(t){var e,r,n,i,o,a,u,c,l,d,_=[],y=t.length,v=0,g=k,m=T;for(r=t.lastIndexOf(O),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&s("not-basic"),_.push(t.charCodeAt(n));for(i=r>0?r+1:0;y>i;){for(o=v,a=1,u=w;i>=y&&s("invalid-input"),c=h(t.charCodeAt(i++)),(c>=w||c>B((b-v)/a))&&s("overflow"),v+=c*a,l=m>=u?E:u>=m+A?A:u-m,!(l>c);u+=w)d=w-l,a>B(b/d)&&s("overflow"),a*=d;e=_.length+1,m=p(v-o,e,0==o),B(v/e)>b-g&&s("overflow"),g+=B(v/e),v%=e,_.splice(v++,0,g)}return f(_)}function _(t){var e,r,n,i,o,a,u,f,h,d,_,y,v,g,m,x=[];for(t=c(t),y=t.length,e=k,r=0,o=T,a=0;y>a;++a)_=t[a],128>_&&x.push(F(_));for(n=i=x.length,i&&x.push(O);y>n;){for(u=b,a=0;y>a;++a)_=t[a],_>=e&&u>_&&(u=_);for(v=n+1,u-e>B((b-r)/v)&&s("overflow"),r+=(u-e)*v,e=u,a=0;y>a;++a)if(_=t[a],e>_&&++r>b&&s("overflow"),_==e){for(f=r,h=w;d=o>=h?E:h>=o+A?A:h-o,!(d>f);h+=w)m=f-d,g=w-d,x.push(F(l(d+m%g,0))),f=B(m/g);x.push(F(l(f,0))),o=p(r,v,n==i),r=0,++n}++r,++e}return x.join("")}function y(t){return u(t,function(t){return I.test(t)?d(t.slice(4).toLowerCase()):t})}function v(t){return u(t,function(t){return j.test(t)?"xn--"+_(t):t})}var g=("object"==typeof e&&e&&!e.nodeType&&e,"object"==typeof t&&t&&!t.nodeType&&t,"object"==typeof i&&i);(g.global===g||g.window===g||g.self===g)&&(o=g);var m,b=2147483647,w=36,E=1,A=26,x=38,S=700,T=72,k=128,O="-",I=/^xn--/,j=/[^\x20-\x7E]/,R=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=w-E,B=Math.floor,F=String.fromCharCode;m={version:"1.3.2",ucs2:{decode:c,encode:f},decode:d,encode:_,toASCII:v,toUnicode:y},n=function(){return m}.call(e,r,e,t),!(void 0!==n&&(t.exports=n))}(this)}).call(e,r(57)(t),function(){return this}())},function(t){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?0/0:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,_=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*_}},function(t){var e=Array.isArray,r=Object.prototype.toString;t.exports=e||function(t){return!!t&&"[object Array]"==r.call(t)}},function(t,e,r){"use strict";e.decode=e.parse=r(68),e.encode=e.stringify=r(69)},function(t,e,r){(function(t,n){function i(t,e){this._id=t,this._clearFn=e}var o=r(55).nextTick,s=Function.prototype.apply,a=Array.prototype.slice,u={},c=0;e.setTimeout=function(){return new i(s.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new i(s.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var r=c++,n=arguments.length<2?!1:a.call(arguments,1);return u[r]=!0,o(function(){u[r]&&(n?t.apply(null,n):t.call(null),e.clearImmediate(r))}),r},e.clearImmediate="function"==typeof n?n:function(t){delete u[t]}}).call(e,r(61).setImmediate,r(61).clearImmediate)},function(t){t.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===h?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function n(t){function r(t){c[h++]=t}var n,i,s,a,u,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var h=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),c}function i(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=n(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),h="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i}(e)},function(t,e,r){(function(e,n){!function(){var i=("undefined"==typeof window?e:window)||{};_crypto=i.crypto||i.msCrypto||r(70),t.exports=function(t){if(_crypto.getRandomValues){var e=new n(t);return _crypto.getRandomValues(e),e}if(_crypto.randomBytes)return _crypto.randomBytes(t);throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}}()}).call(e,function(){return this}(),r(42).Buffer)},function(t,e,r){(function(e){function n(t){return function(){var r=[],n={update:function(t,n){return e.isBuffer(t)||(t=new e(t,n)),r.push(t),this},digest:function(n){var i=e.concat(r),o=t(i);return r=null,n?o.toString(n):o}};return n}}var i=r(72),o=n(r(71)),s=n(r(74));t.exports=function(t){return"md5"===t?new o:"rmd160"===t?new s:i(t)}}).call(e,r(42).Buffer)},function(t,e,r){(function(e){function n(t,r){if(!(this instanceof n))return new n(t,r);this._opad=u,this._alg=t;var s="sha512"===t?128:64;r=this._key=e.isBuffer(r)?r:new e(r),r.length>s?r=i(t).update(r).digest():r.length<s&&(r=e.concat([r,o],s));for(var a=this._ipad=new e(s),u=this._opad=new e(s),c=0;s>c;c++)a[c]=54^r[c],u[c]=92^r[c];this._hash=i(t).update(a)}var i=r(65),o=new e(128);o.fill(0),t.exports=n,n.prototype.update=function(t,e){return this._hash.update(t,e),this},n.prototype.digest=function(t){var e=this._hash.digest();return i(this._alg).update(this._opad).update(e).digest(t)}}).call(e,r(42).Buffer)},function(t,e,r){var n=r(73);t.exports=function(t,e){e=e||{};var r=n(t);return e.pbkdf2=r.pbkdf2,e.pbkdf2Sync=r.pbkdf2Sync,e}},function(t){"use strict";function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,r,n,i){r=r||"&",n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var s=/\+/g;t=t.split(r);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var u=t.length;a>0&&u>a&&(u=a);for(var c=0;u>c;++c){var f,h,l,p,d=t[c].replace(s,"%20"),_=d.indexOf(n);_>=0?(f=d.substr(0,_),h=d.substr(_+1)):(f=d,h=""),l=decodeURIComponent(f),p=decodeURIComponent(h),e(o,l)?Array.isArray(o[l])?o[l].push(p):o[l]=[o[l],p]:o[l]=p}return o}},function(t){"use strict";var e=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,r,n,i){return r=r||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(i){var o=encodeURIComponent(e(i))+n;return Array.isArray(t[i])?t[i].map(function(t){return o+encodeURIComponent(e(t))}).join(r):o+encodeURIComponent(e(t[i]))}).join(r):i?encodeURIComponent(e(i))+n+encodeURIComponent(e(t)):""}},function(){},function(t,e,r){function n(t,e){t[e>>5]|=128<<e%32,t[(e+64>>>9<<4)+14]=e;for(var r=1732584193,n=-271733879,i=-1732584194,f=271733878,h=0;h<t.length;h+=16){var l=r,p=n,d=i,_=f;r=o(r,n,i,f,t[h+0],7,-680876936),f=o(f,r,n,i,t[h+1],12,-389564586),i=o(i,f,r,n,t[h+2],17,606105819),n=o(n,i,f,r,t[h+3],22,-1044525330),r=o(r,n,i,f,t[h+4],7,-176418897),f=o(f,r,n,i,t[h+5],12,1200080426),i=o(i,f,r,n,t[h+6],17,-1473231341),n=o(n,i,f,r,t[h+7],22,-45705983),r=o(r,n,i,f,t[h+8],7,1770035416),f=o(f,r,n,i,t[h+9],12,-1958414417),i=o(i,f,r,n,t[h+10],17,-42063),n=o(n,i,f,r,t[h+11],22,-1990404162),r=o(r,n,i,f,t[h+12],7,1804603682),f=o(f,r,n,i,t[h+13],12,-40341101),i=o(i,f,r,n,t[h+14],17,-1502002290),n=o(n,i,f,r,t[h+15],22,1236535329),r=s(r,n,i,f,t[h+1],5,-165796510),f=s(f,r,n,i,t[h+6],9,-1069501632),i=s(i,f,r,n,t[h+11],14,643717713),n=s(n,i,f,r,t[h+0],20,-373897302),r=s(r,n,i,f,t[h+5],5,-701558691),f=s(f,r,n,i,t[h+10],9,38016083),i=s(i,f,r,n,t[h+15],14,-660478335),n=s(n,i,f,r,t[h+4],20,-405537848),r=s(r,n,i,f,t[h+9],5,568446438),f=s(f,r,n,i,t[h+14],9,-1019803690),i=s(i,f,r,n,t[h+3],14,-187363961),n=s(n,i,f,r,t[h+8],20,1163531501),r=s(r,n,i,f,t[h+13],5,-1444681467),f=s(f,r,n,i,t[h+2],9,-51403784),i=s(i,f,r,n,t[h+7],14,1735328473),n=s(n,i,f,r,t[h+12],20,-1926607734),r=a(r,n,i,f,t[h+5],4,-378558),f=a(f,r,n,i,t[h+8],11,-2022574463),i=a(i,f,r,n,t[h+11],16,1839030562),n=a(n,i,f,r,t[h+14],23,-35309556),r=a(r,n,i,f,t[h+1],4,-1530992060),f=a(f,r,n,i,t[h+4],11,1272893353),i=a(i,f,r,n,t[h+7],16,-155497632),n=a(n,i,f,r,t[h+10],23,-1094730640),r=a(r,n,i,f,t[h+13],4,681279174),f=a(f,r,n,i,t[h+0],11,-358537222),i=a(i,f,r,n,t[h+3],16,-722521979),n=a(n,i,f,r,t[h+6],23,76029189),r=a(r,n,i,f,t[h+9],4,-640364487),f=a(f,r,n,i,t[h+12],11,-421815835),i=a(i,f,r,n,t[h+15],16,530742520),n=a(n,i,f,r,t[h+2],23,-995338651),r=u(r,n,i,f,t[h+0],6,-198630844),f=u(f,r,n,i,t[h+7],10,1126891415),i=u(i,f,r,n,t[h+14],15,-1416354905),n=u(n,i,f,r,t[h+5],21,-57434055),r=u(r,n,i,f,t[h+12],6,1700485571),f=u(f,r,n,i,t[h+3],10,-1894986606),i=u(i,f,r,n,t[h+10],15,-1051523),n=u(n,i,f,r,t[h+1],21,-2054922799),r=u(r,n,i,f,t[h+8],6,1873313359),f=u(f,r,n,i,t[h+15],10,-30611744),i=u(i,f,r,n,t[h+6],15,-1560198380),n=u(n,i,f,r,t[h+13],21,1309151649),r=u(r,n,i,f,t[h+4],6,-145523070),f=u(f,r,n,i,t[h+11],10,-1120210379),i=u(i,f,r,n,t[h+2],15,718787259),n=u(n,i,f,r,t[h+9],21,-343485551),r=c(r,l),n=c(n,p),i=c(i,d),f=c(f,_)}return Array(r,n,i,f)}function i(t,e,r,n,i,o){return c(f(c(c(e,t),c(n,o)),i),r)}function o(t,e,r,n,o,s,a){return i(e&r|~e&n,t,e,o,s,a)}function s(t,e,r,n,o,s,a){return i(e&n|r&~n,t,e,o,s,a)}function a(t,e,r,n,o,s,a){return i(e^r^n,t,e,o,s,a)}function u(t,e,r,n,o,s,a){return i(r^(e|~n),t,e,o,s,a)}function c(t,e){var r=(65535&t)+(65535&e),n=(t>>16)+(e>>16)+(r>>16);return n<<16|65535&r}function f(t,e){return t<<e|t>>>32-e}var h=r(75);t.exports=function(t){return h.hash(t,n,16)}},function(t,e,r){var e=t.exports=function(t){var r=e[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r},n=r(42).Buffer,i=r(76)(n);e.sha1=r(77)(n,i),e.sha256=r(78)(n,i),e.sha512=r(79)(n,i)},function(t,e,r){(function(e){t.exports=function(t){function r(t,e,r,i,o,s){if("function"==typeof o&&(s=o,o=void 0),"function"!=typeof s)throw new Error("No callback provided to pbkdf2");setTimeout(function(){var a;try{a=n(t,e,r,i,o)}catch(u){return s(u)}s(void 0,a)})}function n(r,n,i,o,s){if("number"!=typeof i)throw new TypeError("Iterations not a number");if(0>i)throw new TypeError("Bad iterations");if("number"!=typeof o)throw new TypeError("Key length not a number");if(0>o)throw new TypeError("Bad key length");s=s||"sha1",e.isBuffer(r)||(r=new e(r)),e.isBuffer(n)||(n=new e(n));var a,u,c,f=1,h=new e(o),l=new e(n.length+4);n.copy(l,0,0,n.length);for(var p=1;f>=p;p++){l.writeUInt32BE(p,n.length);var d=t.createHmac(s,r).update(l).digest();if(!a&&(a=d.length,c=new e(a),f=Math.ceil(o/a),u=o-(f-1)*a,o>(Math.pow(2,32)-1)*a))throw new TypeError("keylen exceeds maximum length");d.copy(c,0,0,a);for(var _=1;i>_;_++){d=t.createHmac(s,r).update(d).digest();for(var y=0;a>y;y++)c[y]^=d[y]}var v=(p-1)*a,g=p==f?u:a;c.copy(h,v,0,g)}return h}return{pbkdf2:r,pbkdf2Sync:n}}}).call(e,r(42).Buffer)},function(t,e,r){(function(e){function r(t,e,r){return t^e^r}function n(t,e,r){return t&e|~t&r}function i(t,e,r){return(t|~e)^r}function o(t,e,r){return t&r|e&~r}function s(t,e,r){return t^(e|~r)}function a(t,e){return t<<e|t>>>32-e}function u(t){var r=[1732584193,4023233417,2562383102,271733878,3285377520];"string"==typeof t&&(t=new e(t,"utf8"));var n=_(t),i=8*t.length,o=8*t.length;n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);for(var s=0;s<n.length;s+=16)v(r,n,s);for(var s=0;5>s;s++){var a=r[s];r[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var u=y(r);return new e(u)}t.exports=u;var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],h=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],l=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],p=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0],_=function(t){for(var e=[],r=0,n=0;r<t.length;r++,n+=8)e[n>>>5]|=t[r]<<24-n%32;return e},y=function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},v=function(t,e,u){for(var _=0;16>_;_++){var y=u+_,v=e[y];e[y]=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8)}var g,m,b,w,E,A,x,S,T,k;A=g=t[0],x=m=t[1],S=b=t[2],T=w=t[3],k=E=t[4];for(var O,_=0;80>_;_+=1)O=g+e[u+c[_]]|0,O+=16>_?r(m,b,w)+p[0]:32>_?n(m,b,w)+p[1]:48>_?i(m,b,w)+p[2]:64>_?o(m,b,w)+p[3]:s(m,b,w)+p[4],O=0|O,O=a(O,h[_]),O=O+E|0,g=E,E=w,w=a(b,10),b=m,m=O,O=A+e[u+f[_]]|0,O+=16>_?s(x,S,T)+d[0]:32>_?o(x,S,T)+d[1]:48>_?i(x,S,T)+d[2]:64>_?n(x,S,T)+d[3]:r(x,S,T)+d[4],O=0|O,O=a(O,l[_]),O=O+k|0,A=k,k=T,T=a(S,10),S=x,x=O;O=t[1]+b+T|0,t[1]=t[2]+w+k|0,t[2]=t[3]+E+A|0,t[3]=t[4]+g+x|0,t[4]=t[0]+m+S|0,t[0]=O}}).call(e,r(42).Buffer)},function(t,e,r){(function(e){function r(t,r){if(t.length%o!==0){var n=t.length+(o-t.length%o);t=e.concat([t,s],n)}for(var i=[],a=r?t.readInt32BE:t.readInt32LE,u=0;u<t.length;u+=o)i.push(a.call(t,u));return i}function n(t,r,n){for(var i=new e(r),o=n?i.writeInt32BE:i.writeInt32LE,s=0;s<t.length;s++)o.call(i,t[s],4*s,!0);return i}function i(t,i,o,s){e.isBuffer(t)||(t=new e(t));var u=i(r(t,s),t.length*a);return n(u,o,s)}var o=4,s=new e(o);s.fill(0);var a=8;t.exports={hash:i}}).call(e,r(42).Buffer)},function(t){t.exports=function(t){function e(e,r){this._block=new t(e),this._finalSize=r,this._blockSize=e,this._len=0,this._s=0}return e.prototype.init=function(){this._s=0,this._len=0},e.prototype.update=function(e,r){"string"==typeof e&&(r=r||"utf8",e=new t(e,r));for(var n=this._len+=e.length,i=this._s=this._s||0,o=0,s=this._block;n>i;){for(var a=Math.min(e.length,o+this._blockSize-i%this._blockSize),u=a-o,c=0;u>c;c++)s[i%this._blockSize+c]=e[c+o];i+=u,o+=u,i%this._blockSize===0&&this._update(s)}return this._s=i,this},e.prototype.digest=function(t){var e=8*this._len;this._block[this._len%this._blockSize]=128,this._block.fill(0,this._len%this._blockSize+1),e%(8*this._blockSize)>=8*this._finalSize&&(this._update(this._block),this._block.fill(0)),this._block.writeInt32BE(e,this._blockSize-4);var r=this._update(this._block)||this._hash();return t?r.toString(t):r},e.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e}},function(t,e,r){var n=r(38).inherits;t.exports=function(t,e){function r(){return d.length?d.pop().init():this instanceof r?(this._w=p,e.call(this,64,56),this._h=null,void this.init()):new r}function i(t,e,r,n){return 20>t?e&r|~e&n:40>t?e^r^n:60>t?e&r|e&n|r&n:e^r^n}function o(t){return 20>t?1518500249:40>t?1859775393:60>t?-1894007588:-899497514}function s(t,e){return t+e|0}function a(t,e){return t<<e|t>>>32-e}var u=0,c=4,f=8,h=12,l=16,p=new("undefined"==typeof Int32Array?Array:Int32Array)(80),d=[];return n(r,e),r.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,e.prototype.init.call(this),this},r.prototype._POOL=d,r.prototype._update=function(t){var e,r,n,u,c,f,h,l,p,d;
e=f=this._a,r=h=this._b,n=l=this._c,u=p=this._d,c=d=this._e;for(var _=this._w,y=0;80>y;y++){var v=_[y]=16>y?t.readInt32BE(4*y):a(_[y-3]^_[y-8]^_[y-14]^_[y-16],1),g=s(s(a(e,5),i(y,r,n,u)),s(s(c,v),o(y)));c=u,u=n,n=a(r,30),r=e,e=g}this._a=s(e,f),this._b=s(r,h),this._c=s(n,l),this._d=s(u,p),this._e=s(c,d)},r.prototype._hash=function(){d.length<100&&d.push(this);var e=new t(20);return e.writeInt32BE(0|this._a,u),e.writeInt32BE(0|this._b,c),e.writeInt32BE(0|this._c,f),e.writeInt32BE(0|this._d,h),e.writeInt32BE(0|this._e,l),e},r}},function(t,e,r){var n=r(38).inherits;t.exports=function(t,e){function r(){this.init(),this._w=p,e.call(this,64,56)}function i(t,e){return t>>>e|t<<32-e}function o(t,e){return t>>>e}function s(t,e,r){return t&e^~t&r}function a(t,e,r){return t&e^t&r^e&r}function u(t){return i(t,2)^i(t,13)^i(t,22)}function c(t){return i(t,6)^i(t,11)^i(t,25)}function f(t){return i(t,7)^i(t,18)^o(t,3)}function h(t){return i(t,17)^i(t,19)^o(t,10)}var l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],p=new Array(64);return n(r,e),r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._len=this._s=0,this},r.prototype._update=function(t){var e,r,n,i,o,p,d,_,y,v,g=this._w;e=0|this._a,r=0|this._b,n=0|this._c,i=0|this._d,o=0|this._e,p=0|this._f,d=0|this._g,_=0|this._h;for(var m=0;64>m;m++){var b=g[m]=16>m?t.readInt32BE(4*m):h(g[m-2])+g[m-7]+f(g[m-15])+g[m-16];y=_+c(o)+s(o,p,d)+l[m]+b,v=u(e)+a(e,r,n),_=d,d=p,p=o,o=i+y,i=n,n=r,r=e,e=y+v}this._a=e+this._a|0,this._b=r+this._b|0,this._c=n+this._c|0,this._d=i+this._d|0,this._e=o+this._e|0,this._f=p+this._f|0,this._g=d+this._g|0,this._h=_+this._h|0},r.prototype._hash=function(){var e=new t(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},r}},function(t,e,r){var n=r(38).inherits;t.exports=function(t,e){function r(){this.init(),this._w=u,e.call(this,128,112)}function i(t,e,r){return t>>>r|e<<32-r}function o(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}var a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],u=new Array(160);return n(r,e),r.prototype.init=function(){return this._a=1779033703,this._b=-1150833019,this._c=1013904242,this._d=-1521486534,this._e=1359893119,this._f=-1694144372,this._g=528734635,this._h=1541459225,this._al=-205731576,this._bl=-2067093701,this._cl=-23791573,this._dl=1595750129,this._el=-1377402159,this._fl=725511199,this._gl=-79577749,this._hl=327033209,this._len=this._s=0,this},r.prototype._update=function(t){var e,r,n,u,c,f,h,l,p,d,_,y,v,g,m,b,w=this._w;e=0|this._a,r=0|this._b,n=0|this._c,u=0|this._d,c=0|this._e,f=0|this._f,h=0|this._g,l=0|this._h,p=0|this._al,d=0|this._bl,_=0|this._cl,y=0|this._dl,v=0|this._el,g=0|this._fl,m=0|this._gl,b=0|this._hl;for(var E=0;80>E;E++){var A,x,S=2*E;if(16>E)A=w[S]=t.readInt32BE(4*S),x=w[S+1]=t.readInt32BE(4*S+4);else{var T=w[S-30],k=w[S-30+1],O=i(T,k,1)^i(T,k,8)^T>>>7,I=i(k,T,1)^i(k,T,8)^i(k,T,7);T=w[S-4],k=w[S-4+1];var j=i(T,k,19)^i(k,T,29)^T>>>6,R=i(k,T,19)^i(T,k,29)^i(k,T,6),C=w[S-14],L=w[S-14+1],B=w[S-32],F=w[S-32+1];x=I+L,A=O+C+(I>>>0>x>>>0?1:0),x+=R,A=A+j+(R>>>0>x>>>0?1:0),x+=F,A=A+B+(F>>>0>x>>>0?1:0),w[S]=A,w[S+1]=x}var N=s(e,r,n),q=s(p,d,_),D=i(e,p,28)^i(p,e,2)^i(p,e,7),M=i(p,e,28)^i(e,p,2)^i(e,p,7),P=i(c,v,14)^i(c,v,18)^i(v,c,9),U=i(v,c,14)^i(v,c,18)^i(c,v,9),z=a[S],G=a[S+1],H=o(c,f,h),K=o(v,g,m),V=b+U,Y=l+P+(b>>>0>V>>>0?1:0);V+=K,Y=Y+H+(K>>>0>V>>>0?1:0),V+=G,Y=Y+z+(G>>>0>V>>>0?1:0),V+=x,Y=Y+A+(x>>>0>V>>>0?1:0);var X=M+q,W=D+N+(M>>>0>X>>>0?1:0);l=h,b=m,h=f,m=g,f=c,g=v,v=y+V|0,c=u+Y+(y>>>0>v>>>0?1:0)|0,u=n,y=_,n=r,_=d,r=e,d=p,p=V+X|0,e=Y+W+(V>>>0>p>>>0?1:0)|0}this._al=this._al+p|0,this._bl=this._bl+d|0,this._cl=this._cl+_|0,this._dl=this._dl+y|0,this._el=this._el+v|0,this._fl=this._fl+g|0,this._gl=this._gl+m|0,this._hl=this._hl+b|0,this._a=this._a+e+(this._al>>>0<p>>>0?1:0)|0,this._b=this._b+r+(this._bl>>>0<d>>>0?1:0)|0,this._c=this._c+n+(this._cl>>>0<_>>>0?1:0)|0,this._d=this._d+u+(this._dl>>>0<y>>>0?1:0)|0,this._e=this._e+c+(this._el>>>0<v>>>0?1:0)|0,this._f=this._f+f+(this._fl>>>0<g>>>0?1:0)|0,this._g=this._g+h+(this._gl>>>0<m>>>0?1:0)|0,this._h=this._h+l+(this._hl>>>0<b>>>0?1:0)|0},r.prototype._hash=function(){function e(t,e,n){r.writeInt32BE(t,n),r.writeInt32BE(e,n+4)}var r=new t(64);return e(this._a,this._al,0),e(this._b,this._bl,8),e(this._c,this._cl,16),e(this._d,this._dl,24),e(this._e,this._el,32),e(this._f,this._fl,40),e(this._g,this._gl,48),e(this._h,this._hl,56),r},r}}]);
</script>
<script>
// Opening setup
// --------------------------------
var MY_ADDRESS;
var MASTER_SECRET;
var remote = new ripple.Remote({
servers: [
"wss://s-west.ripple.com:443",
"wss://s-east.ripple.com:443"
]
});
document.getElementById("directxrp").checked = false;
document.getElementById("useoptional").checked = false;
document.getElementById("mysecret").value = "";
clearAllInfo();
var VER_REKEYED = 220;
var VER_ENCRYPTED_ORDINARY = 160;
var VER_ENCRYPTED_REKEYED = 250;
// Helper functions
// --------------------------------
// State/input validation
var validate = {
number: function(x) {
return x!=="" && !isNaN(x);
},
address: function(x) {
return ripple.UInt160.is_valid(x);
},
currency: function(x) {
return x.length===3 && x.toUpperCase()===x;
},
integer: function(x) {
// Allow x==="" because "integer" is only used on optional fields
return x==="" || (!isNaN(x) && parseInt(x)===parseFloat(x));
},
"hex string": function(x) {
// Allow x==="" because "hex string" is only used on optional fields
return /^[0-9A-Fa-f]*$/.test(x) && x.length<=64;
},
secret: function(x) {
return !isNaN(ripple.Base.decode_check(ripple.Base.VER_FAMILY_SEED, x));
},
encryptedSecret: function(x) {
return !isNaN(ripple.Base.decode_check(VER_ENCRYPTED_ORDINARY, x)) ||
!isNaN(ripple.Base.decode_check(VER_ENCRYPTED_REKEYED, x))
},
"currency/issuer pair": function(x) {
var s = x.split("/");
if (s.length === 1 && s[0] === "XRP") {
return true;
} else {
return (s.length === 2 &&
validate.currency(s[0]) &&
validate.address(s[1])
);
}
},
ALLOW_ALL: function(x) {
return true;
}
};
function mustConnect(r) {
if (remote.isConnected()) {
return r;
} else {
return {error: "you must connect first"};
}
}
function mustIdentify(r) {
if (MASTER_SECRET) {
return r;
} else {
return {error: "you must set an identity first"};
}
}
function mustBeValid(values, types) {
if (values.length !== types.length) {
throw "values and types must be the same length";
}
return function(r) {
var returnValues = [];
for (var i=0; i<values.length; i++) {
var value = eval(values[i]);
var type = types[i];
if (!validate[type](value)) {
return {error: '"'+value+'" is not a valid '+type};
} else {
returnValues.push(value);
}
}
return {values: returnValues};
};
}
function guard(guardians, target) {
return function(){
var result = {}
for (var i=0; i<guardians.length; i++) {
var guardian = guardians[i];
result = guardian(result);
if (result.error) {
alert(result.error);
return;
}
}
target.apply(this, result.values);
};
}
// Ripple names
function httpGet(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
callback(null, xhr.responseText);
}
}
xhr.onerror = function() {
callback(true);
}
xhr.open("GET", url, true);
xhr.send(null);
}
var rnCache = {};
function resolveRippleName(name, callback) {
var nameURL = document.getElementById("nameurl").value;
if (!rnCache[nameURL]) {
rnCache[nameURL] = {};
}
if ("undefined" !== typeof rnCache[nameURL][name]) {
callback(null, rnCache[nameURL][name]);
} else {
httpGet("https://"+nameURL+name, function(err, res){
var result;
if (!err) {
var parsed = JSON.parse(res);
var result = parsed.exists && parsed.address;
rnCache[nameURL][name] = result;
}
callback(err, result);
});
}
}
function pressResolve(pressedButton, inputs) {
if (!document.getElementById("useripplenames").checked) {
alert("you must enable the ~ button");
return;
}
pressedButton.disabled = "disabled";
pressedButton.innerHTML = "...";
var numberOfResponses = 0;
function concludeResponse() {
numberOfResponses++;
if (numberOfResponses === inputs.length) {
pressedButton.disabled = "";
pressedButton.innerHTML = "~";
}
}
var alreadyAlerted = false;
for (var i=0; i<inputs.length; i++) {
var input = inputs[i];
var value = document.getElementById(input).value;
var ci = value.split("/");
var currency = false;
if (ci.length === 2) {
currency = ci[0];
value = ci[1];
}
if (!value || inputs.length > 1 && !currency && value === "XRP" || validate.address(value)) {
concludeResponse();
continue;
}
if (value.charAt(0) !== "~") {
alreadyAlerted || alert("ripple name must begin with ~");
alreadyAlerted = true;
concludeResponse();
} else {
resolveRippleName(value, (function(){
var inp = input;
var cur = currency;
return function(err, result) {
concludeResponse();
if (err) {
alreadyAlerted || alert("could not reach ripple name resolver");
alreadyAlerted = true;
} else if (!result) {
alreadyAlerted || alert("could not resolve ripple name "+value);
alreadyAlerted = true;
} else {
document.getElementById(inp).value = cur ?
cur+"/"+result : result;
}
}
})());
}
}
}
// Miscellaneous
function notifyOutcome(err, res) {
var outcome = "transaction finalized with " +
(err ? "error" : "result") + ":";
prompt(outcome, JSON.stringify(err||res));
}
// This is a really kludgy workaround to deal with the fact that
// ripple-lib doesn't currently support signing transactions with
// a RegularKey.
var NORMAL_SIGNING_FUNCTION = ripple.Transaction.prototype.sign;
function redefineSigningToAlwaysUseSecret(secret) {
if (!secret) {
ripple.Transaction.prototype.sign = NORMAL_SIGNING_FUNCTION;
} else {
ripple.Transaction.prototype.sign = function(testnet) {
this.setSecret(secret);
this.tx_json.SigningPubKey = ripple.Seed.from_json(this._secret).get_key().to_hex_pub();
var seed = ripple.Seed.from_json(this._secret);
var prev_sig = this.tx_json.TxnSignature;
delete this.tx_json.TxnSignature;
var hash = this.signingHash(testnet);
// If the hash is the same, we can re-use the previous signature
if (prev_sig && hash === this.previousSigningHash) {
this.tx_json.TxnSignature = prev_sig;
return this;
}
var key = seed.get_key();
var sig = key.sign(hash);
var hex = ripple.sjcl.codec.hex.fromBits(sig).toUpperCase();
this.tx_json.TxnSignature = hex;
this.previousSigningHash = hash;
return this;
};
}
}
// Identity
// --------------------------------
function pressSetIdentity() {
var secret = document.getElementById("mysecret").value;
if (document.getElementById("myaddress").innerHTML) {
alert("you must clear the old identity first");
} else if (secret) {
if (secret.charAt(0) === "s" && setOrdinarySecret(secret)) {
// pass
} else if (secret.charAt(0) === "3" && setRekeyedSecret(secret)) {
// pass
} else if (secret.charAt(0) === "h" && setEncryptedSecret(secret)) {
// pass
} else {
alert('"'+secret+'" is not a valid secret');
}
} else {
alert("you must enter a secret");
}
}
function setOrdinarySecret(secret) {
if (!validate.secret(secret)) {
return false;
} else {
var result = generateAddress(secret);
setIdentity(result.address, result.secret, result.secret);
remote.setSecret(result.address, result.secret);
redefineSigningToAlwaysUseSecret(false);
return true;
}
}
function setRekeyedSecret(secret) {
// This uses a custom format that is specific to this application:
// ripple.Base.encode_check(VER_REKEYED, regular_key_secret concat master_secret)
if (secret.length < 2) {
return false;
}
var b = ripple.Base.decode_check(VER_REKEYED, secret);
if (isNaN(b)) {
return false;
}
var y = ripple.sjcl.codec.bytes.fromBits(b.toBits());
if (y.length !== 32) {
return false;
}
var rks = ripple.Base.encode_check(ripple.Base.VER_FAMILY_SEED, y.slice(0,16));
var ms = ripple.Base.encode_check(ripple.Base.VER_FAMILY_SEED, y.slice(16));
var ra = generateAddress(ms).address;
setIdentity(ra, secret, ms);
remote.setSecret(ra, ms);
remote.setSecret(generateAddress(rks).address, rks);
redefineSigningToAlwaysUseSecret(rks);
return true;
}
function setEncryptedSecret(encryptedSecret) {
if (!validate.encryptedSecret(encryptedSecret)) {
return false;
}
showDecryptor();
return true;
}
function pressDecrypt() {
var es = document.getElementById("mysecret").value;
var passphrase = document.getElementById("passphrase").value;
if (es.charAt(0) !== "h" || !validate.encryptedSecret(es)) {
alert('invalid encrypted secret');
return;
}
if (!passphrase) {
alert('you must enter a passphrase');
return;
}
var secret;
try {
secret = decryptSecret(passphrase, es);
} catch(err) {
alert('invalid passphrase or encrypted secret');
document.getElementById("passphrase").value = "";
return;
}
if (secret.charAt(0) === "s" && setOrdinarySecret(secret)) {
hideDecryptor();
} else if (secret.charAt(0) === "3" && setRekeyedSecret(secret)) {
hideDecryptor();
} else {
alert('invalid passphrase or encrypted secret');
document.getElementById("passphrase").value = "";
}
}
function showDecryptor() {
document.getElementById("passphrase").className = "";
document.getElementById("decryptbutton").className = "";
document.getElementById("encryptshow").className = "displaynone";
}
function hideDecryptor() {
var pp = document.getElementById("passphrase");
pp.value = "";
pp.className = "displaynone";
document.getElementById("decryptbutton").className = "displaynone";
}
function showEncryptorShower() {
document.getElementById("encryptshow").className = "";
}
function showEncryptor() {
document.getElementById("passphrase").className = "";
document.getElementById("confirmpassphrase").className = "";
document.getElementById("encryptshow").className = "displaynone";
document.getElementById("encryptbutton").className = "";
}
function hideEncryptor() {
var pp = document.getElementById("passphrase")
pp.className = "displaynone";
pp.value = "";
var pp2 = document.getElementById("confirmpassphrase")
pp2.className = "displaynone";
pp2.value = "";
document.getElementById("encryptshow").className = "";
document.getElementById("encryptbutton").className = "displaynone";
}
function pressEncryptSecret() {
var pp = document.getElementById("passphrase").value;
var pp2 = document.getElementById("confirmpassphrase").value;
if (!pp || !pp2) {
alert("you must enter something");
} else if (pp !== pp2) {
alert("passphrases must match");
} else {
var es = encryptSecret(pp, document.getElementById("mysecret").value);
prompt("your encrypted secret is:", es);
hideEncryptor();
}
}
function encryptSecret(passphrase, secret) {
var payloadBytes = ripple.Base.decode(secret);
var version = payloadBytes[0]===ripple.Base.VER_FAMILY_SEED ?
VER_ENCRYPTED_ORDINARY : VER_ENCRYPTED_REKEYED;
var salt = ripple.sjcl.random.randomWords(2); // 8 bytes of salt
var streamBytes = ripple.sjcl.codec.bytes.fromBits(
ripple.sjcl.misc.pbkdf2(passphrase, salt, void(0), 8*payloadBytes.length)
);
var encryptedBytes = streamBytes.map(function(x,i) {
return x ^ payloadBytes[i];
});
var saltBytes = ripple.sjcl.codec.bytes.fromBits(salt);
return ripple.Base.encode_check(version, saltBytes.concat(encryptedBytes));
}
function decryptSecret(passphrase, es) {
var ao = ripple.Base.decode_check(VER_ENCRYPTED_ORDINARY, es);
var ar = ripple.Base.decode_check(VER_ENCRYPTED_REKEYED, es);
var a = isNaN(ao) ? ar : ao;
ripple.sjcl.codec.bytes.fromBits(a.toBits());
var b = ripple.sjcl.codec.bytes.fromBits(a.toBits());
var saltBytes = b.slice(0,8)
var encryptedBytes = b.slice(8)
var streamBytes = ripple.sjcl.codec.bytes.fromBits(
ripple.sjcl.misc.pbkdf2(passphrase, ripple.sjcl.codec.bytes.toBits(saltBytes), void(0), 8*encryptedBytes.length)
);
var payloadBytes = streamBytes.map(function(x,i) {
return x ^ encryptedBytes[i];
});
var result = ripple.Base.encode(payloadBytes);
return result;
}
function setIdentity(address, displayedSecret, masterSecret) {
MY_ADDRESS = address;
MASTER_SECRET = masterSecret;
document.getElementById("mysecret").value = displayedSecret;
document.getElementById("myaddress").innerHTML = address;
document.getElementById("mysecret").disabled="disabled";
document.getElementById("mysecret").className="hidden";
showEncryptorShower();
}
function pressGenerateIdentity() {
if (document.getElementById("myaddress").innerHTML) {
alert("you must clear the old identity first");
} else {
var result = generateAddress();
setIdentity(result.address, result.secret, result.secret);
remote.setSecret(result.address, result.secret);
alert("save your secret before you close the window!");
}
}
function pressClearIdentity() {
if (confirm("are you sure? the secret will be lost!")) {
document.getElementById("mysecret").value = "";
document.getElementById("myaddress").innerHTML = "";
setIdentity("", "");
document.getElementById("mysecret").disabled=null;
document.getElementById("mysecret").className="";
hideEncryptor();
hideDecryptor();
document.getElementById("encryptshow").className = "displaynone";
}
}
function toggleSecret() {
var s = document.getElementById("mysecret");
if (s.className === "hidden") {
s.className = "";
} else {
s.className = "hidden";
}
}
function generateAddress(secret) {
if (secret) {
secret = ripple.Seed.from_json(secret);
} else {
secret = ripple.Seed.from_bits(ripple.sjcl.random.randomWords(4));
}
return {
secret: secret.to_json(),
address: secret.get_key().get_address().to_json()
};
}
function generateRekeyedKey() {
var keypair = generateAddress();
var a1 = ripple.sjcl.codec.bytes.fromBits(ripple.Seed.from_json(keypair.secret).to_bits());
var a2 = ripple.sjcl.codec.bytes.fromBits(ripple.Seed.from_json(MASTER_SECRET).to_bits());
var rks = ripple.Base.encode_check(VER_REKEYED, a1.concat(a2));
return {
regularKey: keypair.address,
rekeyedSecret: rks,
actualSecret: keypair.secret
};
}
var pressRekey = guard([
mustConnect,
mustIdentify,
], function() {
var rekeyedKey = generateRekeyedKey();
if (null!==prompt(
"This will submit a transaction to invalidate your current " +
"secret and replace it with the new secret below, which you "+
"should save before continuing. Are you sure you want to do "+
"this?", rekeyedKey.rekeyedSecret)
) {
var rb = document.getElementById("rekeybutton");
rb.disabled = "disabled";
rb.innerHTML = "rekeying...";
rekeyAccount(rekeyedKey);
}
}
);
function rekeyAccount(rekeyedKey) {
remote.requestAccountInfo({
account: MY_ADDRESS,
ledger: "validated"
}, function(err, info) {
if (err) {
prompt("requestAccountInfo failed with error:", JSON.stringify(err));
reenableRB();
} else {
// Set regular key
var transaction = remote.createTransaction("SetRegularKey", {
account: MY_ADDRESS,
regular_key: rekeyedKey.regularKey
});
transaction.submit(function(err, res) {
if (err) {
prompt("SetRegularKey failed with error:", JSON.stringify(err));
reenableRB();
} else {
var dm = ripple.Remote.flags.account_root.DisableMaster;
if (info.account_data.Flags && (info.account_data.Flags & dm)) {
concludeRekeying(rekeyedKey);
} else { // We need to set the DisableMaster flag now.
var transaction2 = remote.createTransaction("AccountSet", {
account: MY_ADDRESS,
set_flag: ripple.Transaction.set_clear_flags.AccountSet.asfDisableMaster
});
transaction2.submit(function(err, res) {
if (err) {
prompt("DisableMaster transaction failed with error:", JSON.stringify(err));
}
concludeRekeying(rekeyedKey);
});
}
}
});
}
});
}
function concludeRekeying(rekeyedKey) {
remote.setSecret(rekeyedKey.regularKey, rekeyedKey.actualSecret);
redefineSigningToAlwaysUseSecret(rekeyedKey.actualSecret)
document.getElementById("mysecret").value = rekeyedKey.rekeyedSecret;
alert("rekeying complete");
reenableRB();
}
function reenableRB() {
var rb = document.getElementById("rekeybutton");
rb.disabled = "";
rb.innerHTML = "rekey account";
}
// Connect
// --------------------------------
function connectToRipple() {
remote.connect(function(err, res) {
res || (res = "success");
var outcome = "connected to ripple with " +
(err ? "error" : "result") + ": " +
JSON.stringify(err||res);
alert(outcome);
});
}
function disconnectFromRipple() {
remote.disconnect(function(){
alert("disconnected");
});
}
// Account Details
// --------------------------------
// Helper functions
function useCurrentIdentity() {
if (MY_ADDRESS && MY_ADDRESS !== "") {
document.getElementById("infoaccount").value = MY_ADDRESS;
clearAllInfo();
}
}
function clearAllInfo() {
document.getElementById("infotable").innerHTML = "";
document.getElementById("linestable").innerHTML = "";
document.getElementById("offerstable").innerHTML = "";
document.getElementById("flagstable").innerHTML = "";
var ia = document.getElementById("infoaccount");
ia.readOnly = false;
ia.disabled = "";
}
function accountInfoError(err, table) {
if (err.remote && err.remote.error === "actNotFound") {
table.innerHTML = "account not found";
} else {
prompt("request failed with error:", JSON.stringify(err));
}
}
// Button presses
function takeAddressAndDo(action) {
return guard([
mustConnect,
mustBeValid([
'document.getElementById("infoaccount").value'
],["address"])
], function(account){
var ia = document.getElementById("infoaccount");
ia.readOnly = true;
ia.disabled = "disabled";
action(account);
});
}
var pressInfo = takeAddressAndDo(getAccountInfo);
var pressLines = takeAddressAndDo(getAccountLines);
var pressOffers = takeAddressAndDo(getAccountOffers);
var pressFlags = takeAddressAndDo(loadFlagsTable);
// Query the network
function getAccountInfo(account) {
remote.requestAccountInfo({
account: account,
ledger: "validated"
}, function(err, res) {
var table = document.getElementById("infotable");
if (err) {
accountInfoError(err, table);
} else {
var content = "";
var data = res.account_data;
for (var key in data) {
content += ("<tr><th>"+key+"</th><td>"+data[key]+"</td></tr>");
}
table.innerHTML = content;
}
});
}
function getAccountLines(account) {
remote.requestAccountLines({
account: account,
ledger: "validated"
}, function(err, res) {
var table = document.getElementById("linestable");
if (err) {
accountInfoError(err, table);
} else {
var content = "";
var lines = res.lines;
if (!lines.length) {
table.innerHTML = "account has no trustlines";
} else {
for (var i=0; i<lines.length; i++) {
var data = lines[i];
var entry = "";
for (var key in data) {
entry += ("<tr><th>"+key+"</th><td>"+data[key]+"</td></tr>");
}
entry = "<table>"+entry+"</table>";
content += ("<tr><td>"+entry+"</td></tr>");
}
table.innerHTML = content;
}
}
});
}
function getAccountOffers(account) {
remote.requestAccountOffers({
account: account,
ledger: "validated"
}, function(err, res) {
var table = document.getElementById("offerstable");
if (err) {
accountInfoError(err, table);
} else {
var content = "";
if (!res.offers.length) {
content = "account has no offers";
} else {
content = "<tr>"+
"<th colspan=2>TakerGets</th>"+
"<th colspan=2>TakerPays</th>"+
"<th rowspan=2>cancel</th>"+
"</tr>"+
"<tr>"+
"<th>amount</th>"+
"<th>CUR/issuer</th>"+
"<th>amount</th>"+
"<th>CUR/issuer</th>"+
"</tr>";
for (var i=0; i<res.offers.length; i++) {
var offer = res.offers[i];
var tg = offer.taker_gets;
var tgc, tgv;
var tp = offer.taker_pays;
var tpc, tpv;
if (tg.currency) {
tgc = tg.currency+"/"+tg.issuer;
tgv = tg.value;
} else {
tgc = "XRP";
tgv = parseInt(tg) / 1000000;
}
if (tp.currency) {
tpc = tp.currency+"/"+tp.issuer;
tpv = tp.value;
} else {
tpc = "XRP";
tpv = parseInt(tp) / 1000000;
}
var args = '"' + res.account + '","' + offer.seq + '"';
content += ("<tr>"+
"<td>"+tgv+"</td>"+
"<td>"+tgc+"</td>"+
"<td>"+tpv+"</td>"+
"<td>"+tpc+"</td>"+
"<td><button class='cancelbutton' onclick='pressCancelOffer(this,"+args+
")'>cancel</button></td>"+
"</tr>");
}
}
table.innerHTML = content;
}
});
}
function loadFlagsTable(account) {
remote.requestAccountInfo({
account: account,
ledger: "validated"