aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/LICENSE16
-rw-r--r--cmd/blocktest/main.go213
-rw-r--r--cmd/bootnode/main.go93
-rw-r--r--cmd/disasm/main.go34
-rw-r--r--cmd/ethereum/js.go294
-rw-r--r--cmd/ethereum/main.go331
-rw-r--r--cmd/ethtest/.bowerrc5
-rw-r--r--cmd/ethtest/.editorconfig12
-rw-r--r--cmd/ethtest/.gitignore18
-rw-r--r--cmd/ethtest/.jshintrc50
-rw-r--r--cmd/ethtest/.npmignore9
-rw-r--r--cmd/ethtest/.travis.yml11
-rw-r--r--cmd/ethtest/main.go205
-rw-r--r--cmd/evm/code.txt1
-rw-r--r--cmd/evm/input.txt1
-rw-r--r--cmd/evm/main.go163
-rw-r--r--cmd/mist/assets/back.pngbin0 -> 1004 bytes
-rw-r--r--cmd/mist/assets/backButton.pngbin0 -> 663 bytes
-rw-r--r--cmd/mist/assets/backButton@2x.pngbin0 -> 1499 bytes
-rw-r--r--cmd/mist/assets/backButtonDisabled.pngbin0 -> 634 bytes
-rw-r--r--cmd/mist/assets/backButtonDisabled@2x.pngbin0 -> 1458 bytes
-rw-r--r--cmd/mist/assets/backButtonHover.pngbin0 -> 657 bytes
-rw-r--r--cmd/mist/assets/backButtonHover@2x.pngbin0 -> 1517 bytes
-rw-r--r--cmd/mist/assets/browser.pngbin0 -> 756 bytes
-rw-r--r--cmd/mist/assets/browser@2x.pngbin0 -> 1603 bytes
-rw-r--r--cmd/mist/assets/bug.pngbin0 -> 1671 bytes
-rw-r--r--cmd/mist/assets/close.pngbin0 -> 905 bytes
-rw-r--r--cmd/mist/assets/debugger/debugger.qml436
-rw-r--r--cmd/mist/assets/examples/abi.html55
-rw-r--r--cmd/mist/assets/examples/balance.html40
-rw-r--r--cmd/mist/assets/examples/bomb.html22
-rw-r--r--cmd/mist/assets/examples/coin.html154
-rw-r--r--cmd/mist/assets/examples/coin.js65
-rw-r--r--cmd/mist/assets/examples/info.html84
-rw-r--r--cmd/mist/assets/examples/whisper.html70
-rw-r--r--cmd/mist/assets/ext/.bowerrc5
-rw-r--r--cmd/mist/assets/ext/.editorconfig12
-rw-r--r--cmd/mist/assets/ext/.gitignore18
-rw-r--r--cmd/mist/assets/ext/.jshintrc50
-rw-r--r--cmd/mist/assets/ext/.npmignore9
-rw-r--r--cmd/mist/assets/ext/.travis.yml13
-rw-r--r--cmd/mist/assets/ext/bignumber.min.js2
m---------cmd/mist/assets/ext/ethereum.js0
-rw-r--r--cmd/mist/assets/ext/filter.js66
-rw-r--r--cmd/mist/assets/ext/http.js30
-rw-r--r--cmd/mist/assets/ext/mist.js36
-rw-r--r--cmd/mist/assets/facet.pngbin0 -> 27302 bytes
-rw-r--r--cmd/mist/assets/heart.pngbin0 -> 4277 bytes
-rw-r--r--cmd/mist/assets/html/home.html83
-rw-r--r--cmd/mist/assets/html/logo.pngbin0 -> 12767 bytes
-rw-r--r--cmd/mist/assets/icecream.pngbin0 -> 4643 bytes
-rw-r--r--cmd/mist/assets/mining-icon.pngbin0 -> 1029 bytes
-rw-r--r--cmd/mist/assets/mining-icon@2x.pngbin0 -> 2312 bytes
-rw-r--r--cmd/mist/assets/muted/codemirror.css272
-rw-r--r--cmd/mist/assets/muted/debugger.html53
-rw-r--r--cmd/mist/assets/muted/eclipse.css23
-rw-r--r--cmd/mist/assets/muted/index.html80
-rw-r--r--cmd/mist/assets/muted/lib/codemirror.js7526
-rw-r--r--cmd/mist/assets/muted/lib/go.js182
-rw-r--r--cmd/mist/assets/muted/lib/matchbrackets.js117
-rw-r--r--cmd/mist/assets/muted/muted.js78
-rw-r--r--cmd/mist/assets/net.pngbin0 -> 4669 bytes
-rw-r--r--cmd/mist/assets/network.pngbin0 -> 2900 bytes
-rw-r--r--cmd/mist/assets/new.pngbin0 -> 4776 bytes
-rw-r--r--cmd/mist/assets/pick.pngbin0 -> 932 bytes
-rw-r--r--cmd/mist/assets/qml/QmlApp.qml22
-rw-r--r--cmd/mist/assets/qml/depricated_browser.qml486
-rw-r--r--cmd/mist/assets/qml/first_run.qml155
-rwxr-xr-xcmd/mist/assets/qml/fonts/Simple-Line-Icons.ttfbin0 -> 35304 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-Black.ttfbin0 -> 117460 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-BlackIt.ttfbin0 -> 123840 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-Bold.ttfbin0 -> 119096 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-BoldIt.ttfbin0 -> 123756 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLight.ttfbin0 -> 120812 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLightIt.ttfbin0 -> 125720 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-It.ttfbin0 -> 124668 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-Light.ttfbin0 -> 121124 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-LightIt.ttfbin0 -> 125480 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-Regular.ttfbin0 -> 120672 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-Semibold.ttfbin0 -> 120036 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSansPro-SemiboldIt.ttfbin0 -> 123840 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSerifPro-Bold.ttfbin0 -> 113188 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSerifPro-Regular.ttfbin0 -> 113640 bytes
-rw-r--r--cmd/mist/assets/qml/fonts/SourceSerifPro-Semibold.ttfbin0 -> 114352 bytes
-rw-r--r--cmd/mist/assets/qml/main.qml1040
-rw-r--r--cmd/mist/assets/qml/muted.qml74
-rw-r--r--cmd/mist/assets/qml/test_app.qml70
-rw-r--r--cmd/mist/assets/qml/transactions.qml9
-rw-r--r--cmd/mist/assets/qml/views/browser.qml506
-rw-r--r--cmd/mist/assets/qml/views/catalog.qml144
-rw-r--r--cmd/mist/assets/qml/views/chain.qml244
-rw-r--r--cmd/mist/assets/qml/views/history.qml51
-rw-r--r--cmd/mist/assets/qml/views/info.qml143
-rw-r--r--cmd/mist/assets/qml/views/jeffcoin/jeff.pngbin0 -> 84076 bytes
-rw-r--r--cmd/mist/assets/qml/views/jeffcoin/jeffcoin.qml190
-rw-r--r--cmd/mist/assets/qml/views/miner.qml283
-rw-r--r--cmd/mist/assets/qml/views/network-health/205f39107b64acf34cb35d7edb57f47893187a12.js176
-rw-r--r--cmd/mist/assets/qml/views/network-health/529f30ee0ee386c5143b4ccb62073179ca8253c3.css4
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Black.otfbin0 -> 45336 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Bold.otfbin0 -> 45968 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Hairline.otfbin0 -> 44156 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Light.otfbin0 -> 44792 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Regular.otfbin0 -> 45360 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SIL Open Font License.txt43
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Black.otfbin0 -> 122372 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BlackIt.otfbin0 -> 95056 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Bold.otfbin0 -> 129212 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BoldIt.otfbin0 -> 100072 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLight.otfbin0 -> 117832 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLightIt.otfbin0 -> 90924 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-It.otfbin0 -> 98820 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Light.otfbin0 -> 124476 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-LightIt.otfbin0 -> 95536 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Regular.otfbin0 -> 127448 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Semibold.otfbin0 -> 127336 bytes
-rw-r--r--cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-SemiboldIt.otfbin0 -> 98352 bytes
-rwxr-xr-xcmd/mist/assets/qml/views/network-health/index.html30
-rw-r--r--cmd/mist/assets/qml/views/network-health/loading.css92
-rw-r--r--cmd/mist/assets/qml/views/network.qml159
-rw-r--r--cmd/mist/assets/qml/views/pending_tx.qml53
-rw-r--r--cmd/mist/assets/qml/views/transaction.qml216
-rw-r--r--cmd/mist/assets/qml/views/wallet.qml190
-rw-r--r--cmd/mist/assets/qml/views/whisper.qml74
-rw-r--r--cmd/mist/assets/tx.pngbin0 -> 4070 bytes
-rw-r--r--cmd/mist/assets/util/test.html43
-rw-r--r--cmd/mist/assets/wallet.pngbin0 -> 1114 bytes
-rw-r--r--cmd/mist/bindings.go100
-rw-r--r--cmd/mist/errors.go56
-rw-r--r--cmd/mist/gui.go483
-rw-r--r--cmd/mist/html_container.go153
-rw-r--r--cmd/mist/main.go115
-rw-r--r--cmd/mist/qml_container.go83
-rw-r--r--cmd/mist/ui_lib.go300
-rw-r--r--cmd/rlpdump/main.go148
-rw-r--r--cmd/utils/cmd.go180
-rw-r--r--cmd/utils/flags.go249
136 files changed, 17401 insertions, 0 deletions
diff --git a/cmd/LICENSE b/cmd/LICENSE
new file mode 100644
index 000000000..78efdaabe
--- /dev/null
+++ b/cmd/LICENSE
@@ -0,0 +1,16 @@
+Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+MA 02110-1301 USA
diff --git a/cmd/blocktest/main.go b/cmd/blocktest/main.go
new file mode 100644
index 000000000..ec2779e2e
--- /dev/null
+++ b/cmd/blocktest/main.go
@@ -0,0 +1,213 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Gustav Simonsson <gustav.simonsson@gmail.com>
+ * @date 2015
+ *
+ */
+
+package main
+
+import (
+ "bytes"
+ "encoding/hex"
+ "encoding/json"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "math/big"
+ "os"
+ "runtime"
+ "strings"
+
+ "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/core"
+ types "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/event"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/rlp"
+)
+
+type Account struct {
+ Balance string
+ Code string
+ Nonce string
+ Storage map[string]string
+}
+
+type BlockHeader struct {
+ Bloom string
+ Coinbase string
+ Difficulty string
+ ExtraData string
+ GasLimit string
+ GasUsed string
+ MixHash string
+ Nonce string
+ Number string
+ ParentHash string
+ ReceiptTrie string
+ SeedHash string
+ StateRoot string
+ Timestamp string
+ TransactionsTrie string
+ UncleHash string
+}
+
+type Tx struct {
+ Data string
+ GasLimit string
+ GasPrice string
+ Nonce string
+ R string
+ S string
+ To string
+ V string
+ Value string
+}
+
+type Block struct {
+ BlockHeader BlockHeader
+ Rlp string
+ Transactions []Tx
+ UncleHeaders []string
+}
+
+type Test struct {
+ Blocks []Block
+ GenesisBlockHeader BlockHeader
+ Pre map[string]Account
+}
+
+func main() {
+ flag.Usage = func() {
+ fmt.Fprintf(os.Stderr, "%s <testfile>\n", os.Args[0])
+ flag.PrintDefaults()
+ }
+ flag.Parse()
+
+ runtime.GOMAXPROCS(runtime.NumCPU())
+ logger.AddLogSystem(logger.NewStdLogSystem(os.Stderr, log.LstdFlags, logger.DebugDetailLevel))
+ defer func() { logger.Flush() }()
+
+ if len(os.Args) < 2 {
+ utils.Fatalf("Please specify a test file as the first argument.")
+ }
+ blocks, err := loadBlocksFromTestFile(os.Args[1])
+ if err != nil {
+ utils.Fatalf("Could not load blocks: %v", err)
+ }
+
+ chain := memchain()
+ chain.ResetWithGenesisBlock(blocks[0])
+ if err = chain.InsertChain(types.Blocks{blocks[1]}); err != nil {
+ utils.Fatalf("Error: %v", err)
+ } else {
+ fmt.Println("PASS")
+ }
+}
+
+func memchain() *core.ChainManager {
+ blockdb, err := ethdb.NewMemDatabase()
+ if err != nil {
+ utils.Fatalf("Could not create in-memory database: %v", err)
+ }
+ statedb, err := ethdb.NewMemDatabase()
+ if err != nil {
+ utils.Fatalf("Could not create in-memory database: %v", err)
+ }
+ return core.NewChainManager(blockdb, statedb, new(event.TypeMux))
+}
+
+func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
+ fileContent, err := ioutil.ReadFile(filePath)
+ if err != nil {
+ return
+ }
+ bt := make(map[string]Test)
+ if err = json.Unmarshal(fileContent, &bt); err != nil {
+ return
+ }
+
+ // TODO: support multiple blocks; loop over all blocks
+ gbh := new(types.Header)
+
+ // Let's use slighlty different namings for the same things, because that's awesome.
+ gbh.ParentHash, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.ParentHash)
+ gbh.UncleHash, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.UncleHash)
+ gbh.Coinbase, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.Coinbase)
+ gbh.Root, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.StateRoot)
+ gbh.TxHash, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.TransactionsTrie)
+ gbh.ReceiptHash, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.ReceiptTrie)
+ gbh.Bloom, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.Bloom)
+
+ gbh.MixDigest, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.MixHash)
+ gbh.SeedHash, err = hex_decode(bt["SimpleTx"].GenesisBlockHeader.SeedHash)
+
+ d, _ := new(big.Int).SetString(bt["SimpleTx"].GenesisBlockHeader.Difficulty, 10)
+ gbh.Difficulty = d
+
+ n, _ := new(big.Int).SetString(bt["SimpleTx"].GenesisBlockHeader.Number, 10)
+ gbh.Number = n
+
+ gl, _ := new(big.Int).SetString(bt["SimpleTx"].GenesisBlockHeader.GasLimit, 10)
+ gbh.GasLimit = gl
+
+ gu, _ := new(big.Int).SetString(bt["SimpleTx"].GenesisBlockHeader.GasUsed, 10)
+ gbh.GasUsed = gu
+
+ ts, _ := new(big.Int).SetString(bt["SimpleTx"].GenesisBlockHeader.Timestamp, 0)
+ gbh.Time = ts.Uint64()
+
+ extra, err := hex_decode(bt["SimpleTx"].GenesisBlockHeader.ExtraData)
+ gbh.Extra = string(extra) // TODO: change ExtraData to byte array
+
+ nonce, _ := hex_decode(bt["SimpleTx"].GenesisBlockHeader.Nonce)
+ gbh.Nonce = nonce
+
+ if err != nil {
+ return
+ }
+
+ gb := types.NewBlockWithHeader(gbh)
+ //gb.uncles = *new([]*types.Header)
+ //gb.transactions = *new(types.Transactions)
+ gb.Td = new(big.Int)
+ gb.Reward = new(big.Int)
+
+ testBlock := new(types.Block)
+
+ rlpBytes, err := hex_decode(bt["SimpleTx"].Blocks[0].Rlp)
+ err = rlp.Decode(bytes.NewReader(rlpBytes), &testBlock)
+ if err != nil {
+ return
+ }
+
+ blocks = types.Blocks{
+ gb,
+ testBlock,
+ }
+
+ return
+}
+
+func hex_decode(s string) (res []byte, err error) {
+ return hex.DecodeString(strings.TrimPrefix(s, "0x"))
+}
diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go
new file mode 100644
index 000000000..dda9f34d4
--- /dev/null
+++ b/cmd/bootnode/main.go
@@ -0,0 +1,93 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// Command bootnode runs a bootstrap node for the Discovery Protocol.
+package main
+
+import (
+ "crypto/ecdsa"
+ "encoding/hex"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+
+ "github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/p2p/nat"
+)
+
+func main() {
+ var (
+ listenAddr = flag.String("addr", ":30301", "listen address")
+ genKey = flag.String("genkey", "", "generate a node key and quit")
+ nodeKeyFile = flag.String("nodekey", "", "private key filename")
+ nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)")
+ natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
+
+ nodeKey *ecdsa.PrivateKey
+ err error
+ )
+ flag.Parse()
+ logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.DebugLevel))
+
+ if *genKey != "" {
+ writeKey(*genKey)
+ os.Exit(0)
+ }
+
+ natm, err := nat.Parse(*natdesc)
+ if err != nil {
+ log.Fatalf("-nat: %v", err)
+ }
+ switch {
+ case *nodeKeyFile == "" && *nodeKeyHex == "":
+ log.Fatal("Use -nodekey or -nodekeyhex to specify a private key")
+ case *nodeKeyFile != "" && *nodeKeyHex != "":
+ log.Fatal("Options -nodekey and -nodekeyhex are mutually exclusive")
+ case *nodeKeyFile != "":
+ if nodeKey, err = crypto.LoadECDSA(*nodeKeyFile); err != nil {
+ log.Fatalf("-nodekey: %v", err)
+ }
+ case *nodeKeyHex != "":
+ if nodeKey, err = crypto.HexToECDSA(*nodeKeyHex); err != nil {
+ log.Fatalf("-nodekeyhex: %v", err)
+ }
+ }
+
+ if _, err := discover.ListenUDP(nodeKey, *listenAddr, natm); err != nil {
+ log.Fatal(err)
+ }
+ select {}
+}
+
+func writeKey(target string) {
+ key, err := crypto.GenerateKey()
+ if err != nil {
+ log.Fatal("could not generate key: %v", err)
+ }
+ b := crypto.FromECDSA(key)
+ if target == "-" {
+ fmt.Println(hex.EncodeToString(b))
+ } else {
+ if err := ioutil.WriteFile(target, b, 0600); err != nil {
+ log.Fatal("write error: ", err)
+ }
+ }
+}
diff --git a/cmd/disasm/main.go b/cmd/disasm/main.go
new file mode 100644
index 000000000..c07246b00
--- /dev/null
+++ b/cmd/disasm/main.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/vm"
+)
+
+func main() {
+ code, err := ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+ code = ethutil.Hex2Bytes(string(code[:len(code)-1]))
+ fmt.Printf("%x\n", code)
+
+ for pc := uint64(0); pc < uint64(len(code)); pc++ {
+ op := vm.OpCode(code[pc])
+ fmt.Printf("%-5d %v", pc, op)
+
+ switch op {
+ case vm.PUSH1, vm.PUSH2, vm.PUSH3, vm.PUSH4, vm.PUSH5, vm.PUSH6, vm.PUSH7, vm.PUSH8, vm.PUSH9, vm.PUSH10, vm.PUSH11, vm.PUSH12, vm.PUSH13, vm.PUSH14, vm.PUSH15, vm.PUSH16, vm.PUSH17, vm.PUSH18, vm.PUSH19, vm.PUSH20, vm.PUSH21, vm.PUSH22, vm.PUSH23, vm.PUSH24, vm.PUSH25, vm.PUSH26, vm.PUSH27, vm.PUSH28, vm.PUSH29, vm.PUSH30, vm.PUSH31, vm.PUSH32:
+ a := uint64(op) - uint64(vm.PUSH1) + 1
+ fmt.Printf(" => %x", code[pc+1:pc+1+a])
+
+ pc += a
+ }
+ fmt.Println()
+ }
+}
diff --git a/cmd/ethereum/js.go b/cmd/ethereum/js.go
new file mode 100644
index 000000000..3b98b588e
--- /dev/null
+++ b/cmd/ethereum/js.go
@@ -0,0 +1,294 @@
+// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301 USA
+
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path"
+ "strings"
+
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/javascript"
+ "github.com/ethereum/go-ethereum/state"
+ "github.com/ethereum/go-ethereum/xeth"
+ "github.com/obscuren/otto"
+ "github.com/peterh/liner"
+)
+
+type prompter interface {
+ AppendHistory(string)
+ Prompt(p string) (string, error)
+ PasswordPrompt(p string) (string, error)
+}
+
+type dumbterm struct{ r *bufio.Reader }
+
+func (r dumbterm) Prompt(p string) (string, error) {
+ fmt.Print(p)
+ return r.r.ReadString('\n')
+}
+
+func (r dumbterm) PasswordPrompt(p string) (string, error) {
+ fmt.Println("!! Unsupported terminal, password will echo.")
+ fmt.Print(p)
+ input, err := bufio.NewReader(os.Stdin).ReadString('\n')
+ fmt.Println()
+ return input, err
+}
+
+func (r dumbterm) AppendHistory(string) {}
+
+type jsre struct {
+ re *javascript.JSRE
+ ethereum *eth.Ethereum
+ xeth *xeth.XEth
+ ps1 string
+ atexit func()
+
+ prompter
+}
+
+func newJSRE(ethereum *eth.Ethereum) *jsre {
+ js := &jsre{ethereum: ethereum, ps1: "> "}
+ js.xeth = xeth.New(ethereum, js)
+ js.re = javascript.NewJSRE(js.xeth)
+ js.initStdFuncs()
+
+ if !liner.TerminalSupported() {
+ js.prompter = dumbterm{bufio.NewReader(os.Stdin)}
+ } else {
+ lr := liner.NewLiner()
+ js.withHistory(func(hist *os.File) { lr.ReadHistory(hist) })
+ lr.SetCtrlCAborts(true)
+ js.prompter = lr
+ js.atexit = func() {
+ js.withHistory(func(hist *os.File) { hist.Truncate(0); lr.WriteHistory(hist) })
+ lr.Close()
+ }
+ }
+ return js
+}
+
+func (self *jsre) ConfirmTransaction(tx *types.Transaction) bool {
+ p := fmt.Sprintf("Confirm Transaction %v\n[y/n] ", tx)
+ answer, _ := self.Prompt(p)
+ return strings.HasPrefix(strings.Trim(answer, " "), "y")
+}
+
+func (self *jsre) UnlockAccount(addr []byte) bool {
+ fmt.Printf("Please unlock account %x.\n", addr)
+ pass, err := self.PasswordPrompt("Passphrase: ")
+ if err != nil {
+ return false
+ }
+ // TODO: allow retry
+ if err := self.ethereum.AccountManager().Unlock(addr, pass); err != nil {
+ return false
+ } else {
+ fmt.Println("Account is now unlocked for this session.")
+ return true
+ }
+}
+
+func (self *jsre) exec(filename string) error {
+ file, err := os.Open(filename)
+ if err != nil {
+ return err
+ }
+ content, err := ioutil.ReadAll(file)
+ if err != nil {
+ return err
+ }
+ if _, err := self.re.Run(string(content)); err != nil {
+ return fmt.Errorf("Javascript Error: %v", err)
+ }
+ return nil
+}
+
+func (self *jsre) interactive() {
+ for {
+ input, err := self.Prompt(self.ps1)
+ if err != nil {
+ break
+ }
+ if input == "" {
+ continue
+ }
+ str += input + "\n"
+ self.setIndent()
+ if indentCount <= 0 {
+ if input == "exit" {
+ break
+ }
+ hist := str[:len(str)-1]
+ self.AppendHistory(hist)
+ self.parseInput(str)
+ str = ""
+ }
+ }
+ if self.atexit != nil {
+ self.atexit()
+ }
+}
+
+func (self *jsre) withHistory(op func(*os.File)) {
+ hist, err := os.OpenFile(path.Join(self.ethereum.DataDir, "history"), os.O_RDWR|os.O_CREATE, os.ModePerm)
+ if err != nil {
+ fmt.Printf("unable to open history file: %v\n", err)
+ return
+ }
+ op(hist)
+ hist.Close()
+}
+
+func (self *jsre) parseInput(code string) {
+ defer func() {
+ if r := recover(); r != nil {
+ fmt.Println("[native] error", r)
+ }
+ }()
+ value, err := self.re.Run(code)
+ if err != nil {
+ fmt.Println(err)
+ return
+ }
+ self.printValue(value)
+}
+
+var indentCount = 0
+var str = ""
+
+func (self *jsre) setIndent() {
+ open := strings.Count(str, "{")
+ open += strings.Count(str, "(")
+ closed := strings.Count(str, "}")
+ closed += strings.Count(str, ")")
+ indentCount = open - closed
+ if indentCount <= 0 {
+ self.ps1 = "> "
+ } else {
+ self.ps1 = strings.Join(make([]string, indentCount*2), "..")
+ self.ps1 += " "
+ }
+}
+
+func (self *jsre) printValue(v interface{}) {
+ method, _ := self.re.Vm.Get("prettyPrint")
+ v, err := self.re.Vm.ToValue(v)
+ if err == nil {
+ val, err := method.Call(method, v)
+ if err == nil {
+ fmt.Printf("%v", val)
+ }
+ }
+}
+
+func (self *jsre) initStdFuncs() {
+ t, _ := self.re.Vm.Get("eth")
+ eth := t.Object()
+ eth.Set("connect", self.connect)
+ eth.Set("stopMining", self.stopMining)
+ eth.Set("startMining", self.startMining)
+ eth.Set("dump", self.dump)
+ eth.Set("export", self.export)
+}
+
+/*
+ * The following methods are natively implemented javascript functions.
+ */
+
+func (self *jsre) dump(call otto.FunctionCall) otto.Value {
+ var block *types.Block
+
+ if len(call.ArgumentList) > 0 {
+ if call.Argument(0).IsNumber() {
+ num, _ := call.Argument(0).ToInteger()
+ block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num))
+ } else if call.Argument(0).IsString() {
+ hash, _ := call.Argument(0).ToString()
+ block = self.ethereum.ChainManager().GetBlock(ethutil.Hex2Bytes(hash))
+ } else {
+ fmt.Println("invalid argument for dump. Either hex string or number")
+ }
+
+ if block == nil {
+ fmt.Println("block not found")
+
+ return otto.UndefinedValue()
+ }
+
+ } else {
+ block = self.ethereum.ChainManager().CurrentBlock()
+ }
+
+ statedb := state.New(block.Root(), self.ethereum.StateDb())
+
+ v, _ := self.re.Vm.ToValue(statedb.RawDump())
+
+ return v
+}
+
+func (self *jsre) stopMining(call otto.FunctionCall) otto.Value {
+ self.ethereum.StopMining()
+ return otto.TrueValue()
+}
+
+func (self *jsre) startMining(call otto.FunctionCall) otto.Value {
+ if err := self.ethereum.StartMining(); err != nil {
+ return otto.FalseValue()
+ }
+ return otto.TrueValue()
+}
+
+func (self *jsre) connect(call otto.FunctionCall) otto.Value {
+ nodeURL, err := call.Argument(0).ToString()
+ if err != nil {
+ return otto.FalseValue()
+ }
+ if err := self.ethereum.SuggestPeer(nodeURL); err != nil {
+ return otto.FalseValue()
+ }
+ return otto.TrueValue()
+}
+
+func (self *jsre) export(call otto.FunctionCall) otto.Value {
+ if len(call.ArgumentList) == 0 {
+ fmt.Println("err: require file name")
+ return otto.FalseValue()
+ }
+
+ fn, err := call.Argument(0).ToString()
+ if err != nil {
+ fmt.Println(err)
+ return otto.FalseValue()
+ }
+
+ data := self.ethereum.ChainManager().Export()
+
+ if err := ethutil.WriteFile(fn, data); err != nil {
+ fmt.Println(err)
+ return otto.FalseValue()
+ }
+
+ return otto.TrueValue()
+}
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go
new file mode 100644
index 000000000..8b01457e6
--- /dev/null
+++ b/cmd/ethereum/main.go
@@ -0,0 +1,331 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "runtime"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/codegangsta/cli"
+ "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/state"
+ "github.com/peterh/liner"
+)
+
+const (
+ ClientIdentifier = "Ethereum(G)"
+ Version = "0.9.0"
+)
+
+var (
+ clilogger = logger.NewLogger("CLI")
+ app = utils.NewApp(Version, "the go-ethereum command line interface")
+)
+
+func init() {
+ app.Action = run
+ app.HideVersion = true // we have a command to print the version
+ app.Commands = []cli.Command{
+ {
+ Action: version,
+ Name: "version",
+ Usage: "print ethereum version numbers",
+ Description: `
+The output of this command is supposed to be machine-readable.
+`,
+ },
+ {
+ Action: accountList,
+ Name: "account",
+ Usage: "manage accounts",
+ Subcommands: []cli.Command{
+ {
+ Action: accountList,
+ Name: "list",
+ Usage: "print account addresses",
+ },
+ {
+ Action: accountCreate,
+ Name: "new",
+ Usage: "create a new account",
+ },
+ },
+ },
+ {
+ Action: dump,
+ Name: "dump",
+ Usage: `dump a specific block from storage`,
+ Description: `
+The arguments are interpreted as block numbers or hashes.
+Use "ethereum dump 0" to dump the genesis block.
+`,
+ },
+ {
+ Action: runjs,
+ Name: "js",
+ Usage: `interactive JavaScript console`,
+ Description: `
+In the console, you can use the eth object to interact
+with the running ethereum stack. The API does not match
+ethereum.js.
+
+A JavaScript file can be provided as the argument. The
+runtime will execute the file and exit.
+`,
+ },
+ {
+ Action: importchain,
+ Name: "import",
+ Usage: `import a blockchain file`,
+ },
+ {
+ Action: exportchain,
+ Name: "export",
+ Usage: `export blockchain into file`,
+ },
+ }
+ app.Flags = []cli.Flag{
+ utils.UnlockedAccountFlag,
+ utils.BootnodesFlag,
+ utils.DataDirFlag,
+ utils.ListenPortFlag,
+ utils.LogFileFlag,
+ utils.LogFormatFlag,
+ utils.LogLevelFlag,
+ utils.MaxPeersFlag,
+ utils.MinerThreadsFlag,
+ utils.MiningEnabledFlag,
+ utils.NATFlag,
+ utils.NodeKeyFileFlag,
+ utils.NodeKeyHexFlag,
+ utils.RPCEnabledFlag,
+ utils.RPCListenAddrFlag,
+ utils.RPCPortFlag,
+ utils.UnencryptedKeysFlag,
+ utils.VMDebugFlag,
+ //utils.VMTypeFlag,
+ }
+
+ // missing:
+ // flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file")
+ // flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0")
+ // flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false")
+
+ // potential subcommands:
+ // flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
+ // flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")
+ // flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
+}
+
+func main() {
+ runtime.GOMAXPROCS(runtime.NumCPU())
+ defer logger.Flush()
+ if err := app.Run(os.Args); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+}
+
+func run(ctx *cli.Context) {
+ fmt.Printf("Welcome to the FRONTIER\n")
+ utils.HandleInterrupt()
+ eth, err := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ if err != nil {
+ utils.Fatalf("%v", err)
+ }
+
+ startEth(ctx, eth)
+ // this blocks the thread
+ eth.WaitForShutdown()
+}
+
+func runjs(ctx *cli.Context) {
+ eth, err := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ if err != nil {
+ utils.Fatalf("%v", err)
+ }
+
+ startEth(ctx, eth)
+ repl := newJSRE(eth)
+ if len(ctx.Args()) == 0 {
+ repl.interactive()
+ } else {
+ for _, file := range ctx.Args() {
+ repl.exec(file)
+ }
+ }
+ eth.Stop()
+ eth.WaitForShutdown()
+}
+
+func startEth(ctx *cli.Context, eth *eth.Ethereum) {
+ utils.StartEthereum(eth)
+
+ // Load startup keys. XXX we are going to need a different format
+ account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
+ if len(account) > 0 {
+ split := strings.Split(account, ":")
+ if len(split) != 2 {
+ utils.Fatalf("Illegal 'unlock' format (address:password)")
+ }
+ am := eth.AccountManager()
+ // Attempt to unlock the account
+ err := am.Unlock(ethutil.Hex2Bytes(split[0]), split[1])
+ if err != nil {
+ utils.Fatalf("Unlock account failed '%v'", err)
+ }
+ }
+ // Start auxiliary services if enabled.
+ if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
+ utils.StartRPC(eth, ctx)
+ }
+ if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
+ eth.StartMining()
+ }
+}
+
+func accountList(ctx *cli.Context) {
+ am := utils.GetAccountManager(ctx)
+ accts, err := am.Accounts()
+ if err != nil {
+ utils.Fatalf("Could not list accounts: %v", err)
+ }
+ for _, acct := range accts {
+ fmt.Printf("Address: %#x\n", acct)
+ }
+}
+
+func accountCreate(ctx *cli.Context) {
+ am := utils.GetAccountManager(ctx)
+ passphrase := ""
+ if !ctx.GlobalBool(utils.UnencryptedKeysFlag.Name) {
+ fmt.Println("The new account will be encrypted with a passphrase.")
+ fmt.Println("Please enter a passphrase now.")
+ auth, err := readPassword("Passphrase: ", true)
+ if err != nil {
+ utils.Fatalf("%v", err)
+ }
+ confirm, err := readPassword("Repeat Passphrase: ", false)
+ if err != nil {
+ utils.Fatalf("%v", err)
+ }
+ if auth != confirm {
+ utils.Fatalf("Passphrases did not match.")
+ }
+ passphrase = auth
+ }
+ acct, err := am.NewAccount(passphrase)
+ if err != nil {
+ utils.Fatalf("Could not create the account: %v", err)
+ }
+ fmt.Printf("Address: %#x\n", acct.Address)
+}
+
+func importchain(ctx *cli.Context) {
+ if len(ctx.Args()) != 1 {
+ utils.Fatalf("This command requires an argument.")
+ }
+ chainmgr, _, _ := utils.GetChain(ctx)
+ start := time.Now()
+ err := utils.ImportChain(chainmgr, ctx.Args().First())
+ if err != nil {
+ utils.Fatalf("Import error: %v\n", err)
+ }
+ fmt.Printf("Import done in %v", time.Since(start))
+ return
+}
+
+func exportchain(ctx *cli.Context) {
+ if len(ctx.Args()) != 1 {
+ utils.Fatalf("This command requires an argument.")
+ }
+ chainmgr, _, _ := utils.GetChain(ctx)
+ start := time.Now()
+ err := utils.ExportChain(chainmgr, ctx.Args().First())
+ if err != nil {
+ utils.Fatalf("Export error: %v\n", err)
+ }
+ fmt.Printf("Export done in %v", time.Since(start))
+ return
+}
+
+func dump(ctx *cli.Context) {
+ chainmgr, _, stateDb := utils.GetChain(ctx)
+ for _, arg := range ctx.Args() {
+ var block *types.Block
+ if hashish(arg) {
+ block = chainmgr.GetBlock(ethutil.Hex2Bytes(arg))
+ } else {
+ num, _ := strconv.Atoi(arg)
+ block = chainmgr.GetBlockByNumber(uint64(num))
+ }
+ if block == nil {
+ fmt.Println("{}")
+ utils.Fatalf("block not found")
+ } else {
+ statedb := state.New(block.Root(), stateDb)
+ fmt.Printf("%s\n", statedb.Dump())
+ // fmt.Println(block)
+ }
+ }
+}
+
+func version(c *cli.Context) {
+ fmt.Printf(`%v
+Version: %v
+Protocol Version: %d
+Network Id: %d
+GO: %s
+OS: %s
+GOPATH=%s
+GOROOT=%s
+`, ClientIdentifier, Version, eth.ProtocolVersion, eth.NetworkId, runtime.Version(), runtime.GOOS, os.Getenv("GOPATH"), runtime.GOROOT())
+}
+
+// hashish returns true for strings that look like hashes.
+func hashish(x string) bool {
+ _, err := strconv.Atoi(x)
+ return err != nil
+}
+
+func readPassword(prompt string, warnTerm bool) (string, error) {
+ if liner.TerminalSupported() {
+ lr := liner.NewLiner()
+ defer lr.Close()
+ return lr.PasswordPrompt(prompt)
+ }
+ if warnTerm {
+ fmt.Println("!! Unsupported terminal, password will be echoed.")
+ }
+ fmt.Print(prompt)
+ input, err := bufio.NewReader(os.Stdin).ReadString('\n')
+ fmt.Println()
+ return input, err
+}
diff --git a/cmd/ethtest/.bowerrc b/cmd/ethtest/.bowerrc
new file mode 100644
index 000000000..c3a8813e8
--- /dev/null
+++ b/cmd/ethtest/.bowerrc
@@ -0,0 +1,5 @@
+{
+ "directory": "example/js/",
+ "cwd": "./",
+ "analytics": false
+} \ No newline at end of file
diff --git a/cmd/ethtest/.editorconfig b/cmd/ethtest/.editorconfig
new file mode 100644
index 000000000..60a2751d3
--- /dev/null
+++ b/cmd/ethtest/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false \ No newline at end of file
diff --git a/cmd/ethtest/.gitignore b/cmd/ethtest/.gitignore
new file mode 100644
index 000000000..399b6dc88
--- /dev/null
+++ b/cmd/ethtest/.gitignore
@@ -0,0 +1,18 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+*.swp
+/tmp
+*/**/*un~
+*un~
+.DS_Store
+*/**/.DS_Store
+ethereum/ethereum
+ethereal/ethereal
+example/js
+node_modules
+bower_components
+npm-debug.log
diff --git a/cmd/ethtest/.jshintrc b/cmd/ethtest/.jshintrc
new file mode 100644
index 000000000..c0ec5f89d
--- /dev/null
+++ b/cmd/ethtest/.jshintrc
@@ -0,0 +1,50 @@
+{
+ "predef": [
+ "console",
+ "require",
+ "equal",
+ "test",
+ "testBoth",
+ "testWithDefault",
+ "raises",
+ "deepEqual",
+ "start",
+ "stop",
+ "ok",
+ "strictEqual",
+ "module",
+ "expect",
+ "reject",
+ "impl"
+ ],
+
+ "esnext": true,
+ "proto": true,
+ "node" : true,
+ "browser" : true,
+ "browserify" : true,
+
+ "boss" : true,
+ "curly": false,
+ "debug": true,
+ "devel": true,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": false,
+ "immed": false,
+ "laxbreak": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false,
+ "shadow": true,
+ "eqnull": true
+} \ No newline at end of file
diff --git a/cmd/ethtest/.npmignore b/cmd/ethtest/.npmignore
new file mode 100644
index 000000000..5bbffe4fd
--- /dev/null
+++ b/cmd/ethtest/.npmignore
@@ -0,0 +1,9 @@
+example/js
+node_modules
+test
+.gitignore
+.editorconfig
+.travis.yml
+.npmignore
+component.json
+testling.html \ No newline at end of file
diff --git a/cmd/ethtest/.travis.yml b/cmd/ethtest/.travis.yml
new file mode 100644
index 000000000..fafacbd5a
--- /dev/null
+++ b/cmd/ethtest/.travis.yml
@@ -0,0 +1,11 @@
+language: node_js
+node_js:
+ - "0.11"
+ - "0.10"
+before_script:
+ - npm install
+ - npm install jshint
+script:
+ - "jshint *.js lib"
+after_script:
+ - npm run-script gulp
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
new file mode 100644
index 000000000..cc5139da1
--- /dev/null
+++ b/cmd/ethtest/main.go
@@ -0,0 +1,205 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors:
+ * Jeffrey Wilcke <i@jev.io>
+ */
+
+package main
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "log"
+ "math/big"
+ "os"
+ "strconv"
+ "strings"
+
+ "github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/state"
+ "github.com/ethereum/go-ethereum/tests/helper"
+ "github.com/ethereum/go-ethereum/vm"
+)
+
+type Log struct {
+ AddressF string `json:"address"`
+ DataF string `json:"data"`
+ TopicsF []string `json:"topics"`
+ BloomF string `json:"bloom"`
+}
+
+func (self Log) Address() []byte { return ethutil.Hex2Bytes(self.AddressF) }
+func (self Log) Data() []byte { return ethutil.Hex2Bytes(self.DataF) }
+func (self Log) RlpData() interface{} { return nil }
+func (self Log) Topics() [][]byte {
+ t := make([][]byte, len(self.TopicsF))
+ for i, topic := range self.TopicsF {
+ t[i] = ethutil.Hex2Bytes(topic)
+ }
+ return t
+}
+
+type Account struct {
+ Balance string
+ Code string
+ Nonce string
+ Storage map[string]string
+}
+
+func StateObjectFromAccount(db ethutil.Database, addr string, account Account) *state.StateObject {
+ obj := state.NewStateObject(ethutil.Hex2Bytes(addr), db)
+ obj.SetBalance(ethutil.Big(account.Balance))
+
+ if ethutil.IsHex(account.Code) {
+ account.Code = account.Code[2:]
+ }
+ obj.SetCode(ethutil.Hex2Bytes(account.Code))
+ obj.SetNonce(ethutil.Big(account.Nonce).Uint64())
+
+ return obj
+}
+
+type VmTest struct {
+ Callcreates interface{}
+ //Env map[string]string
+ Env Env
+ Exec map[string]string
+ Transaction map[string]string
+ Logs []Log
+ Gas string
+ Out string
+ Post map[string]Account
+ Pre map[string]Account
+ PostStateRoot string
+}
+
+type Env struct {
+ CurrentCoinbase string
+ CurrentDifficulty string
+ CurrentGasLimit string
+ CurrentNumber string
+ CurrentTimestamp interface{}
+ PreviousHash string
+}
+
+func RunVmTest(r io.Reader) (failed int) {
+ tests := make(map[string]VmTest)
+
+ data, _ := ioutil.ReadAll(r)
+ err := json.Unmarshal(data, &tests)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ for name, test := range tests {
+ db, _ := ethdb.NewMemDatabase()
+ statedb := state.New(nil, db)
+ for addr, account := range test.Pre {
+ obj := StateObjectFromAccount(db, addr, account)
+ statedb.SetStateObject(obj)
+ }
+
+ env := make(map[string]string)
+ env["currentCoinbase"] = test.Env.CurrentCoinbase
+ env["currentDifficulty"] = test.Env.CurrentDifficulty
+ env["currentGasLimit"] = test.Env.CurrentGasLimit
+ env["currentNumber"] = test.Env.CurrentNumber
+ env["previousHash"] = test.Env.PreviousHash
+ if n, ok := test.Env.CurrentTimestamp.(float64); ok {
+ env["currentTimestamp"] = strconv.Itoa(int(n))
+ } else {
+ env["currentTimestamp"] = test.Env.CurrentTimestamp.(string)
+ }
+
+ ret, logs, _, _ := helper.RunState(statedb, env, test.Transaction)
+ statedb.Sync()
+
+ rexp := helper.FromHex(test.Out)
+ if bytes.Compare(rexp, ret) != 0 {
+ fmt.Printf("%s's return failed. Expected %x, got %x\n", name, rexp, ret)
+ failed = 1
+ }
+
+ for addr, account := range test.Post {
+ obj := statedb.GetStateObject(helper.FromHex(addr))
+ if obj == nil {
+ continue
+ }
+
+ if len(test.Exec) == 0 {
+ if obj.Balance().Cmp(ethutil.Big(account.Balance)) != 0 {
+ fmt.Printf("%s's : (%x) balance failed. Expected %v, got %v => %v\n", name, obj.Address()[:4], account.Balance, obj.Balance(), new(big.Int).Sub(ethutil.Big(account.Balance), obj.Balance()))
+ failed = 1
+ }
+ }
+
+ for addr, value := range account.Storage {
+ v := obj.GetState(helper.FromHex(addr)).Bytes()
+ vexp := helper.FromHex(value)
+
+ if bytes.Compare(v, vexp) != 0 {
+ fmt.Printf("%s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address()[0:4], addr, vexp, v, ethutil.BigD(vexp), ethutil.BigD(v))
+ failed = 1
+ }
+ }
+ }
+
+ if !bytes.Equal(ethutil.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
+ fmt.Printf("%s's : Post state root error. Expected %s, got %x\n", name, test.PostStateRoot, statedb.Root())
+ failed = 1
+ }
+
+ if len(test.Logs) > 0 {
+ if len(test.Logs) != len(logs) {
+ fmt.Printf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs))
+ failed = 1
+ } else {
+ /*
+ fmt.Println("A", test.Logs)
+ fmt.Println("B", logs)
+ for i, log := range test.Logs {
+ genBloom := ethutil.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256)
+ if !bytes.Equal(genBloom, ethutil.Hex2Bytes(log.BloomF)) {
+ t.Errorf("bloom mismatch")
+ }
+ }
+ */
+ }
+ }
+
+ logger.Flush()
+ }
+
+ return
+}
+
+func main() {
+ helper.Logger.SetLogLevel(5)
+ vm.Debug = true
+
+ if len(os.Args) > 1 {
+ os.Exit(RunVmTest(strings.NewReader(os.Args[1])))
+ } else {
+ os.Exit(RunVmTest(os.Stdin))
+ }
+}
diff --git a/cmd/evm/code.txt b/cmd/evm/code.txt
new file mode 100644
index 000000000..a964ad9d2
--- /dev/null
+++ b/cmd/evm/code.txt
@@ -0,0 +1 @@
+60006102ff5360003560001a60008114156103395760013560405260216040516020025990590160009052606052604051602002816060513760405160200281019050506002604051121561005957604051602002606051f35b604051602002599059016000905260a052600060c052604051602002599059016000905260e0526000610100526001610120525b604051610120511215610109576060515161012051602002606051015112156100d8576101205160200260605101516101005160200260e051015260016101005101610100526100f9565b61012051602002606051015160c05160200260a0510152600160c0510160c0525b600161012051016101205261008d565b60216020599059016000905260c051808252806020028301925050602082015990590160009052600081538151600182015260218101825160200260a0518260005b8381101561016657808301518186015260208101905061014b565b50505050825160200281019050604059905901600090526102405281610240515283602061024051015261024051905090509050905060c05160200280599059016000905281816020850151855160003060195a03f1508090509050905060a05260216020599059016000905261010051808252806020028301925050602082015990590160009052600081538151600182015260218101825160200260e0518260005b8381101561022557808301518186015260208101905061020a565b50505050825160200281019050604059905901600090526102c052816102c051528360206102c05101526102c05190509050905090506101005160200280599059016000905281816020850151855160003060195a03f1508090509050905060e05260405160200259905901600090526102e0526000610120525b610100516101205112156102d7576101205160200260e0510151610120516020026102e051015260016101205101610120526102a0565b60605151610100516020026102e05101526000610120525b60c05161012051121561032d576101205160200260a05101516101205160016101005101016020026102e051015260016101205101610120526102ef565b6040516020026102e051f35b50
diff --git a/cmd/evm/input.txt b/cmd/evm/input.txt
new file mode 100644
index 000000000..1b6857ab9
--- /dev/null
+++ b/cmd/evm/input.txt
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000000000000000000000000000c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000150000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001d000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000001f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000023000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000250000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002700000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000029000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002b000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002f0000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000350000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000000000000000000000000000000003700000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000039000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000003d000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000003f0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004100000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004700000000000000000000000000000000000000000000000000000000000000480000000000000000000000000000000000000000000000000000000000000049000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000004b000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000004d000000000000000000000000000000000000000000000000000000000000004e000000000000000000000000000000000000000000000000000000000000004f0000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000005100000000000000000000000000000000000000000000000000000000000000520000000000000000000000000000000000000000000000000000000000000053000000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000550000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000005700000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000059000000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000005c000000000000000000000000000000000000000000000000000000000000005d000000000000000000000000000000000000000000000000000000000000005e000000000000000000000000000000000000000000000000000000000000005f0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006100000000000000000000000000000000000000000000000000000000000000620000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000006700000000000000000000000000000000000000000000000000000000000000680000000000000000000000000000000000000000000000000000000000000069000000000000000000000000000000000000000000000000000000000000006a000000000000000000000000000000000000000000000000000000000000006b000000000000000000000000000000000000000000000000000000000000006c000000000000000000000000000000000000000000000000000000000000006d000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000000000000000000000000000000000000000006f0000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000007100000000000000000000000000000000000000000000000000000000000000720000000000000000000000000000000000000000000000000000000000000073000000000000000000000000000000000000000000000000000000000000007400000000000000000000000000000000000000000000000000000000000000750000000000000000000000000000000000000000000000000000000000000076000000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000780000000000000000000000000000000000000000000000000000000000000079000000000000000000000000000000000000000000000000000000000000007a000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007c000000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000007e000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000008100000000000000000000000000000000000000000000000000000000000000820000000000000000000000000000000000000000000000000000000000000083000000000000000000000000000000000000000000000000000000000000008400000000000000000000000000000000000000000000000000000000000000850000000000000000000000000000000000000000000000000000000000000086000000000000000000000000000000000000000000000000000000000000008700000000000000000000000000000000000000000000000000000000000000880000000000000000000000000000000000000000000000000000000000000089000000000000000000000000000000000000000000000000000000000000008a000000000000000000000000000000000000000000000000000000000000008b000000000000000000000000000000000000000000000000000000000000008c000000000000000000000000000000000000000000000000000000000000008d000000000000000000000000000000000000000000000000000000000000008e000000000000000000000000000000000000000000000000000000000000008f0000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009100000000000000000000000000000000000000000000000000000000000000920000000000000000000000000000000000000000000000000000000000000093000000000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000000000000000000000000000950000000000000000000000000000000000000000000000000000000000000096000000000000000000000000000000000000000000000000000000000000009700000000000000000000000000000000000000000000000000000000000000980000000000000000000000000000000000000000000000000000000000000099000000000000000000000000000000000000000000000000000000000000009a000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000009d000000000000000000000000000000000000000000000000000000000000009e000000000000000000000000000000000000000000000000000000000000009f00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a100000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000a300000000000000000000000000000000000000000000000000000000000000a400000000000000000000000000000000000000000000000000000000000000a500000000000000000000000000000000000000000000000000000000000000a600000000000000000000000000000000000000000000000000000000000000a700000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000a900000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000ab00000000000000000000000000000000000000000000000000000000000000ac00000000000000000000000000000000000000000000000000000000000000ad00000000000000000000000000000000000000000000000000000000000000ae00000000000000000000000000000000000000000000000000000000000000af00000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000b100000000000000000000000000000000000000000000000000000000000000b200000000000000000000000000000000000000000000000000000000000000b300000000000000000000000000000000000000000000000000000000000000b400000000000000000000000000000000000000000000000000000000000000b500000000000000000000000000000000000000000000000000000000000000b600000000000000000000000000000000000000000000000000000000000000b700000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000b900000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000bb00000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000000bd00000000000000000000000000000000000000000000000000000000000000be00000000000000000000000000000000000000000000000000000000000000bf00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c300000000000000000000000000000000000000000000000000000000000000c400000000000000000000000000000000000000000000000000000000000000c500000000000000000000000000000000000000000000000000000000000000c600000000000000000000000000000000000000000000000000000000000000c7
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
new file mode 100644
index 000000000..960558bb4
--- /dev/null
+++ b/cmd/evm/main.go
@@ -0,0 +1,163 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "math/big"
+ "os"
+ "runtime"
+ "time"
+
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/state"
+ "github.com/ethereum/go-ethereum/vm"
+)
+
+var (
+ code = flag.String("code", "", "evm code")
+ loglevel = flag.Int("log", 4, "log level")
+ gas = flag.String("gas", "1000000000", "gas amount")
+ price = flag.String("price", "0", "gas price")
+ value = flag.String("value", "0", "tx value")
+ dump = flag.Bool("dump", false, "dump state after run")
+ data = flag.String("data", "", "data")
+)
+
+func perr(v ...interface{}) {
+ fmt.Println(v...)
+ //os.Exit(1)
+}
+
+func main() {
+ flag.Parse()
+
+ logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.LogLevel(*loglevel)))
+
+ db, _ := ethdb.NewMemDatabase()
+ statedb := state.New(nil, db)
+ sender := statedb.NewStateObject([]byte("sender"))
+ receiver := statedb.NewStateObject([]byte("receiver"))
+ receiver.SetCode(ethutil.Hex2Bytes(*code))
+
+ vmenv := NewEnv(statedb, []byte("evmuser"), ethutil.Big(*value))
+
+ tstart := time.Now()
+
+ ret, e := vmenv.Call(sender, receiver.Address(), ethutil.Hex2Bytes(*data), ethutil.Big(*gas), ethutil.Big(*price), ethutil.Big(*value))
+
+ logger.Flush()
+ if e != nil {
+ perr(e)
+ }
+
+ if *dump {
+ fmt.Println(string(statedb.Dump()))
+ }
+
+ var mem runtime.MemStats
+ runtime.ReadMemStats(&mem)
+ fmt.Printf("vm took %v\n", time.Since(tstart))
+ fmt.Printf(`alloc: %d
+tot alloc: %d
+no. malloc: %d
+heap alloc: %d
+heap objs: %d
+num gc: %d
+`, mem.Alloc, mem.TotalAlloc, mem.Mallocs, mem.HeapAlloc, mem.HeapObjects, mem.NumGC)
+
+ fmt.Printf("%x\n", ret)
+}
+
+type VMEnv struct {
+ state *state.StateDB
+ block *types.Block
+
+ transactor []byte
+ value *big.Int
+
+ depth int
+ Gas *big.Int
+ time int64
+}
+
+func NewEnv(state *state.StateDB, transactor []byte, value *big.Int) *VMEnv {
+ return &VMEnv{
+ state: state,
+ transactor: transactor,
+ value: value,
+ time: time.Now().Unix(),
+ }
+}
+
+func (self *VMEnv) State() *state.StateDB { return self.state }
+func (self *VMEnv) Origin() []byte { return self.transactor }
+func (self *VMEnv) BlockNumber() *big.Int { return ethutil.Big0 }
+func (self *VMEnv) PrevHash() []byte { return make([]byte, 32) }
+func (self *VMEnv) Coinbase() []byte { return self.transactor }
+func (self *VMEnv) Time() int64 { return self.time }
+func (self *VMEnv) Difficulty() *big.Int { return ethutil.Big1 }
+func (self *VMEnv) BlockHash() []byte { return make([]byte, 32) }
+func (self *VMEnv) Value() *big.Int { return self.value }
+func (self *VMEnv) GasLimit() *big.Int { return big.NewInt(1000000000) }
+func (self *VMEnv) VmType() vm.Type { return vm.StdVmTy }
+func (self *VMEnv) Depth() int { return 0 }
+func (self *VMEnv) SetDepth(i int) { self.depth = i }
+func (self *VMEnv) GetHash(n uint64) []byte {
+ if self.block.Number().Cmp(big.NewInt(int64(n))) == 0 {
+ return self.block.Hash()
+ }
+ return nil
+}
+func (self *VMEnv) AddLog(log state.Log) {
+ self.state.AddLog(log)
+}
+func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
+ return vm.Transfer(from, to, amount)
+}
+
+func (self *VMEnv) vm(addr, data []byte, gas, price, value *big.Int) *core.Execution {
+ return core.NewExecution(self, addr, data, gas, price, value)
+}
+
+func (self *VMEnv) Call(caller vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) {
+ exe := self.vm(addr, data, gas, price, value)
+ ret, err := exe.Call(addr, caller)
+ self.Gas = exe.Gas
+
+ return ret, err
+}
+func (self *VMEnv) CallCode(caller vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) {
+ exe := self.vm(caller.Address(), data, gas, price, value)
+ return exe.Call(addr, caller)
+}
+
+func (self *VMEnv) Create(caller vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef) {
+ exe := self.vm(addr, data, gas, price, value)
+ return exe.Create(caller)
+}
diff --git a/cmd/mist/assets/back.png b/cmd/mist/assets/back.png
new file mode 100644
index 000000000..38fc84d6e
--- /dev/null
+++ b/cmd/mist/assets/back.png
Binary files differ
diff --git a/cmd/mist/assets/backButton.png b/cmd/mist/assets/backButton.png
new file mode 100644
index 000000000..eef997434
--- /dev/null
+++ b/cmd/mist/assets/backButton.png
Binary files differ
diff --git a/cmd/mist/assets/backButton@2x.png b/cmd/mist/assets/backButton@2x.png
new file mode 100644
index 000000000..b72fd73f4
--- /dev/null
+++ b/cmd/mist/assets/backButton@2x.png
Binary files differ
diff --git a/cmd/mist/assets/backButtonDisabled.png b/cmd/mist/assets/backButtonDisabled.png
new file mode 100644
index 000000000..428747870
--- /dev/null
+++ b/cmd/mist/assets/backButtonDisabled.png
Binary files differ
diff --git a/cmd/mist/assets/backButtonDisabled@2x.png b/cmd/mist/assets/backButtonDisabled@2x.png
new file mode 100644
index 000000000..0eaa6daa5
--- /dev/null
+++ b/cmd/mist/assets/backButtonDisabled@2x.png
Binary files differ
diff --git a/cmd/mist/assets/backButtonHover.png b/cmd/mist/assets/backButtonHover.png
new file mode 100644
index 000000000..8c5226f5a
--- /dev/null
+++ b/cmd/mist/assets/backButtonHover.png
Binary files differ
diff --git a/cmd/mist/assets/backButtonHover@2x.png b/cmd/mist/assets/backButtonHover@2x.png
new file mode 100644
index 000000000..406601ebc
--- /dev/null
+++ b/cmd/mist/assets/backButtonHover@2x.png
Binary files differ
diff --git a/cmd/mist/assets/browser.png b/cmd/mist/assets/browser.png
new file mode 100644
index 000000000..074c9ae3c
--- /dev/null
+++ b/cmd/mist/assets/browser.png
Binary files differ
diff --git a/cmd/mist/assets/browser@2x.png b/cmd/mist/assets/browser@2x.png
new file mode 100644
index 000000000..8ca417608
--- /dev/null
+++ b/cmd/mist/assets/browser@2x.png
Binary files differ
diff --git a/cmd/mist/assets/bug.png b/cmd/mist/assets/bug.png
new file mode 100644
index 000000000..f5e85dc99
--- /dev/null
+++ b/cmd/mist/assets/bug.png
Binary files differ
diff --git a/cmd/mist/assets/close.png b/cmd/mist/assets/close.png
new file mode 100644
index 000000000..88df442c5
--- /dev/null
+++ b/cmd/mist/assets/close.png
Binary files differ
diff --git a/cmd/mist/assets/debugger/debugger.qml b/cmd/mist/assets/debugger/debugger.qml
new file mode 100644
index 000000000..5566e8fca
--- /dev/null
+++ b/cmd/mist/assets/debugger/debugger.qml
@@ -0,0 +1,436 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+ApplicationWindow {
+ id: win
+ visible: false
+ title: "IceCREAM"
+ minimumWidth: 1280
+ minimumHeight: 700
+ width: 1290
+ height: 750
+
+ property alias codeText: codeEditor.text
+ property alias dataText: rawDataField.text
+
+ onClosing: {
+ //dbg.Stop()
+ }
+
+ menuBar: MenuBar {
+ Menu {
+ title: "Edit"
+ MenuItem {
+ text: "Focus code"
+ shortcut: "Ctrl+1"
+ onTriggered: {
+ codeEditor.focus = true
+ }
+ }
+ MenuItem {
+ text: "Focus data"
+ shortcut: "Ctrl+2"
+ onTriggered: {
+ rawDataField.focus = true
+ }
+ }
+
+ MenuItem {
+ text: "Command"
+ shortcut: "Ctrl+l"
+ onTriggered: {
+ dbgCommand.focus = true
+ }
+ }
+ }
+
+ Menu {
+ title: "Debugger"
+ MenuItem {
+ text: "Run"
+ shortcut: "Ctrl+r"
+ onTriggered: debugCurrent()
+ }
+
+ MenuItem {
+ text: "Stop"
+ onTriggered: dbp.stop()
+ }
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: "Next"
+ shortcut: "Ctrl+n"
+ onTriggered: dbg.next()
+ }
+
+ MenuItem {
+ text: "Continue"
+ shortcut: "Ctrl+g"
+ onTriggered: dbg.continue()
+ }
+ }
+ }
+
+
+ SplitView {
+ anchors.fill: parent
+ property var asmModel: ListModel {
+ id: asmModel
+ }
+
+ TableView {
+ id: asmTableView
+ width: 200
+ headerVisible: false
+ TableViewColumn{ role: "value" ; title: "" ; width: asmTableView.width - 2 }
+ model: asmModel
+ /*
+ alternatingRowColors: false
+ itemDelegate: Item {
+ Rectangle {
+ anchors.fill: parent
+ color: "#DDD"
+ Text {
+ anchors {
+ left: parent.left
+ right: parent.right
+ leftMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ color: "#333"
+ elide: styleData.elideMode
+ text: styleData.value
+ font.pixelSize: 11
+ MouseArea {
+ acceptedButtons: Qt.LeftButton
+ anchors.fill: parent
+ onClicked: {
+ mouse.accepted = true
+ }
+ }
+ }
+ }
+ }
+ */
+ }
+
+ Rectangle {
+ color: "#00000000"
+ anchors.left: asmTableView.right
+ anchors.right: parent.right
+ SplitView {
+ orientation: Qt.Vertical
+ anchors.fill: parent
+
+ Rectangle {
+ color: "#00000000"
+ height: 330
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ TextArea {
+ id: codeEditor
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: settings.left
+ focus: true
+
+ /*
+ Timer {
+ id: compileTimer
+ interval: 500 ; running: true ; repeat: true
+ onTriggered: {
+ dbg.autoComp(codeEditor.text)
+ }
+ }
+ */
+ }
+
+ Column {
+ id: settings
+ spacing: 5
+ width: 300
+ height: parent.height
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+
+ Label {
+ text: "Arbitrary data"
+ }
+ TextArea {
+ id: rawDataField
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: 150
+ }
+
+ Label {
+ text: "Amount"
+ }
+ TextField {
+ id: txValue
+ width: 200
+ placeholderText: "Amount"
+ validator: RegExpValidator { regExp: /\d*/ }
+ }
+ Label {
+ text: "Amount of gas"
+ }
+ TextField {
+ id: txGas
+ width: 200
+ validator: RegExpValidator { regExp: /\d*/ }
+ text: "10000"
+ placeholderText: "Gas"
+ }
+ Label {
+ text: "Gas price"
+ }
+ TextField {
+ id: txGasPrice
+ width: 200
+ placeholderText: "Gas price"
+ text: "1000000000000"
+ validator: RegExpValidator { regExp: /\d*/ }
+ }
+ }
+ }
+
+ SplitView {
+ orientation: Qt.Vertical
+ id: inspectorPane
+ height: 500
+
+ SplitView {
+ orientation: Qt.Horizontal
+ height: 150
+
+ TableView {
+ id: stackTableView
+ property var stackModel: ListModel {
+ id: stackModel
+ }
+ height: parent.height
+ width: 300
+ TableViewColumn{ role: "value" ; title: "Local VM stack" ; width: stackTableView.width - 2 }
+ model: stackModel
+ }
+
+ TableView {
+ id: memoryTableView
+ property var memModel: ListModel {
+ id: memModel
+ }
+ height: parent.height
+ width: parent.width - stackTableView.width
+ TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50 }
+ TableViewColumn{ role: "value" ; title: "Memory" ; width: 650 }
+ model: memModel
+ }
+ }
+
+ Rectangle {
+ height: 100
+ width: parent.width
+ TableView {
+ id: storageTableView
+ property var memModel: ListModel {
+ id: storageModel
+ }
+ height: parent.height
+ width: parent.width
+ TableViewColumn{ id: key ; role: "key" ; title: "#" ; width: storageTableView.width / 2 - 1}
+ TableViewColumn{ role: "value" ; title: "Storage" ; width: storageTableView.width / 2 - 1}
+ model: storageModel
+ }
+ }
+
+ Rectangle {
+ height: 200
+ width: parent.width * 0.66
+ TableView {
+ id: logTableView
+ property var logModel: ListModel {
+ id: logModel
+ }
+ height: parent.height
+ width: parent.width
+ TableViewColumn{ id: message ; role: "message" ; title: "log" ; width: logTableView.width - 2 }
+ model: logModel
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ function exec() {
+ dbg.execCommand(dbgCommand.text);
+ dbgCommand.text = "";
+ }
+ statusBar: StatusBar {
+ height: 30
+
+
+ TextField {
+ id: dbgCommand
+ y: 1
+ x: asmTableView.width
+ width: 500
+ placeholderText: "Debugger (type 'help')"
+ Keys.onReturnPressed: {
+ exec()
+ }
+ }
+
+ RowLayout {
+ anchors.left: dbgCommand.right
+ anchors.leftMargin: 10
+ spacing: 5
+ y: parent.height / 2 - this.height / 2
+
+ Text {
+ objectName: "stackFrame"
+ font.pixelSize: 10
+ text: "<b>stack ptr</b>: 0"
+ }
+
+ Text {
+ objectName: "stackSize"
+ font.pixelSize: 10
+ text: "<b>stack size</b>: 0"
+ }
+
+ Text {
+ objectName: "memSize"
+ font.pixelSize: 10
+ text: "<b>mem size</b>: 0"
+ }
+ }
+ }
+
+ toolBar: ToolBar {
+ height: 30
+ RowLayout {
+ spacing: 10
+
+ Button {
+ property var enabled: true
+ id: debugStart
+ onClicked: {
+ debugCurrent()
+ }
+ text: "Debug"
+ }
+
+ Button {
+ property var enabled: true
+ id: debugNextButton
+ onClicked: {
+ dbg.next()
+ }
+ text: "Next"
+ }
+
+ Button {
+ id: debugContinueButton
+ onClicked: {
+ dbg.continue()
+ }
+ text: "Continue"
+ }
+ }
+
+
+ ComboBox {
+ visible: false
+ id: snippets
+ anchors.right: parent.right
+ model: ListModel {
+ ListElement { text: "Snippets" ; value: "" }
+ ListElement { text: "Call Contract" ; value: "var[2] in = { \"arg1\", 0xdeadbeef };\nvar ret;\n\nvar success = call(0x0c542ddea93dae0c2fcb2cf175f03ad80d6be9a0, 0, 7000, in, ret)\n\nreturn ret" }
+ }
+ onCurrentIndexChanged: {
+ if(currentIndex != 0) {
+ var code = snippets.model.get(currentIndex).value;
+ codeEditor.insert(codeEditor.cursorPosition, code)
+ }
+ }
+ }
+
+ }
+
+ function debugCurrent() {
+ dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text, rawDataField.text)
+ }
+
+ function setAsm(asm) {
+ asmModel.append({asm: asm})
+ }
+
+ function clearAsm() {
+ asmModel.clear()
+ }
+
+ function setInstruction(num) {
+ asmTableView.selection.clear()
+ asmTableView.selection.select(num)
+ asmTableView.positionViewAtRow(num, ListView.Center)
+ }
+
+ function setMem(mem) {
+ memModel.append({num: mem.num, value: mem.value})
+ }
+ function clearMem(){
+ memModel.clear()
+ }
+
+ function setStack(stack) {
+ stackModel.append({value: stack})
+ }
+ function addDebugMessage(message){
+ debuggerLog.append({value: message})
+ }
+
+ function clearStack() {
+ stackModel.clear()
+ }
+
+ function clearStorage() {
+ storageModel.clear()
+ }
+
+ function setStorage(storage) {
+ storageModel.append({key: storage.key, value: storage.value})
+ }
+
+ function setLog(msg) {
+ // Remove first item once we've reached max log items
+ if(logModel.count > 250) {
+ logModel.remove(0)
+ }
+
+ if(msg.len != 0) {
+ if(logTableView.flickableItem.atYEnd) {
+ logModel.append({message: msg})
+ logTableView.positionViewAtRow(logTableView.rowCount - 1, ListView.Contain)
+ } else {
+ logModel.append({message: msg})
+ }
+ }
+ }
+
+ function clearLog() {
+ logModel.clear()
+ }
+}
diff --git a/cmd/mist/assets/examples/abi.html b/cmd/mist/assets/examples/abi.html
new file mode 100644
index 000000000..8170e88b0
--- /dev/null
+++ b/cmd/mist/assets/examples/abi.html
@@ -0,0 +1,55 @@
+<!doctype>
+<html>
+<head>
+<title>Hello world</title>
+<script src="../ext/bignumber.min.js"></script>
+<script src="../ext/ethereum.js/dist/ethereum.js"></script>
+<script>
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
+ var eth = web3.eth;
+ var desc = [{
+ "name": "multiply(uint256)",
+ "inputs": [{
+ "name": "a",
+ "type": "uint256"
+ }],
+ "outputs": [{
+ "name": "d",
+ "type": "uint256"
+ }]
+ }];
+ var address = web3.eth.transact({
+ data: "0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056",
+ gasPrice: "1000000000000000",
+ gas: "10000",
+ });
+ var contract = web3.eth.contract(address, desc);
+
+ function calculate() {
+ var param = parseInt(document.getElementById('value').value);
+
+ var res = contract.call().multiply(param);
+ document.getElementById('result').innerText = res.toString(10);
+ }
+</script>
+</head>
+<body>
+<h3>Contract content</h3>
+<textarea style="height:100px; width: 300px;" disabled="disabled">
+contract test {
+ function multiply(uint a) returns(uint d) {
+ return a * 7;
+ }
+}
+</textarea>
+<code><pre>
+603880600c6000396000f3006001600060e060020a600035048063c6888fa1140
+05b6021600435602b565b8060005260206000f35b600081600702905091905056</pre></code>
+
+<hr>
+<div>7 x <input type="number" id="value" onkeyup='calculate()'></input> =
+<span id="result"></spa>
+
+</body>
+</html>
diff --git a/cmd/mist/assets/examples/balance.html b/cmd/mist/assets/examples/balance.html
new file mode 100644
index 000000000..bc483a879
--- /dev/null
+++ b/cmd/mist/assets/examples/balance.html
@@ -0,0 +1,40 @@
+<!doctype>
+<html>
+
+<head>
+<script src="../ext/bignumber.min.js"></script>
+<script src="../ext/ethereum.js/dist/ethereum.js"></script>
+<script type="text/javascript">
+
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
+
+ function watchBalance() {
+ var coinbase = web3.eth.coinbase;
+ var originalBalance = 0;
+
+ var balance = web3.eth.balanceAt(coinbase);
+ var originalBalance = web3.toDecimal(balance);
+ document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
+
+ web3.eth.watch({altered: coinbase}).changed(function() {
+ balance = web3.eth.balanceAt(coinbase)
+ var currentBalance = web3.toDecimal(balance);
+ document.getElementById("current").innerText = 'current: ' + currentBalance;
+ document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
+ });
+ }
+
+</script>
+</head>
+<body>
+ <h1>coinbase balance</h1>
+ <button type="button" onClick="watchBalance();">watch balance</button>
+ <div></div>
+ <div id="original"></div>
+ <div id="current"></div>
+ <div id="diff"></div>
+</body>
+</html>
+
+
diff --git a/cmd/mist/assets/examples/bomb.html b/cmd/mist/assets/examples/bomb.html
new file mode 100644
index 000000000..62540f9bb
--- /dev/null
+++ b/cmd/mist/assets/examples/bomb.html
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script src="../ext/bignumber.min.js"></script>
+<script src="../ext/ethereum.js/dist/ethereum.js"></script>
+
+<script>
+var web3 = require('web3');
+web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8545'));
+var eth = web3.eth;
+
+function bomb() {
+ for (var i = 0; i < 200; i++) {
+ eth.transact({})
+ }
+}
+</script>
+</head>
+
+<body>
+<button onclick="bomb();">BOOM!</button>
+</body>
+</html>
diff --git a/cmd/mist/assets/examples/coin.html b/cmd/mist/assets/examples/coin.html
new file mode 100644
index 000000000..96f2299a5
--- /dev/null
+++ b/cmd/mist/assets/examples/coin.html
@@ -0,0 +1,154 @@
+<!doctype>
+<html>
+<title>JevCoin</title>
+<head>
+<script type="text/javascript" src="../ext/bignumber.min.js"></script>
+<script type="text/javascript" src="../ext/ethereum.js/dist/ethereum.js"></script>
+</head>
+<body>
+
+<h1>JevCoin <code id="contract_addr"></code></h1>
+<div>
+ <strong>Balance</strong>
+ <span id="balance"></strong>
+</div>
+
+<div>
+ <span>Address:</span>
+ <input type="text" id="address" style="width:200px">
+ <span>Amount:</span>
+ <input type="text" id="amount" style="width:200px">
+ <button onclick="transact()">Send</button>
+ <span id="message"></span>
+</div>
+
+<hr>
+
+<table width="100%" id="table">
+ <tr><td style="width:40%;">Address</td><td>Balance</td></tr>
+ <tbody id="table_body"></tbody>
+</table>
+
+</body>
+
+<script type="text/javascript">
+ var web3 = require('web3');
+ var eth = web3.eth;
+
+ web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
+ var desc = [{
+ "name": "balance(address)",
+ "type": "function",
+ "inputs": [{
+ "name": "who",
+ "type": "address"
+ }],
+ "constant": true,
+ "outputs": [{
+ "name": "value",
+ "type": "uint256"
+ }]
+ }, {
+ "name": "send(address,uint256)",
+ "type": "function",
+ "inputs": [{
+ "name": "to",
+ "type": "address"
+ }, {
+ "name": "value",
+ "type": "uint256"
+ }],
+ "outputs": []
+ }, {
+ "name":"Changed",
+ "type":"event",
+ "inputs": [
+ {"name":"from","type":"address","indexed":true},
+ {"name":"amount","type":"uint256","indexed":true},
+ ],
+ }];
+
+ var address = localStorage.getItem("address");
+ // deploy if not exist
+ if (address == null) {
+ var code = "0x60056013565b61014f8061003a6000396000f35b620f42406000600033600160a060020a0316815260200190815260200160002081905550560060e060020a600035048063d0679d3414610020578063e3d670d71461003457005b61002e600435602435610049565b60006000f35b61003f600435610129565b8060005260206000f35b806000600033600160a060020a03168152602001908152602001600020541061007157610076565b610125565b806000600033600160a060020a03168152602001908152602001600020908154039081905550806000600084600160a060020a031681526020019081526020016000209081540190819055508033600160a060020a03167fb52dda022b6c1a1f40905a85f257f689aa5d69d850e49cf939d688fbe5af594660006000a38082600160a060020a03167fb52dda022b6c1a1f40905a85f257f689aa5d69d850e49cf939d688fbe5af594660006000a35b5050565b60006000600083600160a060020a0316815260200190815260200160002054905091905056";
+ address = web3.eth.transact({from: eth.coinbase, data: code});
+ localStorage.setItem("address", address);
+ }
+ document.querySelector("#contract_addr").innerHTML = address;
+
+ var Contract = web3.eth.contract(desc);
+ contract = new Contract(address);
+ contract.Changed({from: eth.coinbase}).changed(function() {
+ refresh();
+ });
+
+ function refresh() {
+ document.querySelector("#balance").innerHTML = contract.balance(eth.coinbase);
+
+ var table = document.querySelector("#table_body");
+ table.innerHTML = ""; // clear
+
+ var storage = eth.getStorage(address);
+ table.innerHTML = "";
+ for( var item in storage ) {
+ table.innerHTML += "<tr><td>"+item+"</td><td>"+web3.toDecimal(storage[item])+"</td></tr>";
+ }
+ }
+
+ function transact() {
+ var to = document.querySelector("#address");
+ if( to.value.length == 0 ) {
+ to = "0x4205b06c2cfa0e30359edcab94543266cb6fa1d3";
+ } else {
+ if (to.value.substr(0,2) != "0x")
+ to.value = "0x"+to.value;
+ }
+
+ var value = document.querySelector("#amount");
+ var amount = parseInt( value.value );
+ console.log("transact: ", to.value, " => ", amount)
+
+ contract.send( to.value, amount );
+
+ to.value = "";
+ value.value = "";
+
+ var message = document.querySelector("#message")
+ message.innerHTML = "Submitted";
+ setTimeout(function() {
+ message.innerHTML = "";
+ }, 1000);
+ }
+
+ refresh();
+</script>
+</html>
+
+<!--
+contract JevCoin {
+ function JevCoin()
+ {
+ balances[msg.sender] = 1000000;
+ }
+
+ event Changed(address indexed from, uint indexed amount);
+ function send(address to, uint value)
+ {
+ if( balances[msg.sender] < value ) return;
+
+ balances[msg.sender] -= value;
+ balances[to] += value;
+
+ Changed(msg.sender, value);
+ Changed(to, value);
+ }
+
+ function balance(address who) constant returns(uint t)
+ {
+ t = balances[who];
+ }
+
+ mapping(address => uint256) balances;
+ }
+-!>
diff --git a/cmd/mist/assets/examples/coin.js b/cmd/mist/assets/examples/coin.js
new file mode 100644
index 000000000..77daac846
--- /dev/null
+++ b/cmd/mist/assets/examples/coin.js
@@ -0,0 +1,65 @@
+var walletABI = [
+ {
+ "name":"confirm",
+ "type":"function",
+ "constant":false,
+ "inputs":[
+ {"name":"_h","type":"hash256"}
+ ],
+ "outputs":[]
+ },{
+ "name":"execute",
+ "constant":false,
+ "type":"function",
+ "inputs":[
+ {"name":"_to","type":"address"},
+ {"name":"_value","type":"uint256"},
+ {"name":"_data","type":"bytes"}
+ ],
+ "outputs":[
+ {"name":"_r","type":"hash256"}
+ ]
+ },{
+ "name":"kill",
+ "type":"function",
+ "constant":false,
+ "inputs":[
+ {"name":"_to","type":"address"}
+ ],
+ "outputs":[]
+ },{
+ "name":"changeOwner",
+ "type":"function",
+ "constant":false,
+ "inputs":[
+ {"name":"_from","type":"address"},
+ {"name":"_to","type":"address"}
+ ],
+ "outputs":[]
+ },{
+ "name":"CashIn",
+ "type":"event",
+ "inputs":[
+ {"indexed":false,"name":"value","type":"uint256"}
+ ]
+ },{
+ "name":"SingleTransact",
+ "type":"event",
+ "inputs":[
+ {"indexed":true,"name":"out","type":"string32"},
+ {"indexed":false,"name":"owner","type":"address"},
+ {"indexed":false,"name":"value","type":"uint256"},
+ {"indexed":false,"name":"to","type":"address"}
+ ]
+ },{
+ "name":"MultiTransact",
+ "type":"event",
+ "inputs":[
+ {"indexed":true,"name":"out","type":"string32"},
+ {"indexed":false,"name":"owner","type":"address"},
+ {"indexed":false,"name":"operation","type":"hash256"},
+ {"indexed":false,"name":"value","type":"uint256"},
+ {"indexed":false,"name":"to","type":"address"}
+ ]
+ }
+];
diff --git a/cmd/mist/assets/examples/info.html b/cmd/mist/assets/examples/info.html
new file mode 100644
index 000000000..3b958a494
--- /dev/null
+++ b/cmd/mist/assets/examples/info.html
@@ -0,0 +1,84 @@
+
+<!doctype>
+<html>
+<head>
+<meta name="badge" content="10">
+<script type="text/javascript" src="../ext/bignumber.min.js"></script>
+<script type="text/javascript" src="../ext/ethereum.js/dist/ethereum.js"></script>
+</head>
+<body>
+ <h1>Info</h1>
+
+ <table width="100%">
+ <tr>
+ <td>Block number</td>
+ <td id="number"></td>
+ </tr>
+
+ <tr>
+ <td>Peer count</td>
+ <td id="peer_count"></td>
+ </tr>
+
+ <tr>
+ <td>Default block</td>
+ <td id="default_block"></td>
+ </tr>
+
+ <tr>
+ <td>Accounts</td>
+ <td id="accounts"></td>
+ </tr>
+
+ <tr>
+ <td>Balance</td>
+ <td id="balance"></td>
+
+ <tr>
+ <td>Gas price</td>
+ <td id="gas_price"></td>
+ </tr>
+
+ <tr>
+ <td>Mining</td>
+ <td id="mining"></td>
+ </tr>
+
+ <tr>
+ <td>Listening</td>
+ <td id="listening"></td>
+ </tr>
+
+ <tr>
+ <td>Coinbase</td>
+ <td id="coinbase"></td>
+ </tr>
+ </table>
+</body>
+
+<script type="text/javascript">
+ var web3 = require('web3');
+ var eth = web3.eth;
+
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8545'));
+
+ eth.defaultBlock = -2
+
+ document.querySelector("#number").innerHTML = eth.number;
+ document.querySelector("#coinbase").innerHTML = eth.coinbase
+ document.querySelector("#peer_count").innerHTML = eth.peerCount;
+ document.querySelector("#default_block").innerHTML = eth.defaultBlock;
+ document.querySelector("#accounts").innerHTML = eth.accounts;
+ document.querySelector("#balance").innerHTML = web3.toEth(eth.balanceAt(eth.accounts[0]));
+ document.querySelector("#gas_price").innerHTML = eth.gasPrice;
+ document.querySelector("#mining").innerHTML = eth.mining;
+ document.querySelector("#listening").innerHTML = eth.listening;
+ eth.watch('chain').changed(function() {
+ document.querySelector("#number").innerHTML = eth.number;
+ });
+
+
+</script>
+
+</html>
+
diff --git a/cmd/mist/assets/examples/whisper.html b/cmd/mist/assets/examples/whisper.html
new file mode 100644
index 000000000..ad568f783
--- /dev/null
+++ b/cmd/mist/assets/examples/whisper.html
@@ -0,0 +1,70 @@
+<!doctype>
+<html>
+<title>Whisper test</title>
+<head>
+<script type="text/javascript" src="../ext/bignumber.min.js"></script>
+<script type="text/javascript" src="../ext/ethereum.js/dist/ethereum.js"></script>
+</head>
+<body>
+
+<h1>Whisper test</h1>
+
+<button onclick="test()">Send</button>
+<button onclick="test2()">Private send</button>
+
+<table width="100%" id="table">
+ <tr>
+ <td>Count</td>
+ <td id="count"></td>
+ </tr>
+
+ <tr>
+ <td>ID</td>
+ <td id="id"></td>
+ </tr>
+
+ <tr>
+ <td>Has identity</td>
+ <td id="known"></td>
+ </tr>
+</table>
+</body>
+
+<script type="text/javascript">
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
+
+ var shh = web3.shh;
+
+ var id = shh.newIdentity();
+ document.querySelector("#id").innerHTML = id;
+ document.querySelector("#known").innerHTML = shh.haveIdentity(id);
+
+ var watch = shh.watch({topics: ["test"]})
+ watch.arrived(function(message) {
+ document.querySelector("#table").innerHTML += "<tr><td colspan='2'>"+JSON.stringify(message)+"</td></tr>";
+ });
+
+ var selfWatch = shh.watch({to: id, topics: ["test"]})
+ selfWatch.arrived(function(message) {
+ document.querySelector("#table").innerHTML += "<tr><td>To me</td><td>"+JSON.stringify(message)+"</td></tr>";
+ });
+
+ function test() {
+ shh.post({topics: ["test"], payload: web3.fromAscii("test it")});
+ count();
+ }
+
+ function test2() {
+ shh.post({to: id, topics: ["test"], payload: web3.fromAscii("Private")});
+ count();
+ }
+
+ function count() {
+ document.querySelector("#count").innerHTML = watch.messages().length;
+ }
+</script>
+
+</html>
+
+
diff --git a/cmd/mist/assets/ext/.bowerrc b/cmd/mist/assets/ext/.bowerrc
new file mode 100644
index 000000000..c3a8813e8
--- /dev/null
+++ b/cmd/mist/assets/ext/.bowerrc
@@ -0,0 +1,5 @@
+{
+ "directory": "example/js/",
+ "cwd": "./",
+ "analytics": false
+} \ No newline at end of file
diff --git a/cmd/mist/assets/ext/.editorconfig b/cmd/mist/assets/ext/.editorconfig
new file mode 100644
index 000000000..60a2751d3
--- /dev/null
+++ b/cmd/mist/assets/ext/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false \ No newline at end of file
diff --git a/cmd/mist/assets/ext/.gitignore b/cmd/mist/assets/ext/.gitignore
new file mode 100644
index 000000000..399b6dc88
--- /dev/null
+++ b/cmd/mist/assets/ext/.gitignore
@@ -0,0 +1,18 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+*.swp
+/tmp
+*/**/*un~
+*un~
+.DS_Store
+*/**/.DS_Store
+ethereum/ethereum
+ethereal/ethereal
+example/js
+node_modules
+bower_components
+npm-debug.log
diff --git a/cmd/mist/assets/ext/.jshintrc b/cmd/mist/assets/ext/.jshintrc
new file mode 100644
index 000000000..c0ec5f89d
--- /dev/null
+++ b/cmd/mist/assets/ext/.jshintrc
@@ -0,0 +1,50 @@
+{
+ "predef": [
+ "console",
+ "require",
+ "equal",
+ "test",
+ "testBoth",
+ "testWithDefault",
+ "raises",
+ "deepEqual",
+ "start",
+ "stop",
+ "ok",
+ "strictEqual",
+ "module",
+ "expect",
+ "reject",
+ "impl"
+ ],
+
+ "esnext": true,
+ "proto": true,
+ "node" : true,
+ "browser" : true,
+ "browserify" : true,
+
+ "boss" : true,
+ "curly": false,
+ "debug": true,
+ "devel": true,
+ "eqeqeq": true,
+ "evil": true,
+ "forin": false,
+ "immed": false,
+ "laxbreak": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false,
+ "shadow": true,
+ "eqnull": true
+} \ No newline at end of file
diff --git a/cmd/mist/assets/ext/.npmignore b/cmd/mist/assets/ext/.npmignore
new file mode 100644
index 000000000..5bbffe4fd
--- /dev/null
+++ b/cmd/mist/assets/ext/.npmignore
@@ -0,0 +1,9 @@
+example/js
+node_modules
+test
+.gitignore
+.editorconfig
+.travis.yml
+.npmignore
+component.json
+testling.html \ No newline at end of file
diff --git a/cmd/mist/assets/ext/.travis.yml b/cmd/mist/assets/ext/.travis.yml
new file mode 100644
index 000000000..83b21d840
--- /dev/null
+++ b/cmd/mist/assets/ext/.travis.yml
@@ -0,0 +1,13 @@
+language: node_js
+node_js:
+ - "0.11"
+ - "0.10"
+before_script:
+ - npm install
+ - npm install jshint
+script:
+ - "jshint *.js lib"
+after_script:
+ - npm run-script build
+ - npm test
+
diff --git a/cmd/mist/assets/ext/bignumber.min.js b/cmd/mist/assets/ext/bignumber.min.js
new file mode 100644
index 000000000..c1627d780
--- /dev/null
+++ b/cmd/mist/assets/ext/bignumber.min.js
@@ -0,0 +1,2 @@
+/*! bignumber.js v2.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */
+(function(n){"use strict";function t(n,i){var b,a,l,p,o,w,s=this;if(!(s instanceof t))return new t(n,i);if(n instanceof t){if(i==null){u=0;s.s=n.s;s.e=n.e;s.c=(n=n.c)?n.slice():n;return}n+=""}else if(p=(o=typeof n)=="number"){if(i==null&&n===~~n){for(s.s=1/n<0?(n=-n,-1):1,a=u=0,l=n;l>=10;l/=10,a++);s.e=a;s.c=[n];return}n=n===0&&1/n<0?"-0":n+""}else o!="string"&&(n+="");if(o=n,i==null&&ft.test(o))s.s=o.charCodeAt(0)===45?(o=o.slice(1),-1):1;else{if(i==10)return s=new t(o),y(s,c+s.e+1,h);if(o=lt.call(o).replace(/^\+(?!-)/,""),s.s=o.charCodeAt(0)===45?(o=o.replace(/^-(?!-)/,""),-1):1,i!=null?i!=~~i&&d||(e=!(i>=2&&i<65))?(f(i,2),w=ft.test(o)):(b="["+ut.slice(0,i=i|0)+"]+",o=o.replace(/\.$/,"").replace(/^\./,"0."),(w=new RegExp("^"+b+"(?:\\."+b+")?$",i<37?"i":"").test(o))?(p&&(o.replace(/^0\.0*|\./,"").length>15&&f(n,0),p=!p),o=ct(o,10,i,s.s)):o!="Infinity"&&o!="NaN"&&(f(n,1,i),n="NaN")):w=ft.test(o),!w){s.c=s.e=null;o!="Infinity"&&(o!="NaN"&&f(n,3),s.s=null);u=0;return}}for((a=o.indexOf("."))>-1&&(o=o.replace(".","")),(l=o.search(/e/i))>0?(a<0&&(a=l),a+=+o.slice(l+1),o=o.substring(0,l)):a<0&&(a=o.length),l=0;o.charCodeAt(l)===48;l++);for(i=o.length;o.charCodeAt(--i)===48;);if(o=o.slice(l,i+1),o)if(i=o.length,p&&i>15&&f(n,0),a=a-l-1,a>v)s.c=s.e=null;else if(a<nt)s.c=[s.e=0];else{if(s.e=a,s.c=[],l=(a+1)%r,a<0&&(l+=r),l<i){for(l&&s.c.push(+o.slice(0,l)),i-=r;l<i;s.c.push(+o.slice(l,l+=r)));o=o.slice(l);l=r-o.length}else l-=i;for(;l--;o+="0");s.c.push(+o)}else s.c=[s.e=0];u=0}function et(n,t,i){for(var f=1,u=t.length;!t[--u];t.pop());for(u=t[0];u>=10;u/=10,f++);return(i=f+i*r-1)>v?n.c=n.e=null:i<nt?n.c=[n.e=0]:(n.e=i,n.c=t),n}function tt(n){for(var t,f,e=1,i=n.length,u=n[0]+"";e<i;){for(t=n[e++]+"",f=r-t.length;f--;t="0"+t);u+=t}for(i=u.length;u.charCodeAt(--i)===48;);return u.slice(0,i+1||1)}function ht(n,t,i){for(var u,r=[0],f,e=0,o=n.length;e<o;){for(f=r.length;f--;r[f]*=t);for(r[u=0]+=ut.indexOf(n.charAt(e++));u<r.length;u++)r[u]>i-1&&(r[u+1]==null&&(r[u+1]=0),r[u+1]+=r[u]/i|0,r[u]%=i)}return r.reverse()}function ct(n,i,r,u){var l,e,v,y,s,f,w,o=n.indexOf("."),p=h;for(r<37&&(n=n.toLowerCase()),o>=0&&(n=n.replace(".",""),w=new t(r),s=w.pow(n.length-o),w.c=ht(s.toFixed(),10,i),w.e=w.c.length),f=ht(n,r,i),e=v=f.length;f[--v]==0;f.pop());if(!f[0])return"0";if(o<0?--e:(s.c=f,s.e=e,s.s=u,s=a(s,w,c,p,i),f=s.c,y=s.r,e=s.e),l=e+c+1,o=f[l],v=i/2,y=y||l<0||f[l+1]!=null,y=p<4?(o!=null||y)&&(p==0||p==(s.s<0?3:2)):o>v||o==v&&(p==4||y||p==6&&f[l-1]&1||p==(s.s<0?8:7)),l<1||!f[0])f.length=1,v=0,y?(f[0]=1,e=-c):e=f[0]=0;else{if(f.length=l,y)for(--i;++f[--l]>i;)f[l]=0,l||(++e,f.unshift(1));for(v=f.length;!f[--v];);}for(o=0,n="";o<=v;n+=ut.charAt(f[o++]));if(e<0){for(;++e;n="0"+n);n="0."+n}else if(o=n.length,++e>o)for(e-=o;e--;n+="0");else e<o&&(n=n.slice(0,e)+"."+n.slice(e));return n}function rt(n,i,r){var o,u,e,f=(n=new t(n)).e;if(i==null?o=0:(y(n,++i,h),o=r?i:i+n.e-f,f=n.e),u=tt(n.c),r==1||r==2&&(i<=f||f<=p)){for(;u.length<o;u+="0");u.length>1&&(u=u.charAt(0)+"."+u.slice(1));u+=(f<0?"e":"e+")+f}else{if(r=u.length,f<0){for(e=o-r;++f;u="0"+u);u="0."+u}else if(++f>r){for(e=o-f,f-=r;f--;u+="0");e>0&&(u+=".")}else e=o-r,f<r?u=u.slice(0,f)+"."+u.slice(f):e>0&&(u+=".");if(e>0)for(;e--;u+="0");}return n.s<0&&n.c[0]?"-"+u:u}function f(n,t,i,r,f,o){if(d){var c,s=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFraction","divToInt"][u?u<0?-u:u:1/u<0?1:0]+"()",h=e?" out of range":" not a"+(f?" non-zero":"n")+" integer";h=([s+" number type has more than 15 significant digits",s+" not a base "+i+" number",s+" base"+h,s+" not a number"][t]||i+"() "+t+(o?" not a boolean or binary digit":h+(r?" or not ["+(e?" negative, positive":" integer, integer")+" ]":"")))+": "+n;e=u=0;c=new Error(h);c.name="BigNumber Error";throw c;}}function y(n,t,i,u){var c,o,e,s,a,h,p,f,y=st;if(f=n.c){n:{for(c=1,s=f[0];s>=10;s/=10,c++);if(o=t-c,o<0)o+=r,e=t,a=f[h=0],p=a/y[c-e-1]%10|0;else if(h=Math.ceil((o+1)/r),h>=f.length)if(u){for(;f.length<=h;f.push(0));a=p=0;c=1;o%=r;e=o-r+1}else break n;else{for(a=s=f[h],c=1;s>=10;s/=10,c++);o%=r;e=o-r+c;p=e<0?0:a/y[c-e-1]%10|0}if(u=u||t<0||f[h+1]!=null||(e<0?a:a%y[c-e-1]),u=i<4?(p||u)&&(i==0||i==(n.s<0?3:2)):p>5||p==5&&(i==4||u||i==6&&(o>0?e>0?a/y[c-e]:0:f[h-1])%10&1||i==(n.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=n.e+1,f[0]=y[t%r],n.e=-t||0):f[0]=n.e=0,n;if(o==0?(f.length=h,s=1,h--):(f.length=h+1,s=y[r-o],f[h]=e>0?g(a/y[c-e]%y[e])*s:0),u)for(;;)if(h==0){for(o=1,e=f[0];e>=10;e/=10,o++);for(e=f[0]+=s,s=1;e>=10;e/=10,s++);o!=s&&(n.e++,f[0]==l&&(f[0]=1));break}else{if(f[h]+=s,f[h]!=l)break;f[h--]=0;s=1}for(o=f.length;f[--o]===0;f.pop());}n.e>v?n.c=n.e=null:n.e<nt&&(n.c=[n.e=0])}return n}var o=1e9,ot=1e6,c=20,h=4,p=-7,k=21,nt=-o,v=o,d=!0,w=parseInt,b={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0},i=t.prototype,ut="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",e,u=0,g=Math.floor,ft=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,lt=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},l=1e14,r=14,s=1e7,st=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],it=new t(1),a;t.ROUND_UP=0;t.ROUND_DOWN=1;t.ROUND_CEIL=2;t.ROUND_FLOOR=3;t.ROUND_HALF_UP=4;t.ROUND_HALF_DOWN=5;t.ROUND_HALF_EVEN=6;t.ROUND_HALF_CEIL=7;t.ROUND_HALF_FLOOR=8;t.config=function(){var n,t,g=0,i={},y=arguments,a=y[0],s="config",r=function(n,t,i){return!((e=n<t||n>i)||w(n)!=n&&n!==0)},l=a&&typeof a=="object"?function(){if(a.hasOwnProperty(t))return(n=a[t])!=null}:function(){if(y.length>g)return(n=y[g++])!=null};if(l(t="DECIMAL_PLACES")&&(r(n,0,o)?c=n|0:f(n,t,s)),i[t]=c,l(t="ROUNDING_MODE")&&(r(n,0,8)?h=n|0:f(n,t,s)),i[t]=h,l(t="EXPONENTIAL_AT")&&(r(n,-o,o)?p=-(k=~~(n<0?-n:+n)):!e&&n&&r(n[0],-o,0)&&r(n[1],0,o)?(p=~~n[0],k=~~n[1]):f(n,t,s,1)),i[t]=[p,k],l(t="RANGE")&&(r(n,-o,o)&&~~n?nt=-(v=~~(n<0?-n:+n)):!e&&n&&r(n[0],-o,-1)&&r(n[1],1,o)?(nt=~~n[0],v=~~n[1]):f(n,t,s,1,1)),i[t]=[nt,v],l(t="ERRORS")&&(n===!!n||n===1||n===0?(e=u=0,w=(d=!!n)?parseInt:parseFloat):f(n,t,s,0,0,1)),i[t]=d,l(t="FORMAT"))if(typeof n=="object")b=n;else if(d){i=new Error(s+"() "+t+" not an object: "+n);i.name="BigNumber Error";throw i;}return i[t]=b,i};a=function(){function n(n,t,i){var f,e,o,h,r=0,u=n.length,c=t%s,l=t/s|0;for(n=n.slice();u--;)o=n[u]%s,h=n[u]/s|0,f=l*o+h*c,e=c*o+f%s*s+r,r=(e/i|0)+(f/s|0)+l*h,n[u]=e%i;return r&&n.unshift(r),n}function i(n,t,i,r){var u,f;if(i!=r)f=i>r?1:-1;else for(u=f=0;u<i;u++)if(n[u]!=t[u]){f=n[u]>t[u]?1:-1;break}return f}function u(n,t,i,r){for(var u=0;i--;)n[i]-=u,u=n[i]<t[i]?1:0,n[i]=u*r+n[i]-t[i];for(;!n[0]&&n.length>1;n.shift());}return function(f,e,o,s,h){var nt,ut,a,ot,p,tt,ft,it,et,v,w,st,ht,rt,lt,k,ct,d=f.s==e.s?1:-1,b=f.c,c=e.c;if(!b||!b[0]||!c||!c[0])return new t(!f.s||!e.s||(b?c&&b[0]==c[0]:!c)?NaN:b&&b[0]==0||!c?d*0:d/0);for(it=new t(d),et=it.c=[],ut=f.e-e.e,d=o+ut+1,h||(h=l,ut=(rt=f.e/r,a=rt|0,rt>0||rt===a?a:a-1)-(k=e.e/r,a=k|0,k>0||k===a?a:a-1),d=d/r|0),a=0;c[a]==(b[a]||0);a++);if(c[a]>(b[a]||0)&&ut--,d<0)et.push(1),ot=!0;else{for(rt=b.length,k=c.length,a=0,d+=2,p=g(h/(c[0]+1)),p>1&&(c=n(c,p,h),b=n(b,p,h),k=c.length,rt=b.length),ht=k,v=b.slice(0,k),w=v.length;w<k;v[w++]=0);ct=c.slice();ct.unshift(0);lt=c[0];c[1]>=h/2&&lt++;do p=0,nt=i(c,v,k,w),nt<0?(st=v[0],k!=w&&(st=st*h+(v[1]||0)),p=g(st/lt),p>1?(p>=h&&(p=h-1),tt=n(c,p,h),ft=tt.length,w=v.length,nt=i(tt,v,ft,w),nt==1&&(p--,u(tt,k<ft?ct:c,ft,h))):(p==0&&(nt=p=1),tt=c.slice()),ft=tt.length,ft<w&&tt.unshift(0),u(v,tt,w,h),nt==-1&&(w=v.length,nt=i(c,v,k,w),nt<1&&(p++,u(v,k<w?ct:c,w,h))),w=v.length):nt===0&&(p++,v=[0]),et[a++]=p,nt&&v[0]?v[w++]=b[ht]||0:(v=[b[ht]],w=1);while((ht++<rt||v[0]!=null)&&d--);ot=v[0]!=null;et[0]||et.shift()}if(h==l){for(a=1,d=et[0];d>=10;d/=10,a++);y(it,o+(it.e=a+ut*r-1)+1,s,ot)}else it.e=ut,it.r=+ot;return it}}();i.absoluteValue=i.abs=function(){var n=new t(this);return n.s<0&&(n.s=1),n};i.ceil=function(){return y(new t(this),this.e+1,2)};i.comparedTo=i.cmp=function(n,i){var f,l=this,e=l.c,o=(u=-u,n=new t(n,i)).c,r=l.s,c=n.s,s=l.e,h=n.e;if(!r||!c)return null;if(f=e&&!e[0],i=o&&!o[0],f||i)return f?i?0:-c:r;if(r!=c)return r;if(f=r<0,i=s==h,!e||!o)return i?0:!e^f?1:-1;if(!i)return s>h^f?1:-1;for(r=-1,c=(s=e.length)<(h=o.length)?s:h;++r<c;)if(e[r]!=o[r])return e[r]>o[r]^f?1:-1;return s==h?0:s>h^f?1:-1};i.decimalPlaces=i.dp=function(){var n,t,i=this.c;if(!i)return null;if(n=((t=i.length-1)-g(this.e/r))*r,t=i[t])for(;t%10==0;t/=10,n--);return n<0&&(n=0),n};i.dividedBy=i.div=function(n,i){return u=2,a(this,new t(n,i),c,h)};i.dividedToIntegerBy=i.divToInt=function(n,i){return u=13,a(this,new t(n,i),0,1)};i.equals=i.eq=function(n,t){return u=3,this.cmp(n,t)===0};i.floor=function(){return y(new t(this),this.e+1,3)};i.greaterThan=i.gt=function(n,t){return u=4,this.cmp(n,t)>0};i.greaterThanOrEqualTo=i.gte=function(n,t){return u=5,(t=this.cmp(n,t))==1||t===0};i.isFinite=function(){return!!this.c};i.isInteger=i.isInt=function(){return!!this.c&&g(this.e/r)>this.c.length-2};i.isNaN=function(){return!this.s};i.isNegative=i.isNeg=function(){return this.s<0};i.isZero=function(){return!!this.c&&this.c[0]==0};i.lessThan=i.lt=function(n,t){return u=6,this.cmp(n,t)<0};i.lessThanOrEqualTo=i.lte=function(n,t){return u=7,(t=this.cmp(n,t))==-1||t===0};i.minus=function(n,i){var e,c,v,w,p=this,s=p.s;if(u=8,n=new t(n,i),i=n.s,!s||!i)return new t(NaN);if(s!=i)return n.s=-i,p.plus(n);var y=p.e/r,a=n.e/r,f=p.c,o=n.c;if(!y||!a){if(!f||!o)return f?(n.s=-i,n):new t(o?p:NaN);if(!f[0]||!o[0])return o[0]?(n.s=-i,n):new t(f[0]?p:h==3?-0:0)}if(e=y|0,y=y>0||y===e?e:e-1,e=a|0,a=a>0||a===e?e:e-1,f=f.slice(),s=y-a){for((w=s<0)?(s=-s,v=f):(a=y,v=o),v.reverse(),i=s;i--;v.push(0));v.reverse()}else for(c=(w=(s=f.length)<(i=o.length))?s:i,s=i=0;i<c;i++)if(f[i]!=o[i]){w=f[i]<o[i];break}if(w&&(v=f,f=o,o=v,n.s=-n.s),i=(c=o.length)-(e=f.length),i>0)for(;i--;f[e++]=0);for(i=l-1;c>s;){if(f[--c]<o[c]){for(e=c;e&&!f[--e];f[e]=i);--f[e];f[c]+=l}f[c]-=o[c]}for(;f[0]==0;f.shift(),--a);return f[0]?et(n,f,a):(n.s=h==3?-1:1,n.c=[n.e=0],n)};i.modulo=i.mod=function(n,i){u=9;var r=this,f=r.c,e=(n=new t(n,i)).c,o=r.s,s=n.s;return(i=!o||!s||e&&!e[0],i||f&&!f[0])?new t(i?NaN:r):(r.s=n.s=1,i=n.cmp(r)==1,r.s=o,n.s=s,i?new t(r):r.minus(a(r,n,0,1).times(n)))};i.negated=i.neg=function(){var n=new t(this);return n.s=-n.s||null,n};i.plus=function(n,i){var h,a=this,f=a.s;if(u=10,n=new t(n,i),i=n.s,!f||!i)return new t(NaN);if(f!=i)return n.s=-i,a.minus(n);var c=a.e/r,o=n.e/r,e=a.c,s=n.c;if(!c||!o){if(!e||!s)return new t(f/0);if(!e[0]||!s[0])return s[0]?n:new t(e[0]?a:f*0)}if(f=c|0,c=c>0||c===f?f:f-1,f=o|0,o=o>0||o===f?f:f-1,e=e.slice(),f=c-o){for(f>0?(o=c,h=s):(f=-f,h=e),h.reverse();f--;h.push(0));h.reverse()}for(f=e.length,i=s.length,f-i<0&&(h=s,s=e,e=h,i=f),f=0;i;)f=(e[--i]=e[i]+s[i]+f)/l|0,e[i]%=l;return f&&(e.unshift(f),++o),et(n,e,o)};i.round=function(n,i){return n=n==null||((e=n<0||n>o)||w(n)!=n)&&!f(n,"decimal places","round")?0:n|0,i=i==null||((e=i<0||i>8)||w(i)!=i&&i!==0)&&!f(i,"mode","round")?h:i|0,y(new t(this),n+this.e+1,i)};i.squareRoot=i.sqrt=function(){var v,i,r,s,f,e=this,o=e.c,n=e.s,u=e.e,l=c+4,p=new t("0.5");if(n!==1||!o||!o[0])return new t(!n||n<0&&(!o||o[0])?NaN:o?e:1/0);if(n=Math.sqrt(+e),n==0||n==1/0?(i=tt(o),(i.length+u)%2==0&&(i+="0"),n=Math.sqrt(i),u=g((u+1)/2)-(u<0||u%2),n==1/0?i="1e"+u:(i=n.toExponential(),i=i.slice(0,i.indexOf("e")+1)+u),r=new t(i)):r=new t(n.toString()),r.c[0])for(u=r.e,n=u+l,n<3&&(n=0);;)if(f=r,r=p.times(f.plus(a(e,f,l,1))),tt(f.c).slice(0,n)===(i=tt(r.c)).slice(0,n))if(r.e<u&&--n,i=i.slice(n-3,n+1),i!="9999"&&(s||i!="4999")){+i&&(+i.slice(1)||i.charAt(0)!="5")||(y(r,r.e+c+2,1),v=!r.times(r).eq(e));break}else{if(!s&&(y(f,f.e+c+2,0),f.times(f).eq(e))){r=f;break}l+=4;n+=4;s=1}return y(r,r.e+c+1,h,v)};i.times=function(n,i){var p,e,w,b,a,y,k,d,g,nt=this,o=nt.c,h=(u=11,n=new t(n,i)).c,c=nt.e/r,f=n.e/r,v=nt.s;if(n.s=v==(i=n.s)?1:-1,!c&&(!o||!o[0])||!f&&(!h||!h[0]))return new t(!v||!i||o&&!o[0]&&!h||h&&!h[0]&&!o?NaN:!o||!h?n.s/0:n.s*0);for(e=(e=c|0,c>0||c===e?e:e-1)+(e=f|0,f>0||f===e?e:e-1),v=o.length,i=h.length,v<i&&(a=o,o=h,h=a,f=v,v=i,i=f),f=v+i,a=[];f--;a.push(0));for(c=i;--c>=0;){for(p=0,f=v+c,w=v,d=h[c]%s,g=h[c]/s|0;f>c;)y=o[--w]%s,k=o[w]/s|0,b=g*y+k*d,y=d*y+b%s*s+a[f]+p,p=(y/l|0)+(b/s|0)+g*k,a[f--]=y%l;a[f]=p}return p?++e:a.shift(),et(n,a,e)};i.toExponential=function(n){var t=this;return t.c?rt(t,n==null||((e=n<0||n>o)||w(n)!=n&&n!==0)&&!f(n,"decimal places","toExponential")?null:n|0,1):t.toString()};i.toFixed=function(n){var t,i=this,r=p,u=k;return n=n==null||((e=n<0||n>o)||w(n)!=n&&n!==0)&&!f(n,"decimal places","toFixed")?null:i.e+(n|0),p=-(k=1/0),n!=null&&i.c?(t=rt(i,n),i.s<0&&i.c&&(i.c[0]?t.indexOf("-")<0&&(t="-"+t):t=t.replace("-",""))):t=i.toString(),p=r,k=u,t};i.toFormat=function(n){var f=this;if(!f.c)return f.toString();var t,h=f.s<0,c=b.groupSeparator,r=+b.groupSize,u=+b.secondaryGroupSize,l=f.toFixed(n).split("."),i=l[0],s=l[1],e=h?i.slice(1):i,o=e.length;if(u&&(t=r,r=u,u=t,o-=t),r>0&&o>0){for(t=o%r||r,i=e.substr(0,t);t<o;t+=r)i+=c+e.substr(t,r);u>0&&(i+=c+e.slice(t));h&&(i="-"+i)}return s?i+b.decimalSeparator+((u=+b.fractionGroupSize)?s.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+b.fractionGroupSeparator):s):i};i.toFraction=function(n){var ut,c,i,w,k,o,s,nt,rt,l=c=new t(it),y=s=new t(it),b=this,ft=b.c,p=new t(it);if(!ft)return b.toString();for(rt=tt(ft),w=p.e=rt.length-b.e-1,p.c[0]=st[(k=w%r)<0?r+k:k],(n==null||(!(u=12,o=new t(n)).s||(e=o.cmp(l)<0||!o.c)||d&&g(o.e/r)<o.c.length-1)&&!f(n,"max denominator","toFraction")||(n=o).cmp(p)>0)&&(n=w>0?p:l),k=v,v=1/0,o=new t(rt),s.c[0]=0;;){if(nt=a(o,p,0,1),i=c.plus(nt.times(y)),i.cmp(n)==1)break;c=y;y=i;l=s.plus(nt.times(i=l));s=i;p=o.minus(nt.times(i=p));o=i}return i=a(n.minus(c),y,0,1),s=s.plus(i.times(l)),c=c.plus(i.times(y)),s.s=l.s=b.s,w*=2,ut=a(l,y,w,h).minus(b).abs().cmp(a(s,c,w,h).minus(b).abs())<1?[l.toString(),y.toString()]:[s.toString(),c.toString()],v=k,ut};i.toNumber=function(){var n=this;return+n||(n.s?0*n.s:NaN)};i.toPower=i.pow=function(n){var i=n*0==0?~~n:n,r=new t(this),u=new t(it);if(((e=n<-ot||n>ot)&&(i=n/0)||w(n)!=n&&n!==0&&!(i=NaN))&&!f(n,"exponent","pow")||!i)return new t(Math.pow(+r,i));for(i=i<0?-i:i;;){if(i&1&&(u=u.times(r)),i>>=1,!i)break;r=r.times(r)}return n<0?it.div(u):u};i.toPrecision=function(n){var t=this;return n==null||((e=n<1||n>o)||w(n)!=n)&&!f(n,"precision","toPrecision")||!t.c?t.toString():rt(t,--n|0,2)};i.toString=function(n){var r,t,o,u=this,i=u.e;if(i===null)t=u.s?"Infinity":"NaN";else{if(n==r&&(i<=p||i>=k))return rt(u,r,1);if(t=tt(u.c),i<0){for(;++i;t="0"+t);t="0."+t}else if(o=t.length,i>0)if(++i>o)for(i-=o;i--;t+="0");else i<o&&(t=t.slice(0,i)+"."+t.slice(i));else if(r=t.charAt(0),o>1)t=r+"."+t.slice(1);else if(r=="0")return r;if(n!=null)if((e=!(n>=2&&n<65))||n!=~~n&&d)f(n,"base","toS");else if(t=ct(t,n|0,10,u.s),t=="0")return t}return u.s<0?"-"+t:t};i.valueOf=i.toJSON=function(){return this.toString()};typeof module!="undefined"&&module.exports?module.exports=t:typeof define=="function"&&define.amd?define(function(){return t}):n.BigNumber=t})(this) \ No newline at end of file
diff --git a/cmd/mist/assets/ext/ethereum.js b/cmd/mist/assets/ext/ethereum.js
new file mode 160000
+Subproject d5093606945fd871bc62f5d6adade3a903b0533
diff --git a/cmd/mist/assets/ext/filter.js b/cmd/mist/assets/ext/filter.js
new file mode 100644
index 000000000..f8529c54b
--- /dev/null
+++ b/cmd/mist/assets/ext/filter.js
@@ -0,0 +1,66 @@
+// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301 USA
+
+var ethx = {
+ prototype: Object,
+
+ watch: function(options) {
+ return new Filter(options);
+ },
+
+ note: function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ var o = []
+ for(var i = 0; i < args.length; i++) {
+ o.push(args[i].toString())
+ }
+
+ eth.notef(o);
+ },
+};
+
+var Filter = function(options) {
+ this.callbacks = [];
+ this.options = options;
+
+ if(options === "chain") {
+ this.id = eth.newFilterString(options);
+ } else if(typeof options === "object") {
+ this.id = eth.newFilter(options);
+ }
+};
+
+Filter.prototype.changed = function(callback) {
+ this.callbacks.push(callback);
+
+ var self = this;
+ messages.connect(function(messages, id) {
+ if(id == self.id) {
+ for(var i = 0; i < self.callbacks.length; i++) {
+ self.callbacks[i].call(self, messages);
+ }
+ }
+ });
+};
+
+Filter.prototype.uninstall = function() {
+ eth.uninstallFilter(this.id)
+}
+
+Filter.prototype.messages = function() {
+ return eth.messages(this.id)
+}
diff --git a/cmd/mist/assets/ext/http.js b/cmd/mist/assets/ext/http.js
new file mode 100644
index 000000000..81908266f
--- /dev/null
+++ b/cmd/mist/assets/ext/http.js
@@ -0,0 +1,30 @@
+// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301 USA
+
+// this function is included locally, but you can also include separately via a header definition
+function request(url, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = (function(req) {
+ return function() {
+ if(req.readyState === 4) {
+ callback(req);
+ }
+ }
+ })(xhr);
+ xhr.open('GET', url, true);
+ xhr.send('');
+}
diff --git a/cmd/mist/assets/ext/mist.js b/cmd/mist/assets/ext/mist.js
new file mode 100644
index 000000000..849e0804e
--- /dev/null
+++ b/cmd/mist/assets/ext/mist.js
@@ -0,0 +1,36 @@
+// Copyright (c) 2015, ETHDEV. All rights reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301 USA
+
+// this function is included locally, but you can also include separately via a header definition
+
+
+document.onkeydown = function(evt) {
+ // This functions keeps track of keyboard inputs in order to allow copy, paste and other features
+
+ evt = evt || window.event;
+ if (evt.ctrlKey && evt.keyCode == 67) {
+ window.document.execCommand("copy");
+ } else if (evt.ctrlKey && evt.keyCode == 88) {
+ window.document.execCommand("cut");
+ } else if (evt.ctrlKey && evt.keyCode == 86) {
+ window.document.execCommand("paste");
+ } else if (evt.ctrlKey && evt.keyCode == 90) {
+ window.document.execCommand("undo");
+ } else if (evt.ctrlKey && evt.shiftKey && evt.keyCode == 90) {
+ window.document.execCommand("redo");
+ }
+}; \ No newline at end of file
diff --git a/cmd/mist/assets/facet.png b/cmd/mist/assets/facet.png
new file mode 100644
index 000000000..49a266e96
--- /dev/null
+++ b/cmd/mist/assets/facet.png
Binary files differ
diff --git a/cmd/mist/assets/heart.png b/cmd/mist/assets/heart.png
new file mode 100644
index 000000000..3c874ab7f
--- /dev/null
+++ b/cmd/mist/assets/heart.png
Binary files differ
diff --git a/cmd/mist/assets/html/home.html b/cmd/mist/assets/html/home.html
new file mode 100644
index 000000000..dc96cc754
--- /dev/null
+++ b/cmd/mist/assets/html/home.html
@@ -0,0 +1,83 @@
+<!doctype>
+<html>
+<head>
+<title>Ethereum</title>
+<script type="text/javascript" src="../ext/bignumber.min.js"></script>
+<script type="text/javascript" src="../ext/ethereum.js/dist/ethereum.js"></script>
+<style type="text/css">
+ body {
+ font-family: Helvetica;
+ }
+ div.logo {
+ width: 192px;
+ margin: 40px auto;
+ }
+</style>
+</head>
+<body>
+ <div class="logo"><img src="logo.png"></img></div>
+ <h1>Info</h1>
+
+ <table width="100%">
+ <tr>
+ <td>Block number</td>
+ <td id="number"></td>
+ </tr>
+
+ <tr>
+ <td>Peer count</td>
+ <td id="peer_count"></td>
+ </tr>
+
+ <tr>
+ <td>Accounts</td>
+ <td id="accounts"></td>
+ </tr>
+
+ <tr>
+ <td>Gas price</td>
+ <td id="gas_price"></td>
+ </tr>
+
+ <tr>
+ <td>Mining</td>
+ <td id="mining"></td>
+ </tr>
+
+ <tr>
+ <td>Listening</td>
+ <td id="listening"></td>
+ </tr>
+
+ <tr>
+ <td>Coinbase</td>
+ <td id="coinbase"></td>
+ </tr>
+ </table>
+</body>
+
+<script type="text/javascript">
+ var web3 = require('web3');
+ var eth = web3.eth;
+
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8545'));
+
+ document.querySelector("#number").innerHTML = eth.number;
+ document.querySelector("#coinbase").innerHTML = eth.coinbase
+ document.querySelector("#peer_count").innerHTML = eth.peerCount;
+ document.querySelector("#accounts").innerHTML = eth.accounts;
+ document.querySelector("#gas_price").innerHTML = eth.gasPrice;
+ document.querySelector("#mining").innerHTML = eth.mining;
+ document.querySelector("#listening").innerHTML = eth.listening;
+
+ eth.watch('pending').changed(function() {
+ console.log("pending changed");
+ });
+ eth.watch('chain').changed(function() {
+ document.querySelector("#number").innerHTML = eth.number;
+ });
+
+</script>
+
+</html>
+
diff --git a/cmd/mist/assets/html/logo.png b/cmd/mist/assets/html/logo.png
new file mode 100644
index 000000000..28dc9f509
--- /dev/null
+++ b/cmd/mist/assets/html/logo.png
Binary files differ
diff --git a/cmd/mist/assets/icecream.png b/cmd/mist/assets/icecream.png
new file mode 100644
index 000000000..2438ca845
--- /dev/null
+++ b/cmd/mist/assets/icecream.png
Binary files differ
diff --git a/cmd/mist/assets/mining-icon.png b/cmd/mist/assets/mining-icon.png
new file mode 100644
index 000000000..db611e5c0
--- /dev/null
+++ b/cmd/mist/assets/mining-icon.png
Binary files differ
diff --git a/cmd/mist/assets/mining-icon@2x.png b/cmd/mist/assets/mining-icon@2x.png
new file mode 100644
index 000000000..16466d338
--- /dev/null
+++ b/cmd/mist/assets/mining-icon@2x.png
Binary files differ
diff --git a/cmd/mist/assets/muted/codemirror.css b/cmd/mist/assets/muted/codemirror.css
new file mode 100644
index 000000000..098a317a2
--- /dev/null
+++ b/cmd/mist/assets/muted/codemirror.css
@@ -0,0 +1,272 @@
+/* BASICS */
+
+.CodeMirror {
+ /* Set height, width, borders, and global font properties here */
+ font-family: monospace;
+ height: 300px;
+}
+.CodeMirror-scroll {
+ /* Set scrolling behaviour here */
+ overflow: auto;
+}
+
+/* PADDING */
+
+.CodeMirror-lines {
+ padding: 4px 0; /* Vertical padding around content */
+}
+.CodeMirror pre {
+ padding: 0 4px; /* Horizontal padding of content */
+}
+
+.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
+ background-color: white; /* The little square between H and V scrollbars */
+}
+
+/* GUTTER */
+
+.CodeMirror-gutters {
+ border-right: 1px solid #ddd;
+ background-color: #f7f7f7;
+ white-space: nowrap;
+}
+.CodeMirror-linenumbers {}
+.CodeMirror-linenumber {
+ padding: 0 3px 0 5px;
+ min-width: 20px;
+ text-align: right;
+ color: #999;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+}
+
+/* CURSOR */
+
+.CodeMirror div.CodeMirror-cursor {
+ border-left: 1px solid black;
+}
+/* Shown when moving in bi-directional text */
+.CodeMirror div.CodeMirror-secondarycursor {
+ border-left: 1px solid silver;
+}
+.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
+ width: auto;
+ border: 0;
+ background: #7e7;
+}
+/* Can style cursor different in overwrite (non-insert) mode */
+div.CodeMirror-overwrite div.CodeMirror-cursor {}
+
+.cm-tab { display: inline-block; }
+
+.CodeMirror-ruler {
+ border-left: 1px solid #ccc;
+ position: absolute;
+}
+
+/* DEFAULT THEME */
+
+.cm-s-default .cm-keyword {color: #708;}
+.cm-s-default .cm-atom {color: #219;}
+.cm-s-default .cm-number {color: #164;}
+.cm-s-default .cm-def {color: #00f;}
+.cm-s-default .cm-variable,
+.cm-s-default .cm-punctuation,
+.cm-s-default .cm-property,
+.cm-s-default .cm-operator {}
+.cm-s-default .cm-variable-2 {color: #05a;}
+.cm-s-default .cm-variable-3 {color: #085;}
+.cm-s-default .cm-comment {color: #a50;}
+.cm-s-default .cm-string {color: #a11;}
+.cm-s-default .cm-string-2 {color: #f50;}
+.cm-s-default .cm-meta {color: #555;}
+.cm-s-default .cm-qualifier {color: #555;}
+.cm-s-default .cm-builtin {color: #30a;}
+.cm-s-default .cm-bracket {color: #997;}
+.cm-s-default .cm-tag {color: #170;}
+.cm-s-default .cm-attribute {color: #00c;}
+.cm-s-default .cm-header {color: blue;}
+.cm-s-default .cm-quote {color: #090;}
+.cm-s-default .cm-hr {color: #999;}
+.cm-s-default .cm-link {color: #00c;}
+
+.cm-negative {color: #d44;}
+.cm-positive {color: #292;}
+.cm-header, .cm-strong {font-weight: bold;}
+.cm-em {font-style: italic;}
+.cm-link {text-decoration: underline;}
+
+.cm-s-default .cm-error {color: #f00;}
+.cm-invalidchar {color: #f00;}
+
+div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
+div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
+.CodeMirror-activeline-background {background: #e8f2ff;}
+
+/* STOP */
+
+/* The rest of this file contains styles related to the mechanics of
+ the editor. You probably shouldn't touch them. */
+
+.CodeMirror {
+ line-height: 1;
+ position: relative;
+ overflow: hidden;
+ background: white;
+ color: black;
+}
+
+.CodeMirror-scroll {
+ /* 30px is the magic margin used to hide the element's real scrollbars */
+ /* See overflow: hidden in .CodeMirror */
+ margin-bottom: -30px; margin-right: -30px;
+ padding-bottom: 30px;
+ height: 100%;
+ outline: none; /* Prevent dragging from highlighting the element */
+ position: relative;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+}
+.CodeMirror-sizer {
+ position: relative;
+ border-right: 30px solid transparent;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+}
+
+/* The fake, visible scrollbars. Used to force redraw during scrolling
+ before actuall scrolling happens, thus preventing shaking and
+ flickering artifacts. */
+.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
+ position: absolute;
+ z-index: 6;
+ display: none;
+}
+.CodeMirror-vscrollbar {
+ right: 0; top: 0;
+ overflow-x: hidden;
+ overflow-y: scroll;
+}
+.CodeMirror-hscrollbar {
+ bottom: 0; left: 0;
+ overflow-y: hidden;
+ overflow-x: scroll;
+}
+.CodeMirror-scrollbar-filler {
+ right: 0; bottom: 0;
+}
+.CodeMirror-gutter-filler {
+ left: 0; bottom: 0;
+}
+
+.CodeMirror-gutters {
+ position: absolute; left: 0; top: 0;
+ padding-bottom: 30px;
+ z-index: 3;
+}
+.CodeMirror-gutter {
+ white-space: normal;
+ height: 100%;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ padding-bottom: 30px;
+ margin-bottom: -32px;
+ display: inline-block;
+ /* Hack to make IE7 behave */
+ *zoom:1;
+ *display:inline;
+}
+.CodeMirror-gutter-elt {
+ position: absolute;
+ cursor: default;
+ z-index: 4;
+}
+
+.CodeMirror-lines {
+ cursor: text;
+}
+.CodeMirror pre {
+ /* Reset some styles that the rest of the page might have set */
+ -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
+ border-width: 0;
+ background: transparent;
+ font-family: inherit;
+ font-size: inherit;
+ margin: 0;
+ white-space: pre;
+ word-wrap: normal;
+ line-height: inherit;
+ color: inherit;
+ z-index: 2;
+ position: relative;
+ overflow: visible;
+}
+.CodeMirror-wrap pre {
+ word-wrap: break-word;
+ white-space: pre-wrap;
+ word-break: normal;
+}
+
+.CodeMirror-linebackground {
+ position: absolute;
+ left: 0; right: 0; top: 0; bottom: 0;
+ z-index: 0;
+}
+
+.CodeMirror-linewidget {
+ position: relative;
+ z-index: 2;
+ overflow: auto;
+}
+
+.CodeMirror-widget {}
+
+.CodeMirror-wrap .CodeMirror-scroll {
+ overflow-x: hidden;
+}
+
+.CodeMirror-measure {
+ position: absolute;
+ width: 100%;
+ height: 0;
+ overflow: hidden;
+ visibility: hidden;
+}
+.CodeMirror-measure pre { position: static; }
+
+.CodeMirror div.CodeMirror-cursor {
+ position: absolute;
+ border-right: none;
+ width: 0;
+}
+
+div.CodeMirror-cursors {
+ visibility: hidden;
+ position: relative;
+ z-index: 1;
+}
+.CodeMirror-focused div.CodeMirror-cursors {
+ visibility: visible;
+}
+
+.CodeMirror-selected { background: #d9d9d9; }
+.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
+.CodeMirror-crosshair { cursor: crosshair; }
+
+.cm-searching {
+ background: #ffa;
+ background: rgba(255, 255, 0, .4);
+}
+
+/* IE7 hack to prevent it from returning funny offsetTops on the spans */
+.CodeMirror span { *vertical-align: text-bottom; }
+
+/* Used to force a border model for a node */
+.cm-force-border { padding-right: .1px; }
+
+@media print {
+ /* Hide the cursor when printing */
+ .CodeMirror div.CodeMirror-cursors {
+ visibility: hidden;
+ }
+}
diff --git a/cmd/mist/assets/muted/debugger.html b/cmd/mist/assets/muted/debugger.html
new file mode 100644
index 000000000..b7552f030
--- /dev/null
+++ b/cmd/mist/assets/muted/debugger.html
@@ -0,0 +1,53 @@
+<!doctype>
+<html>
+<head>
+<style type="text/css">
+ html, body {
+ margin: 0; padding: 0;
+ min-height: 100%;
+ }
+
+ #debugger {
+ height: 100%;
+ font-family: "Monaco"
+ }
+ #debugger .line {
+ overflow: none;
+ }
+ #debugger .col1, #debugger .col2 {
+ float: left;
+ padding: 3px;
+ }
+ #debugger .col1 {
+ width: 10px;
+ padding-left: 10px
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ }
+ #debugger .col2 {
+ width: 90%;
+ }
+ .prompt {
+ color: "#5089D4";
+ }
+</style>
+
+</head>
+
+<body>
+<div id="debugger">
+ <div class="line">
+ <div class="col1 prompt">
+ &gt;
+ </div>
+ <div class="col2" contenteditable>
+ </div>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/cmd/mist/assets/muted/eclipse.css b/cmd/mist/assets/muted/eclipse.css
new file mode 100644
index 000000000..317218e3d
--- /dev/null
+++ b/cmd/mist/assets/muted/eclipse.css
@@ -0,0 +1,23 @@
+.cm-s-eclipse span.cm-meta {color: #FF1717;}
+.cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
+.cm-s-eclipse span.cm-atom {color: #219;}
+.cm-s-eclipse span.cm-number {color: #164;}
+.cm-s-eclipse span.cm-def {color: #00f;}
+.cm-s-eclipse span.cm-variable {color: black;}
+.cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
+.cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
+.cm-s-eclipse span.cm-property {color: black;}
+.cm-s-eclipse span.cm-operator {color: black;}
+.cm-s-eclipse span.cm-comment {color: #3F7F5F;}
+.cm-s-eclipse span.cm-string {color: #2A00FF;}
+.cm-s-eclipse span.cm-string-2 {color: #f50;}
+.cm-s-eclipse span.cm-qualifier {color: #555;}
+.cm-s-eclipse span.cm-builtin {color: #30a;}
+.cm-s-eclipse span.cm-bracket {color: #cc7;}
+.cm-s-eclipse span.cm-tag {color: #170;}
+.cm-s-eclipse span.cm-attribute {color: #00c;}
+.cm-s-eclipse span.cm-link {color: #219;}
+.cm-s-eclipse span.cm-error {color: #f00;}
+
+.cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
+.cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
diff --git a/cmd/mist/assets/muted/index.html b/cmd/mist/assets/muted/index.html
new file mode 100644
index 000000000..14949b5ac
--- /dev/null
+++ b/cmd/mist/assets/muted/index.html
@@ -0,0 +1,80 @@
+<!doctype>
+<html>
+<head>
+<title>Mutan Editor</title>
+<link rel="stylesheet" href="codemirror.css">
+<link rel="stylesheet" href="eclipse.css">
+<script src="lib/codemirror.js"></script>
+<script src="lib/matchbrackets.js"></script>
+<script src="lib/go.js"></script>
+<script src="muted.js"></script>
+
+<style type="text/css">
+ html, body {
+ margin: 0; padding: 0;
+ min-height: 100%;
+ }
+
+ #debugger {
+ height: 30%;
+ font-family: "Monaco";
+ border-top: 5px solid grey;
+ }
+ #debugger .line {
+ overflow: none;
+ }
+ #debugger .col1, #debugger .col2 {
+ float: left;
+ padding: 3px;
+ }
+ #debugger .col1 {
+ width: 10px;
+ padding-left: 10px
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ }
+ #debugger .col2 {
+ width: 90%;
+ }
+ .prompt {
+ color: "#5089D4";
+ }
+
+ .CodeMirror {
+ height: 70%;
+ font-size: 14pt;
+ }
+</style>
+</head>
+
+<body>
+<textarea id="editor"></textarea>
+
+<div id="debugger">
+ <div class="line">
+ <div class="col1 prompt">
+ &gt;
+ </div>
+ <div class="col2" contenteditable>
+ </div>
+ </div>
+</div>
+
+<script>
+ var textArea = document.querySelector("#editor")
+ var editor = CodeMirror.fromTextArea(textArea, {
+ theme: "eclipse",
+ mode: "text/html",
+ lineNumbers: true,
+ mode: "text/x-go",
+ indentUnit: 8,
+ tabSize: 8,
+ indentWithTabs: true,
+ });
+</script>
+</body>
+</html>
diff --git a/cmd/mist/assets/muted/lib/codemirror.js b/cmd/mist/assets/muted/lib/codemirror.js
new file mode 100644
index 000000000..0ab217711
--- /dev/null
+++ b/cmd/mist/assets/muted/lib/codemirror.js
@@ -0,0 +1,7526 @@
+// This is CodeMirror (http://codemirror.net), a code editor
+// implemented in JavaScript on top of the browser's DOM.
+//
+// You can find some technical background for some of the code below
+// at http://marijnhaverbeke.nl/blog/#cm-internals .
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ module.exports = mod();
+ else if (typeof define == "function" && define.amd) // AMD
+ return define([], mod);
+ else // Plain browser env
+ this.CodeMirror = mod();
+})(function() {
+ "use strict";
+
+ // BROWSER SNIFFING
+
+ // Kludges for bugs and behavior differences that can't be feature
+ // detected are enabled based on userAgent etc sniffing.
+
+ var gecko = /gecko\/\d/i.test(navigator.userAgent);
+ // ie_uptoN means Internet Explorer version N or lower
+ var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
+ var ie_upto7 = ie_upto10 && (document.documentMode == null || document.documentMode < 8);
+ var ie_upto8 = ie_upto10 && (document.documentMode == null || document.documentMode < 9);
+ var ie_upto9 = ie_upto10 && (document.documentMode == null || document.documentMode < 10);
+ var ie_11up = /Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent);
+ var ie = ie_upto10 || ie_11up;
+ var webkit = /WebKit\//.test(navigator.userAgent);
+ var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
+ var chrome = /Chrome\//.test(navigator.userAgent);
+ var presto = /Opera\//.test(navigator.userAgent);
+ var safari = /Apple Computer/.test(navigator.vendor);
+ var khtml = /KHTML\//.test(navigator.userAgent);
+ var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
+ var phantom = /PhantomJS/.test(navigator.userAgent);
+
+ var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
+ // This is woefully incomplete. Suggestions for alternative methods welcome.
+ var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);
+ var mac = ios || /Mac/.test(navigator.platform);
+ var windows = /win/i.test(navigator.platform);
+
+ var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
+ if (presto_version) presto_version = Number(presto_version[1]);
+ if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
+ // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
+ var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
+ var captureRightClick = gecko || (ie && !ie_upto8);
+
+ // Optimize some code when these features are not used.
+ var sawReadOnlySpans = false, sawCollapsedSpans = false;
+
+ // EDITOR CONSTRUCTOR
+
+ // A CodeMirror instance represents an editor. This is the object
+ // that user code is usually dealing with.
+
+ function CodeMirror(place, options) {
+ if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
+
+ this.options = options = options || {};
+ // Determine effective options based on given values and defaults.
+ copyObj(defaults, options, false);
+ setGuttersForLineNumbers(options);
+
+ var doc = options.value;
+ if (typeof doc == "string") doc = new Doc(doc, options.mode);
+ this.doc = doc;
+
+ var display = this.display = new Display(place, doc);
+ display.wrapper.CodeMirror = this;
+ updateGutters(this);
+ themeChanged(this);
+ if (options.lineWrapping)
+ this.display.wrapper.className += " CodeMirror-wrap";
+ if (options.autofocus && !mobile) focusInput(this);
+
+ this.state = {
+ keyMaps: [], // stores maps added by addKeyMap
+ overlays: [], // highlighting overlays, as added by addOverlay
+ modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
+ overwrite: false, focused: false,
+ suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
+ pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput
+ draggingText: false,
+ highlight: new Delayed() // stores highlight worker timeout
+ };
+
+ // Override magic textarea content restore that IE sometimes does
+ // on our hidden textarea on reload
+ if (ie_upto10) setTimeout(bind(resetInput, this, true), 20);
+
+ registerEventHandlers(this);
+
+ var cm = this;
+ runInOp(this, function() {
+ cm.curOp.forceUpdate = true;
+ attachDoc(cm, doc);
+
+ if ((options.autofocus && !mobile) || activeElt() == display.input)
+ setTimeout(bind(onFocus, cm), 20);
+ else
+ onBlur(cm);
+
+ for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
+ optionHandlers[opt](cm, options[opt], Init);
+ for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm);
+ });
+ }
+
+ // DISPLAY CONSTRUCTOR
+
+ // The display handles the DOM integration, both for input reading
+ // and content drawing. It holds references to DOM nodes and
+ // display-related state.
+
+ function Display(place, doc) {
+ var d = this;
+
+ // The semihidden textarea that is focused when the editor is
+ // focused, and receives input.
+ var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
+ // The textarea is kept positioned near the cursor to prevent the
+ // fact that it'll be scrolled into view on input from scrolling
+ // our fake cursor out of view. On webkit, when wrap=off, paste is
+ // very slow. So make the area wide instead.
+ if (webkit) input.style.width = "1000px";
+ else input.setAttribute("wrap", "off");
+ // If border: 0; -- iOS fails to open keyboard (issue #1287)
+ if (ios) input.style.border = "1px solid black";
+ input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
+
+ // Wraps and hides input textarea
+ d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
+ // The fake scrollbar elements.
+ d.scrollbarH = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
+ d.scrollbarV = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
+ // Covers bottom-right square when both scrollbars are present.
+ d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
+ // Covers bottom of gutter when coverGutterNextToScrollbar is on
+ // and h scrollbar is present.
+ d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
+ // Will contain the actual code, positioned to cover the viewport.
+ d.lineDiv = elt("div", null, "CodeMirror-code");
+ // Elements are added to these to represent selection and cursors.
+ d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
+ d.cursorDiv = elt("div", null, "CodeMirror-cursors");
+ // A visibility: hidden element used to find the size of things.
+ d.measure = elt("div", null, "CodeMirror-measure");
+ // When lines outside of the viewport are measured, they are drawn in this.
+ d.lineMeasure = elt("div", null, "CodeMirror-measure");
+ // Wraps everything that needs to exist inside the vertically-padded coordinate system
+ d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
+ null, "position: relative; outline: none");
+ // Moved around its parent to cover visible view.
+ d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
+ // Set to the height of the document, allowing scrolling.
+ d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
+ // Behavior of elts with overflow: auto and padding is
+ // inconsistent across browsers. This is used to ensure the
+ // scrollable area is big enough.
+ d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;");
+ // Will contain the gutters, if any.
+ d.gutters = elt("div", null, "CodeMirror-gutters");
+ d.lineGutter = null;
+ // Actual scrollable element.
+ d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
+ d.scroller.setAttribute("tabIndex", "-1");
+ // The element in which the editor lives.
+ d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
+ d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
+
+ // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
+ if (ie_upto7) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
+ // Needed to hide big blue blinking cursor on Mobile Safari
+ if (ios) input.style.width = "0px";
+ if (!webkit) d.scroller.draggable = true;
+ // Needed to handle Tab key in KHTML
+ if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; }
+ // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
+ if (ie_upto7) d.scrollbarH.style.minHeight = d.scrollbarV.style.minWidth = "18px";
+
+ if (place.appendChild) place.appendChild(d.wrapper);
+ else place(d.wrapper);
+
+ // Current rendered range (may be bigger than the view window).
+ d.viewFrom = d.viewTo = doc.first;
+ // Information about the rendered lines.
+ d.view = [];
+ // Holds info about a single rendered line when it was rendered
+ // for measurement, while not in view.
+ d.externalMeasured = null;
+ // Empty space (in pixels) above the view
+ d.viewOffset = 0;
+ d.lastSizeC = 0;
+ d.updateLineNumbers = null;
+
+ // Used to only resize the line number gutter when necessary (when
+ // the amount of lines crosses a boundary that makes its width change)
+ d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
+ // See readInput and resetInput
+ d.prevInput = "";
+ // Set to true when a non-horizontal-scrolling line widget is
+ // added. As an optimization, line widget aligning is skipped when
+ // this is false.
+ d.alignWidgets = false;
+ // Flag that indicates whether we expect input to appear real soon
+ // now (after some event like 'keypress' or 'input') and are
+ // polling intensively.
+ d.pollingFast = false;
+ // Self-resetting timeout for the poller
+ d.poll = new Delayed();
+
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
+
+ // Tracks when resetInput has punted to just putting a short
+ // string into the textarea instead of the full selection.
+ d.inaccurateSelection = false;
+
+ // Tracks the maximum line length so that the horizontal scrollbar
+ // can be kept static when scrolling.
+ d.maxLine = null;
+ d.maxLineLength = 0;
+ d.maxLineChanged = false;
+
+ // Used for measuring wheel scrolling granularity
+ d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
+
+ // True when shift is held down.
+ d.shift = false;
+ }
+
+ // STATE UPDATES
+
+ // Used to get the editor into a consistent state again when options change.
+
+ function loadMode(cm) {
+ cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
+ resetModeState(cm);
+ }
+
+ function resetModeState(cm) {
+ cm.doc.iter(function(line) {
+ if (line.stateAfter) line.stateAfter = null;
+ if (line.styles) line.styles = null;
+ });
+ cm.doc.frontier = cm.doc.first;
+ startWorker(cm, 100);
+ cm.state.modeGen++;
+ if (cm.curOp) regChange(cm);
+ }
+
+ function wrappingChanged(cm) {
+ if (cm.options.lineWrapping) {
+ addClass(cm.display.wrapper, "CodeMirror-wrap");
+ cm.display.sizer.style.minWidth = "";
+ } else {
+ rmClass(cm.display.wrapper, "CodeMirror-wrap");
+ findMaxLine(cm);
+ }
+ estimateLineHeights(cm);
+ regChange(cm);
+ clearCaches(cm);
+ setTimeout(function(){updateScrollbars(cm);}, 100);
+ }
+
+ // Returns a function that estimates the height of a line, to use as
+ // first approximation until the line becomes visible (and is thus
+ // properly measurable).
+ function estimateHeight(cm) {
+ var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
+ var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
+ return function(line) {
+ if (lineIsHidden(cm.doc, line)) return 0;
+
+ var widgetsHeight = 0;
+ if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
+ if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
+ }
+
+ if (wrapping)
+ return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
+ else
+ return widgetsHeight + th;
+ };
+ }
+
+ function estimateLineHeights(cm) {
+ var doc = cm.doc, est = estimateHeight(cm);
+ doc.iter(function(line) {
+ var estHeight = est(line);
+ if (estHeight != line.height) updateLineHeight(line, estHeight);
+ });
+ }
+
+ function keyMapChanged(cm) {
+ var map = keyMap[cm.options.keyMap], style = map.style;
+ cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
+ (style ? " cm-keymap-" + style : "");
+ }
+
+ function themeChanged(cm) {
+ cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
+ cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
+ clearCaches(cm);
+ }
+
+ function guttersChanged(cm) {
+ updateGutters(cm);
+ regChange(cm);
+ setTimeout(function(){alignHorizontally(cm);}, 20);
+ }
+
+ // Rebuild the gutter elements, ensure the margin to the left of the
+ // code matches their width.
+ function updateGutters(cm) {
+ var gutters = cm.display.gutters, specs = cm.options.gutters;
+ removeChildren(gutters);
+ for (var i = 0; i < specs.length; ++i) {
+ var gutterClass = specs[i];
+ var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
+ if (gutterClass == "CodeMirror-linenumbers") {
+ cm.display.lineGutter = gElt;
+ gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
+ }
+ }
+ gutters.style.display = i ? "" : "none";
+ updateGutterSpace(cm);
+ }
+
+ function updateGutterSpace(cm) {
+ var width = cm.display.gutters.offsetWidth;
+ cm.display.sizer.style.marginLeft = width + "px";
+ cm.display.scrollbarH.style.left = cm.options.fixedGutter ? width + "px" : 0;
+ }
+
+ // Compute the character length of a line, taking into account
+ // collapsed ranges (see markText) that might hide parts, and join
+ // other lines onto it.
+ function lineLength(line) {
+ if (line.height == 0) return 0;
+ var len = line.text.length, merged, cur = line;
+ while (merged = collapsedSpanAtStart(cur)) {
+ var found = merged.find(0, true);
+ cur = found.from.line;
+ len += found.from.ch - found.to.ch;
+ }
+ cur = line;
+ while (merged = collapsedSpanAtEnd(cur)) {
+ var found = merged.find(0, true);
+ len -= cur.text.length - found.from.ch;
+ cur = found.to.line;
+ len += cur.text.length - found.to.ch;
+ }
+ return len;
+ }
+
+ // Find the longest line in the document.
+ function findMaxLine(cm) {
+ var d = cm.display, doc = cm.doc;
+ d.maxLine = getLine(doc, doc.first);
+ d.maxLineLength = lineLength(d.maxLine);
+ d.maxLineChanged = true;
+ doc.iter(function(line) {
+ var len = lineLength(line);
+ if (len > d.maxLineLength) {
+ d.maxLineLength = len;
+ d.maxLine = line;
+ }
+ });
+ }
+
+ // Make sure the gutters options contains the element
+ // "CodeMirror-linenumbers" when the lineNumbers option is true.
+ function setGuttersForLineNumbers(options) {
+ var found = indexOf(options.gutters, "CodeMirror-linenumbers");
+ if (found == -1 && options.lineNumbers) {
+ options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
+ } else if (found > -1 && !options.lineNumbers) {
+ options.gutters = options.gutters.slice(0);
+ options.gutters.splice(found, 1);
+ }
+ }
+
+ // SCROLLBARS
+
+ // Prepare DOM reads needed to update the scrollbars. Done in one
+ // shot to minimize update/measure roundtrips.
+ function measureForScrollbars(cm) {
+ var scroll = cm.display.scroller;
+ return {
+ clientHeight: scroll.clientHeight,
+ barHeight: cm.display.scrollbarV.clientHeight,
+ scrollWidth: scroll.scrollWidth, clientWidth: scroll.clientWidth,
+ barWidth: cm.display.scrollbarH.clientWidth,
+ docHeight: Math.round(cm.doc.height + paddingVert(cm.display))
+ };
+ }
+
+ // Re-synchronize the fake scrollbars with the actual size of the
+ // content.
+ function updateScrollbars(cm, measure) {
+ if (!measure) measure = measureForScrollbars(cm);
+ var d = cm.display;
+ var scrollHeight = measure.docHeight + scrollerCutOff;
+ var needsH = measure.scrollWidth > measure.clientWidth;
+ var needsV = scrollHeight > measure.clientHeight;
+ if (needsV) {
+ d.scrollbarV.style.display = "block";
+ d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0";
+ // A bug in IE8 can cause this value to be negative, so guard it.
+ d.scrollbarV.firstChild.style.height =
+ Math.max(0, scrollHeight - measure.clientHeight + (measure.barHeight || d.scrollbarV.clientHeight)) + "px";
+ } else {
+ d.scrollbarV.style.display = "";
+ d.scrollbarV.firstChild.style.height = "0";
+ }
+ if (needsH) {
+ d.scrollbarH.style.display = "block";
+ d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0";
+ d.scrollbarH.firstChild.style.width =
+ (measure.scrollWidth - measure.clientWidth + (measure.barWidth || d.scrollbarH.clientWidth)) + "px";
+ } else {
+ d.scrollbarH.style.display = "";
+ d.scrollbarH.firstChild.style.width = "0";
+ }
+ if (needsH && needsV) {
+ d.scrollbarFiller.style.display = "block";
+ d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
+ } else d.scrollbarFiller.style.display = "";
+ if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
+ d.gutterFiller.style.display = "block";
+ d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px";
+ d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
+ } else d.gutterFiller.style.display = "";
+
+ if (!cm.state.checkedOverlayScrollbar && measure.clientHeight > 0) {
+ if (scrollbarWidth(d.measure) === 0) {
+ var w = mac && !mac_geMountainLion ? "12px" : "18px";
+ d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = w;
+ var barMouseDown = function(e) {
+ if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH)
+ operation(cm, onMouseDown)(e);
+ };
+ on(d.scrollbarV, "mousedown", barMouseDown);
+ on(d.scrollbarH, "mousedown", barMouseDown);
+ }
+ cm.state.checkedOverlayScrollbar = true;
+ }
+ }
+
+ // Compute the lines that are visible in a given viewport (defaults
+ // the the current scroll position). viewPort may contain top,
+ // height, and ensure (see op.scrollToPos) properties.
+ function visibleLines(display, doc, viewPort) {
+ var top = viewPort && viewPort.top != null ? viewPort.top : display.scroller.scrollTop;
+ top = Math.floor(top - paddingTop(display));
+ var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight;
+
+ var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
+ // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
+ // forces those lines into the viewport (if possible).
+ if (viewPort && viewPort.ensure) {
+ var ensureFrom = viewPort.ensure.from.line, ensureTo = viewPort.ensure.to.line;
+ if (ensureFrom < from)
+ return {from: ensureFrom,
+ to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)};
+ if (Math.min(ensureTo, doc.lastLine()) >= to)
+ return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight),
+ to: ensureTo};
+ }
+ return {from: from, to: to};
+ }
+
+ // LINE NUMBERS
+
+ // Re-align line numbers and gutter marks to compensate for
+ // horizontal scrolling.
+ function alignHorizontally(cm) {
+ var display = cm.display, view = display.view;
+ if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
+ var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
+ var gutterW = display.gutters.offsetWidth, left = comp + "px";
+ for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
+ if (cm.options.fixedGutter && view[i].gutter)
+ view[i].gutter.style.left = left;
+ var align = view[i].alignable;
+ if (align) for (var j = 0; j < align.length; j++)
+ align[j].style.left = left;
+ }
+ if (cm.options.fixedGutter)
+ display.gutters.style.left = (comp + gutterW) + "px";
+ }
+
+ // Used to ensure that the line number gutter is still the right
+ // size for the current document size. Returns true when an update
+ // is needed.
+ function maybeUpdateLineNumberWidth(cm) {
+ if (!cm.options.lineNumbers) return false;
+ var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
+ if (last.length != display.lineNumChars) {
+ var test = display.measure.appendChild(elt("div", [elt("div", last)],
+ "CodeMirror-linenumber CodeMirror-gutter-elt"));
+ var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
+ display.lineGutter.style.width = "";
+ display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
+ display.lineNumWidth = display.lineNumInnerWidth + padding;
+ display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
+ display.lineGutter.style.width = display.lineNumWidth + "px";
+ updateGutterSpace(cm);
+ return true;
+ }
+ return false;
+ }
+
+ function lineNumberFor(options, i) {
+ return String(options.lineNumberFormatter(i + options.firstLineNumber));
+ }
+
+ // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
+ // but using getBoundingClientRect to get a sub-pixel-accurate
+ // result.
+ function compensateForHScroll(display) {
+ return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
+ }
+
+ // DISPLAY DRAWING
+
+ // Updates the display, selection, and scrollbars, using the
+ // information in display.view to find out which nodes are no longer
+ // up-to-date. Tries to bail out early when no changes are needed,
+ // unless forced is true.
+ // Returns true if an actual update happened, false otherwise.
+ function updateDisplay(cm, viewPort, forced) {
+ var oldFrom = cm.display.viewFrom, oldTo = cm.display.viewTo, updated;
+ var visible = visibleLines(cm.display, cm.doc, viewPort);
+ for (var first = true;; first = false) {
+ var oldWidth = cm.display.scroller.clientWidth;
+ if (!updateDisplayInner(cm, visible, forced)) break;
+ updated = true;
+
+ // If the max line changed since it was last measured, measure it,
+ // and ensure the document's width matches it.
+ if (cm.display.maxLineChanged && !cm.options.lineWrapping)
+ adjustContentWidth(cm);
+
+ var barMeasure = measureForScrollbars(cm);
+ updateSelection(cm);
+ setDocumentHeight(cm, barMeasure);
+ updateScrollbars(cm, barMeasure);
+ if (webkit && cm.options.lineWrapping)
+ checkForWebkitWidthBug(cm, barMeasure); // (Issue #2420)
+ if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) {
+ forced = true;
+ continue;
+ }
+ forced = false;
+
+ // Clip forced viewport to actual scrollable area.
+ if (viewPort && viewPort.top != null)
+ viewPort = {top: Math.min(barMeasure.docHeight - scrollerCutOff - barMeasure.clientHeight, viewPort.top)};
+ // Updated line heights might result in the drawn area not
+ // actually covering the viewport. Keep looping until it does.
+ visible = visibleLines(cm.display, cm.doc, viewPort);
+ if (visible.from >= cm.display.viewFrom && visible.to <= cm.display.viewTo)
+ break;
+ }
+
+ cm.display.updateLineNumbers = null;
+ if (updated) {
+ signalLater(cm, "update", cm);
+ if (cm.display.viewFrom != oldFrom || cm.display.viewTo != oldTo)
+ signalLater(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
+ }
+ return updated;
+ }
+
+ // Does the actual updating of the line display. Bails out
+ // (returning false) when there is nothing to be done and forced is
+ // false.
+ function updateDisplayInner(cm, visible, forced) {
+ var display = cm.display, doc = cm.doc;
+ if (!display.wrapper.offsetWidth) {
+ resetView(cm);
+ return;
+ }
+
+ // Bail out if the visible area is already rendered and nothing changed.
+ if (!forced && visible.from >= display.viewFrom && visible.to <= display.viewTo &&
+ countDirtyView(cm) == 0)
+ return;
+
+ if (maybeUpdateLineNumberWidth(cm))
+ resetView(cm);
+ var dims = getDimensions(cm);
+
+ // Compute a suitable new viewport (from & to)
+ var end = doc.first + doc.size;
+ var from = Math.max(visible.from - cm.options.viewportMargin, doc.first);
+ var to = Math.min(end, visible.to + cm.options.viewportMargin);
+ if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
+ if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
+ if (sawCollapsedSpans) {
+ from = visualLineNo(cm.doc, from);
+ to = visualLineEndNo(cm.doc, to);
+ }
+
+ var different = from != display.viewFrom || to != display.viewTo ||
+ display.lastSizeC != display.wrapper.clientHeight;
+ adjustView(cm, from, to);
+
+ display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
+ // Position the mover div to align with the current scroll position
+ cm.display.mover.style.top = display.viewOffset + "px";
+
+ var toUpdate = countDirtyView(cm);
+ if (!different && toUpdate == 0 && !forced) return;
+
+ // For big changes, we hide the enclosing element during the
+ // update, since that speeds up the operations on most browsers.
+ var focused = activeElt();
+ if (toUpdate > 4) display.lineDiv.style.display = "none";
+ patchDisplay(cm, display.updateLineNumbers, dims);
+ if (toUpdate > 4) display.lineDiv.style.display = "";
+ // There might have been a widget with a focused element that got
+ // hidden or updated, if so re-focus it.
+ if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
+
+ // Prevent selection and cursors from interfering with the scroll
+ // width.
+ removeChildren(display.cursorDiv);
+ removeChildren(display.selectionDiv);
+
+ if (different) {
+ display.lastSizeC = display.wrapper.clientHeight;
+ startWorker(cm, 400);
+ }
+
+ updateHeightsInViewport(cm);
+
+ return true;
+ }
+
+ function adjustContentWidth(cm) {
+ var display = cm.display;
+ var width = measureChar(cm, display.maxLine, display.maxLine.text.length).left;
+ display.maxLineChanged = false;
+ var minWidth = Math.max(0, width + 3);
+ var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + minWidth + scrollerCutOff - display.scroller.clientWidth);
+ display.sizer.style.minWidth = minWidth + "px";
+ if (maxScrollLeft < cm.doc.scrollLeft)
+ setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true);
+ }
+
+ function setDocumentHeight(cm, measure) {
+ cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = measure.docHeight + "px";
+ cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px";
+ }
+
+
+ function checkForWebkitWidthBug(cm, measure) {
+ // Work around Webkit bug where it sometimes reserves space for a
+ // non-existing phantom scrollbar in the scroller (Issue #2420)
+ if (cm.display.sizer.offsetWidth + cm.display.gutters.offsetWidth < cm.display.scroller.clientWidth - 1) {
+ cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = "0px";
+ cm.display.gutters.style.height = measure.docHeight + "px";
+ }
+ }
+
+ // Read the actual heights of the rendered lines, and update their
+ // stored heights to match.
+ function updateHeightsInViewport(cm) {
+ var display = cm.display;
+ var prevBottom = display.lineDiv.offsetTop;
+ for (var i = 0; i < display.view.length; i++) {
+ var cur = display.view[i], height;
+ if (cur.hidden) continue;
+ if (ie_upto7) {
+ var bot = cur.node.offsetTop + cur.node.offsetHeight;
+ height = bot - prevBottom;
+ prevBottom = bot;
+ } else {
+ var box = cur.node.getBoundingClientRect();
+ height = box.bottom - box.top;
+ }
+ var diff = cur.line.height - height;
+ if (height < 2) height = textHeight(display);
+ if (diff > .001 || diff < -.001) {
+ updateLineHeight(cur.line, height);
+ updateWidgetHeight(cur.line);
+ if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
+ updateWidgetHeight(cur.rest[j]);
+ }
+ }
+ }
+
+ // Read and store the height of line widgets associated with the
+ // given line.
+ function updateWidgetHeight(line) {
+ if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
+ line.widgets[i].height = line.widgets[i].node.offsetHeight;
+ }
+
+ // Do a bulk-read of the DOM positions and sizes needed to draw the
+ // view, so that we don't interleave reading and writing to the DOM.
+ function getDimensions(cm) {
+ var d = cm.display, left = {}, width = {};
+ for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
+ left[cm.options.gutters[i]] = n.offsetLeft;
+ width[cm.options.gutters[i]] = n.offsetWidth;
+ }
+ return {fixedPos: compensateForHScroll(d),
+ gutterTotalWidth: d.gutters.offsetWidth,
+ gutterLeft: left,
+ gutterWidth: width,
+ wrapperWidth: d.wrapper.clientWidth};
+ }
+
+ // Sync the actual display DOM structure with display.view, removing
+ // nodes for lines that are no longer in view, and creating the ones
+ // that are not there yet, and updating the ones that are out of
+ // date.
+ function patchDisplay(cm, updateNumbersFrom, dims) {
+ var display = cm.display, lineNumbers = cm.options.lineNumbers;
+ var container = display.lineDiv, cur = container.firstChild;
+
+ function rm(node) {
+ var next = node.nextSibling;
+ // Works around a throw-scroll bug in OS X Webkit
+ if (webkit && mac && cm.display.currentWheelTarget == node)
+ node.style.display = "none";
+ else
+ node.parentNode.removeChild(node);
+ return next;
+ }
+
+ var view = display.view, lineN = display.viewFrom;
+ // Loop over the elements in the view, syncing cur (the DOM nodes
+ // in display.lineDiv) with the view as we go.
+ for (var i = 0; i < view.length; i++) {
+ var lineView = view[i];
+ if (lineView.hidden) {
+ } else if (!lineView.node) { // Not drawn yet
+ var node = buildLineElement(cm, lineView, lineN, dims);
+ container.insertBefore(node, cur);
+ } else { // Already drawn
+ while (cur != lineView.node) cur = rm(cur);
+ var updateNumber = lineNumbers && updateNumbersFrom != null &&
+ updateNumbersFrom <= lineN && lineView.lineNumber;
+ if (lineView.changes) {
+ if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
+ updateLineForChanges(cm, lineView, lineN, dims);
+ }
+ if (updateNumber) {
+ removeChildren(lineView.lineNumber);
+ lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
+ }
+ cur = lineView.node.nextSibling;
+ }
+ lineN += lineView.size;
+ }
+ while (cur) cur = rm(cur);
+ }
+
+ // When an aspect of a line changes, a string is added to
+ // lineView.changes. This updates the relevant part of the line's
+ // DOM structure.
+ function updateLineForChanges(cm, lineView, lineN, dims) {
+ for (var j = 0; j < lineView.changes.length; j++) {
+ var type = lineView.changes[j];
+ if (type == "text") updateLineText(cm, lineView);
+ else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
+ else if (type == "class") updateLineClasses(lineView);
+ else if (type == "widget") updateLineWidgets(lineView, dims);
+ }
+ lineView.changes = null;
+ }
+
+ // Lines with gutter elements, widgets or a background class need to
+ // be wrapped, and have the extra elements added to the wrapper div
+ function ensureLineWrapped(lineView) {
+ if (lineView.node == lineView.text) {
+ lineView.node = elt("div", null, null, "position: relative");
+ if (lineView.text.parentNode)
+ lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
+ lineView.node.appendChild(lineView.text);
+ if (ie_upto7) lineView.node.style.zIndex = 2;
+ }
+ return lineView.node;
+ }
+
+ function updateLineBackground(lineView) {
+ var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
+ if (cls) cls += " CodeMirror-linebackground";
+ if (lineView.background) {
+ if (cls) lineView.background.className = cls;
+ else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
+ } else if (cls) {
+ var wrap = ensureLineWrapped(lineView);
+ lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
+ }
+ }
+
+ // Wrapper around buildLineContent which will reuse the structure
+ // in display.externalMeasured when possible.
+ function getLineContent(cm, lineView) {
+ var ext = cm.display.externalMeasured;
+ if (ext && ext.line == lineView.line) {
+ cm.display.externalMeasured = null;
+ lineView.measure = ext.measure;
+ return ext.built;
+ }
+ return buildLineContent(cm, lineView);
+ }
+
+ // Redraw the line's text. Interacts with the background and text
+ // classes because the mode may output tokens that influence these
+ // classes.
+ function updateLineText(cm, lineView) {
+ var cls = lineView.text.className;
+ var built = getLineContent(cm, lineView);
+ if (lineView.text == lineView.node) lineView.node = built.pre;
+ lineView.text.parentNode.replaceChild(built.pre, lineView.text);
+ lineView.text = built.pre;
+ if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
+ lineView.bgClass = built.bgClass;
+ lineView.textClass = built.textClass;
+ updateLineClasses(lineView);
+ } else if (cls) {
+ lineView.text.className = cls;
+ }
+ }
+
+ function updateLineClasses(lineView) {
+ updateLineBackground(lineView);
+ if (lineView.line.wrapClass)
+ ensureLineWrapped(lineView).className = lineView.line.wrapClass;
+ else if (lineView.node != lineView.text)
+ lineView.node.className = "";
+ var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
+ lineView.text.className = textClass || "";
+ }
+
+ function updateLineGutter(cm, lineView, lineN, dims) {
+ if (lineView.gutter) {
+ lineView.node.removeChild(lineView.gutter);
+ lineView.gutter = null;
+ }
+ var markers = lineView.line.gutterMarkers;
+ if (cm.options.lineNumbers || markers) {
+ var wrap = ensureLineWrapped(lineView);
+ var gutterWrap = lineView.gutter =
+ wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " +
+ (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"),
+ lineView.text);
+ if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
+ lineView.lineNumber = gutterWrap.appendChild(
+ elt("div", lineNumberFor(cm.options, lineN),
+ "CodeMirror-linenumber CodeMirror-gutter-elt",
+ "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
+ + cm.display.lineNumInnerWidth + "px"));
+ if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
+ var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
+ if (found)
+ gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
+ dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
+ }
+ }
+ }
+
+ function updateLineWidgets(lineView, dims) {
+ if (lineView.alignable) lineView.alignable = null;
+ for (var node = lineView.node.firstChild, next; node; node = next) {
+ var next = node.nextSibling;
+ if (node.className == "CodeMirror-linewidget")
+ lineView.node.removeChild(node);
+ }
+ insertLineWidgets(lineView, dims);
+ }
+
+ // Build a line's DOM representation from scratch
+ function buildLineElement(cm, lineView, lineN, dims) {
+ var built = getLineContent(cm, lineView);
+ lineView.text = lineView.node = built.pre;
+ if (built.bgClass) lineView.bgClass = built.bgClass;
+ if (built.textClass) lineView.textClass = built.textClass;
+
+ updateLineClasses(lineView);
+ updateLineGutter(cm, lineView, lineN, dims);
+ insertLineWidgets(lineView, dims);
+ return lineView.node;
+ }
+
+ // A lineView may contain multiple logical lines (when merged by
+ // collapsed spans). The widgets for all of them need to be drawn.
+ function insertLineWidgets(lineView, dims) {
+ insertLineWidgetsFor(lineView.line, lineView, dims, true);
+ if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
+ insertLineWidgetsFor(lineView.rest[i], lineView, dims, false);
+ }
+
+ function insertLineWidgetsFor(line, lineView, dims, allowAbove) {
+ if (!line.widgets) return;
+ var wrap = ensureLineWrapped(lineView);
+ for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
+ var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
+ if (!widget.handleMouseEvents) node.ignoreEvents = true;
+ positionLineWidget(widget, node, lineView, dims);
+ if (allowAbove && widget.above)
+ wrap.insertBefore(node, lineView.gutter || lineView.text);
+ else
+ wrap.appendChild(node);
+ signalLater(widget, "redraw");
+ }
+ }
+
+ function positionLineWidget(widget, node, lineView, dims) {
+ if (widget.noHScroll) {
+ (lineView.alignable || (lineView.alignable = [])).push(node);
+ var width = dims.wrapperWidth;
+ node.style.left = dims.fixedPos + "px";
+ if (!widget.coverGutter) {
+ width -= dims.gutterTotalWidth;
+ node.style.paddingLeft = dims.gutterTotalWidth + "px";
+ }
+ node.style.width = width + "px";
+ }
+ if (widget.coverGutter) {
+ node.style.zIndex = 5;
+ node.style.position = "relative";
+ if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
+ }
+ }
+
+ // POSITION OBJECT
+
+ // A Pos instance represents a position within the text.
+ var Pos = CodeMirror.Pos = function(line, ch) {
+ if (!(this instanceof Pos)) return new Pos(line, ch);
+ this.line = line; this.ch = ch;
+ };
+
+ // Compare two positions, return 0 if they are the same, a negative
+ // number when a is less, and a positive number otherwise.
+ var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
+
+ function copyPos(x) {return Pos(x.line, x.ch);}
+ function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
+ function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
+
+ // SELECTION / CURSOR
+
+ // Selection objects are immutable. A new one is created every time
+ // the selection changes. A selection is one or more non-overlapping
+ // (and non-touching) ranges, sorted, and an integer that indicates
+ // which one is the primary selection (the one that's scrolled into
+ // view, that getCursor returns, etc).
+ function Selection(ranges, primIndex) {
+ this.ranges = ranges;
+ this.primIndex = primIndex;
+ }
+
+ Selection.prototype = {
+ primary: function() { return this.ranges[this.primIndex]; },
+ equals: function(other) {
+ if (other == this) return true;
+ if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
+ for (var i = 0; i < this.ranges.length; i++) {
+ var here = this.ranges[i], there = other.ranges[i];
+ if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
+ }
+ return true;
+ },
+ deepCopy: function() {
+ for (var out = [], i = 0; i < this.ranges.length; i++)
+ out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
+ return new Selection(out, this.primIndex);
+ },
+ somethingSelected: function() {
+ for (var i = 0; i < this.ranges.length; i++)
+ if (!this.ranges[i].empty()) return true;
+ return false;
+ },
+ contains: function(pos, end) {
+ if (!end) end = pos;
+ for (var i = 0; i < this.ranges.length; i++) {
+ var range = this.ranges[i];
+ if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
+ return i;
+ }
+ return -1;
+ }
+ };
+
+ function Range(anchor, head) {
+ this.anchor = anchor; this.head = head;
+ }
+
+ Range.prototype = {
+ from: function() { return minPos(this.anchor, this.head); },
+ to: function() { return maxPos(this.anchor, this.head); },
+ empty: function() {
+ return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
+ }
+ };
+
+ // Take an unsorted, potentially overlapping set of ranges, and
+ // build a selection out of it. 'Consumes' ranges array (modifying
+ // it).
+ function normalizeSelection(ranges, primIndex) {
+ var prim = ranges[primIndex];
+ ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
+ primIndex = indexOf(ranges, prim);
+ for (var i = 1; i < ranges.length; i++) {
+ var cur = ranges[i], prev = ranges[i - 1];
+ if (cmp(prev.to(), cur.from()) >= 0) {
+ var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
+ var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
+ if (i <= primIndex) --primIndex;
+ ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
+ }
+ }
+ return new Selection(ranges, primIndex);
+ }
+
+ function simpleSelection(anchor, head) {
+ return new Selection([new Range(anchor, head || anchor)], 0);
+ }
+
+ // Most of the external API clips given positions to make sure they
+ // actually exist within the document.
+ function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
+ function clipPos(doc, pos) {
+ if (pos.line < doc.first) return Pos(doc.first, 0);
+ var last = doc.first + doc.size - 1;
+ if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
+ return clipToLen(pos, getLine(doc, pos.line).text.length);
+ }
+ function clipToLen(pos, linelen) {
+ var ch = pos.ch;
+ if (ch == null || ch > linelen) return Pos(pos.line, linelen);
+ else if (ch < 0) return Pos(pos.line, 0);
+ else return pos;
+ }
+ function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
+ function clipPosArray(doc, array) {
+ for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
+ return out;
+ }
+
+ // SELECTION UPDATES
+
+ // The 'scroll' parameter given to many of these indicated whether
+ // the new cursor position should be scrolled into view after
+ // modifying the selection.
+
+ // If shift is held or the extend flag is set, extends a range to
+ // include a given position (and optionally a second position).
+ // Otherwise, simply returns the range between the given positions.
+ // Used for cursor motion and such.
+ function extendRange(doc, range, head, other) {
+ if (doc.cm && doc.cm.display.shift || doc.extend) {
+ var anchor = range.anchor;
+ if (other) {
+ var posBefore = cmp(head, anchor) < 0;
+ if (posBefore != (cmp(other, anchor) < 0)) {
+ anchor = head;
+ head = other;
+ } else if (posBefore != (cmp(head, other) < 0)) {
+ head = other;
+ }
+ }
+ return new Range(anchor, head);
+ } else {
+ return new Range(other || head, head);
+ }
+ }
+
+ // Extend the primary selection range, discard the rest.
+ function extendSelection(doc, head, other, options) {
+ setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
+ }
+
+ // Extend all selections (pos is an array of selections with length
+ // equal the number of selections)
+ function extendSelections(doc, heads, options) {
+ for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
+ out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
+ var newSel = normalizeSelection(out, doc.sel.primIndex);
+ setSelection(doc, newSel, options);
+ }
+
+ // Updates a single range in the selection.
+ function replaceOneSelection(doc, i, range, options) {
+ var ranges = doc.sel.ranges.slice(0);
+ ranges[i] = range;
+ setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
+ }
+
+ // Reset the selection to a single range.
+ function setSimpleSelection(doc, anchor, head, options) {
+ setSelection(doc, simpleSelection(anchor, head), options);
+ }
+
+ // Give beforeSelectionChange handlers a change to influence a
+ // selection update.
+ function filterSelectionChange(doc, sel) {
+ var obj = {
+ ranges: sel.ranges,
+ update: function(ranges) {
+ this.ranges = [];
+ for (var i = 0; i < ranges.length; i++)
+ this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
+ clipPos(doc, ranges[i].head));
+ }
+ };
+ signal(doc, "beforeSelectionChange", doc, obj);
+ if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
+ if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
+ else return sel;
+ }
+
+ function setSelectionReplaceHistory(doc, sel, options) {
+ var done = doc.history.done, last = lst(done);
+ if (last && last.ranges) {
+ done[done.length - 1] = sel;
+ setSelectionNoUndo(doc, sel, options);
+ } else {
+ setSelection(doc, sel, options);
+ }
+ }
+
+ // Set a new selection.
+ function setSelection(doc, sel, options) {
+ setSelectionNoUndo(doc, sel, options);
+ addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
+ }
+
+ function setSelectionNoUndo(doc, sel, options) {
+ if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
+ sel = filterSelectionChange(doc, sel);
+
+ var bias = cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1;
+ setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
+
+ if (!(options && options.scroll === false) && doc.cm)
+ ensureCursorVisible(doc.cm);
+ }
+
+ function setSelectionInner(doc, sel) {
+ if (sel.equals(doc.sel)) return;
+
+ doc.sel = sel;
+
+ if (doc.cm) {
+ doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
+ signalCursorActivity(doc.cm);
+ }
+ signalLater(doc, "cursorActivity", doc);
+ }
+
+ // Verify that the selection does not partially select any atomic
+ // marked ranges.
+ function reCheckSelection(doc) {
+ setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
+ }
+
+ // Return a selection that does not partially select any atomic
+ // ranges.
+ function skipAtomicInSelection(doc, sel, bias, mayClear) {
+ var out;
+ for (var i = 0; i < sel.ranges.length; i++) {
+ var range = sel.ranges[i];
+ var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear);
+ var newHead = skipAtomic(doc, range.head, bias, mayClear);
+ if (out || newAnchor != range.anchor || newHead != range.head) {
+ if (!out) out = sel.ranges.slice(0, i);
+ out[i] = new Range(newAnchor, newHead);
+ }
+ }
+ return out ? normalizeSelection(out, sel.primIndex) : sel;
+ }
+
+ // Ensure a given position is not inside an atomic range.
+ function skipAtomic(doc, pos, bias, mayClear) {
+ var flipped = false, curPos = pos;
+ var dir = bias || 1;
+ doc.cantEdit = false;
+ search: for (;;) {
+ var line = getLine(doc, curPos.line);
+ if (line.markedSpans) {
+ for (var i = 0; i < line.markedSpans.length; ++i) {
+ var sp = line.markedSpans[i], m = sp.marker;
+ if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
+ (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
+ if (mayClear) {
+ signal(m, "beforeCursorEnter");
+ if (m.explicitlyCleared) {
+ if (!line.markedSpans) break;
+ else {--i; continue;}
+ }
+ }
+ if (!m.atomic) continue;
+ var newPos = m.find(dir < 0 ? -1 : 1);
+ if (cmp(newPos, curPos) == 0) {
+ newPos.ch += dir;
+ if (newPos.ch < 0) {
+ if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1));
+ else newPos = null;
+ } else if (newPos.ch > line.text.length) {
+ if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0);
+ else newPos = null;
+ }
+ if (!newPos) {
+ if (flipped) {
+ // Driven in a corner -- no valid cursor position found at all
+ // -- try again *with* clearing, if we didn't already
+ if (!mayClear) return skipAtomic(doc, pos, bias, true);
+ // Otherwise, turn off editing until further notice, and return the start of the doc
+ doc.cantEdit = true;
+ return Pos(doc.first, 0);
+ }
+ flipped = true; newPos = pos; dir = -dir;
+ }
+ }
+ curPos = newPos;
+ continue search;
+ }
+ }
+ }
+ return curPos;
+ }
+ }
+
+ // SELECTION DRAWING
+
+ // Redraw the selection and/or cursor
+ function updateSelection(cm) {
+ var display = cm.display, doc = cm.doc;
+ var curFragment = document.createDocumentFragment();
+ var selFragment = document.createDocumentFragment();
+
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ var range = doc.sel.ranges[i];
+ var collapsed = range.empty();
+ if (collapsed || cm.options.showCursorWhenSelecting)
+ drawSelectionCursor(cm, range, curFragment);
+ if (!collapsed)
+ drawSelectionRange(cm, range, selFragment);
+ }
+
+ // Move the hidden textarea near the cursor to prevent scrolling artifacts
+ if (cm.options.moveInputWithCursor) {
+ var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
+ var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
+ var top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
+ headPos.top + lineOff.top - wrapOff.top));
+ var left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
+ headPos.left + lineOff.left - wrapOff.left));
+ display.inputDiv.style.top = top + "px";
+ display.inputDiv.style.left = left + "px";
+ }
+
+ removeChildrenAndAdd(display.cursorDiv, curFragment);
+ removeChildrenAndAdd(display.selectionDiv, selFragment);
+ }
+
+ // Draws a cursor for the given range
+ function drawSelectionCursor(cm, range, output) {
+ var pos = cursorCoords(cm, range.head, "div");
+
+ var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
+ cursor.style.left = pos.left + "px";
+ cursor.style.top = pos.top + "px";
+ cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
+
+ if (pos.other) {
+ // Secondary cursor, shown when on a 'jump' in bi-directional text
+ var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
+ otherCursor.style.display = "";
+ otherCursor.style.left = pos.other.left + "px";
+ otherCursor.style.top = pos.other.top + "px";
+ otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
+ }
+ }
+
+ // Draws the given range as a highlighted selection
+ function drawSelectionRange(cm, range, output) {
+ var display = cm.display, doc = cm.doc;
+ var fragment = document.createDocumentFragment();
+ var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - padding.right;
+
+ function add(left, top, width, bottom) {
+ if (top < 0) top = 0;
+ top = Math.round(top);
+ bottom = Math.round(bottom);
+ fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
+ "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
+ "px; height: " + (bottom - top) + "px"));
+ }
+
+ function drawForLine(line, fromArg, toArg) {
+ var lineObj = getLine(doc, line);
+ var lineLen = lineObj.text.length;
+ var start, end;
+ function coords(ch, bias) {
+ return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
+ }
+
+ iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
+ var leftPos = coords(from, "left"), rightPos, left, right;
+ if (from == to) {
+ rightPos = leftPos;
+ left = right = leftPos.left;
+ } else {
+ rightPos = coords(to - 1, "right");
+ if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
+ left = leftPos.left;
+ right = rightPos.right;
+ }
+ if (fromArg == null && from == 0) left = leftSide;
+ if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
+ add(left, leftPos.top, null, leftPos.bottom);
+ left = leftSide;
+ if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
+ }
+ if (toArg == null && to == lineLen) right = rightSide;
+ if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
+ start = leftPos;
+ if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
+ end = rightPos;
+ if (left < leftSide + 1) left = leftSide;
+ add(left, rightPos.top, right - left, rightPos.bottom);
+ });
+ return {start: start, end: end};
+ }
+
+ var sFrom = range.from(), sTo = range.to();
+ if (sFrom.line == sTo.line) {
+ drawForLine(sFrom.line, sFrom.ch, sTo.ch);
+ } else {
+ var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
+ var singleVLine = visualLine(fromLine) == visualLine(toLine);
+ var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
+ var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
+ if (singleVLine) {
+ if (leftEnd.top < rightStart.top - 2) {
+ add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
+ add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
+ } else {
+ add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
+ }
+ }
+ if (leftEnd.bottom < rightStart.top)
+ add(leftSide, leftEnd.bottom, null, rightStart.top);
+ }
+
+ output.appendChild(fragment);
+ }
+
+ // Cursor-blinking
+ function restartBlink(cm) {
+ if (!cm.state.focused) return;
+ var display = cm.display;
+ clearInterval(display.blinker);
+ var on = true;
+ display.cursorDiv.style.visibility = "";
+ if (cm.options.cursorBlinkRate > 0)
+ display.blinker = setInterval(function() {
+ display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
+ }, cm.options.cursorBlinkRate);
+ }
+
+ // HIGHLIGHT WORKER
+
+ function startWorker(cm, time) {
+ if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
+ cm.state.highlight.set(time, bind(highlightWorker, cm));
+ }
+
+ function highlightWorker(cm) {
+ var doc = cm.doc;
+ if (doc.frontier < doc.first) doc.frontier = doc.first;
+ if (doc.frontier >= cm.display.viewTo) return;
+ var end = +new Date + cm.options.workTime;
+ var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
+
+ runInOp(cm, function() {
+ doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
+ if (doc.frontier >= cm.display.viewFrom) { // Visible
+ var oldStyles = line.styles;
+ var highlighted = highlightLine(cm, line, state, true);
+ line.styles = highlighted.styles;
+ if (highlighted.classes) line.styleClasses = highlighted.classes;
+ else if (line.styleClasses) line.styleClasses = null;
+ var ischange = !oldStyles || oldStyles.length != line.styles.length;
+ for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
+ if (ischange) regLineChange(cm, doc.frontier, "text");
+ line.stateAfter = copyState(doc.mode, state);
+ } else {
+ processLine(cm, line.text, state);
+ line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
+ }
+ ++doc.frontier;
+ if (+new Date > end) {
+ startWorker(cm, cm.options.workDelay);
+ return true;
+ }
+ });
+ });
+ }
+
+ // Finds the line to start with when starting a parse. Tries to
+ // find a line with a stateAfter, so that it can start with a
+ // valid state. If that fails, it returns the line with the
+ // smallest indentation, which tends to need the least context to
+ // parse correctly.
+ function findStartLine(cm, n, precise) {
+ var minindent, minline, doc = cm.doc;
+ var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
+ for (var search = n; search > lim; --search) {
+ if (search <= doc.first) return doc.first;
+ var line = getLine(doc, search - 1);
+ if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
+ var indented = countColumn(line.text, null, cm.options.tabSize);
+ if (minline == null || minindent > indented) {
+ minline = search - 1;
+ minindent = indented;
+ }
+ }
+ return minline;
+ }
+
+ function getStateBefore(cm, n, precise) {
+ var doc = cm.doc, display = cm.display;
+ if (!doc.mode.startState) return true;
+ var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
+ if (!state) state = startState(doc.mode);
+ else state = copyState(doc.mode, state);
+ doc.iter(pos, n, function(line) {
+ processLine(cm, line.text, state);
+ var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
+ line.stateAfter = save ? copyState(doc.mode, state) : null;
+ ++pos;
+ });
+ if (precise) doc.frontier = pos;
+ return state;
+ }
+
+ // POSITION MEASUREMENT
+
+ function paddingTop(display) {return display.lineSpace.offsetTop;}
+ function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
+ function paddingH(display) {
+ if (display.cachedPaddingH) return display.cachedPaddingH;
+ var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
+ var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
+ var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
+ if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
+ return data;
+ }
+
+ // Ensure the lineView.wrapping.heights array is populated. This is
+ // an array of bottom offsets for the lines that make up a drawn
+ // line. When lineWrapping is on, there might be more than one
+ // height.
+ function ensureLineHeights(cm, lineView, rect) {
+ var wrapping = cm.options.lineWrapping;
+ var curWidth = wrapping && cm.display.scroller.clientWidth;
+ if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
+ var heights = lineView.measure.heights = [];
+ if (wrapping) {
+ lineView.measure.width = curWidth;
+ var rects = lineView.text.firstChild.getClientRects();
+ for (var i = 0; i < rects.length - 1; i++) {
+ var cur = rects[i], next = rects[i + 1];
+ if (Math.abs(cur.bottom - next.bottom) > 2)
+ heights.push((cur.bottom + next.top) / 2 - rect.top);
+ }
+ }
+ heights.push(rect.bottom - rect.top);
+ }
+ }
+
+ // Find a line map (mapping character offsets to text nodes) and a
+ // measurement cache for the given line number. (A line view might
+ // contain multiple lines when collapsed ranges are present.)
+ function mapFromLineView(lineView, line, lineN) {
+ if (lineView.line == line)
+ return {map: lineView.measure.map, cache: lineView.measure.cache};
+ for (var i = 0; i < lineView.rest.length; i++)
+ if (lineView.rest[i] == line)
+ return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
+ for (var i = 0; i < lineView.rest.length; i++)
+ if (lineNo(lineView.rest[i]) > lineN)
+ return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
+ }
+
+ // Render a line into the hidden node display.externalMeasured. Used
+ // when measurement is needed for a line that's not in the viewport.
+ function updateExternalMeasurement(cm, line) {
+ line = visualLine(line);
+ var lineN = lineNo(line);
+ var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
+ view.lineN = lineN;
+ var built = view.built = buildLineContent(cm, view);
+ view.text = built.pre;
+ removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
+ return view;
+ }
+
+ // Get a {top, bottom, left, right} box (in line-local coordinates)
+ // for a given character.
+ function measureChar(cm, line, ch, bias) {
+ return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
+ }
+
+ // Find a line view that corresponds to the given line number.
+ function findViewForLine(cm, lineN) {
+ if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
+ return cm.display.view[findViewIndex(cm, lineN)];
+ var ext = cm.display.externalMeasured;
+ if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
+ return ext;
+ }
+
+ // Measurement can be split in two steps, the set-up work that
+ // applies to the whole line, and the measurement of the actual
+ // character. Functions like coordsChar, that need to do a lot of
+ // measurements in a row, can thus ensure that the set-up work is
+ // only done once.
+ function prepareMeasureForLine(cm, line) {
+ var lineN = lineNo(line);
+ var view = findViewForLine(cm, lineN);
+ if (view && !view.text)
+ view = null;
+ else if (view && view.changes)
+ updateLineForChanges(cm, view, lineN, getDimensions(cm));
+ if (!view)
+ view = updateExternalMeasurement(cm, line);
+
+ var info = mapFromLineView(view, line, lineN);
+ return {
+ line: line, view: view, rect: null,
+ map: info.map, cache: info.cache, before: info.before,
+ hasHeights: false
+ };
+ }
+
+ // Given a prepared measurement object, measures the position of an
+ // actual character (or fetches it from the cache).
+ function measureCharPrepared(cm, prepared, ch, bias) {
+ if (prepared.before) ch = -1;
+ var key = ch + (bias || ""), found;
+ if (prepared.cache.hasOwnProperty(key)) {
+ found = prepared.cache[key];
+ } else {
+ if (!prepared.rect)
+ prepared.rect = prepared.view.text.getBoundingClientRect();
+ if (!prepared.hasHeights) {
+ ensureLineHeights(cm, prepared.view, prepared.rect);
+ prepared.hasHeights = true;
+ }
+ found = measureCharInner(cm, prepared, ch, bias);
+ if (!found.bogus) prepared.cache[key] = found;
+ }
+ return {left: found.left, right: found.right, top: found.top, bottom: found.bottom};
+ }
+
+ var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
+
+ function measureCharInner(cm, prepared, ch, bias) {
+ var map = prepared.map;
+
+ var node, start, end, collapse;
+ // First, search the line map for the text node corresponding to,
+ // or closest to, the target character.
+ for (var i = 0; i < map.length; i += 3) {
+ var mStart = map[i], mEnd = map[i + 1];
+ if (ch < mStart) {
+ start = 0; end = 1;
+ collapse = "left";
+ } else if (ch < mEnd) {
+ start = ch - mStart;
+ end = start + 1;
+ } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
+ end = mEnd - mStart;
+ start = end - 1;
+ if (ch >= mEnd) collapse = "right";
+ }
+ if (start != null) {
+ node = map[i + 2];
+ if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
+ collapse = bias;
+ if (bias == "left" && start == 0)
+ while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
+ node = map[(i -= 3) + 2];
+ collapse = "left";
+ }
+ if (bias == "right" && start == mEnd - mStart)
+ while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
+ node = map[(i += 3) + 2];
+ collapse = "right";
+ }
+ break;
+ }
+ }
+
+ var rect;
+ if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
+ while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) --start;
+ while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) ++end;
+ if (ie_upto8 && start == 0 && end == mEnd - mStart) {
+ rect = node.parentNode.getBoundingClientRect();
+ } else if (ie && cm.options.lineWrapping) {
+ var rects = range(node, start, end).getClientRects();
+ if (rects.length)
+ rect = rects[bias == "right" ? rects.length - 1 : 0];
+ else
+ rect = nullRect;
+ } else {
+ rect = range(node, start, end).getBoundingClientRect();
+ }
+ } else { // If it is a widget, simply get the box for the whole widget.
+ if (start > 0) collapse = bias = "right";
+ var rects;
+ if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
+ rect = rects[bias == "right" ? rects.length - 1 : 0];
+ else
+ rect = node.getBoundingClientRect();
+ }
+ if (ie_upto8 && !start && (!rect || !rect.left && !rect.right)) {
+ var rSpan = node.parentNode.getClientRects()[0];
+ if (rSpan)
+ rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
+ else
+ rect = nullRect;
+ }
+
+ var top, bot = (rect.bottom + rect.top) / 2 - prepared.rect.top;
+ var heights = prepared.view.measure.heights;
+ for (var i = 0; i < heights.length - 1; i++)
+ if (bot < heights[i]) break;
+ top = i ? heights[i - 1] : 0; bot = heights[i];
+ var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
+ right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
+ top: top, bottom: bot};
+ if (!rect.left && !rect.right) result.bogus = true;
+ return result;
+ }
+
+ function clearLineMeasurementCacheFor(lineView) {
+ if (lineView.measure) {
+ lineView.measure.cache = {};
+ lineView.measure.heights = null;
+ if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
+ lineView.measure.caches[i] = {};
+ }
+ }
+
+ function clearLineMeasurementCache(cm) {
+ cm.display.externalMeasure = null;
+ removeChildren(cm.display.lineMeasure);
+ for (var i = 0; i < cm.display.view.length; i++)
+ clearLineMeasurementCacheFor(cm.display.view[i]);
+ }
+
+ function clearCaches(cm) {
+ clearLineMeasurementCache(cm);
+ cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
+ if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
+ cm.display.lineNumChars = null;
+ }
+
+ function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
+ function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
+
+ // Converts a {top, bottom, left, right} box from line-local
+ // coordinates into another coordinate system. Context may be one of
+ // "line", "div" (display.lineDiv), "local"/null (editor), or "page".
+ function intoCoordSystem(cm, lineObj, rect, context) {
+ if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
+ var size = widgetHeight(lineObj.widgets[i]);
+ rect.top += size; rect.bottom += size;
+ }
+ if (context == "line") return rect;
+ if (!context) context = "local";
+ var yOff = heightAtLine(lineObj);
+ if (context == "local") yOff += paddingTop(cm.display);
+ else yOff -= cm.display.viewOffset;
+ if (context == "page" || context == "window") {
+ var lOff = cm.display.lineSpace.getBoundingClientRect();
+ yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
+ var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
+ rect.left += xOff; rect.right += xOff;
+ }
+ rect.top += yOff; rect.bottom += yOff;
+ return rect;
+ }
+
+ // Coverts a box from "div" coords to another coordinate system.
+ // Context may be "window", "page", "div", or "local"/null.
+ function fromCoordSystem(cm, coords, context) {
+ if (context == "div") return coords;
+ var left = coords.left, top = coords.top;
+ // First move into "page" coordinate system
+ if (context == "page") {
+ left -= pageScrollX();
+ top -= pageScrollY();
+ } else if (context == "local" || !context) {
+ var localBox = cm.display.sizer.getBoundingClientRect();
+ left += localBox.left;
+ top += localBox.top;
+ }
+
+ var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
+ return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
+ }
+
+ function charCoords(cm, pos, context, lineObj, bias) {
+ if (!lineObj) lineObj = getLine(cm.doc, pos.line);
+ return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
+ }
+
+ // Returns a box for a given cursor position, which may have an
+ // 'other' property containing the position of the secondary cursor
+ // on a bidi boundary.
+ function cursorCoords(cm, pos, context, lineObj, preparedMeasure) {
+ lineObj = lineObj || getLine(cm.doc, pos.line);
+ if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
+ function get(ch, right) {
+ var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left");
+ if (right) m.left = m.right; else m.right = m.left;
+ return intoCoordSystem(cm, lineObj, m, context);
+ }
+ function getBidi(ch, partPos) {
+ var part = order[partPos], right = part.level % 2;
+ if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
+ part = order[--partPos];
+ ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
+ right = true;
+ } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
+ part = order[++partPos];
+ ch = bidiLeft(part) - part.level % 2;
+ right = false;
+ }
+ if (right && ch == part.to && ch > part.from) return get(ch - 1);
+ return get(ch, right);
+ }
+ var order = getOrder(lineObj), ch = pos.ch;
+ if (!order) return get(ch);
+ var partPos = getBidiPartAt(order, ch);
+ var val = getBidi(ch, partPos);
+ if (bidiOther != null) val.other = getBidi(ch, bidiOther);
+ return val;
+ }
+
+ // Used to cheaply estimate the coordinates for a position. Used for
+ // intermediate scroll updates.
+ function estimateCoords(cm, pos) {
+ var left = 0, pos = clipPos(cm.doc, pos);
+ if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
+ var lineObj = getLine(cm.doc, pos.line);
+ var top = heightAtLine(lineObj) + paddingTop(cm.display);
+ return {left: left, right: left, top: top, bottom: top + lineObj.height};
+ }
+
+ // Positions returned by coordsChar contain some extra information.
+ // xRel is the relative x position of the input coordinates compared
+ // to the found position (so xRel > 0 means the coordinates are to
+ // the right of the character position, for example). When outside
+ // is true, that means the coordinates lie outside the line's
+ // vertical range.
+ function PosWithInfo(line, ch, outside, xRel) {
+ var pos = Pos(line, ch);
+ pos.xRel = xRel;
+ if (outside) pos.outside = true;
+ return pos;
+ }
+
+ // Compute the character position closest to the given coordinates.
+ // Input must be lineSpace-local ("div" coordinate system).
+ function coordsChar(cm, x, y) {
+ var doc = cm.doc;
+ y += cm.display.viewOffset;
+ if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
+ var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
+ if (lineN > last)
+ return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
+ if (x < 0) x = 0;
+
+ var lineObj = getLine(doc, lineN);
+ for (;;) {
+ var found = coordsCharInner(cm, lineObj, lineN, x, y);
+ var merged = collapsedSpanAtEnd(lineObj);
+ var mergedPos = merged && merged.find(0, true);
+ if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
+ lineN = lineNo(lineObj = mergedPos.to.line);
+ else
+ return found;
+ }
+ }
+
+ function coordsCharInner(cm, lineObj, lineNo, x, y) {
+ var innerOff = y - heightAtLine(lineObj);
+ var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
+ var preparedMeasure = prepareMeasureForLine(cm, lineObj);
+
+ function getX(ch) {
+ var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
+ wrongLine = true;
+ if (innerOff > sp.bottom) return sp.left - adjust;
+ else if (innerOff < sp.top) return sp.left + adjust;
+ else wrongLine = false;
+ return sp.left;
+ }
+
+ var bidi = getOrder(lineObj), dist = lineObj.text.length;
+ var from = lineLeft(lineObj), to = lineRight(lineObj);
+ var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
+
+ if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
+ // Do a binary search between these bounds.
+ for (;;) {
+ if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
+ var ch = x < fromX || x - fromX <= toX - x ? from : to;
+ var xDiff = x - (ch == from ? fromX : toX);
+ while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
+ var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside,
+ xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
+ return pos;
+ }
+ var step = Math.ceil(dist / 2), middle = from + step;
+ if (bidi) {
+ middle = from;
+ for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
+ }
+ var middleX = getX(middle);
+ if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
+ else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
+ }
+ }
+
+ var measureText;
+ // Compute the default text height.
+ function textHeight(display) {
+ if (display.cachedTextHeight != null) return display.cachedTextHeight;
+ if (measureText == null) {
+ measureText = elt("pre");
+ // Measure a bunch of lines, for browsers that compute
+ // fractional heights.
+ for (var i = 0; i < 49; ++i) {
+ measureText.appendChild(document.createTextNode("x"));
+ measureText.appendChild(elt("br"));
+ }
+ measureText.appendChild(document.createTextNode("x"));
+ }
+ removeChildrenAndAdd(display.measure, measureText);
+ var height = measureText.offsetHeight / 50;
+ if (height > 3) display.cachedTextHeight = height;
+ removeChildren(display.measure);
+ return height || 1;
+ }
+
+ // Compute the default character width.
+ function charWidth(display) {
+ if (display.cachedCharWidth != null) return display.cachedCharWidth;
+ var anchor = elt("span", "xxxxxxxxxx");
+ var pre = elt("pre", [anchor]);
+ removeChildrenAndAdd(display.measure, pre);
+ var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
+ if (width > 2) display.cachedCharWidth = width;
+ return width || 10;
+ }
+
+ // OPERATIONS
+
+ // Operations are used to wrap a series of changes to the editor
+ // state in such a way that each change won't have to update the
+ // cursor and display (which would be awkward, slow, and
+ // error-prone). Instead, display updates are batched and then all
+ // combined and executed at once.
+
+ var nextOpId = 0;
+ // Start a new operation.
+ function startOperation(cm) {
+ cm.curOp = {
+ viewChanged: false, // Flag that indicates that lines might need to be redrawn
+ startHeight: cm.doc.height, // Used to detect need to update scrollbar
+ forceUpdate: false, // Used to force a redraw
+ updateInput: null, // Whether to reset the input textarea
+ typing: false, // Whether this reset should be careful to leave existing text (for compositing)
+ changeObjs: null, // Accumulated changes, for firing change events
+ cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
+ selectionChanged: false, // Whether the selection needs to be redrawn
+ updateMaxLine: false, // Set when the widest line needs to be determined anew
+ scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
+ scrollToPos: null, // Used to scroll to a specific position
+ id: ++nextOpId // Unique ID
+ };
+ if (!delayedCallbackDepth++) delayedCallbacks = [];
+ }
+
+ // Finish an operation, updating the display and signalling delayed events
+ function endOperation(cm) {
+ var op = cm.curOp, doc = cm.doc, display = cm.display;
+ cm.curOp = null;
+
+ if (op.updateMaxLine) findMaxLine(cm);
+
+ // If it looks like an update might be needed, call updateDisplay
+ if (op.viewChanged || op.forceUpdate || op.scrollTop != null ||
+ op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
+ op.scrollToPos.to.line >= display.viewTo) ||
+ display.maxLineChanged && cm.options.lineWrapping) {
+ var updated = updateDisplay(cm, {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
+ if (cm.display.scroller.offsetHeight) cm.doc.scrollTop = cm.display.scroller.scrollTop;
+ }
+ // If no update was run, but the selection changed, redraw that.
+ if (!updated && op.selectionChanged) updateSelection(cm);
+ if (!updated && op.startHeight != cm.doc.height) updateScrollbars(cm);
+
+ // Propagate the scroll position to the actual DOM scroller
+ if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) {
+ var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
+ display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top;
+ }
+ if (op.scrollLeft != null && display.scroller.scrollLeft != op.scrollLeft) {
+ var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft));
+ display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left;
+ alignHorizontally(cm);
+ }
+ // If we need to scroll a specific position into view, do so.
+ if (op.scrollToPos) {
+ var coords = scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos.from),
+ clipPos(cm.doc, op.scrollToPos.to), op.scrollToPos.margin);
+ if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
+ }
+
+ if (op.selectionChanged) restartBlink(cm);
+
+ if (cm.state.focused && op.updateInput)
+ resetInput(cm, op.typing);
+
+ // Fire events for markers that are hidden/unidden by editing or
+ // undoing
+ var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
+ if (hidden) for (var i = 0; i < hidden.length; ++i)
+ if (!hidden[i].lines.length) signal(hidden[i], "hide");
+ if (unhidden) for (var i = 0; i < unhidden.length; ++i)
+ if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
+
+ var delayed;
+ if (!--delayedCallbackDepth) {
+ delayed = delayedCallbacks;
+ delayedCallbacks = null;
+ }
+ // Fire change events, and delayed event handlers
+ if (op.changeObjs)
+ signal(cm, "changes", cm, op.changeObjs);
+ if (delayed) for (var i = 0; i < delayed.length; ++i) delayed[i]();
+ if (op.cursorActivityHandlers)
+ for (var i = 0; i < op.cursorActivityHandlers.length; i++)
+ op.cursorActivityHandlers[i](cm);
+ }
+
+ // Run the given function in an operation
+ function runInOp(cm, f) {
+ if (cm.curOp) return f();
+ startOperation(cm);
+ try { return f(); }
+ finally { endOperation(cm); }
+ }
+ // Wraps a function in an operation. Returns the wrapped function.
+ function operation(cm, f) {
+ return function() {
+ if (cm.curOp) return f.apply(cm, arguments);
+ startOperation(cm);
+ try { return f.apply(cm, arguments); }
+ finally { endOperation(cm); }
+ };
+ }
+ // Used to add methods to editor and doc instances, wrapping them in
+ // operations.
+ function methodOp(f) {
+ return function() {
+ if (this.curOp) return f.apply(this, arguments);
+ startOperation(this);
+ try { return f.apply(this, arguments); }
+ finally { endOperation(this); }
+ };
+ }
+ function docMethodOp(f) {
+ return function() {
+ var cm = this.cm;
+ if (!cm || cm.curOp) return f.apply(this, arguments);
+ startOperation(cm);
+ try { return f.apply(this, arguments); }
+ finally { endOperation(cm); }
+ };
+ }
+
+ // VIEW TRACKING
+
+ // These objects are used to represent the visible (currently drawn)
+ // part of the document. A LineView may correspond to multiple
+ // logical lines, if those are connected by collapsed ranges.
+ function LineView(doc, line, lineN) {
+ // The starting line
+ this.line = line;
+ // Continuing lines, if any
+ this.rest = visualLineContinued(line);
+ // Number of logical lines in this visual line
+ this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
+ this.node = this.text = null;
+ this.hidden = lineIsHidden(doc, line);
+ }
+
+ // Create a range of LineView objects for the given lines.
+ function buildViewArray(cm, from, to) {
+ var array = [], nextPos;
+ for (var pos = from; pos < to; pos = nextPos) {
+ var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
+ nextPos = pos + view.size;
+ array.push(view);
+ }
+ return array;
+ }
+
+ // Updates the display.view data structure for a given change to the
+ // document. From and to are in pre-change coordinates. Lendiff is
+ // the amount of lines added or subtracted by the change. This is
+ // used for changes that span multiple lines, or change the way
+ // lines are divided into visual lines. regLineChange (below)
+ // registers single-line changes.
+ function regChange(cm, from, to, lendiff) {
+ if (from == null) from = cm.doc.first;
+ if (to == null) to = cm.doc.first + cm.doc.size;
+ if (!lendiff) lendiff = 0;
+
+ var display = cm.display;
+ if (lendiff && to < display.viewTo &&
+ (display.updateLineNumbers == null || display.updateLineNumbers > from))
+ display.updateLineNumbers = from;
+
+ cm.curOp.viewChanged = true;
+
+ if (from >= display.viewTo) { // Change after
+ if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
+ resetView(cm);
+ } else if (to <= display.viewFrom) { // Change before
+ if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
+ resetView(cm);
+ } else {
+ display.viewFrom += lendiff;
+ display.viewTo += lendiff;
+ }
+ } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
+ resetView(cm);
+ } else if (from <= display.viewFrom) { // Top overlap
+ var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
+ if (cut) {
+ display.view = display.view.slice(cut.index);
+ display.viewFrom = cut.lineN;
+ display.viewTo += lendiff;
+ } else {
+ resetView(cm);
+ }
+ } else if (to >= display.viewTo) { // Bottom overlap
+ var cut = viewCuttingPoint(cm, from, from, -1);
+ if (cut) {
+ display.view = display.view.slice(0, cut.index);
+ display.viewTo = cut.lineN;
+ } else {
+ resetView(cm);
+ }
+ } else { // Gap in the middle
+ var cutTop = viewCuttingPoint(cm, from, from, -1);
+ var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
+ if (cutTop && cutBot) {
+ display.view = display.view.slice(0, cutTop.index)
+ .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
+ .concat(display.view.slice(cutBot.index));
+ display.viewTo += lendiff;
+ } else {
+ resetView(cm);
+ }
+ }
+
+ var ext = display.externalMeasured;
+ if (ext) {
+ if (to < ext.lineN)
+ ext.lineN += lendiff;
+ else if (from < ext.lineN + ext.size)
+ display.externalMeasured = null;
+ }
+ }
+
+ // Register a change to a single line. Type must be one of "text",
+ // "gutter", "class", "widget"
+ function regLineChange(cm, line, type) {
+ cm.curOp.viewChanged = true;
+ var display = cm.display, ext = cm.display.externalMeasured;
+ if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
+ display.externalMeasured = null;
+
+ if (line < display.viewFrom || line >= display.viewTo) return;
+ var lineView = display.view[findViewIndex(cm, line)];
+ if (lineView.node == null) return;
+ var arr = lineView.changes || (lineView.changes = []);
+ if (indexOf(arr, type) == -1) arr.push(type);
+ }
+
+ // Clear the view.
+ function resetView(cm) {
+ cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
+ cm.display.view = [];
+ cm.display.viewOffset = 0;
+ }
+
+ // Find the view element corresponding to a given line. Return null
+ // when the line isn't visible.
+ function findViewIndex(cm, n) {
+ if (n >= cm.display.viewTo) return null;
+ n -= cm.display.viewFrom;
+ if (n < 0) return null;
+ var view = cm.display.view;
+ for (var i = 0; i < view.length; i++) {
+ n -= view[i].size;
+ if (n < 0) return i;
+ }
+ }
+
+ function viewCuttingPoint(cm, oldN, newN, dir) {
+ var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
+ if (!sawCollapsedSpans) return {index: index, lineN: newN};
+ for (var i = 0, n = cm.display.viewFrom; i < index; i++)
+ n += view[i].size;
+ if (n != oldN) {
+ if (dir > 0) {
+ if (index == view.length - 1) return null;
+ diff = (n + view[index].size) - oldN;
+ index++;
+ } else {
+ diff = n - oldN;
+ }
+ oldN += diff; newN += diff;
+ }
+ while (visualLineNo(cm.doc, newN) != newN) {
+ if (index == (dir < 0 ? 0 : view.length - 1)) return null;
+ newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
+ index += dir;
+ }
+ return {index: index, lineN: newN};
+ }
+
+ // Force the view to cover a given range, adding empty view element
+ // or clipping off existing ones as needed.
+ function adjustView(cm, from, to) {
+ var display = cm.display, view = display.view;
+ if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
+ display.view = buildViewArray(cm, from, to);
+ display.viewFrom = from;
+ } else {
+ if (display.viewFrom > from)
+ display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
+ else if (display.viewFrom < from)
+ display.view = display.view.slice(findViewIndex(cm, from));
+ display.viewFrom = from;
+ if (display.viewTo < to)
+ display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
+ else if (display.viewTo > to)
+ display.view = display.view.slice(0, findViewIndex(cm, to));
+ }
+ display.viewTo = to;
+ }
+
+ // Count the number of lines in the view whose DOM representation is
+ // out of date (or nonexistent).
+ function countDirtyView(cm) {
+ var view = cm.display.view, dirty = 0;
+ for (var i = 0; i < view.length; i++) {
+ var lineView = view[i];
+ if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
+ }
+ return dirty;
+ }
+
+ // INPUT HANDLING
+
+ // Poll for input changes, using the normal rate of polling. This
+ // runs as long as the editor is focused.
+ function slowPoll(cm) {
+ if (cm.display.pollingFast) return;
+ cm.display.poll.set(cm.options.pollInterval, function() {
+ readInput(cm);
+ if (cm.state.focused) slowPoll(cm);
+ });
+ }
+
+ // When an event has just come in that is likely to add or change
+ // something in the input textarea, we poll faster, to ensure that
+ // the change appears on the screen quickly.
+ function fastPoll(cm) {
+ var missed = false;
+ cm.display.pollingFast = true;
+ function p() {
+ var changed = readInput(cm);
+ if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}
+ else {cm.display.pollingFast = false; slowPoll(cm);}
+ }
+ cm.display.poll.set(20, p);
+ }
+
+ // Read input from the textarea, and update the document to match.
+ // When something is selected, it is present in the textarea, and
+ // selected (unless it is huge, in which case a placeholder is
+ // used). When nothing is selected, the cursor sits after previously
+ // seen text (can be empty), which is stored in prevInput (we must
+ // not reset the textarea when typing, because that breaks IME).
+ function readInput(cm) {
+ var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc;
+ // Since this is called a *lot*, try to bail out as cheaply as
+ // possible when it is clear that nothing happened. hasSelection
+ // will be the case when there is a lot of text in the textarea,
+ // in which case reading its value would be expensive.
+ if (!cm.state.focused || (hasSelection(input) && !prevInput) || isReadOnly(cm) || cm.options.disableInput)
+ return false;
+ // See paste handler for more on the fakedLastChar kludge
+ if (cm.state.pasteIncoming && cm.state.fakedLastChar) {
+ input.value = input.value.substring(0, input.value.length - 1);
+ cm.state.fakedLastChar = false;
+ }
+ var text = input.value;
+ // If nothing changed, bail.
+ if (text == prevInput && !cm.somethingSelected()) return false;
+ // Work around nonsensical selection resetting in IE9/10
+ if (ie && !ie_upto8 && cm.display.inputHasSelection === text) {
+ resetInput(cm);
+ return false;
+ }
+
+ var withOp = !cm.curOp;
+ if (withOp) startOperation(cm);
+ cm.display.shift = false;
+
+ // Find the part of the input that is actually new
+ var same = 0, l = Math.min(prevInput.length, text.length);
+ while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
+ var inserted = text.slice(same), textLines = splitLines(inserted);
+
+ // When pasing N lines into N selections, insert one line per selection
+ var multiPaste = cm.state.pasteIncoming && textLines.length > 1 && doc.sel.ranges.length == textLines.length;
+
+ // Normal behavior is to insert the new text into every selection
+ for (var i = doc.sel.ranges.length - 1; i >= 0; i--) {
+ var range = doc.sel.ranges[i];
+ var from = range.from(), to = range.to();
+ // Handle deletion
+ if (same < prevInput.length)
+ from = Pos(from.line, from.ch - (prevInput.length - same));
+ // Handle overwrite
+ else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming)
+ to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
+ var updateInput = cm.curOp.updateInput;
+ var changeEvent = {from: from, to: to, text: multiPaste ? [textLines[i]] : textLines,
+ origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"};
+ makeChange(cm.doc, changeEvent);
+ signalLater(cm, "inputRead", cm, changeEvent);
+ // When an 'electric' character is inserted, immediately trigger a reindent
+ if (inserted && !cm.state.pasteIncoming && cm.options.electricChars &&
+ cm.options.smartIndent && range.head.ch < 100 &&
+ (!i || doc.sel.ranges[i - 1].head.line != range.head.line)) {
+ var mode = cm.getModeAt(range.head);
+ if (mode.electricChars) {
+ for (var j = 0; j < mode.electricChars.length; j++)
+ if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
+ indentLine(cm, range.head.line, "smart");
+ break;
+ }
+ } else if (mode.electricInput) {
+ var end = changeEnd(changeEvent);
+ if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch)))
+ indentLine(cm, range.head.line, "smart");
+ }
+ }
+ }
+ ensureCursorVisible(cm);
+ cm.curOp.updateInput = updateInput;
+ cm.curOp.typing = true;
+
+ // Don't leave long text in the textarea, since it makes further polling slow
+ if (text.length > 1000 || text.indexOf("\n") > -1) input.value = cm.display.prevInput = "";
+ else cm.display.prevInput = text;
+ if (withOp) endOperation(cm);
+ cm.state.pasteIncoming = cm.state.cutIncoming = false;
+ return true;
+ }
+
+ // Reset the input to correspond to the selection (or to be empty,
+ // when not typing and nothing is selected)
+ function resetInput(cm, typing) {
+ var minimal, selected, doc = cm.doc;
+ if (cm.somethingSelected()) {
+ cm.display.prevInput = "";
+ var range = doc.sel.primary();
+ minimal = hasCopyEvent &&
+ (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
+ var content = minimal ? "-" : selected || cm.getSelection();
+ cm.display.input.value = content;
+ if (cm.state.focused) selectInput(cm.display.input);
+ if (ie && !ie_upto8) cm.display.inputHasSelection = content;
+ } else if (!typing) {
+ cm.display.prevInput = cm.display.input.value = "";
+ if (ie && !ie_upto8) cm.display.inputHasSelection = null;
+ }
+ cm.display.inaccurateSelection = minimal;
+ }
+
+ function focusInput(cm) {
+ if (cm.options.readOnly != "nocursor" && (!mobile || activeElt() != cm.display.input))
+ cm.display.input.focus();
+ }
+
+ function ensureFocus(cm) {
+ if (!cm.state.focused) { focusInput(cm); onFocus(cm); }
+ }
+
+ function isReadOnly(cm) {
+ return cm.options.readOnly || cm.doc.cantEdit;
+ }
+
+ // EVENT HANDLERS
+
+ // Attach the necessary event handlers when initializing the editor
+ function registerEventHandlers(cm) {
+ var d = cm.display;
+ on(d.scroller, "mousedown", operation(cm, onMouseDown));
+ // Older IE's will not fire a second mousedown for a double click
+ if (ie_upto10)
+ on(d.scroller, "dblclick", operation(cm, function(e) {
+ if (signalDOMEvent(cm, e)) return;
+ var pos = posFromMouse(cm, e);
+ if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
+ e_preventDefault(e);
+ var word = findWordAt(cm.doc, pos);
+ extendSelection(cm.doc, word.anchor, word.head);
+ }));
+ else
+ on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
+ // Prevent normal selection in the editor (we handle our own)
+ on(d.lineSpace, "selectstart", function(e) {
+ if (!eventInWidget(d, e)) e_preventDefault(e);
+ });
+ // Some browsers fire contextmenu *after* opening the menu, at
+ // which point we can't mess with it anymore. Context menu is
+ // handled in onMouseDown for these browsers.
+ if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
+
+ // Sync scrolling between fake scrollbars and real scrollable
+ // area, ensure viewport is updated when scrolling.
+ on(d.scroller, "scroll", function() {
+ if (d.scroller.clientHeight) {
+ setScrollTop(cm, d.scroller.scrollTop);
+ setScrollLeft(cm, d.scroller.scrollLeft, true);
+ signal(cm, "scroll", cm);
+ }
+ });
+ on(d.scrollbarV, "scroll", function() {
+ if (d.scroller.clientHeight) setScrollTop(cm, d.scrollbarV.scrollTop);
+ });
+ on(d.scrollbarH, "scroll", function() {
+ if (d.scroller.clientHeight) setScrollLeft(cm, d.scrollbarH.scrollLeft);
+ });
+
+ // Listen to wheel events in order to try and update the viewport on time.
+ on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
+ on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
+
+ // Prevent clicks in the scrollbars from killing focus
+ function reFocus() { if (cm.state.focused) setTimeout(bind(focusInput, cm), 0); }
+ on(d.scrollbarH, "mousedown", reFocus);
+ on(d.scrollbarV, "mousedown", reFocus);
+ // Prevent wrapper from ever scrolling
+ on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
+
+ // When the window resizes, we need to refresh active editors.
+ var resizeTimer;
+ function onResize() {
+ if (resizeTimer == null) resizeTimer = setTimeout(function() {
+ resizeTimer = null;
+ // Might be a text scaling operation, clear size caches.
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null;
+ cm.setSize();
+ }, 100);
+ }
+ on(window, "resize", onResize);
+ // The above handler holds on to the editor and its data
+ // structures. Here we poll to unregister it when the editor is no
+ // longer in the document, so that it can be garbage-collected.
+ function unregister() {
+ if (contains(document.body, d.wrapper)) setTimeout(unregister, 5000);
+ else off(window, "resize", onResize);
+ }
+ setTimeout(unregister, 5000);
+
+ on(d.input, "keyup", operation(cm, onKeyUp));
+ on(d.input, "input", function() {
+ if (ie && !ie_upto8 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
+ fastPoll(cm);
+ });
+ on(d.input, "keydown", operation(cm, onKeyDown));
+ on(d.input, "keypress", operation(cm, onKeyPress));
+ on(d.input, "focus", bind(onFocus, cm));
+ on(d.input, "blur", bind(onBlur, cm));
+
+ function drag_(e) {
+ if (!signalDOMEvent(cm, e)) e_stop(e);
+ }
+ if (cm.options.dragDrop) {
+ on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
+ on(d.scroller, "dragenter", drag_);
+ on(d.scroller, "dragover", drag_);
+ on(d.scroller, "drop", operation(cm, onDrop));
+ }
+ on(d.scroller, "paste", function(e) {
+ if (eventInWidget(d, e)) return;
+ cm.state.pasteIncoming = true;
+ focusInput(cm);
+ fastPoll(cm);
+ });
+ on(d.input, "paste", function() {
+ // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206
+ // Add a char to the end of textarea before paste occur so that
+ // selection doesn't span to the end of textarea.
+ if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
+ var start = d.input.selectionStart, end = d.input.selectionEnd;
+ d.input.value += "$";
+ d.input.selectionStart = start;
+ d.input.selectionEnd = end;
+ cm.state.fakedLastChar = true;
+ }
+ cm.state.pasteIncoming = true;
+ fastPoll(cm);
+ });
+
+ function prepareCopyCut(e) {
+ if (cm.somethingSelected()) {
+ if (d.inaccurateSelection) {
+ d.prevInput = "";
+ d.inaccurateSelection = false;
+ d.input.value = cm.getSelection();
+ selectInput(d.input);
+ }
+ } else {
+ var text = "", ranges = [];
+ for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
+ var line = cm.doc.sel.ranges[i].head.line;
+ var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
+ ranges.push(lineRange);
+ text += cm.getRange(lineRange.anchor, lineRange.head);
+ }
+ if (e.type == "cut") {
+ cm.setSelections(ranges, null, sel_dontScroll);
+ } else {
+ d.prevInput = "";
+ d.input.value = text;
+ selectInput(d.input);
+ }
+ }
+ if (e.type == "cut") cm.state.cutIncoming = true;
+ }
+ on(d.input, "cut", prepareCopyCut);
+ on(d.input, "copy", prepareCopyCut);
+
+ // Needed to handle Tab key in KHTML
+ if (khtml) on(d.sizer, "mouseup", function() {
+ if (activeElt() == d.input) d.input.blur();
+ focusInput(cm);
+ });
+ }
+
+ // MOUSE EVENTS
+
+ // Return true when the given mouse event happened in a widget
+ function eventInWidget(display, e) {
+ for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
+ if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) return true;
+ }
+ }
+
+ // Given a mouse event, find the corresponding position. If liberal
+ // is false, it checks whether a gutter or scrollbar was clicked,
+ // and returns null if it was. forRect is used by rectangular
+ // selections, and tries to estimate a character position even for
+ // coordinates beyond the right of the text.
+ function posFromMouse(cm, e, liberal, forRect) {
+ var display = cm.display;
+ if (!liberal) {
+ var target = e_target(e);
+ if (target == display.scrollbarH || target == display.scrollbarV ||
+ target == display.scrollbarFiller || target == display.gutterFiller) return null;
+ }
+ var x, y, space = display.lineSpace.getBoundingClientRect();
+ // Fails unpredictably on IE[67] when mouse is dragged around quickly.
+ try { x = e.clientX - space.left; y = e.clientY - space.top; }
+ catch (e) { return null; }
+ var coords = coordsChar(cm, x, y), line;
+ if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
+ var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
+ coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
+ }
+ return coords;
+ }
+
+ // A mouse down can be a single click, double click, triple click,
+ // start of selection drag, start of text drag, new cursor
+ // (ctrl-click), rectangle drag (alt-drag), or xwin
+ // middle-click-paste. Or it might be a click on something we should
+ // not interfere with, such as a scrollbar or widget.
+ function onMouseDown(e) {
+ if (signalDOMEvent(this, e)) return;
+ var cm = this, display = cm.display;
+ display.shift = e.shiftKey;
+
+ if (eventInWidget(display, e)) {
+ if (!webkit) {
+ // Briefly turn off draggability, to allow widgets to do
+ // normal dragging things.
+ display.scroller.draggable = false;
+ setTimeout(function(){display.scroller.draggable = true;}, 100);
+ }
+ return;
+ }
+ if (clickInGutter(cm, e)) return;
+ var start = posFromMouse(cm, e);
+ window.focus();
+
+ switch (e_button(e)) {
+ case 1:
+ if (start)
+ leftButtonDown(cm, e, start);
+ else if (e_target(e) == display.scroller)
+ e_preventDefault(e);
+ break;
+ case 2:
+ if (webkit) cm.state.lastMiddleDown = +new Date;
+ if (start) extendSelection(cm.doc, start);
+ setTimeout(bind(focusInput, cm), 20);
+ e_preventDefault(e);
+ break;
+ case 3:
+ if (captureRightClick) onContextMenu(cm, e);
+ break;
+ }
+ }
+
+ var lastClick, lastDoubleClick;
+ function leftButtonDown(cm, e, start) {
+ setTimeout(bind(ensureFocus, cm), 0);
+
+ var now = +new Date, type;
+ if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
+ type = "triple";
+ } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
+ type = "double";
+ lastDoubleClick = {time: now, pos: start};
+ } else {
+ type = "single";
+ lastClick = {time: now, pos: start};
+ }
+
+ var sel = cm.doc.sel, addNew = mac ? e.metaKey : e.ctrlKey;
+ if (cm.options.dragDrop && dragAndDrop && !addNew && !isReadOnly(cm) &&
+ type == "single" && sel.contains(start) > -1 && sel.somethingSelected())
+ leftButtonStartDrag(cm, e, start);
+ else
+ leftButtonSelect(cm, e, start, type, addNew);
+ }
+
+ // Start a text drag. When it ends, see if any dragging actually
+ // happen, and treat as a click if it didn't.
+ function leftButtonStartDrag(cm, e, start) {
+ var display = cm.display;
+ var dragEnd = operation(cm, function(e2) {
+ if (webkit) display.scroller.draggable = false;
+ cm.state.draggingText = false;
+ off(document, "mouseup", dragEnd);
+ off(display.scroller, "drop", dragEnd);
+ if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
+ e_preventDefault(e2);
+ extendSelection(cm.doc, start);
+ focusInput(cm);
+ // Work around unexplainable focus problem in IE9 (#2127)
+ if (ie_upto10 && !ie_upto8)
+ setTimeout(function() {document.body.focus(); focusInput(cm);}, 20);
+ }
+ });
+ // Let the drag handler handle this.
+ if (webkit) display.scroller.draggable = true;
+ cm.state.draggingText = dragEnd;
+ // IE's approach to draggable
+ if (display.scroller.dragDrop) display.scroller.dragDrop();
+ on(document, "mouseup", dragEnd);
+ on(display.scroller, "drop", dragEnd);
+ }
+
+ // Normal selection, as opposed to text dragging.
+ function leftButtonSelect(cm, e, start, type, addNew) {
+ var display = cm.display, doc = cm.doc;
+ e_preventDefault(e);
+
+ var ourRange, ourIndex, startSel = doc.sel;
+ if (addNew && !e.shiftKey) {
+ ourIndex = doc.sel.contains(start);
+ if (ourIndex > -1)
+ ourRange = doc.sel.ranges[ourIndex];
+ else
+ ourRange = new Range(start, start);
+ } else {
+ ourRange = doc.sel.primary();
+ }
+
+ if (e.altKey) {
+ type = "rect";
+ if (!addNew) ourRange = new Range(start, start);
+ start = posFromMouse(cm, e, true, true);
+ ourIndex = -1;
+ } else if (type == "double") {
+ var word = findWordAt(doc, start);
+ if (cm.display.shift || doc.extend)
+ ourRange = extendRange(doc, ourRange, word.anchor, word.head);
+ else
+ ourRange = word;
+ } else if (type == "triple") {
+ var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
+ if (cm.display.shift || doc.extend)
+ ourRange = extendRange(doc, ourRange, line.anchor, line.head);
+ else
+ ourRange = line;
+ } else {
+ ourRange = extendRange(doc, ourRange, start);
+ }
+
+ if (!addNew) {
+ ourIndex = 0;
+ setSelection(doc, new Selection([ourRange], 0), sel_mouse);
+ startSel = doc.sel;
+ } else if (ourIndex > -1) {
+ replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
+ } else {
+ ourIndex = doc.sel.ranges.length;
+ setSelection(doc, normalizeSelection(doc.sel.ranges.concat([ourRange]), ourIndex),
+ {scroll: false, origin: "*mouse"});
+ }
+
+ var lastPos = start;
+ function extendTo(pos) {
+ if (cmp(lastPos, pos) == 0) return;
+ lastPos = pos;
+
+ if (type == "rect") {
+ var ranges = [], tabSize = cm.options.tabSize;
+ var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
+ var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
+ var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
+ for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
+ line <= end; line++) {
+ var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
+ if (left == right)
+ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
+ else if (text.length > leftPos)
+ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
+ }
+ if (!ranges.length) ranges.push(new Range(start, start));
+ setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), sel_mouse);
+ } else {
+ var oldRange = ourRange;
+ var anchor = oldRange.anchor, head = pos;
+ if (type != "single") {
+ if (type == "double")
+ var range = findWordAt(doc, pos);
+ else
+ var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
+ if (cmp(range.anchor, anchor) > 0) {
+ head = range.head;
+ anchor = minPos(oldRange.from(), range.anchor);
+ } else {
+ head = range.anchor;
+ anchor = maxPos(oldRange.to(), range.head);
+ }
+ }
+ var ranges = startSel.ranges.slice(0);
+ ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
+ setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
+ }
+ }
+
+ var editorSize = display.wrapper.getBoundingClientRect();
+ // Used to ensure timeout re-tries don't fire when another extend
+ // happened in the meantime (clearTimeout isn't reliable -- at
+ // least on Chrome, the timeouts still happen even when cleared,
+ // if the clear happens after their scheduled firing time).
+ var counter = 0;
+
+ function extend(e) {
+ var curCount = ++counter;
+ var cur = posFromMouse(cm, e, true, type == "rect");
+ if (!cur) return;
+ if (cmp(cur, lastPos) != 0) {
+ ensureFocus(cm);
+ extendTo(cur);
+ var visible = visibleLines(display, doc);
+ if (cur.line >= visible.to || cur.line < visible.from)
+ setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
+ } else {
+ var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
+ if (outside) setTimeout(operation(cm, function() {
+ if (counter != curCount) return;
+ display.scroller.scrollTop += outside;
+ extend(e);
+ }), 50);
+ }
+ }
+
+ function done(e) {
+ counter = Infinity;
+ e_preventDefault(e);
+ focusInput(cm);
+ off(document, "mousemove", move);
+ off(document, "mouseup", up);
+ doc.history.lastSelOrigin = null;
+ }
+
+ var move = operation(cm, function(e) {
+ if ((ie && !ie_upto9) ? !e.buttons : !e_button(e)) done(e);
+ else extend(e);
+ });
+ var up = operation(cm, done);
+ on(document, "mousemove", move);
+ on(document, "mouseup", up);
+ }
+
+ // Determines whether an event happened in the gutter, and fires the
+ // handlers for the corresponding event.
+ function gutterEvent(cm, e, type, prevent, signalfn) {
+ try { var mX = e.clientX, mY = e.clientY; }
+ catch(e) { return false; }
+ if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
+ if (prevent) e_preventDefault(e);
+
+ var display = cm.display;
+ var lineBox = display.lineDiv.getBoundingClientRect();
+
+ if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
+ mY -= lineBox.top - display.viewOffset;
+
+ for (var i = 0; i < cm.options.gutters.length; ++i) {
+ var g = display.gutters.childNodes[i];
+ if (g && g.getBoundingClientRect().right >= mX) {
+ var line = lineAtHeight(cm.doc, mY);
+ var gutter = cm.options.gutters[i];
+ signalfn(cm, type, cm, line, gutter, e);
+ return e_defaultPrevented(e);
+ }
+ }
+ }
+
+ function clickInGutter(cm, e) {
+ return gutterEvent(cm, e, "gutterClick", true, signalLater);
+ }
+
+ // Kludge to work around strange IE behavior where it'll sometimes
+ // re-fire a series of drag-related events right after the drop (#1551)
+ var lastDrop = 0;
+
+ function onDrop(e) {
+ var cm = this;
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
+ return;
+ e_preventDefault(e);
+ if (ie) lastDrop = +new Date;
+ var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
+ if (!pos || isReadOnly(cm)) return;
+ // Might be a file drop, in which case we simply extract the text
+ // and insert it.
+ if (files && files.length && window.FileReader && window.File) {
+ var n = files.length, text = Array(n), read = 0;
+ var loadFile = function(file, i) {
+ var reader = new FileReader;
+ reader.onload = operation(cm, function() {
+ text[i] = reader.result;
+ if (++read == n) {
+ pos = clipPos(cm.doc, pos);
+ var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
+ makeChange(cm.doc, change);
+ setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
+ }
+ });
+ reader.readAsText(file);
+ };
+ for (var i = 0; i < n; ++i) loadFile(files[i], i);
+ } else { // Normal drop
+ // Don't do a replace if the drop happened inside of the selected text.
+ if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
+ cm.state.draggingText(e);
+ // Ensure the editor is re-focused
+ setTimeout(bind(focusInput, cm), 20);
+ return;
+ }
+ try {
+ var text = e.dataTransfer.getData("Text");
+ if (text) {
+ var selected = cm.state.draggingText && cm.listSelections();
+ setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
+ if (selected) for (var i = 0; i < selected.length; ++i)
+ replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
+ cm.replaceSelection(text, "around", "paste");
+ focusInput(cm);
+ }
+ }
+ catch(e){}
+ }
+ }
+
+ function onDragStart(cm, e) {
+ if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
+
+ e.dataTransfer.setData("Text", cm.getSelection());
+
+ // Use dummy image instead of default browsers image.
+ // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
+ if (e.dataTransfer.setDragImage && !safari) {
+ var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
+ img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
+ if (presto) {
+ img.width = img.height = 1;
+ cm.display.wrapper.appendChild(img);
+ // Force a relayout, or Opera won't use our image for some obscure reason
+ img._top = img.offsetTop;
+ }
+ e.dataTransfer.setDragImage(img, 0, 0);
+ if (presto) img.parentNode.removeChild(img);
+ }
+ }
+
+ // SCROLL EVENTS
+
+ // Sync the scrollable area and scrollbars, ensure the viewport
+ // covers the visible area.
+ function setScrollTop(cm, val) {
+ if (Math.abs(cm.doc.scrollTop - val) < 2) return;
+ cm.doc.scrollTop = val;
+ if (!gecko) updateDisplay(cm, {top: val});
+ if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
+ if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val;
+ if (gecko) updateDisplay(cm);
+ startWorker(cm, 100);
+ }
+ // Sync scroller and scrollbar, ensure the gutter elements are
+ // aligned.
+ function setScrollLeft(cm, val, isScroller) {
+ if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
+ val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
+ cm.doc.scrollLeft = val;
+ alignHorizontally(cm);
+ if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
+ if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val;
+ }
+
+ // Since the delta values reported on mouse wheel events are
+ // unstandardized between browsers and even browser versions, and
+ // generally horribly unpredictable, this code starts by measuring
+ // the scroll effect that the first few mouse wheel events have,
+ // and, from that, detects the way it can convert deltas to pixel
+ // offsets afterwards.
+ //
+ // The reason we want to know the amount a wheel event will scroll
+ // is that it gives us a chance to update the display before the
+ // actual scrolling happens, reducing flickering.
+
+ var wheelSamples = 0, wheelPixelsPerUnit = null;
+ // Fill in a browser-detected starting value on browsers where we
+ // know one. These don't have to be accurate -- the result of them
+ // being wrong would just be a slight flicker on the first wheel
+ // scroll (if it is large enough).
+ if (ie) wheelPixelsPerUnit = -.53;
+ else if (gecko) wheelPixelsPerUnit = 15;
+ else if (chrome) wheelPixelsPerUnit = -.7;
+ else if (safari) wheelPixelsPerUnit = -1/3;
+
+ function onScrollWheel(cm, e) {
+ var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
+ if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
+ if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
+ else if (dy == null) dy = e.wheelDelta;
+
+ var display = cm.display, scroll = display.scroller;
+ // Quit if there's nothing to scroll here
+ if (!(dx && scroll.scrollWidth > scroll.clientWidth ||
+ dy && scroll.scrollHeight > scroll.clientHeight)) return;
+
+ // Webkit browsers on OS X abort momentum scrolls when the target
+ // of the scroll event is removed from the scrollable element.
+ // This hack (see related code in patchDisplay) makes sure the
+ // element is kept around.
+ if (dy && mac && webkit) {
+ outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
+ for (var i = 0; i < view.length; i++) {
+ if (view[i].node == cur) {
+ cm.display.currentWheelTarget = cur;
+ break outer;
+ }
+ }
+ }
+ }
+
+ // On some browsers, horizontal scrolling will cause redraws to
+ // happen before the gutter has been realigned, causing it to
+ // wriggle around in a most unseemly way. When we have an
+ // estimated pixels/delta value, we just handle horizontal
+ // scrolling entirely here. It'll be slightly off from native, but
+ // better than glitching out.
+ if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
+ if (dy)
+ setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
+ setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
+ e_preventDefault(e);
+ display.wheelStartX = null; // Abort measurement, if in progress
+ return;
+ }
+
+ // 'Project' the visible viewport to cover the area that is being
+ // scrolled into view (if we know enough to estimate it).
+ if (dy && wheelPixelsPerUnit != null) {
+ var pixels = dy * wheelPixelsPerUnit;
+ var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
+ if (pixels < 0) top = Math.max(0, top + pixels - 50);
+ else bot = Math.min(cm.doc.height, bot + pixels + 50);
+ updateDisplay(cm, {top: top, bottom: bot});
+ }
+
+ if (wheelSamples < 20) {
+ if (display.wheelStartX == null) {
+ display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
+ display.wheelDX = dx; display.wheelDY = dy;
+ setTimeout(function() {
+ if (display.wheelStartX == null) return;
+ var movedX = scroll.scrollLeft - display.wheelStartX;
+ var movedY = scroll.scrollTop - display.wheelStartY;
+ var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
+ (movedX && display.wheelDX && movedX / display.wheelDX);
+ display.wheelStartX = display.wheelStartY = null;
+ if (!sample) return;
+ wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
+ ++wheelSamples;
+ }, 200);
+ } else {
+ display.wheelDX += dx; display.wheelDY += dy;
+ }
+ }
+ }
+
+ // KEY EVENTS
+
+ // Run a handler that was bound to a key.
+ function doHandleBinding(cm, bound, dropShift) {
+ if (typeof bound == "string") {
+ bound = commands[bound];
+ if (!bound) return false;
+ }
+ // Ensure previous input has been read, so that the handler sees a
+ // consistent view of the document
+ if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;
+ var prevShift = cm.display.shift, done = false;
+ try {
+ if (isReadOnly(cm)) cm.state.suppressEdits = true;
+ if (dropShift) cm.display.shift = false;
+ done = bound(cm) != Pass;
+ } finally {
+ cm.display.shift = prevShift;
+ cm.state.suppressEdits = false;
+ }
+ return done;
+ }
+
+ // Collect the currently active keymaps.
+ function allKeyMaps(cm) {
+ var maps = cm.state.keyMaps.slice(0);
+ if (cm.options.extraKeys) maps.push(cm.options.extraKeys);
+ maps.push(cm.options.keyMap);
+ return maps;
+ }
+
+ var maybeTransition;
+ // Handle a key from the keydown event.
+ function handleKeyBinding(cm, e) {
+ // Handle automatic keymap transitions
+ var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
+ clearTimeout(maybeTransition);
+ if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
+ if (getKeyMap(cm.options.keyMap) == startMap) {
+ cm.options.keyMap = (next.call ? next.call(null, cm) : next);
+ keyMapChanged(cm);
+ }
+ }, 50);
+
+ var name = keyName(e, true), handled = false;
+ if (!name) return false;
+ var keymaps = allKeyMaps(cm);
+
+ if (e.shiftKey) {
+ // First try to resolve full name (including 'Shift-'). Failing
+ // that, see if there is a cursor-motion command (starting with
+ // 'go') bound to the keyname without 'Shift-'.
+ handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);})
+ || lookupKey(name, keymaps, function(b) {
+ if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
+ return doHandleBinding(cm, b);
+ });
+ } else {
+ handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); });
+ }
+
+ if (handled) {
+ e_preventDefault(e);
+ restartBlink(cm);
+ signalLater(cm, "keyHandled", cm, name, e);
+ }
+ return handled;
+ }
+
+ // Handle a key from the keypress event
+ function handleCharBinding(cm, e, ch) {
+ var handled = lookupKey("'" + ch + "'", allKeyMaps(cm),
+ function(b) { return doHandleBinding(cm, b, true); });
+ if (handled) {
+ e_preventDefault(e);
+ restartBlink(cm);
+ signalLater(cm, "keyHandled", cm, "'" + ch + "'", e);
+ }
+ return handled;
+ }
+
+ var lastStoppedKey = null;
+ function onKeyDown(e) {
+ var cm = this;
+ ensureFocus(cm);
+ if (signalDOMEvent(cm, e)) return;
+ // IE does strange things with escape.
+ if (ie_upto10 && e.keyCode == 27) e.returnValue = false;
+ var code = e.keyCode;
+ cm.display.shift = code == 16 || e.shiftKey;
+ var handled = handleKeyBinding(cm, e);
+ if (presto) {
+ lastStoppedKey = handled ? code : null;
+ // Opera has no cut event... we try to at least catch the key combo
+ if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
+ cm.replaceSelection("", null, "cut");
+ }
+
+ // Turn mouse into crosshair when Alt is held on Mac.
+ if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
+ showCrossHair(cm);
+ }
+
+ function showCrossHair(cm) {
+ var lineDiv = cm.display.lineDiv;
+ addClass(lineDiv, "CodeMirror-crosshair");
+
+ function up(e) {
+ if (e.keyCode == 18 || !e.altKey) {
+ rmClass(lineDiv, "CodeMirror-crosshair");
+ off(document, "keyup", up);
+ off(document, "mouseover", up);
+ }
+ }
+ on(document, "keyup", up);
+ on(document, "mouseover", up);
+ }
+
+ function onKeyUp(e) {
+ if (signalDOMEvent(this, e)) return;
+ if (e.keyCode == 16) this.doc.sel.shift = false;
+ }
+
+ function onKeyPress(e) {
+ var cm = this;
+ if (signalDOMEvent(cm, e)) return;
+ var keyCode = e.keyCode, charCode = e.charCode;
+ if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
+ if (((presto && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;
+ var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
+ if (handleCharBinding(cm, e, ch)) return;
+ if (ie && !ie_upto8) cm.display.inputHasSelection = null;
+ fastPoll(cm);
+ }
+
+ // FOCUS/BLUR EVENTS
+
+ function onFocus(cm) {
+ if (cm.options.readOnly == "nocursor") return;
+ if (!cm.state.focused) {
+ signal(cm, "focus", cm);
+ cm.state.focused = true;
+ addClass(cm.display.wrapper, "CodeMirror-focused");
+ // The prevInput test prevents this from firing when a context
+ // menu is closed (since the resetInput would kill the
+ // select-all detection hack)
+ if (!cm.curOp && cm.display.selForContextMenu == cm.doc.sel) {
+ resetInput(cm);
+ if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730
+ }
+ }
+ slowPoll(cm);
+ restartBlink(cm);
+ }
+ function onBlur(cm) {
+ if (cm.state.focused) {
+ signal(cm, "blur", cm);
+ cm.state.focused = false;
+ rmClass(cm.display.wrapper, "CodeMirror-focused");
+ }
+ clearInterval(cm.display.blinker);
+ setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
+ }
+
+ // CONTEXT MENU HANDLING
+
+ var detectingSelectAll;
+ // To make the context menu work, we need to briefly unhide the
+ // textarea (making it as unobtrusive as possible) to let the
+ // right-click take effect on it.
+ function onContextMenu(cm, e) {
+ if (signalDOMEvent(cm, e, "contextmenu")) return;
+ var display = cm.display;
+ if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) return;
+
+ var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
+ if (!pos || presto) return; // Opera is difficult.
+
+ // Reset the current text selection only if the click is done outside of the selection
+ // and 'resetSelectionOnContextMenu' option is true.
+ var reset = cm.options.resetSelectionOnContextMenu;
+ if (reset && cm.doc.sel.contains(pos) == -1)
+ operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
+
+ var oldCSS = display.input.style.cssText;
+ display.inputDiv.style.position = "absolute";
+ display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
+ "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " +
+ (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
+ "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
+ focusInput(cm);
+ resetInput(cm);
+ // Adds "Select all" to context menu in FF
+ if (!cm.somethingSelected()) display.input.value = display.prevInput = " ";
+ display.selForContextMenu = cm.doc.sel;
+
+ // Select-all will be greyed out if there's nothing to select, so
+ // this adds a zero-width space so that we can later check whether
+ // it got selected.
+ function prepareSelectAllHack() {
+ if (display.input.selectionStart != null) {
+ var selected = cm.somethingSelected();
+ var extval = display.input.value = "\u200b" + (selected ? display.input.value : "");
+ display.prevInput = selected ? "" : "\u200b";
+ display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
+ }
+ }
+ function rehide() {
+ display.inputDiv.style.position = "relative";
+ display.input.style.cssText = oldCSS;
+ if (ie_upto8) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos;
+ slowPoll(cm);
+
+ // Try to detect the user choosing select-all
+ if (display.input.selectionStart != null) {
+ if (!ie || ie_upto8) prepareSelectAllHack();
+ clearTimeout(detectingSelectAll);
+ var i = 0, poll = function() {
+ if (display.selForContextMenu == cm.doc.sel && display.input.selectionStart == 0)
+ operation(cm, commands.selectAll)(cm);
+ else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
+ else resetInput(cm);
+ };
+ detectingSelectAll = setTimeout(poll, 200);
+ }
+ }
+
+ if (ie && !ie_upto8) prepareSelectAllHack();
+ if (captureRightClick) {
+ e_stop(e);
+ var mouseup = function() {
+ off(window, "mouseup", mouseup);
+ setTimeout(rehide, 20);
+ };
+ on(window, "mouseup", mouseup);
+ } else {
+ setTimeout(rehide, 50);
+ }
+ }
+
+ function contextMenuInGutter(cm, e) {
+ if (!hasHandler(cm, "gutterContextMenu")) return false;
+ return gutterEvent(cm, e, "gutterContextMenu", false, signal);
+ }
+
+ // UPDATING
+
+ // Compute the position of the end of a change (its 'to' property
+ // refers to the pre-change end).
+ var changeEnd = CodeMirror.changeEnd = function(change) {
+ if (!change.text) return change.to;
+ return Pos(change.from.line + change.text.length - 1,
+ lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
+ };
+
+ // Adjust a position to refer to the post-change position of the
+ // same text, or the end of the change if the change covers it.
+ function adjustForChange(pos, change) {
+ if (cmp(pos, change.from) < 0) return pos;
+ if (cmp(pos, change.to) <= 0) return changeEnd(change);
+
+ var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
+ if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
+ return Pos(line, ch);
+ }
+
+ function computeSelAfterChange(doc, change) {
+ var out = [];
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ var range = doc.sel.ranges[i];
+ out.push(new Range(adjustForChange(range.anchor, change),
+ adjustForChange(range.head, change)));
+ }
+ return normalizeSelection(out, doc.sel.primIndex);
+ }
+
+ function offsetPos(pos, old, nw) {
+ if (pos.line == old.line)
+ return Pos(nw.line, pos.ch - old.ch + nw.ch);
+ else
+ return Pos(nw.line + (pos.line - old.line), pos.ch);
+ }
+
+ // Used by replaceSelections to allow moving the selection to the
+ // start or around the replaced test. Hint may be "start" or "around".
+ function computeReplacedSel(doc, changes, hint) {
+ var out = [];
+ var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
+ for (var i = 0; i < changes.length; i++) {
+ var change = changes[i];
+ var from = offsetPos(change.from, oldPrev, newPrev);
+ var to = offsetPos(changeEnd(change), oldPrev, newPrev);
+ oldPrev = change.to;
+ newPrev = to;
+ if (hint == "around") {
+ var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
+ out[i] = new Range(inv ? to : from, inv ? from : to);
+ } else {
+ out[i] = new Range(from, from);
+ }
+ }
+ return new Selection(out, doc.sel.primIndex);
+ }
+
+ // Allow "beforeChange" event handlers to influence a change
+ function filterChange(doc, change, update) {
+ var obj = {
+ canceled: false,
+ from: change.from,
+ to: change.to,
+ text: change.text,
+ origin: change.origin,
+ cancel: function() { this.canceled = true; }
+ };
+ if (update) obj.update = function(from, to, text, origin) {
+ if (from) this.from = clipPos(doc, from);
+ if (to) this.to = clipPos(doc, to);
+ if (text) this.text = text;
+ if (origin !== undefined) this.origin = origin;
+ };
+ signal(doc, "beforeChange", doc, obj);
+ if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
+
+ if (obj.canceled) return null;
+ return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
+ }
+
+ // Apply a change to a document, and add it to the document's
+ // history, and propagating it to all linked documents.
+ function makeChange(doc, change, ignoreReadOnly) {
+ if (doc.cm) {
+ if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
+ if (doc.cm.state.suppressEdits) return;
+ }
+
+ if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
+ change = filterChange(doc, change, true);
+ if (!change) return;
+ }
+
+ // Possibly split or suppress the update based on the presence
+ // of read-only spans in its range.
+ var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
+ if (split) {
+ for (var i = split.length - 1; i >= 0; --i)
+ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
+ } else {
+ makeChangeInner(doc, change);
+ }
+ }
+
+ function makeChangeInner(doc, change) {
+ if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
+ var selAfter = computeSelAfterChange(doc, change);
+ addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
+
+ makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
+ var rebased = [];
+
+ linkedDocs(doc, function(doc, sharedHist) {
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
+ rebaseHist(doc.history, change);
+ rebased.push(doc.history);
+ }
+ makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
+ });
+ }
+
+ // Revert a change stored in a document's history.
+ function makeChangeFromHistory(doc, type, allowSelectionOnly) {
+ if (doc.cm && doc.cm.state.suppressEdits) return;
+
+ var hist = doc.history, event, selAfter = doc.sel;
+ var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
+
+ // Verify that there is a useable event (so that ctrl-z won't
+ // needlessly clear selection events)
+ for (var i = 0; i < source.length; i++) {
+ event = source[i];
+ if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
+ break;
+ }
+ if (i == source.length) return;
+ hist.lastOrigin = hist.lastSelOrigin = null;
+
+ for (;;) {
+ event = source.pop();
+ if (event.ranges) {
+ pushSelectionToHistory(event, dest);
+ if (allowSelectionOnly && !event.equals(doc.sel)) {
+ setSelection(doc, event, {clearRedo: false});
+ return;
+ }
+ selAfter = event;
+ }
+ else break;
+ }
+
+ // Build up a reverse change object to add to the opposite history
+ // stack (redo when undoing, and vice versa).
+ var antiChanges = [];
+ pushSelectionToHistory(selAfter, dest);
+ dest.push({changes: antiChanges, generation: hist.generation});
+ hist.generation = event.generation || ++hist.maxGeneration;
+
+ var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
+
+ for (var i = event.changes.length - 1; i >= 0; --i) {
+ var change = event.changes[i];
+ change.origin = type;
+ if (filter && !filterChange(doc, change, false)) {
+ source.length = 0;
+ return;
+ }
+
+ antiChanges.push(historyChangeFromChange(doc, change));
+
+ var after = i ? computeSelAfterChange(doc, change, null) : lst(source);
+ makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
+ if (doc.cm) ensureCursorVisible(doc.cm);
+ var rebased = [];
+
+ // Propagate to the linked documents
+ linkedDocs(doc, function(doc, sharedHist) {
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
+ rebaseHist(doc.history, change);
+ rebased.push(doc.history);
+ }
+ makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
+ });
+ }
+ }
+
+ // Sub-views need their line numbers shifted when text is added
+ // above or below them in the parent document.
+ function shiftDoc(doc, distance) {
+ doc.first += distance;
+ doc.sel = new Selection(map(doc.sel.ranges, function(range) {
+ return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
+ Pos(range.head.line + distance, range.head.ch));
+ }), doc.sel.primIndex);
+ if (doc.cm) regChange(doc.cm, doc.first, doc.first - distance, distance);
+ }
+
+ // More lower-level change function, handling only a single document
+ // (not linked ones).
+ function makeChangeSingleDoc(doc, change, selAfter, spans) {
+ if (doc.cm && !doc.cm.curOp)
+ return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
+
+ if (change.to.line < doc.first) {
+ shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
+ return;
+ }
+ if (change.from.line > doc.lastLine()) return;
+
+ // Clip the change to the size of this doc
+ if (change.from.line < doc.first) {
+ var shift = change.text.length - 1 - (doc.first - change.from.line);
+ shiftDoc(doc, shift);
+ change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
+ text: [lst(change.text)], origin: change.origin};
+ }
+ var last = doc.lastLine();
+ if (change.to.line > last) {
+ change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
+ text: [change.text[0]], origin: change.origin};
+ }
+
+ change.removed = getBetween(doc, change.from, change.to);
+
+ if (!selAfter) selAfter = computeSelAfterChange(doc, change, null);
+ if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
+ else updateDoc(doc, change, spans);
+ setSelectionNoUndo(doc, selAfter, sel_dontScroll);
+ }
+
+ // Handle the interaction of a change to a document with the editor
+ // that this document is part of.
+ function makeChangeSingleDocInEditor(cm, change, spans) {
+ var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
+
+ var recomputeMaxLength = false, checkWidthStart = from.line;
+ if (!cm.options.lineWrapping) {
+ checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
+ doc.iter(checkWidthStart, to.line + 1, function(line) {
+ if (line == display.maxLine) {
+ recomputeMaxLength = true;
+ return true;
+ }
+ });
+ }
+
+ if (doc.sel.contains(change.from, change.to) > -1)
+ signalCursorActivity(cm);
+
+ updateDoc(doc, change, spans, estimateHeight(cm));
+
+ if (!cm.options.lineWrapping) {
+ doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
+ var len = lineLength(line);
+ if (len > display.maxLineLength) {
+ display.maxLine = line;
+ display.maxLineLength = len;
+ display.maxLineChanged = true;
+ recomputeMaxLength = false;
+ }
+ });
+ if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
+ }
+
+ // Adjust frontier, schedule worker
+ doc.frontier = Math.min(doc.frontier, from.line);
+ startWorker(cm, 400);
+
+ var lendiff = change.text.length - (to.line - from.line) - 1;
+ // Remember that these lines changed, for updating the display
+ if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
+ regLineChange(cm, from.line, "text");
+ else
+ regChange(cm, from.line, to.line + 1, lendiff);
+
+ var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
+ if (changeHandler || changesHandler) {
+ var obj = {
+ from: from, to: to,
+ text: change.text,
+ removed: change.removed,
+ origin: change.origin
+ };
+ if (changeHandler) signalLater(cm, "change", cm, obj);
+ if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
+ }
+ }
+
+ function replaceRange(doc, code, from, to, origin) {
+ if (!to) to = from;
+ if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
+ if (typeof code == "string") code = splitLines(code);
+ makeChange(doc, {from: from, to: to, text: code, origin: origin});
+ }
+
+ // SCROLLING THINGS INTO VIEW
+
+ // If an editor sits on the top or bottom of the window, partially
+ // scrolled out of view, this ensures that the cursor is visible.
+ function maybeScrollWindow(cm, coords) {
+ var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
+ if (coords.top + box.top < 0) doScroll = true;
+ else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
+ if (doScroll != null && !phantom) {
+ var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
+ (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
+ (coords.bottom - coords.top + scrollerCutOff) + "px; left: " +
+ coords.left + "px; width: 2px;");
+ cm.display.lineSpace.appendChild(scrollNode);
+ scrollNode.scrollIntoView(doScroll);
+ cm.display.lineSpace.removeChild(scrollNode);
+ }
+ }
+
+ // Scroll a given position into view (immediately), verifying that
+ // it actually became visible (as line heights are accurately
+ // measured, the position of something may 'drift' during drawing).
+ function scrollPosIntoView(cm, pos, end, margin) {
+ if (margin == null) margin = 0;
+ for (;;) {
+ var changed = false, coords = cursorCoords(cm, pos);
+ var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
+ var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
+ Math.min(coords.top, endCoords.top) - margin,
+ Math.max(coords.left, endCoords.left),
+ Math.max(coords.bottom, endCoords.bottom) + margin);
+ var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
+ if (scrollPos.scrollTop != null) {
+ setScrollTop(cm, scrollPos.scrollTop);
+ if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
+ }
+ if (scrollPos.scrollLeft != null) {
+ setScrollLeft(cm, scrollPos.scrollLeft);
+ if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
+ }
+ if (!changed) return coords;
+ }
+ }
+
+ // Scroll a given set of coordinates into view (immediately).
+ function scrollIntoView(cm, x1, y1, x2, y2) {
+ var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
+ if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
+ if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
+ }
+
+ // Calculate a new scroll position needed to scroll the given
+ // rectangle into view. Returns an object with scrollTop and
+ // scrollLeft properties. When these are undefined, the
+ // vertical/horizontal position does not need to be adjusted.
+ function calculateScrollPos(cm, x1, y1, x2, y2) {
+ var display = cm.display, snapMargin = textHeight(cm.display);
+ if (y1 < 0) y1 = 0;
+ var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
+ var screen = display.scroller.clientHeight - scrollerCutOff, result = {};
+ var docBottom = cm.doc.height + paddingVert(display);
+ var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
+ if (y1 < screentop) {
+ result.scrollTop = atTop ? 0 : y1;
+ } else if (y2 > screentop + screen) {
+ var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
+ if (newTop != screentop) result.scrollTop = newTop;
+ }
+
+ var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
+ var screenw = display.scroller.clientWidth - scrollerCutOff;
+ x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth;
+ var gutterw = display.gutters.offsetWidth;
+ var atLeft = x1 < gutterw + 10;
+ if (x1 < screenleft + gutterw || atLeft) {
+ if (atLeft) x1 = 0;
+ result.scrollLeft = Math.max(0, x1 - 10 - gutterw);
+ } else if (x2 > screenw + screenleft - 3) {
+ result.scrollLeft = x2 + 10 - screenw;
+ }
+ return result;
+ }
+
+ // Store a relative adjustment to the scroll position in the current
+ // operation (to be applied when the operation finishes).
+ function addToScrollPos(cm, left, top) {
+ if (left != null || top != null) resolveScrollToPos(cm);
+ if (left != null)
+ cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
+ if (top != null)
+ cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
+ }
+
+ // Make sure that at the end of the operation the current cursor is
+ // shown.
+ function ensureCursorVisible(cm) {
+ resolveScrollToPos(cm);
+ var cur = cm.getCursor(), from = cur, to = cur;
+ if (!cm.options.lineWrapping) {
+ from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
+ to = Pos(cur.line, cur.ch + 1);
+ }
+ cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
+ }
+
+ // When an operation has its scrollToPos property set, and another
+ // scroll action is applied before the end of the operation, this
+ // 'simulates' scrolling that position into view in a cheap way, so
+ // that the effect of intermediate scroll commands is not ignored.
+ function resolveScrollToPos(cm) {
+ var range = cm.curOp.scrollToPos;
+ if (range) {
+ cm.curOp.scrollToPos = null;
+ var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
+ var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
+ Math.min(from.top, to.top) - range.margin,
+ Math.max(from.right, to.right),
+ Math.max(from.bottom, to.bottom) + range.margin);
+ cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
+ }
+ }
+
+ // API UTILITIES
+
+ // Indent the given line. The how parameter can be "smart",
+ // "add"/null, "subtract", or "prev". When aggressive is false
+ // (typically set to true for forced single-line indents), empty
+ // lines are not indented, and places where the mode returns Pass
+ // are left alone.
+ function indentLine(cm, n, how, aggressive) {
+ var doc = cm.doc, state;
+ if (how == null) how = "add";
+ if (how == "smart") {
+ // Fall back to "prev" when the mode doesn't have an indentation
+ // method.
+ if (!cm.doc.mode.indent) how = "prev";
+ else state = getStateBefore(cm, n);
+ }
+
+ var tabSize = cm.options.tabSize;
+ var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
+ if (line.stateAfter) line.stateAfter = null;
+ var curSpaceString = line.text.match(/^\s*/)[0], indentation;
+ if (!aggressive && !/\S/.test(line.text)) {
+ indentation = 0;
+ how = "not";
+ } else if (how == "smart") {
+ indentation = cm.doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
+ if (indentation == Pass) {
+ if (!aggressive) return;
+ how = "prev";
+ }
+ }
+ if (how == "prev") {
+ if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
+ else indentation = 0;
+ } else if (how == "add") {
+ indentation = curSpace + cm.options.indentUnit;
+ } else if (how == "subtract") {
+ indentation = curSpace - cm.options.indentUnit;
+ } else if (typeof how == "number") {
+ indentation = curSpace + how;
+ }
+ indentation = Math.max(0, indentation);
+
+ var indentString = "", pos = 0;
+ if (cm.options.indentWithTabs)
+ for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
+ if (pos < indentation) indentString += spaceStr(indentation - pos);
+
+ if (indentString != curSpaceString) {
+ replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
+ } else {
+ // Ensure that, if the cursor was in the whitespace at the start
+ // of the line, it is moved to the end of that space.
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ var range = doc.sel.ranges[i];
+ if (range.head.line == n && range.head.ch < curSpaceString.length) {
+ var pos = Pos(n, curSpaceString.length);
+ replaceOneSelection(doc, i, new Range(pos, pos));
+ break;
+ }
+ }
+ }
+ line.stateAfter = null;
+ }
+
+ // Utility for applying a change to a line by handle or number,
+ // returning the number and optionally registering the line as
+ // changed.
+ function changeLine(cm, handle, changeType, op) {
+ var no = handle, line = handle, doc = cm.doc;
+ if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
+ else no = lineNo(handle);
+ if (no == null) return null;
+ if (op(line, no)) regLineChange(cm, no, changeType);
+ return line;
+ }
+
+ // Helper for deleting text near the selection(s), used to implement
+ // backspace, delete, and similar functionality.
+ function deleteNearSelection(cm, compute) {
+ var ranges = cm.doc.sel.ranges, kill = [];
+ // Build up a set of ranges to kill first, merging overlapping
+ // ranges.
+ for (var i = 0; i < ranges.length; i++) {
+ var toKill = compute(ranges[i]);
+ while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
+ var replaced = kill.pop();
+ if (cmp(replaced.from, toKill.from) < 0) {
+ toKill.from = replaced.from;
+ break;
+ }
+ }
+ kill.push(toKill);
+ }
+ // Next, remove those actual ranges.
+ runInOp(cm, function() {
+ for (var i = kill.length - 1; i >= 0; i--)
+ replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
+ ensureCursorVisible(cm);
+ });
+ }
+
+ // Used for horizontal relative motion. Dir is -1 or 1 (left or
+ // right), unit can be "char", "column" (like char, but doesn't
+ // cross line boundaries), "word" (across next word), or "group" (to
+ // the start of next group of word or non-word-non-whitespace
+ // chars). The visually param controls whether, in right-to-left
+ // text, direction 1 means to move towards the next index in the
+ // string, or towards the character to the right of the current
+ // position. The resulting position will have a hitSide=true
+ // property if it reached the end of the document.
+ function findPosH(doc, pos, dir, unit, visually) {
+ var line = pos.line, ch = pos.ch, origDir = dir;
+ var lineObj = getLine(doc, line);
+ var possible = true;
+ function findNextLine() {
+ var l = line + dir;
+ if (l < doc.first || l >= doc.first + doc.size) return (possible = false);
+ line = l;
+ return lineObj = getLine(doc, l);
+ }
+ function moveOnce(boundToLine) {
+ var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
+ if (next == null) {
+ if (!boundToLine && findNextLine()) {
+ if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
+ else ch = dir < 0 ? lineObj.text.length : 0;
+ } else return (possible = false);
+ } else ch = next;
+ return true;
+ }
+
+ if (unit == "char") moveOnce();
+ else if (unit == "column") moveOnce(true);
+ else if (unit == "word" || unit == "group") {
+ var sawType = null, group = unit == "group";
+ for (var first = true;; first = false) {
+ if (dir < 0 && !moveOnce(!first)) break;
+ var cur = lineObj.text.charAt(ch) || "\n";
+ var type = isWordChar(cur) ? "w"
+ : group && cur == "\n" ? "n"
+ : !group || /\s/.test(cur) ? null
+ : "p";
+ if (group && !first && !type) type = "s";
+ if (sawType && sawType != type) {
+ if (dir < 0) {dir = 1; moveOnce();}
+ break;
+ }
+
+ if (type) sawType = type;
+ if (dir > 0 && !moveOnce(!first)) break;
+ }
+ }
+ var result = skipAtomic(doc, Pos(line, ch), origDir, true);
+ if (!possible) result.hitSide = true;
+ return result;
+ }
+
+ // For relative vertical movement. Dir may be -1 or 1. Unit can be
+ // "page" or "line". The resulting position will have a hitSide=true
+ // property if it reached the end of the document.
+ function findPosV(cm, pos, dir, unit) {
+ var doc = cm.doc, x = pos.left, y;
+ if (unit == "page") {
+ var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
+ y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
+ } else if (unit == "line") {
+ y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
+ }
+ for (;;) {
+ var target = coordsChar(cm, x, y);
+ if (!target.outside) break;
+ if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
+ y += dir * 5;
+ }
+ return target;
+ }
+
+ // Find the word at the given position (as returned by coordsChar).
+ function findWordAt(doc, pos) {
+ var line = getLine(doc, pos.line).text;
+ var start = pos.ch, end = pos.ch;
+ if (line) {
+ if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
+ var startChar = line.charAt(start);
+ var check = isWordChar(startChar) ? isWordChar
+ : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
+ : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
+ while (start > 0 && check(line.charAt(start - 1))) --start;
+ while (end < line.length && check(line.charAt(end))) ++end;
+ }
+ return new Range(Pos(pos.line, start), Pos(pos.line, end));
+ }
+
+ // EDITOR METHODS
+
+ // The publicly visible API. Note that methodOp(f) means
+ // 'wrap f in an operation, performed on its `this` parameter'.
+
+ // This is not the complete set of editor methods. Most of the
+ // methods defined on the Doc type are also injected into
+ // CodeMirror.prototype, for backwards compatibility and
+ // convenience.
+
+ CodeMirror.prototype = {
+ constructor: CodeMirror,
+ focus: function(){window.focus(); focusInput(this); fastPoll(this);},
+
+ setOption: function(option, value) {
+ var options = this.options, old = options[option];
+ if (options[option] == value && option != "mode") return;
+ options[option] = value;
+ if (optionHandlers.hasOwnProperty(option))
+ operation(this, optionHandlers[option])(this, value, old);
+ },
+
+ getOption: function(option) {return this.options[option];},
+ getDoc: function() {return this.doc;},
+
+ addKeyMap: function(map, bottom) {
+ this.state.keyMaps[bottom ? "push" : "unshift"](map);
+ },
+ removeKeyMap: function(map) {
+ var maps = this.state.keyMaps;
+ for (var i = 0; i < maps.length; ++i)
+ if (maps[i] == map || (typeof maps[i] != "string" && maps[i].name == map)) {
+ maps.splice(i, 1);
+ return true;
+ }
+ },
+
+ addOverlay: methodOp(function(spec, options) {
+ var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
+ if (mode.startState) throw new Error("Overlays may not be stateful.");
+ this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
+ this.state.modeGen++;
+ regChange(this);
+ }),
+ removeOverlay: methodOp(function(spec) {
+ var overlays = this.state.overlays;
+ for (var i = 0; i < overlays.length; ++i) {
+ var cur = overlays[i].modeSpec;
+ if (cur == spec || typeof spec == "string" && cur.name == spec) {
+ overlays.splice(i, 1);
+ this.state.modeGen++;
+ regChange(this);
+ return;
+ }
+ }
+ }),
+
+ indentLine: methodOp(function(n, dir, aggressive) {
+ if (typeof dir != "string" && typeof dir != "number") {
+ if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
+ else dir = dir ? "add" : "subtract";
+ }
+ if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
+ }),
+ indentSelection: methodOp(function(how) {
+ var ranges = this.doc.sel.ranges, end = -1;
+ for (var i = 0; i < ranges.length; i++) {
+ var range = ranges[i];
+ if (!range.empty()) {
+ var start = Math.max(end, range.from().line);
+ var to = range.to();
+ end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
+ for (var j = start; j < end; ++j)
+ indentLine(this, j, how);
+ } else if (range.head.line > end) {
+ indentLine(this, range.head.line, how, true);
+ end = range.head.line;
+ if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
+ }
+ }
+ }),
+
+ // Fetch the parser token for a given character. Useful for hacks
+ // that want to inspect the mode state (say, for completion).
+ getTokenAt: function(pos, precise) {
+ var doc = this.doc;
+ pos = clipPos(doc, pos);
+ var state = getStateBefore(this, pos.line, precise), mode = this.doc.mode;
+ var line = getLine(doc, pos.line);
+ var stream = new StringStream(line.text, this.options.tabSize);
+ while (stream.pos < pos.ch && !stream.eol()) {
+ stream.start = stream.pos;
+ var style = readToken(mode, stream, state);
+ }
+ return {start: stream.start,
+ end: stream.pos,
+ string: stream.current(),
+ type: style || null,
+ state: state};
+ },
+
+ getTokenTypeAt: function(pos) {
+ pos = clipPos(this.doc, pos);
+ var styles = getLineStyles(this, getLine(this.doc, pos.line));
+ var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
+ var type;
+ if (ch == 0) type = styles[2];
+ else for (;;) {
+ var mid = (before + after) >> 1;
+ if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
+ else if (styles[mid * 2 + 1] < ch) before = mid + 1;
+ else { type = styles[mid * 2 + 2]; break; }
+ }
+ var cut = type ? type.indexOf("cm-overlay ") : -1;
+ return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
+ },
+
+ getModeAt: function(pos) {
+ var mode = this.doc.mode;
+ if (!mode.innerMode) return mode;
+ return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
+ },
+
+ getHelper: function(pos, type) {
+ return this.getHelpers(pos, type)[0];
+ },
+
+ getHelpers: function(pos, type) {
+ var found = [];
+ if (!helpers.hasOwnProperty(type)) return helpers;
+ var help = helpers[type], mode = this.getModeAt(pos);
+ if (typeof mode[type] == "string") {
+ if (help[mode[type]]) found.push(help[mode[type]]);
+ } else if (mode[type]) {
+ for (var i = 0; i < mode[type].length; i++) {
+ var val = help[mode[type][i]];
+ if (val) found.push(val);
+ }
+ } else if (mode.helperType && help[mode.helperType]) {
+ found.push(help[mode.helperType]);
+ } else if (help[mode.name]) {
+ found.push(help[mode.name]);
+ }
+ for (var i = 0; i < help._global.length; i++) {
+ var cur = help._global[i];
+ if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
+ found.push(cur.val);
+ }
+ return found;
+ },
+
+ getStateAfter: function(line, precise) {
+ var doc = this.doc;
+ line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
+ return getStateBefore(this, line + 1, precise);
+ },
+
+ cursorCoords: function(start, mode) {
+ var pos, range = this.doc.sel.primary();
+ if (start == null) pos = range.head;
+ else if (typeof start == "object") pos = clipPos(this.doc, start);
+ else pos = start ? range.from() : range.to();
+ return cursorCoords(this, pos, mode || "page");
+ },
+
+ charCoords: function(pos, mode) {
+ return charCoords(this, clipPos(this.doc, pos), mode || "page");
+ },
+
+ coordsChar: function(coords, mode) {
+ coords = fromCoordSystem(this, coords, mode || "page");
+ return coordsChar(this, coords.left, coords.top);
+ },
+
+ lineAtHeight: function(height, mode) {
+ height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
+ return lineAtHeight(this.doc, height + this.display.viewOffset);
+ },
+ heightAtLine: function(line, mode) {
+ var end = false, last = this.doc.first + this.doc.size - 1;
+ if (line < this.doc.first) line = this.doc.first;
+ else if (line > last) { line = last; end = true; }
+ var lineObj = getLine(this.doc, line);
+ return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
+ (end ? this.doc.height - heightAtLine(lineObj) : 0);
+ },
+
+ defaultTextHeight: function() { return textHeight(this.display); },
+ defaultCharWidth: function() { return charWidth(this.display); },
+
+ setGutterMarker: methodOp(function(line, gutterID, value) {
+ return changeLine(this, line, "gutter", function(line) {
+ var markers = line.gutterMarkers || (line.gutterMarkers = {});
+ markers[gutterID] = value;
+ if (!value && isEmpty(markers)) line.gutterMarkers = null;
+ return true;
+ });
+ }),
+
+ clearGutter: methodOp(function(gutterID) {
+ var cm = this, doc = cm.doc, i = doc.first;
+ doc.iter(function(line) {
+ if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
+ line.gutterMarkers[gutterID] = null;
+ regLineChange(cm, i, "gutter");
+ if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
+ }
+ ++i;
+ });
+ }),
+
+ addLineClass: methodOp(function(handle, where, cls) {
+ return changeLine(this, handle, "class", function(line) {
+ var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
+ if (!line[prop]) line[prop] = cls;
+ else if (new RegExp("(?:^|\\s)" + cls + "(?:$|\\s)").test(line[prop])) return false;
+ else line[prop] += " " + cls;
+ return true;
+ });
+ }),
+
+ removeLineClass: methodOp(function(handle, where, cls) {
+ return changeLine(this, handle, "class", function(line) {
+ var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
+ var cur = line[prop];
+ if (!cur) return false;
+ else if (cls == null) line[prop] = null;
+ else {
+ var found = cur.match(new RegExp("(?:^|\\s+)" + cls + "(?:$|\\s+)"));
+ if (!found) return false;
+ var end = found.index + found[0].length;
+ line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
+ }
+ return true;
+ });
+ }),
+
+ addLineWidget: methodOp(function(handle, node, options) {
+ return addLineWidget(this, handle, node, options);
+ }),
+
+ removeLineWidget: function(widget) { widget.clear(); },
+
+ lineInfo: function(line) {
+ if (typeof line == "number") {
+ if (!isLine(this.doc, line)) return null;
+ var n = line;
+ line = getLine(this.doc, line);
+ if (!line) return null;
+ } else {
+ var n = lineNo(line);
+ if (n == null) return null;
+ }
+ return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
+ textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
+ widgets: line.widgets};
+ },
+
+ getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
+
+ addWidget: function(pos, node, scroll, vert, horiz) {
+ var display = this.display;
+ pos = cursorCoords(this, clipPos(this.doc, pos));
+ var top = pos.bottom, left = pos.left;
+ node.style.position = "absolute";
+ display.sizer.appendChild(node);
+ if (vert == "over") {
+ top = pos.top;
+ } else if (vert == "above" || vert == "near") {
+ var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
+ hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
+ // Default to positioning above (if specified and possible); otherwise default to positioning below
+ if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
+ top = pos.top - node.offsetHeight;
+ else if (pos.bottom + node.offsetHeight <= vspace)
+ top = pos.bottom;
+ if (left + node.offsetWidth > hspace)
+ left = hspace - node.offsetWidth;
+ }
+ node.style.top = top + "px";
+ node.style.left = node.style.right = "";
+ if (horiz == "right") {
+ left = display.sizer.clientWidth - node.offsetWidth;
+ node.style.right = "0px";
+ } else {
+ if (horiz == "left") left = 0;
+ else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
+ node.style.left = left + "px";
+ }
+ if (scroll)
+ scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
+ },
+
+ triggerOnKeyDown: methodOp(onKeyDown),
+ triggerOnKeyPress: methodOp(onKeyPress),
+ triggerOnKeyUp: methodOp(onKeyUp),
+
+ execCommand: function(cmd) {
+ if (commands.hasOwnProperty(cmd))
+ return commands[cmd](this);
+ },
+
+ findPosH: function(from, amount, unit, visually) {
+ var dir = 1;
+ if (amount < 0) { dir = -1; amount = -amount; }
+ for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
+ cur = findPosH(this.doc, cur, dir, unit, visually);
+ if (cur.hitSide) break;
+ }
+ return cur;
+ },
+
+ moveH: methodOp(function(dir, unit) {
+ var cm = this;
+ cm.extendSelectionsBy(function(range) {
+ if (cm.display.shift || cm.doc.extend || range.empty())
+ return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
+ else
+ return dir < 0 ? range.from() : range.to();
+ }, sel_move);
+ }),
+
+ deleteH: methodOp(function(dir, unit) {
+ var sel = this.doc.sel, doc = this.doc;
+ if (sel.somethingSelected())
+ doc.replaceSelection("", null, "+delete");
+ else
+ deleteNearSelection(this, function(range) {
+ var other = findPosH(doc, range.head, dir, unit, false);
+ return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
+ });
+ }),
+
+ findPosV: function(from, amount, unit, goalColumn) {
+ var dir = 1, x = goalColumn;
+ if (amount < 0) { dir = -1; amount = -amount; }
+ for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
+ var coords = cursorCoords(this, cur, "div");
+ if (x == null) x = coords.left;
+ else coords.left = x;
+ cur = findPosV(this, coords, dir, unit);
+ if (cur.hitSide) break;
+ }
+ return cur;
+ },
+
+ moveV: methodOp(function(dir, unit) {
+ var cm = this, doc = this.doc, goals = [];
+ var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
+ doc.extendSelectionsBy(function(range) {
+ if (collapse)
+ return dir < 0 ? range.from() : range.to();
+ var headPos = cursorCoords(cm, range.head, "div");
+ if (range.goalColumn != null) headPos.left = range.goalColumn;
+ goals.push(headPos.left);
+ var pos = findPosV(cm, headPos, dir, unit);
+ if (unit == "page" && range == doc.sel.primary())
+ addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
+ return pos;
+ }, sel_move);
+ if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
+ doc.sel.ranges[i].goalColumn = goals[i];
+ }),
+
+ toggleOverwrite: function(value) {
+ if (value != null && value == this.state.overwrite) return;
+ if (this.state.overwrite = !this.state.overwrite)
+ addClass(this.display.cursorDiv, "CodeMirror-overwrite");
+ else
+ rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
+
+ signal(this, "overwriteToggle", this, this.state.overwrite);
+ },
+ hasFocus: function() { return activeElt() == this.display.input; },
+
+ scrollTo: methodOp(function(x, y) {
+ if (x != null || y != null) resolveScrollToPos(this);
+ if (x != null) this.curOp.scrollLeft = x;
+ if (y != null) this.curOp.scrollTop = y;
+ }),
+ getScrollInfo: function() {
+ var scroller = this.display.scroller, co = scrollerCutOff;
+ return {left: scroller.scrollLeft, top: scroller.scrollTop,
+ height: scroller.scrollHeight - co, width: scroller.scrollWidth - co,
+ clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
+ },
+
+ scrollIntoView: methodOp(function(range, margin) {
+ if (range == null) {
+ range = {from: this.doc.sel.primary().head, to: null};
+ if (margin == null) margin = this.options.cursorScrollMargin;
+ } else if (typeof range == "number") {
+ range = {from: Pos(range, 0), to: null};
+ } else if (range.from == null) {
+ range = {from: range, to: null};
+ }
+ if (!range.to) range.to = range.from;
+ range.margin = margin || 0;
+
+ if (range.from.line != null) {
+ resolveScrollToPos(this);
+ this.curOp.scrollToPos = range;
+ } else {
+ var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
+ Math.min(range.from.top, range.to.top) - range.margin,
+ Math.max(range.from.right, range.to.right),
+ Math.max(range.from.bottom, range.to.bottom) + range.margin);
+ this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
+ }
+ }),
+
+ setSize: methodOp(function(width, height) {
+ function interpret(val) {
+ return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
+ }
+ if (width != null) this.display.wrapper.style.width = interpret(width);
+ if (height != null) this.display.wrapper.style.height = interpret(height);
+ if (this.options.lineWrapping) clearLineMeasurementCache(this);
+ this.curOp.forceUpdate = true;
+ signal(this, "refresh", this);
+ }),
+
+ operation: function(f){return runInOp(this, f);},
+
+ refresh: methodOp(function() {
+ var oldHeight = this.display.cachedTextHeight;
+ regChange(this);
+ this.curOp.forceUpdate = true;
+ clearCaches(this);
+ this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
+ updateGutterSpace(this);
+ if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
+ estimateLineHeights(this);
+ signal(this, "refresh", this);
+ }),
+
+ swapDoc: methodOp(function(doc) {
+ var old = this.doc;
+ old.cm = null;
+ attachDoc(this, doc);
+ clearCaches(this);
+ resetInput(this);
+ this.scrollTo(doc.scrollLeft, doc.scrollTop);
+ signalLater(this, "swapDoc", this, old);
+ return old;
+ }),
+
+ getInputField: function(){return this.display.input;},
+ getWrapperElement: function(){return this.display.wrapper;},
+ getScrollerElement: function(){return this.display.scroller;},
+ getGutterElement: function(){return this.display.gutters;}
+ };
+ eventMixin(CodeMirror);
+
+ // OPTION DEFAULTS
+
+ // The default configuration options.
+ var defaults = CodeMirror.defaults = {};
+ // Functions to run when options are changed.
+ var optionHandlers = CodeMirror.optionHandlers = {};
+
+ function option(name, deflt, handle, notOnInit) {
+ CodeMirror.defaults[name] = deflt;
+ if (handle) optionHandlers[name] =
+ notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
+ }
+
+ // Passed to option handlers when there is no old value.
+ var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
+
+ // These two are, on init, called from the constructor because they
+ // have to be initialized before the editor can start at all.
+ option("value", "", function(cm, val) {
+ cm.setValue(val);
+ }, true);
+ option("mode", null, function(cm, val) {
+ cm.doc.modeOption = val;
+ loadMode(cm);
+ }, true);
+
+ option("indentUnit", 2, loadMode, true);
+ option("indentWithTabs", false);
+ option("smartIndent", true);
+ option("tabSize", 4, function(cm) {
+ resetModeState(cm);
+ clearCaches(cm);
+ regChange(cm);
+ }, true);
+ option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function(cm, val) {
+ cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
+ cm.refresh();
+ }, true);
+ option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
+ option("electricChars", true);
+ option("rtlMoveVisually", !windows);
+ option("wholeLineUpdateBefore", true);
+
+ option("theme", "default", function(cm) {
+ themeChanged(cm);
+ guttersChanged(cm);
+ }, true);
+ option("keyMap", "default", keyMapChanged);
+ option("extraKeys", null);
+
+ option("lineWrapping", false, wrappingChanged, true);
+ option("gutters", [], function(cm) {
+ setGuttersForLineNumbers(cm.options);
+ guttersChanged(cm);
+ }, true);
+ option("fixedGutter", true, function(cm, val) {
+ cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
+ cm.refresh();
+ }, true);
+ option("coverGutterNextToScrollbar", false, updateScrollbars, true);
+ option("lineNumbers", false, function(cm) {
+ setGuttersForLineNumbers(cm.options);
+ guttersChanged(cm);
+ }, true);
+ option("firstLineNumber", 1, guttersChanged, true);
+ option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
+ option("showCursorWhenSelecting", false, updateSelection, true);
+
+ option("resetSelectionOnContextMenu", true);
+
+ option("readOnly", false, function(cm, val) {
+ if (val == "nocursor") {
+ onBlur(cm);
+ cm.display.input.blur();
+ cm.display.disabled = true;
+ } else {
+ cm.display.disabled = false;
+ if (!val) resetInput(cm);
+ }
+ });
+ option("disableInput", false, function(cm, val) {if (!val) resetInput(cm);}, true);
+ option("dragDrop", true);
+
+ option("cursorBlinkRate", 530);
+ option("cursorScrollMargin", 0);
+ option("cursorHeight", 1);
+ option("workTime", 100);
+ option("workDelay", 100);
+ option("flattenSpans", true, resetModeState, true);
+ option("addModeClass", false, resetModeState, true);
+ option("pollInterval", 100);
+ option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
+ option("historyEventDelay", 1250);
+ option("viewportMargin", 10, function(cm){cm.refresh();}, true);
+ option("maxHighlightLength", 10000, resetModeState, true);
+ option("moveInputWithCursor", true, function(cm, val) {
+ if (!val) cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0;
+ });
+
+ option("tabindex", null, function(cm, val) {
+ cm.display.input.tabIndex = val || "";
+ });
+ option("autofocus", null);
+
+ // MODE DEFINITION AND QUERYING
+
+ // Known modes, by name and by MIME
+ var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
+
+ // Extra arguments are stored as the mode's dependencies, which is
+ // used by (legacy) mechanisms like loadmode.js to automatically
+ // load a mode. (Preferred mechanism is the require/define calls.)
+ CodeMirror.defineMode = function(name, mode) {
+ if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
+ if (arguments.length > 2) {
+ mode.dependencies = [];
+ for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
+ }
+ modes[name] = mode;
+ };
+
+ CodeMirror.defineMIME = function(mime, spec) {
+ mimeModes[mime] = spec;
+ };
+
+ // Given a MIME type, a {name, ...options} config object, or a name
+ // string, return a mode config object.
+ CodeMirror.resolveMode = function(spec) {
+ if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
+ spec = mimeModes[spec];
+ } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
+ var found = mimeModes[spec.name];
+ if (typeof found == "string") found = {name: found};
+ spec = createObj(found, spec);
+ spec.name = found.name;
+ } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
+ return CodeMirror.resolveMode("application/xml");
+ }
+ if (typeof spec == "string") return {name: spec};
+ else return spec || {name: "null"};
+ };
+
+ // Given a mode spec (anything that resolveMode accepts), find and
+ // initialize an actual mode object.
+ CodeMirror.getMode = function(options, spec) {
+ var spec = CodeMirror.resolveMode(spec);
+ var mfactory = modes[spec.name];
+ if (!mfactory) return CodeMirror.getMode(options, "text/plain");
+ var modeObj = mfactory(options, spec);
+ if (modeExtensions.hasOwnProperty(spec.name)) {
+ var exts = modeExtensions[spec.name];
+ for (var prop in exts) {
+ if (!exts.hasOwnProperty(prop)) continue;
+ if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
+ modeObj[prop] = exts[prop];
+ }
+ }
+ modeObj.name = spec.name;
+ if (spec.helperType) modeObj.helperType = spec.helperType;
+ if (spec.modeProps) for (var prop in spec.modeProps)
+ modeObj[prop] = spec.modeProps[prop];
+
+ return modeObj;
+ };
+
+ // Minimal default mode.
+ CodeMirror.defineMode("null", function() {
+ return {token: function(stream) {stream.skipToEnd();}};
+ });
+ CodeMirror.defineMIME("text/plain", "null");
+
+ // This can be used to attach properties to mode objects from
+ // outside the actual mode definition.
+ var modeExtensions = CodeMirror.modeExtensions = {};
+ CodeMirror.extendMode = function(mode, properties) {
+ var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
+ copyObj(properties, exts);
+ };
+
+ // EXTENSIONS
+
+ CodeMirror.defineExtension = function(name, func) {
+ CodeMirror.prototype[name] = func;
+ };
+ CodeMirror.defineDocExtension = function(name, func) {
+ Doc.prototype[name] = func;
+ };
+ CodeMirror.defineOption = option;
+
+ var initHooks = [];
+ CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
+
+ var helpers = CodeMirror.helpers = {};
+ CodeMirror.registerHelper = function(type, name, value) {
+ if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
+ helpers[type][name] = value;
+ };
+ CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
+ CodeMirror.registerHelper(type, name, value);
+ helpers[type]._global.push({pred: predicate, val: value});
+ };
+
+ // MODE STATE HANDLING
+
+ // Utility functions for working with state. Exported because nested
+ // modes need to do this for their inner modes.
+
+ var copyState = CodeMirror.copyState = function(mode, state) {
+ if (state === true) return state;
+ if (mode.copyState) return mode.copyState(state);
+ var nstate = {};
+ for (var n in state) {
+ var val = state[n];
+ if (val instanceof Array) val = val.concat([]);
+ nstate[n] = val;
+ }
+ return nstate;
+ };
+
+ var startState = CodeMirror.startState = function(mode, a1, a2) {
+ return mode.startState ? mode.startState(a1, a2) : true;
+ };
+
+ // Given a mode and a state (for that mode), find the inner mode and
+ // state at the position that the state refers to.
+ CodeMirror.innerMode = function(mode, state) {
+ while (mode.innerMode) {
+ var info = mode.innerMode(state);
+ if (!info || info.mode == mode) break;
+ state = info.state;
+ mode = info.mode;
+ }
+ return info || {mode: mode, state: state};
+ };
+
+ // STANDARD COMMANDS
+
+ // Commands are parameter-less actions that can be performed on an
+ // editor, mostly used for keybindings.
+ var commands = CodeMirror.commands = {
+ selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
+ singleSelection: function(cm) {
+ cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
+ },
+ killLine: function(cm) {
+ deleteNearSelection(cm, function(range) {
+ if (range.empty()) {
+ var len = getLine(cm.doc, range.head.line).text.length;
+ if (range.head.ch == len && range.head.line < cm.lastLine())
+ return {from: range.head, to: Pos(range.head.line + 1, 0)};
+ else
+ return {from: range.head, to: Pos(range.head.line, len)};
+ } else {
+ return {from: range.from(), to: range.to()};
+ }
+ });
+ },
+ deleteLine: function(cm) {
+ deleteNearSelection(cm, function(range) {
+ return {from: Pos(range.from().line, 0),
+ to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
+ });
+ },
+ delLineLeft: function(cm) {
+ deleteNearSelection(cm, function(range) {
+ return {from: Pos(range.from().line, 0), to: range.from()};
+ });
+ },
+ undo: function(cm) {cm.undo();},
+ redo: function(cm) {cm.redo();},
+ undoSelection: function(cm) {cm.undoSelection();},
+ redoSelection: function(cm) {cm.redoSelection();},
+ goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
+ goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
+ goLineStart: function(cm) {
+ cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, sel_move);
+ },
+ goLineStartSmart: function(cm) {
+ cm.extendSelectionsBy(function(range) {
+ var start = lineStart(cm, range.head.line);
+ var line = cm.getLineHandle(start.line);
+ var order = getOrder(line);
+ if (!order || order[0].level == 0) {
+ var firstNonWS = Math.max(0, line.text.search(/\S/));
+ var inWS = range.head.line == start.line && range.head.ch <= firstNonWS && range.head.ch;
+ return Pos(start.line, inWS ? 0 : firstNonWS);
+ }
+ return start;
+ }, sel_move);
+ },
+ goLineEnd: function(cm) {
+ cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); }, sel_move);
+ },
+ goLineRight: function(cm) {
+ cm.extendSelectionsBy(function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
+ }, sel_move);
+ },
+ goLineLeft: function(cm) {
+ cm.extendSelectionsBy(function(range) {
+ var top = cm.charCoords(range.head, "div").top + 5;
+ return cm.coordsChar({left: 0, top: top}, "div");
+ }, sel_move);
+ },
+ goLineUp: function(cm) {cm.moveV(-1, "line");},
+ goLineDown: function(cm) {cm.moveV(1, "line");},
+ goPageUp: function(cm) {cm.moveV(-1, "page");},
+ goPageDown: function(cm) {cm.moveV(1, "page");},
+ goCharLeft: function(cm) {cm.moveH(-1, "char");},
+ goCharRight: function(cm) {cm.moveH(1, "char");},
+ goColumnLeft: function(cm) {cm.moveH(-1, "column");},
+ goColumnRight: function(cm) {cm.moveH(1, "column");},
+ goWordLeft: function(cm) {cm.moveH(-1, "word");},
+ goGroupRight: function(cm) {cm.moveH(1, "group");},
+ goGroupLeft: function(cm) {cm.moveH(-1, "group");},
+ goWordRight: function(cm) {cm.moveH(1, "word");},
+ delCharBefore: function(cm) {cm.deleteH(-1, "char");},
+ delCharAfter: function(cm) {cm.deleteH(1, "char");},
+ delWordBefore: function(cm) {cm.deleteH(-1, "word");},
+ delWordAfter: function(cm) {cm.deleteH(1, "word");},
+ delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
+ delGroupAfter: function(cm) {cm.deleteH(1, "group");},
+ indentAuto: function(cm) {cm.indentSelection("smart");},
+ indentMore: function(cm) {cm.indentSelection("add");},
+ indentLess: function(cm) {cm.indentSelection("subtract");},
+ insertTab: function(cm) {cm.replaceSelection("\t");},
+ insertSoftTab: function(cm) {
+ var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
+ for (var i = 0; i < ranges.length; i++) {
+ var pos = ranges[i].from();
+ var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
+ spaces.push(new Array(tabSize - col % tabSize + 1).join(" "));
+ }
+ cm.replaceSelections(spaces);
+ },
+ defaultTab: function(cm) {
+ if (cm.somethingSelected()) cm.indentSelection("add");
+ else cm.execCommand("insertTab");
+ },
+ transposeChars: function(cm) {
+ runInOp(cm, function() {
+ var ranges = cm.listSelections();
+ for (var i = 0; i < ranges.length; i++) {
+ var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
+ if (cur.ch > 0 && cur.ch < line.length - 1)
+ cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1),
+ Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
+ }
+ });
+ },
+ newlineAndIndent: function(cm) {
+ runInOp(cm, function() {
+ var len = cm.listSelections().length;
+ for (var i = 0; i < len; i++) {
+ var range = cm.listSelections()[i];
+ cm.replaceRange("\n", range.anchor, range.head, "+input");
+ cm.indentLine(range.from().line + 1, null, true);
+ ensureCursorVisible(cm);
+ }
+ });
+ },
+ toggleOverwrite: function(cm) {cm.toggleOverwrite();}
+ };
+
+ // STANDARD KEYMAPS
+
+ var keyMap = CodeMirror.keyMap = {};
+ keyMap.basic = {
+ "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
+ "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
+ "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
+ "Tab": "defaultTab", "Shift-Tab": "indentAuto",
+ "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
+ "Esc": "singleSelection"
+ };
+ // Note that the save and find-related commands aren't defined by
+ // default. User code or addons can define them. Unknown commands
+ // are simply ignored.
+ keyMap.pcDefault = {
+ "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
+ "Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
+ "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
+ "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
+ "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
+ "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
+ "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
+ fallthrough: "basic"
+ };
+ keyMap.macDefault = {
+ "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
+ "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
+ "Alt-Right": "goGroupRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delGroupBefore",
+ "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
+ "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
+ "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delLineLeft",
+ "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection",
+ fallthrough: ["basic", "emacsy"]
+ };
+ // Very basic readline/emacs-style bindings, which are standard on Mac.
+ keyMap.emacsy = {
+ "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
+ "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
+ "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
+ "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
+ };
+ keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
+
+ // KEYMAP DISPATCH
+
+ function getKeyMap(val) {
+ if (typeof val == "string") return keyMap[val];
+ else return val;
+ }
+
+ // Given an array of keymaps and a key name, call handle on any
+ // bindings found, until that returns a truthy value, at which point
+ // we consider the key handled. Implements things like binding a key
+ // to false stopping further handling and keymap fallthrough.
+ var lookupKey = CodeMirror.lookupKey = function(name, maps, handle) {
+ function lookup(map) {
+ map = getKeyMap(map);
+ var found = map[name];
+ if (found === false) return "stop";
+ if (found != null && handle(found)) return true;
+ if (map.nofallthrough) return "stop";
+
+ var fallthrough = map.fallthrough;
+ if (fallthrough == null) return false;
+ if (Object.prototype.toString.call(fallthrough) != "[object Array]")
+ return lookup(fallthrough);
+ for (var i = 0; i < fallthrough.length; ++i) {
+ var done = lookup(fallthrough[i]);
+ if (done) return done;
+ }
+ return false;
+ }
+
+ for (var i = 0; i < maps.length; ++i) {
+ var done = lookup(maps[i]);
+ if (done) return done != "stop";
+ }
+ };
+
+ // Modifier key presses don't count as 'real' key presses for the
+ // purpose of keymap fallthrough.
+ var isModifierKey = CodeMirror.isModifierKey = function(event) {
+ var name = keyNames[event.keyCode];
+ return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
+ };
+
+ // Look up the name of a key as indicated by an event object.
+ var keyName = CodeMirror.keyName = function(event, noShift) {
+ if (presto && event.keyCode == 34 && event["char"]) return false;
+ var name = keyNames[event.keyCode];
+ if (name == null || event.altGraphKey) return false;
+ if (event.altKey) name = "Alt-" + name;
+ if (flipCtrlCmd ? event.metaKey : event.ctrlKey) name = "Ctrl-" + name;
+ if (flipCtrlCmd ? event.ctrlKey : event.metaKey) name = "Cmd-" + name;
+ if (!noShift && event.shiftKey) name = "Shift-" + name;
+ return name;
+ };
+
+ // FROMTEXTAREA
+
+ CodeMirror.fromTextArea = function(textarea, options) {
+ if (!options) options = {};
+ options.value = textarea.value;
+ if (!options.tabindex && textarea.tabindex)
+ options.tabindex = textarea.tabindex;
+ if (!options.placeholder && textarea.placeholder)
+ options.placeholder = textarea.placeholder;
+ // Set autofocus to true if this textarea is focused, or if it has
+ // autofocus and no other element is focused.
+ if (options.autofocus == null) {
+ var hasFocus = activeElt();
+ options.autofocus = hasFocus == textarea ||
+ textarea.getAttribute("autofocus") != null && hasFocus == document.body;
+ }
+
+ function save() {textarea.value = cm.getValue();}
+ if (textarea.form) {
+ on(textarea.form, "submit", save);
+ // Deplorable hack to make the submit method do the right thing.
+ if (!options.leaveSubmitMethodAlone) {
+ var form = textarea.form, realSubmit = form.submit;
+ try {
+ var wrappedSubmit = form.submit = function() {
+ save();
+ form.submit = realSubmit;
+ form.submit();
+ form.submit = wrappedSubmit;
+ };
+ } catch(e) {}
+ }
+ }
+
+ textarea.style.display = "none";
+ var cm = CodeMirror(function(node) {
+ textarea.parentNode.insertBefore(node, textarea.nextSibling);
+ }, options);
+ cm.save = save;
+ cm.getTextArea = function() { return textarea; };
+ cm.toTextArea = function() {
+ save();
+ textarea.parentNode.removeChild(cm.getWrapperElement());
+ textarea.style.display = "";
+ if (textarea.form) {
+ off(textarea.form, "submit", save);
+ if (typeof textarea.form.submit == "function")
+ textarea.form.submit = realSubmit;
+ }
+ };
+ return cm;
+ };
+
+ // STRING STREAM
+
+ // Fed to the mode parsers, provides helper functions to make
+ // parsers more succinct.
+
+ var StringStream = CodeMirror.StringStream = function(string, tabSize) {
+ this.pos = this.start = 0;
+ this.string = string;
+ this.tabSize = tabSize || 8;
+ this.lastColumnPos = this.lastColumnValue = 0;
+ this.lineStart = 0;
+ };
+
+ StringStream.prototype = {
+ eol: function() {return this.pos >= this.string.length;},
+ sol: function() {return this.pos == this.lineStart;},
+ peek: function() {return this.string.charAt(this.pos) || undefined;},
+ next: function() {
+ if (this.pos < this.string.length)
+ return this.string.charAt(this.pos++);
+ },
+ eat: function(match) {
+ var ch = this.string.charAt(this.pos);
+ if (typeof match == "string") var ok = ch == match;
+ else var ok = ch && (match.test ? match.test(ch) : match(ch));
+ if (ok) {++this.pos; return ch;}
+ },
+ eatWhile: function(match) {
+ var start = this.pos;
+ while (this.eat(match)){}
+ return this.pos > start;
+ },
+ eatSpace: function() {
+ var start = this.pos;
+ while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
+ return this.pos > start;
+ },
+ skipToEnd: function() {this.pos = this.string.length;},
+ skipTo: function(ch) {
+ var found = this.string.indexOf(ch, this.pos);
+ if (found > -1) {this.pos = found; return true;}
+ },
+ backUp: function(n) {this.pos -= n;},
+ column: function() {
+ if (this.lastColumnPos < this.start) {
+ this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
+ this.lastColumnPos = this.start;
+ }
+ return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
+ },
+ indentation: function() {
+ return countColumn(this.string, null, this.tabSize) -
+ (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
+ },
+ match: function(pattern, consume, caseInsensitive) {
+ if (typeof pattern == "string") {
+ var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
+ var substr = this.string.substr(this.pos, pattern.length);
+ if (cased(substr) == cased(pattern)) {
+ if (consume !== false) this.pos += pattern.length;
+ return true;
+ }
+ } else {
+ var match = this.string.slice(this.pos).match(pattern);
+ if (match && match.index > 0) return null;
+ if (match && consume !== false) this.pos += match[0].length;
+ return match;
+ }
+ },
+ current: function(){return this.string.slice(this.start, this.pos);},
+ hideFirstChars: function(n, inner) {
+ this.lineStart += n;
+ try { return inner(); }
+ finally { this.lineStart -= n; }
+ }
+ };
+
+ // TEXTMARKERS
+
+ // Created with markText and setBookmark methods. A TextMarker is a
+ // handle that can be used to clear or find a marked position in the
+ // document. Line objects hold arrays (markedSpans) containing
+ // {from, to, marker} object pointing to such marker objects, and
+ // indicating that such a marker is present on that line. Multiple
+ // lines may point to the same marker when it spans across lines.
+ // The spans will have null for their from/to properties when the
+ // marker continues beyond the start/end of the line. Markers have
+ // links back to the lines they currently touch.
+
+ var TextMarker = CodeMirror.TextMarker = function(doc, type) {
+ this.lines = [];
+ this.type = type;
+ this.doc = doc;
+ };
+ eventMixin(TextMarker);
+
+ // Clear the marker.
+ TextMarker.prototype.clear = function() {
+ if (this.explicitlyCleared) return;
+ var cm = this.doc.cm, withOp = cm && !cm.curOp;
+ if (withOp) startOperation(cm);
+ if (hasHandler(this, "clear")) {
+ var found = this.find();
+ if (found) signalLater(this, "clear", found.from, found.to);
+ }
+ var min = null, max = null;
+ for (var i = 0; i < this.lines.length; ++i) {
+ var line = this.lines[i];
+ var span = getMarkedSpanFor(line.markedSpans, this);
+ if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
+ else if (cm) {
+ if (span.to != null) max = lineNo(line);
+ if (span.from != null) min = lineNo(line);
+ }
+ line.markedSpans = removeMarkedSpan(line.markedSpans, span);
+ if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
+ updateLineHeight(line, textHeight(cm.display));
+ }
+ if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
+ var visual = visualLine(this.lines[i]), len = lineLength(visual);
+ if (len > cm.display.maxLineLength) {
+ cm.display.maxLine = visual;
+ cm.display.maxLineLength = len;
+ cm.display.maxLineChanged = true;
+ }
+ }
+
+ if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
+ this.lines.length = 0;
+ this.explicitlyCleared = true;
+ if (this.atomic && this.doc.cantEdit) {
+ this.doc.cantEdit = false;
+ if (cm) reCheckSelection(cm.doc);
+ }
+ if (cm) signalLater(cm, "markerCleared", cm, this);
+ if (withOp) endOperation(cm);
+ if (this.parent) this.parent.clear();
+ };
+
+ // Find the position of the marker in the document. Returns a {from,
+ // to} object by default. Side can be passed to get a specific side
+ // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
+ // Pos objects returned contain a line object, rather than a line
+ // number (used to prevent looking up the same line twice).
+ TextMarker.prototype.find = function(side, lineObj) {
+ if (side == null && this.type == "bookmark") side = 1;
+ var from, to;
+ for (var i = 0; i < this.lines.length; ++i) {
+ var line = this.lines[i];
+ var span = getMarkedSpanFor(line.markedSpans, this);
+ if (span.from != null) {
+ from = Pos(lineObj ? line : lineNo(line), span.from);
+ if (side == -1) return from;
+ }
+ if (span.to != null) {
+ to = Pos(lineObj ? line : lineNo(line), span.to);
+ if (side == 1) return to;
+ }
+ }
+ return from && {from: from, to: to};
+ };
+
+ // Signals that the marker's widget changed, and surrounding layout
+ // should be recomputed.
+ TextMarker.prototype.changed = function() {
+ var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
+ if (!pos || !cm) return;
+ runInOp(cm, function() {
+ var line = pos.line, lineN = lineNo(pos.line);
+ var view = findViewForLine(cm, lineN);
+ if (view) {
+ clearLineMeasurementCacheFor(view);
+ cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
+ }
+ cm.curOp.updateMaxLine = true;
+ if (!lineIsHidden(widget.doc, line) && widget.height != null) {
+ var oldHeight = widget.height;
+ widget.height = null;
+ var dHeight = widgetHeight(widget) - oldHeight;
+ if (dHeight)
+ updateLineHeight(line, line.height + dHeight);
+ }
+ });
+ };
+
+ TextMarker.prototype.attachLine = function(line) {
+ if (!this.lines.length && this.doc.cm) {
+ var op = this.doc.cm.curOp;
+ if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
+ (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
+ }
+ this.lines.push(line);
+ };
+ TextMarker.prototype.detachLine = function(line) {
+ this.lines.splice(indexOf(this.lines, line), 1);
+ if (!this.lines.length && this.doc.cm) {
+ var op = this.doc.cm.curOp;
+ (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
+ }
+ };
+
+ // Collapsed markers have unique ids, in order to be able to order
+ // them, which is needed for uniquely determining an outer marker
+ // when they overlap (they may nest, but not partially overlap).
+ var nextMarkerId = 0;
+
+ // Create a marker, wire it up to the right lines, and
+ function markText(doc, from, to, options, type) {
+ // Shared markers (across linked documents) are handled separately
+ // (markTextShared will call out to this again, once per
+ // document).
+ if (options && options.shared) return markTextShared(doc, from, to, options, type);
+ // Ensure we are in an operation.
+ if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
+
+ var marker = new TextMarker(doc, type), diff = cmp(from, to);
+ if (options) copyObj(options, marker, false);
+ // Don't connect empty markers unless clearWhenEmpty is false
+ if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
+ return marker;
+ if (marker.replacedWith) {
+ // Showing up as a widget implies collapsed (widget replaces text)
+ marker.collapsed = true;
+ marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
+ if (!options.handleMouseEvents) marker.widgetNode.ignoreEvents = true;
+ if (options.insertLeft) marker.widgetNode.insertLeft = true;
+ }
+ if (marker.collapsed) {
+ if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
+ from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
+ throw new Error("Inserting collapsed marker partially overlapping an existing one");
+ sawCollapsedSpans = true;
+ }
+
+ if (marker.addToHistory)
+ addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
+
+ var curLine = from.line, cm = doc.cm, updateMaxLine;
+ doc.iter(curLine, to.line + 1, function(line) {
+ if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
+ updateMaxLine = true;
+ if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
+ addMarkedSpan(line, new MarkedSpan(marker,
+ curLine == from.line ? from.ch : null,
+ curLine == to.line ? to.ch : null));
+ ++curLine;
+ });
+ // lineIsHidden depends on the presence of the spans, so needs a second pass
+ if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
+ if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
+ });
+
+ if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
+
+ if (marker.readOnly) {
+ sawReadOnlySpans = true;
+ if (doc.history.done.length || doc.history.undone.length)
+ doc.clearHistory();
+ }
+ if (marker.collapsed) {
+ marker.id = ++nextMarkerId;
+ marker.atomic = true;
+ }
+ if (cm) {
+ // Sync editor state
+ if (updateMaxLine) cm.curOp.updateMaxLine = true;
+ if (marker.collapsed)
+ regChange(cm, from.line, to.line + 1);
+ else if (marker.className || marker.title || marker.startStyle || marker.endStyle)
+ for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
+ if (marker.atomic) reCheckSelection(cm.doc);
+ signalLater(cm, "markerAdded", cm, marker);
+ }
+ return marker;
+ }
+
+ // SHARED TEXTMARKERS
+
+ // A shared marker spans multiple linked documents. It is
+ // implemented as a meta-marker-object controlling multiple normal
+ // markers.
+ var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
+ this.markers = markers;
+ this.primary = primary;
+ for (var i = 0; i < markers.length; ++i)
+ markers[i].parent = this;
+ };
+ eventMixin(SharedTextMarker);
+
+ SharedTextMarker.prototype.clear = function() {
+ if (this.explicitlyCleared) return;
+ this.explicitlyCleared = true;
+ for (var i = 0; i < this.markers.length; ++i)
+ this.markers[i].clear();
+ signalLater(this, "clear");
+ };
+ SharedTextMarker.prototype.find = function(side, lineObj) {
+ return this.primary.find(side, lineObj);
+ };
+
+ function markTextShared(doc, from, to, options, type) {
+ options = copyObj(options);
+ options.shared = false;
+ var markers = [markText(doc, from, to, options, type)], primary = markers[0];
+ var widget = options.widgetNode;
+ linkedDocs(doc, function(doc) {
+ if (widget) options.widgetNode = widget.cloneNode(true);
+ markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
+ for (var i = 0; i < doc.linked.length; ++i)
+ if (doc.linked[i].isParent) return;
+ primary = lst(markers);
+ });
+ return new SharedTextMarker(markers, primary);
+ }
+
+ function findSharedMarkers(doc) {
+ return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
+ function(m) { return m.parent; });
+ }
+
+ function copySharedMarkers(doc, markers) {
+ for (var i = 0; i < markers.length; i++) {
+ var marker = markers[i], pos = marker.find();
+ var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
+ if (cmp(mFrom, mTo)) {
+ var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
+ marker.markers.push(subMark);
+ subMark.parent = marker;
+ }
+ }
+ }
+
+ function detachSharedMarkers(markers) {
+ for (var i = 0; i < markers.length; i++) {
+ var marker = markers[i], linked = [marker.primary.doc];;
+ linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
+ for (var j = 0; j < marker.markers.length; j++) {
+ var subMarker = marker.markers[j];
+ if (indexOf(linked, subMarker.doc) == -1) {
+ subMarker.parent = null;
+ marker.markers.splice(j--, 1);
+ }
+ }
+ }
+ }
+
+ // TEXTMARKER SPANS
+
+ function MarkedSpan(marker, from, to) {
+ this.marker = marker;
+ this.from = from; this.to = to;
+ }
+
+ // Search an array of spans for a span matching the given marker.
+ function getMarkedSpanFor(spans, marker) {
+ if (spans) for (var i = 0; i < spans.length; ++i) {
+ var span = spans[i];
+ if (span.marker == marker) return span;
+ }
+ }
+ // Remove a span from an array, returning undefined if no spans are
+ // left (we don't store arrays for lines without spans).
+ function removeMarkedSpan(spans, span) {
+ for (var r, i = 0; i < spans.length; ++i)
+ if (spans[i] != span) (r || (r = [])).push(spans[i]);
+ return r;
+ }
+ // Add a span to a line.
+ function addMarkedSpan(line, span) {
+ line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
+ span.marker.attachLine(line);
+ }
+
+ // Used for the algorithm that adjusts markers for a change in the
+ // document. These functions cut an array of spans at a given
+ // character position, returning an array of remaining chunks (or
+ // undefined if nothing remains).
+ function markedSpansBefore(old, startCh, isInsert) {
+ if (old) for (var i = 0, nw; i < old.length; ++i) {
+ var span = old[i], marker = span.marker;
+ var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
+ if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
+ var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
+ (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
+ }
+ }
+ return nw;
+ }
+ function markedSpansAfter(old, endCh, isInsert) {
+ if (old) for (var i = 0, nw; i < old.length; ++i) {
+ var span = old[i], marker = span.marker;
+ var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
+ if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
+ var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
+ (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
+ span.to == null ? null : span.to - endCh));
+ }
+ }
+ return nw;
+ }
+
+ // Given a change object, compute the new set of marker spans that
+ // cover the line in which the change took place. Removes spans
+ // entirely within the change, reconnects spans belonging to the
+ // same marker that appear on both sides of the change, and cuts off
+ // spans partially within the change. Returns an array of span
+ // arrays with one element for each line in (after) the change.
+ function stretchSpansOverChange(doc, change) {
+ var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
+ var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
+ if (!oldFirst && !oldLast) return null;
+
+ var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
+ // Get the spans that 'stick out' on both sides
+ var first = markedSpansBefore(oldFirst, startCh, isInsert);
+ var last = markedSpansAfter(oldLast, endCh, isInsert);
+
+ // Next, merge those two ends
+ var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
+ if (first) {
+ // Fix up .to properties of first
+ for (var i = 0; i < first.length; ++i) {
+ var span = first[i];
+ if (span.to == null) {
+ var found = getMarkedSpanFor(last, span.marker);
+ if (!found) span.to = startCh;
+ else if (sameLine) span.to = found.to == null ? null : found.to + offset;
+ }
+ }
+ }
+ if (last) {
+ // Fix up .from in last (or move them into first in case of sameLine)
+ for (var i = 0; i < last.length; ++i) {
+ var span = last[i];
+ if (span.to != null) span.to += offset;
+ if (span.from == null) {
+ var found = getMarkedSpanFor(first, span.marker);
+ if (!found) {
+ span.from = offset;
+ if (sameLine) (first || (first = [])).push(span);
+ }
+ } else {
+ span.from += offset;
+ if (sameLine) (first || (first = [])).push(span);
+ }
+ }
+ }
+ // Make sure we didn't create any zero-length spans
+ if (first) first = clearEmptySpans(first);
+ if (last && last != first) last = clearEmptySpans(last);
+
+ var newMarkers = [first];
+ if (!sameLine) {
+ // Fill gap with whole-line-spans
+ var gap = change.text.length - 2, gapMarkers;
+ if (gap > 0 && first)
+ for (var i = 0; i < first.length; ++i)
+ if (first[i].to == null)
+ (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
+ for (var i = 0; i < gap; ++i)
+ newMarkers.push(gapMarkers);
+ newMarkers.push(last);
+ }
+ return newMarkers;
+ }
+
+ // Remove spans that are empty and don't have a clearWhenEmpty
+ // option of false.
+ function clearEmptySpans(spans) {
+ for (var i = 0; i < spans.length; ++i) {
+ var span = spans[i];
+ if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
+ spans.splice(i--, 1);
+ }
+ if (!spans.length) return null;
+ return spans;
+ }
+
+ // Used for un/re-doing changes from the history. Combines the
+ // result of computing the existing spans with the set of spans that
+ // existed in the history (so that deleting around a span and then
+ // undoing brings back the span).
+ function mergeOldSpans(doc, change) {
+ var old = getOldSpans(doc, change);
+ var stretched = stretchSpansOverChange(doc, change);
+ if (!old) return stretched;
+ if (!stretched) return old;
+
+ for (var i = 0; i < old.length; ++i) {
+ var oldCur = old[i], stretchCur = stretched[i];
+ if (oldCur && stretchCur) {
+ spans: for (var j = 0; j < stretchCur.length; ++j) {
+ var span = stretchCur[j];
+ for (var k = 0; k < oldCur.length; ++k)
+ if (oldCur[k].marker == span.marker) continue spans;
+ oldCur.push(span);
+ }
+ } else if (stretchCur) {
+ old[i] = stretchCur;
+ }
+ }
+ return old;
+ }
+
+ // Used to 'clip' out readOnly ranges when making a change.
+ function removeReadOnlyRanges(doc, from, to) {
+ var markers = null;
+ doc.iter(from.line, to.line + 1, function(line) {
+ if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
+ var mark = line.markedSpans[i].marker;
+ if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
+ (markers || (markers = [])).push(mark);
+ }
+ });
+ if (!markers) return null;
+ var parts = [{from: from, to: to}];
+ for (var i = 0; i < markers.length; ++i) {
+ var mk = markers[i], m = mk.find(0);
+ for (var j = 0; j < parts.length; ++j) {
+ var p = parts[j];
+ if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
+ var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
+ if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
+ newParts.push({from: p.from, to: m.from});
+ if (dto > 0 || !mk.inclusiveRight && !dto)
+ newParts.push({from: m.to, to: p.to});
+ parts.splice.apply(parts, newParts);
+ j += newParts.length - 1;
+ }
+ }
+ return parts;
+ }
+
+ // Connect or disconnect spans from a line.
+ function detachMarkedSpans(line) {
+ var spans = line.markedSpans;
+ if (!spans) return;
+ for (var i = 0; i < spans.length; ++i)
+ spans[i].marker.detachLine(line);
+ line.markedSpans = null;
+ }
+ function attachMarkedSpans(line, spans) {
+ if (!spans) return;
+ for (var i = 0; i < spans.length; ++i)
+ spans[i].marker.attachLine(line);
+ line.markedSpans = spans;
+ }
+
+ // Helpers used when computing which overlapping collapsed span
+ // counts as the larger one.
+ function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
+ function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
+
+ // Returns a number indicating which of two overlapping collapsed
+ // spans is larger (and thus includes the other). Falls back to
+ // comparing ids when the spans cover exactly the same range.
+ function compareCollapsedMarkers(a, b) {
+ var lenDiff = a.lines.length - b.lines.length;
+ if (lenDiff != 0) return lenDiff;
+ var aPos = a.find(), bPos = b.find();
+ var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
+ if (fromCmp) return -fromCmp;
+ var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
+ if (toCmp) return toCmp;
+ return b.id - a.id;
+ }
+
+ // Find out whether a line ends or starts in a collapsed span. If
+ // so, return the marker for that span.
+ function collapsedSpanAtSide(line, start) {
+ var sps = sawCollapsedSpans && line.markedSpans, found;
+ if (sps) for (var sp, i = 0; i < sps.length; ++i) {
+ sp = sps[i];
+ if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
+ (!found || compareCollapsedMarkers(found, sp.marker) < 0))
+ found = sp.marker;
+ }
+ return found;
+ }
+ function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
+ function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
+
+ // Test whether there exists a collapsed span that partially
+ // overlaps (covers the start or end, but not both) of a new span.
+ // Such overlap is not allowed.
+ function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
+ var line = getLine(doc, lineNo);
+ var sps = sawCollapsedSpans && line.markedSpans;
+ if (sps) for (var i = 0; i < sps.length; ++i) {
+ var sp = sps[i];
+ if (!sp.marker.collapsed) continue;
+ var found = sp.marker.find(0);
+ var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
+ var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
+ if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
+ if (fromCmp <= 0 && (cmp(found.to, from) || extraRight(sp.marker) - extraLeft(marker)) > 0 ||
+ fromCmp >= 0 && (cmp(found.from, to) || extraLeft(sp.marker) - extraRight(marker)) < 0)
+ return true;
+ }
+ }
+
+ // A visual line is a line as drawn on the screen. Folding, for
+ // example, can cause multiple logical lines to appear on the same
+ // visual line. This finds the start of the visual line that the
+ // given line is part of (usually that is the line itself).
+ function visualLine(line) {
+ var merged;
+ while (merged = collapsedSpanAtStart(line))
+ line = merged.find(-1, true).line;
+ return line;
+ }
+
+ // Returns an array of logical lines that continue the visual line
+ // started by the argument, or undefined if there are no such lines.
+ function visualLineContinued(line) {
+ var merged, lines;
+ while (merged = collapsedSpanAtEnd(line)) {
+ line = merged.find(1, true).line;
+ (lines || (lines = [])).push(line);
+ }
+ return lines;
+ }
+
+ // Get the line number of the start of the visual line that the
+ // given line number is part of.
+ function visualLineNo(doc, lineN) {
+ var line = getLine(doc, lineN), vis = visualLine(line);
+ if (line == vis) return lineN;
+ return lineNo(vis);
+ }
+ // Get the line number of the start of the next visual line after
+ // the given line.
+ function visualLineEndNo(doc, lineN) {
+ if (lineN > doc.lastLine()) return lineN;
+ var line = getLine(doc, lineN), merged;
+ if (!lineIsHidden(doc, line)) return lineN;
+ while (merged = collapsedSpanAtEnd(line))
+ line = merged.find(1, true).line;
+ return lineNo(line) + 1;
+ }
+
+ // Compute whether a line is hidden. Lines count as hidden when they
+ // are part of a visual line that starts with another line, or when
+ // they are entirely covered by collapsed, non-widget span.
+ function lineIsHidden(doc, line) {
+ var sps = sawCollapsedSpans && line.markedSpans;
+ if (sps) for (var sp, i = 0; i < sps.length; ++i) {
+ sp = sps[i];
+ if (!sp.marker.collapsed) continue;
+ if (sp.from == null) return true;
+ if (sp.marker.widgetNode) continue;
+ if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
+ return true;
+ }
+ }
+ function lineIsHiddenInner(doc, line, span) {
+ if (span.to == null) {
+ var end = span.marker.find(1, true);
+ return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
+ }
+ if (span.marker.inclusiveRight && span.to == line.text.length)
+ return true;
+ for (var sp, i = 0; i < line.markedSpans.length; ++i) {
+ sp = line.markedSpans[i];
+ if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
+ (sp.to == null || sp.to != span.from) &&
+ (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
+ lineIsHiddenInner(doc, line, sp)) return true;
+ }
+ }
+
+ // LINE WIDGETS
+
+ // Line widgets are block elements displayed above or below a line.
+
+ var LineWidget = CodeMirror.LineWidget = function(cm, node, options) {
+ if (options) for (var opt in options) if (options.hasOwnProperty(opt))
+ this[opt] = options[opt];
+ this.cm = cm;
+ this.node = node;
+ };
+ eventMixin(LineWidget);
+
+ function adjustScrollWhenAboveVisible(cm, line, diff) {
+ if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
+ addToScrollPos(cm, null, diff);
+ }
+
+ LineWidget.prototype.clear = function() {
+ var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
+ if (no == null || !ws) return;
+ for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
+ if (!ws.length) line.widgets = null;
+ var height = widgetHeight(this);
+ runInOp(cm, function() {
+ adjustScrollWhenAboveVisible(cm, line, -height);
+ regLineChange(cm, no, "widget");
+ updateLineHeight(line, Math.max(0, line.height - height));
+ });
+ };
+ LineWidget.prototype.changed = function() {
+ var oldH = this.height, cm = this.cm, line = this.line;
+ this.height = null;
+ var diff = widgetHeight(this) - oldH;
+ if (!diff) return;
+ runInOp(cm, function() {
+ cm.curOp.forceUpdate = true;
+ adjustScrollWhenAboveVisible(cm, line, diff);
+ updateLineHeight(line, line.height + diff);
+ });
+ };
+
+ function widgetHeight(widget) {
+ if (widget.height != null) return widget.height;
+ if (!contains(document.body, widget.node))
+ removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, "position: relative"));
+ return widget.height = widget.node.offsetHeight;
+ }
+
+ function addLineWidget(cm, handle, node, options) {
+ var widget = new LineWidget(cm, node, options);
+ if (widget.noHScroll) cm.display.alignWidgets = true;
+ changeLine(cm, handle, "widget", function(line) {
+ var widgets = line.widgets || (line.widgets = []);
+ if (widget.insertAt == null) widgets.push(widget);
+ else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
+ widget.line = line;
+ if (!lineIsHidden(cm.doc, line)) {
+ var aboveVisible = heightAtLine(line) < cm.doc.scrollTop;
+ updateLineHeight(line, line.height + widgetHeight(widget));
+ if (aboveVisible) addToScrollPos(cm, null, widget.height);
+ cm.curOp.forceUpdate = true;
+ }
+ return true;
+ });
+ return widget;
+ }
+
+ // LINE DATA STRUCTURE
+
+ // Line objects. These hold state related to a line, including
+ // highlighting info (the styles array).
+ var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
+ this.text = text;
+ attachMarkedSpans(this, markedSpans);
+ this.height = estimateHeight ? estimateHeight(this) : 1;
+ };
+ eventMixin(Line);
+ Line.prototype.lineNo = function() { return lineNo(this); };
+
+ // Change the content (text, markers) of a line. Automatically
+ // invalidates cached information and tries to re-estimate the
+ // line's height.
+ function updateLine(line, text, markedSpans, estimateHeight) {
+ line.text = text;
+ if (line.stateAfter) line.stateAfter = null;
+ if (line.styles) line.styles = null;
+ if (line.order != null) line.order = null;
+ detachMarkedSpans(line);
+ attachMarkedSpans(line, markedSpans);
+ var estHeight = estimateHeight ? estimateHeight(line) : 1;
+ if (estHeight != line.height) updateLineHeight(line, estHeight);
+ }
+
+ // Detach a line from the document tree and its markers.
+ function cleanUpLine(line) {
+ line.parent = null;
+ detachMarkedSpans(line);
+ }
+
+ function extractLineClasses(type, output) {
+ if (type) for (;;) {
+ var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
+ if (!lineClass) break;
+ type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
+ var prop = lineClass[1] ? "bgClass" : "textClass";
+ if (output[prop] == null)
+ output[prop] = lineClass[2];
+ else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
+ output[prop] += " " + lineClass[2];
+ }
+ return type;
+ }
+
+ function callBlankLine(mode, state) {
+ if (mode.blankLine) return mode.blankLine(state);
+ if (!mode.innerMode) return;
+ var inner = CodeMirror.innerMode(mode, state);
+ if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
+ }
+
+ function readToken(mode, stream, state) {
+ var style = mode.token(stream, state);
+ if (stream.pos <= stream.start)
+ throw new Error("Mode " + mode.name + " failed to advance stream.");
+ return style;
+ }
+
+ // Run the given mode's parser over a line, calling f for each token.
+ function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
+ var flattenSpans = mode.flattenSpans;
+ if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
+ var curStart = 0, curStyle = null;
+ var stream = new StringStream(text, cm.options.tabSize), style;
+ if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
+ while (!stream.eol()) {
+ if (stream.pos > cm.options.maxHighlightLength) {
+ flattenSpans = false;
+ if (forceToEnd) processLine(cm, text, state, stream.pos);
+ stream.pos = text.length;
+ style = null;
+ } else {
+ style = extractLineClasses(readToken(mode, stream, state), lineClasses);
+ }
+ if (cm.options.addModeClass) {
+ var mName = CodeMirror.innerMode(mode, state).mode.name;
+ if (mName) style = "m-" + (style ? mName + " " + style : mName);
+ }
+ if (!flattenSpans || curStyle != style) {
+ if (curStart < stream.start) f(stream.start, curStyle);
+ curStart = stream.start; curStyle = style;
+ }
+ stream.start = stream.pos;
+ }
+ while (curStart < stream.pos) {
+ // Webkit seems to refuse to render text nodes longer than 57444 characters
+ var pos = Math.min(stream.pos, curStart + 50000);
+ f(pos, curStyle);
+ curStart = pos;
+ }
+ }
+
+ // Compute a style array (an array starting with a mode generation
+ // -- for invalidation -- followed by pairs of end positions and
+ // style strings), which is used to highlight the tokens on the
+ // line.
+ function highlightLine(cm, line, state, forceToEnd) {
+ // A styles array always starts with a number identifying the
+ // mode/overlays that it is based on (for easy invalidation).
+ var st = [cm.state.modeGen], lineClasses = {};
+ // Compute the base array of styles
+ runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
+ st.push(end, style);
+ }, lineClasses, forceToEnd);
+
+ // Run overlays, adjust style array.
+ for (var o = 0; o < cm.state.overlays.length; ++o) {
+ var overlay = cm.state.overlays[o], i = 1, at = 0;
+ runMode(cm, line.text, overlay.mode, true, function(end, style) {
+ var start = i;
+ // Ensure there's a token end at the current position, and that i points at it
+ while (at < end) {
+ var i_end = st[i];
+ if (i_end > end)
+ st.splice(i, 1, end, st[i+1], i_end);
+ i += 2;
+ at = Math.min(end, i_end);
+ }
+ if (!style) return;
+ if (overlay.opaque) {
+ st.splice(start, i - start, end, "cm-overlay " + style);
+ i = start + 2;
+ } else {
+ for (; start < i; start += 2) {
+ var cur = st[start+1];
+ st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
+ }
+ }
+ }, lineClasses);
+ }
+
+ return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
+ }
+
+ function getLineStyles(cm, line) {
+ if (!line.styles || line.styles[0] != cm.state.modeGen) {
+ var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
+ line.styles = result.styles;
+ if (result.classes) line.styleClasses = result.classes;
+ else if (line.styleClasses) line.styleClasses = null;
+ }
+ return line.styles;
+ }
+
+ // Lightweight form of highlight -- proceed over this line and
+ // update state, but don't save a style array. Used for lines that
+ // aren't currently visible.
+ function processLine(cm, text, state, startAt) {
+ var mode = cm.doc.mode;
+ var stream = new StringStream(text, cm.options.tabSize);
+ stream.start = stream.pos = startAt || 0;
+ if (text == "") callBlankLine(mode, state);
+ while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) {
+ readToken(mode, stream, state);
+ stream.start = stream.pos;
+ }
+ }
+
+ // Convert a style as returned by a mode (either null, or a string
+ // containing one or more styles) to a CSS style. This is cached,
+ // and also looks for line-wide styles.
+ var styleToClassCache = {}, styleToClassCacheWithMode = {};
+ function interpretTokenStyle(style, options) {
+ if (!style || /^\s*$/.test(style)) return null;
+ var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
+ return cache[style] ||
+ (cache[style] = style.replace(/\S+/g, "cm-$&"));
+ }
+
+ // Render the DOM representation of the text of a line. Also builds
+ // up a 'line map', which points at the DOM nodes that represent
+ // specific stretches of text, and is used by the measuring code.
+ // The returned object contains the DOM node, this map, and
+ // information about line-wide styles that were set by the mode.
+ function buildLineContent(cm, lineView) {
+ // The padding-right forces the element to have a 'border', which
+ // is needed on Webkit to be able to get line-level bounding
+ // rectangles for it (in measureChar).
+ var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
+ var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm};
+ lineView.measure = {};
+
+ // Iterate over the logical lines that make up this visual line.
+ for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
+ var line = i ? lineView.rest[i - 1] : lineView.line, order;
+ builder.pos = 0;
+ builder.addToken = buildToken;
+ // Optionally wire in some hacks into the token-rendering
+ // algorithm, to deal with browser quirks.
+ if ((ie || webkit) && cm.getOption("lineWrapping"))
+ builder.addToken = buildTokenSplitSpaces(builder.addToken);
+ if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
+ builder.addToken = buildTokenBadBidi(builder.addToken, order);
+ builder.map = [];
+ insertLineContent(line, builder, getLineStyles(cm, line));
+ if (line.styleClasses) {
+ if (line.styleClasses.bgClass)
+ builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
+ if (line.styleClasses.textClass)
+ builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
+ }
+
+ // Ensure at least a single node is present, for measuring.
+ if (builder.map.length == 0)
+ builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
+
+ // Store the map and a cache object for the current logical line
+ if (i == 0) {
+ lineView.measure.map = builder.map;
+ lineView.measure.cache = {};
+ } else {
+ (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
+ (lineView.measure.caches || (lineView.measure.caches = [])).push({});
+ }
+ }
+
+ signal(cm, "renderLine", cm, lineView.line, builder.pre);
+ return builder;
+ }
+
+ function defaultSpecialCharPlaceholder(ch) {
+ var token = elt("span", "\u2022", "cm-invalidchar");
+ token.title = "\\u" + ch.charCodeAt(0).toString(16);
+ return token;
+ }
+
+ // Build up the DOM representation for a single token, and add it to
+ // the line map. Takes care to render special characters separately.
+ function buildToken(builder, text, style, startStyle, endStyle, title) {
+ if (!text) return;
+ var special = builder.cm.options.specialChars, mustWrap = false;
+ if (!special.test(text)) {
+ builder.col += text.length;
+ var content = document.createTextNode(text);
+ builder.map.push(builder.pos, builder.pos + text.length, content);
+ if (ie_upto8) mustWrap = true;
+ builder.pos += text.length;
+ } else {
+ var content = document.createDocumentFragment(), pos = 0;
+ while (true) {
+ special.lastIndex = pos;
+ var m = special.exec(text);
+ var skipped = m ? m.index - pos : text.length - pos;
+ if (skipped) {
+ var txt = document.createTextNode(text.slice(pos, pos + skipped));
+ if (ie_upto8) content.appendChild(elt("span", [txt]));
+ else content.appendChild(txt);
+ builder.map.push(builder.pos, builder.pos + skipped, txt);
+ builder.col += skipped;
+ builder.pos += skipped;
+ }
+ if (!m) break;
+ pos += skipped + 1;
+ if (m[0] == "\t") {
+ var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
+ var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
+ builder.col += tabWidth;
+ } else {
+ var txt = builder.cm.options.specialCharPlaceholder(m[0]);
+ if (ie_upto8) content.appendChild(elt("span", [txt]));
+ else content.appendChild(txt);
+ builder.col += 1;
+ }
+ builder.map.push(builder.pos, builder.pos + 1, txt);
+ builder.pos++;
+ }
+ }
+ if (style || startStyle || endStyle || mustWrap) {
+ var fullStyle = style || "";
+ if (startStyle) fullStyle += startStyle;
+ if (endStyle) fullStyle += endStyle;
+ var token = elt("span", [content], fullStyle);
+ if (title) token.title = title;
+ return builder.content.appendChild(token);
+ }
+ builder.content.appendChild(content);
+ }
+
+ function buildTokenSplitSpaces(inner) {
+ function split(old) {
+ var out = " ";
+ for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
+ out += " ";
+ return out;
+ }
+ return function(builder, text, style, startStyle, endStyle, title) {
+ inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title);
+ };
+ }
+
+ // Work around nonsense dimensions being reported for stretches of
+ // right-to-left text.
+ function buildTokenBadBidi(inner, order) {
+ return function(builder, text, style, startStyle, endStyle, title) {
+ style = style ? style + " cm-force-border" : "cm-force-border";
+ var start = builder.pos, end = start + text.length;
+ for (;;) {
+ // Find the part that overlaps with the start of this text
+ for (var i = 0; i < order.length; i++) {
+ var part = order[i];
+ if (part.to > start && part.from <= start) break;
+ }
+ if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title);
+ inner(builder, text.slice(0, part.to - start), style, startStyle, null, title);
+ startStyle = null;
+ text = text.slice(part.to - start);
+ start = part.to;
+ }
+ };
+ }
+
+ function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
+ var widget = !ignoreWidget && marker.widgetNode;
+ if (widget) {
+ builder.map.push(builder.pos, builder.pos + size, widget);
+ builder.content.appendChild(widget);
+ }
+ builder.pos += size;
+ }
+
+ // Outputs a number of spans to make up a line, taking highlighting
+ // and marked text into account.
+ function insertLineContent(line, builder, styles) {
+ var spans = line.markedSpans, allText = line.text, at = 0;
+ if (!spans) {
+ for (var i = 1; i < styles.length; i+=2)
+ builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
+ return;
+ }
+
+ var len = allText.length, pos = 0, i = 1, text = "", style;
+ var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
+ for (;;) {
+ if (nextChange == pos) { // Update current marker set
+ spanStyle = spanEndStyle = spanStartStyle = title = "";
+ collapsed = null; nextChange = Infinity;
+ var foundBookmarks = [];
+ for (var j = 0; j < spans.length; ++j) {
+ var sp = spans[j], m = sp.marker;
+ if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
+ if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
+ if (m.className) spanStyle += " " + m.className;
+ if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
+ if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
+ if (m.title && !title) title = m.title;
+ if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
+ collapsed = sp;
+ } else if (sp.from > pos && nextChange > sp.from) {
+ nextChange = sp.from;
+ }
+ if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m);
+ }
+ if (collapsed && (collapsed.from || 0) == pos) {
+ buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
+ collapsed.marker, collapsed.from == null);
+ if (collapsed.to == null) return;
+ }
+ if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j)
+ buildCollapsedSpan(builder, 0, foundBookmarks[j]);
+ }
+ if (pos >= len) break;
+
+ var upto = Math.min(len, nextChange);
+ while (true) {
+ if (text) {
+ var end = pos + text.length;
+ if (!collapsed) {
+ var tokenText = end > upto ? text.slice(0, upto - pos) : text;
+ builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
+ spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title);
+ }
+ if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
+ pos = end;
+ spanStartStyle = "";
+ }
+ text = allText.slice(at, at = styles[i++]);
+ style = interpretTokenStyle(styles[i++], builder.cm.options);
+ }
+ }
+ }
+
+ // DOCUMENT DATA STRUCTURE
+
+ // By default, updates that start and end at the beginning of a line
+ // are treated specially, in order to make the association of line
+ // widgets and marker elements with the text behave more intuitive.
+ function isWholeLineUpdate(doc, change) {
+ return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
+ (!doc.cm || doc.cm.options.wholeLineUpdateBefore);
+ }
+
+ // Perform a change on the document data structure.
+ function updateDoc(doc, change, markedSpans, estimateHeight) {
+ function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
+ function update(line, text, spans) {
+ updateLine(line, text, spans, estimateHeight);
+ signalLater(line, "change", line, change);
+ }
+
+ var from = change.from, to = change.to, text = change.text;
+ var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
+ var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
+
+ // Adjust the line structure
+ if (isWholeLineUpdate(doc, change)) {
+ // This is a whole-line replace. Treated specially to make
+ // sure line objects move the way they are supposed to.
+ for (var i = 0, added = []; i < text.length - 1; ++i)
+ added.push(new Line(text[i], spansFor(i), estimateHeight));
+ update(lastLine, lastLine.text, lastSpans);
+ if (nlines) doc.remove(from.line, nlines);
+ if (added.length) doc.insert(from.line, added);
+ } else if (firstLine == lastLine) {
+ if (text.length == 1) {
+ update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
+ } else {
+ for (var added = [], i = 1; i < text.length - 1; ++i)
+ added.push(new Line(text[i], spansFor(i), estimateHeight));
+ added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
+ doc.insert(from.line + 1, added);
+ }
+ } else if (text.length == 1) {
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
+ doc.remove(from.line + 1, nlines);
+ } else {
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
+ update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
+ for (var i = 1, added = []; i < text.length - 1; ++i)
+ added.push(new Line(text[i], spansFor(i), estimateHeight));
+ if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
+ doc.insert(from.line + 1, added);
+ }
+
+ signalLater(doc, "change", doc, change);
+ }
+
+ // The document is represented as a BTree consisting of leaves, with
+ // chunk of lines in them, and branches, with up to ten leaves or
+ // other branch nodes below them. The top node is always a branch
+ // node, and is the document object itself (meaning it has
+ // additional methods and properties).
+ //
+ // All nodes have parent links. The tree is used both to go from
+ // line numbers to line objects, and to go from objects to numbers.
+ // It also indexes by height, and is used to convert between height
+ // and line object, and to find the total height of the document.
+ //
+ // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
+
+ function LeafChunk(lines) {
+ this.lines = lines;
+ this.parent = null;
+ for (var i = 0, height = 0; i < lines.length; ++i) {
+ lines[i].parent = this;
+ height += lines[i].height;
+ }
+ this.height = height;
+ }
+
+ LeafChunk.prototype = {
+ chunkSize: function() { return this.lines.length; },
+ // Remove the n lines at offset 'at'.
+ removeInner: function(at, n) {
+ for (var i = at, e = at + n; i < e; ++i) {
+ var line = this.lines[i];
+ this.height -= line.height;
+ cleanUpLine(line);
+ signalLater(line, "delete");
+ }
+ this.lines.splice(at, n);
+ },
+ // Helper used to collapse a small branch into a single leaf.
+ collapse: function(lines) {
+ lines.push.apply(lines, this.lines);
+ },
+ // Insert the given array of lines at offset 'at', count them as
+ // having the given height.
+ insertInner: function(at, lines, height) {
+ this.height += height;
+ this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
+ for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
+ },
+ // Used to iterate over a part of the tree.
+ iterN: function(at, n, op) {
+ for (var e = at + n; at < e; ++at)
+ if (op(this.lines[at])) return true;
+ }
+ };
+
+ function BranchChunk(children) {
+ this.children = children;
+ var size = 0, height = 0;
+ for (var i = 0; i < children.length; ++i) {
+ var ch = children[i];
+ size += ch.chunkSize(); height += ch.height;
+ ch.parent = this;
+ }
+ this.size = size;
+ this.height = height;
+ this.parent = null;
+ }
+
+ BranchChunk.prototype = {
+ chunkSize: function() { return this.size; },
+ removeInner: function(at, n) {
+ this.size -= n;
+ for (var i = 0; i < this.children.length; ++i) {
+ var child = this.children[i], sz = child.chunkSize();
+ if (at < sz) {
+ var rm = Math.min(n, sz - at), oldHeight = child.height;
+ child.removeInner(at, rm);
+ this.height -= oldHeight - child.height;
+ if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
+ if ((n -= rm) == 0) break;
+ at = 0;
+ } else at -= sz;
+ }
+ // If the result is smaller than 25 lines, ensure that it is a
+ // single leaf node.
+ if (this.size - n < 25 &&
+ (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
+ var lines = [];
+ this.collapse(lines);
+ this.children = [new LeafChunk(lines)];
+ this.children[0].parent = this;
+ }
+ },
+ collapse: function(lines) {
+ for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
+ },
+ insertInner: function(at, lines, height) {
+ this.size += lines.length;
+ this.height += height;
+ for (var i = 0; i < this.children.length; ++i) {
+ var child = this.children[i], sz = child.chunkSize();
+ if (at <= sz) {
+ child.insertInner(at, lines, height);
+ if (child.lines && child.lines.length > 50) {
+ while (child.lines.length > 50) {
+ var spilled = child.lines.splice(child.lines.length - 25, 25);
+ var newleaf = new LeafChunk(spilled);
+ child.height -= newleaf.height;
+ this.children.splice(i + 1, 0, newleaf);
+ newleaf.parent = this;
+ }
+ this.maybeSpill();
+ }
+ break;
+ }
+ at -= sz;
+ }
+ },
+ // When a node has grown, check whether it should be split.
+ maybeSpill: function() {
+ if (this.children.length <= 10) return;
+ var me = this;
+ do {
+ var spilled = me.children.splice(me.children.length - 5, 5);
+ var sibling = new BranchChunk(spilled);
+ if (!me.parent) { // Become the parent node
+ var copy = new BranchChunk(me.children);
+ copy.parent = me;
+ me.children = [copy, sibling];
+ me = copy;
+ } else {
+ me.size -= sibling.size;
+ me.height -= sibling.height;
+ var myIndex = indexOf(me.parent.children, me);
+ me.parent.children.splice(myIndex + 1, 0, sibling);
+ }
+ sibling.parent = me.parent;
+ } while (me.children.length > 10);
+ me.parent.maybeSpill();
+ },
+ iterN: function(at, n, op) {
+ for (var i = 0; i < this.children.length; ++i) {
+ var child = this.children[i], sz = child.chunkSize();
+ if (at < sz) {
+ var used = Math.min(n, sz - at);
+ if (child.iterN(at, used, op)) return true;
+ if ((n -= used) == 0) break;
+ at = 0;
+ } else at -= sz;
+ }
+ }
+ };
+
+ var nextDocId = 0;
+ var Doc = CodeMirror.Doc = function(text, mode, firstLine) {
+ if (!(this instanceof Doc)) return new Doc(text, mode, firstLine);
+ if (firstLine == null) firstLine = 0;
+
+ BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
+ this.first = firstLine;
+ this.scrollTop = this.scrollLeft = 0;
+ this.cantEdit = false;
+ this.cleanGeneration = 1;
+ this.frontier = firstLine;
+ var start = Pos(firstLine, 0);
+ this.sel = simpleSelection(start);
+ this.history = new History(null);
+ this.id = ++nextDocId;
+ this.modeOption = mode;
+
+ if (typeof text == "string") text = splitLines(text);
+ updateDoc(this, {from: start, to: start, text: text});
+ setSelection(this, simpleSelection(start), sel_dontScroll);
+ };
+
+ Doc.prototype = createObj(BranchChunk.prototype, {
+ constructor: Doc,
+ // Iterate over the document. Supports two forms -- with only one
+ // argument, it calls that for each line in the document. With
+ // three, it iterates over the range given by the first two (with
+ // the second being non-inclusive).
+ iter: function(from, to, op) {
+ if (op) this.iterN(from - this.first, to - from, op);
+ else this.iterN(this.first, this.first + this.size, from);
+ },
+
+ // Non-public interface for adding and removing lines.
+ insert: function(at, lines) {
+ var height = 0;
+ for (var i = 0; i < lines.length; ++i) height += lines[i].height;
+ this.insertInner(at - this.first, lines, height);
+ },
+ remove: function(at, n) { this.removeInner(at - this.first, n); },
+
+ // From here, the methods are part of the public interface. Most
+ // are also available from CodeMirror (editor) instances.
+
+ getValue: function(lineSep) {
+ var lines = getLines(this, this.first, this.first + this.size);
+ if (lineSep === false) return lines;
+ return lines.join(lineSep || "\n");
+ },
+ setValue: docMethodOp(function(code) {
+ var top = Pos(this.first, 0), last = this.first + this.size - 1;
+ makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
+ text: splitLines(code), origin: "setValue"}, true);
+ setSelection(this, simpleSelection(top));
+ }),
+ replaceRange: function(code, from, to, origin) {
+ from = clipPos(this, from);
+ to = to ? clipPos(this, to) : from;
+ replaceRange(this, code, from, to, origin);
+ },
+ getRange: function(from, to, lineSep) {
+ var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
+ if (lineSep === false) return lines;
+ return lines.join(lineSep || "\n");
+ },
+
+ getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
+
+ getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
+ getLineNumber: function(line) {return lineNo(line);},
+
+ getLineHandleVisualStart: function(line) {
+ if (typeof line == "number") line = getLine(this, line);
+ return visualLine(line);
+ },
+
+ lineCount: function() {return this.size;},
+ firstLine: function() {return this.first;},
+ lastLine: function() {return this.first + this.size - 1;},
+
+ clipPos: function(pos) {return clipPos(this, pos);},
+
+ getCursor: function(start) {
+ var range = this.sel.primary(), pos;
+ if (start == null || start == "head") pos = range.head;
+ else if (start == "anchor") pos = range.anchor;
+ else if (start == "end" || start == "to" || start === false) pos = range.to();
+ else pos = range.from();
+ return pos;
+ },
+ listSelections: function() { return this.sel.ranges; },
+ somethingSelected: function() {return this.sel.somethingSelected();},
+
+ setCursor: docMethodOp(function(line, ch, options) {
+ setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
+ }),
+ setSelection: docMethodOp(function(anchor, head, options) {
+ setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
+ }),
+ extendSelection: docMethodOp(function(head, other, options) {
+ extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
+ }),
+ extendSelections: docMethodOp(function(heads, options) {
+ extendSelections(this, clipPosArray(this, heads, options));
+ }),
+ extendSelectionsBy: docMethodOp(function(f, options) {
+ extendSelections(this, map(this.sel.ranges, f), options);
+ }),
+ setSelections: docMethodOp(function(ranges, primary, options) {
+ if (!ranges.length) return;
+ for (var i = 0, out = []; i < ranges.length; i++)
+ out[i] = new Range(clipPos(this, ranges[i].anchor),
+ clipPos(this, ranges[i].head));
+ if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
+ setSelection(this, normalizeSelection(out, primary), options);
+ }),
+ addSelection: docMethodOp(function(anchor, head, options) {
+ var ranges = this.sel.ranges.slice(0);
+ ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
+ setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
+ }),
+
+ getSelection: function(lineSep) {
+ var ranges = this.sel.ranges, lines;
+ for (var i = 0; i < ranges.length; i++) {
+ var sel = getBetween(this, ranges[i].from(), ranges[i].to());
+ lines = lines ? lines.concat(sel) : sel;
+ }
+ if (lineSep === false) return lines;
+ else return lines.join(lineSep || "\n");
+ },
+ getSelections: function(lineSep) {
+ var parts = [], ranges = this.sel.ranges;
+ for (var i = 0; i < ranges.length; i++) {
+ var sel = getBetween(this, ranges[i].from(), ranges[i].to());
+ if (lineSep !== false) sel = sel.join(lineSep || "\n");
+ parts[i] = sel;
+ }
+ return parts;
+ },
+ replaceSelection: function(code, collapse, origin) {
+ var dup = [];
+ for (var i = 0; i < this.sel.ranges.length; i++)
+ dup[i] = code;
+ this.replaceSelections(dup, collapse, origin || "+input");
+ },
+ replaceSelections: docMethodOp(function(code, collapse, origin) {
+ var changes = [], sel = this.sel;
+ for (var i = 0; i < sel.ranges.length; i++) {
+ var range = sel.ranges[i];
+ changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin};
+ }
+ var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
+ for (var i = changes.length - 1; i >= 0; i--)
+ makeChange(this, changes[i]);
+ if (newSel) setSelectionReplaceHistory(this, newSel);
+ else if (this.cm) ensureCursorVisible(this.cm);
+ }),
+ undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
+ redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
+ undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
+ redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
+
+ setExtending: function(val) {this.extend = val;},
+ getExtending: function() {return this.extend;},
+
+ historySize: function() {
+ var hist = this.history, done = 0, undone = 0;
+ for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
+ for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
+ return {undo: done, redo: undone};
+ },
+ clearHistory: function() {this.history = new History(this.history.maxGeneration);},
+
+ markClean: function() {
+ this.cleanGeneration = this.changeGeneration(true);
+ },
+ changeGeneration: function(forceSplit) {
+ if (forceSplit)
+ this.history.lastOp = this.history.lastOrigin = null;
+ return this.history.generation;
+ },
+ isClean: function (gen) {
+ return this.history.generation == (gen || this.cleanGeneration);
+ },
+
+ getHistory: function() {
+ return {done: copyHistoryArray(this.history.done),
+ undone: copyHistoryArray(this.history.undone)};
+ },
+ setHistory: function(histData) {
+ var hist = this.history = new History(this.history.maxGeneration);
+ hist.done = copyHistoryArray(histData.done.slice(0), null, true);
+ hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
+ },
+
+ markText: function(from, to, options) {
+ return markText(this, clipPos(this, from), clipPos(this, to), options, "range");
+ },
+ setBookmark: function(pos, options) {
+ var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
+ insertLeft: options && options.insertLeft,
+ clearWhenEmpty: false, shared: options && options.shared};
+ pos = clipPos(this, pos);
+ return markText(this, pos, pos, realOpts, "bookmark");
+ },
+ findMarksAt: function(pos) {
+ pos = clipPos(this, pos);
+ var markers = [], spans = getLine(this, pos.line).markedSpans;
+ if (spans) for (var i = 0; i < spans.length; ++i) {
+ var span = spans[i];
+ if ((span.from == null || span.from <= pos.ch) &&
+ (span.to == null || span.to >= pos.ch))
+ markers.push(span.marker.parent || span.marker);
+ }
+ return markers;
+ },
+ findMarks: function(from, to, filter) {
+ from = clipPos(this, from); to = clipPos(this, to);
+ var found = [], lineNo = from.line;
+ this.iter(from.line, to.line + 1, function(line) {
+ var spans = line.markedSpans;
+ if (spans) for (var i = 0; i < spans.length; i++) {
+ var span = spans[i];
+ if (!(lineNo == from.line && from.ch > span.to ||
+ span.from == null && lineNo != from.line||
+ lineNo == to.line && span.from > to.ch) &&
+ (!filter || filter(span.marker)))
+ found.push(span.marker.parent || span.marker);
+ }
+ ++lineNo;
+ });
+ return found;
+ },
+ getAllMarks: function() {
+ var markers = [];
+ this.iter(function(line) {
+ var sps = line.markedSpans;
+ if (sps) for (var i = 0; i < sps.length; ++i)
+ if (sps[i].from != null) markers.push(sps[i].marker);
+ });
+ return markers;
+ },
+
+ posFromIndex: function(off) {
+ var ch, lineNo = this.first;
+ this.iter(function(line) {
+ var sz = line.text.length + 1;
+ if (sz > off) { ch = off; return true; }
+ off -= sz;
+ ++lineNo;
+ });
+ return clipPos(this, Pos(lineNo, ch));
+ },
+ indexFromPos: function (coords) {
+ coords = clipPos(this, coords);
+ var index = coords.ch;
+ if (coords.line < this.first || coords.ch < 0) return 0;
+ this.iter(this.first, coords.line, function (line) {
+ index += line.text.length + 1;
+ });
+ return index;
+ },
+
+ copy: function(copyHistory) {
+ var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first);
+ doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
+ doc.sel = this.sel;
+ doc.extend = false;
+ if (copyHistory) {
+ doc.history.undoDepth = this.history.undoDepth;
+ doc.setHistory(this.getHistory());
+ }
+ return doc;
+ },
+
+ linkedDoc: function(options) {
+ if (!options) options = {};
+ var from = this.first, to = this.first + this.size;
+ if (options.from != null && options.from > from) from = options.from;
+ if (options.to != null && options.to < to) to = options.to;
+ var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from);
+ if (options.sharedHist) copy.history = this.history;
+ (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
+ copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
+ copySharedMarkers(copy, findSharedMarkers(this));
+ return copy;
+ },
+ unlinkDoc: function(other) {
+ if (other instanceof CodeMirror) other = other.doc;
+ if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
+ var link = this.linked[i];
+ if (link.doc != other) continue;
+ this.linked.splice(i, 1);
+ other.unlinkDoc(this);
+ detachSharedMarkers(findSharedMarkers(this));
+ break;
+ }
+ // If the histories were shared, split them again
+ if (other.history == this.history) {
+ var splitIds = [other.id];
+ linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
+ other.history = new History(null);
+ other.history.done = copyHistoryArray(this.history.done, splitIds);
+ other.history.undone = copyHistoryArray(this.history.undone, splitIds);
+ }
+ },
+ iterLinkedDocs: function(f) {linkedDocs(this, f);},
+
+ getMode: function() {return this.mode;},
+ getEditor: function() {return this.cm;}
+ });
+
+ // Public alias.
+ Doc.prototype.eachLine = Doc.prototype.iter;
+
+ // Set up methods on CodeMirror's prototype to redirect to the editor's document.
+ var dontDelegate = "iter insert remove copy getEditor".split(" ");
+ for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
+ CodeMirror.prototype[prop] = (function(method) {
+ return function() {return method.apply(this.doc, arguments);};
+ })(Doc.prototype[prop]);
+
+ eventMixin(Doc);
+
+ // Call f for all linked documents.
+ function linkedDocs(doc, f, sharedHistOnly) {
+ function propagate(doc, skip, sharedHist) {
+ if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
+ var rel = doc.linked[i];
+ if (rel.doc == skip) continue;
+ var shared = sharedHist && rel.sharedHist;
+ if (sharedHistOnly && !shared) continue;
+ f(rel.doc, shared);
+ propagate(rel.doc, doc, shared);
+ }
+ }
+ propagate(doc, null, true);
+ }
+
+ // Attach a document to an editor.
+ function attachDoc(cm, doc) {
+ if (doc.cm) throw new Error("This document is already in use.");
+ cm.doc = doc;
+ doc.cm = cm;
+ estimateLineHeights(cm);
+ loadMode(cm);
+ if (!cm.options.lineWrapping) findMaxLine(cm);
+ cm.options.mode = doc.modeOption;
+ regChange(cm);
+ }
+
+ // LINE UTILITIES
+
+ // Find the line object corresponding to the given line number.
+ function getLine(doc, n) {
+ n -= doc.first;
+ if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
+ for (var chunk = doc; !chunk.lines;) {
+ for (var i = 0;; ++i) {
+ var child = chunk.children[i], sz = child.chunkSize();
+ if (n < sz) { chunk = child; break; }
+ n -= sz;
+ }
+ }
+ return chunk.lines[n];
+ }
+
+ // Get the part of a document between two positions, as an array of
+ // strings.
+ function getBetween(doc, start, end) {
+ var out = [], n = start.line;
+ doc.iter(start.line, end.line + 1, function(line) {
+ var text = line.text;
+ if (n == end.line) text = text.slice(0, end.ch);
+ if (n == start.line) text = text.slice(start.ch);
+ out.push(text);
+ ++n;
+ });
+ return out;
+ }
+ // Get the lines between from and to, as array of strings.
+ function getLines(doc, from, to) {
+ var out = [];
+ doc.iter(from, to, function(line) { out.push(line.text); });
+ return out;
+ }
+
+ // Update the height of a line, propagating the height change
+ // upwards to parent nodes.
+ function updateLineHeight(line, height) {
+ var diff = height - line.height;
+ if (diff) for (var n = line; n; n = n.parent) n.height += diff;
+ }
+
+ // Given a line object, find its line number by walking up through
+ // its parent links.
+ function lineNo(line) {
+ if (line.parent == null) return null;
+ var cur = line.parent, no = indexOf(cur.lines, line);
+ for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
+ for (var i = 0;; ++i) {
+ if (chunk.children[i] == cur) break;
+ no += chunk.children[i].chunkSize();
+ }
+ }
+ return no + cur.first;
+ }
+
+ // Find the line at the given vertical position, using the height
+ // information in the document tree.
+ function lineAtHeight(chunk, h) {
+ var n = chunk.first;
+ outer: do {
+ for (var i = 0; i < chunk.children.length; ++i) {
+ var child = chunk.children[i], ch = child.height;
+ if (h < ch) { chunk = child; continue outer; }
+ h -= ch;
+ n += child.chunkSize();
+ }
+ return n;
+ } while (!chunk.lines);
+ for (var i = 0; i < chunk.lines.length; ++i) {
+ var line = chunk.lines[i], lh = line.height;
+ if (h < lh) break;
+ h -= lh;
+ }
+ return n + i;
+ }
+
+
+ // Find the height above the given line.
+ function heightAtLine(lineObj) {
+ lineObj = visualLine(lineObj);
+
+ var h = 0, chunk = lineObj.parent;
+ for (var i = 0; i < chunk.lines.length; ++i) {
+ var line = chunk.lines[i];
+ if (line == lineObj) break;
+ else h += line.height;
+ }
+ for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
+ for (var i = 0; i < p.children.length; ++i) {
+ var cur = p.children[i];
+ if (cur == chunk) break;
+ else h += cur.height;
+ }
+ }
+ return h;
+ }
+
+ // Get the bidi ordering for the given line (and cache it). Returns
+ // false for lines that are fully left-to-right, and an array of
+ // BidiSpan objects otherwise.
+ function getOrder(line) {
+ var order = line.order;
+ if (order == null) order = line.order = bidiOrdering(line.text);
+ return order;
+ }
+
+ // HISTORY
+
+ function History(startGen) {
+ // Arrays of change events and selections. Doing something adds an
+ // event to done and clears undo. Undoing moves events from done
+ // to undone, redoing moves them in the other direction.
+ this.done = []; this.undone = [];
+ this.undoDepth = Infinity;
+ // Used to track when changes can be merged into a single undo
+ // event
+ this.lastModTime = this.lastSelTime = 0;
+ this.lastOp = null;
+ this.lastOrigin = this.lastSelOrigin = null;
+ // Used by the isClean() method
+ this.generation = this.maxGeneration = startGen || 1;
+ }
+
+ // Create a history change event from an updateDoc-style change
+ // object.
+ function historyChangeFromChange(doc, change) {
+ var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
+ attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
+ linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
+ return histChange;
+ }
+
+ // Pop all selection events off the end of a history array. Stop at
+ // a change event.
+ function clearSelectionEvents(array) {
+ while (array.length) {
+ var last = lst(array);
+ if (last.ranges) array.pop();
+ else break;
+ }
+ }
+
+ // Find the top change event in the history. Pop off selection
+ // events that are in the way.
+ function lastChangeEvent(hist, force) {
+ if (force) {
+ clearSelectionEvents(hist.done);
+ return lst(hist.done);
+ } else if (hist.done.length && !lst(hist.done).ranges) {
+ return lst(hist.done);
+ } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
+ hist.done.pop();
+ return lst(hist.done);
+ }
+ }
+
+ // Register a change in the history. Merges changes that are within
+ // a single operation, ore are close together with an origin that
+ // allows merging (starting with "+") into a single event.
+ function addChangeToHistory(doc, change, selAfter, opId) {
+ var hist = doc.history;
+ hist.undone.length = 0;
+ var time = +new Date, cur;
+
+ if ((hist.lastOp == opId ||
+ hist.lastOrigin == change.origin && change.origin &&
+ ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
+ change.origin.charAt(0) == "*")) &&
+ (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
+ // Merge this change into the last event
+ var last = lst(cur.changes);
+ if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
+ // Optimized case for simple insertion -- don't want to add
+ // new changesets for every character typed
+ last.to = changeEnd(change);
+ } else {
+ // Add new sub-event
+ cur.changes.push(historyChangeFromChange(doc, change));
+ }
+ } else {
+ // Can not be merged, start a new event.
+ var before = lst(hist.done);
+ if (!before || !before.ranges)
+ pushSelectionToHistory(doc.sel, hist.done);
+ cur = {changes: [historyChangeFromChange(doc, change)],
+ generation: hist.generation};
+ hist.done.push(cur);
+ while (hist.done.length > hist.undoDepth) {
+ hist.done.shift();
+ if (!hist.done[0].ranges) hist.done.shift();
+ }
+ }
+ hist.done.push(selAfter);
+ hist.generation = ++hist.maxGeneration;
+ hist.lastModTime = hist.lastSelTime = time;
+ hist.lastOp = opId;
+ hist.lastOrigin = hist.lastSelOrigin = change.origin;
+
+ if (!last) signal(doc, "historyAdded");
+ }
+
+ function selectionEventCanBeMerged(doc, origin, prev, sel) {
+ var ch = origin.charAt(0);
+ return ch == "*" ||
+ ch == "+" &&
+ prev.ranges.length == sel.ranges.length &&
+ prev.somethingSelected() == sel.somethingSelected() &&
+ new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
+ }
+
+ // Called whenever the selection changes, sets the new selection as
+ // the pending selection in the history, and pushes the old pending
+ // selection into the 'done' array when it was significantly
+ // different (in number of selected ranges, emptiness, or time).
+ function addSelectionToHistory(doc, sel, opId, options) {
+ var hist = doc.history, origin = options && options.origin;
+
+ // A new event is started when the previous origin does not match
+ // the current, or the origins don't allow matching. Origins
+ // starting with * are always merged, those starting with + are
+ // merged when similar and close together in time.
+ if (opId == hist.lastOp ||
+ (origin && hist.lastSelOrigin == origin &&
+ (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
+ selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
+ hist.done[hist.done.length - 1] = sel;
+ else
+ pushSelectionToHistory(sel, hist.done);
+
+ hist.lastSelTime = +new Date;
+ hist.lastSelOrigin = origin;
+ hist.lastOp = opId;
+ if (options && options.clearRedo !== false)
+ clearSelectionEvents(hist.undone);
+ }
+
+ function pushSelectionToHistory(sel, dest) {
+ var top = lst(dest);
+ if (!(top && top.ranges && top.equals(sel)))
+ dest.push(sel);
+ }
+
+ // Used to store marked span information in the history.
+ function attachLocalSpans(doc, change, from, to) {
+ var existing = change["spans_" + doc.id], n = 0;
+ doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
+ if (line.markedSpans)
+ (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
+ ++n;
+ });
+ }
+
+ // When un/re-doing restores text containing marked spans, those
+ // that have been explicitly cleared should not be restored.
+ function removeClearedSpans(spans) {
+ if (!spans) return null;
+ for (var i = 0, out; i < spans.length; ++i) {
+ if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
+ else if (out) out.push(spans[i]);
+ }
+ return !out ? spans : out.length ? out : null;
+ }
+
+ // Retrieve and filter the old marked spans stored in a change event.
+ function getOldSpans(doc, change) {
+ var found = change["spans_" + doc.id];
+ if (!found) return null;
+ for (var i = 0, nw = []; i < change.text.length; ++i)
+ nw.push(removeClearedSpans(found[i]));
+ return nw;
+ }
+
+ // Used both to provide a JSON-safe object in .getHistory, and, when
+ // detaching a document, to split the history in two
+ function copyHistoryArray(events, newGroup, instantiateSel) {
+ for (var i = 0, copy = []; i < events.length; ++i) {
+ var event = events[i];
+ if (event.ranges) {
+ copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
+ continue;
+ }
+ var changes = event.changes, newChanges = [];
+ copy.push({changes: newChanges});
+ for (var j = 0; j < changes.length; ++j) {
+ var change = changes[j], m;
+ newChanges.push({from: change.from, to: change.to, text: change.text});
+ if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
+ if (indexOf(newGroup, Number(m[1])) > -1) {
+ lst(newChanges)[prop] = change[prop];
+ delete change[prop];
+ }
+ }
+ }
+ }
+ return copy;
+ }
+
+ // Rebasing/resetting history to deal with externally-sourced changes
+
+ function rebaseHistSelSingle(pos, from, to, diff) {
+ if (to < pos.line) {
+ pos.line += diff;
+ } else if (from < pos.line) {
+ pos.line = from;
+ pos.ch = 0;
+ }
+ }
+
+ // Tries to rebase an array of history events given a change in the
+ // document. If the change touches the same lines as the event, the
+ // event, and everything 'behind' it, is discarded. If the change is
+ // before the event, the event's positions are updated. Uses a
+ // copy-on-write scheme for the positions, to avoid having to
+ // reallocate them all on every rebase, but also avoid problems with
+ // shared position objects being unsafely updated.
+ function rebaseHistArray(array, from, to, diff) {
+ for (var i = 0; i < array.length; ++i) {
+ var sub = array[i], ok = true;
+ if (sub.ranges) {
+ if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
+ for (var j = 0; j < sub.ranges.length; j++) {
+ rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
+ rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
+ }
+ continue;
+ }
+ for (var j = 0; j < sub.changes.length; ++j) {
+ var cur = sub.changes[j];
+ if (to < cur.from.line) {
+ cur.from = Pos(cur.from.line + diff, cur.from.ch);
+ cur.to = Pos(cur.to.line + diff, cur.to.ch);
+ } else if (from <= cur.to.line) {
+ ok = false;
+ break;
+ }
+ }
+ if (!ok) {
+ array.splice(0, i + 1);
+ i = 0;
+ }
+ }
+ }
+
+ function rebaseHist(hist, change) {
+ var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
+ rebaseHistArray(hist.done, from, to, diff);
+ rebaseHistArray(hist.undone, from, to, diff);
+ }
+
+ // EVENT UTILITIES
+
+ // Due to the fact that we still support jurassic IE versions, some
+ // compatibility wrappers are needed.
+
+ var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
+ if (e.preventDefault) e.preventDefault();
+ else e.returnValue = false;
+ };
+ var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
+ if (e.stopPropagation) e.stopPropagation();
+ else e.cancelBubble = true;
+ };
+ function e_defaultPrevented(e) {
+ return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
+ }
+ var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
+
+ function e_target(e) {return e.target || e.srcElement;}
+ function e_button(e) {
+ var b = e.which;
+ if (b == null) {
+ if (e.button & 1) b = 1;
+ else if (e.button & 2) b = 3;
+ else if (e.button & 4) b = 2;
+ }
+ if (mac && e.ctrlKey && b == 1) b = 3;
+ return b;
+ }
+
+ // EVENT HANDLING
+
+ // Lightweight event framework. on/off also work on DOM nodes,
+ // registering native DOM handlers.
+
+ var on = CodeMirror.on = function(emitter, type, f) {
+ if (emitter.addEventListener)
+ emitter.addEventListener(type, f, false);
+ else if (emitter.attachEvent)
+ emitter.attachEvent("on" + type, f);
+ else {
+ var map = emitter._handlers || (emitter._handlers = {});
+ var arr = map[type] || (map[type] = []);
+ arr.push(f);
+ }
+ };
+
+ var off = CodeMirror.off = function(emitter, type, f) {
+ if (emitter.removeEventListener)
+ emitter.removeEventListener(type, f, false);
+ else if (emitter.detachEvent)
+ emitter.detachEvent("on" + type, f);
+ else {
+ var arr = emitter._handlers && emitter._handlers[type];
+ if (!arr) return;
+ for (var i = 0; i < arr.length; ++i)
+ if (arr[i] == f) { arr.splice(i, 1); break; }
+ }
+ };
+
+ var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
+ var arr = emitter._handlers && emitter._handlers[type];
+ if (!arr) return;
+ var args = Array.prototype.slice.call(arguments, 2);
+ for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
+ };
+
+ // Often, we want to signal events at a point where we are in the
+ // middle of some work, but don't want the handler to start calling
+ // other methods on the editor, which might be in an inconsistent
+ // state or simply not expect any other events to happen.
+ // signalLater looks whether there are any handlers, and schedules
+ // them to be executed when the last operation ends, or, if no
+ // operation is active, when a timeout fires.
+ var delayedCallbacks, delayedCallbackDepth = 0;
+ function signalLater(emitter, type /*, values...*/) {
+ var arr = emitter._handlers && emitter._handlers[type];
+ if (!arr) return;
+ var args = Array.prototype.slice.call(arguments, 2);
+ if (!delayedCallbacks) {
+ ++delayedCallbackDepth;
+ delayedCallbacks = [];
+ setTimeout(fireDelayed, 0);
+ }
+ function bnd(f) {return function(){f.apply(null, args);};};
+ for (var i = 0; i < arr.length; ++i)
+ delayedCallbacks.push(bnd(arr[i]));
+ }
+
+ function fireDelayed() {
+ --delayedCallbackDepth;
+ var delayed = delayedCallbacks;
+ delayedCallbacks = null;
+ for (var i = 0; i < delayed.length; ++i) delayed[i]();
+ }
+
+ // The DOM events that CodeMirror handles can be overridden by
+ // registering a (non-DOM) handler on the editor for the event name,
+ // and preventDefault-ing the event in that handler.
+ function signalDOMEvent(cm, e, override) {
+ signal(cm, override || e.type, cm, e);
+ return e_defaultPrevented(e) || e.codemirrorIgnore;
+ }
+
+ function signalCursorActivity(cm) {
+ var arr = cm._handlers && cm._handlers.cursorActivity;
+ if (!arr) return;
+ var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
+ for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
+ set.push(arr[i]);
+ }
+
+ function hasHandler(emitter, type) {
+ var arr = emitter._handlers && emitter._handlers[type];
+ return arr && arr.length > 0;
+ }
+
+ // Add on and off methods to a constructor's prototype, to make
+ // registering events on such objects more convenient.
+ function eventMixin(ctor) {
+ ctor.prototype.on = function(type, f) {on(this, type, f);};
+ ctor.prototype.off = function(type, f) {off(this, type, f);};
+ }
+
+ // MISC UTILITIES
+
+ // Number of pixels added to scroller and sizer to hide scrollbar
+ var scrollerCutOff = 30;
+
+ // Returned or thrown by various protocols to signal 'I'm not
+ // handling this'.
+ var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
+
+ // Reused option objects for setSelection & friends
+ var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
+
+ function Delayed() {this.id = null;}
+ Delayed.prototype.set = function(ms, f) {
+ clearTimeout(this.id);
+ this.id = setTimeout(f, ms);
+ };
+
+ // Counts the column offset in a string, taking tabs into account.
+ // Used mostly to find indentation.
+ var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
+ if (end == null) {
+ end = string.search(/[^\s\u00a0]/);
+ if (end == -1) end = string.length;
+ }
+ for (var i = startIndex || 0, n = startValue || 0;;) {
+ var nextTab = string.indexOf("\t", i);
+ if (nextTab < 0 || nextTab >= end)
+ return n + (end - i);
+ n += nextTab - i;
+ n += tabSize - (n % tabSize);
+ i = nextTab + 1;
+ }
+ };
+
+ // The inverse of countColumn -- find the offset that corresponds to
+ // a particular column.
+ function findColumn(string, goal, tabSize) {
+ for (var pos = 0, col = 0;;) {
+ var nextTab = string.indexOf("\t", pos);
+ if (nextTab == -1) nextTab = string.length;
+ var skipped = nextTab - pos;
+ if (nextTab == string.length || col + skipped >= goal)
+ return pos + Math.min(skipped, goal - col);
+ col += nextTab - pos;
+ col += tabSize - (col % tabSize);
+ pos = nextTab + 1;
+ if (col >= goal) return pos;
+ }
+ }
+
+ var spaceStrs = [""];
+ function spaceStr(n) {
+ while (spaceStrs.length <= n)
+ spaceStrs.push(lst(spaceStrs) + " ");
+ return spaceStrs[n];
+ }
+
+ function lst(arr) { return arr[arr.length-1]; }
+
+ var selectInput = function(node) { node.select(); };
+ if (ios) // Mobile Safari apparently has a bug where select() is broken.
+ selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
+ else if (ie) // Suppress mysterious IE10 errors
+ selectInput = function(node) { try { node.select(); } catch(_e) {} };
+
+ function indexOf(array, elt) {
+ for (var i = 0; i < array.length; ++i)
+ if (array[i] == elt) return i;
+ return -1;
+ }
+ if ([].indexOf) indexOf = function(array, elt) { return array.indexOf(elt); };
+ function map(array, f) {
+ var out = [];
+ for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
+ return out;
+ }
+ if ([].map) map = function(array, f) { return array.map(f); };
+
+ function createObj(base, props) {
+ var inst;
+ if (Object.create) {
+ inst = Object.create(base);
+ } else {
+ var ctor = function() {};
+ ctor.prototype = base;
+ inst = new ctor();
+ }
+ if (props) copyObj(props, inst);
+ return inst;
+ };
+
+ function copyObj(obj, target, overwrite) {
+ if (!target) target = {};
+ for (var prop in obj)
+ if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
+ target[prop] = obj[prop];
+ return target;
+ }
+
+ function bind(f) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return function(){return f.apply(null, args);};
+ }
+
+ var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+ var isWordChar = CodeMirror.isWordChar = function(ch) {
+ return /\w/.test(ch) || ch > "\x80" &&
+ (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
+ };
+
+ function isEmpty(obj) {
+ for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
+ return true;
+ }
+
+ // Extending unicode characters. A series of a non-extending char +
+ // any number of extending chars is treated as a single unit as far
+ // as editing and measuring is concerned. This is not fully correct,
+ // since some scripts/fonts/browsers also treat other configurations
+ // of code points as a group.
+ var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
+ function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
+
+ // DOM UTILITIES
+
+ function elt(tag, content, className, style) {
+ var e = document.createElement(tag);
+ if (className) e.className = className;
+ if (style) e.style.cssText = style;
+ if (typeof content == "string") e.appendChild(document.createTextNode(content));
+ else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
+ return e;
+ }
+
+ var range;
+ if (document.createRange) range = function(node, start, end) {
+ var r = document.createRange();
+ r.setEnd(node, end);
+ r.setStart(node, start);
+ return r;
+ };
+ else range = function(node, start, end) {
+ var r = document.body.createTextRange();
+ r.moveToElementText(node.parentNode);
+ r.collapse(true);
+ r.moveEnd("character", end);
+ r.moveStart("character", start);
+ return r;
+ };
+
+ function removeChildren(e) {
+ for (var count = e.childNodes.length; count > 0; --count)
+ e.removeChild(e.firstChild);
+ return e;
+ }
+
+ function removeChildrenAndAdd(parent, e) {
+ return removeChildren(parent).appendChild(e);
+ }
+
+ function contains(parent, child) {
+ if (parent.contains)
+ return parent.contains(child);
+ while (child = child.parentNode)
+ if (child == parent) return true;
+ }
+
+ function activeElt() { return document.activeElement; }
+ // Older versions of IE throws unspecified error when touching
+ // document.activeElement in some cases (during loading, in iframe)
+ if (ie_upto10) activeElt = function() {
+ try { return document.activeElement; }
+ catch(e) { return document.body; }
+ };
+
+ function classTest(cls) { return new RegExp("\\b" + cls + "\\b\\s*"); }
+ function rmClass(node, cls) {
+ var test = classTest(cls);
+ if (test.test(node.className)) node.className = node.className.replace(test, "");
+ }
+ function addClass(node, cls) {
+ if (!classTest(cls).test(node.className)) node.className += " " + cls;
+ }
+ function joinClasses(a, b) {
+ var as = a.split(" ");
+ for (var i = 0; i < as.length; i++)
+ if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
+ return b;
+ }
+
+ // FEATURE DETECTION
+
+ // Detect drag-and-drop
+ var dragAndDrop = function() {
+ // There is *some* kind of drag-and-drop support in IE6-8, but I
+ // couldn't get it to work yet.
+ if (ie_upto8) return false;
+ var div = elt('div');
+ return "draggable" in div || "dragDrop" in div;
+ }();
+
+ var knownScrollbarWidth;
+ function scrollbarWidth(measure) {
+ if (knownScrollbarWidth != null) return knownScrollbarWidth;
+ var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll");
+ removeChildrenAndAdd(measure, test);
+ if (test.offsetWidth)
+ knownScrollbarWidth = test.offsetHeight - test.clientHeight;
+ return knownScrollbarWidth || 0;
+ }
+
+ var zwspSupported;
+ function zeroWidthElement(measure) {
+ if (zwspSupported == null) {
+ var test = elt("span", "\u200b");
+ removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
+ if (measure.firstChild.offsetHeight != 0)
+ zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_upto7;
+ }
+ if (zwspSupported) return elt("span", "\u200b");
+ else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
+ }
+
+ // Feature-detect IE's crummy client rect reporting for bidi text
+ var badBidiRects;
+ function hasBadBidiRects(measure) {
+ if (badBidiRects != null) return badBidiRects;
+ var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
+ var r0 = range(txt, 0, 1).getBoundingClientRect();
+ if (r0.left == r0.right) return false;
+ var r1 = range(txt, 1, 2).getBoundingClientRect();
+ return badBidiRects = (r1.right - r0.right < 3);
+ }
+
+ // See if "".split is the broken IE version, if so, provide an
+ // alternative way to split lines.
+ var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
+ var pos = 0, result = [], l = string.length;
+ while (pos <= l) {
+ var nl = string.indexOf("\n", pos);
+ if (nl == -1) nl = string.length;
+ var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
+ var rt = line.indexOf("\r");
+ if (rt != -1) {
+ result.push(line.slice(0, rt));
+ pos += rt + 1;
+ } else {
+ result.push(line);
+ pos = nl + 1;
+ }
+ }
+ return result;
+ } : function(string){return string.split(/\r\n?|\n/);};
+
+ var hasSelection = window.getSelection ? function(te) {
+ try { return te.selectionStart != te.selectionEnd; }
+ catch(e) { return false; }
+ } : function(te) {
+ try {var range = te.ownerDocument.selection.createRange();}
+ catch(e) {}
+ if (!range || range.parentElement() != te) return false;
+ return range.compareEndPoints("StartToEnd", range) != 0;
+ };
+
+ var hasCopyEvent = (function() {
+ var e = elt("div");
+ if ("oncopy" in e) return true;
+ e.setAttribute("oncopy", "return;");
+ return typeof e.oncopy == "function";
+ })();
+
+ // KEY NAMES
+
+ var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
+ 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
+ 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
+ 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete",
+ 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
+ 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
+ 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"};
+ CodeMirror.keyNames = keyNames;
+ (function() {
+ // Number keys
+ for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
+ // Alphabetic keys
+ for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
+ // Function keys
+ for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
+ })();
+
+ // BIDI HELPERS
+
+ function iterateBidiSections(order, from, to, f) {
+ if (!order) return f(from, to, "ltr");
+ var found = false;
+ for (var i = 0; i < order.length; ++i) {
+ var part = order[i];
+ if (part.from < to && part.to > from || from == to && part.to == from) {
+ f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
+ found = true;
+ }
+ }
+ if (!found) f(from, to, "ltr");
+ }
+
+ function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
+ function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
+
+ function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
+ function lineRight(line) {
+ var order = getOrder(line);
+ if (!order) return line.text.length;
+ return bidiRight(lst(order));
+ }
+
+ function lineStart(cm, lineN) {
+ var line = getLine(cm.doc, lineN);
+ var visual = visualLine(line);
+ if (visual != line) lineN = lineNo(visual);
+ var order = getOrder(visual);
+ var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
+ return Pos(lineN, ch);
+ }
+ function lineEnd(cm, lineN) {
+ var merged, line = getLine(cm.doc, lineN);
+ while (merged = collapsedSpanAtEnd(line)) {
+ line = merged.find(1, true).line;
+ lineN = null;
+ }
+ var order = getOrder(line);
+ var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
+ return Pos(lineN == null ? lineNo(line) : lineN, ch);
+ }
+
+ function compareBidiLevel(order, a, b) {
+ var linedir = order[0].level;
+ if (a == linedir) return true;
+ if (b == linedir) return false;
+ return a < b;
+ }
+ var bidiOther;
+ function getBidiPartAt(order, pos) {
+ bidiOther = null;
+ for (var i = 0, found; i < order.length; ++i) {
+ var cur = order[i];
+ if (cur.from < pos && cur.to > pos) return i;
+ if ((cur.from == pos || cur.to == pos)) {
+ if (found == null) {
+ found = i;
+ } else if (compareBidiLevel(order, cur.level, order[found].level)) {
+ if (cur.from != cur.to) bidiOther = found;
+ return i;
+ } else {
+ if (cur.from != cur.to) bidiOther = i;
+ return found;
+ }
+ }
+ }
+ return found;
+ }
+
+ function moveInLine(line, pos, dir, byUnit) {
+ if (!byUnit) return pos + dir;
+ do pos += dir;
+ while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
+ return pos;
+ }
+
+ // This is needed in order to move 'visually' through bi-directional
+ // text -- i.e., pressing left should make the cursor go left, even
+ // when in RTL text. The tricky part is the 'jumps', where RTL and
+ // LTR text touch each other. This often requires the cursor offset
+ // to move more than one unit, in order to visually move one unit.
+ function moveVisually(line, start, dir, byUnit) {
+ var bidi = getOrder(line);
+ if (!bidi) return moveLogically(line, start, dir, byUnit);
+ var pos = getBidiPartAt(bidi, start), part = bidi[pos];
+ var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
+
+ for (;;) {
+ if (target > part.from && target < part.to) return target;
+ if (target == part.from || target == part.to) {
+ if (getBidiPartAt(bidi, target) == pos) return target;
+ part = bidi[pos += dir];
+ return (dir > 0) == part.level % 2 ? part.to : part.from;
+ } else {
+ part = bidi[pos += dir];
+ if (!part) return null;
+ if ((dir > 0) == part.level % 2)
+ target = moveInLine(line, part.to, -1, byUnit);
+ else
+ target = moveInLine(line, part.from, 1, byUnit);
+ }
+ }
+ }
+
+ function moveLogically(line, start, dir, byUnit) {
+ var target = start + dir;
+ if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
+ return target < 0 || target > line.text.length ? null : target;
+ }
+
+ // Bidirectional ordering algorithm
+ // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
+ // that this (partially) implements.
+
+ // One-char codes used for character types:
+ // L (L): Left-to-Right
+ // R (R): Right-to-Left
+ // r (AL): Right-to-Left Arabic
+ // 1 (EN): European Number
+ // + (ES): European Number Separator
+ // % (ET): European Number Terminator
+ // n (AN): Arabic Number
+ // , (CS): Common Number Separator
+ // m (NSM): Non-Spacing Mark
+ // b (BN): Boundary Neutral
+ // s (B): Paragraph Separator
+ // t (S): Segment Separator
+ // w (WS): Whitespace
+ // N (ON): Other Neutrals
+
+ // Returns null if characters are ordered as they appear
+ // (left-to-right), or an array of sections ({from, to, level}
+ // objects) in the order in which they occur visually.
+ var bidiOrdering = (function() {
+ // Character types for codepoints 0 to 0xff
+ var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
+ // Character types for codepoints 0x600 to 0x6ff
+ var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
+ function charType(code) {
+ if (code <= 0xf7) return lowTypes.charAt(code);
+ else if (0x590 <= code && code <= 0x5f4) return "R";
+ else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
+ else if (0x6ee <= code && code <= 0x8ac) return "r";
+ else if (0x2000 <= code && code <= 0x200b) return "w";
+ else if (code == 0x200c) return "b";
+ else return "L";
+ }
+
+ var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
+ var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
+ // Browsers seem to always treat the boundaries of block elements as being L.
+ var outerType = "L";
+
+ function BidiSpan(level, from, to) {
+ this.level = level;
+ this.from = from; this.to = to;
+ }
+
+ return function(str) {
+ if (!bidiRE.test(str)) return false;
+ var len = str.length, types = [];
+ for (var i = 0, type; i < len; ++i)
+ types.push(type = charType(str.charCodeAt(i)));
+
+ // W1. Examine each non-spacing mark (NSM) in the level run, and
+ // change the type of the NSM to the type of the previous
+ // character. If the NSM is at the start of the level run, it will
+ // get the type of sor.
+ for (var i = 0, prev = outerType; i < len; ++i) {
+ var type = types[i];
+ if (type == "m") types[i] = prev;
+ else prev = type;
+ }
+
+ // W2. Search backwards from each instance of a European number
+ // until the first strong type (R, L, AL, or sor) is found. If an
+ // AL is found, change the type of the European number to Arabic
+ // number.
+ // W3. Change all ALs to R.
+ for (var i = 0, cur = outerType; i < len; ++i) {
+ var type = types[i];
+ if (type == "1" && cur == "r") types[i] = "n";
+ else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
+ }
+
+ // W4. A single European separator between two European numbers
+ // changes to a European number. A single common separator between
+ // two numbers of the same type changes to that type.
+ for (var i = 1, prev = types[0]; i < len - 1; ++i) {
+ var type = types[i];
+ if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
+ else if (type == "," && prev == types[i+1] &&
+ (prev == "1" || prev == "n")) types[i] = prev;
+ prev = type;
+ }
+
+ // W5. A sequence of European terminators adjacent to European
+ // numbers changes to all European numbers.
+ // W6. Otherwise, separators and terminators change to Other
+ // Neutral.
+ for (var i = 0; i < len; ++i) {
+ var type = types[i];
+ if (type == ",") types[i] = "N";
+ else if (type == "%") {
+ for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
+ var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
+ for (var j = i; j < end; ++j) types[j] = replace;
+ i = end - 1;
+ }
+ }
+
+ // W7. Search backwards from each instance of a European number
+ // until the first strong type (R, L, or sor) is found. If an L is
+ // found, then change the type of the European number to L.
+ for (var i = 0, cur = outerType; i < len; ++i) {
+ var type = types[i];
+ if (cur == "L" && type == "1") types[i] = "L";
+ else if (isStrong.test(type)) cur = type;
+ }
+
+ // N1. A sequence of neutrals takes the direction of the
+ // surrounding strong text if the text on both sides has the same
+ // direction. European and Arabic numbers act as if they were R in
+ // terms of their influence on neutrals. Start-of-level-run (sor)
+ // and end-of-level-run (eor) are used at level run boundaries.
+ // N2. Any remaining neutrals take the embedding direction.
+ for (var i = 0; i < len; ++i) {
+ if (isNeutral.test(types[i])) {
+ for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
+ var before = (i ? types[i-1] : outerType) == "L";
+ var after = (end < len ? types[end] : outerType) == "L";
+ var replace = before || after ? "L" : "R";
+ for (var j = i; j < end; ++j) types[j] = replace;
+ i = end - 1;
+ }
+ }
+
+ // Here we depart from the documented algorithm, in order to avoid
+ // building up an actual levels array. Since there are only three
+ // levels (0, 1, 2) in an implementation that doesn't take
+ // explicit embedding into account, we can build up the order on
+ // the fly, without following the level-based algorithm.
+ var order = [], m;
+ for (var i = 0; i < len;) {
+ if (countsAsLeft.test(types[i])) {
+ var start = i;
+ for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
+ order.push(new BidiSpan(0, start, i));
+ } else {
+ var pos = i, at = order.length;
+ for (++i; i < len && types[i] != "L"; ++i) {}
+ for (var j = pos; j < i;) {
+ if (countsAsNum.test(types[j])) {
+ if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
+ var nstart = j;
+ for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
+ order.splice(at, 0, new BidiSpan(2, nstart, j));
+ pos = j;
+ } else ++j;
+ }
+ if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
+ }
+ }
+ if (order[0].level == 1 && (m = str.match(/^\s+/))) {
+ order[0].from = m[0].length;
+ order.unshift(new BidiSpan(0, 0, m[0].length));
+ }
+ if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
+ lst(order).to -= m[0].length;
+ order.push(new BidiSpan(0, len - m[0].length, len));
+ }
+ if (order[0].level != lst(order).level)
+ order.push(new BidiSpan(order[0].level, len, len));
+
+ return order;
+ };
+ })();
+
+ // THE END
+
+ CodeMirror.version = "4.1.0";
+
+ return CodeMirror;
+});
diff --git a/cmd/mist/assets/muted/lib/go.js b/cmd/mist/assets/muted/lib/go.js
new file mode 100644
index 000000000..9f1c1c4ab
--- /dev/null
+++ b/cmd/mist/assets/muted/lib/go.js
@@ -0,0 +1,182 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.defineMode("go", function(config) {
+ var indentUnit = config.indentUnit;
+
+ var keywords = {
+ "break":true, "case":true, "chan":true, "const":true, "continue":true,
+ "default":true, "defer":true, "else":true, "fallthrough":true, "for":true,
+ "func":true, "go":true, "goto":true, "if":true, "import":true,
+ "interface":true, "map":true, "package":true, "range":true, "return":true,
+ "select":true, "struct":true, "switch":true, "type":true, "var":true,
+ "bool":true, "byte":true, "complex64":true, "complex128":true,
+ "float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
+ "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
+ "uint64":true, "int":true, "uint":true, "uintptr":true, "big": true,
+ "main": true, "init": true, "this":true
+ };
+
+ var atoms = {
+ "true":true, "false":true, "iota":true, "nil":true, "append":true,
+ "cap":true, "close":true, "complex":true, "copy":true, "imag":true,
+ "len":true, "make":true, "new":true, "panic":true, "print":true,
+ "println":true, "real":true, "recover":true,
+ };
+
+ var isOperatorChar = /[+\-*&^%:=<>!|\/]/;
+
+ var curPunc;
+
+ function tokenBase(stream, state) {
+ var ch = stream.next();
+ if (ch == '"' || ch == "'" || ch == "`") {
+ state.tokenize = tokenString(ch);
+ return state.tokenize(stream, state);
+ }
+ if (/[\d\.]/.test(ch)) {
+ if (ch == ".") {
+ stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
+ } else if (ch == "0") {
+ stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
+ } else {
+ stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
+ }
+ return "number";
+ }
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
+ curPunc = ch;
+ return null;
+ }
+ if (ch == "/") {
+ if (stream.eat("*")) {
+ state.tokenize = tokenComment;
+ return tokenComment(stream, state);
+ }
+ if (stream.eat("/")) {
+ stream.skipToEnd();
+ return "comment";
+ }
+ }
+ if (isOperatorChar.test(ch)) {
+ stream.eatWhile(isOperatorChar);
+ return "operator";
+ }
+ stream.eatWhile(/[\w\$_]/);
+ var cur = stream.current();
+ if (keywords.propertyIsEnumerable(cur)) {
+ if (cur == "case" || cur == "default") curPunc = "case";
+ return "keyword";
+ }
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
+ return "variable";
+ }
+
+ function tokenString(quote) {
+ return function(stream, state) {
+ var escaped = false, next, end = false;
+ while ((next = stream.next()) != null) {
+ if (next == quote && !escaped) {end = true; break;}
+ escaped = !escaped && next == "\\";
+ }
+ if (end || !(escaped || quote == "`"))
+ state.tokenize = tokenBase;
+ return "string";
+ };
+ }
+
+ function tokenComment(stream, state) {
+ var maybeEnd = false, ch;
+ while (ch = stream.next()) {
+ if (ch == "/" && maybeEnd) {
+ state.tokenize = tokenBase;
+ break;
+ }
+ maybeEnd = (ch == "*");
+ }
+ return "comment";
+ }
+
+ function Context(indented, column, type, align, prev) {
+ this.indented = indented;
+ this.column = column;
+ this.type = type;
+ this.align = align;
+ this.prev = prev;
+ }
+ function pushContext(state, col, type) {
+ return state.context = new Context(state.indented, col, type, null, state.context);
+ }
+ function popContext(state) {
+ var t = state.context.type;
+ if (t == ")" || t == "]" || t == "}")
+ state.indented = state.context.indented;
+ return state.context = state.context.prev;
+ }
+
+ // Interface
+
+ return {
+ startState: function(basecolumn) {
+ return {
+ tokenize: null,
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
+ indented: 0,
+ startOfLine: true
+ };
+ },
+
+ token: function(stream, state) {
+ var ctx = state.context;
+ if (stream.sol()) {
+ if (ctx.align == null) ctx.align = false;
+ state.indented = stream.indentation();
+ state.startOfLine = true;
+ if (ctx.type == "case") ctx.type = "}";
+ }
+ if (stream.eatSpace()) return null;
+ curPunc = null;
+ var style = (state.tokenize || tokenBase)(stream, state);
+ if (style == "comment") return style;
+ if (ctx.align == null) ctx.align = true;
+
+ if (curPunc == "{") pushContext(state, stream.column(), "}");
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
+ else if (curPunc == "case") ctx.type = "case";
+ else if (curPunc == "}" && ctx.type == "}") ctx = popContext(state);
+ else if (curPunc == ctx.type) popContext(state);
+ state.startOfLine = false;
+ return style;
+ },
+
+ indent: function(state, textAfter) {
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
+ var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
+ if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) {
+ state.context.type = "}";
+ return ctx.indented;
+ }
+ var closing = firstChar == ctx.type;
+ if (ctx.align) return ctx.column + (closing ? 0 : 1);
+ else return ctx.indented + (closing ? 0 : indentUnit);
+ },
+
+ electricChars: "{}):",
+ fold: "brace",
+ blockCommentStart: "/*",
+ blockCommentEnd: "*/",
+ lineComment: "//"
+ };
+});
+
+CodeMirror.defineMIME("text/x-go", "go");
+
+});
diff --git a/cmd/mist/assets/muted/lib/matchbrackets.js b/cmd/mist/assets/muted/lib/matchbrackets.js
new file mode 100644
index 000000000..dcdde81df
--- /dev/null
+++ b/cmd/mist/assets/muted/lib/matchbrackets.js
@@ -0,0 +1,117 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
+ (document.documentMode == null || document.documentMode < 8);
+
+ var Pos = CodeMirror.Pos;
+
+ var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
+
+ function findMatchingBracket(cm, where, strict, config) {
+ var line = cm.getLineHandle(where.line), pos = where.ch - 1;
+ var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
+ if (!match) return null;
+ var dir = match.charAt(1) == ">" ? 1 : -1;
+ if (strict && (dir > 0) != (pos == where.ch)) return null;
+ var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
+
+ var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
+ if (found == null) return null;
+ return {from: Pos(where.line, pos), to: found && found.pos,
+ match: found && found.ch == match.charAt(0), forward: dir > 0};
+ }
+
+ // bracketRegex is used to specify which type of bracket to scan
+ // should be a regexp, e.g. /[[\]]/
+ //
+ // Note: If "where" is on an open bracket, then this bracket is ignored.
+ //
+ // Returns false when no bracket was found, null when it reached
+ // maxScanLines and gave up
+ function scanForBracket(cm, where, dir, style, config) {
+ var maxScanLen = (config && config.maxScanLineLength) || 10000;
+ var maxScanLines = (config && config.maxScanLines) || 1000;
+
+ var stack = [];
+ var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
+ var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
+ : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
+ for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
+ var line = cm.getLine(lineNo);
+ if (!line) continue;
+ var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
+ if (line.length > maxScanLen) continue;
+ if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
+ for (; pos != end; pos += dir) {
+ var ch = line.charAt(pos);
+ if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
+ var match = matching[ch];
+ if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
+ else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
+ else stack.pop();
+ }
+ }
+ }
+ return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
+ }
+
+ function matchBrackets(cm, autoclear, config) {
+ // Disable brace matching in long lines, since it'll cause hugely slow updates
+ var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
+ var marks = [], ranges = cm.listSelections();
+ for (var i = 0; i < ranges.length; i++) {
+ var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config);
+ if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
+ var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
+ marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
+ if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
+ marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
+ }
+ }
+
+ if (marks.length) {
+ // Kludge to work around the IE bug from issue #1193, where text
+ // input stops going to the textare whever this fires.
+ if (ie_lt8 && cm.state.focused) cm.display.input.focus();
+
+ var clear = function() {
+ cm.operation(function() {
+ for (var i = 0; i < marks.length; i++) marks[i].clear();
+ });
+ };
+ if (autoclear) setTimeout(clear, 800);
+ else return clear;
+ }
+ }
+
+ var currentlyHighlighted = null;
+ function doMatchBrackets(cm) {
+ cm.operation(function() {
+ if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
+ currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
+ });
+ }
+
+ CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
+ if (old && old != CodeMirror.Init)
+ cm.off("cursorActivity", doMatchBrackets);
+ if (val) {
+ cm.state.matchBrackets = typeof val == "object" ? val : {};
+ cm.on("cursorActivity", doMatchBrackets);
+ }
+ });
+
+ CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
+ CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){
+ return findMatchingBracket(this, pos, strict, config);
+ });
+ CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
+ return scanForBracket(this, pos, dir, style, config);
+ });
+});
diff --git a/cmd/mist/assets/muted/muted.js b/cmd/mist/assets/muted/muted.js
new file mode 100644
index 000000000..467411577
--- /dev/null
+++ b/cmd/mist/assets/muted/muted.js
@@ -0,0 +1,78 @@
+// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+// MA 02110-1301 USA
+
+// Helper function for generating pseudo callbacks and sending data to the QML part of the application
+function postData(data, cb) {
+ data._seed = Math.floor(Math.random() * 1000000)
+ if(cb) {
+ Muted._callbacks[data._seed] = cb;
+ }
+
+ if(data.args === undefined) {
+ data.args = [];
+ }
+
+ navigator.qt.postMessage(JSON.stringify(data));
+}
+
+window.Muted = {
+ prototype: Object(),
+}
+
+window.Muted._callbacks = {}
+window.Muted._onCallbacks = {}
+
+function debug(/**/) {
+ console.log("hello world")
+
+ var args = arguments;
+ var msg = ""
+ for(var i = 0; i < args.length; i++){
+ if(typeof args[i] == "object") {
+ msg += " " + JSON.stringify(args[i])
+ } else {
+ msg += args[i]
+ }
+ }
+
+ document.querySelector("#debugger").innerHTML += "<div class='line'><div class='col1'></div><div class='col2'>"+msg+"</div></div>";
+}
+console.log = function() {
+ var args = []
+ for(var i = 0; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ }
+ postData({call:"log", args:args})
+}
+
+navigator.qt.onmessage = function(ev) {
+ var data = JSON.parse(ev.data)
+
+ if(data._event !== undefined) {
+ Muted.trigger(data._event, data.data);
+ } else {
+ if(data._seed) {
+ var cb = Muted._callbacks[data._seed];
+ if(cb) {
+ // Call the callback
+ cb(data.data);
+ // Remove the "trigger" callback
+ delete Muted._callbacks[ev._seed];
+ }
+ }
+ }
+}
diff --git a/cmd/mist/assets/net.png b/cmd/mist/assets/net.png
new file mode 100644
index 000000000..65a20ea00
--- /dev/null
+++ b/cmd/mist/assets/net.png
Binary files differ
diff --git a/cmd/mist/assets/network.png b/cmd/mist/assets/network.png
new file mode 100644
index 000000000..0a9ffe2ec
--- /dev/null
+++ b/cmd/mist/assets/network.png
Binary files differ
diff --git a/cmd/mist/assets/new.png b/cmd/mist/assets/new.png
new file mode 100644
index 000000000..e80096748
--- /dev/null
+++ b/cmd/mist/assets/new.png
Binary files differ
diff --git a/cmd/mist/assets/pick.png b/cmd/mist/assets/pick.png
new file mode 100644
index 000000000..2f5a261c2
--- /dev/null
+++ b/cmd/mist/assets/pick.png
Binary files differ
diff --git a/cmd/mist/assets/qml/QmlApp.qml b/cmd/mist/assets/qml/QmlApp.qml
new file mode 100644
index 000000000..f5c503f4c
--- /dev/null
+++ b/cmd/mist/assets/qml/QmlApp.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import Ethereum 1.0
+
+ApplicationWindow {
+ minimumWidth: 500
+ maximumWidth: 500
+ maximumHeight: 400
+ minimumHeight: 400
+
+ function onNewBlockCb(block) {
+ console.log("Please overwrite onNewBlock(block):", block)
+ }
+ function onObjectChangeCb(stateObject) {
+ console.log("Please overwrite onObjectChangeCb(object)", stateObject)
+ }
+ function onStorageChangeCb(storageObject) {
+ var ev = ["storage", storageObject.stateAddress, storageObject.address].join(":");
+ console.log("Please overwrite onStorageChangeCb(object)", ev)
+ }
+}
diff --git a/cmd/mist/assets/qml/depricated_browser.qml b/cmd/mist/assets/qml/depricated_browser.qml
new file mode 100644
index 000000000..7fb1f2068
--- /dev/null
+++ b/cmd/mist/assets/qml/depricated_browser.qml
@@ -0,0 +1,486 @@
+import QtQuick 2.1
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+import QtQuick.Controls 1.0;
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Layouts 1.0;
+import QtQuick.Window 2.1;
+import Ethereum 1.0
+
+Rectangle {
+ id: window
+ anchors.fill: parent
+ color: "#00000000"
+
+ property var title: "DApps"
+ property var iconSource: "../browser.png"
+ property var menuItem
+ property var hideUrl: true
+
+ property alias url: webview.url
+ property alias windowTitle: webview.title
+ property alias webView: webview
+
+ property var cleanPath: false
+ property var open: function(url) {
+ if(!window.cleanPath) {
+ var uri = url;
+ if(!/.*\:\/\/.*/.test(uri)) {
+ uri = "http://" + uri;
+ }
+
+ var reg = /(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.eth)(.*)/
+
+ if(reg.test(uri)) {
+ uri.replace(reg, function(match, pre, domain, path) {
+ uri = pre;
+
+ var lookup = eth.lookupDomain(domain.substring(0, domain.length - 4));
+ var ip = [];
+ for(var i = 0, l = lookup.length; i < l; i++) {
+ ip.push(lookup.charCodeAt(i))
+ }
+
+ if(ip.length != 0) {
+ uri += lookup;
+ } else {
+ uri += domain;
+ }
+
+ uri += path;
+ });
+ }
+
+ window.cleanPath = true;
+
+ webview.url = uri;
+
+ //uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
+ uriNav.text = uri;
+ } else {
+ // Prevent inf loop.
+ window.cleanPath = false;
+ }
+ }
+
+ Component.onCompleted: {
+ webview.url = "http://etherian.io"
+ }
+
+ function messages(messages, id) {
+ // Bit of a cheat to get proper JSON
+ var m = JSON.parse(JSON.parse(JSON.stringify(messages)))
+ webview.postEvent("eth_changed", id, m);
+ }
+
+ function onShhMessage(message, id) {
+ webview.postEvent("shh_changed", id, message)
+ }
+
+ Item {
+ objectName: "root"
+ id: root
+ anchors.fill: parent
+ state: "inspectorShown"
+
+ RowLayout {
+ id: navBar
+ height: 40
+ anchors {
+ left: parent.left
+ right: parent.right
+ leftMargin: 7
+ }
+
+ Button {
+ id: back
+ onClicked: {
+ webview.goBack()
+ }
+ style: ButtonStyle {
+ background: Image {
+ source: "../back.png"
+ width: 30
+ height: 30
+ }
+ }
+ }
+
+ TextField {
+ anchors {
+ left: back.right
+ right: toggleInspector.left
+ leftMargin: 10
+ rightMargin: 10
+ }
+ text: webview.url;
+ id: uriNav
+ y: parent.height / 2 - this.height / 2
+
+ Keys.onReturnPressed: {
+ webview.url = this.text;
+ }
+ }
+
+ Button {
+ id: toggleInspector
+ anchors {
+ right: parent.right
+ }
+ iconSource: "../bug.png"
+ onClicked: {
+ if(inspector.visible == true){
+ inspector.visible = false
+ }else{
+ inspector.visible = true
+ inspector.url = webview.experimental.remoteInspectorUrl
+ }
+ }
+ }
+ }
+
+ // Border
+ Rectangle {
+ id: divider
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: navBar.bottom
+ }
+ z: -1
+ height: 1
+ color: "#CCCCCC"
+ }
+
+ ScrollView {
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ top: divider.bottom
+ }
+ WebView {
+ objectName: "webView"
+ id: webview
+ anchors.fill: parent
+
+ function sendMessage(data) {
+ webview.experimental.postMessage(JSON.stringify(data))
+ }
+
+ experimental.preferences.javascriptEnabled: true
+ experimental.preferences.webAudioEnabled: true
+ experimental.preferences.pluginsEnabled: true
+ experimental.preferences.navigatorQtObjectEnabled: true
+ experimental.preferences.developerExtrasEnabled: true
+ experimental.preferences.webGLEnabled: true
+ experimental.preferences.notificationsEnabled: true
+ experimental.preferences.localStorageEnabled: true
+ experimental.userAgent:"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Mist/0.1 Safari/537.36"
+
+ experimental.itemSelector: MouseArea {
+ // To avoid conflicting with ListView.model when inside Initiator context.
+ property QtObject selectorModel: model
+ anchors.fill: parent
+ onClicked: selectorModel.reject()
+
+ Menu {
+ visible: true
+ id: itemSelector
+
+ Instantiator {
+ model: selectorModel.items
+ delegate: MenuItem {
+ text: model.text
+ onTriggered: {
+ selectorModel.accept(index)
+ }
+ }
+ onObjectAdded: itemSelector.insertItem(index, object)
+ onObjectRemoved: itemSelector.removeItem(object)
+ }
+ }
+
+ Component.onCompleted: {
+ itemSelector.popup()
+ }
+ }
+ experimental.userScripts: ["../ext/q.js", "../ext/ethereum.js/dist/ethereum.min.js", "../ext/setup.js"]
+ experimental.onMessageReceived: {
+ //console.log("[onMessageReceived]: ", message.data)
+ var data = JSON.parse(message.data)
+
+ try {
+ switch(data.call) {
+ case "eth_compile":
+ postData(data._id, eth.compile(data.args[0]))
+ break
+
+ case "eth_coinbase":
+ postData(data._id, eth.coinBase())
+
+ case "eth_account":
+ postData(data._id, eth.key().address);
+
+ case "eth_istening":
+ postData(data._id, eth.isListening())
+
+ break
+
+ case "eth_mining":
+ postData(data._id, eth.isMining())
+
+ break
+
+ case "eth_peerCount":
+ postData(data._id, eth.peerCount())
+
+ break
+
+ case "eth_countAt":
+ require(1)
+ postData(data._id, eth.txCountAt(data.args[0]))
+
+ break
+
+ case "eth_codeAt":
+ require(1)
+ var code = eth.codeAt(data.args[0])
+ postData(data._id, code);
+
+ break
+
+ case "eth_blockByNumber":
+ require(1)
+ var block = eth.blockByNumber(data.args[0])
+ postData(data._id, block)
+ break
+
+ case "eth_blockByHash":
+ require(1)
+ var block = eth.blockByHash(data.args[0])
+ postData(data._id, block)
+ break
+
+ require(2)
+ var block = eth.blockByHash(data.args[0])
+ postData(data._id, block.transactions[data.args[1]])
+ break
+
+ case "eth_transactionByHash":
+ case "eth_transactionByNumber":
+ require(2)
+
+ var block;
+ if (data.call === "transactionByHash")
+ block = eth.blockByHash(data.args[0])
+ else
+ block = eth.blockByNumber(data.args[0])
+
+ var tx = block.transactions.get(data.args[1])
+
+ postData(data._id, tx)
+ break
+
+ case "eth_uncleByHash":
+ case "eth_uncleByNumber":
+ require(2)
+
+ var block;
+ if (data.call === "uncleByHash")
+ block = eth.blockByHash(data.args[0])
+ else
+ block = eth.blockByNumber(data.args[0])
+
+ var uncle = block.uncles.get(data.args[1])
+
+ postData(data._id, uncle)
+
+ break
+
+ case "transact":
+ require(5)
+
+ var tx = eth.transact(data.args)
+ postData(data._id, tx)
+
+ break
+
+ case "eth_stateAt":
+ require(2);
+
+ var storage = eth.storageAt(data.args[0], data.args[1]);
+ postData(data._id, storage)
+
+ break
+
+ case "eth_call":
+ require(1);
+ var ret = eth.call(data.args)
+ postData(data._id, ret)
+ break
+
+ case "eth_balanceAt":
+ require(1);
+
+ postData(data._id, eth.balanceAt(data.args[0]));
+ break
+
+ case "eth_watch":
+ require(2)
+ eth.watch(data.args[0], data.args[1])
+
+ case "eth_disconnect":
+ require(1)
+ postData(data._id, null)
+ break;
+
+ case "eth_newFilterString":
+ require(1)
+ var id = eth.newFilterString(data.args[0], window)
+ postData(data._id, id);
+ break;
+
+ case "eth_newFilter":
+ require(1)
+ var id = eth.newFilter(data.args[0], window)
+
+ postData(data._id, id);
+ break;
+
+ case "eth_filterLogs":
+ require(1);
+
+ var messages = eth.messages(data.args[0]);
+ var m = JSON.parse(JSON.parse(JSON.stringify(messages)))
+ postData(data._id, m);
+
+ break;
+
+ case "eth_deleteFilter":
+ require(1);
+ eth.uninstallFilter(data.args[0])
+ break;
+
+
+ case "shh_newFilter":
+ require(1);
+ var id = shh.watch(data.args[0], window);
+ postData(data._id, id);
+ break;
+
+ case "shh_newIdentity":
+ var id = shh.newIdentity()
+ postData(data._id, id)
+
+ break
+
+ case "shh_post":
+ require(1);
+
+ var params = data.args[0];
+ var fields = ["payload", "to", "from"];
+ for(var i = 0; i < fields.length; i++) {
+ params[fields[i]] = params[fields[i]] || "";
+ }
+ if(typeof params.payload !== "object") { params.payload = [params.payload]; } //params.payload = params.payload.join(""); }
+ params.topics = params.topics || [];
+ params.priority = params.priority || 1000;
+ params.ttl = params.ttl || 100;
+
+ shh.post(params.payload, params.to, params.from, params.topics, params.priority, params.ttl);
+
+ break;
+
+ case "shh_getMessages":
+ require(1);
+
+ var m = shh.messages(data.args[0]);
+ var messages = JSON.parse(JSON.parse(JSON.stringify(m)));
+ postData(data._id, messages);
+
+ break;
+
+ case "ssh_newGroup":
+ postData(data._id, "");
+ break;
+ }
+ } catch(e) {
+ console.log(data.call + ": " + e)
+
+ postData(data._id, null);
+ }
+ }
+
+ function post(seed, data) {
+ postData(data._id, data)
+ }
+ function require(args, num) {
+ if(args.length < num) {
+ throw("required argument count of "+num+" got "+args.length);
+ }
+ }
+ function postData(seed, data) {
+ webview.experimental.postMessage(JSON.stringify({data: data, _id: seed}))
+ }
+ function postEvent(event, id, data) {
+ webview.experimental.postMessage(JSON.stringify({data: data, _id: id, _event: event}))
+ }
+ function onWatchedCb(data, id) {
+ var messages = JSON.parse(data)
+ postEvent("watched:"+id, messages)
+ }
+ function onNewBlockCb(block) {
+ postEvent("block:new", block)
+ }
+ function onObjectChangeCb(stateObject) {
+ postEvent("object:"+stateObject.address(), stateObject)
+ }
+ function onStorageChangeCb(storageObject) {
+ var ev = ["storage", storageObject.stateAddress, storageObject.address].join(":");
+ postEvent(ev, [storageObject.address, storageObject.value])
+ }
+ }
+ }
+
+ Rectangle {
+ id: sizeGrip
+ color: "gray"
+ visible: false
+ height: 10
+ anchors {
+ left: root.left
+ right: root.right
+ }
+ y: Math.round(root.height * 2 / 3)
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: sizeGrip
+ drag.minimumY: 0
+ drag.maximumY: root.height
+ drag.axis: Drag.YAxis
+ }
+ }
+
+ WebView {
+ id: inspector
+ visible: false
+ anchors {
+ left: root.left
+ right: root.right
+ top: sizeGrip.bottom
+ bottom: root.bottom
+ }
+ }
+
+ states: [
+ State {
+ name: "inspectorShown"
+ PropertyChanges {
+ target: inspector
+ }
+ }
+ ]
+ }
+}
diff --git a/cmd/mist/assets/qml/first_run.qml b/cmd/mist/assets/qml/first_run.qml
new file mode 100644
index 000000000..0b1dac4c6
--- /dev/null
+++ b/cmd/mist/assets/qml/first_run.qml
@@ -0,0 +1,155 @@
+import QtQuick 2.0
+import Ethereum 1.0
+
+// Which ones do we actually need?
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import QtQuick.Dialogs 1.1
+
+ApplicationWindow {
+ id: wizardRoot
+ width: 500
+ height: 400
+ title: "Ethereal first run setup"
+
+ Column {
+ spacing: 5
+ anchors.leftMargin: 10
+ anchors.left: parent.left
+
+ Text {
+ visible: true
+ text: "<h2>Ethereal setup</h2>"
+ }
+
+ Column {
+ id: restoreColumn
+ spacing: 5
+ Text {
+ visible: true
+ font.pointSize: 14
+ text: "Restore your Ethereum account"
+ id: restoreLabel
+ }
+
+ TextField {
+ id: txPrivKey
+ width: 480
+ placeholderText: "Private key or mnemonic words"
+ focus: true
+ onTextChanged: {
+ if(this.text.length == 64){
+ detailLabel.text = "Private (hex) key detected."
+ actionButton.enabled = true
+ }
+ else if(this.text.split(" ").length == 24){
+ detailLabel.text = "Mnemonic key detected."
+ actionButton.enabled = true
+ }else{
+ detailLabel.text = ""
+ actionButton.enabled = false
+ }
+ }
+ }
+ Row {
+ spacing: 10
+ Button {
+ id: actionButton
+ text: "Restore"
+ enabled: false
+ onClicked: {
+ var success = lib.importAndSetPrivKey(txPrivKey.text)
+ if(success){
+ importedDetails.visible = true
+ restoreColumn.visible = false
+ newKey.visible = false
+ wizardRoot.height = 120
+ }
+ }
+ }
+ Text {
+ id: detailLabel
+ font.pointSize: 12
+ anchors.topMargin: 10
+ }
+ }
+ }
+ Column {
+ id: importedDetails
+ visible: false
+ Text {
+ text: "<b>Your account has been imported. Please close the application and restart it again to let the changes take effect.</b>"
+ wrapMode: Text.WordWrap
+ width: 460
+ }
+ }
+ Column {
+ spacing: 5
+ id: newDetailsColumn
+ visible: false
+ Text {
+ font.pointSize: 14
+ text: "Your account details"
+ }
+ Label {
+ text: "Address"
+ }
+ TextField {
+ id: addressInput
+ readOnly:true
+ width: 480
+ }
+ Label {
+ text: "Private key"
+ }
+ TextField {
+ id: privkeyInput
+ readOnly:true
+ width: 480
+ }
+ Label {
+ text: "Mnemonic words"
+ }
+ TextField {
+ id: mnemonicInput
+ readOnly:true
+ width: 480
+ }
+ Label {
+ text: "<b>A new account has been created. Please take the time to write down the <i>24 words</i>. You can use those to restore your account at a later date.</b>"
+ wrapMode: Text.WordWrap
+ width: 480
+ }
+ Label {
+ text: "Please restart the application once you have completed the steps above."
+ wrapMode: Text.WordWrap
+ width: 480
+ }
+ }
+
+ }
+ Button {
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.rightMargin: 10
+ anchors.bottomMargin: 10
+ id: newKey
+ text: "I don't have an account yet"
+ onClicked: {
+ var res = lib.createAndSetPrivKey()
+ mnemonicInput.text = res[0]
+ addressInput.text = res[1]
+ privkeyInput.text = res[2]
+
+ // Hide restore
+ restoreColumn.visible = false
+
+ // Show new details
+ newDetailsColumn.visible = true
+ newKey.visible = false
+ }
+ }
+}
diff --git a/cmd/mist/assets/qml/fonts/Simple-Line-Icons.ttf b/cmd/mist/assets/qml/fonts/Simple-Line-Icons.ttf
new file mode 100755
index 000000000..2194f1f87
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/Simple-Line-Icons.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-Black.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-Black.ttf
new file mode 100644
index 000000000..be1a3108e
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-Black.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-BlackIt.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-BlackIt.ttf
new file mode 100644
index 000000000..ac5c4ef7c
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-BlackIt.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-Bold.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-Bold.ttf
new file mode 100644
index 000000000..f47161c6b
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-Bold.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-BoldIt.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-BoldIt.ttf
new file mode 100644
index 000000000..6b3db698b
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-BoldIt.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLight.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLight.ttf
new file mode 100644
index 000000000..0a3e51fdb
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLight.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLightIt.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLightIt.ttf
new file mode 100644
index 000000000..a0eb86aca
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-ExtraLightIt.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-It.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-It.ttf
new file mode 100644
index 000000000..fcc95fc7c
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-It.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-Light.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-Light.ttf
new file mode 100644
index 000000000..9cae13c97
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-Light.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-LightIt.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-LightIt.ttf
new file mode 100644
index 000000000..2ed784284
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-LightIt.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-Regular.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-Regular.ttf
new file mode 100644
index 000000000..8e8255e17
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-Regular.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-Semibold.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-Semibold.ttf
new file mode 100644
index 000000000..121ee9bbf
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-Semibold.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSansPro-SemiboldIt.ttf b/cmd/mist/assets/qml/fonts/SourceSansPro-SemiboldIt.ttf
new file mode 100644
index 000000000..6ceaa885f
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSansPro-SemiboldIt.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSerifPro-Bold.ttf b/cmd/mist/assets/qml/fonts/SourceSerifPro-Bold.ttf
new file mode 100644
index 000000000..ac7837fd9
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSerifPro-Bold.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSerifPro-Regular.ttf b/cmd/mist/assets/qml/fonts/SourceSerifPro-Regular.ttf
new file mode 100644
index 000000000..7201a8890
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSerifPro-Regular.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/fonts/SourceSerifPro-Semibold.ttf b/cmd/mist/assets/qml/fonts/SourceSerifPro-Semibold.ttf
new file mode 100644
index 000000000..db2fc804b
--- /dev/null
+++ b/cmd/mist/assets/qml/fonts/SourceSerifPro-Semibold.ttf
Binary files differ
diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml
new file mode 100644
index 000000000..8558ebd51
--- /dev/null
+++ b/cmd/mist/assets/qml/main.qml
@@ -0,0 +1,1040 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+import "../ext/filter.js" as Eth
+import "../ext/http.js" as Http
+
+
+ApplicationWindow {
+ id: root
+
+ //flags: Qt.FramelessWindowHint
+ // Use this to make the window frameless. But then you'll need to do move and resize by hand
+
+ property var ethx : Eth.ethx
+ property var catalog;
+
+ width: 1200
+ height: 820
+ minimumHeight: 600
+ minimumWidth: 800
+
+ title: "Mist"
+
+ TextField {
+ id: copyElementHax
+ visible: false
+ }
+
+ function copyToClipboard(text) {
+ copyElementHax.text = text
+ copyElementHax.selectAll()
+ copyElementHax.copy()
+ }
+
+ // Takes care of loading all default plugins
+ Component.onCompleted: {
+
+ catalog = addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin", active: true});
+
+ var walletWeb = addPlugin("./views/browser.qml", {noAdd: true, close: false, section: "ethereum", active: false});
+ walletWeb.view.url = "http://ethereum-dapp-wallet.meteor.com/";
+ walletWeb.menuItem.title = "Wallet";
+
+ addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "legacy", active: false});
+ addPlugin("./views/network.qml", {noAdd: true, close: false, section: "ethereum", active: false});
+
+ /* var whisperTab = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "ethereum", active: false});
+ whisperTab.view.url = "http://ethereum-dapp-whisper-client.meteor.com/";
+ whisperTab.menuItem.title = "Whisper Chat";
+*/
+ addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "legacy"});
+ addPlugin("./views/transaction.qml", {noAdd: true, close: false, section: "legacy"});
+ addPlugin("./views/whisper.qml", {noAdd: true, close: false, section: "legacy"});
+ addPlugin("./views/chain.qml", {noAdd: true, close: false, section: "legacy"});
+ addPlugin("./views/pending_tx.qml", {noAdd: true, close: false, section: "legacy"});
+ addPlugin("./views/info.qml", {noAdd: true, close: false, section: "legacy"});
+
+ mainSplit.setView(catalog.view, catalog.menuItem);
+
+ //newBrowserTab("http://ethereum-dapp-catalog.meteor.com");
+
+ // Command setup
+ gui.sendCommand(0)
+ }
+
+ function activeView(view, menuItem) {
+ mainSplit.setView(view, menuItem)
+ /*if (view.hideUrl) {
+ urlPane.visible = false;
+ mainView.anchors.top = rootView.top
+ } else {
+ urlPane.visible = true;
+ mainView.anchors.top = divider.bottom
+ }*/
+
+ }
+
+ function addViews(view, path, options) {
+ var views = mainSplit.addComponent(view, options)
+ views.menuItem.path = path
+
+ mainSplit.views.push(views);
+
+ if(!options.noAdd) {
+ gui.addPlugin(path)
+ }
+
+ return views
+ }
+
+ function addPlugin(path, options) {
+ try {
+ if(typeof(path) === "string" && /^https?/.test(path)) {
+ console.log('load http')
+ Http.request(path, function(o) {
+ if(o.status === 200) {
+ var view = Qt.createQmlObject(o.responseText, mainView, path)
+ addViews(view, path, options)
+ }
+ })
+
+ return
+ }
+
+ var component = Qt.createComponent(path);
+ if(component.status != Component.Ready) {
+ if(component.status == Component.Error) {
+ ethx.note("error: ", component.errorString());
+ }
+
+ return
+ }
+
+ var view = mainView.createView(component, options)
+ var views = addViews(view, path, options)
+
+ return views
+ } catch(e) {
+ console.log(e)
+ }
+ }
+
+ function newBrowserTab(url) {
+
+ var urlMatches = url.toString().match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
+ var requestedDomain = urlMatches && urlMatches[1];
+
+ var domainAlreadyOpen = false;
+
+ for(var i = 0; i < mainSplit.views.length; i++) {
+ if (mainSplit.views[i].view.url) {
+ var matches = mainSplit.views[i].view.url.toString().match(/^[a-z]*\:\/\/(?:www\.)?([^\/?#]+)(?:[\/?#]|$)/i);
+ var existingDomain = matches && matches[1];
+ if (requestedDomain == existingDomain) {
+ domainAlreadyOpen = true;
+
+ if (mainSplit.views[i].view.url != url){
+ mainSplit.views[i].view.url = url;
+ }
+
+ activeView(mainSplit.views[i].view, mainSplit.views[i].menuItem);
+ }
+ }
+ }
+
+ if (!domainAlreadyOpen) {
+ var window = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "apps", active: true});
+ window.view.url = url;
+ window.menuItem.title = "Mist";
+ activeView(window.view, window.menuItem);
+ }
+ }
+
+
+
+ menuBar: MenuBar {
+ Menu {
+ title: "File"
+ MenuItem {
+ text: "New tab"
+ shortcut: "Ctrl+t"
+ onTriggered: {
+ activeView(catalog.view, catalog.menuItem);
+ }
+ }
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: "Import key"
+ shortcut: "Ctrl+i"
+ onTriggered: {
+ generalFileDialog.show(true, function(path) {
+ gui.importKey(path)
+ })
+ }
+ }
+
+ MenuItem {
+ text: "Export keys"
+ shortcut: "Ctrl+e"
+ onTriggered: {
+ generalFileDialog.show(false, function(path) {
+ })
+ }
+ }
+
+ MenuItem {
+ text: "Generate key"
+ shortcut: "Ctrl+k"
+ onTriggered: gui.generateKey()
+ }
+ }
+
+ Menu {
+ title: "Developer"
+ MenuItem {
+ text: "Import Tx"
+ onTriggered: {
+ txImportDialog.visible = true
+ }
+ }
+
+ MenuItem {
+ text: "Run JS file"
+ onTriggered: {
+ generalFileDialog.show(true, function(path) {
+ eth.evalJavascriptFile(path)
+ })
+ }
+ }
+
+ MenuItem {
+ text: "Dump state"
+ onTriggered: {
+ generalFileDialog.show(false, function(path) {
+ // Empty hash for latest
+ gui.dumpState("", path)
+ })
+ }
+ }
+
+ MenuSeparator {}
+ }
+
+ Menu {
+ title: "Network"
+ MenuItem {
+ text: "Add Peer"
+ shortcut: "Ctrl+p"
+ onTriggered: {
+ addPeerWin.visible = true
+ }
+ }
+ MenuItem {
+ text: "Show Peers"
+ shortcut: "Ctrl+e"
+ onTriggered: {
+ peerWindow.visible = true
+ }
+ }
+ }
+
+ Menu {
+ title: "Help"
+ MenuItem {
+ text: "About"
+ onTriggered: {
+ aboutWin.visible = true
+ }
+ }
+ }
+
+ }
+
+ property var blockModel: ListModel {
+ id: blockModel
+ }
+
+ SplitView {
+ property var views: [];
+
+ id: mainSplit
+ anchors.fill: parent
+ //resizing: false // this is NOT where we remove that damning resizing handle..
+ handleDelegate: Item {
+ //This handle is a way to remove the line between the split views
+ Rectangle {
+ anchors.fill: parent
+ }
+ }
+
+ function setView(view, menu) {
+ for(var i = 0; i < views.length; i++) {
+ views[i].view.visible = false
+ views[i].menuItem.setSelection(false)
+ }
+ view.visible = true
+ menu.setSelection(true)
+ }
+
+ function addComponent(view, options) {
+ view.visible = false
+ view.anchors.fill = mainView
+
+ var menuItem = menu.createMenuItem(view, options);
+ if( view.hasOwnProperty("menuItem") ) {
+ view.menuItem = menuItem;
+ }
+
+ if( view.hasOwnProperty("onReady") ) {
+ view.onReady.call(view)
+ }
+
+ if( options.active ) {
+ setView(view, menuItem)
+ }
+
+
+ return {view: view, menuItem: menuItem}
+ }
+
+ /*********************
+ * Main menu.
+ ********************/
+ Rectangle {
+ id: menu
+ Layout.minimumWidth: 192
+ Layout.maximumWidth: 192
+
+ FontLoader {
+ id: sourceSansPro
+ source: "fonts/SourceSansPro-Regular.ttf"
+ }
+ FontLoader {
+ source: "fonts/SourceSansPro-Semibold.ttf"
+ }
+ FontLoader {
+ source: "fonts/SourceSansPro-Bold.ttf"
+ }
+ FontLoader {
+ source: "fonts/SourceSansPro-Black.ttf"
+ }
+ FontLoader {
+ source: "fonts/SourceSansPro-Light.ttf"
+ }
+ FontLoader {
+ source: "fonts/SourceSansPro-ExtraLight.ttf"
+ }
+ FontLoader {
+ id: simpleLineIcons
+ source: "fonts/Simple-Line-Icons.ttf"
+ }
+
+ Rectangle {
+ color: "steelblue"
+ anchors.fill: parent
+
+ MouseArea {
+ anchors.fill: parent
+ property real lastMouseX: 0
+ property real lastMouseY: 0
+ onPressed: {
+ lastMouseX = mouseX
+ lastMouseY = mouseY
+ }
+ onPositionChanged: {
+ root.x += (mouseX - lastMouseX)
+ root.y += (mouseY - lastMouseY)
+ }
+ /*onDoubleClicked: {
+ //!maximized ? view.set_max() : view.set_normal()}
+ visibility = "Minimized"
+ }*/
+ }
+ }
+
+
+
+ anchors.top: parent.top
+ Rectangle {
+ width: parent.height
+ height: parent.width
+ anchors.centerIn: parent
+ rotation: 90
+
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#E2DEDE" }
+ GradientStop { position: 0.1; color: "#EBE8E8" }
+ GradientStop { position: 1.0; color: "#EBE8E8" }
+ }
+ }
+
+ Component {
+ id: menuItemTemplate
+ Rectangle {
+ id: menuItem
+ property var view;
+ property var path;
+ property var closable;
+ property var badgeContent;
+
+ property alias title: label.text
+ property alias icon: icon.source
+ property alias secondaryTitle: secondary.text
+ property alias badgeNumber: badgeNumberLabel.text
+ property alias badgeIcon: badgeIconLabel.text
+
+ function setSelection(on) {
+ sel.visible = on
+
+ if (this.closable == true) {
+ closeIcon.visible = on
+ }
+ }
+
+ function setAsBigButton(on) {
+ newAppButton.visible = on
+ label.visible = !on
+ buttonLabel.visible = on
+ }
+
+ width: 192
+ height: 55
+ color: "#00000000"
+
+ anchors {
+ left: parent.left
+ leftMargin: 4
+ }
+
+ Rectangle {
+ // New App Button
+ id: newAppButton
+ visible: false
+ anchors.fill: parent
+ anchors.rightMargin: 8
+ border.width: 0
+ radius: 5
+ height: 55
+ width: 180
+ color: "#F3F1F3"
+ }
+
+ Rectangle {
+ id: sel
+ visible: false
+ anchors.fill: parent
+ color: "#00000000"
+ Rectangle {
+ id: r
+ anchors.fill: parent
+ border.width: 0
+ radius: 5
+ color: "#FAFAFA"
+ }
+ Rectangle {
+ anchors {
+ top: r.top
+ bottom: r.bottom
+ right: r.right
+ }
+ width: 10
+ color: "#FAFAFA"
+ border.width:0
+
+ Rectangle {
+ // Small line on top of selection. What's this for?
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
+ height: 1
+ color: "#FAFAFA"
+ }
+
+ Rectangle {
+ // Small line on bottom of selection. What's this for again?
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ height: 1
+ color: "#FAFAFA"
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: {
+ activeView(view, menuItem);
+ }
+ onEntered: {
+ if (parent.closable == true) {
+ closeIcon.visible = sel.visible
+ }
+ }
+ onExited: {
+ closeIcon.visible = false
+ }
+ }
+
+ Image {
+ id: icon
+ height: 28
+ width: 28
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ leftMargin: 6
+ }
+ }
+
+ Text {
+ id: buttonLabel
+ visible: false
+ text: "GO TO NEW APP"
+ font.family: sourceSansPro.name
+ font.weight: Font.DemiBold
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ color: "#AAA0A0"
+ }
+
+ Text {
+ id: label
+ font.family: sourceSansPro.name
+ font.weight: Font.DemiBold
+ elide: Text.ElideRight
+ x:250
+ color: "#665F5F"
+ font.pixelSize: 14
+ anchors {
+ left: icon.right
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ leftMargin: 6
+ rightMargin: 8
+ verticalCenterOffset: (secondaryTitle == "") ? 0 : -10;
+ }
+
+
+
+
+ }
+
+ Text {
+ id: secondary
+ //only shows secondary title if there's no badge
+ visible: (badgeContent == "icon" || badgeContent == "number" )? false : true
+ font.family: sourceSansPro.name
+ font.weight: Font.Light
+ anchors {
+ left: icon.right
+ leftMargin: 6
+ top: label.bottom
+ }
+ color: "#6691C2"
+ font.pixelSize: 12
+ }
+
+ Rectangle {
+ id: closeIcon
+ visible: false
+ width: 10
+ height: 10
+ color: "#FAFAFA"
+ anchors {
+ fill: icon
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ menuItem.closeApp()
+ }
+ }
+
+ Text {
+
+ font.family: simpleLineIcons.name
+ anchors {
+ centerIn: parent
+ }
+ color: "#665F5F"
+ font.pixelSize: 20
+ text: "\ue082"
+ }
+ }
+
+ Rectangle {
+ id: badge
+ visible: (badgeContent == "icon" || badgeContent == "number" )? true : false
+ width: 32
+ color: "#05000000"
+ anchors {
+ right: parent.right;
+ top: parent.top;
+ bottom: parent.bottom;
+ rightMargin: 4;
+ }
+
+ Text {
+ id: badgeIconLabel
+ visible: (badgeContent == "icon") ? true : false;
+ font.family: simpleLineIcons.name
+ anchors {
+ centerIn: parent
+ }
+ horizontalAlignment: Text.AlignCenter
+ color: "#AAA0A0"
+ font.pixelSize: 20
+ text: badgeIcon
+ }
+
+ Text {
+ id: badgeNumberLabel
+ visible: (badgeContent == "number") ? true : false;
+ anchors {
+ centerIn: parent
+ }
+ horizontalAlignment: Text.AlignCenter
+ font.family: sourceSansPro.name
+ font.weight: Font.Light
+ color: "#AAA0A0"
+ font.pixelSize: 18
+ text: badgeNumber
+ }
+ }
+
+
+
+ function closeApp() {
+ if(!this.closable) { return; }
+
+ if(this.view.hasOwnProperty("onDestroy")) {
+ this.view.onDestroy.call(this.view)
+ }
+
+ this.view.destroy()
+ this.destroy()
+ for (var i = 0; i < mainSplit.views.length; i++) {
+ var view = mainSplit.views[i];
+ if (view.menuItem === this) {
+ mainSplit.views.splice(i, 1);
+ break;
+ }
+ }
+ gui.removePlugin(this.path)
+ activeView(mainSplit.views[0].view, mainSplit.views[0].menuItem);
+ }
+ }
+ }
+
+ function createMenuItem(view, options) {
+ if(options === undefined) {
+ options = {};
+ }
+
+ var section;
+ switch(options.section) {
+ case "begin":
+ section = menuBegin
+ break;
+ case "ethereum":
+ section = menuDefault;
+ break;
+ case "legacy":
+ section = menuLegacy;
+ break;
+ default:
+ section = menuApps;
+ break;
+ }
+
+ var comp = menuItemTemplate.createObject(section)
+ comp.view = view
+ comp.title = view.title
+
+ if(view.hasOwnProperty("iconSource")) {
+ comp.icon = view.iconSource;
+ }
+ comp.closable = options.close;
+
+ if (options.section === "begin") {
+ comp.setAsBigButton(true)
+ }
+
+ return comp
+ }
+
+ ColumnLayout {
+ id: menuColumn
+ y: 10
+ width: parent.width
+ anchors.left: parent.left
+ anchors.right: parent.right
+ spacing: 3
+
+
+
+ ColumnLayout {
+ id: menuBegin
+ spacing: 3
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ }
+
+ Rectangle {
+ height: 19
+ color: "transparent"
+ Text {
+ text: "ETHEREUM"
+ font.family: sourceSansPro.name
+ font.weight: Font.Regular
+ // anchors.top: 20
+ // anchors.left: 16
+ anchors {
+ leftMargin: 12
+ topMargin: 4
+ fill: parent
+ }
+ // anchors.leftMargin: 16
+ // anchors.topMargin: 16
+ // anchors.verticalCenterOffset: 50
+ color: "#AAA0A0"
+ }
+ }
+
+
+ ColumnLayout {
+ id: menuDefault
+ spacing: 3
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ }
+
+ Rectangle {
+ height: 19
+ color: "#00ff00"
+ visible: (menuApps.children.length > 0)
+
+ Text {
+ text: "APPS"
+ font.family: sourceSansPro.name
+ font.weight: Font.Regular
+ anchors.fill: parent
+ anchors.leftMargin: 16
+ color: "#AAA0A0"
+ }
+ }
+
+ ColumnLayout {
+ id: menuApps
+ spacing: 3
+
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ }
+
+ ColumnLayout {
+ id: menuLegacy
+ visible: true
+ spacing: 3
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ }
+ }
+ }
+
+ /*********************
+ * Main view
+ ********************/
+ Rectangle {
+ id: rootView
+ anchors.right: parent.right
+ anchors.left: menu.right
+ anchors.bottom: parent.bottom
+ anchors.top: parent.top
+ color: "#00000000"
+
+ /*Rectangle {
+ id: urlPane
+ height: 40
+ color: "#00000000"
+ anchors {
+ left: parent.left
+ right: parent.right
+ leftMargin: 5
+ rightMargin: 5
+ top: parent.top
+ topMargin: 5
+ }
+ TextField {
+ id: url
+ objectName: "url"
+ placeholderText: "DApp URL"
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ topMargin: 5
+ rightMargin: 5
+ leftMargin: 5
+ }
+
+ Keys.onReturnPressed: {
+ if(/^https?/.test(this.text)) {
+ newBrowserTab(this.text);
+ } else {
+ addPlugin(this.text, {close: true, section: "apps"})
+ }
+ }
+ }
+
+ }
+
+ // Border
+ Rectangle {
+ id: divider
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: urlPane.bottom
+ }
+ z: -1
+ height: 1
+ color: "#CCCCCC"
+ }*/
+
+ Rectangle {
+ id: mainView
+ color: "#00000000"
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.top: parent.top
+
+ function createView(component) {
+ var view = component.createObject(mainView)
+
+ return view;
+ }
+ }
+ }
+ }
+
+
+ /******************
+ * Dialogs
+ *****************/
+ FileDialog {
+ id: generalFileDialog
+ property var callback;
+ onAccepted: {
+ var path = this.fileUrl.toString();
+ callback.call(this, path);
+ }
+
+ function show(selectExisting, callback) {
+ generalFileDialog.callback = callback;
+ generalFileDialog.selectExisting = selectExisting;
+
+ this.open();
+ }
+ }
+
+
+ /******************
+ * Wallet functions
+ *****************/
+ function importApp(path) {
+ var ext = path.split('.').pop()
+ if(ext == "html" || ext == "htm") {
+ eth.openHtml(path)
+ }else if(ext == "qml"){
+ addPlugin(path, {close: true, section: "apps"})
+ }
+ }
+
+ function setWalletValue(value) {
+ //walletValueLabel.text = value
+ }
+
+ function loadPlugin(name) {
+ console.log("Loading plugin" + name)
+ var view = mainView.addPlugin(name)
+ }
+
+ function clearPeers() { peerModel.clear() }
+ function addPeer(peer) { peerModel.append(peer) }
+
+ function setPeerCounters(text) {
+ //peerCounterLabel.text = text
+ }
+
+ function timeAgo(unixTs){
+ var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000
+ return (lapsed + " seconds ago")
+ }
+
+ function convertToPretty(unixTs){
+ var a = new Date(unixTs*1000);
+ var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
+ var year = a.getFullYear();
+ var month = months[a.getMonth()];
+ var date = a.getDate();
+ var hour = a.getHours();
+ var min = a.getMinutes();
+ var sec = a.getSeconds();
+ var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
+ return time;
+ }
+
+ /**********************
+ * Windows
+ *********************/
+ Window {
+ id: peerWindow
+ //flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint
+ height: 200
+ width: 700
+ Rectangle {
+ anchors.fill: parent
+ property var peerModel: ListModel {
+ id: peerModel
+ }
+ TableView {
+ anchors.fill: parent
+ id: peerTable
+ model: peerModel
+ TableViewColumn{width: 180; role: "addr" ; title: "Remote Address" }
+ TableViewColumn{width: 280; role: "nodeID" ; title: "Node ID" }
+ TableViewColumn{width: 100; role: "name" ; title: "Name" }
+ TableViewColumn{width: 40; role: "caps" ; title: "Capabilities" }
+ }
+ }
+ }
+
+ Window {
+ id: aboutWin
+ visible: false
+ title: "About"
+ minimumWidth: 350
+ maximumWidth: 350
+ maximumHeight: 280
+ minimumHeight: 280
+
+ Image {
+ id: aboutIcon
+ height: 150
+ width: 150
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ source: "../facet.png"
+ x: 10
+ y: 30
+ }
+
+ Text {
+ anchors.left: aboutIcon.right
+ anchors.leftMargin: 10
+ anchors.top: parent.top
+ anchors.topMargin: 30
+ font.pointSize: 12
+ text: "<h2>Mist (0.9.0)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br>Gustav Simonsson<br><h3>UX/UI</h3>Alex van de Sande<br>Fabian Vogelsteller"
+ }
+ }
+
+ Window {
+ id: txImportDialog
+ minimumWidth: 270
+ maximumWidth: 270
+ maximumHeight: 50
+ minimumHeight: 50
+ TextField {
+ id: txImportField
+ width: 170
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ onAccepted: {
+ }
+ }
+ Button {
+ anchors.left: txImportField.right
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.leftMargin: 5
+ text: "Import"
+ onClicked: {
+ eth.importTx(txImportField.text)
+ txImportField.visible = false
+ }
+ }
+ Component.onCompleted: {
+ addrField.focus = true
+ }
+ }
+
+ Window {
+ id: addPeerWin
+ visible: false
+ minimumWidth: 400
+ maximumWidth: 400
+ maximumHeight: 50
+ minimumHeight: 50
+ title: "Connect to peer"
+
+ TextField {
+ id: addrField
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.right: addPeerButton.left
+ anchors.leftMargin: 10
+ anchors.rightMargin: 10
+ placeholderText: "enode://<hex node id>:<IP address>:<port>"
+ onAccepted: {
+ if(addrField.text.length != 0) {
+ eth.connectToPeer(addrField.text)
+ addPeerWin.visible = false
+ }
+ }
+ }
+
+ Button {
+ id: addPeerButton
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.rightMargin: 10
+ text: "Connect"
+ onClicked: {
+ if(addrField.text.length != 0) {
+ eth.connectToPeer(addrField.text)
+ addPeerWin.visible = false
+ }
+ }
+ }
+ Component.onCompleted: {
+ addrField.focus = true
+ }
+ }
+ }
diff --git a/cmd/mist/assets/qml/muted.qml b/cmd/mist/assets/qml/muted.qml
new file mode 100644
index 000000000..fac8267c4
--- /dev/null
+++ b/cmd/mist/assets/qml/muted.qml
@@ -0,0 +1,74 @@
+import QtQuick 2.0
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Window 2.1;
+import Ethereum 1.0
+
+ApplicationWindow {
+ id: window
+ title: "muted"
+ width: 900
+ height: 600
+ minimumHeight: 300
+
+ property alias url: webView.url
+ property alias webView: webView
+
+
+ Item {
+ id: root
+ anchors.fill: parent
+ WebView {
+ objectName: "webView"
+ id: webView
+ anchors {
+ top: root.top
+ right: root.right
+ left: root.left
+ bottom: root.bottom
+ //bottom: sizeGrip.top
+ }
+
+ experimental.preferences.javascriptEnabled: true
+ experimental.preferences.navigatorQtObjectEnabled: true
+ experimental.onMessageReceived: {
+ var data = JSON.parse(message.data)
+
+ switch(data.call) {
+ case "log":
+ console.log.apply(this, data.args)
+ break;
+ }
+ }
+ function postData(seed, data) {
+ webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed}))
+ }
+ function postEvent(event, data) {
+ webview.experimental.postMessage(JSON.stringify({data: data, _event: event}))
+ }
+ }
+
+ /*
+ Rectangle {
+ id: sizeGrip
+ color: "gray"
+ height: 5
+ anchors {
+ left: root.left
+ right: root.right
+ }
+ y: Math.round(root.height * 2 / 3)
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: sizeGrip
+ drag.minimumY: 0
+ drag.maximumY: root.height - sizeGrip.height
+ drag.axis: Drag.YAxis
+ }
+ }
+ */
+ }
+}
diff --git a/cmd/mist/assets/qml/test_app.qml b/cmd/mist/assets/qml/test_app.qml
new file mode 100644
index 000000000..c69587839
--- /dev/null
+++ b/cmd/mist/assets/qml/test_app.qml
@@ -0,0 +1,70 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import Ethereum 1.0
+
+QmlApp {
+ minimumWidth: 350
+ maximumWidth: 350
+ maximumHeight: 80
+ minimumHeight: 80
+
+ title: "Generic Coin"
+
+ property string contractAddr: "f299f6c74515620e4c4cd8fe3d205b5c4f2e25c8"
+ property string addr: "2ef47100e0787b915105fd5e3f4ff6752079d5cb"
+
+ Component.onCompleted: {
+ eth.watch(contractAddr, addr)
+ eth.watch(addr, contractAddr)
+ setAmount()
+ }
+
+ function onStorageChangeCb(storageObject) {
+ setAmount()
+ }
+
+ function setAmount(){
+ var state = eth.getStateObject(contractAddr)
+ var storage = state.getStorage(addr)
+ amountLabel.text = storage
+ }
+ Column {
+ spacing: 5
+ Row {
+ spacing: 20
+ Label {
+ id: genLabel
+ text: "Generic coin balance:"
+ }
+ Label {
+ id: amountLabel
+ }
+ }
+ Row {
+ spacing: 20
+ TextField {
+ id: address
+ placeholderText: "Address"
+ }
+ TextField {
+ id: amount
+ placeholderText: "Amount"
+ }
+ }
+ Button {
+ text: "Send coins"
+ onClicked: {
+ var privKey = eth.getKey().privateKey
+ if(privKey){
+ var result = eth.transact(privKey, contractAddr, 0,"100000","250", "0x" + address.text + "\n" + amount.text)
+ resultTx.text = result.hash
+ }
+ }
+ }
+ Label {
+ id: resultTx
+ }
+ }
+
+}
diff --git a/cmd/mist/assets/qml/transactions.qml b/cmd/mist/assets/qml/transactions.qml
new file mode 100644
index 000000000..e9a035a85
--- /dev/null
+++ b/cmd/mist/assets/qml/transactions.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+
+Rectangle {
+ id: transactionView
+ visible: false
+ Text { text: "TX VIEW" }
+}
diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml
new file mode 100644
index 000000000..edecc8696
--- /dev/null
+++ b/cmd/mist/assets/qml/views/browser.qml
@@ -0,0 +1,506 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Layouts 1.0;
+import QtWebEngine 1.0
+import QtWebEngine.experimental 1.0
+import QtQuick.Window 2.0;
+
+Rectangle {
+ id: window
+ anchors.fill: parent
+ color: "#00000000"
+
+ property var title: ""
+ property var iconSource: "../browser.png"
+ property var menuItem
+ property var hideUrl: true
+
+ property alias url: webview.url
+ property alias windowTitle: webview.title
+ property alias webView: webview
+
+ property var cleanPath: false
+ property var open: function(url) {
+ if(!window.cleanPath) {
+ var uri = url;
+ if(!/.*\:\/\/.*/.test(uri)) {
+ uri = "http://" + uri;
+ }
+
+ var reg = /(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.eth)(.*)/
+
+ if(reg.test(uri)) {
+ uri.replace(reg, function(match, pre, domain, path) {
+ uri = pre;
+
+ var lookup = eth.lookupDomain(domain.substring(0, domain.length - 4));
+ var ip = [];
+ for(var i = 0, l = lookup.length; i < l; i++) {
+ ip.push(lookup.charCodeAt(i))
+ }
+
+ if(ip.length != 0) {
+ uri += lookup;
+ } else {
+ uri += domain;
+ }
+
+ uri += path;
+ });
+ }
+
+ window.cleanPath = true;
+
+ webview.url = uri;
+
+ //uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
+ uriNav.text = uri;
+
+ } else {
+ // Prevent inf loop.
+ window.cleanPath = false;
+ }
+ }
+
+ function showFullUrlBar(on){
+ if (uriNav.focus == false ) {
+ if (on == false) {
+ clickAnywhereOnApp.visible = false
+ navBar.state = "titleVisible"
+ } else {
+ clickAnywhereOnApp.visible = true
+ navBar.state = "fullUrlVisible"
+ }
+ }
+
+ }
+
+ Component.onCompleted: {
+ }
+
+ Item {
+ objectName: "root"
+ id: root
+ anchors {
+ fill: parent
+ }
+
+ state: "inspectorShown"
+
+ MouseArea {
+ id: clickAnywhereOnApp
+ z:15
+ // Using a secondary screen to catch on mouse exits for the area, because
+ // there are many hover actions conflicting
+
+ anchors {
+ top: parent.top
+ topMargin: 50
+ right: parent.right
+ bottom: parent.bottom
+ left: parent.left
+ }
+ hoverEnabled: true
+
+ onEntered: {
+ showFullUrlBar(false);
+ }
+
+ onClicked: {
+ uriNav.focus = false
+ showFullUrlBar(false);
+ }
+
+ // Rectangle {
+ // anchors.fill: parent
+ // color: "#88888888"
+ // }
+ }
+
+ RowLayout {
+ id: navBar
+ height: 74
+ z: 20
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ Button {
+ id: back
+ z: 30
+ onClicked: {
+ webview.goBack()
+ }
+
+ anchors {
+ left: parent.left
+ leftMargin: 6
+ }
+
+ style: ButtonStyle {
+ background: Image {
+ source: (webview.canGoBack) ?
+ (control.hovered ? "../../backButtonHover.png" : "../../backButton.png") :
+ "../../backButtonDisabled.png"
+ width: 20
+ height: 30
+ }
+ }
+ }
+
+ Rectangle {
+ id: appInfoPane
+ height: 28
+ color: "#FFFFFF"
+ radius: 6
+ z:2
+ MouseArea {
+ anchors.fill: parent
+ z: 10
+ hoverEnabled: true
+
+ onEntered: {
+ showFullUrlBar(true);
+ }
+ /*onExited: {
+ showFullUrlBar(false);
+ }*/
+
+ }
+
+ anchors {
+ left: back.right
+ right: parent.right
+ leftMargin: 10
+ rightMargin: 10
+ }
+
+ Text {
+ id: appTitle
+ text: "LOADING"
+ font.bold: true
+ font.capitalization: Font.AllUppercase
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ elide: Text.ElideRight
+
+ anchors {
+ left: parent.left
+ right: parent.horizontalCenter
+ top: parent.top
+ bottom: parent.bottom
+ leftMargin: 32
+ }
+ color: "#928484"
+ }
+
+ Text {
+ id: appDomain
+ text: "loading domain"
+ font.bold: false
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ elide: Text.ElideLeft
+
+ anchors {
+ left: parent.horizontalCenter
+ right: parent.right
+ top: parent.top
+ bottom: parent.bottom
+ leftMargin: 32
+
+ }
+ color: "#C0AFAF"
+ }
+
+
+ TextField {
+ id: uriNav
+ opacity: 0.0
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ leftMargin: 16
+ }
+
+ horizontalAlignment: Text.AlignHCenter
+
+ style: TextFieldStyle {
+ textColor: "#928484"
+ background: Rectangle {
+ border.width: 0
+ color: "transparent"
+ }
+ }
+ text: webview.url;
+ y: parent.height / 2 - this.height / 2
+ z: 20
+ activeFocusOnPress: true
+ Keys.onReturnPressed: {
+ // if there's no http, add it.
+ var url = this.text,
+ matches = url.match(/^([a-z]*\:\/\/)?([^\/.]+)(:?\/)(.*|$)/i),
+ requestedProtocol = (matches && matches[1] != "undefined")? "" : "http://";
+
+ webview.url = requestedProtocol + url;
+ }
+ }
+
+
+ }
+
+ Rectangle {
+ id: appInfoPaneShadow
+ width: 10
+ height: 30
+ color: "#BDB6B6"
+ radius: 6
+ z:1
+
+ anchors {
+ left: back.right
+ right: parent.right
+ leftMargin:10
+ rightMargin:10
+ top: parent.top
+ topMargin: 23
+ }
+ }
+
+ Rectangle {
+ id: navBarBackground
+ anchors.fill: parent
+ z:-1
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#F6F1F2" }
+ GradientStop { position: 1.0; color: "#DED5D5" }
+ }
+ }
+
+ states: [
+ State {
+ name: "fullUrlVisible"
+ PropertyChanges {
+ target: appTitle
+ anchors.rightMargin: -50
+ opacity: 0.0
+ }
+ PropertyChanges {
+ target: appDomain
+ anchors.leftMargin: -50
+ opacity: 0.0
+ }
+ PropertyChanges {
+ target: uriNav
+ anchors.leftMargin: 0
+ opacity: 1.0
+ }
+ },
+ State {
+ name: "titleVisible"
+
+ PropertyChanges {
+ target: appTitle
+ anchors.rightMargin: 10
+ opacity: 1.0
+ }
+ PropertyChanges {
+ target: appDomain
+ anchors.leftMargin: 10
+ opacity: 1.0
+ }
+ PropertyChanges {
+ target: uriNav
+ anchors.leftMargin: -50
+ opacity: 0.0
+ }
+ }
+
+ ]
+
+ transitions: [
+ // This adds a transition that defaults to applying to all state changes
+
+ Transition {
+
+ // This applies a default NumberAnimation to any changes a state change makes to x or y properties
+ NumberAnimation {
+ properties: "anchors.leftMargin, anchors.rightMargin, opacity"
+ easing.type: Easing.InOutQuad //Easing.InOutBack
+ duration: 300
+ }
+ }
+ ]
+
+ }
+
+ WebEngineView {
+ objectName: "webView"
+ id: webview
+ experimental.settings.javascriptCanAccessClipboard: true
+ //experimental.settings.localContentCanAccessRemoteUrls: true
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ top: navBar.bottom
+ }
+ z: 10
+
+ Timer {
+ interval: 2000; running: true; repeat: true
+ onTriggered: {
+ webview.runJavaScript("try{document.querySelector('meta[name=ethereum-dapp-info]').getAttribute('content')}catch(e){}", function(extraInfo) {
+ if (extraInfo) {
+ menuItem.secondaryTitle = extraInfo;
+ }
+ });
+ webview.runJavaScript("try{document.querySelector('meta[name=ethereum-dapp-badge]').getAttribute('content')}catch(e){}", function(badge) {
+ if (badge) {
+ if (Number(badge)>0 && Number(badge)<999) {
+ menuItem.badgeNumber = Number(badge);
+ menuItem.badgeContent = "number"
+ } else if (badge == "warning") {
+ menuItem.badgeIcon = "\ue00e"
+ menuItem.badgeContent = "icon"
+
+ } else if (badge == "ghost") {
+ menuItem.badgeIcon = "\ue01a"
+ menuItem.badgeContent = "icon"
+
+ } else if (badge == "question") {
+ menuItem.badgeIcon = "\ue05d"
+ menuItem.badgeContent = "icon"
+
+ } else if (badge == "info") {
+ menuItem.badgeIcon = "\ue08b"
+ menuItem.badgeContent = "icon"
+
+ } else if (badge == "check") {
+ menuItem.badgeIcon = "\ue080"
+ menuItem.badgeContent = "icon"
+
+ } else if (badge == "gear") {
+ menuItem.badgeIcon = "\ue09a"
+ menuItem.badgeContent = "icon"
+
+ } else {
+ menuItem.badgeContent = ""
+ }
+ } else {
+ menuItem.badgeContent = ""
+ }
+ });
+ }
+ }
+
+ onLoadingChanged: {
+ if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
+
+ webview.runJavaScript("document.title", function(pageTitle) {
+ menuItem.title = pageTitle;
+ });
+
+ webView.runJavaScript("try{document.querySelector(\"link[rel='icon']\").getAttribute(\"href\")}catch(e){}", function(sideIcon){
+ if(sideIcon){
+ menuItem.icon = webview.url + sideIcon;
+ };
+ });
+
+ webView.runJavaScript("try{document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")}catch(e){}", function(topBarStyle){
+ if (!topBarStyle) {
+ showFullUrlBar(true);
+ navBarBackground.visible = true;
+ back.visible = true;
+ appInfoPane.anchors.leftMargin = 0;
+ appInfoPaneShadow.anchors.leftMargin = 0;
+ webview.anchors.topMargin = 0;
+ return;
+ }
+
+ if (topBarStyle=="transparent") {
+ // Adjust for a transparent sidebar Dapp
+ navBarBackground.visible = false;
+ back.visible = false;
+ appInfoPane.anchors.leftMargin = -16;
+ appInfoPaneShadow.anchors.leftMargin = -16;
+ webview.anchors.topMargin = -74;
+ webview.runJavaScript("document.querySelector('body').classList.add('ethereum-dapp-url-bar-style-transparent')")
+
+ } else {
+ navBarBackground.visible = true;
+ back.visible = true;
+ appInfoPane.anchors.leftMargin = 0;
+ appInfoPaneShadow.anchors.leftMargin = 0;
+ webview.anchors.topMargin = 0;
+ };
+ });
+
+
+ webview.runJavaScript(eth.readFile("bignumber.min.js"));
+ webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js"));
+ webview.runJavaScript(eth.readFile("mist.js"));
+
+ var cleanTitle = webview.url.toString()
+ var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
+ var domain = matches && matches[1];
+
+
+ if (domain)
+ appDomain.text = domain //webview.url.replace("a", "z")
+ if (webview.title)
+ appTitle.text = webview.title
+
+ showFullUrlBar(false);
+ }
+ }
+ onJavaScriptConsoleMessage: {
+ console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message));
+ }
+ }
+
+ Rectangle {
+ id: sizeGrip
+ color: "gray"
+ visible: false
+ height: 10
+ anchors {
+ left: root.left
+ right: root.right
+ }
+ y: Math.round(root.height * 2 / 3)
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: sizeGrip
+ drag.minimumY: 0
+ drag.maximumY: root.height
+ drag.axis: Drag.YAxis
+ }
+ }
+
+ WebEngineView {
+ id: inspector
+ visible: false
+ anchors {
+ left: root.left
+ right: root.right
+ top: sizeGrip.bottom
+ bottom: root.bottom
+ }
+
+ }
+
+ states: [
+ State {
+ name: "inspectorShown"
+ PropertyChanges {
+ target: inspector
+ }
+ }
+ ]
+ }
+}
diff --git a/cmd/mist/assets/qml/views/catalog.qml b/cmd/mist/assets/qml/views/catalog.qml
new file mode 100644
index 000000000..29e133074
--- /dev/null
+++ b/cmd/mist/assets/qml/views/catalog.qml
@@ -0,0 +1,144 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Layouts 1.0;
+import QtWebEngine 1.0
+import QtWebEngine.experimental 1.0
+import QtQuick.Window 2.0;
+
+
+Rectangle {
+ id: window
+ anchors.fill: parent
+ color: "#00000000"
+
+ property var title: "Catalog"
+ property var iconSource: ""
+ property var menuItem
+ property var hideUrl: true
+
+ property alias url: webview.url
+ property alias windowTitle: webview.title
+ property alias webView: webview
+
+ property var cleanPath: false
+ property var open: function(url) {
+ if(!window.cleanPath) {
+ var uri = url;
+ if(!/.*\:\/\/.*/.test(uri)) {
+ uri = "http://" + uri;
+ }
+
+ var reg = /(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.eth)(.*)/
+
+ if(reg.test(uri)) {
+ uri.replace(reg, function(match, pre, domain, path) {
+ uri = pre;
+
+ var lookup = eth.lookupDomain(domain.substring(0, domain.length - 4));
+ var ip = [];
+ for(var i = 0, l = lookup.length; i < l; i++) {
+ ip.push(lookup.charCodeAt(i))
+ }
+
+ if(ip.length != 0) {
+ uri += lookup;
+ } else {
+ uri += domain;
+ }
+
+ uri += path;
+ });
+ }
+
+ window.cleanPath = true;
+
+ webview.url = uri;
+
+ //uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
+ uriNav.text = uri;
+
+ } else {
+ // Prevent inf loop.
+ window.cleanPath = false;
+ }
+ }
+
+ Item {
+ objectName: "root"
+ id: root
+ anchors.fill: parent
+ state: "inspectorShown"
+
+ WebEngineView {
+ objectName: "webView"
+ id: webview
+ anchors.fill: parent
+
+ property var protocol: "http://"
+ //property var domain: "localhost:3000"
+ property var domain: "ethereum-dapp-catalog.meteor.com"
+ url: protocol + domain
+
+ experimental.settings.javascriptCanAccessClipboard: true
+
+
+ onJavaScriptConsoleMessage: {
+ console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message));
+ }
+
+ onNavigationRequested: {
+ // this checks if the domain of the requested link is the same as the catalog's
+ // If it is, it opens on the same window, if it's not it opens a new tab
+
+ var cleanTitle = request.url.toString()
+ var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
+ var requestedDomain = matches && matches[1];
+
+
+ if(request.navigationType==0){
+
+ if (requestedDomain === this.domain){
+ request.action = WebEngineView.AcceptRequest;
+ } else {
+ request.action = WebEngineView.IgnoreRequest;
+ newBrowserTab(request.url);
+ }
+
+ }
+ }
+ onLoadingChanged: {
+ if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
+ webview.runJavaScript(eth.readFile("mist.js"));
+ }
+ }
+ }
+
+
+
+
+
+
+ WebEngineView {
+ id: inspector
+ visible: false
+ z:10
+ anchors {
+ left: root.left
+ right: root.right
+ top: root.top
+ bottom: root.bottom
+ }
+
+ }
+
+ states: [
+ State {
+ name: "inspectorShown"
+ PropertyChanges {
+ target: inspector
+ }
+ }
+ ]
+ }
+}
diff --git a/cmd/mist/assets/qml/views/chain.qml b/cmd/mist/assets/qml/views/chain.qml
new file mode 100644
index 000000000..9892beddf
--- /dev/null
+++ b/cmd/mist/assets/qml/views/chain.qml
@@ -0,0 +1,244 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ id: root
+ property var title: "Block Chain"
+ property var menuItem
+
+ objectName: "chainView"
+ visible: false
+ anchors.fill: parent
+
+ TableView {
+ id: blockTable
+ width: parent.width
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
+ TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
+ TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 }
+
+ model: blockModel
+
+ itemDelegate: Item {
+ Text {
+ anchors {
+ left: parent.left
+ right: parent.right
+ leftMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ color: styleData.textColor
+ elide: styleData.elideMode
+ text: styleData.value
+ font.pixelSize: 11
+ MouseArea {
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ propagateComposedEvents: true
+ anchors.fill: parent
+ onClicked: {
+ blockTable.selection.clear()
+ blockTable.selection.select(styleData.row)
+
+ if(mouse.button == Qt.RightButton) {
+ contextMenu.row = styleData.row;
+ contextMenu.popup()
+ }
+ }
+
+ onDoubleClicked: {
+ popup.visible = true
+ popup.setDetails(blockModel.get(styleData.row))
+ }
+ }
+ }
+
+ }
+
+ Menu {
+ id: contextMenu
+ property var row
+ MenuItem {
+ text: "Details"
+ onTriggered: {
+ popup.visible = true
+ popup.setDetails(blockModel.get(contextMenu.row))
+ }
+ }
+
+ MenuSeparator{}
+
+ MenuItem {
+ text: "Copy"
+ onTriggered: {
+ copyToClipboard(blockModel.get(contextMenu.row).hash)
+ }
+ }
+
+ MenuItem {
+ text: "Dump State"
+ onTriggered: {
+ generalFileDialog.show(false, function(path) {
+ var hash = blockModel.get(contextMenu.row).hash;
+
+ gui.dumpState(hash, path);
+ });
+ }
+ }
+ }
+ }
+
+
+
+ function addBlock(block, initial) {
+ if(initial == undefined){
+ initial = false
+ }
+
+ var amount = block.transactions.length;
+ var txs = [];
+ for(var i = 0; i < block.transactions.length; i++) {
+ var tx = JSON.parse(block.transactions.getAsJson(i));
+ txs.push(tx);
+ }
+
+ if(initial){
+ blockModel.append({raw: block.raw, bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
+ } else {
+ blockModel.insert(0, {raw: block.raw, bloom: block.bloom, size: block.size, number: block.number, name: block.name, gasLimit: block.gasLimit, gasUsed: block.gasUsed, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
+ }
+ }
+
+ Window {
+ id: popup
+ visible: false
+ //flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint
+ property var block
+ width: root.width
+ height: 300
+ Component{
+ id: blockDetailsDelegate
+ Rectangle {
+ color: "#252525"
+ width: popup.width
+ height: 150
+ Column {
+ anchors.leftMargin: 10
+ anchors.topMargin: 5
+ anchors.top: parent.top
+ anchors.left: parent.left
+ Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"}
+ Text { text: '<b>Block number:</b> ' + number + " (Size: " + size + ")"; color: "#F2F2F2"}
+ Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"}
+ Text { text: '<b>Bloom:</b> ' + bloom; color: "#F2F2F2"}
+ Text { text: '<b>Coinbase:</b> &lt;' + name + '&gt; ' + coinbase; color: "#F2F2F2"}
+ Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"}
+ Text { text: '<b>Gas used:</b> ' + gasUsed + " / " + gasLimit; color: "#F2F2F2"}
+ }
+ }
+ }
+ ListView {
+ model: singleBlock
+ delegate: blockDetailsDelegate
+ anchors.top: parent.top
+ height: 100
+ anchors.leftMargin: 20
+ id: listViewThing
+ Layout.maximumHeight: 40
+ }
+ TableView {
+ id: txView
+ anchors.top: listViewThing.bottom
+ anchors.topMargin: 50
+ width: parent.width
+
+ TableViewColumn{width: 90; role: "value" ; title: "Value" }
+ TableViewColumn{width: 200; role: "hash" ; title: "Hash" }
+ TableViewColumn{width: 200; role: "sender" ; title: "Sender" }
+ TableViewColumn{width: 200;role: "address" ; title: "Receiver" }
+ TableViewColumn{width: 60; role: "gas" ; title: "Gas" }
+ TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" }
+ TableViewColumn{width: 60; role: "isContract" ; title: "Contract" }
+
+ model: transactionModel
+ onClicked: {
+ var tx = transactionModel.get(row)
+ if(tx.data) {
+ popup.showContractData(tx)
+ }else{
+ popup.height = 440
+ }
+ }
+ }
+
+ function showContractData(tx) {
+ if(tx.createsContract) {
+ contractData.text = tx.data
+ contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>"
+ }else{
+ contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>"
+ contractData.text = tx.rawData
+ }
+ popup.height = 540
+ }
+
+ Rectangle {
+ id: txDetails
+ width: popup.width
+ height: 300
+ anchors.left: listViewThing.left
+ anchors.top: txView.bottom
+ Label {
+ text: "<h4>Contract data</h4>"
+ anchors.top: parent.top
+ anchors.left: parent.left
+ id: contractLabel
+ anchors.leftMargin: 10
+ }
+ TextArea {
+ id: contractData
+ text: "Contract"
+ anchors.top: contractLabel.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ wrapMode: Text.Wrap
+ height: 80
+ }
+ TextArea {
+ id: dumpData
+ anchors.top: contractData.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ height: 300
+ }
+ }
+ property var transactionModel: ListModel {
+ id: transactionModel
+ }
+ property var singleBlock: ListModel {
+ id: singleBlock
+ }
+ function setDetails(bl){
+ singleBlock.set(0, bl)
+ popup.height = 300
+ transactionModel.clear()
+ if(bl.txs !== undefined){
+ for(var i = 0; i < bl.txs.count; i++) {
+ transactionModel.insert(0, bl.txs.get(i))
+ }
+ if(bl.txs.count > 0 && bl.txs.get(0).data){
+ popup.showContractData(bl.txs.get(0))
+ }
+ }
+ txView.forceActiveFocus()
+ dumpData.text = bl.raw;
+ }
+ }
+}
diff --git a/cmd/mist/assets/qml/views/history.qml b/cmd/mist/assets/qml/views/history.qml
new file mode 100644
index 000000000..c72f8f3ae
--- /dev/null
+++ b/cmd/mist/assets/qml/views/history.qml
@@ -0,0 +1,51 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ property var title: "Transactions"
+ property var menuItem
+
+
+ id: historyView
+ visible: false
+ anchors.fill: parent
+ objectName: "transactionView"
+
+ property var txModel: ListModel {
+ id: txModel
+ }
+ TableView {
+ id: txTableView
+ anchors.fill: parent
+ TableViewColumn{ role: "inout" ; title: "" ; width: 40 }
+ TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
+ TableViewColumn{ role: "address" ; title: "Address" ; width: 430 }
+ TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 }
+
+ model: txModel
+ }
+
+ function addTx(tx, inout) {
+ var isContract
+ if (tx.contract == true){
+ isContract = "Yes"
+ }else{
+ isContract = "No"
+ }
+
+
+ var address;
+ if(inout == "recv") {
+ address = tx.sender;
+ } else {
+ address = tx.address;
+ }
+
+ txModel.insert(0, {inout: inout, hash: tx.hash, address: address, value: tx.value, contract: isContract})
+ }
+}
diff --git a/cmd/mist/assets/qml/views/info.qml b/cmd/mist/assets/qml/views/info.qml
new file mode 100644
index 000000000..0187bba6d
--- /dev/null
+++ b/cmd/mist/assets/qml/views/info.qml
@@ -0,0 +1,143 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ property var title: "Debug Info"
+ property var menuItem
+
+ objectName: "infoView"
+ visible: false
+ anchors.fill: parent
+
+ color: "#00000000"
+
+ Column {
+ id: info
+ spacing: 3
+ anchors.fill: parent
+ anchors.topMargin: 5
+ anchors.leftMargin: 5
+
+ Label {
+ id: addressLabel
+ text: "Address"
+ }
+ TextField {
+ text: eth.coinbase()
+ width: 500
+ }
+
+ TextArea {
+ objectName: "statsPane"
+ width: parent.width
+ height: 200
+ selectByMouse: true
+ readOnly: true
+ font.family: "Courier"
+ }
+ }
+
+ RowLayout {
+ id: logLayout
+ width: parent.width
+ height: 200
+ anchors.bottom: parent.bottom
+
+ TableView {
+ id: addressView
+ width: parent.width
+ height: 200
+ anchors {
+ left: parent.left
+ bottom: parent.bottom
+ top: parent.top
+ }
+ TableViewColumn{ role: "name"; title: "name" }
+ TableViewColumn{ role: "address"; title: "address"; width: 300}
+
+ property var addressModel: ListModel {
+ id: addressModel
+ }
+
+ model: addressModel
+ itemDelegate: Item {
+ Text {
+ anchors {
+ left: parent.left
+ right: parent.right
+ leftMargin: 10
+ verticalCenter: parent.verticalCenter
+ }
+ color: styleData.textColor
+ elide: styleData.elideMode
+ text: styleData.value
+ font.pixelSize: 11
+ MouseArea {
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+ propagateComposedEvents: true
+ anchors.fill: parent
+ onClicked: {
+ addressView.selection.clear()
+ addressView.selection.select(styleData.row)
+
+ if(mouse.button == Qt.RightButton) {
+ contextMenu.row = styleData.row;
+ contextMenu.popup()
+ }
+ }
+ }
+ }
+ }
+
+ Menu {
+ id: contextMenu
+ property var row;
+
+ MenuItem {
+ text: "Copy"
+ onTriggered: {
+ copyToClipboard(addressModel.get(this.row).address)
+ }
+ }
+ }
+ }
+ }
+
+ property var logModel: ListModel {
+ id: logModel
+ }
+
+ function addDebugMessage(message){
+ debuggerLog.append({value: message})
+ }
+
+ function addAddress(address) {
+ addressModel.append({name: address.name, address: address.address})
+ }
+
+ function clearAddress() {
+ addressModel.clear()
+ }
+
+ function addLog(str) {
+ // Remove first item once we've reached max log items
+ if(logModel.count > 250) {
+ logModel.remove(0)
+ }
+
+ if(str.len != 0) {
+ if(logView.flickableItem.atYEnd) {
+ logModel.append({description: str})
+ logView.positionViewAtRow(logView.rowCount - 1, ListView.Contain)
+ } else {
+ logModel.append({description: str})
+ }
+ }
+
+ }
+}
diff --git a/cmd/mist/assets/qml/views/jeffcoin/jeff.png b/cmd/mist/assets/qml/views/jeffcoin/jeff.png
new file mode 100644
index 000000000..2b9c6651a
--- /dev/null
+++ b/cmd/mist/assets/qml/views/jeffcoin/jeff.png
Binary files differ
diff --git a/cmd/mist/assets/qml/views/jeffcoin/jeffcoin.qml b/cmd/mist/assets/qml/views/jeffcoin/jeffcoin.qml
new file mode 100644
index 000000000..23502d334
--- /dev/null
+++ b/cmd/mist/assets/qml/views/jeffcoin/jeffcoin.qml
@@ -0,0 +1,190 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+
+Rectangle {
+ id: root
+ property var title: "JeffCoin"
+ property var iconSource: "./views/jeffcoin/jeff.png"
+ property var menuItem
+ property var filter
+ property var address: "fc0a9436890478bb9b1c6ed7455c2535366f4a99"
+
+ function insertTx(message, blockNumber) {
+ if(!message) return;
+
+ var from = message.from
+ var to = message.input.substr(24, 40)
+ var value = eth.fromNumber(message.input.substr(64, 64))
+
+ var me = eth.key().address;
+ if((to == me|| from == me) && message.input.length == 128) {
+ var to = eth.lookupName(to)
+ var from = eth.lookupName(from)
+ txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value})
+ }
+ }
+
+ function setBalance() {
+ var jeffCoinAmount = eth.fromNumber(eth.storageAt(address, eth.key().address)) + " JΞF"
+ menuItem.secondaryTitle = jeffCoinAmount
+
+ balance.text = "<b>Balance</b>: " + jeffCoinAmount;
+ }
+
+ function onReady() {
+ setBalance()
+
+ filter = new ethx.watch({latest: -1, to: address})
+ filter.changed(function(messages) {
+ setBalance()
+
+ var blockNumber = eth.block(-1).number;
+ for(var i = 0; i < messages.length; i++) {
+ insertTx(messages.get(i), blockNumber);
+ }
+ });
+
+ var blockNumber = eth.block(-1).number;
+ var msgs = filter.messages()
+ for(var i = msgs.length-1; i >= 0; i--) {
+ var message = JSON.parse(msgs.getAsJson(i))
+
+ insertTx(message, blockNumber)
+ }
+
+ var chainChanged = ethx.watch("chain")
+ chainChanged.changed(function() {
+ for(var i = 0; i < txModel.count; i++) {
+ var entry = txModel.get(i);
+ entry.confirmations++;
+ }
+ });
+ }
+
+ function onDestroy() {
+ filter.uninstall()
+ }
+
+ ColumnLayout {
+ spacing: 10
+ y: 40
+ anchors.fill: parent
+
+ Text {
+ id: balance
+ text: "<b>Balance</b>: " + eth.fromNumber(eth.storageAt(address, eth.key().address)) + " JΞF"
+ font.pixelSize: 24
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ top: parent.top
+ topMargin: 20
+ }
+ }
+
+ Rectangle {
+ id: newTxPane
+ color: "#ececec"
+ border.color: "#cccccc"
+ border.width: 1
+ anchors {
+ top: balance.bottom
+ topMargin: 10
+ left: parent.left
+ leftMargin: 5
+ right: parent.right
+ rightMargin: 5
+ }
+ height: 100
+
+ RowLayout {
+ id: amountFields
+ spacing: 10
+ anchors {
+ top: parent.top
+ topMargin: 20
+ left: parent.left
+ leftMargin: 20
+ }
+
+ Text {
+ text: "JΞF "
+ }
+
+ // There's something off with the row layout where textfields won't listen to the width setting
+ Rectangle {
+ width: 50
+ height: 20
+ TextField {
+ id: txValue
+ width: parent.width
+ placeholderText: "0.00"
+ }
+ }
+ }
+
+ RowLayout {
+ id: toFields
+ spacing: 10
+ anchors {
+ top: amountFields.bottom
+ topMargin: 5
+ left: parent.left
+ leftMargin: 20
+ }
+
+ Text {
+ text: "To"
+ }
+
+ Rectangle {
+ width: 200
+ height: 20
+ TextField {
+ id: txTo
+ width: parent.width
+ placeholderText: "Address or name"
+ }
+ }
+
+ Button {
+ text: "Send"
+ onClicked: {
+ var lookup = eth.lookupAddress(address)
+ if(lookup.length == 0)
+ lookup = address
+
+ eth.transact({from: eth.key().privateKey, to:lookup, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]})
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: newTxPane.bottom
+ topMargin: 10
+ bottom: parent.bottom
+ }
+ TableView {
+ id: txTableView
+ anchors.fill : parent
+ TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
+ TableViewColumn{ role: "from" ; title: "From" ; width: 280 }
+ TableViewColumn{ role: "to" ; title: "To" ; width: 280 }
+ TableViewColumn{ role: "confirmations" ; title: "Confirmations" ; width: 100 }
+
+ model: ListModel {
+ id: txModel
+ Component.onCompleted: {
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/cmd/mist/assets/qml/views/miner.qml b/cmd/mist/assets/qml/views/miner.qml
new file mode 100644
index 000000000..ff2bf85ca
--- /dev/null
+++ b/cmd/mist/assets/qml/views/miner.qml
@@ -0,0 +1,283 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ id: root
+ property var title: "Miner"
+ property var iconSource: "../mining-icon.png"
+ property var menuItem
+
+ color: "#00000000"
+
+ Label {
+ visible: false
+ id: lastBlockLabel
+ objectName: "lastBlockLabel"
+ text: "---"
+ onTextChanged: {
+ //menuItem.secondaryTitle = text
+ }
+ }
+
+ ColumnLayout {
+ spacing: 10
+ anchors.fill: parent
+
+ Rectangle {
+ id: mainPane
+ color: "#00000000"
+ anchors {
+ top: parent.top
+ bottom: localTxPane.top
+ left: parent.left
+ right: parent.right
+ }
+
+ Rectangle {
+ id: menu
+ height: 25
+ anchors {
+ left: parent.left
+ }
+
+ RowLayout {
+ id: tools
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ Button {
+ text: "Start"
+ onClicked: {
+ // eth.setGasPrice(minGasPrice.text || "10000000000000");
+ // eth.setExtra(blockExtra.text)
+ if (eth.toggleMining()) {
+ this.text = "Stop";
+ } else {
+ this.text = "Start";
+ }
+ }
+ }
+
+ // Rectangle {
+ // id: minGasPriceRect
+ // anchors.top: parent.top
+ // anchors.topMargin: 2
+ // width: 200
+ // TextField {
+ // id: minGasPrice
+ // placeholderText: "Min Gas: 10000000000000"
+ // width: 200
+ // validator: RegExpValidator { regExp: /\d*/ }
+ // }
+ // }
+
+ // Rectangle {
+ // width: 300
+ // anchors {
+ // left: minGasPriceRect.right
+ // leftMargin: 5
+ // top: parent.top
+ // topMargin: 2
+ // }
+
+ // TextField {
+ // id: blockExtra
+ // placeholderText: "Extra"
+ // width: parent.width
+ // maximumLength: 1024
+ // }
+ // }
+ }
+ }
+
+ Column {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: menu.bottom
+ topMargin: 5
+ }
+
+ Text {
+ text: "<b>Merged mining options</b>"
+ }
+
+ TableView {
+ id: mergedMiningTable
+ height: 300
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+ Component {
+ id: checkBoxDelegate
+
+ Item {
+ id: test
+ CheckBox {
+ anchors.fill: parent
+ checked: styleData.value
+
+ onClicked: {
+ var model = mergedMiningModel.get(styleData.row)
+
+ if (this.checked) {
+ model.id = txModel.createLocalTx(model.address, "0", "5000", "0", "")
+ } else {
+ txModel.removeWithId(model.id);
+ model.id = 0;
+ }
+ }
+ }
+ }
+ }
+ TableViewColumn{ role: "checked" ; title: "" ; width: 40 ; delegate: checkBoxDelegate }
+ TableViewColumn{ role: "name" ; title: "Name" ; width: 480 }
+ model: ListModel {
+ objectName: "mergedMiningModel"
+ id: mergedMiningModel
+ function addMergedMiningOption(model) {
+ this.append(model);
+ }
+ }
+ Component.onCompleted: {
+ /*
+ // XXX Temp. replace with above eventually
+ var tmpItems = ["JEVCoin", "Some coin", "Other coin", "Etc coin"];
+ var address = "e6716f9544a56c530d868e4bfbacb172315bdead";
+ for (var i = 0; i < tmpItems.length; i++) {
+ mergedMiningModel.append({checked: false, name: tmpItems[i], address: address, id: 0, itemId: i});
+ }
+ */
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: localTxPane
+ color: "#ececec"
+ border.color: "#cccccc"
+ border.width: 1
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ height: 300
+
+ ColumnLayout {
+ spacing: 10
+ anchors.fill: parent
+ RowLayout {
+ id: newLocalTx
+ anchors {
+ left: parent.left
+ leftMargin: 5
+ top: parent.top
+ topMargin: 5
+ bottomMargin: 5
+ }
+
+ Text {
+ text: "Local tx"
+ }
+
+ Rectangle {
+ width: 250
+ color: "#00000000"
+ anchors.top: parent.top
+ anchors.topMargin: 2
+
+ TextField {
+ id: to
+ placeholderText: "To"
+ width: 250
+ validator: RegExpValidator { regExp: /[abcdefABCDEF1234567890]*/ }
+ }
+ }
+ TextField {
+ property var defaultGas: "5000"
+ id: gas
+ placeholderText: "Gas"
+ text: defaultGas
+ validator: RegExpValidator { regExp: /\d*/ }
+ }
+ TextField {
+ id: gasPrice
+ placeholderText: "Price"
+ validator: RegExpValidator { regExp: /\d*/ }
+ }
+ TextField {
+ id: value
+ placeholderText: "Amount"
+ text: "0"
+ validator: RegExpValidator { regExp: /\d*/ }
+ }
+ TextField {
+ id: data
+ placeholderText: "Data"
+ validator: RegExpValidator { regExp: /[abcdefABCDEF1234567890]*/ }
+ }
+ Button {
+ text: "Create"
+ onClicked: {
+ if (to.text.length == 40 && gasPrice.text.length != 0 && value.text.length != 0 && gas.text.length != 0) {
+ txModel.createLocalTx(to.text, gasPrice.text, gas.text, value.text, data.text);
+
+ to.text = ""; gasPrice.text = "";
+ gas.text = gas.defaultGas;
+ value.text = "0"
+ }
+ }
+ }
+ }
+
+ TableView {
+ id: txTableView
+ anchors {
+ top: newLocalTx.bottom
+ topMargin: 5
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+ TableViewColumn{ role: "to" ; title: "To" ; width: 480 }
+ TableViewColumn{ role: "gas" ; title: "Gas" ; width: 100 }
+ TableViewColumn{ role: "gasPrice" ; title: "Gas Price" ; width: 100 }
+ TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
+ TableViewColumn{ role: "data" ; title: "Data" ; width: 100 }
+
+ model: ListModel {
+ id: txModel
+ Component.onCompleted: {
+ }
+ function removeWithId(id) {
+ for (var i = 0; i < this.count; i++) {
+ if (txModel.get(i).id == id) {
+ this.remove(i);
+ eth.removeLocalTransaction(id)
+ break;
+ }
+ }
+ }
+
+ function createLocalTx(to, gasPrice, gas, value, data) {
+ var id = eth.addLocalTransaction(to, data, gas, gasPrice, value)
+ txModel.insert(0, {to: to, gas: gas, gasPrice: gasPrice, value: value, data: data, id: id});
+
+ return id
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/cmd/mist/assets/qml/views/network-health/205f39107b64acf34cb35d7edb57f47893187a12.js b/cmd/mist/assets/qml/views/network-health/205f39107b64acf34cb35d7edb57f47893187a12.js
new file mode 100644
index 000000000..a1f645ca5
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/205f39107b64acf34cb35d7edb57f47893187a12.js
@@ -0,0 +1,176 @@
+!function(){var n,t;(function(){t={}}).call(this),function(){(function(){var n=this,r=n._,e={},u=Array.prototype,i=Object.prototype,a=Function.prototype,o=u.push,c=u.slice,l=u.concat,f=i.toString,s=i.hasOwnProperty,p=u.forEach,v=u.map,h=u.reduce,d=u.reduceRight,g=u.filter,m=u.every,y=u.some,b=u.indexOf,_=u.lastIndexOf,w=Array.isArray,x=Object.keys,j=a.bind,A=function(n){return n instanceof A?n:this instanceof A?void(this._wrapped=n):new A(n)};"undefined"!=typeof t?("undefined"!=typeof module&&module.exports&&(t=module.exports=A),t._=A):n._=A,A.VERSION="1.5.2";var k=function(n){return"[object Arguments]"===f.call(n)};k(arguments)||(k=function(n){return!(!n||!s.call(n,"callee")||"function"!=typeof n.callee)});var O=function(n){return n.length===+n.length&&(k(n)||n.constructor!==Object)},E=A.each=A.forEach=function(n,t,r){if(null!=n)if(p&&n.forEach===p)n.forEach(t,r);else if(O(n)){for(var u=0,i=n.length;i>u;u++)if(t.call(r,n[u],u,n)===e)return}else for(var a=A.keys(n),u=0,i=a.length;i>u;u++)if(t.call(r,n[a[u]],a[u],n)===e)return};A.map=A.collect=function(n,t,r){var e=[];return null==n?e:v&&n.map===v?n.map(t,r):(E(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var F="Reduce of empty array with no initial value";A.reduce=A.foldl=A.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=A.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(E(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(F);return r},A.reduceRight=A.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),d&&n.reduceRight===d)return e&&(t=A.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(!O(n)){var a=A.keys(n);i=a.length}if(E(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(F);return r},A.find=A.detect=function(n,t,r){var e;return M(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},A.filter=A.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(E(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},A.reject=function(n,t,r){return A.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},A.every=A.all=function(n,t,r){t||(t=A.identity);var u=!0;return null==n?u:m&&n.every===m?n.every(t,r):(E(n,function(n,i,a){return(u=u&&t.call(r,n,i,a))?void 0:e}),!!u)};var M=A.some=A.any=function(n,t,r){t||(t=A.identity);var u=!1;return null==n?u:y&&n.some===y?n.some(t,r):(E(n,function(n,i,a){return u||(u=t.call(r,n,i,a))?e:void 0}),!!u)};A.contains=A.include=function(n,t){return null==n?!1:b&&n.indexOf===b?-1!=n.indexOf(t):M(n,function(n){return n===t})},A.invoke=function(n,t){var r=c.call(arguments,2),e=A.isFunction(t);return A.map(n,function(n){return(e?t:n[t]).apply(n,r)})},A.pluck=function(n,t){return A.map(n,function(n){return n[t]})},A.where=function(n,t,r){return A.isEmpty(t)?r?void 0:[]:A[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},A.findWhere=function(n,t){return A.where(n,t,!0)},A.max=function(n,t,r){if(!t&&A.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&A.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return E(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},A.min=function(n,t,r){if(!t&&A.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&A.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return E(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a<e.computed&&(e={value:n,computed:a})}),e.value},A.shuffle=function(n){var t,r=0,e=[];return E(n,function(n){t=A.random(r++),e[r-1]=e[t],e[t]=n}),e},A.sample=function(n,t,r){return arguments.length<2||r?n[A.random(n.length-1)]:A.shuffle(n).slice(0,Math.max(0,t))};var R=function(n){return A.isFunction(n)?n:function(t){return t[n]}};A.sortBy=function(n,t,r){var e=R(t);return A.pluck(A.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.index-t.index}),"value")};var S=function(n){return function(t,r,e){var u={},i=null==r?A.identity:R(r);return E(t,function(r,a){var o=i.call(e,r,a,t);n(u,o,r)}),u}};A.groupBy=S(function(n,t,r){(A.has(n,t)?n[t]:n[t]=[]).push(r)}),A.indexBy=S(function(n,t,r){n[t]=r}),A.countBy=S(function(n,t){A.has(n,t)?n[t]++:n[t]=1}),A.sortedIndex=function(n,t,r,e){r=null==r?A.identity:R(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},A.toArray=function(n){return n?A.isArray(n)?c.call(n):O(n)?A.map(n,A.identity):A.values(n):[]},A.size=function(n){return null==n?0:O(n)?n.length:A.keys(n).length},A.first=A.head=A.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:c.call(n,0,t)},A.initial=function(n,t,r){return c.call(n,0,n.length-(null==t||r?1:t))},A.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:c.call(n,Math.max(n.length-t,0))},A.rest=A.tail=A.drop=function(n,t,r){return c.call(n,null==t||r?1:t)},A.compact=function(n){return A.filter(n,A.identity)};var I=function(n,t,r){return t&&A.every(n,A.isArray)?l.apply(r,n):(E(n,function(n){A.isArray(n)||A.isArguments(n)?t?o.apply(r,n):I(n,t,r):r.push(n)}),r)};A.flatten=function(n,t){return I(n,t,[])},A.without=function(n){return A.difference(n,c.call(arguments,1))},A.uniq=A.unique=function(n,t,r,e){A.isFunction(t)&&(e=r,r=t,t=!1);var u=r?A.map(n,r,e):n,i=[],a=[];return E(u,function(r,e){(t?e&&a[a.length-1]===r:A.contains(a,r))||(a.push(r),i.push(n[e]))}),i},A.union=function(){return A.uniq(A.flatten(arguments,!0))},A.intersection=function(n){var t=c.call(arguments,1);return A.filter(A.uniq(n),function(n){return A.every(t,function(t){return A.indexOf(t,n)>=0})})},A.difference=function(n){var t=l.apply(u,c.call(arguments,1));return A.filter(n,function(n){return!A.contains(t,n)})},A.zip=function(){for(var n=A.max(A.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=A.pluck(arguments,""+r);return t},A.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},A.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=A.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(b&&n.indexOf===b)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},A.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(_&&n.lastIndexOf===_)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},A.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var T=function(){};A.bind=function(n,t){var r,e;if(j&&n.bind===j)return j.apply(n,c.call(arguments,1));if(!A.isFunction(n))throw new TypeError;return r=c.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(c.call(arguments)));T.prototype=n.prototype;var u=new T;T.prototype=null;var i=n.apply(u,r.concat(c.call(arguments)));return Object(i)===i?i:u}},A.partial=function(n){var t=c.call(arguments,1);return function(){return n.apply(this,t.concat(c.call(arguments)))}},A.bindAll=function(n){var t=c.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return E(t,function(t){n[t]=A.bind(n[t],n)}),n},A.memoize=function(n,t){var r={};return t||(t=A.identity),function(){var e=t.apply(this,arguments);return A.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},A.delay=function(n,t){var r=c.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},A.defer=function(n){return A.delay.apply(A,[n,1].concat(c.call(arguments,1)))},A.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},A.debounce=function(n,t,r){var e,u,i,a,o;return function(){i=this,u=arguments,a=new Date;var c=function(){var l=new Date-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u)))},l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u)),o}},A.once=function(n){var t=!1,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},A.wrap=function(n,t){return function(){var r=[n];return o.apply(r,arguments),t.apply(this,r)}},A.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},A.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},A.keys=x||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)A.has(n,r)&&t.push(r);return t},A.values=function(n){for(var t=A.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},A.pairs=function(n){for(var t=A.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},A.invert=function(n){for(var t={},r=A.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},A.functions=A.methods=function(n){var t=[];for(var r in n)A.isFunction(n[r])&&t.push(r);return t.sort()},A.extend=function(n){return E(c.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},A.pick=function(n){var t={},r=l.apply(u,c.call(arguments,1));return E(r,function(r){r in n&&(t[r]=n[r])}),t},A.omit=function(n){var t={},r=l.apply(u,c.call(arguments,1));for(var e in n)A.contains(r,e)||(t[e]=n[e]);return t},A.defaults=function(n){return E(c.call(arguments,1),function(t){if(t)for(var r in t)void 0===n[r]&&(n[r]=t[r])}),n},A.clone=function(n){return A.isObject(n)?A.isArray(n)?n.slice():A.extend({},n):n},A.tap=function(n,t){return t(n),n};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof A&&(n=n._wrapped),t instanceof A&&(t=t._wrapped);var u=f.call(n);if(u!=f.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(A.isFunction(a)&&a instanceof a&&A.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,l=!0;if("[object Array]"==u){if(c=n.length,l=c==t.length)for(;c--&&(l=N(n[c],t[c],r,e)););}else{for(var s in n)if(A.has(n,s)&&(c++,!(l=A.has(t,s)&&N(n[s],t[s],r,e))))break;if(l){for(s in t)if(A.has(t,s)&&!c--)break;l=!c}}return r.pop(),e.pop(),l};A.isEqual=function(n,t){return N(n,t,[],[])},A.isEmpty=function(n){if(null==n)return!0;if(A.isArray(n)||A.isString(n))return 0===n.length;for(var t in n)if(A.has(n,t))return!1;return!0},A.isElement=function(n){return!(!n||1!==n.nodeType)},A.isArray=w||function(n){return"[object Array]"==f.call(n)},A.isObject=function(n){return n===Object(n)},E(["Arguments","Function","String","Number","Date","RegExp"],function(n){A["is"+n]=function(t){return f.call(t)=="[object "+n+"]"}}),A.isArguments(arguments)||(A.isArguments=function(n){return!(!n||!A.has(n,"callee"))}),"function"!=typeof/./&&(A.isFunction=function(n){return"function"==typeof n}),A.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},A.isNaN=function(n){return A.isNumber(n)&&n!=+n},A.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==f.call(n)},A.isNull=function(n){return null===n},A.isUndefined=function(n){return void 0===n},A.has=function(n,t){return s.call(n,t)},A.noConflict=function(){return n._=r,this},A.identity=function(n){return n},A.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},A.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var q={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};q.unescape=A.invert(q.escape);var B={escape:new RegExp("["+A.keys(q.escape).join("")+"]","g"),unescape:new RegExp("("+A.keys(q.unescape).join("|")+")","g")};A.each(["escape","unescape"],function(n){A[n]=function(t){return null==t?"":(""+t).replace(B[n],function(t){return q[n][t]})}}),A.result=function(n,t){if(null==n)return void 0;var r=n[t];return A.isFunction(r)?r.call(n):r},A.mixin=function(n){E(A.functions(n),function(t){var r=A[t]=n[t];A.prototype[t]=function(){var n=[this._wrapped];return o.apply(n,arguments),U.call(this,r.apply(A,n))}})};var D=0;A.uniqueId=function(n){var t=++D+"";return n?n+t:t},A.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},C=/\\|'|\r|\n|\t|\u2028|\u2029/g;A.template=function(n,t,r){var e;r=A.defaults({},r,A.templateSettings);var u=new RegExp([(r.escape||P).source,(r.interpolate||P).source,(r.evaluate||P).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(C,function(n){return"\\"+z[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,A);var c=function(n){return e.call(this,n,A)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},A.chain=function(n){return A(n).chain()};var U=function(n){return this._chain?A(n).chain():n};A.mixin(A),E(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=u[n];A.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],U.call(this,r)}}),E(["concat","join","slice"],function(n){var t=u[n];A.prototype[n]=function(){return U.call(this,t.apply(this._wrapped,arguments))}}),A.extend(A.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)}.call(this),function(){n=t._}.call(this),"undefined"==typeof Package&&(Package={}),Package.underscore={_:n}}();
+
+!function(){var t=Package.underscore._,e;(function(){e={isClient:!0,isServer:!1},"object"==typeof __meteor_runtime_config__&&__meteor_runtime_config__.PUBLIC_SETTINGS&&(e.settings={"public":__meteor_runtime_config__.PUBLIC_SETTINGS})}).call(this),function(){function n(t){return t?e._debug("Exception in callback of async function",t.stack?t.stack:t):void 0}if(e.isServer)var r=Npm.require("fibers/future");"object"==typeof __meteor_runtime_config__&&__meteor_runtime_config__.meteorRelease&&(e.release=__meteor_runtime_config__.meteorRelease),t.extend(e,{_get:function(t){for(var e=1;e<arguments.length;e++){if(!(arguments[e]in t))return void 0;t=t[arguments[e]]}return t},_ensure:function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];n in t||(t[n]={}),t=t[n]}return t},_delete:function(t){for(var e=[t],n=!0,r=1;r<arguments.length-1;r++){var o=arguments[r];if(!(o in t)){n=!1;break}if(t=t[o],"object"!=typeof t)break;e.push(t)}for(var r=e.length-1;r>=0;r--){var o=arguments[r+1];if(n)n=!1;else for(var i in e[r][o])return;delete e[r][o]}},wrapAsync:function(o,i){return function(){for(var a=i||this,u=t.toArray(arguments),s,c=u.length-1;c>=0;--c){var l=u[c],f=typeof l;if("undefined"!==f){"function"===f&&(s=l);break}}if(!s){if(e.isClient)s=n;else{var _=new r;s=_.resolver()}++c}u[c]=e.bindEnvironment(s);var p=o.apply(a,u);return _?_.wait():p}},_inherits:function(e,n){for(var r in n)t.has(n,r)&&(e[r]=n[r]);var o=function(){this.constructor=e};return o.prototype=n.prototype,e.prototype=new o,e.__super__=n.prototype,e}});var o=!1;e._wrapAsync=function(t,n){return o||(e._debug("Meteor._wrapAsync has been renamed to Meteor.wrapAsync"),o=!0),e.wrapAsync.apply(e,arguments)}}.call(this),function(){"use strict";function t(){if(o.setImmediate){var t=function(t){o.setImmediate(t)};return t.implementation="setImmediate",t}return null}function n(){function t(t,e){return"string"==typeof t&&t.substring(0,e.length)===e}function e(e){if(e.source===o&&t(e.data,u)){var n=e.data.substring(u.length);try{a[n]&&a[n]()}finally{delete a[n]}}}if(!o.postMessage||o.importScripts)return null;var n=!0,r=o.onmessage;if(o.onmessage=function(){n=!1},o.postMessage("","*"),o.onmessage=r,!n)return null;var i=0,a={},u="Meteor._setImmediate."+Math.random()+".";o.addEventListener?o.addEventListener("message",e,!1):o.attachEvent("onmessage",e);var s=function(t){++i,a[i]=t,o.postMessage(u+i,"*")};return s.implementation="postMessage",s}function r(){var t=function(t){o.setTimeout(t,0)};return t.implementation="setTimeout",t}var o=this;e._setImmediate=t()||n()||r()}.call(this),function(){var n=function(t){if(Package.ddp){var e=Package.ddp.DDP._CurrentInvocation;if(e.get()&&e.get().isSimulation)throw new Error("Can't set timers inside simulations");return function(){e.withValue(null,t)}}return t},r=function(t,r){return e.bindEnvironment(n(r),t)};t.extend(e,{setTimeout:function(t,e){return setTimeout(r("setTimeout callback",t),e)},setInterval:function(t,e){return setInterval(r("setInterval callback",t),e)},clearInterval:function(t){return clearInterval(t)},clearTimeout:function(t){return clearTimeout(t)},defer:function(t){e._setImmediate(r("defer callback",t))}})}.call(this),function(){e.makeErrorType=function(t,n){var r=function(){var e=this;if(Error.captureStackTrace)Error.captureStackTrace(e,r);else{var o=new Error;o.__proto__=r.prototype,o instanceof r&&(e=o)}return n.apply(e,arguments),e.errorType=t,e};return e._inherits(r,Error),r},e.Error=e.makeErrorType("Meteor.Error",function(t,e,n){var r=this;r.error=t,r.reason=e,r.details=n,r.message=r.reason?r.reason+" ["+r.error+"]":"["+r.error+"]"}),e.Error.prototype.clone=function(){var t=this;return new e.Error(t.error,t.reason,t.details)}}.call(this),function(){e._noYieldsAllowed=function(t){return t()},e._SynchronousQueue=function(){var t=this;t._tasks=[],t._running=!1,t._runTimeout=null},t.extend(e._SynchronousQueue.prototype,{runTask:function(n){var r=this;if(!r.safeToRunTask())throw new Error("Could not synchronously run a task from a running task");r._tasks.push(n);var o=r._tasks;r._tasks=[],r._running=!0,r._runTimeout&&(clearTimeout(r._runTimeout),r._runTimeout=null);try{for(;!t.isEmpty(o);){var i=o.shift();try{i()}catch(a){if(t.isEmpty(o))throw a;e._debug("Exception in queued task: "+a.stack)}}}finally{r._running=!1}},queueTask:function(e){var n=this;n._tasks.push(e),n._runTimeout||(n._runTimeout=setTimeout(t.bind(n.flush,n),0))},flush:function(){var t=this;t.runTask(function(){})},drain:function(){var e=this;if(e.safeToRunTask())for(;!t.isEmpty(e._tasks);)e.flush()},safeToRunTask:function(){var t=this;return!t._running}})}.call(this),function(){var t=[],n=!e.isCordova&&("loaded"===document.readyState||"complete"==document.readyState),r=1,o=function(){if(r--,!(r>0)){n=!0;var o=function(){if(e.isCordova&&(!cordova.plugins||!cordova.plugins.CordovaUpdate))return void e.setTimeout(o,20);for(;t.length;)t.shift()()};o()}};document.addEventListener?(document.addEventListener("DOMContentLoaded",o,!1),e.isCordova&&(r++,document.addEventListener("deviceready",o,!1)),window.addEventListener("load",o,!1)):(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&o()}),window.attachEvent("load",o)),e.startup=function(r){var o=!document.addEventListener&&document.documentElement.doScroll;if(o&&window===top){try{o("left")}catch(i){return void setTimeout(function(){e.startup(r)},50)}r()}else n?r():t.push(r)}}.call(this),function(){var t=0;e._debug=function(){if(t)return void t--;if("undefined"!=typeof console&&"undefined"!=typeof console.log)if(0==arguments.length)console.log("");else if("function"==typeof console.log.apply){for(var e=!0,n=0;n<arguments.length;n++)"string"!=typeof arguments[n]&&(e=!1);e?console.log.apply(console,[Array.prototype.join.call(arguments," ")]):console.log.apply(console,arguments)}else if("function"==typeof Function.prototype.bind){var r=Function.prototype.bind.call(console.log,console);r.apply(console,arguments)}else Function.prototype.call.call(console.log,console,Array.prototype.slice.call(arguments))},e._suppress_log=function(e){t+=e}}.call(this),function(){var n=0,r=[];e.EnvironmentVariable=function(){this.slot=n++},t.extend(e.EnvironmentVariable.prototype,{get:function(){return r[this.slot]},getOrNullIfOutsideFiber:function(){return this.get()},withValue:function(t,e){var n=r[this.slot];try{r[this.slot]=t;var o=e()}finally{r[this.slot]=n}return o}}),e.bindEnvironment=function(n,o,i){var a=t.clone(r);if(!o||"string"==typeof o){var u=o||"callback of async function";o=function(t){e._debug("Exception in "+u+":",t&&t.stack||t)}}return function(){var e=r;try{r=a;var u=n.apply(i,t.toArray(arguments))}catch(s){o(s)}finally{r=e}return u}},e._nodeCodeMustBeInFiber=function(){}}.call(this),function(){e.absoluteUrl=function(n,r){r||"object"!=typeof n||(r=n,n=void 0),r=t.extend({},e.absoluteUrl.defaultOptions,r||{});var o=r.rootUrl;if(!o)throw new Error("Must pass options.rootUrl or set ROOT_URL in the server environment");return/^http[s]?:\/\//i.test(o)||(o="http://"+o),/\/$/.test(o)||(o+="/"),n&&(o+=n),r.secure&&/^http:/.test(o)&&!/http:\/\/localhost[:\/]/.test(o)&&!/http:\/\/127\.0\.0\.1[:\/]/.test(o)&&(o=o.replace(/^http:/,"https:")),r.replaceLocalhost&&(o=o.replace(/^http:\/\/localhost([:\/].*)/,"http://127.0.0.1$1")),o},e.absoluteUrl.defaultOptions={},"object"==typeof __meteor_runtime_config__&&__meteor_runtime_config__.ROOT_URL&&(e.absoluteUrl.defaultOptions.rootUrl=__meteor_runtime_config__.ROOT_URL),e._relativeToSiteRootUrl=function(t){return"object"==typeof __meteor_runtime_config__&&"/"===t.substr(0,1)&&(t=(__meteor_runtime_config__.ROOT_URL_PATH_PREFIX||"")+t),t}}.call(this),"undefined"==typeof Package&&(Package={}),Package.meteor={Meteor:e}}();
+
+!function(){var Meteor=Package.meteor.Meteor,JSON;(function(){window.JSON&&(JSON=window.JSON)}).call(this),function(){"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(t){return 10>t?"0"+t:t}function quote(t){return escapable.lastIndex=0,escapable.test(t)?'"'+t.replace(escapable,function(t){var e=meta[t];return"string"==typeof e?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function str(t,e){var n,r,o,f,u=gap,i,a=e[t];switch(a&&"object"==typeof a&&"function"==typeof a.toJSON&&(a=a.toJSON(t)),"function"==typeof rep&&(a=rep.call(e,t,a)),typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";if(gap+=indent,i=[],"[object Array]"===Object.prototype.toString.apply(a)){for(f=a.length,n=0;f>n;n+=1)i[n]=str(n,a)||"null";return o=0===i.length?"[]":gap?"[\n"+gap+i.join(",\n"+gap)+"\n"+u+"]":"["+i.join(",")+"]",gap=u,o}if(rep&&"object"==typeof rep)for(f=rep.length,n=0;f>n;n+=1)"string"==typeof rep[n]&&(r=rep[n],o=str(r,a),o&&i.push(quote(r)+(gap?": ":":")+o));else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(o=str(r,a),o&&i.push(quote(r)+(gap?": ":":")+o));return o=0===i.length?"{}":gap?"{\n"+gap+i.join(",\n"+gap)+"\n"+u+"}":"{"+i.join(",")+"}",gap=u,o}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(t){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(t){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(t,e,n){var r;if(gap="",indent="","number"==typeof n)for(r=0;n>r;r+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=e,e&&"function"!=typeof e&&("object"!=typeof e||"number"!=typeof e.length))throw new Error("JSON.stringify");return str("",{"":t})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(t,e){var n,r,o=t[e];if(o&&"object"==typeof o)for(n in o)Object.prototype.hasOwnProperty.call(o,n)&&(r=walk(o,n),void 0!==r?o[n]=r:delete o[n]);return reviver.call(t,e,o)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()}.call(this),"undefined"==typeof Package&&(Package={}),Package.json={JSON:JSON}}();
+
+!function(){var n=Package.meteor.Meteor,r;(function(){for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={},a=0;a<n.length;a++)e[n.charAt(a)]=a;r={},r.encode=function(n){if("string"==typeof n){var e=n;n=r.newBinary(e.length);for(var a=0;a<e.length;a++){var l=e.charCodeAt(a);if(l>255)throw new Error("Not ascii. Base64.encode can only take ascii strings.");n[a]=l}}for(var u=[],i=null,o=null,c=null,s=null,a=0;a<n.length;a++)switch(a%3){case 0:i=n[a]>>2&63,o=(3&n[a])<<4;break;case 1:o|=n[a]>>4&15,c=(15&n[a])<<2;break;case 2:c|=n[a]>>6&3,s=63&n[a],u.push(t(i)),u.push(t(o)),u.push(t(c)),u.push(t(s)),i=null,o=null,c=null,s=null}return null!=i&&(u.push(t(i)),u.push(t(o)),u.push(null==c?"=":t(c)),null==s&&u.push("=")),u.join("")};var t=function(r){return n.charAt(r)},l=function(n){return"="===n?-1:e[n]};r.newBinary=function(n){if("undefined"==typeof Uint8Array||"undefined"==typeof ArrayBuffer){for(var r=[],e=0;n>e;e++)r.push(0);return r.$Uint8ArrayPolyfill=!0,r}return new Uint8Array(new ArrayBuffer(n))},r.decode=function(n){var e=Math.floor(3*n.length/4);"="==n.charAt(n.length-1)&&(e--,"="==n.charAt(n.length-2)&&e--);for(var a=r.newBinary(e),t=null,u=null,i=null,o=0,c=0;c<n.length;c++){var s=n.charAt(c),f=l(s);switch(c%4){case 0:if(0>f)throw new Error("invalid base64 string");t=f<<2;break;case 1:if(0>f)throw new Error("invalid base64 string");t|=f>>4,a[o++]=t,u=(15&f)<<4;break;case 2:f>=0&&(u|=f>>2,a[o++]=u,i=(3&f)<<6);break;case 3:f>=0&&(a[o++]=i|f)}}return a}}).call(this),"undefined"==typeof Package&&(Package={}),Package.base64={Base64:r}}();
+
+!function(){var n=Package.meteor.Meteor,e=Package.json.JSON,t=Package.underscore._,r=Package.base64.Base64,u,a;(function(){u={},a={};var i={};u.addType=function(n,e){if(t.has(i,n))throw new Error("Type "+n+" already present");i[n]=e};var o=function(n){return t.isNaN(n)||1/0===n||n===-1/0},f=[{matchJSONValue:function(n){return t.has(n,"$date")&&1===t.size(n)},matchObject:function(n){return n instanceof Date},toJSONValue:function(n){return{$date:n.getTime()}},fromJSONValue:function(n){return new Date(n.$date)}},{matchJSONValue:function(n){return t.has(n,"$InfNaN")&&1===t.size(n)},matchObject:o,toJSONValue:function(n){var e;return e=t.isNaN(n)?0:1/0===n?1:-1,{$InfNaN:e}},fromJSONValue:function(n){return n.$InfNaN/0}},{matchJSONValue:function(n){return t.has(n,"$binary")&&1===t.size(n)},matchObject:function(n){return"undefined"!=typeof Uint8Array&&n instanceof Uint8Array||n&&t.has(n,"$Uint8ArrayPolyfill")},toJSONValue:function(n){return{$binary:r.encode(n)}},fromJSONValue:function(n){return r.decode(n.$binary)}},{matchJSONValue:function(n){return t.has(n,"$escape")&&1===t.size(n)},matchObject:function(n){return t.isEmpty(n)||t.size(n)>2?!1:t.any(f,function(e){return e.matchJSONValue(n)})},toJSONValue:function(n){var e={};return t.each(n,function(n,t){e[t]=u.toJSONValue(n)}),{$escape:e}},fromJSONValue:function(n){var e={};return t.each(n.$escape,function(n,t){e[t]=u.fromJSONValue(n)}),e}},{matchJSONValue:function(n){return t.has(n,"$type")&&t.has(n,"$value")&&2===t.size(n)},matchObject:function(n){return u._isCustomType(n)},toJSONValue:function(e){var t=n._noYieldsAllowed(function(){return e.toJSONValue()});return{$type:e.typeName(),$value:t}},fromJSONValue:function(e){var r=e.$type;if(!t.has(i,r))throw new Error("Custom EJSON type "+r+" is not defined");var u=i[r];return n._noYieldsAllowed(function(){return u(e.$value)})}}];u._isCustomType=function(n){return n&&"function"==typeof n.toJSONValue&&"function"==typeof n.typeName&&t.has(i,n.typeName())};var c=u._adjustTypesToJSONValue=function(n){if(null===n)return null;var e=l(n);return void 0!==e?e:"object"!=typeof n?n:(t.each(n,function(e,t){if("object"==typeof e||void 0===e||o(e)){var r=l(e);return r?void(n[t]=r):void c(e)}}),n)},l=function(n){for(var e=0;e<f.length;e++){var t=f[e];if(t.matchObject(n))return t.toJSONValue(n)}return void 0};u.toJSONValue=function(n){var e=l(n);return void 0!==e?e:("object"==typeof n&&(n=u.clone(n),c(n)),n)};var s=u._adjustTypesFromJSONValue=function(n){if(null===n)return null;var e=y(n);return e!==n?e:"object"!=typeof n?n:(t.each(n,function(e,t){if("object"==typeof e){var r=y(e);if(e!==r)return void(n[t]=r);s(e)}}),n)},y=function(n){if("object"==typeof n&&null!==n&&t.size(n)<=2&&t.all(n,function(n,e){return"string"==typeof e&&"$"===e.substr(0,1)}))for(var e=0;e<f.length;e++){var r=f[e];if(r.matchJSONValue(n))return r.fromJSONValue(n)}return n};u.fromJSONValue=function(n){var e=y(n);return e===n&&"object"==typeof n?(n=u.clone(n),s(n),n):e},u.stringify=function(n,t){var r=u.toJSONValue(n);return t&&(t.canonical||t.indent)?u._canonicalStringify(r,t):e.stringify(r)},u.parse=function(n){if("string"!=typeof n)throw new Error("EJSON.parse argument should be a string");return u.fromJSONValue(e.parse(n))},u.isBinary=function(n){return!!("undefined"!=typeof Uint8Array&&n instanceof Uint8Array||n&&n.$Uint8ArrayPolyfill)},u.equals=function(n,e,r){var a,i=!(!r||!r.keyOrderSensitive);if(n===e)return!0;if(t.isNaN(n)&&t.isNaN(e))return!0;if(!n||!e)return!1;if("object"!=typeof n||"object"!=typeof e)return!1;if(n instanceof Date&&e instanceof Date)return n.valueOf()===e.valueOf();if(u.isBinary(n)&&u.isBinary(e)){if(n.length!==e.length)return!1;for(a=0;a<n.length;a++)if(n[a]!==e[a])return!1;return!0}if("function"==typeof n.equals)return n.equals(e,r);if("function"==typeof e.equals)return e.equals(n,r);if(n instanceof Array){if(!(e instanceof Array))return!1;if(n.length!==e.length)return!1;for(a=0;a<n.length;a++)if(!u.equals(n[a],e[a],r))return!1;return!0}switch(u._isCustomType(n)+u._isCustomType(e)){case 1:return!1;case 2:return u.equals(u.toJSONValue(n),u.toJSONValue(e))}var o;if(i){var f=[];return t.each(e,function(n,e){f.push(e)}),a=0,o=t.all(n,function(n,t){return a>=f.length?!1:t!==f[a]?!1:u.equals(n,e[f[a]],r)?(a++,!0):!1}),o&&a===f.length}return a=0,o=t.all(n,function(n,i){return t.has(e,i)&&u.equals(n,e[i],r)?(a++,!0):!1}),o&&t.size(e)===a},u.clone=function(n){var e;if("object"!=typeof n)return n;if(null===n)return null;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return n;if(u.isBinary(n)){e=u.newBinary(n.length);for(var r=0;r<n.length;r++)e[r]=n[r];return e}if(t.isArray(n)||t.isArguments(n)){for(e=[],r=0;r<n.length;r++)e[r]=u.clone(n[r]);return e}return"function"==typeof n.clone?n.clone():u._isCustomType(n)?u.fromJSONValue(u.clone(u.toJSONValue(n)),!0):(e={},t.each(n,function(n,t){e[t]=u.clone(n)}),e)},u.newBinary=r.newBinary}).call(this),function(){function n(n){return e.stringify(n)}var r=function(e,u,a,i,o){var f,c,l,s,y=i,h,N=u[e];switch(typeof N){case"string":return n(N);case"number":return isFinite(N)?String(N):"null";case"boolean":return String(N);case"object":if(!N)return"null";if(y=i+a,h=[],t.isArray(N)||t.isArguments(N)){for(s=N.length,f=0;s>f;f+=1)h[f]=r(f,N,a,y,o)||"null";return l=0===h.length?"[]":y?"[\n"+y+h.join(",\n"+y)+"\n"+i+"]":"["+h.join(",")+"]"}var p=t.keys(N);return o&&(p=p.sort()),t.each(p,function(e){l=r(e,N,a,y,o),l&&h.push(n(e)+(y?": ":":")+l)}),l=0===h.length?"{}":y?"{\n"+y+h.join(",\n"+y)+"\n"+i+"}":"{"+h.join(",")+"}"}};u._canonicalStringify=function(n,e){if(e=t.extend({indent:"",canonical:!1},e),e.indent===!0)e.indent=" ";else if("number"==typeof e.indent){for(var u="",a=0;a<e.indent;a++)u+=" ";e.indent=u}return r("",{"":n},e.indent,"",e.canonical)}}.call(this),"undefined"==typeof Package&&(Package={}),Package.ejson={EJSON:u,EJSONTest:a}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,r=Package.ejson.EJSON,n;(function(){n=function(){return n.info.apply(this,arguments)};var i=0,o=[],a=0;n._intercept=function(e){i+=e},n._suppress=function(e){a+=e},n._intercepted=function(){var e=o;return o=[],i=0,e},n.outputFormat="json";var s={debug:"green",warn:"magenta",error:"red"},l="blue",c=["time","timeInexact","level","file","line","program","originApp","satellite","stderr"],u=c.concat(["app","message"]),g=function(t){var r=n.format(t),i=t.level;"undefined"!=typeof console&&console[i]?console[i](r):e._debug(r)};n._getCallerDetails=function(){var e=function(){var e=new Error,t=e.stack;return t},t=e();if(!t)return{};for(var r=t.split("\n"),n,i=1;i<r.length;++i){if(n=r[i],n.match(/^\s*at eval \(eval/))return{file:"eval"};if(!n.match(/packages\/(?:local-test:)?logging(?:\/|\.js)/))break}var o={},a=/(?:[@(]| at )([^(]+?):([0-9:]+)(?:\)|$)/.exec(n);return a?(o.line=a[2].split(":")[0],o.file=a[1].split("/").slice(-1)[0].split("?")[0],o):o},t.each(["debug","info","warn","error"],function(s){n[s]=function(l){if(a)return void a--;var u=!1;i&&(i--,u=!0);var f=!t.isObject(l)||t.isRegExp(l)||t.isDate(l)?{message:new String(l).toString()}:l;if(t.each(c,function(e){if(f[e])throw new Error("Can't set '"+e+"' in log message")}),t.has(f,"message")&&!t.isString(f.message))throw new Error("The 'message' field in log objects must be a string");if(f.omitCallerDetails||(f=t.extend(n._getCallerDetails(),f)),f.time=new Date,f.level=s,"debug"!==s)if(u)o.push(r.stringify(f));else if(e.isServer)if("colored-text"===n.outputFormat)console.log(n.format(f,{color:!0}));else{if("json"!==n.outputFormat)throw new Error("Unknown logging output format: "+n.outputFormat);console.log(r.stringify(f))}else g(f)}}),n.parse=function(e){var t=null;if(e&&"{"===e.charAt(0))try{t=r.parse(e)}catch(n){}return t&&t.time&&t.time instanceof Date?t:null},n.format=function(n,i){n=r.clone(n),i=i||{};var o=n.time;if(!(o instanceof Date))throw new Error("'time' must be a Date object");var a=n.timeInexact,c=n.level||"info",g=n.file,f=n.line,m=n.app||"",p=n.originApp,v=n.message||"",h=n.program||"",d=n.satellite,w=n.stderr||"";t.each(u,function(e){delete n[e]}),t.isEmpty(n)||(v&&(v+=" "),v+=r.stringify(n));var b=function(e){return 10>e?"0"+e:e.toString()},D=function(e){return 100>e?"0"+b(e):e.toString()},j=o.getFullYear().toString()+b(o.getMonth()+1)+b(o.getDate()),S=b(o.getHours())+":"+b(o.getMinutes())+":"+b(o.getSeconds())+"."+D(o.getMilliseconds()),k="("+-((new Date).getTimezoneOffset()/60)+")",E="";m&&(E+=m),p&&p!==m&&(E+=" via "+p),E&&(E="["+E+"] ");var x=[];h&&x.push(h),g&&x.push(g),f&&x.push(f);var y=t.isEmpty(x)?"":"("+x.join(":")+") ";d&&(y+=["[",d,"]"].join(""));var _=w?"(STDERR) ":"",C=[c.charAt(0).toUpperCase(),j,"-",S,k,a?"? ":" ",E,y,_].join(""),F=function(t,r){return i.color&&e.isServer&&r?Npm.require("cli-color")[r](t):t};return F(C,i.metaColor||l)+F(v,s[c])},n.objFromText=function(e,r){var n={message:e,level:"info",time:new Date,timeInexact:!0};return t.extend(n,r)}}).call(this),"undefined"==typeof Package&&(Package={}),Package.logging={Log:n}}();
+
+!function(){var a=Package.meteor.Meteor,e=Package.underscore._,t=Package.logging.Log,o=Package.json.JSON,n;(function(){n={};var t="Meteor_Reload",r={},i,l=null;try{l=window.sessionStorage,l?(l.setItem("__dummy__","1"),l.removeItem("__dummy__")):l=null}catch(g){l=null}n._getData=function(){return l&&l.getItem(t)},l&&(i=n._getData(),l.removeItem(t)),i||(i="{}");var c={};try{c=o.parse(i),"object"!=typeof c&&(a._debug("Got bad data on reload. Ignoring."),c={})}catch(d){a._debug("Got invalid JSON on reload. Ignoring.")}c.reload&&"object"==typeof c.data&&(r=c.data);var u=[];n._onMigrate=function(a,e){e||(e=a,a=void 0),u.push({name:a,callback:e})},n._migrationData=function(a){return r[a]};var s=function(a,t){a=a||function(){},t=t||{};for(var o={},n=e.clone(u),r=!0;n.length;){var i=n.shift(),l=i.callback(a,t);l[0]||(r=!1),l.length>1&&i.name&&(o[i.name]=l[1])}return r||t.immediateMigration?o:null};n._migrate=function(e,n){var r=s(e,n);if(null===r)return!1;try{var i=o.stringify({data:r,reload:!0})}catch(g){throw a._debug("Couldn't serialize data for migration",r),g}if(l)try{l.setItem(t,i)}catch(g){a._debug("Couldn't save data for migration to sessionStorage",g)}else a._debug("Browser does not support sessionStorage. Not saving migration state.");return!0},n._withFreshProvidersForTest=function(a){var t=e.clone(u);u=[];try{a()}finally{u=t}};var f=!1;n._reload=function(a){if(a=a||{},!f){f=!0;var t=function(){e.defer(function(){n._migrate(t,a)&&window.location.reload()})};t()}}}).call(this),function(){a._reload={onMigrate:n._onMigrate,migrationData:n._migrationData,reload:n._reload}}.call(this),"undefined"==typeof Package&&(Package={}),Package.reload={Reload:n}}();
+
+!function(){var t=Package.meteor.Meteor,n,e;(function(){n={},n.active=!1,n.currentComputation=null;var e=function(t){n.currentComputation=t,n.active=!!t},o=function(){return"undefined"!=typeof t?t._debug:"undefined"!=typeof console&&console.log?function(){console.log.apply(console,arguments)}:function(){}},r=function(t,n){if(p)throw n;var e;if(n.stack&&n.message){var r=n.stack.indexOf(n.message);e=r>=0&&10>=r?n.stack:n.message+("\n"===n.stack.charAt(0)?"":"\n")+n.stack}else e=n.stack||n.message;o()("Exception from Tracker "+t+" function:",e)},a=function(n){return"undefined"==typeof t||t.isClient?n:function(){var e=arguments;t._noYieldsAllowed(function(){n.apply(null,e)})}},i=1,u=[],c=!1,s=!1,f=!1,p=!1,d=[],l=function(){c||(setTimeout(n.flush,0),c=!0)},v=!1;n.Computation=function(t,n){if(!v)throw new Error("Tracker.Computation constructor is private; use Tracker.autorun");v=!1;var e=this;e.stopped=!1,e.invalidated=!1,e.firstRun=!0,e._id=i++,e._onInvalidateCallbacks=[],e._parent=n,e._func=t,e._recomputing=!1;var o=!0;try{e._compute(),o=!1}finally{e.firstRun=!1,o&&e.stop()}},n.Computation.prototype.onInvalidate=function(t){var e=this;if("function"!=typeof t)throw new Error("onInvalidate requires a function");e.invalidated?n.nonreactive(function(){a(t)(e)}):e._onInvalidateCallbacks.push(t)},n.Computation.prototype.invalidate=function(){var t=this;if(!t.invalidated){t._recomputing||t.stopped||(l(),u.push(this)),t.invalidated=!0;for(var e=0,o;o=t._onInvalidateCallbacks[e];e++)n.nonreactive(function(){a(o)(t)});t._onInvalidateCallbacks=[]}},n.Computation.prototype.stop=function(){this.stopped||(this.stopped=!0,this.invalidate())},n.Computation.prototype._compute=function(){var t=this;t.invalidated=!1;var o=n.currentComputation;e(t);var r=f;f=!0;try{a(t._func)(t)}finally{e(o),f=r}},n.Computation.prototype._recompute=function(){var t=this;t._recomputing=!0;try{for(;t.invalidated&&!t.stopped;)try{t._compute()}catch(n){r("recompute",n)}}finally{t._recomputing=!1}},n.Dependency=function(){this._dependentsById={}},n.Dependency.prototype.depend=function(t){if(!t){if(!n.active)return!1;t=n.currentComputation}var e=this,o=t._id;return o in e._dependentsById?!1:(e._dependentsById[o]=t,t.onInvalidate(function(){delete e._dependentsById[o]}),!0)},n.Dependency.prototype.changed=function(){var t=this;for(var n in t._dependentsById)t._dependentsById[n].invalidate()},n.Dependency.prototype.hasDependents=function(){var t=this;for(var n in t._dependentsById)return!0;return!1},n.flush=function(t){if(s)throw new Error("Can't call Tracker.flush while flushing");if(f)throw new Error("Can't flush inside Tracker.autorun");s=!0,c=!0,p=!(!t||!t._throwFirstError);var e=!1;try{for(;u.length||d.length;){for(;u.length;){var o=u.shift();o._recompute()}if(d.length){var a=d.shift();try{a()}catch(i){r("afterFlush",i)}}}e=!0}finally{e||(s=!1,n.flush({_throwFirstError:!1})),c=!1,s=!1}},n.autorun=function(t){if("function"!=typeof t)throw new Error("Tracker.autorun requires a function argument");v=!0;var e=new n.Computation(t,n.currentComputation);return n.active&&n.onInvalidate(function(){e.stop()}),e},n.nonreactive=function(t){var o=n.currentComputation;e(null);try{return t()}finally{e(o)}},n.onInvalidate=function(t){if(!n.active)throw new Error("Tracker.onInvalidate requires a currentComputation");n.currentComputation.onInvalidate(t)},n.afterFlush=function(t){d.push(t),l()}}).call(this),function(){t.flush=n.flush,t.autorun=n.autorun,t.autosubscribe=n.autorun,n.depend=function(t){return t.depend()},e=n}.call(this),"undefined"==typeof Package&&(Package={}),Package.tracker={Tracker:n,Deps:e}}();
+
+!function(){var e=Package.meteor.Meteor,n=Package.underscore._,t;(function(){if(e.isServer)var n=Npm.require("crypto");var r=function(){function e(){var e=4022871197,n=function(n){n=n.toString();for(var t=0;t<n.length;t++){e+=n.charCodeAt(t);var r=.02519603282416938*e;e=r>>>0,r-=e,r*=e,e=r>>>0,r-=e,e+=4294967296*r}return 2.3283064365386963e-10*(e>>>0)};return n.version="Mash 0.9",n}return function(n){var t=0,r=0,o=0,i=1;0==n.length&&(n=[+new Date]);var a=e();t=a(" "),r=a(" "),o=a(" ");for(var u=0;u<n.length;u++)t-=a(n[u]),0>t&&(t+=1),r-=a(n[u]),0>r&&(r+=1),o-=a(n[u]),0>o&&(o+=1);a=null;var d=function(){var e=2091639*t+2.3283064365386963e-10*i;return t=r,r=o,o=e-(i=0|e)};return d.uint32=function(){return 4294967296*d()},d.fract53=function(){return d()+1.1102230246251565e-16*(2097152*d()|0)},d.version="Alea 0.9",d.args=n,d}(Array.prototype.slice.call(arguments))},o="23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz",i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_",a=function(e){var n=this;void 0!==e&&(n.alea=r.apply(null,e))};a.prototype.fraction=function(){var e=this;if(e.alea)return e.alea();if(n){var t=parseInt(e.hexString(8),16);return 2.3283064365386963e-10*t}if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues){var r=new Uint32Array(1);return window.crypto.getRandomValues(r),2.3283064365386963e-10*r[0]}throw new Error("No random generator available")},a.prototype.hexString=function(e){var t=this;if(n&&!t.alea){var r=Math.ceil(e/2),o;try{o=n.randomBytes(r)}catch(i){o=n.pseudoRandomBytes(r)}var a=o.toString("hex");return a.substring(0,e)}for(var u=[],d=0;e>d;++d)u.push(t.choice("0123456789abcdef"));return u.join("")},a.prototype._randomString=function(e,n){for(var t=this,r=[],o=0;e>o;o++)r[o]=t.choice(n);return r.join("")},a.prototype.id=function(e){var n=this;return void 0===e&&(e=17),n._randomString(e,o)},a.prototype.secret=function(e){var n=this;return void 0===e&&(e=43),n._randomString(e,i)},a.prototype.choice=function(e){var n=Math.floor(this.fraction()*e.length);return"string"==typeof e?e.substr(n,1):e[n]};var u="undefined"!=typeof window&&window.innerHeight||"undefined"!=typeof document&&document.documentElement&&document.documentElement.clientHeight||"undefined"!=typeof document&&document.body&&document.body.clientHeight||1,d="undefined"!=typeof window&&window.innerWidth||"undefined"!=typeof document&&document.documentElement&&document.documentElement.clientWidth||"undefined"!=typeof document&&document.body&&document.body.clientWidth||1,c="undefined"!=typeof navigator&&navigator.userAgent||"";t=n||"undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues?new a:new a([new Date,u,d,c,Math.random()]),t.createWithSeeds=function(){if(0===arguments.length)throw new Error("No seeds were provided");return new a(arguments)}}).call(this),function(){e.uuid=function(){for(var e="0123456789abcdef",n=[],r=0;36>r;r++)n[r]=t.choice(e);n[14]="4",n[19]=e.substr(3&parseInt(n[19],16)|8,1),n[8]=n[13]=n[18]=n[23]="-";var o=n.join("");return o}}.call(this),"undefined"==typeof Package&&(Package={}),Package.random={Random:t}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,r=Package.random.Random,i;(function(){i=function(e){var r=this;t.extend(r,t.defaults(t.clone(e||{}),{baseTimeout:1e3,exponent:2.2,maxTimeout:3e5,minTimeout:10,minCount:2,fuzz:.5})),r.retryTimer=null},t.extend(i.prototype,{clear:function(){var e=this;e.retryTimer&&clearTimeout(e.retryTimer),e.retryTimer=null},_timeout:function(e){var t=this;if(e<t.minCount)return t.minTimeout;var i=Math.min(t.maxTimeout,t.baseTimeout*Math.pow(t.exponent,e));return i*=r.fraction()*t.fuzz+(1-t.fuzz/2)},retryLater:function(t,r){var i=this,n=i._timeout(t);return i.retryTimer&&clearTimeout(i.retryTimer),i.retryTimer=e.setTimeout(r,n),n}})}).call(this),"undefined"==typeof Package&&(Package={}),Package.retry={Retry:i}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,r=Package.ejson.EJSON,n,i;(function(){var o=new e.EnvironmentVariable;n=function(e,t){var r=o.getOrNullIfOutsideFiber();r&&r.checking(e);try{l(e,t)}catch(n){throw n instanceof i.Error&&n.path&&(n.message+=" in field "+n.path),n}},i={Optional:function(e){return new a(e)},OneOf:function(){return new c(t.toArray(arguments))},Any:["__any__"],Where:function(e){return new f(e)},ObjectIncluding:function(e){return new s(e)},ObjectWithValues:function(e){return new h(e)},Integer:["__integer__"],Error:e.makeErrorType("Match.Error",function(t){this.message="Match error: "+t,this.path="",this.sanitizedError=new e.Error(400,"Match failed")}),test:function(e,t){try{return l(e,t),!0}catch(r){if(r instanceof i.Error)return!1;throw r}},_failIfArgumentsAreNotAllChecked:function(e,t,r,n){var i=new p(r,n),a=o.withValue(i,function(){return e.apply(t,r)});return i.throwUnlessAllArgumentsHaveBeenChecked(),a}};var a=function(e){this.pattern=e},c=function(e){if(t.isEmpty(e))throw new Error("Must provide at least one choice to Match.OneOf");this.choices=e},f=function(e){this.condition=e},s=function(e){this.pattern=e},h=function(e){this.pattern=e},u=[[String,"string"],[Number,"number"],[Boolean,"boolean"],[void 0,"undefined"]],l=function(e,n){if(n!==i.Any){for(var o=0;o<u.length;++o)if(n===u[o][0]){if(typeof e===u[o][1])return;throw new i.Error("Expected "+u[o][1]+", got "+typeof e)}if(null===n){if(null===e)return;throw new i.Error("Expected null, got "+r.stringify(e))}if("string"==typeof n||"number"==typeof n){if(e===n)return;throw new i.Error("Expected "+n+", got "+r.stringify(e))}if(n===i.Integer){if("number"==typeof e&&(0|e)===e)return;throw new i.Error("Expected Integer, got "+(e instanceof Object?r.stringify(e):e))}if(n===Object&&(n=i.ObjectIncluding({})),n instanceof Array){if(1!==n.length)throw Error("Bad pattern: arrays must have one type element"+r.stringify(n));if(!t.isArray(e)&&!t.isArguments(e))throw new i.Error("Expected array, got "+r.stringify(e));return void t.each(e,function(e,t){try{l(e,n[0])}catch(r){throw r instanceof i.Error&&(r.path=w(t,r.path)),r}})}if(n instanceof f){if(n.condition(e))return;throw new i.Error("Failed Match.Where validation")}if(n instanceof a&&(n=i.OneOf(void 0,n.pattern)),n instanceof c){for(var o=0;o<n.choices.length;++o)try{return void l(e,n.choices[o])}catch(p){if(!(p instanceof i.Error))throw p}throw new i.Error("Failed Match.OneOf or Match.Optional validation")}if(n instanceof Function){if(e instanceof n)return;throw new i.Error("Expected "+(n.name||"particular constructor"))}var g=!1,d;if(n instanceof s&&(g=!0,n=n.pattern),n instanceof h&&(g=!0,d=[n.pattern],n={}),"object"!=typeof n)throw Error("Bad pattern: unknown pattern type");if("object"!=typeof e)throw new i.Error("Expected object, got "+typeof e);if(null===e)throw new i.Error("Expected object, got null");if(e.constructor!==Object)throw new i.Error("Expected plain object");var y={},E={};t.each(n,function(e,t){e instanceof a?E[t]=e.pattern:y[t]=e}),t.each(e,function(e,r){try{if(t.has(y,r))l(e,y[r]),delete y[r];else if(t.has(E,r))l(e,E[r]);else{if(!g)throw new i.Error("Unknown key");d&&l(e,d[0])}}catch(n){throw n instanceof i.Error&&(n.path=w(r,n.path)),n}}),t.each(y,function(e,t){throw new i.Error("Missing key '"+t+"'")})}},p=function(e,r){var n=this;n.args=t.clone(e),n.args.reverse(),n.description=r};t.extend(p.prototype,{checking:function(e){var r=this;r._checkingOneValue(e)||(t.isArray(e)||t.isArguments(e))&&t.each(e,t.bind(r._checkingOneValue,r))},_checkingOneValue:function(e){for(var r=this,n=0;n<r.args.length;++n)if(e===r.args[n]||t.isNaN(e)&&t.isNaN(r.args[n]))return r.args.splice(n,1),!0;return!1},throwUnlessAllArgumentsHaveBeenChecked:function(){var e=this;if(!t.isEmpty(e.args))throw new Error("Did not check() all arguments during "+e.description)}});var g=["do","if","in","for","let","new","try","var","case","else","enum","eval","false","null","this","true","void","with","break","catch","class","const","super","throw","while","yield","delete","export","import","public","return","static","switch","typeof","default","extends","finally","package","private","continue","debugger","function","arguments","interface","protected","implements","instanceof"],w=function(e,r){return"number"==typeof e||e.match(/^[0-9]+$/)?e="["+e+"]":(!e.match(/^[a-z_$][0-9a-z_$]*$/i)||t.contains(g,e))&&(e=JSON.stringify([e])),r&&"["!==r[0]?e+"."+r:e+r}}).call(this),"undefined"==typeof Package&&(Package={}),Package.check={check:n,Match:i}}();
+
+!function(){var i=Package.meteor.Meteor,t=Package.underscore._,a=Package.json.JSON,n=Package.ejson.EJSON,e;(function(){e=function(i,t){var n=this;n._map={},n._idStringify=i||a.stringify,n._idParse=t||a.parse},t.extend(e.prototype,{get:function(i){var t=this,a=t._idStringify(i);return t._map[a]},set:function(i,t){var a=this,n=a._idStringify(i);a._map[n]=t},remove:function(i){var t=this,a=t._idStringify(i);delete t._map[a]},has:function(i){var a=this,n=a._idStringify(i);return t.has(a._map,n)},empty:function(){var i=this;return t.isEmpty(i._map)},clear:function(){var i=this;i._map={}},forEach:function(i){for(var a=this,n=t.keys(a._map),e=0;e<n.length;e++){var r=i.call(null,a._map[n[e]],a._idParse(n[e]));if(r===!1)return}},size:function(){var i=this;return t.size(i._map)},setDefault:function(i,a){var n=this,e=n._idStringify(i);return t.has(n._map,e)?n._map[e]:(n._map[e]=a,a)},clone:function(){var i=this,t=new e(i._idStringify,i._idParse);return i.forEach(function(i,a){t.set(a,n.clone(i))}),t}})}).call(this),"undefined"==typeof Package&&(Package={}),Package["id-map"]={IdMap:e}}();
+
+!function(){var t=Package.meteor.Meteor,e=Package.underscore._,r;(function(){var t=function(t,e,r,n){return{key:t,value:e,next:r,prev:n}};r=function(){var t=this;t._dict={},t._first=null,t._last=null,t._size=0;var r=e.toArray(arguments);t._stringify=function(t){return t},"function"==typeof r[0]&&(t._stringify=r.shift()),e.each(r,function(e){t.putBefore(e[0],e[1],null)})},e.extend(r.prototype,{_k:function(t){return" "+this._stringify(t)},empty:function(){var t=this;return!t._first},size:function(){var t=this;return t._size},_linkEltIn:function(t){var e=this;t.next?(t.prev=t.next.prev,t.next.prev=t,t.prev&&(t.prev.next=t)):(t.prev=e._last,e._last&&(e._last.next=t),e._last=t),(null===e._first||e._first===t.next)&&(e._first=t)},_linkEltOut:function(t){var e=this;t.next&&(t.next.prev=t.prev),t.prev&&(t.prev.next=t.next),t===e._last&&(e._last=t.prev),t===e._first&&(e._first=t.next)},putBefore:function(e,r,n){var i=this;if(i._dict[i._k(e)])throw new Error("Item "+e+" already present in OrderedDict");var o=n?t(e,r,i._dict[i._k(n)]):t(e,r,null);if(void 0===o.next)throw new Error("could not find item to put this one before");i._linkEltIn(o),i._dict[i._k(e)]=o,i._size++},append:function(t,e){var r=this;r.putBefore(t,e,null)},remove:function(t){var e=this,r=e._dict[e._k(t)];if(void 0===r)throw new Error("Item "+t+" not present in OrderedDict");return e._linkEltOut(r),e._size--,delete e._dict[e._k(t)],r.value},get:function(t){var e=this;return e.has(t)?e._dict[e._k(t)].value:void 0},has:function(t){var r=this;return e.has(r._dict,r._k(t))},forEach:function(t){for(var e=this,n=0,i=e._first;null!==i;){var o=t(i.value,i.key,n);if(o===r.BREAK)return;i=i.next,n++}},first:function(){var t=this;return t.empty()?void 0:t._first.key},firstValue:function(){var t=this;return t.empty()?void 0:t._first.value},last:function(){var t=this;return t.empty()?void 0:t._last.key},lastValue:function(){var t=this;return t.empty()?void 0:t._last.value},prev:function(t){var e=this;if(e.has(t)){var r=e._dict[e._k(t)];if(r.prev)return r.prev.key}return null},next:function(t){var e=this;if(e.has(t)){var r=e._dict[e._k(t)];if(r.next)return r.next.key}return null},moveBefore:function(t,e){var r=this,n=r._dict[r._k(t)],i=e?r._dict[r._k(e)]:null;if(void 0===n)throw new Error("Item to move is not present");if(void 0===i)throw new Error("Could not find element to move this one before");i!==n.next&&(r._linkEltOut(n),n.next=i,r._linkEltIn(n))},indexOf:function(t){var e=this,n=null;return e.forEach(function(i,o,u){return e._k(o)===e._k(t)?(n=u,r.BREAK):void 0}),n},_checkRep:function(){var t=this;e.each(t._dict,function(t,e){if(e.next===e)throw new Error("Next is a loop");if(e.prev===e)throw new Error("Prev is a loop")})}}),r.BREAK={"break":!0}}).call(this),"undefined"==typeof Package&&(Package={}),Package["ordered-dict"]={OrderedDict:r}}();
+
+!function(){var t=Package.meteor.Meteor,n,o;(function(){o={exports:{}}}).call(this),function(){!function(){function t(t){for(var n=[],o=[],a=0;a<t[0].length;a++)n.push(t[0][a][1]),o.push(t[0][a][0]);return n=n.sort(function(t,n){return t-n}),o=o.sort(function(t,n){return t-n}),[[n[0],o[0]],[n[n.length-1],o[o.length-1]]]}function n(t,n,o){for(var a=[[0,0]],r=0;r<o.length;r++){for(var e=0;e<o[r].length;e++)a.push(o[r][e]);a.push([0,0])}for(var i=!1,r=0,e=a.length-1;r<a.length;e=r++)a[r][0]>n!=a[e][0]>n&&t<(a[e][1]-a[r][1])*(n-a[r][0])/(a[e][0]-a[r][0])+a[r][1]&&(i=!i);return i}var a={};"undefined"!=typeof o&&o.exports&&(o.exports=a),a.lineStringsIntersect=function(t,n){for(var o=[],a=0;a<=t.coordinates.length-2;++a)for(var r=0;r<=n.coordinates.length-2;++r){var e={x:t.coordinates[a][1],y:t.coordinates[a][0]},i={x:t.coordinates[a+1][1],y:t.coordinates[a+1][0]},s={x:n.coordinates[r][1],y:n.coordinates[r][0]},c={x:n.coordinates[r+1][1],y:n.coordinates[r+1][0]},u=(c.x-s.x)*(e.y-s.y)-(c.y-s.y)*(e.x-s.x),h=(i.x-e.x)*(e.y-s.y)-(i.y-e.y)*(e.x-s.x),d=(c.y-s.y)*(i.x-e.x)-(c.x-s.x)*(i.y-e.y);if(0!=d){var l=u/d,y=h/d;l>=0&&1>=l&&y>=0&&1>=y&&o.push({type:"Point",coordinates:[e.x+l*(i.x-e.x),e.y+l*(i.y-e.y)]})}}return 0==o.length&&(o=!1),o},a.pointInBoundingBox=function(t,n){return!(t.coordinates[1]<n[0][0]||t.coordinates[1]>n[1][0]||t.coordinates[0]<n[0][1]||t.coordinates[0]>n[1][1])},a.pointInPolygon=function(o,r){for(var e="Polygon"==r.type?[r.coordinates]:r.coordinates,i=!1,s=0;s<e.length;s++)a.pointInBoundingBox(o,t(e[s]))&&(i=!0);if(!i)return!1;for(var c=!1,s=0;s<e.length;s++)n(o.coordinates[1],o.coordinates[0],e[s])&&(c=!0);return c},a.numberToRadius=function(t){return t*Math.PI/180},a.numberToDegree=function(t){return 180*t/Math.PI},a.drawCircle=function(t,n,o){for(var r=[n.coordinates[1],n.coordinates[0]],e=t/1e3/6371,i=[a.numberToRadius(r[0]),a.numberToRadius(r[1])],o=o||15,s=[[r[0],r[1]]],c=0;o>c;c++){var u=2*Math.PI*c/o,h=Math.asin(Math.sin(i[0])*Math.cos(e)+Math.cos(i[0])*Math.sin(e)*Math.cos(u)),d=i[1]+Math.atan2(Math.sin(u)*Math.sin(e)*Math.cos(i[0]),Math.cos(e)-Math.sin(i[0])*Math.sin(h));s[c]=[],s[c][1]=a.numberToDegree(h),s[c][0]=a.numberToDegree(d)}return{type:"Polygon",coordinates:[s]}},a.rectangleCentroid=function(t){var n=t.coordinates[0],o=n[0][0],a=n[0][1],r=n[2][0],e=n[2][1],i=r-o,s=e-a;return{type:"Point",coordinates:[o+i/2,a+s/2]}},a.pointDistance=function(t,n){var o=t.coordinates[0],r=t.coordinates[1],e=n.coordinates[0],i=n.coordinates[1],s=a.numberToRadius(i-r),c=a.numberToRadius(e-o),u=Math.pow(Math.sin(s/2),2)+Math.cos(a.numberToRadius(r))*Math.cos(a.numberToRadius(i))*Math.pow(Math.sin(c/2),2),h=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return 6371*h*1e3},a.geometryWithinRadius=function(t,n,o){if("Point"==t.type)return a.pointDistance(t,n)<=o;if("LineString"==t.type||"Polygon"==t.type){var r={},e;e="Polygon"==t.type?t.coordinates[0]:t.coordinates;for(var i in e)if(r.coordinates=e[i],a.pointDistance(r,n)>o)return!1}return!0},a.area=function(t){for(var n=0,o=t.coordinates[0],a=o.length-1,r,e,i=0;i<o.length;a=i++){var r={x:o[i][1],y:o[i][0]},e={x:o[a][1],y:o[a][0]};n+=r.x*e.y,n-=r.y*e.x}return n/=2},a.centroid=function(t){for(var n,o=0,r=0,e=t.coordinates[0],i=e.length-1,s,c,u=0;u<e.length;i=u++){var s={x:e[u][1],y:e[u][0]},c={x:e[i][1],y:e[i][0]};n=s.x*c.y-c.x*s.y,o+=(s.x+c.x)*n,r+=(s.y+c.y)*n}return n=6*a.area(t),{type:"Point",coordinates:[r/n,o/n]}},a.simplify=function(t,n){n=n||20,t=t.map(function(t){return{lng:t.coordinates[0],lat:t.coordinates[1]}});var o,a,r,e,i,s,c,u,h,d,l,y,M,f,g,x,p,v,P,b=Math.PI/180*.5,m=new Array,T=new Array,I=new Array;if(t.length<3)return t;for(o=t.length,d=360*n/(2*Math.PI*6378137),d*=d,r=0,T[0]=0,I[0]=o-1,a=1;a>0;)if(e=T[a-1],i=I[a-1],a--,i-e>1){for(l=t[i].lng()-t[e].lng(),y=t[i].lat()-t[e].lat(),Math.abs(l)>180&&(l=360-Math.abs(l)),l*=Math.cos(b*(t[i].lat()+t[e].lat())),M=l*l+y*y,s=e+1,c=e,h=-1;i>s;s++)f=t[s].lng()-t[e].lng(),g=t[s].lat()-t[e].lat(),Math.abs(f)>180&&(f=360-Math.abs(f)),f*=Math.cos(b*(t[s].lat()+t[e].lat())),x=f*f+g*g,p=t[s].lng()-t[i].lng(),v=t[s].lat()-t[i].lat(),Math.abs(p)>180&&(p=360-Math.abs(p)),p*=Math.cos(b*(t[s].lat()+t[i].lat())),P=p*p+v*v,u=x>=M+P?P:P>=M+x?x:(f*y-g*l)*(f*y-g*l)/M,u>h&&(c=s,h=u);d>h?(m[r]=e,r++):(a++,T[a-1]=c,I[a-1]=i,a++,T[a-1]=e,I[a-1]=c)}else m[r]=e,r++;m[r]=o-1,r++;for(var R=new Array,s=0;r>s;s++)R.push(t[m[s]]);return R.map(function(t){return{type:"Point",coordinates:[t.lng,t.lat]}})},a.destinationPoint=function(t,n,o){o/=6371,n=a.numberToRadius(n);var r=a.numberToRadius(t.coordinates[0]),e=a.numberToRadius(t.coordinates[1]),i=Math.asin(Math.sin(r)*Math.cos(o)+Math.cos(r)*Math.sin(o)*Math.cos(n)),s=e+Math.atan2(Math.sin(n)*Math.sin(o)*Math.cos(r),Math.cos(o)-Math.sin(r)*Math.sin(i));return s=(s+3*Math.PI)%(2*Math.PI)-Math.PI,{type:"Point",coordinates:[a.numberToDegree(i),a.numberToDegree(s)]}}}()}.call(this),function(){n=o.exports}.call(this),"undefined"==typeof Package&&(Package={}),Package["geojson-utils"]={GeoJSON:n}}();
+
+!function(){var e=Package.meteor.Meteor,r=Package.underscore._,t=Package.json.JSON,n=Package.ejson.EJSON,o=Package["id-map"].IdMap,i=Package["ordered-dict"].OrderedDict,a=Package.tracker.Tracker,s=Package.tracker.Deps,c=Package.random.Random,u=Package["geojson-utils"].GeoJSON,d,f,l,h,p,v,_,m,y,g,w,b,$,I,E,O;(function(){d=function(r){var t=this;t.name=r,t._docs=new d._IdMap,t._observeQueue=new e._SynchronousQueue,t.next_qid=1,t.queries={},t._savedOriginals=null,t.paused=!1},f={},l={},d._applyChanges=function(e,t){r.each(t,function(r,t){void 0===r?delete e[t]:e[t]=r})},h=function(e){var r=new Error(e);return r.name="MinimongoError",r},d.prototype.find=function(e,r){return 0===arguments.length&&(e={}),new d.Cursor(this,e,r)},d.Cursor=function(e,r,t){var n=this;t||(t={}),n.collection=e,n.sorter=null,d._selectorIsId(r)?(n._selectorId=r,n.matcher=new f.Matcher(r,n)):(n._selectorId=void 0,n.matcher=new f.Matcher(r,n),(n.matcher.hasGeoQuery()||t.sort)&&(n.sorter=new f.Sorter(t.sort||[],{matcher:n.matcher}))),n.skip=t.skip,n.limit=t.limit,n.fields=t.fields,n.fields&&(n.projectionFn=d._compileProjection(n.fields)),n._transform=d.wrapTransform(t.transform),"undefined"!=typeof a&&(n.reactive=void 0===t.reactive?!0:t.reactive)},d.Cursor.prototype.rewind=function(){},d.prototype.findOne=function(e,r){return 0===arguments.length&&(e={}),r=r||{},r.limit=1,this.find(e,r).fetch()[0]},d.Cursor.prototype.forEach=function(e,t){var o=this,i=o._getRawObjects({ordered:!0});o.reactive&&o._depend({addedBefore:!0,removed:!0,changed:!0,movedBefore:!0}),r.each(i,function(r,i){r=o.projectionFn?o.projectionFn(r):n.clone(r),o._transform&&(r=o._transform(r)),e.call(t,r,i,o)})},d.Cursor.prototype.getTransform=function(){return this._transform},d.Cursor.prototype.map=function(e,r){var t=this,n=[];return t.forEach(function(o,i){n.push(e.call(r,o,i,t))}),n},d.Cursor.prototype.fetch=function(){var e=this,r=[];return e.forEach(function(e){r.push(e)}),r},d.Cursor.prototype.count=function(){var e=this;return e.reactive&&e._depend({added:!0,removed:!0},!0),e._getRawObjects({ordered:!0}).length},d.Cursor.prototype._publishCursor=function(e){var r=this;if(!r.collection.name)throw new Error("Can't publish a cursor from a collection without a name.");var t=r.collection.name;return Mongo.Collection._publishCursor(r,e,t)},d.Cursor.prototype._getCollectionName=function(){var e=this;return e.collection.name},d._observeChangesCallbacksAreOrdered=function(e){if(e.added&&e.addedBefore)throw new Error("Please specify only one of added() and addedBefore()");return!(!e.addedBefore&&!e.movedBefore)},d._observeCallbacksAreOrdered=function(e){if(e.addedAt&&e.added)throw new Error("Please specify only one of added() and addedAt()");if(e.changedAt&&e.changed)throw new Error("Please specify only one of changed() and changedAt()");if(e.removed&&e.removedAt)throw new Error("Please specify only one of removed() and removedAt()");return!!(e.addedAt||e.movedTo||e.changedAt||e.removedAt)},d.ObserveHandle=function(){},r.extend(d.Cursor.prototype,{observe:function(e){var r=this;return d._observeFromObserveChanges(r,e)},observeChanges:function(e){var t=this,o=d._observeChangesCallbacksAreOrdered(e);if(!e._allow_unordered&&!o&&(t.skip||t.limit))throw new Error("must use ordered observe (ie, 'addedBefore' instead of 'added') with skip or limit");if(t.fields&&(0===t.fields._id||t.fields._id===!1))throw Error("You may not observe a cursor with {fields: {_id: 0}}");var i={matcher:t.matcher,sorter:o&&t.sorter,distances:t.matcher.hasGeoQuery()&&o&&new d._IdMap,resultsSnapshot:null,ordered:o,cursor:t,projectionFn:t.projectionFn},s;t.reactive&&(s=t.collection.next_qid++,t.collection.queries[s]=i),i.results=t._getRawObjects({ordered:o,distances:i.distances}),t.collection.paused&&(i.resultsSnapshot=o?[]:new d._IdMap);var c=function(e,n,o){return e?function(){var i=this,a=arguments;t.collection.paused||void 0!==n&&t.projectionFn&&(a[n]=t.projectionFn(a[n]),o&&r.isEmpty(a[n]))||t.collection._observeQueue.queueTask(function(){e.apply(i,a)})}:function(){}};if(i.added=c(e.added,1),i.changed=c(e.changed,1,!0),i.removed=c(e.removed),o&&(i.addedBefore=c(e.addedBefore,1),i.movedBefore=c(e.movedBefore)),!e._suppress_initial&&!t.collection.paused){var u=o?r.bind(r.each,null,i.results):r.bind(i.results.forEach,i.results);u(function(e){var r=n.clone(e);delete r._id,o&&i.addedBefore(e._id,r,null),i.added(e._id,r)})}var f=new d.ObserveHandle;return r.extend(f,{collection:t.collection,stop:function(){t.reactive&&delete t.collection.queries[s]}}),t.reactive&&a.active&&a.onInvalidate(function(){f.stop()}),t.collection._observeQueue.drain(),f}}),d.Cursor.prototype._getRawObjects=function(e){var r=this;e=e||{};var t=e.ordered?[]:new d._IdMap;if(void 0!==r._selectorId){if(r.skip)return t;var n=r.collection._docs.get(r._selectorId);return n&&(e.ordered?t.push(n):t.set(r._selectorId,n)),t}var o;if(r.matcher.hasGeoQuery()&&e.ordered&&(e.distances?(o=e.distances,o.clear()):o=new d._IdMap),r.collection._docs.forEach(function(n,i){var a=r.matcher.documentMatches(n);return a.result&&(e.ordered?(t.push(n),o&&void 0!==a.distance&&o.set(i,a.distance)):t.set(i,n)),!r.limit||r.skip||r.sorter||t.length!==r.limit?!0:!1}),!e.ordered)return t;if(r.sorter){var i=r.sorter.getComparator({distances:o});t.sort(i)}var a=r.skip||0,s=r.limit?r.limit+a:t.length;return t.slice(a,s)},d.Cursor.prototype._depend=function(e,t){var n=this;if(a.active){var o=new a.Dependency;o.depend();var i=r.bind(o.changed,o),s={_suppress_initial:!0,_allow_unordered:t};r.each(["added","changed","removed","addedBefore","movedBefore"],function(r){e[r]&&(s[r]=i)}),n.observeChanges(s)}},d.prototype.insert=function(t,o){var i=this;t=n.clone(t),r.has(t,"_id")||(t._id=d._useOID?new d._ObjectID:c.id());var a=t._id;if(i._docs.has(a))throw h("Duplicate _id '"+a+"'");i._saveOriginal(a,void 0),i._docs.set(a,t);var s=[];for(var u in i.queries){var f=i.queries[u],l=f.matcher.documentMatches(t);l.result&&(f.distances&&void 0!==l.distance&&f.distances.set(a,l.distance),f.cursor.skip||f.cursor.limit?s.push(u):d._insertInResults(f,t))}return r.each(s,function(e){i.queries[e]&&d._recomputeResults(i.queries[e])}),i._observeQueue.drain(),o&&e.defer(function(){o(null,a)}),a},d.prototype._eachPossiblyMatchingDoc=function(e,r){var t=this,n=d._idsMatchedBySelector(e);if(n)for(var o=0;o<n.length;++o){var i=n[o],a=t._docs.get(i);if(a){var s=r(a,i);if(s===!1)break}}else t._docs.forEach(r)},d.prototype.remove=function(t,o){var i=this;if(i.paused&&!i._savedOriginals&&n.equals(t,{})){var a=i._docs.size();return i._docs.clear(),r.each(i.queries,function(e){e.ordered?e.results=[]:e.results.clear()}),o&&e.defer(function(){o(null,a)}),a}var s=new f.Matcher(t,i),c=[];i._eachPossiblyMatchingDoc(t,function(e,r){s.documentMatches(e).result&&c.push(r)});for(var u=[],l=[],h=0;h<c.length;h++){var p=c[h],v=i._docs.get(p);r.each(i.queries,function(e,r){e.matcher.documentMatches(v).result&&(e.cursor.skip||e.cursor.limit?u.push(r):l.push({qid:r,doc:v}))}),i._saveOriginal(p,v),i._docs.remove(p)}return r.each(l,function(e){var r=i.queries[e.qid];r&&(r.distances&&r.distances.remove(e.doc._id),d._removeFromResults(r,e.doc))}),r.each(u,function(e){var r=i.queries[e];r&&d._recomputeResults(r)}),i._observeQueue.drain(),a=c.length,o&&e.defer(function(){o(null,a)}),a},d.prototype.update=function(t,o,i,a){var s=this;!a&&i instanceof Function&&(a=i,i=null),i||(i={});var c=new f.Matcher(t,s),u={};r.each(s.queries,function(e,r){!e.cursor.skip&&!e.cursor.limit||e.paused||(u[r]=n.clone(e.results))});var l={},h=0;s._eachPossiblyMatchingDoc(t,function(e,r){var t=c.documentMatches(e);return t.result&&(s._saveOriginal(r,e),s._modifyAndNotify(e,o,l,t.arrayIndices),++h,!i.multi)?!1:!0}),r.each(l,function(e,r){var t=s.queries[r];t&&d._recomputeResults(t,u[r])}),s._observeQueue.drain();var p;if(0===h&&i.upsert){var v=d._removeDollarOperators(t);d._modify(v,o,{isInsert:!0}),!v._id&&i.insertedId&&(v._id=i.insertedId),p=s.insert(v),h=1}var _;return i._returnObject?(_={numberAffected:h},void 0!==p&&(_.insertedId=p)):_=h,a&&e.defer(function(){a(null,_)}),_},d.prototype.upsert=function(e,t,n,o){var i=this;return o||"function"!=typeof n||(o=n,n={}),i.update(e,t,r.extend({},n,{upsert:!0,_returnObject:!0}),o)},d.prototype._modifyAndNotify=function(e,r,t,o){var i=this,a={};for(var s in i.queries){var c=i.queries[s];a[s]=c.ordered?c.matcher.documentMatches(e).result:c.results.has(e._id)}var u=n.clone(e);d._modify(e,r,{arrayIndices:o});for(s in i.queries){c=i.queries[s];var f=a[s],l=c.matcher.documentMatches(e),h=l.result;h&&c.distances&&void 0!==l.distance&&c.distances.set(e._id,l.distance),c.cursor.skip||c.cursor.limit?(f||h)&&(t[s]=!0):f&&!h?d._removeFromResults(c,e):!f&&h?d._insertInResults(c,e):f&&h&&d._updateInResults(c,e,u)}},d._insertInResults=function(e,r){var t=n.clone(r);if(delete t._id,e.ordered){if(e.sorter){var o=d._insertInSortedList(e.sorter.getComparator({distances:e.distances}),e.results,r),i=e.results[o+1];i=i?i._id:null,e.addedBefore(r._id,t,i)}else e.addedBefore(r._id,t,null),e.results.push(r);e.added(r._id,t)}else e.added(r._id,t),e.results.set(r._id,r)},d._removeFromResults=function(e,r){if(e.ordered){var t=d._findInOrderedResults(e,r);e.removed(r._id),e.results.splice(t,1)}else{var n=r._id;e.removed(r._id),e.results.remove(n)}},d._updateInResults=function(e,t,o){if(!n.equals(t._id,o._id))throw new Error("Can't change a doc's _id while updating");var i=d._makeChangedFields(t,o);if(!e.ordered)return void(r.isEmpty(i)||(e.changed(t._id,i),e.results.set(t._id,t)));var a=d._findInOrderedResults(e,t);if(r.isEmpty(i)||e.changed(t._id,i),e.sorter){e.results.splice(a,1);var s=d._insertInSortedList(e.sorter.getComparator({distances:e.distances}),e.results,t);if(a!==s){var c=e.results[s+1];c=c?c._id:null,e.movedBefore&&e.movedBefore(t._id,c)}}},d._recomputeResults=function(e,r){r||(r=e.results),e.distances&&e.distances.clear(),e.results=e.cursor._getRawObjects({ordered:e.ordered,distances:e.distances}),e.paused||d._diffQueryChanges(e.ordered,r,e.results,e)},d._findInOrderedResults=function(e,r){if(!e.ordered)throw new Error("Can't call _findInOrderedResults on unordered query");for(var t=0;t<e.results.length;t++)if(e.results[t]===r)return t;throw Error("object missing from query")},d._binarySearch=function(e,r,t){for(var n=0,o=r.length;o>0;){var i=Math.floor(o/2);e(t,r[n+i])>=0?(n+=i+1,o-=i+1):o=i}return n},d._insertInSortedList=function(e,r,t){if(0===r.length)return r.push(t),0;var n=d._binarySearch(e,r,t);return r.splice(n,0,t),n},d.prototype.saveOriginals=function(){var e=this;if(e._savedOriginals)throw new Error("Called saveOriginals twice without retrieveOriginals");e._savedOriginals=new d._IdMap},d.prototype.retrieveOriginals=function(){var e=this;if(!e._savedOriginals)throw new Error("Called retrieveOriginals without saveOriginals");var r=e._savedOriginals;return e._savedOriginals=null,r},d.prototype._saveOriginal=function(e,r){var t=this;t._savedOriginals&&(t._savedOriginals.has(e)||t._savedOriginals.set(e,n.clone(r)))},d.prototype.pauseObservers=function(){if(!this.paused){this.paused=!0;for(var e in this.queries){var r=this.queries[e];r.resultsSnapshot=n.clone(r.results)}}},d.prototype.resumeObservers=function(){var e=this;if(this.paused){this.paused=!1;for(var r in this.queries){var t=e.queries[r];d._diffQueryChanges(t.ordered,t.resultsSnapshot,t.results,t),t.resultsSnapshot=null}e._observeQueue.drain()}},d._idStringify=function(e){if(e instanceof d._ObjectID)return e.valueOf();if("string"==typeof e)return""===e?e:"-"===e.substr(0,1)||"~"===e.substr(0,1)||d._looksLikeObjectID(e)||"{"===e.substr(0,1)?"-"+e:e;if(void 0===e)return"-";if("object"==typeof e&&null!==e)throw new Error("Meteor does not currently support objects other than ObjectID as ids");return"~"+t.stringify(e)},d._idParse=function(e){return""===e?e:"-"===e?void 0:"-"===e.substr(0,1)?e.substr(1):"~"===e.substr(0,1)?t.parse(e.substr(1)):d._looksLikeObjectID(e)?new d._ObjectID(e):e},d._makeChangedFields=function(e,r){var t={};return d._diffObjects(r,e,{leftOnly:function(e,r){t[e]=void 0},rightOnly:function(e,r){t[e]=r},both:function(e,r,o){n.equals(r,o)||(t[e]=o)}}),t}}).call(this),function(){d.wrapTransform=function(e){return e?function(t){if(!r.has(t,"_id"))throw new Error("can only transform documents with _id");var o=t._id,i=a.nonreactive(function(){return e(t)});if(!v(i))throw new Error("transform must return object");if(r.has(i,"_id")){if(!n.equals(i._id,o))throw new Error("transformed document can't have different _id")}else i._id=o;return i}:null}}.call(this),function(){p=function(e){return r.isArray(e)&&!n.isBinary(e)},v=d._isPlainObject=function(e){return e&&3===d._f._type(e)},_=function(e){return p(e)||v(e)},m=function(e,n){if(!v(e))return!1;var o=void 0;return r.each(e,function(r,i){var a="$"===i.substr(0,1);if(void 0===o)o=a;else if(o!==a){if(!n)throw new Error("Inconsistent operator: "+t.stringify(e));o=!1}}),!!o},y=function(e){return/^[0-9]+$/.test(e)}}.call(this),function(){f.Matcher=function(e){var r=this;r._paths={},r._hasGeoQuery=!1,r._hasWhere=!1,r._isSimple=!0,r._matchingDocument=void 0,r._selector=null,r._docMatcher=r._compileSelector(e)},r.extend(f.Matcher.prototype,{documentMatches:function(e){if(!e||"object"!=typeof e)throw Error("documentMatches needs a document");return this._docMatcher(e)},hasGeoQuery:function(){return this._hasGeoQuery},hasWhere:function(){return this._hasWhere},isSimple:function(){return this._isSimple},_compileSelector:function(r){var t=this;if(r instanceof Function)return t._isSimple=!1,t._selector=r,t._recordPathUsed(""),function(e){return{result:!!r.call(e)}};if(d._selectorIsId(r))return t._selector={_id:r},t._recordPathUsed("_id"),function(e){return{result:n.equals(e._id,r)}};if(!r||"_id"in r&&!r._id)return t._isSimple=!1,k;if("boolean"==typeof r||p(r)||n.isBinary(r))throw new Error("Invalid selector: "+r);return t._selector=n.clone(r),e(r,t,{isRoot:!0})},_recordPathUsed:function(e){this._paths[e]=!0},_getPaths:function(){return r.keys(this._paths)}});var e=function(e,n,o){o=o||{};var i=[];return r.each(e,function(e,a){if("$"===a.substr(0,1)){if(!r.has(s,a))throw new Error("Unrecognized logical operator: "+a);n._isSimple=!1,i.push(s[a](e,n,o.inElemMatch))}else{o.inElemMatch||n._recordPathUsed(a);var c=$(a),u=t(e,n,o.isRoot);i.push(function(e){var r=c(e);return u(r)})}}),A(i)},t=function(e,r,t){return e instanceof RegExp?(r._isSimple=!1,o(g(e))):m(e)?i(e,r,t):o(w(e))},o=function(e,t){return t=t||{},function(n){var o=n;t.dontExpandLeafArrays||(o=I(n,t.dontIncludeLeafArrays));var i={};return i.result=r.any(o,function(r){var t=e(r.value);return"number"==typeof t&&(r.arrayIndices||(r.arrayIndices=[t]),t=!0),t&&r.arrayIndices&&(i.arrayIndices=r.arrayIndices),t}),i}};g=function(e){return function(t){return t instanceof RegExp?r.isEqual(t,e):"string"!=typeof t?!1:(e.lastIndex=0,e.test(t))}},w=function(e){if(m(e))throw Error("Can't create equalityValueSelector for operator object");return null==e?function(e){return null==e}:function(r){return d._f._equal(e,r)}};var i=function(e,t,n){var i=[];return r.each(e,function(a,s){var c=r.contains(["$lt","$lte","$gt","$gte"],s)&&r.isNumber(a),u="$ne"===s&&!r.isObject(a),d=r.contains(["$in","$nin"],s)&&r.isArray(a)&&!r.any(a,r.isObject);if("$eq"===s||c||d||u||(t._isSimple=!1),r.has(h,s))i.push(h[s](a,e,t,n));else{if(!r.has(b,s))throw new Error("Unrecognized operator: "+s);var f=b[s];i.push(o(f.compileElementSelector(a,e,t),f))}}),M(i)},a=function(t,n,o){if(!p(t)||r.isEmpty(t))throw Error("$and/$or/$nor must be nonempty array");return r.map(t,function(r){if(!v(r))throw Error("$or/$and/$nor entries need to be full objects");return e(r,n,{inElemMatch:o})})},s={$and:function(e,r,t){var n=a(e,r,t);return A(n)},$or:function(e,t,n){var o=a(e,t,n);return 1===o.length?o[0]:function(e){var t=r.any(o,function(r){return r(e).result});return{result:t}}},$nor:function(e,t,n){var o=a(e,t,n);return function(e){var t=r.all(o,function(r){return!r(e).result});return{result:t}}},$where:function(e,r){return r._recordPathUsed(""),r._hasWhere=!0,e instanceof Function||(e=Function("obj","return "+e)),function(r){return{result:e.call(r,r)}}},$comment:function(){return function(){return{result:!0}}}},c=function(e){return function(r){var t=e(r);return{result:!t.result}}},h={$not:function(e,r,n){return c(t(e,n))},$ne:function(e){return c(o(w(e)))},$nin:function(e){return c(o(b.$in.compileElementSelector(e)))},$exists:function(e){var r=o(function(e){return void 0!==e});return e?r:c(r)},$options:function(e,t){if(!r.has(t,"$regex"))throw Error("$options needs a $regex");return j},$maxDistance:function(e,r){if(!r.$near)throw Error("$maxDistance needs a $near");return j},$all:function(e,n,o){if(!p(e))throw Error("$all requires array");if(r.isEmpty(e))return k;var i=[];return r.each(e,function(e){if(m(e))throw Error("no $ expressions in $all");i.push(t(e,o))}),M(i)},$near:function(e,t,n,o){if(!o)throw Error("$near can't be inside another $ operator");n._hasGeoQuery=!0;var i,a,s;if(v(e)&&r.has(e,"$geometry"))i=e.$maxDistance,a=e.$geometry,s=function(e){return e&&e.type?"Point"===e.type?u.pointDistance(a,e):u.geometryWithinRadius(e,a,i)?0:i+1:null};else{if(i=t.$maxDistance,!p(e)&&!v(e))throw Error("$near argument must be coordinate pair or GeoJSON");a=O(e),s=function(e){return p(e)||v(e)?E(a,e):null}}return function(e){e=I(e);var t={result:!1};return r.each(e,function(e){var r=s(e.value);null===r||r>i||void 0!==t.distance&&t.distance<=r||(t.result=!0,t.distance=r,e.arrayIndices?t.arrayIndices=e.arrayIndices:delete t.arrayIndices)}),t}}},E=function(e,t){e=O(e),t=O(t);var n=e[0]-t[0],o=e[1]-t[1];return r.isNaN(n)||r.isNaN(o)?null:Math.sqrt(n*n+o*o)},O=function(e){return r.map(e,r.identity)},C=function(e){return{compileElementSelector:function(r){if(p(r))return function(){return!1};void 0===r&&(r=null);var t=d._f._type(r);return function(n){return void 0===n&&(n=null),d._f._type(n)!==t?!1:e(d._f._cmp(n,r))}}}};b={$lt:C(function(e){return 0>e}),$gt:C(function(e){return e>0}),$lte:C(function(e){return 0>=e}),$gte:C(function(e){return e>=0}),$mod:{compileElementSelector:function(e){if(!p(e)||2!==e.length||"number"!=typeof e[0]||"number"!=typeof e[1])throw Error("argument to $mod must be an array of two numbers");var r=e[0],t=e[1];return function(e){return"number"==typeof e&&e%r===t}}},$in:{compileElementSelector:function(e){if(!p(e))throw Error("$in needs an array");var t=[];return r.each(e,function(e){if(e instanceof RegExp)t.push(g(e));else{if(m(e))throw Error("cannot nest $ under $in");t.push(w(e))}}),function(e){return void 0===e&&(e=null),r.any(t,function(r){return r(e)})}}},$size:{dontExpandLeafArrays:!0,compileElementSelector:function(e){if("string"==typeof e)e=0;else if("number"!=typeof e)throw Error("$size needs a number");return function(r){return p(r)&&r.length===e}}},$type:{dontIncludeLeafArrays:!0,compileElementSelector:function(e){if("number"!=typeof e)throw Error("$type needs a number");return function(r){return void 0!==r&&d._f._type(r)===e}}},$regex:{compileElementSelector:function(e,r){if(!("string"==typeof e||e instanceof RegExp))throw Error("$regex has to be a string or RegExp");var t;if(void 0!==r.$options){if(/[^gim]/.test(r.$options))throw new Error("Only the i, m, and g regexp options are supported");var n=e instanceof RegExp?e.source:e;t=new RegExp(n,r.$options)}else t=e instanceof RegExp?e:new RegExp(e);return g(t)}},$elemMatch:{dontExpandLeafArrays:!0,compileElementSelector:function(r,n,o){if(!v(r))throw Error("$elemMatch need an object");var i,a;return m(r,!0)?(i=t(r,o),a=!1):(i=e(r,o,{inElemMatch:!0}),a=!0),function(e){if(!p(e))return!1;for(var r=0;r<e.length;++r){var t=e[r],n;if(a){if(!v(t)&&!p(t))return!1;n=t}else n=[{value:t,dontIterate:!0}];if(i(n).result)return r}return!1}}}},$=function(e,t){t=t||{};var n=e.split("."),o=n.length?n[0]:"",i=y(o),a=n.length>=2&&y(n[1]),s;n.length>1&&(s=$(n.slice(1).join(".")));var c=function(e){return e.dontIterate||delete e.dontIterate,e.arrayIndices&&!e.arrayIndices.length&&delete e.arrayIndices,e};return function(e,n){if(n||(n=[]),p(e)){if(!(i&&o<e.length))return[];n=n.concat(+o,"x")}var u=e[o];if(!s)return[c({value:u,dontIterate:p(e)&&p(u),arrayIndices:n})];if(!_(u))return p(e)?[]:[c({value:void 0,arrayIndices:n})];var d=[],f=function(e){Array.prototype.push.apply(d,e)};return f(s(u,n)),!p(u)||a&&t.forSort||r.each(u,function(e,r){v(e)&&f(s(e,n.concat(r)))}),d}},l.makeLookupFunction=$,I=function(e,t){var n=[];return r.each(e,function(e){var o=p(e.value);t&&o&&!e.dontIterate||n.push({value:e.value,arrayIndices:e.arrayIndices}),o&&!e.dontIterate&&r.each(e.value,function(r,t){n.push({value:r,arrayIndices:(e.arrayIndices||[]).concat(t)})})}),n};var k=function(e){return{result:!1}},j=function(e){return{result:!0}},S=function(e){return 0===e.length?j:1===e.length?e[0]:function(t){var n={};return n.result=r.all(e,function(e){var r=e(t);return r.result&&void 0!==r.distance&&void 0===n.distance&&(n.distance=r.distance),r.result&&r.arrayIndices&&(n.arrayIndices=r.arrayIndices),r.result}),n.result||(delete n.distance,delete n.arrayIndices),n}},A=S,M=S;d._f={_type:function(e){return"number"==typeof e?1:"string"==typeof e?2:"boolean"==typeof e?8:p(e)?4:null===e?10:e instanceof RegExp?11:"function"==typeof e?13:e instanceof Date?9:n.isBinary(e)?5:e instanceof d._ObjectID?7:3},_equal:function(e,r){return n.equals(e,r,{keyOrderSensitive:!0})},_typeorder:function(e){return[-1,1,2,3,4,5,-1,6,7,8,0,9,-1,100,2,100,1,8,1][e]},_cmp:function(e,r){if(void 0===e)return void 0===r?0:-1;if(void 0===r)return 1;var t=d._f._type(e),n=d._f._type(r),o=d._f._typeorder(t),i=d._f._typeorder(n);if(o!==i)return i>o?-1:1;if(t!==n)throw Error("Missing type coercion logic in _cmp");if(7===t&&(t=n=2,e=e.toHexString(),r=r.toHexString()),9===t&&(t=n=1,e=e.getTime(),r=r.getTime()),1===t)return e-r;if(2===n)return r>e?-1:e===r?0:1;if(3===t){var a=function(e){var r=[];for(var t in e)r.push(t),r.push(e[t]);return r};return d._f._cmp(a(e),a(r))}if(4===t)for(var s=0;;s++){if(s===e.length)return s===r.length?0:-1;if(s===r.length)return 1;var c=d._f._cmp(e[s],r[s]);if(0!==c)return c}if(5===t){if(e.length!==r.length)return e.length-r.length;for(s=0;s<e.length;s++){if(e[s]<r[s])return-1;if(e[s]>r[s])return 1}return 0}if(8===t)return e?r?0:1:r?-1:0;if(10===t)return 0;if(11===t)throw Error("Sorting not supported on regular expression");if(13===t)throw Error("Sorting not supported on Javascript code");throw Error("Unknown type to sort")}},d._removeDollarOperators=function(e){var r={};for(var t in e)"$"!==t.substr(0,1)&&(r[t]=e[t]);return r}}.call(this),function(){f.Sorter=function(n,o){var i=this;o=o||{},i._sortSpecParts=[];var a=function(e,r){if(!e)throw Error("sort keys must be non-empty");if("$"===e.charAt(0))throw Error("unsupported sort key: "+e);i._sortSpecParts.push({path:e,lookup:$(e,{forSort:!0}),ascending:r})};if(n instanceof Array)for(var s=0;s<n.length;s++)"string"==typeof n[s]?a(n[s],!0):a(n[s][0],"desc"!==n[s][1]);else{if("object"!=typeof n)throw Error("Bad sort specification: "+t.stringify(n));r.each(n,function(e,r){a(r,e>=0)})}if(i.affectedByModifier){var c={};r.each(i._sortSpecParts,function(e){c[e.path]=1}),i._selectorForAffectedByModifier=new f.Matcher(c)}i._keyComparator=e(r.map(i._sortSpecParts,function(e,r){return i._keyFieldComparator(r)})),i._keyFilter=null,o.matcher&&i._useWithMatcher(o.matcher)},r.extend(f.Sorter.prototype,{getComparator:function(r){var t=this;if(!r||!r.distances)return t._getBaseComparator();var n=r.distances;return e([t._getBaseComparator(),function(e,r){if(!n.has(e._id))throw Error("Missing distance for "+e._id);if(!n.has(r._id))throw Error("Missing distance for "+r._id);return n.get(e._id)-n.get(r._id)}])},_getPaths:function(){var e=this;return r.pluck(e._sortSpecParts,"path")},_getMinKeyFromDoc:function(e){var r=this,t=null;if(r._generateKeysFromDoc(e,function(e){return r._keyCompatibleWithSelector(e)?null===t?void(t=e):void(r._compareKeys(e,t)<0&&(t=e)):void 0}),null===t)throw Error("sort selector found no keys in doc?");return t},_keyCompatibleWithSelector:function(e){var r=this;return!r._keyFilter||r._keyFilter(e)},_generateKeysFromDoc:function(e,t){var n=this;if(0===n._sortSpecParts.length)throw new Error("can't generate keys without a spec");var o=[],i=function(e){return e.join(",")+","},a=null;if(r.each(n._sortSpecParts,function(t,n){var s=I(t.lookup(e),!0);s.length||(s=[{value:null}]);var c=!1;if(o[n]={},r.each(s,function(e){if(!e.arrayIndices){if(s.length>1)throw Error("multiple branches but no array used?");return void(o[n][""]=e.value)}c=!0;var t=i(e.arrayIndices);if(r.has(o[n],t))throw Error("duplicate path: "+t);if(o[n][t]=e.value,a&&!r.has(a,t))throw Error("cannot index parallel arrays")}),a){if(!r.has(o[n],"")&&r.size(a)!==r.size(o[n]))throw Error("cannot index parallel arrays!")}else c&&(a={},r.each(o[n],function(e,r){a[r]=!0}))}),!a){var s=r.map(o,function(e){if(!r.has(e,""))throw Error("no value in sole key case?");return e[""]});return void t(s)}r.each(a,function(e,n){var i=r.map(o,function(e){if(r.has(e,""))return e[""];if(!r.has(e,n))throw Error("missing path?");return e[n]});t(i)})},_compareKeys:function(e,r){var t=this;if(e.length!==t._sortSpecParts.length||r.length!==t._sortSpecParts.length)throw Error("Key has wrong length");return t._keyComparator(e,r)},_keyFieldComparator:function(e){var r=this,t=!r._sortSpecParts[e].ascending;return function(r,n){var o=d._f._cmp(r[e],n[e]);return t&&(o=-o),o}},_getBaseComparator:function(){var e=this;return e._sortSpecParts.length?function(r,t){var n=e._getMinKeyFromDoc(r),o=e._getMinKeyFromDoc(t);return e._compareKeys(n,o)}:function(e,r){return 0}},_useWithMatcher:function(e){var t=this;if(t._keyFilter)throw Error("called _useWithMatcher twice?");if(!r.isEmpty(t._sortSpecParts)){var n=e._selector;if(!(n instanceof Function)){var o={};r.each(t._sortSpecParts,function(e,r){o[e.path]=[]}),r.each(n,function(e,t){var n=o[t];if(n){if(e instanceof RegExp){if(e.ignoreCase||e.multiline)return;return void n.push(g(e))}return m(e)?void r.each(e,function(t,o){r.contains(["$lt","$lte","$gt","$gte"],o)&&n.push(b[o].compileElementSelector(t)),"$regex"!==o||e.$options||n.push(b.$regex.compileElementSelector(t,e))}):void n.push(w(e))}}),r.isEmpty(o[t._sortSpecParts[0].path])||(t._keyFilter=function(e){return r.all(t._sortSpecParts,function(t,n){return r.all(o[t.path],function(r){return r(e[n])})})})}}}});var e=function(e){return function(r,t){for(var n=0;n<e.length;++n){var o=e[n](r,t);if(0!==o)return o}return 0}}}.call(this),function(){d._compileProjection=function(e){d._checkSupportedProjection(e);var t=r.isUndefined(e._id)?!0:e._id,o=E(e),i=function(e,t){if(r.isArray(e))return r.map(e,function(e){return i(e,t)});var a=o.including?{}:n.clone(e);return r.each(t,function(t,s){r.has(e,s)&&(r.isObject(t)?r.isObject(e[s])&&(a[s]=i(e[s],t)):o.including?a[s]=n.clone(e[s]):delete a[s])}),a};return function(e){var n=i(e,o.tree);return t&&r.has(e,"_id")&&(n._id=e._id),!t&&r.has(n,"_id")&&delete n._id,n}},E=function(e){var t=r.keys(e).sort();t.length>0&&(1!==t.length||"_id"!==t[0])&&(t=r.reject(t,function(e){return"_id"===e}));var n=null;r.each(t,function(r){var t=!!e[r];if(null===n&&(n=t),n!==t)throw h("You cannot currently mix including and excluding fields.")});var o=O(t,function(e){return n},function(e,r,t){var n=t,o=r;throw h("both "+n+" and "+o+" found in fields option, using both of them may trigger unexpected behavior. Did you mean to use only one of them?")});return{tree:o,including:n}},O=function(e,t,n,o){return o=o||{},r.each(e,function(e){var i=o,a=e.split("."),s=r.all(a.slice(0,-1),function(t,o){if(r.has(i,t)){if(!r.isObject(i[t])&&(i[t]=n(i[t],a.slice(0,o+1).join("."),e),!r.isObject(i[t])))return!1}else i[t]={};return i=i[t],!0});if(s){var c=r.last(a);i[c]=r.has(i,c)?n(i[c],e,e):t(e)}}),o},d._checkSupportedProjection=function(e){if(!r.isObject(e)||r.isArray(e))throw h("fields option must be an object");r.each(e,function(e,t){if(r.contains(t.split("."),"$"))throw h("Minimongo doesn't support $ operator in projections yet.");if(-1===r.indexOf([1,0,!0,!1],e))throw h("Projection values should be one of 1, 0, true, or false")})}}.call(this),function(){d._modify=function(t,a,s){if(s=s||{},!v(a))throw h("Modifier must be an object");var c=m(a),u;if(c)u=n.clone(t),r.each(a,function(t,n){var a=i[n];if(s.isInsert&&"$setOnInsert"===n&&(a=i.$set),!a)throw h("Invalid modifier specified "+n);r.each(t,function(t,i){if(i.length&&"."===i[i.length-1])throw h("Invalid mod field name, may not end in a period");if("_id"===i)throw h("Mod on _id not allowed");var c=i.split("."),d=r.has(o,n),f="$rename"===n,l=e(u,c,{noCreate:o[n],forbidArray:"$rename"===n,arrayIndices:s.arrayIndices}),p=c.pop();a(l,p,t,i,u)})});else{if(a._id&&!n.equals(t._id,a._id))throw h("Cannot change the _id of a document");for(var d in a)if(/\./.test(d))throw h("When replacing document, field name may not contain '.'");u=a}r.each(r.keys(t),function(e){("_id"!==e||s.isInsert)&&delete t[e]}),r.each(u,function(e,r){t[r]=e})};var e=function(e,r,n){n=n||{};for(var o=!1,i=0;i<r.length;i++){var a=i===r.length-1,s=r[i],c=_(e);if(!c){if(n.noCreate)return void 0;var u=h("cannot use the part '"+s+"' to traverse "+e);throw u.setPropertyError=!0,u}if(e instanceof Array){if(n.forbidArray)return null;if("$"===s){if(o)throw h("Too many positional (i.e. '$') elements");if(!n.arrayIndices||!n.arrayIndices.length)throw h("The positional operator did not find the match needed from the query");s=n.arrayIndices[0],o=!0}else{if(!y(s)){if(n.noCreate)return void 0;throw h("can't append to array using string field name ["+s+"]")}s=parseInt(s)}if(a&&(r[i]=s),n.noCreate&&s>=e.length)return void 0;for(;e.length<s;)e.push(null);if(!a)if(e.length===s)e.push({});else if("object"!=typeof e[s])throw h("can't modify field '"+r[i+1]+"' of list value "+t.stringify(e[s]))}else{if(s.length&&"$"===s.substr(0,1))throw h("can't set field named "+s);if(!(s in e)){if(n.noCreate)return void 0;a||(e[s]={})}}if(a)return e;e=e[s]}},o={$unset:!0,$pop:!0,$rename:!0,$pull:!0,$pullAll:!0},i={$inc:function(e,r,t){if("number"!=typeof t)throw h("Modifier $inc allowed for numbers only");if(r in e){if("number"!=typeof e[r])throw h("Cannot apply $inc modifier to non-number");e[r]+=t}else e[r]=t},$set:function(e,t,o){if(!r.isObject(e)){var i=h("Cannot set property on non-object field");throw i.setPropertyError=!0,i}if(null===e){var i=h("Cannot set property on null");throw i.setPropertyError=!0,i}e[t]=n.clone(o)},$setOnInsert:function(e,r,t){},$unset:function(e,r,t){void 0!==e&&(e instanceof Array?r in e&&(e[r]=null):delete e[r])},$push:function(e,r,t){if(void 0===e[r]&&(e[r]=[]),!(e[r]instanceof Array))throw h("Cannot apply $push modifier to non-array");if(!t||!t.$each)return void e[r].push(n.clone(t));var o=t.$each;if(!(o instanceof Array))throw h("$each must be an array");var i=void 0;if("$slice"in t){if("number"!=typeof t.$slice)throw h("$slice must be a numeric value");if(t.$slice>0)throw h("$slice in $push must be zero or negative");i=t.$slice}var a=void 0;if(t.$sort){if(void 0===i)throw h("$sort requires $slice to be present");a=new f.Sorter(t.$sort).getComparator();for(var s=0;s<o.length;s++)if(3!==d._f._type(o[s]))throw h("$push like modifiers using $sort require all elements to be objects")}for(var c=0;c<o.length;c++)e[r].push(n.clone(o[c]));a&&e[r].sort(a),void 0!==i&&(e[r]=0===i?[]:e[r].slice(i))},$pushAll:function(e,r,t){if(!("object"==typeof t&&t instanceof Array))throw h("Modifier $pushAll/pullAll allowed for arrays only");var n=e[r];if(void 0===n)e[r]=t;else{if(!(n instanceof Array))throw h("Cannot apply $pushAll modifier to non-array");for(var o=0;o<t.length;o++)n.push(t[o])}},$addToSet:function(e,t,o){var i=!1;if("object"==typeof o)for(var a in o){"$each"===a&&(i=!0);break}var s=i?o.$each:[o],c=e[t];if(void 0===c)e[t]=s;else{if(!(c instanceof Array))throw h("Cannot apply $addToSet modifier to non-array");r.each(s,function(e){for(var r=0;r<c.length;r++)if(d._f._equal(e,c[r]))return;
+c.push(n.clone(e))})}},$pop:function(e,r,t){if(void 0!==e){var n=e[r];if(void 0!==n){if(!(n instanceof Array))throw h("Cannot apply $pop modifier to non-array");"number"==typeof t&&0>t?n.splice(0,1):n.pop()}}},$pull:function(e,r,t){if(void 0!==e){var n=e[r];if(void 0!==n){if(!(n instanceof Array))throw h("Cannot apply $pull/pullAll modifier to non-array");var o=[];if("object"!=typeof t||t instanceof Array)for(var i=0;i<n.length;i++)d._f._equal(n[i],t)||o.push(n[i]);else for(var a=new f.Matcher(t),i=0;i<n.length;i++)a.documentMatches(n[i]).result||o.push(n[i]);e[r]=o}}},$pullAll:function(e,r,t){if(!("object"==typeof t&&t instanceof Array))throw h("Modifier $pushAll/pullAll allowed for arrays only");if(void 0!==e){var n=e[r];if(void 0!==n){if(!(n instanceof Array))throw h("Cannot apply $pull/pullAll modifier to non-array");for(var o=[],i=0;i<n.length;i++){for(var a=!1,s=0;s<t.length;s++)if(d._f._equal(n[i],t[s])){a=!0;break}a||o.push(n[i])}e[r]=o}}},$rename:function(r,t,n,o,i){if(o===n)throw h("$rename source must differ from target");if(null===r)throw h("$rename source field invalid");if("string"!=typeof n)throw h("$rename target must be a string");if(void 0!==r){var a=r[t];delete r[t];var s=n.split("."),c=e(i,s,{forbidArray:!0});if(null===c)throw h("$rename target field invalid");var u=s.pop();c[u]=a}},$bit:function(e,r,t){throw h("$bit is not supported")}}}.call(this),function(){d._diffQueryChanges=function(e,r,t,n){e?d._diffQueryOrderedChanges(r,t,n):d._diffQueryUnorderedChanges(r,t,n)},d._diffQueryUnorderedChanges=function(e,r,t){if(t.movedBefore)throw new Error("_diffQueryUnordered called with a movedBefore observer!");r.forEach(function(r,o){var i=e.get(o);if(i)t.changed&&!n.equals(i,r)&&t.changed(o,d._makeChangedFields(r,i));else if(t.added){var a=n.clone(r);delete a._id,t.added(r._id,a)}}),t.removed&&e.forEach(function(e,n){r.has(n)||t.removed(n)})},d._diffQueryOrderedChanges=function(t,o,i){var a={};r.each(o,function(r){a[r._id]&&e._debug("Duplicate _id in new_results"),a[r._id]=!0});var s={};r.each(t,function(r,t){r._id in s&&e._debug("Duplicate _id in old_results"),s[r._id]=t});for(var c=[],u=0,f=o.length,l=new Array(f),h=new Array(f),p=function(e){return s[o[e]._id]},v=0;f>v;v++)if(void 0!==s[o[v]._id]){for(var _=u;_>0&&!(p(l[_-1])<p(v));)_--;h[v]=0===_?-1:l[_-1],l[_]=v,_+1>u&&(u=_+1)}for(var m=0===u?-1:l[u-1];m>=0;)c.push(m),m=h[m];c.reverse(),c.push(o.length),r.each(t,function(e){a[e._id]||i.removed&&i.removed(e._id)});var y=0;r.each(c,function(e){for(var a=o[e]?o[e]._id:null,c,u,f,l=y;e>l;l++)u=o[l],r.has(s,u._id)?(c=t[s[u._id]],f=d._makeChangedFields(u,c),r.isEmpty(f)||i.changed&&i.changed(u._id,f),i.movedBefore&&i.movedBefore(u._id,a)):(f=n.clone(u),delete f._id,i.addedBefore&&i.addedBefore(u._id,f,a),i.added&&i.added(u._id,f));a&&(u=o[e],c=t[s[u._id]],f=d._makeChangedFields(u,c),r.isEmpty(f)||i.changed&&i.changed(u._id,f)),y=e+1})},d._diffObjects=function(e,t,n){r.each(e,function(e,o){r.has(t,o)?n.both&&n.both(o,e,t[o]):n.leftOnly&&n.leftOnly(o,e)}),n.rightOnly&&r.each(t,function(t,o){r.has(e,o)||n.rightOnly(o,t)})}}.call(this),function(){d._IdMap=function(){var e=this;o.call(e,d._idStringify,d._idParse)},e._inherits(d._IdMap,o)}.call(this),function(){d._CachingChangeObserver=function(e){var t=this;e=e||{};var o=e.callbacks&&d._observeChangesCallbacksAreOrdered(e.callbacks);if(r.has(e,"ordered")){if(t.ordered=e.ordered,e.callbacks&&e.ordered!==o)throw Error("ordered option doesn't match callbacks")}else{if(!e.callbacks)throw Error("must provide ordered or callbacks");t.ordered=o}var a=e.callbacks||{};t.ordered?(t.docs=new i(d._idStringify),t.applyChange={addedBefore:function(e,r,o){var i=n.clone(r);i._id=e,a.addedBefore&&a.addedBefore.call(t,e,r,o),a.added&&a.added.call(t,e,r),t.docs.putBefore(e,i,o||null)},movedBefore:function(e,r){var n=t.docs.get(e);a.movedBefore&&a.movedBefore.call(t,e,r),t.docs.moveBefore(e,r||null)}}):(t.docs=new d._IdMap,t.applyChange={added:function(e,r){var o=n.clone(r);a.added&&a.added.call(t,e,r),o._id=e,t.docs.set(e,o)}}),t.applyChange.changed=function(e,r){var o=t.docs.get(e);if(!o)throw new Error("Unknown id for changed: "+e);a.changed&&a.changed.call(t,e,n.clone(r)),d._applyChanges(o,r)},t.applyChange.removed=function(e){a.removed&&a.removed.call(t,e),t.docs.remove(e)}},d._observeFromObserveChanges=function(e,t){var o=e.getTransform()||function(e){return e},i=!!t._suppress_initial,a;if(d._observeCallbacksAreOrdered(t)){var s=!t._no_indices;a={addedBefore:function(e,n,a){var c=this;if(!i&&(t.addedAt||t.added)){var u=o(r.extend(n,{_id:e}));if(t.addedAt){var d=s?a?c.docs.indexOf(a):c.docs.size():-1;t.addedAt(u,d,a)}else t.added(u)}},changed:function(e,r){var i=this;if(t.changedAt||t.changed){var a=n.clone(i.docs.get(e));if(!a)throw new Error("Unknown id for changed: "+e);var c=o(n.clone(a));if(d._applyChanges(a,r),a=o(a),t.changedAt){var u=s?i.docs.indexOf(e):-1;t.changedAt(a,c,u)}else t.changed(a,c)}},movedBefore:function(e,r){var i=this;if(t.movedTo){var a=s?i.docs.indexOf(e):-1,c=s?r?i.docs.indexOf(r):i.docs.size():-1;c>a&&--c,t.movedTo(o(n.clone(i.docs.get(e))),a,c,r||null)}},removed:function(e){var r=this;if(t.removedAt||t.removed){var n=o(r.docs.get(e));if(t.removedAt){var i=s?r.docs.indexOf(e):-1;t.removedAt(n,i)}else t.removed(n)}}}}else a={added:function(e,n){if(!i&&t.added){var a=r.extend(n,{_id:e});t.added(o(a))}},changed:function(e,r){var i=this;if(t.changed){var a=i.docs.get(e),s=n.clone(a);d._applyChanges(s,r),t.changed(o(s),o(n.clone(a)))}},removed:function(e){var r=this;t.removed&&t.removed(o(r.docs.get(e)))}};var c=new d._CachingChangeObserver({callbacks:a}),u=e.observeChanges(c.applyChange);return i=!1,u}}.call(this),function(){d._looksLikeObjectID=function(e){return 24===e.length&&e.match(/^[0-9a-f]*$/)},d._ObjectID=function(e){var r=this;if(e){if(e=e.toLowerCase(),!d._looksLikeObjectID(e))throw new Error("Invalid hexadecimal string for creating an ObjectID");r._str=e}else r._str=c.hexString(24)},d._ObjectID.prototype.toString=function(){var e=this;return'ObjectID("'+e._str+'")'},d._ObjectID.prototype.equals=function(e){var r=this;return e instanceof d._ObjectID&&r.valueOf()===e.valueOf()},d._ObjectID.prototype.clone=function(){var e=this;return new d._ObjectID(e._str)},d._ObjectID.prototype.typeName=function(){return"oid"},d._ObjectID.prototype.getTimestamp=function(){var e=this;return parseInt(e._str.substr(0,8),16)},d._ObjectID.prototype.valueOf=d._ObjectID.prototype.toJSONValue=d._ObjectID.prototype.toHexString=function(){return this._str},d._selectorIsId=function(e){return"string"==typeof e||"number"==typeof e||e instanceof d._ObjectID},d._selectorIsIdPerhapsAsObject=function(e){return d._selectorIsId(e)||e&&"object"==typeof e&&e._id&&d._selectorIsId(e._id)&&1===r.size(e)},d._idsMatchedBySelector=function(e){if(d._selectorIsId(e))return[e];if(!e)return null;if(r.has(e,"_id"))return d._selectorIsId(e._id)?[e._id]:e._id&&e._id.$in&&r.isArray(e._id.$in)&&!r.isEmpty(e._id.$in)&&r.all(e._id.$in,d._selectorIsId)?e._id.$in:null;if(e.$and&&r.isArray(e.$and))for(var t=0;t<e.$and.length;++t){var n=d._idsMatchedBySelector(e.$and[t]);if(n)return n}return null},n.addType("oid",function(e){return new d._ObjectID(e)})}.call(this),"undefined"==typeof Package&&(Package={}),Package.minimongo={LocalCollection:d,Minimongo:f,MinimongoTest:l}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.check.check,n=Package.check.Match,r=Package.random.Random,o=Package.ejson.EJSON,i=Package.json.JSON,a=Package.underscore._,s=Package.tracker.Tracker,u=Package.tracker.Deps,c=Package.logging.Log,l=Package.retry.Retry,d=Package.minimongo.LocalCollection,f=Package.minimongo.Minimongo,_,p,h,v,m,g,b,y,w,k,S,C,T;(function(){_={},p={}}).call(this),function(){h=function(){var e=document,t=window,n={},r=function(){};r.prototype.addEventListener=function(e,t){this._listeners||(this._listeners={}),e in this._listeners||(this._listeners[e]=[]);var r=this._listeners[e];-1===n.arrIndexOf(r,t)&&r.push(t)},r.prototype.removeEventListener=function(e,t){if(this._listeners&&e in this._listeners){var r=this._listeners[e],o=n.arrIndexOf(r,t);return-1!==o?void(r.length>1?this._listeners[e]=r.slice(0,o).concat(r.slice(o+1)):delete this._listeners[e]):void 0}},r.prototype.dispatchEvent=function(e){var t=e.type,n=Array.prototype.slice.call(arguments,0);if(this["on"+t]&&this["on"+t].apply(this,n),this._listeners&&t in this._listeners)for(var r=0;r<this._listeners[t].length;r++)this._listeners[t][r].apply(this,n)};var o=function(e,t){if(this.type=e,"undefined"!=typeof t)for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n])};o.prototype.toString=function(){var e=[];for(var t in this)if(this.hasOwnProperty(t)){var n=this[t];"function"==typeof n&&(n="[function]"),e.push(t+"="+n)}return"SimpleEvent("+e.join(", ")+")"};var a=function(e){var t=this;t._events=e||[],t._listeners={}};a.prototype.emit=function(e){var t=this;if(t._verifyType(e),!t._nuked){var n=Array.prototype.slice.call(arguments,1);if(t["on"+e]&&t["on"+e].apply(t,n),e in t._listeners)for(var r=0;r<t._listeners[e].length;r++)t._listeners[e][r].apply(t,n)}},a.prototype.on=function(e,t){var n=this;n._verifyType(e),n._nuked||(e in n._listeners||(n._listeners[e]=[]),n._listeners[e].push(t))},a.prototype._verifyType=function(e){var t=this;-1===n.arrIndexOf(t._events,e)&&n.log("Event "+i.stringify(e)+" not listed "+i.stringify(t._events)+" in "+t)},a.prototype.nuke=function(){var e=this;e._nuked=!0;for(var t=0;t<e._events.length;t++)delete e[e._events[t]];e._listeners={}};var s="abcdefghijklmnopqrstuvwxyz0123456789_";n.random_string=function(e,t){t=t||s.length;var n,r=[];for(n=0;e>n;n++)r.push(s.substr(Math.floor(Math.random()*t),1));return r.join("")},n.random_number=function(e){return Math.floor(Math.random()*e)},n.random_number_string=function(e){var t=(""+(e-1)).length,r=Array(t+1).join("0");return(r+n.random_number(e)).slice(-t)},n.getOrigin=function(e){e+="/";var t=e.split("/").slice(0,3);return t.join("/")},n.isSameOriginUrl=function(e,n){return n||(n=t.location.href),e.split("/").slice(0,3).join("/")===n.split("/").slice(0,3).join("/")},n.isSameOriginScheme=function(e,n){return n||(n=t.location.href),e.split(":")[0]===n.split(":")[0]},n.getParentDomain=function(e){if(/^[0-9.]*$/.test(e))return e;if(/^\[/.test(e))return e;if(!/[.]/.test(e))return e;var t=e.split(".").slice(1);return t.join(".")},n.objectExtend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e};var u="_jp";n.polluteGlobalNamespace=function(){u in t||(t[u]={})},n.closeFrame=function(e,t){return"c"+i.stringify([e,t])},n.userSetCode=function(e){return 1e3===e||e>=3e3&&4999>=e},n.countRTO=function(e){var t;return t=e>100?3*e:e+200},n.log=function(){t.console&&console.log&&console.log.apply&&console.log.apply(console,arguments)},n.bind=function(e,t){return e.bind?e.bind(t):function(){return e.apply(t,arguments)}},n.flatUrl=function(e){return-1===e.indexOf("?")&&-1===e.indexOf("#")},n.amendUrl=function(t,r){var o;if(void 0===r)o=e.location;else{var i=/^([a-z0-9.+-]+:)/i.exec(r);if(i){var a=i[0].toLowerCase(),s=r.substring(a.length),u=/[a-z0-9\.-]+(:[0-9]+)?/.exec(s);if(u)var c=u[0]}if(!a||!c)throw new Error("relativeTo must be an absolute url");o={protocol:a,host:c}}if(!t)throw new Error("Wrong url for SockJS");if(!n.flatUrl(t))throw new Error("Only basic urls are supported in SockJS");0===t.indexOf("//")&&(t=o.protocol+t),0===t.indexOf("/")&&(t=o.protocol+"//"+o.host+t),t=t.replace(/[/]+$/,"");var l=t.split("/");return("http:"===l[0]&&/:80$/.test(l[2])||"https:"===l[0]&&/:443$/.test(l[2]))&&(l[2]=l[2].replace(/:(80|443)$/,"")),t=l.join("/")},n.arrIndexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},n.arrSkip=function(e,t){var r=n.arrIndexOf(e,t);if(-1===r)return e.slice();var o=e.slice(0,r);return o.concat(e.slice(r+1))},n.isArray=Array.isArray||function(e){return{}.toString.call(e).indexOf("Array")>=0},n.delay=function(e,t){return"function"==typeof e&&(t=e,e=0),setTimeout(t,e)};var c=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,l={"\x00":"\\u0000","":"\\u0001","":"\\u0002","":"\\u0003","":"\\u0004","":"\\u0005","":"\\u0006","":"\\u0007","\b":"\\b"," ":"\\t","\n":"\\n"," ":"\\u000b","\f":"\\f","\r":"\\r","":"\\u000e","":"\\u000f","":"\\u0010","":"\\u0011","":"\\u0012","":"\\u0013","":"\\u0014","":"\\u0015","":"\\u0016","":"\\u0017","":"\\u0018","":"\\u0019","":"\\u001a","":"\\u001b","":"\\u001c","":"\\u001d","":"\\u001e","":"\\u001f",'"':'\\"',"\\":"\\\\","":"\\u007f","€":"\\u0080","":"\\u0081","‚":"\\u0082","ƒ":"\\u0083","„":"\\u0084","…":"\\u0085","†":"\\u0086","‡":"\\u0087","ˆ":"\\u0088","‰":"\\u0089","Š":"\\u008a","‹":"\\u008b","Œ":"\\u008c","":"\\u008d","Ž":"\\u008e","":"\\u008f","":"\\u0090","‘":"\\u0091","’":"\\u0092","“":"\\u0093","”":"\\u0094","•":"\\u0095","–":"\\u0096","—":"\\u0097","˜":"\\u0098","™":"\\u0099","š":"\\u009a","›":"\\u009b","œ":"\\u009c","":"\\u009d","ž":"\\u009e","Ÿ":"\\u009f","­":"\\u00ad","؀":"\\u0600","؁":"\\u0601","؂":"\\u0602","؃":"\\u0603","؄":"\\u0604","܏":"\\u070f","឴":"\\u17b4","឵":"\\u17b5","‌":"\\u200c","‍":"\\u200d","‎":"\\u200e","‏":"\\u200f","\u2028":"\\u2028","\u2029":"\\u2029","‪":"\\u202a","‫":"\\u202b","‬":"\\u202c","‭":"\\u202d","‮":"\\u202e"," ":"\\u202f","⁠":"\\u2060","⁡":"\\u2061","⁢":"\\u2062","⁣":"\\u2063","⁤":"\\u2064","⁥":"\\u2065","⁦":"\\u2066","⁧":"\\u2067","⁨":"\\u2068","⁩":"\\u2069","":"\\u206a","":"\\u206b","":"\\u206c","":"\\u206d","":"\\u206e","":"\\u206f","":"\\ufeff","￰":"\\ufff0","￱":"\\ufff1","￲":"\\ufff2","￳":"\\ufff3","￴":"\\ufff4","￵":"\\ufff5","￶":"\\ufff6","￷":"\\ufff7","￸":"\\ufff8","":"\\ufff9","":"\\ufffa","":"\\ufffb","":"\\ufffc","�":"\\ufffd","￾":"\\ufffe","￿":"\\uffff"},d=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,f,_=i&&i.stringify||function(e){return c.lastIndex=0,c.test(e)&&(e=e.replace(c,function(e){return l[e]})),'"'+e+'"'},p=function(e){var t,n={},r=[];for(t=0;65536>t;t++)r.push(String.fromCharCode(t));return e.lastIndex=0,r.join("").replace(e,function(e){return n[e]="\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4),""}),e.lastIndex=0,n};n.quote=function(e){var t=_(e);return d.lastIndex=0,d.test(t)?(f||(f=p(d)),t.replace(d,function(e){return f[e]})):t};var h=["websocket","xdr-streaming","xhr-streaming","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"];n.probeProtocols=function(){for(var e={},t=0;t<h.length;t++){var n=h[t];e[n]=T[n]&&T[n].enabled()}return e},n.detectProtocols=function(e,t,n){var r={},o=[];t||(t=h);for(var i=0;i<t.length;i++){var a=t[i];r[a]=e[a]}var s=function(e){var t=e.shift();r[t]?o.push(t):e.length>0&&s(e)};return n.websocket!==!1&&s(["websocket"]),r["xhr-streaming"]&&!n.null_origin?o.push("xhr-streaming"):!r["xdr-streaming"]||n.cookie_needed||n.null_origin?s(["iframe-eventsource","iframe-htmlfile"]):o.push("xdr-streaming"),r["xhr-polling"]&&!n.null_origin?o.push("xhr-polling"):!r["xdr-polling"]||n.cookie_needed||n.null_origin?s(["iframe-xhr-polling","jsonp-polling"]):o.push("xdr-polling"),o};var v="_sockjs_global";n.createHook=function(){var e="a"+n.random_string(8);if(!(v in t)){var r={};t[v]=function(e){return e in r||(r[e]={id:e,del:function(){delete r[e]}}),r[e]}}return t[v](e)},n.attachMessage=function(e){n.attachEvent("message",e)},n.attachEvent=function(n,r){"undefined"!=typeof t.addEventListener?t.addEventListener(n,r,!1):(e.attachEvent("on"+n,r),t.attachEvent("on"+n,r))},n.detachMessage=function(e){n.detachEvent("message",e)},n.detachEvent=function(n,r){"undefined"!=typeof t.addEventListener?t.removeEventListener(n,r,!1):(e.detachEvent("on"+n,r),t.detachEvent("on"+n,r))};var m={},g=!1,b=function(){for(var e in m)m[e](),delete m[e]},y=function(){g||(g=!0,b())};n.attachEvent("unload",y),n.unload_add=function(e){var t=n.random_string(8);return m[t]=e,g&&n.delay(b),t},n.unload_del=function(e){e in m&&delete m[e]},n.createIframe=function(t,r){var o=e.createElement("iframe"),i,a,s=function(){clearTimeout(i);try{o.onload=null}catch(e){}o.onerror=null},u=function(){o&&(s(),setTimeout(function(){o&&o.parentNode.removeChild(o),o=null},0),n.unload_del(a))},c=function(e){o&&(u(),r(e))},l=function(e,t){try{o&&o.contentWindow&&o.contentWindow.postMessage(e,t)}catch(n){}};return o.src=t,o.style.display="none",o.style.position="absolute",o.onerror=function(){c("onerror")},o.onload=function(){clearTimeout(i),i=setTimeout(function(){c("onload timeout")},2e3)},e.body.appendChild(o),i=setTimeout(function(){c("timeout")},15e3),a=n.unload_add(u),{post:l,cleanup:u,loaded:s}},n.createHtmlfile=function(e,r){var o=new ActiveXObject("htmlfile"),i,a,s,c=function(){clearTimeout(i)},l=function(){o&&(c(),n.unload_del(a),s.parentNode.removeChild(s),s=o=null,CollectGarbage())},d=function(e){o&&(l(),r(e))},f=function(e,t){try{s&&s.contentWindow&&s.contentWindow.postMessage(e,t)}catch(n){}};o.open(),o.write('<html><script>document.domain="'+document.domain+'";</script></html>'),o.close(),o.parentWindow[u]=t[u];var _=o.createElement("div");return o.body.appendChild(_),s=o.createElement("iframe"),_.appendChild(s),s.src=e,i=setTimeout(function(){d("timeout")},15e3),a=n.unload_add(l),{post:f,cleanup:l,loaded:c}};var w=function(){};w.prototype=new a(["chunk","finish"]),w.prototype._start=function(e,r,o,i){var a=this;try{a.xhr=new XMLHttpRequest}catch(s){}if(!a.xhr)try{a.xhr=new t.ActiveXObject("Microsoft.XMLHTTP")}catch(s){}(t.ActiveXObject||t.XDomainRequest)&&(r+=(-1===r.indexOf("?")?"?":"&")+"t="+ +new Date),a.unload_ref=n.unload_add(function(){a._cleanup(!0)});try{a.xhr.open(e,r,!0)}catch(u){return a.emit("finish",0,""),void a._cleanup()}if(i&&i.no_credentials||(a.xhr.withCredentials="true"),i&&i.headers)for(var c in i.headers)a.xhr.setRequestHeader(c,i.headers[c]);a.xhr.onreadystatechange=function(){if(a.xhr){var e=a.xhr;switch(e.readyState){case 3:try{var t=e.status,n=e.responseText}catch(e){}1223===t&&(t=204),n&&n.length>0&&a.emit("chunk",t,n);break;case 4:var t=e.status;1223===t&&(t=204),a.emit("finish",t,e.responseText),a._cleanup(!1)}}},a.xhr.send(o)},w.prototype._cleanup=function(e){var t=this;if(t.xhr){if(n.unload_del(t.unload_ref),t.xhr.onreadystatechange=function(){},e)try{t.xhr.abort()}catch(r){}t.unload_ref=t.xhr=null}},w.prototype.close=function(){var e=this;e.nuke(),e._cleanup(!0)};var k=n.XHRCorsObject=function(){var e=this,t=arguments;n.delay(function(){e._start.apply(e,t)})};k.prototype=new w;var S=n.XHRLocalObject=function(e,t,r){var o=this;n.delay(function(){o._start(e,t,r,{no_credentials:!0})})};S.prototype=new w;var C=n.XDRObject=function(e,t,r){var o=this;n.delay(function(){o._start(e,t,r)})};C.prototype=new a(["chunk","finish"]),C.prototype._start=function(e,t,r){var o=this,i=new XDomainRequest;t+=(-1===t.indexOf("?")?"?":"&")+"t="+ +new Date;var a=i.ontimeout=i.onerror=function(){o.emit("finish",0,""),o._cleanup(!1)};i.onprogress=function(){o.emit("chunk",200,i.responseText)},i.onload=function(){o.emit("finish",200,i.responseText),o._cleanup(!1)},o.xdr=i,o.unload_ref=n.unload_add(function(){o._cleanup(!0)});try{o.xdr.open(e,t),o.xdr.send(r)}catch(s){a()}},C.prototype._cleanup=function(e){var t=this;if(t.xdr){if(n.unload_del(t.unload_ref),t.xdr.ontimeout=t.xdr.onerror=t.xdr.onprogress=t.xdr.onload=null,e)try{t.xdr.abort()}catch(r){}t.unload_ref=t.xdr=null}},C.prototype.close=function(){var e=this;e.nuke(),e._cleanup(!0)},n.isXHRCorsCapable=function(){return t.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest?1:t.XDomainRequest&&e.domain?2:B.enabled()?3:4};var T=function(e,t,r){if(!(this instanceof T))return new T(e,t,r);var o=this,i;o._options={devel:!1,debug:!1,protocols_whitelist:[],info:void 0,rtt:void 0},r&&n.objectExtend(o._options,r),o._base_url=n.amendUrl(e),o._server=o._options.server||n.random_number_string(1e3),o._options.protocols_whitelist&&o._options.protocols_whitelist.length?i=o._options.protocols_whitelist:(i="string"==typeof t&&t.length>0?[t]:n.isArray(t)?t:null,i&&o._debug('Deprecated API: Use "protocols_whitelist" option instead of supplying protocol list as a second parameter to SockJS constructor.')),o._protocols=[],o.protocol=null,o.readyState=T.CONNECTING,o._ir=q(o._base_url),o._ir.onfinish=function(e,t){o._ir=null,e?(o._options.info&&(e=n.objectExtend(e,o._options.info)),o._options.rtt&&(t=o._options.rtt),o._applyInfo(e,t,i),o._didClose()):o._didClose(1002,"Can't connect to server",!0)}};T.prototype=new r,T.version="0.3.4",T.CONNECTING=0,T.OPEN=1,T.CLOSING=2,T.CLOSED=3,T.prototype._debug=function(){this._options.debug&&n.log.apply(n,arguments)},T.prototype._dispatchOpen=function(){var e=this;e.readyState===T.CONNECTING?(e._transport_tref&&(clearTimeout(e._transport_tref),e._transport_tref=null),e.readyState=T.OPEN,e.dispatchEvent(new o("open"))):e._didClose(1006,"Server lost session")},T.prototype._dispatchMessage=function(e){var t=this;t.readyState===T.OPEN&&t.dispatchEvent(new o("message",{data:e}))},T.prototype._dispatchHeartbeat=function(e){var t=this;t.readyState===T.OPEN&&t.dispatchEvent(new o("heartbeat",{}))},T.prototype._didClose=function(e,t,r){var i=this;if(i.readyState!==T.CONNECTING&&i.readyState!==T.OPEN&&i.readyState!==T.CLOSING)throw new Error("INVALID_STATE_ERR");i._ir&&(i._ir.nuke(),i._ir=null),i._transport&&(i._transport.doCleanup(),i._transport=null);var a=new o("close",{code:e,reason:t,wasClean:n.userSetCode(e)});if(!n.userSetCode(e)&&i.readyState===T.CONNECTING&&!r){if(i._try_next_protocol(a))return;a=new o("close",{code:2e3,reason:"All transports failed",wasClean:!1,last_event:a})}i.readyState=T.CLOSED,n.delay(function(){i.dispatchEvent(a)})},T.prototype._didMessage=function(e){var t=this,n=e.slice(0,1);switch(n){case"o":t._dispatchOpen();break;case"a":for(var r=i.parse(e.slice(1)||"[]"),o=0;o<r.length;o++)t._dispatchMessage(r[o]);break;case"m":var r=i.parse(e.slice(1)||"null");t._dispatchMessage(r);break;case"c":var r=i.parse(e.slice(1)||"[]");t._didClose(r[0],r[1]);break;case"h":t._dispatchHeartbeat()}},T.prototype._try_next_protocol=function(t){var r=this;for(r.protocol&&(r._debug("Closed transport:",r.protocol,""+t),r.protocol=null),r._transport_tref&&(clearTimeout(r._transport_tref),r._transport_tref=null);;){var o=r.protocol=r._protocols.shift();if(!o)return!1;if(T[o]&&T[o].need_body===!0&&(!e.body||"undefined"!=typeof e.readyState&&"complete"!==e.readyState))return r._protocols.unshift(o),r.protocol="waiting-for-load",n.attachEvent("load",function(){r._try_next_protocol()}),!0;if(T[o]&&T[o].enabled(r._options)){var i=T[o].roundTrips||1,a=(r._options.rto||0)*i||5e3;r._transport_tref=n.delay(a,function(){r.readyState===T.CONNECTING&&r._didClose(2007,"Transport timeouted")});var s=n.random_string(8),u=r._base_url+"/"+r._server+"/"+s;return r._debug("Opening transport:",o," url:"+u," RTO:"+r._options.rto),r._transport=new T[o](r,u,r._base_url),!0}r._debug("Skipping transport:",o)}},T.prototype.close=function(e,t){var r=this;if(e&&!n.userSetCode(e))throw new Error("INVALID_ACCESS_ERR");return r.readyState!==T.CONNECTING&&r.readyState!==T.OPEN?!1:(r.readyState=T.CLOSING,r._didClose(e||1e3,t||"Normal closure"),!0)},T.prototype.send=function(e){var t=this;if(t.readyState===T.CONNECTING)throw new Error("INVALID_STATE_ERR");return t.readyState===T.OPEN&&t._transport.doSend(n.quote(""+e)),!0},T.prototype._applyInfo=function(t,r,o){var i=this;i._options.info=t,i._options.rtt=r,i._options.rto=n.countRTO(r),i._options.info.null_origin=!e.domain,t.base_url&&(i._base_url=n.amendUrl(t.base_url,i._base_url));var a=n.probeProtocols();i._protocols=n.detectProtocols(a,o,t),n.isSameOriginScheme(i._base_url)||2!==n.isXHRCorsCapable()||(i._protocols=["jsonp-polling"])};var E=T.websocket=function(e,r){var o=this,i=r+"/websocket";i="https"===i.slice(0,5)?"wss"+i.slice(5):"ws"+i.slice(4),o.ri=e,o.url=i;var a=t.WebSocket||t.MozWebSocket;o.ws=new a(o.url),o.ws.onmessage=function(e){o.ri._didMessage(e.data)},o.unload_ref=n.unload_add(function(){o.ws.close()}),o.ws.onclose=function(){o.ri._didMessage(n.closeFrame(1006,"WebSocket connection broken"))}};E.prototype.doSend=function(e){this.ws.send("["+e+"]")},E.prototype.doCleanup=function(){var e=this,t=e.ws;t&&(t.onmessage=t.onclose=null,t.close(),n.unload_del(e.unload_ref),e.unload_ref=e.ri=e.ws=null)},E.enabled=function(){return!(!t.WebSocket&&!t.MozWebSocket)},E.roundTrips=2;var O=function(){};O.prototype.send_constructor=function(e){var t=this;t.send_buffer=[],t.sender=e},O.prototype.doSend=function(e){var t=this;t.send_buffer.push(e),t.send_stop||t.send_schedule()},O.prototype.send_schedule_wait=function(){var e=this,t;e.send_stop=function(){e.send_stop=null,clearTimeout(t)},t=n.delay(25,function(){e.send_stop=null,e.send_schedule()})},O.prototype.send_schedule=function(){var e=this;if(e.send_buffer.length>0){var t="["+e.send_buffer.join(",")+"]";e.send_stop=e.sender(e.trans_url,t,function(t,n){e.send_stop=null,t===!1?e.ri._didClose(1006,"Sending error "+n):e.send_schedule_wait()}),e.send_buffer=[]}},O.prototype.send_destructor=function(){var e=this;e._send_stop&&e._send_stop(),e._send_stop=null};var x=function(t,r,o){var i=this;if(!("_send_form"in i)){var a=i._send_form=e.createElement("form"),s=i._send_area=e.createElement("textarea");s.name="d",a.style.display="none",a.style.position="absolute",a.method="POST",a.enctype="application/x-www-form-urlencoded",a.acceptCharset="UTF-8",a.appendChild(s),e.body.appendChild(a)}var a=i._send_form,s=i._send_area,u="a"+n.random_string(8);a.target=u,a.action=t+"/jsonp_send?i="+u;var c;try{c=e.createElement('<iframe name="'+u+'">')}catch(l){c=e.createElement("iframe"),c.name=u}c.id=u,a.appendChild(c),c.style.display="none";try{s.value=r}catch(d){n.log("Your browser is seriously broken. Go home! "+d.message)}a.submit();var f=function(e){c.onerror&&(c.onreadystatechange=c.onerror=c.onload=null,n.delay(500,function(){c.parentNode.removeChild(c),c=null}),s.value="",o(!0))};return c.onerror=c.onload=f,c.onreadystatechange=function(e){"complete"==c.readyState&&f()},f},I=function(e){return function(t,n,r){var o=new e("POST",t+"/xhr_send",n);return o.onfinish=function(e,t){r(200===e||204===e,"http status "+e)},function(e){r(!1,e)}}},M=function(t,r){var o,i=e.createElement("script"),a,s=function(e){a&&(a.parentNode.removeChild(a),a=null),i&&(clearTimeout(o),i.parentNode.removeChild(i),i.onreadystatechange=i.onerror=i.onload=i.onclick=null,i=null,r(e),r=null)},u=!1,c=null;if(i.id="a"+n.random_string(8),i.src=t,i.type="text/javascript",i.charset="UTF-8",i.onerror=function(e){c||(c=setTimeout(function(){u||s(n.closeFrame(1006,"JSONP script loaded abnormally (onerror)"))},1e3))},i.onload=function(e){s(n.closeFrame(1006,"JSONP script loaded abnormally (onload)"))},i.onreadystatechange=function(e){if(/loaded|closed/.test(i.readyState)){if(i&&i.htmlFor&&i.onclick){u=!0;try{i.onclick()}catch(t){}}i&&s(n.closeFrame(1006,"JSONP script loaded abnormally (onreadystatechange)"))}},"undefined"==typeof i.async&&e.attachEvent)if(/opera/i.test(navigator.userAgent))a=e.createElement("script"),a.text="try{var a = document.getElementById('"+i.id+"'); if(a)a.onerror();}catch(x){};",i.async=a.async=!1;else{try{i.htmlFor=i.id,i.event="onclick"}catch(l){}i.async=!0}"undefined"!=typeof i.async&&(i.async=!0),o=setTimeout(function(){s(n.closeFrame(1006,"JSONP script loaded abnormally (timeout)"))},35e3);var d=e.getElementsByTagName("head")[0];return d.insertBefore(i,d.firstChild),a&&d.insertBefore(a,d.firstChild),s},D=T["jsonp-polling"]=function(e,t){n.polluteGlobalNamespace();var r=this;r.ri=e,r.trans_url=t,r.send_constructor(x),r._schedule_recv()};D.prototype=new O,D.prototype._schedule_recv=function(){var e=this,t=function(t){e._recv_stop=null,t&&(e._is_closing||e.ri._didMessage(t)),e._is_closing||e._schedule_recv()};e._recv_stop=R(e.trans_url+"/jsonp",M,t)},D.enabled=function(){return!0},D.need_body=!0,D.prototype.doCleanup=function(){var e=this;e._is_closing=!0,e._recv_stop&&e._recv_stop(),e.ri=e._recv_stop=null,e.send_destructor()};var R=function(e,r,o){var i="a"+n.random_string(6),a=e+"?c="+escape(u+"."+i),s=0,c=function(e){switch(s){case 0:delete t[u][i],o(e);break;case 1:o(e),s=2;break;case 2:delete t[u][i]}},l=r(a,c);t[u][i]=l;var d=function(){t[u][i]&&(s=1,t[u][i](n.closeFrame(1e3,"JSONP user aborted read")))};return d},P=function(){};P.prototype=new O,P.prototype.run=function(e,t,n,r,o){var i=this;i.ri=e,i.trans_url=t,i.send_constructor(I(o)),i.poll=new Z(e,r,t+n,o)},P.prototype.doCleanup=function(){var e=this;e.poll&&(e.poll.abort(),e.poll=null)};var N=T["xhr-streaming"]=function(e,t){this.run(e,t,"/xhr_streaming",ot,n.XHRCorsObject)};N.prototype=new P,N.enabled=function(){return t.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest&&!/opera/i.test(navigator.userAgent)},N.roundTrips=2,N.need_body=!0;var j=T["xdr-streaming"]=function(e,t){this.run(e,t,"/xhr_streaming",ot,n.XDRObject)};j.prototype=new P,j.enabled=function(){return!!t.XDomainRequest},j.roundTrips=2;var U=T["xhr-polling"]=function(e,t){this.run(e,t,"/xhr",ot,n.XHRCorsObject)};U.prototype=new P,U.enabled=N.enabled,U.roundTrips=2;var A=T["xdr-polling"]=function(e,t){this.run(e,t,"/xhr",ot,n.XDRObject)};A.prototype=new P,A.enabled=j.enabled,A.roundTrips=2;var B=function(){};B.prototype.i_constructor=function(e,t,r){var o=this;o.ri=e,o.origin=n.getOrigin(r),o.base_url=r,o.trans_url=t;var i=r+"/iframe.html";o.ri._options.devel&&(i+="?t="+ +new Date),o.window_id=n.random_string(8),i+="#"+o.window_id,o.iframeObj=n.createIframe(i,function(e){o.ri._didClose(1006,"Unable to load an iframe ("+e+")")}),o.onmessage_cb=n.bind(o.onmessage,o),n.attachMessage(o.onmessage_cb)},B.prototype.doCleanup=function(){var e=this;if(e.iframeObj){n.detachMessage(e.onmessage_cb);try{e.iframeObj.iframe.contentWindow&&e.postMessage("c")}catch(t){}e.iframeObj.cleanup(),e.iframeObj=null,e.onmessage_cb=e.iframeObj=null}},B.prototype.onmessage=function(e){var t=this;if(e.origin===t.origin){var n=e.data.slice(0,8),r=e.data.slice(8,9),o=e.data.slice(9);if(n===t.window_id)switch(r){case"s":t.iframeObj.loaded(),t.postMessage("s",i.stringify([T.version,t.protocol,t.trans_url,t.base_url]));break;case"t":t.ri._didMessage(o)}}},B.prototype.postMessage=function(e,t){var n=this;n.iframeObj.post(n.window_id+e+(t||""),n.origin)},B.prototype.doSend=function(e){this.postMessage("m",e)},B.enabled=function(){var e=navigator&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Konqueror");return("function"==typeof t.postMessage||"object"==typeof t.postMessage)&&!e};var H,L=function(e,r){parent!==t?parent.postMessage(H+e+(r||""),"*"):n.log("Can't postMessage, no parent window.",e,r)},F=function(){};F.prototype._didClose=function(e,t){L("t",n.closeFrame(e,t))},F.prototype._didMessage=function(e){L("t",e)},F.prototype._doSend=function(e){this._transport.doSend(e)},F.prototype._doCleanup=function(){this._transport.doCleanup()},n.parent_origin=void 0,T.bootstrap_iframe=function(){var r;H=e.location.hash.slice(1);var o=function(e){if(e.source===parent&&("undefined"==typeof n.parent_origin&&(n.parent_origin=e.origin),e.origin===n.parent_origin)){var o=e.data.slice(0,8),a=e.data.slice(8,9),s=e.data.slice(9);if(o===H)switch(a){case"s":var u=i.parse(s),c=u[0],l=u[1],d=u[2],f=u[3];if(c!==T.version&&n.log('Incompatibile SockJS! Main site uses: "'+c+'", the iframe: "'+T.version+'".'),!n.flatUrl(d)||!n.flatUrl(f))return void n.log("Only basic urls are supported in SockJS");if(!n.isSameOriginUrl(d)||!n.isSameOriginUrl(f))return void n.log("Can't connect to different domain from within an iframe. ("+i.stringify([t.location.href,d,f])+")");r=new F,r._transport=new F[l](r,d,f);break;case"m":r._doSend(s);break;case"c":r&&r._doCleanup(),r=null}}};n.attachMessage(o),L("s")};var X=function(e,t){var r=this;n.delay(function(){r.doXhr(e,t)})};X.prototype=new a(["finish"]),X.prototype.doXhr=function(e,t){var r=this,o=(new Date).getTime(),a=new t("GET",e+"/info?cb="+n.random_string(10)),s=n.delay(8e3,function(){a.ontimeout()});a.onfinish=function(e,t){if(clearTimeout(s),s=null,200===e){var n=(new Date).getTime()-o,a=i.parse(t);"object"!=typeof a&&(a={}),r.emit("finish",a,n)}else r.emit("finish")},a.ontimeout=function(){a.close(),r.emit("finish")}};var V=function(t){var r=this,o=function(){var e=new B;e.protocol="w-iframe-info-receiver";var n=function(t){if("string"==typeof t&&"m"===t.substr(0,1)){var n=i.parse(t.substr(1)),o=n[0],a=n[1];r.emit("finish",o,a)}else r.emit("finish");e.doCleanup(),e=null},o={_options:{},_didClose:n,_didMessage:n};e.i_constructor(o,t,t)};e.body?o():n.attachEvent("load",o)};V.prototype=new a(["finish"]);var W=function(){var e=this;n.delay(function(){e.emit("finish",{},2e3)})};W.prototype=new a(["finish"]);var q=function(e){if(n.isSameOriginUrl(e))return new X(e,n.XHRLocalObject);switch(n.isXHRCorsCapable()){case 1:return new X(e,n.XHRLocalObject);case 2:return n.isSameOriginScheme(e)?new X(e,n.XDRObject):new W;case 3:return new V(e);default:return new W}},G=F["w-iframe-info-receiver"]=function(e,t,r){var o=new X(r,n.XHRLocalObject);o.onfinish=function(t,n){e._didMessage("m"+i.stringify([t,n])),e._didClose()}};G.prototype.doCleanup=function(){};var J=T["iframe-eventsource"]=function(){var e=this;e.protocol="w-iframe-eventsource",e.i_constructor.apply(e,arguments)};J.prototype=new B,J.enabled=function(){return"EventSource"in t&&B.enabled()},J.need_body=!0,J.roundTrips=3;var Q=F["w-iframe-eventsource"]=function(e,t){this.run(e,t,"/eventsource",et,n.XHRLocalObject)};Q.prototype=new P;var z=T["iframe-xhr-polling"]=function(){var e=this;e.protocol="w-iframe-xhr-polling",e.i_constructor.apply(e,arguments)};z.prototype=new B,z.enabled=function(){return t.XMLHttpRequest&&B.enabled()},z.need_body=!0,z.roundTrips=3;var $=F["w-iframe-xhr-polling"]=function(e,t){this.run(e,t,"/xhr",ot,n.XHRLocalObject)};$.prototype=new P;var Y=T["iframe-htmlfile"]=function(){var e=this;e.protocol="w-iframe-htmlfile",e.i_constructor.apply(e,arguments)};Y.prototype=new B,Y.enabled=function(){return B.enabled()},Y.need_body=!0,Y.roundTrips=3;var K=F["w-iframe-htmlfile"]=function(e,t){this.run(e,t,"/htmlfile",rt,n.XHRLocalObject)};K.prototype=new P;var Z=function(e,t,n,r){var o=this;o.ri=e,o.Receiver=t,o.recv_url=n,o.AjaxObject=r,o._scheduleRecv()};Z.prototype._scheduleRecv=function(){var e=this,t=e.poll=new e.Receiver(e.recv_url,e.AjaxObject),n=0;t.onmessage=function(t){n+=1,e.ri._didMessage(t.data)},t.onclose=function(n){e.poll=t=t.onmessage=t.onclose=null,e.poll_is_closing||("permanent"===n.reason?e.ri._didClose(1006,"Polling error ("+n.reason+")"):e._scheduleRecv())}},Z.prototype.abort=function(){var e=this;e.poll_is_closing=!0,e.poll&&e.poll.abort()};var et=function(e){var t=this,r=new EventSource(e);r.onmessage=function(e){t.dispatchEvent(new o("message",{data:unescape(e.data)}))},t.es_close=r.onerror=function(e,i){var a=i?"user":2!==r.readyState?"network":"permanent";t.es_close=r.onmessage=r.onerror=null,r.close(),r=null,n.delay(200,function(){t.dispatchEvent(new o("close",{reason:a}))})}};et.prototype=new r,et.prototype.abort=function(){var e=this;e.es_close&&e.es_close({},!0)};var tt,nt=function(){if(void 0===tt)if("ActiveXObject"in t)try{tt=!!new ActiveXObject("htmlfile")}catch(e){}else tt=!1;return tt},rt=function(e){var r=this;n.polluteGlobalNamespace(),r.id="a"+n.random_string(6,26),e+=(-1===e.indexOf("?")?"?":"&")+"c="+escape(u+"."+r.id);var i=nt()?n.createHtmlfile:n.createIframe,a;t[u][r.id]={start:function(){a.loaded()},message:function(e){r.dispatchEvent(new o("message",{data:e}))},stop:function(){r.iframe_close({},"network")}},r.iframe_close=function(e,n){a.cleanup(),r.iframe_close=a=null,delete t[u][r.id],r.dispatchEvent(new o("close",{reason:n}))},a=i(e,function(e){r.iframe_close({},"permanent")})};rt.prototype=new r,rt.prototype.abort=function(){var e=this;e.iframe_close&&e.iframe_close({},"user")};var ot=function(e,t){var n=this,r=0;n.xo=new t("POST",e,null),n.xo.onchunk=function(e,t){if(200===e)for(;;){var i=t.slice(r),a=i.indexOf("\n");if(-1===a)break;r+=a+1;var s=i.slice(0,a);n.dispatchEvent(new o("message",{data:s}))}},n.xo.onfinish=function(e,t){n.xo.onchunk(e,t),n.xo=null;var r=200===e?"network":"permanent";n.dispatchEvent(new o("close",{reason:r}))}};return ot.prototype=new r,ot.prototype.abort=function(){var e=this;e.xo&&(e.xo.close(),e.dispatchEvent(new o("close",{reason:"user"})),e.xo=null)},T.getUtils=function(){return n},T.getIframeTransport=function(){return B},T}(),"_sockjs_onload"in window&&setTimeout(_sockjs_onload,1),"function"==typeof define&&define.amd&&define("sockjs",[],function(){return h})}.call(this),function(){p.ClientStream=function(e,t){var n=this;n.options=a.extend({retry:!0},t),n._initCommon(n.options),n.HEARTBEAT_TIMEOUT=1e5,n.rawUrl=e,n.socket=null,n.heartbeatTimer=null,"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("online",a.bind(n._online,n),!1),n._launchConnection()},a.extend(p.ClientStream.prototype,{send:function(e){var t=this;t.currentStatus.connected&&t.socket.send(e)},_changeUrl:function(e){var t=this;t.rawUrl=e},_connected:function(){var e=this;e.connectionTimer&&(clearTimeout(e.connectionTimer),e.connectionTimer=null),e.currentStatus.connected||(e.currentStatus.status="connected",e.currentStatus.connected=!0,e.currentStatus.retryCount=0,e.statusChanged(),a.each(e.eventCallbacks.reset,function(e){e()}))},_cleanup:function(e){var t=this;t._clearConnectionAndHeartbeatTimers(),t.socket&&(t.socket.onmessage=t.socket.onclose=t.socket.onerror=t.socket.onheartbeat=function(){},t.socket.close(),t.socket=null),a.each(t.eventCallbacks.disconnect,function(t){t(e)})},_clearConnectionAndHeartbeatTimers:function(){var e=this;e.connectionTimer&&(clearTimeout(e.connectionTimer),e.connectionTimer=null),e.heartbeatTimer&&(clearTimeout(e.heartbeatTimer),e.heartbeatTimer=null)},_heartbeat_timeout:function(){var t=this;e._debug("Connection timeout. No sockjs heartbeat received."),t._lostConnection(new _.ConnectionError("Heartbeat timed out"))},_heartbeat_received:function(){var e=this;e._forcedToDisconnect||(e.heartbeatTimer&&clearTimeout(e.heartbeatTimer),e.heartbeatTimer=setTimeout(a.bind(e._heartbeat_timeout,e),e.HEARTBEAT_TIMEOUT))},_sockjsProtocolsWhitelist:function(){var e=["xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"],t=navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent)&&/OS 4_|OS 5_/.test(navigator.userAgent);
+return t||(e=["websocket"].concat(e)),e},_launchConnection:function(){var t=this;t._cleanup();var n=a.extend({protocols_whitelist:t._sockjsProtocolsWhitelist()},t.options._sockjsOptions);t.socket=new h(v(t.rawUrl),void 0,n),t.socket.onopen=function(e){t._connected()},t.socket.onmessage=function(e){t._heartbeat_received(),t.currentStatus.connected&&a.each(t.eventCallbacks.message,function(t){t(e.data)})},t.socket.onclose=function(){t._lostConnection()},t.socket.onerror=function(){e._debug("stream error",a.toArray(arguments),(new Date).toDateString())},t.socket.onheartbeat=function(){t._heartbeat_received()},t.connectionTimer&&clearTimeout(t.connectionTimer),t.connectionTimer=setTimeout(function(){t._lostConnection(new _.ConnectionError("DDP connection timed out"))},t.CONNECT_TIMEOUT)}})}.call(this),function(){var t=function(e,t){return e.length>=t.length&&e.substring(0,t.length)===t},n=function(e,t){return e.length>=t.length&&e.substring(e.length-t.length)===t},o=function(o,i,a){i||(i="http");var s=o.match(/^ddp(i?)\+sockjs:\/\//),u=o.match(/^http(s?):\/\//),c;if(s){var l=o.substr(s[0].length);c="i"===s[1]?i:i+"s";var d=l.indexOf("/"),f=-1===d?l:l.substr(0,d),_=-1===d?"":l.substr(d);return f=f.replace(/\*/g,function(){return Math.floor(10*r.fraction())}),c+"://"+f+_}if(u){c=u[1]?i+"s":i;var p=o.substr(u[0].length);o=c+"://"+p}return-1!==o.indexOf("://")||t(o,"/")||(o=i+"://"+o),o=e._relativeToSiteRootUrl(o),n(o,"/")?o+a:o+"/"+a};v=function(e){return o(e,"http","sockjs")},m=function(e){var t=o(e,"ws","websocket");return t},p.toSockjsUrl=v,a.extend(p.ClientStream.prototype,{on:function(e,t){var n=this;if("message"!==e&&"reset"!==e&&"disconnect"!==e)throw new Error("unknown event type: "+e);n.eventCallbacks[e]||(n.eventCallbacks[e]=[]),n.eventCallbacks[e].push(t)},_initCommon:function(e){var t=this;e=e||{},t.CONNECT_TIMEOUT=e.connectTimeoutMs||1e4,t.eventCallbacks={},t._forcedToDisconnect=!1,t.currentStatus={status:"connecting",connected:!1,retryCount:0},t.statusListeners="undefined"!=typeof s&&new s.Dependency,t.statusChanged=function(){t.statusListeners&&t.statusListeners.changed()},t._retry=new l,t.connectionTimer=null},reconnect:function(e){var t=this;return e=e||{},e.url&&t._changeUrl(e.url),e._sockjsOptions&&(t.options._sockjsOptions=e._sockjsOptions),t.currentStatus.connected?void((e._force||e.url)&&t._lostConnection(new _.ForcedReconnectError)):("connecting"===t.currentStatus.status&&t._lostConnection(),t._retry.clear(),t.currentStatus.retryCount-=1,void t._retryNow())},disconnect:function(e){var t=this;e=e||{},t._forcedToDisconnect||(e._permanent&&(t._forcedToDisconnect=!0),t._cleanup(),t._retry.clear(),t.currentStatus={status:e._permanent?"failed":"offline",connected:!1,retryCount:0},e._permanent&&e._error&&(t.currentStatus.reason=e._error),t.statusChanged())},_lostConnection:function(e){var t=this;t._cleanup(e),t._retryLater(e)},_online:function(){"offline"!=this.currentStatus.status&&this.reconnect()},_retryLater:function(e){var t=this,n=0;t.options.retry||e&&"DDP.ForcedReconnectError"===e.errorType?(n=t._retry.retryLater(t.currentStatus.retryCount,a.bind(t._retryNow,t)),t.currentStatus.status="waiting",t.currentStatus.retryTime=(new Date).getTime()+n):(t.currentStatus.status="failed",delete t.currentStatus.retryTime),t.currentStatus.connected=!1,t.statusChanged()},_retryNow:function(){var e=this;e._forcedToDisconnect||(e.currentStatus.retryCount+=1,e.currentStatus.status="connecting",e.currentStatus.connected=!1,delete e.currentStatus.retryTime,e.statusChanged(),e._launchConnection())},status:function(){var e=this;return e.statusListeners&&e.statusListeners.depend(),e.currentStatus}}),_.ConnectionError=e.makeErrorType("DDP.ConnectionError",function(e){var t=this;t.message=e}),_.ForcedReconnectError=e.makeErrorType("DDP.ForcedReconnectError",function(){})}.call(this),function(){g=function(e){var t=this;t.heartbeatInterval=e.heartbeatInterval,t.heartbeatTimeout=e.heartbeatTimeout,t._sendPing=e.sendPing,t._onTimeout=e.onTimeout,t._heartbeatIntervalHandle=null,t._heartbeatTimeoutHandle=null},a.extend(g.prototype,{stop:function(){var e=this;e._clearHeartbeatIntervalTimer(),e._clearHeartbeatTimeoutTimer()},start:function(){var e=this;e.stop(),e._startHeartbeatIntervalTimer()},_startHeartbeatIntervalTimer:function(){var t=this;t._heartbeatIntervalHandle=e.setTimeout(a.bind(t._heartbeatIntervalFired,t),t.heartbeatInterval)},_startHeartbeatTimeoutTimer:function(){var t=this;t._heartbeatTimeoutHandle=e.setTimeout(a.bind(t._heartbeatTimeoutFired,t),t.heartbeatTimeout)},_clearHeartbeatIntervalTimer:function(){var t=this;t._heartbeatIntervalHandle&&(e.clearTimeout(t._heartbeatIntervalHandle),t._heartbeatIntervalHandle=null)},_clearHeartbeatTimeoutTimer:function(){var t=this;t._heartbeatTimeoutHandle&&(e.clearTimeout(t._heartbeatTimeoutHandle),t._heartbeatTimeoutHandle=null)},_heartbeatIntervalFired:function(){var e=this;e._heartbeatIntervalHandle=null,e._sendPing(),e._startHeartbeatTimeoutTimer()},_heartbeatTimeoutFired:function(){var e=this;e._heartbeatTimeoutHandle=null,e._onTimeout()},pingReceived:function(){var e=this;e._heartbeatIntervalHandle&&(e._clearHeartbeatIntervalTimer(),e._startHeartbeatIntervalTimer())},pongReceived:function(){var e=this;e._heartbeatTimeoutHandle&&(e._clearHeartbeatTimeoutTimer(),e._startHeartbeatIntervalTimer())}})}.call(this),function(){b=["1","pre2","pre1"],p.SUPPORTED_DDP_VERSIONS=b,y=function(e){var t=this;this.isSimulation=e.isSimulation,this._unblock=e.unblock||function(){},this._calledUnblock=!1,this.userId=e.userId,this._setUserId=e.setUserId||function(){},this.connection=e.connection,this.randomSeed=e.randomSeed,this.randomStream=null},a.extend(y.prototype,{unblock:function(){var e=this;e._calledUnblock=!0,e._unblock()},setUserId:function(e){var t=this;if(t._calledUnblock)throw new Error("Can't call setUserId in a method after calling unblock");t.userId=e,t._setUserId(e)}}),w=function(t){try{var n=i.parse(t)}catch(r){return e._debug("Discarding message with invalid JSON",t),null}return null===n||"object"!=typeof n?(e._debug("Discarding non-object DDP message",t),null):(a.has(n,"cleared")&&(a.has(n,"fields")||(n.fields={}),a.each(n.cleared,function(e){n.fields[e]=void 0}),delete n.cleared),a.each(["fields","params","result"],function(e){a.has(n,e)&&(n[e]=o._adjustTypesFromJSONValue(n[e]))}),n)},k=function(e){var t=o.clone(e);if(a.has(e,"fields")){var n=[];a.each(e.fields,function(e,r){void 0===e&&(n.push(r),delete t.fields[r])}),a.isEmpty(n)||(t.cleared=n),a.isEmpty(t.fields)&&delete t.fields}if(a.each(["fields","params","result"],function(e){a.has(t,e)&&(t[e]=o._adjustTypesToJSONValue(t[e]))}),e.id&&"string"!=typeof e.id)throw new Error("Message id is not a string");return i.stringify(t)},_._CurrentInvocation=new e.EnvironmentVariable}.call(this),function(){function e(){return r.hexString(20)}S=function(t){var n=this;this.seed=[].concat(t.seed||e()),this.sequences={}},S.get=function(e,t){if(t||(t="default"),!e)return r;var n=e.randomStream;return n||(e.randomStream=n=new S({seed:e.randomSeed})),n._sequence(t)},_.randomStream=function(e){var t=_._CurrentInvocation.get();return S.get(t,e)},C=function(e,t){var n=S.get(e,"/rpc/"+t);return n.hexString(20)},a.extend(S.prototype,{_sequence:function(e){var t=this,n=t.sequences[e]||null;if(null===n){for(var o=t.seed.concat(e),i=0;i<o.length;i++)a.isFunction(o[i])&&(o[i]=o[i]());t.sequences[e]=n=r.createWithSeeds.apply(null,o)}return n}})}.call(this),function(){if(e.isServer)var t=Npm.require("path"),n=Npm.require("fibers"),u=Npm.require(t.join("fibers","future"));var c=function(t,n){var r=this;n=a.extend({onConnected:function(){},onDDPVersionNegotiationFailure:function(t){e._debug(t)},heartbeatInterval:35e3,heartbeatTimeout:15e3,reloadWithOutstanding:!1,supportedDDPVersions:b,retry:!0,respondToPings:!0},n),r.onReconnect=null,r._stream="object"==typeof t?t:new p.ClientStream(t,{retry:n.retry,headers:n.headers,_sockjsOptions:n._sockjsOptions,_dontPrintErrors:n._dontPrintErrors,connectTimeoutMs:n.connectTimeoutMs}),r._lastSessionId=null,r._versionSuggestion=null,r._version=null,r._stores={},r._methodHandlers={},r._nextMethodId=1,r._supportedDDPVersions=n.supportedDDPVersions,r._heartbeatInterval=n.heartbeatInterval,r._heartbeatTimeout=n.heartbeatTimeout,r._methodInvokers={},r._outstandingMethodBlocks=[],r._documentsWrittenByStub={},r._serverDocuments={},r._afterUpdateCallbacks=[],r._messagesBufferedUntilQuiescence=[],r._methodsBlockingQuiescence={},r._subsBeingRevived={},r._resetStores=!1,r._updatesForUnknownStores={},r._retryMigrate=null,r._subscriptions={},r._userId=null,r._userIdDeps=new s.Dependency,e.isClient&&Package.reload&&!n.reloadWithOutstanding&&Package.reload.Reload._onMigrate(function(e){if(r._readyToMigrate())return[!0];if(r._retryMigrate)throw new Error("Two migrations in progress?");return r._retryMigrate=e,!1});var o=function(t){try{var o=w(t)}catch(i){return void e._debug("Exception while parsing DDP",i)}if(null===o||!o.msg)return void(o&&o.server_id||e._debug("discarding invalid livedata message",o));if("connected"===o.msg)r._version=r._versionSuggestion,r._livedata_connected(o),n.onConnected();else if("failed"==o.msg)if(a.contains(r._supportedDDPVersions,o.version))r._versionSuggestion=o.version,r._stream.reconnect({_force:!0});else{var s="DDP version negotiation failed; server requested version "+o.version;r._stream.disconnect({_permanent:!0,_error:s}),n.onDDPVersionNegotiationFailure(s)}else"ping"===o.msg?(n.respondToPings&&r._send({msg:"pong",id:o.id}),r._heartbeat&&r._heartbeat.pingReceived()):"pong"===o.msg?r._heartbeat&&r._heartbeat.pongReceived():a.include(["added","changed","removed","ready","updated"],o.msg)?r._livedata_data(o):"nosub"===o.msg?r._livedata_nosub(o):"result"===o.msg?r._livedata_result(o):"error"===o.msg?r._livedata_error(o):e._debug("discarding unknown livedata message type",o)},i=function(){var e={msg:"connect"};r._lastSessionId&&(e.session=r._lastSessionId),e.version=r._versionSuggestion||r._supportedDDPVersions[0],r._versionSuggestion=e.version,e.support=r._supportedDDPVersions,r._send(e),!a.isEmpty(r._outstandingMethodBlocks)&&a.isEmpty(r._outstandingMethodBlocks[0].methods)&&r._outstandingMethodBlocks.shift(),a.each(r._methodInvokers,function(e){e.sentMessage=!1}),r.onReconnect?r._callOnReconnectAndSendAppropriateOutstandingMethods():r._sendOutstandingMethods(),a.each(r._subscriptions,function(e,t){r._send({msg:"sub",id:t,name:e.name,params:e.params})})},u=function(){r._heartbeat&&(r._heartbeat.stop(),r._heartbeat=null)};e.isServer?(r._stream.on("message",e.bindEnvironment(o,e._debug)),r._stream.on("reset",e.bindEnvironment(i,e._debug)),r._stream.on("disconnect",e.bindEnvironment(u,e._debug))):(r._stream.on("message",o),r._stream.on("reset",i),r._stream.on("disconnect",u))},l=function(e){var t=this;t.methodId=e.methodId,t.sentMessage=!1,t._callback=e.callback,t._connection=e.connection,t._message=e.message,t._onResultReceived=e.onResultReceived||function(){},t._wait=e.wait,t._methodResult=null,t._dataVisible=!1,t._connection._methodInvokers[t.methodId]=t};a.extend(l.prototype,{sendMessage:function(){var e=this;if(e.gotResult())throw new Error("sendingMethod is called on method with result");e._dataVisible=!1,e.sentMessage=!0,e._wait&&(e._connection._methodsBlockingQuiescence[e.methodId]=!0),e._connection._send(e._message)},_maybeInvokeCallback:function(){var e=this;e._methodResult&&e._dataVisible&&(e._callback(e._methodResult[0],e._methodResult[1]),delete e._connection._methodInvokers[e.methodId],e._connection._outstandingMethodFinished())},receiveResult:function(e,t){var n=this;if(n.gotResult())throw new Error("Methods should only receive results once");n._methodResult=[e,t],n._onResultReceived(e,t),n._maybeInvokeCallback()},dataVisible:function(){var e=this;e._dataVisible=!0,e._maybeInvokeCallback()},gotResult:function(){var e=this;return!!e._methodResult}}),a.extend(c.prototype,{registerStore:function(e,t){var n=this;if(e in n._stores)return!1;var r={};a.each(["update","beginUpdate","endUpdate","saveOriginals","retrieveOriginals"],function(e){r[e]=function(){return t[e]?t[e].apply(t,arguments):void 0}}),n._stores[e]=r;var o=n._updatesForUnknownStores[e];return o&&(r.beginUpdate(o.length,!1),a.each(o,function(e){r.update(e)}),r.endUpdate(),delete n._updatesForUnknownStores[e]),!0},subscribe:function(e){var t=this,n=Array.prototype.slice.call(arguments,1),i={};if(n.length){var u=n[n.length-1];"function"==typeof u?i.onReady=n.pop():!u||"function"!=typeof u.onReady&&"function"!=typeof u.onError||(i=n.pop())}var c=a.find(t._subscriptions,function(t){return t.inactive&&t.name===e&&o.equals(t.params,n)}),l;c?(l=c.id,c.inactive=!1,i.onReady&&(c.ready||(c.readyCallback=i.onReady)),i.onError&&(c.errorCallback=i.onError)):(l=r.id(),t._subscriptions[l]={id:l,name:e,params:o.clone(n),inactive:!1,ready:!1,readyDeps:new s.Dependency,readyCallback:i.onReady,errorCallback:i.onError,connection:t,remove:function(){delete this.connection._subscriptions[this.id],this.ready&&this.readyDeps.changed()},stop:function(){this.connection._send({msg:"unsub",id:l}),this.remove()}},t._send({msg:"sub",id:l,name:e,params:n}));var d={stop:function(){a.has(t._subscriptions,l)&&t._subscriptions[l].stop()},ready:function(){if(!a.has(t._subscriptions,l))return!1;var e=t._subscriptions[l];return e.readyDeps.depend(),e.ready}};return s.active&&s.onInvalidate(function(e){a.has(t._subscriptions,l)&&(t._subscriptions[l].inactive=!0),s.afterFlush(function(){a.has(t._subscriptions,l)&&t._subscriptions[l].inactive&&d.stop()})}),d},_subscribeAndWait:function(e,t,n){var r=this,o=new u,i=!1,a;return t=t||[],t.push({onReady:function(){i=!0,o["return"]()},onError:function(e){i?n&&n.onLateError&&n.onLateError(e):o["throw"](e)}}),a=r.subscribe.apply(r,[e].concat(t)),o.wait(),a},methods:function(e){var t=this;a.each(e,function(e,n){if(t._methodHandlers[n])throw new Error("A method named '"+n+"' is already defined");t._methodHandlers[n]=e})},call:function(e){var t=Array.prototype.slice.call(arguments,1);if(t.length&&"function"==typeof t[t.length-1])var n=t.pop();return this.apply(e,t,n)},apply:function(t,n,r,i){var s=this;i||"function"!=typeof r||(i=r,r={}),r=r||{},i&&(i=e.bindEnvironment(i,"delivering result of invoking '"+t+"'")),n=o.clone(n);var c=function(){var e;return function(){return void 0===e&&(e=""+s._nextMethodId++),e}}(),d=_._CurrentInvocation.get(),f=d&&d.isSimulation,p=null,h=function(){return null===p&&(p=C(d,t)),p},v=s._methodHandlers[t];if(v){var m=function(e){s.setUserId(e)},g=new y({isSimulation:!0,userId:s.userId(),setUserId:m,randomSeed:function(){return h()}});f||s._saveOriginals();try{var b=_._CurrentInvocation.withValue(g,function(){return e.isServer?e._noYieldsAllowed(function(){return v.apply(g,o.clone(n))}):v.apply(g,o.clone(n))})}catch(w){var k=w}f||s._retrieveAndStoreOriginals(c())}if(f){if(i)return void i(k,b);if(k)throw k;return b}if(k&&!k.expected&&e._debug("Exception while simulating the effect of invoking '"+t+"'",k,k.stack),!i)if(e.isClient)i=function(n){n&&e._debug("Error invoking Method '"+t+"':",n.message)};else{var S=new u;i=S.resolver()}var T={msg:"method",method:t,params:n,id:c()};null!==p&&(T.randomSeed=p);var E=new l({methodId:c(),callback:i,connection:s,onResultReceived:r.onResultReceived,wait:!!r.wait,message:T});return r.wait?s._outstandingMethodBlocks.push({wait:!0,methods:[E]}):((a.isEmpty(s._outstandingMethodBlocks)||a.last(s._outstandingMethodBlocks).wait)&&s._outstandingMethodBlocks.push({wait:!1,methods:[]}),a.last(s._outstandingMethodBlocks).methods.push(E)),1===s._outstandingMethodBlocks.length&&E.sendMessage(),S?S.wait():r.returnStubValue?b:void 0},_saveOriginals:function(){var e=this;a.each(e._stores,function(e){e.saveOriginals()})},_retrieveAndStoreOriginals:function(e){var t=this;if(t._documentsWrittenByStub[e])throw new Error("Duplicate methodId in _retrieveAndStoreOriginals");var n=[];a.each(t._stores,function(r,o){var i=r.retrieveOriginals();i&&i.forEach(function(r,i){n.push({collection:o,id:i}),a.has(t._serverDocuments,o)||(t._serverDocuments[o]=new d._IdMap);var s=t._serverDocuments[o].setDefault(i,{});s.writtenByStubs?s.writtenByStubs[e]=!0:(s.document=r,s.flushCallbacks=[],s.writtenByStubs={},s.writtenByStubs[e]=!0)})}),a.isEmpty(n)||(t._documentsWrittenByStub[e]=n)},_unsubscribeAll:function(){var e=this;a.each(a.clone(e._subscriptions),function(t,n){"meteor_autoupdate_clientVersions"!==t.name&&e._subscriptions[n].stop()})},_send:function(e){var t=this;t._stream.send(k(e))},_lostConnection:function(e){var t=this;t._stream._lostConnection(e)},status:function(){var e=this;return e._stream.status.apply(e._stream,arguments)},reconnect:function(){var e=this;return e._stream.reconnect.apply(e._stream,arguments)},disconnect:function(){var e=this;return e._stream.disconnect.apply(e._stream,arguments)},close:function(){var e=this;return e._stream.disconnect({_permanent:!0})},userId:function(){var e=this;return e._userIdDeps&&e._userIdDeps.depend(),e._userId},setUserId:function(e){var t=this;t._userId!==e&&(t._userId=e,t._userIdDeps&&t._userIdDeps.changed())},_waitingForQuiescence:function(){var e=this;return!a.isEmpty(e._subsBeingRevived)||!a.isEmpty(e._methodsBlockingQuiescence)},_anyMethodsAreOutstanding:function(){var e=this;return a.any(a.pluck(e._methodInvokers,"sentMessage"))},_livedata_connected:function(e){var t=this;if("pre1"!==t._version&&0!==t._heartbeatInterval&&(t._heartbeat=new g({heartbeatInterval:t._heartbeatInterval,heartbeatTimeout:t._heartbeatTimeout,onTimeout:function(){t._lostConnection(new _.ConnectionError("DDP heartbeat timed out"))},sendPing:function(){t._send({msg:"ping"})}}),t._heartbeat.start()),t._lastSessionId&&(t._resetStores=!0),"string"==typeof e.session){var n=t._lastSessionId===e.session;t._lastSessionId=e.session}n||(t._updatesForUnknownStores={},t._resetStores&&(t._documentsWrittenByStub={},t._serverDocuments={}),t._afterUpdateCallbacks=[],t._subsBeingRevived={},a.each(t._subscriptions,function(e,n){e.ready&&(t._subsBeingRevived[n]=!0)}),t._methodsBlockingQuiescence={},t._resetStores&&a.each(t._methodInvokers,function(e){e.gotResult()?t._afterUpdateCallbacks.push(a.bind(e.dataVisible,e)):e.sentMessage&&(t._methodsBlockingQuiescence[e.methodId]=!0)}),t._messagesBufferedUntilQuiescence=[],t._waitingForQuiescence()||(t._resetStores&&(a.each(t._stores,function(e){e.beginUpdate(0,!0),e.endUpdate()}),t._resetStores=!1),t._runAfterUpdateCallbacks()))},_processOneDataMessage:function(e,t){var n=this;n["_process_"+e.msg](e,t)},_livedata_data:function(e){var t=this,n={};if(t._waitingForQuiescence()){if(t._messagesBufferedUntilQuiescence.push(e),"nosub"===e.msg&&delete t._subsBeingRevived[e.id],a.each(e.subs||[],function(e){delete t._subsBeingRevived[e]}),a.each(e.methods||[],function(e){delete t._methodsBlockingQuiescence[e]}),t._waitingForQuiescence())return;a.each(t._messagesBufferedUntilQuiescence,function(e){t._processOneDataMessage(e,n)}),t._messagesBufferedUntilQuiescence=[]}else t._processOneDataMessage(e,n);(t._resetStores||!a.isEmpty(n))&&(a.each(t._stores,function(e,r){e.beginUpdate(a.has(n,r)?n[r].length:0,t._resetStores)}),t._resetStores=!1,a.each(n,function(e,n){var r=t._stores[n];r?a.each(e,function(e){r.update(e)}):(a.has(t._updatesForUnknownStores,n)||(t._updatesForUnknownStores[n]=[]),Array.prototype.push.apply(t._updatesForUnknownStores[n],e))}),a.each(t._stores,function(e){e.endUpdate()})),t._runAfterUpdateCallbacks()},_runAfterUpdateCallbacks:function(){var e=this,t=e._afterUpdateCallbacks;e._afterUpdateCallbacks=[],a.each(t,function(e){e()})},_pushUpdate:function(e,t,n){var r=this;a.has(e,t)||(e[t]=[]),e[t].push(n)},_getServerDoc:function(e,t){var n=this;if(!a.has(n._serverDocuments,e))return null;var r=n._serverDocuments[e];return r.get(t)||null},_process_added:function(e,t){var n=this,r=d._idParse(e.id),o=n._getServerDoc(e.collection,r);if(o){if(void 0!==o.document)throw new Error("Server sent add for existing id: "+e.id);o.document=e.fields||{},o.document._id=r}else n._pushUpdate(t,e.collection,e)},_process_changed:function(e,t){var n=this,r=n._getServerDoc(e.collection,d._idParse(e.id));if(r){if(void 0===r.document)throw new Error("Server sent changed for nonexisting id: "+e.id);d._applyChanges(r.document,e.fields)}else n._pushUpdate(t,e.collection,e)},_process_removed:function(e,t){var n=this,r=n._getServerDoc(e.collection,d._idParse(e.id));if(r){if(void 0===r.document)throw new Error("Server sent removed for nonexisting id:"+e.id);r.document=void 0}else n._pushUpdate(t,e.collection,{msg:"removed",collection:e.collection,id:e.id})},_process_updated:function(e,t){var n=this;a.each(e.methods,function(e){a.each(n._documentsWrittenByStub[e],function(r){var o=n._getServerDoc(r.collection,r.id);if(!o)throw new Error("Lost serverDoc for "+i.stringify(r));if(!o.writtenByStubs[e])throw new Error("Doc "+i.stringify(r)+" not written by method "+e);delete o.writtenByStubs[e],a.isEmpty(o.writtenByStubs)&&(n._pushUpdate(t,r.collection,{msg:"replace",id:d._idStringify(r.id),replace:o.document}),a.each(o.flushCallbacks,function(e){e()}),n._serverDocuments[r.collection].remove(r.id))}),delete n._documentsWrittenByStub[e];var r=n._methodInvokers[e];if(!r)throw new Error("No callback invoker for method "+e);n._runWhenAllServerDocsAreFlushed(a.bind(r.dataVisible,r))})},_process_ready:function(e,t){var n=this;a.each(e.subs,function(e){n._runWhenAllServerDocsAreFlushed(function(){var t=n._subscriptions[e];t&&(t.ready||(t.readyCallback&&t.readyCallback(),t.ready=!0,t.readyDeps.changed()))})})},_runWhenAllServerDocsAreFlushed:function(e){var t=this,n=function(){t._afterUpdateCallbacks.push(e)},r=0,o=function(){--r,0===r&&n()};a.each(t._serverDocuments,function(e){e.forEach(function(e){var n=a.any(e.writtenByStubs,function(e,n){var r=t._methodInvokers[n];return r&&r.sentMessage});n&&(++r,e.flushCallbacks.push(o))})}),0===r&&n()},_livedata_nosub:function(t){var n=this;if(n._livedata_data(t),a.has(n._subscriptions,t.id)){var r=n._subscriptions[t.id].errorCallback;n._subscriptions[t.id].remove(),r&&t.error&&r(new e.Error(t.error.error,t.error.reason,t.error.details))}},_process_nosub:function(){},_livedata_result:function(t){var n=this;if(a.isEmpty(n._outstandingMethodBlocks))return void e._debug("Received method result but no methods outstanding");for(var r=n._outstandingMethodBlocks[0].methods,o,i=0;i<r.length&&(o=r[i],o.methodId!==t.id);i++);return o?(r.splice(i,1),void(a.has(t,"error")?o.receiveResult(new e.Error(t.error.error,t.error.reason,t.error.details)):o.receiveResult(void 0,t.result))):void e._debug("Can't match method response to original method call",t)},_outstandingMethodFinished:function(){var e=this;if(!e._anyMethodsAreOutstanding()){if(!a.isEmpty(e._outstandingMethodBlocks)){var t=e._outstandingMethodBlocks.shift();if(!a.isEmpty(t.methods))throw new Error("No methods outstanding but nonempty block: "+i.stringify(t));a.isEmpty(e._outstandingMethodBlocks)||e._sendOutstandingMethods()}e._maybeMigrate()}},_sendOutstandingMethods:function(){var e=this;a.isEmpty(e._outstandingMethodBlocks)||a.each(e._outstandingMethodBlocks[0].methods,function(e){e.sendMessage()})},_livedata_error:function(t){e._debug("Received error from server: ",t.reason),t.offendingMessage&&e._debug("For: ",t.offendingMessage)},_callOnReconnectAndSendAppropriateOutstandingMethods:function(){var e=this,t=e._outstandingMethodBlocks;if(e._outstandingMethodBlocks=[],e.onReconnect(),!a.isEmpty(t)){if(a.isEmpty(e._outstandingMethodBlocks))return e._outstandingMethodBlocks=t,void e._sendOutstandingMethods();a.last(e._outstandingMethodBlocks).wait||t[0].wait||(a.each(t[0].methods,function(t){a.last(e._outstandingMethodBlocks).methods.push(t),1===e._outstandingMethodBlocks.length&&t.sendMessage()}),t.shift()),a.each(t,function(t){e._outstandingMethodBlocks.push(t)})}},_readyToMigrate:function(){var e=this;return a.isEmpty(e._methodInvokers)},_maybeMigrate:function(){var e=this;e._retryMigrate&&e._readyToMigrate()&&(e._retryMigrate(),e._retryMigrate=null)}}),p.Connection=c,_.connect=function(e,t){var n=new c(e,t);return T.push(n),n},T=[],_._allSubscriptionsReady=function(){return a.all(T,function(e){return a.all(e._subscriptions,function(e){return e.ready})})}}.call(this),function(){if(e.refresh=function(e){},e.isClient){var t="/";"undefined"!=typeof __meteor_runtime_config__&&__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL&&(t=__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL);var n=new l,r=function(t){if(e._debug(t),Package.reload){var r=Package.reload.Reload._migrationData("livedata")||{},o=r.DDPVersionNegotiationFailures||0;++o,Package.reload.Reload._onMigrate("livedata",function(){return[!0,{DDPVersionNegotiationFailures:o}]}),n.retryLater(o,function(){Package.reload.Reload._reload()})}};e.connection=_.connect(t,{onDDPVersionNegotiationFailure:r}),a.each(["subscribe","methods","call","apply","status","reconnect","disconnect"],function(t){e[t]=a.bind(e.connection[t],e.connection)})}else e.connection=null;e.default_connection=e.connection,e.connect=_.connect}.call(this),"undefined"==typeof Package&&(Package={}),Package.ddp={DDP:_,LivedataTest:p}}();
+
+!function(){var e=Package.meteor.Meteor,a=Package.logging.Log,g=Package.underscore._,o=Package.ddp.DDP,c=Package.ejson.EJSON,P;"undefined"==typeof Package&&(Package={}),Package["follower-livedata"]={Follower:P}}();
+
+!function(){var a=Package.meteor.Meteor,e=Package.logging.Log,o=Package.underscore._,g=Package.ddp.DDP,c=Package.ejson.EJSON,n=Package["follower-livedata"].Follower;"undefined"==typeof Package&&(Package={}),Package["application-configuration"]={}}();
+
+!function(){var e=Package.meteor.Meteor,n=Package.random.Random,o=Package.ejson.EJSON,t=Package.json.JSON,r=Package.underscore._,i=Package.minimongo.LocalCollection,c=Package.minimongo.Minimongo,l=Package.logging.Log,a=Package.ddp.DDP,s=Package.tracker.Tracker,d=Package.tracker.Deps,u=Package.check.check,f=Package.check.Match,_,p;(function(){p=function(){var e=this;e.noConnCollections={}};var e=function(e,n){return e in n||(n[e]=new i(e)),n[e]};r.extend(p.prototype,{open:function(n,o){var t=this;return n?o?(o._mongo_livedata_collections||(o._mongo_livedata_collections={}),e(n,o._mongo_livedata_collections)):e(n,t.noConnCollections):new i}}),p=new p}).call(this),function(){_={},_.Collection=function(o,t){var c=this;if(!(c instanceof _.Collection))throw new Error('use "new" to construct a Mongo.Collection');if(o||null===o||(e._debug("Warning: creating anonymous collection. It will not be saved or synchronized over the network. (Pass null for the collection name to turn off this warning.)"),o=null),null!==o&&"string"!=typeof o)throw new Error("First argument to new Mongo.Collection must be a string or null");switch(t&&t.methods&&(t={connection:t}),t&&t.manager&&!t.connection&&(t.connection=t.manager),t=r.extend({connection:void 0,idGeneration:"STRING",transform:null,_driver:void 0,_preventAutopublish:!1},t),t.idGeneration){case"MONGO":c._makeNewID=function(){var e=o?a.randomStream("/collection/"+o):n;return new _.ObjectID(e.hexString(24))};break;case"STRING":default:c._makeNewID=function(){var e=o?a.randomStream("/collection/"+o):n;return e.id()}}if(c._transform=i.wrapTransform(t.transform),c._connection=o&&null!==t.connection?t.connection?t.connection:e.isClient?e.connection:e.server:null,t._driver||(t._driver=o&&c._connection===e.server&&"undefined"!=typeof MongoInternals&&MongoInternals.defaultRemoteCollectionDriver?MongoInternals.defaultRemoteCollectionDriver():p),c._collection=t._driver.open(o,c._connection),c._name=o,c._connection&&c._connection.registerStore){var l=c._connection.registerStore(o,{beginUpdate:function(e,n){(e>1||n)&&c._collection.pauseObservers(),n&&c._collection.remove({})},update:function(e){var n=i._idParse(e.id),o=c._collection.findOne(n);if("replace"===e.msg){var t=e.replace;return void(t?o?c._collection.update(n,t):c._collection.insert(t):o&&c._collection.remove(n))}if("added"===e.msg){if(o)throw new Error("Expected not to find a document already present for an add");c._collection.insert(r.extend({_id:n},e.fields))}else if("removed"===e.msg){if(!o)throw new Error("Expected to find a document already present for removed");c._collection.remove(n)}else{if("changed"!==e.msg)throw new Error("I don't know how to deal with this message");if(!o)throw new Error("Expected to find a document to change");if(!r.isEmpty(e.fields)){var l={};r.each(e.fields,function(e,n){void 0===e?(l.$unset||(l.$unset={}),l.$unset[n]=1):(l.$set||(l.$set={}),l.$set[n]=e)}),c._collection.update(n,l)}}},endUpdate:function(){c._collection.resumeObservers()},saveOriginals:function(){c._collection.saveOriginals()},retrieveOriginals:function(){return c._collection.retrieveOriginals()}});if(!l)throw new Error("There is already a collection named '"+o+"'")}c._defineMutationMethods(),Package.autopublish&&!t._preventAutopublish&&c._connection&&c._connection.publish&&c._connection.publish(null,function(){return c.find()},{is_auto:!0})},r.extend(_.Collection.prototype,{_getFindSelector:function(e){return 0==e.length?{}:e[0]},_getFindOptions:function(e){var n=this;return e.length<2?{transform:n._transform}:(u(e[1],f.Optional(f.ObjectIncluding({fields:f.Optional(f.OneOf(Object,void 0)),sort:f.Optional(f.OneOf(Object,Array,void 0)),limit:f.Optional(f.OneOf(Number,void 0)),skip:f.Optional(f.OneOf(Number,void 0))}))),r.extend({transform:n._transform},e[1]))},find:function(){var e=this,n=r.toArray(arguments);return e._collection.find(e._getFindSelector(n),e._getFindOptions(n))},findOne:function(){var e=this,n=r.toArray(arguments);return e._collection.findOne(e._getFindSelector(n),e._getFindOptions(n))}}),_.Collection._publishCursor=function(e,n,o){var t=e.observeChanges({added:function(e,t){n.added(o,e,t)},changed:function(e,t){n.changed(o,e,t)},removed:function(e){n.removed(o,e)}});n.onStop(function(){t.stop()})},_.Collection._rewriteSelector=function(e){if(i._selectorIsId(e)&&(e={_id:e}),!e||"_id"in e&&!e._id)return{_id:n.id()};var o={};return r.each(e,function(e,n){e instanceof RegExp?o[n]=t(e):e&&e.$regex instanceof RegExp?(o[n]=t(e.$regex),void 0!==e.$options&&(o[n].$options=e.$options)):o[n]=r.contains(["$or","$and","$nor"],n)?r.map(e,function(e){return _.Collection._rewriteSelector(e)}):e}),o};var t=function(e){u(e,RegExp);var n={$regex:e.source},o="";return e.ignoreCase&&(o+="i"),e.multiline&&(o+="m"),o&&(n.$options=o),n},c=function(n,o){if(!i._selectorIsIdPerhapsAsObject(n))throw new e.Error(403,"Not permitted. Untrusted code may only "+o+" documents by ID.")};r.each(["insert","update","remove"],function(n){_.Collection.prototype[n]=function(){var o=this,t=r.toArray(arguments),i,l,s;if(t.length&&(void 0===t[t.length-1]||t[t.length-1]instanceof Function)&&(i=t.pop()),"insert"===n){if(!t.length)throw new Error("insert requires an argument");if(t[0]=r.extend({},t[0]),"_id"in t[0]){if(l=t[0]._id,!l||!("string"==typeof l||l instanceof _.ObjectID))throw new Error("Meteor requires document _id fields to be non-empty strings or ObjectIDs")}else{var d=!0;if(o._connection&&o._connection!==e.server){var u=a._CurrentInvocation.get();u||(d=!1)}d&&(l=t[0]._id=o._makeNewID())}}else if(t[0]=_.Collection._rewriteSelector(t[0]),"update"===n){var f=t[2]=r.clone(t[2])||{};if(f&&"function"!=typeof f&&f.upsert)if(f.insertedId){if(!("string"==typeof f.insertedId||f.insertedId instanceof _.ObjectID))throw new Error("insertedId must be string or ObjectID")}else f.insertedId=o._makeNewID()}var p=function(e){return"insert"===n?(!l&&e&&(l=e),l):e},h;if(i&&(h=function(e,n){i(e,!e&&p(n))}),o._connection&&o._connection!==e.server){var u=a._CurrentInvocation.get(),v=u&&u.isSimulation;!e.isClient||h||v||(h=function(o){o&&e._debug(n+" failed: "+(o.reason||o.stack))}),v||"insert"===n||c(t[0],n),s=p(o._connection.apply(o._prefix+n,t,{returnStubValue:!0},h))}else{t.push(h);try{var m=o._collection[n].apply(o._collection,t);s=p(m)}catch(g){if(i)return i(g),null;throw g}}return s}}),_.Collection.prototype.upsert=function(e,n,o,t){var i=this;return t||"function"!=typeof o||(t=o,o={}),i.update(e,n,r.extend({},o,{_returnObject:!0,upsert:!0}),t)},_.Collection.prototype._ensureIndex=function(e,n){var o=this;if(!o._collection._ensureIndex)throw new Error("Can only call _ensureIndex on server collections");o._collection._ensureIndex(e,n)},_.Collection.prototype._dropIndex=function(e){var n=this;if(!n._collection._dropIndex)throw new Error("Can only call _dropIndex on server collections");n._collection._dropIndex(e)},_.Collection.prototype._dropCollection=function(){var e=this;if(!e._collection.dropCollection)throw new Error("Can only call _dropCollection on server collections");e._collection.dropCollection()},_.Collection.prototype._createCappedCollection=function(e,n){var o=this;if(!o._collection._createCappedCollection)throw new Error("Can only call _createCappedCollection on server collections");o._collection._createCappedCollection(e,n)},_.ObjectID=i._ObjectID,_.Cursor=i.Cursor,_.Collection.Cursor=_.Cursor,_.Collection.ObjectID=_.ObjectID,function(){var e=function(e,n){var o=["insert","update","remove","fetch","transform"];r.each(r.keys(n),function(n){if(!r.contains(o,n))throw new Error(e+": Invalid key: "+n)});var t=this;if(t._restricted=!0,r.each(["insert","update","remove"],function(o){if(n[o]){if(!(n[o]instanceof Function))throw new Error(e+": Value for `"+o+"` must be a function");n[o].transform=void 0===n.transform?t._transform:i.wrapTransform(n.transform),t._validators[o][e].push(n[o])}}),n.update||n.remove||n.fetch){if(n.fetch&&!(n.fetch instanceof Array))throw new Error(e+": Value for `fetch` must be an array");t._updateFetch(n.fetch)}};_.Collection.prototype.allow=function(n){e.call(this,"allow",n)},_.Collection.prototype.deny=function(n){e.call(this,"deny",n)}}(),_.Collection.prototype._defineMutationMethods=function(){var n=this;if(n._restricted=!1,n._insecure=void 0,n._validators={insert:{allow:[],deny:[]},update:{allow:[],deny:[]},remove:{allow:[],deny:[]},upsert:{allow:[],deny:[]},fetch:[],fetchAllFields:!1},n._name&&(n._prefix="/"+n._name+"/",n._connection)){var o={};r.each(["insert","update","remove"],function(t){o[n._prefix+t]=function(){u(arguments,[f.Any]);var o=r.toArray(arguments);try{var i=null;if("insert"!==t||r.has(o[0],"_id")||(i=n._makeNewID()),this.isSimulation)return null!==i&&(o[0]._id=i),n._collection[t].apply(n._collection,o);if("insert"!==t&&c(o[0],t),n._restricted){if(0===n._validators[t].allow.length)throw new e.Error(403,"Access denied. No allow validators set on restricted collection for method '"+t+"'.");var l="_validated"+t.charAt(0).toUpperCase()+t.slice(1);return o.unshift(this.userId),"insert"===t&&o.push(i),n[l].apply(n,o)}if(n._isInsecure())return null!==i&&(o[0]._id=i),n._collection[t].apply(n._collection,o);throw new e.Error(403,"Access denied")}catch(a){throw"MongoError"===a.name||"MinimongoError"===a.name?new e.Error(409,a.toString()):a}}}),(e.isClient||n._connection===e.server)&&n._connection.methods(o)}},_.Collection.prototype._updateFetch=function(e){var n=this;n._validators.fetchAllFields||(e?n._validators.fetch=r.union(n._validators.fetch,e):(n._validators.fetchAllFields=!0,n._validators.fetch=null))},_.Collection.prototype._isInsecure=function(){var e=this;return void 0===e._insecure?!!Package.insecure:e._insecure};var l=function(e,n,t){var r=n;return e.transform&&(r=o.clone(n),null!==t&&(r._id=t),r=e.transform(r)),r};_.Collection.prototype._validatedInsert=function(n,o,t){var i=this;if(r.any(i._validators.insert.deny,function(e){return e(n,l(e,o,t))}))throw new e.Error(403,"Access denied");if(r.all(i._validators.insert.allow,function(e){return!e(n,l(e,o,t))}))throw new e.Error(403,"Access denied");null!==t&&(o._id=t),i._collection.insert.call(i._collection,o)};var s=function(e,n){return e.transform?e.transform(n):n};_.Collection.prototype._validatedUpdate=function(n,o,t,c){var l=this;if(u(t,Object),c=r.clone(c)||{},!i._selectorIsIdPerhapsAsObject(o))throw new Error("validated update should be of a single ID");if(c.upsert)throw new e.Error(403,"Access denied. Upserts not allowed in a restricted collection.");var a="Access denied. In a restricted collection you can only update documents, not replace them. Use a Mongo update operator, such as '$set'.",f=[];if(r.isEmpty(t))throw new e.Error(403,a);r.each(t,function(n,o){if("$"!==o.charAt(0))throw new e.Error(403,a);if(!r.has(d,o))throw new e.Error(403,"Access denied. Operator "+o+" not allowed in a restricted collection.");r.each(r.keys(n),function(e){-1!==e.indexOf(".")&&(e=e.substring(0,e.indexOf("."))),r.contains(f,e)||f.push(e)})});var _={transform:null};l._validators.fetchAllFields||(_.fields={},r.each(l._validators.fetch,function(e){_.fields[e]=1}));var p=l._collection.findOne(o,_);if(!p)return 0;var h;if(r.any(l._validators.update.deny,function(e){return h||(h=s(e,p)),e(n,h,f,t)}))throw new e.Error(403,"Access denied");if(r.all(l._validators.update.allow,function(e){return h||(h=s(e,p)),!e(n,h,f,t)}))throw new e.Error(403,"Access denied");return c._forbidReplace=!0,l._collection.update.call(l._collection,o,t,c)};var d={$inc:1,$set:1,$unset:1,$addToSet:1,$pop:1,$pullAll:1,$pull:1,$pushAll:1,$push:1,$bit:1};_.Collection.prototype._validatedRemove=function(n,o){var t=this,i={transform:null};t._validators.fetchAllFields||(i.fields={},r.each(t._validators.fetch,function(e){i.fields[e]=1}));var c=t._collection.findOne(o,i);if(!c)return 0;if(r.any(t._validators.remove.deny,function(e){return e(n,s(e,c))}))throw new e.Error(403,"Access denied");if(r.all(t._validators.remove.allow,function(e){return!e(n,s(e,c))}))throw new e.Error(403,"Access denied");return t._collection.remove.call(t._collection,o)},e.Collection=_.Collection}.call(this),"undefined"==typeof Package&&(Package={}),Package.mongo={Mongo:_}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.tracker.Tracker,n=Package.tracker.Deps,a=Package.retry.Retry,r=Package.ddp.DDP,o=Package.mongo.Mongo,i=Package.underscore._,s,c;(function(){var t=__meteor_runtime_config__.autoupdateVersion||"unknown",n=__meteor_runtime_config__.autoupdateVersionRefreshable||"unknown";c=new o.Collection("meteor_autoupdate_clientVersions"),s={},s.newClientAvailable=function(){return!!c.findOne({_id:"version",version:{$ne:t}})||!!c.findOne({_id:"version-refreshable",version:{$ne:n}})};var r=!1,u=new a({minCount:0,baseTimeout:3e4}),l=0;s._retrySubscription=function(){e.subscribe("meteor_autoupdate_clientVersions",{onError:function(t){e._debug("autoupdate subscription failed:",t),l++,u.retryLater(l,function(){s._retrySubscription()})},onReady:function(){if(Package.reload)var a=function(a){var s=this;if("version-refreshable"===a._id&&a.version!==n){n=a.version;var c=a.assets&&a.assets.allCss||[],u=[];i.each(document.getElementsByTagName("link"),function(e){"__meteor-css__"===e.className&&u.push(e)});var l=function(t,n){var a=i.once(n);if(t.onload=function(){r=!0,a()},!r)var o=e.setInterval(function(){t.sheet&&(a(),e.clearInterval(o))},50)},d=i.after(c.length,function(){i.each(u,function(e){e.parentNode.removeChild(e)})}),_=function(t){document.getElementsByTagName("head").item(0).appendChild(t),l(t,function(){e.setTimeout(d,200)})};0!==c.length?i.each(c,function(t){var n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("class","__meteor-css__"),n.setAttribute("href",e._relativeToSiteRootUrl(t.url)),_(n)}):d()}else"version"===a._id&&a.version!==t&&(o&&o.stop(),Package.reload.Reload._reload())},o=c.find().observe({added:a,changed:a})}})},s._retrySubscription()}).call(this),"undefined"==typeof Package&&(Package={}),Package.autoupdate={Autoupdate:s}}();
+
+!function(){var a=Package.meteor.Meteor,e=Package.reload.Reload,o=Package.autoupdate.Autoupdate;"undefined"==typeof Package&&(Package={}),Package["meteor-platform"]={}}();
+
+!function(){var t=Package.meteor.Meteor,e,n;(function(){n={exports:{}}}).call(this),function(){function t(n,i){"use strict";function o(t,e){return function(){return t.apply(e,arguments)}}var r;if(i=i||{},this.trackingClick=!1,this.trackingClickStart=0,this.targetElement=null,this.touchStartX=0,this.touchStartY=0,this.lastTouchIdentifier=0,this.touchBoundary=i.touchBoundary||10,this.layer=n,this.tapDelay=i.tapDelay||200,!t.notNeeded(n)){for(var c=["onMouse","onClick","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel"],s=this,a=0,u=c.length;u>a;a++)s[c[a]]=o(s[c[a]],s);e&&(n.addEventListener("mouseover",this.onMouse,!0),n.addEventListener("mousedown",this.onMouse,!0),n.addEventListener("mouseup",this.onMouse,!0)),n.addEventListener("click",this.onClick,!0),n.addEventListener("touchstart",this.onTouchStart,!1),n.addEventListener("touchmove",this.onTouchMove,!1),n.addEventListener("touchend",this.onTouchEnd,!1),n.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(n.removeEventListener=function(t,e,i){var o=Node.prototype.removeEventListener;"click"===t?o.call(n,t,e.hijacked||e,i):o.call(n,t,e,i)},n.addEventListener=function(t,e,i){var o=Node.prototype.addEventListener;"click"===t?o.call(n,t,e.hijacked||(e.hijacked=function(t){t.propagationStopped||e(t)}),i):o.call(n,t,e,i)}),"function"==typeof n.onclick&&(r=n.onclick,n.addEventListener("click",function(t){r(t)},!1),n.onclick=null)}}var e=navigator.userAgent.indexOf("Android")>0,i=/iP(ad|hone|od)/.test(navigator.userAgent),o=i&&/OS 4_\d(_\d)?/.test(navigator.userAgent),r=i&&/OS ([6-9]|\d{2})_\d/.test(navigator.userAgent),c=navigator.userAgent.indexOf("BB10")>0;t.prototype.needsClick=function(t){"use strict";switch(t.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(t.disabled)return!0;break;case"input":if(i&&"file"===t.type||t.disabled)return!0;break;case"label":case"video":return!0}return/\bneedsclick\b/.test(t.className)},t.prototype.needsFocus=function(t){"use strict";switch(t.nodeName.toLowerCase()){case"textarea":return!0;case"select":return!e;case"input":switch(t.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1}return!t.disabled&&!t.readOnly;default:return/\bneedsfocus\b/.test(t.className)}},t.prototype.sendClick=function(t,e){"use strict";var n,i;document.activeElement&&document.activeElement!==t&&document.activeElement.blur(),i=e.changedTouches[0],n=document.createEvent("MouseEvents"),n.initMouseEvent(this.determineEventType(t),!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null),n.forwardedTouchEvent=!0,t.dispatchEvent(n)},t.prototype.determineEventType=function(t){"use strict";return e&&"select"===t.tagName.toLowerCase()?"mousedown":"click"},t.prototype.focus=function(t){"use strict";var e;i&&t.setSelectionRange&&0!==t.type.indexOf("date")&&"time"!==t.type?(e=t.value.length,t.setSelectionRange(e,e)):t.focus()},t.prototype.updateScrollParent=function(t){"use strict";var e,n;if(e=t.fastClickScrollParent,!e||!e.contains(t)){n=t;do{if(n.scrollHeight>n.offsetHeight){e=n,t.fastClickScrollParent=n;break}n=n.parentElement}while(n)}e&&(e.fastClickLastScrollTop=e.scrollTop)},t.prototype.getTargetElementFromEventTarget=function(t){"use strict";return t.nodeType===Node.TEXT_NODE?t.parentNode:t},t.prototype.onTouchStart=function(t){"use strict";var e,n,r;if(t.targetTouches.length>1)return!0;if(e=this.getTargetElementFromEventTarget(t.target),n=t.targetTouches[0],i){if(r=window.getSelection(),r.rangeCount&&!r.isCollapsed)return!0;if(!o){if(n.identifier&&n.identifier===this.lastTouchIdentifier)return t.preventDefault(),!1;this.lastTouchIdentifier=n.identifier,this.updateScrollParent(e)}}return this.trackingClick=!0,this.trackingClickStart=t.timeStamp,this.targetElement=e,this.touchStartX=n.pageX,this.touchStartY=n.pageY,t.timeStamp-this.lastClickTime<this.tapDelay&&t.preventDefault(),!0},t.prototype.touchHasMoved=function(t){"use strict";var e=t.changedTouches[0],n=this.touchBoundary;return Math.abs(e.pageX-this.touchStartX)>n||Math.abs(e.pageY-this.touchStartY)>n?!0:!1},t.prototype.onTouchMove=function(t){"use strict";return this.trackingClick?((this.targetElement!==this.getTargetElementFromEventTarget(t.target)||this.touchHasMoved(t))&&(this.trackingClick=!1,this.targetElement=null),!0):!0},t.prototype.findControl=function(t){"use strict";return void 0!==t.control?t.control:t.htmlFor?document.getElementById(t.htmlFor):t.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")},t.prototype.onTouchEnd=function(t){"use strict";var n,c,s,a,u,l=this.targetElement;if(!this.trackingClick)return!0;if(t.timeStamp-this.lastClickTime<this.tapDelay)return this.cancelNextClick=!0,!0;if(this.cancelNextClick=!1,this.lastClickTime=t.timeStamp,c=this.trackingClickStart,this.trackingClick=!1,this.trackingClickStart=0,r&&(u=t.changedTouches[0],l=document.elementFromPoint(u.pageX-window.pageXOffset,u.pageY-window.pageYOffset)||l,l.fastClickScrollParent=this.targetElement.fastClickScrollParent),s=l.tagName.toLowerCase(),"label"===s){if(n=this.findControl(l)){if(this.focus(l),e)return!1;l=n}}else if(this.needsFocus(l))return t.timeStamp-c>100||i&&window.top!==window&&"input"===s?(this.targetElement=null,!1):(this.focus(l),this.sendClick(l,t),i&&"select"===s||(this.targetElement=null,t.preventDefault()),!1);return i&&!o&&(a=l.fastClickScrollParent,a&&a.fastClickLastScrollTop!==a.scrollTop)?!0:(this.needsClick(l)||(t.preventDefault(),this.sendClick(l,t)),!1)},t.prototype.onTouchCancel=function(){"use strict";this.trackingClick=!1,this.targetElement=null},t.prototype.onMouse=function(t){"use strict";return this.targetElement?t.forwardedTouchEvent?!0:t.cancelable&&(!this.needsClick(this.targetElement)||this.cancelNextClick)?(t.stopImmediatePropagation?t.stopImmediatePropagation():t.propagationStopped=!0,t.stopPropagation(),t.preventDefault(),!1):!0:!0},t.prototype.onClick=function(t){"use strict";var e;return this.trackingClick?(this.targetElement=null,this.trackingClick=!1,!0):"submit"===t.target.type&&0===t.detail?!0:(e=this.onMouse(t),e||(this.targetElement=null),e)},t.prototype.destroy=function(){"use strict";var t=this.layer;e&&(t.removeEventListener("mouseover",this.onMouse,!0),t.removeEventListener("mousedown",this.onMouse,!0),t.removeEventListener("mouseup",this.onMouse,!0)),t.removeEventListener("click",this.onClick,!0),t.removeEventListener("touchstart",this.onTouchStart,!1),t.removeEventListener("touchmove",this.onTouchMove,!1),t.removeEventListener("touchend",this.onTouchEnd,!1),t.removeEventListener("touchcancel",this.onTouchCancel,!1)},t.notNeeded=function(t){"use strict";var n,i,o;if("undefined"==typeof window.ontouchstart)return!0;if(i=+(/Chrome\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1]){if(!e)return!0;if(n=document.querySelector("meta[name=viewport]")){if(-1!==n.content.indexOf("user-scalable=no"))return!0;if(i>31&&document.documentElement.scrollWidth<=window.outerWidth)return!0}}if(c&&(o=navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/),o[1]>=10&&o[2]>=3&&(n=document.querySelector("meta[name=viewport]")))){if(-1!==n.content.indexOf("user-scalable=no"))return!0;if(document.documentElement.scrollWidth<=window.outerWidth)return!0}return"none"===t.style.msTouchAction?!0:!1},t.attach=function(e,n){"use strict";return new t(e,n)},"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){"use strict";return t}):"undefined"!=typeof n&&n.exports?(n.exports=t.attach,n.exports.FastClick=t):window.FastClick=t}.call(this),function(){e=n.exports.FastClick,t.startup(function(){e.attach(document.body)})}.call(this),"undefined"==typeof Package&&(Package={}),Package.fastclick={FastClick:e}}();
+
+!function(){var e=Package.meteor.Meteor;"undefined"==typeof Package&&(Package={}),Package.less={}}();
+
+!function(){var e=Package.meteor.Meteor,n;(function(){n={},function(e){function n(e,n){var o={};if(t(e)&&e.length>0)for(var r=n?c:i,a=e.split(/;\s/g),u,f,s,g=0,p=a.length;p>g;g++){if(s=a[g].match(/([^=]+)=/i),s instanceof Array)try{u=c(s[1]),f=r(a[g].substring(s[1].length+1))}catch(m){}else u=c(a[g]),f="";u&&(o[u]=f)}return o}function t(e){return"string"==typeof e}function o(e){return t(e)&&""!==e}function r(e){if(!o(e))throw new TypeError("Cookie name must be a non-empty string")}function i(e){return e}var a=e,c=decodeURIComponent,u=encodeURIComponent;a.get=function(e,t){r(e),t="function"==typeof t?{converter:t}:t||{};var o=n(document.cookie,!t.raw);return(t.converter||i)(o[e])},a.set=function(e,n,t){r(e),t=t||{};var i=t.expires,a=t.domain,c=t.path;t.raw||(n=u(String(n)));var f=e+"="+n,s=i;return"number"==typeof s&&(s=new Date,s.setDate(s.getDate()+i)),s instanceof Date&&(f+="; expires="+s.toUTCString()),o(a)&&(f+="; domain="+a),o(c)&&(f+="; path="+c),t.secure&&(f+="; secure"),document.cookie=f,f},a.remove=function(e,n){return n=n||{},n.expires=new Date(0),this.set(e,"",n)}}(n)}).call(this),"undefined"==typeof Package&&(Package={}),Package["chuangbo:cookie"]={Cookie:n}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,a;(function(){(function(e){function t(e,t,a){switch(arguments.length){case 2:return null!=e?e:t;case 3:return null!=e?e:null!=t?t:a;default:throw new Error("Implement me")}}function a(e,t){return wt.call(e,t)}function n(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function _(e){ft.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+e)}function s(e,t){var a=!0;return m(function(){return a&&(_(e),a=!1),t.apply(this,arguments)},t)}function r(e,t){ha[e]||(_(t),ha[e]=!0)}function d(e,t){return function(a){return L(e.call(this,a),t)}}function i(e,t){return function(a){return this.localeData().ordinal(e.call(this,a),t)}}function o(){}function u(e,t){t!==!1&&x(e),M(this,e),this._d=new Date(+e._d)}function l(e){var t=g(e),a=t.year||0,n=t.quarter||0,_=t.month||0,s=t.week||0,r=t.day||0,d=t.hour||0,i=t.minute||0,o=t.second||0,u=t.millisecond||0;this._milliseconds=+u+1e3*o+6e4*i+36e5*d,this._days=+r+7*s,this._months=+_+3*n+12*a,this._data={},this._locale=ft.localeData(),this._bubble()}function m(e,t){for(var n in t)a(t,n)&&(e[n]=t[n]);return a(t,"toString")&&(e.toString=t.toString),a(t,"valueOf")&&(e.valueOf=t.valueOf),e}function M(e,t){var a,n,_;if("undefined"!=typeof t._isAMomentObject&&(e._isAMomentObject=t._isAMomentObject),"undefined"!=typeof t._i&&(e._i=t._i),"undefined"!=typeof t._f&&(e._f=t._f),"undefined"!=typeof t._l&&(e._l=t._l),"undefined"!=typeof t._strict&&(e._strict=t._strict),"undefined"!=typeof t._tzm&&(e._tzm=t._tzm),"undefined"!=typeof t._isUTC&&(e._isUTC=t._isUTC),"undefined"!=typeof t._offset&&(e._offset=t._offset),"undefined"!=typeof t._pf&&(e._pf=t._pf),"undefined"!=typeof t._locale&&(e._locale=t._locale),Ft.length>0)for(a in Ft)n=Ft[a],_=t[n],"undefined"!=typeof _&&(e[n]=_);return e}function c(e){return 0>e?Math.ceil(e):Math.floor(e)}function L(e,t,a){for(var n=""+Math.abs(e),_=e>=0;n.length<t;)n="0"+n;return(_?a?"+":"":"-")+n}function h(e,t){var a={milliseconds:0,months:0};return a.months=t.month()-e.month()+12*(t.year()-e.year()),e.clone().add(a.months,"M").isAfter(t)&&--a.months,a.milliseconds=+t-+e.clone().add(a.months,"M"),a}function Y(e,t){var a;return t=A(t,e),e.isBefore(t)?a=h(e,t):(a=h(t,e),a.milliseconds=-a.milliseconds,a.months=-a.months),a}function y(e,t){return function(a,n){var _,s;return null===n||isNaN(+n)||(r(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period)."),s=a,a=n,n=s),a="string"==typeof a?+a:a,_=ft.duration(a,n),f(this,_,e),this}}function f(e,t,a,n){var _=t._milliseconds,s=t._days,r=t._months;n=null==n?!0:n,_&&e._d.setTime(+e._d+_*a),s&&Mt(e,"Date",mt(e,"Date")+s*a),r&&lt(e,mt(e,"Month")+r*a),n&&ft.updateOffset(e,s||r)}function p(e){return"[object Array]"===Object.prototype.toString.call(e)}function D(e){return"[object Date]"===Object.prototype.toString.call(e)||e instanceof Date}function k(e,t,a){var n,_=Math.min(e.length,t.length),s=Math.abs(e.length-t.length),r=0;for(n=0;_>n;n++)(a&&e[n]!==t[n]||!a&&v(e[n])!==v(t[n]))&&r++;return r+s}function T(e){if(e){var t=e.toLowerCase().replace(/(.)s$/,"$1");e=oa[e]||ua[t]||t}return e}function g(e){var t,n,_={};for(n in e)a(e,n)&&(t=T(n),t&&(_[t]=e[n]));return _}function w(t){var a,n;if(0===t.indexOf("week"))a=7,n="day";else{if(0!==t.indexOf("month"))return;a=12,n="month"}ft[t]=function(_,s){var r,d,i=ft._locale[t],o=[];if("number"==typeof _&&(s=_,_=e),d=function(e){var t=ft().utc().set(n,e);return i.call(ft._locale,t,_||"")},null!=s)return d(s);for(r=0;a>r;r++)o.push(d(r));return o}}function v(e){var t=+e,a=0;return 0!==t&&isFinite(t)&&(a=t>=0?Math.floor(t):Math.ceil(t)),a}function b(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}function S(e,t,a){return dt(ft([e,11,31+t-a]),t,a).week}function j(e){return W(e)?366:365}function W(e){return e%4===0&&e%100!==0||e%400===0}function x(e){var t;e._a&&-2===e._pf.overflow&&(t=e._a[bt]<0||e._a[bt]>11?bt:e._a[St]<1||e._a[St]>b(e._a[vt],e._a[bt])?St:e._a[jt]<0||e._a[jt]>23?jt:e._a[Wt]<0||e._a[Wt]>59?Wt:e._a[xt]<0||e._a[xt]>59?xt:e._a[zt]<0||e._a[zt]>999?zt:-1,e._pf._overflowDayOfYear&&(vt>t||t>St)&&(t=St),e._pf.overflow=t)}function z(e){return null==e._isValid&&(e._isValid=!isNaN(e._d.getTime())&&e._pf.overflow<0&&!e._pf.empty&&!e._pf.invalidMonth&&!e._pf.nullInput&&!e._pf.invalidFormat&&!e._pf.userInvalidated,e._strict&&(e._isValid=e._isValid&&0===e._pf.charsLeftOver&&0===e._pf.unusedTokens.length)),e._isValid}function H(e){return e?e.toLowerCase().replace("_","-"):e}function F(e){for(var t,a,n,_,s=0;s<e.length;){for(_=H(e[s]).split("-"),t=_.length,a=H(e[s+1]),a=a?a.split("-"):null;t>0;){if(n=E(_.slice(0,t).join("-")))return n;if(a&&a.length>=t&&k(_,a,!0)>=t-1)break;t--}s++}return null}function E(e){var t=null;if(!Ht[e]&&Et)try{t=ft.locale(),require("./locale/"+e),ft.locale(t)}catch(a){}return Ht[e]}function A(e,t){return t._isUTC?ft(e).zone(t._offset||0):ft(e).local()}function O(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function J(e){var t,a,n=e.match(Gt);for(t=0,a=n.length;a>t;t++)n[t]=La[n[t]]?La[n[t]]:O(n[t]);return function(_){var s="";for(t=0;a>t;t++)s+=n[t]instanceof Function?n[t].call(_,e):n[t];return s}}function G(e,t){return e.isValid()?(t=P(t,e.localeData()),la[t]||(la[t]=J(t)),la[t](e)):e.localeData().invalidDate()}function P(e,t){function a(e){return t.longDateFormat(e)||e}var n=5;for(Pt.lastIndex=0;n>=0&&Pt.test(e);)e=e.replace(Pt,a),Pt.lastIndex=0,n-=1;return e}function C(e,t){var a,n=t._strict;switch(e){case"Q":return Bt;case"DDDD":return Qt;case"YYYY":case"GGGG":case"gggg":return n?ea:Ut;case"Y":case"G":case"g":return aa;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return n?ta:Nt;case"S":if(n)return Bt;case"SS":if(n)return Xt;case"SSS":if(n)return Qt;case"DDD":return It;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return qt;case"a":case"A":return t._locale._meridiemParse;case"X":return $t;case"Z":case"ZZ":return Zt;case"T":return Kt;case"SSSS":return Vt;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return n?Xt:Ct;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Ct;case"Do":return Rt;default:return a=new RegExp(R($(e.replace("\\","")),"i"))}}function I(e){e=e||"";var t=e.match(Zt)||[],a=t[t.length-1]||[],n=(a+"").match(da)||["-",0,0],_=+(60*n[1])+v(n[2]);return"+"===n[0]?-_:_}function U(e,t,a){var n,_=a._a;switch(e){case"Q":null!=t&&(_[bt]=3*(v(t)-1));break;case"M":case"MM":null!=t&&(_[bt]=v(t)-1);break;case"MMM":case"MMMM":n=a._locale.monthsParse(t),null!=n?_[bt]=n:a._pf.invalidMonth=t;break;case"D":case"DD":null!=t&&(_[St]=v(t));break;case"Do":null!=t&&(_[St]=v(parseInt(t,10)));break;case"DDD":case"DDDD":null!=t&&(a._dayOfYear=v(t));break;case"YY":_[vt]=ft.parseTwoDigitYear(t);break;case"YYYY":case"YYYYY":case"YYYYYY":_[vt]=v(t);break;case"a":case"A":a._isPm=a._locale.isPM(t);break;case"H":case"HH":case"h":case"hh":_[jt]=v(t);break;case"m":case"mm":_[Wt]=v(t);break;case"s":case"ss":_[xt]=v(t);break;case"S":case"SS":case"SSS":case"SSSS":_[zt]=v(1e3*("0."+t));break;case"X":a._d=new Date(1e3*parseFloat(t));break;case"Z":case"ZZ":a._useUTC=!0,a._tzm=I(t);break;case"dd":case"ddd":case"dddd":n=a._locale.weekdaysParse(t),null!=n?(a._w=a._w||{},a._w.d=n):a._pf.invalidWeekday=t;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":e=e.substr(0,1);case"gggg":case"GGGG":case"GGGGG":e=e.substr(0,2),t&&(a._w=a._w||{},a._w[e]=v(t));break;case"gg":case"GG":a._w=a._w||{},a._w[e]=ft.parseTwoDigitYear(t)}}function N(e){var a,n,_,s,r,d,i;a=e._w,null!=a.GG||null!=a.W||null!=a.E?(r=1,d=4,n=t(a.GG,e._a[vt],dt(ft(),1,4).year),_=t(a.W,1),s=t(a.E,1)):(r=e._locale._week.dow,d=e._locale._week.doy,n=t(a.gg,e._a[vt],dt(ft(),r,d).year),_=t(a.w,1),null!=a.d?(s=a.d,r>s&&++_):s=null!=a.e?a.e+r:r),i=it(n,_,s,d,r),e._a[vt]=i.year,e._dayOfYear=i.dayOfYear}function V(e){var a,n,_,s,r=[];if(!e._d){for(_=Z(e),e._w&&null==e._a[St]&&null==e._a[bt]&&N(e),e._dayOfYear&&(s=t(e._a[vt],_[vt]),e._dayOfYear>j(s)&&(e._pf._overflowDayOfYear=!0),n=nt(s,0,e._dayOfYear),e._a[bt]=n.getUTCMonth(),e._a[St]=n.getUTCDate()),a=0;3>a&&null==e._a[a];++a)e._a[a]=r[a]=_[a];for(;7>a;a++)e._a[a]=r[a]=null==e._a[a]?2===a?1:0:e._a[a];e._d=(e._useUTC?nt:at).apply(null,r),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()+e._tzm)}}function q(e){var t;e._d||(t=g(e._i),e._a=[t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond],V(e))}function Z(e){var t=new Date;return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function K(e){if(e._f===ft.ISO_8601)return void X(e);e._a=[],e._pf.empty=!0;var t,a,n,_,s,r=""+e._i,d=r.length,i=0;for(n=P(e._f,e._locale).match(Gt)||[],t=0;t<n.length;t++)_=n[t],a=(r.match(C(_,e))||[])[0],a&&(s=r.substr(0,r.indexOf(a)),s.length>0&&e._pf.unusedInput.push(s),r=r.slice(r.indexOf(a)+a.length),i+=a.length),La[_]?(a?e._pf.empty=!1:e._pf.unusedTokens.push(_),U(_,a,e)):e._strict&&!a&&e._pf.unusedTokens.push(_);e._pf.charsLeftOver=d-i,r.length>0&&e._pf.unusedInput.push(r),e._isPm&&e._a[jt]<12&&(e._a[jt]+=12),e._isPm===!1&&12===e._a[jt]&&(e._a[jt]=0),V(e),x(e)}function $(e){return e.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,a,n,_){return t||a||n||_})}function R(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function B(e){var t,a,_,s,r;if(0===e._f.length)return e._pf.invalidFormat=!0,void(e._d=new Date(0/0));for(s=0;s<e._f.length;s++)r=0,t=M({},e),null!=e._useUTC&&(t._useUTC=e._useUTC),t._pf=n(),t._f=e._f[s],K(t),z(t)&&(r+=t._pf.charsLeftOver,r+=10*t._pf.unusedTokens.length,t._pf.score=r,(null==_||_>r)&&(_=r,a=t));m(e,a||t)}function X(e){var t,a,n=e._i,_=na.exec(n);if(_){for(e._pf.iso=!0,t=0,a=sa.length;a>t;t++)if(sa[t][1].exec(n)){e._f=sa[t][0]+(_[6]||" ");break}for(t=0,a=ra.length;a>t;t++)if(ra[t][1].exec(n)){e._f+=ra[t][0];break}n.match(Zt)&&(e._f+="Z"),K(e)}else e._isValid=!1}function Q(e){X(e),e._isValid===!1&&(delete e._isValid,ft.createFromInputFallback(e))}function et(e,t){var a,n=[];for(a=0;a<e.length;++a)n.push(t(e[a],a));return n}function tt(t){var a,n=t._i;n===e?t._d=new Date:D(n)?t._d=new Date(+n):null!==(a=At.exec(n))?t._d=new Date(+a[1]):"string"==typeof n?Q(t):p(n)?(t._a=et(n.slice(0),function(e){return parseInt(e,10)}),V(t)):"object"==typeof n?q(t):"number"==typeof n?t._d=new Date(n):ft.createFromInputFallback(t)}function at(e,t,a,n,_,s,r){var d=new Date(e,t,a,n,_,s,r);return 1970>e&&d.setFullYear(e),d}function nt(e){var t=new Date(Date.UTC.apply(null,arguments));return 1970>e&&t.setUTCFullYear(e),t}function _t(e,t){if("string"==typeof e)if(isNaN(e)){if(e=t.weekdaysParse(e),"number"!=typeof e)return null}else e=parseInt(e,10);return e}function st(e,t,a,n,_){return _.relativeTime(t||1,!!a,e,n)}function rt(e,t,a){var n=ft.duration(e).abs(),_=gt(n.as("s")),s=gt(n.as("m")),r=gt(n.as("h")),d=gt(n.as("d")),i=gt(n.as("M")),o=gt(n.as("y")),u=_<ma.s&&["s",_]||1===s&&["m"]||s<ma.m&&["mm",s]||1===r&&["h"]||r<ma.h&&["hh",r]||1===d&&["d"]||d<ma.d&&["dd",d]||1===i&&["M"]||i<ma.M&&["MM",i]||1===o&&["y"]||["yy",o];return u[2]=t,u[3]=+e>0,u[4]=a,st.apply({},u)}function dt(e,t,a){var n,_=a-t,s=a-e.day();return s>_&&(s-=7),_-7>s&&(s+=7),n=ft(e).add(s,"d"),{week:Math.ceil(n.dayOfYear()/7),year:n.year()}}function it(e,t,a,n,_){var s,r,d=nt(e,0,1).getUTCDay();return d=0===d?7:d,a=null!=a?a:_,s=_-d+(d>n?7:0)-(_>d?7:0),r=7*(t-1)+(a-_)+s+1,{year:r>0?e:e-1,dayOfYear:r>0?r:j(e-1)+r}}function ot(t){var a=t._i,n=t._f;return t._locale=t._locale||ft.localeData(t._l),null===a||n===e&&""===a?ft.invalid({nullInput:!0}):("string"==typeof a&&(t._i=a=t._locale.preparse(a)),ft.isMoment(a)?new u(a,!0):(n?p(n)?B(t):K(t):tt(t),new u(t)))}function ut(e,t){var a,n;if(1===t.length&&p(t[0])&&(t=t[0]),!t.length)return ft();for(a=t[0],n=1;n<t.length;++n)t[n][e](a)&&(a=t[n]);return a}function lt(e,t){var a;return"string"==typeof t&&(t=e.localeData().monthsParse(t),"number"!=typeof t)?e:(a=Math.min(e.date(),b(e.year(),t)),e._d["set"+(e._isUTC?"UTC":"")+"Month"](t,a),e)}function mt(e,t){return e._d["get"+(e._isUTC?"UTC":"")+t]()}function Mt(e,t,a){return"Month"===t?lt(e,a):e._d["set"+(e._isUTC?"UTC":"")+t](a)}function ct(e,t){return function(a){return null!=a?(Mt(this,e,a),ft.updateOffset(this,t),this):mt(this,e)}}function Lt(e){return 400*e/146097}function ht(e){return 146097*e/400}function Yt(e){ft.duration.fn[e]=function(){return this._data[e]}}function yt(e){"undefined"==typeof ender&&(pt=Tt.moment,Tt.moment=e?s("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.",ft):ft)}for(var ft,pt,Dt,kt="2.8.3",Tt="undefined"!=typeof global?global:this,gt=Math.round,wt=Object.prototype.hasOwnProperty,vt=0,bt=1,St=2,jt=3,Wt=4,xt=5,zt=6,Ht={},Ft=[],Et="undefined"!=typeof module&&module.exports,At=/^\/?Date\((\-?\d+)/i,Ot=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Jt=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Gt=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,Pt=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,Ct=/\d\d?/,It=/\d{1,3}/,Ut=/\d{1,4}/,Nt=/[+\-]?\d{1,6}/,Vt=/\d+/,qt=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Zt=/Z|[\+\-]\d\d:?\d\d/gi,Kt=/T/i,$t=/[\+\-]?\d+(\.\d{1,3})?/,Rt=/\d{1,2}/,Bt=/\d/,Xt=/\d\d/,Qt=/\d{3}/,ea=/\d{4}/,ta=/[+-]?\d{6}/,aa=/[+-]?\d+/,na=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,_a="YYYY-MM-DDTHH:mm:ssZ",sa=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],ra=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],da=/([\+\-]|\d\d)/gi,ia=("Date|Hours|Minutes|Seconds|Milliseconds".split("|"),{Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6}),oa={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},ua={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},la={},ma={s:45,m:45,h:22,d:26,M:11},Ma="DDD w W M D d".split(" "),ca="M D H h m s w W".split(" "),La={M:function(){return this.month()+1},MMM:function(e){return this.localeData().monthsShort(this,e)},MMMM:function(e){return this.localeData().months(this,e)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(e){return this.localeData().weekdaysMin(this,e)},ddd:function(e){return this.localeData().weekdaysShort(this,e)},dddd:function(e){return this.localeData().weekdays(this,e)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return L(this.year()%100,2)},YYYY:function(){return L(this.year(),4)},YYYYY:function(){return L(this.year(),5)},YYYYYY:function(){var e=this.year(),t=e>=0?"+":"-";return t+L(Math.abs(e),6)},gg:function(){return L(this.weekYear()%100,2)},gggg:function(){return L(this.weekYear(),4)},ggggg:function(){return L(this.weekYear(),5)},GG:function(){return L(this.isoWeekYear()%100,2)},GGGG:function(){return L(this.isoWeekYear(),4)},GGGGG:function(){return L(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return v(this.milliseconds()/100)},SS:function(){return L(v(this.milliseconds()/10),2)},SSS:function(){return L(this.milliseconds(),3)},SSSS:function(){return L(this.milliseconds(),3)},Z:function(){var e=-this.zone(),t="+";return 0>e&&(e=-e,t="-"),t+L(v(e/60),2)+":"+L(v(e)%60,2)},ZZ:function(){var e=-this.zone(),t="+";return 0>e&&(e=-e,t="-"),t+L(v(e/60),2)+L(v(e)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},ha={},Ya=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Ma.length;)Dt=Ma.pop(),La[Dt+"o"]=i(La[Dt],Dt);for(;ca.length;)Dt=ca.pop(),La[Dt+Dt]=d(La[Dt],2);La.DDDD=d(La.DDD,3),m(o.prototype,{set:function(e){var t,a;for(a in e)t=e[a],"function"==typeof t?this[a]=t:this["_"+a]=t},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(e){return this._months[e.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(e){return this._monthsShort[e.month()]},monthsParse:function(e){var t,a,n;for(this._monthsParse||(this._monthsParse=[]),t=0;12>t;t++)if(this._monthsParse[t]||(a=ft.utc([2e3,t]),n="^"+this.months(a,"")+"|^"+this.monthsShort(a,""),this._monthsParse[t]=new RegExp(n.replace(".",""),"i")),this._monthsParse[t].test(e))return t},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(e){return this._weekdays[e.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(e){return this._weekdaysShort[e.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(e){return this._weekdaysMin[e.day()]},weekdaysParse:function(e){var t,a,n;for(this._weekdaysParse||(this._weekdaysParse=[]),t=0;7>t;t++)if(this._weekdaysParse[t]||(a=ft([2e3,1]).day(t),n="^"+this.weekdays(a,"")+"|^"+this.weekdaysShort(a,"")+"|^"+this.weekdaysMin(a,""),this._weekdaysParse[t]=new RegExp(n.replace(".",""),"i")),this._weekdaysParse[t].test(e))return t},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(e){var t=this._longDateFormat[e];return!t&&this._longDateFormat[e.toUpperCase()]&&(t=this._longDateFormat[e.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(e){return e.slice(1)}),this._longDateFormat[e]=t),t},isPM:function(e){return"p"===(e+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(e,t,a){return e>11?a?"pm":"PM":a?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(e,t){var a=this._calendar[e];return"function"==typeof a?a.apply(t):a},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(e,t,a,n){var _=this._relativeTime[a];return"function"==typeof _?_(e,t,a,n):_.replace(/%d/i,e)},pastFuture:function(e,t){var a=this._relativeTime[e>0?"future":"past"];return"function"==typeof a?a(t):a.replace(/%s/i,t)},ordinal:function(e){return this._ordinal.replace("%d",e)},_ordinal:"%d",preparse:function(e){return e},postformat:function(e){return e},week:function(e){return dt(e,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),ft=function(t,a,_,s){var r;return"boolean"==typeof _&&(s=_,_=e),r={},r._isAMomentObject=!0,r._i=t,r._f=a,r._l=_,r._strict=s,r._isUTC=!1,r._pf=n(),ot(r)},ft.suppressDeprecationWarnings=!1,ft.createFromInputFallback=s("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(e){e._d=new Date(e._i)}),ft.min=function(){var e=[].slice.call(arguments,0);return ut("isBefore",e)},ft.max=function(){var e=[].slice.call(arguments,0);return ut("isAfter",e)},ft.utc=function(t,a,_,s){var r;return"boolean"==typeof _&&(s=_,_=e),r={},r._isAMomentObject=!0,r._useUTC=!0,r._isUTC=!0,r._l=_,r._i=t,r._f=a,r._strict=s,r._pf=n(),ot(r).utc()},ft.unix=function(e){return ft(1e3*e)},ft.duration=function(e,t){var n,_,s,r,d=e,i=null;return ft.isDuration(e)?d={ms:e._milliseconds,d:e._days,M:e._months}:"number"==typeof e?(d={},t?d[t]=e:d.milliseconds=e):(i=Ot.exec(e))?(n="-"===i[1]?-1:1,d={y:0,d:v(i[St])*n,h:v(i[jt])*n,m:v(i[Wt])*n,s:v(i[xt])*n,ms:v(i[zt])*n}):(i=Jt.exec(e))?(n="-"===i[1]?-1:1,s=function(e){var t=e&&parseFloat(e.replace(",","."));return(isNaN(t)?0:t)*n},d={y:s(i[2]),M:s(i[3]),d:s(i[4]),h:s(i[5]),m:s(i[6]),s:s(i[7]),w:s(i[8])}):"object"==typeof d&&("from"in d||"to"in d)&&(r=Y(ft(d.from),ft(d.to)),d={},d.ms=r.milliseconds,d.M=r.months),_=new l(d),ft.isDuration(e)&&a(e,"_locale")&&(_._locale=e._locale),_},ft.version=kt,ft.defaultFormat=_a,ft.ISO_8601=function(){},ft.momentProperties=Ft,ft.updateOffset=function(){},ft.relativeTimeThreshold=function(t,a){return ma[t]===e?!1:a===e?ma[t]:(ma[t]=a,!0)},ft.lang=s("moment.lang is deprecated. Use moment.locale instead.",function(e,t){return ft.locale(e,t)}),ft.locale=function(e,t){var a;return e&&(a="undefined"!=typeof t?ft.defineLocale(e,t):ft.localeData(e),a&&(ft.duration._locale=ft._locale=a)),ft._locale._abbr},ft.defineLocale=function(e,t){return null!==t?(t.abbr=e,Ht[e]||(Ht[e]=new o),Ht[e].set(t),ft.locale(e),Ht[e]):(delete Ht[e],null)},ft.langData=s("moment.langData is deprecated. Use moment.localeData instead.",function(e){return ft.localeData(e)}),ft.localeData=function(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return ft._locale;if(!p(e)){if(t=E(e))return t;e=[e]}return F(e)},ft.isMoment=function(e){return e instanceof u||null!=e&&a(e,"_isAMomentObject")},ft.isDuration=function(e){return e instanceof l};for(Dt=Ya.length-1;Dt>=0;--Dt)w(Ya[Dt]);ft.normalizeUnits=function(e){return T(e)},ft.invalid=function(e){var t=ft.utc(0/0);return null!=e?m(t._pf,e):t._pf.userInvalidated=!0,t},ft.parseZone=function(){return ft.apply(null,arguments).parseZone()},ft.parseTwoDigitYear=function(e){return v(e)+(v(e)>68?1900:2e3)},m(ft.fn=u.prototype,{clone:function(){return ft(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var e=ft(this).utc();return 0<e.year()&&e.year()<=9999?G(e,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):G(e,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var e=this;return[e.year(),e.month(),e.date(),e.hours(),e.minutes(),e.seconds(),e.milliseconds()]},isValid:function(){return z(this)},isDSTShifted:function(){return this._a?this.isValid()&&k(this._a,(this._isUTC?ft.utc(this._a):ft(this._a)).toArray())>0:!1},parsingFlags:function(){return m({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(e){return this.zone(0,e)},local:function(e){return this._isUTC&&(this.zone(0,e),this._isUTC=!1,e&&this.add(this._dateTzOffset(),"m")),this},format:function(e){var t=G(this,e||ft.defaultFormat);return this.localeData().postformat(t)},add:y(1,"add"),subtract:y(-1,"subtract"),diff:function(e,t,a){var n,_,s,r=A(e,this),d=6e4*(this.zone()-r.zone());return t=T(t),"year"===t||"month"===t?(n=432e5*(this.daysInMonth()+r.daysInMonth()),_=12*(this.year()-r.year())+(this.month()-r.month()),s=this-ft(this).startOf("month")-(r-ft(r).startOf("month")),s-=6e4*(this.zone()-ft(this).startOf("month").zone()-(r.zone()-ft(r).startOf("month").zone())),_+=s/n,"year"===t&&(_/=12)):(n=this-r,_="second"===t?n/1e3:"minute"===t?n/6e4:"hour"===t?n/36e5:"day"===t?(n-d)/864e5:"week"===t?(n-d)/6048e5:n),a?_:c(_)},from:function(e,t){return ft.duration({to:this,from:e}).locale(this.locale()).humanize(!t)},fromNow:function(e){return this.from(ft(),e)},calendar:function(e){var t=e||ft(),a=A(t,this).startOf("day"),n=this.diff(a,"days",!0),_=-6>n?"sameElse":-1>n?"lastWeek":0>n?"lastDay":1>n?"sameDay":2>n?"nextDay":7>n?"nextWeek":"sameElse";return this.format(this.localeData().calendar(_,this))},isLeapYear:function(){return W(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(e){var t=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=e?(e=_t(e,this.localeData()),this.add(e-t,"d")):t},month:ct("Month",!0),startOf:function(e){switch(e=T(e)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===e?this.weekday(0):"isoWeek"===e&&this.isoWeekday(1),"quarter"===e&&this.month(3*Math.floor(this.month()/3)),this},endOf:function(e){return e=T(e),this.startOf(e).add(1,"isoWeek"===e?"week":e).subtract(1,"ms")},isAfter:function(e,t){return t=T("undefined"!=typeof t?t:"millisecond"),"millisecond"===t?(e=ft.isMoment(e)?e:ft(e),+this>+e):+this.clone().startOf(t)>+ft(e).startOf(t)},isBefore:function(e,t){return t=T("undefined"!=typeof t?t:"millisecond"),"millisecond"===t?(e=ft.isMoment(e)?e:ft(e),+e>+this):+this.clone().startOf(t)<+ft(e).startOf(t)},isSame:function(e,t){return t=T(t||"millisecond"),"millisecond"===t?(e=ft.isMoment(e)?e:ft(e),+this===+e):+this.clone().startOf(t)===+A(e,this).startOf(t)},min:s("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(e){return e=ft.apply(null,arguments),this>e?this:e}),max:s("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(e){return e=ft.apply(null,arguments),e>this?this:e}),zone:function(e,t){var a,n=this._offset||0;return null==e?this._isUTC?n:this._dateTzOffset():("string"==typeof e&&(e=I(e)),Math.abs(e)<16&&(e=60*e),!this._isUTC&&t&&(a=this._dateTzOffset()),this._offset=e,this._isUTC=!0,null!=a&&this.subtract(a,"m"),n!==e&&(!t||this._changeInProgress?f(this,ft.duration(n-e,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,ft.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(e){return e=e?ft(e).zone():0,(this.zone()-e)%60===0},daysInMonth:function(){return b(this.year(),this.month())},dayOfYear:function(e){var t=gt((ft(this).startOf("day")-ft(this).startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"d")},quarter:function(e){return null==e?Math.ceil((this.month()+1)/3):this.month(3*(e-1)+this.month()%3)},weekYear:function(e){var t=dt(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==e?t:this.add(e-t,"y")},isoWeekYear:function(e){var t=dt(this,1,4).year;return null==e?t:this.add(e-t,"y")},week:function(e){var t=this.localeData().week(this);return null==e?t:this.add(7*(e-t),"d")},isoWeek:function(e){var t=dt(this,1,4).week;return null==e?t:this.add(7*(e-t),"d")},weekday:function(e){var t=(this.day()+7-this.localeData()._week.dow)%7;return null==e?t:this.add(e-t,"d")},isoWeekday:function(e){return null==e?this.day()||7:this.day(this.day()%7?e:e-7)},isoWeeksInYear:function(){return S(this.year(),1,4)},weeksInYear:function(){var e=this.localeData()._week;return S(this.year(),e.dow,e.doy)},get:function(e){return e=T(e),this[e]()},set:function(e,t){return e=T(e),"function"==typeof this[e]&&this[e](t),this},locale:function(t){var a;return t===e?this._locale._abbr:(a=ft.localeData(t),null!=a&&(this._locale=a),this)},lang:s("moment().lang() is deprecated. Use moment().localeData() instead.",function(t){return t===e?this.localeData():this.locale(t)}),localeData:function(){return this._locale},_dateTzOffset:function(){return 15*Math.round(this._d.getTimezoneOffset()/15)}}),ft.fn.millisecond=ft.fn.milliseconds=ct("Milliseconds",!1),ft.fn.second=ft.fn.seconds=ct("Seconds",!1),ft.fn.minute=ft.fn.minutes=ct("Minutes",!1),ft.fn.hour=ft.fn.hours=ct("Hours",!0),ft.fn.date=ct("Date",!0),ft.fn.dates=s("dates accessor is deprecated. Use date instead.",ct("Date",!0)),ft.fn.year=ct("FullYear",!0),ft.fn.years=s("years accessor is deprecated. Use year instead.",ct("FullYear",!0)),ft.fn.days=ft.fn.day,ft.fn.months=ft.fn.month,ft.fn.weeks=ft.fn.week,ft.fn.isoWeeks=ft.fn.isoWeek,ft.fn.quarters=ft.fn.quarter,ft.fn.toJSON=ft.fn.toISOString,m(ft.duration.fn=l.prototype,{_bubble:function(){var e,t,a,n=this._milliseconds,_=this._days,s=this._months,r=this._data,d=0;r.milliseconds=n%1e3,e=c(n/1e3),r.seconds=e%60,t=c(e/60),r.minutes=t%60,a=c(t/60),r.hours=a%24,_+=c(a/24),d=c(Lt(_)),_-=c(ht(d)),s+=c(_/30),_%=30,d+=c(s/12),s%=12,r.days=_,r.months=s,r.years=d},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return c(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*v(this._months/12)},humanize:function(e){var t=rt(this,!e,this.localeData());return e&&(t=this.localeData().pastFuture(+this,t)),this.localeData().postformat(t)},add:function(e,t){var a=ft.duration(e,t);return this._milliseconds+=a._milliseconds,this._days+=a._days,this._months+=a._months,this._bubble(),this},subtract:function(e,t){var a=ft.duration(e,t);return this._milliseconds-=a._milliseconds,this._days-=a._days,this._months-=a._months,this._bubble(),this},get:function(e){return e=T(e),this[e.toLowerCase()+"s"]()},as:function(e){var t,a;if(e=T(e),"month"===e||"year"===e)return t=this._days+this._milliseconds/864e5,a=this._months+12*Lt(t),"month"===e?a:a/12;switch(t=this._days+ht(this._months/12),e){case"week":return t/7+this._milliseconds/6048e5;case"day":return t+this._milliseconds/864e5;case"hour":return 24*t+this._milliseconds/36e5;case"minute":return 24*t*60+this._milliseconds/6e4;case"second":return 24*t*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*t*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+e)}},lang:ft.fn.lang,locale:ft.fn.locale,toIsoString:s("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var e=Math.abs(this.years()),t=Math.abs(this.months()),a=Math.abs(this.days()),n=Math.abs(this.hours()),_=Math.abs(this.minutes()),s=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(e?e+"Y":"")+(t?t+"M":"")+(a?a+"D":"")+(n||_||s?"T":"")+(n?n+"H":"")+(_?_+"M":"")+(s?s+"S":""):"P0D"},localeData:function(){return this._locale}}),ft.duration.fn.toString=ft.duration.fn.toISOString;for(Dt in ia)a(ia,Dt)&&Yt(Dt.toLowerCase());ft.duration.fn.asMilliseconds=function(){return this.as("ms")},ft.duration.fn.asSeconds=function(){return this.as("s")},ft.duration.fn.asMinutes=function(){return this.as("m")},ft.duration.fn.asHours=function(){return this.as("h")},ft.duration.fn.asDays=function(){return this.as("d")},ft.duration.fn.asWeeks=function(){return this.as("weeks")},ft.duration.fn.asMonths=function(){return this.as("M")},ft.duration.fn.asYears=function(){return this.as("y")},ft.locale("en",{ordinal:function(e){var t=e%10,a=1===v(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th";
+return e+a}}),function(e){e(ft)}(function(e){return e.defineLocale("af",{months:"Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des".split("_"),weekdays:"Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag".split("_"),weekdaysShort:"Son_Maa_Din_Woe_Don_Vry_Sat".split("_"),weekdaysMin:"So_Ma_Di_Wo_Do_Vr_Sa".split("_"),meridiem:function(e,t,a){return 12>e?a?"vm":"VM":a?"nm":"NM"},longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Vandag om] LT",nextDay:"[Môre om] LT",nextWeek:"dddd [om] LT",lastDay:"[Gister om] LT",lastWeek:"[Laas] dddd [om] LT",sameElse:"L"},relativeTime:{future:"oor %s",past:"%s gelede",s:"'n paar sekondes",m:"'n minuut",mm:"%d minute",h:"'n uur",hh:"%d ure",d:"'n dag",dd:"%d dae",M:"'n maand",MM:"%d maande",y:"'n jaar",yy:"%d jaar"},ordinal:function(e){return e+(1===e||8===e||e>=20?"ste":"de")},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("ar-ma",{months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdays:"الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[اليوم على الساعة] LT",nextDay:"[غدا على الساعة] LT",nextWeek:"dddd [على الساعة] LT",lastDay:"[أمس على الساعة] LT",lastWeek:"dddd [على الساعة] LT",sameElse:"L"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"},week:{dow:6,doy:12}})}),function(e){e(ft)}(function(e){var t={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"};return e.defineLocale("ar-sa",{months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},meridiem:function(e){return 12>e?"ص":"م"},calendar:{sameDay:"[اليوم على الساعة] LT",nextDay:"[غدا على الساعة] LT",nextWeek:"dddd [على الساعة] LT",lastDay:"[أمس على الساعة] LT",lastWeek:"dddd [على الساعة] LT",sameElse:"L"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"},preparse:function(e){return e.replace(/[۰-۹]/g,function(e){return a[e]}).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]}).replace(/,/g,"،")},week:{dow:6,doy:12}})}),function(e){e(ft)}(function(e){var t={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},n=function(e){return 0===e?0:1===e?1:2===e?2:e%100>=3&&10>=e%100?3:e%100>=11?4:5},_={s:["أقل من ثانية","ثانية واحدة",["ثانيتان","ثانيتين"],"%d ثوان","%d ثانية","%d ثانية"],m:["أقل من دقيقة","دقيقة واحدة",["دقيقتان","دقيقتين"],"%d دقائق","%d دقيقة","%d دقيقة"],h:["أقل من ساعة","ساعة واحدة",["ساعتان","ساعتين"],"%d ساعات","%d ساعة","%d ساعة"],d:["أقل من يوم","يوم واحد",["يومان","يومين"],"%d أيام","%d يومًا","%d يوم"],M:["أقل من شهر","شهر واحد",["شهران","شهرين"],"%d أشهر","%d شهرا","%d شهر"],y:["أقل من عام","عام واحد",["عامان","عامين"],"%d أعوام","%d عامًا","%d عام"]},s=function(e){return function(t,a){var s=n(t),r=_[e][n(t)];return 2===s&&(r=r[a?0:1]),r.replace(/%d/i,t)}},r=["كانون الثاني يناير","شباط فبراير","آذار مارس","نيسان أبريل","أيار مايو","حزيران يونيو","تموز يوليو","آب أغسطس","أيلول سبتمبر","تشرين الأول أكتوبر","تشرين الثاني نوفمبر","كانون الأول ديسمبر"];return e.defineLocale("ar",{months:r,monthsShort:r,weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},meridiem:function(e){return 12>e?"ص":"م"},calendar:{sameDay:"[اليوم عند الساعة] LT",nextDay:"[غدًا عند الساعة] LT",nextWeek:"dddd [عند الساعة] LT",lastDay:"[أمس عند الساعة] LT",lastWeek:"dddd [عند الساعة] LT",sameElse:"L"},relativeTime:{future:"بعد %s",past:"منذ %s",s:s("s"),m:s("m"),mm:s("m"),h:s("h"),hh:s("h"),d:s("d"),dd:s("d"),M:s("M"),MM:s("M"),y:s("y"),yy:s("y")},preparse:function(e){return e.replace(/[۰-۹]/g,function(e){return a[e]}).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]}).replace(/,/g,"،")},week:{dow:6,doy:12}})}),function(e){e(ft)}(function(e){var t={1:"-inci",5:"-inci",8:"-inci",70:"-inci",80:"-inci",2:"-nci",7:"-nci",20:"-nci",50:"-nci",3:"-üncü",4:"-üncü",100:"-üncü",6:"-ncı",9:"-uncu",10:"-uncu",30:"-uncu",60:"-ıncı",90:"-ıncı"};return e.defineLocale("az",{months:"yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr".split("_"),monthsShort:"yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek".split("_"),weekdays:"Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə".split("_"),weekdaysShort:"Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən".split("_"),weekdaysMin:"Bz_BE_ÇA_Çə_CA_Cü_Şə".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[bugün saat] LT",nextDay:"[sabah saat] LT",nextWeek:"[gələn həftə] dddd [saat] LT",lastDay:"[dünən] LT",lastWeek:"[keçən həftə] dddd [saat] LT",sameElse:"L"},relativeTime:{future:"%s sonra",past:"%s əvvəl",s:"birneçə saniyyə",m:"bir dəqiqə",mm:"%d dəqiqə",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir il",yy:"%d il"},meridiem:function(e){return 4>e?"gecə":12>e?"səhər":17>e?"gündüz":"axşam"},ordinal:function(e){if(0===e)return e+"-ıncı";var a=e%10,n=e%100-a,_=e>=100?100:null;return e+(t[a]||t[n]||t[_])},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){function t(e,t){var a=e.split("_");return t%10===1&&t%100!==11?a[0]:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?a[1]:a[2]}function a(e,a,n){var _={mm:a?"хвіліна_хвіліны_хвілін":"хвіліну_хвіліны_хвілін",hh:a?"гадзіна_гадзіны_гадзін":"гадзіну_гадзіны_гадзін",dd:"дзень_дні_дзён",MM:"месяц_месяцы_месяцаў",yy:"год_гады_гадоў"};return"m"===n?a?"хвіліна":"хвіліну":"h"===n?a?"гадзіна":"гадзіну":e+" "+t(_[n],+e)}function n(e,t){var a={nominative:"студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань".split("_"),accusative:"студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня".split("_")},n=/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/.test(t)?"accusative":"nominative";return a[n][e.month()]}function _(e,t){var a={nominative:"нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота".split("_"),accusative:"нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу".split("_")},n=/\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/.test(t)?"accusative":"nominative";return a[n][e.day()]}return e.defineLocale("be",{months:n,monthsShort:"студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж".split("_"),weekdays:_,weekdaysShort:"нд_пн_ат_ср_чц_пт_сб".split("_"),weekdaysMin:"нд_пн_ат_ср_чц_пт_сб".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., LT",LLLL:"dddd, D MMMM YYYY г., LT"},calendar:{sameDay:"[Сёння ў] LT",nextDay:"[Заўтра ў] LT",lastDay:"[Учора ў] LT",nextWeek:function(){return"[У] dddd [ў] LT"},lastWeek:function(){switch(this.day()){case 0:case 3:case 5:case 6:return"[У мінулую] dddd [ў] LT";case 1:case 2:case 4:return"[У мінулы] dddd [ў] LT"}},sameElse:"L"},relativeTime:{future:"праз %s",past:"%s таму",s:"некалькі секунд",m:a,mm:a,h:a,hh:a,d:"дзень",dd:a,M:"месяц",MM:a,y:"год",yy:a},meridiem:function(e){return 4>e?"ночы":12>e?"раніцы":17>e?"дня":"вечара"},ordinal:function(e,t){switch(t){case"M":case"d":case"DDD":case"w":case"W":return e%10!==2&&e%10!==3||e%100===12||e%100===13?e+"-ы":e+"-і";case"D":return e+"-га";default:return e}},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("bg",{months:"януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември".split("_"),monthsShort:"янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек".split("_"),weekdays:"неделя_понеделник_вторник_сряда_четвъртък_петък_събота".split("_"),weekdaysShort:"нед_пон_вто_сря_чет_пет_съб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),longDateFormat:{LT:"H:mm",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Днес в] LT",nextDay:"[Утре в] LT",nextWeek:"dddd [в] LT",lastDay:"[Вчера в] LT",lastWeek:function(){switch(this.day()){case 0:case 3:case 6:return"[В изминалата] dddd [в] LT";case 1:case 2:case 4:case 5:return"[В изминалия] dddd [в] LT"}},sameElse:"L"},relativeTime:{future:"след %s",past:"преди %s",s:"няколко секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дни",M:"месец",MM:"%d месеца",y:"година",yy:"%d години"},ordinal:function(e){var t=e%10,a=e%100;return 0===e?e+"-ев":0===a?e+"-ен":a>10&&20>a?e+"-ти":1===t?e+"-ви":2===t?e+"-ри":7===t||8===t?e+"-ми":e+"-ти"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){var t={1:"১",2:"২",3:"৩",4:"৪",5:"৫",6:"৬",7:"৭",8:"৮",9:"৯",0:"০"},a={"১":"1","২":"2","৩":"3","৪":"4","৫":"5","৬":"6","৭":"7","৮":"8","৯":"9","০":"0"};return e.defineLocale("bn",{months:"জানুয়ারী_ফেবুয়ারী_মার্চ_এপ্রিল_মে_জুন_জুলাই_অগাস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),monthsShort:"জানু_ফেব_মার্চ_এপর_মে_জুন_জুল_অগ_সেপ্ট_অক্টো_নভ_ডিসেম্".split("_"),weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পত্তিবার_শুক্রুবার_শনিবার".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পত্তি_শুক্রু_শনি".split("_"),weekdaysMin:"রব_সম_মঙ্গ_বু_ব্রিহ_শু_শনি".split("_"),longDateFormat:{LT:"A h:mm সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},calendar:{sameDay:"[আজ] LT",nextDay:"[আগামীকাল] LT",nextWeek:"dddd, LT",lastDay:"[গতকাল] LT",lastWeek:"[গত] dddd, LT",sameElse:"L"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কএক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"},preparse:function(e){return e.replace(/[১২৩৪৫৬৭৮৯০]/g,function(e){return a[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]})},meridiem:function(e){return 4>e?"রাত":10>e?"শকাল":17>e?"দুপুর":20>e?"বিকেল":"রাত"},week:{dow:0,doy:6}})}),function(e){e(ft)}(function(e){var t={1:"༡",2:"༢",3:"༣",4:"༤",5:"༥",6:"༦",7:"༧",8:"༨",9:"༩",0:"༠"},a={"༡":"1","༢":"2","༣":"3","༤":"4","༥":"5","༦":"6","༧":"7","༨":"8","༩":"9","༠":"0"};return e.defineLocale("bo",{months:"ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ".split("_"),monthsShort:"ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ".split("_"),weekdays:"གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་".split("_"),weekdaysShort:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),weekdaysMin:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),longDateFormat:{LT:"A h:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},calendar:{sameDay:"[དི་རིང] LT",nextDay:"[སང་ཉིན] LT",nextWeek:"[བདུན་ཕྲག་རྗེས་མ], LT",lastDay:"[ཁ་སང] LT",lastWeek:"[བདུན་ཕྲག་མཐའ་མ] dddd, LT",sameElse:"L"},relativeTime:{future:"%s ལ་",past:"%s སྔན་ལ",s:"ལམ་སང",m:"སྐར་མ་གཅིག",mm:"%d སྐར་མ",h:"ཆུ་ཚོད་གཅིག",hh:"%d ཆུ་ཚོད",d:"ཉིན་གཅིག",dd:"%d ཉིན་",M:"ཟླ་བ་གཅིག",MM:"%d ཟླ་བ",y:"ལོ་གཅིག",yy:"%d ལོ"},preparse:function(e){return e.replace(/[༡༢༣༤༥༦༧༨༩༠]/g,function(e){return a[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]})},meridiem:function(e){return 4>e?"མཚན་མོ":10>e?"ཞོགས་ཀས":17>e?"ཉིན་གུང":20>e?"དགོང་དག":"མཚན་མོ"},week:{dow:0,doy:6}})}),function(e){e(ft)}(function(t){function a(e,t,a){var n={mm:"munutenn",MM:"miz",dd:"devezh"};return e+" "+s(n[a],e)}function n(e){switch(_(e)){case 1:case 3:case 4:case 5:case 9:return e+" bloaz";default:return e+" vloaz"}}function _(e){return e>9?_(e%10):e}function s(e,t){return 2===t?r(e):e}function r(t){var a={m:"v",b:"v",d:"z"};return a[t.charAt(0)]===e?t:a[t.charAt(0)]+t.substring(1)}return t.defineLocale("br",{months:"Genver_C'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split("_"),monthsShort:"Gen_C'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split("_"),weekdays:"Sul_Lun_Meurzh_Merc'her_Yaou_Gwener_Sadorn".split("_"),weekdaysShort:"Sul_Lun_Meu_Mer_Yao_Gwe_Sad".split("_"),weekdaysMin:"Su_Lu_Me_Mer_Ya_Gw_Sa".split("_"),longDateFormat:{LT:"h[e]mm A",L:"DD/MM/YYYY",LL:"D [a viz] MMMM YYYY",LLL:"D [a viz] MMMM YYYY LT",LLLL:"dddd, D [a viz] MMMM YYYY LT"},calendar:{sameDay:"[Hiziv da] LT",nextDay:"[Warc'hoazh da] LT",nextWeek:"dddd [da] LT",lastDay:"[Dec'h da] LT",lastWeek:"dddd [paset da] LT",sameElse:"L"},relativeTime:{future:"a-benn %s",past:"%s 'zo",s:"un nebeud segondennoù",m:"ur vunutenn",mm:a,h:"un eur",hh:"%d eur",d:"un devezh",dd:a,M:"ur miz",MM:a,y:"ur bloaz",yy:n},ordinal:function(e){var t=1===e?"añ":"vet";return e+t},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n=e+" ";switch(a){case"m":return t?"jedna minuta":"jedne minute";case"mm":return n+=1===e?"minuta":2===e||3===e||4===e?"minute":"minuta";case"h":return t?"jedan sat":"jednog sata";case"hh":return n+=1===e?"sat":2===e||3===e||4===e?"sata":"sati";case"dd":return n+=1===e?"dan":"dana";case"MM":return n+=1===e?"mjesec":2===e||3===e||4===e?"mjeseca":"mjeseci";case"yy":return n+=1===e?"godina":2===e||3===e||4===e?"godine":"godina"}}return e.defineLocale("bs",{months:"januar_februar_mart_april_maj_juni_juli_avgust_septembar_oktobar_novembar_decembar".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),longDateFormat:{LT:"H:mm",L:"DD. MM. YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[danas u] LT",nextDay:"[sutra u] LT",nextWeek:function(){switch(this.day()){case 0:return"[u] [nedjelju] [u] LT";case 3:return"[u] [srijedu] [u] LT";case 6:return"[u] [subotu] [u] LT";case 1:case 2:case 4:case 5:return"[u] dddd [u] LT"}},lastDay:"[jučer u] LT",lastWeek:function(){switch(this.day()){case 0:case 3:return"[prošlu] dddd [u] LT";case 6:return"[prošle] [subote] [u] LT";case 1:case 2:case 4:case 5:return"[prošli] dddd [u] LT"}},sameElse:"L"},relativeTime:{future:"za %s",past:"prije %s",s:"par sekundi",m:t,mm:t,h:t,hh:t,d:"dan",dd:t,M:"mjesec",MM:t,y:"godinu",yy:t},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("ca",{months:"gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre".split("_"),monthsShort:"gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.".split("_"),weekdays:"diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte".split("_"),weekdaysShort:"dg._dl._dt._dc._dj._dv._ds.".split("_"),weekdaysMin:"Dg_Dl_Dt_Dc_Dj_Dv_Ds".split("_"),longDateFormat:{LT:"H:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:function(){return"[avui a "+(1!==this.hours()?"les":"la")+"] LT"},nextDay:function(){return"[demà a "+(1!==this.hours()?"les":"la")+"] LT"},nextWeek:function(){return"dddd [a "+(1!==this.hours()?"les":"la")+"] LT"},lastDay:function(){return"[ahir a "+(1!==this.hours()?"les":"la")+"] LT"},lastWeek:function(){return"[el] dddd [passat a "+(1!==this.hours()?"les":"la")+"] LT"},sameElse:"L"},relativeTime:{future:"en %s",past:"fa %s",s:"uns segons",m:"un minut",mm:"%d minuts",h:"una hora",hh:"%d hores",d:"un dia",dd:"%d dies",M:"un mes",MM:"%d mesos",y:"un any",yy:"%d anys"},ordinal:"%dº",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e){return e>1&&5>e&&1!==~~(e/10)}function a(e,a,n,_){var s=e+" ";switch(n){case"s":return a||_?"pár sekund":"pár sekundami";case"m":return a?"minuta":_?"minutu":"minutou";case"mm":return a||_?s+(t(e)?"minuty":"minut"):s+"minutami";break;case"h":return a?"hodina":_?"hodinu":"hodinou";case"hh":return a||_?s+(t(e)?"hodiny":"hodin"):s+"hodinami";break;case"d":return a||_?"den":"dnem";case"dd":return a||_?s+(t(e)?"dny":"dní"):s+"dny";break;case"M":return a||_?"měsíc":"měsícem";case"MM":return a||_?s+(t(e)?"měsíce":"měsíců"):s+"měsíci";break;case"y":return a||_?"rok":"rokem";case"yy":return a||_?s+(t(e)?"roky":"let"):s+"lety"}}var n="leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec".split("_"),_="led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro".split("_");return e.defineLocale("cs",{months:n,monthsShort:_,monthsParse:function(e,t){var a,n=[];for(a=0;12>a;a++)n[a]=new RegExp("^"+e[a]+"$|^"+t[a]+"$","i");return n}(n,_),weekdays:"neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota".split("_"),weekdaysShort:"ne_po_út_st_čt_pá_so".split("_"),weekdaysMin:"ne_po_út_st_čt_pá_so".split("_"),longDateFormat:{LT:"H:mm",L:"DD. MM. YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd D. MMMM YYYY LT"},calendar:{sameDay:"[dnes v] LT",nextDay:"[zítra v] LT",nextWeek:function(){switch(this.day()){case 0:return"[v neděli v] LT";case 1:case 2:return"[v] dddd [v] LT";case 3:return"[ve středu v] LT";case 4:return"[ve čtvrtek v] LT";case 5:return"[v pátek v] LT";case 6:return"[v sobotu v] LT"}},lastDay:"[včera v] LT",lastWeek:function(){switch(this.day()){case 0:return"[minulou neděli v] LT";case 1:case 2:return"[minulé] dddd [v] LT";case 3:return"[minulou středu v] LT";case 4:case 5:return"[minulý] dddd [v] LT";case 6:return"[minulou sobotu v] LT"}},sameElse:"L"},relativeTime:{future:"za %s",past:"před %s",s:a,m:a,mm:a,h:a,hh:a,d:a,dd:a,M:a,MM:a,y:a,yy:a},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("cv",{months:"кăрлач_нарăс_пуш_ака_май_çĕртме_утă_çурла_авăн_юпа_чӳк_раштав".split("_"),monthsShort:"кăр_нар_пуш_ака_май_çĕр_утă_çур_ав_юпа_чӳк_раш".split("_"),weekdays:"вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун".split("_"),weekdaysShort:"выр_тун_ытл_юн_кĕç_эрн_шăм".split("_"),weekdaysMin:"вр_тн_ыт_юн_кç_эр_шм".split("_"),longDateFormat:{LT:"HH:mm",L:"DD-MM-YYYY",LL:"YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ]",LLL:"YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT",LLLL:"dddd, YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT"},calendar:{sameDay:"[Паян] LT [сехетре]",nextDay:"[Ыран] LT [сехетре]",lastDay:"[Ĕнер] LT [сехетре]",nextWeek:"[Çитес] dddd LT [сехетре]",lastWeek:"[Иртнĕ] dddd LT [сехетре]",sameElse:"L"},relativeTime:{future:function(e){var t=/сехет$/i.exec(e)?"рен":/çул$/i.exec(e)?"тан":"ран";return e+t},past:"%s каялла",s:"пĕр-ик çеккунт",m:"пĕр минут",mm:"%d минут",h:"пĕр сехет",hh:"%d сехет",d:"пĕр кун",dd:"%d кун",M:"пĕр уйăх",MM:"%d уйăх",y:"пĕр çул",yy:"%d çул"},ordinal:"%d-мĕш",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("cy",{months:"Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr".split("_"),monthsShort:"Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag".split("_"),weekdays:"Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn".split("_"),weekdaysShort:"Sul_Llun_Maw_Mer_Iau_Gwe_Sad".split("_"),weekdaysMin:"Su_Ll_Ma_Me_Ia_Gw_Sa".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Heddiw am] LT",nextDay:"[Yfory am] LT",nextWeek:"dddd [am] LT",lastDay:"[Ddoe am] LT",lastWeek:"dddd [diwethaf am] LT",sameElse:"L"},relativeTime:{future:"mewn %s",past:"%s yn ôl",s:"ychydig eiliadau",m:"munud",mm:"%d munud",h:"awr",hh:"%d awr",d:"diwrnod",dd:"%d diwrnod",M:"mis",MM:"%d mis",y:"blwyddyn",yy:"%d flynedd"},ordinal:function(e){var t=e,a="",n=["","af","il","ydd","ydd","ed","ed","ed","fed","fed","fed","eg","fed","eg","eg","fed","eg","eg","fed","eg","fed"];return t>20?a=40===t||50===t||60===t||80===t||100===t?"fed":"ain":t>0&&(a=n[t]),e+a},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("da",{months:"januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn_man_tir_ons_tor_fre_lør".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd [d.] D. MMMM YYYY LT"},calendar:{sameDay:"[I dag kl.] LT",nextDay:"[I morgen kl.] LT",nextWeek:"dddd [kl.] LT",lastDay:"[I går kl.] LT",lastWeek:"[sidste] dddd [kl] LT",sameElse:"L"},relativeTime:{future:"om %s",past:"%s siden",s:"få sekunder",m:"et minut",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dage",M:"en måned",MM:"%d måneder",y:"et år",yy:"%d år"},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n={m:["eine Minute","einer Minute"],h:["eine Stunde","einer Stunde"],d:["ein Tag","einem Tag"],dd:[e+" Tage",e+" Tagen"],M:["ein Monat","einem Monat"],MM:[e+" Monate",e+" Monaten"],y:["ein Jahr","einem Jahr"],yy:[e+" Jahre",e+" Jahren"]};return t?n[a][0]:n[a][1]}return e.defineLocale("de-at",{months:"Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),longDateFormat:{LT:"HH:mm [Uhr]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[Heute um] LT",sameElse:"L",nextDay:"[Morgen um] LT",nextWeek:"dddd [um] LT",lastDay:"[Gestern um] LT",lastWeek:"[letzten] dddd [um] LT"},relativeTime:{future:"in %s",past:"vor %s",s:"ein paar Sekunden",m:t,mm:"%d Minuten",h:t,hh:"%d Stunden",d:t,dd:t,M:t,MM:t,y:t,yy:t},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n={m:["eine Minute","einer Minute"],h:["eine Stunde","einer Stunde"],d:["ein Tag","einem Tag"],dd:[e+" Tage",e+" Tagen"],M:["ein Monat","einem Monat"],MM:[e+" Monate",e+" Monaten"],y:["ein Jahr","einem Jahr"],yy:[e+" Jahre",e+" Jahren"]};return t?n[a][0]:n[a][1]}return e.defineLocale("de",{months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),longDateFormat:{LT:"HH:mm [Uhr]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[Heute um] LT",sameElse:"L",nextDay:"[Morgen um] LT",nextWeek:"dddd [um] LT",lastDay:"[Gestern um] LT",lastWeek:"[letzten] dddd [um] LT"},relativeTime:{future:"in %s",past:"vor %s",s:"ein paar Sekunden",m:t,mm:"%d Minuten",h:t,hh:"%d Stunden",d:t,dd:t,M:t,MM:t,y:t,yy:t},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("el",{monthsNominativeEl:"Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος".split("_"),monthsGenitiveEl:"Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου".split("_"),months:function(e,t){return/D/.test(t.substring(0,t.indexOf("MMMM")))?this._monthsGenitiveEl[e.month()]:this._monthsNominativeEl[e.month()]},monthsShort:"Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ".split("_"),weekdays:"Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο".split("_"),weekdaysShort:"Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ".split("_"),weekdaysMin:"Κυ_Δε_Τρ_Τε_Πε_Πα_Σα".split("_"),meridiem:function(e,t,a){return e>11?a?"μμ":"ΜΜ":a?"πμ":"ΠΜ"},isPM:function(e){return"μ"===(e+"").toLowerCase()[0]},meridiemParse:/[ΠΜ]\.?Μ?\.?/i,longDateFormat:{LT:"h:mm A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendarEl:{sameDay:"[Σήμερα {}] LT",nextDay:"[Αύριο {}] LT",nextWeek:"dddd [{}] LT",lastDay:"[Χθες {}] LT",lastWeek:function(){switch(this.day()){case 6:return"[το προηγούμενο] dddd [{}] LT";default:return"[την προηγούμενη] dddd [{}] LT"}},sameElse:"L"},calendar:function(e,t){var a=this._calendarEl[e],n=t&&t.hours();return"function"==typeof a&&(a=a.apply(t)),a.replace("{}",n%12===1?"στη":"στις")},relativeTime:{future:"σε %s",past:"%s πριν",s:"δευτερόλεπτα",m:"ένα λεπτό",mm:"%d λεπτά",h:"μία ώρα",hh:"%d ώρες",d:"μία μέρα",dd:"%d μέρες",M:"ένας μήνας",MM:"%d μήνες",y:"ένας χρόνος",yy:"%d χρόνια"},ordinal:function(e){return e+"η"},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("en-au",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(e){var t=e%10,a=1===~~(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th";return e+a},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("en-ca",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"YYYY-MM-DD",LL:"D MMMM, YYYY",LLL:"D MMMM, YYYY LT",LLLL:"dddd, D MMMM, YYYY LT"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(e){var t=e%10,a=1===~~(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th";return e+a}})}),function(e){e(ft)}(function(e){return e.defineLocale("en-gb",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(e){var t=e%10,a=1===~~(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th";return e+a},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("eo",{months:"januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec".split("_"),weekdays:"Dimanĉo_Lundo_Mardo_Merkredo_Ĵaŭdo_Vendredo_Sabato".split("_"),weekdaysShort:"Dim_Lun_Mard_Merk_Ĵaŭ_Ven_Sab".split("_"),weekdaysMin:"Di_Lu_Ma_Me_Ĵa_Ve_Sa".split("_"),longDateFormat:{LT:"HH:mm",L:"YYYY-MM-DD",LL:"D[-an de] MMMM, YYYY",LLL:"D[-an de] MMMM, YYYY LT",LLLL:"dddd, [la] D[-an de] MMMM, YYYY LT"},meridiem:function(e,t,a){return e>11?a?"p.t.m.":"P.T.M.":a?"a.t.m.":"A.T.M."},calendar:{sameDay:"[Hodiaŭ je] LT",nextDay:"[Morgaŭ je] LT",nextWeek:"dddd [je] LT",lastDay:"[Hieraŭ je] LT",lastWeek:"[pasinta] dddd [je] LT",sameElse:"L"},relativeTime:{future:"je %s",past:"antaŭ %s",s:"sekundoj",m:"minuto",mm:"%d minutoj",h:"horo",hh:"%d horoj",d:"tago",dd:"%d tagoj",M:"monato",MM:"%d monatoj",y:"jaro",yy:"%d jaroj"},ordinal:"%da",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){var t="ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.".split("_"),a="ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_");return e.defineLocale("es",{months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:function(e,n){return/-MMM-/.test(n)?a[e.month()]:t[e.month()]},weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"Do_Lu_Ma_Mi_Ju_Vi_Sá".split("_"),longDateFormat:{LT:"H:mm",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY LT",LLLL:"dddd, D [de] MMMM [de] YYYY LT"},calendar:{sameDay:function(){return"[hoy a la"+(1!==this.hours()?"s":"")+"] LT"},nextDay:function(){return"[mañana a la"+(1!==this.hours()?"s":"")+"] LT"},nextWeek:function(){return"dddd [a la"+(1!==this.hours()?"s":"")+"] LT"},lastDay:function(){return"[ayer a la"+(1!==this.hours()?"s":"")+"] LT"},lastWeek:function(){return"[el] dddd [pasado a la"+(1!==this.hours()?"s":"")+"] LT"},sameElse:"L"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:"%dº",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a,n){var _={s:["mõne sekundi","mõni sekund","paar sekundit"],m:["ühe minuti","üks minut"],mm:[e+" minuti",e+" minutit"],h:["ühe tunni","tund aega","üks tund"],hh:[e+" tunni",e+" tundi"],d:["ühe päeva","üks päev"],M:["kuu aja","kuu aega","üks kuu"],MM:[e+" kuu",e+" kuud"],y:["ühe aasta","aasta","üks aasta"],yy:[e+" aasta",e+" aastat"]};return t?_[a][2]?_[a][2]:_[a][1]:n?_[a][0]:_[a][1]}return e.defineLocale("et",{months:"jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember".split("_"),monthsShort:"jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets".split("_"),weekdays:"pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev".split("_"),weekdaysShort:"P_E_T_K_N_R_L".split("_"),weekdaysMin:"P_E_T_K_N_R_L".split("_"),longDateFormat:{LT:"H:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[Täna,] LT",nextDay:"[Homme,] LT",nextWeek:"[Järgmine] dddd LT",lastDay:"[Eile,] LT",lastWeek:"[Eelmine] dddd LT",sameElse:"L"},relativeTime:{future:"%s pärast",past:"%s tagasi",s:t,m:t,mm:t,h:t,hh:t,d:t,dd:"%d päeva",M:t,MM:t,y:t,yy:t},ordinal:"%d.",week:{dow:1,doy:4}})
+}),function(e){e(ft)}(function(e){return e.defineLocale("eu",{months:"urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua".split("_"),monthsShort:"urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),weekdays:"igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),weekdaysShort:"ig._al._ar._az._og._ol._lr.".split("_"),weekdaysMin:"ig_al_ar_az_og_ol_lr".split("_"),longDateFormat:{LT:"HH:mm",L:"YYYY-MM-DD",LL:"YYYY[ko] MMMM[ren] D[a]",LLL:"YYYY[ko] MMMM[ren] D[a] LT",LLLL:"dddd, YYYY[ko] MMMM[ren] D[a] LT",l:"YYYY-M-D",ll:"YYYY[ko] MMM D[a]",lll:"YYYY[ko] MMM D[a] LT",llll:"ddd, YYYY[ko] MMM D[a] LT"},calendar:{sameDay:"[gaur] LT[etan]",nextDay:"[bihar] LT[etan]",nextWeek:"dddd LT[etan]",lastDay:"[atzo] LT[etan]",lastWeek:"[aurreko] dddd LT[etan]",sameElse:"L"},relativeTime:{future:"%s barru",past:"duela %s",s:"segundo batzuk",m:"minutu bat",mm:"%d minutu",h:"ordu bat",hh:"%d ordu",d:"egun bat",dd:"%d egun",M:"hilabete bat",MM:"%d hilabete",y:"urte bat",yy:"%d urte"},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){var t={1:"۱",2:"۲",3:"۳",4:"۴",5:"۵",6:"۶",7:"۷",8:"۸",9:"۹",0:"۰"},a={"۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","۰":"0"};return e.defineLocale("fa",{months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},meridiem:function(e){return 12>e?"قبل از ظهر":"بعد از ظهر"},calendar:{sameDay:"[امروز ساعت] LT",nextDay:"[فردا ساعت] LT",nextWeek:"dddd [ساعت] LT",lastDay:"[دیروز ساعت] LT",lastWeek:"dddd [پیش] [ساعت] LT",sameElse:"L"},relativeTime:{future:"در %s",past:"%s پیش",s:"چندین ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"},preparse:function(e){return e.replace(/[۰-۹]/g,function(e){return a[e]}).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]}).replace(/,/g,"،")},ordinal:"%dم",week:{dow:6,doy:12}})}),function(e){e(ft)}(function(e){function t(e,t,n,_){var s="";switch(n){case"s":return _?"muutaman sekunnin":"muutama sekunti";case"m":return _?"minuutin":"minuutti";case"mm":s=_?"minuutin":"minuuttia";break;case"h":return _?"tunnin":"tunti";case"hh":s=_?"tunnin":"tuntia";break;case"d":return _?"päivän":"päivä";case"dd":s=_?"päivän":"päivää";break;case"M":return _?"kuukauden":"kuukausi";case"MM":s=_?"kuukauden":"kuukautta";break;case"y":return _?"vuoden":"vuosi";case"yy":s=_?"vuoden":"vuotta"}return s=a(e,_)+" "+s}function a(e,t){return 10>e?t?_[e]:n[e]:e}var n="nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän".split(" "),_=["nolla","yhden","kahden","kolmen","neljän","viiden","kuuden",n[7],n[8],n[9]];return e.defineLocale("fi",{months:"tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),monthsShort:"tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),weekdays:"sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),weekdaysShort:"su_ma_ti_ke_to_pe_la".split("_"),weekdaysMin:"su_ma_ti_ke_to_pe_la".split("_"),longDateFormat:{LT:"HH.mm",L:"DD.MM.YYYY",LL:"Do MMMM[ta] YYYY",LLL:"Do MMMM[ta] YYYY, [klo] LT",LLLL:"dddd, Do MMMM[ta] YYYY, [klo] LT",l:"D.M.YYYY",ll:"Do MMM YYYY",lll:"Do MMM YYYY, [klo] LT",llll:"ddd, Do MMM YYYY, [klo] LT"},calendar:{sameDay:"[tänään] [klo] LT",nextDay:"[huomenna] [klo] LT",nextWeek:"dddd [klo] LT",lastDay:"[eilen] [klo] LT",lastWeek:"[viime] dddd[na] [klo] LT",sameElse:"L"},relativeTime:{future:"%s päästä",past:"%s sitten",s:t,m:t,mm:t,h:t,hh:t,d:t,dd:t,M:t,MM:t,y:t,yy:t},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("fo",{months:"januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdays:"sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur".split("_"),weekdaysShort:"sun_mán_týs_mik_hós_frí_ley".split("_"),weekdaysMin:"su_má_tý_mi_hó_fr_le".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D. MMMM, YYYY LT"},calendar:{sameDay:"[Í dag kl.] LT",nextDay:"[Í morgin kl.] LT",nextWeek:"dddd [kl.] LT",lastDay:"[Í gjár kl.] LT",lastWeek:"[síðstu] dddd [kl] LT",sameElse:"L"},relativeTime:{future:"um %s",past:"%s síðani",s:"fá sekund",m:"ein minutt",mm:"%d minuttir",h:"ein tími",hh:"%d tímar",d:"ein dagur",dd:"%d dagar",M:"ein mánaði",MM:"%d mánaðir",y:"eitt ár",yy:"%d ár"},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("fr-ca",{months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"Di_Lu_Ma_Me_Je_Ve_Sa".split("_"),longDateFormat:{LT:"HH:mm",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[Aujourd'hui à] LT",nextDay:"[Demain à] LT",nextWeek:"dddd [à] LT",lastDay:"[Hier à] LT",lastWeek:"dddd [dernier à] LT",sameElse:"L"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return e+(1===e?"er":"")}})}),function(e){e(ft)}(function(e){return e.defineLocale("fr",{months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"Di_Lu_Ma_Me_Je_Ve_Sa".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[Aujourd'hui à] LT",nextDay:"[Demain à] LT",nextWeek:"dddd [à] LT",lastDay:"[Hier à] LT",lastWeek:"dddd [dernier à] LT",sameElse:"L"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return e+(1===e?"er":"")},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("gl",{months:"Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro".split("_"),monthsShort:"Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.".split("_"),weekdays:"Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado".split("_"),weekdaysShort:"Dom._Lun._Mar._Mér._Xov._Ven._Sáb.".split("_"),weekdaysMin:"Do_Lu_Ma_Mé_Xo_Ve_Sá".split("_"),longDateFormat:{LT:"H:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:function(){return"[hoxe "+(1!==this.hours()?"ás":"á")+"] LT"},nextDay:function(){return"[mañá "+(1!==this.hours()?"ás":"á")+"] LT"},nextWeek:function(){return"dddd ["+(1!==this.hours()?"ás":"a")+"] LT"},lastDay:function(){return"[onte "+(1!==this.hours()?"á":"a")+"] LT"},lastWeek:function(){return"[o] dddd [pasado "+(1!==this.hours()?"ás":"a")+"] LT"},sameElse:"L"},relativeTime:{future:function(e){return"uns segundos"===e?"nuns segundos":"en "+e},past:"hai %s",s:"uns segundos",m:"un minuto",mm:"%d minutos",h:"unha hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un ano",yy:"%d anos"},ordinal:"%dº",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("he",{months:"ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר".split("_"),monthsShort:"ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳".split("_"),weekdays:"ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת".split("_"),weekdaysShort:"א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳".split("_"),weekdaysMin:"א_ב_ג_ד_ה_ו_ש".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY LT",LLLL:"dddd, D [ב]MMMM YYYY LT",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY LT",llll:"ddd, D MMM YYYY LT"},calendar:{sameDay:"[היום ב־]LT",nextDay:"[מחר ב־]LT",nextWeek:"dddd [בשעה] LT",lastDay:"[אתמול ב־]LT",lastWeek:"[ביום] dddd [האחרון בשעה] LT",sameElse:"L"},relativeTime:{future:"בעוד %s",past:"לפני %s",s:"מספר שניות",m:"דקה",mm:"%d דקות",h:"שעה",hh:function(e){return 2===e?"שעתיים":e+" שעות"},d:"יום",dd:function(e){return 2===e?"יומיים":e+" ימים"},M:"חודש",MM:function(e){return 2===e?"חודשיים":e+" חודשים"},y:"שנה",yy:function(e){return 2===e?"שנתיים":e+" שנים"}}})}),function(e){e(ft)}(function(e){var t={1:"१",2:"२",3:"३",4:"४",5:"५",6:"६",7:"७",8:"८",9:"९",0:"०"},a={"१":"1","२":"2","३":"3","४":"4","५":"5","६":"6","७":"7","८":"8","९":"9","०":"0"};return e.defineLocale("hi",{months:"जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर".split("_"),monthsShort:"जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.".split("_"),weekdays:"रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),weekdaysShort:"रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),longDateFormat:{LT:"A h:mm बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},calendar:{sameDay:"[आज] LT",nextDay:"[कल] LT",nextWeek:"dddd, LT",lastDay:"[कल] LT",lastWeek:"[पिछले] dddd, LT",sameElse:"L"},relativeTime:{future:"%s में",past:"%s पहले",s:"कुछ ही क्षण",m:"एक मिनट",mm:"%d मिनट",h:"एक घंटा",hh:"%d घंटे",d:"एक दिन",dd:"%d दिन",M:"एक महीने",MM:"%d महीने",y:"एक वर्ष",yy:"%d वर्ष"},preparse:function(e){return e.replace(/[१२३४५६७८९०]/g,function(e){return a[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]})},meridiem:function(e){return 4>e?"रात":10>e?"सुबह":17>e?"दोपहर":20>e?"शाम":"रात"},week:{dow:0,doy:6}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n=e+" ";switch(a){case"m":return t?"jedna minuta":"jedne minute";case"mm":return n+=1===e?"minuta":2===e||3===e||4===e?"minute":"minuta";case"h":return t?"jedan sat":"jednog sata";case"hh":return n+=1===e?"sat":2===e||3===e||4===e?"sata":"sati";case"dd":return n+=1===e?"dan":"dana";case"MM":return n+=1===e?"mjesec":2===e||3===e||4===e?"mjeseca":"mjeseci";case"yy":return n+=1===e?"godina":2===e||3===e||4===e?"godine":"godina"}}return e.defineLocale("hr",{months:"sječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac".split("_"),monthsShort:"sje._vel._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.".split("_"),weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),longDateFormat:{LT:"H:mm",L:"DD. MM. YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[danas u] LT",nextDay:"[sutra u] LT",nextWeek:function(){switch(this.day()){case 0:return"[u] [nedjelju] [u] LT";case 3:return"[u] [srijedu] [u] LT";case 6:return"[u] [subotu] [u] LT";case 1:case 2:case 4:case 5:return"[u] dddd [u] LT"}},lastDay:"[jučer u] LT",lastWeek:function(){switch(this.day()){case 0:case 3:return"[prošlu] dddd [u] LT";case 6:return"[prošle] [subote] [u] LT";case 1:case 2:case 4:case 5:return"[prošli] dddd [u] LT"}},sameElse:"L"},relativeTime:{future:"za %s",past:"prije %s",s:"par sekundi",m:t,mm:t,h:t,hh:t,d:"dan",dd:t,M:"mjesec",MM:t,y:"godinu",yy:t},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){function t(e,t,a,n){var _=e;switch(a){case"s":return n||t?"néhány másodperc":"néhány másodperce";case"m":return"egy"+(n||t?" perc":" perce");case"mm":return _+(n||t?" perc":" perce");case"h":return"egy"+(n||t?" óra":" órája");case"hh":return _+(n||t?" óra":" órája");case"d":return"egy"+(n||t?" nap":" napja");case"dd":return _+(n||t?" nap":" napja");case"M":return"egy"+(n||t?" hónap":" hónapja");case"MM":return _+(n||t?" hónap":" hónapja");case"y":return"egy"+(n||t?" év":" éve");case"yy":return _+(n||t?" év":" éve")}return""}function a(e){return(e?"":"[múlt] ")+"["+n[this.day()]+"] LT[-kor]"}var n="vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton".split(" ");return e.defineLocale("hu",{months:"január_február_március_április_május_június_július_augusztus_szeptember_október_november_december".split("_"),monthsShort:"jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec".split("_"),weekdays:"vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat".split("_"),weekdaysShort:"vas_hét_kedd_sze_csüt_pén_szo".split("_"),weekdaysMin:"v_h_k_sze_cs_p_szo".split("_"),longDateFormat:{LT:"H:mm",L:"YYYY.MM.DD.",LL:"YYYY. MMMM D.",LLL:"YYYY. MMMM D., LT",LLLL:"YYYY. MMMM D., dddd LT"},meridiem:function(e,t,a){return 12>e?a===!0?"de":"DE":a===!0?"du":"DU"},calendar:{sameDay:"[ma] LT[-kor]",nextDay:"[holnap] LT[-kor]",nextWeek:function(){return a.call(this,!0)},lastDay:"[tegnap] LT[-kor]",lastWeek:function(){return a.call(this,!1)},sameElse:"L"},relativeTime:{future:"%s múlva",past:"%s",s:t,m:t,mm:t,h:t,hh:t,d:t,dd:t,M:t,MM:t,y:t,yy:t},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){function t(e,t){var a={nominative:"հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր".split("_"),accusative:"հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի".split("_")},n=/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/.test(t)?"accusative":"nominative";return a[n][e.month()]}function a(e){var t="հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ".split("_");return t[e.month()]}function n(e){var t="կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ".split("_");return t[e.day()]}return e.defineLocale("hy-am",{months:t,monthsShort:a,weekdays:n,weekdaysShort:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),weekdaysMin:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY թ.",LLL:"D MMMM YYYY թ., LT",LLLL:"dddd, D MMMM YYYY թ., LT"},calendar:{sameDay:"[այսօր] LT",nextDay:"[վաղը] LT",lastDay:"[երեկ] LT",nextWeek:function(){return"dddd [օրը ժամը] LT"},lastWeek:function(){return"[անցած] dddd [օրը ժամը] LT"},sameElse:"L"},relativeTime:{future:"%s հետո",past:"%s առաջ",s:"մի քանի վայրկյան",m:"րոպե",mm:"%d րոպե",h:"ժամ",hh:"%d ժամ",d:"օր",dd:"%d օր",M:"ամիս",MM:"%d ամիս",y:"տարի",yy:"%d տարի"},meridiem:function(e){return 4>e?"գիշերվա":12>e?"առավոտվա":17>e?"ցերեկվա":"երեկոյան"},ordinal:function(e,t){switch(t){case"DDD":case"w":case"W":case"DDDo":return 1===e?e+"-ին":e+"-րդ";default:return e}},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("id",{months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des".split("_"),weekdays:"Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu".split("_"),weekdaysShort:"Min_Sen_Sel_Rab_Kam_Jum_Sab".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sb".split("_"),longDateFormat:{LT:"HH.mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] LT",LLLL:"dddd, D MMMM YYYY [pukul] LT"},meridiem:function(e){return 11>e?"pagi":15>e?"siang":19>e?"sore":"malam"},calendar:{sameDay:"[Hari ini pukul] LT",nextDay:"[Besok pukul] LT",nextWeek:"dddd [pukul] LT",lastDay:"[Kemarin pukul] LT",lastWeek:"dddd [lalu pukul] LT",sameElse:"L"},relativeTime:{future:"dalam %s",past:"%s yang lalu",s:"beberapa detik",m:"semenit",mm:"%d menit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){function t(e){return e%100===11?!0:e%10===1?!1:!0}function a(e,a,n,_){var s=e+" ";switch(n){case"s":return a||_?"nokkrar sekúndur":"nokkrum sekúndum";case"m":return a?"mínúta":"mínútu";case"mm":return t(e)?s+(a||_?"mínútur":"mínútum"):a?s+"mínúta":s+"mínútu";case"hh":return t(e)?s+(a||_?"klukkustundir":"klukkustundum"):s+"klukkustund";case"d":return a?"dagur":_?"dag":"degi";case"dd":return t(e)?a?s+"dagar":s+(_?"daga":"dögum"):a?s+"dagur":s+(_?"dag":"degi");case"M":return a?"mánuður":_?"mánuð":"mánuði";case"MM":return t(e)?a?s+"mánuðir":s+(_?"mánuði":"mánuðum"):a?s+"mánuður":s+(_?"mánuð":"mánuði");case"y":return a||_?"ár":"ári";case"yy":return t(e)?s+(a||_?"ár":"árum"):s+(a||_?"ár":"ári")}}return e.defineLocale("is",{months:"janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember".split("_"),monthsShort:"jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des".split("_"),weekdays:"sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur".split("_"),weekdaysShort:"sun_mán_þri_mið_fim_fös_lau".split("_"),weekdaysMin:"Su_Má_Þr_Mi_Fi_Fö_La".split("_"),longDateFormat:{LT:"H:mm",L:"DD/MM/YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] LT",LLLL:"dddd, D. MMMM YYYY [kl.] LT"},calendar:{sameDay:"[í dag kl.] LT",nextDay:"[á morgun kl.] LT",nextWeek:"dddd [kl.] LT",lastDay:"[í gær kl.] LT",lastWeek:"[síðasta] dddd [kl.] LT",sameElse:"L"},relativeTime:{future:"eftir %s",past:"fyrir %s síðan",s:a,m:a,mm:a,h:"klukkustund",hh:a,d:a,dd:a,M:a,MM:a,y:a,yy:a},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("it",{months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),weekdays:"Domenica_Lunedì_Martedì_Mercoledì_Giovedì_Venerdì_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),weekdaysMin:"D_L_Ma_Me_G_V_S".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Oggi alle] LT",nextDay:"[Domani alle] LT",nextWeek:"dddd [alle] LT",lastDay:"[Ieri alle] LT",lastWeek:"[lo scorso] dddd [alle] LT",sameElse:"L"},relativeTime:{future:function(e){return(/^[0-9].+$/.test(e)?"tra":"in")+" "+e},past:"%s fa",s:"alcuni secondi",m:"un minuto",mm:"%d minuti",h:"un'ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:"%dº",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("ja",{months:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),weekdaysShort:"日_月_火_水_木_金_土".split("_"),weekdaysMin:"日_月_火_水_木_金_土".split("_"),longDateFormat:{LT:"Ah時m分",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日LT",LLLL:"YYYY年M月D日LT dddd"},meridiem:function(e){return 12>e?"午前":"午後"},calendar:{sameDay:"[今日] LT",nextDay:"[明日] LT",nextWeek:"[来週]dddd LT",lastDay:"[昨日] LT",lastWeek:"[前週]dddd LT",sameElse:"L"},relativeTime:{future:"%s後",past:"%s前",s:"数秒",m:"1分",mm:"%d分",h:"1時間",hh:"%d時間",d:"1日",dd:"%d日",M:"1ヶ月",MM:"%dヶ月",y:"1年",yy:"%d年"}})}),function(e){e(ft)}(function(e){function t(e,t){var a={nominative:"იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი".split("_"),accusative:"იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს".split("_")},n=/D[oD] *MMMM?/.test(t)?"accusative":"nominative";return a[n][e.month()]}function a(e,t){var a={nominative:"კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი".split("_"),accusative:"კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს".split("_")},n=/(წინა|შემდეგ)/.test(t)?"accusative":"nominative";return a[n][e.day()]}return e.defineLocale("ka",{months:t,monthsShort:"იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ".split("_"),weekdays:a,weekdaysShort:"კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ".split("_"),weekdaysMin:"კვ_ორ_სა_ოთ_ხუ_პა_შა".split("_"),longDateFormat:{LT:"h:mm A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[დღეს] LT[-ზე]",nextDay:"[ხვალ] LT[-ზე]",lastDay:"[გუშინ] LT[-ზე]",nextWeek:"[შემდეგ] dddd LT[-ზე]",lastWeek:"[წინა] dddd LT-ზე",sameElse:"L"},relativeTime:{future:function(e){return/(წამი|წუთი|საათი|წელი)/.test(e)?e.replace(/ი$/,"ში"):e+"ში"},past:function(e){return/(წამი|წუთი|საათი|დღე|თვე)/.test(e)?e.replace(/(ი|ე)$/,"ის წინ"):/წელი/.test(e)?e.replace(/წელი$/,"წლის წინ"):void 0},s:"რამდენიმე წამი",m:"წუთი",mm:"%d წუთი",h:"საათი",hh:"%d საათი",d:"დღე",dd:"%d დღე",M:"თვე",MM:"%d თვე",y:"წელი",yy:"%d წელი"},ordinal:function(e){return 0===e?e:1===e?e+"-ლი":20>e||100>=e&&e%20===0||e%100===0?"მე-"+e:e+"-ე"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("km",{months:"មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),monthsShort:"មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekdays:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),weekdaysShort:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),weekdaysMin:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[ថ្ងៃនៈ ម៉ោង] LT",nextDay:"[ស្អែក ម៉ោង] LT",nextWeek:"dddd [ម៉ោង] LT",lastDay:"[ម្សិលមិញ ម៉ោង] LT",lastWeek:"dddd [សប្តាហ៍មុន] [ម៉ោង] LT",sameElse:"L"},relativeTime:{future:"%sទៀត",past:"%sមុន",s:"ប៉ុន្មានវិនាទី",m:"មួយនាទី",mm:"%d នាទី",h:"មួយម៉ោង",hh:"%d ម៉ោង",d:"មួយថ្ងៃ",dd:"%d ថ្ងៃ",M:"មួយខែ",MM:"%d ខែ",y:"មួយឆ្នាំ",yy:"%d ឆ្នាំ"},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("ko",{months:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),monthsShort:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),weekdays:"일요일_월요일_화요일_수요일_목요일_금요일_토요일".split("_"),weekdaysShort:"일_월_화_수_목_금_토".split("_"),weekdaysMin:"일_월_화_수_목_금_토".split("_"),longDateFormat:{LT:"A h시 m분",L:"YYYY.MM.DD",LL:"YYYY년 MMMM D일",LLL:"YYYY년 MMMM D일 LT",LLLL:"YYYY년 MMMM D일 dddd LT"},meridiem:function(e){return 12>e?"오전":"오후"},calendar:{sameDay:"오늘 LT",nextDay:"내일 LT",nextWeek:"dddd LT",lastDay:"어제 LT",lastWeek:"지난주 dddd LT",sameElse:"L"},relativeTime:{future:"%s 후",past:"%s 전",s:"몇초",ss:"%d초",m:"일분",mm:"%d분",h:"한시간",hh:"%d시간",d:"하루",dd:"%d일",M:"한달",MM:"%d달",y:"일년",yy:"%d년"},ordinal:"%d일",meridiemParse:/(오전|오후)/,isPM:function(e){return"오후"===e}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n={m:["eng Minutt","enger Minutt"],h:["eng Stonn","enger Stonn"],d:["een Dag","engem Dag"],M:["ee Mount","engem Mount"],y:["ee Joer","engem Joer"]};return t?n[a][0]:n[a][1]}function a(e){var t=e.substr(0,e.indexOf(" "));return _(t)?"a "+e:"an "+e}function n(e){var t=e.substr(0,e.indexOf(" "));return _(t)?"viru "+e:"virun "+e}function _(e){if(e=parseInt(e,10),isNaN(e))return!1;if(0>e)return!0;if(10>e)return e>=4&&7>=e?!0:!1;if(100>e){var t=e%10,a=e/10;return _(0===t?a:t)}if(1e4>e){for(;e>=10;)e/=10;return _(e)}return e/=1e3,_(e)}return e.defineLocale("lb",{months:"Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdays:"Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg".split("_"),weekdaysShort:"So._Mé._Dë._Më._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mé_Dë_Më_Do_Fr_Sa".split("_"),longDateFormat:{LT:"H:mm [Auer]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[Haut um] LT",sameElse:"L",nextDay:"[Muer um] LT",nextWeek:"dddd [um] LT",lastDay:"[Gëschter um] LT",lastWeek:function(){switch(this.day()){case 2:case 4:return"[Leschten] dddd [um] LT";default:return"[Leschte] dddd [um] LT"}}},relativeTime:{future:a,past:n,s:"e puer Sekonnen",m:t,mm:"%d Minutten",h:t,hh:"%d Stonnen",d:t,dd:"%d Deeg",M:t,MM:"%d Méint",y:t,yy:"%d Joer"},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a,n){return t?"kelios sekundės":n?"kelių sekundžių":"kelias sekundes"}function a(e,t,a,n){return t?_(a)[0]:n?_(a)[1]:_(a)[2]}function n(e){return e%10===0||e>10&&20>e}function _(e){return d[e].split("_")}function s(e,t,s,r){var d=e+" ";return 1===e?d+a(e,t,s[0],r):t?d+(n(e)?_(s)[1]:_(s)[0]):r?d+_(s)[1]:d+(n(e)?_(s)[1]:_(s)[2])}function r(e,t){var a=-1===t.indexOf("dddd HH:mm"),n=i[e.day()];return a?n:n.substring(0,n.length-2)+"į"}var d={m:"minutė_minutės_minutę",mm:"minutės_minučių_minutes",h:"valanda_valandos_valandą",hh:"valandos_valandų_valandas",d:"diena_dienos_dieną",dd:"dienos_dienų_dienas",M:"mėnuo_mėnesio_mėnesį",MM:"mėnesiai_mėnesių_mėnesius",y:"metai_metų_metus",yy:"metai_metų_metus"},i="sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis".split("_");return e.defineLocale("lt",{months:"sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio".split("_"),monthsShort:"sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd".split("_"),weekdays:r,weekdaysShort:"Sek_Pir_Ant_Tre_Ket_Pen_Šeš".split("_"),weekdaysMin:"S_P_A_T_K_Pn_Š".split("_"),longDateFormat:{LT:"HH:mm",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], LT [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, LT [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], LT [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, LT [val.]"},calendar:{sameDay:"[Šiandien] LT",nextDay:"[Rytoj] LT",nextWeek:"dddd LT",lastDay:"[Vakar] LT",lastWeek:"[Praėjusį] dddd LT",sameElse:"L"},relativeTime:{future:"po %s",past:"prieš %s",s:t,m:a,mm:s,h:a,hh:s,d:a,dd:s,M:a,MM:s,y:a,yy:s},ordinal:function(e){return e+"-oji"},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n=e.split("_");return a?t%10===1&&11!==t?n[2]:n[3]:t%10===1&&11!==t?n[0]:n[1]}function a(e,a,_){return e+" "+t(n[_],e,a)}var n={mm:"minūti_minūtes_minūte_minūtes",hh:"stundu_stundas_stunda_stundas",dd:"dienu_dienas_diena_dienas",MM:"mēnesi_mēnešus_mēnesis_mēneši",yy:"gadu_gadus_gads_gadi"};return e.defineLocale("lv",{months:"janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris".split("_"),monthsShort:"jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec".split("_"),weekdays:"svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena".split("_"),weekdaysShort:"Sv_P_O_T_C_Pk_S".split("_"),weekdaysMin:"Sv_P_O_T_C_Pk_S".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"YYYY. [gada] D. MMMM",LLL:"YYYY. [gada] D. MMMM, LT",LLLL:"YYYY. [gada] D. MMMM, dddd, LT"},calendar:{sameDay:"[Šodien pulksten] LT",nextDay:"[Rīt pulksten] LT",nextWeek:"dddd [pulksten] LT",lastDay:"[Vakar pulksten] LT",lastWeek:"[Pagājušā] dddd [pulksten] LT",sameElse:"L"},relativeTime:{future:"%s vēlāk",past:"%s agrāk",s:"dažas sekundes",m:"minūti",mm:a,h:"stundu",hh:a,d:"dienu",dd:a,M:"mēnesi",MM:a,y:"gadu",yy:a},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("mk",{months:"јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември".split("_"),monthsShort:"јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек".split("_"),weekdays:"недела_понеделник_вторник_среда_четврток_петок_сабота".split("_"),weekdaysShort:"нед_пон_вто_сре_чет_пет_саб".split("_"),weekdaysMin:"нe_пo_вт_ср_че_пе_сa".split("_"),longDateFormat:{LT:"H:mm",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Денес во] LT",nextDay:"[Утре во] LT",nextWeek:"dddd [во] LT",lastDay:"[Вчера во] LT",lastWeek:function(){switch(this.day()){case 0:case 3:case 6:return"[Во изминатата] dddd [во] LT";case 1:case 2:case 4:case 5:return"[Во изминатиот] dddd [во] LT"}},sameElse:"L"},relativeTime:{future:"после %s",past:"пред %s",s:"неколку секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеци",y:"година",yy:"%d години"},ordinal:function(e){var t=e%10,a=e%100;return 0===e?e+"-ев":0===a?e+"-ен":a>10&&20>a?e+"-ти":1===t?e+"-ви":2===t?e+"-ри":7===t||8===t?e+"-ми":e+"-ти"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("ml",{months:"ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ".split("_"),monthsShort:"ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.".split("_"),weekdays:"ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച".split("_"),weekdaysShort:"ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി".split("_"),weekdaysMin:"ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ".split("_"),longDateFormat:{LT:"A h:mm -നു",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},calendar:{sameDay:"[ഇന്ന്] LT",nextDay:"[നാളെ] LT",nextWeek:"dddd, LT",lastDay:"[ഇന്നലെ] LT",lastWeek:"[കഴിഞ്ഞ] dddd, LT",sameElse:"L"},relativeTime:{future:"%s കഴിഞ്ഞ്",past:"%s മുൻപ്",s:"അൽപ നിമിഷങ്ങൾ",m:"ഒരു മിനിറ്റ്",mm:"%d മിനിറ്റ്",h:"ഒരു മണിക്കൂർ",hh:"%d മണിക്കൂർ",d:"ഒരു ദിവസം",dd:"%d ദിവസം",M:"ഒരു മാസം",MM:"%d മാസം",y:"ഒരു വർഷം",yy:"%d വർഷം"},meridiem:function(e){return 4>e?"രാത്രി":12>e?"രാവിലെ":17>e?"ഉച്ച കഴിഞ്ഞ്":20>e?"വൈകുന്നേരം":"രാത്രി"}})}),function(e){e(ft)}(function(e){var t={1:"१",2:"२",3:"३",4:"४",5:"५",6:"६",7:"७",8:"८",9:"९",0:"०"},a={"१":"1","२":"2","३":"3","४":"4","५":"5","६":"6","७":"7","८":"8","९":"9","०":"0"};return e.defineLocale("mr",{months:"जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर".split("_"),monthsShort:"जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.".split("_"),weekdays:"रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),weekdaysShort:"रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),longDateFormat:{LT:"A h:mm वाजता",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},calendar:{sameDay:"[आज] LT",nextDay:"[उद्या] LT",nextWeek:"dddd, LT",lastDay:"[काल] LT",lastWeek:"[मागील] dddd, LT",sameElse:"L"},relativeTime:{future:"%s नंतर",past:"%s पूर्वी",s:"सेकंद",m:"एक मिनिट",mm:"%d मिनिटे",h:"एक तास",hh:"%d तास",d:"एक दिवस",dd:"%d दिवस",M:"एक महिना",MM:"%d महिने",y:"एक वर्ष",yy:"%d वर्षे"},preparse:function(e){return e.replace(/[१२३४५६७८९०]/g,function(e){return a[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]})},meridiem:function(e){return 4>e?"रात्री":10>e?"सकाळी":17>e?"दुपारी":20>e?"सायंकाळी":"रात्री"},week:{dow:0,doy:6}})}),function(e){e(ft)}(function(e){return e.defineLocale("ms-my",{months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),longDateFormat:{LT:"HH.mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] LT",LLLL:"dddd, D MMMM YYYY [pukul] LT"},meridiem:function(e){return 11>e?"pagi":15>e?"tengahari":19>e?"petang":"malam"},calendar:{sameDay:"[Hari ini pukul] LT",nextDay:"[Esok pukul] LT",nextWeek:"dddd [pukul] LT",lastDay:"[Kelmarin pukul] LT",lastWeek:"dddd [lepas pukul] LT",sameElse:"L"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){var t={1:"၁",2:"၂",3:"၃",4:"၄",5:"၅",6:"၆",7:"၇",8:"၈",9:"၉",0:"၀"},a={"၁":"1","၂":"2","၃":"3","၄":"4","၅":"5","၆":"6","၇":"7","၈":"8","၉":"9","၀":"0"};
+return e.defineLocale("my",{months:"ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ".split("_"),monthsShort:"ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ".split("_"),weekdays:"တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ".split("_"),weekdaysShort:"နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),weekdaysMin:"နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[ယနေ.] LT [မှာ]",nextDay:"[မနက်ဖြန်] LT [မှာ]",nextWeek:"dddd LT [မှာ]",lastDay:"[မနေ.က] LT [မှာ]",lastWeek:"[ပြီးခဲ့သော] dddd LT [မှာ]",sameElse:"L"},relativeTime:{future:"လာမည့် %s မှာ",past:"လွန်ခဲ့သော %s က",s:"စက္ကန်.အနည်းငယ်",m:"တစ်မိနစ်",mm:"%d မိနစ်",h:"တစ်နာရီ",hh:"%d နာရီ",d:"တစ်ရက်",dd:"%d ရက်",M:"တစ်လ",MM:"%d လ",y:"တစ်နှစ်",yy:"%d နှစ်"},preparse:function(e){return e.replace(/[၁၂၃၄၅၆၇၈၉၀]/g,function(e){return a[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]})},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("nb",{months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn_man_tirs_ons_tors_fre_lør".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),longDateFormat:{LT:"H.mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] LT",LLLL:"dddd D. MMMM YYYY [kl.] LT"},calendar:{sameDay:"[i dag kl.] LT",nextDay:"[i morgen kl.] LT",nextWeek:"dddd [kl.] LT",lastDay:"[i går kl.] LT",lastWeek:"[forrige] dddd [kl.] LT",sameElse:"L"},relativeTime:{future:"om %s",past:"for %s siden",s:"noen sekunder",m:"ett minutt",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dager",M:"en måned",MM:"%d måneder",y:"ett år",yy:"%d år"},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){var t={1:"१",2:"२",3:"३",4:"४",5:"५",6:"६",7:"७",8:"८",9:"९",0:"०"},a={"१":"1","२":"2","३":"3","४":"4","५":"5","६":"6","७":"7","८":"8","९":"9","०":"0"};return e.defineLocale("ne",{months:"जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर".split("_"),monthsShort:"जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.".split("_"),weekdays:"आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार".split("_"),weekdaysShort:"आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.".split("_"),weekdaysMin:"आइ._सो._मङ्_बु._बि._शु._श.".split("_"),longDateFormat:{LT:"Aको h:mm बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},preparse:function(e){return e.replace(/[१२३४५६७८९०]/g,function(e){return a[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return t[e]})},meridiem:function(e){return 3>e?"राती":10>e?"बिहान":15>e?"दिउँसो":18>e?"बेलुका":20>e?"साँझ":"राती"},calendar:{sameDay:"[आज] LT",nextDay:"[भोली] LT",nextWeek:"[आउँदो] dddd[,] LT",lastDay:"[हिजो] LT",lastWeek:"[गएको] dddd[,] LT",sameElse:"L"},relativeTime:{future:"%sमा",past:"%s अगाडी",s:"केही समय",m:"एक मिनेट",mm:"%d मिनेट",h:"एक घण्टा",hh:"%d घण्टा",d:"एक दिन",dd:"%d दिन",M:"एक महिना",MM:"%d महिना",y:"एक बर्ष",yy:"%d बर्ष"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){var t="jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),a="jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_");return e.defineLocale("nl",{months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:function(e,n){return/-MMM-/.test(n)?a[e.month()]:t[e.month()]},weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"Zo_Ma_Di_Wo_Do_Vr_Za".split("_"),longDateFormat:{LT:"HH:mm",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[vandaag om] LT",nextDay:"[morgen om] LT",nextWeek:"dddd [om] LT",lastDay:"[gisteren om] LT",lastWeek:"[afgelopen] dddd [om] LT",sameElse:"L"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuut",mm:"%d minuten",h:"één uur",hh:"%d uur",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaar"},ordinal:function(e){return e+(1===e||8===e||e>=20?"ste":"de")},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("nn",{months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdays:"sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag".split("_"),weekdaysShort:"sun_mån_tys_ons_tor_fre_lau".split("_"),weekdaysMin:"su_må_ty_on_to_fr_lø".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[I dag klokka] LT",nextDay:"[I morgon klokka] LT",nextWeek:"dddd [klokka] LT",lastDay:"[I går klokka] LT",lastWeek:"[Føregåande] dddd [klokka] LT",sameElse:"L"},relativeTime:{future:"om %s",past:"for %s sidan",s:"nokre sekund",m:"eit minutt",mm:"%d minutt",h:"ein time",hh:"%d timar",d:"ein dag",dd:"%d dagar",M:"ein månad",MM:"%d månader",y:"eit år",yy:"%d år"},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e){return 5>e%10&&e%10>1&&~~(e/10)%10!==1}function a(e,a,n){var _=e+" ";switch(n){case"m":return a?"minuta":"minutę";case"mm":return _+(t(e)?"minuty":"minut");case"h":return a?"godzina":"godzinę";case"hh":return _+(t(e)?"godziny":"godzin");case"MM":return _+(t(e)?"miesiące":"miesięcy");case"yy":return _+(t(e)?"lata":"lat")}}var n="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),_="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_");return e.defineLocale("pl",{months:function(e,t){return/D MMMM/.test(t)?_[e.month()]:n[e.month()]},monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"nie_pon_wt_śr_czw_pt_sb".split("_"),weekdaysMin:"N_Pn_Wt_Śr_Cz_Pt_So".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Dziś o] LT",nextDay:"[Jutro o] LT",nextWeek:"[W] dddd [o] LT",lastDay:"[Wczoraj o] LT",lastWeek:function(){switch(this.day()){case 0:return"[W zeszłą niedzielę o] LT";case 3:return"[W zeszłą środę o] LT";case 6:return"[W zeszłą sobotę o] LT";default:return"[W zeszły] dddd [o] LT"}},sameElse:"L"},relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:a,mm:a,h:a,hh:a,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:a,y:"rok",yy:a},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("pt-br",{months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sáb".split("_"),weekdaysMin:"dom_2ª_3ª_4ª_5ª_6ª_sáb".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] LT",LLLL:"dddd, D [de] MMMM [de] YYYY [às] LT"},calendar:{sameDay:"[Hoje às] LT",nextDay:"[Amanhã às] LT",nextWeek:"dddd [às] LT",lastDay:"[Ontem às] LT",lastWeek:function(){return 0===this.day()||6===this.day()?"[Último] dddd [às] LT":"[Última] dddd [às] LT"},sameElse:"L"},relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:"%dº"})}),function(e){e(ft)}(function(e){return e.defineLocale("pt",{months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sáb".split("_"),weekdaysMin:"dom_2ª_3ª_4ª_5ª_6ª_sáb".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY LT",LLLL:"dddd, D [de] MMMM [de] YYYY LT"},calendar:{sameDay:"[Hoje às] LT",nextDay:"[Amanhã às] LT",nextWeek:"dddd [às] LT",lastDay:"[Ontem às] LT",lastWeek:function(){return 0===this.day()||6===this.day()?"[Último] dddd [às] LT":"[Última] dddd [às] LT"},sameElse:"L"},relativeTime:{future:"em %s",past:"há %s",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:"%dº",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n={mm:"minute",hh:"ore",dd:"zile",MM:"luni",yy:"ani"},_=" ";return(e%100>=20||e>=100&&e%100===0)&&(_=" de "),e+_+n[a]}return e.defineLocale("ro",{months:"ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie".split("_"),monthsShort:"ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.".split("_"),weekdays:"duminică_luni_marți_miercuri_joi_vineri_sâmbătă".split("_"),weekdaysShort:"Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"),weekdaysMin:"Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"),longDateFormat:{LT:"H:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},calendar:{sameDay:"[azi la] LT",nextDay:"[mâine la] LT",nextWeek:"dddd [la] LT",lastDay:"[ieri la] LT",lastWeek:"[fosta] dddd [la] LT",sameElse:"L"},relativeTime:{future:"peste %s",past:"%s în urmă",s:"câteva secunde",m:"un minut",mm:t,h:"o oră",hh:t,d:"o zi",dd:t,M:"o lună",MM:t,y:"un an",yy:t},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){function t(e,t){var a=e.split("_");return t%10===1&&t%100!==11?a[0]:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?a[1]:a[2]}function a(e,a,n){var _={mm:a?"минута_минуты_минут":"минуту_минуты_минут",hh:"час_часа_часов",dd:"день_дня_дней",MM:"месяц_месяца_месяцев",yy:"год_года_лет"};return"m"===n?a?"минута":"минуту":e+" "+t(_[n],+e)}function n(e,t){var a={nominative:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),accusative:"января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря".split("_")},n=/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/.test(t)?"accusative":"nominative";return a[n][e.month()]}function _(e,t){var a={nominative:"янв_фев_мар_апр_май_июнь_июль_авг_сен_окт_ноя_дек".split("_"),accusative:"янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек".split("_")},n=/D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/.test(t)?"accusative":"nominative";return a[n][e.month()]}function s(e,t){var a={nominative:"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота".split("_"),accusative:"воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу".split("_")},n=/\[ ?[Вв] ?(?:прошлую|следующую)? ?\] ?dddd/.test(t)?"accusative":"nominative";return a[n][e.day()]}return e.defineLocale("ru",{months:n,monthsShort:_,weekdays:s,weekdaysShort:"вс_пн_вт_ср_чт_пт_сб".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),monthsParse:[/^янв/i,/^фев/i,/^мар/i,/^апр/i,/^ма[й|я]/i,/^июн/i,/^июл/i,/^авг/i,/^сен/i,/^окт/i,/^ноя/i,/^дек/i],longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., LT",LLLL:"dddd, D MMMM YYYY г., LT"},calendar:{sameDay:"[Сегодня в] LT",nextDay:"[Завтра в] LT",lastDay:"[Вчера в] LT",nextWeek:function(){return 2===this.day()?"[Во] dddd [в] LT":"[В] dddd [в] LT"},lastWeek:function(){switch(this.day()){case 0:return"[В прошлое] dddd [в] LT";case 1:case 2:case 4:return"[В прошлый] dddd [в] LT";case 3:case 5:case 6:return"[В прошлую] dddd [в] LT"}},sameElse:"L"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",m:a,mm:a,h:"час",hh:a,d:"день",dd:a,M:"месяц",MM:a,y:"год",yy:a},meridiemParse:/ночи|утра|дня|вечера/i,isPM:function(e){return/^(дня|вечера)$/.test(e)},meridiem:function(e){return 4>e?"ночи":12>e?"утра":17>e?"дня":"вечера"},ordinal:function(e,t){switch(t){case"M":case"d":case"DDD":return e+"-й";case"D":return e+"-го";case"w":case"W":return e+"-я";default:return e}},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){function t(e){return e>1&&5>e}function a(e,a,n,_){var s=e+" ";switch(n){case"s":return a||_?"pár sekúnd":"pár sekundami";case"m":return a?"minúta":_?"minútu":"minútou";case"mm":return a||_?s+(t(e)?"minúty":"minút"):s+"minútami";break;case"h":return a?"hodina":_?"hodinu":"hodinou";case"hh":return a||_?s+(t(e)?"hodiny":"hodín"):s+"hodinami";break;case"d":return a||_?"deň":"dňom";case"dd":return a||_?s+(t(e)?"dni":"dní"):s+"dňami";break;case"M":return a||_?"mesiac":"mesiacom";case"MM":return a||_?s+(t(e)?"mesiace":"mesiacov"):s+"mesiacmi";break;case"y":return a||_?"rok":"rokom";case"yy":return a||_?s+(t(e)?"roky":"rokov"):s+"rokmi"}}var n="január_február_marec_apríl_máj_jún_júl_august_september_október_november_december".split("_"),_="jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec".split("_");return e.defineLocale("sk",{months:n,monthsShort:_,monthsParse:function(e,t){var a,n=[];for(a=0;12>a;a++)n[a]=new RegExp("^"+e[a]+"$|^"+t[a]+"$","i");return n}(n,_),weekdays:"nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota".split("_"),weekdaysShort:"ne_po_ut_st_št_pi_so".split("_"),weekdaysMin:"ne_po_ut_st_št_pi_so".split("_"),longDateFormat:{LT:"H:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd D. MMMM YYYY LT"},calendar:{sameDay:"[dnes o] LT",nextDay:"[zajtra o] LT",nextWeek:function(){switch(this.day()){case 0:return"[v nedeľu o] LT";case 1:case 2:return"[v] dddd [o] LT";case 3:return"[v stredu o] LT";case 4:return"[vo štvrtok o] LT";case 5:return"[v piatok o] LT";case 6:return"[v sobotu o] LT"}},lastDay:"[včera o] LT",lastWeek:function(){switch(this.day()){case 0:return"[minulú nedeľu o] LT";case 1:case 2:return"[minulý] dddd [o] LT";case 3:return"[minulú stredu o] LT";case 4:case 5:return"[minulý] dddd [o] LT";case 6:return"[minulú sobotu o] LT"}},sameElse:"L"},relativeTime:{future:"za %s",past:"pred %s",s:a,m:a,mm:a,h:a,hh:a,d:a,dd:a,M:a,MM:a,y:a,yy:a},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){function t(e,t,a){var n=e+" ";switch(a){case"m":return t?"ena minuta":"eno minuto";case"mm":return n+=1===e?"minuta":2===e?"minuti":3===e||4===e?"minute":"minut";case"h":return t?"ena ura":"eno uro";case"hh":return n+=1===e?"ura":2===e?"uri":3===e||4===e?"ure":"ur";case"dd":return n+=1===e?"dan":"dni";case"MM":return n+=1===e?"mesec":2===e?"meseca":3===e||4===e?"mesece":"mesecev";case"yy":return n+=1===e?"leto":2===e?"leti":3===e||4===e?"leta":"let"}}return e.defineLocale("sl",{months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),longDateFormat:{LT:"H:mm",L:"DD. MM. YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[danes ob] LT",nextDay:"[jutri ob] LT",nextWeek:function(){switch(this.day()){case 0:return"[v] [nedeljo] [ob] LT";case 3:return"[v] [sredo] [ob] LT";case 6:return"[v] [soboto] [ob] LT";case 1:case 2:case 4:case 5:return"[v] dddd [ob] LT"}},lastDay:"[včeraj ob] LT",lastWeek:function(){switch(this.day()){case 0:case 3:case 6:return"[prejšnja] dddd [ob] LT";case 1:case 2:case 4:case 5:return"[prejšnji] dddd [ob] LT"}},sameElse:"L"},relativeTime:{future:"čez %s",past:"%s nazaj",s:"nekaj sekund",m:t,mm:t,h:t,hh:t,d:"en dan",dd:t,M:"en mesec",MM:t,y:"eno leto",yy:t},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("sq",{months:"Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor".split("_"),monthsShort:"Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj".split("_"),weekdays:"E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë".split("_"),weekdaysShort:"Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),weekdaysMin:"D_H_Ma_Më_E_P_Sh".split("_"),meridiem:function(e){return 12>e?"PD":"MD"},longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[Sot në] LT",nextDay:"[Nesër në] LT",nextWeek:"dddd [në] LT",lastDay:"[Dje në] LT",lastWeek:"dddd [e kaluar në] LT",sameElse:"L"},relativeTime:{future:"në %s",past:"%s më parë",s:"disa sekonda",m:"një minutë",mm:"%d minuta",h:"një orë",hh:"%d orë",d:"një ditë",dd:"%d ditë",M:"një muaj",MM:"%d muaj",y:"një vit",yy:"%d vite"},ordinal:"%d.",week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){var t={words:{m:["један минут","једне минуте"],mm:["минут","минуте","минута"],h:["један сат","једног сата"],hh:["сат","сата","сати"],dd:["дан","дана","дана"],MM:["месец","месеца","месеци"],yy:["година","године","година"]},correctGrammaticalCase:function(e,t){return 1===e?t[0]:e>=2&&4>=e?t[1]:t[2]},translate:function(e,a,n){var _=t.words[n];return 1===n.length?a?_[0]:_[1]:e+" "+t.correctGrammaticalCase(e,_)}};return e.defineLocale("sr-cyrl",{months:["јануар","фебруар","март","април","мај","јун","јул","август","септембар","октобар","новембар","децембар"],monthsShort:["јан.","феб.","мар.","апр.","мај","јун","јул","авг.","сеп.","окт.","нов.","дец."],weekdays:["недеља","понедељак","уторак","среда","четвртак","петак","субота"],weekdaysShort:["нед.","пон.","уто.","сре.","чет.","пет.","суб."],weekdaysMin:["не","по","ут","ср","че","пе","су"],longDateFormat:{LT:"H:mm",L:"DD. MM. YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[данас у] LT",nextDay:"[сутра у] LT",nextWeek:function(){switch(this.day()){case 0:return"[у] [недељу] [у] LT";case 3:return"[у] [среду] [у] LT";case 6:return"[у] [суботу] [у] LT";case 1:case 2:case 4:case 5:return"[у] dddd [у] LT"}},lastDay:"[јуче у] LT",lastWeek:function(){var e=["[прошле] [недеље] [у] LT","[прошлог] [понедељка] [у] LT","[прошлог] [уторка] [у] LT","[прошле] [среде] [у] LT","[прошлог] [четвртка] [у] LT","[прошлог] [петка] [у] LT","[прошле] [суботе] [у] LT"];return e[this.day()]},sameElse:"L"},relativeTime:{future:"за %s",past:"пре %s",s:"неколико секунди",m:t.translate,mm:t.translate,h:t.translate,hh:t.translate,d:"дан",dd:t.translate,M:"месец",MM:t.translate,y:"годину",yy:t.translate},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){var t={words:{m:["jedan minut","jedne minute"],mm:["minut","minute","minuta"],h:["jedan sat","jednog sata"],hh:["sat","sata","sati"],dd:["dan","dana","dana"],MM:["mesec","meseca","meseci"],yy:["godina","godine","godina"]},correctGrammaticalCase:function(e,t){return 1===e?t[0]:e>=2&&4>=e?t[1]:t[2]},translate:function(e,a,n){var _=t.words[n];return 1===n.length?a?_[0]:_[1]:e+" "+t.correctGrammaticalCase(e,_)}};return e.defineLocale("sr",{months:["januar","februar","mart","april","maj","jun","jul","avgust","septembar","oktobar","novembar","decembar"],monthsShort:["jan.","feb.","mar.","apr.","maj","jun","jul","avg.","sep.","okt.","nov.","dec."],weekdays:["nedelja","ponedeljak","utorak","sreda","četvrtak","petak","subota"],weekdaysShort:["ned.","pon.","uto.","sre.","čet.","pet.","sub."],weekdaysMin:["ne","po","ut","sr","če","pe","su"],longDateFormat:{LT:"H:mm",L:"DD. MM. YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY LT",LLLL:"dddd, D. MMMM YYYY LT"},calendar:{sameDay:"[danas u] LT",nextDay:"[sutra u] LT",nextWeek:function(){switch(this.day()){case 0:return"[u] [nedelju] [u] LT";case 3:return"[u] [sredu] [u] LT";case 6:return"[u] [subotu] [u] LT";case 1:case 2:case 4:case 5:return"[u] dddd [u] LT"}},lastDay:"[juče u] LT",lastWeek:function(){var e=["[prošle] [nedelje] [u] LT","[prošlog] [ponedeljka] [u] LT","[prošlog] [utorka] [u] LT","[prošle] [srede] [u] LT","[prošlog] [četvrtka] [u] LT","[prošlog] [petka] [u] LT","[prošle] [subote] [u] LT"];return e[this.day()]},sameElse:"L"},relativeTime:{future:"za %s",past:"pre %s",s:"nekoliko sekundi",m:t.translate,mm:t.translate,h:t.translate,hh:t.translate,d:"dan",dd:t.translate,M:"mesec",MM:t.translate,y:"godinu",yy:t.translate},ordinal:"%d.",week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("sv",{months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),longDateFormat:{LT:"HH:mm",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[Idag] LT",nextDay:"[Imorgon] LT",lastDay:"[Igår] LT",nextWeek:"dddd LT",lastWeek:"[Förra] dddd[en] LT",sameElse:"L"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"},ordinal:function(e){var t=e%10,a=1===~~(e%100/10)?"e":1===t?"a":2===t?"a":3===t?"e":"e";return e+a},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("ta",{months:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),monthsShort:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdays:"ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை".split("_"),weekdaysShort:"ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி".split("_"),weekdaysMin:"ஞா_தி_செ_பு_வி_வெ_ச".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, LT",LLLL:"dddd, D MMMM YYYY, LT"},calendar:{sameDay:"[இன்று] LT",nextDay:"[நாளை] LT",nextWeek:"dddd, LT",lastDay:"[நேற்று] LT",lastWeek:"[கடந்த வாரம்] dddd, LT",sameElse:"L"},relativeTime:{future:"%s இல்",past:"%s முன்",s:"ஒரு சில விநாடிகள்",m:"ஒரு நிமிடம்",mm:"%d நிமிடங்கள்",h:"ஒரு மணி நேரம்",hh:"%d மணி நேரம்",d:"ஒரு நாள்",dd:"%d நாட்கள்",M:"ஒரு மாதம்",MM:"%d மாதங்கள்",y:"ஒரு வருடம்",yy:"%d ஆண்டுகள்"},ordinal:function(e){return e+"வது"},meridiem:function(e){return e>=6&&10>=e?" காலை":e>=10&&14>=e?" நண்பகல்":e>=14&&18>=e?" எற்பாடு":e>=18&&20>=e?" மாலை":e>=20&&24>=e?" இரவு":e>=0&&6>=e?" வைகறை":void 0},week:{dow:0,doy:6}})}),function(e){e(ft)}(function(e){return e.defineLocale("th",{months:"มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),monthsShort:"มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา".split("_"),weekdays:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),weekdaysShort:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"),weekdaysMin:"อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),longDateFormat:{LT:"H นาฬิกา m นาที",L:"YYYY/MM/DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY เวลา LT",LLLL:"วันddddที่ D MMMM YYYY เวลา LT"},meridiem:function(e){return 12>e?"ก่อนเที่ยง":"หลังเที่ยง"},calendar:{sameDay:"[วันนี้ เวลา] LT",nextDay:"[พรุ่งนี้ เวลา] LT",nextWeek:"dddd[หน้า เวลา] LT",lastDay:"[เมื่อวานนี้ เวลา] LT",lastWeek:"[วัน]dddd[ที่แล้ว เวลา] LT",sameElse:"L"},relativeTime:{future:"อีก %s",past:"%sที่แล้ว",s:"ไม่กี่วินาที",m:"1 นาที",mm:"%d นาที",h:"1 ชั่วโมง",hh:"%d ชั่วโมง",d:"1 วัน",dd:"%d วัน",M:"1 เดือน",MM:"%d เดือน",y:"1 ปี",yy:"%d ปี"}})}),function(e){e(ft)}(function(e){return e.defineLocale("tl-ph",{months:"Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre".split("_"),monthsShort:"Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis".split("_"),weekdays:"Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado".split("_"),weekdaysShort:"Lin_Lun_Mar_Miy_Huw_Biy_Sab".split("_"),weekdaysMin:"Li_Lu_Ma_Mi_Hu_Bi_Sab".split("_"),longDateFormat:{LT:"HH:mm",L:"MM/D/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM DD, YYYY LT"},calendar:{sameDay:"[Ngayon sa] LT",nextDay:"[Bukas sa] LT",nextWeek:"dddd [sa] LT",lastDay:"[Kahapon sa] LT",lastWeek:"dddd [huling linggo] LT",sameElse:"L"},relativeTime:{future:"sa loob ng %s",past:"%s ang nakalipas",s:"ilang segundo",m:"isang minuto",mm:"%d minuto",h:"isang oras",hh:"%d oras",d:"isang araw",dd:"%d araw",M:"isang buwan",MM:"%d buwan",y:"isang taon",yy:"%d taon"},ordinal:function(e){return e},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){var t={1:"'inci",5:"'inci",8:"'inci",70:"'inci",80:"'inci",2:"'nci",7:"'nci",20:"'nci",50:"'nci",3:"'üncü",4:"'üncü",100:"'üncü",6:"'ncı",9:"'uncu",10:"'uncu",30:"'uncu",60:"'ıncı",90:"'ıncı"};return e.defineLocale("tr",{months:"Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık".split("_"),monthsShort:"Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara".split("_"),weekdays:"Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi".split("_"),weekdaysShort:"Paz_Pts_Sal_Çar_Per_Cum_Cts".split("_"),weekdaysMin:"Pz_Pt_Sa_Ça_Pe_Cu_Ct".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd, D MMMM YYYY LT"},calendar:{sameDay:"[bugün saat] LT",nextDay:"[yarın saat] LT",nextWeek:"[haftaya] dddd [saat] LT",lastDay:"[dün] LT",lastWeek:"[geçen hafta] dddd [saat] LT",sameElse:"L"},relativeTime:{future:"%s sonra",past:"%s önce",s:"birkaç saniye",m:"bir dakika",mm:"%d dakika",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir yıl",yy:"%d yıl"},ordinal:function(e){if(0===e)return e+"'ıncı";var a=e%10,n=e%100-a,_=e>=100?100:null;return e+(t[a]||t[n]||t[_])},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("tzm-latn",{months:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),monthsShort:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekdays:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),weekdaysShort:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),weekdaysMin:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[asdkh g] LT",nextDay:"[aska g] LT",nextWeek:"dddd [g] LT",lastDay:"[assant g] LT",lastWeek:"dddd [g] LT",sameElse:"L"},relativeTime:{future:"dadkh s yan %s",past:"yan %s",s:"imik",m:"minuḍ",mm:"%d minuḍ",h:"saɛa",hh:"%d tassaɛin",d:"ass",dd:"%d ossan",M:"ayowr",MM:"%d iyyirn",y:"asgas",yy:"%d isgasn"},week:{dow:6,doy:12}})}),function(e){e(ft)}(function(e){return e.defineLocale("tzm",{months:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),monthsShort:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekdays:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),weekdaysShort:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),weekdaysMin:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"dddd D MMMM YYYY LT"},calendar:{sameDay:"[ⴰⵙⴷⵅ ⴴ] LT",nextDay:"[ⴰⵙⴽⴰ ⴴ] LT",nextWeek:"dddd [ⴴ] LT",lastDay:"[ⴰⵚⴰⵏⵜ ⴴ] LT",lastWeek:"dddd [ⴴ] LT",sameElse:"L"},relativeTime:{future:"ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s",past:"ⵢⴰⵏ %s",s:"ⵉⵎⵉⴽ",m:"ⵎⵉⵏⵓⴺ",mm:"%d ⵎⵉⵏⵓⴺ",h:"ⵙⴰⵄⴰ",hh:"%d ⵜⴰⵙⵙⴰⵄⵉⵏ",d:"ⴰⵙⵙ",dd:"%d oⵙⵙⴰⵏ",M:"ⴰⵢoⵓⵔ",MM:"%d ⵉⵢⵢⵉⵔⵏ",y:"ⴰⵙⴳⴰⵙ",yy:"%d ⵉⵙⴳⴰⵙⵏ"},week:{dow:6,doy:12}})}),function(e){e(ft)}(function(e){function t(e,t){var a=e.split("_");return t%10===1&&t%100!==11?a[0]:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?a[1]:a[2]}function a(e,a,n){var _={mm:"хвилина_хвилини_хвилин",hh:"година_години_годин",dd:"день_дні_днів",MM:"місяць_місяці_місяців",yy:"рік_роки_років"};return"m"===n?a?"хвилина":"хвилину":"h"===n?a?"година":"годину":e+" "+t(_[n],+e)}function n(e,t){var a={nominative:"січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень".split("_"),accusative:"січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня".split("_")},n=/D[oD]? *MMMM?/.test(t)?"accusative":"nominative";return a[n][e.month()]}function _(e,t){var a={nominative:"неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота".split("_"),accusative:"неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу".split("_"),genitive:"неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи".split("_")},n=/(\[[ВвУу]\]) ?dddd/.test(t)?"accusative":/\[?(?:минулої|наступної)? ?\] ?dddd/.test(t)?"genitive":"nominative";return a[n][e.day()]}function s(e){return function(){return e+"о"+(11===this.hours()?"б":"")+"] LT"}}return e.defineLocale("uk",{months:n,monthsShort:"січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд".split("_"),weekdays:_,weekdaysShort:"нд_пн_вт_ср_чт_пт_сб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),longDateFormat:{LT:"HH:mm",L:"DD.MM.YYYY",LL:"D MMMM YYYY р.",LLL:"D MMMM YYYY р., LT",LLLL:"dddd, D MMMM YYYY р., LT"},calendar:{sameDay:s("[Сьогодні "),nextDay:s("[Завтра "),lastDay:s("[Вчора "),nextWeek:s("[У] dddd ["),lastWeek:function(){switch(this.day()){case 0:case 3:case 5:case 6:return s("[Минулої] dddd [").call(this);case 1:case 2:case 4:return s("[Минулого] dddd [").call(this)}},sameElse:"L"},relativeTime:{future:"за %s",past:"%s тому",s:"декілька секунд",m:a,mm:a,h:"годину",hh:a,d:"день",dd:a,M:"місяць",MM:a,y:"рік",yy:a},meridiem:function(e){return 4>e?"ночі":12>e?"ранку":17>e?"дня":"вечора"},ordinal:function(e,t){switch(t){case"M":case"d":case"DDD":case"w":case"W":return e+"-й";case"D":return e+"-го";default:return e}},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("uz",{months:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdays:"Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба".split("_"),weekdaysShort:"Якш_Душ_Сеш_Чор_Пай_Жум_Шан".split("_"),weekdaysMin:"Як_Ду_Се_Чо_Па_Жу_Ша".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY LT",LLLL:"D MMMM YYYY, dddd LT"},calendar:{sameDay:"[Бугун соат] LT [да]",nextDay:"[Эртага] LT [да]",nextWeek:"dddd [куни соат] LT [да]",lastDay:"[Кеча соат] LT [да]",lastWeek:"[Утган] dddd [куни соат] LT [да]",sameElse:"L"},relativeTime:{future:"Якин %s ичида",past:"Бир неча %s олдин",s:"фурсат",m:"бир дакика",mm:"%d дакика",h:"бир соат",hh:"%d соат",d:"бир кун",dd:"%d кун",M:"бир ой",MM:"%d ой",y:"бир йил",yy:"%d йил"},week:{dow:1,doy:7}})}),function(e){e(ft)}(function(e){return e.defineLocale("vi",{months:"tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12".split("_"),monthsShort:"Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12".split("_"),weekdays:"chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy".split("_"),weekdaysShort:"CN_T2_T3_T4_T5_T6_T7".split("_"),weekdaysMin:"CN_T2_T3_T4_T5_T6_T7".split("_"),longDateFormat:{LT:"HH:mm",L:"DD/MM/YYYY",LL:"D MMMM [năm] YYYY",LLL:"D MMMM [năm] YYYY LT",LLLL:"dddd, D MMMM [năm] YYYY LT",l:"DD/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY LT",llll:"ddd, D MMM YYYY LT"},calendar:{sameDay:"[Hôm nay lúc] LT",nextDay:"[Ngày mai lúc] LT",nextWeek:"dddd [tuần tới lúc] LT",lastDay:"[Hôm qua lúc] LT",lastWeek:"dddd [tuần rồi lúc] LT",sameElse:"L"},relativeTime:{future:"%s tới",past:"%s trước",s:"vài giây",m:"một phút",mm:"%d phút",h:"một giờ",hh:"%d giờ",d:"một ngày",dd:"%d ngày",M:"một tháng",MM:"%d tháng",y:"một năm",yy:"%d năm"},ordinal:function(e){return e},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("zh-cn",{months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),longDateFormat:{LT:"Ah点mm",L:"YYYY-MM-DD",LL:"YYYY年MMMD日",LLL:"YYYY年MMMD日LT",LLLL:"YYYY年MMMD日ddddLT",l:"YYYY-MM-DD",ll:"YYYY年MMMD日",lll:"YYYY年MMMD日LT",llll:"YYYY年MMMD日ddddLT"},meridiem:function(e,t){var a=100*e+t;
+return 600>a?"凌晨":900>a?"早上":1130>a?"上午":1230>a?"中午":1800>a?"下午":"晚上"},calendar:{sameDay:function(){return 0===this.minutes()?"[今天]Ah[点整]":"[今天]LT"},nextDay:function(){return 0===this.minutes()?"[明天]Ah[点整]":"[明天]LT"},lastDay:function(){return 0===this.minutes()?"[昨天]Ah[点整]":"[昨天]LT"},nextWeek:function(){var t,a;return t=e().startOf("week"),a=this.unix()-t.unix()>=604800?"[下]":"[本]",0===this.minutes()?a+"dddAh点整":a+"dddAh点mm"},lastWeek:function(){var t,a;return t=e().startOf("week"),a=this.unix()<t.unix()?"[上]":"[本]",0===this.minutes()?a+"dddAh点整":a+"dddAh点mm"},sameElse:"LL"},ordinal:function(e,t){switch(t){case"d":case"D":case"DDD":return e+"日";case"M":return e+"月";case"w":case"W":return e+"周";default:return e}},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1分钟",mm:"%d分钟",h:"1小时",hh:"%d小时",d:"1天",dd:"%d天",M:"1个月",MM:"%d个月",y:"1年",yy:"%d年"},week:{dow:1,doy:4}})}),function(e){e(ft)}(function(e){return e.defineLocale("zh-tw",{months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),longDateFormat:{LT:"Ah點mm",L:"YYYY年MMMD日",LL:"YYYY年MMMD日",LLL:"YYYY年MMMD日LT",LLLL:"YYYY年MMMD日ddddLT",l:"YYYY年MMMD日",ll:"YYYY年MMMD日",lll:"YYYY年MMMD日LT",llll:"YYYY年MMMD日ddddLT"},meridiem:function(e,t){var a=100*e+t;return 900>a?"早上":1130>a?"上午":1230>a?"中午":1800>a?"下午":"晚上"},calendar:{sameDay:"[今天]LT",nextDay:"[明天]LT",nextWeek:"[下]ddddLT",lastDay:"[昨天]LT",lastWeek:"[上]ddddLT",sameElse:"L"},ordinal:function(e,t){switch(t){case"d":case"D":case"DDD":return e+"日";case"M":return e+"月";case"w":case"W":return e+"週";default:return e}},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"一分鐘",mm:"%d分鐘",h:"一小時",hh:"%d小時",d:"一天",dd:"%d天",M:"一個月",MM:"%d個月",y:"一年",yy:"%d年"}})}),ft.locale("en"),Et?module.exports=ft:"function"==typeof define&&define.amd?(define("moment",function(e,t,a){return a.config&&a.config()&&a.config().noGlobal===!0&&(Tt.moment=pt),ft}),yt(!0)):yt()}).call(this)}).call(this),function(){"undefined"!=typeof Package&&(a=this.moment)}.call(this),"undefined"==typeof Package&&(Package={}),Package["jeeeyul:moment-with-langs"]={moment:a}}();
+
+!function(){var e=Package.meteor.Meteor;"undefined"==typeof Package&&(Package={}),Package.coffeescript={}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,a=Package.tracker.Tracker,i=Package.tracker.Deps,n=Package.ejson.EJSON,r;(function(){var e=function(e){return void 0===e?"undefined":n.stringify(e)},i=function(e){return void 0===e||"undefined"===e?void 0:n.parse(e)};r=function(e){if(e)if("string"==typeof e)r._registerDictForMigrate(e,this),this.keys=r._loadMigratedDict(e)||{};else{if("object"!=typeof e)throw new Error("Invalid ReactiveDict argument: "+e);this.keys=e}else this.keys={};this.keyDeps={},this.keyValueDeps={}},t.extend(r.prototype,{set:function(a,i){var n=this;i=e(i);var r="undefined";if(t.has(n.keys,a)&&(r=n.keys[a]),i!==r){n.keys[a]=i;var s=function(e){e&&e.changed()};s(n.keyDeps[a]),n.keyValueDeps[a]&&(s(n.keyValueDeps[a][r]),s(n.keyValueDeps[a][i]))}},setDefault:function(e,t){var a=this;void 0===a.keys[e]&&a.set(e,t)},get:function(e){var t=this;return t._ensureKey(e),t.keyDeps[e].depend(),i(t.keys[e])},equals:function(r,s){var c=this,o=null;if("undefined"!=typeof Mongo&&(o=Mongo.ObjectID),!("string"==typeof s||"number"==typeof s||"boolean"==typeof s||"undefined"==typeof s||s instanceof Date||o&&s instanceof o||null===s))throw new Error("ReactiveDict.equals: value must be scalar");var u=e(s);if(a.active){c._ensureKey(r),t.has(c.keyValueDeps[r],u)||(c.keyValueDeps[r][u]=new a.Dependency);var d=c.keyValueDeps[r][u].depend();d&&a.onInvalidate(function(){c.keyValueDeps[r][u].hasDependents()||delete c.keyValueDeps[r][u]})}var f=void 0;return t.has(c.keys,r)&&(f=i(c.keys[r])),n.equals(f,s)},_ensureKey:function(e){var t=this;e in t.keyDeps||(t.keyDeps[e]=new a.Dependency,t.keyValueDeps[e]={})},_getMigrationData:function(){return this.keys}})}).call(this),function(){if(r._migratedDictData={},r._dictsToMigrate={},r._loadMigratedDict=function(e){return t.has(r._migratedDictData,e)?r._migratedDictData[e]:null},r._registerDictForMigrate=function(e,a){if(t.has(r._dictsToMigrate,e))throw new Error("Duplicate ReactiveDict name: "+e);r._dictsToMigrate[e]=a},e.isClient&&Package.reload){var a=Package.reload.Reload._migrationData("reactive-dict");a&&a.dicts&&(r._migratedDictData=a.dicts),Package.reload.Reload._onMigrate("reactive-dict",function(){var e=r._dictsToMigrate,t={};for(var a in e)t[a]=e[a]._getMigrationData();return[!0,{dicts:t}]})}}.call(this),"undefined"==typeof Package&&(Package={}),Package["reactive-dict"]={ReactiveDict:r}}();
+
+!function(){var e=Package.meteor.Meteor,a=Package.underscore._,c=Package["reactive-dict"].ReactiveDict,n=Package.ejson.EJSON,i;(function(){i=new c("session")}).call(this),"undefined"==typeof Package&&(Package={}),Package.session={Session:i}}();
+
+!function(){var e=Package.meteor.Meteor,t,n;(function(){!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=it.type(e);return"function"===n||it.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function r(e,t,n){if(it.isFunction(t))return it.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return it.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(ft.test(t))return it.filter(t,e,n);t=it.filter(t,e)}return it.grep(e,function(e){return it.inArray(e,t)>=0!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t=xt[e]={};return it.each(e.match(bt)||[],function(e,n){t[n]=!0}),t}function a(){ht.addEventListener?(ht.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1)):(ht.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(ht.addEventListener||"load"===event.type||"complete"===ht.readyState)&&(a(),it.ready())}function u(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(Et,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:Nt.test(n)?it.parseJSON(n):n}catch(i){}it.data(e,t,n)}else n=void 0}return n}function l(e){var t;for(t in e)if(("data"!==t||!it.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,r){if(it.acceptData(e)){var i,o,a=it.expando,s=e.nodeType,u=s?it.cache:e,l=s?e[a]:e[a]&&a;if(l&&u[l]&&(r||u[l].data)||void 0!==n||"string"!=typeof t)return l||(l=s?e[a]=J.pop()||it.guid++:a),u[l]||(u[l]=s?{}:{toJSON:it.noop}),("object"==typeof t||"function"==typeof t)&&(r?u[l]=it.extend(u[l],t):u[l].data=it.extend(u[l].data,t)),o=u[l],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[it.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[it.camelCase(t)])):i=o,i}}function d(e,t,n){if(it.acceptData(e)){var r,i,o=e.nodeType,a=o?it.cache:e,s=o?e[it.expando]:it.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){it.isArray(t)?t=t.concat(it.map(t,it.camelCase)):t in r?t=[t]:(t=it.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!l(r):!it.isEmptyObject(r))return}(n||(delete a[s].data,l(a[s])))&&(o?it.cleanData([e],!0):nt.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}function f(){return!0}function p(){return!1}function h(){try{return ht.activeElement}catch(e){}}function m(e){var t=Ft.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function g(e,t){var n,r,i=0,o=typeof e.getElementsByTagName!==Tt?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==Tt?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||it.nodeName(r,t)?o.push(r):it.merge(o,g(r,t));return void 0===t||t&&it.nodeName(e,t)?it.merge([e],o):o}function v(e){jt.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t){return it.nodeName(e,"table")&&it.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==it.find.attr(e,"type"))+"/"+e.type,e}function x(e){var t=Vt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){for(var n,r=0;null!=(n=e[r]);r++)it._data(n,"globalEval",!t||it._data(t[r],"globalEval"))}function T(e,t){if(1===t.nodeType&&it.hasData(e)){var n,r,i,o=it._data(e),a=it._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)it.event.add(t,n,s[n][r])}a.data&&(a.data=it.extend({},a.data))}}function C(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!nt.noCloneEvent&&t[it.expando]){i=it._data(t);for(r in i.events)it.removeEvent(t,r,i.handle);t.removeAttribute(it.expando)}"script"===n&&t.text!==e.text?(b(t).text=e.text,x(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),nt.html5Clone&&e.innerHTML&&!it.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&jt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function N(t,n){var r,i=it(n.createElement(t)).appendTo(n.body),o=e.getDefaultComputedStyle&&(r=e.getDefaultComputedStyle(i[0]))?r.display:it.css(i[0],"display");return i.detach(),o}function E(e){var t=ht,n=Zt[e];return n||(n=N(e,t),"none"!==n&&n||(Kt=(Kt||it("<iframe frameborder='0' width='0' height='0'/>")).appendTo(t.documentElement),t=(Kt[0].contentWindow||Kt[0].contentDocument).document,t.write(),t.close(),n=N(e,t),Kt.detach()),Zt[e]=n),n}function k(e,t){return{get:function(){var n=e();if(null!=n)return n?void delete this.get:(this.get=t).apply(this,arguments)}}}function S(e,t){if(t in e)return t;for(var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=pn.length;i--;)if(t=pn[i]+n,t in e)return t;return r}function A(e,t){for(var n,r,i,o=[],a=0,s=e.length;s>a;a++)r=e[a],r.style&&(o[a]=it._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&At(r)&&(o[a]=it._data(r,"olddisplay",E(r.nodeName)))):(i=At(r),(n&&"none"!==n||!i)&&it._data(r,"olddisplay",i?n:it.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}function D(e,t,n){var r=ln.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function j(e,t,n,r,i){for(var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;4>o;o+=2)"margin"===n&&(a+=it.css(e,n+St[o],!0,i)),r?("content"===n&&(a-=it.css(e,"padding"+St[o],!0,i)),"margin"!==n&&(a-=it.css(e,"border"+St[o]+"Width",!0,i))):(a+=it.css(e,"padding"+St[o],!0,i),"padding"!==n&&(a+=it.css(e,"border"+St[o]+"Width",!0,i)));return a}function L(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=nn(e),a=nt.boxSizing&&"border-box"===it.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=rn(e,t,o),(0>i||null==i)&&(i=e.style[t]),tn.test(i))return i;r=a&&(nt.boxSizingReliable()||i===e.style[t]),i=parseFloat(i)||0}return i+j(e,t,n||(a?"border":"content"),r,o)+"px"}function H(e,t,n,r,i){return new H.prototype.init(e,t,n,r,i)}function q(){return setTimeout(function(){hn=void 0}),hn=it.now()}function _(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=St[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function M(e,t,n){for(var r,i=(xn[t]||[]).concat(xn["*"]),o=0,a=i.length;a>o;o++)if(r=i[o].call(n,t,e))return r}function F(e,t,n){var r,i,o,a,s,u,l,c,d=this,f={},p=e.style,h=e.nodeType&&At(e),m=it._data(e,"fxshow");n.queue||(s=it._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,u=s.empty.fire,s.empty.fire=function(){s.unqueued||u()}),s.unqueued++,d.always(function(){d.always(function(){s.unqueued--,it.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],l=it.css(e,"display"),c="none"===l?it._data(e,"olddisplay")||E(e.nodeName):l,"inline"===c&&"none"===it.css(e,"float")&&(nt.inlineBlockNeedsLayout&&"inline"!==E(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",nt.shrinkWrapBlocks()||d.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],gn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(h?"hide":"show")){if("show"!==i||!m||void 0===m[r])continue;h=!0}f[r]=m&&m[r]||it.style(e,r)}else l=void 0;if(it.isEmptyObject(f))"inline"===("none"===l?E(e.nodeName):l)&&(p.display=l);else{m?"hidden"in m&&(h=m.hidden):m=it._data(e,"fxshow",{}),o&&(m.hidden=!h),h?it(e).show():d.done(function(){it(e).hide()}),d.done(function(){var t;it._removeData(e,"fxshow");for(t in f)it.style(e,t,f[t])});for(r in f)a=M(h?m[r]:0,r,d),r in m||(m[r]=a.start,h&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function O(e,t){var n,r,i,o,a;for(n in e)if(r=it.camelCase(n),i=t[r],o=e[n],it.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=it.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function B(e,t,n){var r,i,o=0,a=bn.length,s=it.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=hn||q(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:it.extend({},t),opts:it.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:hn||q(),duration:n.duration,tweens:[],createTween:function(t,n){var r=it.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(O(c,l.opts.specialEasing);a>o;o++)if(r=bn[o].call(l,e,c,l.opts))return r;return it.map(c,M,l),it.isFunction(l.opts.start)&&l.opts.start.call(e,l),it.fx.timer(it.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function P(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(bt)||[];if(it.isFunction(n))for(;r=o[i++];)"+"===r.charAt(0)?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function R(e,t,n,r){function i(s){var u;return o[s]=!0,it.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||a||o[l]?a?!(u=l):void 0:(t.dataTypes.unshift(l),i(l),!1)}),u}var o={},a=e===In;return i(t.dataTypes[0])||!o["*"]&&i("*")}function W(e,t){var n,r,i=it.ajaxSettings.flatOptions||{};for(r in t)void 0!==t[r]&&((i[r]?e:n||(n={}))[r]=t[r]);return n&&it.extend(!0,e,n),e}function $(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;"*"===u[0];)u.shift(),void 0===i&&(i=e.mimeType||t.getResponseHeader("Content-Type"));if(i)for(a in s)if(s[a]&&s[a].test(i)){u.unshift(a);break}if(u[0]in n)o=u[0];else{for(a in n){if(!u[0]||e.converters[a+" "+u[0]]){o=a;break}r||(r=a)}o=o||r}return o?(o!==u[0]&&u.unshift(o),n[o]):void 0}function z(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(a=l[u+" "+o]||l["* "+o],!a)for(i in l)if(s=i.split(" "),s[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){a===!0?a=l[i]:l[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(d){return{state:"parsererror",error:a?d:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}function I(e,t,n,r){var i;if(it.isArray(t))it.each(t,function(t,i){n||Jn.test(e)?r(e,i):I(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==it.type(t))r(e,t);else for(i in t)I(e+"["+i+"]",t[i],n,r)}function X(){try{return new e.XMLHttpRequest}catch(t){}}function U(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function V(e){return it.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}var J=[],Y=J.slice,Q=J.concat,G=J.push,K=J.indexOf,Z={},et=Z.toString,tt=Z.hasOwnProperty,nt={},rt="1.11.2",it=function(e,t){return new it.fn.init(e,t)},ot=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,at=/^-ms-/,st=/-([\da-z])/gi,ut=function(e,t){return t.toUpperCase()};it.fn=it.prototype={jquery:rt,constructor:it,selector:"",length:0,toArray:function(){return Y.call(this)},get:function(e){return null!=e?0>e?this[e+this.length]:this[e]:Y.call(this)},pushStack:function(e){var t=it.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return it.each(this,e,t)},map:function(e){return this.pushStack(it.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(Y.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:G,sort:J.sort,splice:J.splice},it.extend=it.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||it.isFunction(a)||(a={}),s===u&&(a=this,s--);u>s;s++)if(null!=(i=arguments[s]))for(r in i)e=a[r],n=i[r],a!==n&&(l&&n&&(it.isPlainObject(n)||(t=it.isArray(n)))?(t?(t=!1,o=e&&it.isArray(e)?e:[]):o=e&&it.isPlainObject(e)?e:{},a[r]=it.extend(l,o,n)):void 0!==n&&(a[r]=n));return a},it.extend({expando:"jQuery"+(rt+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return"function"===it.type(e)},isArray:Array.isArray||function(e){return"array"===it.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!it.isArray(e)&&e-parseFloat(e)+1>=0},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},isPlainObject:function(e){var t;if(!e||"object"!==it.type(e)||e.nodeType||it.isWindow(e))return!1;try{if(e.constructor&&!tt.call(e,"constructor")&&!tt.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(nt.ownLast)for(t in e)return tt.call(e,t);for(t in e);return void 0===t||tt.call(e,t)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?Z[et.call(e)]||"object":typeof e},globalEval:function(t){t&&it.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(at,"ms-").replace(st,ut)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,r){var i,o=0,a=e.length,s=n(e);if(r){if(s)for(;a>o&&(i=t.apply(e[o],r),i!==!1);o++);else for(o in e)if(i=t.apply(e[o],r),i===!1)break}else if(s)for(;a>o&&(i=t.call(e[o],o,e[o]),i!==!1);o++);else for(o in e)if(i=t.call(e[o],o,e[o]),i===!1)break;return e},trim:function(e){return null==e?"":(e+"").replace(ot,"")},makeArray:function(e,t){var r=t||[];return null!=e&&(n(Object(e))?it.merge(r,"string"==typeof e?[e]:e):G.call(r,e)),r},inArray:function(e,t,n){var r;if(t){if(K)return K.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;n>r;)e[i++]=t[r++];if(n!==n)for(;void 0!==t[r];)e[i++]=t[r++];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;a>o;o++)r=!t(e[o],o),r!==s&&i.push(e[o]);return i},map:function(e,t,r){var i,o=0,a=e.length,s=n(e),u=[];if(s)for(;a>o;o++)i=t(e[o],o,r),null!=i&&u.push(i);else for(o in e)i=t(e[o],o,r),null!=i&&u.push(i);return Q.apply([],u)},guid:1,proxy:function(e,t){var n,r,i;return"string"==typeof t&&(i=e[t],t=e,e=i),it.isFunction(e)?(n=Y.call(arguments,2),r=function(){return e.apply(t||this,n.concat(Y.call(arguments)))},r.guid=e.guid=e.guid||it.guid++,r):void 0},now:function(){return+new Date},support:nt}),it.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){Z["[object "+t+"]"]=t.toLowerCase()});var lt=function(e){function t(e,t,n,r){var i,o,a,s,u,l,d,p,h,m;if((t?t.ownerDocument||t:R)!==H&&L(t),t=t||H,n=n||[],s=t.nodeType,"string"!=typeof e||!e||1!==s&&9!==s&&11!==s)return n;if(!r&&_){if(11!==s&&(i=yt.exec(e)))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&B(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return K.apply(n,t.getElementsByTagName(e)),n;if((a=i[3])&&w.getElementsByClassName)return K.apply(n,t.getElementsByClassName(a)),n}if(w.qsa&&(!M||!M.test(e))){if(p=d=P,h=t,m=1!==s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){for(l=E(e),(d=t.getAttribute("id"))?p=d.replace(xt,"\\$&"):t.setAttribute("id",p),p="[id='"+p+"'] ",u=l.length;u--;)l[u]=p+f(l[u]);h=bt.test(e)&&c(t.parentNode)||t,m=l.join(",")}if(m)try{return K.apply(n,h.querySelectorAll(m)),n}catch(g){}finally{d||t.removeAttribute("id")}}}return S(e.replace(ut,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>T.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[P]=!0,e}function i(e){var t=H.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=e.length;r--;)T.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||V)-(~e.sourceIndex||V);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function u(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function l(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function c(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function d(){}function f(e){for(var t=0,n=e.length,r="";n>t;t++)r+=e[t].value;return r}function p(e,t,n){var r=t.dir,i=n&&"parentNode"===r,o=$++;return t.first?function(t,n,o){for(;t=t[r];)if(1===t.nodeType||i)return e(t,n,o)}:function(t,n,a){var s,u,l=[W,o];if(a){for(;t=t[r];)if((1===t.nodeType||i)&&e(t,n,a))return!0}else for(;t=t[r];)if(1===t.nodeType||i){if(u=t[P]||(t[P]={}),(s=u[r])&&s[0]===W&&s[1]===o)return l[2]=s[2];if(u[r]=l,l[2]=e(t,n,a))return!0}}}function h(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function m(e,n,r){for(var i=0,o=n.length;o>i;i++)t(e,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function v(e,t,n,i,o,a){return i&&!i[P]&&(i=v(i)),o&&!o[P]&&(o=v(o,a)),r(function(r,a,s,u){var l,c,d,f=[],p=[],h=a.length,v=r||m(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?v:g(v,f,e,s,u),b=n?o||(r?e:h||i)?[]:a:y;if(n&&n(y,b,s,u),i)for(l=g(b,p),i(l,[],s,u),c=l.length;c--;)(d=l[c])&&(b[p[c]]=!(y[p[c]]=d));if(r){if(o||e){if(o){for(l=[],c=b.length;c--;)(d=b[c])&&l.push(y[c]=d);o(null,b=[],l,u)}for(c=b.length;c--;)(d=b[c])&&(l=o?et(r,d):f[c])>-1&&(r[l]=!(a[l]=d))}}else b=g(b===a?b.splice(h,b.length):b),o?o(null,a,b,u):K.apply(a,b)})}function y(e){for(var t,n,r,i=e.length,o=T.relative[e[0].type],a=o||T.relative[" "],s=o?1:0,u=p(function(e){return e===t},a,!0),l=p(function(e){return et(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==A)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];i>s;s++)if(n=T.relative[e[s].type])c=[p(h(c),n)];else{if(n=T.filter[e[s].type].apply(null,e[s].matches),n[P]){for(r=++s;i>r&&!T.relative[e[r].type];r++);return v(s>1&&h(c),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(ut,"$1"),n,r>s&&y(e.slice(s,r)),i>r&&y(e=e.slice(r)),i>r&&f(e))}c.push(n)}return h(c)}function b(e,n){var i=n.length>0,o=e.length>0,a=function(r,a,s,u,l){var c,d,f,p=0,h="0",m=r&&[],v=[],y=A,b=r||o&&T.find.TAG("*",l),x=W+=null==y?1:Math.random()||.1,w=b.length;for(l&&(A=a!==H&&a);h!==w&&null!=(c=b[h]);h++){if(o&&c){for(d=0;f=e[d++];)if(f(c,a,s)){u.push(c);break}l&&(W=x)}i&&((c=!f&&c)&&p--,r&&m.push(c))}if(p+=h,i&&h!==p){for(d=0;f=n[d++];)f(m,v,a,s);if(r){if(p>0)for(;h--;)m[h]||v[h]||(v[h]=Q.call(u));v=g(v)}K.apply(u,v),l&&!r&&v.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(W=x,A=y),m};return i?r(a):a}var x,w,T,C,N,E,k,S,A,D,j,L,H,q,_,M,F,O,B,P="sizzle"+1*new Date,R=e.document,W=0,$=0,z=n(),I=n(),X=n(),U=function(e,t){return e===t&&(j=!0),0},V=1<<31,J={}.hasOwnProperty,Y=[],Q=Y.pop,G=Y.push,K=Y.push,Z=Y.slice,et=function(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1},tt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",nt="[\\x20\\t\\r\\n\\f]",rt="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",it=rt.replace("w","w#"),ot="\\["+nt+"*("+rt+")(?:"+nt+"*([*^$|!~]?=)"+nt+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+it+"))|)"+nt+"*\\]",at=":("+rt+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ot+")*)|.*)\\)|)",st=new RegExp(nt+"+","g"),ut=new RegExp("^"+nt+"+|((?:^|[^\\\\])(?:\\\\.)*)"+nt+"+$","g"),lt=new RegExp("^"+nt+"*,"+nt+"*"),ct=new RegExp("^"+nt+"*([>+~]|"+nt+")"+nt+"*"),dt=new RegExp("="+nt+"*([^\\]'\"]*?)"+nt+"*\\]","g"),ft=new RegExp(at),pt=new RegExp("^"+it+"$"),ht={ID:new RegExp("^#("+rt+")"),CLASS:new RegExp("^\\.("+rt+")"),TAG:new RegExp("^("+rt.replace("w","w*")+")"),ATTR:new RegExp("^"+ot),PSEUDO:new RegExp("^"+at),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+nt+"*(even|odd|(([+-]|)(\\d*)n|)"+nt+"*(?:([+-]|)"+nt+"*(\\d+)|))"+nt+"*\\)|)","i"),bool:new RegExp("^(?:"+tt+")$","i"),needsContext:new RegExp("^"+nt+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+nt+"*((?:-\\d)?\\d*)"+nt+"*\\)|)(?=[^-]|$)","i")},mt=/^(?:input|select|textarea|button)$/i,gt=/^h\d$/i,vt=/^[^{]+\{\s*\[native \w/,yt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,bt=/[+~]/,xt=/'|\\/g,wt=new RegExp("\\\\([\\da-f]{1,6}"+nt+"?|("+nt+")|.)","ig"),Tt=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},Ct=function(){L()};try{K.apply(Y=Z.call(R.childNodes),R.childNodes),Y[R.childNodes.length].nodeType}catch(Nt){K={apply:Y.length?function(e,t){G.apply(e,Z.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}w=t.support={},N=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},L=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:R;return r!==H&&9===r.nodeType&&r.documentElement?(H=r,q=r.documentElement,n=r.defaultView,n&&n!==n.top&&(n.addEventListener?n.addEventListener("unload",Ct,!1):n.attachEvent&&n.attachEvent("onunload",Ct)),_=!N(r),w.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),w.getElementsByTagName=i(function(e){return e.appendChild(r.createComment("")),!e.getElementsByTagName("*").length}),w.getElementsByClassName=vt.test(r.getElementsByClassName),w.getById=i(function(e){return q.appendChild(e).id=P,!r.getElementsByName||!r.getElementsByName(P).length}),w.getById?(T.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&_){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},T.filter.ID=function(e){var t=e.replace(wt,Tt);return function(e){return e.getAttribute("id")===t}}):(delete T.find.ID,T.filter.ID=function(e){var t=e.replace(wt,Tt);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}}),T.find.TAG=w.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):w.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},T.find.CLASS=w.getElementsByClassName&&function(e,t){return _?t.getElementsByClassName(e):void 0},F=[],M=[],(w.qsa=vt.test(r.querySelectorAll))&&(i(function(e){q.appendChild(e).innerHTML="<a id='"+P+"'></a><select id='"+P+"-\f]' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&M.push("[*^$]="+nt+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||M.push("\\["+nt+"*(?:value|"+tt+")"),e.querySelectorAll("[id~="+P+"-]").length||M.push("~="),e.querySelectorAll(":checked").length||M.push(":checked"),e.querySelectorAll("a#"+P+"+*").length||M.push(".#.+[+~]")}),i(function(e){var t=r.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&M.push("name"+nt+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||M.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),M.push(",.*:")})),(w.matchesSelector=vt.test(O=q.matches||q.webkitMatchesSelector||q.mozMatchesSelector||q.oMatchesSelector||q.msMatchesSelector))&&i(function(e){w.disconnectedMatch=O.call(e,"div"),O.call(e,"[s!='']:x"),F.push("!=",at)}),M=M.length&&new RegExp(M.join("|")),F=F.length&&new RegExp(F.join("|")),t=vt.test(q.compareDocumentPosition),B=t||vt.test(q.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},U=t?function(e,t){if(e===t)return j=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n?n:(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!w.sortDetached&&t.compareDocumentPosition(e)===n?e===r||e.ownerDocument===R&&B(R,e)?-1:t===r||t.ownerDocument===R&&B(R,t)?1:D?et(D,e)-et(D,t):0:4&n?-1:1)}:function(e,t){if(e===t)return j=!0,0;var n,i=0,o=e.parentNode,s=t.parentNode,u=[e],l=[t];if(!o||!s)return e===r?-1:t===r?1:o?-1:s?1:D?et(D,e)-et(D,t):0;if(o===s)return a(e,t);for(n=e;n=n.parentNode;)u.unshift(n);for(n=t;n=n.parentNode;)l.unshift(n);for(;u[i]===l[i];)i++;return i?a(u[i],l[i]):u[i]===R?-1:l[i]===R?1:0},r):H},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==H&&L(e),n=n.replace(dt,"='$1']"),!(!w.matchesSelector||!_||F&&F.test(n)||M&&M.test(n)))try{var r=O.call(e,n);if(r||w.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(i){}return t(n,H,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==H&&L(e),B(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==H&&L(e);var n=T.attrHandle[t.toLowerCase()],r=n&&J.call(T.attrHandle,t.toLowerCase())?n(e,t,!_):void 0;return void 0!==r?r:w.attributes||!_?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(j=!w.detectDuplicates,D=!w.sortStable&&e.slice(0),e.sort(U),j){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return D=null,e},C=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=C(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=C(t);return n},T=t.selectors={cacheLength:50,createPseudo:r,match:ht,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(wt,Tt),e[3]=(e[3]||e[4]||e[5]||"").replace(wt,Tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return ht.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&ft.test(n)&&(t=E(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(wt,Tt).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=z[e+" "];return t||(t=new RegExp("(^|"+nt+")"+e+"("+nt+"|$)"))&&z(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:n?(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(st," ")+" ").indexOf(r)>-1:"|="===n?o===r||o.slice(0,r.length+1)===r+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,d,f,p,h,m=o!==a?"nextSibling":"previousSibling",g=t.parentNode,v=s&&t.nodeName.toLowerCase(),y=!u&&!s;if(g){if(o){for(;m;){for(d=t;d=d[m];)if(s?d.nodeName.toLowerCase()===v:1===d.nodeType)return!1;h=m="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?g.firstChild:g.lastChild],a&&y){for(c=g[P]||(g[P]={}),l=c[e]||[],p=l[0]===W&&l[1],f=l[0]===W&&l[2],d=p&&g.childNodes[p];d=++p&&d&&d[m]||(f=p=0)||h.pop();)if(1===d.nodeType&&++f&&d===t){c[e]=[W,p,f];break}}else if(y&&(l=(t[P]||(t[P]={}))[e])&&l[0]===W)f=l[1];else for(;(d=++p&&d&&d[m]||(f=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==v:1!==d.nodeType)||!++f||(y&&((d[P]||(d[P]={}))[e]=[W,f]),d!==t)););return f-=i,f===r||f%r===0&&f/r>=0}}},PSEUDO:function(e,n){var i,o=T.pseudos[e]||T.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[P]?o(n):o.length>1?(i=[e,e,"",n],T.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=et(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(ut,"$1"));return i[P]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(wt,Tt),function(t){return(t.textContent||t.innerText||C(t)).indexOf(e)>-1}}),lang:r(function(e){return pt.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(wt,Tt).toLowerCase(),function(t){var n;do if(n=_?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===q},focus:function(e){return e===H.activeElement&&(!H.hasFocus||H.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!T.pseudos.empty(e)},header:function(e){return gt.test(e.nodeName)},input:function(e){return mt.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:l(function(){return[0]}),last:l(function(e,t){return[t-1]}),eq:l(function(e,t,n){return[0>n?n+t:n]}),even:l(function(e,t){for(var n=0;t>n;n+=2)e.push(n);return e}),odd:l(function(e,t){for(var n=1;t>n;n+=2)e.push(n);return e}),lt:l(function(e,t,n){for(var r=0>n?n+t:n;--r>=0;)e.push(r);return e}),gt:l(function(e,t,n){for(var r=0>n?n+t:n;++r<t;)e.push(r);return e})}},T.pseudos.nth=T.pseudos.eq;for(x in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})T.pseudos[x]=s(x);for(x in{submit:!0,reset:!0})T.pseudos[x]=u(x);return d.prototype=T.filters=T.pseudos,T.setFilters=new d,E=t.tokenize=function(e,n){var r,i,o,a,s,u,l,c=I[e+" "];if(c)return n?0:c.slice(0);for(s=e,u=[],l=T.preFilter;s;){(!r||(i=lt.exec(s)))&&(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),r=!1,(i=ct.exec(s))&&(r=i.shift(),o.push({value:r,type:i[0].replace(ut," ")}),s=s.slice(r.length));
+for(a in T.filter)!(i=ht[a].exec(s))||l[a]&&!(i=l[a](i))||(r=i.shift(),o.push({value:r,type:a,matches:i}),s=s.slice(r.length));if(!r)break}return n?s.length:s?t.error(e):I(e,u).slice(0)},k=t.compile=function(e,t){var n,r=[],i=[],o=X[e+" "];if(!o){for(t||(t=E(e)),n=t.length;n--;)o=y(t[n]),o[P]?r.push(o):i.push(o);o=X(e,b(i,r)),o.selector=e}return o},S=t.select=function(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,d=!r&&E(e=l.selector||e);if(n=n||[],1===d.length){if(o=d[0]=d[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&w.getById&&9===t.nodeType&&_&&T.relative[o[1].type]){if(t=(T.find.ID(a.matches[0].replace(wt,Tt),t)||[])[0],!t)return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=ht.needsContext.test(e)?0:o.length;i--&&(a=o[i],!T.relative[s=a.type]);)if((u=T.find[s])&&(r=u(a.matches[0].replace(wt,Tt),bt.test(o[0].type)&&c(t.parentNode)||t))){if(o.splice(i,1),e=r.length&&f(o),!e)return K.apply(n,r),n;break}}return(l||k(e,d))(r,t,!_,n,bt.test(e)&&c(t.parentNode)||t),n},w.sortStable=P.split("").sort(U).join("")===P,w.detectDuplicates=!!j,L(),w.sortDetached=i(function(e){return 1&e.compareDocumentPosition(H.createElement("div"))}),i(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){return n?void 0:e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),w.attributes&&i(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){return n||"input"!==e.nodeName.toLowerCase()?void 0:e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(tt,function(e,t,n){var r;return n?void 0:e[t]===!0?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(e);it.find=lt,it.expr=lt.selectors,it.expr[":"]=it.expr.pseudos,it.unique=lt.uniqueSort,it.text=lt.getText,it.isXMLDoc=lt.isXML,it.contains=lt.contains;var ct=it.expr.match.needsContext,dt=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,ft=/^.[^:#\[\.,]*$/;it.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?it.find.matchesSelector(r,e)?[r]:[]:it.find.matches(e,it.grep(t,function(e){return 1===e.nodeType}))},it.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(it(e).filter(function(){for(t=0;i>t;t++)if(it.contains(r[t],this))return!0}));for(t=0;i>t;t++)it.find(e,r[t],n);return n=this.pushStack(i>1?it.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},filter:function(e){return this.pushStack(r(this,e||[],!1))},not:function(e){return this.pushStack(r(this,e||[],!0))},is:function(e){return!!r(this,"string"==typeof e&&ct.test(e)?it(e):e||[],!1).length}});var pt,ht=e.document,mt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,gt=it.fn.init=function(e,t){var n,r;if(!e)return this;if("string"==typeof e){if(n="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:mt.exec(e),!n||!n[1]&&t)return!t||t.jquery?(t||pt).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof it?t[0]:t,it.merge(this,it.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:ht,!0)),dt.test(n[1])&&it.isPlainObject(t))for(n in t)it.isFunction(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}if(r=ht.getElementById(n[2]),r&&r.parentNode){if(r.id!==n[2])return pt.find(e);this.length=1,this[0]=r}return this.context=ht,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):it.isFunction(e)?"undefined"!=typeof pt.ready?pt.ready(e):e(it):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),it.makeArray(e,this))};gt.prototype=it.fn,pt=it(ht);var vt=/^(?:parents|prev(?:Until|All))/,yt={children:!0,contents:!0,next:!0,prev:!0};it.extend({dir:function(e,t,n){for(var r=[],i=e[t];i&&9!==i.nodeType&&(void 0===n||1!==i.nodeType||!it(i).is(n));)1===i.nodeType&&r.push(i),i=i[t];return r},sibling:function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}}),it.fn.extend({has:function(e){var t,n=it(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(it.contains(this,n[t]))return!0})},closest:function(e,t){for(var n,r=0,i=this.length,o=[],a=ct.test(e)||"string"!=typeof e?it(e,t||this.context):0;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&it.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?it.unique(o):o)},index:function(e){return e?"string"==typeof e?it.inArray(this[0],it(e)):it.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(it.unique(it.merge(this.get(),it(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),it.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return it.dir(e,"parentNode")},parentsUntil:function(e,t,n){return it.dir(e,"parentNode",n)},next:function(e){return i(e,"nextSibling")},prev:function(e){return i(e,"previousSibling")},nextAll:function(e){return it.dir(e,"nextSibling")},prevAll:function(e){return it.dir(e,"previousSibling")},nextUntil:function(e,t,n){return it.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return it.dir(e,"previousSibling",n)},siblings:function(e){return it.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return it.sibling(e.firstChild)},contents:function(e){return it.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:it.merge([],e.childNodes)}},function(e,t){it.fn[e]=function(n,r){var i=it.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=it.filter(r,i)),this.length>1&&(yt[e]||(i=it.unique(i)),vt.test(e)&&(i=i.reverse())),this.pushStack(i)}});var bt=/\S+/g,xt={};it.Callbacks=function(e){e="string"==typeof e?xt[e]||o(e):it.extend({},e);var t,n,r,i,a,s,u=[],l=!e.once&&[],c=function(o){for(n=e.memory&&o,r=!0,a=s||0,s=0,i=u.length,t=!0;u&&i>a;a++)if(u[a].apply(o[0],o[1])===!1&&e.stopOnFalse){n=!1;break}t=!1,u&&(l?l.length&&c(l.shift()):n?u=[]:d.disable())},d={add:function(){if(u){var r=u.length;!function o(t){it.each(t,function(t,n){var r=it.type(n);"function"===r?e.unique&&d.has(n)||u.push(n):n&&n.length&&"string"!==r&&o(n)})}(arguments),t?i=u.length:n&&(s=r,c(n))}return this},remove:function(){return u&&it.each(arguments,function(e,n){for(var r;(r=it.inArray(n,u,r))>-1;)u.splice(r,1),t&&(i>=r&&i--,a>=r&&a--)}),this},has:function(e){return e?it.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],i=0,this},disable:function(){return u=l=n=void 0,this},disabled:function(){return!u},lock:function(){return l=void 0,n||d.disable(),this},locked:function(){return!l},fireWith:function(e,n){return!u||r&&!l||(n=n||[],n=[e,n.slice?n.slice():n],t?l.push(n):c(n)),this},fire:function(){return d.fireWith(this,arguments),this},fired:function(){return!!r}};return d},it.extend({Deferred:function(e){var t=[["resolve","done",it.Callbacks("once memory"),"resolved"],["reject","fail",it.Callbacks("once memory"),"rejected"],["notify","progress",it.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return it.Deferred(function(n){it.each(t,function(t,o){var a=it.isFunction(e[t])&&e[t];i[o[1]](function(){var e=a&&a.apply(this,arguments);e&&it.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[o[0]+"With"](this===r?n.promise():this,a?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?it.extend(e,r):r}},i={};return r.pipe=r.then,it.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=Y.call(arguments),r=n.length,i=1!==r||e&&it.isFunction(e.promise)?r:0,o=1===i?e:it.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?Y.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=new Array(r),u=new Array(r),l=new Array(r);r>t;t++)n[t]&&it.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}});var wt;it.fn.ready=function(e){return it.ready.promise().done(e),this},it.extend({isReady:!1,readyWait:1,holdReady:function(e){e?it.readyWait++:it.ready(!0)},ready:function(e){if(e===!0?!--it.readyWait:!it.isReady){if(!ht.body)return setTimeout(it.ready);it.isReady=!0,e!==!0&&--it.readyWait>0||(wt.resolveWith(ht,[it]),it.fn.triggerHandler&&(it(ht).triggerHandler("ready"),it(ht).off("ready")))}}}),it.ready.promise=function(t){if(!wt)if(wt=it.Deferred(),"complete"===ht.readyState)setTimeout(it.ready);else if(ht.addEventListener)ht.addEventListener("DOMContentLoaded",s,!1),e.addEventListener("load",s,!1);else{ht.attachEvent("onreadystatechange",s),e.attachEvent("onload",s);var n=!1;try{n=null==e.frameElement&&ht.documentElement}catch(r){}n&&n.doScroll&&!function i(){if(!it.isReady){try{n.doScroll("left")}catch(e){return setTimeout(i,50)}a(),it.ready()}}()}return wt.promise(t)};var Tt="undefined",Ct;for(Ct in it(nt))break;nt.ownLast="0"!==Ct,nt.inlineBlockNeedsLayout=!1,it(function(){var e,t,n,r;n=ht.getElementsByTagName("body")[0],n&&n.style&&(t=ht.createElement("div"),r=ht.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(t),typeof t.style.zoom!==Tt&&(t.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",nt.inlineBlockNeedsLayout=e=3===t.offsetWidth,e&&(n.style.zoom=1)),n.removeChild(r))}),function(){var e=ht.createElement("div");if(null==nt.deleteExpando){nt.deleteExpando=!0;try{delete e.test}catch(t){nt.deleteExpando=!1}}e=null}(),it.acceptData=function(e){var t=it.noData[(e.nodeName+" ").toLowerCase()],n=+e.nodeType||1;return 1!==n&&9!==n?!1:!t||t!==!0&&e.getAttribute("classid")===t};var Nt=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Et=/([A-Z])/g;it.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?it.cache[e[it.expando]]:e[it.expando],!!e&&!l(e)},data:function(e,t,n){return c(e,t,n)},removeData:function(e,t){return d(e,t)},_data:function(e,t,n){return c(e,t,n,!0)},_removeData:function(e,t){return d(e,t,!0)}}),it.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=it.data(o),1===o.nodeType&&!it._data(o,"parsedAttrs"))){for(n=a.length;n--;)a[n]&&(r=a[n].name,0===r.indexOf("data-")&&(r=it.camelCase(r.slice(5)),u(o,r,i[r])));it._data(o,"parsedAttrs",!0)}return i}return"object"==typeof e?this.each(function(){it.data(this,e)}):arguments.length>1?this.each(function(){it.data(this,e,t)}):o?u(o,e,it.data(o,e)):void 0},removeData:function(e){return this.each(function(){it.removeData(this,e)})}}),it.extend({queue:function(e,t,n){var r;return e?(t=(t||"fx")+"queue",r=it._data(e,t),n&&(!r||it.isArray(n)?r=it._data(e,t,it.makeArray(n)):r.push(n)),r||[]):void 0},dequeue:function(e,t){t=t||"fx";var n=it.queue(e,t),r=n.length,i=n.shift(),o=it._queueHooks(e,t),a=function(){it.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return it._data(e,n)||it._data(e,n,{empty:it.Callbacks("once memory").add(function(){it._removeData(e,t+"queue"),it._removeData(e,n)})})}}),it.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?it.queue(this[0],e):void 0===t?this:this.each(function(){var n=it.queue(this,e,t);it._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&it.dequeue(this,e)})},dequeue:function(e){return this.each(function(){it.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=it.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";a--;)n=it._data(o[a],e+"queueHooks"),n&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var kt=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,St=["Top","Right","Bottom","Left"],At=function(e,t){return e=t||e,"none"===it.css(e,"display")||!it.contains(e.ownerDocument,e)},Dt=it.access=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===it.type(n)){i=!0;for(s in n)it.access(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,it.isFunction(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(it(e),n)})),t))for(;u>s;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},jt=/^(?:checkbox|radio)$/i;!function(){var e=ht.createElement("input"),t=ht.createElement("div"),n=ht.createDocumentFragment();if(t.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",nt.leadingWhitespace=3===t.firstChild.nodeType,nt.tbody=!t.getElementsByTagName("tbody").length,nt.htmlSerialize=!!t.getElementsByTagName("link").length,nt.html5Clone="<:nav></:nav>"!==ht.createElement("nav").cloneNode(!0).outerHTML,e.type="checkbox",e.checked=!0,n.appendChild(e),nt.appendChecked=e.checked,t.innerHTML="<textarea>x</textarea>",nt.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue,n.appendChild(t),t.innerHTML="<input type='radio' checked='checked' name='t'/>",nt.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,nt.noCloneEvent=!0,t.attachEvent&&(t.attachEvent("onclick",function(){nt.noCloneEvent=!1}),t.cloneNode(!0).click()),null==nt.deleteExpando){nt.deleteExpando=!0;try{delete t.test}catch(r){nt.deleteExpando=!1}}}(),function(){var t,n,r=ht.createElement("div");for(t in{submit:!0,change:!0,focusin:!0})n="on"+t,(nt[t+"Bubbles"]=n in e)||(r.setAttribute(n,"t"),nt[t+"Bubbles"]=r.attributes[n].expando===!1);r=null}();var Lt=/^(?:input|select|textarea)$/i,Ht=/^key/,qt=/^(?:mouse|pointer|contextmenu)|click/,_t=/^(?:focusinfocus|focusoutblur)$/,Mt=/^([^.]*)(?:\.(.+)|)$/;it.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,d,f,p,h,m,g=it._data(e);if(g){for(n.handler&&(u=n,n=u.handler,i=u.selector),n.guid||(n.guid=it.guid++),(a=g.events)||(a=g.events={}),(c=g.handle)||(c=g.handle=function(e){return typeof it===Tt||e&&it.event.triggered===e.type?void 0:it.event.dispatch.apply(c.elem,arguments)},c.elem=e),t=(t||"").match(bt)||[""],s=t.length;s--;)o=Mt.exec(t[s])||[],p=m=o[1],h=(o[2]||"").split(".").sort(),p&&(l=it.event.special[p]||{},p=(i?l.delegateType:l.bindType)||p,l=it.event.special[p]||{},d=it.extend({type:p,origType:m,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&it.expr.match.needsContext.test(i),namespace:h.join(".")},u),(f=a[p])||(f=a[p]=[],f.delegateCount=0,l.setup&&l.setup.call(e,r,h,c)!==!1||(e.addEventListener?e.addEventListener(p,c,!1):e.attachEvent&&e.attachEvent("on"+p,c))),l.add&&(l.add.call(e,d),d.handler.guid||(d.handler.guid=n.guid)),i?f.splice(f.delegateCount++,0,d):f.push(d),it.event.global[p]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,d,f,p,h,m,g=it.hasData(e)&&it._data(e);if(g&&(c=g.events)){for(t=(t||"").match(bt)||[""],l=t.length;l--;)if(s=Mt.exec(t[l])||[],p=m=s[1],h=(s[2]||"").split(".").sort(),p){for(d=it.event.special[p]||{},p=(r?d.delegateType:d.bindType)||p,f=c[p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;o--;)a=f[o],!i&&m!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,d.remove&&d.remove.call(e,a));u&&!f.length&&(d.teardown&&d.teardown.call(e,h,g.handle)!==!1||it.removeEvent(e,p,g.handle),delete c[p])}else for(p in c)it.event.remove(e,p+t[l],n,r,!0);it.isEmptyObject(c)&&(delete g.handle,it._removeData(e,"events"))}},trigger:function(t,n,r,i){var o,a,s,u,l,c,d,f=[r||ht],p=tt.call(t,"type")?t.type:t,h=tt.call(t,"namespace")?t.namespace.split("."):[];if(s=c=r=r||ht,3!==r.nodeType&&8!==r.nodeType&&!_t.test(p+it.event.triggered)&&(p.indexOf(".")>=0&&(h=p.split("."),p=h.shift(),h.sort()),a=p.indexOf(":")<0&&"on"+p,t=t[it.expando]?t:new it.Event(p,"object"==typeof t&&t),t.isTrigger=i?2:3,t.namespace=h.join("."),t.namespace_re=t.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:it.makeArray(n,[t]),l=it.event.special[p]||{},i||!l.trigger||l.trigger.apply(r,n)!==!1)){if(!i&&!l.noBubble&&!it.isWindow(r)){for(u=l.delegateType||p,_t.test(u+p)||(s=s.parentNode);s;s=s.parentNode)f.push(s),c=s;c===(r.ownerDocument||ht)&&f.push(c.defaultView||c.parentWindow||e)}for(d=0;(s=f[d++])&&!t.isPropagationStopped();)t.type=d>1?u:l.bindType||p,o=(it._data(s,"events")||{})[t.type]&&it._data(s,"handle"),o&&o.apply(s,n),o=a&&s[a],o&&o.apply&&it.acceptData(s)&&(t.result=o.apply(s,n),t.result===!1&&t.preventDefault());if(t.type=p,!i&&!t.isDefaultPrevented()&&(!l._default||l._default.apply(f.pop(),n)===!1)&&it.acceptData(r)&&a&&r[p]&&!it.isWindow(r)){c=r[a],c&&(r[a]=null),it.event.triggered=p;try{r[p]()}catch(m){}it.event.triggered=void 0,c&&(r[a]=c)}return t.result}},dispatch:function(e){e=it.event.fix(e);var t,n,r,i,o,a=[],s=Y.call(arguments),u=(it._data(this,"events")||{})[e.type]||[],l=it.event.special[e.type]||{};if(s[0]=e,e.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,e)!==!1){for(a=it.event.handlers.call(this,e,u),t=0;(i=a[t++])&&!e.isPropagationStopped();)for(e.currentTarget=i.elem,o=0;(r=i.handlers[o++])&&!e.isImmediatePropagationStopped();)(!e.namespace_re||e.namespace_re.test(r.namespace))&&(e.handleObj=r,e.data=r.data,n=((it.event.special[r.origType]||{}).handle||r.handler).apply(i.elem,s),void 0!==n&&(e.result=n)===!1&&(e.preventDefault(),e.stopPropagation()));return l.postDispatch&&l.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,r,i,o,a=[],s=t.delegateCount,u=e.target;if(s&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(i=[],o=0;s>o;o++)r=t[o],n=r.selector+" ",void 0===i[n]&&(i[n]=r.needsContext?it(n,this).index(u)>=0:it.find(n,this,null,[u]).length),i[n]&&i.push(r);i.length&&a.push({elem:u,handlers:i})}return s<t.length&&a.push({elem:this,handlers:t.slice(s)}),a},fix:function(e){if(e[it.expando])return e;var t,n,r,i=e.type,o=e,a=this.fixHooks[i];for(a||(this.fixHooks[i]=a=qt.test(i)?this.mouseHooks:Ht.test(i)?this.keyHooks:{}),r=a.props?this.props.concat(a.props):this.props,e=new it.Event(o),t=r.length;t--;)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||ht),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,a.filter?a.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,t){var n,r,i,o=t.button,a=t.fromElement;return null==e.pageX&&null!=t.clientX&&(r=e.target.ownerDocument||ht,i=r.documentElement,n=r.body,e.pageX=t.clientX+(i&&i.scrollLeft||n&&n.scrollLeft||0)-(i&&i.clientLeft||n&&n.clientLeft||0),e.pageY=t.clientY+(i&&i.scrollTop||n&&n.scrollTop||0)-(i&&i.clientTop||n&&n.clientTop||0)),!e.relatedTarget&&a&&(e.relatedTarget=a===e.target?t.toElement:a),e.which||void 0===o||(e.which=1&o?1:2&o?3:4&o?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==h()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===h()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return it.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(e){return it.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=it.extend(new it.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?it.event.trigger(i,null,t):it.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},it.removeEvent=ht.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===Tt&&(e[r]=null),e.detachEvent(r,n))},it.Event=function(e,t){return this instanceof it.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&e.returnValue===!1?f:p):this.type=e,t&&it.extend(this,t),this.timeStamp=e&&e.timeStamp||it.now(),void(this[it.expando]=!0)):new it.Event(e,t)},it.Event.prototype={isDefaultPrevented:p,isPropagationStopped:p,isImmediatePropagationStopped:p,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=f,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=f,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=f,e&&e.stopImmediatePropagation&&e.stopImmediatePropagation(),this.stopPropagation()}},it.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){it.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!it.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),nt.submitBubbles||(it.event.special.submit={setup:function(){return it.nodeName(this,"form")?!1:void it.event.add(this,"click._submit keypress._submit",function(e){var t=e.target,n=it.nodeName(t,"input")||it.nodeName(t,"button")?t.form:void 0;n&&!it._data(n,"submitBubbles")&&(it.event.add(n,"submit._submit",function(e){e._submit_bubble=!0}),it._data(n,"submitBubbles",!0))})},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&it.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return it.nodeName(this,"form")?!1:void it.event.remove(this,"._submit")}}),nt.changeBubbles||(it.event.special.change={setup:function(){return Lt.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(it.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),it.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),it.event.simulate("change",this,e,!0)})),!1):void it.event.add(this,"beforeactivate._change",function(e){var t=e.target;Lt.test(t.nodeName)&&!it._data(t,"changeBubbles")&&(it.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||it.event.simulate("change",this.parentNode,e,!0)}),it._data(t,"changeBubbles",!0))})},handle:function(e){var t=e.target;return this!==t||e.isSimulated||e.isTrigger||"radio"!==t.type&&"checkbox"!==t.type?e.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return it.event.remove(this,"._change"),!Lt.test(this.nodeName)}}),nt.focusinBubbles||it.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){it.event.simulate(t,e.target,it.event.fix(e),!0)};it.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=it._data(r,t);i||r.addEventListener(e,n,!0),it._data(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=it._data(r,t)-1;i?it._data(r,t,i):(r.removeEventListener(e,n,!0),it._removeData(r,t))}}}),it.fn.extend({on:function(e,t,n,r,i){var o,a;if("object"==typeof e){"string"!=typeof t&&(n=n||t,t=void 0);for(o in e)this.on(o,t,n,e[o],i);return this}if(null==n&&null==r?(r=t,n=t=void 0):null==r&&("string"==typeof t?(r=n,n=void 0):(r=n,n=t,t=void 0)),r===!1)r=p;else if(!r)return this;return 1===i&&(a=r,r=function(e){return it().off(e),a.apply(this,arguments)},r.guid=a.guid||(a.guid=it.guid++)),this.each(function(){it.event.add(this,e,r,n,t)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,it(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return(t===!1||"function"==typeof t)&&(n=t,t=void 0),n===!1&&(n=p),this.each(function(){it.event.remove(this,e,n,t)})},trigger:function(e,t){return this.each(function(){it.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];return n?it.event.trigger(e,t,n,!0):void 0}});var Ft="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Ot=/ jQuery\d+="(?:null|\d+)"/g,Bt=new RegExp("<(?:"+Ft+")[\\s/>]","i"),Pt=/^\s+/,Rt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Wt=/<([\w:]+)/,$t=/<tbody/i,zt=/<|&#?\w+;/,It=/<(?:script|style|link)/i,Xt=/checked\s*(?:[^=]|=\s*.checked.)/i,Ut=/^$|\/(?:java|ecma)script/i,Vt=/^true\/(.*)/,Jt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,Yt={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:nt.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},Qt=m(ht),Gt=Qt.appendChild(ht.createElement("div"));Yt.optgroup=Yt.option,Yt.tbody=Yt.tfoot=Yt.colgroup=Yt.caption=Yt.thead,Yt.th=Yt.td,it.extend({clone:function(e,t,n){var r,i,o,a,s,u=it.contains(e.ownerDocument,e);if(nt.html5Clone||it.isXMLDoc(e)||!Bt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Gt.innerHTML=e.outerHTML,Gt.removeChild(o=Gt.firstChild)),!(nt.noCloneEvent&&nt.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||it.isXMLDoc(e)))for(r=g(o),s=g(e),a=0;null!=(i=s[a]);++a)r[a]&&C(i,r[a]);if(t)if(n)for(s=s||g(e),r=r||g(o),a=0;null!=(i=s[a]);a++)T(i,r[a]);else T(e,o);return r=g(o,"script"),r.length>0&&w(r,!u&&g(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){for(var i,o,a,s,u,l,c,d=e.length,f=m(t),p=[],h=0;d>h;h++)if(o=e[h],o||0===o)if("object"===it.type(o))it.merge(p,o.nodeType?[o]:o);else if(zt.test(o)){for(s=s||f.appendChild(t.createElement("div")),u=(Wt.exec(o)||["",""])[1].toLowerCase(),c=Yt[u]||Yt._default,s.innerHTML=c[1]+o.replace(Rt,"<$1></$2>")+c[2],i=c[0];i--;)s=s.lastChild;if(!nt.leadingWhitespace&&Pt.test(o)&&p.push(t.createTextNode(Pt.exec(o)[0])),!nt.tbody)for(o="table"!==u||$t.test(o)?"<table>"!==c[1]||$t.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;i--;)it.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l);for(it.merge(p,s.childNodes),s.textContent="";s.firstChild;)s.removeChild(s.firstChild);s=f.lastChild}else p.push(t.createTextNode(o));for(s&&f.removeChild(s),nt.appendChecked||it.grep(g(p,"input"),v),h=0;o=p[h++];)if((!r||-1===it.inArray(o,r))&&(a=it.contains(o.ownerDocument,o),s=g(f.appendChild(o),"script"),a&&w(s),n))for(i=0;o=s[i++];)Ut.test(o.type||"")&&n.push(o);return s=null,f},cleanData:function(e,t){for(var n,r,i,o,a=0,s=it.expando,u=it.cache,l=nt.deleteExpando,c=it.event.special;null!=(n=e[a]);a++)if((t||it.acceptData(n))&&(i=n[s],o=i&&u[i])){if(o.events)for(r in o.events)c[r]?it.event.remove(n,r):it.removeEvent(n,r,o.handle);u[i]&&(delete u[i],l?delete n[s]:typeof n.removeAttribute!==Tt?n.removeAttribute(s):n[s]=null,J.push(i))}}}),it.fn.extend({text:function(e){return Dt(this,function(e){return void 0===e?it.text(this):this.empty().append((this[0]&&this[0].ownerDocument||ht).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=y(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=y(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){for(var n,r=e?it.filter(e,this):this,i=0;null!=(n=r[i]);i++)t||1!==n.nodeType||it.cleanData(g(n)),n.parentNode&&(t&&it.contains(n.ownerDocument,n)&&w(g(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){for(var e,t=0;null!=(e=this[t]);t++){for(1===e.nodeType&&it.cleanData(g(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&it.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return it.clone(this,e,t)})},html:function(e){return Dt(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e)return 1===t.nodeType?t.innerHTML.replace(Ot,""):void 0;if(!("string"!=typeof e||It.test(e)||!nt.htmlSerialize&&Bt.test(e)||!nt.leadingWhitespace&&Pt.test(e)||Yt[(Wt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(Rt,"<$1></$2>");try{for(;r>n;n++)t=this[n]||{},1===t.nodeType&&(it.cleanData(g(t,!1)),t.innerHTML=e);t=0}catch(i){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=arguments[0];return this.domManip(arguments,function(t){e=this.parentNode,it.cleanData(g(this)),e&&e.replaceChild(t,this)}),e&&(e.length||e.nodeType)?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t){e=Q.apply([],e);var n,r,i,o,a,s,u=0,l=this.length,c=this,d=l-1,f=e[0],p=it.isFunction(f);if(p||l>1&&"string"==typeof f&&!nt.checkClone&&Xt.test(f))return this.each(function(n){var r=c.eq(n);p&&(e[0]=f.call(this,n,r.html())),r.domManip(e,t)});if(l&&(s=it.buildFragment(e,this[0].ownerDocument,!1,this),n=s.firstChild,1===s.childNodes.length&&(s=n),n)){for(o=it.map(g(s,"script"),b),i=o.length;l>u;u++)r=s,u!==d&&(r=it.clone(r,!0,!0),i&&it.merge(o,g(r,"script"))),t.call(this[u],r,u);if(i)for(a=o[o.length-1].ownerDocument,it.map(o,x),u=0;i>u;u++)r=o[u],Ut.test(r.type||"")&&!it._data(r,"globalEval")&&it.contains(a,r)&&(r.src?it._evalUrl&&it._evalUrl(r.src):it.globalEval((r.text||r.textContent||r.innerHTML||"").replace(Jt,"")));s=n=null}return this}}),it.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){it.fn[e]=function(e){for(var n,r=0,i=[],o=it(e),a=o.length-1;a>=r;r++)n=r===a?this:this.clone(!0),it(o[r])[t](n),G.apply(i,n.get());return this.pushStack(i)}});var Kt,Zt={};!function(){var e;nt.shrinkWrapBlocks=function(){if(null!=e)return e;e=!1;var t,n,r;return n=ht.getElementsByTagName("body")[0],n&&n.style?(t=ht.createElement("div"),r=ht.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(t),typeof t.style.zoom!==Tt&&(t.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",t.appendChild(ht.createElement("div")).style.width="5px",e=3!==t.offsetWidth),n.removeChild(r),e):void 0}}();var en=/^margin/,tn=new RegExp("^("+kt+")(?!px)[a-z%]+$","i"),nn,rn,on=/^(top|right|bottom|left)$/;e.getComputedStyle?(nn=function(t){return t.ownerDocument.defaultView.opener?t.ownerDocument.defaultView.getComputedStyle(t,null):e.getComputedStyle(t,null)},rn=function(e,t,n){var r,i,o,a,s=e.style;return n=n||nn(e),a=n?n.getPropertyValue(t)||n[t]:void 0,n&&(""!==a||it.contains(e.ownerDocument,e)||(a=it.style(e,t)),tn.test(a)&&en.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0===a?a:a+""
+}):ht.documentElement.currentStyle&&(nn=function(e){return e.currentStyle},rn=function(e,t,n){var r,i,o,a,s=e.style;return n=n||nn(e),a=n?n[t]:void 0,null==a&&s&&s[t]&&(a=s[t]),tn.test(a)&&!on.test(t)&&(r=s.left,i=e.runtimeStyle,o=i&&i.left,o&&(i.left=e.currentStyle.left),s.left="fontSize"===t?"1em":a,a=s.pixelLeft+"px",s.left=r,o&&(i.left=o)),void 0===a?a:a+""||"auto"}),function(){function t(){var t,n,r,i;n=ht.getElementsByTagName("body")[0],n&&n.style&&(t=ht.createElement("div"),r=ht.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(t),t.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",o=a=!1,u=!0,e.getComputedStyle&&(o="1%"!==(e.getComputedStyle(t,null)||{}).top,a="4px"===(e.getComputedStyle(t,null)||{width:"4px"}).width,i=t.appendChild(ht.createElement("div")),i.style.cssText=t.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",t.style.width="1px",u=!parseFloat((e.getComputedStyle(i,null)||{}).marginRight),t.removeChild(i)),t.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=t.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",s=0===i[0].offsetHeight,s&&(i[0].style.display="",i[1].style.display="none",s=0===i[0].offsetHeight),n.removeChild(r))}var n,r,i,o,a,s,u;n=ht.createElement("div"),n.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",i=n.getElementsByTagName("a")[0],r=i&&i.style,r&&(r.cssText="float:left;opacity:.5",nt.opacity="0.5"===r.opacity,nt.cssFloat=!!r.cssFloat,n.style.backgroundClip="content-box",n.cloneNode(!0).style.backgroundClip="",nt.clearCloneStyle="content-box"===n.style.backgroundClip,nt.boxSizing=""===r.boxSizing||""===r.MozBoxSizing||""===r.WebkitBoxSizing,it.extend(nt,{reliableHiddenOffsets:function(){return null==s&&t(),s},boxSizingReliable:function(){return null==a&&t(),a},pixelPosition:function(){return null==o&&t(),o},reliableMarginRight:function(){return null==u&&t(),u}}))}(),it.swap=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i};var an=/alpha\([^)]*\)/i,sn=/opacity\s*=\s*([^)]*)/,un=/^(none|table(?!-c[ea]).+)/,ln=new RegExp("^("+kt+")(.*)$","i"),cn=new RegExp("^([+-])=("+kt+")","i"),dn={position:"absolute",visibility:"hidden",display:"block"},fn={letterSpacing:"0",fontWeight:"400"},pn=["Webkit","O","Moz","ms"];it.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=rn(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":nt.cssFloat?"cssFloat":"styleFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=it.camelCase(t),u=e.style;if(t=it.cssProps[s]||(it.cssProps[s]=S(u,s)),a=it.cssHooks[t]||it.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:u[t];if(o=typeof n,"string"===o&&(i=cn.exec(n))&&(n=(i[1]+1)*i[2]+parseFloat(it.css(e,t)),o="number"),null!=n&&n===n&&("number"!==o||it.cssNumber[s]||(n+="px"),nt.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),!(a&&"set"in a&&void 0===(n=a.set(e,n,r)))))try{u[t]=n}catch(l){}}},css:function(e,t,n,r){var i,o,a,s=it.camelCase(t);return t=it.cssProps[s]||(it.cssProps[s]=S(e.style,s)),a=it.cssHooks[t]||it.cssHooks[s],a&&"get"in a&&(o=a.get(e,!0,n)),void 0===o&&(o=rn(e,t,r)),"normal"===o&&t in fn&&(o=fn[t]),""===n||n?(i=parseFloat(o),n===!0||it.isNumeric(i)?i||0:o):o}}),it.each(["height","width"],function(e,t){it.cssHooks[t]={get:function(e,n,r){return n?un.test(it.css(e,"display"))&&0===e.offsetWidth?it.swap(e,dn,function(){return L(e,t,r)}):L(e,t,r):void 0},set:function(e,n,r){var i=r&&nn(e);return D(e,n,r?j(e,t,r,nt.boxSizing&&"border-box"===it.css(e,"boxSizing",!1,i),i):0)}}}),nt.opacity||(it.cssHooks.opacity={get:function(e,t){return sn.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=it.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===it.trim(o.replace(an,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=an.test(o)?o.replace(an,i):o+" "+i)}}),it.cssHooks.marginRight=k(nt.reliableMarginRight,function(e,t){return t?it.swap(e,{display:"inline-block"},rn,[e,"marginRight"]):void 0}),it.each({margin:"",padding:"",border:"Width"},function(e,t){it.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];4>r;r++)i[e+St[r]+t]=o[r]||o[r-2]||o[0];return i}},en.test(e)||(it.cssHooks[e+t].set=D)}),it.fn.extend({css:function(e,t){return Dt(this,function(e,t,n){var r,i,o={},a=0;if(it.isArray(t)){for(r=nn(e),i=t.length;i>a;a++)o[t[a]]=it.css(e,t[a],!1,r);return o}return void 0!==n?it.style(e,t,n):it.css(e,t)},e,t,arguments.length>1)},show:function(){return A(this,!0)},hide:function(){return A(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){At(this)?it(this).show():it(this).hide()})}}),it.Tween=H,H.prototype={constructor:H,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(it.cssNumber[n]?"":"px")},cur:function(){var e=H.propHooks[this.prop];return e&&e.get?e.get(this):H.propHooks._default.get(this)},run:function(e){var t,n=H.propHooks[this.prop];return this.pos=t=this.options.duration?it.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):H.propHooks._default.set(this),this}},H.prototype.init.prototype=H.prototype,H.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=it.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){it.fx.step[e.prop]?it.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[it.cssProps[e.prop]]||it.cssHooks[e.prop])?it.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},H.propHooks.scrollTop=H.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},it.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},it.fx=H.prototype.init,it.fx.step={};var hn,mn,gn=/^(?:toggle|show|hide)$/,vn=new RegExp("^(?:([+-])=|)("+kt+")([a-z%]*)$","i"),yn=/queueHooks$/,bn=[F],xn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=vn.exec(t),o=i&&i[3]||(it.cssNumber[e]?"":"px"),a=(it.cssNumber[e]||"px"!==o&&+r)&&vn.exec(it.css(n.elem,e)),s=1,u=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,it.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--u)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};it.Animation=it.extend(B,{tweener:function(e,t){it.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");for(var n,r=0,i=e.length;i>r;r++)n=e[r],xn[n]=xn[n]||[],xn[n].unshift(t)},prefilter:function(e,t){t?bn.unshift(e):bn.push(e)}}),it.speed=function(e,t,n){var r=e&&"object"==typeof e?it.extend({},e):{complete:n||!n&&t||it.isFunction(e)&&e,duration:e,easing:n&&t||t&&!it.isFunction(t)&&t};return r.duration=it.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in it.fx.speeds?it.fx.speeds[r.duration]:it.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){it.isFunction(r.old)&&r.old.call(this),r.queue&&it.dequeue(this,r.queue)},r},it.fn.extend({fadeTo:function(e,t,n,r){return this.filter(At).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=it.isEmptyObject(e),o=it.speed(t,n,r),a=function(){var t=B(this,it.extend({},e),o);(i||it._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=it.timers,a=it._data(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&yn.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));(t||!n)&&it.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=it._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=it.timers,a=r?r.length:0;for(n.finish=!0,it.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),it.each(["toggle","show","hide"],function(e,t){var n=it.fn[t];it.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(_(t,!0),e,r,i)}}),it.each({slideDown:_("show"),slideUp:_("hide"),slideToggle:_("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){it.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),it.timers=[],it.fx.tick=function(){var e,t=it.timers,n=0;for(hn=it.now();n<t.length;n++)e=t[n],e()||t[n]!==e||t.splice(n--,1);t.length||it.fx.stop(),hn=void 0},it.fx.timer=function(e){it.timers.push(e),e()?it.fx.start():it.timers.pop()},it.fx.interval=13,it.fx.start=function(){mn||(mn=setInterval(it.fx.tick,it.fx.interval))},it.fx.stop=function(){clearInterval(mn),mn=null},it.fx.speeds={slow:600,fast:200,_default:400},it.fn.delay=function(e,t){return e=it.fx?it.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},function(){var e,t,n,r,i;t=ht.createElement("div"),t.setAttribute("className","t"),t.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",r=t.getElementsByTagName("a")[0],n=ht.createElement("select"),i=n.appendChild(ht.createElement("option")),e=t.getElementsByTagName("input")[0],r.style.cssText="top:1px",nt.getSetAttribute="t"!==t.className,nt.style=/top/.test(r.getAttribute("style")),nt.hrefNormalized="/a"===r.getAttribute("href"),nt.checkOn=!!e.value,nt.optSelected=i.selected,nt.enctype=!!ht.createElement("form").enctype,n.disabled=!0,nt.optDisabled=!i.disabled,e=ht.createElement("input"),e.setAttribute("value",""),nt.input=""===e.getAttribute("value"),e.value="t",e.setAttribute("type","radio"),nt.radioValue="t"===e.value}();var wn=/\r/g;it.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=it.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,it(this).val()):e,null==i?i="":"number"==typeof i?i+="":it.isArray(i)&&(i=it.map(i,function(e){return null==e?"":e+""})),t=it.valHooks[this.type]||it.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return t=it.valHooks[i.type]||it.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(wn,""):null==n?"":n)}}}),it.extend({valHooks:{option:{get:function(e){var t=it.find.attr(e,"value");return null!=t?t:it.trim(it.text(e))}},select:{get:function(e){for(var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(nt.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&it.nodeName(n.parentNode,"optgroup"))){if(t=it(n).val(),o)return t;a.push(t)}return a},set:function(e,t){for(var n,r,i=e.options,o=it.makeArray(t),a=i.length;a--;)if(r=i[a],it.inArray(it.valHooks.option.get(r),o)>=0)try{r.selected=n=!0}catch(s){r.scrollHeight}else r.selected=!1;return n||(e.selectedIndex=-1),i}}}}),it.each(["radio","checkbox"],function(){it.valHooks[this]={set:function(e,t){return it.isArray(t)?e.checked=it.inArray(it(e).val(),t)>=0:void 0}},nt.checkOn||(it.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Tn,Cn,Nn=it.expr.attrHandle,En=/^(?:checked|selected)$/i,kn=nt.getSetAttribute,Sn=nt.input;it.fn.extend({attr:function(e,t){return Dt(this,it.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){it.removeAttr(this,e)})}}),it.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(e&&3!==o&&8!==o&&2!==o)return typeof e.getAttribute===Tt?it.prop(e,t,n):(1===o&&it.isXMLDoc(e)||(t=t.toLowerCase(),r=it.attrHooks[t]||(it.expr.match.bool.test(t)?Cn:Tn)),void 0===n?r&&"get"in r&&null!==(i=r.get(e,t))?i:(i=it.find.attr(e,t),null==i?void 0:i):null!==n?r&&"set"in r&&void 0!==(i=r.set(e,n,t))?i:(e.setAttribute(t,n+""),n):void it.removeAttr(e,t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(bt);if(o&&1===e.nodeType)for(;n=o[i++];)r=it.propFix[n]||n,it.expr.match.bool.test(n)?Sn&&kn||!En.test(n)?e[r]=!1:e[it.camelCase("default-"+n)]=e[r]=!1:it.attr(e,n,""),e.removeAttribute(kn?n:r)},attrHooks:{type:{set:function(e,t){if(!nt.radioValue&&"radio"===t&&it.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}}}),Cn={set:function(e,t,n){return t===!1?it.removeAttr(e,n):Sn&&kn||!En.test(n)?e.setAttribute(!kn&&it.propFix[n]||n,n):e[it.camelCase("default-"+n)]=e[n]=!0,n}},it.each(it.expr.match.bool.source.match(/\w+/g),function(e,t){var n=Nn[t]||it.find.attr;Nn[t]=Sn&&kn||!En.test(t)?function(e,t,r){var i,o;return r||(o=Nn[t],Nn[t]=i,i=null!=n(e,t,r)?t.toLowerCase():null,Nn[t]=o),i}:function(e,t,n){return n?void 0:e[it.camelCase("default-"+t)]?t.toLowerCase():null}}),Sn&&kn||(it.attrHooks.value={set:function(e,t,n){return it.nodeName(e,"input")?void(e.defaultValue=t):Tn&&Tn.set(e,t,n)}}),kn||(Tn={set:function(e,t,n){var r=e.getAttributeNode(n);return r||e.setAttributeNode(r=e.ownerDocument.createAttribute(n)),r.value=t+="","value"===n||t===e.getAttribute(n)?t:void 0}},Nn.id=Nn.name=Nn.coords=function(e,t,n){var r;return n?void 0:(r=e.getAttributeNode(t))&&""!==r.value?r.value:null},it.valHooks.button={get:function(e,t){var n=e.getAttributeNode(t);return n&&n.specified?n.value:void 0},set:Tn.set},it.attrHooks.contenteditable={set:function(e,t,n){Tn.set(e,""===t?!1:t,n)}},it.each(["width","height"],function(e,t){it.attrHooks[t]={set:function(e,n){return""===n?(e.setAttribute(t,"auto"),n):void 0}}})),nt.style||(it.attrHooks.style={get:function(e){return e.style.cssText||void 0},set:function(e,t){return e.style.cssText=t+""}});var An=/^(?:input|select|textarea|button|object)$/i,Dn=/^(?:a|area)$/i;it.fn.extend({prop:function(e,t){return Dt(this,it.prop,e,t,arguments.length>1)},removeProp:function(e){return e=it.propFix[e]||e,this.each(function(){try{this[e]=void 0,delete this[e]}catch(t){}})}}),it.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var r,i,o,a=e.nodeType;if(e&&3!==a&&8!==a&&2!==a)return o=1!==a||!it.isXMLDoc(e),o&&(t=it.propFix[t]||t,i=it.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=it.find.attr(e,"tabindex");return t?parseInt(t,10):An.test(e.nodeName)||Dn.test(e.nodeName)&&e.href?0:-1}}}}),nt.hrefNormalized||it.each(["href","src"],function(e,t){it.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),nt.optSelected||(it.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),it.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){it.propFix[this.toLowerCase()]=this}),nt.enctype||(it.propFix.enctype="encoding");var jn=/[\t\r\n\f]/g;it.fn.extend({addClass:function(e){var t,n,r,i,o,a,s=0,u=this.length,l="string"==typeof e&&e;if(it.isFunction(e))return this.each(function(t){it(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(bt)||[];u>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(jn," "):" ")){for(o=0;i=t[o++];)r.indexOf(" "+i+" ")<0&&(r+=i+" ");a=it.trim(r),n.className!==a&&(n.className=a)}return this},removeClass:function(e){var t,n,r,i,o,a,s=0,u=this.length,l=0===arguments.length||"string"==typeof e&&e;if(it.isFunction(e))return this.each(function(t){it(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(bt)||[];u>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(jn," "):"")){for(o=0;i=t[o++];)for(;r.indexOf(" "+i+" ")>=0;)r=r.replace(" "+i+" "," ");a=e?it.trim(r):"",n.className!==a&&(n.className=a)}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):this.each(it.isFunction(e)?function(n){it(this).toggleClass(e.call(this,n,this.className,t),t)}:function(){if("string"===n)for(var t,r=0,i=it(this),o=e.match(bt)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else(n===Tt||"boolean"===n)&&(this.className&&it._data(this,"__className__",this.className),this.className=this.className||e===!1?"":it._data(this,"__className__")||"")})},hasClass:function(e){for(var t=" "+e+" ",n=0,r=this.length;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(jn," ").indexOf(t)>=0)return!0;return!1}}),it.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){it.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),it.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var Ln=it.now(),Hn=/\?/,qn=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;it.parseJSON=function(t){if(e.JSON&&e.JSON.parse)return e.JSON.parse(t+"");var n,r=null,i=it.trim(t+"");return i&&!it.trim(i.replace(qn,function(e,t,i,o){return n&&t&&(r=0),0===r?e:(n=i||t,r+=!o-!i,"")}))?Function("return "+i)():it.error("Invalid JSON: "+t)},it.parseXML=function(t){var n,r;if(!t||"string"!=typeof t)return null;try{e.DOMParser?(r=new DOMParser,n=r.parseFromString(t,"text/xml")):(n=new ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(t))}catch(i){n=void 0}return n&&n.documentElement&&!n.getElementsByTagName("parsererror").length||it.error("Invalid XML: "+t),n};var _n,Mn,Fn=/#.*$/,On=/([?&])_=[^&]*/,Bn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Pn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Rn=/^(?:GET|HEAD)$/,Wn=/^\/\//,$n=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,zn={},In={},Xn="*/".concat("*");try{Mn=location.href}catch(Un){Mn=ht.createElement("a"),Mn.href="",Mn=Mn.href}_n=$n.exec(Mn.toLowerCase())||[],it.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Mn,type:"GET",isLocal:Pn.test(_n[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Xn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":it.parseJSON,"text xml":it.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?W(W(e,it.ajaxSettings),t):W(it.ajaxSettings,e)},ajaxPrefilter:P(zn),ajaxTransport:P(In),ajax:function(e,t){function n(e,t,n,r){var i,c,v,y,x,T=t;2!==b&&(b=2,s&&clearTimeout(s),l=void 0,a=r||"",w.readyState=e>0?4:0,i=e>=200&&300>e||304===e,n&&(y=$(d,w,n)),y=z(d,y,w,i),i?(d.ifModified&&(x=w.getResponseHeader("Last-Modified"),x&&(it.lastModified[o]=x),x=w.getResponseHeader("etag"),x&&(it.etag[o]=x)),204===e||"HEAD"===d.type?T="nocontent":304===e?T="notmodified":(T=y.state,c=y.data,v=y.error,i=!v)):(v=T,(e||!T)&&(T="error",0>e&&(e=0))),w.status=e,w.statusText=(t||T)+"",i?h.resolveWith(f,[c,T,w]):h.rejectWith(f,[w,T,v]),w.statusCode(g),g=void 0,u&&p.trigger(i?"ajaxSuccess":"ajaxError",[w,d,i?c:v]),m.fireWith(f,[w,T]),u&&(p.trigger("ajaxComplete",[w,d]),--it.active||it.event.trigger("ajaxStop")))}"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,i,o,a,s,u,l,c,d=it.ajaxSetup({},t),f=d.context||d,p=d.context&&(f.nodeType||f.jquery)?it(f):it.event,h=it.Deferred(),m=it.Callbacks("once memory"),g=d.statusCode||{},v={},y={},b=0,x="canceled",w={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c)for(c={};t=Bn.exec(a);)c[t[1].toLowerCase()]=t[2];t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=y[n]=y[n]||e,v[e]=t),this},overrideMimeType:function(e){return b||(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)g[t]=[g[t],e[t]];else w.always(e[w.status]);return this},abort:function(e){var t=e||x;return l&&l.abort(t),n(0,t),this}};if(h.promise(w).complete=m.add,w.success=w.done,w.error=w.fail,d.url=((e||d.url||Mn)+"").replace(Fn,"").replace(Wn,_n[1]+"//"),d.type=t.method||t.type||d.method||d.type,d.dataTypes=it.trim(d.dataType||"*").toLowerCase().match(bt)||[""],null==d.crossDomain&&(r=$n.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]===_n[1]&&r[2]===_n[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(_n[3]||("http:"===_n[1]?"80":"443")))),d.data&&d.processData&&"string"!=typeof d.data&&(d.data=it.param(d.data,d.traditional)),R(zn,d,t,w),2===b)return w;u=it.event&&d.global,u&&0===it.active++&&it.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!Rn.test(d.type),o=d.url,d.hasContent||(d.data&&(o=d.url+=(Hn.test(o)?"&":"?")+d.data,delete d.data),d.cache===!1&&(d.url=On.test(o)?o.replace(On,"$1_="+Ln++):o+(Hn.test(o)?"&":"?")+"_="+Ln++)),d.ifModified&&(it.lastModified[o]&&w.setRequestHeader("If-Modified-Since",it.lastModified[o]),it.etag[o]&&w.setRequestHeader("If-None-Match",it.etag[o])),(d.data&&d.hasContent&&d.contentType!==!1||t.contentType)&&w.setRequestHeader("Content-Type",d.contentType),w.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+Xn+"; q=0.01":""):d.accepts["*"]);for(i in d.headers)w.setRequestHeader(i,d.headers[i]);if(d.beforeSend&&(d.beforeSend.call(f,w,d)===!1||2===b))return w.abort();x="abort";for(i in{success:1,error:1,complete:1})w[i](d[i]);if(l=R(In,d,t,w)){w.readyState=1,u&&p.trigger("ajaxSend",[w,d]),d.async&&d.timeout>0&&(s=setTimeout(function(){w.abort("timeout")},d.timeout));try{b=1,l.send(v,n)}catch(T){if(!(2>b))throw T;n(-1,T)}}else n(-1,"No Transport");return w},getJSON:function(e,t,n){return it.get(e,t,n,"json")},getScript:function(e,t){return it.get(e,void 0,t,"script")}}),it.each(["get","post"],function(e,t){it[t]=function(e,n,r,i){return it.isFunction(n)&&(i=i||r,r=n,n=void 0),it.ajax({url:e,type:t,dataType:i,data:n,success:r})}}),it._evalUrl=function(e){return it.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},it.fn.extend({wrapAll:function(e){if(it.isFunction(e))return this.each(function(t){it(this).wrapAll(e.call(this,t))});if(this[0]){var t=it(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return this.each(it.isFunction(e)?function(t){it(this).wrapInner(e.call(this,t))}:function(){var t=it(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=it.isFunction(e);return this.each(function(n){it(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){it.nodeName(this,"body")||it(this).replaceWith(this.childNodes)}).end()}}),it.expr.filters.hidden=function(e){return e.offsetWidth<=0&&e.offsetHeight<=0||!nt.reliableHiddenOffsets()&&"none"===(e.style&&e.style.display||it.css(e,"display"))},it.expr.filters.visible=function(e){return!it.expr.filters.hidden(e)};var Vn=/%20/g,Jn=/\[\]$/,Yn=/\r?\n/g,Qn=/^(?:submit|button|image|reset|file)$/i,Gn=/^(?:input|select|textarea|keygen)/i;it.param=function(e,t){var n,r=[],i=function(e,t){t=it.isFunction(t)?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(void 0===t&&(t=it.ajaxSettings&&it.ajaxSettings.traditional),it.isArray(e)||e.jquery&&!it.isPlainObject(e))it.each(e,function(){i(this.name,this.value)});else for(n in e)I(n,e[n],t,i);return r.join("&").replace(Vn,"+")},it.fn.extend({serialize:function(){return it.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=it.prop(this,"elements");return e?it.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!it(this).is(":disabled")&&Gn.test(this.nodeName)&&!Qn.test(e)&&(this.checked||!jt.test(e))}).map(function(e,t){var n=it(this).val();return null==n?null:it.isArray(n)?it.map(n,function(e){return{name:t.name,value:e.replace(Yn,"\r\n")}}):{name:t.name,value:n.replace(Yn,"\r\n")}}).get()}}),it.ajaxSettings.xhr=void 0!==e.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&X()||U()}:X;var Kn=0,Zn={},er=it.ajaxSettings.xhr();e.attachEvent&&e.attachEvent("onunload",function(){for(var e in Zn)Zn[e](void 0,!0)}),nt.cors=!!er&&"withCredentials"in er,er=nt.ajax=!!er,er&&it.ajaxTransport(function(e){if(!e.crossDomain||nt.cors){var t;return{send:function(n,r){var i,o=e.xhr(),a=++Kn;if(o.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(i in e.xhrFields)o[i]=e.xhrFields[i];e.mimeType&&o.overrideMimeType&&o.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest");for(i in n)void 0!==n[i]&&o.setRequestHeader(i,n[i]+"");o.send(e.hasContent&&e.data||null),t=function(n,i){var s,u,l;if(t&&(i||4===o.readyState))if(delete Zn[a],t=void 0,o.onreadystatechange=it.noop,i)4!==o.readyState&&o.abort();else{l={},s=o.status,"string"==typeof o.responseText&&(l.text=o.responseText);try{u=o.statusText}catch(c){u=""}s||!e.isLocal||e.crossDomain?1223===s&&(s=204):s=l.text?200:404}l&&r(s,u,l,o.getAllResponseHeaders())},e.async?4===o.readyState?setTimeout(t):o.onreadystatechange=Zn[a]=t:t()},abort:function(){t&&t(void 0,!0)}}}}),it.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return it.globalEval(e),e}}}),it.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),it.ajaxTransport("script",function(e){if(e.crossDomain){var t,n=ht.head||it("head")[0]||ht.documentElement;return{send:function(r,i){t=ht.createElement("script"),t.async=!0,e.scriptCharset&&(t.charset=e.scriptCharset),t.src=e.url,t.onload=t.onreadystatechange=function(e,n){(n||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),t=null,n||i(200,"success"))},n.insertBefore(t,n.firstChild)},abort:function(){t&&t.onload(void 0,!0)}}}});var tr=[],nr=/(=)\?(?=&|$)|\?\?/;it.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=tr.pop()||it.expando+"_"+Ln++;return this[e]=!0,e}}),it.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=t.jsonp!==!1&&(nr.test(t.url)?"url":"string"==typeof t.data&&!(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&nr.test(t.data)&&"data");return s||"jsonp"===t.dataTypes[0]?(i=t.jsonpCallback=it.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(nr,"$1"+i):t.jsonp!==!1&&(t.url+=(Hn.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||it.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,tr.push(i)),a&&it.isFunction(o)&&o(a[0]),a=o=void 0}),"script"):void 0}),it.parseHTML=function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||ht;var r=dt.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=it.buildFragment([e],t,i),i&&i.length&&it(i).remove(),it.merge([],r.childNodes))};var rr=it.fn.load;it.fn.load=function(e,t,n){if("string"!=typeof e&&rr)return rr.apply(this,arguments);var r,i,o,a=this,s=e.indexOf(" ");return s>=0&&(r=it.trim(e.slice(s,e.length)),e=e.slice(0,s)),it.isFunction(t)?(n=t,t=void 0):t&&"object"==typeof t&&(o="POST"),a.length>0&&it.ajax({url:e,type:o,dataType:"html",data:t}).done(function(e){i=arguments,a.html(r?it("<div>").append(it.parseHTML(e)).find(r):e)}).complete(n&&function(e,t){a.each(n,i||[e.responseText,t,e])}),this},it.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){it.fn[t]=function(e){return this.on(t,e)}}),it.expr.filters.animated=function(e){return it.grep(it.timers,function(t){return e===t.elem}).length};var ir=e.document.documentElement;it.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=it.css(e,"position"),d=it(e),f={};"static"===c&&(e.style.position="relative"),s=d.offset(),o=it.css(e,"top"),u=it.css(e,"left"),l=("absolute"===c||"fixed"===c)&&it.inArray("auto",[o,u])>-1,l?(r=d.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),it.isFunction(t)&&(t=t.call(e,n,s)),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):d.css(f)}},it.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){it.offset.setOffset(this,e,t)});var t,n,r={top:0,left:0},i=this[0],o=i&&i.ownerDocument;if(o)return t=o.documentElement,it.contains(t,i)?(typeof i.getBoundingClientRect!==Tt&&(r=i.getBoundingClientRect()),n=V(o),{top:r.top+(n.pageYOffset||t.scrollTop)-(t.clientTop||0),left:r.left+(n.pageXOffset||t.scrollLeft)-(t.clientLeft||0)}):r},position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===it.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),it.nodeName(e[0],"html")||(n=e.offset()),n.top+=it.css(e[0],"borderTopWidth",!0),n.left+=it.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-it.css(r,"marginTop",!0),left:t.left-n.left-it.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent||ir;e&&!it.nodeName(e,"html")&&"static"===it.css(e,"position");)e=e.offsetParent;return e||ir})}}),it.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n=/Y/.test(t);it.fn[e]=function(r){return Dt(this,function(e,r,i){var o=V(e);return void 0===i?o?t in o?o[t]:o.document.documentElement[r]:e[r]:void(o?o.scrollTo(n?it(o).scrollLeft():i,n?i:it(o).scrollTop()):e[r]=i)},e,r,arguments.length,null)}}),it.each(["top","left"],function(e,t){it.cssHooks[t]=k(nt.pixelPosition,function(e,n){return n?(n=rn(e,t),tn.test(n)?it(e).position()[t]+"px":n):void 0})}),it.each({Height:"height",Width:"width"},function(e,t){it.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){it.fn[r]=function(r,i){var o=arguments.length&&(n||"boolean"!=typeof r),a=n||(r===!0||i===!0?"margin":"border");return Dt(this,function(t,n,r){var i;return it.isWindow(t)?t.document.documentElement["client"+e]:9===t.nodeType?(i=t.documentElement,Math.max(t.body["scroll"+e],i["scroll"+e],t.body["offset"+e],i["offset"+e],i["client"+e])):void 0===r?it.css(t,n,a):it.style(t,n,r,a)
+},t,o?r:void 0,o,null)}})}),it.fn.size=function(){return this.length},it.fn.andSelf=it.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return it});var or=e.jQuery,ar=e.$;return it.noConflict=function(t){return e.$===it&&(e.$=ar),t&&e.jQuery===it&&(e.jQuery=or),it},typeof t===Tt&&(e.jQuery=e.$=it),it})}).call(this),function(){t=n=window.jQuery.noConflict()}.call(this),"undefined"==typeof Package&&(Package={}),Package.jquery={$:t,jQuery:n}}();
+
+!function(){var e=Package.meteor.Meteor,a=Package.tracker.Tracker,c=Package.tracker.Deps,a,c;"undefined"==typeof Package&&(Package={}),Package.deps={Tracker:a,Deps:c}}();
+
+!function(){var t=Package.meteor.Meteor,e=Package.tracker.Tracker,r=Package.tracker.Deps,i,n,a;(function(){i={},n=function(t){return t},a=Array.prototype.slice}).call(this),function(){var t=Object.prototype.hasOwnProperty,e=function(e,r){for(var i in r)t.call(r,i)&&(e[i]=r[i]);return e};i.Visitor=function(t){e(this,t)},i.Visitor.def=function(t){e(this.prototype,t)},i.Visitor.extend=function(t){var r=this,n=function a(){i.Visitor.apply(this,arguments)};return n.prototype=new r,n.extend=r.extend,n.def=r.def,t&&e(n.prototype,t),n},i.Visitor.def({visit:function(t){if(null==t)return this.visitNull.apply(this,arguments);if("object"==typeof t){if(t.htmljsType)switch(t.htmljsType){case i.Tag.htmljsType:return this.visitTag.apply(this,arguments);case i.CharRef.htmljsType:return this.visitCharRef.apply(this,arguments);case i.Comment.htmljsType:return this.visitComment.apply(this,arguments);case i.Raw.htmljsType:return this.visitRaw.apply(this,arguments);default:throw new Error("Unknown htmljs type: "+t.htmljsType)}return i.isArray(t)?this.visitArray.apply(this,arguments):this.visitObject.apply(this,arguments)}if("string"==typeof t||"boolean"==typeof t||"number"==typeof t)return this.visitPrimitive.apply(this,arguments);if("function"==typeof t)return this.visitFunction.apply(this,arguments);throw new Error("Unexpected object in htmljs: "+t)},visitNull:function(t){},visitPrimitive:function(t){},visitArray:function(t){},visitComment:function(t){},visitCharRef:function(t){},visitRaw:function(t){},visitTag:function(t){},visitObject:function(t){throw new Error("Unexpected object in htmljs: "+t)},visitFunction:function(t){throw new Error("Unexpected function in htmljs: "+t)}}),i.TransformingVisitor=i.Visitor.extend(),i.TransformingVisitor.def({visitNull:n,visitPrimitive:n,visitArray:function(t){for(var e=a.call(arguments),r=t,i=0;i<t.length;i++){var n=t[i];e[0]=n;var o=this.visit.apply(this,e);o!==n&&(r===t&&(r=t.slice()),r[i]=o)}return r},visitComment:n,visitCharRef:n,visitRaw:n,visitObject:n,visitFunction:n,visitTag:function(t){var e=t.children,r=a.call(arguments);r[0]=e;var n=this.visitChildren.apply(this,r),o=t.attrs;r[0]=o;var s=this.visitAttributes.apply(this,r);if(s===o&&n===e)return t;var u=i.getTag(t.tagName).apply(null,n);return u.attrs=s,u},visitChildren:function(t){return this.visitArray.apply(this,arguments)},visitAttributes:function(t){if(i.isArray(t)){for(var r=a.call(arguments),n=t,o=0;o<t.length;o++){var s=t[o];r[0]=s;var u=this.visitAttributes.apply(this,r);u!==s&&(n===t&&(n=t.slice()),n[o]=u)}return n}if(t&&i.isConstructedObject(t))throw new Error("The basic HTML.TransformingVisitor does not support foreign objects in attributes. Define a custom visitAttributes for this case.");var l=t,f=l;if(l){var c=[null,null];c.push.apply(c,arguments);for(var h in l){var p=l[h];c[0]=h,c[1]=p;var m=this.visitAttribute.apply(this,c);m!==p&&(f===l&&(f=e({},l)),f[h]=m)}}return f},visitAttribute:function(t,e,r){var i=a.call(arguments,2);return i[0]=e,this.visit.apply(this,i)}}),i.ToTextVisitor=i.Visitor.extend(),i.ToTextVisitor.def({visitNull:function(t){return""},visitPrimitive:function(t){var e=String(t);return this.textMode===i.TEXTMODE.RCDATA?e.replace(/&/g,"&amp;").replace(/</g,"&lt;"):this.textMode===i.TEXTMODE.ATTRIBUTE?e.replace(/&/g,"&amp;").replace(/"/g,"&quot;"):e},visitArray:function(t){for(var e=[],r=0;r<t.length;r++)e.push(this.visit(t[r]));return e.join("")},visitComment:function(t){throw new Error("Can't have a comment here")},visitCharRef:function(t){return this.textMode===i.TEXTMODE.RCDATA||this.textMode===i.TEXTMODE.ATTRIBUTE?t.html:t.str},visitRaw:function(t){return t.value},visitTag:function(t){return this.visit(this.toHTML(t))},visitObject:function(t){throw new Error("Unexpected object in htmljs in toText: "+t)},toHTML:function(t){return i.toHTML(t)}}),i.ToHTMLVisitor=i.Visitor.extend(),i.ToHTMLVisitor.def({visitNull:function(t){return""},visitPrimitive:function(t){var e=String(t);return e.replace(/&/g,"&amp;").replace(/</g,"&lt;")},visitArray:function(t){for(var e=[],r=0;r<t.length;r++)e.push(this.visit(t[r]));return e.join("")},visitComment:function(t){return"<!--"+t.sanitizedValue+"-->"},visitCharRef:function(t){return t.html},visitRaw:function(t){return t.value},visitTag:function(t){var e=[],r=t.tagName,n=t.children,a=t.attrs;if(a){a=i.flattenAttributes(a);for(var o in a)if("value"===o&&"textarea"===r)n=[a[o],n];else{var s=this.toText(a[o],i.TEXTMODE.ATTRIBUTE);e.push(" "+o+'="'+s+'"')}}var u="<"+r+e.join("")+">",l=[],f;if("textarea"===r){for(var c=0;c<n.length;c++)l.push(this.toText(n[c],i.TEXTMODE.RCDATA));f=l.join(""),"\n"===f.slice(0,1)&&(f="\n"+f)}else{for(var c=0;c<n.length;c++)l.push(this.visit(n[c]));f=l.join("")}var h=u+f;return(n.length||!i.isVoidElement(r))&&(h+="</"+r+">"),h},visitObject:function(t){throw new Error("Unexpected object in htmljs in toHTML: "+t)},toText:function(t,e){return i.toText(t,e)}})}.call(this),function(){i.Tag=function(){},i.Tag.prototype.tagName="",i.Tag.prototype.attrs=null,i.Tag.prototype.children=Object.freeze?Object.freeze([]):[],i.Tag.prototype.htmljsType=i.Tag.htmljsType=["Tag"];var t=function(t){var e=function(){var t=this instanceof i.Tag?this:new e,r=0,n=arguments.length&&arguments[0];if(n&&"object"==typeof n)if(i.isConstructedObject(n)){if(n instanceof i.Attrs){var o=n.value;1===o.length?t.attrs=o[0]:o.length>1&&(t.attrs=o),r++}}else t.attrs=n,r++;return r<arguments.length&&(t.children=a.call(arguments,r)),t};return e.prototype=new i.Tag,e.prototype.constructor=e,e.prototype.tagName=t,e},e=i.Attrs=function(){var t=this instanceof e?this:new e;return t.value=a.call(arguments),t};i.getTag=function(e){var r=i.getSymbolName(e);if(r===e)throw new Error("Use the lowercase or camelCase form of '"+e+"' here");return i[r]||(i[r]=t(e)),i[r]},i.ensureTag=function(t){i.getTag(t)},i.isTagEnsured=function(t){return i.isKnownElement(t)},i.getSymbolName=function(t){return t.toUpperCase().replace(/-/g,"_")},i.knownElementNames="a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup command data datagrid datalist dd del details dfn dir div dl dt em embed eventsource fieldset figcaption figure font footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins isindex kbd keygen label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td textarea tfoot th thead time title tr track tt u ul var video wbr".split(" "),i.knownSVGElementNames="altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform circle clipPath color-profile cursor defs desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font font-face font-face-format font-face-name font-face-src font-face-uri foreignObject g glyph glyphRef hkern image line linearGradient marker mask metadata missing-glyph path pattern polygon polyline radialGradient rect script set stop style svg switch symbol text textPath title tref tspan use view vkern".split(" "),i.knownElementNames=i.knownElementNames.concat(i.knownSVGElementNames),i.voidElementNames="area base br col command embed hr img input keygen link meta param source track wbr".split(" ");var r={yes:!0},n=function(t){for(var e={},i=0;i<t.length;i++)e[t[i]]=r;return e},o=n(i.voidElementNames),s=n(i.knownElementNames),u=n(i.knownSVGElementNames);i.isKnownElement=function(t){return s[t]===r},i.isKnownSVGElement=function(t){return u[t]===r},i.isVoidElement=function(t){return o[t]===r};for(var l=0;l<i.knownElementNames.length;l++)i.ensureTag(i.knownElementNames[l]);var f=i.CharRef=function(t){if(!(this instanceof f))return new f(t);if(!(t&&t.html&&t.str))throw new Error("HTML.CharRef must be constructed with ({html:..., str:...})");this.html=t.html,this.str=t.str};f.prototype.htmljsType=f.htmljsType=["CharRef"];var c=i.Comment=function(t){if(!(this instanceof c))return new c(t);if("string"!=typeof t)throw new Error("HTML.Comment must be constructed with a string");this.value=t,this.sanitizedValue=t.replace(/^-|--+|-$/g,"")};c.prototype.htmljsType=c.htmljsType=["Comment"];var h=i.Raw=function(t){if(!(this instanceof h))return new h(t);if("string"!=typeof t)throw new Error("HTML.Raw must be constructed with a string");this.value=t};h.prototype.htmljsType=h.htmljsType=["Raw"],i.isArray=function(t){return t instanceof Array},i.isConstructedObject=function(t){return t&&"object"==typeof t&&t.constructor!==Object&&!Object.prototype.hasOwnProperty.call(t,"constructor")},i.isNully=function(t){if(null==t)return!0;if(i.isArray(t)){for(var e=0;e<t.length;e++)if(!i.isNully(t[e]))return!1;return!0}return!1},i.isValidAttributeName=function(t){return/^[:_A-Za-z][:_A-Za-z0-9.\-]*/.test(t)},i.flattenAttributes=function(t){if(!t)return t;var e=i.isArray(t);if(e&&0===t.length)return null;for(var r={},n=0,a=e?t.length:1;a>n;n++){var o=e?t[n]:t;if("object"!=typeof o||i.isConstructedObject(o))throw new Error("Expected plain JS object as attrs, found: "+o);for(var s in o){if(!i.isValidAttributeName(s))throw new Error("Illegal HTML attribute name: "+s);var u=o[s];i.isNully(u)||(r[s]=u)}}return r},i.toHTML=function(t){return(new i.ToHTMLVisitor).visit(t)},i.TEXTMODE={STRING:1,RCDATA:2,ATTRIBUTE:3},i.toText=function(t,e){if(!e)throw new Error("textMode required for HTML.toText");if(e!==i.TEXTMODE.STRING&&e!==i.TEXTMODE.RCDATA&&e!==i.TEXTMODE.ATTRIBUTE)throw new Error("Unknown textMode: "+e);var r=new i.ToTextVisitor({textMode:e});return r.visit(t)}}.call(this),"undefined"==typeof Package&&(Package={}),Package.htmljs={HTML:i}}();
+
+!function(){var e=Package.meteor.Meteor,n=Package.tracker.Tracker,o=Package.tracker.Deps,r=Package.minimongo.LocalCollection,t=Package.minimongo.Minimongo,i=Package.underscore._,a=Package.random.Random,c,u,f,d;(function(){var e=function(){c._suppressWarnings?c._suppressWarnings--:("undefined"!=typeof console&&console.warn&&console.warn.apply(console,arguments),c._loggedWarnings++)},o=r._idStringify,t=r._idParse;c={_suppressWarnings:0,_loggedWarnings:0,observe:function(e,o){var r=null,t=null,a=[],c=n.autorun(function(){var c=e();n.nonreactive(function(){var e;if(t&&(a=i.map(r.fetch(),function(e){return{_id:e._id,item:e}}),t.stop(),t=null),c)if(c instanceof Array)e=f(a,c,o);else{if(!l(c))throw s();var n=d(a,c,o);e=n[0],t=n[1]}else e=u(a,o);v(a,e,o),r=c,a=e})});return{stop:function(){c.stop(),t&&t.stop()}}},fetch:function(e){if(e){if(e instanceof Array)return e;if(l(e))return e.fetch();throw s()}return[]}};var s=function(){return new Error("{{#each}} currently only accepts arrays, cursors or falsey values.")},l=function(e){return e&&i.isObject(e)&&i.isFunction(e.observe)&&i.isFunction(e.fetch)},v=function(e,n,r){var a=Package.minimongo.LocalCollection._diffQueryOrderedChanges,c=[],u=[],f={},d={},s={},l=e.length;i.each(n,function(e,n){u.push({_id:e._id}),d[o(e._id)]=n}),i.each(e,function(e,n){c.push({_id:e._id}),f[o(e._id)]=n,s[o(e._id)]=n}),a(c,u,{addedBefore:function(e,t,a){var c=a?s[o(a)]:l;i.each(s,function(e,n){e>=c&&s[n]++}),l++,s[o(e)]=c,r.addedAt(e,n[d[o(e)]].item,c,a)},movedBefore:function(e,t){var a=s[o(e)],c=t?s[o(t)]:l-1;i.each(s,function(e,n){e>=a&&c>=e?s[n]--:a>=e&&e>=c&&s[n]++}),s[o(e)]=c,r.movedTo(e,n[d[o(e)]].item,a,c,t)},removed:function(n){var t=s[o(n)];i.each(s,function(e,n){e>=t&&s[n]--}),delete s[o(n)],l--,r.removedAt(n,e[f[o(n)]].item,t)}}),i.each(d,function(o,a){var c=t(a);if(i.has(f,a)){var u=n[o].item,d=e[f[a]].item;("object"==typeof u||u!==d)&&r.changedAt(c,u,d,o)}})};u=function(e,n){return[]},f=function(n,r,t){var c={},u=i.map(r,function(n,t){var i;if("string"==typeof n)i="-"+n;else if("number"==typeof n||"boolean"==typeof n||void 0===n)i=n;else{if("object"!=typeof n)throw new Error("{{#each}} doesn't support arrays with elements of type "+typeof n);i=n&&n._id||t}var u=o(i);return c[u]?("object"==typeof n&&"_id"in n&&e("duplicate id "+i+" in",r),i=a.id()):c[u]=!0,{_id:i,item:n}});return u},d=function(e,n,o){var r=!0,t=[],i=n.observe({addedAt:function(e,n,i){if(r){if(null!==i)throw new Error("Expected initial data from observe in order");t.push({_id:e._id,item:e})}else o.addedAt(e._id,e,n,i)},changedAt:function(e,n,r){o.changedAt(e._id,e,n,r)},removedAt:function(e,n){o.removedAt(e._id,e,n)},movedTo:function(e,n,r,t){o.movedTo(e._id,e,n,r,t)}});return r=!1,[t,i]}}).call(this),"undefined"==typeof Package&&(Package={}),Package["observe-sequence"]={ObserveSequence:c}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.tracker.Tracker,n=Package.tracker.Deps,r;(function(){r=function(e,n){return this instanceof r?(this.curValue=e,this.equalsFunc=n,void(this.dep=new t.Dependency)):new r(e,n)},r._isEqual=function(e,t){var n=e,r=t;return n!==r?!1:!n||"number"==typeof n||"boolean"==typeof n||"string"==typeof n},r.prototype.get=function(){return t.active&&this.dep.depend(),this.curValue},r.prototype.set=function(e){var t=this.curValue;(this.equalsFunc||r._isEqual)(t,e)||(this.curValue=e,this.dep.changed())},r.prototype.toString=function(){return"ReactiveVar{"+this.get()+"}"},r.prototype._numListeners=function(){var e=0;for(var t in this.dep._dependentsById)e++;return e}}).call(this),"undefined"==typeof Package&&(Package={}),Package["reactive-var"]={ReactiveVar:r}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.jquery.$,n=Package.jquery.jQuery,r=Package.tracker.Tracker,i=Package.tracker.Deps,a=Package.underscore._,o=Package.htmljs.HTML,s=Package["observe-sequence"].ObserveSequence,u=Package["reactive-var"].ReactiveVar,l,c,d,f,p,h;(function(){l={},l._escape=function(){var e={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;","&":"&amp;"},t=function(t){return e[t]};return function(e){return e.replace(/[&<>"'`]/g,t)}}(),l._warn=function(e){e="Warning: "+e,"undefined"!=typeof Log&&Log&&Log.warn?Log.warn(e):"undefined"!=typeof console&&console.log&&console.log(e)}}).call(this),function(){var e={};l._DOMBackend=e;var t="undefined"!=typeof n?n:"undefined"!=typeof Package?Package.jquery&&Package.jquery.jQuery:null;if(!t)throw new Error("jQuery not found");e._$jq=t,e.parseHTML=function(e){return t.parseHTML(e)||[]},e.Events={delegateEvents:function(e,n,r,i){t(e).on(n,r,i)},undelegateEvents:function(e,n,r){t(e).off(n,"**",r)},bindEventCapturer:function(n,r,i,a){var o=t(n),s=function(e){e=t.event.fix(e),e.currentTarget=e.target;var r=t(e.currentTarget);r.is(o.find(i))&&a.call(n,e)};a._meteorui_wrapper=s,r=e.Events.parseEventType(r),n.addEventListener(r,s,!0)},unbindEventCapturer:function(t,n,r){n=e.Events.parseEventType(n),t.removeEventListener(n,r._meteorui_wrapper,!0)},parseEventType:function(e){var t=e.indexOf(".");return t>=0?e.slice(0,t):e}};var r=function(){},i=function(e){this.next=this,this.prev=this,this.func=e};i.prototype.linkBefore=function(e){this.prev=e.prev,this.next=e,e.prev.next=this,e.prev=this},i.prototype.unlink=function(){this.prev.next=this.next,this.next.prev=this.prev},i.prototype.go=function(){var e=this.func;e&&e()},i.prototype.stop=i.prototype.unlink,e.Teardown={_JQUERY_EVENT_NAME:"blaze_teardown_watcher",_CB_PROP:"$blaze_teardown_callbacks",onElementTeardown:function(n,a){var o=new i(a),s=e.Teardown._CB_PROP;return n[s]||(n[s]=new i,t(n).on(e.Teardown._JQUERY_EVENT_NAME,r)),o.linkBefore(n[s]),o},tearDownElement:function(e){for(var n=[],r=e.getElementsByTagName("*"),i=0;i<r.length;i++)n.push(r[i]);n.push(e),t.cleanData(n)}},t.event.special[e.Teardown._JQUERY_EVENT_NAME]={setup:function(){},teardown:function(){var t=this,n=t[e.Teardown._CB_PROP];if(n){for(var r=n.next;r!==n;)r.go(),r=r.next;n.go(),t[e.Teardown._CB_PROP]=null}}},e.findBySelector=function(e,n){return t(e,n)}}.call(this),function(){var e=Object.freeze?Object.freeze([]):[];l._DOMRange=function(n){if(!(this instanceof t))return new t(n);var r=n||e;if(!r||"number"!=typeof r.length)throw new Error("Expected array");for(var i=0;i<r.length;i++)this._memberIn(r[i]);this.members=r,this.emptyRangePlaceholder=null,this.attached=!1,this.parentElement=null,this.parentRange=null,this.attachedCallbacks=e};var t=l._DOMRange;t._USE_COMMENT_PLACEHOLDERS=function(){var e=!1,t=document.createTextNode("");try{t.someProp=!0}catch(n){e=!0}return e}(),t._insert=function(e,n,r,i){var a=e;a instanceof t?a.attach(n,r,i):i?t._moveNodeWithHooks(a,n,r):t._insertNodeWithHooks(a,n,r)},t._remove=function(e){var n=e;n instanceof t?n.detach():t._removeNodeWithHooks(n)},t._removeNodeWithHooks=function(e){e.parentNode&&(1===e.nodeType&&e.parentNode._uihooks&&e.parentNode._uihooks.removeElement?e.parentNode._uihooks.removeElement(e):e.parentNode.removeChild(e))},t._insertNodeWithHooks=function(e,t,n){n=n||null,1===e.nodeType&&t._uihooks&&t._uihooks.insertElement?t._uihooks.insertElement(e,n):t.insertBefore(e,n)},t._moveNodeWithHooks=function(e,t,n){e.parentNode===t&&(n=n||null,1===e.nodeType&&t._uihooks&&t._uihooks.moveElement?t._uihooks.moveElement(e,n):t.insertBefore(e,n))},t.forElement=function(e){if(1!==e.nodeType)throw new Error("Expected element, found: "+e);for(var t=null;e&&!t;)t=e.$blaze_range||null,t||(e=e.parentNode);return t},t.prototype.attach=function(e,n,r,i){if((r||i)&&(this.parentElement!==e||!this.attached))throw new Error("Can only move or replace an attached DOMRange, and only under the same parent element");var a=this.members;if(a.length){this.emptyRangePlaceholder=null;for(var o=0;o<a.length;o++)t._insert(a[o],e,n,r)}else{var s=t._USE_COMMENT_PLACEHOLDERS?document.createComment(""):document.createTextNode("");this.emptyRangePlaceholder=s,e.insertBefore(s,n||null)}if(this.attached=!0,this.parentElement=e,!r&&!i)for(var o=0;o<this.attachedCallbacks.length;o++){var u=this.attachedCallbacks[o];u.attached&&u.attached(this,e)}},t.prototype.setMembers=function(e){var t=e;if(!t||"number"!=typeof t.length)throw new Error("Expected array");for(var n=this.members,r=0;r<n.length;r++)this._memberOut(n[r]);for(var r=0;r<t.length;r++)this._memberIn(t[r]);if(this.attached){if(t.length||n.length){var i=this.lastNode().nextSibling,a=this.parentElement;this.detach(!0),this.members=t,this.attach(a,i,!1,!0)}}else this.members=t},t.prototype.firstNode=function(){if(!this.attached)throw new Error("Must be attached");if(!this.members.length)return this.emptyRangePlaceholder;var e=this.members[0];return e instanceof t?e.firstNode():e},t.prototype.lastNode=function(){if(!this.attached)throw new Error("Must be attached");if(!this.members.length)return this.emptyRangePlaceholder;var e=this.members[this.members.length-1];return e instanceof t?e.lastNode():e},t.prototype.detach=function(e){if(!this.attached)throw new Error("Must be attached");var n=this.parentElement,r=this.members;if(r.length)for(var i=0;i<r.length;i++)t._remove(r[i]);else{var a=this.emptyRangePlaceholder;this.parentElement.removeChild(a),this.emptyRangePlaceholder=null}if(!e){this.attached=!1,this.parentElement=null;for(var i=0;i<this.attachedCallbacks.length;i++){var o=this.attachedCallbacks[i];o.detached&&o.detached(this,n)}}},t.prototype.addMember=function(e,n,r){var i=this.members;if(!(n>=0&&n<=i.length))throw new Error("Bad index in range.addMember: "+n);if(r||this._memberIn(e),this.attached)if(0===i.length)this.setMembers([e]);else{var a;if(n===i.length)a=this.lastNode().nextSibling;else{var o=i[n];a=o instanceof t?o.firstNode():o}i.splice(n,0,e),t._insert(e,this.parentElement,a,r)}else i.splice(n,0,e)},t.prototype.removeMember=function(n,r){var i=this.members;if(!(n>=0&&n<i.length))throw new Error("Bad index in range.removeMember: "+n);if(r)i.splice(n,1);else{var a=i[n];this._memberOut(a),1===i.length?this.setMembers(e):(i.splice(n,1),this.attached&&t._remove(a))}},t.prototype.moveMember=function(e,t){var n=this.members[e];this.removeMember(e,!0),this.addMember(n,t,!0)},t.prototype.getMember=function(e){var t=this.members;if(!(e>=0&&e<t.length))throw new Error("Bad index in range.getMember: "+e);return this.members[e]},t.prototype._memberIn=function(e){e instanceof t?e.parentRange=this:1===e.nodeType&&(e.$blaze_range=this)},t._destroy=function(e,n){e instanceof t?e.view&&l._destroyView(e.view,n):n||1!==e.nodeType||e.$blaze_range&&(l._destroyNode(e),e.$blaze_range=null)},t.prototype._memberOut=t._destroy,t.prototype.destroyMembers=function(e){for(var t=this.members,n=0;n<t.length;n++)this._memberOut(t[n],e)},t.prototype.destroy=function(e){t._destroy(this,e)},t.prototype.containsElement=function(e){if(!this.attached)throw new Error("Must be attached");if(!l._elementContains(this.parentElement,e))return!1;for(;e.parentNode!==this.parentElement;)e=e.parentNode;for(var t=e.$blaze_range;t&&t!==this;)t=t.parentRange;return t===this},t.prototype.containsRange=function(e){if(!this.attached)throw new Error("Must be attached");if(!e.attached)return!1;if(e.parentElement!==this.parentElement)return this.containsElement(e.parentElement);if(e===this)return!1;for(;e&&e!==this;)e=e.parentRange;return e===this},t.prototype.onAttached=function(e){this.onAttachedDetached({attached:e})},t.prototype.onAttachedDetached=function(t){this.attachedCallbacks===e&&(this.attachedCallbacks=[]),this.attachedCallbacks.push(t)},t.prototype.$=function(e){var t=this,n=this.parentElement;if(!n)throw new Error("Can't select in removed DomRange");if(11===n.nodeType)throw new Error("Can't use $ on an offscreen range");var r=l._DOMBackend.findBySelector(e,n),i=function(e){return"number"==typeof e&&(e=this),t.containsElement(e)};if(r.filter)r=r.filter(i);else{for(var a=[],o=0;o<r.length;o++){var s=r[o];i(s)&&a.push(s)}r=a}return r},l._elementContains=function(e,t){return 1!==e.nodeType?!1:e===t?!1:e.compareDocumentPosition?16&e.compareDocumentPosition(t):(t=t.parentNode,t&&1===t.nodeType?e===t?!0:e.contains(t):!1)}}.call(this),function(){var e=l._EventSupport={},t=l._DOMBackend,n=e.eventsToDelegate={blur:1,change:1,click:1,focus:1,focusin:1,focusout:1,reset:1,submit:1},r=e.EVENT_MODE={TBD:0,BUBBLING:1,CAPTURING:2},i=1,o=function(e,o,s,u,l){this.elem=e,this.type=o,this.selector=s,this.handler=u,this.recipient=l,this.id=i++,this.mode=r.TBD,this.delegatedHandler=function(e){return function(t){return e.selector||t.currentTarget===t.target?e.handler.apply(e.recipient,arguments):void 0}}(this);var c=e.addEventListener&&!a.has(n,t.Events.parseEventType(o));c?this.capturingHandler=function(e){return function(n){if(e.mode===r.TBD){if(n.bubbles)return e.mode=r.BUBBLING,void t.Events.unbindEventCapturer(e.elem,e.type,e.capturingHandler);e.mode=r.CAPTURING,t.Events.undelegateEvents(e.elem,e.type,e.delegatedHandler)}e.delegatedHandler(n)}}(this):this.mode=r.BUBBLING};e.HandlerRec=o,o.prototype.bind=function(){this.mode!==r.BUBBLING&&t.Events.bindEventCapturer(this.elem,this.type,this.selector||"*",this.capturingHandler),this.mode!==r.CAPTURING&&t.Events.delegateEvents(this.elem,this.type,this.selector||"*",this.delegatedHandler)},o.prototype.unbind=function(){this.mode!==r.BUBBLING&&t.Events.unbindEventCapturer(this.elem,this.type,this.capturingHandler),this.mode!==r.CAPTURING&&t.Events.undelegateEvents(this.elem,this.type,this.delegatedHandler)},e.listen=function(e,t,n,r,i,a){try{e=e}finally{}var s=[];t.replace(/[^ /]+/g,function(e){s.push(e)});for(var u=[],l=0,c=s.length;c>l;l++){var d=s[l],f=e.$blaze_events;f||(f=e.$blaze_events={});var p=f[d];p||(p=f[d]={},p.handlers=[]);var h=p.handlers,m=new o(e,d,n,r,i);if(u.push(m),m.bind(),h.push(m),a)for(var w=a(i);w;w=a(w))for(var v=0,_=h.length;_>v;v++){var g=h[v];g.recipient===w&&(g.unbind(),g.bind(),h.splice(v,1),h.push(g),v--,_--)}}return{stop:function(){var t=e.$blaze_events;if(t){for(var n=0;n<u.length;n++){var r=u[n],i=t[r.type];if(i)for(var a=i.handlers,o=a.length-1;o>=0;o--)a[o]===r&&(r.unbind(),a.splice(o,1))}u.length=0}}}}}.call(this),function(){var n=!1;l._allowJavascriptUrls=function(){n=!0},l._javascriptUrlsAllowed=function(){return n},f=function(e,t){this.name=e,this.value=t},l._AttributeHandler=f,f.prototype.update=function(e,t,n){null===n?null!==t&&e.removeAttribute(this.name):e.setAttribute(this.name,n)},f.extend=function(e){var t=this,n=function r(){f.apply(this,arguments)};return n.prototype=new t,n.extend=t.extend,e&&a.extend(n.prototype,e),n};var r=f.extend({update:function(e,t,n){if(!this.getCurrentValue||!this.setValue||!this.parseValue)throw new Error("Missing methods in subclass of 'DiffingAttributeHandler'");var r=t?this.parseValue(t):{},i=n?this.parseValue(n):{},o=this.getCurrentValue(e),s=o?this.parseValue(o):{};a.each(a.keys(r),function(e){e in i||delete s[e]}),a.each(a.keys(i),function(e){s[e]=i[e]}),this.setValue(e,a.values(s).join(" "))}}),i=r.extend({getCurrentValue:function(e){return e.className},setValue:function(e,t){e.className=t},parseValue:function(e){var t={};return a.each(e.split(" "),function(e){e&&(t[e]=e)}),t}}),o=i.extend({getCurrentValue:function(e){return e.className.baseVal},setValue:function(e,t){e.setAttribute("class",t)}}),s=r.extend({getCurrentValue:function(e){return e.getAttribute("style")},setValue:function(e,t){""===t?e.removeAttribute("style"):e.setAttribute("style",t)},parseValue:function(e){for(var n={},r=/(\*?[-#\/\*\\\w]+(?:\[[0-9a-z_-]+\])?)\s*:\s*(?:\'(?:\\\'|.)*?\'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+[;\s]*/g,i=r.exec(e);i;)n[" "+i[1]]=i[0].trim?i[0].trim():t.trim(i[0]),i=r.exec(e);return n}}),u=f.extend({update:function(e,t,n){var r=this.name;null==n?null!=t&&(e[r]=!1):e[r]=!0}}),c=f.extend({update:function(e,t,n){n!==e.value&&(e.value=n)}}),d=f.extend({update:function(e,t,n){var r="http://www.w3.org/1999/xlink";null===n?null!==t&&e.removeAttributeNS(r,this.name):e.setAttributeNS(r,this.name,this.value)}}),m=function(e){return"ownerSVGElement"in e},w=function(e,t){var n={FORM:["action"],BODY:["background"],BLOCKQUOTE:["cite"],Q:["cite"],DEL:["cite"],INS:["cite"],OBJECT:["classid","codebase","data","usemap"],APPLET:["codebase"],A:["href"],AREA:["href"],LINK:["href"],BASE:["href"],IMG:["longdesc","src","usemap"],FRAME:["longdesc","src"],IFRAME:["longdesc","src"],HEAD:["profile"],SCRIPT:["src"],INPUT:["src","usemap","formaction"],BUTTON:["formaction"],BASE:["href"],MENUITEM:["icon"],HTML:["manifest"],VIDEO:["poster"]};if("itemid"===t)return!0;var r=n[e]||[];return a.contains(r,t)};if(e.isClient)var v=document.createElement("A");var _=function(t){if(e.isClient)return v.href=t,(v.protocol||"").toLowerCase();throw new Error("getUrlProtocol not implemented on the server")},g=f.prototype.update,E=f.extend({update:function(e,t,n){var r=this,i=arguments;if(l._javascriptUrlsAllowed())g.apply(r,i);else{var a="javascript:"===_(n);a?(l._warn("URLs that use the 'javascript:' protocol are not allowed in URL attribute values. Call Blaze._allowJavascriptUrls() to enable them."),g.apply(r,[e,t,null])):g.apply(r,i)}}});p=function(e,t,n){return"class"===t?m(e)?new o(t,n):new i(t,n):"style"===t?new s(t,n):"OPTION"===e.tagName&&"selected"===t||"INPUT"===e.tagName&&"checked"===t?new u(t,n):"TEXTAREA"!==e.tagName&&"INPUT"!==e.tagName||"value"!==t?"xlink:"===t.substring(0,6)?new d(t.substring(6),n):w(e.tagName,t)?new E(t,n):new f(t,n):new c(t,n)},h=function(e){this.elem=e,this.handlers={}},h.prototype.update=function(e){var t=this.elem,n=this.handlers;for(var r in n)if(!a.has(e,r)){var i=n[r],o=i.value;i.value=null,i.update(t,o,null),delete n[r]}for(var r in e){var i=null,o,s=e[r];a.has(n,r)?(i=n[r],o=i.value):null!==s&&(i=p(t,r,s),n[r]=i,o=null),o!==s&&(i.value=s,i.update(t,o,s),null===s&&delete n[r])}}}.call(this),function(){l._DOMMaterializer=o.Visitor.extend(),l._DOMMaterializer.def({visitNull:function(e,t){return t},visitPrimitive:function(e,t){var n=String(e);return t.push(document.createTextNode(n)),t},visitCharRef:function(e,t){return this.visitPrimitive(e.str,t)},visitArray:function(e,t){for(var n=0;n<e.length;n++)this.visit(e[n],t);return t},visitComment:function(e,t){return t.push(document.createComment(e.sanitizedValue)),t},visitRaw:function(e,t){for(var n=l._DOMBackend.parseHTML(e.value),r=0;r<n.length;r++)t.push(n[r]);return t},visitTag:function(t,n){var i=this,s=t.tagName,u;u=(o.isKnownSVGElement(s)||e(t))&&document.createElementNS?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s);var c=t.attrs,d=t.children;if("textarea"===s&&t.children.length&&!(c&&"value"in c)){if("function"==typeof c||o.isArray(c))throw new Error("Can't have reactive children of TEXTAREA node; use the 'value' attribute instead.");c=a.extend({},c||null),c.value=l._expand(d,i.parentView),d=[]}if(c){var f=new h(u),p=function(){var e=i.parentView,t=l._expandAttributes(c,e),n=o.flattenAttributes(t),r={};for(var a in n)r[a]=l._toText(n[a],e,o.TEXTMODE.STRING);f.update(r)},m;m=i.parentView?i.parentView.autorun(p):r.nonreactive(function(){return r.autorun(function(){r._withCurrentView(i.parentView,p)})}),l._DOMBackend.Teardown.onElementTeardown(u,function g(){m.stop()})}for(var w=i.visit(d,[]),v=0;v<w.length;v++){var _=w[v];_ instanceof l._DOMRange?_.attach(u):u.appendChild(_)}return n.push(u),n},visitObject:function(e,t){return e instanceof l.Template&&(e=e.constructView()),e instanceof l.View?(t.push(l._materializeView(e,this.parentView)),t):o.Visitor.prototype.visitObject.call(this,e)}});var e=function(e){return"a"===e.tagName&&e.attrs&&void 0!==e.attrs["xlink:href"]}}.call(this),function(){var t;l._throwNextException=!1,l._reportException=function(n,r){if(l._throwNextException)throw l._throwNextException=!1,n;t||(t=function(){return"undefined"!=typeof e?e._debug:"undefined"!=typeof console&&console.log?console.log:function(){}}),t()(r||"Exception caught in template:",n.stack||n.message)},l._wrapCatchingExceptions=function(e,t){return"function"!=typeof e?e:function(){try{return e.apply(this,arguments)}catch(n){l._reportException(n,"Exception in "+t+":")}}}}.call(this),function(){l.View=function(e,t){return this instanceof l.View?("function"==typeof e&&(t=e,e=""),this.name=e,this._render=t,this._callbacks={created:null,rendered:null,destroyed:null},this.isCreated=!1,this._isCreatedForExpansion=!1,this.isRendered=!1,this._isAttached=!1,this.isDestroyed=!1,this._isInRender=!1,this.parentView=null,this._domrange=null,this._hasGeneratedParent=!1,void(this.renderCount=0)):new l.View(e,t)},l.View.prototype._render=function(){return null},l.View.prototype.onViewCreated=function(e){this._callbacks.created=this._callbacks.created||[],this._callbacks.created.push(e)},l.View.prototype._onViewRendered=function(e){this._callbacks.rendered=this._callbacks.rendered||[],this._callbacks.rendered.push(e)},l.View.prototype.onViewReady=function(e){var t=this,n=function(){r.afterFlush(function(){t.isDestroyed||l._withCurrentView(t,function(){e.call(t)})})};t._onViewRendered(function i(){t.isDestroyed||(t._domrange.attached?n():t._domrange.onAttached(n))})},l.View.prototype.onViewDestroyed=function(e){this._callbacks.destroyed=this._callbacks.destroyed||[],this._callbacks.destroyed.push(e)},l.View.prototype.autorun=function(e,t){var n=this;if(!n.isCreated)throw new Error("View#autorun must be called from the created callback at the earliest");if(this._isInRender)throw new Error("Can't call View#autorun from inside render(); try calling it from the created or rendered callback");if(r.active)throw new Error("Can't call View#autorun from a Tracker Computation; try calling it from the created or rendered callback");var i=r.autorun(function a(r){return l._withCurrentView(t||n,function(){return e.call(n,r)})});return n.onViewDestroyed(function(){i.stop()}),i},l.View.prototype.firstNode=function(){if(!this._isAttached)throw new Error("View must be attached before accessing its DOM");return this._domrange.firstNode()},l.View.prototype.lastNode=function(){if(!this._isAttached)throw new Error("View must be attached before accessing its DOM");return this._domrange.lastNode()},l._fireCallbacks=function(e,t){l._withCurrentView(e,function(){r.nonreactive(function n(){for(var n=e._callbacks[t],r=0,i=n&&n.length;i>r;r++)n[r].call(e)})})},l._createView=function(e,t,n){if(e.isCreated)throw new Error("Can't render the same View twice");e.parentView=t||null,e.isCreated=!0,n&&(e._isCreatedForExpansion=!0),l._fireCallbacks(e,"created")},l._materializeView=function(e,t){l._createView(e,t);var n,i;return r.nonreactive(function(){e.autorun(function a(t){e.renderCount++,e._isInRender=!0;var a=e._render();e._isInRender=!1,r.nonreactive(function o(){var r=new l._DOMMaterializer({parentView:e}),o=r.visit(a,[]);(t.firstRun||!l._isContentEqual(i,a))&&(t.firstRun?(n=new l._DOMRange(o),e._domrange=n,n.view=e,e.isRendered=!0):n.setMembers(o),l._fireCallbacks(e,"rendered"))}),i=a,r.onInvalidate(function(){n.destroyMembers()})});var t=null;n.onAttached(function o(n,r){e._isAttached=!0,t=l._DOMBackend.Teardown.onElementTeardown(r,function i(){l._destroyView(e,!0)})}),e.onViewDestroyed(function(){t&&t.stop(),t=null})}),n},l._expandView=function(e,t){l._createView(e,t,!0),e._isInRender=!0;var n=l._withCurrentView(e,function(){return e._render()});e._isInRender=!1;var i=l._expand(n,e);return r.active?r.onInvalidate(function(){l._destroyView(e)}):l._destroyView(e),i},l._HTMLJSExpander=o.TransformingVisitor.extend(),l._HTMLJSExpander.def({visitObject:function(e){return e instanceof l.Template&&(e=e.constructView()),e instanceof l.View?l._expandView(e,this.parentView):o.TransformingVisitor.prototype.visitObject.call(this,e)},visitAttributes:function(e){return"function"==typeof e&&(e=l._withCurrentView(this.parentView,e)),o.TransformingVisitor.prototype.visitAttributes.call(this,e)},visitAttribute:function(e,t,n){return"function"==typeof t&&(t=l._withCurrentView(this.parentView,t)),o.TransformingVisitor.prototype.visitAttribute.call(this,e,t,n)}});var e=function(){var e=l.currentView;return e&&e._isInRender?e:null};l._expand=function(t,n){return n=n||e(),new l._HTMLJSExpander({parentView:n}).visit(t)},l._expandAttributes=function(t,n){return n=n||e(),new l._HTMLJSExpander({parentView:n}).visitAttributes(t)},l._destroyView=function(e,t){e.isDestroyed||(e.isDestroyed=!0,l._fireCallbacks(e,"destroyed"),e._domrange&&e._domrange.destroyMembers(t))},l._destroyNode=function(e){1===e.nodeType&&l._DOMBackend.Teardown.tearDownElement(e)},l._isContentEqual=function(e,t){return e instanceof o.Raw?t instanceof o.Raw&&e.value===t.value:null==e?null==t:e===t&&("number"==typeof e||"boolean"==typeof e||"string"==typeof e)},l.currentView=null,l._withCurrentView=function(e,t){var n=l.currentView;try{return l.currentView=e,t()}finally{l.currentView=n}};var t=function(e){if(null===e)throw new Error("Can't render null");if("undefined"==typeof e)throw new Error("Can't render undefined");if(!(e instanceof l.View||e instanceof l.Template||"function"==typeof e))try{(new o.Visitor).visit(e)}catch(t){throw new Error("Expected Template or View")}},n=function(e){if(t(e),e instanceof l.Template)return e.constructView();if(e instanceof l.View)return e;var n=e;return"function"!=typeof n&&(n=function(){return e}),l.View("render",n)},i=function(e){return t(e),"function"!=typeof e?function(){return e}:e};l.render=function(t,r,i,a){if(r||l._warn("Blaze.render without a parent element is deprecated. You must specify where to insert the rendered content."),i instanceof l.View&&(a=i,i=null),r&&"number"!=typeof r.nodeType)throw new Error("'parentElement' must be a DOM node");if(i&&"number"!=typeof i.nodeType)throw new Error("'nextNode' must be a DOM node");a=a||e();var o=n(t);return l._materializeView(o,a),r&&o._domrange.attach(r,i),o},l.insert=function(e,t,n){if(l._warn("Blaze.insert has been deprecated. Specify where to insert the rendered content in the call to Blaze.render."),!(e&&e._domrange instanceof l._DOMRange))throw new Error("Expected template rendered with Blaze.render");e._domrange.attach(t,n)},l.renderWithData=function(e,t,n,r,a){return l.render(l._TemplateWith(t,i(e)),n,r,a)},l.remove=function(e){if(!(e&&e._domrange instanceof l._DOMRange))throw new Error("Expected template rendered with Blaze.render");for(;e;){if(!e.isDestroyed){var t=e._domrange;t.attached&&!t.parentRange&&t.detach(),t.destroy()}e=e._hasGeneratedParent&&e.parentView}},l.toHTML=function(t,r){return r=r||e(),o.toHTML(l._expandView(n(t),r))},l.toHTMLWithData=function(t,n,r){return r=r||e(),o.toHTML(l._expandView(l._TemplateWith(n,i(t)),r))},l._toText=function(t,n,r){if("function"==typeof t)throw new Error("Blaze._toText doesn't take a function, just HTMLjs");if(null==n||n instanceof l.View||(r=n,n=null),n=n||e(),!r)throw new Error("textMode required");if(r!==o.TEXTMODE.STRING&&r!==o.TEXTMODE.RCDATA&&r!==o.TEXTMODE.ATTRIBUTE)throw new Error("Unknown textMode: "+r);return o.toText(l._expand(t,n),r)},l.getData=function(e){var t;if(e)if(e instanceof l.View){var n=e;t="with"===n.name?n:l.getView(n,"with")}else{if("number"!=typeof e.nodeType)throw new Error("Expected DOM element or View");if(1!==e.nodeType)throw new Error("Expected DOM element");t=l.getView(e,"with")}else t=l.getView("with");return t?t.dataVar.get():null},l.getElementData=function(e){if(l._warn("Blaze.getElementData has been deprecated. Use Blaze.getData(element) instead."),1!==e.nodeType)throw new Error("Expected DOM element");return l.getData(e)},l.getView=function(e,t){var n=t;if("string"==typeof e&&(n=e,e=null),e){if(e instanceof l.View)return l._getParentView(e,n);if("number"==typeof e.nodeType)return l._getElementView(e,n);throw new Error("Expected DOM element or View")}return l._getCurrentView(n)},l._getCurrentView=function(e){var t=l.currentView;if(!t)throw new Error("There is no current view");if(e){for(;t&&t.name!==e;)t=t.parentView;return t||null}return t},l._getParentView=function(e,t){var n=e.parentView;if(t)for(;n&&n.name!==t;)n=n.parentView;return n||null},l._getElementView=function(e,t){for(var n=l._DOMRange.forElement(e),r=null;n&&!r;)r=n.view||null,r||(n=n.parentRange?n.parentRange:l._DOMRange.forElement(n.parentElement));if(t){for(;r&&r.name!==t;)r=r.parentView;return r||null}return r},l._addEventMap=function(e,t,n){n=n||null;var r=[];if(!e._domrange)throw new Error("View must have a DOMRange");e._domrange.onAttached(function i(o,s){a.each(t,function(t,i){var u=i.split(/,\s+/);a.each(u,function(i){var a=i.split(/\s+/);if(0!==a.length){var u=a.shift(),c=a.join(" ");r.push(l._EventSupport.listen(s,u,c,function(r){if(!o.containsElement(r.currentTarget))return null;var i=n||this,a=arguments;return l._withCurrentView(e,function(){return t.apply(i,a)})},o,function(e){return e.parentRange}))}})})}),e.onViewDestroyed(function(){a.each(r,function(e){e.stop()}),r.length=0})}}.call(this),function(){l._calculateCondition=function(e){return e instanceof Array&&0===e.length&&(e=!1),!!e},l.With=function(e,t){var n=l.View("with",t);return n.dataVar=new u,n.onViewCreated(function(){"function"==typeof e?n.autorun(function(){n.dataVar.set(e())},n.parentView):n.dataVar.set(e)}),n},l.If=function(e,t,n,r){var i=new u,a=l.View(r?"unless":"if",function(){return i.get()?t():n?n():null});return a.__conditionVar=i,a.onViewCreated(function(){this.autorun(function(){var t=l._calculateCondition(e());i.set(r?!t:t)},this.parentView)}),a},l.Unless=function(e,t,n){return l.If(e,t,n,!0)},l.Each=function(e,t,n){var i=l.View("each",function(){var e=this.initialSubviews;return this.initialSubviews=null,this._isCreatedForExpansion&&(this.expandedValueDep=new r.Dependency,this.expandedValueDep.depend()),e});return i.initialSubviews=[],i.numItems=0,i.inElseMode=!1,i.stopHandle=null,i.contentFunc=t,i.elseFunc=n,i.argVar=new u,i.onViewCreated(function(){i.autorun(function(){i.argVar.set(e())},i.parentView),i.stopHandle=s.observe(function(){return i.argVar.get()},{addedAt:function(e,t,n){r.nonreactive(function(){var e=l.With(t,i.contentFunc);if(i.numItems++,i.expandedValueDep)i.expandedValueDep.changed();else if(i._domrange){i.inElseMode&&(i._domrange.removeMember(0),i.inElseMode=!1);var r=l._materializeView(e,i);i._domrange.addMember(r,n)}else i.initialSubviews.splice(n,0,e)})},removedAt:function(e,t,n){r.nonreactive(function(){i.numItems--,i.expandedValueDep?i.expandedValueDep.changed():i._domrange?(i._domrange.removeMember(n),i.elseFunc&&0===i.numItems&&(i.inElseMode=!0,i._domrange.addMember(l._materializeView(l.View("each_else",i.elseFunc),i),0))):i.initialSubviews.splice(n,1)})},changedAt:function(e,t,n,a){r.nonreactive(function(){var e;i.expandedValueDep?i.expandedValueDep.changed():e=i._domrange?i._domrange.getMember(a).view:i.initialSubviews[a],e.dataVar.set(t)})},movedTo:function(e,t,n,a){r.nonreactive(function(){if(i.expandedValueDep)i.expandedValueDep.changed();else if(i._domrange)i._domrange.moveMember(n,a);else{var e=i.initialSubviews,t=e[n];e.splice(n,1),e.splice(a,0,t)}})}}),i.elseFunc&&0===i.numItems&&(i.inElseMode=!0,i.initialSubviews[0]=l.View("each_else",i.elseFunc))}),i.onViewDestroyed(function(){i.stopHandle&&i.stopHandle.stop()}),i},l._TemplateWith=function(e,t){var n,r=e;"function"!=typeof e&&(r=function(){return e});var i=function(){var e=null;return n.parentView&&"InOuterTemplateScope"===n.parentView.name&&(e=n.parentView.originalParentView),e?l._withCurrentView(e,r):r()},a=function(){var e=t.call(this);return e instanceof l.Template&&(e=e.constructView()),e instanceof l.View&&(e._hasGeneratedParent=!0),e};return n=l.With(i,a),n.__isTemplateWith=!0,n},l._InOuterTemplateScope=function(e,t){var n=l.View("InOuterTemplateScope",t),r=e.parentView;return r.__isTemplateWith&&(r=r.parentView),n.onViewCreated(function(){this.originalParentView=this.parentView,this.parentView=r}),n},l.InOuterTemplateScope=l._InOuterTemplateScope}.call(this),function(){l._globalHelpers={},l.registerHelper=function(e,t){l._globalHelpers[e]=t};var e=function(e,t){return"function"!=typeof e?e:function(){return e.apply(t,arguments)}},t=function(e){return"function"==typeof e?function(){var t=l.getData();return null==t&&(t={}),e.apply(t,arguments)}:e};l._OLDSTYLE_HELPER={};var n=l._getTemplateHelper=function(e,t){var n=!1;if(e.__helpers.has(t)){var r=e.__helpers.get(t);if(r!==l._OLDSTYLE_HELPER)return r;n=!0}return t in e?(n||(e.__helpers.set(t,l._OLDSTYLE_HELPER),e._NOWARN_OLDSTYLE_HELPERS||l._warn("Assigning helper with `"+e.viewName+"."+t+" = ...` is deprecated. Use `"+e.viewName+".helpers(...)` instead.")),e[t]):null},r=function(e){return l._wrapCatchingExceptions(e,"template helper")};l.View.prototype.lookup=function(e,i){var a=this.template,o=i&&i.template,s;if(/^\./.test(e)){if(!/^(\.)+$/.test(e))throw new Error("id starting with dot must be a series of dots");return l._parentData(e.length-1,!0)}return a&&null!=(s=n(a,e))?r(t(s)):o&&e in l.Template&&l.Template[e]instanceof l.Template?l.Template[e]:null!=l._globalHelpers[e]?r(t(l._globalHelpers[e])):function(){var t=arguments.length>0,n=l.getData();if(o&&(!n||!n[e]))throw new Error("No such template: "+e);if(t&&(!n||!n[e]))throw new Error("No such function: "+e);if(!n)return null;var r=n[e];if("function"!=typeof r){if(t)throw new Error("Can't call non-function: "+r);return r}return r.apply(n,arguments)};return null},l._parentData=function(e,t){null==e&&(e=1);for(var n=l.getView("with"),r=0;e>r&&n;r++)n=l.getView(n,"with");return n?t?function(){return n.dataVar.get()}:n.dataVar.get():null},l.View.prototype.lookupTemplate=function(e){return this.lookup(e,{template:!0})}}.call(this),function(){l.Template=function(e,n){if(!(this instanceof l.Template))return new l.Template(e,n);if("function"==typeof e&&(n=e,e=""),"string"!=typeof e)throw new Error("viewName must be a String (or omitted)");if("function"!=typeof n)throw new Error("renderFunction must be a function");this.viewName=e,this.renderFunction=n,this.__helpers=new t,this.__eventMaps=[]};var e=l.Template,t=function(){};t.prototype.get=function(e){return this[" "+e]},t.prototype.set=function(e,t){this[" "+e]=t},t.prototype.has=function(e){return" "+e in this},l.isTemplate=function(e){return e instanceof l.Template},e.prototype.constructView=function(t,n){var r=this,i=l.View(r.viewName,r.renderFunction);return i.template=r,i.templateContentBlock=t?new e("(contentBlock)",t):null,i.templateElseBlock=n?new e("(elseBlock)",n):null,(r.__eventMaps||"object"==typeof r.events)&&i._onViewRendered(function(){1===i.renderCount&&(r.__eventMaps.length||"object"!=typeof r.events||e.prototype.events.call(r,r.events),a.each(r.__eventMaps,function(e){l._addEventMap(i,e,i)}))}),i._templateInstance=new l.TemplateInstance(i),i.templateInstance=function(){var e=i._templateInstance;return e.data=l.getData(i),i._domrange&&!i.isDestroyed?(e.firstNode=i._domrange.firstNode(),e.lastNode=i._domrange.lastNode()):(e.firstNode=null,e.lastNode=null),e},r.created&&i.onViewCreated(function(){r.created.call(i.templateInstance())}),r.rendered&&i.onViewReady(function(){r.rendered.call(i.templateInstance())}),r.destroyed&&i.onViewDestroyed(function(){r.destroyed.call(i.templateInstance())}),i},l.TemplateInstance=function(e){if(!(this instanceof l.TemplateInstance))return new l.TemplateInstance(e);if(!(e instanceof l.View))throw new Error("View required");e._templateInstance=this,this.view=e,this.data=null,this.firstNode=null,this.lastNode=null},l.TemplateInstance.prototype.$=function(e){var t=this.view;if(!t._domrange)throw new Error("Can't use $ on template instance with no DOM");return t._domrange.$(e)},l.TemplateInstance.prototype.findAll=function(e){return Array.prototype.slice.call(this.$(e))},l.TemplateInstance.prototype.find=function(e){var t=this.$(e);return t[0]||null},l.TemplateInstance.prototype.autorun=function(e){return this.view.autorun(e)
+},e.prototype.helpers=function(e){for(var t in e)this.__helpers.set(t,e[t])},e.prototype.events=function(e){var t=this,n={};for(var r in e)n[r]=function(e,t){return function(e){var n=this,r=l.getData(e.currentTarget);null==r&&(r={});var i=Array.prototype.slice.call(arguments),a=n.templateInstance();return i.splice(1,0,a),t.apply(r,i)}}(r,e[r]);t.__eventMaps.push(n)},e.instance=function(){for(var e=l.currentView;e&&!e.template;)e=e.parentView;return e?e.templateInstance():null},e.currentData=l.getData,e.parentData=l._parentData,e.registerHelper=l.registerHelper}.call(this),function(){c=l,l.ReactiveVar=u,c._templateInstance=l.Template.instance,d={},d.registerHelper=l.registerHelper,d._escape=l._escape,d.SafeString=function(e){this.string=e},d.SafeString.prototype.toString=function(){return this.string.toString()}}.call(this),"undefined"==typeof Package&&(Package={}),Package.blaze={Blaze:l,UI:c,Handlebars:d}}();
+
+!function(){var e=Package.meteor.Meteor,n=Package.underscore._,t=Package.blaze.Blaze,o=Package.blaze.UI,a=Package.blaze.Handlebars,d=Package.htmljs.HTML,c;(function(){c=t.Template;var e="__proto__ name".split(" ");c.__checkName=function(t){if(t in c||n.contains(e,t)){if(c[t]instanceof c&&"body"!==t)throw new Error("There are multiple templates named '"+t+"'. Each template needs a unique name.");throw new Error("This template name is reserved: "+t)}},c.__define__=function(e,n){c.__checkName(e),c[e]=new c("Template."+e,n),c[e]._NOWARN_OLDSTYLE_HELPERS=!0},c.body=new c("body",function(){for(var e=c.body.contentViews,n=0;n<e.length;n++)e[n].template=c.body;return e}),c.body.contentViews=[],c.body.view=null,c.body.addContent=function(e){var n="body_content_"+c.body.contentViews.length;c.body.contentViews.push(t.View(n,e))},c.body.renderToDocument=function(){if(!c.body.view){var e=t.render(c.body,document.body);c.body.view=e}},o.body=c.body,c.__body__=c.body,c.__body__.__contentParts=c.body.contentViews,c.__body__.__instantiate=c.body.renderToDocument}).call(this),"undefined"==typeof Package&&(Package={}),Package.templating={Template:c}}();
+
+!function(){var e=Package.underscore._,n=Package.meteor.Meteor,r=Package.tracker.Tracker,t=Package.tracker.Deps,a=Package.session.Session,u=Package.jquery.$,o=Package.jquery.jQuery,s=Package.templating.Template,l=Package.blaze.Blaze,i=Package.blaze.UI,c=Package.blaze.Handlebars,f=Package.htmljs.HTML,p,m,g,d;(function(){g={fallback_language:"en",langauges_tags_regex:"([a-z]{2})(-[A-Z]{2})?",project_translations_domain:"project",browser_path:"/tap-i18n",debug:!1}}).call(this),function(){p={},function(){function e(e,n){if(!n||"function"==typeof n)return e;for(var r in n)e[r]=n[r];return e}function n(e,n,r){var t,a=0,u=e.length,o=void 0===u||"[object Array]"!==Object.prototype.toString.apply(e)||"function"==typeof e;if(r)if(o){for(t in e)if(n.apply(e[t],r)===!1)break}else for(;u>a&&n.apply(e[a++],r)!==!1;);else if(o){for(t in e)if(n.call(e[t],t,e[t])===!1)break}else for(;u>a&&n.call(e[a],a,e[a++])!==!1;);return e}function r(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return E[e]}):e}function t(e){var n=function(e){if(window.XMLHttpRequest)return e(null,new XMLHttpRequest);if(window.ActiveXObject)try{return e(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(n){return e(null,new ActiveXObject("Microsoft.XMLHTTP"))}return e(new Error)},r=function(e){if("string"==typeof e)return e;var n=[];for(var r in e)e.hasOwnProperty(r)&&n.push(encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return n.join("&")},t=function(e){e=e.replace(/\r\n/g,"\n");for(var n="",r=0;r<e.length;r++){var t=e.charCodeAt(r);128>t?n+=String.fromCharCode(t):t>127&&2048>t?(n+=String.fromCharCode(t>>6|192),n+=String.fromCharCode(63&t|128)):(n+=String.fromCharCode(t>>12|224),n+=String.fromCharCode(t>>6&63|128),n+=String.fromCharCode(63&t|128))}return n},a=function(e){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=t(e);var r="",a,u,o,s,l,i,c,f=0;do a=e.charCodeAt(f++),u=e.charCodeAt(f++),o=e.charCodeAt(f++),s=a>>2,l=(3&a)<<4|u>>4,i=(15&u)<<2|o>>6,c=63&o,isNaN(u)?i=c=64:isNaN(o)&&(c=64),r+=n.charAt(s)+n.charAt(l)+n.charAt(i)+n.charAt(c),a=u=o="",s=l=i=c="";while(f<e.length);return r},u=function(){for(var e=arguments[0],n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])}return e},o=function(e,t,a,s){"function"==typeof a&&(s=a,a={}),a.cache=a.cache||!1,a.data=a.data||{},a.headers=a.headers||{},a.jsonp=a.jsonp||!1,a.async=void 0===a.async?!0:a.async;var l=u({accept:"*/*","content-type":"application/x-www-form-urlencoded;charset=UTF-8"},o.headers,a.headers),i;if(i="application/json"===l["content-type"]?JSON.stringify(a.data):r(a.data),"GET"===e){var c=[];if(i&&(c.push(i),i=null),a.cache||c.push("_="+(new Date).getTime()),a.jsonp&&(c.push("callback="+a.jsonp),c.push("jsonp="+a.jsonp)),c=c.join("&"),c.length>1&&(t+=t.indexOf("?")>-1?"&"+c:"?"+c),a.jsonp){var f=document.getElementsByTagName("head")[0],p=document.createElement("script");return p.type="text/javascript",p.src=t,void f.appendChild(p)}}n(function(n,r){if(n)return s(n);r.open(e,t,a.async);for(var u in l)l.hasOwnProperty(u)&&r.setRequestHeader(u,l[u]);r.onreadystatechange=function(){if(4===r.readyState){var e=r.responseText||"";if(!s)return;s(r.status,{text:function(){return e},json:function(){return JSON.parse(e)}})}},r.send(i)})},s={authBasic:function(e,n){o.headers.Authorization="Basic "+a(e+":"+n)},connect:function(e,n,r){return o("CONNECT",e,n,r)},del:function(e,n,r){return o("DELETE",e,n,r)},get:function(e,n,r){return o("GET",e,n,r)},head:function(e,n,r){return o("HEAD",e,n,r)},headers:function(e){o.headers=e||{}},isAllowed:function(e,n,r){this.options(e,function(e,t){r(-1!==t.text().indexOf(n))})},options:function(e,n,r){return o("OPTIONS",e,n,r)},patch:function(e,n,r){return o("PATCH",e,n,r)},post:function(e,n,r){return o("POST",e,n,r)},put:function(e,n,r){return o("PUT",e,n,r)},trace:function(e,n,r){return o("TRACE",e,n,r)}},l=e.type?e.type.toLowerCase():"get";s[l](e.url,e,function(n,r){200===n?e.success(r.json(),n,null):e.error(r.text(),n,null)})}function a(e,n){"function"==typeof e&&(n=e,e={}),e=e||{},D.extend(M,e),delete M.fixLng,"string"==typeof M.ns&&(M.ns={namespaces:[M.ns],defaultNs:M.ns}),"string"==typeof M.fallbackNS&&(M.fallbackNS=[M.fallbackNS]),("string"==typeof M.fallbackLng||"boolean"==typeof M.fallbackLng)&&(M.fallbackLng=[M.fallbackLng]),M.interpolationPrefixEscaped=D.regexEscape(M.interpolationPrefix),M.interpolationSuffixEscaped=D.regexEscape(M.interpolationSuffix),M.lng||(M.lng=D.detectLanguage()),M.lng?M.useCookie&&D.cookie.create(M.cookieName,M.lng,M.cookieExpirationTime,M.cookieDomain):(M.lng=M.fallbackLng[0],M.useCookie&&D.cookie.remove(M.cookieName)),A=D.toLanguages(M.lng),O=A[0],D.log("currentLng set to: "+O);var r=x;e.fixLng&&(r=function(e,n){return n=n||{},n.lng=n.lng||r.lng,x(e,n)},r.lng=O),z.setCurrentLng(O),S&&M.setJqueryExt&&g();var t;if(S&&S.Deferred&&(t=S.Deferred()),!M.resStore){var a=D.toLanguages(M.lng);"string"==typeof M.preload&&(M.preload=[M.preload]);for(var u=0,o=M.preload.length;o>u;u++)for(var s=D.toLanguages(M.preload[u]),l=0,i=s.length;i>l;l++)a.indexOf(s[l])<0&&a.push(s[l]);return p.sync.load(a,M,function(e,a){T=a,C=!0,n&&n(r),t&&t.resolve(r)}),t?t.promise():void 0}return T=M.resStore,C=!0,n&&n(r),t&&t.resolve(r),t?t.promise():void 0}function u(e,n){"string"==typeof e&&(e=[e]);for(var r=0,t=e.length;t>r;r++)M.preload.indexOf(e[r])<0&&M.preload.push(e[r]);return a(n)}function o(e,n,r){"string"!=typeof n?(r=n,n=M.ns.defaultNs):M.ns.namespaces.indexOf(n)<0&&M.ns.namespaces.push(n),T[e]=T[e]||{},T[e][n]=T[e][n]||{},D.extend(T[e][n],r)}function s(e,n){"string"!=typeof n&&(n=M.ns.defaultNs),T[e]=T[e]||{},T[e][n]={}}function l(e){M.ns.defaultNs=e}function i(e,n){c([e],n)}function c(e,n){var r={dynamicLoad:M.dynamicLoad,resGetPath:M.resGetPath,getAsync:M.getAsync,customLoad:M.customLoad,ns:{namespaces:e,defaultNs:""}},t=D.toLanguages(M.lng);"string"==typeof M.preload&&(M.preload=[M.preload]);for(var a=0,u=M.preload.length;u>a;a++)for(var o=D.toLanguages(M.preload[a]),s=0,l=o.length;l>s;s++)t.indexOf(o[s])<0&&t.push(o[s]);for(var i=[],c=0,f=t.length;f>c;c++){var m=!1,g=T[t[c]];if(g)for(var d=0,b=e.length;b>d;d++)g[e[d]]||(m=!0);else m=!0;m&&i.push(t[c])}i.length?p.sync._fetch(i,r,function(r,t){var a=e.length*i.length;D.each(e,function(e,r){M.ns.namespaces.indexOf(r)<0&&M.ns.namespaces.push(r),D.each(i,function(e,u){T[u]=T[u]||{},T[u][r]=t[u][r],a--,0===a&&n&&(M.useLocalStorage&&p.sync._storeLocal(T),n())})})}):n&&n()}function f(e,n,r){return"function"==typeof n?(r=n,n={}):n||(n={}),n.lng=e,a(n,r)}function m(){return O}function g(){function e(e,n,r){if(0!==n.length){var t="text";if(0===n.indexOf("[")){var a=n.split("]");n=a[1],t=a[0].substr(1,a[0].length-1)}n.indexOf(";")===n.length-1&&(n=n.substr(0,n.length-2));var u;if("html"===t)u=M.defaultValueFromContent?S.extend({defaultValue:e.html()},r):r,e.html(S.t(n,u));else if("text"===t)u=M.defaultValueFromContent?S.extend({defaultValue:e.text()},r):r,e.text(S.t(n,u));else if("prepend"===t)u=M.defaultValueFromContent?S.extend({defaultValue:e.html()},r):r,e.prepend(S.t(n,u));else if("append"===t)u=M.defaultValueFromContent?S.extend({defaultValue:e.html()},r):r,e.append(S.t(n,u));else if(0===t.indexOf("data-")){var o=t.substr("data-".length);u=M.defaultValueFromContent?S.extend({defaultValue:e.data(o)},r):r;var s=S.t(n,u);e.data(o,s),e.attr(t,s)}else u=M.defaultValueFromContent?S.extend({defaultValue:e.attr(t)},r):r,e.attr(t,S.t(n,u))}}function n(n,r){var t=n.attr(M.selectorAttr);if(t||"undefined"==typeof t||t===!1||(t=n.text()||n.val()),t){var a=n,u=n.data("i18n-target");if(u&&(a=n.find(u)||n),r||M.useDataAttrOptions!==!0||(r=n.data("i18n-options")),r=r||{},t.indexOf(";")>=0){var o=t.split(";");S.each(o,function(n,t){""!==t&&e(a,t,r)})}else e(a,t,r);M.useDataAttrOptions===!0&&n.data("i18n-options",r)}}S.t=S.t||x,S.fn.TAPi18next=function(e){return this.each(function(){n(S(this),e);var r=S(this).find("["+M.selectorAttr+"]");r.each(function(){n(S(this),e)})})}}function d(e,n,r,t){if(!e)return e;if(t=t||n,e.indexOf(t.interpolationPrefix||M.interpolationPrefix)<0)return e;var a=t.interpolationPrefix?D.regexEscape(t.interpolationPrefix):M.interpolationPrefixEscaped,u=t.interpolationSuffix?D.regexEscape(t.interpolationSuffix):M.interpolationSuffixEscaped,o="HTML"+u;return D.each(n,function(n,s){var l=r?r+M.keyseparator+n:n;"object"==typeof s&&null!==s?e=d(e,s,l,t):t.escapeInterpolation||M.escapeInterpolation?(e=e.replace(new RegExp([a,l,o].join(""),"g"),s),e=e.replace(new RegExp([a,l,u].join(""),"g"),D.escape(s))):e=e.replace(new RegExp([a,l,u].join(""),"g"),s)}),e}function b(e,n){var r=",",t="{",a="}",u=D.extend({},n);for(delete u.postProcess;-1!=e.indexOf(M.reusePrefix)&&(w++,!(w>M.maxRecursion));){var o=e.lastIndexOf(M.reusePrefix),s=e.indexOf(M.reuseSuffix,o)+M.reuseSuffix.length,l=e.substring(o,s),i=l.replace(M.reusePrefix,"").replace(M.reuseSuffix,"");if(-1!=i.indexOf(r)){var c=i.indexOf(r);if(-1!=i.indexOf(t,c)&&-1!=i.indexOf(a,c)){var f=i.indexOf(t,c),p=i.indexOf(a,f)+a.length;try{u=D.extend(u,JSON.parse(i.substring(f,p))),i=i.substring(0,c)}catch(m){}}}var g=k(i,u);e=e.replace(l,g)}return e}function h(e){return e.context&&("string"==typeof e.context||"number"==typeof e.context)}function v(e){return void 0!==e.count&&"string"!=typeof e.count&&1!==e.count}function y(e,n){n=n||{};var r=N(e,n),t=L(e,n);return void 0!==t||t===r}function x(e,n){return n=n||{},C?(w=0,k.apply(null,arguments)):(D.log("i18next not finished initialization. you might have called t function before loading resources finished."),n.defaultValue||"")}function N(e,n){return void 0!==n.defaultValue?n.defaultValue:e}function _(){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);return{postProcess:"sprintf",sprintf:e}}function k(e,n){if(n&&"object"!=typeof n?"sprintf"===M.shortcutFunction?n=_.apply(null,arguments):"defaultValue"===M.shortcutFunction&&(n={defaultValue:n}):n=n||{},void 0===e||null===e)return"";"string"==typeof e&&(e=[e]);var r=e[0];if(e.length>1)for(var t=0;t<e.length&&(r=e[t],!y(r,n));t++);var a=N(r,n),u=L(r,n),o=n.lng?D.toLanguages(n.lng):A,s=n.ns||M.ns.defaultNs,l;r.indexOf(M.nsseparator)>-1&&(l=r.split(M.nsseparator),s=l[0],r=l[1]),void 0===u&&M.sendMissing&&(n.lng?H.postMissing(o[0],s,r,a,o):H.postMissing(M.lng,s,r,a,o));var i=n.postProcess||M.postProcess;void 0!==u&&i&&I[i]&&(u=I[i](u,r,n));var c=a;if(a.indexOf(M.nsseparator)>-1&&(l=a.split(M.nsseparator),c=l[1]),c===r&&M.parseMissingKey&&(a=M.parseMissingKey(a)),void 0===u&&(a=d(a,n),a=b(a,n),i&&I[i])){var f=N(r,n);u=I[i](f,r,n)}return void 0!==u?u:a}function L(e,n){n=n||{};var r,t,a=N(e,n),u=A;if(!T)return a;if("cimode"===u[0].toLowerCase())return a;if(n.lng&&(u=D.toLanguages(n.lng),!T[u[0]])){var o=M.getAsync;M.getAsync=!1,p.sync.load(u,M,function(e,n){D.extend(T,n),M.getAsync=o})}var s=n.ns||M.ns.defaultNs;if(e.indexOf(M.nsseparator)>-1){var l=e.split(M.nsseparator);s=l[0],e=l[1]}if(h(n)){r=D.extend({},n),delete r.context,r.defaultValue=M.contextNotFound;var i=s+M.nsseparator+e+"_"+n.context;if(t=x(i,r),t!=M.contextNotFound)return d(t,{context:n.context})}if(v(n)){r=D.extend({},n),delete r.count,r.defaultValue=M.pluralNotFound;var c=s+M.nsseparator+e+M.pluralSuffix,f=z.get(u[0],n.count);if(f>=0?c=c+"_"+f:1===f&&(c=s+M.nsseparator+e),t=x(c,r),t!=M.pluralNotFound)return d(t,{count:n.count,interpolationPrefix:n.interpolationPrefix,interpolationSuffix:n.interpolationSuffix})}for(var m,g=e.split(M.keyseparator),y=0,_=u.length;_>y&&void 0===m;y++){for(var j=u[y],P=0,S=T[j]&&T[j][s];g[P];)S=S&&S[g[P]],P++;if(void 0!==S){var O=Object.prototype.toString.apply(S);if("string"==typeof S)S=d(S,n),S=b(S,n);else if("[object Array]"!==O||M.returnObjectTrees||n.returnObjectTrees){if(null===S&&M.fallbackOnNull===!0)S=void 0;else if(null!==S)if(M.returnObjectTrees||n.returnObjectTrees){if("[object Number]"!==O&&"[object Function]"!==O&&"[object RegExp]"!==O){var w="[object Array]"===O?[]:{};D.each(S,function(r){w[r]=k(s+M.nsseparator+e+M.keyseparator+r,n)}),S=w}}else M.objectTreeKeyHandler&&"function"==typeof M.objectTreeKeyHandler?S=M.objectTreeKeyHandler(e,S,j,s,n):(S="key '"+s+":"+e+" ("+j+")' returned an object instead of string.",D.log(S))}else S=S.join("\n"),S=d(S,n),S=b(S,n);"string"==typeof S&&""===S.trim()&&M.fallbackOnEmpty===!0&&(S=void 0),m=S}}if(void 0===m&&!n.isFallbackLookup&&(M.fallbackToDefaultNS===!0||M.fallbackNS&&M.fallbackNS.length>0))if(n.isFallbackLookup=!0,M.fallbackNS.length){for(var C=0,E=M.fallbackNS.length;E>C;C++)if(m=L(M.fallbackNS[C]+M.nsseparator+e,n)){var F=m.indexOf(M.nsseparator)>-1?m.split(M.nsseparator)[1]:m,R=a.indexOf(M.nsseparator)>-1?a.split(M.nsseparator)[1]:a;if(F!==R)break}}else m=L(e,n);return m}function j(){var e,n=[];if("undefined"!=typeof window&&(!function(){for(var e=window.location.search.substring(1),r=e.split("&"),t=0;t<r.length;t++){var a=r[t].indexOf("=");if(a>0){var u=r[t].substring(0,a),o=r[t].substring(a+1);n[u]=o}}}(),n[M.detectLngQS]&&(e=n[M.detectLngQS])),!e&&"undefined"!=typeof document&&M.useCookie){var r=D.cookie.read(M.cookieName);r&&(e=r)}return e||"undefined"==typeof navigator||(e=navigator.language?navigator.language:navigator.userLanguage),e}Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var n=Object(this),r=n.length>>>0;if(0===r)return-1;var t=0;if(arguments.length>0&&(t=Number(arguments[1]),t!=t?t=0:0!=t&&1/0!=t&&t!=-1/0&&(t=(t>0||-1)*Math.floor(Math.abs(t)))),t>=r)return-1;for(var a=t>=0?t:Math.max(r-Math.abs(t),0);r>a;a++)if(a in n&&n[a]===e)return a;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(e){"use strict";if(null==this)throw new TypeError;var n=Object(this),r=n.length>>>0;if(0===r)return-1;var t=r;arguments.length>1&&(t=Number(arguments[1]),t!=t?t=0:0!=t&&t!=1/0&&t!=-(1/0)&&(t=(t>0||-1)*Math.floor(Math.abs(t))));for(var a=t>=0?Math.min(t,r-1):r-Math.abs(t);a>=0;a--)if(a in n&&n[a]===e)return a;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var P=this,S=P.jQuery||P.Zepto,T={},O,w=0,A=[],C=!1;"undefined"!=typeof module&&module.exports?module.exports=p:(S&&(S.TAPi18next=S.TAPi18next||p),P.TAPi18next=P.TAPi18next||p);var M={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",ns:"translation",fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,setJqueryExt:!1,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"TAPi18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:["sprintf"],parseMissingKey:void 0,shortcutFunction:"sprintf"},E={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},F={create:function(e,n,r,t){var a;if(r){var u=new Date;u.setTime(u.getTime()+60*r*1e3),a="; expires="+u.toGMTString()}else a="";t=t?"domain="+t+";":"",document.cookie=e+"="+n+a+";"+t+"path=/"},read:function(e){for(var n=e+"=",r=document.cookie.split(";"),t=0;t<r.length;t++){for(var a=r[t];" "==a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(n))return a.substring(n.length,a.length)}return null},remove:function(e){this.create(e,"",-1)}},R={create:function(e,n,r,t){},read:function(e){return null},remove:function(e){}},D={extend:S?S.extend:e,each:S?S.each:n,ajax:S?S.ajax:"undefined"!=typeof document?t:function(){},cookie:"undefined"!=typeof document?F:R,detectLanguage:j,escape:r,log:function(e){M.debug&&"undefined"!=typeof console&&console.log(e)},toLanguages:function(e){var n=[];if("string"==typeof e&&e.indexOf("-")>-1){var r=e.split("-");e=M.lowerCaseLng?r[0].toLowerCase()+"-"+r[1].toLowerCase():r[0].toLowerCase()+"-"+r[1].toUpperCase(),"unspecific"!==M.load&&n.push(e),"current"!==M.load&&n.push(r[0])}else n.push(e);for(var t=0;t<M.fallbackLng.length;t++)-1===n.indexOf(M.fallbackLng[t])&&M.fallbackLng[t]&&n.push(M.fallbackLng[t]);return n},regexEscape:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}};D.applyReplacement=d;var H={load:function(e,n,r){n.useLocalStorage?H._loadLocal(e,n,function(t,a){for(var u=[],o=0,s=e.length;s>o;o++)a[e[o]]||u.push(e[o]);u.length>0?H._fetch(u,n,function(e,n){D.extend(a,n),H._storeLocal(n),r(null,a)}):r(null,a)}):H._fetch(e,n,function(e,n){r(null,n)})},_loadLocal:function(e,n,r){var t={},a=(new Date).getTime();if(window.localStorage){var u=e.length;D.each(e,function(e,o){var s=window.localStorage.getItem("res_"+o);s&&(s=JSON.parse(s),s.i18nStamp&&s.i18nStamp+n.localStorageExpirationTime>a&&(t[o]=s)),u--,0===u&&r(null,t)})}},_storeLocal:function(e){if(window.localStorage)for(var n in e)e[n].i18nStamp=(new Date).getTime(),window.localStorage.setItem("res_"+n,JSON.stringify(e[n]))},_fetch:function(e,n,r){var t=n.ns,a={};if(n.dynamicLoad){var u=function(e,n){r(null,n)};if("function"==typeof n.customLoad)n.customLoad(e,t.namespaces,n,u);else{var o=d(n.resGetPath,{lng:e.join("+"),ns:t.namespaces.join("+")});D.ajax({url:o,success:function(e,n,r){D.log("loaded: "+o),u(null,e)},error:function(e,n,r){D.log("failed loading: "+o),u("failed loading resource.json error: "+r)},dataType:"json",async:n.getAsync})}}else{var s=t.namespaces.length*e.length,l;D.each(t.namespaces,function(t,u){D.each(e,function(e,t){var o=function(e,n){e&&(l=l||[],l.push(e)),a[t]=a[t]||{},a[t][u]=n,s--,0===s&&r(l,a)};"function"==typeof n.customLoad?n.customLoad(t,u,n,o):H._fetchOne(t,u,n,o)})})}},_fetchOne:function(e,n,r,t){var a=d(r.resGetPath,{lng:e,ns:n});D.ajax({url:a,success:function(e,n,r){D.log("loaded: "+a),t(null,e)},error:function(e,n,r){if(n&&200==n||e&&e.status&&200==e.status)D.log("There is a typo in: "+a);else if(n&&404==n||e&&e.status&&404==e.status)D.log("Does not exist: "+a);else{var u=n?n:e&&e.status?e.status:null;D.log(u+" when loading "+a)}t(r,{})},dataType:"json",async:r.getAsync})},postMissing:function(e,n,r,t,a){var u={};u[r]=t;var o=[];if("fallback"===M.sendMissingTo&&M.fallbackLng[0]!==!1)for(var s=0;s<M.fallbackLng.length;s++)o.push({lng:M.fallbackLng[s],url:d(M.resPostPath,{lng:M.fallbackLng[s],ns:n})});else if("current"===M.sendMissingTo||"fallback"===M.sendMissingTo&&M.fallbackLng[0]===!1)o.push({lng:e,url:d(M.resPostPath,{lng:e,ns:n})});else if("all"===M.sendMissingTo)for(var s=0,l=a.length;l>s;s++)o.push({lng:a[s],url:d(M.resPostPath,{lng:a[s],ns:n})});for(var i=0,c=o.length;c>i;i++){var f=o[i];D.ajax({url:f.url,type:M.sendType,data:u,success:function(e,a,u){D.log("posted missing key '"+r+"' to: "+f.url);for(var o=r.split("."),s=0,l=T[f.lng][n];o[s];)l=l[o[s]]=s===o.length-1?t:l[o[s]]||{},s++},error:function(e,n,t){D.log("failed posting missing key '"+r+"' to: "+f.url)},dataType:"json",async:M.postAsync})}}},z={rules:{ach:{name:"Acholi",numbers:[1,2],plurals:function(e){return Number(e>1)}},af:{name:"Afrikaans",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ak:{name:"Akan",numbers:[1,2],plurals:function(e){return Number(e>1)}},am:{name:"Amharic",numbers:[1,2],plurals:function(e){return Number(e>1)}},an:{name:"Aragonese",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ar:{name:"Arabic",numbers:[0,1,2,3,11,100],plurals:function(e){return Number(0===e?0:1==e?1:2==e?2:e%100>=3&&10>=e%100?3:e%100>=11?4:5)}},arn:{name:"Mapudungun",numbers:[1,2],plurals:function(e){return Number(e>1)}},ast:{name:"Asturian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ay:{name:"Aymará",numbers:[1],plurals:function(e){return 0}},az:{name:"Azerbaijani",numbers:[1,2],plurals:function(e){return Number(1!=e)}},be:{name:"Belarusian",numbers:[1,2,5],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},bg:{name:"Bulgarian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},bn:{name:"Bengali",numbers:[1,2],plurals:function(e){return Number(1!=e)}},bo:{name:"Tibetan",numbers:[1],plurals:function(e){return 0}},br:{name:"Breton",numbers:[1,2],plurals:function(e){return Number(e>1)}},bs:{name:"Bosnian",numbers:[1,2,5],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},ca:{name:"Catalan",numbers:[1,2],plurals:function(e){return Number(1!=e)}},cgg:{name:"Chiga",numbers:[1],plurals:function(e){return 0}},cs:{name:"Czech",numbers:[1,2,5],plurals:function(e){return Number(1==e?0:e>=2&&4>=e?1:2)}},csb:{name:"Kashubian",numbers:[1,2,5],plurals:function(e){return Number(1==e?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},cy:{name:"Welsh",numbers:[1,2,3,8],plurals:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)}},da:{name:"Danish",numbers:[1,2],plurals:function(e){return Number(1!=e)}},de:{name:"German",numbers:[1,2],plurals:function(e){return Number(1!=e)}},dz:{name:"Dzongkha",numbers:[1],plurals:function(e){return 0}},el:{name:"Greek",numbers:[1,2],plurals:function(e){return Number(1!=e)}},en:{name:"English",numbers:[1,2],plurals:function(e){return Number(1!=e)}},eo:{name:"Esperanto",numbers:[1,2],plurals:function(e){return Number(1!=e)}},es:{name:"Spanish",numbers:[1,2],plurals:function(e){return Number(1!=e)}},es_ar:{name:"Argentinean Spanish",numbers:[1,2],plurals:function(e){return Number(1!=e)}},et:{name:"Estonian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},eu:{name:"Basque",numbers:[1,2],plurals:function(e){return Number(1!=e)}},fa:{name:"Persian",numbers:[1],plurals:function(e){return 0}},fi:{name:"Finnish",numbers:[1,2],plurals:function(e){return Number(1!=e)}},fil:{name:"Filipino",numbers:[1,2],plurals:function(e){return Number(e>1)}},fo:{name:"Faroese",numbers:[1,2],plurals:function(e){return Number(1!=e)}},fr:{name:"French",numbers:[1,2],plurals:function(e){return Number(e>1)}},fur:{name:"Friulian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},fy:{name:"Frisian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ga:{name:"Irish",numbers:[1,2,3,7,11],plurals:function(e){return Number(1==e?0:2==e?1:7>e?2:11>e?3:4)}},gd:{name:"Scottish Gaelic",numbers:[1,2,3,20],plurals:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&20>e?2:3)}},gl:{name:"Galician",numbers:[1,2],plurals:function(e){return Number(1!=e)}},gu:{name:"Gujarati",numbers:[1,2],plurals:function(e){return Number(1!=e)}},gun:{name:"Gun",numbers:[1,2],plurals:function(e){return Number(e>1)}},ha:{name:"Hausa",numbers:[1,2],plurals:function(e){return Number(1!=e)}},he:{name:"Hebrew",numbers:[1,2],plurals:function(e){return Number(1!=e)}},hi:{name:"Hindi",numbers:[1,2],plurals:function(e){return Number(1!=e)}},hr:{name:"Croatian",numbers:[1,2,5],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},hu:{name:"Hungarian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},hy:{name:"Armenian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ia:{name:"Interlingua",numbers:[1,2],plurals:function(e){return Number(1!=e)}},id:{name:"Indonesian",numbers:[1],plurals:function(e){return 0}},is:{name:"Icelandic",numbers:[1,2],plurals:function(e){return Number(e%10!=1||e%100==11)}},it:{name:"Italian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ja:{name:"Japanese",numbers:[1],plurals:function(e){return 0}},jbo:{name:"Lojban",numbers:[1],plurals:function(e){return 0}},jv:{name:"Javanese",numbers:[0,1],plurals:function(e){return Number(0!==e)}},ka:{name:"Georgian",numbers:[1],plurals:function(e){return 0}},kk:{name:"Kazakh",numbers:[1],plurals:function(e){return 0}},km:{name:"Khmer",numbers:[1],plurals:function(e){return 0}},kn:{name:"Kannada",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ko:{name:"Korean",numbers:[1],plurals:function(e){return 0}},ku:{name:"Kurdish",numbers:[1,2],plurals:function(e){return Number(1!=e)}},kw:{name:"Cornish",numbers:[1,2,3,4],plurals:function(e){return Number(1==e?0:2==e?1:3==e?2:3)}},ky:{name:"Kyrgyz",numbers:[1],plurals:function(e){return 0}},lb:{name:"Letzeburgesch",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ln:{name:"Lingala",numbers:[1,2],plurals:function(e){return Number(e>1)}},lo:{name:"Lao",numbers:[1],plurals:function(e){return 0}},lt:{name:"Lithuanian",numbers:[1,2,10],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(10>e%100||e%100>=20)?1:2)}},lv:{name:"Latvian",numbers:[1,2,0],plurals:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)}},mai:{name:"Maithili",numbers:[1,2],plurals:function(e){return Number(1!=e)}},mfe:{name:"Mauritian Creole",numbers:[1,2],plurals:function(e){return Number(e>1)}},mg:{name:"Malagasy",numbers:[1,2],plurals:function(e){return Number(e>1)}},mi:{name:"Maori",numbers:[1,2],plurals:function(e){return Number(e>1)}},mk:{name:"Macedonian",numbers:[1,2],plurals:function(e){return Number(1==e||e%10==1?0:1)}},ml:{name:"Malayalam",numbers:[1,2],plurals:function(e){return Number(1!=e)}},mn:{name:"Mongolian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},mnk:{name:"Mandinka",numbers:[0,1,2],plurals:function(e){return Number(1==e?1:2)}},mr:{name:"Marathi",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ms:{name:"Malay",numbers:[1],plurals:function(e){return 0}},mt:{name:"Maltese",numbers:[1,2,11,20],plurals:function(e){return Number(1==e?0:0===e||e%100>1&&11>e%100?1:e%100>10&&20>e%100?2:3)}},nah:{name:"Nahuatl",numbers:[1,2],plurals:function(e){return Number(1!=e)}},nap:{name:"Neapolitan",numbers:[1,2],plurals:function(e){return Number(1!=e)}},nb:{name:"Norwegian Bokmal",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ne:{name:"Nepali",numbers:[1,2],plurals:function(e){return Number(1!=e)}},nl:{name:"Dutch",numbers:[1,2],plurals:function(e){return Number(1!=e)}},nn:{name:"Norwegian Nynorsk",numbers:[1,2],plurals:function(e){return Number(1!=e)}},no:{name:"Norwegian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},nso:{name:"Northern Sotho",numbers:[1,2],plurals:function(e){return Number(1!=e)}},oc:{name:"Occitan",numbers:[1,2],plurals:function(e){return Number(e>1)}},or:{name:"Oriya",numbers:[2,1],plurals:function(e){return Number(1!=e)}},pa:{name:"Punjabi",numbers:[1,2],plurals:function(e){return Number(1!=e)}},pap:{name:"Papiamento",numbers:[1,2],plurals:function(e){return Number(1!=e)}},pl:{name:"Polish",numbers:[1,2,5],plurals:function(e){return Number(1==e?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},pms:{name:"Piemontese",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ps:{name:"Pashto",numbers:[1,2],plurals:function(e){return Number(1!=e)}},pt:{name:"Portuguese",numbers:[1,2],plurals:function(e){return Number(1!=e)}},pt_br:{name:"Brazilian Portuguese",numbers:[1,2],plurals:function(e){return Number(1!=e)}},rm:{name:"Romansh",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ro:{name:"Romanian",numbers:[1,2,20],plurals:function(e){return Number(1==e?0:0===e||e%100>0&&20>e%100?1:2)}},ru:{name:"Russian",numbers:[1,2,5],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},sah:{name:"Yakut",numbers:[1],plurals:function(e){return 0}},sco:{name:"Scots",numbers:[1,2],plurals:function(e){return Number(1!=e)}},se:{name:"Northern Sami",numbers:[1,2],plurals:function(e){return Number(1!=e)}},si:{name:"Sinhala",numbers:[1,2],plurals:function(e){return Number(1!=e)}},sk:{name:"Slovak",numbers:[1,2,5],plurals:function(e){return Number(1==e?0:e>=2&&4>=e?1:2)}},sl:{name:"Slovenian",numbers:[5,1,2,3],plurals:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)}},so:{name:"Somali",numbers:[1,2],plurals:function(e){return Number(1!=e)}},son:{name:"Songhay",numbers:[1,2],plurals:function(e){return Number(1!=e)}},sq:{name:"Albanian",numbers:[1,2],plurals:function(e){return Number(1!=e)}},sr:{name:"Serbian",numbers:[1,2,5],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},su:{name:"Sundanese",numbers:[1],plurals:function(e){return 0}},sv:{name:"Swedish",numbers:[1,2],plurals:function(e){return Number(1!=e)}},sw:{name:"Swahili",numbers:[1,2],plurals:function(e){return Number(1!=e)}},ta:{name:"Tamil",numbers:[1,2],plurals:function(e){return Number(1!=e)}},te:{name:"Telugu",numbers:[1,2],plurals:function(e){return Number(1!=e)}},tg:{name:"Tajik",numbers:[1,2],plurals:function(e){return Number(e>1)}},th:{name:"Thai",numbers:[1],plurals:function(e){return 0}},ti:{name:"Tigrinya",numbers:[1,2],plurals:function(e){return Number(e>1)}},tk:{name:"Turkmen",numbers:[1,2],plurals:function(e){return Number(1!=e)}},tr:{name:"Turkish",numbers:[1,2],plurals:function(e){return Number(e>1)}},tt:{name:"Tatar",numbers:[1],plurals:function(e){return 0}},ug:{name:"Uyghur",numbers:[1],plurals:function(e){return 0}},uk:{name:"Ukrainian",numbers:[1,2,5],plurals:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&4>=e%10&&(10>e%100||e%100>=20)?1:2)}},ur:{name:"Urdu",numbers:[1,2],plurals:function(e){return Number(1!=e)}},uz:{name:"Uzbek",numbers:[1,2],plurals:function(e){return Number(e>1)}},vi:{name:"Vietnamese",numbers:[1],plurals:function(e){return 0}},wa:{name:"Walloon",numbers:[1,2],plurals:function(e){return Number(e>1)}},wo:{name:"Wolof",numbers:[1],plurals:function(e){return 0}},yo:{name:"Yoruba",numbers:[1,2],plurals:function(e){return Number(1!=e)}},zh:{name:"Chinese",numbers:[1],plurals:function(e){return 0}}},addRule:function(e,n){z.rules[e]=n},setCurrentLng:function(e){if(!z.currentRule||z.currentRule.lng!==e){var n=e.split("-");z.currentRule={lng:e,rule:z.rules[n[0]]}}},get:function(e,n){function r(n,r){var t;if(t=z.currentRule&&z.currentRule.lng===e?z.currentRule.rule:z.rules[n]){var a=t.plurals(r),u=t.numbers[a];return 2===t.numbers.length&&1===t.numbers[0]&&(2===u?u=-1:1===u&&(u=1)),u}return 1===r?"1":"-1"}var t=e.split("-");return r(t[0],n)}},I={},V=function(e,n){I[e]=n},B=function(){function e(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function n(e,n){for(var r=[];n>0;r[--n]=e);return r.join("")}var r=function(){return r.cache.hasOwnProperty(arguments[0])||(r.cache[arguments[0]]=r.parse(arguments[0])),r.format.call(null,r.cache[arguments[0]],arguments)};return r.format=function(r,t){var a=1,u=r.length,o="",s,l=[],i,c,f,p,m,g;for(i=0;u>i;i++)if(o=e(r[i]),"string"===o)l.push(r[i]);else if("array"===o){if(f=r[i],f[2])for(s=t[a],c=0;c<f[2].length;c++){if(!s.hasOwnProperty(f[2][c]))throw B('[sprintf] property "%s" does not exist',f[2][c]);s=s[f[2][c]]}else s=f[1]?t[f[1]]:t[a++];if(/[^s]/.test(f[8])&&"number"!=e(s))throw B("[sprintf] expecting number but found %s",e(s));switch(f[8]){case"b":s=s.toString(2);break;case"c":s=String.fromCharCode(s);break;case"d":s=parseInt(s,10);break;case"e":s=f[7]?s.toExponential(f[7]):s.toExponential();break;case"f":s=f[7]?parseFloat(s).toFixed(f[7]):parseFloat(s);break;case"o":s=s.toString(8);break;case"s":s=(s=String(s))&&f[7]?s.substring(0,f[7]):s;break;case"u":s=Math.abs(s);break;case"x":s=s.toString(16);break;case"X":s=s.toString(16).toUpperCase()}s=/[def]/.test(f[8])&&f[3]&&s>=0?"+"+s:s,m=f[4]?"0"==f[4]?"0":f[4].charAt(1):" ",g=f[6]-String(s).length,p=f[6]?n(m,g):"",l.push(f[5]?s+p:p+s)}return l.join("")},r.cache={},r.parse=function(e){for(var n=e,r=[],t=[],a=0;n;){if(null!==(r=/^[^\x25]+/.exec(n)))t.push(r[0]);else if(null!==(r=/^\x25{2}/.exec(n)))t.push("%");else{if(null===(r=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(n)))throw"[sprintf] huh?";if(r[2]){a|=1;var u=[],o=r[2],s=[];if(null===(s=/^([a-z_][a-z_\d]*)/i.exec(o)))throw"[sprintf] huh?";for(u.push(s[1]);""!==(o=o.substring(s[0].length));)if(null!==(s=/^\.([a-z_][a-z_\d]*)/i.exec(o)))u.push(s[1]);
+else{if(null===(s=/^\[(\d+)\]/.exec(o)))throw"[sprintf] huh?";u.push(s[1])}r[2]=u}else a|=2;if(3===a)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";t.push(r)}n=n.substring(r[0].length)}return t},r}(),G=function(e,n){return n.unshift(e),B.apply(null,n)};V("sprintf",function(e,n,r){return r.sprintf?"[object Array]"===Object.prototype.toString.apply(r.sprintf)?G(e,r.sprintf):"object"==typeof r.sprintf?B(e,r.sprintf):e:e}),p.init=a,p.setLng=f,p.preload=u,p.addResourceBundle=o,p.removeResourceBundle=s,p.loadNamespace=i,p.loadNamespaces=c,p.setDefaultNamespace=l,p.t=x,p.translate=x,p.exists=y,p.detectLanguage=D.detectLanguage,p.pluralExtensions=z,p.sync=H,p.functions=D,p.lng=m,p.addPostProcessor=V,p.options=M}()}.call(this),function(){p.init({resStore:{},fallbackLng:g.fallback_language,useCookie:!1})}.call(this),function(){d="object"==typeof d?d:{};var e=d;e.helpers={}}.call(this),d="object"==typeof d?d:{};var b=d,h;m={},h=g.fallback_language,e.extend(m,{_language_changed_tracker:new r.Dependency,_loaded_languages:[h],_fallback_language:h,_loaded_lang_session_key:"TAPi18n::loaded_lang",conf:null,packages:{},languages_names:{},translations:{},_enable:function(e){return this.conf=e,this._onceEnabled()},_onceEnabled:function(){},_enabled:function(){return null!=this.conf},_getPackageDomain:function(e){return e.replace(/:/g,"-")},addResourceBundle:function(e,n,r){return p.addResourceBundle(e,m._getPackageDomain(n),r)},_getProjectLanguages:function(){return this._enabled()?e.isArray(this.conf.supported_languages)?e.union([this._fallback_language],this.conf.supported_languages):e.keys(this.languages_names):[this._fallback_language]},getLanguages:function(){var e,n,r,t,a;if(!this._enabled())return null;for(n={},a=this._getProjectLanguages(),r=0,t=a.length;t>r;r++)e=a[r],n[e]={name:this.languages_names[e][1],en:this.languages_names[e][0]};return n},_loadLangFileObject:function(n,r){var t,a,u,o;o=[];for(a in r)t=r[a],t=e.extend({},t,(null!=(u=this._loadTranslations_cache[n])?u[a]:void 0)||{}),o.push(m.addResourceBundle(n,a,t));return o},_loadTranslations_cache:{},loadTranslations:function(r,t){var a,u,o,s;u=this._getProjectLanguages(),s=[];for(a in r)o=r[a],null==this._loadTranslations_cache[a]&&(this._loadTranslations_cache[a]={}),null==this._loadTranslations_cache[a][t]&&(this._loadTranslations_cache[a][t]={}),e.extend(this._loadTranslations_cache[a][t],o),m.addResourceBundle(a,t,o),s.push(n.isClient&&this.getLanguage()===a?this._language_changed_tracker.changed():void 0);return s}}),d="object"==typeof d?d:{};var b=d,v,y=[].indexOf||function(e){for(var n=0,r=this.length;r>n;n++)if(n in this&&this[n]===e)return n;return-1},x=[].slice;v=m._loaded_lang_session_key,a.set(v,null),e.extend(m,{_getLanguageFilePath:function(e){var r;return this._enabled()?(r=null!=this.conf.cdn_path?this.conf.cdn_path:this.conf.i18n_files_route,r=r.replace(/\/$/,""),n.isCordova&&"/"===r[0]&&(r=n.absoluteUrl()+r),""+r+"/"+e+".json"):null},_loadLanguage:function(e){var n,r,t,a,o,s;return s=this,r=new u.Deferred,this._enabled()?(o=s._getProjectLanguages(),y.call(o,e)>=0?y.call(s._loaded_languages,e)<0?(a=function(){var n;return n=u.getJSON(s._getLanguageFilePath(e)),n.done(function(n){return m._loadLangFileObject(e,n),s._loaded_languages.push(e),r.resolve()}),n.fail(function(n,t){return r.reject("Couldn't load language '"+e+"' JSON: "+t)})},t=y.call(e,"-")>=0?e.replace(/-.*/,""):h,e!==h&&y.call(o,t)>=0?(n=s._loadLanguage(t),n.done(function(){return a()}),n.fail(function(e){return r.reject("Loading process failed since dependency language '"+t+"' failed to load: "+e)})):a()):r.resolve():r.reject(["Language "+e+" is not supported"]),r.promise()):r.reject("tap-i18n is not enabled in the project level, check tap-i18n README")},_registerHelpers:function(n,r){var t,a,u,o;return a=this,u=this._getPackageI18nextProxy(n!==g.project_translations_domain?a.packages[n].namespace:g.project_translations_domain),o=function(){var n,r,t;return r=arguments[0],n=2<=arguments.length?x.call(arguments,1):[],t=n.pop().hash,e.isEmpty(n)||(t.sprintf=n),u(r,t)},n===g.project_translations_domain?(i.registerHelper(a.conf.helper_name,o),i.registerHelper("languageTag",function(){return a.getLanguage()})):null!=s[r]&&null!=s[r].helpers?(t={},t[a.packages[n].helper_name]=o,s[r].helpers(t)):void 0},_getRegisterHelpersProxy:function(e){var n;return n=this,function(r){return n._registerHelpers(e,r)}},_getPackageI18nextProxy:function(e){var n;return n=this,function(r,t,a){return null==a&&(a=null),null!=a&&console.log("Warning: specifying lang_tag is not supported in client side, using session language"),n._language_changed_tracker.depend(),p.t(""+m._getPackageDomain(e)+":"+r,t)}},_onceEnabled:function(){return m._registerHelpers(g.project_translations_domain)},setLanguage:function(e){var n;return n=this,this._loadLanguage(e).then(function(){return p.setLng(e),n._language_changed_tracker.changed(),a.set(v,e)})},getLanguage:function(){var e;return this._enabled()?(e=a.get(v),null!=e?e:this._fallback_language):null}}),m.__=m._getPackageI18nextProxy(g.project_translations_domain),"undefined"==typeof Package&&(Package={}),Package["tap:i18n"]={TAPi18next:p,TAPi18n:m}}();
+
+!function(){var a=Package.meteor.Meteor,e=Package.blaze.Blaze,c=Package.blaze.UI,g=Package.blaze.Handlebars,k=Package.htmljs.HTML,e,c,g;"undefined"==typeof Package&&(Package={}),Package.ui={Blaze:e,UI:c,Handlebars:g}}();
+
+!function(){var e=Package.meteor.Meteor,r=Package.blaze.Blaze,n=Package.blaze.UI,t=Package.blaze.Handlebars,i=Package.session.Session,o=Package.tracker.Tracker,a=Package.tracker.Deps,u=Package.underscore._,s=Package.htmljs.HTML,c,n;(function(){"undefined"==typeof c&&(c={});var r={},n=e.isClient?new a.Dependency:null,t="en";c.setLanguage=function(r){r&&r!==t&&(t=r,e.isClient&&n.changed())},c.language=function(){return e.isClient&&n.depend(),t},c.setDictionary=function(e){r=e},c.addDictionary=function(e){u.extend(r,e)};var i=function(e,r){return e==e.toLowerCase()?r.toLowerCase():e==e.toUpperCase()?r.toUpperCase():e.substr(1)==e.substr(1).toLowerCase()?r.substr(0,1).toUpperCase()+r.substr(1).toLowerCase():e.substr(0,2)==e.substr(0,2).toUpperCase()?r:r.replace(/( [a-z])/g,function(e){return e.toUpperCase()})};c.getText=function(e,n){var t=e.toLowerCase(),o=r&&r[t],a="string"==typeof n?n:c.language();return i(e,o?o[a]?o[a]:o.en:"["+e+"]")}}).call(this),function(){("undefined"==typeof n||"function"!=typeof n.registerHelper)&&(n={registerHelper:function(e,r){if("undefined"!=typeof t)return t.registerHelper(e,r);throw new Error("No UI or Handlebars found")}}),"undefined"!=typeof n&&(n.registerHelper("getLength",function(e){return e&&e.length}),n.registerHelper("isSelected",function(e,r){return e===r?" selected":""}),n.registerHelper("isChecked",function(e,r){return e===r?" checked":""}),n.registerHelper("cutString",function(e,r){return e.length>r?e.substr(0,Math.max(r-3,0))+"...":e}),n.registerHelper("$eq",function(e,r){return e===r}),n.registerHelper("$neq",function(e,r){return e!==r}),n.registerHelper("$in",function(e,r,n,t){return e===r||e===n||e===t}),n.registerHelper("$nin",function(e,r,n,t){return e!==r&&e!==n&&e!==t}),n.registerHelper("$exists",function(e){return void 0!==e}),n.registerHelper("$lt",function(e,r){return r>e}),n.registerHelper("$gt",function(e,r){return e>r}),n.registerHelper("$lte",function(e,r){return r>=e}),n.registerHelper("$gte",function(e,r){return e>=r}),n.registerHelper("$and",function(e,r){return e&&r}),n.registerHelper("$or",function(e,r){return e||r}),n.registerHelper("$not",function(e){return!e}),n.registerHelper("nl2br",function(e){var r=(e+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br>$2");return new Spacebars.SafeString(r)}),n.registerHelper("getText",function(e,r){var n=r||null;return c.getText(e,n)}),n.registerHelper("$mapped",function(e){if(!Array.isArray(e))try{e=e.fetch()}catch(r){return console.log("Error in $mapped: perhaps you aren't sending in a collection or array."),[]}var n=e.map(function(r,n){return r.$index=n,r.$first=0===n,r.$last=n===e.length-1,r});return n||[]}),c.superScope={},c.addScope=function(e,r){c.superScope[e]=u.bind(function(){return this},r)},c.removeScope=function(e){delete n._globalHelpers[e],delete c.superScope[e]},c.addScope("Session",i),c.addScope("Meteor",e),n.registerHelper("$",function(){return c.superScope}))}.call(this),"undefined"==typeof Package&&(Package={}),Package["raix:handlebar-helpers"]={Helpers:c}}();
+
+!function(){var n=Package.meteor.Meteor,i=Package.underscore._,e=Package.templating.Template,a=Package.jquery.$,t=Package.jquery.jQuery,o=Package.blaze.Blaze,r=Package.blaze.UI,s=Package.blaze.Handlebars,m=Package.htmljs.HTML;(function(){e.__checkName("Animate"),e.Animate=new e("Template.Animate",function(){var n=this;return o._InOuterTemplateScope(n,function(){return Spacebars.include(function(){return Spacebars.call(n.templateContentBlock)})})})}).call(this),function(){var t=function(n){return"all 0s ease 0s"===n.css("transition")&&"none 0s ease 0s 1 normal none running"===n.css("animation")?(console.warn('animation-helper error: The following element has no transition defined, but an "animate" class:',n[0]),!0):!1};e.Animate.rendered=function(){var e=this;i.each(this.findAll(".animate"),function(n){var i=a(n);t(i)||(i.width(),i.removeClass("animate"),i.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionEnd msTransitionEnd animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd animationEnd msAnimationEnd",function(e){e.target===n&&(i.off(e),n._animation_helper_isVisible=!0)}))}),e._animation_helper_parentNode=this.firstNode.parentNode,e._animation_helper_parentNode._uihooks={insertElement:function(n,i){var e=a(n);e.insertBefore(i),e.hasClass("animate")&&!t(e)&&(e.width(),e.removeClass("animate"),e.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionEnd msTransitionEnd animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd animationEnd msAnimationEnd",function(i){i.target===n&&(e.off(i),n._animation_helper_isVisible=!0)}))},removeElement:function(i){var e=a(i);if(i._animation_helper_isVisible){var t;n.isClient&&(t=n.setTimeout(function(){e.remove(),e=null},5e3)),e.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd transitionEnd msTransitionEnd animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd animationEnd msAnimationEnd",function(a){a.target===i&&(e.off(a),n.clearTimeout(t),delete i._animation_helper_isVisible,e.remove(),e=null)}),e.addClass("animate").width()}else e.remove(),e=null}}},e.Animate.destroyed=function(){var i=this;n.isClient&&i._animation_helper_parentNode&&Tracker.afterFlush(function(){i._animation_helper_parentNode._uihooks=null})}}.call(this),"undefined"==typeof Package&&(Package={}),Package["frozeman:animation-helper"]={}}();
+
+!function(){var e=Package.meteor.Meteor,a=Package.underscore._,t=Package["reactive-var"].ReactiveVar,r;(function(){r={_getTemplateInstance:function(r,n,l){var p=null;if(a.isObject(r)&&(r.hasOwnProperty("_templateInstance")||r.hasOwnProperty("view")))r.hasOwnProperty("_templateInstance")?p=r:r.hasOwnProperty("view")&&(p=r.view);else try{p=Template.instance().view,l=n,n=r}catch(c){throw new e.Error("TemplateVar works only from withing template helpers, callbacks or events. Additonally you can pass a template instance as the first parameter.")}for(;-1===p.name.indexOf("Template.")&&p.parentView;)p=p.parentView;return p&&!p._templateVar&&(p._templateVar={}),p&&!p._templateVar[n]&&(p._templateVar[n]=new t(l)),{key:n,value:l,template:p}},get:function(e,a){var t=r._getTemplateInstance(e,a);return t.template._templateVar[t.key].get()},set:function(e,a,t){var n=r._getTemplateInstance(e,a,t);n.template._templateVar[n.key].set(n.value)}}}).call(this),"undefined"==typeof Package&&(Package={}),Package["frozeman:template-var"]={TemplateVar:r}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.jquery.$,r=Package.jquery.jQuery;(function(){!function(e,t){var r=[].slice,s={},n=e.amplify={publish:function(e){if("string"!=typeof e)throw new Error("You must provide a valid topic to publish.");var t=r.call(arguments,1),n,u,a,o=0,i;if(!s[e])return!0;for(n=s[e].slice(),a=n.length;a>o&&(u=n[o],i=u.callback.apply(u.context,t),i!==!1);o++);return i!==!1},subscribe:function(e,t,r,n){if("string"!=typeof e)throw new Error("You must provide a valid topic to create a subscription.");3===arguments.length&&"number"==typeof r&&(n=r,r=t,t=null),2===arguments.length&&(r=t,t=null),n=n||10;for(var u=0,a=e.split(/\s/),o=a.length,i;o>u;u++){e=a[u],i=!1,s[e]||(s[e]=[]);for(var c=s[e].length-1,l={callback:r,context:t,priority:n};c>=0;c--)if(s[e][c].priority<=n){s[e].splice(c+1,0,l),i=!0;break}i||s[e].unshift(l)}return r},unsubscribe:function(e,t,r){if("string"!=typeof e)throw new Error("You must provide a valid topic to remove a subscription.");if(2===arguments.length&&(r=t,t=null),s[e])for(var n=s[e].length,u=0;n>u;u++)s[e][u].callback===r&&(t&&s[e][u].context!==t||(s[e].splice(u,1),u--,n--))}}}(this),function(e,t){function r(e,r){s.addType(e,function(u,a,o){var i,c,l,p,f=a,d=(new Date).getTime();if(!u){f={},p=[],l=0;try{for(u=r.length;u=r.key(l++);)n.test(u)&&(c=JSON.parse(r.getItem(u)),c.expires&&c.expires<=d?p.push(u):f[u.replace(n,"")]=c.data);for(;u=p.pop();)r.removeItem(u)}catch(y){}return f}if(u="__amplify__"+u,a===t){if(i=r.getItem(u),c=i?JSON.parse(i):{expires:-1},!(c.expires&&c.expires<=d))return c.data;r.removeItem(u)}else if(null===a)r.removeItem(u);else{c=JSON.stringify({data:a,expires:o.expires?d+o.expires:null});try{r.setItem(u,c)}catch(y){s[e]();try{r.setItem(u,c)}catch(y){throw s.error()}}}return f})}var s=e.store=function(e,t,r){var n=s.type;return r&&r.type&&r.type in s.types&&(n=r.type),s.types[n](e,t,r||{})};s.types={},s.type=null,s.addType=function(e,t){s.type||(s.type=e),s.types[e]=t,s[e]=function(t,r,n){return n=n||{},n.type=e,s(t,r,n)}},s.error=function(){return"amplify.store quota exceeded"};var n=/^__amplify__/;for(var u in{localStorage:1,sessionStorage:1})try{window[u].setItem("__amplify__","x"),window[u].removeItem("__amplify__"),r(u,window[u])}catch(a){}if(!s.types.localStorage&&window.globalStorage)try{r("globalStorage",window.globalStorage[window.location.hostname]),"sessionStorage"===s.type&&(s.type="globalStorage")}catch(a){}!function(){if(!s.types.localStorage){var e=document.createElement("div"),r="amplify";e.style.display="none",document.getElementsByTagName("head")[0].appendChild(e);try{e.addBehavior("#default#userdata"),e.load(r)}catch(n){return void e.parentNode.removeChild(e)}s.addType("userData",function(n,u,a){e.load(r);var o,i,c,l,p,f=u,d=(new Date).getTime();if(!n){for(f={},p=[],l=0;o=e.XMLDocument.documentElement.attributes[l++];)i=JSON.parse(o.value),i.expires&&i.expires<=d?p.push(o.name):f[o.name]=i.data;for(;n=p.pop();)e.removeAttribute(n);return e.save(r),f}if(n=n.replace(/[^\-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g,"-"),n=n.replace(/^-/,"_-"),u===t){if(o=e.getAttribute(n),i=o?JSON.parse(o):{expires:-1},!(i.expires&&i.expires<=d))return i.data;e.removeAttribute(n)}else null===u?e.removeAttribute(n):(c=e.getAttribute(n),i=JSON.stringify({data:u,expires:a.expires?d+a.expires:null}),e.setAttribute(n,i));try{e.save(r)}catch(y){null===c?e.removeAttribute(n):e.setAttribute(n,c),s.userData();try{e.setAttribute(n,i),e.save(r)}catch(y){throw null===c?e.removeAttribute(n):e.setAttribute(n,c),s.error()}}return f})}}(),function(){function e(e){return e===t?t:JSON.parse(JSON.stringify(e))}var r={},n={};s.addType("memory",function(s,u,a){return s?u===t?e(r[s]):(n[s]&&(clearTimeout(n[s]),delete n[s]),null===u?(delete r[s],null):(r[s]=u,a.expires&&(n[s]=setTimeout(function(){delete r[s],delete n[s]},a.expires)),u)):e(r)})}()}(this.amplify=this.amplify||{}),function(e,t){"use strict";function r(){}function s(e){return"[object Function]"==={}.toString.call(e)}function n(e){var t=!1;return setTimeout(function(){t=!0},1),function(){var r=this,s=arguments;t?e.apply(r,s):setTimeout(function(){e.apply(r,s)},1)}}e.request=function(t,u,a){var o=t||{};"string"==typeof o&&(s(u)&&(a=u,u={}),o={resourceId:t,data:u||{},success:a});var i={abort:r},c=e.request.resources[o.resourceId],l=o.success||r,p=o.error||r;if(o.success=n(function(t,r){r=r||"success",e.publish("request.success",o,t,r),e.publish("request.complete",o,t,r),l(t,r)}),o.error=n(function(t,r){r=r||"error",e.publish("request.error",o,t,r),e.publish("request.complete",o,t,r),p(t,r)}),!c){if(!o.resourceId)throw"amplify.request: no resourceId provided";throw"amplify.request: unknown resourceId: "+o.resourceId}return e.publish("request.before",o)?(e.request.resources[o.resourceId](o,i),i):void o.error(null,"abort")},e.request.types={},e.request.resources={},e.request.define=function(t,r,s){if("string"==typeof r){if(!(r in e.request.types))throw"amplify.request.define: unknown type: "+r;s.resourceId=t,e.request.resources[t]=e.request.types[r](s)}else e.request.resources[t]=r}}(amplify),function(e,t,r){"use strict";var s=["status","statusText","responseText","responseXML","readyState"],n=/\{([^\}]+)\}/g;e.request.types.ajax=function(n){return n=t.extend({type:"GET"},n),function(u,a){var o,i,c=n.url,l=a.abort,p=t.extend(!0,{},n,{data:u.data}),f=!1,d={readyState:0,setRequestHeader:function(e,t){return o.setRequestHeader(e,t)},getAllResponseHeaders:function(){return o.getAllResponseHeaders()},getResponseHeader:function(e){return o.getResponseHeader(e)},overrideMimeType:function(e){return o.overrideMimeType(e)},abort:function(){f=!0;try{o.abort()}catch(e){}i(null,"abort")},success:function(e,t){u.success(e,t)},error:function(e,t){u.error(e,t)}};i=function(e,n){t.each(s,function(e,t){try{d[t]=o[t]}catch(r){}}),/OK$/.test(d.statusText)&&(d.statusText="success"),e===r&&(e=null),f&&(n="abort"),/timeout|error|abort/.test(n)?d.error(e,n):d.success(e,n),i=t.noop},e.publish("request.ajax.preprocess",n,u,p,d),t.extend(p,{isJSONP:function(){return/jsonp/gi.test(this.dataType)},cacheURL:function(){if(!this.isJSONP())return this.url;var e="callback";this.hasOwnProperty("jsonp")&&(this.jsonp!==!1?e=this.jsonp:this.hasOwnProperty("jsonpCallback")&&(e=this.jsonpCallback));var t=new RegExp("&?"+e+"=[^&]*&?","gi");return this.url.replace(t,"")},success:function(e,t){i(e,t)},error:function(e,t){i(null,t)},beforeSend:function(t,r){o=t,p=r;var s=n.beforeSend?n.beforeSend.call(this,d,p):!0;return s&&e.publish("request.before.ajax",n,u,p,d)}}),p.cache&&p.isJSONP()&&t.extend(p,{cache:!0}),t.ajax(p),a.abort=function(){d.abort(),l.call(this)}}},e.subscribe("request.ajax.preprocess",function(e,r,s){var u=[],a=s.data;"string"!=typeof a&&(a=t.extend(!0,{},e.data,a),s.url=s.url.replace(n,function(e,t){return t in a?(u.push(t),a[t]):void 0}),t.each(u,function(e,t){delete a[t]}),s.data=a)}),e.subscribe("request.ajax.preprocess",function(e,r,s){var n=s.data,u=e.dataMap;u&&"string"!=typeof n&&(t.isFunction(u)?s.data=u(n):(t.each(e.dataMap,function(e,t){e in n&&(n[t]=n[e],delete n[e])}),s.data=n))});var u=e.request.cache={_key:function(e,t,r){function s(){return r.charCodeAt(u++)<<24|r.charCodeAt(u++)<<16|r.charCodeAt(u++)<<8|r.charCodeAt(u++)<<0}r=t+r;for(var n=r.length,u=0,a=s();n>u;)a^=s();return"request-"+e+"-"+a},_default:function(){var e={};return function(t,r,s,n){var a=u._key(r.resourceId,s.cacheURL(),s.data),o=t.cache;if(a in e)return n.success(e[a]),!1;var i=n.success;n.success=function(t){e[a]=t,"number"==typeof o&&setTimeout(function(){delete e[a]},o),i.apply(this,arguments)}}}()};e.store&&(t.each(e.store.types,function(t){u[t]=function(r,s,n,a){var o=u._key(s.resourceId,n.cacheURL(),n.data),i=e.store[t](o);if(i)return n.success(i),!1;var c=a.success;a.success=function(s){e.store[t](o,s,{expires:r.cache.expires}),c.apply(this,arguments)}}}),u.persist=u[e.store.type]),e.subscribe("request.before.ajax",function(e){var t=e.cache;return t?(t=t.type||t,u[t in u?t:"_default"].apply(this,arguments)):void 0}),e.request.decoders={jsend:function(e,t,r,s,n){"success"===e.status?s(e.data):"fail"===e.status?n(e.data,"fail"):"error"===e.status?(delete e.status,n(e,"error")):n(null,"error")}},e.subscribe("request.before.ajax",function(r,s,n,u){function a(e,t){i(e,t)}function o(e,t){c(e,t)}var i=u.success,c=u.error,l=t.isFunction(r.decoder)?r.decoder:r.decoder in e.request.decoders?e.request.decoders[r.decoder]:e.request.decoders._default;l&&(u.success=function(e,t){l(e,t,u,a,o)},u.error=function(e,t){l(e,t,u,a,o)})})}(amplify,r)}).call(this),"undefined"==typeof Package&&(Package={}),Package.amplify={}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,n;(function(){var o=4.8,a=50;n=function(e){var o=this;if(!(o instanceof n))throw new Error('use "new" to construct a PersistentMinimongo');o.key="minimongo__"+e._name,o.col=e,o.cur=o.col.find({}),o.stats={added:0,removed:0,changed:0},i.push(o),o.refresh(!0),o.cur.observe({added:function(e){o.capCollection();var n=amplify.store(o.key);n||(n=[]),t.contains(n,e._id)||(n.push(e._id),amplify.store(o.key,n));var a=o._makeDataKey(e._id);amplify.store(a)||amplify.store(a,e),++o.stats.added},removed:function(e){var n=amplify.store(o.key);t.contains(n,e._id)&&(n=t.without(n,e._id),amplify.store(o._makeDataKey(e._id),null),amplify.store(o.key,0===n.length?null:n),++o.stats.removed)},changed:function(e,t){amplify.store(o._makeDataKey(e._id),e),++o.stats.changed}})},n.prototype={constructor:n,_getStats:function(){return this.stats},_getKey:function(){return this.key},_makeDataKey:function(e){return this.key+"__"+e},refresh:function(e){var n=this,o=amplify.store(n.key),a=[];if(n.stats.added=0,o){var i=o.length;o=t.filter(o,function(e){var t=amplify.store(n._makeDataKey(e));if(t){var o=n.col.findOne({_id:t._id});o?n.col.update({_id:o._id},t):n.col.insert(t)}return!!t}),e||(n.col.find({}).forEach(function(e){t.contains(o,e._id)||a.push(e._id)}),t.each(a,function(e){n.col.remove({_id:e})})),e&&i!=o.length&&amplify.store(n.key,0===o.length?null:o)}},localStorageSize:function(){var e=0;return localStorage&&t.each(Object.keys(localStorage),function(t){e+=2*localStorage[t].length/1024/1024}),e},capCollection:function(){var e=this;e.localStorageSize()>o&&(console.log(e.localStorageSize(),e.col.find({}).count()),t.each(e.col.find({},{limit:a}).fetch(),function(t){e.col.remove(t._id)}))}};var i=[],r=null;e.startup(function(){$(window).bind("storage",function(n){e.clearTimeout(r),r=e.setTimeout(function(){t.each(i,function(e){e.refresh(!1)})},250)})})}).call(this),"undefined"==typeof Package&&(Package={}),Package["frozeman:persistent-minimongo"]={PersistentMinimongo:n}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.tracker.Tracker,n=Package.tracker.Deps,a=Package.underscore._,i;(function(){i=function(){function n(e){this._dependency=new t.Dependency,this._intervalId=null,a.isFinite(e)&&this.start(e)}return n.prototype.start=function(t){var n=this;this._intervalId=e.setInterval(function(){n._dependency.changed()},1e3*t)},n.prototype.stop=function(){e.clearInterval(this._intervalId),this._intervalId=null},n.prototype.tick=function(){this._dependency.depend()},n}()}).call(this),"undefined"==typeof Package&&(Package={}),Package["frozeman:reactive-timer"]={ReactiveTimer:i}}();
+
+!function(){var e=Package.meteor.Meteor,n;(function(){n=function(){"use strict";function e(n,t){var r,s,u,f,h,g,v=this;if(!(v instanceof e))return new e(n,t);if(n instanceof e){if(null==t)return S=0,v.s=n.s,v.e=n.e,void(v.c=(n=n.c)?n.slice():n);n+=""}else if(f="number"==(h=typeof n)){if(null==t&&n===~~n){for(v.s=0>1/n?(n=-n,-1):1,s=S=0,u=n;u>=10;u/=10,s++);return v.e=s,void(v.c=[n])}n=0===n&&0>1/n?"-0":n+""}else"string"!=h&&(n+="");if(h=n,null==t&&A.test(h))v.s=45===h.charCodeAt(0)?(h=h.slice(1),-1):1;else{if(10==t)return v=new e(h),l(v,c+v.e+1,a);if(h=R.call(h).replace(/^\+(?!-)/,""),v.s=45===h.charCodeAt(0)?(h=h.replace(/^-(?!-)/,""),-1):1,null!=t?t!=~~t&&d||(O=!(t>=2&&65>t))?(o(t,2),g=A.test(h)):(r="["+b.slice(0,t=0|t)+"]+",h=h.replace(/\.$/,"").replace(/^\./,"0."),(g=new RegExp("^"+r+"(?:\\."+r+")?$",37>t?"i":"").test(h))?(f&&(h.replace(/^0\.0*|\./,"").length>15&&o(n,0),f=!f),h=i(h,10,t,v.s)):"Infinity"!=h&&"NaN"!=h&&(o(n,1,t),n="NaN")):g=A.test(h),!g)return v.c=v.e=null,"Infinity"!=h&&("NaN"!=h&&o(n,3),v.s=null),void(S=0)}for((s=h.indexOf("."))>-1&&(h=h.replace(".","")),(u=h.search(/e/i))>0?(0>s&&(s=u),s+=+h.slice(u+1),h=h.substring(0,u)):0>s&&(s=h.length),u=0;48===h.charCodeAt(u);u++);for(t=h.length;48===h.charCodeAt(--t););if(h=h.slice(u,t+1))if(t=h.length,f&&t>15&&o(n,0),s=s-u-1,s>m)v.c=v.e=null;else if(p>s)v.c=[v.e=0];else{if(v.e=s,v.c=[],u=(s+1)%_,0>s&&(u+=_),t>u){for(u&&v.c.push(+h.slice(0,u)),t-=_;t>u;v.c.push(+h.slice(u,u+=_)));h=h.slice(u),u=_-h.length}else u-=t;for(;u--;h+="0");v.c.push(+h)}else v.c=[v.e=0];S=0}function n(e,n,t){for(var r=1,i=n.length;!n[--i];n.pop());for(i=n[0];i>=10;i/=10,r++);return(t=r+t*_-1)>m?e.c=e.e=null:p>t?e.c=[e.e=0]:(e.e=t,e.c=n),e}function t(e){for(var n,t,r=1,i=e.length,s=e[0]+"";i>r;){for(n=e[r++]+"",t=_-n.length;t--;n="0"+n);s+=n}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function r(e,n,t){for(var r,i=[0],s,o=0,l=e.length;l>o;){for(s=i.length;s--;i[s]*=n);for(i[r=0]+=b.indexOf(e.charAt(o++));r<i.length;r++)i[r]>t-1&&(null==i[r+1]&&(i[r+1]=0),i[r+1]+=i[r]/t|0,i[r]%=t)}return i.reverse()}function i(n,t,i,s){var o,l,u,f,h,g,p,m=n.indexOf("."),d=a;for(37>i&&(n=n.toLowerCase()),m>=0&&(n=n.replace(".",""),p=new e(i),h=p.pow(n.length-m),p.c=r(h.toFixed(),10,t),p.e=p.c.length),g=r(n,i,t),l=u=g.length;0==g[--u];g.pop());if(!g[0])return"0";if(0>m?--l:(h.c=g,h.e=l,h.s=s,h=D(h,p,c,d,t),g=h.c,f=h.r,l=h.e),o=l+c+1,m=g[o],u=t/2,f=f||0>o||null!=g[o+1],f=4>d?(null!=m||f)&&(0==d||d==(h.s<0?3:2)):m>u||m==u&&(4==d||f||6==d&&1&g[o-1]||d==(h.s<0?8:7)),1>o||!g[0])g.length=1,u=0,f?(g[0]=1,l=-c):l=g[0]=0;else{if(g.length=o,f)for(--t;++g[--o]>t;)g[o]=0,o||(++l,g.unshift(1));for(u=g.length;!g[--u];);}for(m=0,n="";u>=m;n+=b.charAt(g[m++]));if(0>l){for(;++l;n="0"+n);n="0."+n}else if(m=n.length,++l>m)for(l-=m;l--;n+="0");else m>l&&(n=n.slice(0,l)+"."+n.slice(l));return n}function s(n,r,i){var s,o,u,f=(n=new e(n)).e;if(null==r?s=0:(l(n,++r,a),s=i?r:r+n.e-f,f=n.e),o=t(n.c),1==i||2==i&&(f>=r||h>=f)){for(;o.length<s;o+="0");o.length>1&&(o=o.charAt(0)+"."+o.slice(1)),o+=(0>f?"e":"e+")+f}else{if(i=o.length,0>f){for(u=s-i;++f;o="0"+o);o="0."+o}else if(++f>i){for(u=s-f,f-=i;f--;o+="0");u>0&&(o+=".")}else u=s-i,i>f?o=o.slice(0,f)+"."+o.slice(f):u>0&&(o+=".");if(u>0)for(;u--;o+="0");}return n.s<0&&n.c[0]?"-"+o:o}function o(e,n,t,r,i,s){if(d){var o,l=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFraction","divToInt"][S?0>S?-S:S:0>1/S?1:0]+"()",u=O?" out of range":" not a"+(i?" non-zero":"n")+" integer";throw u=([l+" number type has more than 15 significant digits",l+" not a base "+t+" number",l+" base"+u,l+" not a number"][n]||t+"() "+n+(s?" not a boolean or binary digit":u+(r?" or not ["+(O?" negative, positive":" integer, integer")+" ]":"")))+": "+e,O=S=0,o=new Error(u),o.name="BigNumber Error",o}}function l(e,n,t,r){var i,s,o,l,u,f,c,a,h=y;if(a=e.c){e:{for(i=1,l=a[0];l>=10;l/=10,i++);if(s=n-i,0>s)s+=_,o=n,u=a[f=0],c=u/h[i-o-1]%10|0;else if(f=Math.ceil((s+1)/_),f>=a.length){if(!r)break e;for(;a.length<=f;a.push(0));u=c=0,i=1,s%=_,o=s-_+1}else{for(u=l=a[f],i=1;l>=10;l/=10,i++);s%=_,o=s-_+i,c=0>o?0:u/h[i-o-1]%10|0}if(r=r||0>n||null!=a[f+1]||(0>o?u:u%h[i-o-1]),r=4>t?(c||r)&&(0==t||t==(e.s<0?3:2)):c>5||5==c&&(4==t||r||6==t&&(s>0?o>0?u/h[i-o]:0:a[f-1])%10&1||t==(e.s<0?8:7)),1>n||!a[0])return a.length=0,r?(n-=e.e+1,a[0]=h[n%_],e.e=-n||0):a[0]=e.e=0,e;if(0==s?(a.length=f,l=1,f--):(a.length=f+1,l=h[_-s],a[f]=o>0?E(u/h[i-o]%h[o])*l:0),r)for(;;){if(0==f){for(s=1,o=a[0];o>=10;o/=10,s++);for(o=a[0]+=l,l=1;o>=10;o/=10,l++);s!=l&&(e.e++,a[0]==F&&(a[0]=1));break}if(a[f]+=l,a[f]!=F)break;a[f--]=0,l=1}for(s=a.length;0===a[--s];a.pop());}e.e>m?e.c=e.e=null:e.e<p&&(e.c=[e.e=0])}return e}var u=1e9,f=1e6,c=20,a=4,h=-7,g=21,p=-u,m=u,d=!0,v=parseInt,w={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0},N=e.prototype,b="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",O,S=0,E=Math.floor,A=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,R=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},F=1e14,_=14,x=1e7,y=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],I=new e(1);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.config=function(){var e,n,t=0,r={},i=arguments,s=i[0],l="config",f=function(e,n,t){return!((O=n>e||e>t)||v(e)!=e&&0!==e)},N=s&&"object"==typeof s?function(){return s.hasOwnProperty(n)?null!=(e=s[n]):void 0}:function(){return i.length>t?null!=(e=i[t++]):void 0};if(N(n="DECIMAL_PLACES")&&(f(e,0,u)?c=0|e:o(e,n,l)),r[n]=c,N(n="ROUNDING_MODE")&&(f(e,0,8)?a=0|e:o(e,n,l)),r[n]=a,N(n="EXPONENTIAL_AT")&&(f(e,-u,u)?h=-(g=~~(0>e?-e:+e)):!O&&e&&f(e[0],-u,0)&&f(e[1],0,u)?(h=~~e[0],g=~~e[1]):o(e,n,l,1)),r[n]=[h,g],N(n="RANGE")&&(f(e,-u,u)&&~~e?p=-(m=~~(0>e?-e:+e)):!O&&e&&f(e[0],-u,-1)&&f(e[1],1,u)?(p=~~e[0],m=~~e[1]):o(e,n,l,1,1)),r[n]=[p,m],N(n="ERRORS")&&(e===!!e||1===e||0===e?(O=S=0,v=(d=!!e)?parseInt:parseFloat):o(e,n,l,0,0,1)),r[n]=d,N(n="FORMAT"))if("object"==typeof e)w=e;else if(d)throw r=new Error(l+"() "+n+" not an object: "+e),r.name="BigNumber Error",r;return r[n]=w,r};var D=function(){function n(e,n,t){var r,i,s,o,l=0,u=e.length,f=n%x,c=n/x|0;for(e=e.slice();u--;)s=e[u]%x,o=e[u]/x|0,r=c*s+o*f,i=f*s+r%x*x+l,l=(i/t|0)+(r/x|0)+c*o,e[u]=i%t;return l&&e.unshift(l),e}function t(e,n,t,r){var i,s;if(t!=r)s=t>r?1:-1;else for(i=s=0;t>i;i++)if(e[i]!=n[i]){s=e[i]>n[i]?1:-1;break}return s}function r(e,n,t,r){for(var i=0;t--;)e[t]-=i,i=e[t]<n[t]?1:0,e[t]=i*r+e[t]-n[t];for(;!e[0]&&e.length>1;e.shift());}return function(i,s,o,u,f){var c,a,h,g,p,m,d,v,w,N,b,O,S,A,R,x,y,I=i.s==s.s?1:-1,D=i.c,L=s.c;if(!(D&&D[0]&&L&&L[0]))return new e(i.s&&s.s&&(D?!L||D[0]!=L[0]:L)?D&&0==D[0]||!L?0*I:I/0:0/0);for(v=new e(I),w=v.c=[],a=i.e-s.e,I=o+a+1,f||(f=F,A=i.e/_,h=0|A,a=(A>0||A===h?h:h-1)-(x=s.e/_,h=0|x,x>0||x===h?h:h-1),I=I/_|0),h=0;L[h]==(D[h]||0);h++);if(L[h]>(D[h]||0)&&a--,0>I)w.push(1),g=!0;else{for(A=D.length,x=L.length,h=0,I+=2,p=E(f/(L[0]+1)),p>1&&(L=n(L,p,f),D=n(D,p,f),x=L.length,A=D.length),S=x,N=D.slice(0,x),b=N.length;x>b;N[b++]=0);y=L.slice(),y.unshift(0),R=L[0],L[1]>=f/2&&R++;do p=0,c=t(L,N,x,b),0>c?(O=N[0],x!=b&&(O=O*f+(N[1]||0)),p=E(O/R),p>1?(p>=f&&(p=f-1),m=n(L,p,f),d=m.length,b=N.length,c=t(m,N,d,b),1==c&&(p--,r(m,d>x?y:L,d,f))):(0==p&&(c=p=1),m=L.slice()),d=m.length,b>d&&m.unshift(0),r(N,m,b,f),-1==c&&(b=N.length,c=t(L,N,x,b),1>c&&(p++,r(N,b>x?y:L,b,f))),b=N.length):0===c&&(p++,N=[0]),w[h++]=p,c&&N[0]?N[b++]=D[S]||0:(N=[D[S]],b=1);while((S++<A||null!=N[0])&&I--);g=null!=N[0],w[0]||w.shift()}if(f==F){for(h=1,I=w[0];I>=10;I/=10,h++);l(v,o+(v.e=h+a*_-1)+1,u,g)}else v.e=a,v.r=+g;return v}}();return N.absoluteValue=N.abs=function(){var n=new e(this);return n.s<0&&(n.s=1),n},N.ceil=function(){return l(new e(this),this.e+1,2)},N.comparedTo=N.cmp=function(n,t){var r,i=this,s=i.c,o=(S=-S,n=new e(n,t)).c,l=i.s,u=n.s,f=i.e,c=n.e;if(!l||!u)return null;if(r=s&&!s[0],t=o&&!o[0],r||t)return r?t?0:-u:l;if(l!=u)return l;if(r=0>l,t=f==c,!s||!o)return t?0:!s^r?1:-1;if(!t)return f>c^r?1:-1;for(l=-1,u=(f=s.length)<(c=o.length)?f:c;++l<u;)if(s[l]!=o[l])return s[l]>o[l]^r?1:-1;return f==c?0:f>c^r?1:-1},N.decimalPlaces=N.dp=function(){var e,n,t=this.c;if(!t)return null;if(e=((n=t.length-1)-E(this.e/_))*_,n=t[n])for(;n%10==0;n/=10,e--);return 0>e&&(e=0),e},N.dividedBy=N.div=function(n,t){return S=2,D(this,new e(n,t),c,a)},N.dividedToIntegerBy=N.divToInt=function(n,t){return S=13,D(this,new e(n,t),0,1)},N.equals=N.eq=function(e,n){return S=3,0===this.cmp(e,n)},N.floor=function(){return l(new e(this),this.e+1,3)},N.greaterThan=N.gt=function(e,n){return S=4,this.cmp(e,n)>0},N.greaterThanOrEqualTo=N.gte=function(e,n){return S=5,1==(n=this.cmp(e,n))||0===n},N.isFinite=function(){return!!this.c},N.isInteger=N.isInt=function(){return!!this.c&&E(this.e/_)>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(e,n){return S=6,this.cmp(e,n)<0},N.lessThanOrEqualTo=N.lte=function(e,n){return S=7,-1==(n=this.cmp(e,n))||0===n},N.minus=function(t,r){var i,s,o,l,u=this,f=u.s;if(S=8,t=new e(t,r),r=t.s,!f||!r)return new e(0/0);if(f!=r)return t.s=-r,u.plus(t);var c=u.e/_,h=t.e/_,g=u.c,p=t.c;if(!c||!h){if(!g||!p)return g?(t.s=-r,t):new e(p?u:0/0);if(!g[0]||!p[0])return p[0]?(t.s=-r,t):new e(g[0]?u:3==a?-0:0)}if(i=0|c,c=c>0||c===i?i:i-1,i=0|h,h=h>0||h===i?i:i-1,g=g.slice(),f=c-h){for((l=0>f)?(f=-f,o=g):(h=c,o=p),o.reverse(),r=f;r--;o.push(0));o.reverse()}else for(s=(l=(f=g.length)<(r=p.length))?f:r,f=r=0;s>r;r++)if(g[r]!=p[r]){l=g[r]<p[r];break}if(l&&(o=g,g=p,p=o,t.s=-t.s),r=(s=p.length)-(i=g.length),r>0)for(;r--;g[i++]=0);for(r=F-1;s>f;){if(g[--s]<p[s]){for(i=s;i&&!g[--i];g[i]=r);--g[i],g[s]+=F}g[s]-=p[s]}for(;0==g[0];g.shift(),--h);return g[0]?n(t,g,h):(t.s=3==a?-1:1,t.c=[t.e=0],t)},N.modulo=N.mod=function(n,t){S=9;var r=this,i=r.c,s=(n=new e(n,t)).c,o=r.s,l=n.s;return t=!o||!l||s&&!s[0],t||i&&!i[0]?new e(t?0/0:r):(r.s=n.s=1,t=1==n.cmp(r),r.s=o,n.s=l,t?new e(r):r.minus(D(r,n,0,1).times(n)))},N.negated=N.neg=function(){var n=new e(this);return n.s=-n.s||null,n},N.plus=function(t,r){var i,s=this,o=s.s;if(S=10,t=new e(t,r),r=t.s,!o||!r)return new e(0/0);if(o!=r)return t.s=-r,s.minus(t);var l=s.e/_,u=t.e/_,f=s.c,c=t.c;if(!l||!u){if(!f||!c)return new e(o/0);if(!f[0]||!c[0])return c[0]?t:new e(f[0]?s:0*o)}if(o=0|l,l=l>0||l===o?o:o-1,o=0|u,u=u>0||u===o?o:o-1,f=f.slice(),o=l-u){for(o>0?(u=l,i=c):(o=-o,i=f),i.reverse();o--;i.push(0));i.reverse()}for(o=f.length,r=c.length,0>o-r&&(i=c,c=f,f=i,r=o),o=0;r;)o=(f[--r]=f[r]+c[r]+o)/F|0,f[r]%=F;return o&&(f.unshift(o),++u),n(t,f,u)},N.round=function(n,t){return n=null==n||((O=0>n||n>u)||v(n)!=n)&&!o(n,"decimal places","round")?0:0|n,t=null==t||((O=0>t||t>8)||v(t)!=t&&0!==t)&&!o(t,"mode","round")?a:0|t,l(new e(this),n+this.e+1,t)},N.squareRoot=N.sqrt=function(){var n,r,i,s,o,u=this,f=u.c,h=u.s,g=u.e,p=c+4,m=new e("0.5");if(1!==h||!f||!f[0])return new e(!h||0>h&&(!f||f[0])?0/0:f?u:1/0);if(h=Math.sqrt(+u),0==h||h==1/0?(r=t(f),(r.length+g)%2==0&&(r+="0"),h=Math.sqrt(r),g=E((g+1)/2)-(0>g||g%2),h==1/0?r="1e"+g:(r=h.toExponential(),r=r.slice(0,r.indexOf("e")+1)+g),i=new e(r)):i=new e(h.toString()),i.c[0])for(g=i.e,h=g+p,3>h&&(h=0);;)if(o=i,i=m.times(o.plus(D(u,o,p,1))),t(o.c).slice(0,h)===(r=t(i.c)).slice(0,h)){if(i.e<g&&--h,r=r.slice(h-3,h+1),"9999"!=r&&(s||"4999"!=r)){(!+r||!+r.slice(1)&&"5"==r.charAt(0))&&(l(i,i.e+c+2,1),n=!i.times(i).eq(u));break}if(!s&&(l(o,o.e+c+2,0),o.times(o).eq(u))){i=o;break}p+=4,h+=4,s=1}return l(i,i.e+c+1,a,n)},N.times=function(t,r){var i,s,o,l,u,f,c,a,h,g=this,p=g.c,m=(S=11,t=new e(t,r)).c,d=g.e/_,v=t.e/_,w=g.s;if(t.s=w==(r=t.s)?1:-1,!((d||p&&p[0])&&(v||m&&m[0])))return new e(!w||!r||p&&!p[0]&&!m||m&&!m[0]&&!p?0/0:p&&m?0*t.s:t.s/0);for(s=0|d,s=(d>0||d===s?s:s-1)+(s=0|v,v>0||v===s?s:s-1),w=p.length,r=m.length,r>w&&(u=p,p=m,m=u,v=w,w=r,r=v),v=w+r,u=[];v--;u.push(0));for(d=r;--d>=0;){for(i=0,v=w+d,o=w,a=m[d]%x,h=m[d]/x|0;v>d;)f=p[--o]%x,c=p[o]/x|0,l=h*f+c*a,f=a*f+l%x*x+u[v]+i,i=(f/F|0)+(l/x|0)+h*c,u[v--]=f%F;u[v]=i}return i?++s:u.shift(),n(t,u,s)},N.toExponential=function(e){var n=this;return n.c?s(n,null==e||((O=0>e||e>u)||v(e)!=e&&0!==e)&&!o(e,"decimal places","toExponential")?null:0|e,1):n.toString()},N.toFixed=function(e){var n,t=this,r=h,i=g;return e=null==e||((O=0>e||e>u)||v(e)!=e&&0!==e)&&!o(e,"decimal places","toFixed")?null:t.e+(0|e),h=-(g=1/0),null!=e&&t.c?(n=s(t,e),t.s<0&&t.c&&(t.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace("-",""))):n=t.toString(),h=r,g=i,n},N.toFormat=function(e){var n=this;if(!n.c)return n.toString();var t,r=n.s<0,i=w.groupSeparator,s=+w.groupSize,o=+w.secondaryGroupSize,l=n.toFixed(e).split("."),u=l[0],f=l[1],c=r?u.slice(1):u,a=c.length;if(o&&(t=s,s=o,o=t,a-=t),s>0&&a>0){for(t=a%s||s,u=c.substr(0,t);a>t;t+=s)u+=i+c.substr(t,s);o>0&&(u+=i+c.slice(t)),r&&(u="-"+u)}return f?u+w.decimalSeparator+((o=+w.fractionGroupSize)?f.replace(new RegExp("\\d{"+o+"}\\B","g"),"$&"+w.fractionGroupSeparator):f):u},N.toFraction=function(n){var r,i,s,l,u,f,c,h,g,p=i=new e(I),v=c=new e(I),w=this,N=w.c,b=new e(I);if(!N)return w.toString();for(g=t(N),l=b.e=g.length-w.e-1,b.c[0]=y[(u=l%_)<0?_+u:u],(null==n||(!(S=12,f=new e(n)).s||(O=f.cmp(p)<0||!f.c)||d&&E(f.e/_)<f.c.length-1)&&!o(n,"max denominator","toFraction")||(n=f).cmp(b)>0)&&(n=l>0?b:p),u=m,m=1/0,f=new e(g),c.c[0]=0;h=D(f,b,0,1),s=i.plus(h.times(v)),1!=s.cmp(n);)i=v,v=s,p=c.plus(h.times(s=p)),c=s,b=f.minus(h.times(s=b)),f=s;return s=D(n.minus(i),v,0,1),c=c.plus(s.times(p)),i=i.plus(s.times(v)),c.s=p.s=w.s,l*=2,r=D(p,v,l,a).minus(w).abs().cmp(D(c,i,l,a).minus(w).abs())<1?[p.toString(),v.toString()]:[c.toString(),i.toString()],m=u,r},N.toNumber=function(){var e=this;return+e||(e.s?0*e.s:0/0)},N.toPower=N.pow=function(n){var t=0*n==0?~~n:n,r=new e(this),i=new e(I);if(((O=-f>n||n>f)&&(t=1*n/0)||v(n)!=n&&0!==n&&!(t=0/0))&&!o(n,"exponent","pow")||!t)return new e(Math.pow(+r,t));for(t=0>t?-t:t;1&t&&(i=i.times(r)),t>>=1,t;)r=r.times(r);return 0>n?I.div(i):i},N.toPrecision=function(e){var n=this;return null!=e&&(!(O=1>e||e>u)&&v(e)==e||o(e,"precision","toPrecision"))&&n.c?s(n,0|--e,2):n.toString()},N.toString=function(e){var n,r,l,u=this,f=u.e;if(null===f)r=u.s?"Infinity":"NaN";else{if(e==n&&(h>=f||f>=g))return s(u,n,1);if(r=t(u.c),0>f){for(;++f;r="0"+r);r="0."+r}else if(l=r.length,f>0)if(++f>l)for(f-=l;f--;r+="0");else l>f&&(r=r.slice(0,f)+"."+r.slice(f));else if(n=r.charAt(0),l>1)r=n+"."+r.slice(1);else if("0"==n)return n;if(null!=e)if((O=!(e>=2&&65>e))||e!=~~e&&d)o(e,"base","toS");else if(r=i(r,0|e,10,u.s),"0"==r)return r}return u.s<0?"-"+r:r},N.valueOf=N.toJSON=function(){return this.toString()},e}()}).call(this),"undefined"==typeof Package&&(Package={}),Package["3stack:bignumber"]={BigNumber:n}}();
+
+!function(){var e=Package.meteor.Meteor,r;(function(){r={extensions:{}};var e=r.forEach=function(e,r){if("function"==typeof e.forEach)e.forEach(r);else{var n,t=e.length;for(n=0;t>n;n++)r(e[n],n,e)}},n=function(e){return e.replace(/[_-]||\s/g,"").toLowerCase()};r.converter=function(e){var t,a,c,o=0,l=[],i=[];if("undefind"!=typeof module&&"undefined"!=typeof exports&&"undefind"!=typeof require){var u=require("fs");if(u){var p=u.readdirSync((__dirname||".")+"/extensions").filter(function(e){return~e.indexOf(".js")}).map(function(e){return e.replace(/\.js$/,"")});r.forEach(p,function(e){var t=n(e);r.extensions[t]=require("./extensions/"+e)})}}if(this.makeHtml=function(e){return t={},a={},c=[],e=e.replace(/~/g,"~T"),e=e.replace(/\$/g,"~D"),e=e.replace(/\r\n/g,"\n"),e=e.replace(/\r/g,"\n"),e="\n\n"+e+"\n\n",e=D(e),e=e.replace(/^[ \t]+$/gm,""),r.forEach(l,function(r){e=g(r,e)}),e=C(e),e=d(e),e=s(e),e=m(e),e=j(e),e=e.replace(/~D/g,"$$"),e=e.replace(/~T/g,"~"),r.forEach(i,function(r){e=g(r,e)}),e},e&&e.extensions){var f=this;r.forEach(e.extensions,function(e){if("string"==typeof e&&(e=r.extensions[n(e)]),"function"!=typeof e)throw"Extension '"+e+"' could not be loaded. It was either not found or is not a valid extension.";r.forEach(e(f),function(e){e.type?"language"===e.type||"lang"===e.type?l.push(e):("output"===e.type||"html"===e.type)&&i.push(e):i.push(e)})})}var g=function(e,r){if(e.regex){var n=new RegExp(e.regex,"g");return r.replace(n,e.replace)}return e.filter?e.filter(r):void 0},s=function(e){return e+="~0",e=e.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,function(e,r,n,c,o){return r=r.toLowerCase(),t[r]=A(n),c?c+o:(o&&(a[r]=o.replace(/"/g,"&quot;")),"")}),e=e.replace(/~0/,"")},d=function(e){e=e.replace(/\n/g,"\n\n");var r="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|section|header|footer|nav|article|aside",n="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";return e=e.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,h),e=e.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,h),e=e.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,h),e=e.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,h),e=e.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,h),e=e.replace(/\n\n/g,"\n")},h=function(e,r){var n=r;return n=n.replace(/\n\n/g,"\n"),n=n.replace(/^\n/,""),n=n.replace(/\n+$/g,""),n="\n\n~K"+(c.push(n)-1)+"K\n\n"},m=function(e){e=E(e);var r=q("<hr />");return e=e.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,r),e=e.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,r),e=e.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,r),e=_(e),e=S(e),e=P(e),e=d(e),e=z(e)},v=function(e){return e=K(e),e=$(e),e=B(e),e=x(e),e=w(e),e=M(e),e=A(e),e=L(e),e=e.replace(/ +\n/g," <br />\n")},$=function(e){var r=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;return e=e.replace(r,function(e){var r=e.replace(/(.)<\/?code>(?=.)/g,"$1`");return r=I(r,"\\`*_")})},w=function(e){return e=e.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,k),e=e.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,k),e=e.replace(/(\[([^\[\]]+)\])()()()()()/g,k)},k=function(e,r,n,c,o,l,i,u){void 0==u&&(u="");var p=r,f=n,g=c.toLowerCase(),s=o,d=u;if(""==s)if(""==g&&(g=f.toLowerCase().replace(/ ?\n/g," ")),s="#"+g,void 0!=t[g])s=t[g],void 0!=a[g]&&(d=a[g]);else{if(!(p.search(/\(\s*\)$/m)>-1))return p;s=""}s=I(s,"*_");var h='<a href="'+s+'"';return""!=d&&(d=d.replace(/"/g,"&quot;"),d=I(d,"*_"),h+=' title="'+d+'"'),h+=">"+f+"</a>"},x=function(e){return e=e.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,y),e=e.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,y)},y=function(e,r,n,c,o,l,i,u){var p=r,f=n,g=c.toLowerCase(),s=o,d=u;if(d||(d=""),""==s){if(""==g&&(g=f.toLowerCase().replace(/ ?\n/g," ")),s="#"+g,void 0==t[g])return p;s=t[g],void 0!=a[g]&&(d=a[g])}f=f.replace(/"/g,"&quot;"),s=I(s,"*_");var h='<img src="'+s+'" alt="'+f+'"';return d=d.replace(/"/g,"&quot;"),d=I(d,"*_"),h+=' title="'+d+'"',h+=" />"},E=function(e){function r(e){return e.replace(/[^\w]/g,"").toLowerCase()}return e=e.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(e,n){return q('<h1 id="'+r(n)+'">'+v(n)+"</h1>")}),e=e.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(e,n){return q('<h2 id="'+r(n)+'">'+v(n)+"</h2>")}),e=e.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(e,n,t){var a=n.length;return q("<h"+a+' id="'+r(t)+'">'+v(t)+"</h"+a+">")})},b,_=function(e){e+="~0";var r=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return o?e=e.replace(r,function(e,r,n){var t=r,a=n.search(/[*+-]/g)>-1?"ul":"ol";t=t.replace(/\n{2,}/g,"\n\n\n");var c=b(t);return c=c.replace(/\s+$/,""),c="<"+a+">"+c+"</"+a+">\n"}):(r=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,e=e.replace(r,function(e,r,n,t){var a=r,c=n,o=t.search(/[*+-]/g)>-1?"ul":"ol",c=c.replace(/\n{2,}/g,"\n\n\n"),l=b(c);return l=a+"<"+o+">\n"+l+"</"+o+">\n"})),e=e.replace(/~0/,"")};b=function(e){return o++,e=e.replace(/\n{2,}$/,"\n"),e+="~0",e=e.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(e,r,n,t,a){var c=a,o=r,l=n;return o||c.search(/\n{2,}/)>-1?c=m(H(c)):(c=_(H(c)),c=c.replace(/\n$/,""),c=v(c)),"<li>"+c+"</li>\n"}),e=e.replace(/~0/g,""),o--,e};var S=function(e){return e+="~0",e=e.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(e,r,n){var t=r,a=n;return t=T(H(t)),t=D(t),t=t.replace(/^\n+/g,""),t=t.replace(/\n+$/g,""),t="<pre><code>"+t+"\n</code></pre>",q(t)+a}),e=e.replace(/~0/,"")},C=function(e){return e+="~0",e=e.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(e,r,n){var t=r,a=n;return a=T(a),a=D(a),a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,""),a="<pre><code"+(t?' class="'+t+'"':"")+">"+a+"\n</code></pre>",q(a)}),e=e.replace(/~0/,"")},q=function(e){return e=e.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(c.push(e)-1)+"K\n\n"},K=function(e){return e=e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(e,r,n,t,a){var c=t;return c=c.replace(/^([ \t]*)/g,""),c=c.replace(/[ \t]*$/g,""),c=T(c),r+"<code>"+c+"</code>"})},T=function(e){return e=e.replace(/&/g,"&amp;"),e=e.replace(/</g,"&lt;"),e=e.replace(/>/g,"&gt;"),e=I(e,"*_{}[]\\",!1)},L=function(e){return e=e.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>"),e=e.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>")},P=function(e){return e=e.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(e,r){var n=r;return n=n.replace(/^[ \t]*>[ \t]?/gm,"~0"),n=n.replace(/~0/g,""),n=n.replace(/^[ \t]+$/gm,""),n=m(n),n=n.replace(/(^|\n)/g,"$1 "),n=n.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(e,r){var n=r;return n=n.replace(/^ /gm,"~0"),n=n.replace(/~0/g,"")}),q("<blockquote>\n"+n+"\n</blockquote>")})},z=function(e){e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,"");for(var r=e.split(/\n{2,}/g),n=[],t=r.length,a=0;t>a;a++){var o=r[a];o.search(/~K(\d+)K/g)>=0?n.push(o):o.search(/\S/)>=0&&(o=v(o),o=o.replace(/^([ \t]*)/g,"<p>"),o+="</p>",n.push(o))}t=n.length;for(var a=0;t>a;a++)for(;n[a].search(/~K(\d+)K/)>=0;){var l=c[RegExp.$1];l=l.replace(/\$/g,"$$$$"),n[a]=n[a].replace(/~K\d+K/,l)}return n.join("\n\n")},A=function(e){return e=e.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;"),e=e.replace(/<(?![a-z\/?\$!])/gi,"&lt;")},B=function(e){return e=e.replace(/\\(\\)/g,O),e=e.replace(/\\([`*_{}\[\]()>#+-.!])/g,O)},M=function(e){return e=e.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'<a href="$1">$1</a>'),e=e.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(e,r){return R(j(r))})},R=function(e){var r=[function(e){return"&#"+e.charCodeAt(0)+";"},function(e){return"&#x"+e.charCodeAt(0).toString(16)+";"},function(e){return e}];return e="mailto:"+e,e=e.replace(/./g,function(e){if("@"==e)e=r[Math.floor(2*Math.random())](e);else if(":"!=e){var n=Math.random();e=n>.9?r[2](e):n>.45?r[1](e):r[0](e)}return e}),e='<a href="'+e+'">'+e+"</a>",e=e.replace(/">.+:/g,'">')},j=function(e){return e=e.replace(/~E(\d+)E/g,function(e,r){var n=parseInt(r);return String.fromCharCode(n)})},H=function(e){return e=e.replace(/^(\t|[ ]{1,4})/gm,"~0"),e=e.replace(/~0/g,"")},D=function(e){return e=e.replace(/\t(?=\t)/g," "),e=e.replace(/\t/g,"~A~B"),e=e.replace(/~B(.+?)~A/g,function(e,r,n){for(var t=r,a=4-t.length%4,c=0;a>c;c++)t+=" ";return t}),e=e.replace(/~A/g," "),e=e.replace(/~B/g,"")},I=function(e,r,n){var t="(["+r.replace(/([\[\]\\])/g,"\\$1")+"])";n&&(t="\\\\"+t);var a=new RegExp(t,"g");return e=e.replace(a,O)},O=function(e,r){var n=r.charCodeAt(0);return"~E"+n+"E"}},"undefined"!=typeof module&&(module.exports=r),"function"==typeof define&&define.amd&&define("showdown",function(){return r})}).call(this),function(){if(Package.templating){var e=Package.templating.Template,n=Package.blaze.Blaze,t=Package.htmljs.HTML;n.Template.registerHelper("markdown",new e("markdown",function(){var e=this,a="";e.templateContentBlock&&(a=n._toText(e.templateContentBlock,t.TEXTMODE.STRING));var c=new r.converter;return t.Raw(c.makeHtml(a))}))}}.call(this),"undefined"==typeof Package&&(Package={}),Package.markdown={Showdown:r}}();
+
+!function(){var e=Package.meteor.Meteor,n;(function(){(function(){function e(e){this._value=e}function n(e,n,i,t){var l=Math.pow(10,n),o,r;return r=(i(e*l)/l).toFixed(n),t&&(o=new RegExp("0{1,"+t+"}$"),r=r.replace(o,"")),r}function i(e,n,i){var t;return t=n.indexOf("$")>-1?l(e,n,i):n.indexOf("%")>-1?o(e,n,i):n.indexOf(":")>-1?r(e,n):a(e._value,n,i)}function t(e,n){var i=n,t,l,o,r,a=["KB","MB","GB","TB","PB","EB","ZB","YB"],d=!1,s;if(n.indexOf(":")>-1)e._value=u(n);else if(n===b)e._value=0;else{for("."!==h[p].delimiters.decimal&&(n=n.replace(/\./g,"").replace(h[p].delimiters.decimal,".")),t=new RegExp("[^a-zA-Z]"+h[p].abbreviations.thousand+"(?:\\)|(\\"+h[p].currency.symbol+")?(?:\\))?)?$"),l=new RegExp("[^a-zA-Z]"+h[p].abbreviations.million+"(?:\\)|(\\"+h[p].currency.symbol+")?(?:\\))?)?$"),o=new RegExp("[^a-zA-Z]"+h[p].abbreviations.billion+"(?:\\)|(\\"+h[p].currency.symbol+")?(?:\\))?)?$"),r=new RegExp("[^a-zA-Z]"+h[p].abbreviations.trillion+"(?:\\)|(\\"+h[p].currency.symbol+")?(?:\\))?)?$"),s=0;s<=a.length&&!(d=n.indexOf(a[s])>-1?Math.pow(1024,s+1):!1);s++);e._value=(d?d:1)*(i.match(t)?Math.pow(10,3):1)*(i.match(l)?Math.pow(10,6):1)*(i.match(o)?Math.pow(10,9):1)*(i.match(r)?Math.pow(10,12):1)*(n.indexOf("%")>-1?.01:1)*((n.split("-").length+Math.min(n.split("(").length-1,n.split(")").length-1))%2?1:-1)*Number(n.replace(/[^0-9\.]+/g,"")),e._value=d?Math.ceil(e._value):e._value}return e._value}function l(e,n,i){var t=n.indexOf("$"),l=n.indexOf("("),o=n.indexOf("-"),r="",u,d;return n.indexOf(" $")>-1?(r=" ",n=n.replace(" $","")):n.indexOf("$ ")>-1?(r=" ",n=n.replace("$ ","")):n=n.replace("$",""),d=a(e._value,n,i),1>=t?d.indexOf("(")>-1||d.indexOf("-")>-1?(d=d.split(""),u=1,(l>t||o>t)&&(u=0),d.splice(u,0,h[p].currency.symbol+r),d=d.join("")):d=h[p].currency.symbol+r+d:d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,r+h[p].currency.symbol),d=d.join("")):d=d+r+h[p].currency.symbol,d}function o(e,n,i){var t="",l,o=100*e._value;return n.indexOf(" %")>-1?(t=" ",n=n.replace(" %","")):n=n.replace("%",""),l=a(o,n,i),l.indexOf(")")>-1?(l=l.split(""),l.splice(-1,0,t+"%"),l=l.join("")):l=l+t+"%",l}function r(e){var n=Math.floor(e._value/60/60),i=Math.floor((e._value-60*n*60)/60),t=Math.round(e._value-60*n*60-60*i);return n+":"+(10>i?"0"+i:i)+":"+(10>t?"0"+t:t)}function u(e){var n=e.split(":"),i=0;return 3===n.length?(i+=60*Number(n[0])*60,i+=60*Number(n[1]),i+=Number(n[2])):2===n.length&&(i+=60*Number(n[0]),i+=Number(n[1])),Number(i)}function a(e,i,t){var l=!1,o=!1,r=!1,u="",a=!1,d=!1,s=!1,m=!1,c=!1,f="",g="",y=Math.abs(e),v=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],w,x,M,O,_,k,$="",B=!1;if(0===e&&null!==b)return b;if(i.indexOf("(")>-1?(l=!0,i=i.slice(1,-1)):i.indexOf("+")>-1&&(o=!0,i=i.replace(/\+/g,"")),i.indexOf("a")>-1&&(a=i.indexOf("aK")>=0,d=i.indexOf("aM")>=0,s=i.indexOf("aB")>=0,m=i.indexOf("aT")>=0,c=a||d||s||m,i.indexOf(" a")>-1?(u=" ",i=i.replace(" a","")):i=i.replace("a",""),y>=Math.pow(10,12)&&!c||m?(u+=h[p].abbreviations.trillion,e/=Math.pow(10,12)):y<Math.pow(10,12)&&y>=Math.pow(10,9)&&!c||s?(u+=h[p].abbreviations.billion,e/=Math.pow(10,9)):y<Math.pow(10,9)&&y>=Math.pow(10,6)&&!c||d?(u+=h[p].abbreviations.million,e/=Math.pow(10,6)):(y<Math.pow(10,6)&&y>=Math.pow(10,3)&&!c||a)&&(u+=h[p].abbreviations.thousand,e/=Math.pow(10,3))),i.indexOf("b")>-1)for(i.indexOf(" b")>-1?(f=" ",i=i.replace(" b","")):i=i.replace("b",""),M=0;M<=v.length;M++)if(w=Math.pow(1024,M),x=Math.pow(1024,M+1),e>=w&&x>e){f+=v[M],w>0&&(e/=w);break}return i.indexOf("o")>-1&&(i.indexOf(" o")>-1?(g=" ",i=i.replace(" o","")):i=i.replace("o",""),g+=h[p].ordinal(e)),i.indexOf("[.]")>-1&&(r=!0,i=i.replace("[.]",".")),O=e.toString().split(".")[0],_=i.split(".")[1],k=i.indexOf(","),_?(_.indexOf("[")>-1?(_=_.replace("]",""),_=_.split("["),$=n(e,_[0].length+_[1].length,t,_[1].length)):$=n(e,_.length,t),O=$.split(".")[0],$=$.split(".")[1].length?h[p].delimiters.decimal+$.split(".")[1]:"",r&&0===Number($.slice(1))&&($="")):O=n(e,null,t),O.indexOf("-")>-1&&(O=O.slice(1),B=!0),k>-1&&(O=O.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+h[p].delimiters.thousands)),0===i.indexOf(".")&&(O=""),(l&&B?"(":"")+(!l&&B?"-":"")+(!B&&o?"+":"")+O+$+(g?g:"")+(u?u:"")+(f?f:"")+(l&&B?")":"")}function d(e,n){h[e]=n}function s(e){var n=e.toString().split(".");return n.length<2?1:Math.pow(10,n[1].length)}function m(){var e=Array.prototype.slice.call(arguments);return e.reduce(function(e,n){var i=s(e),t=s(n);return i>t?i:t},-1/0)}var c,f="1.5.3",h={},p="en",b=null,g="0,0",y="undefined"!=typeof module&&module.exports;c=function(n){return c.isNumeral(n)?n=n.value():0===n||"undefined"==typeof n?n=0:Number(n)||(n=c.fn.unformat(n)),new e(Number(n))},c.version=f,c.isNumeral=function(n){return n instanceof e},c.language=function(e,n){if(!e)return p;if(e=e.toLowerCase(),e&&!n){if(!h[e])throw new Error("Unknown language : "+e);p=e}return(n||!h[e])&&d(e,n),c},c.languageData=function(e){if(!e)return h[p];if(!h[e])throw new Error("Unknown language : "+e);return h[e]},c.language("en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){var n=e%10;return 1===~~(e%100/10)?"th":1===n?"st":2===n?"nd":3===n?"rd":"th"},currency:{symbol:"$"}}),c.zeroFormat=function(e){b="string"==typeof e?e:null},c.defaultFormat=function(e){g="string"==typeof e?e:"0.0"},c.validate=function(e,n){var i,t,l,o,r,u,a,d;if("string"!=typeof e&&(e+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",e)),e=e.trim(),e.match(/^\d+$/))return!0;if(""===e)return!1;try{a=c.languageData(n)}catch(s){a=c.languageData(c.language())}return l=a.currency.symbol,r=a.abbreviations,i=a.delimiters.decimal,t="."===a.delimiters.thousands?"\\.":a.delimiters.thousands,d=e.match(/^[^\d]+/),null!==d&&(e=e.substr(1),d[0]!==l)?!1:(d=e.match(/[^\d]+$/),null!==d&&(e=e.slice(0,-1),d[0]!==r.thousand&&d[0]!==r.million&&d[0]!==r.billion&&d[0]!==r.trillion)?!1:(u=new RegExp(t+"{2}"),e.match(/[^\d.,]/g)?!1:(o=e.split(i),o.length>2?!1:o.length<2?!!o[0].match(/^\d+.*\d$/)&&!o[0].match(u):1===o[0].length?!!o[0].match(/^\d+$/)&&!o[0].match(u)&&!!o[1].match(/^\d+$/):!!o[0].match(/^\d+.*\d$/)&&!o[0].match(u)&&!!o[1].match(/^\d+$/))))},"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(e,n){"use strict";if(null===this||"undefined"==typeof this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof e)throw new TypeError(e+" is not a function");var i,t,l=this.length>>>0,o=!1;for(1<arguments.length&&(t=n,o=!0),i=0;l>i;++i)this.hasOwnProperty(i)&&(o?t=e(t,this[i],i,this):(t=this[i],o=!0));if(!o)throw new TypeError("Reduce of empty array with no initial value");return t}),c.fn=e.prototype={clone:function(){return c(this)},format:function(e,n){return i(this,e?e:g,void 0!==n?n:Math.round)},unformat:function(e){return"[object Number]"===Object.prototype.toString.call(e)?e:t(this,e?e:g)},value:function(){return this._value},valueOf:function(){return this._value},set:function(e){return this._value=Number(e),this},add:function(e){function n(e,n,t,l){return e+i*n}var i=m.call(null,this._value,e);return this._value=[this._value,e].reduce(n,0)/i,this},subtract:function(e){function n(e,n,t,l){return e-i*n}var i=m.call(null,this._value,e);return this._value=[e].reduce(n,this._value*i)/i,this},multiply:function(e){function n(e,n,i,t){var l=m(e,n);return e*l*n*l/(l*l)}return this._value=[this._value,e].reduce(n,1),this},divide:function(e){function n(e,n,i,t){var l=m(e,n);return e*l/(n*l)}return this._value=[this._value,e].reduce(n),this},difference:function(e){return Math.abs(c(this._value).subtract(e).value())}},y&&(module.exports=c),"undefined"==typeof ender&&(this.numeral=c),"function"==typeof define&&define.amd&&define([],function(){return c})}).call(this)}).call(this),function(){!function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:" mln",billion:" mld",trillion:" bln"},ordinal:function(e){var n=e%100;return 0!==e&&1>=n||8===n||n>=20?"ste":"de"},currency:{symbol:"€ "}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("be-nl",e)}(),function(){var e={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十亿",trillion:"兆"},ordinal:function(){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("chs",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"Kč"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("cs",e)}(),function(){var e={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mio",billion:"mia",trillion:"b"},ordinal:function(){return"."},currency:{symbol:"DKK"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("da-dk",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de-ch",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("de",e)}(),function(){var e={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){var n=e%10;return 1===~~(e%100/10)?"th":1===n?"st":2===n?"nd":3===n?"rd":"th"},currency:{symbol:"£"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("en-gb",e)}(),function(){var e={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(e){var n=e%10;return 1===n||3===n?"er":2===n?"do":7===n||0===n?"mo":8===n?"vo":9===n?"no":"to"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("es",e)}(),function(){var e={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mm",billion:"b",trillion:"t"},ordinal:function(e){var n=e%10;return 1===n||3===n?"er":2===n?"do":7===n||0===n?"mo":8===n?"vo":9===n?"no":"to"},currency:{symbol:"$"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("es",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tuh",million:" mln",billion:" mld",trillion:" trl"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("et",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fi",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"M",billion:"G",trillion:"T"},ordinal:function(e){return 1===e?"er":"e"},currency:{symbol:"$"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr-CA",e)}(),function(){var e={delimiters:{thousands:"'",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){return 1===e?"er":"e"},currency:{symbol:"CHF"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr-ch",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){return 1===e?"er":"e"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("fr",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"E",million:"M",billion:"Mrd",trillion:"T"},ordinal:function(){return"."},currency:{symbol:" Ft"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("hu",e)}(),function(){var e={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mila",million:"mil",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("it",e)}(),function(){var e={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"千",million:"百万",billion:"十億",trillion:"兆"},ordinal:function(){return"."},currency:{symbol:"¥"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ja",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:" tūkst.",million:" milj.",billion:" mljrd.",trillion:" trilj."},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("lv",e)}(),function(){var e={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"k",million:"mln",billion:"mrd",trillion:"bln"},ordinal:function(e){var n=e%100;return 0!==e&&1>=n||8===n||n>=20?"ste":"de"},currency:{symbol:"€ "}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("nl-nl",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tys.",million:"mln",billion:"mld",trillion:"bln"},ordinal:function(){return"."},currency:{symbol:"PLN"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pl",e)}(),function(){var e={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"mil",million:"milhões",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"R$"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pt-br",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(){return"º"},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("pt-pt",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"₴"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ru-UA",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тыс.",million:"млн",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"руб."}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("ru",e)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"tis.",million:"mil.",billion:"b",trillion:"t"},ordinal:function(){return"."},currency:{symbol:"€"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("sk",e)}(),function(){var e={delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"พัน",million:"ล้าน",billion:"พันล้าน",trillion:"ล้านล้าน"},ordinal:function(){return"."},currency:{symbol:"฿"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("th",e)}(),function(){var e={1:"'inci",5:"'inci",8:"'inci",70:"'inci",80:"'inci",2:"'nci",7:"'nci",20:"'nci",50:"'nci",3:"'üncü",4:"'üncü",100:"'üncü",6:"'ncı",9:"'uncu",10:"'uncu",30:"'uncu",60:"'ıncı",90:"'ıncı"},n={delimiters:{thousands:".",decimal:","},abbreviations:{thousand:"bin",million:"milyon",billion:"milyar",trillion:"trilyon"},ordinal:function(n){if(0===n)return"'ıncı";var i=n%10,t=n%100-i,l=n>=100?100:null;return e[i]||e[t]||e[l]},currency:{symbol:"₺"}};"undefined"!=typeof module&&module.exports&&(module.exports=n),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("tr",n)}(),function(){var e={delimiters:{thousands:" ",decimal:","},abbreviations:{thousand:"тис.",million:"млн",billion:"млрд",trillion:"блн"},ordinal:function(){return""},currency:{symbol:"₴"}};"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&this.numeral&&this.numeral.language&&this.numeral.language("uk-UA",e)}()}.call(this),function(){e.isClient&&(n=window.numeral,delete window.numeral),e.isServer&&(n=Npm.require("numeral"))}.call(this),"undefined"==typeof Package&&(Package={}),Package["numeral:numeral"]={numeral:n}}();
+
+!function(){var e=Package.meteor.Meteor,a=Package["3stack:bignumber"].BigNumber,i;(function(){i={},i.fromWei=function(e,i){if(!e)return e;switch("string"==typeof e&&0===e.indexOf("0x")&&(e=web3.toDecimal(e)),e instanceof a||(e=new a(e.toString())),i=i.toLowerCase()){case"kwei":case"ada":e=e.dividedBy(1e3);break;case"mwei":case"babbage":e=e.dividedBy(1e6);break;case"gwei":case"schannon":e=e.dividedBy(1e9);break;case"szabo":e=e.dividedBy(1e12);break;case"finney":e=e.dividedBy(1e15);break;case"ether":e=e.dividedBy(1e18);break;case"kether":case"grand":case"einstein":e=e.dividedBy(1e21);break;case"mether":e=e.dividedBy(1e24);break;case"gether":e=e.dividedBy(1e27);break;case"tether":e=e.dividedBy(1e30)}return e.toNumber()},i.toWei=function(e,i){if(!e)return e;switch("string"==typeof e&&0===e.indexOf("0x")&&(e=web3.toDecimal(e)),e instanceof a||(e=new a(e.toString())),i=i.toLowerCase()){case"kwei":case"ada":e=e.times(1e3);break;case"mwei":case"babbage":e=e.times(1e6);break;case"gwei":case"schannon":e=e.times(1e9);break;case"szabo":e=e.times(1e12);break;case"finney":e=e.times(1e15);break;case"ether":e=e.times(1e18);break;case"kether":case"grand":case"einstein":e=e.times(1e21);break;case"mether":e=e.times(1e24);break;case"gether":e=e.times(1e27);break;case"tether":e=e.times(1e30)}return e.toNumber()},i.isAddress=function(e){return 0===e.indexOf("0x")&&42!=e.length?!1:-1===e.indexOf("0x")&&40!=e.length?!1:/^\w+$/.test(e)}}).call(this),"undefined"==typeof Package&&(Package={}),Package["ethereum:tools"]={EthTools:i}}();
+
+!function(){var e=Package.meteor.Meteor;(function(){!function(){function e(e){c=0;for(var t=0;t<e.length;t+=2){var r=e.charCodeAt(t)<<8|e.charCodeAt(t+1);c^=r}}function t(){var e=(Math.sin(c++)+1)/2,t=1e4*e;return e=t-Math.floor(t)}function r(){var e=Math.floor(360*t()),r=50*t()+50+"%",a=60*t()+20+"%",n="hsl("+e+","+r+","+a+")";return n}function a(e){for(var r=e,a=e,n=Math.ceil(r/2),o=r-n,c=[],i=0;a>i;i++){for(var l=[],f=0;n>f;f++)l[f]=t()>=.5;var h=l.slice(0,o);h.reverse(),l=l.concat(h);for(var s=0;s<l.length;s++)c.push(l[s])}return c}function n(e,t,r,a){var n=document.createElement("canvas"),o=Math.sqrt(e.length);n.width=n.height=o*r;var c=n.getContext("2d");c.fillStyle=a,c.fillRect(0,0,n.width,n.height),c.fillStyle=t;for(var i=0;i<e.length;i++){var l=Math.floor(i/o),f=i%o;e[i]&&c.fillRect(f*r,l*r,r,r)}return n}function o(t){t=t||{};var o=t.size||10,c=t.scale||5,i=t.seed||Math.random().toString(36).substr(2),l=t.bgcolor||"#fff";e(i);var f=t.color||r(),h=a(o),s=n(h,f,c,l);return s}var c=0;window.blockies={create:o}}()}).call(this),function(){"use strict";Package.templating&&Package.templating.Template.registerHelper("identicon",function(e,t){return t=t&&t.hash||{},e&&(t.seed=e),blockies.create(t).toDataURL()})}.call(this),"undefined"==typeof Package&&(Package={}),Package["mistereo:identicon"]={}}();
+
+!function(){var e=Package.meteor.Meteor,a=Package.underscore._,n=Package.jquery.$,t=Package.jquery.jQuery,c=Package.templating.Template,o=Package["ethereum:tools"].EthTools,r=Package["frozeman:template-var"].TemplateVar,u=Package.blaze.Blaze,l=Package.blaze.UI,s=Package.blaze.Handlebars,i=Package.htmljs.HTML;(function(){c.__checkName("dapp_identicon"),c.dapp_identicon=new c("Template.dapp_identicon",function(){var e=this;return u.If(function(){return Spacebars.call(e.lookup("identity"))},function(){return["\n ",i.A({href:function(){return Spacebars.mustache(e.lookup("pathFor"),Spacebars.kw({route:"userProfile",userId:e.lookup("identity")}))},"class":function(){return["dapp-identicon ",Spacebars.mustache(e.lookup("class"))]},style:function(){return["background-image: url('",Spacebars.mustache(e.lookup("identicon"),e.lookup("identity"),Spacebars.kw({size:8,scale:8,bgcolor:"#424343"})),"')"]}}),"\n "]})})}).call(this),function(){c.dapp_identicon.helpers({})}.call(this),function(){c.__checkName("dapp_addressInput"),c.dapp_addressInput=new c("Template.dapp_addressInput",function(){var e=this;return i.DIV({"class":"dapp-address-input"},"\n ",i.INPUT({type:"text",name:"to",placeholder:function(){return Spacebars.mustache(e.lookup("placeholder"))},"class":function(){return[Spacebars.mustache(e.lookup("class"))," ",u.Unless(function(){return Spacebars.call(e.lookup("isValid"))},function(){return"dapp-error"})]},autofocus:"true",value:function(){return Spacebars.mustache(e.lookup("value"))}}),"\n ",u.If(function(){return Spacebars.call(e.lookup("isValid"))},function(){return["\n ",u._TemplateWith(function(){return{identity:Spacebars.call(e.lookup("address")),"class":Spacebars.call("dapp-small")}},function(){return Spacebars.include(e.lookupTemplate("dapp_identicon"))}),"\n "]},function(){return["\n ",i.I({"class":"icon-shield"}),"\n "]}),"\n ")})}.call(this),function(){c.dapp_addressInput.created=function(){r.set("isValid",!0),this.data.value&&r.set("address",this.data.value)},c.dapp_addressInput.helpers({address:function(){var e=r.get("address");return a.isString(e)?e.replace("0x",""):""},isValid:function(){return r.get("isValid")}}),c.dapp_addressInput.events({'input input[name="to"], change input[name="to"]':function(e){o.isAddress(e.currentTarget.value)||a.isEmpty(e.currentTarget.value)?r.set("isValid",!0):r.set("isValid",!1),r.set("address",e.currentTarget.value)},"click a":function(e){e.preventDefault()}})}.call(this),function(){c.__checkName("dapp_modal"),c.dapp_modal=new c("Template.dapp_modal",function(){var e=this;return Spacebars.include(e.lookupTemplate("Animate"),function(){return["\n ",i.DIV({"class":"dapp-modal-overlay animate"},"\n ",i.SECTION({"class":"dapp-modal-container"},"\n ",u.If(function(){return Spacebars.call(e.lookup("yield"))},function(){return["\n ",u._TemplateWith(function(){return{region:Spacebars.call("modalContent")}},function(){return Spacebars.include(e.lookupTemplate("yield"))}),"\n "]}),"\n "),"\n "),"\n "]})})}.call(this),function(){c.dapp_modal.created=function(){n("body").addClass("disable-scroll blur")},c.dapp_modal.destroyed=function(){n("body").removeClass("disable-scroll blur")},c.dapp_modal.events({"click .dapp-modal-overlay":function(e){n(e.target).hasClass("dapp-modal-overlay")&&"undefined"!=typeof Router&&(this.closePath?Router.go(this.closePath):Router.current().render(null,{to:"modal"}))}})}.call(this),function(){c.__checkName("dapp_modal_question"),c.dapp_modal_question=new c("Template.dapp_modal_question",function(){var e=this;return[i.P(u.View(function(){return Spacebars.mustache(e.lookup("text"))})),"\n ",i.DIV({"class":"dapp-modal-buttons"},"\n ",u.If(function(){return Spacebars.call(e.lookup("hasCancel"))},function(){return["\n ",i.BUTTON({"class":"cancel"},u.View(function(){return Spacebars.mustache(e.lookup("i18nText"),"cancel")})),"\n "]}),"\n ",u.If(function(){return Spacebars.call(e.lookup("hasOk"))},function(){return["\n ",i.BUTTON({"class":"ok dapp-primary-button"},u.View(function(){return Spacebars.mustache(e.lookup("i18nText"),"ok")})),"\n "]}),"\n ")]})}.call(this),function(){c.dapp_modal_question.helpers({hasOk:function(){return this.ok},hasCancel:function(){return this.cancel},i18nText:function(e){return"undefined"==typeof TAPi18n?"ok"===e?"OK":"Cancel":TAPi18n.__("buttons."+e)}}),c.dapp_modal_question.events({"click button.ok":function(e){a.isFunction(this.ok)&&this.ok(),Router.current().render(null,{to:"modal"})},"click button.cancel":function(e){a.isFunction(this.cancel)&&this.cancel(),Router.current().render(null,{to:"modal"})}})}.call(this),"undefined"==typeof Package&&(Package={}),Package["ethereum:elements"]={}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,n=Package.ejson.EJSON,r;(function(){if(Package["cmather:iron-core"])throw new Error("\n\n Sorry! The cmather:iron-{x} packages were migrated to the new package system with the wrong name, and you have duplicate copies.\n You can see which cmather:iron-{x} packages have been installed by using this command:\n\n > meteor list\n\n Can you remove any installed cmather:iron-{x} packages like this: \n\n > meteor remove cmather:iron-core\n > meteor remove cmather:iron-router\n > meteor remove cmather:iron-dynamic-template\n > meteor remove cmather:iron-dynamic-layout\n \n The new packages are named iron:{x}. For example:\n\n > meteor add iron:router\n\n Sorry for the hassle, but thank you! \n\n ")}).call(this),function(){r={},r.utils={},r.utils.assert=function(e,t){if(!e)throw new Error(t)},r.utils.warn=function(e,t){e||console&&console.warn&&console.warn(t)},r.utils.defaultValue=function(e,t,n){return"undefined"==typeof e[t]?(e[t]=n,n):e[t]},r.utils.inherits=function(e,o,i){r.utils.assert("undefined"!=typeof e,"Child is undefined in inherits function"),r.utils.assert("undefined"!=typeof o,"Parent is undefined in inherits function");for(var a in o)t.has(o,a)&&(e[a]=n.clone(o[a]));var s=function(){this.constructor=e};return s.prototype=o.prototype,e.prototype=new s,e.__super__=o.prototype,t.isObject(i)&&t.extend(e.prototype,i),e},r.utils.extend=function(e,n){n=n||{};var o=function(){var e;e=t.has(n,"constructor")?n.constructor:o.__super__.constructor,e.apply(this,arguments)};return r.utils.inherits(o,e,n)},r.utils.global=function(){return e.isClient?window:global}(),r.utils.namespace=function(e,t){var n=r.utils.global,o,i,a,s;r.utils.assert("string"==typeof e,"namespace must be a string"),o=e.split("."),a=o.pop(),s=n;for(var u=0;u<o.length;u++)i=o[u],s=s[i]=s[i]||{};return 2===arguments.length?(s[a]=t,t):s[a]},r.utils.resolve=function(e){var t=r.utils.global,n,o;if("string"==typeof e){n=e.split("."),o=t;for(var i=0;i<n.length;i++)if(o=o[n[i]],!o)return void 0}else o=e;return o},r.utils.capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1,e.length)},r.utils.classCase=function(e){var n=/_|-|\.|\//;return e?t.map(e.split(n),function(e){return r.utils.capitalize(e)}).join(""):""},r.utils.camelCase=function(e){var t=r.utils.classCase(e);return t=t.charAt(0).toLowerCase()+t.slice(1,t.length)},r.utils.notifyDeprecated=function(e){var n,r,o,i,a="[:where] ':name' is deprecated. Please use ':instead' instead.";t.isObject(e)?(n=e.name,r=e.instead,o=e.message||a,i=e.where||"IronRouter"):(o=e,n="",r="",i=""),"undefined"!=typeof console&&console.warn&&console.warn("<deprecated> "+o.replace(":name",n).replace(":instead",r).replace(":where",i)+" "+(new Error).stack)},r.utils.withDeprecatedNotice=function(e,t,n){return function(){return Utils.notifyDeprecated(e),t&&t.apply(n||this,arguments)}},Function.prototype.deprecate=function(e){var t=this;return r.utils.withDeprecatedNotice(e,t)},r.utils.debug=function(e){return r.utils.assert("string"==typeof e,"debug requires a package name"),function n(){if(console&&console.log&&r.debug===!0){var n=t.toArray(arguments).join(" ");console.log("%c<"+e+"> %c"+n,"color: #999;","color: #000;")}}},r.utils.get=function(e){for(var t=1;t<arguments.length;t++){if(!(e&&arguments[t]in e))return void 0;e=e[arguments[t]]}return e},r.utils.global.Iron=r}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:core"]={Iron:r}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.ui.Blaze,n=Package.ui.UI,a=Package.ui.Handlebars,r=Package.underscore._,i=Package.jquery.$,o=Package.jquery.jQuery,s=Package.tracker.Tracker,u=Package.tracker.Deps,c=Package["reactive-var"].ReactiveVar,l=Package.templating.Template,p=Package.random.Random,h=Package["iron:core"].Iron,d=Package.htmljs.HTML,m;(function(){if(Package["cmather:iron-dynamic-template"])throw new Error("\n\n Sorry! The cmather:iron-{x} packages were migrated to the new package system with the wrong name, and you have duplicate copies.\n You can see which cmather:iron-{x} packages have been installed by using this command:\n\n > meteor list\n\n Can you remove any installed cmather:iron-{x} packages like this: \n\n > meteor remove cmather:iron-core\n > meteor remove cmather:iron-router\n > meteor remove cmather:iron-dynamic-template\n > meteor remove cmather:iron-dynamic-layout\n \n The new packages are named iron:{x}. For example:\n\n > meteor add iron:router\n\n Sorry for the hassle, but thank you! \n\n ")}).call(this),function(){l.__checkName("__DynamicTemplateError__"),l.__DynamicTemplateError__=new l("Template.__DynamicTemplateError__",function(){var e=this;return d.DIV({style:"margin: 0 auto; color: red;"},"\n ",t.View(function(){return Spacebars.mustache(e.lookup("msg"))}),"\n ")})}.call(this),function(){var e=h.utils.debug("iron:dynamic-template"),a=h.utils.assert,o=h.utils.get,d=h.utils.camelCase,f=function(e){return Object.prototype.toString.call(e)};m=function(e){this._id=p.id(),this.options=e=e||{},this._template=e.template,this._defaultTemplate=e.defaultTemplate,this._content=e.content,this._data=e.data,this._templateDep=new s.Dependency,this._dataDep=new s.Dependency,this._lookupHostDep=new s.Dependency,this._lookupHostValue=null,this._hooks={},this._eventMap=null,this._eventHandles=null,this._eventThisArg=null,this.name=e.name||this.constructor.prototype.name||"DynamicTemplate",this.isCreated=!1,this.isDestroyed=!1},m.prototype.template=function(e){if(1===arguments.length&&e!==this._template)return this._template=e,void this._templateDep.changed();if(!(arguments.length>0))return this._templateDep.depend(),this._template?"function"==typeof this._template?this._template():this._template:this._defaultTemplate?"function"==typeof this._defaultTemplate?this._defaultTemplate():this._defaultTemplate:void 0},m.prototype.defaultTemplate=function(e){return 1!==arguments.length?this._defaultTemplate:void(this._defaultTemplate=e)},m.prototype.clear=function(){this._template=void 0,this._data=void 0,this._templateDep.changed()},m.prototype.data=function(e){return 1===arguments.length&&e!==this._data?(this._data=e,void this._dataDep.changed()):(this._dataDep.depend(),"function"==typeof this._data?this._data():this._data)},m.prototype.create=function(e){var n=this;if(this.isCreated)throw new Error("DynamicTemplate view is already created");this.isCreated=!0,this.isDestroyed=!1;var a=c(null),i=t.View("DynamicTemplate",function(){var e=this,r=a.get();return t.With(function(){var t=n.data();return"undefined"!=typeof t?t:m.getParentDataContext(e)},function(){return n.renderView(r)})});return i.onViewCreated(function(){this.autorun(function(){a.set(n.template())})}),r.each(["onViewCreated","onViewReady","_onViewRendered","onViewDestroyed"],function(e){i[e](function(){n._runHooks(e,this)})}),i._onViewRendered(function(){n.isInserted=!0,1===i.renderCount&&n._attachEvents()}),i.onViewDestroyed(function(){n._detachEvents()}),i._templateInstance=new t.TemplateInstance(i),i.templateInstance=function(){var e=i._templateInstance;return e.data=t.getData(i),i._domrange&&!i.isDestroyed?(e.firstNode=i._domrange.firstNode(),e.lastNode=i._domrange.lastNode()):(e.firstNode=null,e.lastNode=null),e},this.view=i,i.__dynamicTemplate__=this,i.name=this.name,i},m.prototype.renderView=function(e){var n=this,a=null;return"string"==typeof e?(a=l[e],a||(a=l[d(e)]),a||(a=t.With({msg:"Couldn't find a template named "+JSON.stringify(e)+" or "+JSON.stringify(d(e))+". Are you sure you defined it?"},function(){return l.__DynamicTemplateError__}))):"[object Object]"===f(e)?a=e:"undefined"!=typeof n._content&&(a=n._content),a},m.prototype.destroy=function(){this.isCreated&&(t.remove(this.view),this.view=null,this.isDestroyed=!0,this.isCreated=!1)},r.each(["onViewCreated","onViewReady","_onViewRendered","onViewDestroyed"],function(e){m.prototype[e]=function(t){var n=this._hooks[e]=this._hooks[e]||[];return n.push(t),this}}),m.prototype._runHooks=function(e,t){for(var n=this._hooks[e]||[],a,r=0;r<n.length;r++)a=n[r],a.call(t,this)},m.prototype.events=function(e,n){var a=this;this._detachEvents(),this._eventThisArg=n;var r=this._eventMap={};for(var i in e)r[i]=function(e,r){return function(e){var i=t.getData(e.currentTarget);null==i&&(i={});var o=a.view.templateInstance();return r.call(n||this,e,o,i)}}(i,e[i]);this._attachEvents()},m.prototype._attachEvents=function(){var e=this,n=e._eventThisArg,a=e._eventMap,i=e.view,o=e._eventHandles;if(i){var s=i._domrange;if(!s)throw new Error("no domrange");var u=function(n,s){r.each(a,function(a,u){var c=u.split(/,\s+/);r.each(c,function(r){var u=r.split(/\s+/);if(0!==u.length){var c=u.shift(),l=u.join(" ");o.push(t._EventSupport.listen(s,c,l,function(r){if(!n.containsElement(r.currentTarget))return null;var o=e._eventThisArg||this,s=arguments;return t._withCurrentView(i,function(){return a.apply(o,s)})},n,function(e){return e.parentRange}))}})})};s.attached?u(s,s.parentElement):s.onAttached(u)}},m.prototype._detachEvents=function(){r.each(this._eventHandles,function(e){e.stop()}),this._eventHandles=[]};var _=function(e,n,a,i){r.each(a,function(a,o){var s=o.split(/,\s+/);r.each(s,function(r){var o=r.split(/\s+/);if(0!==o.length){var s=o.shift(),u=o.join(" ");handles.push(t._EventSupport.listen(n,s,u,function(n){if(!e.containsElement(n.currentTarget))return null;var r=i||this,o=arguments;return t._withCurrentView(view,function(){return a.apply(r,o)})},e,function(e){return e.parentRange}))}})})};m.prototype.insert=function(e){if(e=e||{},!this.isInserted){this.isInserted=!0;var n=e.el||document.body,a=i(n);if(0===a.length)throw new Error("No element to insert layout into. Is your element defined? Try a Meteor.startup callback.");return this.view||this.create(e),t.render(this.view,a[0],e.nextNode,e.parentView),this}},m.prototype._getLookupHost=function(){return this._lookupHostValue},m.prototype._setLookupHost=function(e){var t=this;return t._lookupHostValue!==e&&(t._lookupHostValue=e,u.afterFlush(function(){t._lookupHostDep.changed()})),this},m.getParentDataContext=function(e){return m.getDataContext(e&&e.parentView)},m.getDataContext=function(e){for(;e;){if("with"===e.name&&!e.__isTemplateWith)return e.dataVar.get();e=e.parentView}return null},m.getInclusionArguments=function(e){var t=e&&e.parentView;return t&&t.__isTemplateWith?t.dataVar.get():null},m.args=function(e){return function(t){var n=m.getInclusionArguments(e);return n?t?n[t]:n:null}},m.extend=function(e){return h.utils.extend(this,e)},m.findFirstLookupHost=function(e){var n,r;for(a(e instanceof t.View,"view must be a Blaze.View");e;)if(e.__dynamicTemplate__){var n=e.__dynamicTemplate__._getLookupHost();if(n)return n}else e=e.parentView;return void 0},m.findLookupHostWithProperty=function(e,n){var r,i;for(a(e instanceof t.View,"view must be a Blaze.View");e;){if(e.__dynamicTemplate__){var r=e.__dynamicTemplate__._getLookupHost();if(r&&o(r,n))return r}e=e.parentView}return void 0},m.findLookupHostWithHelper=function(e,n){var r,i;for(a(e instanceof t.View,"view must be a Blaze.View");e;){if(e.__dynamicTemplate__){var r=e.__dynamicTemplate__._getLookupHost();if(r&&o(r,"constructor","_helpers",n))return r}e=e.parentView}return void 0},"undefined"!=typeof l&&n.registerHelper("DynamicTemplate",new l("DynamicTemplateHelper",function(){var e=m.args(this);return new m({data:function(){return e("data")},template:function(){return e("template")},content:this.templateContentBlock}).create()})),h.DynamicTemplate=m}.call(this),function(){var e=h.utils.assert,n=h.utils.get,a=t.View.prototype.lookup;t.View.prototype.lookup=function(e){var r;return r=m.findLookupHostWithHelper(t.getView(),e),r?function i(){var t=n(r,"constructor","_helpers",e),a=[].slice.call(arguments);return"function"==typeof t?t.apply(r,a):t}:a.apply(this,arguments)}}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:dynamic-template"]={}}();
+
+!function(){var e=Package.meteor.Meteor,n=Package.templating.Template,t=Package.blaze.Blaze,r=Package.blaze.UI,o=Package.blaze.Handlebars,i=Package.underscore._,a=Package["iron:core"].Iron,s=Package.htmljs.HTML,c,u,h;(function(){var e=[];if(Package["cmather:iron-layout"]&&e.push("\n\n The cmather:iron-{x} packages were migrated to the new package system with the wrong name, and you have duplicate copies.\n You can see which cmather:iron-{x} packages have been installed by using this command:\n\n > meteor list\n\n Can you remove any installed cmather:iron-{x} packages like this: \n\n > meteor remove cmather:iron-core\n > meteor remove cmather:iron-router\n > meteor remove cmather:iron-dynamic-template\n > meteor remove cmather:iron-dynamic-layout\n \n The new packages are named iron:{x}. For example:\n\n > meteor add iron:router\n\n Sorry for the hassle, but thank you! \n\n "),Package["cmather:blaze-layout"]&&e.push("The blaze-layout package has been replaced by iron-layout. Please remove the package like this:\n> meteor remove cmather:blaze-layout\n"),e.length>0)throw new Error("Sorry! Looks like there's a few errors related to iron:layout\n\n"+e.join("\n\n"))}).call(this),function(){n.__checkName("__IronDefaultLayout__"),n.__IronDefaultLayout__=new n("Template.__IronDefaultLayout__",function(){var e=this;return Spacebars.include(e.lookupTemplate("yield"))})}.call(this),function(){var e=a.DynamicTemplate,o=a.utils.inherits;c=function(e){for(;e;){if("Iron.Layout"===e.name)return e.__dynamicTemplate__;e=e.parentView}return null},u=function(e){var n=this;u.__super__.constructor.apply(this,arguments),e=e||{},this.name="Iron.Layout",this._regions={},this._regionHooks={},this.defaultTemplate("__IronDefaultLayout__"),e.content&&this.render(e.content)},h=u.DEFAULT_REGION="main",o(u,a.DynamicTemplate),u.prototype.region=function(e,n){return this._ensureRegion(e,n)},u.prototype.destroyRegions=function(){i.each(this._regions,function(e){e.destroy()}),this._regions={}},u.prototype.render=function(e,n){n=n||{};var t=n.to||n.region||h,r=this.region(t);return this._trackRenderedRegion(t),r.template(e),r.data(n.data),r},u.prototype.has=function(e){return e=e||u.DEFAULT_REGION,!!this._regions[e]},u.prototype.regionKeys=function(){return i.keys(this._regions)},u.prototype.clear=function(e){return e=e||u.DEFAULT_REGION,this.has(e)&&this.region(e).template(null),this},u.prototype.clearAll=function(){return i.each(this._regions,function(e){e.template(null)}),this},u.prototype.beginRendering=function(e){var n=this;if(this._finishRenderingTransaction&&this._finishRenderingTransaction(),this._finishRenderingTransaction=i.once(function(){var t=n._endRendering({flush:!1});e&&e(t)}),Deps.afterFlush(this._finishRenderingTransaction),this._renderedRegions)throw new Error("You called beginRendering again before calling endRendering");this._renderedRegions={}},u.prototype._trackRenderedRegion=function(e){this._renderedRegions&&(this._renderedRegions[e]=!0)},u.prototype._endRendering=function(e){e=e||{},e.flush!==!1&&Deps.flush();var n=this._renderedRegions||{};return this._renderedRegions=null,i.keys(n)},i.each(["onRegionCreated","onRegionRendered","onRegionDestroyed"],function(e){u.prototype[e]=function(n){var t=this._regionHooks[e]=this._regionHooks[e]||[];return t.push(n),this}}),u.prototype._ensureRegion=function(e,n){return this._regions[e]=this._regions[e]||this._createDynamicTemplate(e,n)},u.prototype._createDynamicTemplate=function(e,n){var t=this,r=new a.DynamicTemplate(n),o=a.utils.capitalize;return r._region=e,i.each(["viewCreated","viewReady","viewDestroyed"],function(e){e=o(e),r["on"+e](function(n){var r=this,o={viewCreated:"regionCreated",viewReady:"regionRendered",viewDestroyed:"regionDestroyed"}[e];t._runRegionHooks("on"+o,r,n)})}),r},u.prototype._runRegionHooks=function(e,n,t){for(var r=this,o=this._regionHooks[e]||[],i,a=0;a<o.length;a++)i=o[a],i.call(n,t.region,t,this)},"undefined"!=typeof n&&(r.registerHelper("yield",new n("yield",function(){var n=c(this);if(!n)throw new Error("No Iron.Layout found so you can't use yield!");var t=e.getInclusionArguments(this),r,o;return i.isString(t)?r=t:i.isObject(t)&&(r=t.region),r=r||h,o=n.region(r),o.isCreated&&o.destroy(),o.create()})),r.registerHelper("contentFor",new n("contentFor",function(){var n=c(this);if(!n)throw new Error("No Iron.Layout found so you can't use contentFor!");var t=e.getInclusionArguments(this)||{},r=this.templateContentBlock,o=t.template,a=t.data,s;if(i.isString(t))s=t;else{if(!i.isObject(t))throw new Error("Which region is this contentFor block supposed to be for?");s=t.region}return n.region(s).template(o||r),n._trackRenderedRegion(s),a&&n.region(s).data(a),null})),r.registerHelper("hasRegion",function(e){var n=c(t.getView());if(!n)throw new Error("No Iron.Layout found so you can't use hasRegion!");if(!i.isString(e))throw new Error("You need to provide an region argument to hasRegion");return!!n.region(e).template()}),r.registerHelper("Layout",new n("layout",function(){var e=a.DynamicTemplate.args(this),n=new u({template:function(){return e("template")},data:function(){return e("data")},content:this.templateContentBlock});return n.create()}))),a.Layout=u}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:layout"]={}}();
+
+!function(){var e=Package.meteor.Meteor,r=Package.underscore._,n=Package["iron:core"].Iron,t,i;(function(){function e(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function r(t,a,s){a&&"[object Array]"!==n(a)&&(s=a,a=null),a=a||[],s=s||{};var c=s.strict,u=s.end!==!1,p=s.sensitive?"":"i",h=0;if(t instanceof RegExp){var l=t.source.match(/\((?!\?)/g)||[];return a.push.apply(a,l.map(function(e,r){return{name:r,delimiter:null,optional:!1,repeat:!1}})),o(t,a)}if("[object Array]"===n(t))return t=t.map(function(e){return r(e,a,s).source}),o(new RegExp("(?:"+t.join("|")+")",p),a);t=t.replace(i,function(r,n,t,i,o,s,c,u){if(n)return n;if(u)return"\\"+u;var p="+"===c||"*"===c,l="?"===c||"*"===c;return a.push({name:i||h++,delimiter:t||"/",optional:l,repeat:p}),t=t?"\\"+t:"",o=e(o||s||"[^"+(t||"\\/")+"]+?"),p&&(o=o+"(?:"+t+o+")*"),l?"(?:"+t+"("+o+"))?":t+"("+o+")"});var f="/"===t[t.length-1];return c||(t=(f?t.slice(0,-2):t)+"(?:\\/(?=$))?"),u||(t+=c&&f?"":"(?=\\/|$)"),o(new RegExp("^"+t+(u?"$":""),p),a)}var n=function(e){return Object.prototype.toString.call(e)},i=new RegExp(["(\\\\.)","([\\/.])?(?:\\:(\\w+)(?:\\(((?:\\\\.|[^)])*)\\))?|\\(((?:\\\\.|[^)])*)\\))([+*?])?","([.+*?=^!:${}()[\\]|\\/])"].join("|"),"g"),o=function(e,r){return e.keys=r,e};t=r}).call(this),function(){function e(e){try{return decodeURIComponent(e).replace(/\+/g," ")}catch(r){return void(r.constructor==URIError&&a("Tried to decode an invalid URI component: "+JSON.stringify(e)+" "+r.stack))}}function o(e){try{return decodeURI(e).replace(/\+/g," ")}catch(r){return void(r.constructor==URIError&&a("Tried to decode an invalid URI: "+JSON.stringify(e)+" "+r.stack))}}var a=n.utils.warn;i=function(e,n){n=n||{},this.options=n,this.keys=[],this.regexp=t(e,this.keys,n),this._originalPath=e,r.extend(this,i.parse(e))},i.normalize=function(e){if(e instanceof RegExp)return e;if("string"!=typeof e)return"/";var r=i.parse(e),n=r.pathname;return"/"!==n.charAt(0)&&(n="/"+n),n.length>1&&"/"===n.charAt(n.length-1)&&(n=n.slice(0,n.length-1)),n},i.isSameOrigin=function(e,r){var n=i.parse(e),t=i.parse(r),o=n.origin===t.origin;return o},i.fromQueryString=function(n){if(!n)return{};if("string"!=typeof n)throw new Error("expected string");"?"===n.charAt(0)&&(n=n.slice(1));var t=n.split("&"),i={},o;return r.each(t,function(r){var n=r.split("="),t=n[0],o=e(n[1]);"[]"===t.slice(-2)?(t=t.slice(0,-2),i[t]=i[t]||[],i[t].push(o)):i[t]=o}),i},i.toQueryString=function(e){var n=[];return"string"==typeof e?"?"!==e.charAt(0)?"?"+e:e:(r.each(e,function(e,t){r.isArray(e)?r.each(e,function(e){n.push(encodeURIComponent(t+"[]")+"="+encodeURIComponent(e))}):n.push(encodeURIComponent(t)+"="+encodeURIComponent(e))}),n.length>0?"?"+n.join("&"):"")},i.parse=function(e){if("string"!=typeof e)return{};var r=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,n=e.match(r),t=n[1]?n[1].toLowerCase():void 0,o=n[3],a=!!o,s=n[4]?n[4].toLowerCase():void 0,c=s?s.split("@"):[],u,p;2==c.length?(p=c[0],u=c[1]):1==c.length?(u=c[0],p=void 0):(u=void 0,p=void 0);var h=u&&u.split(":")||[],l=h[0],f=h[1],g=t&&u?t+"//"+u:void 0,d=n[5],m=n[8],y=e,v=n[6],w,R=m&&m.indexOf("?")||-1;~R&&!v?(v=m.slice(R),m=m.substr(0,R),w=v.slice(1)):w=n[7];var x=d+(v||""),U=i.fromQueryString(w),S=[t||"",a?"//":"",s||""].join(""),I=[t||"",a?"//":"",s||"",d||"",v||"",m||""].join("");return{rootUrl:S||"",originalUrl:e||"",href:I||"",protocol:t||"",auth:p||"",host:u||"",hostname:l||"",port:f||"",origin:g||"",path:x||"",pathname:d||"",search:v||"",query:w||"",queryObject:U||"",hash:m||"",slashes:a}},i.prototype.test=function(e){return this.regexp.test(i.normalize(e))},i.prototype.exec=function(e){return this.regexp.exec(i.normalize(e))},i.prototype.params=function(r){if(!r)return[];var n=[],t=this.exec(r),a,s=this.keys,c,u;if(!t)throw new Error('The route named "'+this.name+'" does not match the path "'+r+'"');for(var p=1,h=t.length;h>p;++p)c=s[p-1],u="string"==typeof t[p]?e(t[p]):t[p],c?n[c.name]=void 0!==n[c.name]?n[c.name]:u:n.push(u);return r=o(r),"undefined"!=typeof r&&(a=r.split("?")[1],a&&(a=a.split("#")[0]),n.hash=r.split("#")[1]||null,n.query=i.fromQueryString(a)),n},i.prototype.resolve=function(e,n){var t,o,a,s=0,c=this._originalPath,u,p,h=[],l=e;if(n=n||{},e=e||[],p=n.query,u=n.hash&&n.hash.toString(),c instanceof RegExp)throw new Error("Cannot currently resolve a regular expression path");if(c=c.replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,function(n,i,a,s,c,u,p){if(i=i||"",t=e[s],o="undefined"!=typeof t,u&&!o)t="";else if(!o)return void h.push(s);t=r.isFunction(t)?t.call(e):t;var l=r.map(String(t).split("/"),function(e){return encodeURIComponent(e)}).join("/");return i+l}).replace(/\*/g,function(n){if("undefined"==typeof e[s])throw new Error("You are trying to access a wild card parameter at index "+s+" but the value of params at that index is undefined");var t=String(e[s++]);return r.map(t.split("/"),function(e){return encodeURIComponent(e)}).join("/")}),p=i.toQueryString(p),c+=p,u&&(u=encodeURI(u.replace("#","")),c=c+"#"+u),c=c.replace(/\/+/g,"/"),c=c.replace(/^(.+)\/$/g,"$1"),0==h.length)return c;if(n.throwOnMissingParams===!0)throw new Error("Missing required parameters on path "+JSON.stringify(this._originalPath)+". The missing params are: "+JSON.stringify(h)+". The params object passed in was: "+JSON.stringify(l)+".");return null},n.Url=i}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:url"]={}}();
+
+!function(){var t=Package.meteor.Meteor,e=Package.underscore._,n=Package["iron:core"].Iron,r,i,n;(function(){var t=n.Url;r=function(n,r,i){e.isFunction(n)&&(i=i||r||{},r=n,n="/",this.middleware=!0,"undefined"==typeof i.mount&&(i.mount=!0)),"object"==typeof r&&(i=r,r=i.action||"action"),i=i||{},this.options=i,this.mount=i.mount,this.method=i.method&&i.method.toLowerCase()||!1,this.where=i.where||"client",this.mount&&(i.end=!1),i.name?this.name=i.name:"string"==typeof n&&"/"!==n.charAt(0)?this.name=n:r&&r.name?this.name=r.name:"string"==typeof n&&"/"!==n&&(this.name=n.split("/").slice(1).join(".")),n=i.path||n,"string"==typeof n&&"/"!==n.charAt(0)&&(n="/"+n),this.path=n,this.compiledUrl=new t(n,i),e.isString(r)?this.handle=function o(){var t=this[r];if("function"!=typeof t)throw new Error("No method named "+JSON.stringify(r)+" found on handler.");return t.apply(this,arguments)}:e.isFunction(r)&&(this.handle=r)},r.prototype.test=function(t,e){e=e||{};var n=this.compiledUrl.test(t),r=!0,i=!0;return this.method&&e.method&&(r=this.method==e.method.toLowerCase()),e.where&&(i=this.where==e.where),n&&r&&i},r.prototype.params=function(t){return this.compiledUrl.params(t)},r.prototype.resolve=function(t,e){return this.compiledUrl.resolve(t,e)},r.prototype.clone=function(){var t=new r(this.path,this.handle,this.options);return t.name=this.name,t}}).call(this),function(){var o=n.Url,a=n.utils.assert,s=n.utils.defaultValue;i=function(){this._stack=[],this.length=0},i.prototype._create=function(t,n,i){var o=new r(t,n,i),a=o.name;if(a){if(e.has(this._stack,a))throw new Error("Handler with name '"+a+"' already exists.");this._stack[a]=o}return o},i.prototype.findByName=function(t){return this._stack[t]},i.prototype.push=function(t,e,n){var r=this._create(t,e,n);return this._stack.push(r),this.length++,r},i.prototype.append=function(){var t=this,n=e.toArray(arguments),r={};return"object"==typeof n[n.length-1]&&(r=n.pop()),e.each(n,function(n){if("undefined"!=typeof n)if("function"==typeof n)t.push(n,r);else{if(!e.isArray(n))throw new Error("Can only append functions or arrays to the MiddlewareStack");t.append.apply(t,n.concat([r]))}}),this},i.prototype.insertAt=function(t,e,n,r){var i=this._create(e,n,r);return this._stack.splice(t,0,i),this.length=this._stack.length,this},i.prototype.insertBefore=function(t,n,r,i){var o,a;if(!(o=this._stack[t]))throw new Error("Couldn't find a handler named '"+t+"' on the path stack");return a=e.indexOf(this._stack,o),this.insertAt(a,n,r,i),this},i.prototype.insertAfter=function(t,n,r,i){var o,a;if(!(o=this._stack[t]))throw new Error("Couldn't find a handler named '"+t+"' on the path stack");return a=e.indexOf(this._stack,o),this.insertAt(a+1,n,r,i),this},i.prototype.concat=function(){var t=new i,n=Array.prototype.concat,r=EJSON.clone(this._stack),o=e.map(e.toArray(arguments),function(t){return EJSON.clone(t._stack)});return t._stack=n.apply(r,o),this.length=t._stack.length,t},i.prototype.dispatch=function h(e,n,r){var i=this,h=e;a("string"==typeof e,"Requires url"),a("object"==typeof n,"Requires context object"),e=o.normalize(e||"/"),s(n,"request",{}),s(n,"response",{}),s(n,"originalUrl",e),s(n,"_method",n.method),s(n,"_handlersForEnv",{client:!1,server:!1}),s(n,"_handled",!1),s(n,"isHandled",function(){return n._handled}),s(n,"willBeHandledOnClient",function(){return n._handlersForEnv.client}),s(n,"willBeHandledOnServer",function(){return n._handlersForEnv.server});var l=function(){if(r)try{r.apply(this,arguments)}catch(t){throw t._punt=!0,t}},c=0,u=t.bindEnvironment(function p(r){var a=i._stack[c++];if(n.url=n.request.url=n.originalUrl,!a)return l.call(n,r);if(!a.test(e,{method:n._method}))return u(r);var s=t.isClient?"client":"server";if(a.middleware||(n._handlersForEnv[a.where]=!0),a.where!==s)return u(r);if(n.next=u,a.mount){var h=o.normalize(a.compiledUrl.pathname),p=e.substr(h.length,e.length);p=o.normalize(p),n.url=n.request.url=p}try{var d=a.handle.length,f=n.request,m=n.response;return r&&4===d?a.handle.call(n,r,f,m,u):!r&&4>d?a.handle.call(n,f,m,u):u(r)}catch(r){if(r._punt)throw r;u(r)}finally{n._handled=!0,n.next=null}});return u(),n.next=null,n},n=n||{},n.MiddlewareStack=i}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:middleware-stack"]={Handler:r}}();
+
+!function(){var t=Package.meteor.Meteor,e=Package.underscore._,n=Package.tracker.Tracker,a=Package.tracker.Deps,r=Package.jquery.$,o=Package.jquery.jQuery,i=Package["iron:core"].Iron,c,s,h,u,l;(function(){var t=i.Url,n="__hash__";c=function(e){var a=t.parse(e),r=a.hash&&a.hash.replace("#",""),o=a.search,i=a.pathname,c=a.rootUrl;if(r&&"!"!==r.charAt(0)){var s=n+"="+r;o=o?o+"&":"?",o+=s,r=""}return!r&&i?r="#!"+i.substring(1):r&&(r="#"+r),[c,r,o].join("")},s=function(a){var r=t.parse(a),o=r.hash&&r.hash.replace("#!","/"),i=r.search,c=r.rootUrl,s;return e.has(r.queryObject,n)?(s="#"+r.queryObject[n],delete r.queryObject[n]):s="",[c,o,t.toQueryString(r.queryObject),s].join("")},h=function(e){var a=t.parse(e),r=a.queryObject;return a.hash&&(r[n]=a.hash.replace("#","")),["!",a.pathname.substring(1),t.toQueryString(r)].join("")}}).call(this),function(){var t=i.Url;u=function(n,a){e.extend(this,t.parse(n),{options:a||{}})},u.prototype.equals=function(t){return t&&t instanceof u&&t.pathname==this.pathname&&t.search==this.search&&t.hash==this.hash&&t.options.historyState===this.options.historyState?!0:!1},u.prototype.isCancelled=function(){return!!this._isCancelled},u.prototype.cancelUrlChange=function(){this._isCancelled=!0}}.call(this),function(){var n=i.Url,o=null,f=new a.Dependency,p={go:[],popState:[]},y=function(){return/MSIE 9/.test(navigator.appVersion)},g=function(){return/MSIE 8/.test(navigator.appVersion)},d=function(){return!!Package.appcache},S=function(){return"undefined"==typeof history||"function"!=typeof history.pushState},v=function(){return l.options.useHashPaths||g()||y()||d()||S()},k=function(){return!!l.options.useHashPaths},w=function(t,n){e.each(p[t],function(t){t.call(n)})},P=function(t){if(!(t instanceof u))throw new Error("Expected a State instance");return t.equals(o)?!1:(o=t,f.changed(),!0)},m=function(){var t=location.href,e;e=k()?new u(s(t)):new u(t,{historyState:history.state}),w("popState",e),P(e)},j=function(t){var e=q;e&&e(t)},_=function(t,e){e=e||{};var n=new u(t,e);w("go",n),P(n)&&a.afterFlush(function(){n.isCancelled()||(k()?location.hash=h(t):e.replaceState===!0?history.replaceState(e.historyState,null,t):history.pushState(e.historyState,null,t))})},q=function(t){try{var e=t.currentTarget,a=e.href,r=e.pathname+e.search+e.hash;if(r=r.replace(/(^\/?)/,"/"),t.isDefaultPrevented())return void t.preventDefault();if(t.metaKey||t.ctrlKey||t.shiftKey)return;if(e.target)return;if(!n.isSameOrigin(a,location.href))return;t.preventDefault(),_(r)}catch(o){throw t.preventDefault(),o}};l={},l.options={linkSelector:"a[href]",useHashPaths:!1},l.configure=function(t){e.extend(this.options,t||{})},l.get=function(){return f.depend(),o},l.start=function(){if(!this._isStarted){var e=n.parse(location.href);if(v()){if(e.pathname.length>1){var a=c(location.href);window.location=a}this.configure({useHashPaths:!0})}var o=location.href;if(k()){var i=new u(s(o));P(i)}else{if("!"===e.hash.replace("#","")[0])var o=s(o);var h={initial:!0};history.replaceState(h,null,o);var i=new u(o,{historyState:h});P(i)}r(window).on("popstate.iron-location",m),r(window).on("hashchange.iron-location",m),t.startup(function(){r(document).on("click.iron-location",l.options.linkSelector,j)}),this._isStarted=!0}},l.stop=function(){this._isStarted&&(r(window).on("popstate.iron-location"),r(window).on("hashchange.iron-location"),r(document).off("click.iron-location"),this._isStarted=!1)},l.onClick=function(t){q=t},l.go=function(t,e){return _(t,e)},l.onGo=function(t){p.go.push(t)},l.onPopState=function(t){p.popState.push(t)},l.start(),i.Location=l}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:location"]={urlToHashStyle:c,urlFromHashStyle:s}}();
+
+!function(){var t=Package.meteor.Meteor,n=Package.underscore._,e=Package.tracker.Tracker,o=Package.tracker.Deps,a=Package["reactive-dict"].ReactiveDict,r=Package.templating.Template,i=Package["iron:core"].Iron,u=Package.blaze.Blaze,s=Package.blaze.UI,c=Package.blaze.Handlebars,l=Package.htmljs.HTML,p,d;(function(){var t=i.utils.assert,e=function(){for(var t={},n=o.currentComputation;n;)t[String(n._id)]=!0,n=n._parent;return t},a=function(o){var a=e(),r=n.keys(o._dependentsById);r.forEach(function(n){t(!a[n],"\n\nYou called wait() after calling ready() inside the same computation tree.\n\nYou can fix this problem in two possible ways:\n\n1) Put all of your wait() calls before any ready() calls.\n2) Put your ready() call in its own computation with Deps.autorun.")})};p=function(){this._readyDep=new o.Dependency,this._comps=[],this._notReadyCount=0},p.prototype.wait=function(t){var e=this,r=o.currentComputation;a(e._readyDep),o.nonreactive(function(){var a=null,i=o.autorun(function(n){var o=!!t(),r=e._notReadyCount;n.firstRun&&!o?e._notReadyCount++:null!==a&&o!==a&&o===!0?e._notReadyCount--:null!==a&&o!==a&&o===!1&&e._notReadyCount++,a=o,0===r&&e._notReadyCount>0?e._readyDep.changed():r>0&&0===e._notReadyCount&&e._readyDep.changed()});e._comps.push(i),r&&r.onInvalidate(function(){o.afterFlush(function(){i.stop(),e._comps.splice(n.indexOf(e._comps,i),1),a===!1&&(e._notReadyCount--,0===e._notReadyCount&&e._readyDep.changed())})})})},p.prototype.ready=function(){return this._readyDep.depend(),0===this._notReadyCount},p.prototype.stop=function(){n.each(this._comps,function(t){t.stop()}),this._comps=[]},i.WaitList=p}).call(this),function(){var t=i.utils.debug("iron:controller"),e=i.Layout,o=i.DynamicTemplate,a=function(t,n){return function(){return"function"==typeof t?t.apply(n,arguments):t}};d=function(t){var n=this;this.options=t||{},this._layout=this.options.layout||new e(this.options),this._isController=!0,this._layout._setLookupHost(this);var o=d._collectEventMaps.call(this.constructor);this._layout.events(o,this),this.init(t)},d.prototype.layout=function(t,e){var o=this;return this._layout.template(t),e&&n.has(e,"data")&&this._layout.data(a(e.data,this)),{data:function(t){return o._layout.data(a(t,o))}}},d.prototype.render=function(t,n){var e=this;n&&"undefined"!=typeof n.data&&(n.data=a(n.data,this));var o=this._layout.render(t,n);return{data:function(t){return o.data(a(t,e))}}},d.prototype.beginRendering=function(t){return this._layout.beginRendering(t)},d.extend=function(t){return i.utils.extend(this,t)},d.events=function(t){return this._eventMap=t,this};var s=function(t,e){var o={};return t.__super__&&n.extend(o,s(t.__super__.constructor,e)),n.has(t,e)?n.extend(o,t[e]):o};d._collectEventMaps=function(){return s(this,"_eventMap")},d._helpers={},d.helpers=function(t){return n.extend(this._helpers,t),this},"undefined"!=typeof r&&(i.controller=function(){return o.findLookupHostWithProperty(u.getView(),"_isController")},r.registerHelper("get",function(t){var n=i.controller();return n&&n.state?n.state.get(t):void 0})),i.Controller=d}.call(this),function(){var t=i.Layout,e=i.utils.debug("iron:controller"),o=i.utils.defaultValue,r=function(t,n){return function(){return"function"==typeof t?t.apply(n,arguments):t}};d.prototype.init=function(t){this._waitlist=new p,this.state=new a},d.prototype.insert=function(t){return this._layout.insert.apply(this._layout,arguments)},d.prototype.wait=function(t){var e=this;if(t)return n.isArray(t)?n.each(t,function o(t){e.wait(t)}):this._waitlist.wait(t.ready?function(){return t.ready()}:t),this},d.prototype.ready=function(){return this._waitlist.ready()},d.prototype.stop=function(){this._waitlist.stop()}}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:controller"]={}}();
+
+!function(){var t=Package.underscore._,e=Package.tracker.Tracker,o=Package.tracker.Deps,r=Package.blaze.Blaze,n=Package.blaze.UI,i=Package.blaze.Handlebars,a=Package.templating.Template,u=Package.ejson.EJSON,s=Package.meteor.Meteor,l=Package["iron:core"].Iron,p=Package.htmljs.HTML,c,h,f,d,y,m;(function(){f=new s.EnvironmentVariable}).call(this),function(){d=["get","post","put","delete"]}.call(this),function(){var e=l.Controller,o=l.Url,r=l.MiddlewareStack,n=l.utils.assert;h=e.extend({constructor:function(e){h.__super__.constructor.apply(this,arguments),e=e||{},this.options=e,this._onStopCallbacks=[],this.route=e.route,this.params=[];var o=this.lookupOption("data");"function"==typeof o?this.data=t.bind(o,this):"undefined"!=typeof o&&(this.data=function(){return o}),this.init(e)}}),h.prototype.lookupOption=function(e){if(this.route&&this.route.options&&t.has(this.route.options,e))return this.route.options[e];if(t.has(this.options,e))return this.options[e];if("undefined"!=typeof this[e])return this[e];var o=f.get();return o&&t.has(o,e)?o[e]:this.router&&this.router.options&&t.has(this.router.options,e)?this.router.options[e]:void 0},h.prototype.configureFromUrl=function(t,e,o){n("string"==typeof t,"url must be a string"),e=e||{},this.request=e.request||{},this.response=e.response||{},this.url=e.url||t,this.originalUrl=e.originalUrl||t,this.method=this.request.method,this.route&&this.setParams(this.route.params(t),o)},h.prototype._collectHooks=function(){var e=this,o=t.toArray(arguments),r=function(o){if(!o)return[];var r=e.router.lookupHook,n=t.isArray(o)?o:[o];return t.map(n,function(t){return r(t)})},n=function(e,o){var i=[];return e.__super__&&(i=i.concat(n(e.__super__.constructor,o))),t.has(e.prototype,o)?i.concat(r(e.prototype[o])):i},i=function(t){for(var e=0;e<o.length;e++)t(o[e])},a=[];i(function(t){var o=e.route&&e.route.getName(),r=e.router.getHooks(t,o);a=a.concat(r)});var u=[];i(function(t){var o=n(e.constructor,t);u=u.concat(o)});var s=[];i(function(o){if(t.has(e,o)){var n=r(e[o]);s=s.concat(n)}});var l=[];e.route&&i(function(t){var o=r(e.route.options[t]);l=l.concat(o)});var p=a.concat(l).concat(u).concat(s);return p},h.prototype.runHooks=function(){for(var t=this._collectHooks.apply(this,arguments),e=0,o=t.length;o>e;e++){var r=t[e];r.call(this)}return t.length},h.prototype.getParams=function(){return this.params},h.prototype.setParams=function(t){return this.params=t,this},l.RouteController=h}.call(this),function(){var r=l.Controller,n=l.Url,i=l.MiddlewareStack,a=l.utils.debug("iron-router:RouteController");if(h.prototype.init=function(t){h.__super__.init.apply(this,arguments),this._computation=null,this._paramsDep=new e.Dependency,this.location=l.Location},h.prototype.getParams=function(){return this._paramsDep.depend(),this.params},h.prototype.setParams=function(e,o){var r=function(e,r){if(!(e instanceof Array))throw new Error("you called equals with a non array value in setParams");if(!(r instanceof Array))return!1;if(e.length!==r.length)return!1;for(var n=0;n<e.length;n++)if(!u.equals(e[n],r[n],o))return!1;var i=t.keys(e),a=t.keys(r),s;if(i.length!==a.length)return!1;for(var n=0;n<i.length;n++){if(s=i[n],!t.has(r,s))return!1;if(!u.equals(e[s],r[s]))return!1}return!0};if(!r(this.params,e))return this.params=e,o=o||{},o.reactive!==!1&&this._paramsDep.changed(),this},h.prototype.dispatch=function(t,e,r){if(this._computation&&!this._computation.stopped)throw new Error("RouteController computation is already running. Stop it first.");var n=this;return o.nonreactive(function(){o.autorun(function(o){n._computation=o,t.dispatch(e,n,r)})}),n},h.prototype._runRoute=function(e,r,n){var a=this,u=this._collectHooks("subscriptions");t.each(u,function(t){a.wait(t.call(a))});var s=this._collectHooks("waitOn");t.each(s,function(t){a.wait(t.call(a))});var p=s.length>0,c,f,d=function(){return o.nonreactive(function(){return a._layout.template()})},y=function(){return o.nonreactive(function(){var t=a._layout._regions.main;return t&&t.template()})},m=d(),_=y();this.beginRendering(function R(e){if(!a.isStopped){var o=d(),r=y();if(m!==o||_!=r){var n=a._layout.regionKeys(),i=t.difference(n,e);t.each(i,function(t){a._layout.clear(t)})}}}),this.layout(this.lookupOption("layoutTemplate"),{data:this.lookupOption("data")});var g=new i,v=new i,k=new i;v.append(this._collectHooks("onRun","load"),{where:"client"}),k.append(this._collectHooks("onRerun"),{where:"client"}),g.append(function b(t,e,o){this._computation.firstRun&&!h._hasJustReloaded?(h._hasJustReloaded=!1,v.length>0?v.dispatch(t.url,this,o):o()):o()},function C(t,e,o){this._computation.firstRun?o():k.length>0?k.dispatch(t.url,this,o):o()},{where:"client"}),p&&g.push(t.bind(l.Router.hooks.loading,a));var w=this._collectHooks("onBeforeAction","before");g.append(w,{where:"client"}),0===e._actionStack.length&&e._actionStack.push(e._path,"action",e.options),g=g.concat(e._actionStack),this._rendered=!1,g.dispatch(r,this,n),o.afterFlush(function(){l.utils.warn(a._rendered||a.isStopped,"Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?")}),this.runHooks("onAfterAction","after")},h.prototype.action=function(){this.render()},h.prototype.lookupTemplate=function(){return this.lookupOption("template")||this.router&&this.router.toTemplateName(this.route.getName())},h.prototype.lookupRegionTemplates=function(){return this.lookupOption("yieldRegions")||this.lookupOption("regionTemplates")||this.lookupOption("yieldTemplates")||{}},h.prototype.render=function(t,e){if(this._rendered=!0,0===arguments.length){var t=this.lookupTemplate(),o=h.__super__.render.call(this,t);return this.renderRegions(),o}return h.__super__.render.call(this,t,e)},h.prototype.renderRegions=function(){var e=this,o=this.lookupRegionTemplates();a("regionTemplates: "+JSON.stringify(o)),t.each(o,function(t,o){e.render(o,t)})},h.prototype.stop=function(){h.__super__.stop.call(this),this._computation&&this._computation.stop(),this.runHooks("onStop","unload"),this.isStopped=!0},h.prototype.redirect=function(){return this.router.go.apply(this.router,arguments)},h.prototype.subscribe=function(){var e=this,o=s.subscribe.apply(this,arguments);return t.extend(o,{wait:function(){e.wait(this)}})},s._reload){s._reload.onMigrate("iron-router",function(){return[!0,!0]});var p=s._reload.migrationData("iron-router");h._hasJustReloaded=p}}.call(this),function(){var e=l.Url,o=l.MiddlewareStack,r=l.utils.assert;y=function(e,r,n){var i=function(t,e,o){var r=this;r.request=t,r.response=e,i.dispatch(t.url,r,o)};return"object"==typeof r&&(n=r,r=n.action),n=n||{},"string"==typeof e&&"/"!==e.charAt(0)&&(e=n.path?n.path:"/"+e),t.extend(i,this),n=i.options=n||{},i._actionStack=new o,i._beforeStack=new o,i._beforeStack.append(i.options.onBeforeAction),i._beforeStack.append(i.options.before),i._afterStack=new o,i._afterStack.append(i.options.onAfterAction),i._afterStack.append(i.options.after),i._methods={},"string"==typeof r?i._actionStack.push(e,t.extend(n,{template:r})):("function"==typeof r||"object"==typeof r)&&i._actionStack.push(e,r,n),i._path=e,i},y.prototype.getName=function(){return this.handler&&this.handler.name},y.prototype.findControllerConstructor=function(){var t=this,e=function(t,e){e=e||{};var o=l.utils.resolve(t);if(o&&h.prototype.isPrototypeOf(o.prototype))return o;if(e.supressErrors!==!0)throw new Error("RouteController '"+t+"' is not defined.");return void 0},o=function(e){return t.router.toControllerName(e)},r,n=this.getName();return"function"==typeof this.options.controller?this.options.controller:"string"==typeof this.options.controller?e(this.options.controller):n&&(r=e(o(n),{supressErrors:!0}))?r:h},y.prototype.createController=function(t){t=t||{};var e=this.findControllerConstructor();t.route=this;var o=new e(t);return o},y.prototype.setControllerParams=function(t,e){},y.prototype.dispatch=function(t,e,o){return r(e._runRoute,"context doesn't have a _runRoute method"),e._runRoute(this,t,o)},y.prototype.path=function(t,e){return this.handler.resolve(t,e)},y.prototype.url=function(t,e){var o=this.path(t,e),r=e&&e.host||s.absoluteUrl();return"/"===r.charAt(r.length-1),r=r.slice(0,r.length-1),r+o},y.prototype.params=function(t){return this.handler.params(t)},t.each(d,function(t){y.prototype[t]=function(e){return this._methods[t]=!0,this._actionStack.push(this._path,e,{name:this.getName()+"_"+t.toLowerCase(),method:t,where:this.handler.where,mount:!1}),this}}),l.Route=y}.call(this),function(){var e=l.MiddlewareStack,o=l.Url,r=l.Layout,n=l.utils.warn,i=l.utils.assert;c=function(o){function r(t,e,o){r.dispatch(t.url,{request:t,response:e},o)}return r._stack=new e,r._globalHooks={},r.routes=[],r.routes._byPath={},this.configure.call(r,o),t.extend(r,this),this.init.call(r,o),s.startup(function(){s.defer(function(){r.options.autoStart!==!1&&r.start()})}),r},c.prototype.init=function(t){},c.prototype.configure=function(e){var o=this;e=e||{};var r=function(e){return e?t.isArray(e)?e:[e]:[]};return t.each(l.Router.HOOK_TYPES,function n(i){e[i]&&(t.each(r(e[i]),function a(t){o.addHook(i,t)}),delete e[i])}),this.options=this.options||{},t.extend(this.options,e),this},c.prototype.map=function(t){return t.call(this)},c.prototype.route=function(t,e,o){var r=function(t){return Object.prototype.toString.call(t)};i("[object String]"===r(t)||"[object RegExp]"===r(t),"Router.route requires a path that is a string or regular expression."),"object"==typeof e&&(o=e,e=o.action);var n=new y(t,e,o);o=o||{},o.mount=!1;var a=this._stack.push(t,n,o);return a.route=n,n.handler=a,n.router=this,i(!this.routes._byPath[a.path],"A route for the path "+JSON.stringify(a.path)+" already exists by the name of "+JSON.stringify(a.name)+"."),this.routes._byPath[a.path]=n,this.routes.push(n),"string"==typeof a.name&&(this.routes[a.name]=n),n},c.prototype.findFirstRoute=function(t){for(var e,o,r=0;r<this.routes.length;r++)if(m=this.routes[r],e=m.handler.test(t,{where:s.isServer?"server":"client"}))return m;return null},c.prototype.path=function(t,e,o){var r=this.routes[t];return n(r,"You called Router.path for a route named "+JSON.stringify(t)+" but that route doesn't seem to exist. Are you sure you created it?"),r&&r.path(e,o)},c.prototype.url=function(t,e,o){var r=this.routes[t];return n(r,"You called Router.url for a route named "+JSON.stringify(t)+" but that route doesn't seem to exist. Are you sure you created it?"),r&&r.url(e,o)},c.prototype.createController=function(t,e){var o=this.findFirstRoute(t),r;return e=e||{},r=o?o.createController({layout:this._layout}):new h({layout:this._layout}),r.router=this,r.configureFromUrl(t,e,{reactive:!1}),r},c.prototype.setTemplateNameConverter=function(t){return this._templateNameConverter=t,this},c.prototype.setControllerNameConverter=function(t){return this._controllerNameConverter=t,this},c.prototype.toTemplateName=function(t){return this._templateNameConverter?this._templateNameConverter(t):l.utils.classCase(t)},c.prototype.toControllerName=function(t){return this._controllerNameConverter?this._controllerNameConverter(t):l.utils.classCase(t)+"Controller"},c.prototype.addHook=function(e,o,r){var n=this;r=r||{};var i=function(e){return e?t.isArray(e)?e:[e]:[]};r.only&&(r.only=i(r.only)),r.except&&(r.except=i(r.except));var a=this._globalHooks[e]=this._globalHooks[e]||[],u=function(){var t=this,e=arguments;return f.withValue(r,function(){return n.lookupHook(o).apply(t,e)})};return a.push({options:r,hook:u}),this},c.prototype.lookupHook=function(e){var o=e;if(t.isFunction(o))return o;if(t.isString(o)&&t.isFunction(l.Router.hooks[o]))return l.Router.hooks[o];throw new Error("No hook found named: "+e)},c.prototype.getHooks=function(e,o){var r=this,n=[];return t.each(this._globalHooks[e],function(e){var r=e.options;return r.except&&t.include(r.except,o)?[]:r.only&&!t.include(r.only,o)?[]:void n.push(e.hook)}),n},c.HOOK_TYPES=["onRun","onRerun","onBeforeAction","onAfterAction","onStop","waitOn","subscriptions","load","before","after","unload"],c.hooks={},c.plugins={},t.each(c.HOOK_TYPES,function(t){c.prototype[t]=function(e,o){this.addHook(t,e,o)}}),c.prototype.plugin=function(t,e){var o;if("function"==typeof t?o=t:"string"==typeof t&&(o=l.Router.plugins[t]),!o)throw new Error("No plugin found named "+JSON.stringify(t));return o.call(this,this,e),this},l.Router=c}.call(this),function(){if("undefined"!=typeof a)var t=new a("DefaultLoadingTemplate",function(){return"Loading..."}),e=new a("DefaultDataNotFoundTemplate",function(){return"Data not found..."});c.hooks.loading=function(){if(this.ready())return void this.next();var e=this.lookupOption("loadingTemplate");this.render(e||t),this.renderRegions()},c.hooks.dataNotFound=function(){if(!this.ready())return void this.next();var t=this.lookupOption("data"),o,r=this.lookupOption("notFoundTemplate");return"function"!=typeof t||(o=t.call(this))?void this.next():(this.render(r||e),void this.renderRegions())}}.call(this),function(){var e=l.utils.warn,o=l.DynamicTemplate,i=l.utils.debug("iron:router <helpers>");n.registerHelper("Router",new r.Template("Router",function(){return c.createView()})),n.registerHelper("pathFor",function(o){var r;arguments.length>1&&(r=arguments[0],o=arguments[1]||{});var n=o&&o.hash;n=n||{};var i="",a=n.query,s=n.hash,r=r||n.route,l=t.extend({},n.data||this),p=c.routes[r];return e(p,"pathFor couldn't find a route named "+JSON.stringify(r)),p&&(t.each(p.handler.compiledUrl.keys,function(e){var o=e.name;t.has(n,o)&&(l[o]=u.clone(n[o]),delete n[o])}),i=p.path(l,{query:a,hash:s})),i}),n.registerHelper("urlFor",function(o){var r;arguments.length>1&&(r=arguments[0],o=arguments[1]||{});var n=o&&o.hash;n=n||{};var i="",a=n.query,s=n.hash,r=r||n.route,l=t.extend({},n.data||this),p=c.routes[r];return e(p,"urlFor couldn't find a route named "+JSON.stringify(r)),p&&(t.each(p.handler.compiledUrl.keys,function(e){var o=e.name;t.has(n,o)&&(l[o]=u.clone(n[o]),delete n[o])}),i=p.url(l,{query:a,hash:s})),i}),n.registerHelper("linkTo",new r.Template("linkTo",function(){var n=this,i=o.getInclusionArguments(this);if("object"!=typeof i)throw new Error("linkTo options must be key value pairs such as {{#linkTo route='my.route.name'}}. You passed: "+JSON.stringify(i));i=i||{};var a="",s=i.query,l=i.hash,h=i.route,f=t.extend({},i.data||o.getParentDataContext(this)),d=c.routes[h],y;e(d,"linkTo couldn't find a route named "+JSON.stringify(h)),d&&(t.each(d.handler.compiledUrl.keys,function(e){var o=e.name;t.has(i,o)&&(f[o]=u.clone(i[o]),delete i[o])}),a=d.path(f,{query:s,hash:l}));var m=t.omit(i,"route","query","hash","data");return m.href=a,r.With(function(){return o.getParentDataContext(n)},function(){return p.A(m,n.templateContentBlock)})}))}.call(this),function(){var e=l.MiddlewareStack,r=l.Url,n=l.Layout,i=l.utils.assert,a="__IronRouterNotFound__",u="__IronRouterNoRoutes__";c.prototype.init=function(t){var e=this;e._currentController=null,e._currentRoute=null,e._currentDep=new o.Dependency,e._locationComputation=null,e._layout=new n({template:e.options.layoutTemplate}),s.startup(function(){setTimeout(function t(){e.options.autoRender!==!1&&e.insert({el:document.body})})})},c.prototype.insert=function(t){return this._layout.insert(t),this},c.prototype.createView=function(){return this._layout.create()},c.prototype.lookupNotFoundTemplate=function(){return this.options.notFoundTemplate?this.options.notFoundTemplate:0===this.routes.length?u:a},c.prototype.lookupLayoutTemplate=function(){return this.options.layoutTemplate},c.prototype.dispatch=function(t,e,r){var n=this;i("string"==typeof t,"expected url string in router dispatch");var s=this._currentController,l=this.findFirstRoute(t),p=this._currentRoute;return this._currentRoute=l,this._currentController&&this._currentController.stop(),s&&l&&p===l?s.configureFromUrl(t,e):s=this.createController(t,e),this._currentController=s,s.dispatch(n._stack,t,function c(t){if(t)throw t;if(!s.isHandled()){var e=o.nonreactive(function(){return s.location.get().options.historyState});if(e&&e.initial===!0){this.layout(this.lookupOption("layoutTemplate"),{data:{url:this.url}});var i=this.lookupOption("notFoundTemplate");i||(i=0===n.routes.length?u:a),this.render(i,{data:{url:this.url}}),this.renderRegions(),s.isHandled=function(){return!0}}return r&&r.call(s)}}),this._currentController==s&&this._currentDep.changed(),s},c.prototype.current=function(){return this._currentDep.depend(),this._currentController},c.prototype._scrollToHash=function(t){try{var e=$(t);$("html, body").scrollTop(e.offset().top)}catch(o){}},c.prototype.start=function(){var t=this,e;t._locationComputation=o.autorun(function r(o){var r,n=l.Location.get(),i,a,u,s=t._currentController;!s||e&&e.path!==n.path?r=t.dispatch(n.href,null,function p(t){this.isHandled()||(n.cancelUrlChange(),window.location=n.path)}):(t._scrollToHash(n.hash),s.configureFromUrl(n.href)),e=n})},c.prototype.stop=function(){this._isStarted&&(this._locationComputation&&this._locationComputation.stop(),this._currentController&&this._currentController.stop(),this._isStarted=!1)},c.prototype.go=function(e,o,r){var n=this,a=/^\/|http/,u;if(r=r||{},a.test(e))u=e;else{var s=n.routes[e];i(s,"No route found named "+JSON.stringify(e)),u=s.path(o,t.extend(r,{throwOnMissingParams:!0}))}l.Location.go(u,r)}}.call(this),function(){c.plugins.loading=function(t,e){t.onBeforeAction("loading",e)},c.plugins.dataNotFound=function(t,e){t.onBeforeAction("dataNotFound",e)}}.call(this),function(){c=new l.Router}.call(this),function(){a.__checkName("__IronRouterNotFound__"),a.__IronRouterNotFound__=new a("Template.__IronRouterNotFound__",function(){var t=this;return p.DIV({style:"width: 600px; margin: 0 auto; padding: 20px;"},"\n ",p.DIV({style:"font-size: 18pt; color: #999;"},"\n Oops, looks like there's no route on the client or the server for url: \"",r.View(function(){return Spacebars.mustache(t.lookup("url"))}),'."\n '),"\n ")}),a.__checkName("__IronRouterNoRoutes__"),a.__IronRouterNoRoutes__=new a("Template.__IronRouterNoRoutes__",function(){var t=this;return p.Raw('<div style="font-family: helvetica; color: #777; max-width: 600px; margin: 20px auto;">\n <h1 style="text-align: center; margin: 0; font-size: 48pt;">\n iron:router\n </h1>\n <p style="text-align: center; font-size: 1.3em;">\n Organize your Meteor application.\n </p>\n <div style="margin: 50px 0px;">\n <pre style="background: #f2f2f2; margin: 0; padding: 10px;">\nRouter.route(\'/\', function () {\n this.render(\'Home\', {\n data: function () { return Items.findOne({_id: this.params._id}); }\n });\n});\n </pre>\n </div>\n <div style="margin: 50px 0px;">\n Check it out on Github:<br>\n <a href="https://github.com/eventedmind/iron-router" target="_blank">https://github.com/eventedmind/iron-router</a>\n <br>\n <br>\n And check out the new Guide:<br>\n <a href="https://eventedmind.github.io/iron-router" target="_blank">\n https://eventedmind.github.io/iron-router\n </a>\n </div>\n </div>')})}.call(this),"undefined"==typeof Package&&(Package={}),Package["iron:router"]={Router:c,RouteController:h}}();
+
+!function(){var e=Package.meteor.Meteor,t=Package.underscore._,n;(function(){n={_isCssLoaded:function(){return 0===document.styleSheets.length?!0:t.find(document.styleSheets,function(e){return e.cssText&&!e.cssRules?!e.cssText.match(/meteor-css-not-found-error/):!t.find(e.cssRules,function(e){return".meteor-css-not-found-error"===e.selectorText})})}}}).call(this),"undefined"==typeof Package&&(Package={}),Package.webapp={WebApp:n}}();
+
+!function(){var a=Package.meteor.Meteor,e=Package.ddp.DDP,e,t;"undefined"==typeof Package&&(Package={}),Package.livedata={DDP:e,LivedataTest:t}}();
+
+!function(){var t=Package.meteor.Meteor,n=Package.htmljs.HTML,e=Package.tracker.Tracker,a=Package.tracker.Deps,r=Package.blaze.Blaze,u=Package.blaze.UI,i=Package.blaze.Handlebars,o=Package["observe-sequence"].ObserveSequence,c=Package.templating.Template,l;(function(){l={};var t=function(t,n){return t===n};l.include=function(n,e,a){if(!n)return null;if("function"!=typeof n){var u=n;if(!r.isTemplate(u))throw new Error("Expected template or null, found: "+u);return n.constructView(e,a)}var i=r.ReactiveVar(null,t),o=r.View("Spacebars.include",function(){var t=i.get();if(null===t)return null;if(!r.isTemplate(t))throw new Error("Expected template or null, found: "+t);return t.constructView(e,a)});return o.__templateVar=i,o.onViewCreated(function(){this.autorun(function(){i.set(n())})}),o},l.mustacheImpl=function(t){var n=arguments;if(n.length>1){var e=n[n.length-1];if(e instanceof l.kw){var a={};for(var r in e.hash){var u=e.hash[r];a[r]="function"==typeof u?u():u}n[n.length-1]=l.kw(a)}else e=l.kw(),n=Array.prototype.slice.call(arguments),n.push(e)}return l.call.apply(null,n)},l.mustache=function(t){var e=l.mustacheImpl.apply(null,arguments);return e instanceof l.SafeString?n.Raw(e.toString()):null==e||e===!1?null:String(e)},l.attrMustache=function(t){var e=l.mustacheImpl.apply(null,arguments);if(null==e||""===e)return null;if("object"==typeof e)return e;if("string"==typeof e&&n.isValidAttributeName(e)){var a={};return a[e]="",a}throw new Error("Expected valid attribute name, '', null, or object")},l.dataMustache=function(t){var n=l.mustacheImpl.apply(null,arguments);return n},l.makeRaw=function(t){return null==t?null:t instanceof n.Raw?t:n.Raw(t)},l.call=function(t){if("function"==typeof t){for(var n=[],e=1;e<arguments.length;e++){var a=arguments[e];n[e-1]="function"==typeof a?a():a}return t.apply(null,n)}if(arguments.length>1)throw new Error("Can't call non-function: "+t);return t},l.kw=function(t){return this instanceof l.kw?void(this.hash=t||{}):new l.kw(t)},l.SafeString=function(t){return this instanceof l.SafeString?new i.SafeString(t):new l.SafeString(t)},l.SafeString.prototype=i.SafeString.prototype,l.dot=function(t,n){if(arguments.length>2){var e=[];return e.push(l.dot(t,n)),e.push.apply(e,Array.prototype.slice.call(arguments,2)),l.dot.apply(null,e)}if("function"==typeof t&&(t=t()),!t)return t;var a=t[n];return"function"!=typeof a?a:function(){return a.apply(t,arguments)}},l.With=function(t,n,a){var u=new r.ReactiveVar,i=r.View("Spacebars_with",function(){return r.If(function(){return u.get()},function(){return r.With(function(){return u.get()},n)},a)});return i.onViewCreated(function(){this.autorun(function(){u.set(t()),e.onInvalidate(function(){u.dep.changed()})})}),i},l.TemplateWith=r._TemplateWith}).call(this),function(){c.__checkName("__dynamic"),c.__dynamic=new c("Template.__dynamic",function(){var t=this;return[r.View(function(){return l.mustache(t.lookup("checkContext"))}),"\n ",r.If(function(){return l.call(t.lookup("dataContextPresent"))},function(){return["\n ",l.include(t.lookupTemplate("__dynamicWithDataContext")),"\n "]},function(){return["\n \n ",r._TemplateWith(function(){return{template:l.call(t.lookup("template")),data:l.call(t.lookup(".."))}},function(){return l.include(t.lookupTemplate("__dynamicWithDataContext"))}),"\n "]})]}),c.__checkName("__dynamicWithDataContext"),c.__dynamicWithDataContext=new c("Template.__dynamicWithDataContext",function(){var t=this;return l.With(function(){return l.dataMustache(t.lookup("chooseTemplate"),t.lookup("template"))},function(){return["\n ",r._TemplateWith(function(){return l.call(l.dot(t.lookup(".."),"data"))},function(){return l.include(t.lookupTemplate(".."))})," \n "]})})}.call(this),function(){c.__dynamicWithDataContext.helpers({chooseTemplate:function(t){return c[t]||null}}),c.__dynamic.helpers({dataContextPresent:function(){return _.has(this,"data")},checkContext:function(){if(!_.has(this,"template"))throw new Error("Must specify name in the 'template' argument to {{> Template.dynamic}}.");_.each(this,function(t,n){if("template"!==n&&"data"!==n)throw new Error("Invalid argument to {{> Template.dynamic}}: "+n)})}})}.call(this),"undefined"==typeof Package&&(Package={}),Package.spacebars={Spacebars:l}}();
+
+!function(){var e=Package.meteor.Meteor,a;(function(){var n=0,r=!1;a={hold:function(){if(!e.isCordova)return{release:function(){}};if(r)throw new Error("Can't show launch screen once it's hidden");n++;var a=!1,t=function(){e.isCordova&&(a||(n--,0===n&&"undefined"!=typeof navigator&&navigator.splashscreen&&(r=!0,navigator.splashscreen.hide())))};return{release:t}}}}).call(this),function(){var n=a.hold(),r=Package.templating&&Package.templating.Template;e.startup(function(){if(r)if(Package["iron:router"])Package["iron:router"].Router.onAfterAction(function(){n.release()});else{var e=setInterval(function(){r.body.view&&r.body.view.isRendered&&(n.release(),clearInterval(e))},50);setTimeout(function(){n.release()},6e3)}else n.release()})}.call(this),"undefined"==typeof Package&&(Package={}),Package["launch-screen"]={LaunchScreen:a}}();
+
+FastClick=Package.fastclick.FastClick,Cookie=Package["chuangbo:cookie"].Cookie,moment=Package["jeeeyul:moment-with-langs"].moment,TAPi18next=Package["tap:i18n"].TAPi18next,TAPi18n=Package["tap:i18n"].TAPi18n,Helpers=Package["raix:handlebar-helpers"].Helpers,TemplateVar=Package["frozeman:template-var"].TemplateVar,PersistentMinimongo=Package["frozeman:persistent-minimongo"].PersistentMinimongo,ReactiveTimer=Package["frozeman:reactive-timer"].ReactiveTimer,BigNumber=Package["3stack:bignumber"].BigNumber,Showdown=Package.markdown.Showdown,numeral=Package["numeral:numeral"].numeral,EthTools=Package["ethereum:tools"].EthTools,Router=Package["iron:router"].Router,RouteController=Package["iron:router"].RouteController,Meteor=Package.meteor.Meteor,WebApp=Package.webapp.WebApp,Log=Package.logging.Log,Tracker=Package.deps.Tracker,Deps=Package.deps.Deps,Session=Package.session.Session,DDP=Package.livedata.DDP,Mongo=Package.mongo.Mongo,Blaze=Package.ui.Blaze,UI=Package.ui.UI,Handlebars=Package.ui.Handlebars,Spacebars=Package.spacebars.Spacebars,Template=Package.templating.Template,check=Package.check.check,Match=Package.check.Match,_=Package.underscore._,$=Package.jquery.$,jQuery=Package.jquery.jQuery,Random=Package.random.Random,EJSON=Package.ejson.EJSON,LaunchScreen=Package["launch-screen"].LaunchScreen,Iron=Package["iron:core"].Iron,HTML=Package.htmljs.HTML;
+
+!function(){Template.__checkName("layout_notFound"),Template.layout_notFound=new Template("Template.layout_notFound",function(){var n=this;return HTML.Raw('<main class="dapp-content">\n <h1>Nothing here...</h1>\n </main>')})}();
+
+!function(){Template.__checkName("views_home"),Template.views_home=new Template("Template.views_home",function(){var e=this;return[HTML.H2({"class":"page-title"}," ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.NetworkHealth")})),"\n \n\n ",HTML.H2(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Mining")})," "),"\n \n ",HTML.DIV({"class":"dapp container mining-stats"},"\n ",HTML.DIV({"class":"mining-slider dapp-big-number"},"\n ",HTML.INPUT({type:"range",name:"fee",min:"0",max:"1",step:"1",value:function(){return Spacebars.mustache(e.lookup("miningSlider"))},"class":"slider-vertical"}),"\n ",HTML.DD(Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.MiningStatus")})),"\n ",HTML.DT({"class":"mining-status"},"\n ",Blaze.If(function(){return Spacebars.call(e.lookup("miningSlider"))},function(){return["\n ",Blaze.If(function(){return Spacebars.call(e.lookup("hashrate"))},function(){return["\n ",Blaze.View(function(){return Spacebars.mustache(e.lookup("hashrate"))})," ",HTML.SMALL("KHash "),"\n "]},function(){return["\n ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.on")}),"\n "]}),"\n "]},function(){return["\n ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.off")}),"\n "]}),"\n \n "),"\n "),"\n ",HTML.DIV({"class":"dapp-big-number"},"\n ",HTML.DD(Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.TimeSpent")})),"\n ",HTML.DT({"class":"time-spent"},Blaze.View(function(){return Spacebars.makeRaw(Spacebars.mustache(e.lookup("timeSpent")))})),"\n ")," \n ",HTML.DIV({"class":"dapp-big-number"},"\n ",HTML.DD(Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Rewards")})),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.makeRaw(Spacebars.mustache(e.lookup("totalRewards")))})),"\n ")," \n ",HTML.DIV({"class":"dapp-big-number"},"\n ",HTML.DD(Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.AverageReward")})),"\n ",HTML.DT(" ",Blaze.View(function(){return Spacebars.makeRaw(Spacebars.mustache(e.lookup("averageRewardPerHour")))})),"\n ")," \n "),"\n\n \n ",HTML.H2(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Connections")})," "),"\n\n ",HTML.DIV({"class":"dapp-container"},"\n\n ",HTML.DL({"class":"latest-block-info"},"\n\n ",HTML.DIV({"class":"dapp-big-number"},"\n ",HTML.DD(Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.PeerCount")})),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.mustache(e.lookup("peerCount"))})," ",HTML.SMALL(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Peers")})," ")),"\n "),"\n ",HTML.DIV({"class":"dapp-big-number"},"\n ",HTML.DD(Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.GasPrice")})),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.mustache(e.lookup("gasPrice"))})," ",HTML.SMALL(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Finney")})," ")),"\n "),"\n "),"\n\n "),"\n \n ",HTML.H2(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Blockchain")})," "),"\n\n ",HTML.DIV({"class":"block-chain"},"\n ",HTML.DIV({"class":"wrapper"},"\n ",Blaze.Each(function(){return Spacebars.call(e.lookup("blocks"))},function(){return["\n ",HTML.DIV({"class":"dapp-box card",style:function(){return["background-image:",Spacebars.mustache(e.lookup("currentBlockPattern"))]}},"\n ",Blaze._TemplateWith(function(){return{identity:Spacebars.call("miner")}},function(){return Spacebars.include(e.lookupTemplate("dapp_identicon"))}),"\n ",HTML.H1(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Block")})," ",Blaze.View(function(){return Spacebars.mustache(e.lookup("number"))})),"\n ",HTML.H3(Blaze.View(function(){return Spacebars.mustache(e.lookup("hash"))})),"\n ",HTML.DL("\n ",HTML.DD(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.GasUsed")})," "),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.mustache(e.lookup("gasUsed"))})),"\n ",HTML.DD(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Size")})," "),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.mustache(e.lookup("size"))})),"\n ",HTML.DD(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Uncles")})," "),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.mustache(e.lookup("uncles"))})),"\n ",HTML.DD(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.Time")})," "),"\n ",HTML.DT(Blaze.View(function(){return Spacebars.mustache(e.lookup("formatTime"),e.lookup("time"),"YYYY-MM-DD HH:mm:ss")})),"\n "),"\n "),"\n "]}),"\n ",HTML.DIV({"class":"",style:""},"\n ",HTML.H3(" ",Blaze.View(function(){return Spacebars.mustache(e.lookup("i18n"),"network.home.EndOfBlocks")})," "),"\n "),"\n "),"\n ")]})}();
+
+!function(){Template.body.addContent(function(){var e=this;return[Spacebars.include(e.lookupTemplate("layout_main")),HTML.Raw('\n \n <!-- Form Helper iFrame -->\n <iframe id="dapp-form-helper-iframe" name="dapp-form-helper-iframe" src="javascript:false;"></iframe>')]}),Meteor.startup(Template.body.renderToDocument)}();
+
+!function(){Template.__checkName("layout_main"),Template.layout_main=new Template("Template.layout_main",function(){var n=this;return[HTML.Raw('<!-- <div class="dapp-grid"></div>\n --> \n '),HTML.DIV({"class":"dapp-flex-content"},"\n\n ",HTML.Raw("<!-- content -->"),"\n ",HTML.MAIN({"class":"dapp-content"},"\n ",Spacebars.include(n.lookupTemplate("views_home")),"\n "),"\n\n ")]})}();
+
+!function(){Helpers={},Helpers.rerun={"10s":new ReactiveTimer(10)},Helpers.getLocalStorageSize=function(){var e=0;return localStorage&&_.each(Object.keys(localStorage),function(n){e+=2*localStorage[n].length/1024/1024}),e},Helpers.moment=function(e){return TAPi18n.getLanguage(),_.isFinite(e)&&moment.unix(e).isValid()?moment.unix(e):moment(e)},Helpers.formatTime=function(e,n){return n instanceof Spacebars.kw&&(n=null),e?(_.isString(n)&&!_.isEmpty(n)&&("iso"===n.toLowerCase()?e=Helpers.moment(e).toISOString():"fromnow"===n.toLowerCase()?(Helpers.rerun["10s"].tick(),e=Helpers.moment(e).fromNow()):e=Helpers.moment(e).format(n)),e):""}}();
+
+!function(){Template.registerHelper("debug",function(e){console.log(e)}),Template.registerHelper("username",function(e){var t=Users.findOne(e);return Whisper.getIdentity().identity===e?Whisper.getIdentity().name:t?t.name:"anonymous"}),Template.registerHelper("currentIdentity",function(e){return Whisper.getIdentity()}),Template.registerHelper("formatTime",Helpers.formatTime)}();
+
+!function(){!function(){function a(e){if(!(this instanceof a))return new a(e);if("function"==typeof e)return this.random=e,this;var n;arguments.length&&(this.seed=0);for(var i=0;i<arguments.length;i++){if(n=0,"string"==typeof arguments[i])for(var t=0;t<arguments[i].length;t++)n+=(arguments[i].length-t)*arguments[i].charCodeAt(t);else n=arguments[i];this.seed+=(arguments.length-i)*n}return this.mt=this.mersenne_twister(this.seed),this.random=function(){return this.mt.random(this.seed)},this}function e(a,e){if(a||(a={}),e)for(var n in e)"undefined"==typeof a[n]&&(a[n]=e[n]);return a}function n(a,e){if(a)throw new RangeError(e)}function i(a){return function(){return this.natural(a)}}function t(a,e){for(var n=y(a),i=0,t=n.length;t>i;i++)key=n[i],e[key]=a[key]||e[key]}function r(a,e){for(var n=0,i=a.length;i>n;n++)e[n]=a[n]}function o(a,e){var n=Array.isArray(a),i=e||(n?new Array(a.length):{});return n?r(a,i):t(a,i),i}var s=9007199254740992,m=-s,l="0123456789",b="abcdefghijklmnopqrstuvwxyz",h=b.toUpperCase(),c=l+"abcdef",u=Array.prototype.slice;a.prototype.VERSION="0.7.1";var d=function(){throw new Error("No Base64 encoder available.")};!function(){"function"==typeof btoa?d=btoa:"function"==typeof Buffer&&(d=function(a){return new Buffer(a).toString("base64")})}(),a.prototype.bool=function(a){return a=e(a,{likelihood:50}),n(a.likelihood<0||a.likelihood>100,"Chance: Likelihood accepts values from 0 to 100."),100*this.random()<a.likelihood},a.prototype.character=function(a){a=e(a);var i,t,r="!@#$%^&*()[]";return n(a.alpha&&a.symbols,"Chance: Cannot specify both alpha and symbols."),i="lower"===a.casing?b:"upper"===a.casing?h:b+h,t=a.pool?a.pool:a.alpha?i:a.symbols?r:i+l+r,t.charAt(this.natural({max:t.length-1}))},a.prototype.floating=function(a){var i;a=e(a,{fixed:4});var t=Math.pow(10,a.fixed);n(a.fixed&&a.precision,"Chance: Cannot specify both fixed and precision.");var r=s/t,o=-r;n(a.min&&a.fixed&&a.min<o,"Chance: Min specified is out of range with fixed. Min should be, at least, "+o),n(a.max&&a.fixed&&a.max>r,"Chance: Max specified is out of range with fixed. Max should be, at most, "+r),a=e(a,{min:o,max:r}),i=this.integer({min:a.min*t,max:a.max*t});var m=(i/t).toFixed(a.fixed);return parseFloat(m)},a.prototype.integer=function(a){return a=e(a,{min:m,max:s}),n(a.min>a.max,"Chance: Min cannot be greater than Max."),Math.floor(this.random()*(a.max-a.min+1)+a.min)},a.prototype.natural=function(a){return a=e(a,{min:0,max:s}),this.integer(a)},a.prototype.string=function(a){a=e(a);var n=a.length||this.natural({min:5,max:20}),i=a.pool,t=this.n(this.character,n,{pool:i});return t.join("")},a.prototype.capitalize=function(a){return a.charAt(0).toUpperCase()+a.substr(1)},a.prototype.mixin=function(e){for(var n in e)a.prototype[n]=e[n];return this},a.prototype.unique=function(a,n,i){i=e(i,{comparator:function(a,e){return-1!==a.indexOf(e)}});for(var t,r=[],o=0,s=50*n,m=u.call(arguments,2);r.length<n;)if(t=a.apply(this,m),i.comparator(r,t)||(r.push(t),o=0),++o>s)throw new RangeError("Chance: num is likely too large for sample set");return r},a.prototype.n=function(a,e){var n=e||1,i=[],t=u.call(arguments,2);for(n=Math.max(0,n),null;n--;null)i.push(a.apply(this,t));return i},a.prototype.pad=function(a,e,n){return n=n||"0",a+="",a.length>=e?a:new Array(e-a.length+1).join(n)+a},a.prototype.pick=function(a,e){if(0===a.length)throw new RangeError("Chance: Cannot pick() from an empty array");return e&&1!==e?this.shuffle(a).slice(0,e):a[this.natural({max:a.length-1})]},a.prototype.shuffle=function(a){for(var e=a.slice(0),n=[],i=0,t=Number(e.length),r=0;t>r;r++)i=this.natural({max:e.length-1}),n[r]=e[i],e.splice(i,1);return n},a.prototype.weighted=function(a,e){if(a.length!==e.length)throw new RangeError("Chance: length of array and weights must match");if(e.some(function(a){return 1>a})){var n=e.reduce(function(a,e){return a>e?e:a},e[0]),i=1/n;e=e.map(function(a){return a*i})}var t,r=e.reduce(function(a,e){return a+e},0),o=this.natural({min:1,max:r}),s=0;return e.some(function(e,n){return s+e>=o?(t=a[n],!0):(s+=e,!1)}),t},a.prototype.paragraph=function(a){a=e(a);var n=a.sentences||this.natural({min:3,max:7}),i=this.n(this.sentence,n);return i.join(" ")},a.prototype.sentence=function(a){a=e(a);var n,i=a.words||this.natural({min:12,max:18}),t=this.n(this.word,i);return n=t.join(" "),n=this.capitalize(n)+"."},a.prototype.syllable=function(a){a=e(a);for(var n,i=a.length||this.natural({min:2,max:3}),t="bcdfghjklmnprstvwz",r="aeiou",o=t+r,s="",m=0;i>m;m++)n=this.character(0===m?{pool:o}:-1===t.indexOf(n)?{pool:t}:{pool:r}),s+=n;return s},a.prototype.word=function(a){a=e(a),n(a.syllables&&a.length,"Chance: Cannot specify both syllables AND length.");var i=a.syllables||this.natural({min:1,max:3}),t="";if(a.length){do t+=this.syllable();while(t.length<a.length);t=t.substring(0,a.length)}else for(var r=0;i>r;r++)t+=this.syllable();return t},a.prototype.age=function(a){a=e(a);var n;switch(a.type){case"child":n={min:1,max:12};break;case"teen":n={min:13,max:19};break;case"adult":n={min:18,max:65};break;case"senior":n={min:65,max:100};break;case"all":n={min:1,max:100};break;default:n={min:18,max:65}}return this.natural(n)},a.prototype.birthday=function(a){return a=e(a,{year:(new Date).getFullYear()-this.age(a)}),this.date(a)},a.prototype.cpf=function(){var a=this.n(this.natural,9,{max:9}),e=2*a[8]+3*a[7]+4*a[6]+5*a[5]+6*a[4]+7*a[3]+8*a[2]+9*a[1]+10*a[0];e=11-e%11,e>=10&&(e=0);var n=2*e+3*a[8]+4*a[7]+5*a[6]+6*a[5]+7*a[4]+8*a[3]+9*a[2]+10*a[1]+11*a[0];return n=11-n%11,n>=10&&(n=0),""+a[0]+a[1]+a[2]+"."+a[3]+a[4]+a[5]+"."+a[6]+a[7]+a[8]+"-"+e+n},a.prototype.first=function(a){return a=e(a,{gender:this.gender()}),this.pick(this.get("firstNames")[a.gender.toLowerCase()])},a.prototype.gender=function(){return this.pick(["Male","Female"])},a.prototype.last=function(){return this.pick(this.get("lastNames"))},a.prototype.name=function(a){a=e(a);var n,i=this.first(a),t=this.last();return n=a.middle?i+" "+this.first(a)+" "+t:a.middle_initial?i+" "+this.character({alpha:!0,casing:"upper"})+". "+t:i+" "+t,a.prefix&&(n=this.prefix(a)+" "+n),a.suffix&&(n=n+" "+this.suffix(a)),n},a.prototype.name_prefixes=function(a){a=a||"all",a=a.toLowerCase();var e=[{name:"Doctor",abbreviation:"Dr."}];return("male"===a||"all"===a)&&e.push({name:"Mister",abbreviation:"Mr."}),("female"===a||"all"===a)&&(e.push({name:"Miss",abbreviation:"Miss"}),e.push({name:"Misses",abbreviation:"Mrs."})),e},a.prototype.prefix=function(a){return this.name_prefix(a)},a.prototype.name_prefix=function(a){return a=e(a,{gender:"all"}),a.full?this.pick(this.name_prefixes(a.gender)).name:this.pick(this.name_prefixes(a.gender)).abbreviation},a.prototype.ssn=function(a){a=e(a,{ssnFour:!1,dashes:!0});var n,i="1234567890",t=a.dashes?"-":"";return n=a.ssnFour?this.string({pool:i,length:4}):this.string({pool:i,length:3})+t+this.string({pool:i,length:2})+t+this.string({pool:i,length:4})},a.prototype.name_suffixes=function(){var a=[{name:"Doctor of Osteopathic Medicine",abbreviation:"D.O."},{name:"Doctor of Philosophy",abbreviation:"Ph.D."},{name:"Esquire",abbreviation:"Esq."},{name:"Junior",abbreviation:"Jr."},{name:"Juris Doctor",abbreviation:"J.D."},{name:"Master of Arts",abbreviation:"M.A."},{name:"Master of Business Administration",abbreviation:"M.B.A."},{name:"Master of Science",abbreviation:"M.S."},{name:"Medical Doctor",abbreviation:"M.D."},{name:"Senior",abbreviation:"Sr."},{name:"The Third",abbreviation:"III"},{name:"The Fourth",abbreviation:"IV"}];return a},a.prototype.suffix=function(a){return this.name_suffix(a)},a.prototype.name_suffix=function(a){return a=e(a),a.full?this.pick(this.name_suffixes()).name:this.pick(this.name_suffixes()).abbreviation},a.prototype.android_id=function(){return"APA91"+this.string({pool:"0123456789abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",length:178})},a.prototype.apple_token=function(){return this.string({pool:"abcdef1234567890",length:64})},a.prototype.wp8_anid2=function(){return d(this.hash({length:32}))},a.prototype.wp7_anid=function(){return"A="+this.guid().replace(/-/g,"").toUpperCase()+"&E="+this.hash({length:3})+"&W="+this.integer({min:0,max:9})},a.prototype.bb_pin=function(){return this.hash({length:8})},a.prototype.color=function(a){function n(a,e){return[a,a,a].join(e||"")}a=e(a,{format:this.pick(["hex","shorthex","rgb","0x"]),grayscale:!1,casing:"lower"});var i,t=a.grayscale;if("hex"===a.format)i="#"+(t?n(this.hash({length:2})):this.hash({length:6}));else if("shorthex"===a.format)i="#"+(t?n(this.hash({length:1})):this.hash({length:3}));else if("rgb"===a.format)i=t?"rgb("+n(this.natural({max:255}),",")+")":"rgb("+this.natural({max:255})+","+this.natural({max:255})+","+this.natural({max:255})+")";else{if("0x"!==a.format)throw new Error('Invalid format provided. Please provide one of "hex", "shorthex", "rgb" or "0x".');i="0x"+(t?n(this.hash({length:2})):this.hash({length:6}))}return"upper"===a.casing&&(i=i.toUpperCase()),i},a.prototype.domain=function(a){return a=e(a),this.word()+"."+(a.tld||this.tld())},a.prototype.email=function(a){return a=e(a),this.word({length:a.length})+"@"+(a.domain||this.domain())},a.prototype.fbid=function(){return parseInt("10000"+this.natural({max:1e11}),10)},a.prototype.google_analytics=function(){var a=this.pad(this.natural({max:999999}),6),e=this.pad(this.natural({max:99}),2);return"UA-"+a+"-"+e},a.prototype.hashtag=function(){return"#"+this.word()},a.prototype.ip=function(){return this.natural({max:255})+"."+this.natural({max:255})+"."+this.natural({max:255})+"."+this.natural({max:255})},a.prototype.ipv6=function(){var a=this.n(this.hash,8,{length:4});return a.join(":")},a.prototype.klout=function(){return this.natural({min:1,max:99})},a.prototype.tlds=function(){return["com","org","edu","gov","co.uk","net","io"]},a.prototype.tld=function(){return this.pick(this.tlds())},a.prototype.twitter=function(){return"@"+this.word()},a.prototype.url=function(a){a=e(a,{protocol:"http",domain:this.domain(a),domain_prefix:"",path:this.word(),extensions:[]});var n=a.extensions.length>0?"."+this.pick(a.extensions):"",i=a.domain_prefix?a.domain_prefix+"."+a.domain:a.domain;return a.protocol+"://"+i+"/"+a.path+n},a.prototype.address=function(a){return a=e(a),this.natural({min:5,max:2e3})+" "+this.street(a)},a.prototype.altitude=function(a){return a=e(a,{fixed:5,max:8848}),this.floating({min:0,max:a.max,fixed:a.fixed})},a.prototype.areacode=function(a){a=e(a,{parens:!0});var n=this.natural({min:2,max:9}).toString()+this.natural({min:0,max:8}).toString()+this.natural({min:0,max:9}).toString();return a.parens?"("+n+")":n},a.prototype.city=function(){return this.capitalize(this.word({syllables:3}))},a.prototype.coordinates=function(a){return a=e(a),this.latitude(a)+", "+this.longitude(a)},a.prototype.countries=function(){return this.get("countries")},a.prototype.country=function(a){a=e(a);var n=this.pick(this.countries());return a.full?n.name:n.abbreviation},a.prototype.depth=function(a){return a=e(a,{fixed:5,min:-2550}),this.floating({min:a.min,max:0,fixed:a.fixed})},a.prototype.geohash=function(a){return a=e(a,{length:7}),this.string({length:a.length,pool:"0123456789bcdefghjkmnpqrstuvwxyz"})},a.prototype.geojson=function(a){return a=e(a),this.latitude(a)+", "+this.longitude(a)+", "+this.altitude(a)},a.prototype.latitude=function(a){return a=e(a,{fixed:5,min:-90,max:90}),this.floating({min:a.min,max:a.max,fixed:a.fixed})},a.prototype.longitude=function(a){return a=e(a,{fixed:5,min:-180,max:180}),this.floating({min:a.min,max:a.max,fixed:a.fixed})},a.prototype.phone=function(a){var n,i=this,t=function(a){var e=[];return a.sections.forEach(function(a){e.push(i.string({pool:"0123456789",length:a}))}),a.area+e.join(" ")};a=e(a,{formatted:!0,country:"us",mobile:!1}),a.formatted||(a.parens=!1);var r;switch(a.country){case"fr":a.mobile?(n=this.pick(["06","07"])+i.string({pool:"0123456789",length:8}),r=a.formatted?n.match(/../g).join(" "):n):(n=this.pick(["01"+this.pick(["30","34","39","40","41","42","43","44","45","46","47","48","49","53","55","56","58","60","64","69","70","72","73","74","75","76","77","78","79","80","81","82","83"])+i.string({pool:"0123456789",length:6}),"02"+this.pick(["14","18","22","23","28","29","30","31","32","33","34","35","36","37","38","40","41","43","44","45","46","47","48","49","50","51","52","53","54","56","57","61","62","69","72","76","77","78","85","90","96","97","98","99"])+i.string({pool:"0123456789",length:6}),"03"+this.pick(["10","20","21","22","23","24","25","26","27","28","29","39","44","45","51","52","54","55","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","80","81","82","83","84","85","86","87","88","89","90"])+i.string({pool:"0123456789",length:6}),"04"+this.pick(["11","13","15","20","22","26","27","30","32","34","37","42","43","44","50","56","57","63","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","88","89","90","91","92","93","94","95","97","98"])+i.string({pool:"0123456789",length:6}),"05"+this.pick(["08","16","17","19","24","31","32","33","34","35","40","45","46","47","49","53","55","56","57","58","59","61","62","63","64","65","67","79","81","82","86","87","90","94"])+i.string({pool:"0123456789",length:6}),"09"+i.string({pool:"0123456789",length:8})]),r=a.formatted?n.match(/../g).join(" "):n);break;case"uk":a.mobile?(n=this.pick([{area:"07"+this.pick(["4","5","7","8","9"]),sections:[2,6]},{area:"07624 ",sections:[6]}]),r=a.formatted?t(n):t(n).replace(" ","")):(n=this.pick([{area:"01"+this.character({pool:"234569"})+"1 ",sections:[3,4]},{area:"020 "+this.character({pool:"378"}),sections:[3,4]},{area:"023 "+this.character({pool:"89"}),sections:[3,4]},{area:"024 7",sections:[3,4]},{area:"028 "+this.pick(["25","28","37","71","82","90","92","95"]),sections:[2,4]},{area:"012"+this.pick(["04","08","54","76","97","98"])+" ",sections:[5]},{area:"013"+this.pick(["63","64","84","86"])+" ",sections:[5]},{area:"014"+this.pick(["04","20","60","61","80","88"])+" ",sections:[5]},{area:"015"+this.pick(["24","27","62","66"])+" ",sections:[5]},{area:"016"+this.pick(["06","29","35","47","59","95"])+" ",sections:[5]},{area:"017"+this.pick(["26","44","50","68"])+" ",sections:[5]},{area:"018"+this.pick(["27","37","84","97"])+" ",sections:[5]},{area:"019"+this.pick(["00","05","35","46","49","63","95"])+" ",sections:[5]}]),r=a.formatted?t(n):t(n).replace(" ","","g"));break;case"us":var o=this.areacode(a).toString(),s=this.natural({min:2,max:9}).toString()+this.natural({min:0,max:9}).toString()+this.natural({min:0,max:9}).toString(),m=this.natural({min:1e3,max:9999}).toString();r=a.formatted?o+" "+s+"-"+m:o+s+m}return r},a.prototype.postal=function(){var a=this.character({pool:"XVTSRPNKLMHJGECBA"}),e=a+this.natural({max:9})+this.character({alpha:!0,casing:"upper"}),n=this.natural({max:9})+this.character({alpha:!0,casing:"upper"})+this.natural({max:9});return e+" "+n},a.prototype.provinces=function(){return this.get("provinces")},a.prototype.province=function(a){return a&&a.full?this.pick(this.provinces()).name:this.pick(this.provinces()).abbreviation},a.prototype.state=function(a){return a&&a.full?this.pick(this.states(a)).name:this.pick(this.states(a)).abbreviation},a.prototype.states=function(a){a=e(a);var n,i=this.get("us_states_and_dc"),t=this.get("territories"),r=this.get("armed_forces");return n=i,a.territories&&(n=n.concat(t)),a.armed_forces&&(n=n.concat(r)),n},a.prototype.street=function(a){a=e(a);var n=this.word({syllables:2});return n=this.capitalize(n),n+=" ",n+=a.short_suffix?this.street_suffix().abbreviation:this.street_suffix().name},a.prototype.street_suffix=function(){return this.pick(this.street_suffixes())},a.prototype.street_suffixes=function(){return this.get("street_suffixes")},a.prototype.zip=function(a){var e=this.n(this.natural,5,{max:9});return a&&a.plusfour===!0&&(e.push("-"),e=e.concat(this.n(this.natural,4,{max:9}))),e.join("")},a.prototype.ampm=function(){return this.bool()?"am":"pm"},a.prototype.date=function(a){var n,i;if(a&&(a.min||a.max)){a=e(a,{american:!0,string:!1});var t="undefined"!=typeof a.min?a.min.getTime():1,r="undefined"!=typeof a.max?a.max.getTime():864e13;i=new Date(this.natural({min:t,max:r}))}else{var o=this.month({raw:!0});a=e(a,{year:parseInt(this.year(),10),month:o.numeric-1,day:this.natural({min:1,max:o.days}),hour:this.hour(),minute:this.minute(),second:this.second(),millisecond:this.millisecond(),american:!0,string:!1}),i=new Date(a.year,a.month,a.day,a.hour,a.minute,a.second,a.millisecond)}return n=a.american?i.getMonth()+1+"/"+i.getDate()+"/"+i.getFullYear():i.getDate()+"/"+(i.getMonth()+1)+"/"+i.getFullYear(),a.string?n:i},a.prototype.hammertime=function(a){return this.date(a).getTime()},a.prototype.hour=function(a){return a=e(a,{min:1,max:a&&a.twentyfour?24:12}),n(a.min<1,"Chance: Min cannot be less than 1."),n(a.twentyfour&&a.max>24,"Chance: Max cannot be greater than 24 for twentyfour option."),n(!a.twentyfour&&a.max>12,"Chance: Max cannot be greater than 12."),n(a.min>a.max,"Chance: Min cannot be greater than Max."),this.natural({min:a.min,max:a.max})},a.prototype.millisecond=function(){return this.natural({max:999})},a.prototype.minute=a.prototype.second=function(a){return a=e(a,{min:0,max:59}),n(a.min<0,"Chance: Min cannot be less than 0."),n(a.max>59,"Chance: Max cannot be greater than 59."),n(a.min>a.max,"Chance: Min cannot be greater than Max."),this.natural({min:a.min,max:a.max})},a.prototype.month=function(a){a=e(a,{min:1,max:12}),n(a.min<1,"Chance: Min cannot be less than 1."),n(a.max>12,"Chance: Max cannot be greater than 12."),n(a.min>a.max,"Chance: Min cannot be greater than Max.");var i=this.pick(this.months().slice(a.min-1,a.max));return a.raw?i:i.name},a.prototype.months=function(){return this.get("months")},a.prototype.second=function(){return this.natural({max:59})},a.prototype.timestamp=function(){return this.natural({min:1,max:parseInt((new Date).getTime()/1e3,10)})},a.prototype.year=function(a){return a=e(a,{min:(new Date).getFullYear()}),a.max="undefined"!=typeof a.max?a.max:a.min+100,this.natural(a).toString()},a.prototype.cc=function(a){a=e(a);var n,i,t;return n=this.cc_type(a.type?{name:a.type,raw:!0}:{raw:!0}),i=n.prefix.split(""),t=n.length-n.prefix.length-1,i=i.concat(this.n(this.integer,t,{min:0,max:9})),i.push(this.luhn_calculate(i.join(""))),i.join("")},a.prototype.cc_types=function(){return this.get("cc_types")},a.prototype.cc_type=function(a){a=e(a);var n=this.cc_types(),i=null;if(a.name){for(var t=0;t<n.length;t++)if(n[t].name===a.name||n[t].short_name===a.name){i=n[t];break}if(null===i)throw new Error("Credit card type '"+a.name+"'' is not supported")}else i=this.pick(n);return a.raw?i:i.name},a.prototype.currency_types=function(){return this.get("currency_types")},a.prototype.currency=function(){return this.pick(this.currency_types())},a.prototype.currency_pair=function(a){var e=this.unique(this.currency,2,{comparator:function(a,e){return a.reduce(function(a,n){return a||n.code===e.code},!1)}});return a?e[0]+"/"+e[1]:e},a.prototype.dollar=function(a){a=e(a,{max:1e4,min:0});var n=this.floating({min:a.min,max:a.max,fixed:2}).toString(),i=n.split(".")[1];return void 0===i?n+=".00":i.length<2&&(n+="0"),0>n?"-$"+n.replace("-",""):"$"+n},a.prototype.exp=function(a){a=e(a);var n={};return n.year=this.exp_year(),n.month=n.year===(new Date).getFullYear()?this.exp_month({future:!0}):this.exp_month(),a.raw?n:n.month+"/"+n.year},a.prototype.exp_month=function(a){a=e(a);var n,i,t=(new Date).getMonth();if(a.future){do n=this.month({raw:!0}).numeric,i=parseInt(n,10);while(t>i)}else n=this.month({raw:!0}).numeric;return n},a.prototype.exp_year=function(){return this.year({max:(new Date).getFullYear()+10})},a.prototype.d4=i({min:1,max:4}),a.prototype.d6=i({min:1,max:6}),a.prototype.d8=i({min:1,max:8}),a.prototype.d10=i({min:1,max:10}),a.prototype.d12=i({min:1,max:12}),a.prototype.d20=i({min:1,max:20}),a.prototype.d30=i({min:1,max:30}),a.prototype.d100=i({min:1,max:100}),a.prototype.rpg=function(a,n){if(n=e(n),null===a)throw new Error("A type of die roll must be included");var i=a.toLowerCase().split("d"),t=[];if(2!==i.length||!parseInt(i[0],10)||!parseInt(i[1],10))throw new Error("Invalid format provided. Please provide #d# where the first # is the number of dice to roll, the second # is the max of each die");for(var r=i[0];r>0;r--)t[r-1]=this.natural({min:1,max:i[1]});return"undefined"!=typeof n.sum&&n.sum?t.reduce(function(a,e){return a+e}):t},a.prototype.guid=function(a){a=e(a,{version:5});var n="abcdef1234567890",i="ab89",t=this.string({pool:n,length:8})+"-"+this.string({pool:n,length:4})+"-"+a.version+this.string({pool:n,length:3})+"-"+this.string({pool:i,length:1})+this.string({pool:n,length:3})+"-"+this.string({pool:n,length:12});return t},a.prototype.hash=function(a){a=e(a,{length:40,casing:"lower"});var n="upper"===a.casing?c.toUpperCase():c;return this.string({pool:n,length:a.length})},a.prototype.luhn_check=function(a){var e=a.toString(),n=+e.substring(e.length-1);return n===this.luhn_calculate(+e.substring(0,e.length-1))},a.prototype.luhn_calculate=function(a){for(var e,n=a.toString().split("").reverse(),i=0,t=0,r=n.length;r>t;++t)e=+n[t],t%2===0&&(e*=2,e>9&&(e-=9)),i+=e;return 9*i%10};var p={firstNames:{male:["James","John","Robert","Michael","William","David","Richard","Joseph","Charles","Thomas","Christopher","Daniel","Matthew","George","Donald","Anthony","Paul","Mark","Edward","Steven","Kenneth","Andrew","Brian","Joshua","Kevin","Ronald","Timothy","Jason","Jeffrey","Frank","Gary","Ryan","Nicholas","Eric","Stephen","Jacob","Larry","Jonathan","Scott","Raymond","Justin","Brandon","Gregory","Samuel","Benjamin","Patrick","Jack","Henry","Walter","Dennis","Jerry","Alexander","Peter","Tyler","Douglas","Harold","Aaron","Jose","Adam","Arthur","Zachary","Carl","Nathan","Albert","Kyle","Lawrence","Joe","Willie","Gerald","Roger","Keith","Jeremy","Terry","Harry","Ralph","Sean","Jesse","Roy","Louis","Billy","Austin","Bruce","Eugene","Christian","Bryan","Wayne","Russell","Howard","Fred","Ethan","Jordan","Philip","Alan","Juan","Randy","Vincent","Bobby","Dylan","Johnny","Phillip","Victor","Clarence","Ernest","Martin","Craig","Stanley","Shawn","Travis","Bradley","Leonard","Earl","Gabriel","Jimmy","Francis","Todd","Noah","Danny","Dale","Cody","Carlos","Allen","Frederick","Logan","Curtis","Alex","Joel","Luis","Norman","Marvin","Glenn","Tony","Nathaniel","Rodney","Melvin","Alfred","Steve","Cameron","Chad","Edwin","Caleb","Evan","Antonio","Lee","Herbert","Jeffery","Isaac","Derek","Ricky","Marcus","Theodore","Elijah","Luke","Jesus","Eddie","Troy","Mike","Dustin","Ray","Adrian","Bernard","Leroy","Angel","Randall","Wesley","Ian","Jared","Mason","Hunter","Calvin","Oscar","Clifford","Jay","Shane","Ronnie","Barry","Lucas","Corey","Manuel","Leo","Tommy","Warren","Jackson","Isaiah","Connor","Don","Dean","Jon","Julian","Miguel","Bill","Lloyd","Charlie","Mitchell","Leon","Jerome","Darrell","Jeremiah","Alvin","Brett","Seth","Floyd","Jim","Blake","Micheal","Gordon","Trevor","Lewis","Erik","Edgar","Vernon","Devin","Gavin","Jayden","Chris","Clyde","Tom","Derrick","Mario","Brent","Marc","Herman","Chase","Dominic","Ricardo","Franklin","Maurice","Max","Aiden","Owen","Lester","Gilbert","Elmer","Gene","Francisco","Glen","Cory","Garrett","Clayton","Sam","Jorge","Chester","Alejandro","Jeff","Harvey","Milton","Cole","Ivan","Andre","Duane","Landon"],female:["Mary","Emma","Elizabeth","Minnie","Margaret","Ida","Alice","Bertha","Sarah","Annie","Clara","Ella","Florence","Cora","Martha","Laura","Nellie","Grace","Carrie","Maude","Mabel","Bessie","Jennie","Gertrude","Julia","Hattie","Edith","Mattie","Rose","Catherine","Lillian","Ada","Lillie","Helen","Jessie","Louise","Ethel","Lula","Myrtle","Eva","Frances","Lena","Lucy","Edna","Maggie","Pearl","Daisy","Fannie","Josephine","Dora","Rosa","Katherine","Agnes","Marie","Nora","May","Mamie","Blanche","Stella","Ellen","Nancy","Effie","Sallie","Nettie","Della","Lizzie","Flora","Susie","Maud","Mae","Etta","Harriet","Sadie","Caroline","Katie","Lydia","Elsie","Kate","Susan","Mollie","Alma","Addie","Georgia","Eliza","Lulu","Nannie","Lottie","Amanda","Belle","Charlotte","Rebecca","Ruth","Viola","Olive","Amelia","Hannah","Jane","Virginia","Emily","Matilda","Irene","Kathryn","Esther","Willie","Henrietta","Ollie","Amy","Rachel","Sara","Estella","Theresa","Augusta","Ora","Pauline","Josie","Lola","Sophia","Leona","Anne","Mildred","Ann","Beulah","Callie","Lou","Delia","Eleanor","Barbara","Iva","Louisa","Maria","Mayme","Evelyn","Estelle","Nina","Betty","Marion","Bettie","Dorothy","Luella","Inez","Lela","Rosie","Allie","Millie","Janie","Cornelia","Victoria","Ruby","Winifred","Alta","Celia","Christine","Beatrice","Birdie","Harriett","Mable","Myra","Sophie","Tillie","Isabel","Sylvia","Carolyn","Isabelle","Leila","Sally","Ina","Essie","Bertie","Nell","Alberta","Katharine","Lora","Rena","Mina","Rhoda","Mathilda","Abbie","Eula","Dollie","Hettie","Eunice","Fanny","Ola","Lenora","Adelaide","Christina","Lelia","Nelle","Sue","Johanna","Lilly","Lucinda","Minerva","Lettie","Roxie","Cynthia","Helena","Hilda","Hulda","Bernice","Genevieve","Jean","Cordelia","Marian","Francis","Jeanette","Adeline","Gussie","Leah","Lois","Lura","Mittie","Hallie","Isabella","Olga","Phoebe","Teresa","Hester","Lida","Lina","Winnie","Claudia","Marguerite","Vera","Cecelia","Bess","Emilie","John","Rosetta","Verna","Myrtie","Cecilia","Elva","Olivia","Ophelia","Georgie","Elnora","Violet","Adele","Lily","Linnie","Loretta","Madge","Polly","Virgie","Eugenia","Lucile","Lucille","Mabelle","Rosalie"]},lastNames:["Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Jackson","White","Harris","Martin","Thompson","Garcia","Martinez","Robinson","Clark","Rodriguez","Lewis","Lee","Walker","Hall","Allen","Young","Hernandez","King","Wright","Lopez","Hill","Scott","Green","Adams","Baker","Gonzalez","Nelson","Carter","Mitchell","Perez","Roberts","Turner","Phillips","Campbell","Parker","Evans","Edwards","Collins","Stewart","Sanchez","Morris","Rogers","Reed","Cook","Morgan","Bell","Murphy","Bailey","Rivera","Cooper","Richardson","Cox","Howard","Ward","Torres","Peterson","Gray","Ramirez","James","Watson","Brooks","Kelly","Sanders","Price","Bennett","Wood","Barnes","Ross","Henderson","Coleman","Jenkins","Perry","Powell","Long","Patterson","Hughes","Flores","Washington","Butler","Simmons","Foster","Gonzales","Bryant","Alexander","Russell","Griffin","Diaz","Hayes","Myers","Ford","Hamilton","Graham","Sullivan","Wallace","Woods","Cole","West","Jordan","Owens","Reynolds","Fisher","Ellis","Harrison","Gibson","McDonald","Cruz","Marshall","Ortiz","Gomez","Murray","Freeman","Wells","Webb","Simpson","Stevens","Tucker","Porter","Hunter","Hicks","Crawford","Henry","Boyd","Mason","Morales","Kennedy","Warren","Dixon","Ramos","Reyes","Burns","Gordon","Shaw","Holmes","Rice","Robertson","Hunt","Black","Daniels","Palmer","Mills","Nichols","Grant","Knight","Ferguson","Rose","Stone","Hawkins","Dunn","Perkins","Hudson","Spencer","Gardner","Stephens","Payne","Pierce","Berry","Matthews","Arnold","Wagner","Willis","Ray","Watkins","Olson","Carroll","Duncan","Snyder","Hart","Cunningham","Bradley","Lane","Andrews","Ruiz","Harper","Fox","Riley","Armstrong","Carpenter","Weaver","Greene","Lawrence","Elliott","Chavez","Sims","Austin","Peters","Kelley","Franklin","Lawson","Fields","Gutierrez","Ryan","Schmidt","Carr","Vasquez","Castillo","Wheeler","Chapman","Oliver","Montgomery","Richards","Williamson","Johnston","Banks","Meyer","Bishop","McCoy","Howell","Alvarez","Morrison","Hansen","Fernandez","Garza","Harvey","Little","Burton","Stanley","Nguyen","George","Jacobs","Reid","Kim","Fuller","Lynch","Dean","Gilbert","Garrett","Romero","Welch","Larson","Frazier","Burke","Hanson","Day","Mendoza","Moreno","Bowman","Medina","Fowler","Brewer","Hoffman","Carlson","Silva","Pearson","Holland","Douglas","Fleming","Jensen","Vargas","Byrd","Davidson","Hopkins","May","Terry","Herrera","Wade","Soto","Walters","Curtis","Neal","Caldwell","Lowe","Jennings","Barnett","Graves","Jimenez","Horton","Shelton","Barrett","Obrien","Castro","Sutton","Gregory","McKinney","Lucas","Miles","Craig","Rodriquez","Chambers","Holt","Lambert","Fletcher","Watts","Bates","Hale","Rhodes","Pena","Beck","Newman","Haynes","McDaniel","Mendez","Bush","Vaughn","Parks","Dawson","Santiago","Norris","Hardy","Love","Steele","Curry","Powers","Schultz","Barker","Guzman","Page","Munoz","Ball","Keller","Chandler","Weber","Leonard","Walsh","Lyons","Ramsey","Wolfe","Schneider","Mullins","Benson","Sharp","Bowen","Daniel","Barber","Cummings","Hines","Baldwin","Griffith","Valdez","Hubbard","Salazar","Reeves","Warner","Stevenson","Burgess","Santos","Tate","Cross","Garner","Mann","Mack","Moss","Thornton","Dennis","McGee","Farmer","Delgado","Aguilar","Vega","Glover","Manning","Cohen","Harmon","Rodgers","Robbins","Newton","Todd","Blair","Higgins","Ingram","Reese","Cannon","Strickland","Townsend","Potter","Goodwin","Walton","Rowe","Hampton","Ortega","Patton","Swanson","Joseph","Francis","Goodman","Maldonado","Yates","Becker","Erickson","Hodges","Rios","Conner","Adkins","Webster","Norman","Malone","Hammond","Flowers","Cobb","Moody","Quinn","Blake","Maxwell","Pope","Floyd","Osborne","Paul","McCarthy","Guerrero","Lindsey","Estrada","Sandoval","Gibbs","Tyler","Gross","Fitzgerald","Stokes","Doyle","Sherman","Saunders","Wise","Colon","Gill","Alvarado","Greer","Padilla","Simon","Waters","Nunez","Ballard","Schwartz","McBride","Houston","Christensen","Klein","Pratt","Briggs","Parsons","McLaughlin","Zimmerman","French","Buchanan","Moran","Copeland","Roy","Pittman","Brady","McCormick","Holloway","Brock","Poole","Frank","Logan","Owen","Bass","Marsh","Drake","Wong","Jefferson","Park","Morton","Abbott","Sparks","Patrick","Norton","Huff","Clayton","Massey","Lloyd","Figueroa","Carson","Bowers","Roberson","Barton","Tran","Lamb","Harrington","Casey","Boone","Cortez","Clarke","Mathis","Singleton","Wilkins","Cain","Bryan","Underwood","Hogan","McKenzie","Collier","Luna","Phelps","McGuire","Allison","Bridges","Wilkerson","Nash","Summers","Atkins"],countries:[{name:"Afghanistan",abbreviation:"AF"},{name:"Albania",abbreviation:"AL"},{name:"Algeria",abbreviation:"DZ"},{name:"American Samoa",abbreviation:"AS"},{name:"Andorra",abbreviation:"AD"},{name:"Angola",abbreviation:"AO"},{name:"Anguilla",abbreviation:"AI"},{name:"Antarctica",abbreviation:"AQ"},{name:"Antigua and Barbuda",abbreviation:"AG"},{name:"Argentina",abbreviation:"AR"},{name:"Armenia",abbreviation:"AM"},{name:"Aruba",abbreviation:"AW"},{name:"Australia",abbreviation:"AU"},{name:"Austria",abbreviation:"AT"},{name:"Azerbaijan",abbreviation:"AZ"},{name:"Bahamas",abbreviation:"BS"},{name:"Bahrain",abbreviation:"BH"},{name:"Bangladesh",abbreviation:"BD"},{name:"Barbados",abbreviation:"BB"},{name:"Belarus",abbreviation:"BY"},{name:"Belgium",abbreviation:"BE"},{name:"Belize",abbreviation:"BZ"},{name:"Benin",abbreviation:"BJ"},{name:"Bermuda",abbreviation:"BM"},{name:"Bhutan",abbreviation:"BT"},{name:"Bolivia",abbreviation:"BO"},{name:"Bosnia and Herzegovina",abbreviation:"BA"},{name:"Botswana",abbreviation:"BW"},{name:"Bouvet Island",abbreviation:"BV"},{name:"Brazil",abbreviation:"BR"},{name:"British Antarctic Territory",abbreviation:"BQ"},{name:"British Indian Ocean Territory",abbreviation:"IO"},{name:"British Virgin Islands",abbreviation:"VG"},{name:"Brunei",abbreviation:"BN"},{name:"Bulgaria",abbreviation:"BG"},{name:"Burkina Faso",abbreviation:"BF"},{name:"Burundi",abbreviation:"BI"},{name:"Cambodia",abbreviation:"KH"},{name:"Cameroon",abbreviation:"CM"},{name:"Canada",abbreviation:"CA"},{name:"Canton and Enderbury Islands",abbreviation:"CT"},{name:"Cape Verde",abbreviation:"CV"},{name:"Cayman Islands",abbreviation:"KY"},{name:"Central African Republic",abbreviation:"CF"},{name:"Chad",abbreviation:"TD"},{name:"Chile",abbreviation:"CL"},{name:"China",abbreviation:"CN"},{name:"Christmas Island",abbreviation:"CX"},{name:"Cocos [Keeling] Islands",abbreviation:"CC"},{name:"Colombia",abbreviation:"CO"},{name:"Comoros",abbreviation:"KM"},{name:"Congo - Brazzaville",abbreviation:"CG"},{name:"Congo - Kinshasa",abbreviation:"CD"},{name:"Cook Islands",abbreviation:"CK"},{name:"Costa Rica",abbreviation:"CR"},{name:"Croatia",abbreviation:"HR"},{name:"Cuba",abbreviation:"CU"},{name:"Cyprus",abbreviation:"CY"},{name:"Czech Republic",abbreviation:"CZ"},{name:"Côte d’Ivoire",abbreviation:"CI"},{name:"Denmark",abbreviation:"DK"},{name:"Djibouti",abbreviation:"DJ"},{name:"Dominica",abbreviation:"DM"},{name:"Dominican Republic",abbreviation:"DO"},{name:"Dronning Maud Land",abbreviation:"NQ"},{name:"East Germany",abbreviation:"DD"},{name:"Ecuador",abbreviation:"EC"},{name:"Egypt",abbreviation:"EG"},{name:"El Salvador",abbreviation:"SV"},{name:"Equatorial Guinea",abbreviation:"GQ"},{name:"Eritrea",abbreviation:"ER"},{name:"Estonia",abbreviation:"EE"},{name:"Ethiopia",abbreviation:"ET"},{name:"Falkland Islands",abbreviation:"FK"},{name:"Faroe Islands",abbreviation:"FO"},{name:"Fiji",abbreviation:"FJ"},{name:"Finland",abbreviation:"FI"},{name:"France",abbreviation:"FR"},{name:"French Guiana",abbreviation:"GF"},{name:"French Polynesia",abbreviation:"PF"},{name:"French Southern Territories",abbreviation:"TF"},{name:"French Southern and Antarctic Territories",abbreviation:"FQ"},{name:"Gabon",abbreviation:"GA"},{name:"Gambia",abbreviation:"GM"},{name:"Georgia",abbreviation:"GE"},{name:"Germany",abbreviation:"DE"},{name:"Ghana",abbreviation:"GH"},{name:"Gibraltar",abbreviation:"GI"},{name:"Greece",abbreviation:"GR"},{name:"Greenland",abbreviation:"GL"},{name:"Grenada",abbreviation:"GD"},{name:"Guadeloupe",abbreviation:"GP"},{name:"Guam",abbreviation:"GU"},{name:"Guatemala",abbreviation:"GT"},{name:"Guernsey",abbreviation:"GG"},{name:"Guinea",abbreviation:"GN"},{name:"Guinea-Bissau",abbreviation:"GW"},{name:"Guyana",abbreviation:"GY"},{name:"Haiti",abbreviation:"HT"},{name:"Heard Island and McDonald Islands",abbreviation:"HM"},{name:"Honduras",abbreviation:"HN"},{name:"Hong Kong SAR China",abbreviation:"HK"},{name:"Hungary",abbreviation:"HU"},{name:"Iceland",abbreviation:"IS"},{name:"India",abbreviation:"IN"},{name:"Indonesia",abbreviation:"ID"},{name:"Iran",abbreviation:"IR"},{name:"Iraq",abbreviation:"IQ"},{name:"Ireland",abbreviation:"IE"},{name:"Isle of Man",abbreviation:"IM"},{name:"Israel",abbreviation:"IL"},{name:"Italy",abbreviation:"IT"},{name:"Jamaica",abbreviation:"JM"},{name:"Japan",abbreviation:"JP"},{name:"Jersey",abbreviation:"JE"},{name:"Johnston Island",abbreviation:"JT"},{name:"Jordan",abbreviation:"JO"},{name:"Kazakhstan",abbreviation:"KZ"},{name:"Kenya",abbreviation:"KE"},{name:"Kiribati",abbreviation:"KI"},{name:"Kuwait",abbreviation:"KW"},{name:"Kyrgyzstan",abbreviation:"KG"},{name:"Laos",abbreviation:"LA"},{name:"Latvia",abbreviation:"LV"},{name:"Lebanon",abbreviation:"LB"},{name:"Lesotho",abbreviation:"LS"},{name:"Liberia",abbreviation:"LR"},{name:"Libya",abbreviation:"LY"},{name:"Liechtenstein",abbreviation:"LI"},{name:"Lithuania",abbreviation:"LT"},{name:"Luxembourg",abbreviation:"LU"},{name:"Macau SAR China",abbreviation:"MO"},{name:"Macedonia",abbreviation:"MK"},{name:"Madagascar",abbreviation:"MG"},{name:"Malawi",abbreviation:"MW"},{name:"Malaysia",abbreviation:"MY"},{name:"Maldives",abbreviation:"MV"},{name:"Mali",abbreviation:"ML"},{name:"Malta",abbreviation:"MT"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Martinique",abbreviation:"MQ"},{name:"Mauritania",abbreviation:"MR"},{name:"Mauritius",abbreviation:"MU"},{name:"Mayotte",abbreviation:"YT"},{name:"Metropolitan France",abbreviation:"FX"},{name:"Mexico",abbreviation:"MX"},{name:"Micronesia",abbreviation:"FM"},{name:"Midway Islands",abbreviation:"MI"},{name:"Moldova",abbreviation:"MD"},{name:"Monaco",abbreviation:"MC"},{name:"Mongolia",abbreviation:"MN"},{name:"Montenegro",abbreviation:"ME"},{name:"Montserrat",abbreviation:"MS"},{name:"Morocco",abbreviation:"MA"},{name:"Mozambique",abbreviation:"MZ"},{name:"Myanmar [Burma]",abbreviation:"MM"},{name:"Namibia",abbreviation:"NA"},{name:"Nauru",abbreviation:"NR"},{name:"Nepal",abbreviation:"NP"},{name:"Netherlands",abbreviation:"NL"},{name:"Netherlands Antilles",abbreviation:"AN"},{name:"Neutral Zone",abbreviation:"NT"},{name:"New Caledonia",abbreviation:"NC"},{name:"New Zealand",abbreviation:"NZ"},{name:"Nicaragua",abbreviation:"NI"},{name:"Niger",abbreviation:"NE"},{name:"Nigeria",abbreviation:"NG"},{name:"Niue",abbreviation:"NU"},{name:"Norfolk Island",abbreviation:"NF"},{name:"North Korea",abbreviation:"KP"},{name:"North Vietnam",abbreviation:"VD"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Norway",abbreviation:"NO"},{name:"Oman",abbreviation:"OM"},{name:"Pacific Islands Trust Territory",abbreviation:"PC"},{name:"Pakistan",abbreviation:"PK"},{name:"Palau",abbreviation:"PW"},{name:"Palestinian Territories",abbreviation:"PS"},{name:"Panama",abbreviation:"PA"},{name:"Panama Canal Zone",abbreviation:"PZ"},{name:"Papua New Guinea",abbreviation:"PG"},{name:"Paraguay",abbreviation:"PY"},{name:"People's Democratic Republic of Yemen",abbreviation:"YD"},{name:"Peru",abbreviation:"PE"},{name:"Philippines",abbreviation:"PH"},{name:"Pitcairn Islands",abbreviation:"PN"},{name:"Poland",abbreviation:"PL"},{name:"Portugal",abbreviation:"PT"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Qatar",abbreviation:"QA"},{name:"Romania",abbreviation:"RO"},{name:"Russia",abbreviation:"RU"},{name:"Rwanda",abbreviation:"RW"},{name:"Réunion",abbreviation:"RE"},{name:"Saint Barthélemy",abbreviation:"BL"},{name:"Saint Helena",abbreviation:"SH"},{name:"Saint Kitts and Nevis",abbreviation:"KN"},{name:"Saint Lucia",abbreviation:"LC"},{name:"Saint Martin",abbreviation:"MF"},{name:"Saint Pierre and Miquelon",abbreviation:"PM"},{name:"Saint Vincent and the Grenadines",abbreviation:"VC"},{name:"Samoa",abbreviation:"WS"},{name:"San Marino",abbreviation:"SM"},{name:"Saudi Arabia",abbreviation:"SA"},{name:"Senegal",abbreviation:"SN"},{name:"Serbia",abbreviation:"RS"},{name:"Serbia and Montenegro",abbreviation:"CS"},{name:"Seychelles",abbreviation:"SC"},{name:"Sierra Leone",abbreviation:"SL"},{name:"Singapore",abbreviation:"SG"},{name:"Slovakia",abbreviation:"SK"},{name:"Slovenia",abbreviation:"SI"},{name:"Solomon Islands",abbreviation:"SB"},{name:"Somalia",abbreviation:"SO"},{name:"South Africa",abbreviation:"ZA"},{name:"South Georgia and the South Sandwich Islands",abbreviation:"GS"},{name:"South Korea",abbreviation:"KR"},{name:"Spain",abbreviation:"ES"},{name:"Sri Lanka",abbreviation:"LK"},{name:"Sudan",abbreviation:"SD"},{name:"Suriname",abbreviation:"SR"},{name:"Svalbard and Jan Mayen",abbreviation:"SJ"},{name:"Swaziland",abbreviation:"SZ"},{name:"Sweden",abbreviation:"SE"},{name:"Switzerland",abbreviation:"CH"},{name:"Syria",abbreviation:"SY"},{name:"São Tomé and Príncipe",abbreviation:"ST"},{name:"Taiwan",abbreviation:"TW"},{name:"Tajikistan",abbreviation:"TJ"},{name:"Tanzania",abbreviation:"TZ"},{name:"Thailand",abbreviation:"TH"},{name:"Timor-Leste",abbreviation:"TL"},{name:"Togo",abbreviation:"TG"},{name:"Tokelau",abbreviation:"TK"},{name:"Tonga",abbreviation:"TO"},{name:"Trinidad and Tobago",abbreviation:"TT"},{name:"Tunisia",abbreviation:"TN"},{name:"Turkey",abbreviation:"TR"},{name:"Turkmenistan",abbreviation:"TM"},{name:"Turks and Caicos Islands",abbreviation:"TC"},{name:"Tuvalu",abbreviation:"TV"},{name:"U.S. Minor Outlying Islands",abbreviation:"UM"},{name:"U.S. Miscellaneous Pacific Islands",abbreviation:"PU"},{name:"U.S. Virgin Islands",abbreviation:"VI"},{name:"Uganda",abbreviation:"UG"},{name:"Ukraine",abbreviation:"UA"},{name:"Union of Soviet Socialist Republics",abbreviation:"SU"},{name:"United Arab Emirates",abbreviation:"AE"},{name:"United Kingdom",abbreviation:"GB"},{name:"United States",abbreviation:"US"},{name:"Unknown or Invalid Region",abbreviation:"ZZ"},{name:"Uruguay",abbreviation:"UY"},{name:"Uzbekistan",abbreviation:"UZ"},{name:"Vanuatu",abbreviation:"VU"},{name:"Vatican City",abbreviation:"VA"},{name:"Venezuela",abbreviation:"VE"},{name:"Vietnam",abbreviation:"VN"},{name:"Wake Island",abbreviation:"WK"},{name:"Wallis and Futuna",abbreviation:"WF"},{name:"Western Sahara",abbreviation:"EH"},{name:"Yemen",abbreviation:"YE"},{name:"Zambia",abbreviation:"ZM"},{name:"Zimbabwe",abbreviation:"ZW"},{name:"Åland Islands",abbreviation:"AX"}],provinces:[{name:"Alberta",abbreviation:"AB"},{name:"British Columbia",abbreviation:"BC"},{name:"Manitoba",abbreviation:"MB"},{name:"New Brunswick",abbreviation:"NB"},{name:"Newfoundland and Labrador",abbreviation:"NL"},{name:"Nova Scotia",abbreviation:"NS"},{name:"Ontario",abbreviation:"ON"},{name:"Prince Edward Island",abbreviation:"PE"},{name:"Quebec",abbreviation:"QC"},{name:"Saskatchewan",abbreviation:"SK"},{name:"Northwest Territories",abbreviation:"NT"},{name:"Nunavut",abbreviation:"NU"},{name:"Yukon",abbreviation:"YT"}],us_states_and_dc:[{name:"Alabama",abbreviation:"AL"},{name:"Alaska",abbreviation:"AK"},{name:"Arizona",abbreviation:"AZ"},{name:"Arkansas",abbreviation:"AR"},{name:"California",abbreviation:"CA"},{name:"Colorado",abbreviation:"CO"},{name:"Connecticut",abbreviation:"CT"},{name:"Delaware",abbreviation:"DE"},{name:"District of Columbia",abbreviation:"DC"},{name:"Florida",abbreviation:"FL"},{name:"Georgia",abbreviation:"GA"},{name:"Hawaii",abbreviation:"HI"},{name:"Idaho",abbreviation:"ID"},{name:"Illinois",abbreviation:"IL"},{name:"Indiana",abbreviation:"IN"},{name:"Iowa",abbreviation:"IA"},{name:"Kansas",abbreviation:"KS"},{name:"Kentucky",abbreviation:"KY"},{name:"Louisiana",abbreviation:"LA"},{name:"Maine",abbreviation:"ME"},{name:"Maryland",abbreviation:"MD"},{name:"Massachusetts",abbreviation:"MA"},{name:"Michigan",abbreviation:"MI"},{name:"Minnesota",abbreviation:"MN"},{name:"Mississippi",abbreviation:"MS"},{name:"Missouri",abbreviation:"MO"},{name:"Montana",abbreviation:"MT"},{name:"Nebraska",abbreviation:"NE"},{name:"Nevada",abbreviation:"NV"},{name:"New Hampshire",abbreviation:"NH"},{name:"New Jersey",abbreviation:"NJ"},{name:"New Mexico",abbreviation:"NM"},{name:"New York",abbreviation:"NY"},{name:"North Carolina",abbreviation:"NC"},{name:"North Dakota",abbreviation:"ND"},{name:"Ohio",abbreviation:"OH"},{name:"Oklahoma",abbreviation:"OK"},{name:"Oregon",abbreviation:"OR"},{name:"Pennsylvania",abbreviation:"PA"},{name:"Rhode Island",abbreviation:"RI"},{name:"South Carolina",abbreviation:"SC"},{name:"South Dakota",abbreviation:"SD"},{name:"Tennessee",abbreviation:"TN"},{name:"Texas",abbreviation:"TX"},{name:"Utah",abbreviation:"UT"},{name:"Vermont",abbreviation:"VT"},{name:"Virginia",abbreviation:"VA"},{name:"Washington",abbreviation:"WA"},{name:"West Virginia",abbreviation:"WV"},{name:"Wisconsin",abbreviation:"WI"},{name:"Wyoming",abbreviation:"WY"}],territories:[{name:"American Samoa",abbreviation:"AS"},{name:"Federated States of Micronesia",abbreviation:"FM"},{name:"Guam",abbreviation:"GU"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Virgin Islands, U.S.",abbreviation:"VI"}],armed_forces:[{name:"Armed Forces Europe",abbreviation:"AE"},{name:"Armed Forces Pacific",abbreviation:"AP"},{name:"Armed Forces the Americas",abbreviation:"AA"}],street_suffixes:[{name:"Avenue",abbreviation:"Ave"},{name:"Boulevard",abbreviation:"Blvd"},{name:"Center",abbreviation:"Ctr"},{name:"Circle",abbreviation:"Cir"},{name:"Court",abbreviation:"Ct"},{name:"Drive",abbreviation:"Dr"},{name:"Extension",abbreviation:"Ext"},{name:"Glen",abbreviation:"Gln"},{name:"Grove",abbreviation:"Grv"},{name:"Heights",abbreviation:"Hts"},{name:"Highway",abbreviation:"Hwy"},{name:"Junction",abbreviation:"Jct"},{name:"Key",abbreviation:"Key"},{name:"Lane",abbreviation:"Ln"},{name:"Loop",abbreviation:"Loop"},{name:"Manor",abbreviation:"Mnr"},{name:"Mill",abbreviation:"Mill"},{name:"Park",abbreviation:"Park"},{name:"Parkway",abbreviation:"Pkwy"},{name:"Pass",abbreviation:"Pass"},{name:"Path",abbreviation:"Path"},{name:"Pike",abbreviation:"Pike"},{name:"Place",abbreviation:"Pl"},{name:"Plaza",abbreviation:"Plz"},{name:"Point",abbreviation:"Pt"},{name:"Ridge",abbreviation:"Rdg"},{name:"River",abbreviation:"Riv"},{name:"Road",abbreviation:"Rd"},{name:"Square",abbreviation:"Sq"},{name:"Street",abbreviation:"St"},{name:"Terrace",abbreviation:"Ter"},{name:"Trail",abbreviation:"Trl"},{name:"Turnpike",abbreviation:"Tpke"},{name:"View",abbreviation:"Vw"},{name:"Way",abbreviation:"Way"}],months:[{name:"January",short_name:"Jan",numeric:"01",days:31},{name:"February",short_name:"Feb",numeric:"02",days:28},{name:"March",short_name:"Mar",numeric:"03",days:31},{name:"April",short_name:"Apr",numeric:"04",days:30},{name:"May",short_name:"May",numeric:"05",days:31},{name:"June",short_name:"Jun",numeric:"06",days:30},{name:"July",short_name:"Jul",numeric:"07",days:31},{name:"August",short_name:"Aug",numeric:"08",days:31},{name:"September",short_name:"Sep",numeric:"09",days:30},{name:"October",short_name:"Oct",numeric:"10",days:31},{name:"November",short_name:"Nov",numeric:"11",days:30},{name:"December",short_name:"Dec",numeric:"12",days:31}],cc_types:[{name:"American Express",short_name:"amex",prefix:"34",length:15},{name:"Bankcard",short_name:"bankcard",prefix:"5610",length:16},{name:"China UnionPay",short_name:"chinaunion",prefix:"62",length:16},{name:"Diners Club Carte Blanche",short_name:"dccarte",prefix:"300",length:14},{name:"Diners Club enRoute",short_name:"dcenroute",prefix:"2014",length:15},{name:"Diners Club International",short_name:"dcintl",prefix:"36",length:14},{name:"Diners Club United States & Canada",short_name:"dcusc",prefix:"54",length:16},{name:"Discover Card",short_name:"discover",prefix:"6011",length:16},{name:"InstaPayment",short_name:"instapay",prefix:"637",length:16},{name:"JCB",short_name:"jcb",prefix:"3528",length:16},{name:"Laser",short_name:"laser",prefix:"6304",length:16},{name:"Maestro",short_name:"maestro",prefix:"5018",length:16},{name:"Mastercard",short_name:"mc",prefix:"51",length:16},{name:"Solo",short_name:"solo",prefix:"6334",length:16},{name:"Switch",short_name:"switch",prefix:"4903",length:16},{name:"Visa",short_name:"visa",prefix:"4",length:16},{name:"Visa Electron",short_name:"electron",prefix:"4026",length:16}],currency_types:[{code:"AED",name:"United Arab Emirates Dirham"},{code:"AFN",name:"Afghanistan Afghani"},{code:"ALL",name:"Albania Lek"},{code:"AMD",name:"Armenia Dram"},{code:"ANG",name:"Netherlands Antilles Guilder"},{code:"AOA",name:"Angola Kwanza"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australia Dollar"},{code:"AWG",name:"Aruba Guilder"},{code:"AZN",name:"Azerbaijan New Manat"},{code:"BAM",name:"Bosnia and Herzegovina Convertible Marka"},{code:"BBD",name:"Barbados Dollar"},{code:"BDT",name:"Bangladesh Taka"},{code:"BGN",name:"Bulgaria Lev"},{code:"BHD",name:"Bahrain Dinar"},{code:"BIF",name:"Burundi Franc"},{code:"BMD",name:"Bermuda Dollar"},{code:"BND",name:"Brunei Darussalam Dollar"},{code:"BOB",name:"Bolivia Boliviano"},{code:"BRL",name:"Brazil Real"},{code:"BSD",name:"Bahamas Dollar"},{code:"BTN",name:"Bhutan Ngultrum"},{code:"BWP",name:"Botswana Pula"},{code:"BYR",name:"Belarus Ruble"},{code:"BZD",name:"Belize Dollar"},{code:"CAD",name:"Canada Dollar"},{code:"CDF",name:"Congo/Kinshasa Franc"},{code:"CHF",name:"Switzerland Franc"},{code:"CLP",name:"Chile Peso"},{code:"CNY",name:"China Yuan Renminbi"},{code:"COP",name:"Colombia Peso"},{code:"CRC",name:"Costa Rica Colon"},{code:"CUC",name:"Cuba Convertible Peso"},{code:"CUP",name:"Cuba Peso"},{code:"CVE",name:"Cape Verde Escudo"},{code:"CZK",name:"Czech Republic Koruna"},{code:"DJF",name:"Djibouti Franc"},{code:"DKK",name:"Denmark Krone"},{code:"DOP",name:"Dominican Republic Peso"},{code:"DZD",name:"Algeria Dinar"},{code:"EGP",name:"Egypt Pound"},{code:"ERN",name:"Eritrea Nakfa"},{code:"ETB",name:"Ethiopia Birr"},{code:"EUR",name:"Euro Member Countries"},{code:"FJD",name:"Fiji Dollar"},{code:"FKP",name:"Falkland Islands (Malvinas) Pound"},{code:"GBP",name:"United Kingdom Pound"},{code:"GEL",name:"Georgia Lari"},{code:"GGP",name:"Guernsey Pound"},{code:"GHS",name:"Ghana Cedi"},{code:"GIP",name:"Gibraltar Pound"},{code:"GMD",name:"Gambia Dalasi"},{code:"GNF",name:"Guinea Franc"},{code:"GTQ",name:"Guatemala Quetzal"},{code:"GYD",name:"Guyana Dollar"},{code:"HKD",name:"Hong Kong Dollar"},{code:"HNL",name:"Honduras Lempira"},{code:"HRK",name:"Croatia Kuna"},{code:"HTG",name:"Haiti Gourde"},{code:"HUF",name:"Hungary Forint"},{code:"IDR",name:"Indonesia Rupiah"},{code:"ILS",name:"Israel Shekel"},{code:"IMP",name:"Isle of Man Pound"},{code:"INR",name:"India Rupee"},{code:"IQD",name:"Iraq Dinar"},{code:"IRR",name:"Iran Rial"},{code:"ISK",name:"Iceland Krona"},{code:"JEP",name:"Jersey Pound"},{code:"JMD",name:"Jamaica Dollar"},{code:"JOD",name:"Jordan Dinar"},{code:"JPY",name:"Japan Yen"},{code:"KES",name:"Kenya Shilling"},{code:"KGS",name:"Kyrgyzstan Som"},{code:"KHR",name:"Cambodia Riel"},{code:"KMF",name:"Comoros Franc"},{code:"KPW",name:"Korea (North) Won"},{code:"KRW",name:"Korea (South) Won"},{code:"KWD",name:"Kuwait Dinar"},{code:"KYD",name:"Cayman Islands Dollar"},{code:"KZT",name:"Kazakhstan Tenge"},{code:"LAK",name:"Laos Kip"},{code:"LBP",name:"Lebanon Pound"},{code:"LKR",name:"Sri Lanka Rupee"},{code:"LRD",name:"Liberia Dollar"},{code:"LSL",name:"Lesotho Loti"},{code:"LTL",name:"Lithuania Litas"},{code:"LYD",name:"Libya Dinar"},{code:"MAD",name:"Morocco Dirham"},{code:"MDL",name:"Moldova Leu"},{code:"MGA",name:"Madagascar Ariary"},{code:"MKD",name:"Macedonia Denar"},{code:"MMK",name:"Myanmar (Burma) Kyat"},{code:"MNT",name:"Mongolia Tughrik"},{code:"MOP",name:"Macau Pataca"},{code:"MRO",name:"Mauritania Ouguiya"},{code:"MUR",name:"Mauritius Rupee"},{code:"MVR",name:"Maldives (Maldive Islands) Rufiyaa"},{code:"MWK",name:"Malawi Kwacha"},{code:"MXN",name:"Mexico Peso"},{code:"MYR",name:"Malaysia Ringgit"},{code:"MZN",name:"Mozambique Metical"},{code:"NAD",name:"Namibia Dollar"},{code:"NGN",name:"Nigeria Naira"},{code:"NIO",name:"Nicaragua Cordoba"},{code:"NOK",name:"Norway Krone"},{code:"NPR",name:"Nepal Rupee"},{code:"NZD",name:"New Zealand Dollar"},{code:"OMR",name:"Oman Rial"},{code:"PAB",name:"Panama Balboa"},{code:"PEN",name:"Peru Nuevo Sol"},{code:"PGK",name:"Papua New Guinea Kina"},{code:"PHP",name:"Philippines Peso"},{code:"PKR",name:"Pakistan Rupee"},{code:"PLN",name:"Poland Zloty"},{code:"PYG",name:"Paraguay Guarani"},{code:"QAR",name:"Qatar Riyal"},{code:"RON",name:"Romania New Leu"},{code:"RSD",name:"Serbia Dinar"},{code:"RUB",name:"Russia Ruble"},{code:"RWF",name:"Rwanda Franc"},{code:"SAR",name:"Saudi Arabia Riyal"},{code:"SBD",name:"Solomon Islands Dollar"},{code:"SCR",name:"Seychelles Rupee"},{code:"SDG",name:"Sudan Pound"},{code:"SEK",name:"Sweden Krona"},{code:"SGD",name:"Singapore Dollar"},{code:"SHP",name:"Saint Helena Pound"},{code:"SLL",name:"Sierra Leone Leone"},{code:"SOS",name:"Somalia Shilling"},{code:"SPL",name:"Seborga Luigino"},{code:"SRD",name:"Suriname Dollar"},{code:"STD",name:"São Tomé and Príncipe Dobra"},{code:"SVC",name:"El Salvador Colon"},{code:"SYP",name:"Syria Pound"},{code:"SZL",name:"Swaziland Lilangeni"},{code:"THB",name:"Thailand Baht"},{code:"TJS",name:"Tajikistan Somoni"},{code:"TMT",name:"Turkmenistan Manat"},{code:"TND",name:"Tunisia Dinar"},{code:"TOP",name:"Tonga Pa'anga"},{code:"TRY",name:"Turkey Lira"},{code:"TTD",name:"Trinidad and Tobago Dollar"},{code:"TVD",name:"Tuvalu Dollar"},{code:"TWD",name:"Taiwan New Dollar"},{code:"TZS",name:"Tanzania Shilling"},{code:"UAH",name:"Ukraine Hryvnia"},{code:"UGX",name:"Uganda Shilling"},{code:"USD",name:"United States Dollar"},{code:"UYU",name:"Uruguay Peso"},{code:"UZS",name:"Uzbekistan Som"},{code:"VEF",name:"Venezuela Bolivar"},{code:"VND",name:"Viet Nam Dong"},{code:"VUV",name:"Vanuatu Vatu"},{code:"WST",name:"Samoa Tala"},{code:"XAF",name:"Communauté Financière Africaine (BEAC) CFA Franc BEAC"},{code:"XCD",name:"East Caribbean Dollar"},{code:"XDR",name:"International Monetary Fund (IMF) Special Drawing Rights"},{code:"XOF",name:"Communauté Financière Africaine (BCEAO) Franc"},{code:"XPF",name:"Comptoirs Français du Pacifique (CFP) Franc"},{code:"YER",name:"Yemen Rial"},{code:"ZAR",name:"South Africa Rand"},{code:"ZMW",name:"Zambia Kwacha"},{code:"ZWD",name:"Zimbabwe Dollar"}]},v=Object.prototype.hasOwnProperty,y=Object.keys||function(a){var e=[];
+for(var n in a)v.call(a,n)&&e.push(n);return e};a.prototype.get=function(a){return o(p[a])},a.prototype.mac_address=function(a){a=e(a),a.separator||(a.separator=a.networkVersion?".":":");var n="ABCDEF1234567890",i="";return i=a.networkVersion?this.n(this.string,3,{pool:n,length:4}).join(a.separator):this.n(this.string,6,{pool:n,length:2}).join(a.separator)},a.prototype.normal=function(a){a=e(a,{mean:0,dev:1});var n,i,t,r,o=a.mean,s=a.dev;do i=2*this.random()-1,t=2*this.random()-1,n=i*i+t*t;while(n>=1);return r=i*Math.sqrt(-2*Math.log(n)/n),s*r+o},a.prototype.radio=function(a){a=e(a,{side:"?"});var n="";switch(a.side.toLowerCase()){case"east":case"e":n="W";break;case"west":case"w":n="K";break;default:n=this.character({pool:"KW"})}return n+this.character({alpha:!0,casing:"upper"})+this.character({alpha:!0,casing:"upper"})+this.character({alpha:!0,casing:"upper"})},a.prototype.set=function(a,e){"string"==typeof a?p[a]=e:p=o(a,p)},a.prototype.tv=function(a){return this.radio(a)},a.prototype.cnpj=function(){var a=this.n(this.natural,8,{max:9}),e=2+6*a[7]+7*a[6]+8*a[5]+9*a[4]+2*a[3]+3*a[2]+4*a[1]+5*a[0];e=11-e%11,e>=10&&(e=0);var n=2*e+3+7*a[7]+8*a[6]+9*a[5]+2*a[4]+3*a[3]+4*a[2]+5*a[1]+6*a[0];return n=11-n%11,n>=10&&(n=0),""+a[0]+a[1]+"."+a[2]+a[3]+a[4]+"."+a[5]+a[6]+a[7]+"/0001-"+e+n},a.prototype.mersenne_twister=function(a){return new g(a)};var g=function(a){void 0===a&&(a=(new Date).getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,this.init_genrand(a)};g.prototype.init_genrand=function(a){for(this.mt[0]=a>>>0,this.mti=1;this.mti<this.N;this.mti++)a=this.mt[this.mti-1]^this.mt[this.mti-1]>>>30,this.mt[this.mti]=(1812433253*((4294901760&a)>>>16)<<16)+1812433253*(65535&a)+this.mti,this.mt[this.mti]>>>=0},g.prototype.init_by_array=function(a,e){var n,i,t=1,r=0;for(this.init_genrand(19650218),n=this.N>e?this.N:e;n;n--)i=this.mt[t-1]^this.mt[t-1]>>>30,this.mt[t]=(this.mt[t]^(1664525*((4294901760&i)>>>16)<<16)+1664525*(65535&i))+a[r]+r,this.mt[t]>>>=0,t++,r++,t>=this.N&&(this.mt[0]=this.mt[this.N-1],t=1),r>=e&&(r=0);for(n=this.N-1;n;n--)i=this.mt[t-1]^this.mt[t-1]>>>30,this.mt[t]=(this.mt[t]^(1566083941*((4294901760&i)>>>16)<<16)+1566083941*(65535&i))-t,this.mt[t]>>>=0,t++,t>=this.N&&(this.mt[0]=this.mt[this.N-1],t=1);this.mt[0]=2147483648},g.prototype.genrand_int32=function(){var a,e=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var n;for(this.mti===this.N+1&&this.init_genrand(5489),n=0;n<this.N-this.M;n++)a=this.mt[n]&this.UPPER_MASK|this.mt[n+1]&this.LOWER_MASK,this.mt[n]=this.mt[n+this.M]^a>>>1^e[1&a];for(;n<this.N-1;n++)a=this.mt[n]&this.UPPER_MASK|this.mt[n+1]&this.LOWER_MASK,this.mt[n]=this.mt[n+(this.M-this.N)]^a>>>1^e[1&a];a=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^a>>>1^e[1&a],this.mti=0}return a=this.mt[this.mti++],a^=a>>>11,a^=a<<7&2636928640,a^=a<<15&4022730752,a^=a>>>18,a>>>0},g.prototype.genrand_int31=function(){return this.genrand_int32()>>>1},g.prototype.genrand_real1=function(){return this.genrand_int32()*(1/4294967295)},g.prototype.random=function(){return this.genrand_int32()*(1/4294967296)},g.prototype.genrand_real3=function(){return(this.genrand_int32()+.5)*(1/4294967296)},g.prototype.genrand_res53=function(){var a=this.genrand_int32()>>>5,e=this.genrand_int32()>>>6;return(67108864*a+e)*(1/9007199254740992)},"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=a),exports.Chance=a),"function"==typeof define&&define.amd&&define([],function(){return a}),"undefined"!=typeof importScripts&&(chance=new a),"object"==typeof window&&"object"==typeof window.document&&(window.Chance=a,window.chance=new a)}()}();
+
+!function(){require=function t(e,n,r){function i(a,f){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!f&&u)return u(a,!0);if(o)return o(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){var r=t("./web3");BigNumber.config({ROUNDING_MODE:BigNumber.ROUND_DOWN});var i=32,o=4,a=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},f=function(t,e){return a(t,function(t){return t.name===e})},u=function(t,e){var n=f(t,e);return-1===n?void console.error("method "+e+" not found in the abi"):t[n]},s=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},c=function(t){return function(e){return 0===e.indexOf(t)}},l=function(t){return function(e){return t===e}},h=function(t){return"[]"===t.slice(-2)},p=function(t){var e=2*i;return t instanceof BigNumber||"number"==typeof t?("number"==typeof t&&(t=new BigNumber(t)),t=t.round(),t.lessThan(0)&&(t=new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?p(new BigNumber(t)):(+t).toString(16),s(t,e)},d=function(t){return r.fromAscii(t,i).substr(2)},m=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},g=function(t){return p(new BigNumber(t).times(new BigNumber(2).pow(128)))},v=function(t,e){return h(t)||"string"===t?p(e.length):""},b=function(){return[{type:c("uint"),format:p},{type:c("int"),format:p},{type:c("hash"),format:p},{type:c("string"),format:d},{type:c("real"),format:g},{type:c("ureal"),format:g},{type:l("address"),format:p},{type:l("bool"),format:m}]},y=b(),_=function(t,e,n){var r="",o=u(t,e),a=2*i;return o.inputs.forEach(function(t,e){r+=v(t.type,n[e])}),o.inputs.forEach(function(t,e){for(var i=!1,a=0;a<y.length&&!i;a++)i=y[a].type(o.inputs[e].type,n[e]);i||console.error("input parser does not support type: "+o.inputs[e].type);var f=y[a-1].format,u="";u=h(o.inputs[e].type)?n[e].reduce(function(t,e){return t+f(e)},""):f(n[e]),r+=u}),r},w=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},N=function(t){return t=t||"0",w(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},x=function(t){return t=t||"0",new BigNumber(t,16)},B=function(t){return N(t).dividedBy(new BigNumber(2).pow(128))},A=function(t){return x(t).dividedBy(new BigNumber(2).pow(128))},S=function(t){return"0x"+t},O=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},P=function(t){return r.toAscii(t)},E=function(t){return"0x"+t.slice(t.length-40,t.length)},k=function(t){return h(t)||"string"===t?2*i:0},F=function(){return[{type:c("uint"),format:x},{type:c("int"),format:N},{type:c("hash"),format:S},{type:c("string"),format:P},{type:c("real"),format:B},{type:c("ureal"),format:A},{type:l("address"),format:E},{type:l("bool"),format:O}]},T=F(),M=function(t,e,n){n=n.slice(2);var r=[],o=u(t,e),a=2*i,f=o.outputs.reduce(function(t,e){return t+k(e.type)},0),s=n.slice(0,f);return n=n.slice(f),o.outputs.forEach(function(t,e){for(var i=!1,f=0;f<T.length&&!i;f++)i=T[f].type(o.outputs[e].type);i||console.error("output parser does not support type: "+o.outputs[e].type);var u=T[f-1].format;if(h(o.outputs[e].type)){var l=x(s.slice(0,a));s=s.slice(a);for(var p=[],d=0;l>d;d++)p.push(u(n.slice(0,a))),n=n.slice(a);r.push(p)}else c("string")(o.outputs[e].type)?(s=s.slice(a),r.push(u(n.slice(0,a))),n=n.slice(a)):(r.push(u(n.slice(0,a))),n=n.slice(a))}),r},D=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},C=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)):""},q=function(t){var e={};return t.forEach(function(n){var r=D(n.name),i=C(n.name),o=function(){var e=Array.prototype.slice.call(arguments);return _(t,n.name,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},I=function(t){var e={};return t.forEach(function(n){var r=D(n.name),i=C(n.name),o=function(e){return M(t,n.name,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},G=function(t){return r.sha3(r.fromAscii(t)).slice(0,2+2*o)};e.exports={inputParser:q,outputParser:I,methodSignature:G,methodDisplayName:D,methodTypeName:C,getMethodWithName:u}},{"./web3":7}],2:[function(t,e,n){var r=t("./web3"),i=t("./abi"),o=function(t,e){e.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var n=i.inputParser(e),o=i.outputParser(e),a={};return a.call=function(t){return a._isTransact=!1,a._options=t,a},a.transact=function(t){return a._isTransact=!0,a._options=t,a},a._options={},["gas","gasPrice","value","from"].forEach(function(t){a[t]=function(e){return a._options[t]=e,a}}),e.forEach(function(f){var u=i.methodDisplayName(f.name),s=i.methodTypeName(f.name),c=function(){var c=Array.prototype.slice.call(arguments),l=i.methodSignature(f.name),h=n[u][s].apply(null,c),p=a._options||{};p.to=t,p.data=l+h;var d=a._isTransact===!0||a._isTransact!==!1&&!f.constant,m=p.collapse!==!1;if(a._options={},a._isTransact=null,d)return r._currentContractAbi=e,r._currentContractAddress=t,r._currentContractMethodName=f.name,r._currentContractMethodParams=c,void r.eth.transact(p);var g=r.eth.call(p),v=o[u][s](g);return m&&(1===v.length?v=v[0]:0===v.length&&(v=null)),v};void 0===a[u]&&(a[u]=c),a[u][s]=c}),a};e.exports=o},{"./abi":1,"./web3":7}],3:[function(t,e,n){var r=t("./web3"),i=function(t,e){this.impl=e,this.callbacks=[],this.id=e.newFilter(t),r.provider.startPolling({call:e.changed,args:[this.id]},this.id,this.trigger.bind(this))};i.prototype.arrived=function(t){this.changed(t)},i.prototype.changed=function(t){this.callbacks.push(t)},i.prototype.trigger=function(t){for(var e=0;e<this.callbacks.length;e++)for(var n=0;n<t.length;n++)this.callbacks[e].call(this,t[n])},i.prototype.uninstall=function(){this.impl.uninstallFilter(this.id),r.provider.stopPolling(this.id)},i.prototype.messages=function(){return this.impl.getMessages(this.id)},i.prototype.logs=function(){return this.messages()},e.exports=i},{"./web3":7}],4:[function(t,e,n){function r(t){return{jsonrpc:"2.0",method:t.call,params:t.args,id:t._id}}function i(t){var e=JSON.parse(t);return{_id:e.id,data:e.result,error:e.error}}var o=function(t){this.handlers=[],this.host=t||"http://localhost:8080"};o.prototype.send=function(t){var e=r(t),n=new XMLHttpRequest;return n.open("POST",this.host,!1),n.send(JSON.stringify(e)),n.responseText},e.exports=o},{}],5:[function(t,e,n){var r=t("./web3"),i=function(){this.polls=[],this.provider=void 0,this.id=1;var t=this,e=function(){t.provider&&t.polls.forEach(function(e){e.data._id=t.id,t.id++;var n=t.provider.send(e.data);n=JSON.parse(n),!n.error&&n.result instanceof Array&&0!==n.result.length&&e.callback(n.result)}),setTimeout(e,1e3)};e()};i.prototype.send=function(t){if(t.args=t.args||[],t._id=this.id++,void 0===this.provider)return console.error("provider is not set"),null;var e=this.provider.send(t);return e=JSON.parse(e),e.error?(console.log(e.error),null):e.result},i.prototype.set=function(t){this.provider=t},i.prototype.startPolling=function(t,e,n){this.polls.push({data:t,id:e,callback:n})},i.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var n=this.polls[e];n.id===t&&this.polls.splice(e,1)}},e.exports=i},{"./web3":7}],6:[function(t,e,n){var r=function(){};r.prototype.send=function(t){return navigator.qt.callMethod(JSON.stringify(t))},e.exports=r},{}],7:[function(t,e,n){var r=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"],i=function(){return[{name:"sha3",call:"web3_sha3"}]},o=function(){var t=function(t){return"string"==typeof t[0]?"eth_blockByHash":"eth_blockByNumber"},e=function(t){return"string"==typeof t[0]?"eth_transactionByHash":"eth_transactionByNumber"},n=function(t){return"string"==typeof t[0]?"eth_uncleByHash":"eth_uncleByNumber"},r=[{name:"balanceAt",call:"eth_balanceAt"},{name:"stateAt",call:"eth_stateAt"},{name:"storageAt",call:"eth_storageAt"},{name:"countAt",call:"eth_countAt"},{name:"codeAt",call:"eth_codeAt"},{name:"transact",call:"eth_transact"},{name:"call",call:"eth_call"},{name:"block",call:t},{name:"transaction",call:e},{name:"uncle",call:n},{name:"compilers",call:"eth_compilers"},{name:"flush",call:"eth_flush"},{name:"lll",call:"eth_lll"},{name:"solidity",call:"eth_solidity"},{name:"serpent",call:"eth_serpent"},{name:"logs",call:"eth_logs"}];return r},a=function(){return[{name:"coinbase",getter:"eth_coinbase",setter:"eth_setCoinbase"},{name:"listening",getter:"eth_listening",setter:"eth_setListening"},{name:"mining",getter:"eth_mining",setter:"eth_setMining"},{name:"gasPrice",getter:"eth_gasPrice"},{name:"accounts",getter:"eth_accounts"},{name:"peerCount",getter:"eth_peerCount"},{name:"defaultBlock",getter:"eth_defaultBlock",setter:"eth_setDefaultBlock"},{name:"number",getter:"eth_number"}]},f=function(){return[{name:"put",call:"db_put"},{name:"get",call:"db_get"},{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"}]},u=function(){return[{name:"post",call:"shh_post"},{name:"newIdentity",call:"shh_newIdentity"},{name:"haveIdentity",call:"shh_haveIdentity"},{name:"newGroup",call:"shh_newGroup"},{name:"addToGroup",call:"shh_addToGroup"}]},s=function(){var t=function(t){return"string"==typeof t[0]?"eth_newFilterString":"eth_newFilter"};return[{name:"newFilter",call:t},{name:"uninstallFilter",call:"eth_uninstallFilter"},{name:"getMessages",call:"eth_filterLogs"}]},c=function(){return[{name:"newFilter",call:"shh_newFilter"},{name:"uninstallFilter",call:"shh_uninstallFilter"},{name:"getMessages",call:"shh_getMessages"}]},l=function(t,e){e.forEach(function(e){t[e.name]=function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof e.call?e.call(t):e.call;return p.provider.send({call:n,args:t})}})},h=function(t,e){e.forEach(function(e){var n={};n.get=function(){return p.provider.send({call:e.getter})},e.setter&&(n.set=function(t){return p.provider.send({call:e.setter,args:[t]})}),Object.defineProperty(t,e.name,n)})},p={_callbacks:{},_events:{},providers:{},toHex:function(t){for(var e="",n=0;n<t.length;n++){var r=t.charCodeAt(n).toString(16);e+=r.length<2?"0"+r:r}return e},toAscii:function(t){var e="",n=0,r=t.length;for("0x"===t.substring(0,2)&&(n=2);r>n;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},fromAscii:function(t,e){e=void 0===e?0:e;for(var n=this.toHex(t);n.length<2*e;)n+="00";return"0x"+n},toDecimal:function(t){return t=t.length>2?t.substring(2):"0",new BigNumber(t,16).toString(10)},fromDecimal:function(t){return"0x"+new BigNumber(t).toString(16)},toEth:function(t){for(var e="string"==typeof t?0===t.indexOf("0x")?parseInt(t.substr(2),16):parseInt(t):t,n=0,i=r;e>3e3&&n<i.length-1;)e/=1e3,n++;for(var o=e.toString().length<e.toFixed(2).length?e.toString():e.toFixed(2),a=function(t,e,n){return e+","+n};;){var f=o;if(o=o.replace(/(\d)(\d\d\d[\.\,])/,a),f===o)break}return o+" "+i[n]},eth:{contractFromAbi:function(t){return function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=p.eth.contract(e,t);return n.address=e,n}},watch:function(t){return new p.filter(t,d)}},db:{},shh:{watch:function(t){return new p.filter(t,m)}},haveProvider:function(){return!!p.provider.provider}};l(p,i()),l(p.eth,o()),h(p.eth,a()),l(p.db,f()),l(p.shh,u());var d={changed:"eth_changed"};l(d,s());var m={changed:"shh_changed"};l(m,c()),p.setProvider=function(t){p.provider.set(t)},e.exports=p},{}],web3:[function(t,e,n){var r=t("./lib/web3"),i=t("./lib/providermanager");r.provider=new i,r.filter=t("./lib/filter"),r.providers.HttpSyncProvider=t("./lib/httpsync"),r.providers.QtSyncProvider=t("./lib/qtsync"),r.eth.contract=t("./lib/contract"),r.abi=t("./lib/abi"),e.exports=r},{"./lib/abi":1,"./lib/contract":2,"./lib/filter":3,"./lib/httpsync":4,"./lib/providermanager":5,"./lib/qtsync":6,"./lib/web3":7}]},{},["web3"])}();
+
+!function(){!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.GeoPattern=t()}}(function(){return function t(r,s,e){function i(o,a){if(!s[o]){if(!r[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(n)return n(o,!0);throw new Error("Cannot find module '"+o+"'")}var l=s[o]={exports:{}};r[o][0].call(l.exports,function(t){var s=r[o][1][t];return i(s?s:t)},l,l.exports,t,r,s,e)}return s[o].exports}for(var n="function"==typeof require&&require,o=0;o<e.length;o++)i(e[o]);return i}({1:[function(t,r){r.exports=t("./lib/")},{"./lib/":3}],2:[function(t,r){"use strict";function s(t){var r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(r,function(t,r,s,e){return r+r+s+s+e+e});var s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:null}function e(t){return"#"+["r","g","b"].map(function(r){return("0"+t[r].toString(16)).slice(-2)}).join("")}function i(t){var r=t.r,s=t.g,e=t.b;r/=255,s/=255,e/=255;var i,n,o=Math.max(r,s,e),a=Math.min(r,s,e),h=(o+a)/2;if(o===a)i=n=0;else{var l=o-a;switch(n=h>.5?l/(2-o-a):l/(o+a),o){case r:i=(s-e)/l+(e>s?6:0);break;case s:i=(e-r)/l+2;break;case e:i=(r-s)/l+4}i/=6}return{h:i,s:n,l:h}}function n(t){function r(t,r,s){return 0>s&&(s+=1),s>1&&(s-=1),1/6>s?t+6*(r-t)*s:.5>s?r:2/3>s?t+(r-t)*(2/3-s)*6:t}var s,e,i,n=t.h,o=t.s,a=t.l;if(0===o)s=e=i=a;else{var h=.5>a?a*(1+o):a+o-a*o,l=2*a-h;s=r(l,h,n+1/3),e=r(l,h,n),i=r(l,h,n-1/3)}return{r:Math.round(255*s),g:Math.round(255*e),b:Math.round(255*i)}}r.exports={hex2rgb:s,rgb2hex:e,rgb2hsl:i,hsl2rgb:n,rgb2rgbString:function(t){return"rgb("+[t.r,t.g,t.b].join(",")+")"}}},{}],3:[function(t,r){!function(s){"use strict";function e(t){return function(r,s){return"object"==typeof r&&(s=r,r=null),(null===r||void 0===r)&&(r=(new Date).toString()),s||(s={}),t.call(this,r,s)}}var i=t("./pattern"),n=r.exports={generate:e(function(t,r){return new i(t,r)})};s&&(s.fn.geopattern=e(function(t,r){return this.each(function(){var e=s(this).attr("data-title-sha");e&&(r=s.extend({hash:e},r));var i=n.generate(t,r);s(this).css("background-image",i.toDataUrl())})}))}("undefined"!=typeof jQuery?jQuery:null)},{"./pattern":4}],4:[function(t,r){(function(s){"use strict";function e(t,r,s){return parseInt(t.substr(r,s||1),16)}function i(t,r,s,e,i){var n=parseFloat(t),o=s-r,a=i-e;return(n-r)*a/o+e}function n(t){return t%2===0?C:j}function o(t){return i(t,0,15,M,W)}function a(t){var r=t,s=r/2,e=Math.sin(60*Math.PI/180)*r;return[0,e,s,0,s+r,0,2*r,e,s+r,2*e,s,2*e,0,e].join(",")}function h(t,r){var s=.66*r;return[[0,0,t/2,r-s,t/2,r,0,s,0,0],[t/2,r-s,t,0,t,s,t/2,r,t/2,r-s]].map(function(t){return t.join(",")})}function l(t){return[[t,0,t,3*t],[0,t,3*t,t]]}function c(t){var r=t,s=.33*r;return[s,0,r-s,0,r,s,r,r-s,r-s,r,s,r,0,r-s,0,s,s,0].join(",")}function f(t,r){var s=t/2;return[s,0,t,r,0,r,s,0].join(",")}function u(t,r){return[t/2,0,t,r/2,t/2,r,0,r/2].join(",")}function p(t){return[0,0,t,t,0,t,0,0].join(",")}function g(t,r,s,e,i){var a=p(e),h=o(i[0]),l=n(i[0]),c={stroke:S,"stroke-opacity":A,"fill-opacity":h,fill:l};t.polyline(a,c).transform({translate:[r+e,s],scale:[-1,1]}),t.polyline(a,c).transform({translate:[r+e,s+2*e],scale:[1,-1]}),h=o(i[1]),l=n(i[1]),c={stroke:S,"stroke-opacity":A,"fill-opacity":h,fill:l},t.polyline(a,c).transform({translate:[r+e,s+2*e],scale:[-1,-1]}),t.polyline(a,c).transform({translate:[r+e,s],scale:[1,1]})}function v(t,r,s,e,i){var a=o(i),h=n(i),l=p(e),c={stroke:S,"stroke-opacity":A,"fill-opacity":a,fill:h};t.polyline(l,c).transform({translate:[r,s+e],scale:[1,-1]}),t.polyline(l,c).transform({translate:[r+2*e,s+e],scale:[-1,-1]}),t.polyline(l,c).transform({translate:[r,s+e],scale:[1,1]}),t.polyline(l,c).transform({translate:[r+2*e,s+e],scale:[-1,1]})}function y(t,r){var s=t/2;return[0,0,r,s,0,t,0,0].join(",")}var d=t("extend"),b=t("./color"),m=t("./sha1"),k=t("./svg"),x={baseColor:"#933c3c"},w=["octogons","overlappingCircles","plusSigns","xes","sineWaves","hexagons","overlappingRings","plaid","triangles","squares","concentricCircles","diamonds","tessellation","nestedSquares","mosaicSquares","chevrons"],j="#222",C="#ddd",S="#000",A=.02,M=.02,W=.15,H=r.exports=function(t,r){return this.opts=d({},x,r),this.hash=r.hash||m(t),this.svg=new k,this.generateBackground(),this.generatePattern(),this};H.prototype.toSvg=function(){return this.svg.toString()},H.prototype.toString=function(){return this.toSvg()},H.prototype.toBase64=function(){var t,r=this.toSvg();return t="undefined"!=typeof window&&"function"==typeof window.btoa?window.btoa(r):new s(r).toString("base64")},H.prototype.toDataUri=function(){return"data:image/svg+xml;base64,"+this.toBase64()},H.prototype.toDataUrl=function(){return'url("'+this.toDataUri()+'")'},H.prototype.generateBackground=function(){var t,r,s,n;this.opts.color?s=b.hex2rgb(this.opts.color):(r=i(e(this.hash,14,3),0,4095,0,359),n=e(this.hash,17),t=b.rgb2hsl(b.hex2rgb(this.opts.baseColor)),t.h=(360*t.h-r+360)%360/360,t.s=n%2===0?Math.min(1,(100*t.s+n)/100):Math.max(0,(100*t.s-n)/100),s=b.hsl2rgb(t)),this.color=b.rgb2hex(s),this.svg.rect(0,0,"100%","100%",{fill:b.rgb2rgbString(s)})},H.prototype.generatePattern=function(){var t=this.opts.generator;if(t){if(w.indexOf(t)<0)throw new Error("The generator "+t+" does not exist.")}else t=w[e(this.hash,20)];return this["geo"+t.slice(0,1).toUpperCase()+t.slice(1)]()},H.prototype.geoHexagons=function(){var t,r,s,h,l,c,f,u,p=e(this.hash,0),g=i(p,0,15,8,60),v=g*Math.sqrt(3),y=2*g,d=a(g);for(this.svg.setWidth(3*y+3*g),this.svg.setHeight(6*v),s=0,u=0;6>u;u++)for(f=0;6>f;f++)c=e(this.hash,s),t=f%2===0?u*v:u*v+v/2,h=o(c),r=n(c),l={fill:r,"fill-opacity":h,stroke:S,"stroke-opacity":A},this.svg.polyline(d,l).transform({translate:[f*g*1.5-y/2,t-v/2]}),0===f&&this.svg.polyline(d,l).transform({translate:[6*g*1.5-y/2,t-v/2]}),0===u&&(t=f%2===0?6*v:6*v+v/2,this.svg.polyline(d,l).transform({translate:[f*g*1.5-y/2,t-v/2]})),0===f&&0===u&&this.svg.polyline(d,l).transform({translate:[6*g*1.5-y/2,5*v+v/2]}),s++},H.prototype.geoSineWaves=function(){var t,r,s,a,h,l,c,f=Math.floor(i(e(this.hash,0),0,15,100,400)),u=Math.floor(i(e(this.hash,1),0,15,30,100)),p=Math.floor(i(e(this.hash,2),0,15,3,30));for(this.svg.setWidth(f),this.svg.setHeight(36*p),r=0;36>r;r++)l=e(this.hash,r),s=o(l),t=n(l),c=f/4*.7,h={fill:"none",stroke:t,opacity:s,"stroke-width":""+p+"px"},a="M0 "+u+" C "+c+" 0, "+(f/2-c)+" 0, "+f/2+" "+u+" S "+(f-c)+" "+2*u+", "+f+" "+u+" S "+(1.5*f-c)+" 0, "+1.5*f+", "+u,this.svg.path(a,h).transform({translate:[-f/4,p*r-1.5*u]}),this.svg.path(a,h).transform({translate:[-f/4,p*r-1.5*u+36*p]})},H.prototype.geoChevrons=function(){var t,r,s,a,l,c,f,u=i(e(this.hash,0),0,15,30,80),p=i(e(this.hash,0),0,15,30,80),g=h(u,p);for(this.svg.setWidth(6*u),this.svg.setHeight(6*p*.66),r=0,f=0;6>f;f++)for(c=0;6>c;c++)l=e(this.hash,r),s=o(l),t=n(l),a={stroke:S,"stroke-opacity":A,fill:t,"fill-opacity":s,"stroke-width":1},this.svg.group(a).transform({translate:[c*u,f*p*.66-p/2]}).polyline(g).end(),0===f&&this.svg.group(a).transform({translate:[c*u,6*p*.66-p/2]}).polyline(g).end(),r+=1},H.prototype.geoPlusSigns=function(){var t,r,s,a,h,c,f,u,p=i(e(this.hash,0),0,15,10,25),g=3*p,v=l(p);for(this.svg.setWidth(12*p),this.svg.setHeight(12*p),s=0,u=0;6>u;u++)for(f=0;6>f;f++)c=e(this.hash,s),a=o(c),r=n(c),t=u%2===0?0:1,h={fill:r,stroke:S,"stroke-opacity":A,"fill-opacity":a},this.svg.group(h).transform({translate:[f*g-f*p+t*p-p,u*g-u*p-g/2]}).rect(v).end(),0===f&&this.svg.group(h).transform({translate:[4*g-f*p+t*p-p,u*g-u*p-g/2]}).rect(v).end(),0===u&&this.svg.group(h).transform({translate:[f*g-f*p+t*p-p,4*g-u*p-g/2]}).rect(v).end(),0===f&&0===u&&this.svg.group(h).transform({translate:[4*g-f*p+t*p-p,4*g-u*p-g/2]}).rect(v).end(),s++},H.prototype.geoXes=function(){var t,r,s,a,h,c,f,u,p=i(e(this.hash,0),0,15,10,25),g=l(p),v=3*p*.943;for(this.svg.setWidth(3*v),this.svg.setHeight(3*v),s=0,u=0;6>u;u++)for(f=0;6>f;f++)c=e(this.hash,s),a=o(c),t=f%2===0?u*v-.5*v:u*v-.5*v+v/4,r=n(c),h={fill:r,opacity:a},this.svg.group(h).transform({translate:[f*v/2-v/2,t-u*v/2],rotate:[45,v/2,v/2]}).rect(g).end(),0===f&&this.svg.group(h).transform({translate:[6*v/2-v/2,t-u*v/2],rotate:[45,v/2,v/2]}).rect(g).end(),0===u&&(t=f%2===0?6*v-v/2:6*v-v/2+v/4,this.svg.group(h).transform({translate:[f*v/2-v/2,t-6*v/2],rotate:[45,v/2,v/2]}).rect(g).end()),5===u&&this.svg.group(h).transform({translate:[f*v/2-v/2,t-11*v/2],rotate:[45,v/2,v/2]}).rect(g).end(),0===f&&0===u&&this.svg.group(h).transform({translate:[6*v/2-v/2,t-6*v/2],rotate:[45,v/2,v/2]}).rect(g).end(),s++},H.prototype.geoOverlappingCircles=function(){var t,r,s,a,h,l,c,f=e(this.hash,0),u=i(f,0,15,25,200),p=u/2;for(this.svg.setWidth(6*p),this.svg.setHeight(6*p),r=0,c=0;6>c;c++)for(l=0;6>l;l++)h=e(this.hash,r),s=o(h),t=n(h),a={fill:t,opacity:s},this.svg.circle(l*p,c*p,p,a),0===l&&this.svg.circle(6*p,c*p,p,a),0===c&&this.svg.circle(l*p,6*p,p,a),0===l&&0===c&&this.svg.circle(6*p,6*p,p,a),r++},H.prototype.geoOctogons=function(){var t,r,s,a,h,l,f=i(e(this.hash,0),0,15,10,60),u=c(f);for(this.svg.setWidth(6*f),this.svg.setHeight(6*f),r=0,l=0;6>l;l++)for(h=0;6>h;h++)a=e(this.hash,r),s=o(a),t=n(a),this.svg.polyline(u,{fill:t,"fill-opacity":s,stroke:S,"stroke-opacity":A}).transform({translate:[h*f,l*f]}),r+=1},H.prototype.geoSquares=function(){var t,r,s,a,h,l,c=i(e(this.hash,0),0,15,10,60);for(this.svg.setWidth(6*c),this.svg.setHeight(6*c),r=0,l=0;6>l;l++)for(h=0;6>h;h++)a=e(this.hash,r),s=o(a),t=n(a),this.svg.rect(h*c,l*c,c,c,{fill:t,"fill-opacity":s,stroke:S,"stroke-opacity":A}),r+=1},H.prototype.geoConcentricCircles=function(){var t,r,s,a,h,l,c=e(this.hash,0),f=i(c,0,15,10,60),u=f/5;for(this.svg.setWidth(6*(f+u)),this.svg.setHeight(6*(f+u)),r=0,l=0;6>l;l++)for(h=0;6>h;h++)a=e(this.hash,r),s=o(a),t=n(a),this.svg.circle(h*f+h*u+(f+u)/2,l*f+l*u+(f+u)/2,f/2,{fill:"none",stroke:t,opacity:s,"stroke-width":u+"px"}),a=e(this.hash,39-r),s=o(a),t=n(a),this.svg.circle(h*f+h*u+(f+u)/2,l*f+l*u+(f+u)/2,f/4,{fill:t,"fill-opacity":s}),r+=1},H.prototype.geoOverlappingRings=function(){var t,r,s,a,h,l,c,f=e(this.hash,0),u=i(f,0,15,10,60),p=u/4;for(this.svg.setWidth(6*u),this.svg.setHeight(6*u),r=0,c=0;6>c;c++)for(l=0;6>l;l++)h=e(this.hash,r),s=o(h),t=n(h),a={fill:"none",stroke:t,opacity:s,"stroke-width":p+"px"},this.svg.circle(l*u,c*u,u-p/2,a),0===l&&this.svg.circle(6*u,c*u,u-p/2,a),0===c&&this.svg.circle(l*u,6*u,u-p/2,a),0===l&&0===c&&this.svg.circle(6*u,6*u,u-p/2,a),r+=1},H.prototype.geoTriangles=function(){var t,r,s,a,h,l,c,u,p=e(this.hash,0),g=i(p,0,15,15,80),v=g/2*Math.sqrt(3),y=f(g,v);for(this.svg.setWidth(3*g),this.svg.setHeight(6*v),r=0,u=0;6>u;u++)for(c=0;6>c;c++)l=e(this.hash,r),s=o(l),t=n(l),h={fill:t,"fill-opacity":s,stroke:S,"stroke-opacity":A},a=u%2===0?c%2===0?180:0:c%2!==0?180:0,this.svg.polyline(y,h).transform({translate:[c*g*.5-g/2,v*u],rotate:[a,g/2,v/2]}),0===c&&this.svg.polyline(y,h).transform({translate:[6*g*.5-g/2,v*u],rotate:[a,g/2,v/2]}),r+=1},H.prototype.geoDiamonds=function(){var t,r,s,a,h,l,c,f,p=i(e(this.hash,0),0,15,10,50),g=i(e(this.hash,1),0,15,10,50),v=u(p,g);for(this.svg.setWidth(6*p),this.svg.setHeight(3*g),s=0,f=0;6>f;f++)for(c=0;6>c;c++)l=e(this.hash,s),a=o(l),r=n(l),h={fill:r,"fill-opacity":a,stroke:S,"stroke-opacity":A},t=f%2===0?0:p/2,this.svg.polyline(v,h).transform({translate:[c*p-p/2+t,g/2*f-g/2]}),0===c&&this.svg.polyline(v,h).transform({translate:[6*p-p/2+t,g/2*f-g/2]}),0===f&&this.svg.polyline(v,h).transform({translate:[c*p-p/2+t,g/2*6-g/2]}),0===c&&0===f&&this.svg.polyline(v,h).transform({translate:[6*p-p/2+t,g/2*6-g/2]}),s+=1},H.prototype.geoNestedSquares=function(){var t,r,s,a,h,l,c,f=i(e(this.hash,0),0,15,4,12),u=7*f;for(this.svg.setWidth(6*(u+f)+6*f),this.svg.setHeight(6*(u+f)+6*f),r=0,c=0;6>c;c++)for(l=0;6>l;l++)h=e(this.hash,r),s=o(h),t=n(h),a={fill:"none",stroke:t,opacity:s,"stroke-width":f+"px"},this.svg.rect(l*u+l*f*2+f/2,c*u+c*f*2+f/2,u,u,a),h=e(this.hash,39-r),s=o(h),t=n(h),a={fill:"none",stroke:t,opacity:s,"stroke-width":f+"px"},this.svg.rect(l*u+l*f*2+f/2+2*f,c*u+c*f*2+f/2+2*f,3*f,3*f,a),r+=1},H.prototype.geoMosaicSquares=function(){var t,r,s,n=i(e(this.hash,0),0,15,15,50);for(this.svg.setWidth(8*n),this.svg.setHeight(8*n),t=0,s=0;4>s;s++)for(r=0;4>r;r++)r%2===0?s%2===0?v(this.svg,r*n*2,s*n*2,n,e(this.hash,t)):g(this.svg,r*n*2,s*n*2,n,[e(this.hash,t),e(this.hash,t+1)]):s%2===0?g(this.svg,r*n*2,s*n*2,n,[e(this.hash,t),e(this.hash,t+1)]):v(this.svg,r*n*2,s*n*2,n,e(this.hash,t)),t+=1},H.prototype.geoPlaid=function(){var t,r,s,i,a,h,l,c=0,f=0;for(r=0;36>r;)i=e(this.hash,r),c+=i+5,l=e(this.hash,r+1),s=o(l),t=n(l),a=l+5,this.svg.rect(0,c,"100%",a,{opacity:s,fill:t}),c+=a,r+=2;for(r=0;36>r;)i=e(this.hash,r),f+=i+5,l=e(this.hash,r+1),s=o(l),t=n(l),h=l+5,this.svg.rect(f,0,h,"100%",{opacity:s,fill:t}),f+=h,r+=2;this.svg.setWidth(f),this.svg.setHeight(c)},H.prototype.geoTessellation=function(){var t,r,s,a,h,l=i(e(this.hash,0),0,15,5,40),c=l*Math.sqrt(3),f=2*l,u=l/2*Math.sqrt(3),p=y(l,u),g=3*l+2*u,v=2*c+2*l;for(this.svg.setWidth(g),this.svg.setHeight(v),r=0;20>r;r++)switch(h=e(this.hash,r),s=o(h),t=n(h),a={stroke:S,"stroke-opacity":A,fill:t,"fill-opacity":s,"stroke-width":1},r){case 0:this.svg.rect(-l/2,-l/2,l,l,a),this.svg.rect(g-l/2,-l/2,l,l,a),this.svg.rect(-l/2,v-l/2,l,l,a),this.svg.rect(g-l/2,v-l/2,l,l,a);break;case 1:this.svg.rect(f/2+u,c/2,l,l,a);break;case 2:this.svg.rect(-l/2,v/2-l/2,l,l,a),this.svg.rect(g-l/2,v/2-l/2,l,l,a);break;case 3:this.svg.rect(f/2+u,1.5*c+l,l,l,a);break;case 4:this.svg.polyline(p,a).transform({translate:[l/2,-l/2],rotate:[0,l/2,u/2]}),this.svg.polyline(p,a).transform({translate:[l/2,v- -l/2],rotate:[0,l/2,u/2],scale:[1,-1]});break;case 5:this.svg.polyline(p,a).transform({translate:[g-l/2,-l/2],rotate:[0,l/2,u/2],scale:[-1,1]}),this.svg.polyline(p,a).transform({translate:[g-l/2,v+l/2],rotate:[0,l/2,u/2],scale:[-1,-1]});break;case 6:this.svg.polyline(p,a).transform({translate:[g/2+l/2,c/2]});break;case 7:this.svg.polyline(p,a).transform({translate:[g-g/2-l/2,c/2],scale:[-1,1]});break;case 8:this.svg.polyline(p,a).transform({translate:[g/2+l/2,v-c/2],scale:[1,-1]});break;case 9:this.svg.polyline(p,a).transform({translate:[g-g/2-l/2,v-c/2],scale:[-1,-1]});break;case 10:this.svg.polyline(p,a).transform({translate:[l/2,v/2-l/2]});break;case 11:this.svg.polyline(p,a).transform({translate:[g-l/2,v/2-l/2],scale:[-1,1]});break;case 12:this.svg.rect(0,0,l,l,a).transform({translate:[l/2,l/2],rotate:[-30,0,0]});break;case 13:this.svg.rect(0,0,l,l,a).transform({scale:[-1,1],translate:[-g+l/2,l/2],rotate:[-30,0,0]});break;case 14:this.svg.rect(0,0,l,l,a).transform({translate:[l/2,v/2-l/2-l],rotate:[30,0,l]});break;case 15:this.svg.rect(0,0,l,l,a).transform({scale:[-1,1],translate:[-g+l/2,v/2-l/2-l],rotate:[30,0,l]});break;case 16:this.svg.rect(0,0,l,l,a).transform({scale:[1,-1],translate:[l/2,-v+v/2-l/2-l],rotate:[30,0,l]});break;case 17:this.svg.rect(0,0,l,l,a).transform({scale:[-1,-1],translate:[-g+l/2,-v+v/2-l/2-l],rotate:[30,0,l]});break;case 18:this.svg.rect(0,0,l,l,a).transform({scale:[1,-1],translate:[l/2,-v+l/2],rotate:[-30,0,0]});break;case 19:this.svg.rect(0,0,l,l,a).transform({scale:[-1,-1],translate:[-g+l/2,-v+l/2],rotate:[-30,0,0]})}}}).call(this,t("buffer").Buffer)},{"./color":2,"./sha1":5,"./svg":6,buffer:8,extend:9}],5:[function(t,r){"use strict";function s(){function t(){for(var t=16;80>t;t++){var r=f[t-3]^f[t-8]^f[t-14]^f[t-16];f[t]=r<<1|r>>>31}var s,e,i=o,n=a,p=h,g=l,v=c;for(t=0;80>t;t++){20>t?(s=g^n&(p^g),e=1518500249):40>t?(s=n^p^g,e=1859775393):60>t?(s=n&p|g&(n|p),e=2400959708):(s=n^p^g,e=3395469782);var y=(i<<5|i>>>27)+s+v+e+(0|f[t]);v=g,g=p,p=n<<30|n>>>2,n=i,i=y}for(o=o+i|0,a=a+n|0,h=h+p|0,l=l+g|0,c=c+v|0,u=0,t=0;16>t;t++)f[t]=0}function r(r){f[u]|=(255&r)<<p,p?p-=8:(u++,p=24),16===u&&t()}function s(t){var s=t.length;g+=8*s;for(var e=0;s>e;e++)r(t.charCodeAt(e))}function e(t){if("string"==typeof t)return s(t);var e=t.length;g+=8*e;for(var i=0;e>i;i++)r(t[i])}function i(t){for(var r="",s=28;s>=0;s-=4)r+=(t>>s&15).toString(16);return r}function n(){r(128),(u>14||14===u&&24>p)&&t(),u=14,p=24,r(0),r(0),r(g>0xffffffffff?g/1099511627776:0),r(g>4294967295?g/4294967296:0);for(var s=24;s>=0;s-=8)r(g>>s);return i(o)+i(a)+i(h)+i(l)+i(c)}var o=1732584193,a=4023233417,h=2562383102,l=271733878,c=3285377520,f=new Uint32Array(80),u=0,p=24,g=0;return{update:e,digest:n}}r.exports=function(t){if(void 0===t)return s();var r=s();return r.update(t),r.digest()}},{}],6:[function(t,r){"use strict";function s(){return this.width=100,this.height=100,this.svg=new i("svg"),this.context=[],this.setAttributes(this.svg,{xmlns:"http://www.w3.org/2000/svg",width:this.width,height:this.height}),this}var e=t("extend"),i=t("./xml");r.exports=s,s.prototype.currentContext=function(){return this.context[this.context.length-1]||this.svg},s.prototype.end=function(){return this.context.pop(),this},s.prototype.currentNode=function(){var t=this.currentContext();return t.lastChild||t},s.prototype.transform=function(t){return this.currentNode().setAttribute("transform",Object.keys(t).map(function(r){return r+"("+t[r].join(",")+")"}).join(" ")),this},s.prototype.setAttributes=function(t,r){Object.keys(r).forEach(function(s){t.setAttribute(s,r[s])})},s.prototype.setWidth=function(t){this.svg.setAttribute("width",Math.floor(t))},s.prototype.setHeight=function(t){this.svg.setAttribute("height",Math.floor(t))},s.prototype.toString=function(){return this.svg.toString()},s.prototype.rect=function(t,r,s,n,o){var a=this;if(Array.isArray(t))return t.forEach(function(t){a.rect.apply(a,t.concat(o))}),this;var h=new i("rect");return this.currentContext().appendChild(h),this.setAttributes(h,e({x:t,y:r,width:s,height:n},o)),this},s.prototype.circle=function(t,r,s,n){var o=new i("circle");return this.currentContext().appendChild(o),this.setAttributes(o,e({cx:t,cy:r,r:s},n)),this},s.prototype.path=function(t,r){var s=new i("path");return this.currentContext().appendChild(s),this.setAttributes(s,e({d:t},r)),this},s.prototype.polyline=function(t,r){var s=this;if(Array.isArray(t))return t.forEach(function(t){s.polyline(t,r)}),this;var n=new i("polyline");return this.currentContext().appendChild(n),this.setAttributes(n,e({points:t},r)),this},s.prototype.group=function(t){var r=new i("g");return this.currentContext().appendChild(r),this.context.push(r),this.setAttributes(r,e({},t)),this}},{"./xml":7,extend:9}],7:[function(t,r){"use strict";var s=r.exports=function(t){return this instanceof s?(this.tagName=t,this.attributes=Object.create(null),this.children=[],this.lastChild=null,this):new s(t)};s.prototype.appendChild=function(t){return this.children.push(t),this.lastChild=t,this},s.prototype.setAttribute=function(t,r){return this.attributes[t]=r,this},s.prototype.toString=function(){var t=this;return["<",t.tagName,Object.keys(t.attributes).map(function(r){return[" ",r,'="',t.attributes[r],'"'].join("")}).join(""),">",t.children.map(function(t){return t.toString()}).join(""),"</",t.tagName,">"].join("")}},{}],8:[function(){},{}],9:[function(t,r){function s(t){if(!t||"[object Object]"!==i.call(t)||t.nodeType||t.setInterval)return!1;var r=e.call(t,"constructor"),s=e.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!s)return!1;var n;for(n in t);return void 0===n||e.call(t,n)}var e=Object.prototype.hasOwnProperty,i=Object.prototype.toString;r.exports=function n(){var t,r,e,i,o,a,h=arguments[0]||{},l=1,c=arguments.length,f=!1;for("boolean"==typeof h&&(f=h,h=arguments[1]||{},l=2),"object"!=typeof h&&"function"!=typeof h&&(h={});c>l;l++)if(null!=(t=arguments[l]))for(r in t)e=h[r],i=t[r],h!==i&&(f&&i&&(s(i)||(o=Array.isArray(i)))?(o?(o=!1,a=e&&Array.isArray(e)?e:[]):a=e&&s(e)?e:{},h[r]=n(f,a,i)):void 0!==i&&(h[r]=i));return h}},{}]},{},[1])(1)})}();
+
+!function(){!function(t,e,i){!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):jQuery&&!jQuery.fn.sparkline&&t(jQuery)}(function(s){"use strict";var r={},n,a,h,o,l,g,p,u,c,d,f,m,v,x,y,C,w,b,R,S,k,M,_,H,W,T,q,I,j,P,L,A,F=0;n=function(){return{common:{type:"line",lineColor:"#00f",fillColor:"#cdf",defaultPixelsPerValue:3,width:"auto",height:"auto",composite:!1,tagValuesAttribute:"values",tagOptionsPrefix:"spark",enableTagOptions:!1,enableHighlight:!0,highlightLighten:1.4,tooltipSkipNull:!0,tooltipPrefix:"",tooltipSuffix:"",disableHiddenCheck:!1,numberFormatter:!1,numberDigitGroupCount:3,numberDigitGroupSep:",",numberDecimalMark:".",disableTooltips:!1,disableInteraction:!1},line:{spotColor:"#f80",highlightSpotColor:"#5f5",highlightLineColor:"#f22",spotRadius:1.5,minSpotColor:"#f80",maxSpotColor:"#f80",lineWidth:1,normalRangeMin:i,normalRangeMax:i,normalRangeColor:"#ccc",drawNormalOnTop:!1,chartRangeMin:i,chartRangeMax:i,chartRangeMinX:i,chartRangeMaxX:i,tooltipFormat:new h('<span style="color: {{color}}">&#9679;</span> {{prefix}}{{y}}{{suffix}}')},bar:{barColor:"#3366cc",negBarColor:"#f44",stackedBarColor:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],zeroColor:i,nullColor:i,zeroAxis:!0,barWidth:4,barSpacing:1,chartRangeMax:i,chartRangeMin:i,chartRangeClip:!1,colorMap:i,tooltipFormat:new h('<span style="color: {{color}}">&#9679;</span> {{prefix}}{{value}}{{suffix}}')},tristate:{barWidth:4,barSpacing:1,posBarColor:"#6f6",negBarColor:"#f44",zeroBarColor:"#999",colorMap:{},tooltipFormat:new h('<span style="color: {{color}}">&#9679;</span> {{value:map}}'),tooltipValueLookups:{map:{"-1":"Loss",0:"Draw",1:"Win"}}},discrete:{lineHeight:"auto",thresholdColor:i,thresholdValue:0,chartRangeMax:i,chartRangeMin:i,chartRangeClip:!1,tooltipFormat:new h("{{prefix}}{{value}}{{suffix}}")},bullet:{targetColor:"#f33",targetWidth:3,performanceColor:"#33f",rangeColors:["#d3dafe","#a8b6ff","#7f94ff"],base:i,tooltipFormat:new h("{{fieldkey:fields}} - {{value}}"),tooltipValueLookups:{fields:{r:"Range",p:"Performance",t:"Target"}}},pie:{offset:0,sliceColors:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"],borderWidth:0,borderColor:"#000",tooltipFormat:new h('<span style="color: {{color}}">&#9679;</span> {{value}} ({{percent.1}}%)')},box:{raw:!1,boxLineColor:"#000",boxFillColor:"#cdf",whiskerColor:"#000",outlierLineColor:"#333",outlierFillColor:"#fff",medianColor:"#f00",showOutliers:!0,outlierIQR:1.5,spotRadius:1.5,target:i,targetColor:"#4a2",chartRangeMax:i,chartRangeMin:i,tooltipFormat:new h("{{field:fields}}: {{value}}"),tooltipFormatFieldlistKey:"field",tooltipValueLookups:{fields:{lq:"Lower Quartile",med:"Median",uq:"Upper Quartile",lo:"Left Outlier",ro:"Right Outlier",lw:"Left Whisker",rw:"Right Whisker"}}}}},T='.jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}',a=function(){var t,e;return t=function(){this.init.apply(this,arguments)},arguments.length>1?(arguments[0]?(t.prototype=s.extend(new arguments[0],arguments[arguments.length-1]),t._super=arguments[0].prototype):t.prototype=arguments[arguments.length-1],arguments.length>2&&(e=Array.prototype.slice.call(arguments,1,-1),e.unshift(t.prototype),s.extend.apply(s,e))):t.prototype=arguments[0],t.prototype.cls=t,t},s.SPFormatClass=h=a({fre:/\{\{([\w.]+?)(:(.+?))?\}\}/g,precre:/(\w+)\.(\d+)/,init:function(t,e){this.format=t,this.fclass=e},render:function(t,e,s){var r=this,n=t,a,h,o,l,g;return this.format.replace(this.fre,function(){var t;return h=arguments[1],o=arguments[3],a=r.precre.exec(h),a?(g=a[2],h=a[1]):g=!1,l=n[h],l===i?"":o&&e&&e[o]?(t=e[o],t.get?e[o].get(l)||l:e[o][l]||l):(c(l)&&(l=s.get("numberFormatter")?s.get("numberFormatter")(l):x(l,g,s.get("numberDigitGroupCount"),s.get("numberDigitGroupSep"),s.get("numberDecimalMark"))),l)})}}),s.spformat=function(t,e){return new h(t,e)},o=function(t,e,i){return e>t?e:t>i?i:t},l=function(t,i){var s;return 2===i?(s=e.floor(t.length/2),t.length%2?t[s]:(t[s-1]+t[s])/2):t.length%2?(s=(t.length*i+i)/4,s%1?(t[e.floor(s)]+t[e.floor(s)-1])/2:t[s-1]):(s=(t.length*i+2)/4,s%1?(t[e.floor(s)]+t[e.floor(s)-1])/2:t[s-1])},g=function(t){var e;switch(t){case"undefined":t=i;break;case"null":t=null;break;case"true":t=!0;break;case"false":t=!1;break;default:e=parseFloat(t),t==e&&(t=e)}return t},p=function(t){var e,i=[];for(e=t.length;e--;)i[e]=g(t[e]);return i},u=function(t,e){var i,s,r=[];for(i=0,s=t.length;s>i;i++)t[i]!==e&&r.push(t[i]);return r},c=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},x=function(t,e,i,r,n){var a,h;for(t=(e===!1?parseFloat(t).toString():t.toFixed(e)).split(""),a=(a=s.inArray(".",t))<0?t.length:a,a<t.length&&(t[a]=n),h=a-i;h>0;h-=i)t.splice(h,0,r);return t.join("")},d=function(t,e,i){var s;for(s=e.length;s--;)if((!i||null!==e[s])&&e[s]!==t)return!1;return!0},f=function(t){var e=0,i;for(i=t.length;i--;)e+="number"==typeof t[i]?t[i]:0;return e},v=function(t){return s.isArray(t)?t:[t]},m=function(e){var i;t.createStyleSheet?t.createStyleSheet().cssText=e:(i=t.createElement("style"),i.type="text/css",t.getElementsByTagName("head")[0].appendChild(i),i["string"==typeof t.body.style.WebkitAppearance?"innerText":"innerHTML"]=e)},s.fn.simpledraw=function(e,r,n,a){var h,o;if(n&&(h=this.data("_jqs_vcanvas")))return h;if(s.fn.sparkline.canvas===!1)return!1;if(s.fn.sparkline.canvas===i){var l=t.createElement("canvas");if(l.getContext&&l.getContext("2d"))s.fn.sparkline.canvas=function(t,e,i,s){return new P(t,e,i,s)};else{if(!t.namespaces||t.namespaces.v)return s.fn.sparkline.canvas=!1,!1;t.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML"),s.fn.sparkline.canvas=function(t,e,i,s){return new L(t,e,i)}}}return e===i&&(e=s(this).innerWidth()),r===i&&(r=s(this).innerHeight()),h=s.fn.sparkline.canvas(e,r,this,a),o=s(this).data("_jqs_mhandler"),o&&o.registerCanvas(h),h},s.fn.cleardraw=function(){var t=this.data("_jqs_vcanvas");t&&t.reset()},s.RangeMapClass=y=a({init:function(t){var e,i,s=[];for(e in t)t.hasOwnProperty(e)&&"string"==typeof e&&e.indexOf(":")>-1&&(i=e.split(":"),i[0]=0===i[0].length?-1/0:parseFloat(i[0]),i[1]=0===i[1].length?1/0:parseFloat(i[1]),i[2]=t[e],s.push(i));this.map=t,this.rangelist=s||!1},get:function(t){var e=this.rangelist,s,r,n;if((n=this.map[t])!==i)return n;if(e)for(s=e.length;s--;)if(r=e[s],r[0]<=t&&r[1]>=t)return r[2];return i}}),s.range_map=function(t){return new y(t)},C=a({init:function(t,e){var i=s(t);this.$el=i,this.options=e,this.currentPageX=0,this.currentPageY=0,this.el=t,this.splist=[],this.tooltip=null,this.over=!1,this.displayTooltips=!e.get("disableTooltips"),this.highlightEnabled=!e.get("disableHighlight")},registerSparkline:function(t){this.splist.push(t),this.over&&this.updateDisplay()},registerCanvas:function(t){var e=s(t.canvas);this.canvas=t,this.$canvas=e,e.mouseenter(s.proxy(this.mouseenter,this)),e.mouseleave(s.proxy(this.mouseleave,this)),e.click(s.proxy(this.mouseclick,this))},reset:function(t){this.splist=[],this.tooltip&&t&&(this.tooltip.remove(),this.tooltip=i)},mouseclick:function(t){var e=s.Event("sparklineClick");e.originalEvent=t,e.sparklines=this.splist,this.$el.trigger(e)},mouseenter:function(e){s(t.body).unbind("mousemove.jqs"),s(t.body).bind("mousemove.jqs",s.proxy(this.mousemove,this)),this.over=!0,this.currentPageX=e.pageX,this.currentPageY=e.pageY,this.currentEl=e.target,!this.tooltip&&this.displayTooltips&&(this.tooltip=new w(this.options),this.tooltip.updatePosition(e.pageX,e.pageY)),this.updateDisplay()},mouseleave:function(){s(t.body).unbind("mousemove.jqs");var e=this.splist,i=e.length,r=!1,n,a;for(this.over=!1,this.currentEl=null,this.tooltip&&(this.tooltip.remove(),this.tooltip=null),a=0;i>a;a++)n=e[a],n.clearRegionHighlight()&&(r=!0);r&&this.canvas.render()},mousemove:function(t){this.currentPageX=t.pageX,this.currentPageY=t.pageY,this.currentEl=t.target,this.tooltip&&this.tooltip.updatePosition(t.pageX,t.pageY),this.updateDisplay()},updateDisplay:function(){var t=this.splist,e=t.length,i=!1,r=this.$canvas.offset(),n=this.currentPageX-r.left,a=this.currentPageY-r.top,h,o,l,g,p;if(this.over){for(l=0;e>l;l++)o=t[l],g=o.setRegionHighlight(this.currentEl,n,a),g&&(i=!0);if(i){if(p=s.Event("sparklineRegionChange"),p.sparklines=this.splist,this.$el.trigger(p),this.tooltip){for(h="",l=0;e>l;l++)o=t[l],h+=o.getCurrentRegionTooltip();this.tooltip.setContent(h)}this.disableHighlight||this.canvas.render()}null===g&&this.mouseleave()}}}),w=a({sizeStyle:"position: static !important;display: block !important;visibility: hidden !important;float: left !important;",init:function(e){var i=e.get("tooltipClassname","jqstooltip"),r=this.sizeStyle,n;this.container=e.get("tooltipContainer")||t.body,this.tooltipOffsetX=e.get("tooltipOffsetX",10),this.tooltipOffsetY=e.get("tooltipOffsetY",12),s("#jqssizetip").remove(),s("#jqstooltip").remove(),this.sizetip=s("<div/>",{id:"jqssizetip",style:r,"class":i}),this.tooltip=s("<div/>",{id:"jqstooltip","class":i}).appendTo(this.container),n=this.tooltip.offset(),this.offsetLeft=n.left,this.offsetTop=n.top,this.hidden=!0,s(window).unbind("resize.jqs scroll.jqs"),s(window).bind("resize.jqs scroll.jqs",s.proxy(this.updateWindowDims,this)),this.updateWindowDims()},updateWindowDims:function(){this.scrollTop=s(window).scrollTop(),this.scrollLeft=s(window).scrollLeft(),this.scrollRight=this.scrollLeft+s(window).width(),this.updatePosition()},getSize:function(t){this.sizetip.html(t).appendTo(this.container),this.width=this.sizetip.width()+1,this.height=this.sizetip.height(),this.sizetip.remove()},setContent:function(t){return t?(this.getSize(t),this.tooltip.html(t).css({width:this.width,height:this.height,visibility:"visible"}),this.hidden&&(this.hidden=!1,this.updatePosition()),void 0):(this.tooltip.css("visibility","hidden"),void(this.hidden=!0))},updatePosition:function(t,e){if(t===i){if(this.mousex===i)return;t=this.mousex-this.offsetLeft,e=this.mousey-this.offsetTop}else this.mousex=t-=this.offsetLeft,this.mousey=e-=this.offsetTop;this.height&&this.width&&!this.hidden&&(e-=this.height+this.tooltipOffsetY,t+=this.tooltipOffsetX,e<this.scrollTop&&(e=this.scrollTop),t<this.scrollLeft?t=this.scrollLeft:t+this.width>this.scrollRight&&(t=this.scrollRight-this.width),this.tooltip.css({left:t,top:e}))},remove:function(){this.tooltip.remove(),this.sizetip.remove(),this.sizetip=this.tooltip=i,s(window).unbind("resize.jqs scroll.jqs")}}),q=function(){m(T)},s(q),A=[],s.fn.sparkline=function(e,r){return this.each(function(){var n=new s.fn.sparkline.options(this,r),a=s(this),h,o;if(h=function(){var r,h,o,l,g,p,u;return"html"===e||e===i?(u=this.getAttribute(n.get("tagValuesAttribute")),(u===i||null===u)&&(u=a.html()),r=u.replace(/(^\s*<!--)|(-->\s*$)|\s+/g,"").split(",")):r=e,h="auto"===n.get("width")?r.length*n.get("defaultPixelsPerValue"):n.get("width"),"auto"===n.get("height")?n.get("composite")&&s.data(this,"_jqs_vcanvas")||(l=t.createElement("span"),l.innerHTML="a",a.html(l),o=s(l).innerHeight()||s(l).height(),s(l).remove(),l=null):o=n.get("height"),n.get("disableInteraction")?g=!1:(g=s.data(this,"_jqs_mhandler"),g?n.get("composite")||g.reset():(g=new C(this,n),s.data(this,"_jqs_mhandler",g))),n.get("composite")&&!s.data(this,"_jqs_vcanvas")?void(s.data(this,"_jqs_errnotify")||(alert("Attempted to attach a composite sparkline to an element with no existing sparkline"),s.data(this,"_jqs_errnotify",!0))):(p=new(s.fn.sparkline[n.get("type")])(this,r,n,h,o),p.render(),g&&g.registerSparkline(p),void 0)},s(this).html()&&!n.get("disableHiddenCheck")&&s(this).is(":hidden")||!s(this).parents("body").length){if(!n.get("composite")&&s.data(this,"_jqs_pending"))for(o=A.length;o;o--)A[o-1][0]==this&&A.splice(o-1,1);A.push([this,h]),s.data(this,"_jqs_pending",!0)}else h.call(this)})},s.fn.sparkline.defaults=n(),s.sparkline_display_visible=function(){var t,e,i,r=[];for(e=0,i=A.length;i>e;e++)t=A[e][0],s(t).is(":visible")&&!s(t).parents().is(":hidden")?(A[e][1].call(t),s.data(A[e][0],"_jqs_pending",!1),r.push(e)):!s(t).closest("html").length&&!s.data(t,"_jqs_pending")&&(s.data(A[e][0],"_jqs_pending",!1),r.push(e));for(e=r.length;e;e--)A.splice(r[e-1],1)},s.fn.sparkline.options=a({init:function(t,e){var i,n,a,h;this.userOptions=e=e||{},this.tag=t,this.tagValCache={},n=s.fn.sparkline.defaults,a=n.common,this.tagOptionsPrefix=e.enableTagOptions&&(e.tagOptionsPrefix||a.tagOptionsPrefix),h=this.getTagSetting("type"),i=h===r?n[e.type||a.type]:n[h],this.mergedOptions=s.extend({},a,i,e)},getTagSetting:function(t){var e=this.tagOptionsPrefix,s,n,a,h;if(e===!1||e===i)return r;if(this.tagValCache.hasOwnProperty(t))s=this.tagValCache.key;else{if(s=this.tag.getAttribute(e+t),s===i||null===s)s=r;else if("["===s.substr(0,1))for(s=s.substr(1,s.length-2).split(","),n=s.length;n--;)s[n]=g(s[n].replace(/(^\s*)|(\s*$)/g,""));else if("{"===s.substr(0,1))for(a=s.substr(1,s.length-2).split(","),s={},n=a.length;n--;)h=a[n].split(":",2),s[h[0].replace(/(^\s*)|(\s*$)/g,"")]=g(h[1].replace(/(^\s*)|(\s*$)/g,""));else s=g(s);this.tagValCache.key=s}return s},get:function(t,e){var s=this.getTagSetting(t),n;return s!==r?s:(n=this.mergedOptions[t])===i?e:n}}),s.fn.sparkline._base=a({disabled:!1,init:function(t,e,r,n,a){this.el=t,this.$el=s(t),this.values=e,this.options=r,this.width=n,this.height=a,this.currentRegion=i},initTarget:function(){var t=!this.options.get("disableInteraction");(this.target=this.$el.simpledraw(this.width,this.height,this.options.get("composite"),t))?(this.canvasWidth=this.target.pixelWidth,this.canvasHeight=this.target.pixelHeight):this.disabled=!0},render:function(){return this.disabled?(this.el.innerHTML="",!1):!0},getRegion:function(t,e){},setRegionHighlight:function(t,e,s){var r=this.currentRegion,n=!this.options.get("disableHighlight"),a;return e>this.canvasWidth||s>this.canvasHeight||0>e||0>s?null:(a=this.getRegion(t,e,s),r!==a?(r!==i&&n&&this.removeHighlight(),this.currentRegion=a,a!==i&&n&&this.renderHighlight(),!0):!1)},clearRegionHighlight:function(){return this.currentRegion!==i?(this.removeHighlight(),this.currentRegion=i,!0):!1},renderHighlight:function(){this.changeHighlight(!0)},removeHighlight:function(){this.changeHighlight(!1)},changeHighlight:function(t){},getCurrentRegionTooltip:function(){var t=this.options,e="",r=[],n,a,o,l,g,p,u,c,d,f,m,v,x,y;if(this.currentRegion===i)return"";if(n=this.getCurrentRegionFields(),m=t.get("tooltipFormatter"))return m(this,t,n);if(t.get("tooltipChartTitle")&&(e+='<div class="jqs jqstitle">'+t.get("tooltipChartTitle")+"</div>\n"),a=this.options.get("tooltipFormat"),!a)return"";if(s.isArray(a)||(a=[a]),s.isArray(n)||(n=[n]),u=this.options.get("tooltipFormatFieldlist"),c=this.options.get("tooltipFormatFieldlistKey"),u&&c){for(d=[],p=n.length;p--;)f=n[p][c],-1!=(y=s.inArray(f,u))&&(d[y]=n[p]);n=d}for(o=a.length,x=n.length,p=0;o>p;p++)for(v=a[p],"string"==typeof v&&(v=new h(v)),l=v.fclass||"jqsfield",y=0;x>y;y++)n[y].isNull&&t.get("tooltipSkipNull")||(s.extend(n[y],{prefix:t.get("tooltipPrefix"),suffix:t.get("tooltipSuffix")}),g=v.render(n[y],t.get("tooltipValueLookups"),t),r.push('<div class="'+l+'">'+g+"</div>"));return r.length?e+r.join("\n"):""},getCurrentRegionFields:function(){},calcHighlightColor:function(t,i){var s=i.get("highlightColor"),r=i.get("highlightLighten"),n,a,h,l;if(s)return s;if(r&&(n=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(t)||/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t))){for(h=[],a=4===t.length?16:1,l=0;3>l;l++)h[l]=o(e.round(parseInt(n[l+1],16)*a*r),0,255);return"rgb("+h.join(",")+")"}return t}}),b={changeHighlight:function(t){var e=this.currentRegion,i=this.target,r=this.regionShapes[e],n;r&&(n=this.renderRegion(e,t),s.isArray(n)||s.isArray(r)?(i.replaceWithShapes(r,n),this.regionShapes[e]=s.map(n,function(t){return t.id})):(i.replaceWithShape(r,n),this.regionShapes[e]=n.id))},render:function(){var t=this.values,e=this.target,i=this.regionShapes,r,n,a,h;if(this.cls._super.render.call(this)){for(a=t.length;a--;)if(r=this.renderRegion(a))if(s.isArray(r)){for(n=[],h=r.length;h--;)r[h].append(),n.push(r[h].id);i[a]=n}else r.append(),i[a]=r.id;else i[a]=null;e.render()}}},s.fn.sparkline.line=R=a(s.fn.sparkline._base,{type:"line",init:function(t,e,i,s,r){R._super.init.call(this,t,e,i,s,r),this.vertices=[],this.regionMap=[],this.xvalues=[],this.yvalues=[],this.yminmax=[],this.hightlightSpotId=null,this.lastShapeId=null,this.initTarget()},getRegion:function(t,e,s){var r,n=this.regionMap;for(r=n.length;r--;)if(null!==n[r]&&e>=n[r][0]&&e<=n[r][1])return n[r][2];return i},getCurrentRegionFields:function(){var t=this.currentRegion;return{isNull:null===this.yvalues[t],x:this.xvalues[t],y:this.yvalues[t],color:this.options.get("lineColor"),fillColor:this.options.get("fillColor"),offset:t}},renderHighlight:function(){var t=this.currentRegion,e=this.target,s=this.vertices[t],r=this.options,n=r.get("spotRadius"),a=r.get("highlightSpotColor"),h=r.get("highlightLineColor"),o,l;s&&(n&&a&&(o=e.drawCircle(s[0],s[1],n,i,a),this.highlightSpotId=o.id,e.insertAfterShape(this.lastShapeId,o)),h&&(l=e.drawLine(s[0],this.canvasTop,s[0],this.canvasTop+this.canvasHeight,h),this.highlightLineId=l.id,e.insertAfterShape(this.lastShapeId,l)))},removeHighlight:function(){var t=this.target;this.highlightSpotId&&(t.removeShapeId(this.highlightSpotId),this.highlightSpotId=null),this.highlightLineId&&(t.removeShapeId(this.highlightLineId),this.highlightLineId=null)},scanValues:function(){var t=this.values,i=t.length,s=this.xvalues,r=this.yvalues,n=this.yminmax,a,h,o,l,g;for(a=0;i>a;a++)h=t[a],o="string"==typeof t[a],l="object"==typeof t[a]&&t[a]instanceof Array,g=o&&t[a].split(":"),o&&2===g.length?(s.push(Number(g[0])),r.push(Number(g[1])),n.push(Number(g[1]))):l?(s.push(h[0]),r.push(h[1]),n.push(h[1])):(s.push(a),null===t[a]||"null"===t[a]?r.push(null):(r.push(Number(h)),n.push(Number(h))));this.options.get("xvalues")&&(s=this.options.get("xvalues")),this.maxy=this.maxyorg=e.max.apply(e,n),this.miny=this.minyorg=e.min.apply(e,n),this.maxx=e.max.apply(e,s),this.minx=e.min.apply(e,s),this.xvalues=s,this.yvalues=r,this.yminmax=n},processRangeOptions:function(){var t=this.options,e=t.get("normalRangeMin"),s=t.get("normalRangeMax");e!==i&&(e<this.miny&&(this.miny=e),s>this.maxy&&(this.maxy=s)),t.get("chartRangeMin")!==i&&(t.get("chartRangeClip")||t.get("chartRangeMin")<this.miny)&&(this.miny=t.get("chartRangeMin")),t.get("chartRangeMax")!==i&&(t.get("chartRangeClip")||t.get("chartRangeMax")>this.maxy)&&(this.maxy=t.get("chartRangeMax")),t.get("chartRangeMinX")!==i&&(t.get("chartRangeClipX")||t.get("chartRangeMinX")<this.minx)&&(this.minx=t.get("chartRangeMinX")),t.get("chartRangeMaxX")!==i&&(t.get("chartRangeClipX")||t.get("chartRangeMaxX")>this.maxx)&&(this.maxx=t.get("chartRangeMaxX"))},drawNormalRange:function(t,s,r,n,a){var h=this.options.get("normalRangeMin"),o=this.options.get("normalRangeMax"),l=s+e.round(r-r*((o-this.miny)/a)),g=e.round(r*(o-h)/a);this.target.drawRect(t,l,n,g,i,this.options.get("normalRangeColor")).append()},render:function(){var t=this.options,r=this.target,n=this.canvasWidth,a=this.canvasHeight,h=this.vertices,o=t.get("spotRadius"),l=this.regionMap,g,p,u,c,d,f,m,v,x,C,w,b,S,k,M,_,H,W,T,q,I,j,P,L,A;if(R._super.render.call(this)&&(this.scanValues(),this.processRangeOptions(),P=this.xvalues,L=this.yvalues,this.yminmax.length&&!(this.yvalues.length<2))){for(c=d=0,g=this.maxx-this.minx===0?1:this.maxx-this.minx,p=this.maxy-this.miny===0?1:this.maxy-this.miny,u=this.yvalues.length-1,o&&(4*o>n||4*o>a)&&(o=0),o&&(I=t.get("highlightSpotColor")&&!t.get("disableInteraction"),(I||t.get("minSpotColor")||t.get("spotColor")&&L[u]===this.miny)&&(a-=e.ceil(o)),(I||t.get("maxSpotColor")||t.get("spotColor")&&L[u]===this.maxy)&&(a-=e.ceil(o),c+=e.ceil(o)),(I||(t.get("minSpotColor")||t.get("maxSpotColor"))&&(L[0]===this.miny||L[0]===this.maxy))&&(d+=e.ceil(o),n-=e.ceil(o)),(I||t.get("spotColor")||t.get("minSpotColor")||t.get("maxSpotColor")&&(L[u]===this.miny||L[u]===this.maxy))&&(n-=e.ceil(o))),a--,t.get("normalRangeMin")!==i&&!t.get("drawNormalOnTop")&&this.drawNormalRange(d,c,a,n,p),m=[],v=[m],k=M=null,_=L.length,A=0;_>A;A++)x=P[A],w=P[A+1],C=L[A],b=d+e.round((x-this.minx)*(n/g)),S=_-1>A?d+e.round((w-this.minx)*(n/g)):n,M=b+(S-b)/2,l[A]=[k||0,M,A],k=M,null===C?A&&(null!==L[A-1]&&(m=[],v.push(m)),h.push(null)):(C<this.miny&&(C=this.miny),C>this.maxy&&(C=this.maxy),m.length||m.push([b,c+a]),f=[b,c+e.round(a-a*((C-this.miny)/p))],m.push(f),h.push(f));for(H=[],W=[],T=v.length,A=0;T>A;A++)m=v[A],m.length&&(t.get("fillColor")&&(m.push([m[m.length-1][0],c+a]),W.push(m.slice(0)),m.pop()),m.length>2&&(m[0]=[m[0][0],m[1][1]]),H.push(m));for(T=W.length,A=0;T>A;A++)r.drawShape(W[A],t.get("fillColor"),t.get("fillColor")).append();for(t.get("normalRangeMin")!==i&&t.get("drawNormalOnTop")&&this.drawNormalRange(d,c,a,n,p),T=H.length,A=0;T>A;A++)r.drawShape(H[A],t.get("lineColor"),i,t.get("lineWidth")).append();if(o&&t.get("valueSpots"))for(q=t.get("valueSpots"),q.get===i&&(q=new y(q)),A=0;_>A;A++)j=q.get(L[A]),j&&r.drawCircle(d+e.round((P[A]-this.minx)*(n/g)),c+e.round(a-a*((L[A]-this.miny)/p)),o,i,j).append();o&&t.get("spotColor")&&null!==L[u]&&r.drawCircle(d+e.round((P[P.length-1]-this.minx)*(n/g)),c+e.round(a-a*((L[u]-this.miny)/p)),o,i,t.get("spotColor")).append(),this.maxy!==this.minyorg&&(o&&t.get("minSpotColor")&&(x=P[s.inArray(this.minyorg,L)],r.drawCircle(d+e.round((x-this.minx)*(n/g)),c+e.round(a-a*((this.minyorg-this.miny)/p)),o,i,t.get("minSpotColor")).append()),o&&t.get("maxSpotColor")&&(x=P[s.inArray(this.maxyorg,L)],r.drawCircle(d+e.round((x-this.minx)*(n/g)),c+e.round(a-a*((this.maxyorg-this.miny)/p)),o,i,t.get("maxSpotColor")).append())),this.lastShapeId=r.getLastShapeId(),this.canvasTop=c,r.render()}}}),s.fn.sparkline.bar=S=a(s.fn.sparkline._base,b,{type:"bar",init:function(t,r,n,a,h){var l=parseInt(n.get("barWidth"),10),c=parseInt(n.get("barSpacing"),10),d=n.get("chartRangeMin"),f=n.get("chartRangeMax"),m=n.get("chartRangeClip"),v=1/0,x=-1/0,C,w,b,R,k,M,_,H,W,T,q,I,j,P,L,A,F,B,O,V,X,z,N;for(S._super.init.call(this,t,r,n,a,h),M=0,_=r.length;_>M;M++)V=r[M],C="string"==typeof V&&V.indexOf(":")>-1,(C||s.isArray(V))&&(L=!0,C&&(V=r[M]=p(V.split(":"))),V=u(V,null),w=e.min.apply(e,V),b=e.max.apply(e,V),v>w&&(v=w),b>x&&(x=b));this.stacked=L,this.regionShapes={},this.barWidth=l,this.barSpacing=c,this.totalBarWidth=l+c,this.width=a=r.length*l+(r.length-1)*c,this.initTarget(),m&&(j=d===i?-1/0:d,P=f===i?1/0:f),k=[],R=L?[]:k;var E=[],D=[];for(M=0,_=r.length;_>M;M++)if(L)for(A=r[M],r[M]=O=[],E[M]=0,R[M]=D[M]=0,F=0,B=A.length;B>F;F++)V=O[F]=m?o(A[F],j,P):A[F],null!==V&&(V>0&&(E[M]+=V),0>v&&x>0?0>V?D[M]+=e.abs(V):R[M]+=V:R[M]+=e.abs(V-(0>V?x:v)),k.push(V));else V=m?o(r[M],j,P):r[M],V=r[M]=g(V),null!==V&&k.push(V);this.max=I=e.max.apply(e,k),this.min=q=e.min.apply(e,k),this.stackMax=x=L?e.max.apply(e,E):I,this.stackMin=v=L?e.min.apply(e,k):q,n.get("chartRangeMin")!==i&&(n.get("chartRangeClip")||n.get("chartRangeMin")<q)&&(q=n.get("chartRangeMin")),n.get("chartRangeMax")!==i&&(n.get("chartRangeClip")||n.get("chartRangeMax")>I)&&(I=n.get("chartRangeMax")),this.zeroAxis=W=n.get("zeroAxis",!0),T=0>=q&&I>=0&&W?0:0==W?q:q>0?q:I,this.xaxisOffset=T,H=L?e.max.apply(e,R)+e.max.apply(e,D):I-q,this.canvasHeightEf=W&&0>q?this.canvasHeight-2:this.canvasHeight-1,T>q?(z=L&&I>=0?x:I,X=(z-T)/H*this.canvasHeight,X!==e.ceil(X)&&(this.canvasHeightEf-=2,X=e.ceil(X))):X=this.canvasHeight,this.yoffset=X,s.isArray(n.get("colorMap"))?(this.colorMapByIndex=n.get("colorMap"),this.colorMapByValue=null):(this.colorMapByIndex=null,this.colorMapByValue=n.get("colorMap"),this.colorMapByValue&&this.colorMapByValue.get===i&&(this.colorMapByValue=new y(this.colorMapByValue))),this.range=H},getRegion:function(t,s,r){var n=e.floor(s/this.totalBarWidth);return 0>n||n>=this.values.length?i:n},getCurrentRegionFields:function(){var t=this.currentRegion,e=v(this.values[t]),i=[],s,r;for(r=e.length;r--;)s=e[r],i.push({isNull:null===s,value:s,color:this.calcColor(r,s,t),offset:t});return i},calcColor:function(t,e,r){var n=this.colorMapByIndex,a=this.colorMapByValue,h=this.options,o,l;return o=h.get(this.stacked?"stackedBarColor":0>e?"negBarColor":"barColor"),0===e&&h.get("zeroColor")!==i&&(o=h.get("zeroColor")),a&&(l=a.get(e))?o=l:n&&n.length>r&&(o=n[r]),s.isArray(o)?o[t%o.length]:o},renderRegion:function(t,r){var n=this.values[t],a=this.options,h=this.xaxisOffset,o=[],l=this.range,g=this.stacked,p=this.target,u=t*this.totalBarWidth,c=this.canvasHeightEf,f=this.yoffset,m,v,x,y,C,w,b,R,S,k;if(n=s.isArray(n)?n:[n],b=n.length,R=n[0],y=d(null,n),k=d(h,n,!0),y)return a.get("nullColor")?(x=r?a.get("nullColor"):this.calcHighlightColor(a.get("nullColor"),a),m=f>0?f-1:f,p.drawRect(u,m,this.barWidth-1,0,x,x)):i;for(C=f,w=0;b>w;w++){if(R=n[w],g&&R===h){if(!k||S)continue;S=!0}v=l>0?e.floor(c*(e.abs(R-h)/l))+1:1,h>R||R===h&&0===f?(m=C,C+=v):(m=f-v,f-=v),x=this.calcColor(w,R,t),r&&(x=this.calcHighlightColor(x,a)),o.push(p.drawRect(u,m,this.barWidth-1,v-1,x,x))}return 1===o.length?o[0]:o}}),s.fn.sparkline.tristate=k=a(s.fn.sparkline._base,b,{type:"tristate",init:function(t,e,r,n,a){var h=parseInt(r.get("barWidth"),10),o=parseInt(r.get("barSpacing"),10);k._super.init.call(this,t,e,r,n,a),this.regionShapes={},this.barWidth=h,this.barSpacing=o,this.totalBarWidth=h+o,this.values=s.map(e,Number),this.width=n=e.length*h+(e.length-1)*o,s.isArray(r.get("colorMap"))?(this.colorMapByIndex=r.get("colorMap"),this.colorMapByValue=null):(this.colorMapByIndex=null,this.colorMapByValue=r.get("colorMap"),this.colorMapByValue&&this.colorMapByValue.get===i&&(this.colorMapByValue=new y(this.colorMapByValue))),this.initTarget()},getRegion:function(t,i,s){return e.floor(i/this.totalBarWidth)},getCurrentRegionFields:function(){var t=this.currentRegion;return{isNull:this.values[t]===i,value:this.values[t],color:this.calcColor(this.values[t],t),offset:t}},calcColor:function(t,e){var i=this.values,s=this.options,r=this.colorMapByIndex,n=this.colorMapByValue,a,h;return a=n&&(h=n.get(t))?h:r&&r.length>e?r[e]:s.get(i[e]<0?"negBarColor":i[e]>0?"posBarColor":"zeroBarColor")},renderRegion:function(t,i){var s=this.values,r=this.options,n=this.target,a,h,o,l,g,p;return a=n.pixelHeight,o=e.round(a/2),l=t*this.totalBarWidth,s[t]<0?(g=o,h=o-1):s[t]>0?(g=0,h=o-1):(g=o-1,h=2),p=this.calcColor(s[t],t),null!==p?(i&&(p=this.calcHighlightColor(p,r)),n.drawRect(l,g,this.barWidth-1,h-1,p,p)):void 0}}),s.fn.sparkline.discrete=M=a(s.fn.sparkline._base,b,{type:"discrete",init:function(t,r,n,a,h){M._super.init.call(this,t,r,n,a,h),this.regionShapes={},this.values=r=s.map(r,Number),this.min=e.min.apply(e,r),this.max=e.max.apply(e,r),this.range=this.max-this.min,this.width=a="auto"===n.get("width")?2*r.length:this.width,this.interval=e.floor(a/r.length),this.itemWidth=a/r.length,n.get("chartRangeMin")!==i&&(n.get("chartRangeClip")||n.get("chartRangeMin")<this.min)&&(this.min=n.get("chartRangeMin")),n.get("chartRangeMax")!==i&&(n.get("chartRangeClip")||n.get("chartRangeMax")>this.max)&&(this.max=n.get("chartRangeMax")),this.initTarget(),this.target&&(this.lineHeight="auto"===n.get("lineHeight")?e.round(.3*this.canvasHeight):n.get("lineHeight"))},getRegion:function(t,i,s){return e.floor(i/this.itemWidth)},getCurrentRegionFields:function(){var t=this.currentRegion;return{isNull:this.values[t]===i,value:this.values[t],offset:t}},renderRegion:function(t,i){var s=this.values,r=this.options,n=this.min,a=this.max,h=this.range,l=this.interval,g=this.target,p=this.canvasHeight,u=this.lineHeight,c=p-u,d,f,m,v;return f=o(s[t],n,a),v=t*l,d=e.round(c-c*((f-n)/h)),m=r.get(r.get("thresholdColor")&&f<r.get("thresholdValue")?"thresholdColor":"lineColor"),i&&(m=this.calcHighlightColor(m,r)),g.drawLine(v,d,v,d+u,m)}}),s.fn.sparkline.bullet=_=a(s.fn.sparkline._base,{type:"bullet",init:function(t,s,r,n,a){var h,o,l;_._super.init.call(this,t,s,r,n,a),this.values=s=p(s),l=s.slice(),l[0]=null===l[0]?l[2]:l[0],l[1]=null===s[1]?l[2]:l[1],h=e.min.apply(e,s),o=e.max.apply(e,s),h=r.get("base")===i?0>h?h:0:r.get("base"),this.min=h,this.max=o,this.range=o-h,this.shapes={},this.valueShapes={},this.regiondata={},this.width=n="auto"===r.get("width")?"4.0em":n,this.target=this.$el.simpledraw(n,a,r.get("composite")),s.length||(this.disabled=!0),this.initTarget()},getRegion:function(t,e,s){var r=this.target.getShapeAt(t,e,s);return r!==i&&this.shapes[r]!==i?this.shapes[r]:i},getCurrentRegionFields:function(){var t=this.currentRegion;return{fieldkey:t.substr(0,1),value:this.values[t.substr(1)],region:t}},changeHighlight:function(t){var e=this.currentRegion,i=this.valueShapes[e],s;switch(delete this.shapes[i],e.substr(0,1)){case"r":s=this.renderRange(e.substr(1),t);break;case"p":s=this.renderPerformance(t);break;case"t":s=this.renderTarget(t)}this.valueShapes[e]=s.id,this.shapes[s.id]=e,this.target.replaceWithShape(i,s)},renderRange:function(t,i){var s=this.values[t],r=e.round(this.canvasWidth*((s-this.min)/this.range)),n=this.options.get("rangeColors")[t-2];return i&&(n=this.calcHighlightColor(n,this.options)),this.target.drawRect(0,0,r-1,this.canvasHeight-1,n,n)},renderPerformance:function(t){var i=this.values[1],s=e.round(this.canvasWidth*((i-this.min)/this.range)),r=this.options.get("performanceColor");return t&&(r=this.calcHighlightColor(r,this.options)),this.target.drawRect(0,e.round(.3*this.canvasHeight),s-1,e.round(.4*this.canvasHeight)-1,r,r)},renderTarget:function(t){var i=this.values[0],s=e.round(this.canvasWidth*((i-this.min)/this.range)-this.options.get("targetWidth")/2),r=e.round(.1*this.canvasHeight),n=this.canvasHeight-2*r,a=this.options.get("targetColor");return t&&(a=this.calcHighlightColor(a,this.options)),this.target.drawRect(s,r,this.options.get("targetWidth")-1,n-1,a,a)},render:function(){var t=this.values.length,e=this.target,i,s;if(_._super.render.call(this)){for(i=2;t>i;i++)s=this.renderRange(i).append(),this.shapes[s.id]="r"+i,this.valueShapes["r"+i]=s.id;null!==this.values[1]&&(s=this.renderPerformance().append(),this.shapes[s.id]="p1",this.valueShapes.p1=s.id),null!==this.values[0]&&(s=this.renderTarget().append(),this.shapes[s.id]="t0",this.valueShapes.t0=s.id),e.render()}}}),s.fn.sparkline.pie=H=a(s.fn.sparkline._base,{type:"pie",init:function(t,i,r,n,a){var h=0,o;if(H._super.init.call(this,t,i,r,n,a),this.shapes={},this.valueShapes={},this.values=i=s.map(i,Number),"auto"===r.get("width")&&(this.width=this.height),i.length>0)for(o=i.length;o--;)h+=i[o];this.total=h,this.initTarget(),this.radius=e.floor(e.min(this.canvasWidth,this.canvasHeight)/2)},getRegion:function(t,e,s){var r=this.target.getShapeAt(t,e,s);return r!==i&&this.shapes[r]!==i?this.shapes[r]:i},getCurrentRegionFields:function(){var t=this.currentRegion;return{isNull:this.values[t]===i,value:this.values[t],percent:this.values[t]/this.total*100,color:this.options.get("sliceColors")[t%this.options.get("sliceColors").length],offset:t}},changeHighlight:function(t){var e=this.currentRegion,i=this.renderSlice(e,t),s=this.valueShapes[e];delete this.shapes[s],this.target.replaceWithShape(s,i),this.valueShapes[e]=i.id,this.shapes[i.id]=e},renderSlice:function(t,s){var r=this.target,n=this.options,a=this.radius,h=n.get("borderWidth"),o=n.get("offset"),l=2*e.PI,g=this.values,p=this.total,u=o?2*e.PI*(o/360):0,c,d,f,m,v;for(m=g.length,f=0;m>f;f++){if(c=u,d=u,p>0&&(d=u+l*(g[f]/p)),t===f)return v=n.get("sliceColors")[f%n.get("sliceColors").length],s&&(v=this.calcHighlightColor(v,n)),r.drawPieSlice(a,a,a-h,c,d,i,v);u=d}},render:function(){var t=this.target,s=this.values,r=this.options,n=this.radius,a=r.get("borderWidth"),h,o;
+if(H._super.render.call(this)){for(a&&t.drawCircle(n,n,e.floor(n-a/2),r.get("borderColor"),i,a).append(),o=s.length;o--;)s[o]&&(h=this.renderSlice(o).append(),this.valueShapes[o]=h.id,this.shapes[h.id]=o);t.render()}}}),s.fn.sparkline.box=W=a(s.fn.sparkline._base,{type:"box",init:function(t,e,i,r,n){W._super.init.call(this,t,e,i,r,n),this.values=s.map(e,Number),this.width="auto"===i.get("width")?"4.0em":r,this.initTarget(),this.values.length||(this.disabled=1)},getRegion:function(){return 1},getCurrentRegionFields:function(){var t=[{field:"lq",value:this.quartiles[0]},{field:"med",value:this.quartiles[1]},{field:"uq",value:this.quartiles[2]}];return this.loutlier!==i&&t.push({field:"lo",value:this.loutlier}),this.routlier!==i&&t.push({field:"ro",value:this.routlier}),this.lwhisker!==i&&t.push({field:"lw",value:this.lwhisker}),this.rwhisker!==i&&t.push({field:"rw",value:this.rwhisker}),t},render:function(){var t=this.target,s=this.values,r=s.length,n=this.options,a=this.canvasWidth,h=this.canvasHeight,o=n.get("chartRangeMin")===i?e.min.apply(e,s):n.get("chartRangeMin"),g=n.get("chartRangeMax")===i?e.max.apply(e,s):n.get("chartRangeMax"),p=0,u,c,d,f,m,v,x,y,C,w,b;if(W._super.render.call(this)){if(n.get("raw"))n.get("showOutliers")&&s.length>5?(c=s[0],u=s[1],f=s[2],m=s[3],v=s[4],x=s[5],y=s[6]):(u=s[0],f=s[1],m=s[2],v=s[3],x=s[4]);else if(s.sort(function(t,e){return t-e}),f=l(s,1),m=l(s,2),v=l(s,3),d=v-f,n.get("showOutliers")){for(u=x=i,C=0;r>C;C++)u===i&&s[C]>f-d*n.get("outlierIQR")&&(u=s[C]),s[C]<v+d*n.get("outlierIQR")&&(x=s[C]);c=s[0],y=s[r-1]}else u=s[0],x=s[r-1];this.quartiles=[f,m,v],this.lwhisker=u,this.rwhisker=x,this.loutlier=c,this.routlier=y,b=a/(g-o+1),n.get("showOutliers")&&(p=e.ceil(n.get("spotRadius")),a-=2*e.ceil(n.get("spotRadius")),b=a/(g-o+1),u>c&&t.drawCircle((c-o)*b+p,h/2,n.get("spotRadius"),n.get("outlierLineColor"),n.get("outlierFillColor")).append(),y>x&&t.drawCircle((y-o)*b+p,h/2,n.get("spotRadius"),n.get("outlierLineColor"),n.get("outlierFillColor")).append()),t.drawRect(e.round((f-o)*b+p),e.round(.1*h),e.round((v-f)*b),e.round(.8*h),n.get("boxLineColor"),n.get("boxFillColor")).append(),t.drawLine(e.round((u-o)*b+p),e.round(h/2),e.round((f-o)*b+p),e.round(h/2),n.get("lineColor")).append(),t.drawLine(e.round((u-o)*b+p),e.round(h/4),e.round((u-o)*b+p),e.round(h-h/4),n.get("whiskerColor")).append(),t.drawLine(e.round((x-o)*b+p),e.round(h/2),e.round((v-o)*b+p),e.round(h/2),n.get("lineColor")).append(),t.drawLine(e.round((x-o)*b+p),e.round(h/4),e.round((x-o)*b+p),e.round(h-h/4),n.get("whiskerColor")).append(),t.drawLine(e.round((m-o)*b+p),e.round(.1*h),e.round((m-o)*b+p),e.round(.9*h),n.get("medianColor")).append(),n.get("target")&&(w=e.ceil(n.get("spotRadius")),t.drawLine(e.round((n.get("target")-o)*b+p),e.round(h/2-w),e.round((n.get("target")-o)*b+p),e.round(h/2+w),n.get("targetColor")).append(),t.drawLine(e.round((n.get("target")-o)*b+p-w),e.round(h/2),e.round((n.get("target")-o)*b+p+w),e.round(h/2),n.get("targetColor")).append()),t.render()}}}),I=a({init:function(t,e,i,s){this.target=t,this.id=e,this.type=i,this.args=s},append:function(){return this.target.appendShape(this),this}}),j=a({_pxregex:/(\d+)(px)?\s*$/i,init:function(t,e,i){t&&(this.width=t,this.height=e,this.target=i,this.lastShapeId=null,i[0]&&(i=i[0]),s.data(i,"_jqs_vcanvas",this))},drawLine:function(t,e,i,s,r,n){return this.drawShape([[t,e],[i,s]],r,n)},drawShape:function(t,e,i,s){return this._genShape("Shape",[t,e,i,s])},drawCircle:function(t,e,i,s,r,n){return this._genShape("Circle",[t,e,i,s,r,n])},drawPieSlice:function(t,e,i,s,r,n,a){return this._genShape("PieSlice",[t,e,i,s,r,n,a])},drawRect:function(t,e,i,s,r,n){return this._genShape("Rect",[t,e,i,s,r,n])},getElement:function(){return this.canvas},getLastShapeId:function(){return this.lastShapeId},reset:function(){alert("reset not implemented")},_insert:function(t,e){s(e).html(t)},_calculatePixelDims:function(t,e,i){var r;r=this._pxregex.exec(e),this.pixelHeight=r?r[1]:s(i).height(),r=this._pxregex.exec(t),this.pixelWidth=r?r[1]:s(i).width()},_genShape:function(t,e){var i=F++;return e.unshift(i),new I(this,i,t,e)},appendShape:function(t){alert("appendShape not implemented")},replaceWithShape:function(t,e){alert("replaceWithShape not implemented")},insertAfterShape:function(t,e){alert("insertAfterShape not implemented")},removeShapeId:function(t){alert("removeShapeId not implemented")},getShapeAt:function(t,e,i){alert("getShapeAt not implemented")},render:function(){alert("render not implemented")}}),P=a(j,{init:function(e,r,n,a){P._super.init.call(this,e,r,n),this.canvas=t.createElement("canvas"),n[0]&&(n=n[0]),s.data(n,"_jqs_vcanvas",this),s(this.canvas).css({display:"inline-block",width:e,height:r,verticalAlign:"top"}),this._insert(this.canvas,n),this._calculatePixelDims(e,r,this.canvas),this.canvas.width=this.pixelWidth,this.canvas.height=this.pixelHeight,this.interact=a,this.shapes={},this.shapeseq=[],this.currentTargetShapeId=i,s(this.canvas).css({width:this.pixelWidth,height:this.pixelHeight})},_getContext:function(t,e,s){var r=this.canvas.getContext("2d");return t!==i&&(r.strokeStyle=t),r.lineWidth=s===i?1:s,e!==i&&(r.fillStyle=e),r},reset:function(){var t=this._getContext();t.clearRect(0,0,this.pixelWidth,this.pixelHeight),this.shapes={},this.shapeseq=[],this.currentTargetShapeId=i},_drawShape:function(t,e,s,r,n){var a=this._getContext(s,r,n),h,o;for(a.beginPath(),a.moveTo(e[0][0]+.5,e[0][1]+.5),h=1,o=e.length;o>h;h++)a.lineTo(e[h][0]+.5,e[h][1]+.5);s!==i&&a.stroke(),r!==i&&a.fill(),this.targetX!==i&&this.targetY!==i&&a.isPointInPath(this.targetX,this.targetY)&&(this.currentTargetShapeId=t)},_drawCircle:function(t,s,r,n,a,h,o){var l=this._getContext(a,h,o);l.beginPath(),l.arc(s,r,n,0,2*e.PI,!1),this.targetX!==i&&this.targetY!==i&&l.isPointInPath(this.targetX,this.targetY)&&(this.currentTargetShapeId=t),a!==i&&l.stroke(),h!==i&&l.fill()},_drawPieSlice:function(t,e,s,r,n,a,h,o){var l=this._getContext(h,o);l.beginPath(),l.moveTo(e,s),l.arc(e,s,r,n,a,!1),l.lineTo(e,s),l.closePath(),h!==i&&l.stroke(),o&&l.fill(),this.targetX!==i&&this.targetY!==i&&l.isPointInPath(this.targetX,this.targetY)&&(this.currentTargetShapeId=t)},_drawRect:function(t,e,i,s,r,n,a){return this._drawShape(t,[[e,i],[e+s,i],[e+s,i+r],[e,i+r],[e,i]],n,a)},appendShape:function(t){return this.shapes[t.id]=t,this.shapeseq.push(t.id),this.lastShapeId=t.id,t.id},replaceWithShape:function(t,e){var i=this.shapeseq,s;for(this.shapes[e.id]=e,s=i.length;s--;)i[s]==t&&(i[s]=e.id);delete this.shapes[t]},replaceWithShapes:function(t,e){var i=this.shapeseq,s={},r,n,a;for(n=t.length;n--;)s[t[n]]=!0;for(n=i.length;n--;)r=i[n],s[r]&&(i.splice(n,1),delete this.shapes[r],a=n);for(n=e.length;n--;)i.splice(a,0,e[n].id),this.shapes[e[n].id]=e[n]},insertAfterShape:function(t,e){var i=this.shapeseq,s;for(s=i.length;s--;)if(i[s]===t)return i.splice(s+1,0,e.id),void(this.shapes[e.id]=e)},removeShapeId:function(t){var e=this.shapeseq,i;for(i=e.length;i--;)if(e[i]===t){e.splice(i,1);break}delete this.shapes[t]},getShapeAt:function(t,e,i){return this.targetX=e,this.targetY=i,this.render(),this.currentTargetShapeId},render:function(){var t=this.shapeseq,e=this.shapes,i=t.length,s=this._getContext(),r,n,a;for(s.clearRect(0,0,this.pixelWidth,this.pixelHeight),a=0;i>a;a++)r=t[a],n=e[r],this["_draw"+n.type].apply(this,n.args);this.interact||(this.shapes={},this.shapeseq=[])}}),L=a(j,{init:function(e,i,r){var n;L._super.init.call(this,e,i,r),r[0]&&(r=r[0]),s.data(r,"_jqs_vcanvas",this),this.canvas=t.createElement("span"),s(this.canvas).css({display:"inline-block",position:"relative",overflow:"hidden",width:e,height:i,margin:"0px",padding:"0px",verticalAlign:"top"}),this._insert(this.canvas,r),this._calculatePixelDims(e,i,this.canvas),this.canvas.width=this.pixelWidth,this.canvas.height=this.pixelHeight,n='<v:group coordorigin="0 0" coordsize="'+this.pixelWidth+" "+this.pixelHeight+'" style="position:absolute;top:0;left:0;width:'+this.pixelWidth+"px;height="+this.pixelHeight+'px;"></v:group>',this.canvas.insertAdjacentHTML("beforeEnd",n),this.group=s(this.canvas).children()[0],this.rendered=!1,this.prerender=""},_drawShape:function(t,e,s,r,n){var a=[],h,o,l,g,p,u,c;for(c=0,u=e.length;u>c;c++)a[c]=""+e[c][0]+","+e[c][1];return h=a.splice(0,1),n=n===i?1:n,o=s===i?' stroked="false" ':' strokeWeight="'+n+'px" strokeColor="'+s+'" ',l=r===i?' filled="false"':' fillColor="'+r+'" filled="true" ',g=a[0]===a[a.length-1]?"x ":"",p='<v:shape coordorigin="0 0" coordsize="'+this.pixelWidth+" "+this.pixelHeight+'" id="jqsshape'+t+'" '+o+l+' style="position:absolute;left:0px;top:0px;height:'+this.pixelHeight+"px;width:"+this.pixelWidth+'px;padding:0px;margin:0px;" path="m '+h+" l "+a.join(", ")+" "+g+'e"> </v:shape>'},_drawCircle:function(t,e,s,r,n,a,h){var o,l,g;return e-=r,s-=r,o=n===i?' stroked="false" ':' strokeWeight="'+h+'px" strokeColor="'+n+'" ',l=a===i?' filled="false"':' fillColor="'+a+'" filled="true" ',g='<v:oval id="jqsshape'+t+'" '+o+l+' style="position:absolute;top:'+s+"px; left:"+e+"px; width:"+2*r+"px; height:"+2*r+'px"></v:oval>'},_drawPieSlice:function(t,s,r,n,a,h,o,l){var g,p,u,c,d,f,m,v;if(a===h)return"";if(h-a===2*e.PI&&(a=0,h=2*e.PI),p=s+e.round(e.cos(a)*n),u=r+e.round(e.sin(a)*n),c=s+e.round(e.cos(h)*n),d=r+e.round(e.sin(h)*n),p===c&&u===d){if(h-a<e.PI)return"";p=c=s+n,u=d=r}return p===c&&u===d&&h-a<e.PI?"":(g=[s-n,r-n,s+n,r+n,p,u,c,d],f=o===i?' stroked="false" ':' strokeWeight="1px" strokeColor="'+o+'" ',m=l===i?' filled="false"':' fillColor="'+l+'" filled="true" ',v='<v:shape coordorigin="0 0" coordsize="'+this.pixelWidth+" "+this.pixelHeight+'" id="jqsshape'+t+'" '+f+m+' style="position:absolute;left:0px;top:0px;height:'+this.pixelHeight+"px;width:"+this.pixelWidth+'px;padding:0px;margin:0px;" path="m '+s+","+r+" wa "+g.join(", ")+' x e"> </v:shape>')},_drawRect:function(t,e,i,s,r,n,a){return this._drawShape(t,[[e,i],[e,i+r],[e+s,i+r],[e+s,i],[e,i]],n,a)},reset:function(){this.group.innerHTML=""},appendShape:function(t){var e=this["_draw"+t.type].apply(this,t.args);return this.rendered?this.group.insertAdjacentHTML("beforeEnd",e):this.prerender+=e,this.lastShapeId=t.id,t.id},replaceWithShape:function(t,e){var i=s("#jqsshape"+t),r=this["_draw"+e.type].apply(this,e.args);i[0].outerHTML=r},replaceWithShapes:function(t,e){var i=s("#jqsshape"+t[0]),r="",n=e.length,a;for(a=0;n>a;a++)r+=this["_draw"+e[a].type].apply(this,e[a].args);for(i[0].outerHTML=r,a=1;a<t.length;a++)s("#jqsshape"+t[a]).remove()},insertAfterShape:function(t,e){var i=s("#jqsshape"+t),r=this["_draw"+e.type].apply(this,e.args);i[0].insertAdjacentHTML("afterEnd",r)},removeShapeId:function(t){var e=s("#jqsshape"+t);this.group.removeChild(e[0])},getShapeAt:function(t,e,i){var s=t.id.substr(8);return s},render:function(){this.rendered||(this.group.innerHTML=this.prerender,this.rendered=!0)}})})}(document,Math)}();
+
+!function(){"undefined"==typeof web3&&(web3=require("web3"),web3.setProvider(new web3.providers.HttpSyncProvider("http://localhost:8545")))}();
+
+!function(){Template.views_home.created=function(){var e=Blocks.findOne({},{sort:{number:-1}}),t=GeoPattern.generate(e?e.hash:"---");$(".latest-block-info").css("background-image",t.toDataUrl());try{if(void 0!=web3.eth.number)for(currentBlock=web3.eth.number,Blocks.remove({number:{$lt:currentBlock-50}}),i=currentBlock;i>currentBlock-10;i--)Blocks.upsert("block_"+i,{_id:"block_"+i,number:i,gasUsed:web3.eth.block(i).gasUsed,size:web3.eth.block(i).size,time:web3.eth.block(i).time,hash:web3.eth.block(i).hash,miner:web3.eth.block(i).coinbase,uncles:web3.eth.block(i).uncles.Length})}catch(n){console.log("no web3 object")}},Template.views_home.destroyed=function(){},Template.views_home.helpers({blocks:function(){var e=Blocks.find({},{limit:50,sort:{number:-1}}),t=Template.instance();return Tracker.afterFlush(function(){t.view.isRendered&&t.$(".wrapper").css("width",562*e.count()+500+"px")}),e.fetch()},currentBlockPattern:function(){var e=GeoPattern.generate(this.hash);return e?e.toDataUrl():"white"},peerCount:function(){try{return web3.eth.peerCount}catch(e){return"---"}},gasPrice:function(){try{return EthTools.fromWei(web3.eth.gasPrice,"finney")}catch(e){return"---"}},miningSlider:function(){return Miner.mining||0},hashrate:function(){return Miner.hashrate},timeSpent:function(){var e=MiningData.findOne().totalTimeSpent;return e?180>e?Math.round(10*e)/10+"<small> Seconds </small>":10800>e?Math.round(10*e/60)/10+"<small> Minutes </small>":86400>e?Math.round(10*e/3600)/10+"<small> Hours </small>":Math.round(10*e/86400)/10+"<small> Days </small>":"---"},totalRewards:function(){var e=MiningData.findOne().totalRewards;return e&&e>0?1e3>e?Math.floor(100*e)/100+"<small> Finney </small>":e>1e6?Math.floor(e/1e3).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")+"<small> Ether </small>":Math.floor(e/10)/100+"<small> Ether </small>":"---"},averageRewardPerHour:function(){var e=MiningData.findOne().totalRewards,t=MiningData.findOne().totalTimeSpent;if(e&&t>0){var n=3600*e/t;return 1e3>n?Math.floor(100*n)/100+"<small> Finney/h </small>":n>1e6?Math.floor(n/1e3).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")+"<small> Ether/h </small>":Math.floor(n/10)/100+"<small> Ether/h </small>";return reward}return"---"}}),Template.views_home.events({"change input.slider-vertical, input input.slider-vertical":function(e){Miner.mining=Number(e.currentTarget.value)}})}();
+
+!function(){Blocks=new Mongo.Collection("blocks",{connection:null}),new PersistentMinimongo(Blocks),MiningData=new Mongo.Collection("miningdata",{connection:null}),new PersistentMinimongo(MiningData),MiningData.findOne()||MiningData.insert({totalTimeSpent:0,lastCoinbaseBalance:0,totalRewards:0})}();
+
+!function(){"localhost:3000"!==location.host&&"127.0.0.1:3000"!==location.host&&Meteor.disconnect(),Meteor.startup(function(){if(Cookie.get("TAPi18next"))TAPi18n.setLanguage(Cookie.get("TAPi18next"));else{var e=navigator.language||navigator.userLanguage,n=TAPi18n.getLanguages();TAPi18n.setLanguage(_.isObject(n)&&n[e]?e:_.isObject(n)&&n[e.substr(0,2)]?e.substr(0,2):"en")}Tracker.autorun(function(){_.isString(TAPi18n.getLanguage())&&(moment.locale(TAPi18n.getLanguage().substr(0,2)),numeral.language(TAPi18n.getLanguage().substr(0,2)))})})}();
+
+!function(){var e=function(e,n,r){_.isUndefined(r)||(e["__tracker_"+n+"_value__"]=r),e["__tracker_"+n+"_dependency__"]=new Tracker.Dependency,Object.defineProperty(e,n,{get:function(){return this["__tracker_"+n+"_dependency__"].depend(),this["__tracker_"+n+"_value__"]},set:function(_){_!==this["__tracker_"+n+"_value__"]&&(this["__tracker_"+n+"_value__"]=_,this["__tracker_"+n+"_dependency__"].changed())}})};Miner={},e(Miner,"mining",0),e(Miner,"hashrate",0)}();
+
+!function(){Router.configure({layoutTemplate:"layout_main",yieldRegions:{layout_header:{to:"header"}},autoRun:!1,autoRender:!1}),Router.route("/",{template:"views_home",name:"home"}),Router.route("/profile",{template:"views_home",name:"userProfile"})}();
+
+!function(){var e=web3.eth.watch("chain");e.changed(function(e){if(e.number=web3.eth.number,Blocks.upsert("block_"+e.number,{_id:"block_"+e.number,number:e.number,gasUsed:web3.eth.block(e.number).gasUsed,size:web3.eth.block(e.number).size,time:web3.eth.block(e.number).time,hash:web3.eth.block(e.number).hash,miner:web3.eth.block(e.number).coinbase,uncles:web3.eth.block(e.number).uncles.Length}),web3.eth.coinbase==web3.eth.block(e.number).coinbase){var a=MiningData.findOne();WeiToFin=1e15,lastBalance=a.lastCoinbaseBalance||Number(web3.toDecimal(web3.eth.balanceAt(web3.eth.coinbase)))/WeiToFin,currentBalance=Number(web3.toDecimal(web3.eth.balanceAt(web3.eth.coinbase)))/WeiToFin,blockReward=currentBalance-lastBalance,console.log("New Block! last balance: "+a.lastCoinbaseBalance+" Reward: "+blockReward),MiningData.update(a._id,{$inc:{totalRewards:blockReward}}),MiningData.update(a._id,{$set:{lastCoinbaseBalance:currentBalance}})}else{WeiToFin=1e15,currentBalance=Number(web3.toDecimal(web3.eth.balanceAt(web3.eth.coinbase)))/WeiToFin;var a=MiningData.findOne();MiningData.update(a._id,{lastCoinbaseBalance:currentBalance}),console.log("New Block! last balance: "+a.lastCoinbaseBalance)}})}();
+
+!function(){var n=Package.underscore._,e="project",o="project";"project"!=e&&(o=TAPi18n.packages[e].namespace),TAPi18n._enable({helper_name:"_",supported_languages:null,i18n_files_route:"/tap-i18n",cdn_path:null}),TAPi18n.languages_names.en=["English","English"],translations={},translations[o]={app:{loading:"Loading...",offline:"Can't connect are you offline?",logginIn:"Logging in..."},error:{insufficientRights:"You don't have enough rights for this action."},buttons:{ok:"OK",cancel:"Cancel",save:"Save",edit:"edit",send:"Send",create:"Create",tryToReconnect:"Try to reconnect"},commonWords:{you:"You",send:"Send",or:"or","with":"with",and:"and",on:"on",off:"off",per:"per"}},TAPi18n._loadLangFileObject("en",translations)}();
+
+!function(){var e=Package.underscore._,n="project",a="project";"project"!=n&&(a=TAPi18n.packages[n].namespace),translations={},translations[a]={network:{home:{NetworkHealth:"Network Health",Mining:"Mining",MiningStatus:"Mining Status",on:"On",off:"Off",TimeSpent:"Time Spent",Rewards:"Rewards",AverageReward:"Average Reward",Connections:"Connections",PeerCount:"Peer Count",Peers:"Peers",GasPrice:"Gas Price",Finney:"Finney",Blockchain:"Blockchain",Block:"Block",GasUsed:"Gas Used",Size:"Size",Uncles:"Number of uncles",Time:"Time",EndOfBlocks:"No more loaded blocks"}}},TAPi18n._loadLangFileObject("en",translations)}();
+
+!function(){TAPi18n._enable({helper_name:"i18n",supported_languages:["en","de"],i18n_files_route:"/i18n",cdn_path:null}),TAPi18n.languages_names.en=["English","English"],TAPi18n.languages_names.en=["English","English"],TAPi18n.languages_names.de=["German","Deutsch"]}(); \ No newline at end of file
diff --git a/cmd/mist/assets/qml/views/network-health/529f30ee0ee386c5143b4ccb62073179ca8253c3.css b/cmd/mist/assets/qml/views/network-health/529f30ee0ee386c5143b4ccb62073179ca8253c3.css
new file mode 100644
index 000000000..379e5808b
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/529f30ee0ee386c5143b4ccb62073179ca8253c3.css
@@ -0,0 +1,4 @@
+@font-face{font-family:'Simple-Line-Icons';src:url('packages/ethereum_elements/icons/Simple-Line-Icons.eot');src:url('packages/ethereum_elements/icons/Simple-Line-Icons.eot?') format('embedded-opentype'),
+ url('packages/ethereum_elements/icons/Simple-Line-Icons.woff') format('woff'),
+ url('packages/ethereum_elements/icons/Simple-Line-Icons.ttf') format('truetype'),
+ url('packages/ethereum_elements/icons/Simple-Line-Icons.svg') format('svg');font-weight:normal;font-style:normal}[data-icon]:before{font-family:'Simple-Line-Icons';content:attr(data-icon);speak:none;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-user-female,.icon-user-follow,.icon-user-following,.icon-user-unfollow,.icon-trophy,.icon-screen-smartphone,.icon-screen-desktop,.icon-plane,.icon-notebook,.icon-moustache,.icon-mouse,.icon-magnet,.icon-energy,.icon-emoticon-smile,.icon-disc,.icon-cursor-move,.icon-crop,.icon-credit-card,.icon-chemistry,.icon-user,.icon-speedometer,.icon-social-youtube,.icon-social-twitter,.icon-social-tumblr,.icon-social-facebook,.icon-social-dropbox,.icon-social-dribbble,.icon-shield,.icon-screen-tablet,.icon-magic-wand,.icon-hourglass,.icon-graduation,.icon-ghost,.icon-game-controller,.icon-fire,.icon-eyeglasses,.icon-envelope-open,.icon-envelope-letter,.icon-bell,.icon-badge,.icon-anchor,.icon-wallet,.icon-vector,.icon-speech,.icon-puzzle,.icon-printer,.icon-present,.icon-playlist,.icon-pin,.icon-picture,.icon-map,.icon-layers,.icon-handbag,.icon-globe-alt,.icon-globe,.icon-frame,.icon-folder-alt,.icon-film,.icon-feed,.icon-earphones-alt,.icon-earphones,.icon-drop,.icon-drawer,.icon-docs,.icon-directions,.icon-direction,.icon-diamond,.icon-cup,.icon-compass,.icon-call-out,.icon-call-in,.icon-call-end,.icon-calculator,.icon-bubbles,.icon-briefcase,.icon-book-open,.icon-basket-loaded,.icon-basket,.icon-bag,.icon-action-undo,.icon-action-redo,.icon-wrench,.icon-umbrella,.icon-trash,.icon-tag,.icon-support,.icon-size-fullscreen,.icon-size-actual,.icon-shuffle,.icon-share-alt,.icon-share,.icon-rocket,.icon-question,.icon-pie-chart,.icon-pencil,.icon-note,.icon-music-tone-alt,.icon-music-tone,.icon-microphone,.icon-loop,.icon-logout,.icon-login,.icon-list,.icon-like,.icon-home,.icon-grid,.icon-graph,.icon-equalizer,.icon-dislike,.icon-cursor,.icon-control-start,.icon-control-rewind,.icon-control-play,.icon-control-pause,.icon-control-forward,.icon-control-end,.icon-calendar,.icon-bulb,.icon-bar-chart,.icon-arrow-up,.icon-arrow-right,.icon-arrow-left,.icon-arrow-down,.icon-ban,.icon-bubble,.icon-camcorder,.icon-camera,.icon-check,.icon-clock,.icon-close,.icon-cloud-download,.icon-cloud-upload,.icon-doc,.icon-envelope,.icon-eye,.icon-flag,.icon-folder,.icon-heart,.icon-info,.icon-key,.icon-link,.icon-lock,.icon-lock-open,.icon-magnifier,.icon-magnifier-add,.icon-magnifier-remove,.icon-paper-clip,.icon-paper-plane,.icon-plus,.icon-pointer,.icon-power,.icon-refresh,.icon-reload,.icon-settings,.icon-star,.icon-symbol-female,.icon-symbol-male,.icon-target,.icon-volume-1,.icon-volume-2,.icon-volume-off,.icon-users{font-family:'Simple-Line-Icons';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased}.icon-user-female:before{content:"\e000"}.icon-user-follow:before{content:"\e002"}.icon-user-following:before{content:"\e003"}.icon-user-unfollow:before{content:"\e004"}.icon-trophy:before{content:"\e006"}.icon-screen-smartphone:before{content:"\e010"}.icon-screen-desktop:before{content:"\e011"}.icon-plane:before{content:"\e012"}.icon-notebook:before{content:"\e013"}.icon-moustache:before{content:"\e014"}.icon-mouse:before{content:"\e015"}.icon-magnet:before{content:"\e016"}.icon-energy:before{content:"\e020"}.icon-emoticon-smile:before{content:"\e021"}.icon-disc:before{content:"\e022"}.icon-cursor-move:before{content:"\e023"}.icon-crop:before{content:"\e024"}.icon-credit-card:before{content:"\e025"}.icon-chemistry:before{content:"\e026"}.icon-user:before{content:"\e005"}.icon-speedometer:before{content:"\e007"}.icon-social-youtube:before{content:"\e008"}.icon-social-twitter:before{content:"\e009"}.icon-social-tumblr:before{content:"\e00a"}.icon-social-facebook:before{content:"\e00b"}.icon-social-dropbox:before{content:"\e00c"}.icon-social-dribbble:before{content:"\e00d"}.icon-shield:before{content:"\e00e"}.icon-screen-tablet:before{content:"\e00f"}.icon-magic-wand:before{content:"\e017"}.icon-hourglass:before{content:"\e018"}.icon-graduation:before{content:"\e019"}.icon-ghost:before{content:"\e01a"}.icon-game-controller:before{content:"\e01b"}.icon-fire:before{content:"\e01c"}.icon-eyeglasses:before{content:"\e01d"}.icon-envelope-open:before{content:"\e01e"}.icon-envelope-letter:before{content:"\e01f"}.icon-bell:before{content:"\e027"}.icon-badge:before{content:"\e028"}.icon-anchor:before{content:"\e029"}.icon-wallet:before{content:"\e02a"}.icon-vector:before{content:"\e02b"}.icon-speech:before{content:"\e02c"}.icon-puzzle:before{content:"\e02d"}.icon-printer:before{content:"\e02e"}.icon-present:before{content:"\e02f"}.icon-playlist:before{content:"\e030"}.icon-pin:before{content:"\e031"}.icon-picture:before{content:"\e032"}.icon-map:before{content:"\e033"}.icon-layers:before{content:"\e034"}.icon-handbag:before{content:"\e035"}.icon-globe-alt:before{content:"\e036"}.icon-globe:before{content:"\e037"}.icon-frame:before{content:"\e038"}.icon-folder-alt:before{content:"\e039"}.icon-film:before{content:"\e03a"}.icon-feed:before{content:"\e03b"}.icon-earphones-alt:before{content:"\e03c"}.icon-earphones:before{content:"\e03d"}.icon-drop:before{content:"\e03e"}.icon-drawer:before{content:"\e03f"}.icon-docs:before{content:"\e040"}.icon-directions:before{content:"\e041"}.icon-direction:before{content:"\e042"}.icon-diamond:before{content:"\e043"}.icon-cup:before{content:"\e044"}.icon-compass:before{content:"\e045"}.icon-call-out:before{content:"\e046"}.icon-call-in:before{content:"\e047"}.icon-call-end:before{content:"\e048"}.icon-calculator:before{content:"\e049"}.icon-bubbles:before{content:"\e04a"}.icon-briefcase:before{content:"\e04b"}.icon-book-open:before{content:"\e04c"}.icon-basket-loaded:before{content:"\e04d"}.icon-basket:before{content:"\e04e"}.icon-bag:before{content:"\e04f"}.icon-action-undo:before{content:"\e050"}.icon-action-redo:before{content:"\e051"}.icon-wrench:before{content:"\e052"}.icon-umbrella:before{content:"\e053"}.icon-trash:before{content:"\e054"}.icon-tag:before{content:"\e055"}.icon-support:before{content:"\e056"}.icon-size-fullscreen:before{content:"\e057"}.icon-size-actual:before{content:"\e058"}.icon-shuffle:before{content:"\e059"}.icon-share-alt:before{content:"\e05a"}.icon-share:before{content:"\e05b"}.icon-rocket:before{content:"\e05c"}.icon-question:before{content:"\e05d"}.icon-pie-chart:before{content:"\e05e"}.icon-pencil:before{content:"\e05f"}.icon-note:before{content:"\e060"}.icon-music-tone-alt:before{content:"\e061"}.icon-music-tone:before{content:"\e062"}.icon-microphone:before{content:"\e063"}.icon-loop:before{content:"\e064"}.icon-logout:before{content:"\e065"}.icon-login:before{content:"\e066"}.icon-list:before{content:"\e067"}.icon-like:before{content:"\e068"}.icon-home:before{content:"\e069"}.icon-grid:before{content:"\e06a"}.icon-graph:before{content:"\e06b"}.icon-equalizer:before{content:"\e06c"}.icon-dislike:before{content:"\e06d"}.icon-cursor:before{content:"\e06e"}.icon-control-start:before{content:"\e06f"}.icon-control-rewind:before{content:"\e070"}.icon-control-play:before{content:"\e071"}.icon-control-pause:before{content:"\e072"}.icon-control-forward:before{content:"\e073"}.icon-control-end:before{content:"\e074"}.icon-calendar:before{content:"\e075"}.icon-bulb:before{content:"\e076"}.icon-bar-chart:before{content:"\e077"}.icon-arrow-up:before{content:"\e078"}.icon-arrow-right:before{content:"\e079"}.icon-arrow-left:before{content:"\e07a"}.icon-arrow-down:before{content:"\e07b"}.icon-ban:before{content:"\e07c"}.icon-bubble:before{content:"\e07d"}.icon-camcorder:before{content:"\e07e"}.icon-camera:before{content:"\e07f"}.icon-check:before{content:"\e080"}.icon-clock:before{content:"\e081"}.icon-close:before{content:"\e082"}.icon-cloud-download:before{content:"\e083"}.icon-cloud-upload:before{content:"\e084"}.icon-doc:before{content:"\e085"}.icon-envelope:before{content:"\e086"}.icon-eye:before{content:"\e087"}.icon-flag:before{content:"\e088"}.icon-folder:before{content:"\e089"}.icon-heart:before{content:"\e08a"}.icon-info:before{content:"\e08b"}.icon-key:before{content:"\e08c"}.icon-link:before{content:"\e08d"}.icon-lock:before{content:"\e08e"}.icon-lock-open:before{content:"\e08f"}.icon-magnifier:before{content:"\e090"}.icon-magnifier-add:before{content:"\e091"}.icon-magnifier-remove:before{content:"\e092"}.icon-paper-clip:before{content:"\e093"}.icon-paper-plane:before{content:"\e094"}.icon-plus:before{content:"\e095"}.icon-pointer:before{content:"\e096"}.icon-power:before{content:"\e097"}.icon-refresh:before{content:"\e098"}.icon-reload:before{content:"\e099"}.icon-settings:before{content:"\e09a"}.icon-star:before{content:"\e09b"}.icon-symbol-female:before{content:"\e09c"}.icon-symbol-male:before{content:"\e09d"}.icon-target:before{content:"\e09e"}.icon-volume-1:before{content:"\e09f"}.icon-volume-2:before{content:"\e0a0"}.icon-volume-off:before{content:"\e0a1"}.icon-users:before{content:"\e001"}body.disable-scroll{overflow:hidden}body.blur .dapp-flex-content,body.blur .dapp-footer,body.blur .dapp-header{-webkit-filter:blur(4px);-moz-filter:blur(4px);-ms-filter:blur(4px);filter:blur(4px)}.dapp-modal-overlay{z-index:99;position:fixed;top:0;left:0;right:0;bottom:0;display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-moz-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;-webkit-box-pack:center;-moz-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;background:rgba(17, 17, 17, 0.5);-webkit-transition:opacity 400ms;-moz-transition:opacity 400ms;-o-transition:opacity 400ms;transition:opacity 400ms}.dapp-modal-overlay.animate{zoom:1;filter:alpha(opacity=0);-webkit-opacity:0;-moz-opacity:0;opacity:0}.dapp-modal-overlay.animate .dapp-modal-container{-webkit-transform:translateY(-20%);-moz-transform:translateY(-20%);-o-transform:translateY(-20%);-ms-transform:translateY(-20%);transform:translateY(-20%)}.dapp-modal-container{position:relative;width:448px;margin:110.4px auto;padding:18.4px 32px;background:#fafafa;box-sizing:border-box;box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);border-radius:3px;text-align:center;-webkit-transition:-webkit-transform 400ms;-moz-transition:-moz-transform 400ms;-o-transition:-o-transform 400ms;transition:-webkit-transform 400ms,-moz-transform 400ms,-o-transform 400ms,transform 400ms}.dapp-modal-container .dapp-modal-header{position:relative;padding:36.8px 0;margin:-18.4px -32px;margin-bottom:18.4px;border-radius:2px 2px 0 0;color:#111111;line-height:36.8px;text-align:center}.dapp-modal-container .dapp-modal-header.dapp-pattern{color:#fafafa}.dapp-modal-container .dapp-modal-header h1{margin:0}.dapp-modal-container .dapp-modal-header .dapp-identicon{position:absolute;top:-34.96px;left:50%;margin-left:-32px}.dapp-modal-container p{margin:36.8px 0;line-height:22.08px;font-size:1.2em}.dapp-overflow{overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch}.dapp-shadow-none{box-shadow:0 0 0 rgba(0, 0, 0, 0)}.dapp-shadow-small{box-shadow:0 0px 1px rgba(0, 0, 0, 0.3)}.dapp-shadow-medium{box-shadow:0 1px 4px rgba(0, 0, 0, 0.3)}.dapp-shadow-large{box-shadow:0 1px 16px rgba(0, 0, 0, 0.3)}.dapp-input{display:inline-block;width:300px;max-width:100%;margin-top:18.4px;padding:9.2px 16px;padding-bottom:6.13333333px;border:0;border-bottom:solid 2px #dddcdb;box-sizing:border-box;background-color:#f5f4f2;font-size:1em;font-weight:300;color:#6691c2}.dapp-input::-webkit-input-placeholder{color:#dddcdb}.dapp-input:-moz-placeholder{color:#dddcdb}.dapp-input::-moz-placeholder{color:#dddcdb}.dapp-input:-ms-input-placeholder{color:#dddcdb}.dapp-input:focus{outline:0}.dapp-input.dapp-large{font-size:1.5em}.dapp-input.dapp-error{color:#c20e25;background:rgba(194, 14, 37, 0.1);border-color:rgba(194, 14, 37, 0.15)}.dapp-input:disabled{color:#797673}.dapp-identicon{display:inline-block;width:64px;height:64px;border-radius:50%;background-size:cover;background-positon:50% 50%;box-shadow:inset rgba(255, 255, 255, 0.2) 0 2px 2px, inset rgba(0, 0, 0, 0.3) 0 -1px 8px}.dapp-identicon.dapp-small{width:32px;height:32px}.dapp-identicon.dapp-medium{width:48px;height:48px}.dapp-modal-buttons{position:relative;display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-moz-box-pack:end;-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end;margin-top:16px}.dapp-modal-buttons button,.dapp-modal-buttons a,.dapp-modal-buttons a:visited{-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;margin:0 8px;height:36.8px;line-height:36.8px;font-family:'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, Sans;font-size:0.9em;text-transform:uppercase;font-weight:400}.dapp-modal-buttons button.dapp-primary-button,.dapp-modal-buttons a.dapp-primary-button,.dapp-modal-buttons a:visited.dapp-primary-button{font-weight:600}.dapp-address-input{position:relative}.dapp-address-input input{display:inline-block;width:300px;max-width:100%;margin-top:18.4px;padding:9.2px 16px;padding-bottom:6.13333333px;border:0;border-bottom:solid 2px #dddcdb;box-sizing:border-box;background-color:#f5f4f2;font-size:1em;font-weight:300;color:#6691c2;z-index:1;margin-top:0;padding-left:48px}.dapp-address-input input::-webkit-input-placeholder{color:#dddcdb}.dapp-address-input input:-moz-placeholder{color:#dddcdb}.dapp-address-input input::-moz-placeholder{color:#dddcdb}.dapp-address-input input:-ms-input-placeholder{color:#dddcdb}.dapp-address-input input:focus{outline:0}.dapp-address-input input.dapp-large{font-size:1.5em}.dapp-address-input input.dapp-error{color:#c20e25;background:rgba(194, 14, 37, 0.1);border-color:rgba(194, 14, 37, 0.15)}.dapp-address-input input:disabled{color:#797673}.dapp-address-input input.dapp-large{font-size:1.5em}.dapp-address-input input.dapp-large+.dapp-identicon{top:6px;width:32px;height:32px}.dapp-address-input input.dapp-large+.icon-shield{top:12px}.dapp-address-input input.dapp-error{border-color:#c20e25}.dapp-address-input .dapp-identicon{z-index:2;position:absolute;top:3px;left:5px;width:26.66666667px;height:26.66666667px}.dapp-address-input .icon-shield{position:absolute;top:6px;left:13px;font-size:1.4em;color:#c20e25}@font-face{font-family:'Simple-Line-Icons';src:url('dapp-styles/icons/Simple-Line-Icons.eot');src:url('dapp-styles/icons/Simple-Line-Icons.eot?') format('embedded-opentype'), url('dapp-styles/icons/Simple-Line-Icons.woff') format('woff'), url('dapp-styles/icons/Simple-Line-Icons.ttf') format('truetype'), url('dapp-styles/icons/Simple-Line-Icons.svg') format('svg');font-weight:normal;font-style:normal}[data-icon]:before{font-family:'Simple-Line-Icons';content:attr(data-icon);speak:none;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-user-female,.icon-user-follow,.icon-user-following,.icon-user-unfollow,.icon-trophy,.icon-screen-smartphone,.icon-screen-desktop,.icon-plane,.icon-notebook,.icon-moustache,.icon-mouse,.icon-magnet,.icon-energy,.icon-emoticon-smile,.icon-disc,.icon-cursor-move,.icon-crop,.icon-credit-card,.icon-chemistry,.icon-user,.icon-speedometer,.icon-social-youtube,.icon-social-twitter,.icon-social-tumblr,.icon-social-facebook,.icon-social-dropbox,.icon-social-dribbble,.icon-shield,.icon-screen-tablet,.icon-magic-wand,.icon-hourglass,.icon-graduation,.icon-ghost,.icon-game-controller,.icon-fire,.icon-eyeglasses,.icon-envelope-open,.icon-envelope-letter,.icon-bell,.icon-badge,.icon-anchor,.icon-wallet,.icon-vector,.icon-speech,.icon-puzzle,.icon-printer,.icon-present,.icon-playlist,.icon-pin,.icon-picture,.icon-map,.icon-layers,.icon-handbag,.icon-globe-alt,.icon-globe,.icon-frame,.icon-folder-alt,.icon-film,.icon-feed,.icon-earphones-alt,.icon-earphones,.icon-drop,.icon-drawer,.icon-docs,.icon-directions,.icon-direction,.icon-diamond,.icon-cup,.icon-compass,.icon-call-out,.icon-call-in,.icon-call-end,.icon-calculator,.icon-bubbles,.icon-briefcase,.icon-book-open,.icon-basket-loaded,.icon-basket,.icon-bag,.icon-action-undo,.icon-action-redo,.icon-wrench,.icon-umbrella,.icon-trash,.icon-tag,.icon-support,.icon-size-fullscreen,.icon-size-actual,.icon-shuffle,.icon-share-alt,.icon-share,.icon-rocket,.icon-question,.icon-pie-chart,.icon-pencil,.icon-note,.icon-music-tone-alt,.icon-music-tone,.icon-microphone,.icon-loop,.icon-logout,.icon-login,.icon-list,.icon-like,.icon-home,.icon-grid,.icon-graph,.icon-equalizer,.icon-dislike,.icon-cursor,.icon-control-start,.icon-control-rewind,.icon-control-play,.icon-control-pause,.icon-control-forward,.icon-control-end,.icon-calendar,.icon-bulb,.icon-bar-chart,.icon-arrow-up,.icon-arrow-right,.icon-arrow-left,.icon-arrow-down,.icon-ban,.icon-bubble,.icon-camcorder,.icon-camera,.icon-check,.icon-clock,.icon-close,.icon-cloud-download,.icon-cloud-upload,.icon-doc,.icon-envelope,.icon-eye,.icon-flag,.icon-folder,.icon-heart,.icon-info,.icon-key,.icon-link,.icon-lock,.icon-lock-open,.icon-magnifier,.icon-magnifier-add,.icon-magnifier-remove,.icon-paper-clip,.icon-paper-plane,.icon-plus,.icon-pointer,.icon-power,.icon-refresh,.icon-reload,.icon-settings,.icon-star,.icon-symbol-female,.icon-symbol-male,.icon-target,.icon-volume-1,.icon-volume-2,.icon-volume-off,.icon-users{font-family:'Simple-Line-Icons';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased}.icon-user-female:before{content:"\e000"}.icon-user-follow:before{content:"\e002"}.icon-user-following:before{content:"\e003"}.icon-user-unfollow:before{content:"\e004"}.icon-trophy:before{content:"\e006"}.icon-screen-smartphone:before{content:"\e010"}.icon-screen-desktop:before{content:"\e011"}.icon-plane:before{content:"\e012"}.icon-notebook:before{content:"\e013"}.icon-moustache:before{content:"\e014"}.icon-mouse:before{content:"\e015"}.icon-magnet:before{content:"\e016"}.icon-energy:before{content:"\e020"}.icon-emoticon-smile:before{content:"\e021"}.icon-disc:before{content:"\e022"}.icon-cursor-move:before{content:"\e023"}.icon-crop:before{content:"\e024"}.icon-credit-card:before{content:"\e025"}.icon-chemistry:before{content:"\e026"}.icon-user:before{content:"\e005"}.icon-speedometer:before{content:"\e007"}.icon-social-youtube:before{content:"\e008"}.icon-social-twitter:before{content:"\e009"}.icon-social-tumblr:before{content:"\e00a"}.icon-social-facebook:before{content:"\e00b"}.icon-social-dropbox:before{content:"\e00c"}.icon-social-dribbble:before{content:"\e00d"}.icon-shield:before{content:"\e00e"}.icon-screen-tablet:before{content:"\e00f"}.icon-magic-wand:before{content:"\e017"}.icon-hourglass:before{content:"\e018"}.icon-graduation:before{content:"\e019"}.icon-ghost:before{content:"\e01a"}.icon-game-controller:before{content:"\e01b"}.icon-fire:before{content:"\e01c"}.icon-eyeglasses:before{content:"\e01d"}.icon-envelope-open:before{content:"\e01e"}.icon-envelope-letter:before{content:"\e01f"}.icon-bell:before{content:"\e027"}.icon-badge:before{content:"\e028"}.icon-anchor:before{content:"\e029"}.icon-wallet:before{content:"\e02a"}.icon-vector:before{content:"\e02b"}.icon-speech:before{content:"\e02c"}.icon-puzzle:before{content:"\e02d"}.icon-printer:before{content:"\e02e"}.icon-present:before{content:"\e02f"}.icon-playlist:before{content:"\e030"}.icon-pin:before{content:"\e031"}.icon-picture:before{content:"\e032"}.icon-map:before{content:"\e033"}.icon-layers:before{content:"\e034"}.icon-handbag:before{content:"\e035"}.icon-globe-alt:before{content:"\e036"}.icon-globe:before{content:"\e037"}.icon-frame:before{content:"\e038"}.icon-folder-alt:before{content:"\e039"}.icon-film:before{content:"\e03a"}.icon-feed:before{content:"\e03b"}.icon-earphones-alt:before{content:"\e03c"}.icon-earphones:before{content:"\e03d"}.icon-drop:before{content:"\e03e"}.icon-drawer:before{content:"\e03f"}.icon-docs:before{content:"\e040"}.icon-directions:before{content:"\e041"}.icon-direction:before{content:"\e042"}.icon-diamond:before{content:"\e043"}.icon-cup:before{content:"\e044"}.icon-compass:before{content:"\e045"}.icon-call-out:before{content:"\e046"}.icon-call-in:before{content:"\e047"}.icon-call-end:before{content:"\e048"}.icon-calculator:before{content:"\e049"}.icon-bubbles:before{content:"\e04a"}.icon-briefcase:before{content:"\e04b"}.icon-book-open:before{content:"\e04c"}.icon-basket-loaded:before{content:"\e04d"}.icon-basket:before{content:"\e04e"}.icon-bag:before{content:"\e04f"}.icon-action-undo:before{content:"\e050"}.icon-action-redo:before{content:"\e051"}.icon-wrench:before{content:"\e052"}.icon-umbrella:before{content:"\e053"}.icon-trash:before{content:"\e054"}.icon-tag:before{content:"\e055"}.icon-support:before{content:"\e056"}.icon-size-fullscreen:before{content:"\e057"}.icon-size-actual:before{content:"\e058"}.icon-shuffle:before{content:"\e059"}.icon-share-alt:before{content:"\e05a"}.icon-share:before{content:"\e05b"}.icon-rocket:before{content:"\e05c"}.icon-question:before{content:"\e05d"}.icon-pie-chart:before{content:"\e05e"}.icon-pencil:before{content:"\e05f"}.icon-note:before{content:"\e060"}.icon-music-tone-alt:before{content:"\e061"}.icon-music-tone:before{content:"\e062"}.icon-microphone:before{content:"\e063"}.icon-loop:before{content:"\e064"}.icon-logout:before{content:"\e065"}.icon-login:before{content:"\e066"}.icon-list:before{content:"\e067"}.icon-like:before{content:"\e068"}.icon-home:before{content:"\e069"}.icon-grid:before{content:"\e06a"}.icon-graph:before{content:"\e06b"}.icon-equalizer:before{content:"\e06c"}.icon-dislike:before{content:"\e06d"}.icon-cursor:before{content:"\e06e"}.icon-control-start:before{content:"\e06f"}.icon-control-rewind:before{content:"\e070"}.icon-control-play:before{content:"\e071"}.icon-control-pause:before{content:"\e072"}.icon-control-forward:before{content:"\e073"}.icon-control-end:before{content:"\e074"}.icon-calendar:before{content:"\e075"}.icon-bulb:before{content:"\e076"}.icon-bar-chart:before{content:"\e077"}.icon-arrow-up:before{content:"\e078"}.icon-arrow-right:before{content:"\e079"}.icon-arrow-left:before{content:"\e07a"}.icon-arrow-down:before{content:"\e07b"}.icon-ban:before{content:"\e07c"}.icon-bubble:before{content:"\e07d"}.icon-camcorder:before{content:"\e07e"}.icon-camera:before{content:"\e07f"}.icon-check:before{content:"\e080"}.icon-clock:before{content:"\e081"}.icon-close:before{content:"\e082"}.icon-cloud-download:before{content:"\e083"}.icon-cloud-upload:before{content:"\e084"}.icon-doc:before{content:"\e085"}.icon-envelope:before{content:"\e086"}.icon-eye:before{content:"\e087"}.icon-flag:before{content:"\e088"}.icon-folder:before{content:"\e089"}.icon-heart:before{content:"\e08a"}.icon-info:before{content:"\e08b"}.icon-key:before{content:"\e08c"}.icon-link:before{content:"\e08d"}.icon-lock:before{content:"\e08e"}.icon-lock-open:before{content:"\e08f"}.icon-magnifier:before{content:"\e090"}.icon-magnifier-add:before{content:"\e091"}.icon-magnifier-remove:before{content:"\e092"}.icon-paper-clip:before{content:"\e093"}.icon-paper-plane:before{content:"\e094"}.icon-plus:before{content:"\e095"}.icon-pointer:before{content:"\e096"}.icon-power:before{content:"\e097"}.icon-refresh:before{content:"\e098"}.icon-reload:before{content:"\e099"}.icon-settings:before{content:"\e09a"}.icon-star:before{content:"\e09b"}.icon-symbol-female:before{content:"\e09c"}.icon-symbol-male:before{content:"\e09d"}.icon-target:before{content:"\e09e"}.icon-volume-1:before{content:"\e09f"}.icon-volume-2:before{content:"\e0a0"}.icon-volume-off:before{content:"\e0a1"}.icon-users:before{content:"\e001"}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-size:100%;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:0.67em 0}h2{font-size:1.5em;margin:0.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:0.83em;margin:1.67em 0}h6{font-size:0.67em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}p,pre{margin:1em 0}code,kbd,pre,samp{font-family:monospace, serif;_font-family:'courier new', monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:before,q:after{content:'';content:none}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}dl,menu,ol,ul{margin:1em 0}dd{margin:0 0 0 40px}menu,ol,ul{padding:0 0 0 40px}nav ul,nav ol{list-style:none;list-style-image:none}img{border:0;-ms-interpolation-mode:bicubic;}svg:not(:root){overflow:hidden}figure{margin:0}form{margin:0}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0;white-space:normal;*margin-left:-7px;}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle;}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer;*overflow:visible;}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0;*height:13px;*width:13px;}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;}table{border-collapse:collapse;border-spacing:0}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}html,button,input,select,textarea{font-family:sans-serif}body,form,fieldset,legend,input,select,textarea,button{margin:0}html{font-size:100%}.section{position:relative}.container{max-width:960px;margin-left:auto;margin-right:auto;padding-left:10px;padding-right:10px}.container-full{max-width:960px;margin-left:auto;margin-right:auto}.col{float:left;padding-left:10px;padding-right:10px}[class*="pull-"],[class*="push-"]{position:relative}.no-gutter{padding-left:0;padding-right:0}.col-1{width:8.33333%;width:calc(100% / 12 * 1);width:-webkit-calc(100% / 12 * 1);width:-moz-calc(100% / 12 * 1)}.col-2{width:16.66667%;width:calc(100% / 12 * 2);width:-webkit-calc(100% / 12 * 2);width:-moz-calc(100% / 12 * 2)}.col-3,.col-1-4{width:25%;width:calc(100% / 12 * 3);width:-webkit-calc(100% / 12 * 3);width:-moz-calc(100% / 12 * 3)}.col-4,.col-1-3{width:33.33333%;width:calc(100% / 12 * 4);width:-webkit-calc(100% / 12 * 4);width:-moz-calc(100% / 12 * 4)}.col-5{width:41.66665%;width:calc(100% / 12 * 5);width:-webkit-calc(100% / 12 * 5);width:-moz-calc(100% / 12 * 5)}.col-6,.col-1-2{width:50%;width:calc(100% / 12 * 6);width:-webkit-calc(100% / 12 * 6);width:-moz-calc(100% / 12 * 6)}.col-7{width:58.33333%;width:calc(100% / 12 * 7);width:-webkit-calc(100% / 12 * 7);width:-moz-calc(100% / 12 * 7)}.col-8{width:66.66666%;width:calc(100% / 12 * 8);width:-webkit-calc(100% / 12 * 8);width:-moz-calc(100% / 12 * 8)}.col-9,.col-3-4{width:75%;width:calc(100% / 12 * 9);width:-webkit-calc(100% / 12 * 9);width:-moz-calc(100% / 12 * 9)}.col-10{width:83.33333%;width:calc(100% / 12 * 10);width:-webkit-calc(100% / 12 * 10);width:-moz-calc(100% / 12 * 10)}.col-11{width:91.66666%;width:calc(100% / 12 * 11);width:-webkit-calc(100% / 12 * 11);width:-moz-calc(100% / 12 * 11)}.col-12{width:100%}.push-1{left:8.33333%;left:calc(100% / 12 * 1);left:-webkit-calc(100% / 12 * 1);left:-moz-calc(100% / 12 * 1)}.pull-1{left:-8.33333%;left:calc(-100% / 12 * 1);left:-webkit-calc(-100% / 12 * 1);left:-moz-calc(-100% / 12 * 1)}.push-2{left:16.66667%;left:calc(100% / 12 * 2);left:-webkit-calc(100% / 12 * 2);left:-moz-calc(100% / 12 * 2)}.pull-2{left:-16.66667%;left:calc(-100% / 12 * 2);left:-webkit-calc(-100% / 12 * 2);left:-moz-calc(-100% / 12 * 2)}.push-3,.push-1-4{left:25%;left:calc(100% / 12 * 3);left:-webkit-calc(100% / 12 * 3);left:-moz-calc(100% / 12 * 3)}.pull-3,.pull-1-4{left:-25%;left:calc(-100% / 12 * 3);left:-webkit-calc(-100% / 12 * 3);left:-moz-calc(-100% / 12 * 3)}.push-4,.push-1-3{left:33.33333%;left:calc(100% / 12 * 4);left:-webkit-calc(100% / 12 * 4);left:-moz-calc(100% / 12 * 4)}.pull-4,.pull-1-3{left:-33.33333%;left:calc(-100% / 12 * 4);left:-webkit-calc(-100% / 12 * 4);left:-moz-calc(-100% / 12 * 4)}.push-5{left:41.66665%;left:calc(100% / 12 * 5);left:-webkit-calc(100% / 12 * 5);left:-moz-calc(100% / 12 * 5)}.pull-5{left:-41.66665%;left:calc(-100% / 12 * 5);left:-webkit-calc(-100% / 12 * 5);left:-moz-calc(-100% / 12 * 5)}.push-6,.push-1-2{left:50%;left:calc(100% / 12 * 6);left:-webkit-calc(100% / 12 * 6);left:-moz-calc(100% / 12 * 6)}.pull-6,.pull-1-2{left:-50%;left:calc(-100% / 12 * 6);left:-webkit-calc(-100% / 12 * 6);left:-moz-calc(-100% / 12 * 6)}.push-7{left:58.33333%;left:calc(100% / 12 * 7);left:-webkit-calc(100% / 12 * 7);left:-moz-calc(100% / 12 * 7)}.pull-7{left:-58.33333%;left:calc(-100% / 12 * 7);left:-webkit-calc(-100% / 12 * 7);left:-moz-calc(-100% / 12 * 7)}.push-8{left:66.66666%;left:calc(100% / 12 * 8);left:-webkit-calc(100% / 12 * 8);left:-moz-calc(100% / 12 * 8)}.pull-8{left:-66.66666%;left:calc(-100% / 12 * 8);left:-webkit-calc(-100% / 12 * 8);left:-moz-calc(-100% / 12 * 8)}.push-9,.push-3-4{left:75%;left:calc(100% / 12 * 9);left:-webkit-calc(100% / 12 * 9);left:-moz-calc(100% / 12 * 9)}.pull-9,.pull-3-4{left:-75%;left:calc(-100% / 12 * 9);left:-webkit-calc(-100% / 12 * 9);left:-moz-calc(-100% / 12 * 9)}.push-10{left:83.33333%;left:calc(100% / 12 * 10);left:-webkit-calc(100% / 12 * 10);left:-moz-calc(100% / 12 * 10)}.pull-10{left:-83.33333%;left:calc(-100% / 12 * 10);left:-webkit-calc(-100% / 12 * 10);left:-moz-calc(-100% / 12 * 10)}.push-11{left:91.66666%;left:calc(100% / 12 * 11);left:-webkit-calc(100% / 12 * 11);left:-moz-calc(100% / 12 * 11)}.pull-11{left:-91.66666%;left:calc(-100% / 12 * 11);left:-webkit-calc(-100% / 12 * 11);left:-moz-calc(-100% / 12 * 11)}.row{padding-top:1em;padding-bottom:1em}.no-desktop{display:none}.no-margin{margin:0}.no-padding{padding:0}@media only screen and (min-width: 660px) and (max-width: 959px){.container,.tablet-container{max-width:960px;padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.tablet-container:first-child{margin-left:auto}.tablet-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.tablet-container-full:first-child{margin-left:auto}.tablet-no-gutter{padding-left:0;padding-right:0}.tablet-col-1{width:8.33333%;width:calc(100% / 12 * 1);width:-webkit-calc(100% / 12 * 1);width:-moz-calc(100% / 12 * 1)}.tablet-col-2{width:16.66667%;width:calc(100% / 12 * 2);width:-webkit-calc(100% / 12 * 2);width:-moz-calc(100% / 12 * 2)}.tablet-col-3,.tablet-col-1-4{width:25%;width:calc(100% / 12 * 3);width:-webkit-calc(100% / 12 * 3);width:-moz-calc(100% / 12 * 3)}.tablet-col-4,.tablet-col-1-3{width:33.33333%;width:calc(100% / 12 * 4);width:-webkit-calc(100% / 12 * 4);width:-moz-calc(100% / 12 * 4)}.tablet-col-5{width:41.66665%;width:calc(100% / 12 * 5);width:-webkit-calc(100% / 12 * 5);width:-moz-calc(100% / 12 * 5)}.tablet-col-6,.tablet-col-1-2{width:50%;width:calc(100% / 12 * 6);width:-webkit-calc(100% / 12 * 6);width:-moz-calc(100% / 12 * 6)}.tablet-col-7{width:58.33333%;width:calc(100% / 12 * 7);width:-webkit-calc(100% / 12 * 7);width:-moz-calc(100% / 12 * 7)}.tablet-col-8{width:66.66666%;width:calc(100% / 12 * 8);width:-webkit-calc(100% / 12 * 8);width:-moz-calc(100% / 12 * 8)}.tablet-col-9,.tablet-col-3-4{width:75%;width:calc(100% / 12 * 9);width:-webkit-calc(100% / 12 * 9);width:-moz-calc(100% / 12 * 9)}.tablet-col-10{width:83.33333%;width:calc(100% / 12 * 10);width:-webkit-calc(100% / 12 * 10);width:-moz-calc(100% / 12 * 10)}.tablet-col-11{width:91.66666%;width:calc(100% / 12 * 11);width:-webkit-calc(100% / 12 * 11);width:-moz-calc(100% / 12 * 11)}.tablet-col-12{width:100%}.tablet-push-1{left:8.33333%;left:calc(100% / 12 * 1);left:-webkit-calc(100% / 12 * 1);left:-moz-calc(100% / 12 * 1)}.tablet-pull-1{left:-8.33333%;left:calc(-100% / 12 * 1);left:-webkit-calc(-100% / 12 * 1);left:-moz-calc(-100% / 12 * 1)}.tablet-push-2{left:16.66667%;left:calc(100% / 12 * 2);left:-webkit-calc(100% / 12 * 2);left:-moz-calc(100% / 12 * 2)}.tablet-pull-2{left:-16.66667%;left:calc(-100% / 12 * 2);left:-webkit-calc(-100% / 12 * 2);left:-moz-calc(-100% / 12 * 2)}.tablet-push-3,.tablet-push-1-4{left:25%;left:calc(100% / 12 * 3);left:-webkit-calc(100% / 12 * 3);left:-moz-calc(100% / 12 * 3)}.tablet-pull-3,.tablet-pull-1-4{left:-25%;left:calc(-100% / 12 * 3);left:-webkit-calc(-100% / 12 * 3);left:-moz-calc(-100% / 12 * 3)}.tablet-push-4,.tablet-push-1-3{left:33.33333%;left:calc(100% / 12 * 4);left:-webkit-calc(100% / 12 * 4);left:-moz-calc(100% / 12 * 4)}.tablet-pull-4,.tablet-pull-1-3{left:-33.33333%;left:calc(-100% / 12 * 4);left:-webkit-calc(-100% / 12 * 4);left:-moz-calc(-100% / 12 * 4)}.tablet-push-5{left:41.66665%;left:calc(100% / 12 * 5);left:-webkit-calc(100% / 12 * 5);left:-moz-calc(100% / 12 * 5)}.tablet-pull-5{left:-41.66665%;left:calc(-100% / 12 * 5);left:-webkit-calc(-100% / 12 * 5);left:-moz-calc(-100% / 12 * 5)}.tablet-push-6,.tablet-push-1-2{left:50%;left:calc(100% / 12 * 6);left:-webkit-calc(100% / 12 * 6);left:-moz-calc(100% / 12 * 6)}.tablet-pull-6,.tablet-pull-1-2{left:-50%;left:calc(-100% / 12 * 6);left:-webkit-calc(-100% / 12 * 6);left:-moz-calc(-100% / 12 * 6)}.tablet-push-7{left:58.33333%;left:calc(100% / 12 * 7);left:-webkit-calc(100% / 12 * 7);left:-moz-calc(100% / 12 * 7)}.tablet-pull-7{left:-58.33333%;left:calc(-100% / 12 * 7);left:-webkit-calc(-100% / 12 * 7);left:-moz-calc(-100% / 12 * 7)}.tablet-push-8{left:66.66666%;left:calc(100% / 12 * 8);left:-webkit-calc(100% / 12 * 8);left:-moz-calc(100% / 12 * 8)}.tablet-pull-8{left:-66.66666%;left:calc(-100% / 12 * 8);left:-webkit-calc(-100% / 12 * 8);left:-moz-calc(-100% / 12 * 8)}.tablet-push-9,.tablet-push-3-4{left:75%;left:calc(100% / 12 * 9);left:-webkit-calc(100% / 12 * 9);left:-moz-calc(100% / 12 * 9)}.tablet-pull-9,.tablet-pull-3-4{left:-75%;left:calc(-100% / 12 * 9);left:-webkit-calc(-100% / 12 * 9);left:-moz-calc(-100% / 12 * 9)}.tablet-push-10{left:83.33333%;left:calc(100% / 12 * 10);left:-webkit-calc(100% / 12 * 10);left:-moz-calc(100% / 12 * 10)}.tablet-pull-10{left:-83.33333%;left:calc(-100% / 12 * 10);left:-webkit-calc(-100% / 12 * 10);left:-moz-calc(-100% / 12 * 10)}.tablet-push-11{left:91.66666%;left:calc(100% / 12 * 11);left:-webkit-calc(100% / 12 * 11);left:-moz-calc(100% / 12 * 11)}.tablet-pull-11{left:-91.66666%;left:calc(-100% / 12 * 11);left:-webkit-calc(-100% / 12 * 11);left:-moz-calc(-100% / 12 * 11)}.tablet-no-push,.tablet-no-pull{left:auto}.tablet-row{padding-top:1em;padding-bottom:1em}.tablet-full{left:auto;clear:both;float:none;width:100%;margin:1em 0 0 0;display:block}.tablet-full:first-child{margin-top:0}.tablet-text-left{text-align:left}.tablet-text-right{text-align:right}.tablet-text-center{text-align:center}.tablet-left{float:left}.tablet-right{float:right}.tablet-no-float{float:none}.tablet-no-margin{margin:0}.tablet-no-padding{padding:0}.no-tablet{display:none}.show-tablet{display:block}}@media only screen and (max-width: 659px){.container,.mobile-container{padding-left:20px;padding-right:20px;margin-left:auto;margin-right:auto;float:none}.container:first-child,.mobile-container:first-child{margin-left:auto}.mobile-container-full{padding-left:0;padding-right:0;margin-left:auto;margin-right:auto;float:none}.mobile-container-full:first-child{margin-left:auto}.mobile-no-gutter{padding-left:0;padding-right:0}.mobile-col-1-2{width:50%;width:calc(100% / 12 * 6);width:-webkit-calc(100% / 12 * 6);width:-moz-calc(100% / 12 * 6)}.mobile-col-1-3{width:33.33333%;width:calc(100% / 12 * 4);width:-webkit-calc(100% / 12 * 4);width:-moz-calc(100% / 12 * 4)}.mobile-col-1-4{width:25%;width:calc(100% / 12 * 3);width:-webkit-calc(100% / 12 * 3);width:-moz-calc(100% / 12 * 3)}.mobile-col-3-4{width:75%;width:calc(100% / 12 * 9);width:-webkit-calc(100% / 12 * 9);width:-moz-calc(100% / 12 * 9)}.mobile-push-1-2{left:50%;left:calc(100% / 12 * 6);left:-webkit-calc(100% / 12 * 6);left:-moz-calc(100% / 12 * 6)}.mobile-pull-1-2{left:-50%;left:calc(-100% / 12 * 6);left:-webkit-calc(-100% / 12 * 6);left:-moz-calc(-100% / 12 * 6)}.mobile-push-1-3{left:25%;left:calc(100% / 12 * 3);left:-webkit-calc(100% / 12 * 3);left:-moz-calc(100% / 12 * 3)}.mobile-pull-1-3{left:-25%;left:calc(-100% / 12 * 3);left:-webkit-calc(-100% / 12 * 3);left:-moz-calc(-100% / 12 * 3)}.mobile-push-1-4{left:33.33333%;left:calc(100% / 12 * 4);left:-webkit-calc(100% / 12 * 4);left:-moz-calc(100% / 12 * 4)}.mobile-pull-1-4{left:-33.33333%;left:calc(-100% / 12 * 4);left:-webkit-calc(-100% / 12 * 4);left:-moz-calc(-100% / 12 * 4)}.mobile-push-3-4{left:75%;left:calc(100% / 12 * 9);left:-webkit-calc(100% / 12 * 9);left:-moz-calc(100% / 12 * 9)}.mobile-pull-3-4{left:-75%;left:calc(-100% / 12 * 9);left:-webkit-calc(-100% / 12 * 9);left:-moz-calc(-100% / 12 * 9)}.mobile-no-push,.mobile-no-pull{left:auto}.mobile-row{padding-top:1em;padding-bottom:1em}.mobile-full{left:auto;clear:both;float:none;width:100%;margin:0.2em 0 0 0;display:block}.mobile-full:first-child{margin-top:0}.mobile-text-left{text-align:left}.mobile-text-right{text-align:right}.mobile-text-center{text-align:center}.mobile-left{float:left}.mobile-right{float:right}.mobile-no-float{float:none}.mobile-no-margin{margin:0}.mobile-no-padding{padding:0}.no-mobile{display:none}.show-mobile{display:block}}@media print{*{background:transparent}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%}@page {margin:0.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}@font-face{font-family:'Source Sans Pro';src:url('dapp-styles/fonts/SourceSansPro-ExtraLight.otf');font-weight:100;font-style:normal}@font-face{font-family:'Source Sans Pro';src:url('dapp-styles/fonts/SourceSansPro-ExtraLightIt.otf');font-weight:100;font-style:italic}@font-face{font-family:'Source Sans Pro';src:url('dapp-styles/fonts/SourceSansPro-Light.otf');font-weight:300;font-style:normal}@font-face{font-family:'Source Sans Pro';src:url('dapp-styles/fonts/SourceSansPro-Regular.otf');font-weight:400;font-style:normal}@font-face{font-family:'Source Sans Pro';src:url('dapp-styles/fonts/SourceSansPro-Semibold.otf');font-weight:500;font-style:normal}@font-face{font-family:'Source Sans Pro';src:url('dapp-styles/fonts/SourceSansPro-Bold.otf');font-weight:700;font-style:normal}@font-face{font-family:'Montserrat';src:url('dapp-styles/fonts/Montserrat-Regular.otf');font-weight:400;font-style:normal}.dapp-clear-fix{clear:both}.dapp-overflow{overflow:auto;-webkit-overflow-scrolling:touch}.dapp-shorten-text{display:inline-block;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:100%}.dapp-button-reset{background:none;border:0;padding:0;margin:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.dapp-button-reset:hover,.dapp-button-reset:focus{outline:0}.dapp-shadow-none{-webkit-box-shadow:0 0 0 rgba(0, 0, 0, 0);-moz-box-shadow:0 0 0 rgba(0, 0, 0, 0);box-shadow:0 0 0 rgba(0, 0, 0, 0)}.dapp-shadow-small{-webkit-box-shadow:0 0px 1px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 0px 1px rgba(0, 0, 0, 0.3);box-shadow:0 0px 1px rgba(0, 0, 0, 0.3)}.dapp-shadow-medium{-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);box-shadow:0 1px 4px rgba(0, 0, 0, 0.3)}.dapp-shadow-large{-webkit-box-shadow:0 1px 16px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 1px 16px rgba(0, 0, 0, 0.3);box-shadow:0 1px 16px rgba(0, 0, 0, 0.3)}.dapp-horizontal-menu,.dapp-vertical-menu{padding:0;margin:0;list-style:none}.dapp-horizontal-menu li{display:inline-block;padding:0;margin:0}.dapp-vertical-menu li{display:block;padding:0;margin:0}.cubic-bezier{-webkit-transition-timing-function:cubic-bezier(0.15, 0.3, 0.1, 1);-moz-transition-timing-function:cubic-bezier(0.15, 0.3, 0.1, 1);-o-transition-timing-function:cubic-bezier(0.15, 0.3, 0.1, 1);transition-timing-function:cubic-bezier(0.15, 0.3, 0.1, 1)}.cubic-bezier.animate{-webkit-transition-timing-function:cubic-bezier(0.5, 0.1, 0.2, 1);-moz-transition-timing-function:cubic-bezier(0.5, 0.1, 0.2, 1);-o-transition-timing-function:cubic-bezier(0.5, 0.1, 0.2, 1);transition-timing-function:cubic-bezier(0.5, 0.1, 0.2, 1)}#dapp-form-helper-iframe{display:none}.dapp-message{position:relative;max-width:512px;margin:48px 0;font-size:1.5em;font-weight:100;line-height:27pt}.dapp-count{display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-moz-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;position:absolute;top:0;bottom:0;right:0;padding:0 8px;color:#fafafa;font-weight:100;zoom:1;filter:alpha(opacity=70);-webkit-opacity:0.7;-moz-opacity:0.7;opacity:0.7;-webkit-transition:opacity 400ms;-moz-transition:opacity 400ms;-o-transition:opacity 400ms;transition:opacity 400ms}.dapp-count.animate{zoom:1;filter:alpha(opacity=0);-webkit-opacity:0;-moz-opacity:0;opacity:0}.active .dapp-count{background-color:#f5f4f2;color:#9c9090}.dapp-url-bar{display:block;text-align:center;width:100%;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px}.dapp-big-number{font-size:2em;display:inline-block;width:192px;margin-right:16px;padding-top:18.4px}.dapp-big-number dd{margin:0;font-size:50%;font-weight:600;text-transform:uppercase;color:#695e5e}.dapp-big-number dt{color:#02a8f3}a,a:visited,button{text-decoration:none;color:#02a8f3;outline:0}a:hover,a:visited:hover,button:hover,a:focus,a:visited:focus,button:focus{outline:0}a:active,a:visited:active,button:active{-webkit-transform:scale(0.95);-moz-transform:scale(0.95);-o-transform:scale(0.95);-ms-transform:scale(0.95);transform:scale(0.95)}button{background:none;border:0;padding:0;margin:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;font-weight:inherit}button:hover,button:focus{outline:0}hr{border:0;height:0;margin:32px 0;background-color:transparent;border-bottom:1px solid #ccc6c6}h1{margin:16px 0;margin-bottom:48px;font-weight:100;font-size:2.2em;color:#827a7a}h1 span{font-weight:500}h1+h2{margin-top:0}h1 strong{font-weight:400}h2{display:inline-block;padding:0 8px;padding-bottom:1px;margin:64px 0 16px;font-weight:500;font-size:1em;text-transform:uppercase;background:#827a7a;color:#fafafa;font-family:'Montserrat';font-weight:400}h2+table{margin-top:0}h3{margin:16px 0;padding:0;color:rgba(130, 122, 122, 0.7);text-transform:uppercase;font-weight:500;font-size:1em}h4{margin:16px 0;padding:0;color:rgba(130, 122, 122, 0.7);font-weight:500;font-size:1em}table{width:100%;margin:16px 0}table+h2,table+h3{margin-top:32px}table tbody tr:nth-child(odd){background-color:rgba(204, 198, 198, 0.3)}table tbody tr td{padding:2px 0}table tbody tr td span{display:inline-block;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:100%}.dapp-input{border:0;border-bottom:solid 2px #ccc6c6;background-color:#f5f4f2;color:#02a8f3}.dapp-input::-webkit-input-placeholder{color:#ccc6c6}.dapp-input:-moz-placeholder{color:#ccc6c6}.dapp-input::-moz-placeholder{color:#ccc6c6}.dapp-input:-ms-input-placeholder{color:#ccc6c6}.dapp-input:disabled{color:#695e5e}.dapp-address-input input{border:0;border-bottom:solid 2px #ccc6c6;background-color:#f5f4f2;color:#02a8f3}.dapp-address-input input::-webkit-input-placeholder{color:#ccc6c6}.dapp-address-input input:-moz-placeholder{color:#ccc6c6}.dapp-address-input input::-moz-placeholder{color:#ccc6c6}.dapp-address-input input:-ms-input-placeholder{color:#ccc6c6}.dapp-address-input input:disabled{color:#695e5e}.dapp-address-input .dapp-error+.dapp-identicon{display:none}.dapp-address-input .icon-shield{display:none;position:absolute;top:9px;left:13px;font-size:1.4em;color:#c20e25}.dapp-address-input .dapp-error+.dapp-identicon+.icon-shield{display:block}input,select,textarea{border:0;border-bottom:solid 2px #ccc6c6;background-color:#f5f4f2;color:#02a8f3;display:inline-block;width:300px;max-width:100%;margin-top:18.4px;padding:9.2px 16px;padding-bottom:6.13333333px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;font-size:1em;font-weight:300}input::-webkit-input-placeholder,select::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#ccc6c6}input:-moz-placeholder,select:-moz-placeholder,textarea:-moz-placeholder{color:#ccc6c6}input::-moz-placeholder,select::-moz-placeholder,textarea::-moz-placeholder{color:#ccc6c6}input:-ms-input-placeholder,select:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#ccc6c6}input:disabled,select:disabled,textarea:disabled{color:#695e5e}input:focus,select:focus,textarea:focus{outline:0}input.dapp-large,select.dapp-large,textarea.dapp-large{font-size:1.5em}input.dapp-error,select.dapp-error,textarea.dapp-error{color:#c20e25;background:#f2d7d7;border-color:#f5b6b6}:disabled{color:#695e5e}input[type="checkbox"],input[type="radio"]{display:inline-block;position:relative;margin:0;outline:none !important;-webkit-appearance:none;width:auto;width:24px;height:24px}input[type="checkbox"]::before,input[type="radio"]::before{content:'';position:relative;top:0;left:0;display:block;background:#f5f4f2;border:1px solid #f5f4f2;-webkit-box-shadow:inset 0 0 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:inset 0 0 2px rgba(0, 0, 0, 0.2);box-shadow:inset 0 0 2px rgba(0, 0, 0, 0.2);width:24px;height:24px}input[type="checkbox"]:focus::before,input[type="radio"]:focus::before{border-color:rgba(2, 168, 243, 0.4)}input[type="checkbox"]:disabled::before,input[type="radio"]:disabled::before{cursor:not-allowed;background-color:rgba(245, 244, 242, 0.8);border-color:#f5f4f2}input[type="checkbox"]:after,input[type="radio"]:after{content:'';display:inline-block;position:absolute;top:6px;left:6px;background:#02a8f3;-webkit-box-shadow:0 0px 1px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 0px 1px rgba(0, 0, 0, 0.3);box-shadow:0 0px 1px rgba(0, 0, 0, 0.3);width:12px;height:12px;-webkit-transition:-webkit-transform 400ms;-moz-transition:-moz-transform 400ms;-o-transition:-o-transform 400ms;transition:-webkit-transform 400ms,-moz-transform 400ms,-o-transform 400ms,transform 400ms;-webkit-transform:scale(0);-moz-transform:scale(0);-o-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}input[type="checkbox"]:checked:after,input[type="radio"]:checked:after{-webkit-transform:scale(1);-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}input[type="checkbox"]:disabled:after,input[type="radio"]:disabled:after{background:rgba(2, 168, 243, 0.4)}input[type="radio"]{-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}input[type="radio"]:before{-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}input[type="radio"]:after{-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}input[type="range"]{-webkit-appearance:none;padding:0;border:0;background-color:transparent;overflow:hidden;height:18.4px}input[type="range"]::-webkit-slider-runnable-track{height:5px;background-color:#ccc6c6;border:none;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;border:none;height:16px;width:16px;border-radius:50%;background-color:#02a8f3;margin-top:-6px;z-index:30}input[type="range"]::-webkit-slider-thumb:after{content:" ";width:500px;height:5px;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMSAxIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj48bGluZWFyR3JhZGllbnQgaWQ9Imxlc3NoYXQtZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjEwMCUiIHkxPSIwJSIgeDI9IjAlIiB5Mj0iMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiMwMmE4ZjMiIHN0b3Atb3BhY2l0eT0iMSIvPjxzdG9wIG9mZnNldD0iNTAlIiBzdG9wLWNvbG9yPSIjMDJhOGYzIiBzdG9wLW9wYWNpdHk9IjEiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9InJnYigwLDAsMCkiIHN0b3Atb3BhY2l0eT0iMCIvPjwvbGluZWFyR3JhZGllbnQ+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNsZXNzaGF0LWdlbmVyYXRlZCkiIC8+PC9zdmc+);background-image:-webkit--webkit-linear-gradient(right, #02a8f3 0%, #02a8f3 50%, transparent 100%);background-image:-webkit--moz-linear-gradient(right, #02a8f3 0%, #02a8f3 50%, transparent 100%);background-image:-webkit--o-linear-gradient(right, #02a8f3 0%, #02a8f3 50%, transparent 100%);background-image:-webkit-linear-gradient(to left, #02a8f3 0%, #02a8f3 50%, transparent 100%);display:block;position:relative;left:-500px;top:6px;z-index:20}input[type="range"]:focus{outline:none}input[type="range"]::-moz-range-track{height:5px;background-color:#02a8f3;border:none;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}input[type="range"]::-moz-range-thumb{-webkit-appearance:none;border:none;height:16px;width:16px;border-radius:50%;background-color:#695e5e;margin-top:-4px}input[type="range"]:focus{outline:none}input[type="range"].slider-vertical{transform:rotate(-90deg);width:73.6px}label{font-weight:300}fieldset{border:0;padding:0;margin:16px}select{height:45px}body{display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-direction:normal;-moz-box-direction:normal;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;min-height:100vh;padding:0;margin:0;background-color:#fafafa;font:100 16px 'Source Sans Pro', 'Helvetica Neue', arial, sans-serif;color:#111111}body.disable-scroll{overflow:hidden}body.blur .dapp-flex-content,body.blur .dapp-footer,body.blur .dapp-header{-webkit-filter:blur(4px);-moz-filter:blur(4px);-ms-filter:blur(4px);filter:blur(4px)}.ethereum-dapp-url-bar-style-transparent .dapp-header{padding-top:73.6px}.dapp-grid{z-index:999;background:#ffffff url('dapp-styles/hex-grid-tile.png');background-size:64px 111px;position:absolute;min-height:100%;left:0;right:0;opacity:0.05;pointer-events:none}.dapp-container{display:block;position:relative;margin:0 auto;max-width:960px}.dapp-header,.dapp-aside,.dapp-content,.dapp-footer{position:relative;padding:18.4px 32px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.dapp-header{height:64px;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMSAxIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj48bGluZWFyR3JhZGllbnQgaWQ9Imxlc3NoYXQtZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNmYmZhZmEiIHN0b3Atb3BhY2l0eT0iMSIvPjxzdG9wIG9mZnNldD0iOTAlIiBzdG9wLWNvbG9yPSIjZDlkMGQwIiBzdG9wLW9wYWNpdHk9IjEiLz48L2xpbmVhckdyYWRpZW50PjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjbGVzc2hhdC1nZW5lcmF0ZWQpIiAvPjwvc3ZnPg==);background-image:-webkit-linear-gradient(top, #fbfafa 0, #d9d0d0 90%);background-image:-moz-linear-gradient(top, #fbfafa 0, #d9d0d0 90%);background-image:-o-linear-gradient(top, #fbfafa 0, #d9d0d0 90%);background-image:linear-gradient(to bottom, #fbfafa 0, #d9d0d0 90%)}.dapp-header nav{position:absolute;bottom:0}.dapp-header nav ul{padding:0;margin:0;list-style:none}.dapp-header nav ul li{display:inline-block;padding:0;margin:0}.dapp-header nav ul a{display:inline-block;padding:9.2px 32px;text-align:center;border-bottom:5px solid transparent;color:#0285c0}.dapp-header nav ul a.active{color:#ab9898;border-bottom:5px solid #fafafa}.dapp-header nav ul a.active{-webkit-transform-origin:50% 100%;-moz-transform-origin:50% 100%;-o-transform-origin:50% 100%;-ms-transform-origin:50% 100%;transform-origin:50% 100%}.dapp-header nav ul a i{font-size:1.5em}.dapp-header nav ul a span{display:block;text-transform:uppercase;font-weight:400}.dapp-footer{height:96px;background-color:#111111}.dapp-flex-content{display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.dapp-content{-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;background:#fafafa}.dapp-content.dapp-has-header{padding-top:175.2px}.dapp-content .dapp-content-header{position:fixed;top:0;width:80%;min-height:36.8px;padding:18.4px 16px;margin-left:-32px;background:rgba(245, 244, 242, 0.8);z-index:10;line-height:36.8px;-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.dapp-aside{-webkit-box-flex:0;-moz-box-flex:0;-webkit-flex:0 0 224px;-ms-flex:0 0 224px;flex:0 0 224px;padding-right:0;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMSAxIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj48bGluZWFyR3JhZGllbnQgaWQ9Imxlc3NoYXQtZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNmMGVlZWUiIHN0b3Atb3BhY2l0eT0iMSIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2NjYzZjNiIgc3RvcC1vcGFjaXR5PSIxIi8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2xlc3NoYXQtZ2VuZXJhdGVkKSIgLz48L3N2Zz4=);background-image:-webkit-linear-gradient(top, #f0eeee 0, #ccc6c6 100px);background-image:-moz-linear-gradient(top, #f0eeee 0, #ccc6c6 100px);background-image:-o-linear-gradient(top, #f0eeee 0, #ccc6c6 100px);background-image:linear-gradient(to bottom, #f0eeee 0, #ccc6c6 100px);-webkit-transition:flex 400ms;-moz-transition:flex 400ms;-o-transition:flex 400ms;transition:flex 400ms}.dapp-aside nav ul{padding:0;margin:0;list-style:none;padding-top:18.4px}.dapp-aside nav ul li{display:block;padding:0;margin:0}.dapp-aside nav ul li a,.dapp-aside nav ul li a:visited,.dapp-aside nav ul li button{display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-moz-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;position:relative;min-height:73.6px;max-height:92px;padding:18.4px 32px;padding-left:10.66666667px;overflow:hidden;border-top:#b9b0b0 solid 1px;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;color:#111111;font-weight:300;line-height:20px}.dapp-aside nav ul li a:active,.dapp-aside nav ul li a:visited:active,.dapp-aside nav ul li button:active{-webkit-transform-origin:100% 50%;-moz-transform-origin:100% 50%;-o-transform-origin:100% 50%;-ms-transform-origin:100% 50%;transform-origin:100% 50%;-webkit-transform:scale(0.98);-moz-transform:scale(0.98);-o-transform:scale(0.98);-ms-transform:scale(0.98);transform:scale(0.98)}.dapp-aside nav ul li a>i,.dapp-aside nav ul li a:visited>i,.dapp-aside nav ul li button>i{margin-right:4px}.dapp-aside nav ul li a>span,.dapp-aside nav ul li a:visited>span,.dapp-aside nav ul li button>span{max-width:115px;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.dapp-aside nav ul li .dapp-main-button{position:relative;width:100%;margin-bottom:73.6px;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;background:#665f5f;color:#fafafa;border-top:none}.dapp-aside nav ul li .dapp-main-button i{position:absolute;right:8px;top:27.6px}.dapp-aside nav ul li.active a{background:#fafafa;border-top:none;color:#111111;font-weight:500}.dapp-aside nav ul li:first-child a,.dapp-aside nav ul li.active+li>a,.dapp-aside nav ul li.dapp-main-button+li{border-top:0}.dapp-actionbar{z-index:20;-webkit-box-flex:0;-moz-box-flex:0;-webkit-flex:0 0 64px;-ms-flex:0 0 64px;flex:0 0 64px;background:#fafafa}.dapp-actionbar nav ul{padding:0;margin:0;list-style:none}.dapp-actionbar nav ul li{display:block;padding:0;margin:0}.dapp-actionbar nav ul li{margin:16px 0;color:#02a8f3;position:relative;overflow:hidden;text-align:center;-webkit-transition:height 400ms;-moz-transition:height 400ms;-o-transition:height 400ms;transition:height 400ms}.dapp-actionbar nav ul li button,.dapp-actionbar nav ul li a,.dapp-actionbar nav ul li a:visited{background:none;border:0;padding:0;margin:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:inline-block;color:#111111;color:#0e73b8;font-size:0.8em;font-weight:400}.dapp-actionbar nav ul li button:hover,.dapp-actionbar nav ul li a:hover,.dapp-actionbar nav ul li a:visited:hover,.dapp-actionbar nav ul li button:focus,.dapp-actionbar nav ul li a:focus,.dapp-actionbar nav ul li a:visited:focus{outline:0}.dapp-actionbar nav ul li button:active,.dapp-actionbar nav ul li a:active,.dapp-actionbar nav ul li a:visited:active{-webkit-transform:scale(0.95);-moz-transform:scale(0.95);-o-transform:scale(0.95);-ms-transform:scale(0.95);transform:scale(0.95)}.dapp-actionbar nav ul li button:hover,.dapp-actionbar nav ul li a:hover,.dapp-actionbar nav ul li a:visited:hover{opacity:0.9}.dapp-actionbar nav ul li button i,.dapp-actionbar nav ul li a i,.dapp-actionbar nav ul li a:visited i{font-size:2em;display:block}.dapp-box{display:inline-block;float:left;width:192px;height:220.8px;padding-top:18.4px;padding-left:16px;padding-bottom:9.2px;padding-right:16px;margin-bottom:9.2px;margin-right:16px;background-color:#fafafa;-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3);box-shadow:0 1px 4px rgba(0, 0, 0, 0.3)}.dapp-box h2{margin:0;padding:0;background-color:transparent;color:#827a7a;font-family:'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, Sans;text-transform:none;font-size:1.5em;font-weight:100}.dapp-box.card{padding-left:96px;padding-right:64px;width:512px;max-width:none;height:auto;border-radius:4px;background-repeat-x:no-repeat;background-repeat:repeat-y;background-size:64px}.dapp-box.card h1{margin-bottom:0}.dapp-box.card h3{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-transform:lowercase;margin-top:0}.dapp-box.card dd,.dapp-box.card dt{display:block;height:36.8px;font-size:1.1em;float:left}.dapp-box.card dd{margin:0;width:128px;clear:both;text-align:right}.dapp-box.card dt{font-weight:500;padding-left:16px}.dapp-modal-overlay{background:rgba(17, 17, 17, 0.5)}.dapp-modal-container{background:#fafafa}.dapp-icon-button{background:none;border:0;padding:0;margin:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:inline-block;color:#111111}.dapp-icon-button:hover,.dapp-icon-button:focus{outline:0}.dapp-icon-button:active{-webkit-transform:scale(0.95);-moz-transform:scale(0.95);-o-transform:scale(0.95);-ms-transform:scale(0.95);transform:scale(0.95)}.dapp-icon-button:hover{opacity:0.9}.dapp-block-button,.dapp-block-button:visited{background:none;border:0;padding:0;margin:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;height:36.8px;min-width:100px;padding:4.6px 10.66666667px;background:#02a8f3;color:#fafafa;border-bottom:solid 3px #0297da;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;display:inline-block;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:100%;font-family:'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, Sans;font-size:1em;font-weight:400;text-transform:uppercase}.dapp-block-button:hover,.dapp-block-button:visited:hover,.dapp-block-button:focus,.dapp-block-button:visited:focus{outline:0}.dapp-block-button:active,.dapp-block-button:visited:active{border-bottom-width:3px}.dapp-block-button i,.dapp-block-button:visited i{position:relative;top:2px}.dapp-tag-button{background:none;border:0;padding:0;margin:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;padding:4.6px 8px;background:#ccc6c6;color:#111111;-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;display:inline-block;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:100%;font-size:0.7em}.dapp-tag-button:hover,.dapp-tag-button:focus{outline:0}.dapp-tag-button.active{background:#02a8f3;color:#fafafa}@media screen and (max-width: 576px){aside.dapp-main{-webkit-box-flex:0;-moz-box-flex:0;-webkit-flex:0 0 64px;-ms-flex:0 0 64px;flex:0 0 64px}}@media screen and (max-device-width: 480px) and (orientation: portrait){body{font-size:14px}}@media screen and (max-device-width: 640px) and (orientation: landscape){body{font-size:15px}}.page-title{position:-webkit-sticky;top:15px;left:0;right:0;background:transparent;color:#ccc6c6;display:block;text-align:center;margin:9.2px 0 73.6px}.block-chain{margin:0 -40px;height:331.2px;padding:9.2px 16px;overflow:auto;-webkit-overflow-scrolling:touch}.block-chain .wrapper{padding-right:160px}.block-chain .wrapper .card{position:relative}.block-chain .wrapper .card .dapp-identicon{position:absolute;width:40px;height:40px;left:44px;top:38.2px;border:solid 2px #fafafa}.mining-slider{position:relative;padding-left:16px}.mining-slider .slider-vertical{position:absolute;top:18.4px;left:-40px} \ No newline at end of file
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Black.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Black.otf
new file mode 100644
index 000000000..5e04cf3f7
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Black.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Bold.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Bold.otf
new file mode 100644
index 000000000..eaf99a571
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Bold.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Hairline.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Hairline.otf
new file mode 100644
index 000000000..1ee11cede
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Hairline.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Light.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Light.otf
new file mode 100644
index 000000000..a01805ff0
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Light.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Regular.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Regular.otf
new file mode 100644
index 000000000..85d0c1e8f
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/Montserrat-Regular.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SIL Open Font License.txt b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SIL Open Font License.txt
new file mode 100644
index 000000000..295975a5d
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SIL Open Font License.txt
@@ -0,0 +1,43 @@
+Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
+
+5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Black.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Black.otf
new file mode 100644
index 000000000..492661cba
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Black.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BlackIt.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BlackIt.otf
new file mode 100644
index 000000000..2fbb1d1a1
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BlackIt.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Bold.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Bold.otf
new file mode 100644
index 000000000..597072f58
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Bold.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BoldIt.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BoldIt.otf
new file mode 100644
index 000000000..56bdfaccd
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-BoldIt.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLight.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLight.otf
new file mode 100644
index 000000000..20a21c630
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLight.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLightIt.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLightIt.otf
new file mode 100644
index 000000000..787bfcfae
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-ExtraLightIt.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-It.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-It.otf
new file mode 100644
index 000000000..7ab613d4d
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-It.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Light.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Light.otf
new file mode 100644
index 000000000..4a8eafd78
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Light.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-LightIt.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-LightIt.otf
new file mode 100644
index 000000000..c5b8ca860
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-LightIt.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Regular.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Regular.otf
new file mode 100644
index 000000000..38941ae72
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Regular.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Semibold.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Semibold.otf
new file mode 100644
index 000000000..fd41bcf1c
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-Semibold.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-SemiboldIt.otf b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-SemiboldIt.otf
new file mode 100644
index 000000000..447ff80bf
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/dapp-styles/fonts/SourceSansPro-SemiboldIt.otf
Binary files differ
diff --git a/cmd/mist/assets/qml/views/network-health/index.html b/cmd/mist/assets/qml/views/network-health/index.html
new file mode 100755
index 000000000..96c958a35
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/index.html
@@ -0,0 +1,30 @@
+<html>
+ <meta charset="utf-8">
+ <title>Network</title>
+
+ <!-- <base href="/"> -->
+
+ <meta name="description" content="">
+ <meta name="keywords" content="dapp, ethereum">
+
+ <!-- <link rel="icon" href="/favicon.ico" type="image/x-icon"> -->
+ <!-- <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> -->
+
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black">
+
+ <!-- <link rel="apple-touch-icon" href="/apple-touch-icon-precomposed.png"> -->
+ <!-- <link rel="apple-touch-startup-image" href="/startup.png"> -->
+
+
+ <link rel="stylesheet" type="text/css" class="__meteor-css__" href="529f30ee0ee386c5143b4ccb62073179ca8253c3.css?meteor_css_resource=true">
+<body>
+
+
+ <script type="text/javascript">__meteor_runtime_config__ = {"meteorRelease":"METEOR@1.0.3.1","ROOT_URL":"http://localhost:3000/","ROOT_URL_PATH_PREFIX":"","appId":"e350zy16p3kznipbx5o","autoupdateVersion":"df83a37bd2952ddbb9ba6c5f2a59e9caba02642b","autoupdateVersionRefreshable":"81118ed5fac9ef5f8d55835426179e1e058da42b","autoupdateVersionCordova":"none"};</script>
+
+ <script type="text/javascript" src="205f39107b64acf34cb35d7edb57f47893187a12.js"></script>
+
+</body>
+</html> \ No newline at end of file
diff --git a/cmd/mist/assets/qml/views/network-health/loading.css b/cmd/mist/assets/qml/views/network-health/loading.css
new file mode 100644
index 000000000..1b3f4bd65
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network-health/loading.css
@@ -0,0 +1,92 @@
+body {
+ background-color: #000;
+ font: 16px solid 'Helvetica Neue', sans-serif;
+}
+
+.inject-loading-container {
+ position: relative;
+ padding-top: 20%;
+ /*left: 50%;*/
+ margin: 0 auto;
+ /*max-width: 600px;*/
+ /*margin-left: -300px;*/
+ text-align: center;
+
+}
+.inject-loading-container h1 {
+ text-align: center;
+ font-weight: 300;
+ font-size: 2em;
+}
+
+img.loading-circle {
+ width: 24px;
+ height: 24px;
+
+ animation: rotate 1s linear infinite;
+ -moz-animation: rotate 1s linear infinite;
+ -webkit-animation: rotate 1s linear infinite;
+ -ms-animation: rotate 1s linear infinite;
+
+ transform-origin:50% 49.5%;
+ -ms-transform-origin:50% 49.5%; /* IE 9 */
+ -moz-transform-origin:50% 49.5%; /* Chrome, Safari, Opera */
+ -webkit-transform-origin:50% 49.5%; /* Chrome, Safari, Opera */
+}
+
+/* Keyframes */
+@-webkit-keyframes rotate {
+ 0% {
+ -webkit-transform: rotate(0deg);
+ }
+ 50% {
+ opacity: 0.2;
+ }
+ 100% {
+ -webkit-transform: rotate(360deg);
+ }
+}
+@-moz-keyframes rotate {
+ 0% {
+ -moz-transform: rotate(0deg);
+ }
+ 50% {
+ opacity: 0.2;
+ }
+ 100% {
+ -moz-transform: rotate(360deg);
+ }
+}
+@-o-keyframes rotate {
+ 0% {
+ -o-transform: rotate(0deg);
+ }
+ 50% {
+ opacity: 0.2;
+ }
+ 100% {
+ -o-transform: rotate(360deg);
+ }
+}
+@-ms-keyframes rotate {
+ 0% {
+ -ms-transform: rotate(0deg);
+ }
+ 50% {
+ opacity: 0.2;
+ }
+ 100% {
+ -ms-transform-origin: rotate(360deg);
+ }
+}
+@keyframes rotate {
+ 0% {
+ transform: rotate(0deg);
+ }
+ 50% {
+ opacity: 0.2;
+ }
+ 100% {
+ transform: rotate(360deg);
+ }
+} \ No newline at end of file
diff --git a/cmd/mist/assets/qml/views/network.qml b/cmd/mist/assets/qml/views/network.qml
new file mode 100644
index 000000000..fe4c7734f
--- /dev/null
+++ b/cmd/mist/assets/qml/views/network.qml
@@ -0,0 +1,159 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Layouts 1.0;
+import QtWebEngine 1.0
+import QtWebEngine.experimental 1.0
+import QtQuick.Window 2.0;
+import Ethereum 1.0
+import Qt.WebSockets 1.0
+//import "qwebchannel.js" as WebChannel
+
+
+
+Rectangle {
+ id: window
+ anchors.fill: parent
+ color: "#00000000"
+
+ property var title: "Network"
+ property var iconSource: "../mining-icon.png"
+ property var menuItem
+ property var hideUrl: true
+
+ property alias url: webview.url
+ property alias windowTitle: webview.title
+ property alias webView: webview
+
+ property var cleanPath: false
+ property var open: function(url) {
+ if(!window.cleanPath) {
+ var uri = url;
+ if(!/.*\:\/\/.*/.test(uri)) {
+ uri = "http://" + uri;
+ }
+
+ var reg = /(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.eth)(.*)/
+
+ if(reg.test(uri)) {
+ uri.replace(reg, function(match, pre, domain, path) {
+ uri = pre;
+
+ var lookup = eth.lookupDomain(domain.substring(0, domain.length - 4));
+ var ip = [];
+ for(var i = 0, l = lookup.length; i < l; i++) {
+ ip.push(lookup.charCodeAt(i))
+ }
+
+ if(ip.length != 0) {
+ uri += lookup;
+ } else {
+ uri += domain;
+ }
+
+ uri += path;
+ });
+ }
+
+ window.cleanPath = true;
+
+ webview.url = uri;
+
+ //uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
+ uriNav.text = uri;
+
+ } else {
+ // Prevent inf loop.
+ window.cleanPath = false;
+ }
+ }
+
+ Label {
+ objectName: "miningLabel"
+ visible: false
+ font.pixelSize: 10
+ anchors.right: lastBlockLabel.left
+ anchors.rightMargin: 5
+ onTextChanged: {
+ menuItem.secondaryTitle = eth.miner().mining()? eth.miner().hashRate() + " Khash" : ""
+ }
+ }
+
+ Item {
+ objectName: "root"
+ id: root
+ anchors.fill: parent
+ state: "inspectorShown"
+
+ Timer {
+ interval: 1000; running: true; repeat: true
+ onTriggered: {
+ webview.runJavaScript("Miner.mining", function(miningSliderValue) {
+
+ // Check if it's mining and set it accordingly
+ if (miningSliderValue > 0 && !eth.miner().mining()) {
+ // If the
+ eth.miner().start();
+ } else if (miningSliderValue == 0 && eth.miner().mining()) {
+ eth.miner().stop();
+ } else if (eth.miner().mining()) {
+
+ webview.runJavaScript('var miningData = MiningData.findOne(); MiningData.update(miningData._id, {$inc: {totalTimeSpent: 1}}); Miner.hashrate = ' + eth.miner().hashRate() );
+
+ //var miningData = MiningData.findOne(); MiningData.update(miningData._id, {$inc: {totalTimeSpent: 1}});
+
+ } else if (miningSliderValue == "undefined") {
+
+ webview.runJavaScript('Miner.mining = 0' );
+
+ }
+ });
+
+ }
+ }
+
+ WebEngineView {
+ objectName: "webView"
+ id: webview
+ anchors.fill: parent
+
+ url: "network-health/index.html"
+ //url: "http://localhost:3000/"
+
+ experimental.settings.javascriptCanAccessClipboard: true
+
+
+ onJavaScriptConsoleMessage: {
+ console.log(sourceID + ":" + lineNumber + ":" + JSON.stringify(message));
+ }
+
+ onLoadingChanged: {
+ if (loadRequest.status == WebEngineView.LoadSucceededStatus) {
+ webview.runJavaScript(eth.readFile("mist.js"));
+ }
+ }
+ }
+
+ WebEngineView {
+ id: inspector
+ visible: false
+ z:10
+ anchors {
+ left: root.left
+ right: root.right
+ top: root.top
+ bottom: root.bottom
+ }
+
+ }
+
+ states: [
+ State {
+ name: "inspectorShown"
+ PropertyChanges {
+ target: inspector
+ }
+ }
+ ]
+ }
+}
diff --git a/cmd/mist/assets/qml/views/pending_tx.qml b/cmd/mist/assets/qml/views/pending_tx.qml
new file mode 100644
index 000000000..3dcedeff2
--- /dev/null
+++ b/cmd/mist/assets/qml/views/pending_tx.qml
@@ -0,0 +1,53 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ property var title: "Pending Transactions"
+ property var menuItem
+
+ objectName: "pendingTxView"
+ anchors.fill: parent
+ visible: false
+ id: pendingTxView
+
+ property var pendingTxModel: ListModel {
+ id: pendingTxModel
+ }
+
+ TableView {
+ id: pendingTxTableView
+ anchors.fill: parent
+ TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
+ TableViewColumn{ role: "from" ; title: "sender" ; width: 230 }
+ TableViewColumn{ role: "to" ; title: "Reciever" ; width: 230 }
+ TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 }
+
+ model: pendingTxModel
+ }
+
+ function addTx(tx, inout) {
+ var isContract
+ if (tx.contract == true){
+ isContract = "Yes"
+ }else{
+ isContract = "No"
+ }
+
+
+ pendingTxModel.insert(0, {hash: tx.hash, to: tx.address, from: tx.sender, value: tx.value, contract: isContract})
+ }
+
+ function removeTx(tx) {
+ for (var i = 0; i < pendingTxModel.count; i++) {
+ if (tx.hash === pendingTxModel.get(i).hash) {
+ pendingTxModel.remove(i);
+ break;
+ }
+ }
+ }
+}
diff --git a/cmd/mist/assets/qml/views/transaction.qml b/cmd/mist/assets/qml/views/transaction.qml
new file mode 100644
index 000000000..df798a9c0
--- /dev/null
+++ b/cmd/mist/assets/qml/views/transaction.qml
@@ -0,0 +1,216 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ property var title: "New Transaction"
+ property var menuItem
+
+ objectName: "newTxView"
+ visible: false
+ anchors.fill: parent
+ color: "#00000000"
+
+ Column {
+ id: mainContractColumn
+ anchors.fill: parent
+
+
+ states: [
+ State{
+ name: "ERROR"
+
+ PropertyChanges { target: txResult; visible:true}
+ PropertyChanges { target: codeView; visible:true}
+ },
+ State {
+ name: "DONE"
+
+ PropertyChanges { target: txValue; visible:false}
+ PropertyChanges { target: txGas; visible:false}
+ PropertyChanges { target: txGasPrice; visible:false}
+ PropertyChanges { target: codeView; visible:false}
+ PropertyChanges { target: txButton; visible:false}
+ PropertyChanges { target: txDataLabel; visible:false}
+ PropertyChanges { target: atLabel; visible:false}
+ PropertyChanges { target: txFuelRecipient; visible:false}
+ PropertyChanges { target: valueDenom; visible:false}
+ PropertyChanges { target: gasDenom; visible:false}
+
+ PropertyChanges { target: txResult; visible:true}
+ PropertyChanges { target: txOutput; visible:true}
+ PropertyChanges { target: newTxButton; visible:true}
+ },
+ State {
+ name: "SETUP"
+
+ PropertyChanges { target: txValue; visible:true; text: ""}
+ PropertyChanges { target: txGas; visible:true;}
+ PropertyChanges { target: txGasPrice; visible:true;}
+ PropertyChanges { target: codeView; visible:true; text: ""}
+ PropertyChanges { target: txButton; visible:true}
+ PropertyChanges { target: txDataLabel; visible:true}
+ PropertyChanges { target: valueDenom; visible:true}
+ PropertyChanges { target: gasDenom; visible:true}
+
+ PropertyChanges { target: txResult; visible:false}
+ PropertyChanges { target: txOutput; visible:false}
+ PropertyChanges { target: newTxButton; visible:false}
+ }
+ ]
+ width: 400
+ spacing: 5
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.leftMargin: 5
+ anchors.topMargin: 5
+
+ ListModel {
+ id: denomModel
+ ListElement { text: "Wei" ; zeros: "" }
+ ListElement { text: "Ada" ; zeros: "000" }
+ ListElement { text: "Babbage" ; zeros: "000000" }
+ ListElement { text: "Shannon" ; zeros: "000000000" }
+ ListElement { text: "Szabo" ; zeros: "000000000000" }
+ ListElement { text: "Finney" ; zeros: "000000000000000" }
+ ListElement { text: "Ether" ; zeros: "000000000000000000" }
+ ListElement { text: "Einstein" ;zeros: "000000000000000000000" }
+ ListElement { text: "Douglas" ; zeros: "000000000000000000000000000000000000000000" }
+ }
+
+
+ TextField {
+ id: txFuelRecipient
+ placeholderText: "Address / Name or empty for contract"
+ //validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
+ width: 400
+ }
+
+ RowLayout {
+ TextField {
+ id: txValue
+ width: 222
+ placeholderText: "Amount"
+ validator: RegExpValidator { regExp: /\d*/ }
+ onTextChanged: {
+ contractFormReady()
+ }
+ }
+
+ ComboBox {
+ id: valueDenom
+ currentIndex: 5
+ model: denomModel
+ }
+ }
+
+ RowLayout {
+ TextField {
+ id: txGas
+ width: 50
+ validator: RegExpValidator { regExp: /\d*/ }
+ placeholderText: "Gas"
+ text: "5000"
+ }
+ Label {
+ id: atLabel
+ text: "@"
+ }
+
+ TextField {
+ id: txGasPrice
+ width: 200
+ placeholderText: "Gas price"
+ text: "10"
+ validator: RegExpValidator { regExp: /\d*/ }
+ }
+
+ ComboBox {
+ id: gasDenom
+ currentIndex: 4
+ model: denomModel
+ }
+ }
+
+ Label {
+ id: txDataLabel
+ text: "Data"
+ }
+
+ TextArea {
+ id: codeView
+ height: 300
+ anchors.topMargin: 5
+ width: 400
+ onTextChanged: {
+ contractFormReady()
+ }
+ }
+
+
+ Button {
+ id: txButton
+ /* enabled: false */
+ states: [
+ State {
+ name: "READY"
+ PropertyChanges { target: txButton; /*enabled: true*/}
+ },
+ State {
+ name: "NOTREADY"
+ PropertyChanges { target: txButton; /*enabled:false*/}
+ }
+ ]
+ text: "Send"
+ onClicked: {
+ var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros;
+ var gasPrice = txGasPrice.text + denomModel.get(gasDenom.currentIndex).zeros;
+ var res = gui.transact(txFuelRecipient.text, value, txGas.text, gasPrice, codeView.text)
+ if(res[1]) {
+ txResult.text = "Your contract <b>could not</b> be sent over the network:\n<b>"
+ txResult.text += res[1].error()
+ txResult.text += "</b>"
+ mainContractColumn.state = "ERROR"
+ } else {
+ txResult.text = "Your transaction has been submitted:\n"
+ txOutput.text = res.toString()
+ mainContractColumn.state = "DONE"
+
+ console.log(res)
+ }
+ }
+ }
+ Text {
+ id: txResult
+ visible: false
+ }
+ TextField {
+ id: txOutput
+ visible: false
+ width: 530
+ }
+ Button {
+ id: newTxButton
+ visible: false
+ text: "Create a new transaction"
+ onClicked: {
+ this.visible = false
+ txResult.text = ""
+ txOutput.text = ""
+ mainContractColumn.state = "SETUP"
+ }
+ }
+ }
+
+ function contractFormReady(){
+ if(codeView.text.length > 0 && txValue.text.length > 0 && txGas.text.length > 0 && txGasPrice.length > 0) {
+ txButton.state = "READY"
+ }else{
+ txButton.state = "NOTREADY"
+ }
+ }
+}
diff --git a/cmd/mist/assets/qml/views/wallet.qml b/cmd/mist/assets/qml/views/wallet.qml
new file mode 100644
index 000000000..2369390c3
--- /dev/null
+++ b/cmd/mist/assets/qml/views/wallet.qml
@@ -0,0 +1,190 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ id: root
+ property var title: "Wallet"
+ property var menuItem
+
+ objectName: "walletView"
+ anchors.fill: parent
+
+ Label {
+ objectName: "balanceLabel"
+ visible: false
+ onTextChanged: {
+ balance.text = text
+ menuItem.secondaryTitle = text
+ }
+ }
+
+ function onReady() {
+ setBalance()
+ }
+
+ function setBalance() {
+ balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.coinbase()))
+ if(menuItem)
+ menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.coinbase()))
+ }
+
+ ListModel {
+ id: denomModel
+ ListElement { text: "Wei" ; zeros: "" }
+ ListElement { text: "Ada" ; zeros: "000" }
+ ListElement { text: "Babbage" ; zeros: "000000" }
+ ListElement { text: "Shannon" ; zeros: "000000000" }
+ ListElement { text: "Szabo" ; zeros: "000000000000" }
+ ListElement { text: "Finney" ; zeros: "000000000000000" }
+ ListElement { text: "Ether" ; zeros: "000000000000000000" }
+ ListElement { text: "Einstein" ;zeros: "000000000000000000000" }
+ ListElement { text: "Douglas" ; zeros: "000000000000000000000000000000000000000000" }
+ }
+
+ ColumnLayout {
+ spacing: 10
+ y: 40
+ anchors.fill: parent
+
+ Text {
+ id: balance
+ font.pixelSize: 24
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ top: parent.top
+ topMargin: 20
+ }
+ }
+
+ Rectangle {
+ id: newTxPane
+ color: "#ececec"
+ border.color: "#cccccc"
+ border.width: 1
+ anchors {
+ top: balance.bottom
+ topMargin: 10
+ left: parent.left
+ leftMargin: 5
+ right: parent.right
+ rightMargin: 5
+ }
+ height: 100
+
+ RowLayout {
+ id: amountFields
+ spacing: 10
+ anchors {
+ top: parent.top
+ topMargin: 20
+ left: parent.left
+ leftMargin: 20
+ }
+
+ Text {
+ text: "Ξ "
+ }
+
+ // There's something off with the row layout where textfields won't listen to the width setting
+ Rectangle {
+ width: 50
+ height: 20
+ TextField {
+ id: txValue
+ width: parent.width
+ placeholderText: "0.00"
+ }
+ }
+
+ ComboBox {
+ id: valueDenom
+ currentIndex: 5
+ model: denomModel
+ }
+
+ }
+
+ RowLayout {
+ id: toFields
+ spacing: 10
+ anchors {
+ top: amountFields.bottom
+ topMargin: 5
+ left: parent.left
+ leftMargin: 20
+ }
+
+ Text {
+ text: "To"
+ }
+
+ Rectangle {
+ width: 200
+ height: 20
+ TextField {
+ id: txTo
+ width: parent.width
+ placeholderText: "Address or name"
+ }
+ }
+
+ Button {
+ text: "Send"
+ onClicked: {
+ var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros;
+ var gasPrice = "10000000000000"
+ var res = eth.transact({from: eth.coinbase(), to: txTo.text, value: value, gas: "500", gasPrice: gasPrice})
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: newTxPane.bottom
+ topMargin: 10
+ bottom: parent.bottom
+ }
+ TableView {
+ id: txTableView
+ anchors.fill : parent
+ TableViewColumn{ role: "num" ; title: "#" ; width: 30 }
+ TableViewColumn{ role: "from" ; title: "From" ; width: 340 }
+ TableViewColumn{ role: "to" ; title: "To" ; width: 340 }
+ TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
+
+ model: ListModel {
+ id: txModel
+ Component.onCompleted: {
+ }
+
+ function addTxs(messages) {
+ /*
+ setBalance()
+
+ for(var i = 0; i < messages.length; i++) {
+ var message = messages.get(i);
+ var to = eth.lookupName(message.to);
+ var from;
+ if(message.from.length == 0) {
+ from = "- MINED -";
+ } else {
+ from = eth.lookupName(message.from);
+ }
+ txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)})
+ }
+ */
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/cmd/mist/assets/qml/views/whisper.qml b/cmd/mist/assets/qml/views/whisper.qml
new file mode 100644
index 000000000..dc097b806
--- /dev/null
+++ b/cmd/mist/assets/qml/views/whisper.qml
@@ -0,0 +1,74 @@
+
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+Rectangle {
+ id: root
+ property var title: "Whisper Traffic"
+ property var menuItem
+
+ objectName: "whisperView"
+ anchors.fill: parent
+
+ property var identity: ""
+ Component.onCompleted: {
+ identity = shh.newIdentity()
+
+ var t = shh.watch({}, root)
+ }
+
+ function onShhMessage(message, i) {
+ whisperModel.insert(0, {from: message.from, payload: eth.toAscii(message.payload)})
+ }
+
+ RowLayout {
+ id: input
+ anchors {
+ left: parent.left
+ leftMargin: 20
+ top: parent.top
+ topMargin: 20
+ }
+
+ TextField {
+ id: to
+ placeholderText: "To"
+ }
+ TextField {
+ id: data
+ placeholderText: "Data"
+ }
+ TextField {
+ id: topics
+ placeholderText: "topic1, topic2, topic3, ..."
+ }
+ Button {
+ text: "Send"
+ onClicked: {
+ shh.post([eth.toHex(data.text)], "", identity, topics.text.split(","), 500, 50)
+ }
+ }
+ }
+
+ TableView {
+ id: txTableView
+ anchors {
+ top: input.bottom
+ topMargin: 10
+ bottom: parent.bottom
+ left: parent.left
+ right: parent.right
+ }
+ TableViewColumn{ id: fromRole; role: "from" ; title: "From"; width: 300 }
+ TableViewColumn{ role: "payload" ; title: "Payload" ; width: parent.width - fromRole.width - 2 }
+
+ model: ListModel {
+ id: whisperModel
+ }
+ }
+}
diff --git a/cmd/mist/assets/tx.png b/cmd/mist/assets/tx.png
new file mode 100644
index 000000000..62204c315
--- /dev/null
+++ b/cmd/mist/assets/tx.png
Binary files differ
diff --git a/cmd/mist/assets/util/test.html b/cmd/mist/assets/util/test.html
new file mode 100644
index 000000000..d458e6670
--- /dev/null
+++ b/cmd/mist/assets/util/test.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<title>Utils</title>
+</head>
+<body onload="init();">
+<label>Nonce for 2ef47100e0787b915105fd5e3f4ff6752079d5cb</label>
+<p id="nonce"></p>
+
+<label>Connected peers</label>
+<p id="peers"></p>
+
+<label>Is mining</label>
+<p id="isMining"></p>
+
+<label>Is listening</label>
+<p id="isListen"></p>
+
+<label>Coinbase</label>
+<p id="coinbase"></p>
+
+<script type="text/javascript">
+
+function init() {
+ eth.getTxCountAt("2ef47100e0787b915105fd5e3f4ff6752079d5cb", function(nonce){
+ document.querySelector("#nonce").innerHTML = nonce;
+ })
+ eth.getPeerCount(function(peerLength){
+ document.querySelector("#peers").innerHTML = peerLength;
+ })
+ eth.getIsMining(function(mining){
+ document.querySelector("#isMining").innerHTML = mining;
+ })
+ eth.getIsListening(function(listen){
+ document.querySelector("#isListen").innerHTML = listen;
+ })
+ eth.getCoinBase(function(address){
+ document.querySelector("#coinbase").innerHTML = address;
+ })
+}
+</script>
+</body>
+</html>
+
diff --git a/cmd/mist/assets/wallet.png b/cmd/mist/assets/wallet.png
new file mode 100644
index 000000000..92c401e52
--- /dev/null
+++ b/cmd/mist/assets/wallet.png
Binary files differ
diff --git a/cmd/mist/bindings.go b/cmd/mist/bindings.go
new file mode 100644
index 000000000..b56c0dddf
--- /dev/null
+++ b/cmd/mist/bindings.go
@@ -0,0 +1,100 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import (
+ "encoding/json"
+ "os"
+ "strconv"
+
+ "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/state"
+)
+
+type plugin struct {
+ Name string `json:"name"`
+ Path string `json:"path"`
+}
+
+func (gui *Gui) Transact(from, recipient, value, gas, gasPrice, d string) (string, error) {
+ var data string
+ if len(recipient) == 0 {
+ code, err := ethutil.Compile(d, false)
+ if err != nil {
+ return "", err
+ }
+ data = ethutil.Bytes2Hex(code)
+ } else {
+ data = ethutil.Bytes2Hex(utils.FormatTransactionData(d))
+ }
+
+ return gui.xeth.Transact(from, recipient, value, gas, gasPrice, data)
+}
+
+func (self *Gui) AddPlugin(pluginPath string) {
+ self.plugins[pluginPath] = plugin{Name: pluginPath, Path: pluginPath}
+
+ json, _ := json.MarshalIndent(self.plugins, "", " ")
+ ethutil.WriteFile(self.eth.DataDir+"/plugins.json", json)
+}
+
+func (self *Gui) RemovePlugin(pluginPath string) {
+ delete(self.plugins, pluginPath)
+
+ json, _ := json.MarshalIndent(self.plugins, "", " ")
+ ethutil.WriteFile(self.eth.DataDir+"/plugins.json", json)
+}
+
+func (self *Gui) DumpState(hash, path string) {
+ var stateDump []byte
+
+ if len(hash) == 0 {
+ stateDump = self.eth.ChainManager().State().Dump()
+ } else {
+ var block *types.Block
+ if hash[0] == '#' {
+ i, _ := strconv.Atoi(hash[1:])
+ block = self.eth.ChainManager().GetBlockByNumber(uint64(i))
+ } else {
+ block = self.eth.ChainManager().GetBlock(ethutil.Hex2Bytes(hash))
+ }
+
+ if block == nil {
+ guilogger.Infof("block err: not found %s\n", hash)
+ return
+ }
+
+ stateDump = state.New(block.Root(), self.eth.StateDb()).Dump()
+ }
+
+ file, err := os.OpenFile(path[7:], os.O_CREATE|os.O_RDWR, os.ModePerm)
+ if err != nil {
+ guilogger.Infoln("dump err: ", err)
+ return
+ }
+ defer file.Close()
+
+ guilogger.Infof("dumped state (%s) to %s\n", hash, path)
+
+ file.Write(stateDump)
+}
diff --git a/cmd/mist/errors.go b/cmd/mist/errors.go
new file mode 100644
index 000000000..255ed07c1
--- /dev/null
+++ b/cmd/mist/errors.go
@@ -0,0 +1,56 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/obscuren/qml"
+)
+
+func ErrorWindow(err error) {
+ engine := qml.NewEngine()
+ component, e := engine.LoadString("local", qmlErr)
+ if e != nil {
+ fmt.Println("err:", err)
+ os.Exit(1)
+ }
+
+ win := component.CreateWindow(nil)
+ win.Root().ObjectByName("label").Set("text", err.Error())
+ win.Show()
+ win.Wait()
+}
+
+const qmlErr = `
+import QtQuick 2.0; import QtQuick.Controls 1.0;
+ApplicationWindow {
+ width: 600; height: 150;
+ flags: Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
+ title: "Error"
+ Text {
+ x: parent.width / 2 - this.width / 2;
+ y: parent.height / 2 - this.height / 2;
+ objectName: "label";
+ }
+}
+`
diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go
new file mode 100644
index 000000000..a49e9f6f8
--- /dev/null
+++ b/cmd/mist/gui.go
@@ -0,0 +1,483 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import "C"
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "math/big"
+ "os"
+ "path"
+ "runtime"
+ "sort"
+ "time"
+
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/ui/qt/qwhisper"
+ "github.com/ethereum/go-ethereum/xeth"
+ "github.com/obscuren/qml"
+)
+
+var guilogger = logger.NewLogger("GUI")
+
+type ServEv byte
+
+const (
+ setup ServEv = iota
+ update
+)
+
+type Gui struct {
+ // The main application window
+ win *qml.Window
+ // QML Engine
+ engine *qml.Engine
+ component *qml.Common
+ // The ethereum interface
+ eth *eth.Ethereum
+ serviceEvents chan ServEv
+
+ // The public Ethereum library
+ uiLib *UiLib
+ whisper *qwhisper.Whisper
+
+ txDb *ethdb.LDBDatabase
+
+ open bool
+
+ xeth *xeth.XEth
+
+ Session string
+
+ plugins map[string]plugin
+}
+
+// Create GUI, but doesn't start it
+func NewWindow(ethereum *eth.Ethereum) *Gui {
+ db, err := ethdb.NewLDBDatabase(path.Join(ethereum.DataDir, "tx_database"))
+ if err != nil {
+ panic(err)
+ }
+
+ xeth := xeth.New(ethereum, nil)
+ gui := &Gui{eth: ethereum,
+ txDb: db,
+ xeth: xeth,
+ open: false,
+ plugins: make(map[string]plugin),
+ serviceEvents: make(chan ServEv, 1),
+ }
+ data, _ := ethutil.ReadAllFile(path.Join(ethereum.DataDir, "plugins.json"))
+ json.Unmarshal([]byte(data), &gui.plugins)
+
+ return gui
+}
+
+func (gui *Gui) Start(assetPath string) {
+ defer gui.txDb.Close()
+
+ guilogger.Infoln("Starting GUI")
+
+ go gui.service()
+
+ // Register ethereum functions
+ qml.RegisterTypes("Ethereum", 1, 0, []qml.TypeSpec{{
+ Init: func(p *xeth.Block, obj qml.Object) { p.Number = 0; p.Hash = "" },
+ }, {
+ Init: func(p *xeth.Transaction, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" },
+ }, {
+ Init: func(p *xeth.KeyVal, obj qml.Object) { p.Key = ""; p.Value = "" },
+ }})
+ // Create a new QML engine
+ gui.engine = qml.NewEngine()
+ context := gui.engine.Context()
+ gui.uiLib = NewUiLib(gui.engine, gui.eth, assetPath)
+ gui.whisper = qwhisper.New(gui.eth.Whisper())
+
+ // Expose the eth library and the ui library to QML
+ context.SetVar("gui", gui)
+ context.SetVar("eth", gui.uiLib)
+ context.SetVar("shh", gui.whisper)
+ //clipboard.SetQMLClipboard(context)
+
+ win, err := gui.showWallet(context)
+ if err != nil {
+ guilogger.Errorln("asset not found: you can set an alternative asset path on the command line using option 'asset_path'", err)
+
+ panic(err)
+ }
+
+ gui.open = true
+ win.Show()
+
+ win.Wait()
+ gui.open = false
+}
+
+func (gui *Gui) Stop() {
+ if gui.open {
+ gui.open = false
+ gui.win.Hide()
+ }
+
+ guilogger.Infoln("Stopped")
+}
+
+func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
+ component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/main.qml"))
+ if err != nil {
+ return nil, err
+ }
+
+ gui.createWindow(component)
+
+ return gui.win, nil
+}
+
+func (gui *Gui) GenerateKey() {
+ _, err := gui.eth.AccountManager().NewAccount("hurr")
+ if err != nil {
+ // TODO: UI feedback?
+ }
+}
+
+func (gui *Gui) showKeyImport(context *qml.Context) (*qml.Window, error) {
+ context.SetVar("lib", gui)
+ component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/first_run.qml"))
+ if err != nil {
+ return nil, err
+ }
+ return gui.createWindow(component), nil
+}
+
+func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
+ gui.win = comp.CreateWindow(nil)
+ gui.uiLib.win = gui.win
+
+ return gui.win
+}
+
+func (gui *Gui) setInitialChain(ancientBlocks bool) {
+ sBlk := gui.eth.ChainManager().LastBlockHash()
+ blk := gui.eth.ChainManager().GetBlock(sBlk)
+ for ; blk != nil; blk = gui.eth.ChainManager().GetBlock(sBlk) {
+ sBlk = blk.ParentHash()
+ gui.processBlock(blk, true)
+ }
+}
+
+func (gui *Gui) loadAddressBook() {
+ /*
+ view := gui.getObjectByName("infoView")
+ nameReg := gui.xeth.World().Config().Get("NameReg")
+ if nameReg != nil {
+ it := nameReg.Trie().Iterator()
+ for it.Next() {
+ if it.Key[0] != 0 {
+ view.Call("addAddress", struct{ Name, Address string }{string(it.Key), ethutil.Bytes2Hex(it.Value)})
+ }
+
+ }
+ }
+ */
+}
+
+func (self *Gui) loadMergedMiningOptions() {
+ /*
+ view := self.getObjectByName("mergedMiningModel")
+
+ mergeMining := self.xeth.World().Config().Get("MergeMining")
+ if mergeMining != nil {
+ i := 0
+ it := mergeMining.Trie().Iterator()
+ for it.Next() {
+ view.Call("addMergedMiningOption", struct {
+ Checked bool
+ Name, Address string
+ Id, ItemId int
+ }{false, string(it.Key), ethutil.Bytes2Hex(it.Value), 0, i})
+
+ i++
+
+ }
+ }
+ */
+}
+
+func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
+ var inout string
+ if gui.eth.AccountManager().HasAccount(tx.From()) {
+ inout = "send"
+ } else {
+ inout = "recv"
+ }
+
+ var (
+ ptx = xeth.NewTx(tx)
+ send = ethutil.Bytes2Hex(tx.From())
+ rec = ethutil.Bytes2Hex(tx.To())
+ )
+ ptx.Sender = send
+ ptx.Address = rec
+
+ if window == "post" {
+ //gui.getObjectByName("transactionView").Call("addTx", ptx, inout)
+ } else {
+ gui.getObjectByName("pendingTxView").Call("addTx", ptx, inout)
+ }
+}
+
+func (gui *Gui) readPreviousTransactions() {
+ it := gui.txDb.NewIterator()
+ for it.Next() {
+ tx := types.NewTransactionFromBytes(it.Value())
+
+ gui.insertTransaction("post", tx)
+
+ }
+ it.Release()
+}
+
+func (gui *Gui) processBlock(block *types.Block, initial bool) {
+ name := ethutil.Bytes2Hex(block.Coinbase())
+ b := xeth.NewBlock(block)
+ b.Name = name
+
+ gui.getObjectByName("chainView").Call("addBlock", b, initial)
+}
+
+func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
+ var str string
+ if unconfirmedFunds != nil {
+ pos := "+"
+ if unconfirmedFunds.Cmp(big.NewInt(0)) < 0 {
+ pos = "-"
+ }
+ val := ethutil.CurrencyToString(new(big.Int).Abs(ethutil.BigCopy(unconfirmedFunds)))
+ str = fmt.Sprintf("%v (%s %v)", ethutil.CurrencyToString(amount), pos, val)
+ } else {
+ str = fmt.Sprintf("%v", ethutil.CurrencyToString(amount))
+ }
+
+ gui.win.Root().Call("setWalletValue", str)
+}
+
+func (self *Gui) getObjectByName(objectName string) qml.Object {
+ return self.win.Root().ObjectByName(objectName)
+}
+
+func loadJavascriptAssets(gui *Gui) (jsfiles string) {
+ for _, fn := range []string{"ext/q.js", "ext/eth.js/main.js", "ext/eth.js/qt.js", "ext/setup.js"} {
+ f, err := os.Open(gui.uiLib.AssetPath(fn))
+ if err != nil {
+ fmt.Println(err)
+ continue
+ }
+
+ content, err := ioutil.ReadAll(f)
+ if err != nil {
+ fmt.Println(err)
+ continue
+ }
+ jsfiles += string(content)
+ }
+
+ return
+}
+
+func (gui *Gui) SendCommand(cmd ServEv) {
+ gui.serviceEvents <- cmd
+}
+
+func (gui *Gui) service() {
+ for ev := range gui.serviceEvents {
+ switch ev {
+ case setup:
+ go gui.setup()
+ case update:
+ go gui.update()
+ }
+ }
+}
+
+func (gui *Gui) setup() {
+ for gui.win == nil {
+ time.Sleep(time.Millisecond * 200)
+ }
+
+ for _, plugin := range gui.plugins {
+ guilogger.Infoln("Loading plugin ", plugin.Name)
+ gui.win.Root().Call("addPlugin", plugin.Path, "")
+ }
+
+ go func() {
+ go gui.setInitialChain(false)
+ gui.loadAddressBook()
+ gui.loadMergedMiningOptions()
+ gui.setPeerInfo()
+ }()
+
+ gui.whisper.SetView(gui.getObjectByName("whisperView"))
+
+ gui.SendCommand(update)
+}
+
+// Simple go routine function that updates the list of peers in the GUI
+func (gui *Gui) update() {
+ peerUpdateTicker := time.NewTicker(5 * time.Second)
+ generalUpdateTicker := time.NewTicker(500 * time.Millisecond)
+ statsUpdateTicker := time.NewTicker(5 * time.Second)
+
+ lastBlockLabel := gui.getObjectByName("lastBlockLabel")
+ //miningLabel := gui.getObjectByName("miningLabel")
+
+ events := gui.eth.EventMux().Subscribe(
+ core.ChainEvent{},
+ core.TxPreEvent{},
+ core.TxPostEvent{},
+ )
+
+ defer events.Unsubscribe()
+ for {
+ select {
+ case ev, isopen := <-events.Chan():
+ if !isopen {
+ return
+ }
+ switch ev := ev.(type) {
+ case core.ChainEvent:
+ gui.processBlock(ev.Block, false)
+ case core.TxPreEvent:
+ gui.insertTransaction("pre", ev.Tx)
+
+ case core.TxPostEvent:
+ gui.getObjectByName("pendingTxView").Call("removeTx", xeth.NewTx(ev.Tx))
+ }
+
+ case <-peerUpdateTicker.C:
+ gui.setPeerInfo()
+
+ case <-generalUpdateTicker.C:
+ statusText := "#" + gui.eth.ChainManager().CurrentBlock().Number().String()
+ lastBlockLabel.Set("text", statusText)
+ //miningLabel.Set("text", strconv.FormatInt(gui.uiLib.Miner().HashRate(), 10))
+ case <-statsUpdateTicker.C:
+ gui.setStatsPane()
+ }
+ }
+}
+
+func (gui *Gui) setStatsPane() {
+ var memStats runtime.MemStats
+ runtime.ReadMemStats(&memStats)
+
+ statsPane := gui.getObjectByName("statsPane")
+ statsPane.Set("text", fmt.Sprintf(`###### Mist %s (%s) #######
+
+eth %d (p2p = %d)
+
+CPU: # %d
+Goroutines: # %d
+CGoCalls: # %d
+
+Alloc: %d
+Heap Alloc: %d
+
+CGNext: %x
+NumGC: %d
+`, Version, runtime.Version(),
+ eth.ProtocolVersion, 2,
+ runtime.NumCPU, runtime.NumGoroutine(), runtime.NumCgoCall(),
+ memStats.Alloc, memStats.HeapAlloc,
+ memStats.NextGC, memStats.NumGC,
+ ))
+}
+
+type qmlpeer struct{ Addr, NodeID, Name, Caps string }
+
+type peersByID []*qmlpeer
+
+func (s peersByID) Len() int { return len(s) }
+func (s peersByID) Less(i, j int) bool { return s[i].NodeID < s[j].NodeID }
+func (s peersByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+
+func (gui *Gui) setPeerInfo() {
+ peers := gui.eth.Peers()
+ qpeers := make(peersByID, len(peers))
+ for i, p := range peers {
+ qpeers[i] = &qmlpeer{
+ NodeID: p.ID().String(),
+ Addr: p.RemoteAddr().String(),
+ Name: p.Name(),
+ Caps: fmt.Sprint(p.Caps()),
+ }
+ }
+ // we need to sort the peers because they jump around randomly
+ // otherwise. order returned by eth.Peers is random because they
+ // are taken from a map.
+ sort.Sort(qpeers)
+
+ gui.win.Root().Call("setPeerCounters", fmt.Sprintf("%d / %d", len(peers), gui.eth.MaxPeers()))
+ gui.win.Root().Call("clearPeers")
+ for _, p := range qpeers {
+ gui.win.Root().Call("addPeer", p)
+ }
+}
+
+/*
+func LoadExtension(path string) (uintptr, error) {
+ lib, err := ffi.NewLibrary(path)
+ if err != nil {
+ return 0, err
+ }
+
+ so, err := lib.Fct("sharedObject", ffi.Pointer, nil)
+ if err != nil {
+ return 0, err
+ }
+
+ ptr := so()
+
+ err = lib.Close()
+ if err != nil {
+ return 0, err
+ }
+
+ return ptr.Interface().(uintptr), nil
+}
+*/
+/*
+ vec, errr := LoadExtension("/Users/jeffrey/Desktop/build-libqmltest-Desktop_Qt_5_2_1_clang_64bit-Debug/liblibqmltest_debug.dylib")
+ fmt.Printf("Fetched vec with addr: %#x\n", vec)
+ if errr != nil {
+ fmt.Println(errr)
+ } else {
+ context.SetVar("vec", (unsafe.Pointer)(vec))
+ }
+*/
diff --git a/cmd/mist/html_container.go b/cmd/mist/html_container.go
new file mode 100644
index 000000000..e4ea57b9b
--- /dev/null
+++ b/cmd/mist/html_container.go
@@ -0,0 +1,153 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import (
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "net/url"
+ "os"
+ "path"
+ "path/filepath"
+
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/xeth"
+ "github.com/howeyc/fsnotify"
+ "github.com/obscuren/qml"
+)
+
+type HtmlApplication struct {
+ win *qml.Window
+ webView qml.Object
+ engine *qml.Engine
+ lib *UiLib
+ path string
+ watcher *fsnotify.Watcher
+}
+
+func NewHtmlApplication(path string, lib *UiLib) *HtmlApplication {
+ engine := qml.NewEngine()
+
+ return &HtmlApplication{engine: engine, lib: lib, path: path}
+
+}
+
+func (app *HtmlApplication) Create() error {
+ component, err := app.engine.LoadFile(app.lib.AssetPath("qml/webapp.qml"))
+ if err != nil {
+ return err
+ }
+
+ if filepath.Ext(app.path) == "eth" {
+ return errors.New("Ethereum package not yet supported")
+
+ // TODO
+ //ethutil.OpenPackage(app.path)
+ }
+
+ win := component.CreateWindow(nil)
+ win.Set("url", app.path)
+ webView := win.ObjectByName("webView")
+
+ app.win = win
+ app.webView = webView
+
+ return nil
+}
+
+func (app *HtmlApplication) RootFolder() string {
+ folder, err := url.Parse(app.path)
+ if err != nil {
+ return ""
+ }
+ return path.Dir(ethutil.WindonizePath(folder.RequestURI()))
+}
+func (app *HtmlApplication) RecursiveFolders() []os.FileInfo {
+ files, _ := ioutil.ReadDir(app.RootFolder())
+ var folders []os.FileInfo
+ for _, file := range files {
+ if file.IsDir() {
+ folders = append(folders, file)
+ }
+ }
+ return folders
+}
+
+func (app *HtmlApplication) NewWatcher(quitChan chan bool) {
+ var err error
+
+ app.watcher, err = fsnotify.NewWatcher()
+ if err != nil {
+ guilogger.Infoln("Could not create new auto-reload watcher:", err)
+ return
+ }
+ err = app.watcher.Watch(app.RootFolder())
+ if err != nil {
+ guilogger.Infoln("Could not start auto-reload watcher:", err)
+ return
+ }
+ for _, folder := range app.RecursiveFolders() {
+ fullPath := app.RootFolder() + "/" + folder.Name()
+ app.watcher.Watch(fullPath)
+ }
+
+ go func() {
+ out:
+ for {
+ select {
+ case <-quitChan:
+ app.watcher.Close()
+ break out
+ case <-app.watcher.Event:
+ //guilogger.Debugln("Got event:", ev)
+ app.webView.Call("reload")
+ case err := <-app.watcher.Error:
+ // TODO: Do something here
+ guilogger.Infoln("Watcher error:", err)
+ }
+ }
+ }()
+
+}
+
+func (app *HtmlApplication) Engine() *qml.Engine {
+ return app.engine
+}
+
+func (app *HtmlApplication) Window() *qml.Window {
+ return app.win
+}
+
+func (app *HtmlApplication) NewBlock(block *types.Block) {
+ b := &xeth.Block{Number: int(block.NumberU64()), Hash: ethutil.Bytes2Hex(block.Hash())}
+ app.webView.Call("onNewBlockCb", b)
+}
+
+func (app *HtmlApplication) Destroy() {
+ app.engine.Destroy()
+}
+
+func (app *HtmlApplication) Post(data string, seed int) {
+ fmt.Println("about to call 'post'")
+ app.webView.Call("post", seed, data)
+}
diff --git a/cmd/mist/main.go b/cmd/mist/main.go
new file mode 100644
index 000000000..9a773e33a
--- /dev/null
+++ b/cmd/mist/main.go
@@ -0,0 +1,115 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import (
+ "fmt"
+ "os"
+ "runtime"
+ "time"
+
+ "github.com/codegangsta/cli"
+ "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/ui/qt/webengine"
+ "github.com/obscuren/qml"
+)
+
+const (
+ ClientIdentifier = "Mist"
+ Version = "0.9.0"
+)
+
+var (
+ app = utils.NewApp(Version, "the ether browser")
+ assetPathFlag = cli.StringFlag{
+ Name: "asset_path",
+ Usage: "absolute path to GUI assets directory",
+ Value: ethutil.DefaultAssetPath(),
+ }
+)
+
+func init() {
+ app.Action = run
+ app.Flags = []cli.Flag{
+ assetPathFlag,
+
+ utils.BootnodesFlag,
+ utils.DataDirFlag,
+ utils.ListenPortFlag,
+ utils.LogFileFlag,
+ utils.LogLevelFlag,
+ utils.MaxPeersFlag,
+ utils.MinerThreadsFlag,
+ utils.NATFlag,
+ utils.NodeKeyFileFlag,
+ utils.RPCListenAddrFlag,
+ utils.RPCPortFlag,
+ }
+}
+
+func main() {
+ runtime.GOMAXPROCS(runtime.NumCPU())
+
+ // This is a bit of a cheat, but ey!
+ os.Setenv("QTWEBKIT_INSPECTOR_SERVER", "127.0.0.1:99999")
+
+ var interrupted = false
+ utils.RegisterInterrupt(func(os.Signal) {
+ interrupted = true
+ })
+ utils.HandleInterrupt()
+
+ if err := app.Run(os.Args); err != nil {
+ fmt.Fprintln(os.Stderr, "Error: ", err)
+ }
+
+ // we need to run the interrupt callbacks in case gui is closed
+ // this skips if we got here by actual interrupt stopping the GUI
+ if !interrupted {
+ utils.RunInterruptCallbacks(os.Interrupt)
+ }
+ logger.Flush()
+}
+
+func run(ctx *cli.Context) {
+ tstart := time.Now()
+
+ // TODO: show qml popup instead of exiting if initialization fails.
+ ethereum, err := utils.GetEthereum(ClientIdentifier, Version, ctx)
+ if err != nil {
+ utils.Fatalf("%v", err)
+ }
+ utils.StartRPC(ethereum, ctx)
+ go utils.StartEthereum(ethereum)
+ fmt.Println("initializing eth stack took", time.Since(tstart))
+
+ // Open the window
+ qml.Run(func() error {
+ webengine.Initialize()
+ gui := NewWindow(ethereum)
+ utils.RegisterInterrupt(func(os.Signal) { gui.Stop() })
+ // gui blocks the main thread
+ gui.Start(ctx.GlobalString(assetPathFlag.Name))
+ return nil
+ })
+}
diff --git a/cmd/mist/qml_container.go b/cmd/mist/qml_container.go
new file mode 100644
index 000000000..16a055bc0
--- /dev/null
+++ b/cmd/mist/qml_container.go
@@ -0,0 +1,83 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+
+package main
+
+import (
+ "runtime"
+
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/xeth"
+ "github.com/obscuren/qml"
+)
+
+type QmlApplication struct {
+ win *qml.Window
+ engine *qml.Engine
+ lib *UiLib
+ path string
+}
+
+func NewQmlApplication(path string, lib *UiLib) *QmlApplication {
+ engine := qml.NewEngine()
+ return &QmlApplication{engine: engine, path: path, lib: lib}
+}
+
+func (app *QmlApplication) Create() error {
+ path := string(app.path)
+
+ // For some reason for windows we get /c:/path/to/something, windows doesn't like the first slash but is fine with the others so we are removing it
+ if app.path[0] == '/' && runtime.GOOS == "windows" {
+ path = app.path[1:]
+ }
+
+ component, err := app.engine.LoadFile(path)
+ if err != nil {
+ guilogger.Warnln(err)
+ }
+ app.win = component.CreateWindow(nil)
+
+ return nil
+}
+
+func (app *QmlApplication) Destroy() {
+ app.engine.Destroy()
+}
+
+func (app *QmlApplication) NewWatcher(quitChan chan bool) {
+}
+
+// Events
+func (app *QmlApplication) NewBlock(block *types.Block) {
+ pblock := &xeth.Block{Number: int(block.NumberU64()), Hash: ethutil.Bytes2Hex(block.Hash())}
+ app.win.Call("onNewBlockCb", pblock)
+}
+
+// Getters
+func (app *QmlApplication) Engine() *qml.Engine {
+ return app.engine
+}
+func (app *QmlApplication) Window() *qml.Window {
+ return app.win
+}
+
+func (app *QmlApplication) Post(data string, s int) {}
diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go
new file mode 100644
index 000000000..cc213b49a
--- /dev/null
+++ b/cmd/mist/ui_lib.go
@@ -0,0 +1,300 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ */
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "path"
+
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/event/filter"
+ "github.com/ethereum/go-ethereum/javascript"
+ "github.com/ethereum/go-ethereum/xeth"
+ "github.com/obscuren/qml"
+)
+
+type memAddr struct {
+ Num string
+ Value string
+}
+
+// UI Library that has some basic functionality exposed
+type UiLib struct {
+ *xeth.XEth
+ engine *qml.Engine
+ eth *eth.Ethereum
+ connected bool
+ assetPath string
+ // The main application window
+ win *qml.Window
+
+ jsEngine *javascript.JSRE
+
+ filterCallbacks map[int][]int
+ filterManager *filter.FilterManager
+}
+
+func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
+ x := xeth.New(eth, nil)
+ lib := &UiLib{XEth: x, engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(x), filterCallbacks: make(map[int][]int)} //, filters: make(map[int]*xeth.JSFilter)}
+ lib.filterManager = filter.NewFilterManager(eth.EventMux())
+ go lib.filterManager.Start()
+
+ return lib
+}
+
+func (self *UiLib) Notef(args []interface{}) {
+ guilogger.Infoln(args...)
+}
+
+func (self *UiLib) ImportTx(rlpTx string) {
+ tx := types.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx))
+ err := self.eth.TxPool().Add(tx)
+ if err != nil {
+ guilogger.Infoln("import tx failed ", err)
+ }
+}
+
+func (self *UiLib) EvalJavascriptFile(path string) {
+ self.jsEngine.LoadExtFile(path[7:])
+}
+
+func (self *UiLib) EvalJavascriptString(str string) string {
+ value, err := self.jsEngine.Run(str)
+ if err != nil {
+ return err.Error()
+ }
+
+ return fmt.Sprintf("%v", value)
+}
+
+func (ui *UiLib) Muted(content string) {
+ component, err := ui.engine.LoadFile(ui.AssetPath("qml/muted.qml"))
+ if err != nil {
+ guilogger.Debugln(err)
+
+ return
+ }
+ win := component.CreateWindow(nil)
+ go func() {
+ path := "file://" + ui.AssetPath("muted/index.html")
+ win.Set("url", path)
+
+ win.Show()
+ win.Wait()
+ }()
+}
+
+func (ui *UiLib) Connect(button qml.Object) {
+ if !ui.connected {
+ ui.eth.Start()
+ ui.connected = true
+ button.Set("enabled", false)
+ }
+}
+
+func (ui *UiLib) ConnectToPeer(nodeURL string) {
+ if err := ui.eth.SuggestPeer(nodeURL); err != nil {
+ guilogger.Infoln("SuggestPeer error: " + err.Error())
+ }
+}
+
+func (ui *UiLib) AssetPath(p string) string {
+ return path.Join(ui.assetPath, p)
+}
+
+func (self *UiLib) Transact(params map[string]interface{}) (string, error) {
+ object := mapToTxParams(params)
+
+ return self.XEth.Transact(
+ object["from"],
+ object["to"],
+ object["value"],
+ object["gas"],
+ object["gasPrice"],
+ object["data"],
+ )
+}
+
+func (self *UiLib) Compile(code string) (string, error) {
+ bcode, err := ethutil.Compile(code, false)
+ if err != nil {
+ return err.Error(), err
+ }
+
+ return ethutil.Bytes2Hex(bcode), err
+}
+
+func (self *UiLib) Call(params map[string]interface{}) (string, error) {
+ object := mapToTxParams(params)
+
+ return self.XEth.Call(
+ object["from"],
+ object["to"],
+ object["value"],
+ object["gas"],
+ object["gasPrice"],
+ object["data"],
+ )
+}
+
+func (self *UiLib) AddLocalTransaction(to, data, gas, gasPrice, value string) int {
+ return 0
+ /*
+ return self.miner.AddLocalTx(&miner.LocalTx{
+ To: ethutil.Hex2Bytes(to),
+ Data: ethutil.Hex2Bytes(data),
+ Gas: gas,
+ GasPrice: gasPrice,
+ Value: value,
+ }) - 1
+ */
+}
+
+func (self *UiLib) RemoveLocalTransaction(id int) {
+ //self.miner.RemoveLocalTx(id)
+}
+
+func (self *UiLib) ToggleMining() bool {
+ if !self.eth.IsMining() {
+ err := self.eth.StartMining()
+ return err == nil
+ } else {
+ self.eth.StopMining()
+ return false
+ }
+}
+
+func (self *UiLib) ToHex(data string) string {
+ return "0x" + ethutil.Bytes2Hex([]byte(data))
+}
+
+func (self *UiLib) ToAscii(data string) string {
+ start := 0
+ if len(data) > 1 && data[0:2] == "0x" {
+ start = 2
+ }
+ return string(ethutil.Hex2Bytes(data[start:]))
+}
+
+/// Ethereum filter methods
+func (self *UiLib) NewFilter(object map[string]interface{}, view *qml.Common) (id int) {
+ /* TODO remove me
+ filter := qt.NewFilterFromMap(object, self.eth)
+ filter.MessageCallback = func(messages state.Messages) {
+ view.Call("messages", xeth.ToMessages(messages), id)
+ }
+ id = self.filterManager.InstallFilter(filter)
+ return id
+ */
+ return 0
+}
+
+func (self *UiLib) NewFilterString(typ string, view *qml.Common) (id int) {
+ /* TODO remove me
+ filter := core.NewFilter(self.eth)
+ filter.BlockCallback = func(block *types.Block) {
+ view.Call("messages", "{}", id)
+ }
+ id = self.filterManager.InstallFilter(filter)
+ return id
+ */
+ return 0
+}
+
+func (self *UiLib) Messages(id int) *ethutil.List {
+ /* TODO remove me
+ filter := self.filterManager.GetFilter(id)
+ if filter != nil {
+ messages := xeth.ToMessages(filter.Find())
+
+ return messages
+ }
+ */
+
+ return ethutil.EmptyList()
+}
+
+func (self *UiLib) ReadFile(p string) string {
+ content, err := ioutil.ReadFile(self.AssetPath(path.Join("ext", p)))
+ if err != nil {
+ guilogger.Infoln("error reading file", p, ":", err)
+ }
+ return string(content)
+}
+
+func (self *UiLib) UninstallFilter(id int) {
+ self.filterManager.UninstallFilter(id)
+}
+
+func mapToTxParams(object map[string]interface{}) map[string]string {
+ // Default values
+ if object["from"] == nil {
+ object["from"] = ""
+ }
+ if object["to"] == nil {
+ object["to"] = ""
+ }
+ if object["value"] == nil {
+ object["value"] = ""
+ }
+ if object["gas"] == nil {
+ object["gas"] = ""
+ }
+ if object["gasPrice"] == nil {
+ object["gasPrice"] = ""
+ }
+
+ var dataStr string
+ var data []string
+ if list, ok := object["data"].(*qml.List); ok {
+ list.Convert(&data)
+ } else if str, ok := object["data"].(string); ok {
+ data = []string{str}
+ }
+
+ for _, str := range data {
+ if ethutil.IsHex(str) {
+ str = str[2:]
+
+ if len(str) != 64 {
+ str = ethutil.LeftPadString(str, 64)
+ }
+ } else {
+ str = ethutil.Bytes2Hex(ethutil.LeftPadBytes(ethutil.Big(str).Bytes(), 32))
+ }
+
+ dataStr += str
+ }
+ object["data"] = dataStr
+
+ conv := make(map[string]string)
+ for key, value := range object {
+ if v, ok := value.(string); ok {
+ conv[key] = v
+ }
+ }
+
+ return conv
+}
diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go
new file mode 100644
index 000000000..8567dcff8
--- /dev/null
+++ b/cmd/rlpdump/main.go
@@ -0,0 +1,148 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Felix Lange <felix@ethdev.com>
+ */
+
+// rlpdump is a pretty-printer for RLP data.
+package main
+
+import (
+ "bytes"
+ "encoding/hex"
+ "flag"
+ "fmt"
+ "io"
+ "os"
+ "strings"
+
+ "github.com/ethereum/go-ethereum/rlp"
+)
+
+var (
+ hexMode = flag.String("hex", "", "dump given hex data")
+ noASCII = flag.Bool("noascii", false, "don't print ASCII strings readably")
+)
+
+func init() {
+ flag.Usage = func() {
+ fmt.Fprintln(os.Stderr, "Usage:", os.Args[0], "[-noascii] [-hex <data>] [filename]")
+ flag.PrintDefaults()
+ fmt.Fprintln(os.Stderr, `
+Dumps RLP data from the given file in readable form.
+If the filename is omitted, data is read from stdin.`)
+ }
+}
+
+func main() {
+ flag.Parse()
+
+ var r io.Reader
+ switch {
+ case *hexMode != "":
+ data, err := hex.DecodeString(*hexMode)
+ if err != nil {
+ die(err)
+ }
+ r = bytes.NewReader(data)
+
+ case flag.NArg() == 0:
+ r = os.Stdin
+
+ case flag.NArg() == 1:
+ fd, err := os.Open(flag.Arg(0))
+ if err != nil {
+ die(err)
+ }
+ defer fd.Close()
+ r = fd
+
+ default:
+ fmt.Fprintln(os.Stderr, "Error: too many arguments")
+ flag.Usage()
+ os.Exit(2)
+ }
+
+ s := rlp.NewStream(r)
+ for {
+ if err := dump(s, 0); err != nil {
+ if err != io.EOF {
+ die(err)
+ }
+ break
+ }
+ fmt.Println()
+ }
+}
+
+func dump(s *rlp.Stream, depth int) error {
+ kind, size, err := s.Kind()
+ if err != nil {
+ return err
+ }
+ switch kind {
+ case rlp.Byte, rlp.String:
+ str, err := s.Bytes()
+ if err != nil {
+ return err
+ }
+ if len(str) == 0 || !*noASCII && isASCII(str) {
+ fmt.Printf("%s%q", ws(depth), str)
+ } else {
+ fmt.Printf("%s%x", ws(depth), str)
+ }
+ case rlp.List:
+ s.List()
+ defer s.ListEnd()
+ if size == 0 {
+ fmt.Print(ws(depth) + "[]")
+ } else {
+ fmt.Println(ws(depth) + "[")
+ for i := 0; ; i++ {
+ if i > 0 {
+ fmt.Print(",\n")
+ }
+ if err := dump(s, depth+1); err == rlp.EOL {
+ break
+ } else if err != nil {
+ return err
+ }
+ }
+ fmt.Print(ws(depth) + "]")
+ }
+ }
+ return nil
+}
+
+func isASCII(b []byte) bool {
+ for _, c := range b {
+ if c < 32 || c > 126 {
+ return false
+ }
+ }
+ return true
+}
+
+func ws(n int) string {
+ return strings.Repeat(" ", n)
+}
+
+func die(args ...interface{}) {
+ fmt.Fprintln(os.Stderr, args...)
+ os.Exit(1)
+}
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
new file mode 100644
index 000000000..6b99b841f
--- /dev/null
+++ b/cmd/utils/cmd.go
@@ -0,0 +1,180 @@
+/*
+ This file is part of go-ethereum
+
+ go-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ go-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @authors
+ * Jeffrey Wilcke <i@jev.io>
+ * Viktor Tron <viktor@ethdev.com>
+ */
+package utils
+
+import (
+ "fmt"
+ "os"
+ "os/signal"
+ "regexp"
+
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/rlp"
+)
+
+var clilogger = logger.NewLogger("CLI")
+var interruptCallbacks = []func(os.Signal){}
+
+// Register interrupt handlers callbacks
+func RegisterInterrupt(cb func(os.Signal)) {
+ interruptCallbacks = append(interruptCallbacks, cb)
+}
+
+// go routine that call interrupt handlers in order of registering
+func HandleInterrupt() {
+ c := make(chan os.Signal, 1)
+ go func() {
+ signal.Notify(c, os.Interrupt)
+ for sig := range c {
+ clilogger.Errorf("Shutting down (%v) ... \n", sig)
+ RunInterruptCallbacks(sig)
+ }
+ }()
+}
+
+func RunInterruptCallbacks(sig os.Signal) {
+ for _, cb := range interruptCallbacks {
+ cb(sig)
+ }
+}
+
+func openLogFile(Datadir string, filename string) *os.File {
+ path := ethutil.AbsolutePath(Datadir, filename)
+ file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
+ if err != nil {
+ panic(fmt.Sprintf("error opening log file '%s': %v", filename, err))
+ }
+ return file
+}
+
+func confirm(message string) bool {
+ fmt.Println(message, "Are you sure? (y/n)")
+ var r string
+ fmt.Scanln(&r)
+ for ; ; fmt.Scanln(&r) {
+ if r == "n" || r == "y" {
+ break
+ } else {
+ fmt.Printf("Yes or no? (%s)", r)
+ }
+ }
+ return r == "y"
+}
+
+func initDataDir(Datadir string) {
+ _, err := os.Stat(Datadir)
+ if err != nil {
+ if os.IsNotExist(err) {
+ fmt.Printf("Data directory '%s' doesn't exist, creating it\n", Datadir)
+ os.Mkdir(Datadir, 0777)
+ }
+ }
+}
+
+func exit(err error) {
+ status := 0
+ if err != nil {
+ fmt.Fprintln(os.Stderr, "Fatal:", err)
+ status = 1
+ }
+ logger.Flush()
+ os.Exit(status)
+}
+
+// Fatalf formats a message to standard output and exits the program.
+func Fatalf(format string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, "Fatal: "+format+"\n", args...)
+ logger.Flush()
+ os.Exit(1)
+}
+
+func StartEthereum(ethereum *eth.Ethereum) {
+ clilogger.Infoln("Starting ", ethereum.Name())
+ if err := ethereum.Start(); err != nil {
+ exit(err)
+ }
+ RegisterInterrupt(func(sig os.Signal) {
+ ethereum.Stop()
+ logger.Flush()
+ })
+}
+
+func StartEthereumForTest(ethereum *eth.Ethereum) {
+ clilogger.Infoln("Starting ", ethereum.Name())
+ ethereum.StartForTest()
+ RegisterInterrupt(func(sig os.Signal) {
+ ethereum.Stop()
+ logger.Flush()
+ })
+}
+
+func FormatTransactionData(data string) []byte {
+ d := ethutil.StringToByteFunc(data, func(s string) (ret []byte) {
+ slice := regexp.MustCompile("\\n|\\s").Split(s, 1000000000)
+ for _, dataItem := range slice {
+ d := ethutil.FormatData(dataItem)
+ ret = append(ret, d...)
+ }
+ return
+ })
+
+ return d
+}
+
+func ImportChain(chainmgr *core.ChainManager, fn string) error {
+ fmt.Printf("importing blockchain '%s'\n", fn)
+ fh, err := os.OpenFile(fn, os.O_RDONLY, os.ModePerm)
+ if err != nil {
+ return err
+ }
+ defer fh.Close()
+
+ var blocks types.Blocks
+ if err := rlp.Decode(fh, &blocks); err != nil {
+ return err
+ }
+
+ chainmgr.Reset()
+ if err := chainmgr.InsertChain(blocks); err != nil {
+ return err
+ }
+ fmt.Printf("imported %d blocks\n", len(blocks))
+
+ return nil
+}
+
+func ExportChain(chainmgr *core.ChainManager, fn string) error {
+ fmt.Printf("exporting blockchain '%s'\n", fn)
+
+ data := chainmgr.Export()
+
+ if err := ethutil.WriteFile(fn, data); err != nil {
+ return err
+ }
+ fmt.Printf("exported blockchain\n")
+
+ return nil
+}
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
new file mode 100644
index 000000000..990fb08e0
--- /dev/null
+++ b/cmd/utils/flags.go
@@ -0,0 +1,249 @@
+package utils
+
+import (
+ "crypto/ecdsa"
+ "fmt"
+ "net"
+ "net/http"
+ "os"
+ "path"
+ "runtime"
+
+ "github.com/codegangsta/cli"
+ "github.com/ethereum/go-ethereum/accounts"
+ "github.com/ethereum/go-ethereum/core"
+ "github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/event"
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/p2p/nat"
+ "github.com/ethereum/go-ethereum/rpc"
+ "github.com/ethereum/go-ethereum/xeth"
+)
+
+func init() {
+ cli.AppHelpTemplate = `{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
+
+VERSION:
+ {{.Version}}
+
+COMMANDS:
+ {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
+ {{end}}{{if .Flags}}
+GLOBAL OPTIONS:
+ {{range .Flags}}{{.}}
+ {{end}}{{end}}
+`
+
+ cli.CommandHelpTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...]
+{{if .Description}}{{.Description}}
+{{end}}{{if .Subcommands}}
+SUBCOMMANDS:
+ {{range .Subcommands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
+ {{end}}{{end}}{{if .Flags}}
+OPTIONS:
+ {{range .Flags}}{{.}}
+ {{end}}{{end}}
+`
+}
+
+// NewApp creates an app with sane defaults.
+func NewApp(version, usage string) *cli.App {
+ app := cli.NewApp()
+ app.Name = path.Base(os.Args[0])
+ app.Author = ""
+ app.Authors = nil
+ app.Email = ""
+ app.Version = version
+ app.Usage = usage
+ return app
+}
+
+// These are all the command line flags we support.
+// If you add to this list, please remember to include the
+// flag in the appropriate command definition.
+//
+// The flags are defined here so their names and help texts
+// are the same for all commands.
+
+var (
+ // General settings
+ /*
+ VMTypeFlag = cli.IntFlag{
+ Name: "vm",
+ Usage: "Virtual Machine type: 0 is standard VM, 1 is debug VM",
+ }
+ */
+ UnlockedAccountFlag = cli.StringFlag{
+ Name: "unlock",
+ Usage: "Unlock a given account untill this programs exits (address:password)",
+ }
+ VMDebugFlag = cli.BoolFlag{
+ Name: "vmdebug",
+ Usage: "Virtual Machine debug output",
+ }
+ DataDirFlag = cli.StringFlag{
+ Name: "datadir",
+ Usage: "Data directory to be used",
+ Value: ethutil.DefaultDataDir(),
+ }
+ MinerThreadsFlag = cli.IntFlag{
+ Name: "minerthreads",
+ Usage: "Number of miner threads",
+ Value: runtime.NumCPU(),
+ }
+ MiningEnabledFlag = cli.BoolFlag{
+ Name: "mine",
+ Usage: "Enable mining",
+ }
+ UnencryptedKeysFlag = cli.BoolFlag{
+ Name: "unencrypted-keys",
+ Usage: "disable private key disk encryption (for testing)",
+ }
+
+ LogFileFlag = cli.StringFlag{
+ Name: "logfile",
+ Usage: "Send log output to a file",
+ }
+ LogLevelFlag = cli.IntFlag{
+ Name: "loglevel",
+ Usage: "0-5 (silent, error, warn, info, debug, debug detail)",
+ Value: int(logger.InfoLevel),
+ }
+ LogFormatFlag = cli.StringFlag{
+ Name: "logformat",
+ Usage: `"std" or "raw"`,
+ Value: "std",
+ }
+
+ // RPC settings
+ RPCEnabledFlag = cli.BoolFlag{
+ Name: "rpc",
+ Usage: "Whether RPC server is enabled",
+ }
+ RPCListenAddrFlag = cli.StringFlag{
+ Name: "rpcaddr",
+ Usage: "Listening address for the JSON-RPC server",
+ Value: "127.0.0.1",
+ }
+ RPCPortFlag = cli.IntFlag{
+ Name: "rpcport",
+ Usage: "Port on which the JSON-RPC server should listen",
+ Value: 8545,
+ }
+
+ // Network Settings
+ MaxPeersFlag = cli.IntFlag{
+ Name: "maxpeers",
+ Usage: "Maximum number of network peers",
+ Value: 16,
+ }
+ ListenPortFlag = cli.IntFlag{
+ Name: "port",
+ Usage: "Network listening port",
+ Value: 30303,
+ }
+ BootnodesFlag = cli.StringFlag{
+ Name: "bootnodes",
+ Usage: "Space-separated enode URLs for discovery bootstrap",
+ Value: "",
+ }
+ NodeKeyFileFlag = cli.StringFlag{
+ Name: "nodekey",
+ Usage: "P2P node key file",
+ }
+ NodeKeyHexFlag = cli.StringFlag{
+ Name: "nodekeyhex",
+ Usage: "P2P node key as hex (for testing)",
+ }
+ NATFlag = cli.StringFlag{
+ Name: "nat",
+ Usage: "Port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
+ Value: "any",
+ }
+)
+
+func GetNAT(ctx *cli.Context) nat.Interface {
+ natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
+ if err != nil {
+ Fatalf("Option %s: %v", NATFlag.Name, err)
+ }
+ return natif
+}
+
+func GetNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey) {
+ hex, file := ctx.GlobalString(NodeKeyHexFlag.Name), ctx.GlobalString(NodeKeyFileFlag.Name)
+ var err error
+ switch {
+ case file != "" && hex != "":
+ Fatalf("Options %q and %q are mutually exclusive", NodeKeyFileFlag.Name, NodeKeyHexFlag.Name)
+ case file != "":
+ if key, err = crypto.LoadECDSA(file); err != nil {
+ Fatalf("Option %q: %v", NodeKeyFileFlag.Name, err)
+ }
+ case hex != "":
+ if key, err = crypto.HexToECDSA(hex); err != nil {
+ Fatalf("Option %q: %v", NodeKeyHexFlag.Name, err)
+ }
+ }
+ return key
+}
+
+func GetEthereum(clientID, version string, ctx *cli.Context) (*eth.Ethereum, error) {
+ return eth.New(&eth.Config{
+ Name: ethutil.MakeName(clientID, version),
+ DataDir: ctx.GlobalString(DataDirFlag.Name),
+ LogFile: ctx.GlobalString(LogFileFlag.Name),
+ LogLevel: ctx.GlobalInt(LogLevelFlag.Name),
+ LogFormat: ctx.GlobalString(LogFormatFlag.Name),
+ MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
+ AccountManager: GetAccountManager(ctx),
+ VmDebug: ctx.GlobalBool(VMDebugFlag.Name),
+ MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
+ Port: ctx.GlobalString(ListenPortFlag.Name),
+ NAT: GetNAT(ctx),
+ NodeKey: GetNodeKey(ctx),
+ Shh: true,
+ Dial: true,
+ BootNodes: ctx.GlobalString(BootnodesFlag.Name),
+ })
+}
+
+func GetChain(ctx *cli.Context) (*core.ChainManager, ethutil.Database, ethutil.Database) {
+ dataDir := ctx.GlobalString(DataDirFlag.Name)
+ blockDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "blockchain"))
+ if err != nil {
+ Fatalf("Could not open database: %v", err)
+ }
+
+ stateDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "state"))
+ if err != nil {
+ Fatalf("Could not open database: %v", err)
+ }
+ return core.NewChainManager(blockDb, stateDb, new(event.TypeMux)), blockDb, stateDb
+}
+
+func GetAccountManager(ctx *cli.Context) *accounts.Manager {
+ dataDir := ctx.GlobalString(DataDirFlag.Name)
+ var ks crypto.KeyStore2
+ if ctx.GlobalBool(UnencryptedKeysFlag.Name) {
+ ks = crypto.NewKeyStorePlain(path.Join(dataDir, "plainkeys"))
+ } else {
+ ks = crypto.NewKeyStorePassphrase(path.Join(dataDir, "keys"))
+ }
+ return accounts.NewManager(ks)
+}
+
+func StartRPC(eth *eth.Ethereum, ctx *cli.Context) {
+ addr := ctx.GlobalString(RPCListenAddrFlag.Name)
+ port := ctx.GlobalInt(RPCPortFlag.Name)
+ dataDir := ctx.GlobalString(DataDirFlag.Name)
+
+ l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", addr, port))
+ if err != nil {
+ Fatalf("Can't listen on %s:%d: %v", addr, port, err)
+ }
+ go http.Serve(l, rpc.JSONRPC(xeth.New(eth, nil), dataDir))
+}