!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.WebglAddon=e():t.WebglAddon=e()}(window,function(){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(r,o,function(e){return t[e]}.bind(null,o));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_COLOR=256,e.DEFAULT_ATTR=256|e.DEFAULT_COLOR<<9,e.CHAR_DATA_ATTR_INDEX=0,e.CHAR_DATA_CHAR_INDEX=1,e.CHAR_DATA_WIDTH_INDEX=2,e.CHAR_DATA_CODE_INDEX=3,e.NULL_CELL_CHAR="",e.NULL_CELL_WIDTH=1,e.NULL_CELL_CODE=0,e.WHITESPACE_CELL_CHAR=" ",e.WHITESPACE_CELL_WIDTH=1,e.WHITESPACE_CELL_CODE=32},function(t,e,i){"use strict";function r(t,e,i){var r=o(t.createShader(e));if(t.shaderSource(r,i),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS))return r;console.error(t.getShaderInfoLog(r)),t.deleteShader(r)}function o(t){if(!t)throw new Error("value must not be falsy");return t}Object.defineProperty(e,"__esModule",{value:!0}),e.PROJECTION_MATRIX=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]),e.createProgram=function(t,e,i){var n=o(t.createProgram());if(t.attachShader(n,o(r(t,t.VERTEX_SHADER,e))),t.attachShader(n,o(r(t,t.FRAGMENT_SHADER,i))),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS))return n;console.error(t.getProgramInfoLog(n)),t.deleteProgram(n)},e.createShader=r,e.expandFloat32Array=function(t,e){for(var i=Math.min(2*t.length,e),r=new Float32Array(i),o=0;o=t.length)return t;i=(t.length+i)%t.length,r=r>=t.length?t.length:(t.length+r)%t.length;for(var o=i;o.5?this._colors.selection={css:"#000",rgba:255}:this._colors.selection={css:"#fff",rgba:4294967295}},i.prototype.setColors=function(t){var e=this;this._colors=t,this._applyBgLuminanceBasedSelection(),this._renderLayers.forEach(function(t){t.setColors(e._terminal,e._colors),t.reset(e._terminal)}),this._rectangleRenderer.setColors(),this._glyphRenderer.setColors(),this._refreshCharAtlas(),this._model.clear()},i.prototype.onDevicePixelRatioChange=function(){this._devicePixelRatio!==window.devicePixelRatio&&(this._devicePixelRatio=window.devicePixelRatio,this.onResize(this._terminal.cols,this._terminal.rows))},i.prototype.onResize=function(t,e){var i=this;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows),this._rectangleRenderer.onResize(),this._renderLayers.forEach(function(t){return t.resize(i._terminal,i.dimensions)}),this._canvas.width=this.dimensions.scaledCanvasWidth,this._canvas.height=this.dimensions.scaledCanvasHeight,this._canvas.style.width=this.dimensions.canvasWidth+"px",this._canvas.style.height=this.dimensions.canvasHeight+"px",this._core.screenElement.style.width=this.dimensions.canvasWidth+"px",this._core.screenElement.style.height=this.dimensions.canvasHeight+"px",this._glyphRenderer.setDimensions(this.dimensions),this._glyphRenderer.onResize(),this._refreshCharAtlas(),this._model.clear()},i.prototype.onCharSizeChanged=function(){this.onResize(this._terminal.cols,this._terminal.rows)},i.prototype.onBlur=function(){var t=this;this._renderLayers.forEach(function(e){return e.onBlur(t._terminal)})},i.prototype.onFocus=function(){var t=this;this._renderLayers.forEach(function(e){return e.onFocus(t._terminal)})},i.prototype.onSelectionChanged=function(t,e,i){var r=this;this._renderLayers.forEach(function(o){return o.onSelectionChanged(r._terminal,t,e,i)}),this._updateSelectionModel(t,e),this._rectangleRenderer.updateSelection(this._model.selection,i),this._glyphRenderer.updateSelection(this._model,i),this._core.refresh(0,this._terminal.rows-1)},i.prototype.onCursorMove=function(){var t=this;this._renderLayers.forEach(function(e){return e.onCursorMove(t._terminal)})},i.prototype.onOptionsChanged=function(){var t=this;this._renderLayers.forEach(function(e){return e.onOptionsChanged(t._terminal)}),this._updateDimensions(),this._refreshCharAtlas()},i.prototype._refreshCharAtlas=function(){if(!(this.dimensions.scaledCharWidth<=0&&this.dimensions.scaledCharHeight<=0)){var t=l.acquireCharAtlas(this._terminal,this._colors,this.dimensions.scaledCharWidth,this.dimensions.scaledCharHeight);if(!("getRasterizedGlyph"in t))throw new Error("The webgl renderer only works with the webgl char atlas");this._charAtlas=t,this._charAtlas.warmUp(),this._glyphRenderer.setAtlas(this._charAtlas)}},i.prototype.clear=function(){var t=this;this._renderLayers.forEach(function(e){return e.reset(t._terminal)})},i.prototype.registerCharacterJoiner=function(t){return-1},i.prototype.deregisterCharacterJoiner=function(t){return!1},i.prototype.renderRows=function(t,e){var i=this;this._renderLayers.forEach(function(r){return r.onGridChanged(i._terminal,t,e)}),this._glyphRenderer.beginFrame()&&this._model.clear(),this._updateModel(t,e),this._rectangleRenderer.render(),this._glyphRenderer.render(this._model,this._model.selection.hasSelection)},i.prototype._updateModel=function(t,i){for(var r=this._core,o=t;o<=i;o++){var n=o+r.buffer.ydisp,s=r.buffer.lines.get(n);this._model.lineLengths[o]=0;for(var a=0;a>18,g=511&f,m=f>>9&511;if(8&C){var y=g;g=m,(m=y)===u.DEFAULT_COLOR&&(m=h.INVERTED_DEFAULT_COLOR),g===u.DEFAULT_COLOR&&(g=h.INVERTED_DEFAULT_COLOR)}m+=r.options.drawBoldTextInBrightColors&&!!(1&C)&&m<8&&m!==h.INVERTED_DEFAULT_COLOR?8:0,c.length>1&&(d|=_.COMBINED_CHAR_BIT_MASK),this._model.cells[v]=d,this._model.cells[v+1]=f,this._model.cells[v+2]=g,this._model.cells[v+3]=m,this._glyphRenderer.updateCell(a,o,d,f,g,m,c)}}}this._rectangleRenderer.updateBackgrounds(this._model)},i.prototype._updateSelectionModel=function(t,e){var i=this._terminal;if(t&&e&&(t[0]!==e[0]||t[1]!==e[1])){var r=t[1]-i.buffer.viewportY,o=e[1]-i.buffer.viewportY,n=Math.max(r,0),s=Math.min(o,i.rows-1);n>=i.rows||s<0?this._model.clearSelection():(this._model.selection.hasSelection=!0,this._model.selection.viewportStartRow=r,this._model.selection.viewportEndRow=o,this._model.selection.viewportCappedStartRow=n,this._model.selection.viewportCappedEndRow=s,this._model.selection.startCol=t[0],this._model.selection.endCol=e[0])}else this._model.clearSelection()},i.prototype._updateDimensions=function(){this._core._charSizeService.width&&this._core._charSizeService.height&&(this.dimensions.scaledCharWidth=Math.floor(this._core._charSizeService.width*this._devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._core._charSizeService.height*this._devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._terminal.getOption("lineHeight")),this.dimensions.scaledCharTop=1===this._terminal.getOption("lineHeight")?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._terminal.getOption("letterSpacing")),this.dimensions.scaledCharLeft=Math.floor(this._terminal.getOption("letterSpacing")/2),this.dimensions.scaledCanvasHeight=this._terminal.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._terminal.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/this._devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/this._devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.scaledCellHeight/this._devicePixelRatio,this.dimensions.actualCellWidth=this.dimensions.scaledCellWidth/this._devicePixelRatio)},i}(d.Disposable);e.WebglRenderer=v},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(4);e.RENDER_MODEL_INDICIES_PER_CELL=4,e.COMBINED_CHAR_BIT_MASK=2147483648;var o=function(){function t(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection={hasSelection:!1,viewportStartRow:0,viewportEndRow:0,viewportCappedStartRow:0,viewportCappedEndRow:0,startCol:0,endCol:0}}return t.prototype.resize=function(t,i){var r=t*i*e.RENDER_MODEL_INDICIES_PER_CELL;r!==this.cells.length&&(this.cells=new Uint32Array(r),this.lineLengths=new Uint32Array(i))},t.prototype.clear=function(){r.fill(this.cells,0,0),r.fill(this.lineLengths,0,0),this.clearSelection()},t.prototype.clearSelection=function(){this.selection.hasSelection=!1,this.selection.viewportStartRow=0,this.selection.viewportEndRow=0,this.selection.viewportCappedStartRow=0,this.selection.viewportCappedEndRow=0,this.selection.startCol=0,this.selection.endCol=0},t}();e.RenderModel=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getLuminance=function(t){return(.299*(t.rgba>>24&255)+.587*(t.rgba>>16&255)+.114*(t.rgba>>8&255))/255}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(9),o=i(1),n=function(){function t(t,e,i,r,o){this._container=t,this._alpha=r,this._colors=o,this._scaledCharWidth=0,this._scaledCharHeight=0,this._scaledCellWidth=0,this._scaledCellHeight=0,this._scaledCharLeft=0,this._scaledCharTop=0,this._currentGlyphIdentifier={chars:"",code:0,bg:0,fg:0,bold:!1,dim:!1,italic:!1},this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-"+e+"-layer"),this._canvas.style.zIndex=i.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return t.prototype.dispose=function(){this._container.removeChild(this._canvas),this._charAtlas&&this._charAtlas.dispose()},t.prototype._initCanvas=function(){this._ctx=o.throwIfFalsy(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()},t.prototype.onOptionsChanged=function(t){},t.prototype.onBlur=function(t){},t.prototype.onFocus=function(t){},t.prototype.onCursorMove=function(t){},t.prototype.onGridChanged=function(t,e,i){},t.prototype.onSelectionChanged=function(t,e,i,r){void 0===r&&(r=!1)},t.prototype.setColors=function(t,e){this._refreshCharAtlas(t,e)},t.prototype._setTransparency=function(t,e){if(e!==this._alpha){var i=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(t,this._colors),this.onGridChanged(t,0,t.rows-1)}},t.prototype._refreshCharAtlas=function(t,e){this._scaledCharWidth<=0&&this._scaledCharHeight<=0||(this._charAtlas=r.acquireCharAtlas(t,e,this._scaledCharWidth,this._scaledCharHeight),this._charAtlas.warmUp())},t.prototype.resize=function(t,e){this._scaledCellWidth=e.scaledCellWidth,this._scaledCellHeight=e.scaledCellHeight,this._scaledCharWidth=e.scaledCharWidth,this._scaledCharHeight=e.scaledCharHeight,this._scaledCharLeft=e.scaledCharLeft,this._scaledCharTop=e.scaledCharTop,this._canvas.width=e.scaledCanvasWidth,this._canvas.height=e.scaledCanvasHeight,this._canvas.style.width=e.canvasWidth+"px",this._canvas.style.height=e.canvasHeight+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._colors)},t.prototype._fillCells=function(t,e,i,r){this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight)},t.prototype._fillBottomLineAtCells=function(t,e,i){void 0===i&&(i=1),this._ctx.fillRect(t*this._scaledCellWidth,(e+1)*this._scaledCellHeight-window.devicePixelRatio-1,i*this._scaledCellWidth,window.devicePixelRatio)},t.prototype._fillLeftLineAtCell=function(t,e){this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,window.devicePixelRatio,this._scaledCellHeight)},t.prototype._strokeRectAtCell=function(t,e,i,r){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(t*this._scaledCellWidth+window.devicePixelRatio/2,e*this._scaledCellHeight+window.devicePixelRatio/2,i*this._scaledCellWidth-window.devicePixelRatio,r*this._scaledCellHeight-window.devicePixelRatio)},t.prototype._clearAll=function(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))},t.prototype._clearCells=function(t,e,i,r){this._alpha?this._ctx.clearRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(t*this._scaledCellWidth,e*this._scaledCellHeight,i*this._scaledCellWidth,r*this._scaledCellHeight))},t.prototype._fillCharTrueColor=function(t,e,i,r){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline="middle",this._clipRow(t,r),this._ctx.fillText(e.getChars(),i*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2)},t.prototype._clipRow=function(t,e){this._ctx.beginPath(),this._ctx.rect(0,e*this._scaledCellHeight,t.cols*this._scaledCellWidth,this._scaledCellHeight),this._ctx.clip()},t.prototype._getFont=function(t,e,i){return(i?"italic":"")+" "+(e?t.getOption("fontWeightBold"):t.getOption("fontWeight"))+" "+t.getOption("fontSize")*window.devicePixelRatio+"px "+t.getOption("fontFamily")},t}();e.BaseRenderLayer=n},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(2),o=i(15),n=[];e.acquireCharAtlas=function(t,e,i,s){for(var a=r.generateConfig(i,s,t,e),l=0;l=0){if(r.configEquals(h.config,a))return h.atlas;1===h.ownedBy.length?(h.atlas.dispose(),n.splice(l,1)):h.ownedBy.splice(c,1);break}}for(l=0;l>22},e.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?n.stringFromCodePoint(2097151&this.content):""},e.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},e.prototype.setFromCharData=function(t){this.fg=t[s.CHAR_DATA_ATTR_INDEX],this.bg=0;var e=!1;if(t[s.CHAR_DATA_CHAR_INDEX].length>2)e=!0;else if(2===t[s.CHAR_DATA_CHAR_INDEX].length){var i=t[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=i&&i<=56319){var r=t[s.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|t[s.CHAR_DATA_WIDTH_INDEX]<<22:e=!0}else e=!0}else this.content=t[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[s.CHAR_DATA_WIDTH_INDEX]<<22;e&&(this.combinedData=t[s.CHAR_DATA_CHAR_INDEX],this.content=2097152|t[s.CHAR_DATA_WIDTH_INDEX]<<22)},e.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},e}(i(18).AttributeData);e.CellData=a},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(5),o=function(){function t(t){this._preserveDrawingBuffer=t}return t.prototype.activate=function(t){if(!t.element)throw new Error("Cannot activate WebglRendererAddon before Terminal.open");var e=t._core._renderService,i=t._core._colorManager.colors;e.setRenderer(new r.WebglRenderer(t,i,this._preserveDrawingBuffer))},t.prototype.dispose=function(){throw new Error("WebglRendererAddon.dispose Not yet implemented")},t}();e.WebglAddon=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),o=i(5),n=i(6),s=i(4),a=i(13),l=i(0),c=i(7),h="#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in vec2 a_texcoord;\nlayout (location = 5) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",_="#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\n\nuniform sampler2D u_texture;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = texture(u_texture, v_texcoord);\n}",d=10*Float32Array.BYTES_PER_ELEMENT,u=function(){function t(t,e,i,o){this._terminal=t,this._colors=e,this._gl=i,this._dimensions=o,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)],selectionAttributes:new Float32Array(0)};var n=this._gl,s=r.throwIfFalsy(r.createProgram(n,h,_));if(void 0===s)throw new Error("Could not create WebGL program");this._program=s,this._projectionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_resolution")),this._textureLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=n.createVertexArray(),n.bindVertexArray(this._vertexArrayObject);var a=new Float32Array([0,0,1,0,0,1,1,1]),l=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,l),n.bufferData(n.ARRAY_BUFFER,a,n.STATIC_DRAW),n.enableVertexAttribArray(0),n.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);var c=new Uint8Array([0,1,3,0,2,3]),u=n.createBuffer();n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,u),n.bufferData(n.ELEMENT_ARRAY_BUFFER,c,n.STATIC_DRAW),this._attributesBuffer=r.throwIfFalsy(n.createBuffer()),n.bindBuffer(n.ARRAY_BUFFER,this._attributesBuffer),n.enableVertexAttribArray(2),n.vertexAttribPointer(2,2,n.FLOAT,!1,d,0),n.vertexAttribDivisor(2,1),n.enableVertexAttribArray(3),n.vertexAttribPointer(3,2,n.FLOAT,!1,d,2*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(3,1),n.enableVertexAttribArray(4),n.vertexAttribPointer(4,2,n.FLOAT,!1,d,4*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(4,1),n.enableVertexAttribArray(5),n.vertexAttribPointer(5,2,n.FLOAT,!1,d,6*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(5,1),n.enableVertexAttribArray(1),n.vertexAttribPointer(1,2,n.FLOAT,!1,d,8*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(1,1),this._atlasTexture=r.throwIfFalsy(n.createTexture()),n.bindTexture(n.TEXTURE_2D,this._atlasTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,new Uint8Array([0,0,255,255])),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),this.onResize()}return t.prototype.beginFrame=function(){return!this._atlas||this._atlas.beginFrame()},t.prototype.updateCell=function(t,e,i,r,o,n,s){this._updateCell(this._vertices.attributes,t,e,i,r,o,n,s)},t.prototype._updateCell=function(t,e,i,r,o,n,a,c){var h=10*(i*this._terminal.cols+e);if(r!==l.NULL_CELL_CODE&&r!==l.WHITESPACE_CELL_CODE&&void 0!==r){var _;if(!this._atlas)throw new Error("atlas must be set before updating cell");(_=c&&c.length>1?this._atlas.getRasterizedGlyphCombinedChar(c,o,n,a):this._atlas.getRasterizedGlyph(r,o,n,a))?(t[h]=-_.offset.x+this._dimensions.scaledCharLeft,t[h+1]=-_.offset.y+this._dimensions.scaledCharTop,t[h+2]=_.size.x/this._dimensions.scaledCanvasWidth,t[h+3]=_.size.y/this._dimensions.scaledCanvasHeight,t[h+4]=_.texturePositionClipSpace.x,t[h+5]=_.texturePositionClipSpace.y,t[h+6]=_.sizeClipSpace.x,t[h+7]=_.sizeClipSpace.y):s.fill(t,0,h,h+10-1-2)}else s.fill(t,0,h,h+10-1-2)},t.prototype.updateSelection=function(t,e){var i=this._terminal;this._vertices.selectionAttributes=a.slice(this._vertices.attributes,0);var r=c.getLuminance(this._colors.background),o=r>.5?7:0,n=r>.5?0:7;if(e)for(var s=t.selection.startCol,l=t.selection.endCol-s,h=t.selection.viewportCappedEndRow-t.selection.viewportCappedStartRow+1,_=t.selection.viewportCappedStartRow;_=t.length?t.length:(t.length+i)%t.length,e=Math.min(e,i);for(var r=new t.constructor(i-e),o=0;o0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}},e.prototype._onLinkHover=function(t){if(t.fg===s.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._colors.background.css:void 0!==t.fg&&a.is256Color(t.fg)?this._ctx.fillStyle=this._colors.ansi[t.fg].css:this._ctx.fillStyle=this._colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(var e=t.y1+1;ec&&(this._cacheCtx.clearRect(0,0,a,l),this._cacheMap={},this._currentRowHeight=0,this._currentRowX=0,this._currentRowY=0,this._doWarmUp(),!0)},t.prototype.getRasterizedGlyphCombinedChar=function(t,e,i,r){var o=this._cacheMapCombined[t];o||(o={},this._cacheMapCombined[t]=o);var n=o[e];return n||(n=this._drawToCache(t,e,i,r),o[e]=n),n},t.prototype.getRasterizedGlyph=function(t,e,i,r){var o=this._cacheMap[t];o||(o={},this._cacheMap[t]=o);var n=o[e];return n||(n=this._drawToCache(t,e,i,r),o[e]=n),n},t.prototype._getColorFromAnsiIndex=function(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]},t.prototype._getBackgroundColor=function(t){return this._config.allowTransparency?h:t===r.INVERTED_DEFAULT_COLOR?this._config.colors.foreground:n.is256Color(t)?this._getColorFromAnsiIndex(t):this._config.colors.background},t.prototype._getForegroundColor=function(t){return t===r.INVERTED_DEFAULT_COLOR?this._config.colors.background:n.is256Color(t)?this._getColorFromAnsiIndex(t):this._config.colors.foreground},t.prototype._drawToCache=function(t,e,i,o){var n="number"==typeof t?String.fromCharCode(t):t;this.hasCanvasChanged=!0;var s=e>>18,c=!!(1&s),h=!!(32&s),u=!!(64&s);this._tmpCtx.save();var f=this._getBackgroundColor(i);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=f.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";var p=c?this._config.fontWeightBold:this._config.fontWeight,v=u?"italic":"";this._tmpCtx.font=v+" "+p+" "+this._config.fontSize*this._config.devicePixelRatio+"px "+this._config.fontFamily,this._tmpCtx.textBaseline="top",this._tmpCtx.fillStyle=this._getForegroundColor(o).css,h&&(this._tmpCtx.globalAlpha=r.DIM_OPACITY),this._tmpCtx.fillText(n,d,d),this._tmpCtx.restore();var C=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(function(t,e){for(var i=!0,r=e.rgba>>>24,o=e.rgba>>>16&255,n=e.rgba>>>8&255,s=0;sa&&(this._currentRowX=0,this._currentRowY+=this._currentRowHeight,this._currentRowHeight=0),g.texturePosition.x=this._currentRowX,g.texturePosition.y=this._currentRowY,g.texturePositionClipSpace.x=this._currentRowX/a,g.texturePositionClipSpace.y=this._currentRowY/l,this._currentRowHeight=Math.max(this._currentRowHeight,g.size.y),this._currentRowX+=g.size.x,this._cacheCtx.putImageData(m,g.texturePosition.x,g.texturePosition.y),g},t.prototype._findGlyphBoundingBox=function(t,e){e.top=0;for(var i=!1,r=0;r=0;o--){for(r=0;r=0;r--){for(o=0;o=t.rows)this._clearCursor();else if(t._core.buffer.lines.get(i).loadCell(t.buffer.cursorX,this._cell),void 0!==this._cell.content){if(!c(t))return this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._renderBlurCursor(t,t.buffer.cursorX,r,this._cell),this._ctx.restore(),this._state.x=t.buffer.cursorX,this._state.y=r,this._state.isFocused=!1,this._state.style=t.getOption("cursorStyle"),void(this._state.width=this._cell.getWidth());if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===t.buffer.cursorX&&this._state.y===r&&this._state.isFocused===c(t)&&this._state.style===t.getOption("cursorStyle")&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[t.getOption("cursorStyle")||"block"](t,t.buffer.cursorX,r,this._cell),this._ctx.restore(),this._state.x=t.buffer.cursorX,this._state.y=r,this._state.isFocused=!1,this._state.style=t.getOption("cursorStyle"),this._state.width=this._cell.getWidth()}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:0,y:0,isFocused:!1,style:"",width:0})},e.prototype._renderBarCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,i),this._ctx.restore()},e.prototype._renderBlockCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,i,r.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(t,r,e,i),this._ctx.restore()},e.prototype._renderUnderlineCursor=function(t,e,i,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,i),this._ctx.restore()},e.prototype._renderBlurCursor=function(t,e,i,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,i,r.getWidth(),1),this._ctx.restore()},e}(n.BaseRenderLayer);e.CursorRenderLayer=a;var l=function(){function t(t,e){this._renderCallback=e,this.isCursorVisible=!0,c(t)&&this._restartInterval()}return Object.defineProperty(t.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},t.prototype.restartBlinkAnimation=function(t){var e=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})))},t.prototype._restartInterval=function(t){var e=this;void 0===t&&(t=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=setTimeout(function(){if(e._animationTimeRestarted){var t=600-(Date.now()-e._animationTimeRestarted);if(e._animationTimeRestarted=void 0,t>0)return void e._restartInterval(t)}e.isCursorVisible=!1,e._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0}),e._blinkInterval=setInterval(function(){if(e._animationTimeRestarted){var t=600-(Date.now()-e._animationTimeRestarted);return e._animationTimeRestarted=void 0,void e._restartInterval(t)}e.isCursorVisible=!e.isCursorVisible,e._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})},600)},t)},t.prototype.pause=function(){this.isCursorVisible=!0,this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},t.prototype.resume=function(t){this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation(t)},t}();function c(t){return document.activeElement===t.textarea&&document.hasFocus()}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.stringFromCodePoint=function(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)},e.utf32ToString=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);for(var r="",o=e;o65535?(n-=65536,r+=String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):r+=String.fromCharCode(n)}return r};var r=function(){function t(){this._interim=0}return t.prototype.clear=function(){this._interim=0},t.prototype.decode=function(t,e){var i=t.length;if(!i)return 0;var r=0,o=0;this._interim&&(56320<=(a=t.charCodeAt(o++))&&a<=57343?e[r++]=1024*(this._interim-55296)+a-56320+65536:(e[r++]=this._interim,e[r++]=a),this._interim=0);for(var n=o;n=i)return this._interim=s,r;var a;56320<=(a=t.charCodeAt(n))&&a<=57343?e[r++]=1024*(s-55296)+a-56320+65536:(e[r++]=s,e[r++]=a)}else e[r++]=s}return r},t}();e.StringToUtf32=r;var o=function(){function t(){this.interim=new Uint8Array(3)}return t.prototype.clear=function(){this.interim.fill(0)},t.prototype.decode=function(t,e){var i=t.length;if(!i)return 0;var r,o,n,s,a=0,l=0,c=0;if(this.interim[0]){var h=!1,_=this.interim[0];_&=192==(224&_)?31:224==(240&_)?15:7;for(var d=0,u=void 0;(u=63&this.interim[++d])&&d<4;)_<<=6,_|=u;for(var f=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,p=f-d;c=i)return 0;if(128!=(192&(u=t[c++]))){c--,h=!0;break}this.interim[d++]=u,_<<=6,_|=63&u}h||(2===f?_<128?c--:e[a++]=_:3===f?_<2048||_>=55296&&_<=57343||(e[a++]=_):l<65536||l>1114111||(e[a++]=_)),this.interim.fill(0)}for(var v=i-4,C=c;C=i)return this.interim[0]=r,a;if(128!=(192&(o=t[C++]))){C--;continue}if((l=(31&r)<<6|63&o)<128){C--;continue}e[a++]=l}else if(224==(240&r)){if(C>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[C++]))){C--;continue}if(C>=i)return this.interim[0]=r,this.interim[1]=o,a;if(128!=(192&(n=t[C++]))){C--;continue}if((l=(15&r)<<12|(63&o)<<6|63&n)<2048||l>=55296&&l<=57343)continue;e[a++]=l}else if(240==(248&r)){if(C>=i)return this.interim[0]=r,a;if(128!=(192&(o=t[C++]))){C--;continue}if(C>=i)return this.interim[0]=r,this.interim[1]=o,a;if(128!=(192&(n=t[C++]))){C--;continue}if(C>=i)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,a;if(128!=(192&(s=t[C++]))){C--;continue}if((l=(7&r)<<18|(63&o)<<12|(63&n)<<6|63&s)<65536||l>1114111)continue;e[a++]=l}}return a},t}();e.Utf8ToUtf32=o},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this.fg=0,this.bg=0}return t.toColorRGB=function(t){return[t>>>16&255,t>>>8&255,255&t]},t.fromColorRGB=function(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},t.prototype.clone=function(){var e=new t;return e.fg=this.fg,e.bg=this.bg,e},t.prototype.isInverse=function(){return 67108864&this.fg},t.prototype.isBold=function(){return 134217728&this.fg},t.prototype.isUnderline=function(){return 268435456&this.fg},t.prototype.isBlink=function(){return 536870912&this.fg},t.prototype.isInvisible=function(){return 1073741824&this.fg},t.prototype.isItalic=function(){return 67108864&this.bg},t.prototype.isDim=function(){return 134217728&this.bg},t.prototype.getFgColorMode=function(){return 50331648&this.fg},t.prototype.getBgColorMode=function(){return 50331648&this.bg},t.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},t.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},t.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},t.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},t.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},t.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},t.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},t.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},t}();e.AttributeData=r},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(1),o=i(4),n=i(3),s=i(2),a=i(0),l="#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec3 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec3 v_color;\n\nvoid main() {\n vec2 zeroToOne = (a_position + (a_unitquad * a_size)) / u_resolution;\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}",c="#version 300 es\nprecision lowp float;\n\nin vec3 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = vec4(v_color, 1);\n}",h=8,_=h*Float32Array.BYTES_PER_ELEMENT,d=20*h,u=function(){function t(t,e,i,o){this._terminal=t,this._colors=e,this._gl=i,this._dimensions=o,this._vertices={count:0,attributes:new Float32Array(d),selection:new Float32Array(3*h)};var n=this._gl;this._program=r.throwIfFalsy(r.createProgram(n,l,c)),this._resolutionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_resolution")),this._projectionLocation=r.throwIfFalsy(n.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=n.createVertexArray(),n.bindVertexArray(this._vertexArrayObject);var s=new Float32Array([0,0,1,0,0,1,1,1]),a=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,a),n.bufferData(n.ARRAY_BUFFER,s,n.STATIC_DRAW),n.enableVertexAttribArray(3),n.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);var u=new Uint8Array([0,1,3,0,2,3]),f=n.createBuffer();n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.bufferData(n.ELEMENT_ARRAY_BUFFER,u,n.STATIC_DRAW),this._attributesBuffer=r.throwIfFalsy(n.createBuffer()),n.bindBuffer(n.ARRAY_BUFFER,this._attributesBuffer),n.enableVertexAttribArray(0),n.vertexAttribPointer(0,2,n.FLOAT,!1,_,0),n.vertexAttribDivisor(0,1),n.enableVertexAttribArray(1),n.vertexAttribPointer(1,2,n.FLOAT,!1,_,2*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(1,1),n.enableVertexAttribArray(2),n.vertexAttribPointer(2,4,n.FLOAT,!1,_,4*Float32Array.BYTES_PER_ELEMENT),n.vertexAttribDivisor(2,1),this._updateCachedColors()}return t.prototype.render=function(){var t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,r.PROJECTION_MATRIX),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertices.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLES,6,t.UNSIGNED_BYTE,0,this._vertices.count),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,this._vertices.selection,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLES,6,t.UNSIGNED_BYTE,0,3)},t.prototype.onResize=function(){this._updateViewportRectangle()},t.prototype.setColors=function(){this._updateCachedColors(),this._updateViewportRectangle()},t.prototype._updateCachedColors=function(){this._bgFloat=this._colorToFloat32Array(this._colors.background),this._selectionFloat=this._colorToFloat32Array(this._colors.selection)},t.prototype._updateViewportRectangle=function(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.scaledCellWidth,this._terminal.rows*this._dimensions.scaledCellHeight,this._bgFloat)},t.prototype.updateSelection=function(t,e){var i=this._terminal;if(t.hasSelection)if(e){var r=t.startCol,n=t.endCol-r,s=t.viewportCappedEndRow-t.viewportCappedStartRow+1;this._addRectangleFloat(this._vertices.selection,0,r*this._dimensions.scaledCellWidth,t.viewportCappedStartRow*this._dimensions.scaledCellHeight,n*this._dimensions.scaledCellWidth,s*this._dimensions.scaledCellHeight,this._selectionFloat),o.fill(this._vertices.selection,0,h)}else{r=t.viewportStartRow===t.viewportCappedStartRow?t.startCol:0;var a=t.viewportCappedStartRow===t.viewportCappedEndRow?t.endCol:i.cols;this._addRectangleFloat(this._vertices.selection,0,r*this._dimensions.scaledCellWidth,t.viewportCappedStartRow*this._dimensions.scaledCellHeight,(a-r)*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,this._selectionFloat);var l=Math.max(t.viewportCappedEndRow-t.viewportCappedStartRow-1,0);if(this._addRectangleFloat(this._vertices.selection,h,0,(t.viewportCappedStartRow+1)*this._dimensions.scaledCellHeight,i.cols*this._dimensions.scaledCellWidth,l*this._dimensions.scaledCellHeight,this._selectionFloat),t.viewportCappedStartRow!==t.viewportCappedEndRow){var c=t.viewportEndRow===t.viewportCappedEndRow?t.endCol:i.cols;this._addRectangleFloat(this._vertices.selection,2*h,0,t.viewportCappedEndRow*this._dimensions.scaledCellHeight,c*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,this._selectionFloat)}else o.fill(this._vertices.selection,0,2*h)}else o.fill(this._vertices.selection,0,0)},t.prototype.updateBackgrounds=function(t){for(var e=this._terminal,i=this._vertices,r=1,o=0;o>24&255)/255,f=(c.rgba>>16&255)/255,p=(c.rgba>>8&255)/255;this._addRectangle(t.attributes,e,_,d,(a-o)*this._dimensions.scaledCellWidth,this._dimensions.scaledCellHeight,u,f,p,1)},t.prototype._addRectangle=function(t,e,i,r,o,n,s,a,l,c){t[e]=i,t[e+1]=r,t[e+2]=o,t[e+3]=n,t[e+4]=s,t[e+5]=a,t[e+6]=l,t[e+7]=c},t.prototype._addRectangleFloat=function(t,e,i,r,o,n,s){t[e]=i,t[e+1]=r,t[e+2]=o,t[e+3]=n,t[e+4]=s[0],t[e+5]=s[1],t[e+6]=s[2],t[e+7]=s[3]},t.prototype._colorToFloat32Array=function(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(255&t.rgba)/255])},t}();e.RectangleRenderer=u},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this._disposables=[],this._isDisposed=!1}return t.prototype.dispose=function(){this._isDisposed=!0,this._disposables.forEach(function(t){return t.dispose()}),this._disposables.length=0},t.prototype.register=function(t){this._disposables.push(t)},t.prototype.unregister=function(t){var e=this._disposables.indexOf(t);-1!==e&&this._disposables.splice(e,1)},t}();e.Disposable=r},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(10);e.getCompatAttr=function(t,e){var i=new r.CellData;return t.loadCell(e,i),(-1===i.getBgColor()?256:i.getBgColor())|(-1===i.getFgColor()?256:i.getFgColor())<<9|((i.isBold()?1:0)|(i.isUnderline()?2:0)|(i.isBlink()?4:0)|(i.isInverse()?8:0)|(i.isDim()?32:0)|(i.isItalic()?64:0))<<18}}])}); //# sourceMappingURL=xterm-addon-webgl.js.map