├── pkg
├── pod.go
├── console.go
├── options.go
├── fun.go
├── terminal.go
└── ssh.go
├── .gitignore
├── docs
└── images
│ ├── demo.png
│ └── webssh.png
├── main.go
├── README.md
├── api
└── websocket.go
├── ui
├── static
│ ├── css
│ │ ├── xterm.min.css
│ │ └── xterm.css
│ └── js
│ │ ├── xterm-addon-fit.js
│ │ ├── xterm-addon-fit.js.map
│ │ └── xterm.min.js
└── index.html
├── go.mod
└── middlewares
└── cors.go
/pkg/pod.go:
--------------------------------------------------------------------------------
1 | package pkg
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | .idea/
3 | go.sum
--------------------------------------------------------------------------------
/pkg/console.go:
--------------------------------------------------------------------------------
1 | package pkg
2 |
--------------------------------------------------------------------------------
/docs/images/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/go-webssh/demo/HEAD/docs/images/demo.png
--------------------------------------------------------------------------------
/docs/images/webssh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/go-webssh/demo/HEAD/docs/images/webssh.png
--------------------------------------------------------------------------------
/pkg/options.go:
--------------------------------------------------------------------------------
1 | package pkg
2 |
3 | type Options struct {
4 | Addr string `json:"addr"`
5 | User string `json:"user"`
6 | Password string `json:"password"`
7 | Cols int `json:"cols"`
8 | Rows int `json:"rows"`
9 | }
10 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gin-gonic/gin"
5 | "github.com/go-webssh/demo/api"
6 | "github.com/go-webssh/demo/middlewares"
7 | "net/http"
8 | )
9 |
10 | func main() {
11 | r := gin.Default()
12 | r.Use(middlewares.Cors())
13 | r.LoadHTMLFiles("ui/index.html")
14 | r.Static("/static", "./ui/static")
15 | r.GET("/", func(c *gin.Context) {
16 | c.HTML(http.StatusOK, "index.html", gin.H{
17 | "title": "demo",
18 | })
19 | })
20 | r.GET("/ws", api.Websocket)
21 | _ = r.Run()
22 | }
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 介绍
2 | 一个简单的web应用程序demo,用作连接到ssh服务器的ssh客户端。它是用go+xterm.js编写的。
3 |
4 | ## 模块
5 | 模块交互图
6 | 
7 | ### 前端ui
8 | 使用xterm.js实现 demo版本只用了简单的html,达到效果就OK
9 |
10 | 前端有个FitAddon插件,在html版本上用了,后面还是用vue+xterm.js实现前端吧。
11 | ### 后端
12 | 从交互图上可以看出,项目有两大功能,一个是ssh交互,一个是回放。在ssh通讯的过程中,交互的数据会被保存下来,这一步要录屏。
13 | #### websocket
14 | 前端ui与ssh服务器通讯的桥梁,
15 | #### terminal
16 | 封装各种shell的控制台。包含本地shell、远程ssh和k8s中pod的shell
17 | #### replay
18 | 包含录屏与回放两种功能。
19 | ## SSH服务器
20 | 本demo提供了这个模拟ssh服务的默认参数,开箱即用。
21 | ```bash
22 | docker run -d -p 222:22 --rm bimg/alpine-ssh
23 | ```
24 | ssh-server项目地址:https://github.com/basicimage/alpine-ssh
25 | ## 运行
26 | ```bash
27 | go run main.go
28 | ```
29 | 打开 http://localhost:8080 即可查看效果
30 | ## 效果
31 | 
--------------------------------------------------------------------------------
/pkg/fun.go:
--------------------------------------------------------------------------------
1 | package pkg
2 |
3 | import (
4 | "github.com/gin-gonic/gin"
5 | "github.com/gorilla/websocket"
6 | "github.com/sirupsen/logrus"
7 | "time"
8 | )
9 |
10 | func JsonError(c *gin.Context, msg interface{}) {
11 | c.AbortWithStatusJSON(200, gin.H{"ok": false, "msg": msg})
12 | }
13 |
14 | func HandleError(c *gin.Context, err error) bool {
15 | if err != nil {
16 | //logrus.WithError(err).Error("gin context http handler error")
17 | JsonError(c, err.Error())
18 | return true
19 | }
20 | return false
21 | }
22 |
23 | func WsHandleError(ws *websocket.Conn, err error) bool {
24 | if err != nil {
25 | logrus.WithError(err).Error("handler ws ERROR:")
26 | dt := time.Now().Add(time.Second)
27 | if err := ws.WriteControl(websocket.CloseMessage, []byte(err.Error()), dt); err != nil {
28 | logrus.WithError(err).Error("websocket writes control message failed:")
29 | }
30 | return true
31 | }
32 | return false
33 | }
34 |
--------------------------------------------------------------------------------
/api/websocket.go:
--------------------------------------------------------------------------------
1 | package api
2 |
3 | import (
4 | "github.com/gin-gonic/gin"
5 | "github.com/go-webssh/demo/pkg"
6 | "github.com/gorilla/websocket"
7 | "github.com/sirupsen/logrus"
8 | "net/http"
9 | "strconv"
10 | )
11 |
12 | var upGrader = websocket.Upgrader{
13 | ReadBufferSize: 1024,
14 | WriteBufferSize: 1024 * 1024 * 10,
15 | CheckOrigin: func(r *http.Request) bool {
16 | return true
17 | },
18 | }
19 |
20 | func Websocket(c *gin.Context) {
21 | wsConn, err := upGrader.Upgrade(c.Writer, c.Request, nil)
22 | if pkg.HandleError(c, err) {
23 | return
24 | }
25 | defer wsConn.Close()
26 | cols, err := strconv.Atoi(c.DefaultQuery("cols", "180"))
27 | if pkg.WsHandleError(wsConn, err) {
28 | return
29 | }
30 | rows, err := strconv.Atoi(c.DefaultQuery("rows", "38"))
31 | if pkg.WsHandleError(wsConn, err) {
32 | return
33 | }
34 | address := c.DefaultQuery("address", "127.0.0.1:222")
35 | user := c.DefaultQuery("user", "root")
36 | password := c.DefaultQuery("password", "123456")
37 | logrus.Infof("cols:%d rows:%d address:%s user:%s password:%s", cols, rows, address, user, password)
38 | ter := pkg.NewTerminal(wsConn, pkg.Options{
39 | Addr: address,
40 | User: user,
41 | Password: password,
42 | Cols: cols,
43 | Rows: rows,
44 | })
45 | ter.Run()
46 | }
47 |
--------------------------------------------------------------------------------
/pkg/terminal.go:
--------------------------------------------------------------------------------
1 | package pkg
2 |
3 | import (
4 | "bytes"
5 | "context"
6 | "github.com/gorilla/websocket"
7 | "github.com/sirupsen/logrus"
8 | "golang.org/x/crypto/ssh"
9 | "os"
10 | )
11 |
12 | type Terminal struct {
13 | opts Options
14 | ip string
15 | ws *websocket.Conn
16 | stdin *os.File
17 | stdinr *os.File
18 | conn *ssh.Client
19 | session *SshConn
20 | inited int32
21 | cancelFn context.CancelFunc
22 | }
23 |
24 | func NewTerminal(ws *websocket.Conn, opts Options) *Terminal {
25 | return &Terminal{opts: opts, ws: ws}
26 | }
27 |
28 | func (t *Terminal) Run() {
29 | var err error
30 | t.conn, err = NewSshClient(t.opts.Addr, t.opts.User, t.opts.Password)
31 | if WsHandleError(t.ws, err) {
32 | return
33 | }
34 | defer func() {
35 | t.conn.Close()
36 | }()
37 | //startTime := time.Now()
38 | t.session, err = NewSshConn(t.opts.Cols, t.opts.Rows, t.conn)
39 |
40 | if WsHandleError(t.ws, err) {
41 | return
42 | }
43 | defer func() {
44 | t.session.Close()
45 | }()
46 |
47 | quitChan := make(chan bool, 3)
48 |
49 | var logBuff = new(bytes.Buffer)
50 |
51 | go t.session.ReceiveWsMsg(t.ws, logBuff, quitChan)
52 | go t.session.SendComboOutput(t.ws, quitChan)
53 | go t.session.SessionWait(quitChan)
54 |
55 | <-quitChan
56 | logrus.Info("websocket finished")
57 | }
58 |
--------------------------------------------------------------------------------
/ui/static/css/xterm.min.css:
--------------------------------------------------------------------------------
1 | .xterm{font-family:courier-new,courier,monospace;font-feature-settings:"liga" 0;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:0}.xterm .xterm-helpers{position:absolute;top:0;z-index:10}.xterm .xterm-helper-textarea{position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-10;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm{cursor:text}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:100;color:transparent}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}
2 | /*# sourceMappingURL=xterm.min.css.map */
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/go-webssh/demo
2 |
3 | go 1.20
4 |
5 | require (
6 | github.com/bytedance/sonic v1.8.0 // indirect
7 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
8 | github.com/gin-contrib/sse v0.1.0 // indirect
9 | github.com/gin-gonic/gin v1.9.0 // indirect
10 | github.com/go-playground/locales v0.14.1 // indirect
11 | github.com/go-playground/universal-translator v0.18.1 // indirect
12 | github.com/go-playground/validator/v10 v10.11.2 // indirect
13 | github.com/goccy/go-json v0.10.0 // indirect
14 | github.com/gorilla/websocket v1.5.0 // indirect
15 | github.com/json-iterator/go v1.1.12 // indirect
16 | github.com/klauspost/cpuid/v2 v2.0.9 // indirect
17 | github.com/leodido/go-urn v1.2.1 // indirect
18 | github.com/mattn/go-isatty v0.0.17 // indirect
19 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
20 | github.com/modern-go/reflect2 v1.0.2 // indirect
21 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect
22 | github.com/sirupsen/logrus v1.9.0 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.9 // indirect
25 | golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
26 | golang.org/x/crypto v0.5.0 // indirect
27 | golang.org/x/net v0.7.0 // indirect
28 | golang.org/x/sys v0.5.0 // indirect
29 | golang.org/x/text v0.7.0 // indirect
30 | google.golang.org/protobuf v1.28.1 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/ui/static/js/xterm-addon-fit.js:
--------------------------------------------------------------------------------
1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(function(){return(()=>{"use strict";var e={775:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0;var r=function(){function e(){}return e.prototype.activate=function(e){this._terminal=e},e.prototype.dispose=function(){},e.prototype.fit=function(){var e=this.proposeDimensions();if(e&&this._terminal){var t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}},e.prototype.proposeDimensions=function(){if(this._terminal&&this._terminal.element&&this._terminal.element.parentElement){var e=this._terminal._core;if(0!==e._renderService.dimensions.actualCellWidth&&0!==e._renderService.dimensions.actualCellHeight){var t=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(t.getPropertyValue("height")),i=Math.max(0,parseInt(t.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o=r-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=i-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-e.viewport.scrollBarWidth;return{cols:Math.max(2,Math.floor(a/e._renderService.dimensions.actualCellWidth)),rows:Math.max(1,Math.floor(o/e._renderService.dimensions.actualCellHeight))}}}},e}();t.FitAddon=r}},t={};return function r(i){if(t[i])return t[i].exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(775)})()}));
2 | //# sourceMappingURL=xterm-addon-fit.js.map
--------------------------------------------------------------------------------
/ui/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | go-webssh demo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
67 |
68 |
--------------------------------------------------------------------------------
/middlewares/cors.go:
--------------------------------------------------------------------------------
1 | package middlewares
2 |
3 | import (
4 | "fmt"
5 | "github.com/gin-gonic/gin"
6 | "net/http"
7 | "strings"
8 | )
9 |
10 | func Cors() gin.HandlerFunc {
11 | return func(c *gin.Context) {
12 | method := c.Request.Method //请求方法
13 | origin := c.Request.Header.Get("Origin") //请求头部
14 | var headerKeys []string // 声明请求头keys
15 | for k, _ := range c.Request.Header {
16 | headerKeys = append(headerKeys, k)
17 | }
18 | headerStr := strings.Join(headerKeys, ", ")
19 | if headerStr != "" {
20 | headerStr = fmt.Sprintf("access-control-allow-origin, access-control-allow-headers, %s", headerStr)
21 | } else {
22 | headerStr = "access-control-allow-origin, access-control-allow-headers"
23 | }
24 | if origin != "" {
25 | c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
26 | c.Header("Access-Control-Allow-Origin", "*") // 这是允许访问所有域
27 | c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE") //服务器支持的所有跨域请求的方法,为了避免浏览次请求的多次'预检'请求
28 | // header的类型
29 | c.Header("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,X_Requested_With,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language,DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Pragma")
30 | // 允许跨域设置 可以返回其他子段
31 | c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
32 | c.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
33 | c.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
34 | c.Set("content-type", "application/json") // 设置返回格式是json
35 | }
36 |
37 | //放行所有OPTIONS方法
38 | if method == "OPTIONS" {
39 | c.JSON(http.StatusOK, "Options Request!")
40 | }
41 | // 处理请求
42 | c.Next() // 处理请求
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ui/static/css/xterm.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 The xterm.js authors. All rights reserved.
3 | * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4 | * https://github.com/chjj/term.js
5 | * @license MIT
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | *
25 | * Originally forked from (with the author's permission):
26 | * Fabrice Bellard's javascript vt100 for jslinux:
27 | * http://bellard.org/jslinux/
28 | * Copyright (c) 2011 Fabrice Bellard
29 | * The original design remains. The terminal itself
30 | * has been extended to include xterm CSI codes, among
31 | * other features.
32 | */
33 |
34 | /**
35 | * Default styles for xterm.js
36 | */
37 |
38 | .xterm {
39 | font-feature-settings: "liga" 0;
40 | position: relative;
41 | user-select: none;
42 | -ms-user-select: none;
43 | -webkit-user-select: none;
44 | }
45 |
46 | .xterm.focus,
47 | .xterm:focus {
48 | outline: none;
49 | }
50 |
51 | .xterm .xterm-helpers {
52 | position: absolute;
53 | top: 0;
54 | /**
55 | * The z-index of the helpers must be higher than the canvases in order for
56 | * IMEs to appear on top.
57 | */
58 | z-index: 5;
59 | }
60 |
61 | .xterm .xterm-helper-textarea {
62 | padding: 0;
63 | border: 0;
64 | margin: 0;
65 | /* Move textarea out of the screen to the far left, so that the cursor is not visible */
66 | position: absolute;
67 | opacity: 0;
68 | left: -9999em;
69 | top: 0;
70 | width: 0;
71 | height: 0;
72 | z-index: -5;
73 | /** Prevent wrapping so the IME appears against the textarea at the correct position */
74 | white-space: nowrap;
75 | overflow: hidden;
76 | resize: none;
77 | }
78 |
79 | .xterm .composition-view {
80 | /* TODO: Composition position got messed up somewhere */
81 | background: #000;
82 | color: #FFF;
83 | display: none;
84 | position: absolute;
85 | white-space: nowrap;
86 | z-index: 1;
87 | }
88 |
89 | .xterm .composition-view.active {
90 | display: block;
91 | }
92 |
93 | .xterm .xterm-viewport {
94 | /* On OS X this is required in order for the scroll bar to appear fully opaque */
95 | background-color: #000;
96 | overflow-y: scroll;
97 | cursor: default;
98 | position: absolute;
99 | right: 0;
100 | left: 0;
101 | top: 0;
102 | bottom: 0;
103 | }
104 |
105 | .xterm .xterm-screen {
106 | position: relative;
107 | }
108 |
109 | .xterm .xterm-screen canvas {
110 | position: absolute;
111 | left: 0;
112 | top: 0;
113 | }
114 |
115 | .xterm .xterm-scroll-area {
116 | visibility: hidden;
117 | }
118 |
119 | .xterm-char-measure-element {
120 | display: inline-block;
121 | visibility: hidden;
122 | position: absolute;
123 | top: 0;
124 | left: -9999em;
125 | line-height: normal;
126 | }
127 |
128 | .xterm {
129 | cursor: text;
130 | }
131 |
132 | .xterm.enable-mouse-events {
133 | /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
134 | cursor: default;
135 | }
136 |
137 | .xterm.xterm-cursor-pointer {
138 | cursor: pointer;
139 | }
140 |
141 | .xterm.column-select.focus {
142 | /* Column selection mode */
143 | cursor: crosshair;
144 | }
145 |
146 | .xterm .xterm-accessibility,
147 | .xterm .xterm-message {
148 | position: absolute;
149 | left: 0;
150 | top: 0;
151 | bottom: 0;
152 | right: 0;
153 | z-index: 10;
154 | color: transparent;
155 | }
156 |
157 | .xterm .live-region {
158 | position: absolute;
159 | left: -9999px;
160 | width: 1px;
161 | height: 1px;
162 | overflow: hidden;
163 | }
164 |
165 | .xterm-dim {
166 | opacity: 0.5;
167 | }
168 |
169 | .xterm-underline {
170 | text-decoration: underline;
171 | }
172 |
--------------------------------------------------------------------------------
/pkg/ssh.go:
--------------------------------------------------------------------------------
1 | package pkg
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | "github.com/gorilla/websocket"
7 | "github.com/sirupsen/logrus"
8 | "golang.org/x/crypto/ssh"
9 | "io"
10 | "sync"
11 | "time"
12 | )
13 |
14 | func NewSshClient(addr, user, password string) (*ssh.Client, error) {
15 | config := &ssh.ClientConfig{
16 | Timeout: time.Second * 5,
17 | User: user,
18 | HostKeyCallback: ssh.InsecureIgnoreHostKey(), //这个可以, 但是不够安全
19 | }
20 | config.Auth = []ssh.AuthMethod{ssh.Password(password)}
21 | c, err := ssh.Dial("tcp", addr, config)
22 | if err != nil {
23 | return nil, err
24 | }
25 | return c, nil
26 | }
27 |
28 | type wsBufferWriter struct {
29 | buffer bytes.Buffer
30 | mu sync.Mutex
31 | }
32 |
33 | func (w *wsBufferWriter) Write(p []byte) (int, error) {
34 | w.mu.Lock()
35 | defer w.mu.Unlock()
36 | return w.buffer.Write(p)
37 | }
38 |
39 | const (
40 | wsMsgCmd = "cmd"
41 | wsMsgResize = "resize"
42 | )
43 |
44 | type wsMsg struct {
45 | Type string `json:"type"`
46 | Cmd string `json:"cmd"`
47 | Cols int `json:"cols"`
48 | Rows int `json:"rows"`
49 | }
50 |
51 | type SshConn struct {
52 | StdinPipe io.WriteCloser
53 | ComboOutput *wsBufferWriter
54 | Session *ssh.Session
55 | }
56 |
57 | func flushComboOutput(w *wsBufferWriter, wsConn *websocket.Conn) error {
58 | if w.buffer.Len() != 0 {
59 | err := wsConn.WriteMessage(websocket.TextMessage, w.buffer.Bytes())
60 | if err != nil {
61 | return err
62 | }
63 | w.buffer.Reset()
64 | }
65 | return nil
66 | }
67 |
68 | func NewSshConn(cols, rows int, sshClient *ssh.Client) (*SshConn, error) {
69 | sshSession, err := sshClient.NewSession()
70 | if err != nil {
71 | return nil, err
72 | }
73 |
74 | stdinP, err := sshSession.StdinPipe()
75 | if err != nil {
76 | return nil, err
77 | }
78 |
79 | comboWriter := new(wsBufferWriter)
80 | sshSession.Stdout = comboWriter
81 | sshSession.Stderr = comboWriter
82 |
83 | modes := ssh.TerminalModes{
84 | ssh.ECHO: 1, // disable echo
85 | ssh.TTY_OP_ISPEED: 14400, // input speed = 14.4kbaud
86 | ssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
87 | }
88 | if err := sshSession.RequestPty("xterm", rows, cols, modes); err != nil {
89 | return nil, err
90 | }
91 | // Start remote shell
92 | if err := sshSession.Shell(); err != nil {
93 | return nil, err
94 | }
95 | return &SshConn{StdinPipe: stdinP, ComboOutput: comboWriter, Session: sshSession}, nil
96 | }
97 |
98 | func (s *SshConn) Close() {
99 | if s.Session != nil {
100 | s.Session.Close()
101 | }
102 |
103 | }
104 |
105 | // ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin
106 | func (s *SshConn) ReceiveWsMsg(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool) {
107 | //tells other go routine quit
108 | defer setQuit(exitCh)
109 | for {
110 | select {
111 | case <-exitCh:
112 | return
113 | default:
114 | //read websocket msg
115 | _, wsData, err := wsConn.ReadMessage()
116 | if websocket.IsCloseError(err, websocket.CloseNormalClosure) {
117 | return
118 | }
119 | if err != nil {
120 | logrus.WithError(err).Error("reading webSocket message failed")
121 | return
122 | }
123 | //unmashal bytes into struct
124 | msgObj := wsMsg{
125 | Type: "cmd",
126 | Cmd: "",
127 | Rows: 50,
128 | Cols: 180,
129 | }
130 | if err := json.Unmarshal(wsData, &msgObj); err != nil {
131 | logrus.WithError(err).WithField("wsData", string(wsData)).Error("unmarshal websocket message failed")
132 | }
133 | switch msgObj.Type {
134 | case wsMsgResize:
135 | //handle xterm.js size change
136 | if msgObj.Cols > 0 && msgObj.Rows > 0 {
137 | if err := s.Session.WindowChange(msgObj.Rows, msgObj.Cols); err != nil {
138 | logrus.WithError(err).Error("ssh pty change windows size failed")
139 | }
140 | }
141 | case wsMsgCmd:
142 | decodeBytes := []byte(msgObj.Cmd)
143 | if err != nil {
144 | logrus.WithError(err).Error("websock cmd string base64 decoding failed")
145 | }
146 | if _, err := s.StdinPipe.Write(decodeBytes); err != nil {
147 | logrus.WithError(err).Error("ws cmd bytes write to ssh.stdin pipe failed")
148 | }
149 | if _, err := logBuff.Write(decodeBytes); err != nil {
150 | logrus.WithError(err).Error("write received cmd into log buffer failed")
151 | }
152 | }
153 | }
154 | }
155 | }
156 | func (s *SshConn) SendComboOutput(wsConn *websocket.Conn, exitCh chan bool) {
157 | defer setQuit(exitCh)
158 |
159 | tick := time.NewTicker(time.Millisecond * time.Duration(120))
160 | defer tick.Stop()
161 | for {
162 | select {
163 | case <-tick.C:
164 | if err := flushComboOutput(s.ComboOutput, wsConn); err != nil {
165 | logrus.WithError(err).Error("ssh sending combo output to webSocket failed")
166 | return
167 | }
168 | case <-exitCh:
169 | return
170 | }
171 | }
172 | }
173 |
174 | func (s *SshConn) SessionWait(quitChan chan bool) {
175 | if err := s.Session.Wait(); err != nil {
176 | logrus.WithError(err).Error("ssh session wait failed")
177 | setQuit(quitChan)
178 | }
179 | }
180 |
181 | func setQuit(ch chan bool) {
182 | ch <- true
183 | }
184 |
--------------------------------------------------------------------------------
/ui/static/js/xterm-addon-fit.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack://FitAddon/webpack/universalModuleDefinition","webpack://FitAddon/./src/FitAddon.ts","webpack://FitAddon/webpack/bootstrap","webpack://FitAddon/webpack/startup"],"names":["root","factory","exports","module","define","amd","self","activate","terminal","this","_terminal","dispose","fit","dims","proposeDimensions","core","_core","rows","cols","_renderService","clear","resize","element","parentElement","dimensions","actualCellWidth","actualCellHeight","parentElementStyle","window","getComputedStyle","parentElementHeight","parseInt","getPropertyValue","parentElementWidth","Math","max","elementStyle","availableHeight","availableWidth","viewport","scrollBarWidth","floor","FitAddon","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAkB,SAAID,IAEtBD,EAAe,SAAIC,IARrB,CASGK,MAAM,WACT,M,yGCSA,IAGA,aAGE,cA4DF,OA1DS,YAAAC,SAAP,SAAgBC,GACdC,KAAKC,UAAYF,GAGZ,YAAAG,QAAP,aAEO,YAAAC,IAAP,WACE,IAAMC,EAAOJ,KAAKK,oBAClB,GAAKD,GAASJ,KAAKC,UAAnB,CAKA,IAAMK,EAAQN,KAAKC,UAAkBM,MAGjCP,KAAKC,UAAUO,OAASJ,EAAKI,MAAQR,KAAKC,UAAUQ,OAASL,EAAKK,OACpEH,EAAKI,eAAeC,QACpBX,KAAKC,UAAUW,OAAOR,EAAKK,KAAML,EAAKI,SAInC,YAAAH,kBAAP,WACE,GAAKL,KAAKC,WAILD,KAAKC,UAAUY,SAAYb,KAAKC,UAAUY,QAAQC,cAAvD,CAKA,IAAMR,EAAQN,KAAKC,UAAkBM,MAErC,GAAuD,IAAnDD,EAAKI,eAAeK,WAAWC,iBAA6E,IAApDV,EAAKI,eAAeK,WAAWE,iBAA3F,CAIA,IAAMC,EAAqBC,OAAOC,iBAAiBpB,KAAKC,UAAUY,QAAQC,eACpEO,EAAsBC,SAASJ,EAAmBK,iBAAiB,WACnEC,EAAqBC,KAAKC,IAAI,EAAGJ,SAASJ,EAAmBK,iBAAiB,WAC9EI,EAAeR,OAAOC,iBAAiBpB,KAAKC,UAAUY,SAStDe,EAAkBP,GAPjBC,SAASK,EAAaJ,iBAAiB,gBACpCD,SAASK,EAAaJ,iBAAiB,oBAO3CM,EAAiBL,GANdF,SAASK,EAAaJ,iBAAiB,kBACxCD,SAASK,EAAaJ,iBAAiB,kBAKiBjB,EAAKwB,SAASC,eAK9E,MAJiB,CACftB,KAAMgB,KAAKC,IA7DI,EA6DcD,KAAKO,MAAMH,EAAiBvB,EAAKI,eAAeK,WAAWC,kBACxFR,KAAMiB,KAAKC,IA7DI,EA6DcD,KAAKO,MAAMJ,EAAkBtB,EAAKI,eAAeK,WAAWE,uBAI/F,EA/DA,GAAa,EAAAgB,aCrBTC,EAA2B,GCE/B,ODCA,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAU3C,QAG3C,IAAIC,EAASwC,EAAyBE,GAAY,CAGjD3C,QAAS,IAOV,OAHA4C,EAAoBD,GAAU1C,EAAQA,EAAOD,QAAS0C,GAG/CzC,EAAOD,QCjBR0C,CAAoB,M","file":"xterm-addon-fit.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FitAddon\"] = factory();\n\telse\n\t\troot[\"FitAddon\"] = factory();\n})(self, function() {\nreturn ","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Terminal, ITerminalAddon } from 'xterm';\n\ninterface ITerminalDimensions {\n /**\n * The number of rows in the terminal.\n */\n rows: number;\n\n /**\n * The number of columns in the terminal.\n */\n cols: number;\n}\n\nconst MINIMUM_COLS = 2;\nconst MINIMUM_ROWS = 1;\n\nexport class FitAddon implements ITerminalAddon {\n private _terminal: Terminal | undefined;\n\n constructor() {}\n\n public activate(terminal: Terminal): void {\n this._terminal = terminal;\n }\n\n public dispose(): void {}\n\n public fit(): void {\n const dims = this.proposeDimensions();\n if (!dims || !this._terminal) {\n return;\n }\n\n // TODO: Remove reliance on private API\n const core = (this._terminal as any)._core;\n\n // Force a full render\n if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {\n core._renderService.clear();\n this._terminal.resize(dims.cols, dims.rows);\n }\n }\n\n public proposeDimensions(): ITerminalDimensions | undefined {\n if (!this._terminal) {\n return undefined;\n }\n\n if (!this._terminal.element || !this._terminal.element.parentElement) {\n return undefined;\n }\n\n // TODO: Remove reliance on private API\n const core = (this._terminal as any)._core;\n\n if (core._renderService.dimensions.actualCellWidth === 0 || core._renderService.dimensions.actualCellHeight === 0) {\n return undefined;\n }\n\n const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);\n const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\n const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));\n const elementStyle = window.getComputedStyle(this._terminal.element);\n const elementPadding = {\n top: parseInt(elementStyle.getPropertyValue('padding-top')),\n bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),\n right: parseInt(elementStyle.getPropertyValue('padding-right')),\n left: parseInt(elementStyle.getPropertyValue('padding-left'))\n };\n const elementPaddingVer = elementPadding.top + elementPadding.bottom;\n const elementPaddingHor = elementPadding.right + elementPadding.left;\n const availableHeight = parentElementHeight - elementPaddingVer;\n const availableWidth = parentElementWidth - elementPaddingHor - core.viewport.scrollBarWidth;\n const geometry = {\n cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / core._renderService.dimensions.actualCellWidth)),\n rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / core._renderService.dimensions.actualCellHeight))\n };\n return geometry;\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(775);\n"],"sourceRoot":""}
--------------------------------------------------------------------------------
/ui/static/js/xterm.min.js:
--------------------------------------------------------------------------------
1 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Terminal=e()}}(function(){return function s(o,a,l){function h(t,e){if(!a[t]){if(!o[t]){var i="function"==typeof require&&require;if(!e&&i)return i(t,!0);if(c)return c(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var n=a[t]={exports:{}};o[t][0].call(n.exports,function(e){return h(o[t][1][e]||e)},n,n.exports,s,o,a,l)}return a[t].exports}for(var c="function"==typeof require&&require,e=0;ee;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()},e.prototype._createAccessibilityTreeNode=function(){var e=document.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e},e.prototype._onTab=function(e){for(var t=0;tthis._terminal.rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCursorInViewport",{get:function(){var e=this.ybase+this.y-this.ydisp;return 0<=e&&eu.MAX_BUFFER_SIZE?u.MAX_BUFFER_SIZE:t},e.prototype.fillViewportRows=function(e){if(0===this.lines.length){void 0===e&&(e=u.DEFAULT_ATTR);for(var t=this._terminal.rows;t--;)this.lines.push(this.getBlankLine(e))}},e.prototype.clear=function(){this.setBufferLineFactory(this._terminal.options.experimentalBufferLineImpl),this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i.CircularList(this._getCorrectBufferLength(this._terminal.rows)),this.scrollTop=0,this.scrollBottom=this._terminal.rows-1,this.setupTabStops()},e.prototype.resize=function(e,t){var i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),0t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i=this._terminal.cols?this._terminal.cols-1:e<0?0:e},e.prototype.nextStop=function(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e=this._terminal.cols?this._terminal.cols-1:e<0?0:e},e.prototype.addMarker=function(e){var t=this,i=new h(e);return this.markers.push(i),i.register(this.lines.addDisposableListener("trim",function(e){i.line-=e,i.line<0&&i.dispose()})),i.register(i.addDisposableListener("dispose",function(){return t._removeMarker(i)})),i},e.prototype._removeMarker=function(e){this.markers.splice(this.markers.indexOf(e),1)},e.prototype.iterator=function(e,t,i,r,n){return new c(this,e,t,i,r,n)},e}();u.Buffer=l;var h=function(i){function r(e){var t=i.call(this)||this;return t.line=e,t._id=r._nextId++,t.isDisposed=!1,t}return n(r,i),Object.defineProperty(r.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.emit("dispose"),i.prototype.dispose.call(this))},r._nextId=1,r}(s.EventEmitter);u.Marker=h;var c=function(){function e(e,t,i,r,n,s){void 0===i&&(i=0),void 0===r&&(r=e.lines.length),void 0===n&&(n=0),void 0===s&&(s=0),this._buffer=e,this._trimRight=t,this._startIndex=i,this._endIndex=r,this._startOverscan=n,this._endOverscan=s,this._startIndex<0&&(this._startIndex=0),this._endIndex>this._buffer.lines.length&&(this._endIndex=this._buffer.lines.length),this._current=this._startIndex}return e.prototype.hasNext=function(){return this._currentthis._endIndex+this._endOverscan&&(e.last=this._endIndex+this._endOverscan),e.first=Math.max(e.first,0),e.last=Math.min(e.last,this._buffer.lines.length);for(var t="",i=e.first;i<=e.last;++i)t+=this._buffer.translateBufferLineToString(i,!!this._trimRight&&i===e.last);return this._current=e.last+1,{range:e,content:t}},e}();u.BufferStringIterator=c},{"./BufferLine":3,"./common/CircularList":16,"./common/EventEmitter":17,"./renderer/atlas/Types":43}],3:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e("./Buffer"),r=function(){function t(e,t,i){this.isWrapped=!1,this._data=[],t||(t=[0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]);for(var r=0;re;)this._data.pop();this.length=this._data.length},t.prototype.fill=function(e){for(var t=0;tthis.length){var r=new Uint32Array(3*e);this.length&&(3*et[n][1])return!1;for(;r<=n;)if(e>t[i=r+n>>1][1])r=i+1;else{if(!(e=i)return t+o.wcwidth(n);var s=e.charCodeAt(r);56320<=s&&s<=57343?n=1024*(n-55296)+s-56320+65536:t+=o.wcwidth(s)}t+=o.wcwidth(n)}return t}},{"./common/TypedArrayUtils":19}],6:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t,i){this._textarea=e,this._compositionView=t,this._terminal=i,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:null,end:null}}return e.prototype.compositionstart=function(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._compositionView.classList.add("active")},e.prototype.compositionupdate=function(e){var t=this;this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(function(){t._compositionPosition.end=t._textarea.value.length},0)},e.prototype.compositionend=function(){this._finalizeComposition(!0)},e.prototype.keydown=function(e){if(this._isComposing||this._isSendingComposition){if(229===e.keyCode)return!1;if(16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)},e.prototype._finalizeComposition=function(e){var t=this;if(this._compositionView.classList.remove("active"),this._isComposing=!1,this._clearTextareaPosition(),e){var i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(function(){if(t._isSendingComposition){t._isSendingComposition=!1;var e=void 0;e=t._isComposing?t._textarea.value.substring(i.start,i.end):t._textarea.value.substring(i.start),t._terminal.handler(e)}},0)}else{this._isSendingComposition=!1;var r=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._terminal.handler(r)}},e.prototype._handleAnyTextareaChanges=function(){var t=this,i=this._textarea.value;setTimeout(function(){if(!t._isComposing){var e=t._textarea.value.replace(i,"");0>4){case 2:s=~s?s:d;break;case 3:~s&&(this._printHandler(e,s,d),s=-1),(_=this._executeHandlers[t])?_():this._executeHandlerFb(t);break;case 0:~s?(this._printHandler(e,s,d),s=-1):~o&&(u.put(e,o,d),o=-1);break;case 1:if(159",function(){return r.keypadNumericMode()}),r._parser.setEscHandler("c",function(){return r.reset()}),r._parser.setEscHandler("n",function(){return r.setgLevel(2)}),r._parser.setEscHandler("o",function(){return r.setgLevel(3)}),r._parser.setEscHandler("|",function(){return r.setgLevel(3)}),r._parser.setEscHandler("}",function(){return r.setgLevel(2)}),r._parser.setEscHandler("~",function(){return r.setgLevel(1)}),r._parser.setEscHandler("%@",function(){return r.selectDefaultCharset()}),r._parser.setEscHandler("%G",function(){return r.selectDefaultCharset()});var i=function(e){n._parser.setEscHandler("("+e,function(){return r.selectCharset("("+e)}),n._parser.setEscHandler(")"+e,function(){return r.selectCharset(")"+e)}),n._parser.setEscHandler("*"+e,function(){return r.selectCharset("*"+e)}),n._parser.setEscHandler("+"+e,function(){return r.selectCharset("+"+e)}),n._parser.setEscHandler("-"+e,function(){return r.selectCharset("-"+e)}),n._parser.setEscHandler("."+e,function(){return r.selectCharset("."+e)}),n._parser.setEscHandler("/"+e,function(){return r.selectCharset("/"+e)})},n=this;for(var s in l.CHARSETS)i(s);return r._parser.setErrorHandler(function(e){return r._terminal.error("Parsing error: ",e),e}),r._parser.setDcsHandler("$q",new u(r._terminal)),r}return n(e,o),e.prototype.dispose=function(){o.prototype.dispose.call(this),this._terminal=null},e.prototype.parse=function(e){if(this._terminal){var t=this._terminal.buffer,i=t.x,r=t.y;this._terminal.debug&&this._terminal.log("data: "+e),this._surrogateFirst&&(e=this._surrogateFirst+e,this._surrogateFirst=""),this._parser.parse(e),(t=this._terminal.buffer).x===i&&t.y===r||this._terminal.emit("cursormove")}},e.prototype.print=function(e,t,i){var r,n,s,o=this._terminal.buffer,a=this._terminal.charset,l=this._terminal.options.screenReaderMode,h=this._terminal.cols,c=this._terminal.wraparoundMode,u=this._terminal.insertMode,_=this._terminal.curAttr,f=o.lines.get(o.y+o.ybase);this._terminal.updateRange(o.y);for(var d=t;d=i){this._surrogateFirst=r;continue}var p=e.charCodeAt(d);56320<=p&&p<=57343?(n=1024*(n-55296)+p-56320+65536,r+=e.charAt(d)):d--}if(s=g.wcwidth(n),a&&(n=(r=a[r]||r).charCodeAt(0)),l&&this._terminal.emit("a11y.char",r),s||!o.x){if(o.x+s-1>=h)if(c)o.x=0,o.y++,o.y>o.scrollBottom?(o.y--,this._terminal.scroll(!0)):o.lines.get(o.y).isWrapped=!0,f=o.lines.get(o.y+o.ybase);else if(2===s)continue;if(u)f.insertCells(o.x,s,[_,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),2===f.get(h-1)[C.CHAR_DATA_WIDTH_INDEX]&&f.set(h-1,[_,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]);if(f.set(o.x++,[_,r,s,n]),0e.scrollBottom&&(e.y--,this._terminal.scroll()),e.x>=this._terminal.cols&&e.x--,this._terminal.emit("linefeed")},e.prototype.carriageReturn=function(){this._terminal.buffer.x=0},e.prototype.backspace=function(){0=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1),this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--},e.prototype.cursorForward=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x+=t,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.cursorBackward=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--,this._terminal.buffer.x-=t,this._terminal.buffer.x<0&&(this._terminal.buffer.x=0)},e.prototype.cursorNextLine=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y+=t,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1),this._terminal.buffer.x=0},e.prototype.cursorPrecedingLine=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y-=t,this._terminal.buffer.y<0&&(this._terminal.buffer.y=0),this._terminal.buffer.x=0},e.prototype.cursorCharAbsolute=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x=t-1},e.prototype.cursorPosition=function(e){var t,i=e[0]-1;t=2<=e.length?e[1]-1:0,i<0?i=0:i>=this._terminal.rows&&(i=this._terminal.rows-1),t<0?t=0:t>=this._terminal.cols&&(t=this._terminal.cols-1),this._terminal.buffer.x=t,this._terminal.buffer.y=i},e.prototype.cursorForwardTab=function(e){for(var t=e[0]||1;t--;)this._terminal.buffer.x=this._terminal.buffer.nextStop()},e.prototype._eraseInBufferLine=function(e,t,i,r){void 0===r&&(r=!1);var n=this._terminal.buffer.lines.get(this._terminal.buffer.ybase+e);n.replaceCells(t,i,[this._terminal.eraseAttr(),C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),r&&(n.isWrapped=!1)},e.prototype._resetBufferLine=function(e){this._eraseInBufferLine(e,0,this._terminal.cols,!0)},e.prototype.eraseInDisplay=function(e){var t;switch(e[0]){case 0:for(t=this._terminal.buffer.y,this._terminal.updateRange(t),this._eraseInBufferLine(t++,this._terminal.buffer.x,this._terminal.cols,0===this._terminal.buffer.x);t=this._terminal.cols&&(this._terminal.buffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t);this._terminal.updateRange(0);break;case 2:for(t=this._terminal.rows,this._terminal.updateRange(t-1);t--;)this._resetBufferLine(t);this._terminal.updateRange(0);break;case 3:var i=this._terminal.buffer.lines.length-this._terminal.rows;0=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.hPositionRelative=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x+=t,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.repeatPrecedingCharacter=function(e){var t=this._terminal.buffer,i=t.lines.get(t.ybase+t.y);i.replaceCells(t.x,t.x+(e[0]||1),i.get(t.x-1)||[C.DEFAULT_ATTR,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE])},e.prototype.sendDeviceAttributes=function(e,t){0"===t&&(this._terminal.is("xterm")?this._terminal.handler(a.C0.ESC+"[>0;276;0c"):this._terminal.is("rxvt-unicode")?this._terminal.handler(a.C0.ESC+"[>85;95;0c"):this._terminal.is("linux")?this._terminal.handler(e[0]+"c"):this._terminal.is("screen")&&this._terminal.handler(a.C0.ESC+"[>83;40003;0c")):this._terminal.is("xterm")||this._terminal.is("rxvt-unicode")||this._terminal.is("screen")?this._terminal.handler(a.C0.ESC+"[?1;2c"):this._terminal.is("linux")&&this._terminal.handler(a.C0.ESC+"[?6c"))},e.prototype.linePosAbsolute=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y=t-1,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1)},e.prototype.vPositionRelative=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y+=t,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1),this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--},e.prototype.hVPosition=function(e){e[0]<1&&(e[0]=1),e[1]<1&&(e[1]=1),this._terminal.buffer.y=e[0]-1,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1),this._terminal.buffer.x=e[1]-1,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.tabClear=function(e){var t=e[0];t<=0?delete this._terminal.buffer.tabs[this._terminal.buffer.x]:3===t&&(this._terminal.buffer.tabs={})},e.prototype.setMode=function(e,t){if(1>18,n=this._terminal.curAttr>>9&511,s=511&this._terminal.curAttr,o=0;o>18,n=C.DEFAULT_ATTR>>9&511,s=511&C.DEFAULT_ATTR):1===t?r|=1:3===t?r|=64:4===t?r|=2:5===t?r|=4:7===t?r|=8:8===t?r|=16:2===t?r|=32:22===t?(r&=-2,r&=-33):23===t?r&=-65:24===t?r&=-3:25===t?r&=-5:27===t?r&=-9:28===t?r&=-17:39===t?n=C.DEFAULT_ATTR>>9&511:49===t?s=511&C.DEFAULT_ATTR:38===t?2===e[o+1]?(o+=2,-1===(n=this._terminal.matchColor(255&e[o],255&e[o+1],255&e[o+2]))&&(n=511),o+=2):5===e[o+1]&&(n=t=255&e[o+=2]):48===t?2===e[o+1]?(o+=2,-1===(s=this._terminal.matchColor(255&e[o],255&e[o+1],255&e[o+2]))&&(s=511),o+=2):5===e[o+1]&&(s=t=255&e[o+=2]):100===t?(n=C.DEFAULT_ATTR>>9&511,s=511&C.DEFAULT_ATTR):this._terminal.error("Unknown SGR attribute: %d.",t);this._terminal.curAttr=r<<18|n<<9|s}else this._terminal.curAttr=C.DEFAULT_ATTR},e.prototype.deviceStatus=function(e,t){if(t){if("?"===t)switch(e[0]){case 6:i=this._terminal.buffer.y+1,r=this._terminal.buffer.x+1;this._terminal.emit("data",a.C0.ESC+"[?"+i+";"+r+"R")}}else switch(e[0]){case 5:this._terminal.emit("data",a.C0.ESC+"[0n");break;case 6:var i=this._terminal.buffer.y+1,r=this._terminal.buffer.x+1;this._terminal.emit("data",a.C0.ESC+"["+i+";"+r+"R")}},e.prototype.softReset=function(e,t){"!"===t&&(this._terminal.cursorHidden=!1,this._terminal.insertMode=!1,this._terminal.originMode=!1,this._terminal.wraparoundMode=!0,this._terminal.applicationKeypad=!1,this._terminal.viewport&&this._terminal.viewport.syncScrollArea(),this._terminal.applicationCursor=!1,this._terminal.buffer.scrollTop=0,this._terminal.buffer.scrollBottom=this._terminal.rows-1,this._terminal.curAttr=C.DEFAULT_ATTR,this._terminal.buffer.x=this._terminal.buffer.y=0,this._terminal.charset=null,this._terminal.glevel=0,this._terminal.charsets=[null])},e.prototype.setCursorStyle=function(e,t){if(" "===t){var i=e[0]<1?1:e[0];switch(i){case 1:case 2:this._terminal.setOption("cursorStyle","block");break;case 3:case 4:this._terminal.setOption("cursorStyle","underline");break;case 5:case 6:this._terminal.setOption("cursorStyle","bar")}var r=i%2==1;this._terminal.setOption("cursorBlink",r)}},e.prototype.setScrollRegion=function(e,t){t||(this._terminal.buffer.scrollTop=(e[0]||1)-1,this._terminal.buffer.scrollBottom=(e[1]&&e[1]<=this._terminal.rows?e[1]:this._terminal.rows)-1,this._terminal.buffer.x=0,this._terminal.buffer.y=0)},e.prototype.saveCursor=function(e){this._terminal.buffer.savedX=this._terminal.buffer.x,this._terminal.buffer.savedY=this._terminal.buffer.y,this._terminal.buffer.savedCurAttr=this._terminal.curAttr},e.prototype.restoreCursor=function(e){this._terminal.buffer.x=this._terminal.buffer.savedX||0,this._terminal.buffer.y=this._terminal.buffer.savedY||0,this._terminal.curAttr=this._terminal.buffer.savedCurAttr||C.DEFAULT_ATTR},e.prototype.setTitle=function(e){this._terminal.handleTitle(e)},e.prototype.nextLine=function(){this._terminal.buffer.x=0,this.index()},e.prototype.keypadApplicationMode=function(){this._terminal.log("Serial port requested application keypad."),this._terminal.applicationKeypad=!0,this._terminal.viewport&&this._terminal.viewport.syncScrollArea()},e.prototype.keypadNumericMode=function(){this._terminal.log("Switching back to normal keypad."),this._terminal.applicationKeypad=!1,this._terminal.viewport&&this._terminal.viewport.syncScrollArea()},e.prototype.selectDefaultCharset=function(){this._terminal.setgLevel(0),this._terminal.setgCharset(0,l.DEFAULT_CHARSET)},e.prototype.selectCharset=function(e){if(2!==e.length)return this.selectDefaultCharset();"/"!==e[0]&&this._terminal.setgCharset(c[e[0]],l.CHARSETS[e[1]]||l.DEFAULT_CHARSET)},e.prototype.index=function(){this._terminal.index()},e.prototype.tabSet=function(){this._terminal.tabSet()},e.prototype.reverseIndex=function(){this._terminal.reverseIndex()},e.prototype.reset=function(){this._parser.reset(),this._terminal.reset()},e.prototype.setgLevel=function(e){this._terminal.setgLevel(e)},e}(s.Disposable);i.InputHandler=o},{"./Buffer":2,"./CharWidth":5,"./EscapeSequenceParser":7,"./common/Lifecycle":18,"./common/data/EscapeSequences":20,"./core/data/Charsets":22}],9:[function(e,t,i){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var u=e("./ui/MouseZoneManager"),s=e("./common/EventEmitter"),f=e("./Buffer"),_=e("./CharWidth"),o=function(i){function a(e){var t=i.call(this)||this;return t._terminal=e,t._linkMatchers=[],t._nextLinkMatcherId=0,t._rowsToLinkify={start:null,end:null},t}return n(a,i),a.prototype.attachToDom=function(e){this._mouseZoneManager=e},a.prototype.linkifyRows=function(e,t){var i=this;this._mouseZoneManager&&(null===this._rowsToLinkify.start?(this._rowsToLinkify.start=e,this._rowsToLinkify.end=t):(this._rowsToLinkify.start=Math.min(this._rowsToLinkify.start,e),this._rowsToLinkify.end=Math.max(this._rowsToLinkify.end,t)),this._mouseZoneManager.clearAll(e,t),this._rowsTimeoutId&&clearTimeout(this._rowsTimeoutId),this._rowsTimeoutId=setTimeout(function(){return i._linkifyRows()},a.TIME_BEFORE_LINKIFY))},a.prototype._linkifyRows=function(){this._rowsTimeoutId=null;var e=this._terminal.buffer,t=e.ydisp+this._rowsToLinkify.start;if(!(t>=e.lines.length)){for(var i=e.ydisp+Math.min(this._rowsToLinkify.end,this._terminal.rows)+1,r=Math.ceil(a.OVERSCAN_CHAR_LIMIT/this._terminal.cols),n=this._terminal.buffer.iterator(!1,t,i,r,r);n.hasNext();)for(var s=n.next(),o=0;o>9&511}a.validationCallback?a.validationCallback(t,function(e){h._rowsTimeoutId||e&&h._addLink(r[1],r[0]-h._terminal.buffer.ydisp,t,a,i)}):_._addLink(r[1],r[0]-_._terminal.buffer.ydisp,t,a,i)},_=this;null!==(l=c.exec(o));){if("break"===e())break}},a.prototype._addLink=function(e,t,i,r,n){var s=this,o=_.getStringCellWidth(i),a=e%this._terminal.cols,l=t+Math.floor(e/this._terminal.cols),h=(a+o)%this._terminal.cols,c=l+Math.floor((a+o)/this._terminal.cols);0===h&&(h=this._terminal.cols,c--),this._mouseZoneManager.add(new u.MouseZone(a+1,l+1,h+1,c+1,function(e){if(r.handler)return r.handler(e,i);window.open(i,"_blank")},function(e){s.emit("linkhover",s._createLinkHoverEvent(a,l,h,c,n)),s._terminal.element.classList.add("xterm-cursor-pointer")},function(e){s.emit("linktooltip",s._createLinkHoverEvent(a,l,h,c,n)),r.hoverTooltipCallback&&r.hoverTooltipCallback(e,i)},function(){s.emit("linkleave",s._createLinkHoverEvent(a,l,h,c,n)),s._terminal.element.classList.remove("xterm-cursor-pointer"),r.hoverLeaveCallback&&r.hoverLeaveCallback()},function(e){return!r.willLinkActivate||r.willLinkActivate(e,i)}))},a.prototype._createLinkHoverEvent=function(e,t,i,r,n){return{x1:e,y1:t,x2:i,y2:r,cols:this._terminal.cols,fg:n}},a.TIME_BEFORE_LINKIFY=200,a.OVERSCAN_CHAR_LIMIT=2e3,a}(s.EventEmitter);i.Linkifier=o},{"./Buffer":2,"./CharWidth":5,"./common/EventEmitter":17,"./ui/MouseZoneManager":49}],10:[function(e,t,i){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var s=e("./utils/MouseHelper"),a=e("./core/Platform"),o=e("./common/EventEmitter"),l=e("./SelectionModel"),L=e("./Buffer"),h=e("./handlers/AltClickHandler"),c=String.fromCharCode(160),u=new RegExp(c,"g"),_=function(r){function e(e,t){var i=r.call(this)||this;return i._terminal=e,i._charMeasure=t,i._enabled=!0,i._initListeners(),i.enable(),i._model=new l.SelectionModel(e),i._activeSelectionMode=0,i}return n(e,r),e.prototype.dispose=function(){r.prototype.dispose.call(this),this._removeMouseDownListeners()},Object.defineProperty(e.prototype,"_buffer",{get:function(){return this._terminal.buffers.active},enumerable:!0,configurable:!0}),e.prototype._initListeners=function(){var t=this;this._mouseMoveListener=function(e){return t._onMouseMove(e)},this._mouseUpListener=function(e){return t._onMouseUp(e)},this._trimListener=function(e){return t._onTrim(e)},this.initBuffersListeners()},e.prototype.initBuffersListeners=function(){var t=this;this._terminal.buffer.lines.on("trim",this._trimListener),this._terminal.buffers.on("activate",function(e){return t._onBufferActivate(e)})},e.prototype.disable=function(){this.clearSelection(),this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},Object.defineProperty(e.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSelection",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t)&&(e[0]!==t[0]||e[1]!==t[1])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectionText",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";var i=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";for(var r=e[1];r<=t[1];r++){var n=this._buffer.translateBufferLineToString(r,!0,e[0],t[0]);i.push(n)}}else{var s=e[1]===t[1]?t[0]:null;i.push(this._buffer.translateBufferLineToString(e[1],!0,e[0],s));for(r=e[1]+1;r<=t[1]-1;r++){var o=this._buffer.lines.get(r);n=this._buffer.translateBufferLineToString(r,!0);o.isWrapped?i[i.length-1]+=n:i.push(n)}if(e[1]!==t[1]){o=this._buffer.lines.get(t[1]),n=this._buffer.translateBufferLineToString(t[1],!0,0,t[0]);o.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(function(e){return e.replace(u," ")}).join(a.isMSWindows?"\r\n":"\n")},enumerable:!0,configurable:!0}),e.prototype.clearSelection=function(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh()},e.prototype.refresh=function(e){var t=this;(this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(function(){return t._refresh()})),a.isLinux&&e)&&(this.selectionText.length&&this.emit("newselection",this.selectionText))},e.prototype._refresh=function(){this._refreshAnimationFrame=null,this.emit("refresh",{start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})},e.prototype.isClickInSelection=function(e){var t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!(!i||!r)&&this._areCoordsInSelection(t,i,r)},e.prototype._areCoordsInSelection=function(e,t,i){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]},e.prototype.selectWordAtCursor=function(e){var t=this._getMouseBufferCoords(e);t&&(this._selectWordAt(t,!1),this._model.selectionEnd=null,this.refresh(!0))},e.prototype.selectAll=function(){this._model.isSelectAllActive=!0,this.refresh(),this._terminal.emit("selection")},e.prototype.selectLines=function(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._terminal.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._terminal.cols,t],this.refresh(),this._terminal.emit("selection")},e.prototype._onTrim=function(e){this._model.onTrim(e)&&this.refresh()},e.prototype._getMouseBufferCoords=function(e){var t=this._terminal.mouseHelper.getCoords(e,this._terminal.screenElement,this._charMeasure,this._terminal.cols,this._terminal.rows,!0);return t?(t[0]--,t[1]--,t[1]+=this._terminal.buffer.ydisp,t):null},e.prototype._getMouseEventScrollAmount=function(e){var t=s.MouseHelper.getCoordsRelativeToElement(e,this._terminal.screenElement)[1],i=this._terminal.rows*Math.ceil(this._charMeasure.height*this._terminal.options.lineHeight);return 0<=t&&t<=i?0:(i=this._model.selectionStart[0]))0===t.get(this._model.selectionStart[0])[L.CHAR_DATA_WIDTH_INDEX]&&this._model.selectionStart[0]++}},e.prototype._onDoubleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=1,this._selectWordAt(t,!0))},e.prototype._onTripleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))},e.prototype.shouldColumnSelect=function(e){return e.altKey&&!(a.isMac&&this._terminal.options.macOptionClickForcesSelection)},e.prototype._onMouseMove=function(e){e.stopImmediatePropagation();var t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),this._model.selectionEnd){if(2===this._activeSelectionMode?this._model.selectionEnd[1]=r;r++){var n=e.get(r);0===n[L.CHAR_DATA_WIDTH_INDEX]?i--:1=this._terminal.cols)return null;var n=this._buffer.lines.get(e[1]);if(!n)return null;var s=this._buffer.translateBufferLineToString(e[1],!1),o=this._convertViewportColToCharacterIndex(n,e),a=o,l=e[0]-o,h=0,c=0,u=0,_=0;if(" "===s.charAt(o)){for(;0this._terminal.cols;)t.length-=this._terminal.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}},e.prototype._isCharWordSeparator=function(e){return 0!==e[L.CHAR_DATA_WIDTH_INDEX]&&0<=" ()[]{}'\"".indexOf(e[L.CHAR_DATA_CHAR_INDEX])},e.prototype._selectLineAt=function(e){var t=this._buffer.getWrappedRangeForLine(e);this._model.selectionStart=[0,t.first],this._model.selectionEnd=[this._terminal.cols,t.last],this._model.selectionStartLength=0},e}(o.EventEmitter);i.SelectionManager=_},{"./Buffer":2,"./SelectionModel":11,"./common/EventEmitter":17,"./core/Platform":21,"./handlers/AltClickHandler":24,"./utils/MouseHelper":53}],11:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e){this._terminal=e,this.clearSelection()}return e.prototype.clearSelection=function(){this.selectionStart=null,this.selectionEnd=null,this.isSelectAllActive=!1,this.selectionStartLength=0},Object.defineProperty(e.prototype,"finalSelectionStart",{get:function(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"finalSelectionEnd",{get:function(){if(this.isSelectAllActive)return[this._terminal.cols,this._terminal.buffer.ybase+this._terminal.rows-1];if(!this.selectionStart)return null;if(this.selectionEnd&&!this.areSelectionValuesReversed())return this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]?[Math.max(this.selectionStart[0]+this.selectionStartLength,this.selectionEnd[0]),this.selectionEnd[1]]:this.selectionEnd;var e=this.selectionStart[0]+this.selectionStartLength;return e>this._terminal.cols?[e%this._terminal.cols,this.selectionStart[1]+Math.floor(e/this._terminal.cols)]:[e,this.selectionStart[1]]},enumerable:!0,configurable:!0}),e.prototype.areSelectionValuesReversed=function(){var e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])},e.prototype.onTrim=function(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)},e}();i.SelectionModel=r},{}],12:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_BELL_SOUND="data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==";var r=function(){function r(e){this._terminal=e}return Object.defineProperty(r,"audioContext",{get:function(){if(!r._audioContext){var e=window.AudioContext||window.webkitAudioContext;if(!e)return console.warn("Web Audio API is not supported by this browser. Consider upgrading to the latest version"),null;r._audioContext=new e}return r._audioContext},enumerable:!0,configurable:!0}),r.prototype.playBellSound=function(){var t=r.audioContext;if(t){var i=t.createBufferSource();t.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)),function(e){i.buffer=e,i.connect(t.destination),i.start(0)})}},r.prototype._base64ToArrayBuffer=function(e){for(var t=window.atob(e),i=t.length,r=new Uint8Array(i),n=0;ni){var r=this.buffer.lines.length-i,n=this.buffer.ydisp-r<0;this.buffer.lines.trimStart(r),this.buffer.ybase=Math.max(this.buffer.ybase-r,0),this.buffer.ydisp=Math.max(this.buffer.ydisp-r,0),n&&this.refresh(0,this.rows-1)}}}switch(this.options[e]=t,e){case"fontFamily":case"fontSize":this.renderer&&(this.renderer.clear(),this.charMeasure.measure(this.options));break;case"drawBoldTextInBrightColors":case"experimentalCharAtlas":case"enableBold":case"letterSpacing":case"lineHeight":case"fontWeight":case"fontWeightBold":this.renderer&&(this.renderer.clear(),this.renderer.onResize(this.cols,this.rows),this.refresh(0,this.rows-1));case"rendererType":this.renderer&&(this.unregister(this.renderer),this.renderer.dispose(),this.renderer=null),this._setupRenderer(),this.renderer.onCharSizeChanged(),this._theme&&this.renderer.setTheme(this._theme),this.mouseHelper.setRenderer(this.renderer);break;case"scrollback":this.buffers.resize(this.cols,this.rows),this.viewport&&this.viewport.syncScrollArea();break;case"screenReaderMode":t?this._accessibilityManager||(this._accessibilityManager=new S.AccessibilityManager(this)):this._accessibilityManager&&(this._accessibilityManager.dispose(),this._accessibilityManager=null);break;case"tabStopWidth":this.buffers.setupTabStops();break;case"experimentalBufferLineImpl":this.buffers.normal.setBufferLineFactory(t),this.buffers.alt.setBufferLineFactory(t),this._blankLine=null}this.renderer&&this.renderer.onOptionsChanged()}},e.prototype._onTextAreaFocus=function(e){this.sendFocus&&this.handler(u.C0.ESC+"[I"),this.updateCursorStyle(e),this.element.classList.add("focus"),this.showCursor(),this.emit("focus")},e.prototype.blur=function(){return this.textarea.blur()},e.prototype._onTextAreaBlur=function(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.sendFocus&&this.handler(u.C0.ESC+"[O"),this.element.classList.remove("focus"),this.emit("blur")},e.prototype._initGlobal=function(){var t=this;this._bindKeys(),this.register(C.addDisposableDomListener(this.element,"copy",function(e){t.hasSelection()&&c.copyHandler(e,t,t.selectionManager)}));var e=function(e){return c.pasteHandler(e,t)};this.register(C.addDisposableDomListener(this.textarea,"paste",e)),this.register(C.addDisposableDomListener(this.element,"paste",e)),y.isFirefox?this.register(C.addDisposableDomListener(this.element,"mousedown",function(e){2===e.button&&c.rightClickHandler(e,t.textarea,t.selectionManager,t.options.rightClickSelectsWord)})):this.register(C.addDisposableDomListener(this.element,"contextmenu",function(e){c.rightClickHandler(e,t.textarea,t.selectionManager,t.options.rightClickSelectsWord)})),y.isLinux&&this.register(C.addDisposableDomListener(this.element,"auxclick",function(e){1===e.button&&c.moveTextAreaUnderMouseCursor(e,t.textarea)}))},e.prototype._bindKeys=function(){var i=this,r=this;this.register(C.addDisposableDomListener(this.element,"keydown",function(e){M.activeElement===this&&r._keyDown(e)},!0)),this.register(C.addDisposableDomListener(this.element,"keypress",function(e){M.activeElement===this&&r._keyPress(e)},!0)),this.register(C.addDisposableDomListener(this.element,"keyup",function(e){var t;16!==(t=e).keyCode&&17!==t.keyCode&&18!==t.keyCode&&i.focus(),r._keyUp(e)},!0)),this.register(C.addDisposableDomListener(this.textarea,"keydown",function(e){return i._keyDown(e)},!0)),this.register(C.addDisposableDomListener(this.textarea,"keypress",function(e){return i._keyPress(e)},!0)),this.register(C.addDisposableDomListener(this.textarea,"compositionstart",function(){return i._compositionHelper.compositionstart()})),this.register(C.addDisposableDomListener(this.textarea,"compositionupdate",function(e){return i._compositionHelper.compositionupdate(e)})),this.register(C.addDisposableDomListener(this.textarea,"compositionend",function(){return i._compositionHelper.compositionend()})),this.register(this.addDisposableListener("refresh",function(){return i._compositionHelper.updateCompositionElements()})),this.register(this.addDisposableListener("refresh",function(e){return i._queueLinkification(e.start,e.end)}))},e.prototype.open=function(e){var t=this;if(this._parent=e||this._parent,!this._parent)throw new Error("Terminal requires a parent element.");this._context=this._parent.ownerDocument.defaultView,this._document=this._parent.ownerDocument,this._screenDprMonitor=new A.ScreenDprMonitor,this._screenDprMonitor.setListener(function(){return t.emit("dprchange",window.devicePixelRatio)}),this.register(this._screenDprMonitor),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),this.element.setAttribute("tabindex","0"),this._parent.appendChild(this.element);var i=M.createDocumentFragment();this._viewportElement=M.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this._viewportScrollArea=M.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=M.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=M.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement),this._mouseZoneManager=new E.MouseZoneManager(this),this.register(this._mouseZoneManager),this.register(this.addDisposableListener("scroll",function(){return t._mouseZoneManager.clearAll()})),this.linkifier.attachToDom(this._mouseZoneManager),this.textarea=M.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this.register(C.addDisposableDomListener(this.textarea,"focus",function(e){return t._onTextAreaFocus(e)})),this.register(C.addDisposableDomListener(this.textarea,"blur",function(){return t._onTextAreaBlur()})),this._helperContainer.appendChild(this.textarea),this._compositionView=M.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=new o.CompositionHelper(this.textarea,this._compositionView,this),this._helperContainer.appendChild(this._compositionView),this.charMeasure=new m.CharMeasure(M,this._helperContainer),this.element.appendChild(i),this._setupRenderer(),this._theme=this.options.theme,this.options.theme=null,this.viewport=new h.Viewport(this,this._viewportElement,this._viewportScrollArea,this.charMeasure),this.viewport.onThemeChanged(this.renderer.colorManager.colors),this.register(this.viewport),this.register(this.addDisposableListener("cursormove",function(){return t.renderer.onCursorMove()})),this.register(this.addDisposableListener("resize",function(){return t.renderer.onResize(t.cols,t.rows)})),this.register(this.addDisposableListener("blur",function(){return t.renderer.onBlur()})),this.register(this.addDisposableListener("focus",function(){return t.renderer.onFocus()})),this.register(this.addDisposableListener("dprchange",function(){return t.renderer.onWindowResize(window.devicePixelRatio)})),this.register(C.addDisposableDomListener(window,"resize",function(){return t.renderer.onWindowResize(window.devicePixelRatio)})),this.register(this.charMeasure.addDisposableListener("charsizechanged",function(){return t.renderer.onCharSizeChanged()})),this.register(this.renderer.addDisposableListener("resize",function(e){return t.viewport.syncScrollArea()})),this.selectionManager=new p.SelectionManager(this,this.charMeasure),this.register(C.addDisposableDomListener(this.element,"mousedown",function(e){return t.selectionManager.onMouseDown(e)})),this.register(this.selectionManager.addDisposableListener("refresh",function(e){return t.renderer.onSelectionChanged(e.start,e.end,e.columnSelectMode)})),this.register(this.selectionManager.addDisposableListener("newselection",function(e){t.textarea.value=e,t.textarea.focus(),t.textarea.select()})),this.register(this.addDisposableListener("scroll",function(){t.viewport.syncScrollArea(),t.selectionManager.refresh()})),this.register(C.addDisposableDomListener(this._viewportElement,"scroll",function(){return t.selectionManager.refresh()})),this.mouseHelper=new v.MouseHelper(this.renderer),this.options.screenReaderMode&&(this._accessibilityManager=new S.AccessibilityManager(this)),this.charMeasure.measure(this.options),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()},e.prototype._setupRenderer=function(){switch(this.options.rendererType){case"canvas":this.renderer=new f.Renderer(this,this.options.theme);break;case"dom":this.renderer=new T.DomRenderer(this,this.options.theme);break;default:throw new Error('Unrecognized rendererType "'+this.options.rendererType+'"')}this.register(this.renderer)},e.prototype._setTheme=function(e){this._theme=e;var t=this.renderer.setTheme(e);this.viewport&&this.viewport.onThemeChanged(t)},e.prototype.bindMouse=function(){var s=this,e=this.element,o=this,n=32;function a(e){var t,i;if(t=function(e){var t,i,r,n,s;switch(e.overrideType||e.type){case"mousedown":t=null!==e.button&&void 0!==e.button?+e.button:null!==e.which&&void 0!==e.which?e.which-1:null,y.isMSIE&&(t=1===t?0:4===t?1:t);break;case"mouseup":t=3;break;case"DOMMouseScroll":t=e.detail<0?64:65;break;case"wheel":t=e.deltaY<0?64:65}i=e.shiftKey?4:0,r=e.metaKey?8:0,n=e.ctrlKey?16:0,s=i|r|n,o.vt200Mouse?s&=n:o.normalMouse||(s=0);return t=32+(s<<2)+t}(e),i=o.mouseHelper.getRawByteCoords(e,o.screenElement,o.charMeasure,o.cols,o.rows))switch(h(t,i),e.overrideType||e.type){case"mousedown":n=t;break;case"mouseup":n=32}}function l(e,t){if(o.utfMouse){if(2047===t)return void e.push(0);t<127?e.push(t):(2047>6),e.push(128|63&t))}else{if(255===t)return void e.push(0);127=this.buffer.ybase&&(this._userScrolling=!1);var i=this.buffer.ydisp;this.buffer.ydisp=Math.max(Math.min(this.buffer.ydisp+e,this.buffer.ybase),0),i!==this.buffer.ydisp&&(t||this.emit("scroll",this.buffer.ydisp),this.refresh(0,this.rows-1))},e.prototype.scrollPages=function(e){this.scrollLines(e*(this.rows-1))},e.prototype.scrollToTop=function(){this.scrollLines(-this.buffer.ydisp)},e.prototype.scrollToBottom=function(){this.scrollLines(this.buffer.ybase-this.buffer.ydisp)},e.prototype.scrollToLine=function(e){var t=e-this.buffer.ydisp;0!==t&&this.scrollLines(t)},e.prototype.write=function(e){var t=this;this._isDisposed||e&&(this.writeBuffer.push(e),this.options.useFlowControl&&!this._xoffSentToCatchUp&&5<=this.writeBuffer.length&&(this.handler(u.C0.DC3),this._xoffSentToCatchUp=!0),!this._writeInProgress&&0this._refreshEnd&&(this._refreshEnd=e)},e.prototype.maxRange=function(){this._refreshStart=0,this._refreshEnd=this.rows-1},e.prototype.clear=function(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(var e=1;ethis.buffer.scrollBottom&&(this.buffer.y--,this.scroll()),this.buffer.x>=this.cols&&this.buffer.x--},e.prototype.reverseIndex=function(){if(this.buffer.y===this.buffer.scrollTop){var e=this.buffer.scrollBottom-this.buffer.scrollTop;this.buffer.lines.shiftElements(this.buffer.y+this.buffer.ybase,e,1),this.buffer.lines.set(this.buffer.y+this.buffer.ybase,this.buffer.getBlankLine(this.eraseAttr())),this.updateRange(this.buffer.scrollTop),this.updateRange(this.buffer.scrollBottom)}else this.buffer.y--},e.prototype.reset=function(){this.options.rows=this.rows,this.options.cols=this.cols;var e=this._customKeyEventHandler,t=this._inputHandler,i=this.cursorState;this._setup(),this._customKeyEventHandler=e,this._inputHandler=t,this.cursorState=i,this.refresh(0,this.rows-1),this.viewport&&this.viewport.syncScrollArea()},e.prototype.tabSet=function(){this.buffer.tabs[this.buffer.x]=!0},e.prototype.cancel=function(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1},e.prototype.matchColor=function(e,t,i){var r=e<<16|t<<8|i;if(null!==O[r]&&void 0!==O[r])return O[r];for(var n,s,o,a,l,h,c,u,_=1/0,f=-1,d=0;d>>24,c=n>>>16&255,u=n>>>8&255,0===(s=Math.pow(30*(o-h),2)+Math.pow(59*(a-c),2)+Math.pow(11*(l-u),2))){f=d;break}s<_&&(_=s,f=d)}return O[r]=f},e.prototype._visualBell=function(){return!1},e.prototype._soundBell=function(){return"sound"===this.options.bellStyle},e}(l.EventEmitter);i.Terminal=H;var O={}},{"./AccessibilityManager":1,"./Buffer":2,"./BufferSet":4,"./CompositionHelper":6,"./InputHandler":8,"./Linkifier":9,"./SelectionManager":10,"./SoundManager":12,"./Strings":13,"./Viewport":15,"./common/EventEmitter":17,"./common/data/EscapeSequences":20,"./core/Platform":21,"./core/input/Keyboard":23,"./renderer/ColorManager":28,"./renderer/Renderer":32,"./renderer/atlas/CharAtlasCache":36,"./renderer/dom/DomRenderer":44,"./ui/CharMeasure":46,"./ui/Clipboard":47,"./ui/Lifecycle":48,"./ui/MouseZoneManager":49,"./ui/ScreenDprMonitor":51,"./utils/Clone":52,"./utils/MouseHelper":53}],15:[function(e,t,i){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var s=e("./common/Lifecycle"),o=e("./ui/Lifecycle"),a=function(s){function e(e,t,i,r){var n=s.call(this)||this;return n._terminal=e,n._viewportElement=t,n._scrollArea=i,n._charMeasure=r,n.scrollBarWidth=0,n._currentRowHeight=0,n._lastRecordedBufferLength=0,n._lastRecordedViewportHeight=0,n._lastRecordedBufferHeight=0,n._lastScrollTop=0,n._wheelPartialScroll=0,n._refreshAnimationFrame=null,n._ignoreNextScrollEvent=!1,n.scrollBarWidth=n._viewportElement.offsetWidth-n._scrollArea.offsetWidth||15,n.register(o.addDisposableDomListener(n._viewportElement,"scroll",n._onScroll.bind(n))),setTimeout(function(){return n.syncScrollArea()},0),n}return n(e,s),e.prototype.onThemeChanged=function(e){this._viewportElement.style.backgroundColor=e.background.css},e.prototype._refresh=function(){var e=this;null===this._refreshAnimationFrame&&(this._refreshAnimationFrame=requestAnimationFrame(function(){return e._innerRefresh()}))},e.prototype._innerRefresh=function(){if(0this._length)for(var t=this._length;tthis._maxLength){var s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.emit("trim",s)}else this._length+=i.length}},e.prototype.trimStart=function(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.emit("trim",e)},e.prototype.shiftElements=function(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(0this._maxLength;)this._length--,this._startIndex++,this.emit("trim",1)}else for(r=0;r=e.length)return e;i=(e.length+i)%e.length,r=r>=e.length?e.length:(e.length+r)%e.length;for(var n=i;n"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(e,t,i,r){var n={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?n.key=t?h.C0.ESC+"OA":h.C0.ESC+"[A":"UIKeyInputLeftArrow"===e.key?n.key=t?h.C0.ESC+"OD":h.C0.ESC+"[D":"UIKeyInputRightArrow"===e.key?n.key=t?h.C0.ESC+"OC":h.C0.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(n.key=t?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:if(e.shiftKey){n.key=h.C0.BS;break}if(e.altKey){n.key=h.C0.ESC+h.C0.DEL;break}n.key=h.C0.DEL;break;case 9:if(e.shiftKey){n.key=h.C0.ESC+"[Z";break}n.key=h.C0.HT,n.cancel=!0;break;case 13:n.key=h.C0.CR,n.cancel=!0;break;case 27:n.key=h.C0.ESC,n.cancel=!0;break;case 37:s?(n.key=h.C0.ESC+"[1;"+(s+1)+"D",n.key===h.C0.ESC+"[1;3D"&&(n.key=i?h.C0.ESC+"b":h.C0.ESC+"[1;5D")):n.key=t?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:s?(n.key=h.C0.ESC+"[1;"+(s+1)+"C",n.key===h.C0.ESC+"[1;3C"&&(n.key=i?h.C0.ESC+"f":h.C0.ESC+"[1;5C")):n.key=t?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:s?(n.key=h.C0.ESC+"[1;"+(s+1)+"A",n.key===h.C0.ESC+"[1;3A"&&(n.key=h.C0.ESC+"[1;5A")):n.key=t?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:s?(n.key=h.C0.ESC+"[1;"+(s+1)+"B",n.key===h.C0.ESC+"[1;3B"&&(n.key=h.C0.ESC+"[1;5B")):n.key=t?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=h.C0.ESC+"[2~");break;case 46:n.key=s?h.C0.ESC+"[3;"+(s+1)+"~":h.C0.ESC+"[3~";break;case 36:n.key=s?h.C0.ESC+"[1;"+(s+1)+"H":t?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:n.key=s?h.C0.ESC+"[1;"+(s+1)+"F":t?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:e.shiftKey?n.type=2:n.key=h.C0.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:n.key=h.C0.ESC+"[6~";break;case 112:n.key=s?h.C0.ESC+"[1;"+(s+1)+"P":h.C0.ESC+"OP";break;case 113:n.key=s?h.C0.ESC+"[1;"+(s+1)+"Q":h.C0.ESC+"OQ";break;case 114:n.key=s?h.C0.ESC+"[1;"+(s+1)+"R":h.C0.ESC+"OR";break;case 115:n.key=s?h.C0.ESC+"[1;"+(s+1)+"S":h.C0.ESC+"OS";break;case 116:n.key=s?h.C0.ESC+"[15;"+(s+1)+"~":h.C0.ESC+"[15~";break;case 117:n.key=s?h.C0.ESC+"[17;"+(s+1)+"~":h.C0.ESC+"[17~";break;case 118:n.key=s?h.C0.ESC+"[18;"+(s+1)+"~":h.C0.ESC+"[18~";break;case 119:n.key=s?h.C0.ESC+"[19;"+(s+1)+"~":h.C0.ESC+"[19~";break;case 120:n.key=s?h.C0.ESC+"[20;"+(s+1)+"~":h.C0.ESC+"[20~";break;case 121:n.key=s?h.C0.ESC+"[21;"+(s+1)+"~":h.C0.ESC+"[21~";break;case 122:n.key=s?h.C0.ESC+"[23;"+(s+1)+"~":h.C0.ESC+"[23~";break;case 123:n.key=s?h.C0.ESC+"[24;"+(s+1)+"~":h.C0.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(i&&!r||!e.altKey||e.metaKey)i&&!e.altKey&&!e.ctrlKey&&e.metaKey&&65===e.keyCode&&(n.type=1);else{var o=c[e.keyCode],a=o&&o[e.shiftKey?1:0];if(a)n.key=h.C0.ESC+a;else if(65<=e.keyCode&&e.keyCode<=90){var l=e.ctrlKey?e.keyCode-64:e.keyCode+32;n.key=h.C0.ESC+String.fromCharCode(l)}}else 65<=e.keyCode&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=String.fromCharCode(0):51<=e.keyCode&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=String.fromCharCode(127):219===e.keyCode?n.key=String.fromCharCode(27):220===e.keyCode?n.key=String.fromCharCode(28):221===e.keyCode&&(n.key=String.fromCharCode(29))}return n}},{"../../common/data/EscapeSequences":20}],24:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=e("../common/data/EscapeSequences"),n=function(){function e(e,t){var i;this._mouseEvent=e,this._terminal=t,this._lines=this._terminal.buffer.lines,this._startCol=this._terminal.buffer.x,this._startRow=this._terminal.buffer.y;var r=this._terminal.mouseHelper.getCoords(this._mouseEvent,this._terminal.element,this._terminal.charMeasure,this._terminal.cols,this._terminal.rows,!1);r&&(i=r.map(function(e){return e-1}),this._endCol=i[0],this._endRow=i[1])}return e.prototype.move=function(){this._mouseEvent.altKey&&void 0!==this._endCol&&void 0!==this._endRow&&this._terminal.handler(this._arrowSequences())},e.prototype._arrowSequences=function(){return this._terminal.buffer.hasScrollback?this._moveHorizontallyOnly():this._resetStartingRow()+this._moveToRequestedRow()+this._moveToRequestedCol()},e.prototype._resetStartingRow=function(){return 0===this._moveToRequestedRow().length?"":s(this._bufferLine(this._startCol,this._startRow,this._startCol,this._startRow-this._wrappedRowsForRow(this._startRow),!1).length,this._sequence("D"))},e.prototype._moveToRequestedRow=function(){var e=this._startRow-this._wrappedRowsForRow(this._startRow),t=this._endRow-this._wrappedRowsForRow(this._endRow);return s(Math.abs(e-t)-this._wrappedRowsCount(),this._sequence(this._verticalDirection()))},e.prototype._moveToRequestedCol=function(){var e;e=0=this._endCol&ðis._endRow?"A":"B"},e.prototype._bufferLine=function(e,t,i,r,n){for(var s=e,o=t,a="";s!==i||o!==r;)s+=n?1:-1,n&&s>this._terminal.cols-1?(a+=this._terminal.buffer.translateBufferLineToString(o,!1,e,s),e=s=0,o++):!n&&s<0&&(a+=this._terminal.buffer.translateBufferLineToString(o,!1,0,e+1),e=s=this._terminal.cols-1,o--);return a+this._terminal.buffer.translateBufferLineToString(o,!1,e,s)},e.prototype._sequence=function(e){var t=this._terminal.applicationCursor?"O":"[";return r.C0.ESC+t+e},e}();function s(e,t){e=Math.floor(e);for(var i="",r=0;r>9,l=0;l>9;if(0!==u){if(_!==a){if(1>>0})}for(i=0;i<24;i++){var o=8+10*i,a=c(o);e.push({css:"#"+a+a+a,rgba:(o<<24|o<<16|o<<8|255)>>>0})}return e}();var i=function(){function e(e,t){this.allowTransparency=t;var i=e.createElement("canvas");i.width=1,i.height=1,this._ctx=i.getContext("2d"),this._ctx.globalCompositeOperation="copy",this._litmusColor=this._ctx.createLinearGradient(0,0,1,1),this.colors={foreground:n,background:s,cursor:o,cursorAccent:a,selection:l,ansi:r.DEFAULT_ANSI_COLORS.slice()}}return e.prototype.setTheme=function(e){this.colors.foreground=this._parseColor(e.foreground,n),this.colors.background=this._parseColor(e.background,s),this.colors.cursor=this._parseColor(e.cursor,o,!0),this.colors.cursorAccent=this._parseColor(e.cursorAccent,a,!0),this.colors.selection=this._parseColor(e.selection,l,!0),this.colors.ansi[0]=this._parseColor(e.black,r.DEFAULT_ANSI_COLORS[0]),this.colors.ansi[1]=this._parseColor(e.red,r.DEFAULT_ANSI_COLORS[1]),this.colors.ansi[2]=this._parseColor(e.green,r.DEFAULT_ANSI_COLORS[2]),this.colors.ansi[3]=this._parseColor(e.yellow,r.DEFAULT_ANSI_COLORS[3]),this.colors.ansi[4]=this._parseColor(e.blue,r.DEFAULT_ANSI_COLORS[4]),this.colors.ansi[5]=this._parseColor(e.magenta,r.DEFAULT_ANSI_COLORS[5]),this.colors.ansi[6]=this._parseColor(e.cyan,r.DEFAULT_ANSI_COLORS[6]),this.colors.ansi[7]=this._parseColor(e.white,r.DEFAULT_ANSI_COLORS[7]),this.colors.ansi[8]=this._parseColor(e.brightBlack,r.DEFAULT_ANSI_COLORS[8]),this.colors.ansi[9]=this._parseColor(e.brightRed,r.DEFAULT_ANSI_COLORS[9]),this.colors.ansi[10]=this._parseColor(e.brightGreen,r.DEFAULT_ANSI_COLORS[10]),this.colors.ansi[11]=this._parseColor(e.brightYellow,r.DEFAULT_ANSI_COLORS[11]),this.colors.ansi[12]=this._parseColor(e.brightBlue,r.DEFAULT_ANSI_COLORS[12]),this.colors.ansi[13]=this._parseColor(e.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),this.colors.ansi[14]=this._parseColor(e.brightCyan,r.DEFAULT_ANSI_COLORS[14]),this.colors.ansi[15]=this._parseColor(e.brightWhite,r.DEFAULT_ANSI_COLORS[15])},e.prototype._parseColor=function(e,t,i){if(void 0===i&&(i=this.allowTransparency),!e)return t;if(this._ctx.fillStyle=this._litmusColor,this._ctx.fillStyle=e,"string"!=typeof this._ctx.fillStyle)return console.warn("Color: "+e+" is invalid using fallback "+t.css),t;this._ctx.fillRect(0,0,1,1);var r=this._ctx.getImageData(0,0,1,1).data;return i||255===r[3]?{css:e,rgba:(r[0]<<24|r[1]<<16|r[2]<<8|r[3])>>>0}:(console.warn("Color: "+e+" is using transparency, but allowTransparency is false. Using fallback "+t.css+"."),t)},e}();r.ColorManager=i},{}],29:[function(e,t,i){"use strict";var r,s=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var o=e("../Buffer"),n=e("./BaseRenderLayer"),a=function(n){function e(e,t,i){var r=n.call(this,e,"cursor",t,!0,i)||this;return r._state={x:null,y:null,isFocused:null,style:null,width:null},r._cursorRenderers={bar:r._renderBarCursor.bind(r),block:r._renderBlockCursor.bind(r),underline:r._renderUnderlineCursor.bind(r)},r}return s(e,n),e.prototype.resize=function(e,t){n.prototype.resize.call(this,e,t),this._state={x:null,y:null,isFocused:null,style:null,width:null}},e.prototype.reset=function(e){this._clearCursor(),this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=null,this.onOptionsChanged(e))},e.prototype.onBlur=function(e){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause(),e.refresh(e.buffer.y,e.buffer.y)},e.prototype.onFocus=function(e){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume(e):e.refresh(e.buffer.y,e.buffer.y)},e.prototype.onOptionsChanged=function(e){var t=this;e.options.cursorBlink?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new l(e,function(){t._render(e,!0)})):(this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=null),e.refresh(e.buffer.y,e.buffer.y))},e.prototype.onCursorMove=function(e){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation(e)},e.prototype.onGridChanged=function(e,t,i){!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isPaused?this._render(e,!1):this._cursorBlinkStateManager.restartBlinkAnimation(e)},e.prototype._render=function(e,t){if(e.cursorState&&!e.cursorHidden){var i=e.buffer.ybase+e.buffer.y,r=i-e.buffer.ydisp;if(r<0||r>=e.rows)this._clearCursor();else{var n=e.buffer.lines.get(i).get(e.buffer.x);if(n){if(!e.isFocused)return this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._renderBlurCursor(e,e.buffer.x,r,n),this._ctx.restore(),this._state.x=e.buffer.x,this._state.y=r,this._state.isFocused=!1,this._state.style=e.options.cursorStyle,void(this._state.width=n[o.CHAR_DATA_WIDTH_INDEX]);if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===e.buffer.x&&this._state.y===r&&this._state.isFocused===e.isFocused&&this._state.style===e.options.cursorStyle&&this._state.width===n[o.CHAR_DATA_WIDTH_INDEX])return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[e.options.cursorStyle||"block"](e,e.buffer.x,r,n),this._ctx.restore(),this._state.x=e.buffer.x,this._state.y=r,this._state.isFocused=!1,this._state.style=e.options.cursorStyle,this._state.width=n[o.CHAR_DATA_WIDTH_INDEX]}else this._clearCursor()}}}else this._clearCursor()},e.prototype._clearCursor=function(){this._state&&(this.clearCells(this._state.x,this._state.y,this._state.width,1),this._state={x:null,y:null,isFocused:null,style:null,width:null})},e.prototype._renderBarCursor=function(e,t,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this.fillLeftLineAtCell(t,i),this._ctx.restore()},e.prototype._renderBlockCursor=function(e,t,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this.fillCells(t,i,r[o.CHAR_DATA_WIDTH_INDEX],1),this._ctx.fillStyle=this._colors.cursorAccent.css,this.fillCharTrueColor(e,r,t,i),this._ctx.restore()},e.prototype._renderUnderlineCursor=function(e,t,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this.fillBottomLineAtCells(t,i),this._ctx.restore()},e.prototype._renderBlurCursor=function(e,t,i,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this.strokeRectAtCell(t,i,r[o.CHAR_DATA_WIDTH_INDEX],1),this._ctx.restore()},e}(n.BaseRenderLayer);i.CursorRenderLayer=a;var l=function(){function e(e,t){this._renderCallback=t,this.isCursorVisible=!0,e.isFocused&&this._restartInterval()}return Object.defineProperty(e.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=null),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=null),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=null)},e.prototype.restartBlinkAnimation=function(e){var t=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){t._renderCallback(),t._animationFrame=null})))},e.prototype._restartInterval=function(e){var t=this;void 0===e&&(e=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=setTimeout(function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);if(t._animationTimeRestarted=null,0=e.rows||a<0)){if(this._ctx.fillStyle=this._colors.selection.css,r){var l=t[0],h=i[0]-l,c=a-o+1;this.fillCells(l,o,h,c)}else{l=n===o?t[0]:0;var u=o===a?i[0]:e.cols;this.fillCells(l,o,u-l,1);var _=Math.max(a-o-1,0);if(this.fillCells(0,o+1,e.cols,_),o!==a){var f=s===a?i[0]:e.cols;this.fillCells(0,a,f,1)}}this._state.start=[t[0],t[1]],this._state.end=[i[0],i[1]],this._state.columnSelectMode=r,this._state.ydisp=e.buffer.ydisp}}},e.prototype._didStateChange=function(e,t,i,r){return!this._areCoordinatesEqual(e,this._state.start)||!this._areCoordinatesEqual(t,this._state.end)||i!==this._state.columnSelectMode||r!==this._state.ydisp},e.prototype._areCoordinatesEqual=function(e,t){return!(!e||!t)&&(e[0]===t[0]&&e[1]===t[1])},e}(e("./BaseRenderLayer").BaseRenderLayer);i.SelectionRenderLayer=n},{"./BaseRenderLayer":26}],34:[function(e,t,i){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var w=e("../Buffer"),L=e("./atlas/Types"),a=e("./GridCache"),s=e("./BaseRenderLayer"),p=e("./atlas/CharAtlasUtils"),o=function(o){function e(e,t,i,r,n){var s=o.call(this,e,"text",t,n,i)||this;return s._characterOverlapCache={},s._state=new a.GridCache,s._characterJoinerRegistry=r,s}return n(e,o),e.prototype.resize=function(e,t){o.prototype.resize.call(this,e,t);var i=this._getFont(e,!1,!1);this._characterWidth===t.scaledCharWidth&&this._characterFont===i||(this._characterWidth=t.scaledCharWidth,this._characterFont=i,this._characterOverlapCache={}),this._state.clear(),this._state.resize(e.cols,e.rows)},e.prototype.reset=function(e){this._state.clear(),this.clearAll()},e.prototype._forEachCell=function(e,t,i,r,n){for(var s=t;s<=i;s++)for(var o=s+e.buffer.ydisp,a=e.buffer.lines.get(o),l=r?r.getJoinedCharacters(o):[],h=0;h>18,g=511&f,v=f>>9&511;if(8&C){var b=g;g=v,(v=b)===L.DEFAULT_COLOR&&(v=L.INVERTED_DEFAULT_COLOR),g===L.DEFAULT_COLOR&&(g=L.INVERTED_DEFAULT_COLOR)}n(u,_,d,h,s,v,g,C),h=m}}},e.prototype._drawBackground=function(e,t,i){var h=this,c=this._ctx,u=e.cols,_=0,f=0,d=null;c.save(),this._forEachCell(e,t,i,null,function(e,t,i,r,n,s,o,a){var l=null;o===L.INVERTED_DEFAULT_COLOR?l=h._colors.foreground.css:p.is256Color(o)&&(l=h._colors.ansi[o].css),null===d&&(_=r,f=n),n!==f?(c.fillStyle=d,h.fillCells(_,f,u-_,1),_=r,f=n):d!==l&&(c.fillStyle=d,h.fillCells(_,f,r-_,1),_=r,f=n),d=l}),null!==d&&(c.fillStyle=d,this.fillCells(_,f,u-_,1)),c.restore()},e.prototype._drawForeground=function(l,e,t){var h=this;this._forEachCell(l,e,t,this._characterJoinerRegistry,function(e,t,i,r,n,s,o,a){16&a||(2&a&&(h._ctx.save(),s===L.INVERTED_DEFAULT_COLOR?h._ctx.fillStyle=h._colors.background.css:p.is256Color(s)?h._ctx.fillStyle=h._colors.ansi[s].css:h._ctx.fillStyle=h._colors.foreground.css,h.fillBottomLineAtCells(r,n,i),h._ctx.restore()),h.drawChars(l,t,e,i,r,n,s,o,!!(1&a),!!(32&a),!!(64&a)))})},e.prototype.onGridChanged=function(e,t,i){0!==this._state.cache.length&&(this._charAtlas&&this._charAtlas.beginFrame(),this.clearCells(0,t,e.cols,i-t+1),this._drawBackground(e,t,i),this._drawForeground(e,t,i))},e.prototype.onOptionsChanged=function(e){this.setTransparency(e,e.options.allowTransparency)},e.prototype._isOverlapping=function(e){if(1!==e[w.CHAR_DATA_WIDTH_INDEX])return!1;if(e[w.CHAR_DATA_CODE_INDEX]<256)return!1;var t=e[w.CHAR_DATA_CHAR_INDEX];if(this._characterOverlapCache.hasOwnProperty(t))return this._characterOverlapCache[t];this._ctx.save(),this._ctx.font=this._characterFont;var i=Math.floor(this._ctx.measureText(t).width)>this._characterWidth;return this._ctx.restore(),this._characterOverlapCache[t]=i},e}(s.BaseRenderLayer);i.TextRenderLayer=o},{"../Buffer":2,"./BaseRenderLayer":26,"./GridCache":30,"./atlas/CharAtlasUtils":38,"./atlas/Types":43}],35:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(){this._didWarmUp=!1}return e.prototype.dispose=function(){},e.prototype.warmUp=function(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)},e.prototype._doWarmUp=function(){},e.prototype.beginFrame=function(){},e}();i.default=r},{}],36:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var h=e("./CharAtlasUtils"),r=e("./DynamicCharAtlas"),n=e("./NoneCharAtlas"),s=e("./StaticCharAtlas"),c={none:n.default,static:s.default,dynamic:r.default},u=[];i.acquireCharAtlas=function(e,t,i,r){for(var n=h.generateConfig(i,r,e,t),s=0;s>>24,n=t.rgba>>>16&255,s=t.rgba>>>8&255,o=0;o=this.capacity)i=this._head,this._unlinkNode(i),delete this._map[i.key],i.key=e,i.value=t,this._map[e]=i;else{var r=this._nodePool;0t;)this._rowContainer.removeChild(this._rowElements.pop())},e.prototype.onResize=function(e,t){this._refreshRowElements(e,t),this._updateDimensions()},e.prototype.onCharSizeChanged=function(){this._updateDimensions()},e.prototype.onBlur=function(){this._rowContainer.classList.remove(d)},e.prototype.onFocus=function(){this._rowContainer.classList.add(d)},e.prototype.onSelectionChanged=function(e,t,i){for(;this._selectionContainer.children.length;)this._selectionContainer.removeChild(this._selectionContainer.children[0]);if(e&&t){var r=e[1]-this._terminal.buffer.ydisp,n=t[1]-this._terminal.buffer.ydisp,s=Math.max(r,0),o=Math.min(n,this._terminal.rows-1);if(!(s>=this._terminal.rows||o<0)){var a=document.createDocumentFragment();if(i)a.appendChild(this._createSelectionElement(s,e[0],t[0],o-s+1));else{var l=r===s?e[0]:0,h=s===o?t[0]:this._terminal.cols;a.appendChild(this._createSelectionElement(s,l,h));var c=o-s-1;if(a.appendChild(this._createSelectionElement(s+1,0,this._terminal.cols,c)),s!==o){var u=n===o?t[0]:this._terminal.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}}},e.prototype._createSelectionElement=function(e,t,i,r){void 0===r&&(r=1);var n=document.createElement("div");return n.style.height=r*this.dimensions.actualCellHeight+"px",n.style.top=e*this.dimensions.actualCellHeight+"px",n.style.left=t*this.dimensions.actualCellWidth+"px",n.style.width=this.dimensions.actualCellWidth*(i-t)+"px",n},e.prototype.onCursorMove=function(){},e.prototype.onOptionsChanged=function(){this._updateDimensions(),this.setTheme(void 0),this._terminal.refresh(0,this._terminal.rows-1)},e.prototype.clear=function(){this._rowElements.forEach(function(e){return e.innerHTML=""})},e.prototype.refreshRows=function(e,t){this._renderDebouncer.refresh(e,t)},e.prototype._renderRows=function(e,t){for(var i=this._terminal,r=i.buffer.ybase+i.buffer.y,n=this._terminal.buffer.x,s=e;s<=t;s++){var o=this._rowElements[s];o.innerHTML="";var a=s+i.buffer.ydisp,l=i.buffer.lines.get(a),h=i.options.cursorStyle;o.appendChild(this._rowFactory.createRow(l,a===r,h,n,this.dimensions.actualCellWidth,i.cols))}this._terminal.emit("refresh",{start:e,end:t})},Object.defineProperty(e.prototype,"_terminalSelector",{get:function(){return"."+c+this._terminalClass},enumerable:!0,configurable:!0}),e.prototype.registerCharacterJoiner=function(e){return-1},e.prototype.deregisterCharacterJoiner=function(e){return!1},e.prototype._onLinkHover=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)},e.prototype._onLinkLeave=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)},e.prototype._setCellUnderline=function(e,t,i,r,n,s){for(;e!==t||i!==r;){var o=this._rowElements[i];if(!o)return;o.children[e].style.textDecoration=s?"underline":"none",0===(e=(e+1)%n)&&i++}},e}(n.EventEmitter);i.DomRenderer=y},{"../../common/EventEmitter":17,"../../ui/RenderDebouncer":50,"../ColorManager":28,"../atlas/Types":43,"./DomRendererRowFactory":45}],45:[function(e,t,C){"use strict";Object.defineProperty(C,"__esModule",{value:!0});var g=e("../../Buffer"),v=e("../atlas/Types");C.BOLD_CLASS="xterm-bold",C.ITALIC_CLASS="xterm-italic",C.CURSOR_CLASS="xterm-cursor",C.CURSOR_STYLE_BLOCK_CLASS="xterm-cursor-block",C.CURSOR_STYLE_BAR_CLASS="xterm-cursor-bar",C.CURSOR_STYLE_UNDERLINE_CLASS="xterm-cursor-underline";var i=function(){function e(e){this._document=e}return e.prototype.createRow=function(e,t,i,r,n,s){for(var o=this._document.createDocumentFragment(),a=0,l=Math.min(e.length,s)-1;0<=l;l--){if((h=e.get(l))[g.CHAR_DATA_CODE_INDEX]!==g.NULL_CELL_CODE||t&&l===r){a=l+1;break}}for(l=0;l>18,p=511&u,m=u>>9&511;if(t&&l===r)switch(f.classList.add(C.CURSOR_CLASS),i){case"bar":f.classList.add(C.CURSOR_STYLE_BAR_CLASS);break;case"underline":f.classList.add(C.CURSOR_STYLE_UNDERLINE_CLASS);break;default:f.classList.add(C.CURSOR_STYLE_BLOCK_CLASS)}if(8&d){var y=p;p=m,(m=y)===v.DEFAULT_COLOR&&(m=v.INVERTED_DEFAULT_COLOR),p===v.DEFAULT_COLOR&&(p=v.INVERTED_DEFAULT_COLOR)}1&d&&(m<8&&(m+=8),f.classList.add(C.BOLD_CLASS)),64&d&&f.classList.add(C.ITALIC_CLASS),f.textContent=c,m!==v.DEFAULT_COLOR&&f.classList.add("xterm-fg-"+m),p!==v.DEFAULT_COLOR&&f.classList.add("xterm-bg-"+p),o.appendChild(f)}}return o},e}();C.DomRendererRowFactory=i},{"../../Buffer":2,"../atlas/Types":43}],46:[function(e,t,i){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var s=function(r){function e(e,t){var i=r.call(this)||this;return i._document=e,i._parentElement=t,i._measureElement=i._document.createElement("span"),i._measureElement.classList.add("xterm-char-measure-element"),i._measureElement.textContent="W",i._measureElement.setAttribute("aria-hidden","true"),i._parentElement.appendChild(i._measureElement),i}return n(e,r),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),e.prototype.measure=function(e){this._measureElement.style.fontFamily=e.fontFamily,this._measureElement.style.fontSize=e.fontSize+"px";var t=this._measureElement.getBoundingClientRect();0!==t.width&&0!==t.height&&(this._width===t.width&&this._height===t.height||(this._width=t.width,this._height=Math.ceil(t.height),this.emit("charsizechanged")))},e}(e("../common/EventEmitter").EventEmitter);i.CharMeasure=s},{"../common/EventEmitter":17}],47:[function(e,t,i){"use strict";function r(e){return e.replace(/\r?\n/g,"\r")}function n(e,t){return t?"[200~"+e+"[201~":e}function s(e,t){t.style.position="fixed",t.style.width="20px",t.style.height="20px",t.style.left=e.clientX-10+"px",t.style.top=e.clientY-10+"px",t.style.zIndex="1000",t.focus(),setTimeout(function(){t.style.position=null,t.style.width=null,t.style.height=null,t.style.left=null,t.style.top=null,t.style.zIndex=null},200)}Object.defineProperty(i,"__esModule",{value:!0}),i.prepareTextForTerminal=r,i.bracketTextForPaste=n,i.copyHandler=function(e,t,i){t.browser.isMSIE?window.clipboardData.setData("Text",i.selectionText):e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault()},i.pasteHandler=function(t,i){t.stopPropagation();var e=function(e){e=n(e=r(e),i.bracketedPasteMode),i.handler(e),i.textarea.value="",i.emit("paste",e),i.cancel(t)};i.browser.isMSIE?window.clipboardData&&e(window.clipboardData.getData("Text")):t.clipboardData&&e(t.clipboardData.getData("text/plain"))},i.moveTextAreaUnderMouseCursor=s,i.rightClickHandler=function(e,t,i,r){s(e,t),r&&!i.isClickInSelection(e)&&i.selectWordAtCursor(e),t.value=i.selectionText,t.select()}},{}],48:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=function(e,t,i,r){return e.addEventListener(t,i,r),{dispose:function(){i&&(e.removeEventListener(t,i,r),i=e=null)}}}},{}],49:[function(e,t,i){"use strict";var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var s=e("../common/Lifecycle"),o=e("./Lifecycle"),a=function(i){function e(e){var t=i.call(this)||this;return t._terminal=e,t._zones=[],t._areZonesActive=!1,t._tooltipTimeout=null,t._currentZone=null,t._lastHoverCoords=[null,null],t.register(o.addDisposableDomListener(t._terminal.element,"mousedown",function(e){return t._onMouseDown(e)})),t._mouseMoveListener=function(e){return t._onMouseMove(e)},t._clickListener=function(e){return t._onClick(e)},t}return n(e,i),e.prototype.dispose=function(){i.prototype.dispose.call(this),this._deactivate()},e.prototype.add=function(e){this._zones.push(e),1===this._zones.length&&this._activate()},e.prototype.clearAll=function(e,t){if(0!==this._zones.length){t||(e=0,t=this._terminal.rows-1);for(var i=0;ie&&r.y1<=t+1||r.y2>e&&r.y2<=t+1||r.y1t+1)&&(this._currentZone&&this._currentZone===r&&(this._currentZone.leaveCallback(),this._currentZone=null),this._zones.splice(i--,1))}0===this._zones.length&&this._deactivate()}},e.prototype._activate=function(){this._areZonesActive||(this._areZonesActive=!0,this._terminal.element.addEventListener("mousemove",this._mouseMoveListener),this._terminal.element.addEventListener("click",this._clickListener))},e.prototype._deactivate=function(){this._areZonesActive&&(this._areZonesActive=!1,this._terminal.element.removeEventListener("mousemove",this._mouseMoveListener),this._terminal.element.removeEventListener("click",this._clickListener))},e.prototype._onMouseMove=function(e){this._lastHoverCoords[0]===e.pageX&&this._lastHoverCoords[1]===e.pageY||(this._onHover(e),this._lastHoverCoords=[e.pageX,e.pageY])},e.prototype._onHover=function(e){var t=this,i=this._findZoneEventAt(e);i!==this._currentZone&&(this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=null,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout)),i&&((this._currentZone=i).hoverCallback&&i.hoverCallback(e),this._tooltipTimeout=setTimeout(function(){return t._onTooltip(e)},500)))},e.prototype._onTooltip=function(e){this._tooltipTimeout=null;var t=this._findZoneEventAt(e);t&&t.tooltipCallback&&t.tooltipCallback(e)},e.prototype._onMouseDown=function(e){if(this._areZonesActive){var t=this._findZoneEventAt(e);t&&t.willLinkActivate(e)&&(e.preventDefault(),e.stopImmediatePropagation())}},e.prototype._onClick=function(e){var t=this._findZoneEventAt(e);t&&(t.clickCallback(e),e.preventDefault(),e.stopImmediatePropagation())},e.prototype._findZoneEventAt=function(e){var t=this._terminal.mouseHelper.getCoords(e,this._terminal.screenElement,this._terminal.charMeasure,this._terminal.cols,this._terminal.rows);if(!t)return null;for(var i=t[0],r=t[1],n=0;n=s.x1&&i=s.x1||r===s.y2&&is.y1&&r