From 6a1eef06277c0e187a09a847bc3f90ae86e892c5 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Mon, 6 Apr 2020 12:56:00 +0200 Subject: [PATCH 001/120] QEMU config disk - initial implementation. Ref #2958 (cherry picked from commit b69965791df773f75cbca76f74c8931afeae2ff0) --- gns3server/compute/qemu/qemu_vm.py | 152 +++++++++++++++++++++++++---- 1 file changed, 133 insertions(+), 19 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 69494b51..1eeeb8c0 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -38,6 +38,7 @@ from gns3server.utils.asyncio import subprocess_check_output, cancellable_wait_r from .qemu_error import QemuError from .utils.qcow2 import Qcow2, Qcow2Error from ..adapters.ethernet_adapter import EthernetAdapter +from ..error import NodeError, ImageMissingError from ..nios.nio_udp import NIOUDP from ..nios.nio_tap import NIOTAP from ..base_node import BaseNode @@ -125,6 +126,22 @@ class QemuVM(BaseNode): self.mac_address = "" # this will generate a MAC address self.adapters = 1 # creates 1 adapter by default + + # config disk + self.config_disk_name = "config.img" + if not shutil.which("mcopy"): + log.warning("Config disk: 'mtools' are not installed.") + self.config_disk_name = "" + self.config_disk_image = "" + else: + try: + self.config_disk_image = self.manager.get_abs_image_path( + self.config_disk_name, self.project.path) + except (NodeError, ImageMissingError) as e: + log.warning("Config disk: {}".format(e)) + self.config_disk_name = "" + self.config_disk_image = "" + log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id)) @property @@ -1115,6 +1132,7 @@ class QemuVM(BaseNode): self._stop_cpulimit() if self.on_close != "save_vm_state": await self._clear_save_vm_stated() + await self._export_config() await super().stop() async def _open_qemu_monitor_connection_vm(self, timeout=10): @@ -1627,6 +1645,96 @@ class QemuVM(BaseNode): log.info("{} returned with {}".format(self._get_qemu_img(), retcode)) return retcode + async def _mcopy(self, *args): + env = os.environ + env["MTOOLSRC"] = 'mtoolsrc' + try: + process = await asyncio.create_subprocess_exec("mcopy", *args, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.working_dir, env=env) + (stdout, _) = await process.communicate() + retcode = process.returncode + except (OSError, subprocess.SubprocessError) as e: + log.error("mcopy failure: {}".format(e)) + return 1 + if retcode != 0: + stdout = stdout.decode("utf-8").rstrip() + if stdout: + log.error("mcopy failure: {}".format(stdout)) + else: + log.error("mcopy failure: return code {}".format(retcode)) + return retcode + + async def _export_config(self): + disk_name = getattr(self, "config_disk_name") + if not disk_name or \ + not os.path.exists(os.path.join(self.working_dir, disk_name)): + return + config_dir = os.path.join(self.working_dir, "configs") + zip_file = os.path.join(self.working_dir, "config.zip") + try: + shutil.rmtree(config_dir, ignore_errors=True) + os.mkdir(config_dir) + if os.path.exists(zip_file): + os.remove(zip_file) + if await self._mcopy("-s", "-m", "x:/", config_dir) == 0: + shutil.make_archive(zip_file[:-4], "zip", config_dir) + except OSError as e: + log.error("Can't export config: {}".format(e)) + finally: + shutil.rmtree(config_dir, ignore_errors=True) + + async def _import_config(self): + disk_name = getattr(self, "config_disk_name") + zip_file = os.path.join(self.working_dir, "config.zip") + if not disk_name or not os.path.exists(zip_file): + return + config_dir = os.path.join(self.working_dir, "configs") + disk = os.path.join(self.working_dir, disk_name) + try: + shutil.rmtree(config_dir, ignore_errors=True) + os.mkdir(config_dir) + shutil.unpack_archive(zip_file, config_dir) + shutil.copyfile(getattr(self, "config_disk_image"), disk) + config_files = [os.path.join(config_dir, fname) + for fname in os.listdir(config_dir)] + if config_files: + if await self._mcopy("-s", "-m", *config_files, "x:/") != 0: + os.remove(disk) + os.remove(zip_file) + except OSError as e: + log.error("Can't import config: {}".format(e)) + os.remove(zip_file) + finally: + shutil.rmtree(config_dir, ignore_errors=True) + + def _disk_interface_options(self, disk, disk_index, interface, format=None): + options = [] + extra_drive_options = "" + if format: + extra_drive_options += ",format={}".format(format) + + # From Qemu man page: if the filename contains comma, you must double it + # (for instance, "file=my,,file" to use file "my,file"). + disk = disk.replace(",", ",,") + + if interface == "sata": + # special case, sata controller doesn't exist in Qemu + options.extend(["-device", 'ahci,id=ahci{}'.format(disk_index)]) + options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk{}'.format(disk, disk_index, disk_index, extra_drive_options)]) + options.extend(["-device", 'ide-drive,drive=drive{},bus=ahci{}.0,id=drive{}'.format(disk_index, disk_index, disk_index)]) + elif interface == "nvme": + options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk{}'.format(disk, disk_index, disk_index, extra_drive_options)]) + options.extend(["-device", 'nvme,drive=drive{},serial={}'.format(disk_index, disk_index)]) + elif interface == "scsi": + options.extend(["-device", 'virtio-scsi-pci,id=scsi{}'.format(disk_index)]) + options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk{}'.format(disk, disk_index, disk_index, extra_drive_options)]) + options.extend(["-device", 'scsi-hd,drive=drive{}'.format(disk_index)]) + #elif interface == "sd": + # options.extend(["-drive", 'file={},id=drive{},index={}{}'.format(disk, disk_index, disk_index, extra_drive_options)]) + # options.extend(["-device", 'sd-card,drive=drive{},id=drive{}'.format(disk_index, disk_index, disk_index)]) + else: + options.extend(["-drive", 'file={},if={},index={},media=disk,id=drive{}{}'.format(disk, interface, disk_index, disk_index, extra_drive_options)]) + return options + async def _disk_options(self): options = [] qemu_img_path = self._get_qemu_img() @@ -1691,27 +1799,33 @@ class QemuVM(BaseNode): else: disk = disk_image - # From Qemu man page: if the filename contains comma, you must double it - # (for instance, "file=my,,file" to use file "my,file"). - disk = disk.replace(",", ",,") + options.extend(self._disk_interface_options(disk, disk_index, interface)) - if interface == "sata": - # special case, sata controller doesn't exist in Qemu - options.extend(["-device", 'ahci,id=ahci{}'.format(disk_index)]) - options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk'.format(disk, disk_index, disk_index)]) - options.extend(["-device", 'ide-drive,drive=drive{},bus=ahci{}.0,id=drive{}'.format(disk_index, disk_index, disk_index)]) - elif interface == "nvme": - options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk'.format(disk, disk_index, disk_index)]) - options.extend(["-device", 'nvme,drive=drive{},serial={}'.format(disk_index, disk_index)]) - elif interface == "scsi": - options.extend(["-device", 'virtio-scsi-pci,id=scsi{}'.format(disk_index)]) - options.extend(["-drive", 'file={},if=none,id=drive{},index={},media=disk'.format(disk, disk_index, disk_index)]) - options.extend(["-device", 'scsi-hd,drive=drive{}'.format(disk_index)]) - #elif interface == "sd": - # options.extend(["-drive", 'file={},id=drive{},index={}'.format(disk, disk_index, disk_index)]) - # options.extend(["-device", 'sd-card,drive=drive{},id=drive{}'.format(disk_index, disk_index, disk_index)]) + # config disk + disk_image = getattr(self, "config_disk_image") + if disk_image: + if getattr(self, "_hdd_disk_image"): + log.warning("Config disk: blocked by disk image 'hdd'") else: - options.extend(["-drive", 'file={},if={},index={},media=disk,id=drive{}'.format(disk, interface, disk_index, disk_index)]) + disk_name = getattr(self, "config_disk_name") + disk = os.path.join(self.working_dir, disk_name) + interface = getattr(self, "hda_disk_interface", "ide") + await self._import_config() + if not os.path.exists(disk): + try: + shutil.copyfile(disk_image, disk) + except OSError as e: + raise QemuError("Could not create '{}' disk image: {}".format(disk_name, e)) + mtoolsrc = os.path.join(self.working_dir, "mtoolsrc") + if not os.path.exists(mtoolsrc): + try: + with open(mtoolsrc, 'w') as outfile: + outfile.write('drive x:\n') + outfile.write(' file="{}"\n'.format(disk)) + outfile.write(' partition=1\n') + except OSError as e: + raise QemuError("Could not create 'mtoolsrc': {}".format(e)) + options.extend(self._disk_interface_options(disk, 3, interface, "raw")) return options From 99d9728360b69fc34f2cdad00563d04b5d245ac7 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Tue, 7 Apr 2020 14:11:00 +0200 Subject: [PATCH 002/120] QEMU config disk - preserve file timestamp on zip unpack (cherry picked from commit 5c4426847602ab59475403901cf6f3ea3a3e6270) --- gns3server/compute/qemu/qemu_vm.py | 9 ++-- gns3server/compute/qemu/utils/ziputils.py | 53 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 gns3server/compute/qemu/utils/ziputils.py diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 1eeeb8c0..4c82d658 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -37,6 +37,7 @@ from gns3server.utils import parse_version, shlex_quote from gns3server.utils.asyncio import subprocess_check_output, cancellable_wait_run_in_executor from .qemu_error import QemuError from .utils.qcow2 import Qcow2, Qcow2Error +from .utils.ziputils import pack_zip, unpack_zip from ..adapters.ethernet_adapter import EthernetAdapter from ..error import NodeError, ImageMissingError from ..nios.nio_udp import NIOUDP @@ -1675,8 +1676,8 @@ class QemuVM(BaseNode): os.mkdir(config_dir) if os.path.exists(zip_file): os.remove(zip_file) - if await self._mcopy("-s", "-m", "x:/", config_dir) == 0: - shutil.make_archive(zip_file[:-4], "zip", config_dir) + if await self._mcopy("-s", "-m", "-n", "--", "x:/", config_dir) == 0: + pack_zip(zip_file, config_dir) except OSError as e: log.error("Can't export config: {}".format(e)) finally: @@ -1692,12 +1693,12 @@ class QemuVM(BaseNode): try: shutil.rmtree(config_dir, ignore_errors=True) os.mkdir(config_dir) - shutil.unpack_archive(zip_file, config_dir) + unpack_zip(zip_file, config_dir) shutil.copyfile(getattr(self, "config_disk_image"), disk) config_files = [os.path.join(config_dir, fname) for fname in os.listdir(config_dir)] if config_files: - if await self._mcopy("-s", "-m", *config_files, "x:/") != 0: + if await self._mcopy("-s", "-m", "-o", "--", *config_files, "x:/") != 0: os.remove(disk) os.remove(zip_file) except OSError as e: diff --git a/gns3server/compute/qemu/utils/ziputils.py b/gns3server/compute/qemu/utils/ziputils.py new file mode 100644 index 00000000..3ff8c999 --- /dev/null +++ b/gns3server/compute/qemu/utils/ziputils.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 GNS3 Technologies Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import time +import shutil +import zipfile + +def pack_zip(filename, root_dir=None, base_dir=None): + """Create a zip archive""" + + if filename[-4:].lower() == ".zip": + filename = filename[:-4] + shutil.make_archive(filename, 'zip', root_dir, base_dir) + +def unpack_zip(filename, extract_dir=None): + """Unpack a zip archive""" + + dirs = [] + if not extract_dir: + extract_dir = os.getcwd() + + try: + with zipfile.ZipFile(filename, 'r') as zfile: + for zinfo in zfile.infolist(): + fname = os.path.join(extract_dir, zinfo.filename) + date_time = time.mktime(zinfo.date_time + (0, 0, -1)) + zfile.extract(zinfo, extract_dir) + + # update timestamp + if zinfo.is_dir(): + dirs.append((fname, date_time)) + else: + os.utime(fname, (date_time, date_time)) + # update timestamp of directories + for fname, date_time in reversed(dirs): + os.utime(fname, (date_time, date_time)) + except zipfile.BadZipFile: + raise shutil.ReadError("%s is not a zip file" % filename) From 0db0f6256bf396973d3b511f8b31841edcb0e43f Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Wed, 15 Apr 2020 20:50:59 +0200 Subject: [PATCH 003/120] QEMU config disk - get rid of mtoolsrc (cherry picked from commit 450c6cddc743c5b1a1bfa4a9b58a8aaa4983160c) --- gns3server/compute/qemu/qemu_vm.py | 43 ++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 4c82d658..78d54fc8 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -26,6 +26,7 @@ import re import shlex import math import shutil +import struct import asyncio import socket import gns3server @@ -1646,11 +1647,26 @@ class QemuVM(BaseNode): log.info("{} returned with {}".format(self._get_qemu_img(), retcode)) return retcode - async def _mcopy(self, *args): - env = os.environ - env["MTOOLSRC"] = 'mtoolsrc' + async def _mcopy(self, image, *args): try: - process = await asyncio.create_subprocess_exec("mcopy", *args, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.working_dir, env=env) + # read offset of first partition from MBR + with open(image, "rb") as img_file: + mbr = img_file.read(512) + part_type, offset, signature = struct.unpack("<450xB3xL52xH", mbr) + if signature != 0xAA55: + log.error("mcopy failure: {}: invalid MBR".format(image)) + return 1 + if part_type not in (1, 4, 6, 11, 12, 14): + log.error("mcopy failure: {}: invalid partition type {:02X}" + .format(image, part_type)) + return 1 + part_image = image + "@@{}S".format(offset) + + process = await asyncio.create_subprocess_exec( + "mcopy", "-i", part_image, *args, + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + cwd=self.working_dir) (stdout, _) = await process.communicate() retcode = process.returncode except (OSError, subprocess.SubprocessError) as e: @@ -1666,8 +1682,10 @@ class QemuVM(BaseNode): async def _export_config(self): disk_name = getattr(self, "config_disk_name") - if not disk_name or \ - not os.path.exists(os.path.join(self.working_dir, disk_name)): + if not disk_name: + return + disk = os.path.join(self.working_dir, disk_name) + if not os.path.exists(disk): return config_dir = os.path.join(self.working_dir, "configs") zip_file = os.path.join(self.working_dir, "config.zip") @@ -1676,7 +1694,7 @@ class QemuVM(BaseNode): os.mkdir(config_dir) if os.path.exists(zip_file): os.remove(zip_file) - if await self._mcopy("-s", "-m", "-n", "--", "x:/", config_dir) == 0: + if await self._mcopy(disk, "-s", "-m", "-n", "--", "::/", config_dir) == 0: pack_zip(zip_file, config_dir) except OSError as e: log.error("Can't export config: {}".format(e)) @@ -1698,7 +1716,7 @@ class QemuVM(BaseNode): config_files = [os.path.join(config_dir, fname) for fname in os.listdir(config_dir)] if config_files: - if await self._mcopy("-s", "-m", "-o", "--", *config_files, "x:/") != 0: + if await self._mcopy(disk, "-s", "-m", "-o", "--", *config_files, "::/") != 0: os.remove(disk) os.remove(zip_file) except OSError as e: @@ -1817,15 +1835,6 @@ class QemuVM(BaseNode): shutil.copyfile(disk_image, disk) except OSError as e: raise QemuError("Could not create '{}' disk image: {}".format(disk_name, e)) - mtoolsrc = os.path.join(self.working_dir, "mtoolsrc") - if not os.path.exists(mtoolsrc): - try: - with open(mtoolsrc, 'w') as outfile: - outfile.write('drive x:\n') - outfile.write(' file="{}"\n'.format(disk)) - outfile.write(' partition=1\n') - except OSError as e: - raise QemuError("Could not create 'mtoolsrc': {}".format(e)) options.extend(self._disk_interface_options(disk, 3, interface, "raw")) return options From 347035a99bf99618d945105d4205dc3d985eceb5 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Thu, 16 Apr 2020 11:07:56 +0200 Subject: [PATCH 004/120] QEMU config disk - add missing config disk to image directory (cherry picked from commit 2e0fba925bdd796ddd5eea0a4c9e4dcebed861ab) --- gns3server/compute/qemu/qemu_vm.py | 27 +++++++++++++----- .../compute/qemu/resources/config.img.zip | Bin 0 -> 1368 bytes 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 gns3server/compute/qemu/resources/config.img.zip diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 78d54fc8..32608370 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -46,6 +46,7 @@ from ..nios.nio_tap import NIOTAP from ..base_node import BaseNode from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS from ...utils.asyncio import monitor_process +from ...utils.get_resource import get_resource from ...utils.images import md5sum from ...utils import macaddress_to_int, int_to_macaddress @@ -130,19 +131,31 @@ class QemuVM(BaseNode): self.adapters = 1 # creates 1 adapter by default # config disk - self.config_disk_name = "config.img" + config_disk_name = "config.img" + self.config_disk_name = "" + self.config_disk_image = "" if not shutil.which("mcopy"): log.warning("Config disk: 'mtools' are not installed.") - self.config_disk_name = "" - self.config_disk_image = "" else: try: self.config_disk_image = self.manager.get_abs_image_path( - self.config_disk_name, self.project.path) + config_disk_name, self.project.path) + self.config_disk_name = config_disk_name except (NodeError, ImageMissingError) as e: - log.warning("Config disk: {}".format(e)) - self.config_disk_name = "" - self.config_disk_image = "" + config_disk_zip = get_resource("compute/qemu/resources/{}.zip" + .format(config_disk_name)) + if config_disk_zip and os.path.exists(config_disk_zip): + directory = self.manager.get_images_directory() + try: + unpack_zip(config_disk_zip, directory) + self.config_disk_image = os.path.join(directory, + config_disk_name) + self.config_disk_name = config_disk_name + except OSError as e: + log.warning("Config disk creation: {}".format(e)) + else: + log.warning("Config disk: image '{}' missing" + .format(config_disk_name)) log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id)) diff --git a/gns3server/compute/qemu/resources/config.img.zip b/gns3server/compute/qemu/resources/config.img.zip new file mode 100644 index 0000000000000000000000000000000000000000..7ba43f9e0db1535a2d465dad484dbb05046d0575 GIT binary patch literal 1368 zcmWIWW@Zs#U|`^2;D~Dru#K9RvW^AFWe{NCVvu1-&d*EBOxMfIO%Dy>WMF>qt1IsH zrM|e*3T_5QmKV$n3}E8zbwxksKmmpeKW95!pUTp@`shWc00pfBTeG9qHMp<8A#4)E zbXhoHmV>Q` L1Az1=aQO)Uu Date: Wed, 17 Jun 2020 17:06:55 +0200 Subject: [PATCH 005/120] QEMU config disk - use disk interface of HD-D, fallback is HD-A (cherry picked from commit b672900406e5ce10251cc1e231fee1d117ca3805) --- gns3server/compute/qemu/qemu_vm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 32608370..6c6f10f3 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1841,7 +1841,9 @@ class QemuVM(BaseNode): else: disk_name = getattr(self, "config_disk_name") disk = os.path.join(self.working_dir, disk_name) - interface = getattr(self, "hda_disk_interface", "ide") + interface = getattr(self, "hdd_disk_interface", "ide") + if interface == "ide": + interface = getattr(self, "hda_disk_interface", "none") await self._import_config() if not os.path.exists(disk): try: From f747b3a880180e480db32e8ee595c652bbe2896f Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Sun, 28 Jun 2020 09:21:57 +0200 Subject: [PATCH 006/120] QEMU config disk - notification of import/export errors (cherry picked from commit 50c49cfedb226c3d15397fec443d86ebc0fdb26a) --- gns3server/compute/qemu/qemu_vm.py | 32 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 6c6f10f3..923c691c 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1667,12 +1667,10 @@ class QemuVM(BaseNode): mbr = img_file.read(512) part_type, offset, signature = struct.unpack("<450xB3xL52xH", mbr) if signature != 0xAA55: - log.error("mcopy failure: {}: invalid MBR".format(image)) - return 1 + raise OSError("mcopy failure: {}: invalid MBR".format(image)) if part_type not in (1, 4, 6, 11, 12, 14): - log.error("mcopy failure: {}: invalid partition type {:02X}" - .format(image, part_type)) - return 1 + raise OSError("mcopy failure: {}: invalid partition type {:02X}" + .format(image, part_type)) part_image = image + "@@{}S".format(offset) process = await asyncio.create_subprocess_exec( @@ -1683,15 +1681,13 @@ class QemuVM(BaseNode): (stdout, _) = await process.communicate() retcode = process.returncode except (OSError, subprocess.SubprocessError) as e: - log.error("mcopy failure: {}".format(e)) - return 1 + raise OSError("mcopy failure: {}".format(e)) if retcode != 0: stdout = stdout.decode("utf-8").rstrip() if stdout: - log.error("mcopy failure: {}".format(stdout)) + raise OSError("mcopy failure: {}".format(stdout)) else: - log.error("mcopy failure: return code {}".format(retcode)) - return retcode + raise OSError("mcopy failure: return code {}".format(retcode)) async def _export_config(self): disk_name = getattr(self, "config_disk_name") @@ -1707,10 +1703,11 @@ class QemuVM(BaseNode): os.mkdir(config_dir) if os.path.exists(zip_file): os.remove(zip_file) - if await self._mcopy(disk, "-s", "-m", "-n", "--", "::/", config_dir) == 0: - pack_zip(zip_file, config_dir) + await self._mcopy(disk, "-s", "-m", "-n", "--", "::/", config_dir) + pack_zip(zip_file, config_dir) except OSError as e: - log.error("Can't export config: {}".format(e)) + log.warning("Can't export config: {}".format(e)) + self.project.emit("log.warning", {"message": "{}: Can't export config: {}".format(self._name, e)}) finally: shutil.rmtree(config_dir, ignore_errors=True) @@ -1729,11 +1726,12 @@ class QemuVM(BaseNode): config_files = [os.path.join(config_dir, fname) for fname in os.listdir(config_dir)] if config_files: - if await self._mcopy(disk, "-s", "-m", "-o", "--", *config_files, "::/") != 0: - os.remove(disk) - os.remove(zip_file) + await self._mcopy(disk, "-s", "-m", "-o", "--", *config_files, "::/") except OSError as e: - log.error("Can't import config: {}".format(e)) + log.warning("Can't import config: {}".format(e)) + self.project.emit("log.warning", {"message": "{}: Can't import config: {}".format(self._name, e)}) + if os.path.exists(disk): + os.remove(disk) os.remove(zip_file) finally: shutil.rmtree(config_dir, ignore_errors=True) From 053828f3e8f3d350a7143a0c6543feb2a0024830 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Sun, 28 Jun 2020 16:35:39 +0200 Subject: [PATCH 007/120] QEMU config disk - init config disk in base class (cherry picked from commit 2bbee15b18594ee517046016c6c33e066b300659) --- gns3server/compute/qemu/__init__.py | 25 +++++++++++++++++++++++++ gns3server/compute/qemu/qemu_vm.py | 25 ++++++------------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/gns3server/compute/qemu/__init__.py b/gns3server/compute/qemu/__init__.py index 828e94b2..663ee37f 100644 --- a/gns3server/compute/qemu/__init__.py +++ b/gns3server/compute/qemu/__init__.py @@ -27,10 +27,13 @@ import re import subprocess from ...utils.asyncio import subprocess_check_output +from ...utils.get_resource import get_resource from ..base_manager import BaseManager +from ..error import NodeError, ImageMissingError from .qemu_error import QemuError from .qemu_vm import QemuVM from .utils.guest_cid import get_next_guest_cid +from .utils.ziputils import unpack_zip import logging log = logging.getLogger(__name__) @@ -45,6 +48,7 @@ class Qemu(BaseManager): super().__init__() self._guest_cid_lock = asyncio.Lock() + self._init_config_disk() async def create_node(self, *args, **kwargs): """ @@ -343,3 +347,24 @@ class Qemu(BaseManager): log.info("Qemu disk '{}' extended by {} MB".format(path, extend)) except (OSError, subprocess.SubprocessError) as e: raise QemuError("Could not update disk image {}:{}".format(path, e)) + + def _init_config_disk(self): + """ + Initialize the default config disk + """ + + self.config_disk = "config.img" + try: + self.get_abs_image_path(self.config_disk) + except (NodeError, ImageMissingError) as e: + config_disk_zip = get_resource("compute/qemu/resources/{}.zip" + .format(self.config_disk)) + if config_disk_zip and os.path.exists(config_disk_zip): + directory = self.get_images_directory() + try: + unpack_zip(config_disk_zip, directory) + except OSError as e: + log.warning("Config disk creation: {}".format(e)) + else: + log.warning("Config disk: image '{}' missing" + .format(self.config_disk)) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 923c691c..8380dcdc 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -46,7 +46,6 @@ from ..nios.nio_tap import NIOTAP from ..base_node import BaseNode from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS from ...utils.asyncio import monitor_process -from ...utils.get_resource import get_resource from ...utils.images import md5sum from ...utils import macaddress_to_int, int_to_macaddress @@ -131,31 +130,19 @@ class QemuVM(BaseNode): self.adapters = 1 # creates 1 adapter by default # config disk - config_disk_name = "config.img" - self.config_disk_name = "" + self.config_disk_name = self.manager.config_disk self.config_disk_image = "" if not shutil.which("mcopy"): log.warning("Config disk: 'mtools' are not installed.") + self.config_disk_name = "" else: try: self.config_disk_image = self.manager.get_abs_image_path( - config_disk_name, self.project.path) - self.config_disk_name = config_disk_name + self.config_disk_name) except (NodeError, ImageMissingError) as e: - config_disk_zip = get_resource("compute/qemu/resources/{}.zip" - .format(config_disk_name)) - if config_disk_zip and os.path.exists(config_disk_zip): - directory = self.manager.get_images_directory() - try: - unpack_zip(config_disk_zip, directory) - self.config_disk_image = os.path.join(directory, - config_disk_name) - self.config_disk_name = config_disk_name - except OSError as e: - log.warning("Config disk creation: {}".format(e)) - else: - log.warning("Config disk: image '{}' missing" - .format(config_disk_name)) + log.warning("Config disk: image '{}' missing" + .format(self.config_disk_name)) + self.config_disk_name = "" log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id)) From 9acb2ceda1a2f9ad6f8e7bd6229410a47225f0bb Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Fri, 3 Jul 2020 11:31:17 +0200 Subject: [PATCH 008/120] QEMU config disk - improve error handling (cherry picked from commit 068c31038f33e08d5bcf1b71a3b7eae0133e29dd) --- gns3server/compute/qemu/qemu_vm.py | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 8380dcdc..d33f7316 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1686,17 +1686,15 @@ class QemuVM(BaseNode): config_dir = os.path.join(self.working_dir, "configs") zip_file = os.path.join(self.working_dir, "config.zip") try: - shutil.rmtree(config_dir, ignore_errors=True) os.mkdir(config_dir) + await self._mcopy(disk, "-s", "-m", "-n", "--", "::/", config_dir) if os.path.exists(zip_file): os.remove(zip_file) - await self._mcopy(disk, "-s", "-m", "-n", "--", "::/", config_dir) pack_zip(zip_file, config_dir) except OSError as e: log.warning("Can't export config: {}".format(e)) self.project.emit("log.warning", {"message": "{}: Can't export config: {}".format(self._name, e)}) - finally: - shutil.rmtree(config_dir, ignore_errors=True) + shutil.rmtree(config_dir, ignore_errors=True) async def _import_config(self): disk_name = getattr(self, "config_disk_name") @@ -1705,23 +1703,23 @@ class QemuVM(BaseNode): return config_dir = os.path.join(self.working_dir, "configs") disk = os.path.join(self.working_dir, disk_name) + disk_tmp = disk + ".tmp" try: - shutil.rmtree(config_dir, ignore_errors=True) os.mkdir(config_dir) + shutil.copyfile(getattr(self, "config_disk_image"), disk_tmp) unpack_zip(zip_file, config_dir) - shutil.copyfile(getattr(self, "config_disk_image"), disk) config_files = [os.path.join(config_dir, fname) for fname in os.listdir(config_dir)] if config_files: - await self._mcopy(disk, "-s", "-m", "-o", "--", *config_files, "::/") + await self._mcopy(disk_tmp, "-s", "-m", "-o", "--", *config_files, "::/") + os.replace(disk_tmp, disk) except OSError as e: log.warning("Can't import config: {}".format(e)) self.project.emit("log.warning", {"message": "{}: Can't import config: {}".format(self._name, e)}) - if os.path.exists(disk): - os.remove(disk) - os.remove(zip_file) - finally: - shutil.rmtree(config_dir, ignore_errors=True) + if os.path.exists(disk_tmp): + os.remove(disk_tmp) + os.remove(zip_file) + shutil.rmtree(config_dir, ignore_errors=True) def _disk_interface_options(self, disk, disk_index, interface, format=None): options = [] @@ -1830,12 +1828,15 @@ class QemuVM(BaseNode): if interface == "ide": interface = getattr(self, "hda_disk_interface", "none") await self._import_config() - if not os.path.exists(disk): + disk_exists = os.path.exists(disk) + if not disk_exists: try: shutil.copyfile(disk_image, disk) + disk_exists = True except OSError as e: - raise QemuError("Could not create '{}' disk image: {}".format(disk_name, e)) - options.extend(self._disk_interface_options(disk, 3, interface, "raw")) + log.warning("Could not create '{}' disk image: {}".format(disk_name, e)) + if disk_exists: + options.extend(self._disk_interface_options(disk, 3, interface, "raw")) return options From c684c554bf90f831f5fc6305e44dd14374413831 Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 13 Aug 2020 17:10:31 +0930 Subject: [PATCH 009/120] Fix tests (cherry picked from commit 2ba6eac1135e0ddf01cb2d975822303d258c5299) --- gns3server/compute/qemu/__init__.py | 10 ++++------ gns3server/compute/qemu/qemu_vm.py | 20 ++++++++++---------- tests/compute/qemu/test_qemu_vm.py | 1 + tests/compute/test_manager.py | 3 ++- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gns3server/compute/qemu/__init__.py b/gns3server/compute/qemu/__init__.py index 663ee37f..bca490cc 100644 --- a/gns3server/compute/qemu/__init__.py +++ b/gns3server/compute/qemu/__init__.py @@ -48,6 +48,7 @@ class Qemu(BaseManager): super().__init__() self._guest_cid_lock = asyncio.Lock() + self.config_disk = "config.img" self._init_config_disk() async def create_node(self, *args, **kwargs): @@ -353,12 +354,10 @@ class Qemu(BaseManager): Initialize the default config disk """ - self.config_disk = "config.img" try: self.get_abs_image_path(self.config_disk) - except (NodeError, ImageMissingError) as e: - config_disk_zip = get_resource("compute/qemu/resources/{}.zip" - .format(self.config_disk)) + except (NodeError, ImageMissingError): + config_disk_zip = get_resource("compute/qemu/resources/{}.zip".format(self.config_disk)) if config_disk_zip and os.path.exists(config_disk_zip): directory = self.get_images_directory() try: @@ -366,5 +365,4 @@ class Qemu(BaseManager): except OSError as e: log.warning("Config disk creation: {}".format(e)) else: - log.warning("Config disk: image '{}' missing" - .format(self.config_disk)) + log.warning("Config disk: image '{}' missing".format(self.config_disk)) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index d33f7316..2870ad29 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -132,17 +132,17 @@ class QemuVM(BaseNode): # config disk self.config_disk_name = self.manager.config_disk self.config_disk_image = "" - if not shutil.which("mcopy"): - log.warning("Config disk: 'mtools' are not installed.") - self.config_disk_name = "" - else: - try: - self.config_disk_image = self.manager.get_abs_image_path( - self.config_disk_name) - except (NodeError, ImageMissingError) as e: - log.warning("Config disk: image '{}' missing" - .format(self.config_disk_name)) + if self.config_disk_name: + if not shutil.which("mcopy"): + log.warning("Config disk: 'mtools' are not installed.") self.config_disk_name = "" + else: + try: + self.config_disk_image = self.manager.get_abs_image_path(self.config_disk_name) + except (NodeError, ImageMissingError) as e: + log.warning("Config disk: image '{}' missing" + .format(self.config_disk_name)) + self.config_disk_name = "" log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id)) diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index 6067a205..2df4c389 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -337,6 +337,7 @@ def test_set_qemu_path_kvm_binary(vm, fake_qemu_binary): async def test_set_platform(compute_project, manager): + manager.config_disk = None # avoids conflict with config.img support with patch("shutil.which", return_value="/bin/qemu-system-x86_64") as which_mock: with patch("gns3server.compute.qemu.QemuVM._check_qemu_path"): vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager, platform="x86_64") diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index bceb9e20..e257e763 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -18,7 +18,7 @@ import uuid import os import pytest -from unittest.mock import patch +from unittest.mock import patch, MagicMock from tests.utils import asyncio_patch from gns3server.compute.vpcs import VPCS @@ -41,6 +41,7 @@ async def vpcs(loop, port_manager): async def qemu(loop, port_manager): Qemu._instance = None + Qemu._init_config_disk = MagicMock() # do not create the config.img image qemu = Qemu.instance() qemu.port_manager = port_manager return qemu From 9d3f7c79a2564611ec4144e683ebbde9e16ac59e Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 13 Aug 2020 17:18:45 +0930 Subject: [PATCH 010/120] Fix more tests (cherry picked from commit 546982d1ea1d44ce97bc974b65248389c29cf80e) --- tests/conftest.py | 4 ++-- tests/handlers/api/compute/test_qemu.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index d94b4bc2..7311b7e6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -117,8 +117,8 @@ def images_dir(config): path = config.get_section_config("Server").get("images_path") os.makedirs(path, exist_ok=True) - os.makedirs(os.path.join(path, "QEMU")) - os.makedirs(os.path.join(path, "IOU")) + os.makedirs(os.path.join(path, "QEMU"), exist_ok=True) + os.makedirs(os.path.join(path, "IOU"), exist_ok=True) return path diff --git a/tests/handlers/api/compute/test_qemu.py b/tests/handlers/api/compute/test_qemu.py index d88ee33d..112cdbda 100644 --- a/tests/handlers/api/compute/test_qemu.py +++ b/tests/handlers/api/compute/test_qemu.py @@ -277,7 +277,8 @@ async def test_images(compute_api, fake_qemu_vm): response = await compute_api.get("/qemu/images") assert response.status == 200 - assert response.json == [{"filename": "linux载.img", "path": "linux载.img", "md5sum": "c4ca4238a0b923820dcc509a6f75849b", "filesize": 1}] + assert response.json == [{'filename': 'config.img', 'filesize': 1048576, 'md5sum': '0ab49056760ae1db6c25376446190b47', 'path': 'config.img'}, + {"filename": "linux载.img", "path": "linux载.img", "md5sum": "c4ca4238a0b923820dcc509a6f75849b", "filesize": 1}] @pytest.mark.skipif(sys.platform.startswith("win"), reason="Does not work on Windows") From a56b816c1af2b0edaa5d6f64f86ea7665be8abde Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 14 Aug 2020 17:57:24 +0930 Subject: [PATCH 011/120] Add explicit option to automatically create or not the config disk. Off by default. (cherry picked from commit 56aba96a5fb57f502b283a0bc543da415bb3943a) --- gns3server/compute/qemu/qemu_vm.py | 33 +++++++++++++++++++++++++---- gns3server/schemas/qemu.py | 13 ++++++++++++ gns3server/schemas/qemu_template.py | 5 +++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 2870ad29..3e7b0280 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -122,6 +122,7 @@ class QemuVM(BaseNode): self._kernel_command_line = "" self._legacy_networking = False self._replicate_network_connection_state = True + self._create_config_disk = False self._on_close = "power_off" self._cpu_throttling = 0 # means no CPU throttling self._process_priority = "low" @@ -139,9 +140,8 @@ class QemuVM(BaseNode): else: try: self.config_disk_image = self.manager.get_abs_image_path(self.config_disk_name) - except (NodeError, ImageMissingError) as e: - log.warning("Config disk: image '{}' missing" - .format(self.config_disk_name)) + except (NodeError, ImageMissingError): + log.warning("Config disk: image '{}' missing".format(self.config_disk_name)) self.config_disk_name = "" log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id)) @@ -671,6 +671,30 @@ class QemuVM(BaseNode): log.info('QEMU VM "{name}" [{id}] has disabled network connection state replication'.format(name=self._name, id=self._id)) self._replicate_network_connection_state = replicate_network_connection_state + @property + def create_config_disk(self): + """ + Returns whether a config disk is automatically created on HDD disk interface (secondary slave) + + :returns: boolean + """ + + return self._create_config_disk + + @create_config_disk.setter + def create_config_disk(self, create_config_disk): + """ + Sets whether a config disk is automatically created on HDD disk interface (secondary slave) + + :param replicate_network_connection_state: boolean + """ + + if create_config_disk: + log.info('QEMU VM "{name}" [{id}] has enabled the config disk creation feature'.format(name=self._name, id=self._id)) + else: + log.info('QEMU VM "{name}" [{id}] has disabled the config disk creation feature'.format(name=self._name, id=self._id)) + self._create_config_disk = create_config_disk + @property def on_close(self): """ @@ -1818,7 +1842,7 @@ class QemuVM(BaseNode): # config disk disk_image = getattr(self, "config_disk_image") - if disk_image: + if disk_image and self._create_config_disk: if getattr(self, "_hdd_disk_image"): log.warning("Config disk: blocked by disk image 'hdd'") else: @@ -1837,6 +1861,7 @@ class QemuVM(BaseNode): log.warning("Could not create '{}' disk image: {}".format(disk_name, e)) if disk_exists: options.extend(self._disk_interface_options(disk, 3, interface, "raw")) + self.hdd_disk_image = disk return options diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index 567e5c3f..3ae444d4 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -190,6 +190,10 @@ QEMU_CREATE_SCHEMA = { "description": "Replicate the network connection state for links in Qemu", "type": ["boolean", "null"], }, + "create_config_disk": { + "description": "Automatically create a config disk on HDD disk interface (secondary slave)", + "type": ["boolean", "null"], + }, "on_close": { "description": "Action to execute on the VM is closed", "enum": ["power_off", "shutdown_signal", "save_vm_state"], @@ -380,6 +384,10 @@ QEMU_UPDATE_SCHEMA = { "description": "Replicate the network connection state for links in Qemu", "type": ["boolean", "null"], }, + "create_config_disk": { + "description": "Automatically create a config disk on HDD disk interface (secondary slave)", + "type": ["boolean", "null"], + }, "on_close": { "description": "Action to execute on the VM is closed", "enum": ["power_off", "shutdown_signal", "save_vm_state"], @@ -583,6 +591,10 @@ QEMU_OBJECT_SCHEMA = { "description": "Replicate the network connection state for links in Qemu", "type": "boolean", }, + "create_config_disk": { + "description": "Automatically create a config disk on HDD disk interface (secondary slave)", + "type": ["boolean", "null"], + }, "on_close": { "description": "Action to execute on the VM is closed", "enum": ["power_off", "shutdown_signal", "save_vm_state"], @@ -653,6 +665,7 @@ QEMU_OBJECT_SCHEMA = { "kernel_command_line", "legacy_networking", "replicate_network_connection_state", + "create_config_disk", "on_close", "cpu_throttling", "process_priority", diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py index f98c81d7..6414066e 100644 --- a/gns3server/schemas/qemu_template.py +++ b/gns3server/schemas/qemu_template.py @@ -183,6 +183,11 @@ QEMU_TEMPLATE_PROPERTIES = { "type": "boolean", "default": True }, + "create_config_disk": { + "description": "Automatically create a config disk on HDD disk interface (secondary slave)", + "type": "boolean", + "default": True + }, "on_close": { "description": "Action to execute on the VM is closed", "enum": ["power_off", "shutdown_signal", "save_vm_state"], From ec02150fd2207d52374ecfe19dd3dd018ef27acb Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 15 Aug 2020 16:14:16 +0930 Subject: [PATCH 012/120] Set default disk interface type to "none". Fail-safe: use "ide" if an image is set but no interface type is configured. Use the HDA disk interface type if none has been configured for HDD. (cherry picked from commit 464fd804cebaf3f569d4552ba53b82ab3b87c17c) --- gns3server/compute/qemu/qemu_vm.py | 25 +++++++++++++------------ gns3server/schemas/qemu_template.py | 8 ++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 3e7b0280..8b40396a 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -104,10 +104,10 @@ class QemuVM(BaseNode): self._hdb_disk_image = "" self._hdc_disk_image = "" self._hdd_disk_image = "" - self._hda_disk_interface = "ide" - self._hdb_disk_interface = "ide" - self._hdc_disk_interface = "ide" - self._hdd_disk_interface = "ide" + self._hda_disk_interface = "none" + self._hdb_disk_interface = "none" + self._hdc_disk_interface = "none" + self._hdd_disk_interface = "none" self._cdrom_image = "" self._bios_image = "" self._boot_priority = "c" @@ -1782,13 +1782,15 @@ class QemuVM(BaseNode): for disk_index, drive in enumerate(drives): disk_image = getattr(self, "_hd{}_disk_image".format(drive)) - interface = getattr(self, "hd{}_disk_interface".format(drive)) - if not disk_image: continue - disk_name = "hd" + drive + interface = getattr(self, "hd{}_disk_interface".format(drive)) + # fail-safe: use "ide" if there is a disk image and no interface type has been explicitly configured + if interface == "none": + setattr(self, "hd{}_disk_interface".format(drive), "ide") + disk_name = "hd" + drive if not os.path.isfile(disk_image) or not os.path.exists(disk_image): if os.path.islink(disk_image): raise QemuError("{} disk image '{}' linked to '{}' is not accessible".format(disk_name, disk_image, os.path.realpath(disk_image))) @@ -1848,9 +1850,9 @@ class QemuVM(BaseNode): else: disk_name = getattr(self, "config_disk_name") disk = os.path.join(self.working_dir, disk_name) - interface = getattr(self, "hdd_disk_interface", "ide") - if interface == "ide": - interface = getattr(self, "hda_disk_interface", "none") + if self.hdd_disk_interface == "none": + # use the HDA interface type if none has been configured for HDD + self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none") await self._import_config() disk_exists = os.path.exists(disk) if not disk_exists: @@ -1860,8 +1862,7 @@ class QemuVM(BaseNode): except OSError as e: log.warning("Could not create '{}' disk image: {}".format(disk_name, e)) if disk_exists: - options.extend(self._disk_interface_options(disk, 3, interface, "raw")) - self.hdd_disk_image = disk + options.extend(self._disk_interface_options(disk, 3, self.hdd_disk_interface, "raw")) return options diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py index 6414066e..4202f66c 100644 --- a/gns3server/schemas/qemu_template.py +++ b/gns3server/schemas/qemu_template.py @@ -116,7 +116,7 @@ QEMU_TEMPLATE_PROPERTIES = { "hda_disk_interface": { "description": "QEMU hda interface", "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], - "default": "ide" + "default": "none" }, "hdb_disk_image": { "description": "QEMU hdb disk image path", @@ -126,7 +126,7 @@ QEMU_TEMPLATE_PROPERTIES = { "hdb_disk_interface": { "description": "QEMU hdb interface", "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], - "default": "ide" + "default": "none" }, "hdc_disk_image": { "description": "QEMU hdc disk image path", @@ -136,7 +136,7 @@ QEMU_TEMPLATE_PROPERTIES = { "hdc_disk_interface": { "description": "QEMU hdc interface", "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], - "default": "ide" + "default": "none" }, "hdd_disk_image": { "description": "QEMU hdd disk image path", @@ -146,7 +146,7 @@ QEMU_TEMPLATE_PROPERTIES = { "hdd_disk_interface": { "description": "QEMU hdd interface", "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"], - "default": "ide" + "default": "none" }, "cdrom_image": { "description": "QEMU cdrom image path", From f2ddef855faedaed9d4077c9cd6c924d907ed0a3 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 15 Aug 2020 16:35:31 +0930 Subject: [PATCH 013/120] Fix tests. (cherry picked from commit 620d93634e835701c271dd70cbe2abf9aa16b1f4) --- gns3server/compute/qemu/qemu_vm.py | 3 ++- tests/handlers/api/controller/test_template.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 8b40396a..62148042 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1788,7 +1788,8 @@ class QemuVM(BaseNode): interface = getattr(self, "hd{}_disk_interface".format(drive)) # fail-safe: use "ide" if there is a disk image and no interface type has been explicitly configured if interface == "none": - setattr(self, "hd{}_disk_interface".format(drive), "ide") + interface = "ide" + setattr(self, "hd{}_disk_interface".format(drive), interface) disk_name = "hd" + drive if not os.path.isfile(disk_image) or not os.path.exists(disk_image): diff --git a/tests/handlers/api/controller/test_template.py b/tests/handlers/api/controller/test_template.py index c9eaf75a..2aeff91f 100644 --- a/tests/handlers/api/controller/test_template.py +++ b/tests/handlers/api/controller/test_template.py @@ -669,13 +669,13 @@ async def test_qemu_template_create(controller_api): "default_name_format": "{name}-{0}", "first_port_name": "", "hda_disk_image": "IOSvL2-15.2.4.0.55E.qcow2", - "hda_disk_interface": "ide", + "hda_disk_interface": "none", "hdb_disk_image": "", - "hdb_disk_interface": "ide", + "hdb_disk_interface": "none", "hdc_disk_image": "", - "hdc_disk_interface": "ide", + "hdc_disk_interface": "none", "hdd_disk_image": "", - "hdd_disk_interface": "ide", + "hdd_disk_interface": "none", "initrd": "", "kernel_command_line": "", "kernel_image": "", From 01db2d2a866a4e8ba413ff661b61db284dc6896b Mon Sep 17 00:00:00 2001 From: Jeremy Grossmann Date: Mon, 17 Aug 2020 12:45:57 +0930 Subject: [PATCH 014/120] Create config disk property false by default for Qemu templates Ref https://github.com/GNS3/gns3-gui/issues/3035 (cherry picked from commit a2e884e315ca25432ba5612142d60ce8e1dd7911) --- gns3server/schemas/qemu_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py index 4202f66c..496ee06a 100644 --- a/gns3server/schemas/qemu_template.py +++ b/gns3server/schemas/qemu_template.py @@ -186,7 +186,7 @@ QEMU_TEMPLATE_PROPERTIES = { "create_config_disk": { "description": "Automatically create a config disk on HDD disk interface (secondary slave)", "type": "boolean", - "default": True + "default": False }, "on_close": { "description": "Action to execute on the VM is closed", From 4843084158313a9c4ecfcd3ff4b5669647f1f48d Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 18 Aug 2020 10:54:11 +0930 Subject: [PATCH 015/120] Prioritize the config disk over HD-D for Qemu VMs. Fixes https://github.com/GNS3/gns3-gui/issues/3036 (cherry picked from commit c12b675691e01bedf093c57660db6a5ad19f39eb) --- gns3server/compute/qemu/qemu_vm.py | 37 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 62148042..611442e3 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1781,6 +1781,10 @@ class QemuVM(BaseNode): drives = ["a", "b", "c", "d"] for disk_index, drive in enumerate(drives): + # prioritize config disk over harddisk d + if drive == 'd' and self._create_config_disk: + continue + disk_image = getattr(self, "_hd{}_disk_image".format(drive)) if not disk_image: continue @@ -1846,24 +1850,21 @@ class QemuVM(BaseNode): # config disk disk_image = getattr(self, "config_disk_image") if disk_image and self._create_config_disk: - if getattr(self, "_hdd_disk_image"): - log.warning("Config disk: blocked by disk image 'hdd'") - else: - disk_name = getattr(self, "config_disk_name") - disk = os.path.join(self.working_dir, disk_name) - if self.hdd_disk_interface == "none": - # use the HDA interface type if none has been configured for HDD - self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none") - await self._import_config() - disk_exists = os.path.exists(disk) - if not disk_exists: - try: - shutil.copyfile(disk_image, disk) - disk_exists = True - except OSError as e: - log.warning("Could not create '{}' disk image: {}".format(disk_name, e)) - if disk_exists: - options.extend(self._disk_interface_options(disk, 3, self.hdd_disk_interface, "raw")) + disk_name = getattr(self, "config_disk_name") + disk = os.path.join(self.working_dir, disk_name) + if self.hdd_disk_interface == "none": + # use the HDA interface type if none has been configured for HDD + self.hdd_disk_interface = getattr(self, "hda_disk_interface", "none") + await self._import_config() + disk_exists = os.path.exists(disk) + if not disk_exists: + try: + shutil.copyfile(disk_image, disk) + disk_exists = True + except OSError as e: + log.warning("Could not create '{}' disk image: {}".format(disk_name, e)) + if disk_exists: + options.extend(self._disk_interface_options(disk, 3, self.hdd_disk_interface, "raw")) return options From de2b9caeeb7770a97b8aa561ddd71f42df287aa3 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Mon, 19 Oct 2020 03:19:22 +0200 Subject: [PATCH 016/120] Use HDD disk image as startup QEMU config disk --- gns3server/compute/qemu/qemu_vm.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 611442e3..e421790a 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -1722,11 +1722,21 @@ class QemuVM(BaseNode): async def _import_config(self): disk_name = getattr(self, "config_disk_name") + if not disk_name: + return + disk = os.path.join(self.working_dir, disk_name) zip_file = os.path.join(self.working_dir, "config.zip") - if not disk_name or not os.path.exists(zip_file): + startup_config = self.hdd_disk_image + if startup_config and startup_config.lower().endswith(".zip") and \ + not os.path.exists(zip_file) and not os.path.exists(disk): + try: + shutil.copyfile(startup_config, zip_file) + except OSError as e: + log.warning("Can't access startup config: {}".format(e)) + self.project.emit("log.warning", {"message": "{}: Can't access startup config: {}".format(self._name, e)}) + if not os.path.exists(zip_file): return config_dir = os.path.join(self.working_dir, "configs") - disk = os.path.join(self.working_dir, disk_name) disk_tmp = disk + ".tmp" try: os.mkdir(config_dir) From 5d1fdceb98e0114cb09dbd7aecef6794604e92aa Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 27 Oct 2020 19:41:24 +1030 Subject: [PATCH 017/120] Fix bug with application id allocation for IOU nodes. Fixes #3079 --- gns3server/controller/project.py | 18 ++++++++++++++++-- gns3server/utils/application_id.py | 15 ++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 5a289e15..33bb27a8 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -174,6 +174,7 @@ class Project: self._links = {} self._drawings = {} self._snapshots = {} + self._computes = [] # List the available snapshots snapshot_dir = os.path.join(self.path, "snapshots") @@ -564,6 +565,9 @@ class Project: if node_id in self._nodes: return self._nodes[node_id] + if compute.id not in self._computes: + self._computes.append(compute.id) + if node_type == "iou": async with self._iou_id_lock: # wait for a IOU node to be completely created before adding a new one @@ -571,10 +575,10 @@ class Project: # to generate MAC addresses) when creating multiple IOU node at the same time if "properties" in kwargs.keys(): # allocate a new application id for nodes loaded from the project - kwargs.get("properties")["application_id"] = get_next_application_id(self._controller.projects, compute) + kwargs.get("properties")["application_id"] = get_next_application_id(self._controller.projects, self._computes) elif "application_id" not in kwargs.keys() and not kwargs.get("properties"): # allocate a new application id for nodes added to the project - kwargs["application_id"] = get_next_application_id(self._controller.projects, compute) + kwargs["application_id"] = get_next_application_id(self._controller.projects, self._computes) node = await self._create_node(compute, name, node_id, node_type, **kwargs) else: node = await self._create_node(compute, name, node_id, node_type, **kwargs) @@ -604,6 +608,8 @@ class Project: self.remove_allocated_node_name(node.name) del self._nodes[node.id] await node.destroy() + # refresh the compute IDs list + self._computes = [n.compute.id for n in self.nodes.values()] self.dump() self.emit_notification("node.deleted", node.__json__()) @@ -931,6 +937,14 @@ class Project: topology = project_data["topology"] for compute in topology.get("computes", []): await self.controller.add_compute(**compute) + + # Get all compute used in the project + # used to allocate application IDs for IOU nodes. + for node in topology.get("nodes", []): + compute_id = node.get("compute_id") + if compute_id not in self._computes: + self._computes.append(compute_id) + for node in topology.get("nodes", []): compute = self.controller.get_compute(node.pop("compute_id")) name = node.pop("name") diff --git a/gns3server/utils/application_id.py b/gns3server/utils/application_id.py index 95fc76ad..d1ad984f 100644 --- a/gns3server/utils/application_id.py +++ b/gns3server/utils/application_id.py @@ -21,26 +21,27 @@ import logging log = logging.getLogger(__name__) -def get_next_application_id(projects, compute): +def get_next_application_id(projects, computes): """ Calculates free application_id from given nodes :param projects: all projects managed by controller - :param compute: Compute instance + :param computes: all computes used by the project :raises HTTPConflict when exceeds number :return: integer first free id """ nodes = [] - # look for application id for in all nodes across all opened projects that share the same compute + # look for application id for in all nodes across all opened projects that share the same computes for project in projects.values(): - if project.status == "opened" and compute in project.computes: + if project.status == "opened": nodes.extend(list(project.nodes.values())) - used = set([n.properties["application_id"] for n in nodes if n.node_type == "iou"]) + used = set([n.properties["application_id"] for n in nodes if n.node_type == "iou" and n.compute.id in computes]) pool = set(range(1, 512)) try: - return (pool - used).pop() + application_id = (pool - used).pop() + return application_id except KeyError: - raise aiohttp.web.HTTPConflict(text="Cannot create a new IOU node (limit of 512 nodes across all opened projects using compute {} reached".format(compute.name)) + raise aiohttp.web.HTTPConflict(text="Cannot create a new IOU node (limit of 512 nodes across all opened projects using the same computes)") From 5dab0c2587e786c7a05057333c07b3805dcce1da Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 27 Oct 2020 20:08:01 +1030 Subject: [PATCH 018/120] Prevent WIC to be added/removed while Dynamips router is running. Fixes https://github.com/GNS3/gns3-gui/issues/3082 --- gns3server/compute/dynamips/nodes/router.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gns3server/compute/dynamips/nodes/router.py b/gns3server/compute/dynamips/nodes/router.py index 182c9e37..23fc7b59 100644 --- a/gns3server/compute/dynamips/nodes/router.py +++ b/gns3server/compute/dynamips/nodes/router.py @@ -1182,13 +1182,17 @@ class Router(BaseNode): if not adapter.wic_slot_available(wic_slot_number): raise DynamipsError("WIC slot {wic_slot_number} is already occupied by another WIC".format(wic_slot_number=wic_slot_number)) + if await self.is_running(): + raise DynamipsError('WIC "{wic}" cannot be added while router "{name}" is running'.format(wic=wic, + name=self._name)) + # Dynamips WICs slot IDs start on a multiple of 16 # WIC1 = 16, WIC2 = 32 and WIC3 = 48 internal_wic_slot_number = 16 * (wic_slot_number + 1) await self._hypervisor.send('vm slot_add_binding "{name}" {slot_number} {wic_slot_number} {wic}'.format(name=self._name, - slot_number=slot_number, - wic_slot_number=internal_wic_slot_number, - wic=wic)) + slot_number=slot_number, + wic_slot_number=internal_wic_slot_number, + wic=wic)) log.info('Router "{name}" [{id}]: {wic} inserted into WIC slot {wic_slot_number}'.format(name=self._name, id=self._id, @@ -1217,12 +1221,16 @@ class Router(BaseNode): if adapter.wic_slot_available(wic_slot_number): raise DynamipsError("No WIC is installed in WIC slot {wic_slot_number}".format(wic_slot_number=wic_slot_number)) + if await self.is_running(): + raise DynamipsError('WIC cannot be removed from slot {wic_slot_number} while router "{name}" is running'.format(wic_slot_number=wic_slot_number, + name=self._name)) + # Dynamips WICs slot IDs start on a multiple of 16 # WIC1 = 16, WIC2 = 32 and WIC3 = 48 internal_wic_slot_number = 16 * (wic_slot_number + 1) await self._hypervisor.send('vm slot_remove_binding "{name}" {slot_number} {wic_slot_number}'.format(name=self._name, - slot_number=slot_number, - wic_slot_number=internal_wic_slot_number)) + slot_number=slot_number, + wic_slot_number=internal_wic_slot_number)) log.info('Router "{name}" [{id}]: {wic} removed from WIC slot {wic_slot_number}'.format(name=self._name, id=self._id, From b6a021dabdfc48cd7b0af11765cf36d5cf17b371 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 27 Oct 2020 23:25:19 +1030 Subject: [PATCH 019/120] Fix SSL support for controller and local compute. Fixes #1826 --- gns3server/controller/__init__.py | 11 +++++++++-- gns3server/controller/compute.py | 8 ++++++-- gns3server/web/web_server.py | 16 +++++++++++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 82910589..d3a3489b 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -81,16 +81,23 @@ class Controller: name = "Main server" computes = self._load_controller_settings() + from gns3server.web.web_server import WebServer + ssl_context = WebServer.instance().ssl_context() + protocol = server_config.get("protocol", "http") + if ssl_context and protocol != "https": + log.warning("Protocol changed to 'https' for local compute because SSL is enabled".format(port)) + protocol = "https" try: self._local_server = await self.add_compute(compute_id="local", name=name, - protocol=server_config.get("protocol", "http"), + protocol=protocol, host=host, console_host=console_host, port=port, user=server_config.get("user", ""), password=server_config.get("password", ""), - force=True) + force=True, + ssl_context=ssl_context) except aiohttp.web.HTTPConflict: log.fatal("Cannot access to the local server, make sure something else is not running on the TCP port {}".format(port)) sys.exit(1) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 39eb961b..117a71e3 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -57,7 +57,8 @@ class Compute: A GNS3 compute. """ - def __init__(self, compute_id, controller=None, protocol="http", host="localhost", port=3080, user=None, password=None, name=None, console_host=None): + def __init__(self, compute_id, controller=None, protocol="http", host="localhost", + port=3080, user=None, password=None, name=None, console_host=None, ssl_context=None): self._http_session = None assert controller is not None log.info("Create compute %s", compute_id) @@ -81,6 +82,7 @@ class Compute: self._cpu_usage_percent = None self._memory_usage_percent = None self._last_error = None + self._ssl_context = ssl_context self._capabilities = { "version": None, "node_types": [] @@ -92,7 +94,9 @@ class Compute: def _session(self): if self._http_session is None or self._http_session.closed is True: - self._http_session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(limit=None, force_close=True)) + self._http_session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(limit=None, + force_close=True, + ssl_context=self._ssl_context)) return self._http_session #def __del__(self): diff --git a/gns3server/web/web_server.py b/gns3server/web/web_server.py index 72f422d4..4e07fd69 100644 --- a/gns3server/web/web_server.py +++ b/gns3server/web/web_server.py @@ -64,6 +64,7 @@ class WebServer: self._start_time = time.time() self._running = False self._closing = False + self._ssl_context = None @staticmethod def instance(host=None, port=None): @@ -88,7 +89,6 @@ class WebServer: return False return True - async def reload_server(self): """ Reload the server. @@ -96,7 +96,6 @@ class WebServer: await Controller.instance().reload() - async def shutdown_server(self): """ Cleanly shutdown the server. @@ -147,6 +146,13 @@ class WebServer: self._loop.stop() + def ssl_context(self): + """ + Returns the SSL context for the server. + """ + + return self._ssl_context + def _signal_handling(self): def signal_handler(signame, *args): @@ -255,12 +261,12 @@ class WebServer: server_config = Config.instance().get_section_config("Server") - ssl_context = None + self._ssl_context = None if server_config.getboolean("ssl"): if sys.platform.startswith("win"): log.critical("SSL mode is not supported on Windows") raise SystemExit - ssl_context = self._create_ssl_context(server_config) + self._ssl_context = self._create_ssl_context(server_config) self._loop = asyncio.get_event_loop() @@ -307,7 +313,7 @@ class WebServer: log.info("Starting server on {}:{}".format(self._host, self._port)) self._handler = self._app.make_handler() - if self._run_application(self._handler, ssl_context) is False: + if self._run_application(self._handler, self._ssl_context) is False: self._loop.stop() sys.exit(1) From 5a7b5e4e08423705457b10598423816bdaa4a275 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 2 Nov 2020 18:08:25 +1030 Subject: [PATCH 020/120] Make sure all HTTP exceptions return JSON with a "message" field instead of "detail" --- gns3server/app.py | 10 ++++ gns3server/compute/base_manager.py | 58 ------------------------ gns3server/endpoints/compute/__init__.py | 11 +++++ 3 files changed, 21 insertions(+), 58 deletions(-) diff --git a/gns3server/app.py b/gns3server/app.py index bdf41541..46ec41e3 100644 --- a/gns3server/app.py +++ b/gns3server/app.py @@ -24,6 +24,7 @@ import asyncio import time from fastapi import FastAPI, Request +from starlette.exceptions import HTTPException as StarletteHTTPException from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse @@ -120,6 +121,15 @@ async def controller_not_found_error_handler(request: Request, exc: ControllerNo ) +# make sure the content key is "message", not "detail" per default +@app.exception_handler(StarletteHTTPException) +async def http_exception_handler(request: Request, exc: StarletteHTTPException): + return JSONResponse( + status_code=exc.status_code, + content={"message": exc.detail}, + ) + + @app.middleware("http") async def add_extra_headers(request: Request, call_next): start_time = time.time() diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index 3a7c9d84..e92f78ff 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -180,59 +180,6 @@ class BaseManager: return node - async def convert_old_project(self, project, legacy_id, name): - """ - Convert projects made before version 1.3 - - :param project: Project instance - :param legacy_id: old identifier - :param name: node name - - :returns: new identifier - """ - - new_id = str(uuid4()) - legacy_project_files_path = os.path.join(project.path, "{}-files".format(project.name)) - new_project_files_path = os.path.join(project.path, "project-files") - if os.path.exists(legacy_project_files_path) and not os.path.exists(new_project_files_path): - # move the project files - log.info("Converting old project...") - try: - log.info('Moving "{}" to "{}"'.format(legacy_project_files_path, new_project_files_path)) - await wait_run_in_executor(shutil.move, legacy_project_files_path, new_project_files_path) - except OSError as e: - raise ComputeError("Could not move project files directory: {} to {} {}".format(legacy_project_files_path, - new_project_files_path, e)) - - if project.is_local() is False: - legacy_remote_project_path = os.path.join(project.location, project.name, self.module_name.lower()) - new_remote_project_path = os.path.join(project.path, "project-files", self.module_name.lower()) - if os.path.exists(legacy_remote_project_path) and not os.path.exists(new_remote_project_path): - # move the legacy remote project (remote servers only) - log.info("Converting old remote project...") - try: - log.info('Moving "{}" to "{}"'.format(legacy_remote_project_path, new_remote_project_path)) - await wait_run_in_executor(shutil.move, legacy_remote_project_path, new_remote_project_path) - except OSError as e: - raise ComputeError("Could not move directory: {} to {} {}".format(legacy_remote_project_path, - new_remote_project_path, e)) - - if hasattr(self, "get_legacy_vm_workdir"): - # rename old project node working dir - log.info("Converting old node working directory...") - legacy_vm_dir = self.get_legacy_vm_workdir(legacy_id, name) - legacy_vm_working_path = os.path.join(new_project_files_path, legacy_vm_dir) - new_vm_working_path = os.path.join(new_project_files_path, self.module_name.lower(), new_id) - if os.path.exists(legacy_vm_working_path) and not os.path.exists(new_vm_working_path): - try: - log.info('Moving "{}" to "{}"'.format(legacy_vm_working_path, new_vm_working_path)) - await wait_run_in_executor(shutil.move, legacy_vm_working_path, new_vm_working_path) - except OSError as e: - raise ComputeError("Could not move vm working directory: {} to {} {}".format(legacy_vm_working_path, - new_vm_working_path, e)) - - return new_id - async def create_node(self, name, project_id, node_id, *args, **kwargs): """ Create a new node @@ -246,11 +193,6 @@ class BaseManager: return self._nodes[node_id] project = ProjectManager.instance().get_project(project_id) - if node_id and isinstance(node_id, int): - # old project - async with BaseManager._convert_lock: - node_id = await self.convert_old_project(project, node_id, name) - if not node_id: node_id = str(uuid4()) diff --git a/gns3server/endpoints/compute/__init__.py b/gns3server/endpoints/compute/__init__.py index 04c1bfe3..42f8b066 100644 --- a/gns3server/endpoints/compute/__init__.py +++ b/gns3server/endpoints/compute/__init__.py @@ -17,6 +17,7 @@ from fastapi import FastAPI, Request from fastapi.responses import JSONResponse +from starlette.exceptions import HTTPException as StarletteHTTPException from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError from gns3server.compute.error import ImageMissingError, NodeError from gns3server.ubridge.ubridge_error import UbridgeError @@ -125,6 +126,16 @@ async def ubridge_error_handler(request: Request, exc: UbridgeError): content={"message": str(exc), "exception": exc.__class__.__name__}, ) + +# make sure the content key is "message", not "detail" per default +@compute_api.exception_handler(StarletteHTTPException) +async def http_exception_handler(request: Request, exc: StarletteHTTPException): + return JSONResponse( + status_code=exc.status_code, + content={"message": exc.detail}, + ) + + compute_api.include_router(capabilities.router, tags=["Capabilities"]) compute_api.include_router(compute.router, tags=["Compute"]) compute_api.include_router(notifications.router, tags=["Notifications"]) From e2d444928d91655e37795932590b26f430637a41 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 2 Nov 2020 18:09:14 +1030 Subject: [PATCH 021/120] Add back script to create a self-signed SSL certificate. --- scripts/create_cert.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/create_cert.sh diff --git a/scripts/create_cert.sh b/scripts/create_cert.sh new file mode 100755 index 00000000..afcbdec2 --- /dev/null +++ b/scripts/create_cert.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# -*- coding: utf-8 -*- +# +# Copyright (C) 2020 GNS3 Technologies Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Bash shell script for generating self-signed certs. +# The certificate is automatically put in your GNS3 config + +DST_DIR="$HOME/.config/GNS3/ssl" +OLD_DIR=`pwd` + +fail_if_error() { + [ $1 != 0 ] && { + unset PASSPHRASE + cd $OLD_DIR + exit 10 + } +} + + +mkdir -p $DST_DIR +fail_if_error $? +cd $DST_DIR + +SUBJ="/C=US/ST=Texas/O=GNS3SELF/localityName=Austin/commonName=localhost/organizationalUnitName=GNS3Server/emailAddress=gns3cert@gns3.com" + +openssl req -nodes -new -x509 -keyout server.key -out server.cert -subj "$SUBJ" From aef8f0dff315d694e78a76ffc1e425937ac7c1ea Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 2 Nov 2020 18:23:41 +1030 Subject: [PATCH 022/120] Use EnvironmentFile for Systemd service. Ref https://github.com/GNS3/gns3-gui/issues/3048 --- scripts/remote-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remote-install.sh b/scripts/remote-install.sh index 124276d5..dc9fe198 100644 --- a/scripts/remote-install.sh +++ b/scripts/remote-install.sh @@ -260,7 +260,7 @@ Conflicts=shutdown.target User=gns3 Group=gns3 PermissionsStartOnly=true -Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +EnvironmentFile=/etc/environment ExecStartPre=/bin/mkdir -p /var/log/gns3 /var/run/gns3 ExecStartPre=/bin/chown -R gns3:gns3 /var/log/gns3 /var/run/gns3 ExecStart=/usr/bin/gns3server --log /var/log/gns3/gns3.log From 7314b41d8f142b1d38fd1063a0803d0fc110affb Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 2 Nov 2020 22:45:01 +1030 Subject: [PATCH 023/120] Fix tests. --- tests/compute/test_manager.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index 75a8cfdd..91d7c09b 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -77,30 +77,6 @@ async def test_create_node_new_topology_without_uuid(compute_project, vpcs): assert len(node.id) == 36 -@pytest.mark.asyncio -async def test_create_node_old_topology(compute_project, tmpdir, vpcs): - - with patch("gns3server.compute.project.Project.is_local", return_value=True): - # Create an old topology directory - project_dir = str(tmpdir / "testold") - node_dir = os.path.join(project_dir, "testold-files", "vpcs", "pc-1") - compute_project.path = project_dir - compute_project.name = "testold" - os.makedirs(node_dir, exist_ok=True) - with open(os.path.join(node_dir, "startup.vpc"), "w+") as f: - f.write("1") - - node_id = 1 - node = await vpcs.create_node("PC 1", compute_project.id, node_id) - assert len(node.id) == 36 - - assert os.path.exists(os.path.join(project_dir, "testold-files")) is False - - node_dir = os.path.join(project_dir, "project-files", "vpcs", node.id) - with open(os.path.join(node_dir, "startup.vpc")) as f: - assert f.read() == "1" - - def test_get_abs_image_path(qemu, tmpdir, config): os.makedirs(str(tmpdir / "QEMU")) From e182f53d69f51e9addbdc2ced94d272cfebeccab Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 4 Nov 2020 12:30:23 +1030 Subject: [PATCH 024/120] Fix wrong defaults for images_path, configs_path, appliances_path. Fixes #1829 --- gns3server/controller/__init__.py | 10 +++++----- gns3server/controller/appliance_manager.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index d3a3489b..14dc6196 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -82,7 +82,7 @@ class Controller: computes = self._load_controller_settings() from gns3server.web.web_server import WebServer - ssl_context = WebServer.instance().ssl_context() + ssl_context = WebServer.instance(host=host, port=port).ssl_context() protocol = server_config.get("protocol", "http") if ssl_context and protocol != "https": log.warning("Protocol changed to 'https' for local compute because SSL is enabled".format(port)) @@ -273,7 +273,7 @@ class Controller: """ server_config = Config.instance().get_section_config("Server") - images_path = os.path.expanduser(server_config.get("images_path", "~/GNS3/projects")) + images_path = os.path.expanduser(server_config.get("images_path", "~/GNS3/images")) os.makedirs(images_path, exist_ok=True) return images_path @@ -283,9 +283,9 @@ class Controller: """ server_config = Config.instance().get_section_config("Server") - images_path = os.path.expanduser(server_config.get("configs_path", "~/GNS3/projects")) - os.makedirs(images_path, exist_ok=True) - return images_path + configs_path = os.path.expanduser(server_config.get("configs_path", "~/GNS3/configs")) + os.makedirs(configs_path, exist_ok=True) + return configs_path async def add_compute(self, compute_id=None, name=None, force=False, connect=True, **kwargs): """ diff --git a/gns3server/controller/appliance_manager.py b/gns3server/controller/appliance_manager.py index 17c7fd30..e0ea0a4a 100644 --- a/gns3server/controller/appliance_manager.py +++ b/gns3server/controller/appliance_manager.py @@ -70,7 +70,7 @@ class ApplianceManager: """ server_config = Config.instance().get_section_config("Server") - appliances_path = os.path.expanduser(server_config.get("appliances_path", "~/GNS3/projects")) + appliances_path = os.path.expanduser(server_config.get("appliances_path", "~/GNS3/appliances")) os.makedirs(appliances_path, exist_ok=True) return appliances_path From 004acdc271817cb0079cc86c16eb99fe7da63a3d Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:51:25 +0100 Subject: [PATCH 025/120] Release web UI 2.2.16 --- gns3server/static/web-ui/3rdpartylicenses.txt | 25 ------------------- gns3server/static/web-ui/index.html | 2 +- .../web-ui/main.8367ffc0bf45ea7cf3c7.js | 1 + .../web-ui/main.b8ab802a67c1c69cf879.js | 1 - 4 files changed, 2 insertions(+), 27 deletions(-) create mode 100644 gns3server/static/web-ui/main.8367ffc0bf45ea7cf3c7.js delete mode 100644 gns3server/static/web-ui/main.b8ab802a67c1c69cf879.js diff --git a/gns3server/static/web-ui/3rdpartylicenses.txt b/gns3server/static/web-ui/3rdpartylicenses.txt index 236c506f..ddaf4177 100644 --- a/gns3server/static/web-ui/3rdpartylicenses.txt +++ b/gns3server/static/web-ui/3rdpartylicenses.txt @@ -418,31 +418,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -angular2-hotkeys -MIT -The MIT License (MIT) - -Copyright (c) 2016 Nick Richardson - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - angular2-indexeddb MIT The MIT License (MIT) diff --git a/gns3server/static/web-ui/index.html b/gns3server/static/web-ui/index.html index 452f5cff..8aa54783 100644 --- a/gns3server/static/web-ui/index.html +++ b/gns3server/static/web-ui/index.html @@ -48,5 +48,5 @@ gtag('config', 'G-5D6FZL9923'); - + diff --git a/gns3server/static/web-ui/main.8367ffc0bf45ea7cf3c7.js b/gns3server/static/web-ui/main.8367ffc0bf45ea7cf3c7.js new file mode 100644 index 00000000..f9e71711 --- /dev/null +++ b/gns3server/static/web-ui/main.8367ffc0bf45ea7cf3c7.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[1],{"+/L5":function(e,t,n){var i=n("t1UP").isCustomProperty,r=n("vd7W").TYPE,o=n("4njK").mode,a=r.Ident,s=r.Hash,c=r.Colon,l=r.Semicolon,u=r.Delim;function h(e){return this.Raw(e,o.exclamationMarkOrSemicolon,!0)}function d(e){return this.Raw(e,o.exclamationMarkOrSemicolon,!1)}function f(){var e=this.scanner.tokenIndex,t=this.Value();return"Raw"!==t.type&&!1===this.scanner.eof&&this.scanner.tokenType!==l&&!1===this.scanner.isDelim(33)&&!1===this.scanner.isBalanceEdge(e)&&this.error(),t}function p(){var e=this.scanner.tokenStart;if(this.scanner.tokenType===u)switch(this.scanner.source.charCodeAt(this.scanner.tokenStart)){case 42:case 36:case 43:case 35:case 38:this.scanner.next();break;case 47:this.scanner.next(),this.scanner.isDelim(47)&&this.scanner.next()}return this.eat(this.scanner.tokenType===s?s:a),this.scanner.substrToCursor(e)}function m(){this.eat(u),this.scanner.skipSC();var e=this.consume(a);return"important"===e||e}e.exports={name:"Declaration",structure:{important:[Boolean,String],property:String,value:["Value","Raw"]},parse:function(){var e,t=this.scanner.tokenStart,n=this.scanner.tokenIndex,r=p.call(this),o=i(r),a=o?this.parseCustomProperty:this.parseValue,s=o?d:h,u=!1;return this.scanner.skipSC(),this.eat(c),o||this.scanner.skipSC(),e=a?this.parseWithFallback(f,s):s.call(this,this.scanner.tokenIndex),this.scanner.isDelim(33)&&(u=m.call(this),this.scanner.skipSC()),!1===this.scanner.eof&&this.scanner.tokenType!==l&&!1===this.scanner.isBalanceEdge(n)&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.scanner.tokenStart),important:u,property:r,value:e}},generate:function(e){this.chunk(e.property),this.chunk(":"),this.node(e.value),e.important&&this.chunk(!0===e.important?"!important":"!"+e.important)},walkContext:"declaration"}},"+4/i":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("odkN");i.Observable.prototype.let=r.letProto,i.Observable.prototype.letBind=r.letProto},"+Kd2":function(e,t,n){var i=n("vd7W").TYPE,r=n("4njK").mode,o=i.Comma;e.exports=function(){var e=this.createList();return this.scanner.skipSC(),e.push(this.Identifier()),this.scanner.skipSC(),this.scanner.tokenType===o&&(e.push(this.Operator()),e.push(this.parseCustomProperty?this.Value(null):this.Raw(this.scanner.tokenIndex,r.exclamationMarkOrSemicolon,!1))),e}},"+oeQ":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("H+DX");i.Observable.prototype.observeOn=r.observeOn},"+psR":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("16Oq");i.Observable.prototype.retry=r.retry},"+qxJ":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("GsYY");i.Observable.prototype.distinctUntilChanged=r.distinctUntilChanged},"+v8i":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp");i.Observable.concat=i.concat},"/+5V":function(e,t){function n(e){function t(e){return null!==e&&("Type"===e.type||"Property"===e.type||"Keyword"===e.type)}var n=null;return null!==this.matched&&function i(r){if(Array.isArray(r.match)){for(var o=0;o>22},t.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?o.stringFromCodePoint(2097151&this.content):""},t.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},t.prototype.setFromCharData=function(e){this.fg=e[a.CHAR_DATA_ATTR_INDEX],this.bg=0;var t=!1;if(e[a.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(2===e[a.CHAR_DATA_CHAR_INDEX].length){var n=e[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=n&&n<=56319){var i=e[a.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(n-55296)+i-56320+65536|e[a.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[a.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[a.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[a.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[a.CHAR_DATA_WIDTH_INDEX]<<22)},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(s.AttributeData);t.CellData=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ISoundService=t.ISelectionService=t.IRenderService=t.IMouseService=t.ICoreBrowserService=t.ICharSizeService=void 0;var i=n(14);t.ICharSizeService=i.createDecorator("CharSizeService"),t.ICoreBrowserService=i.createDecorator("CoreBrowserService"),t.IMouseService=i.createDecorator("MouseService"),t.IRenderService=i.createDecorator("RenderService"),t.ISelectionService=i.createDecorator("SelectionService"),t.ISoundService=i.createDecorator("SoundService")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;var i=function(){function e(){this.fg=0,this.bg=0,this.extended=new r}return e.toColorRGB=function(e){return[e>>>16&255,e>>>8&255,255&e]},e.fromColorRGB=function(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},e.prototype.clone=function(){var t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t},e.prototype.isInverse=function(){return 67108864&this.fg},e.prototype.isBold=function(){return 134217728&this.fg},e.prototype.isUnderline=function(){return 268435456&this.fg},e.prototype.isBlink=function(){return 536870912&this.fg},e.prototype.isInvisible=function(){return 1073741824&this.fg},e.prototype.isItalic=function(){return 67108864&this.bg},e.prototype.isDim=function(){return 134217728&this.bg},e.prototype.getFgColorMode=function(){return 50331648&this.fg},e.prototype.getBgColorMode=function(){return 50331648&this.bg},e.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},e.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},e.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},e.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},e.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},e.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},e.prototype.isAttributeDefault=function(){return 0===this.fg&&0===this.bg},e.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},e.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},e.prototype.hasExtendedAttrs=function(){return 268435456&this.bg},e.prototype.updateExtended=function(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456},e.prototype.getUnderlineColor=function(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()},e.prototype.getUnderlineColorMode=function(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()},e.prototype.isUnderlineColorRGB=function(){return 268435456&this.bg&&~this.extended.underlineColor?50331648==(50331648&this.extended.underlineColor):this.isFgRGB()},e.prototype.isUnderlineColorPalette=function(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()},e.prototype.isUnderlineColorDefault=function(){return 268435456&this.bg&&~this.extended.underlineColor?0==(50331648&this.extended.underlineColor):this.isFgDefault()},e.prototype.getUnderlineStyle=function(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0},e}();t.AttributeData=i;var r=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=-1),this.underlineStyle=e,this.underlineColor=t}return e.prototype.clone=function(){return new e(this.underlineStyle,this.underlineColor)},e.prototype.isEmpty=function(){return 0===this.underlineStyle},e}();t.ExtendedAttrs=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,n,i){e.addEventListener(t,n,i);var r=!1;return{dispose:function(){r||(r=!0,e.removeEventListener(t,n,i))}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=t.utf32ToString=t.stringFromCodePoint=void 0,t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=e.length);for(var i="",r=t;r65535?(o-=65536,i+=String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i};var i=function(){function e(){this._interim=0}return e.prototype.clear=function(){this._interim=0},e.prototype.decode=function(e,t){var n=e.length;if(!n)return 0;var i=0,r=0;this._interim&&(56320<=(s=e.charCodeAt(r++))&&s<=57343?t[i++]=1024*(this._interim-55296)+s-56320+65536:(t[i++]=this._interim,t[i++]=s),this._interim=0);for(var o=r;o=n)return this._interim=a,i;var s;56320<=(s=e.charCodeAt(o))&&s<=57343?t[i++]=1024*(a-55296)+s-56320+65536:(t[i++]=a,t[i++]=s)}else t[i++]=a}return i},e}();t.StringToUtf32=i;var r=function(){function e(){this.interim=new Uint8Array(3)}return e.prototype.clear=function(){this.interim.fill(0)},e.prototype.decode=function(e,t){var n=e.length;if(!n)return 0;var i,r,o,a,s=0,c=0,l=0;if(this.interim[0]){var u=!1,h=this.interim[0];h&=192==(224&h)?31:224==(240&h)?15:7;for(var d=0,f=void 0;(f=63&this.interim[++d])&&d<4;)h<<=6,h|=f;for(var p=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,m=p-d;l=n)return 0;if(128!=(192&(f=e[l++]))){l--,u=!0;break}this.interim[d++]=f,h<<=6,h|=63&f}u||(2===p?h<128?l--:t[s++]=h:3===p?h<2048||h>=55296&&h<=57343||(t[s++]=h):h<65536||h>1114111||(t[s++]=h)),this.interim.fill(0)}for(var g=n-4,v=l;v=n)return this.interim[0]=i,s;if(128!=(192&(r=e[v++]))){v--;continue}if((c=(31&i)<<6|63&r)<128){v--;continue}t[s++]=c}else if(224==(240&i)){if(v>=n)return this.interim[0]=i,s;if(128!=(192&(r=e[v++]))){v--;continue}if(v>=n)return this.interim[0]=i,this.interim[1]=r,s;if(128!=(192&(o=e[v++]))){v--;continue}if((c=(15&i)<<12|(63&r)<<6|63&o)<2048||c>=55296&&c<=57343)continue;t[s++]=c}else if(240==(248&i)){if(v>=n)return this.interim[0]=i,s;if(128!=(192&(r=e[v++]))){v--;continue}if(v>=n)return this.interim[0]=i,this.interim[1]=r,s;if(128!=(192&(o=e[v++]))){v--;continue}if(v>=n)return this.interim[0]=i,this.interim[1]=r,this.interim[2]=o,s;if(128!=(192&(a=e[v++]))){v--;continue}if((c=(7&i)<<18|(63&r)<<12|(63&o)<<6|63&a)<65536||c>1114111)continue;t[s++]=c}}return s},e}();t.Utf8ToUtf32=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CHAR_ATLAS_CELL_SPACING=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0,t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.CHAR_ATLAS_CELL_SPACING=1},function(e,t,n){"use strict";var i,r,o,a;function s(e){var t=e.toString(16);return t.length<2?"0"+t:t}function c(e,t){return e>>0}}(i=t.channels||(t.channels={})),(r=t.color||(t.color={})).blend=function(e,t){var n=(255&t.rgba)/255;if(1===n)return{css:t.css,rgba:t.rgba};var r=t.rgba>>16&255,o=t.rgba>>8&255,a=e.rgba>>24&255,s=e.rgba>>16&255,c=e.rgba>>8&255,l=a+Math.round(((t.rgba>>24&255)-a)*n),u=s+Math.round((r-s)*n),h=c+Math.round((o-c)*n);return{css:i.toCss(l,u,h),rgba:i.toRgba(l,u,h)}},r.isOpaque=function(e){return 255==(255&e.rgba)},r.ensureContrastRatio=function(e,t,n){var i=a.ensureContrastRatio(e.rgba,t.rgba,n);if(i)return a.toColor(i>>24&255,i>>16&255,i>>8&255)},r.opaque=function(e){var t=(255|e.rgba)>>>0,n=a.toChannels(t);return{css:i.toCss(n[0],n[1],n[2]),rgba:t}},r.opacity=function(e,t){var n=Math.round(255*t),r=a.toChannels(e.rgba),o=r[0],s=r[1],c=r[2];return{css:i.toCss(o,s,c,n),rgba:i.toRgba(o,s,c,n)}},(t.css||(t.css={})).toColor=function(e){switch(e.length){case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}throw new Error("css.toColor: Unsupported css format")},function(e){function t(e,t,n){var i=e/255,r=t/255,o=n/255;return.2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(o=t.rgb||(t.rgb={})),function(e){function t(e,t,n){for(var i=e>>24&255,r=e>>16&255,a=e>>8&255,s=t>>24&255,l=t>>16&255,u=t>>8&255,h=c(o.relativeLuminance2(s,u,l),o.relativeLuminance2(i,r,a));h0||l>0||u>0);)s-=Math.max(0,Math.ceil(.1*s)),l-=Math.max(0,Math.ceil(.1*l)),u-=Math.max(0,Math.ceil(.1*u)),h=c(o.relativeLuminance2(s,u,l),o.relativeLuminance2(i,r,a));return(s<<24|l<<16|u<<8|255)>>>0}function n(e,t,n){for(var i=e>>24&255,r=e>>16&255,a=e>>8&255,s=t>>24&255,l=t>>16&255,u=t>>8&255,h=c(o.relativeLuminance2(s,u,l),o.relativeLuminance2(i,r,a));h>>0}e.ensureContrastRatio=function(e,i,r){var a=o.relativeLuminance(e>>8),s=o.relativeLuminance(i>>8);if(c(a,s)>24&255,e>>16&255,e>>8&255,255&e]},e.toColor=function(e,t,n){return{css:i.toCss(e,t,n),rgba:i.toRgba(e,t,n)}}}(a=t.rgba||(t.rgba={})),t.toPaddedHex=s,t.contrastRatio=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.isSafari=t.isFirefox=void 0;var i="undefined"==typeof navigator,r=i?"node":navigator.userAgent,o=i?"node":navigator.platform;function a(e,t){return e.indexOf(t)>=0}t.isFirefox=!!~r.indexOf("Firefox"),t.isSafari=/^((?!chrome|android).)*safari/i.test(r),t.isMac=a(["Macintosh","MacIntel","MacPPC","Mac68K"],o),t.isIpad="iPad"===o,t.isIphone="iPhone"===o,t.isWindows=a(["Windows","Win16","Win32","WinCE"],o),t.isLinux=o.indexOf("Linux")>=0},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.C1=t.C0=void 0,function(e){e.NUL="\0",e.SOH="\x01",e.STX="\x02",e.ETX="\x03",e.EOT="\x04",e.ENQ="\x05",e.ACK="\x06",e.BEL="\x07",e.BS="\b",e.HT="\t",e.LF="\n",e.VT="\v",e.FF="\f",e.CR="\r",e.SO="\x0e",e.SI="\x0f",e.DLE="\x10",e.DC1="\x11",e.DC2="\x12",e.DC3="\x13",e.DC4="\x14",e.NAK="\x15",e.SYN="\x16",e.ETB="\x17",e.CAN="\x18",e.EM="\x19",e.SUB="\x1a",e.ESC="\x1b",e.FS="\x1c",e.GS="\x1d",e.RS="\x1e",e.US="\x1f",e.SP=" ",e.DEL="\x7f"}(t.C0||(t.C0={})),function(e){e.PAD="\x80",e.HOP="\x81",e.BPH="\x82",e.NBH="\x83",e.IND="\x84",e.NEL="\x85",e.SSA="\x86",e.ESA="\x87",e.HTS="\x88",e.HTJ="\x89",e.VTS="\x8a",e.PLD="\x8b",e.PLU="\x8c",e.RI="\x8d",e.SS2="\x8e",e.SS3="\x8f",e.DCS="\x90",e.PU1="\x91",e.PU2="\x92",e.STS="\x93",e.CCH="\x94",e.MW="\x95",e.SPA="\x96",e.EPA="\x97",e.SOS="\x98",e.SGCI="\x99",e.SCI="\x9a",e.CSI="\x9b",e.ST="\x9c",e.OSC="\x9d",e.PM="\x9e",e.APC="\x9f"}(t.C1||(t.C1={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseRenderLayer=void 0;var i=n(3),r=n(9),o=n(25),a=n(6),s=n(28),c=n(10),l=n(17),u=function(){function e(e,t,n,i,r,o,a,s){this._container=e,this._alpha=i,this._colors=r,this._rendererId=o,this._bufferService=a,this._optionsService=s,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-"+t+"-layer"),this._canvas.style.zIndex=n.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return e.prototype.dispose=function(){var e;l.removeElementFromParent(this._canvas),null===(e=this._charAtlas)||void 0===e||e.dispose()},e.prototype._initCanvas=function(){this._ctx=s.throwIfFalsy(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()},e.prototype.onOptionsChanged=function(){},e.prototype.onBlur=function(){},e.prototype.onFocus=function(){},e.prototype.onCursorMove=function(){},e.prototype.onGridChanged=function(e,t){},e.prototype.onSelectionChanged=function(e,t,n){void 0===n&&(n=!1)},e.prototype.setColors=function(e){this._refreshCharAtlas(e)},e.prototype._setTransparency=function(e){if(e!==this._alpha){var t=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,t),this._refreshCharAtlas(this._colors),this.onGridChanged(0,this._bufferService.rows-1)}},e.prototype._refreshCharAtlas=function(e){this._scaledCharWidth<=0&&this._scaledCharHeight<=0||(this._charAtlas=o.acquireCharAtlas(this._optionsService.options,this._rendererId,e,this._scaledCharWidth,this._scaledCharHeight),this._charAtlas.warmUp())},e.prototype.resize=function(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(this._colors)},e.prototype._fillCells=function(e,t,n,i){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,n*this._scaledCellWidth,i*this._scaledCellHeight)},e.prototype._fillBottomLineAtCells=function(e,t,n){void 0===n&&(n=1),this._ctx.fillRect(e*this._scaledCellWidth,(t+1)*this._scaledCellHeight-window.devicePixelRatio-1,n*this._scaledCellWidth,window.devicePixelRatio)},e.prototype._fillLeftLineAtCell=function(e,t,n){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,window.devicePixelRatio*n,this._scaledCellHeight)},e.prototype._strokeRectAtCell=function(e,t,n,i){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(e*this._scaledCellWidth+window.devicePixelRatio/2,t*this._scaledCellHeight+window.devicePixelRatio/2,n*this._scaledCellWidth-window.devicePixelRatio,i*this._scaledCellHeight-window.devicePixelRatio)},e.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))},e.prototype._clearCells=function(e,t,n,i){this._alpha?this._ctx.clearRect(e*this._scaledCellWidth,t*this._scaledCellHeight,n*this._scaledCellWidth,i*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,n*this._scaledCellWidth,i*this._scaledCellHeight))},e.prototype._fillCharTrueColor=function(e,t,n){this._ctx.font=this._getFont(!1,!1),this._ctx.textBaseline="middle",this._clipRow(n),this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,n*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2)},e.prototype._drawChars=function(e,t,n){var o,a,s=this._getContrastColor(e);s||e.isFgRGB()||e.isBgRGB()?this._drawUncachedChars(e,t,n,s):(e.isInverse()?(o=e.isBgDefault()?r.INVERTED_DEFAULT_COLOR:e.getBgColor(),a=e.isFgDefault()?r.INVERTED_DEFAULT_COLOR:e.getFgColor()):(a=e.isBgDefault()?i.DEFAULT_COLOR:e.getBgColor(),o=e.isFgDefault()?i.DEFAULT_COLOR:e.getFgColor()),o+=this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8?8:0,this._currentGlyphIdentifier.chars=e.getChars()||i.WHITESPACE_CELL_CHAR,this._currentGlyphIdentifier.code=e.getCode()||i.WHITESPACE_CELL_CODE,this._currentGlyphIdentifier.bg=a,this._currentGlyphIdentifier.fg=o,this._currentGlyphIdentifier.bold=!!e.isBold(),this._currentGlyphIdentifier.dim=!!e.isDim(),this._currentGlyphIdentifier.italic=!!e.isItalic(),this._charAtlas&&this._charAtlas.draw(this._ctx,this._currentGlyphIdentifier,t*this._scaledCellWidth+this._scaledCharLeft,n*this._scaledCellHeight+this._scaledCharTop)||this._drawUncachedChars(e,t,n))},e.prototype._drawUncachedChars=function(e,t,n,i){if(this._ctx.save(),this._ctx.font=this._getFont(!!e.isBold(),!!e.isItalic()),this._ctx.textBaseline="middle",e.isInverse())if(i)this._ctx.fillStyle=i.css;else if(e.isBgDefault())this._ctx.fillStyle=c.color.opaque(this._colors.background).css;else if(e.isBgRGB())this._ctx.fillStyle="rgb("+a.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var o=e.getBgColor();this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8&&(o+=8),this._ctx.fillStyle=this._colors.ansi[o].css}else if(i)this._ctx.fillStyle=i.css;else if(e.isFgDefault())this._ctx.fillStyle=this._colors.foreground.css;else if(e.isFgRGB())this._ctx.fillStyle="rgb("+a.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var s=e.getFgColor();this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&s<8&&(s+=8),this._ctx.fillStyle=this._colors.ansi[s].css}this._clipRow(n),e.isDim()&&(this._ctx.globalAlpha=r.DIM_OPACITY),this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,n*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2),this._ctx.restore()},e.prototype._clipRow=function(e){this._ctx.beginPath(),this._ctx.rect(0,e*this._scaledCellHeight,this._bufferService.cols*this._scaledCellWidth,this._scaledCellHeight),this._ctx.clip()},e.prototype._getFont=function(e,t){return(t?"italic":"")+" "+(e?this._optionsService.options.fontWeightBold:this._optionsService.options.fontWeight)+" "+this._optionsService.options.fontSize*window.devicePixelRatio+"px "+this._optionsService.options.fontFamily},e.prototype._getContrastColor=function(e){if(1!==this._optionsService.options.minimumContrastRatio){var t=this._colors.contrastCache.getColor(e.bg,e.fg);if(void 0!==t)return t||void 0;var n=e.getFgColor(),i=e.getFgColorMode(),r=e.getBgColor(),o=e.getBgColorMode(),a=!!e.isInverse(),s=!!e.isInverse();if(a){var l=n;n=r,r=l;var u=i;i=o,o=u}var h=this._resolveBackgroundRgba(o,r,a),d=this._resolveForegroundRgba(i,n,a,s),f=c.rgba.ensureContrastRatio(h,d,this._optionsService.options.minimumContrastRatio);if(f){var p={css:c.channels.toCss(f>>24&255,f>>16&255,f>>8&255),rgba:f};return this._colors.contrastCache.setColor(e.bg,e.fg,p),p}this._colors.contrastCache.setColor(e.bg,e.fg,null)}},e.prototype._resolveBackgroundRgba=function(e,t,n){switch(e){case 16777216:case 33554432:return this._colors.ansi[t].rgba;case 50331648:return t<<8;case 0:default:return n?this._colors.foreground.rgba:this._colors.background.rgba}},e.prototype._resolveForegroundRgba=function(e,t,n,i){switch(e){case 16777216:case 33554432:return this._optionsService.options.drawBoldTextInBrightColors&&i&&t<8&&(t+=8),this._colors.ansi[t].rgba;case 50331648:return t<<8;case 0:default:return n?this._colors.background.rgba:this._colors.foreground.rgba}},e}();t.BaseRenderLayer=u},function(e,t,n){"use strict";function i(e,t,n){t.di$target===t?t.di$dependencies.push({id:e,index:n}):(t.di$dependencies=[{id:e,index:n}],t.di$target=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.createDecorator=t.getServiceDependencies=t.serviceRegistry=void 0,t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e.di$dependencies||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);var n=function e(t,n,r){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");i(e,t,r)};return n.toString=function(){return e},t.serviceRegistry.set(e,n),n}},function(e,t,n){"use strict";function i(e,t,n,i){if(void 0===n&&(n=0),void 0===i&&(i=e.length),n>=e.length)return e;i=i>=e.length?e.length:(e.length+i)%e.length;for(var r=n=(e.length+n)%e.length;r>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):n]},e.prototype.set=function(e,t){this._data[3*e+1]=t[r.CHAR_DATA_ATTR_INDEX],t[r.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[r.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[r.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[r.CHAR_DATA_WIDTH_INDEX]<<22},e.prototype.getWidth=function(e){return this._data[3*e+0]>>22},e.prototype.hasWidth=function(e){return 12582912&this._data[3*e+0]},e.prototype.getFg=function(e){return this._data[3*e+1]},e.prototype.getBg=function(e){return this._data[3*e+2]},e.prototype.hasContent=function(e){return 4194303&this._data[3*e+0]},e.prototype.getCodePoint=function(e){var t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t},e.prototype.isCombined=function(e){return 2097152&this._data[3*e+0]},e.prototype.getString=function(e){var t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?i.stringFromCodePoint(2097151&t):""},e.prototype.loadCell=function(e,t){var n=3*e;return t.content=this._data[n+0],t.fg=this._data[n+1],t.bg=this._data[n+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t},e.prototype.setCell=function(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg},e.prototype.setCellFromCodePoint=function(e,t,n,i,r,o){268435456&r&&(this._extendedAttrs[e]=o),this._data[3*e+0]=t|n<<22,this._data[3*e+1]=i,this._data[3*e+2]=r},e.prototype.addCodepointToCell=function(e,t){var n=this._data[3*e+0];2097152&n?this._combined[e]+=i.stringFromCodePoint(t):(2097151&n?(this._combined[e]=i.stringFromCodePoint(2097151&n)+i.stringFromCodePoint(t),n&=-2097152,n|=2097152):n=t|1<<22,this._data[3*e+0]=n)},e.prototype.insertCells=function(e,t,n,i){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodePoint(e-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0,(null==i?void 0:i.extended)||new a.ExtendedAttrs),t=0;--s)this.setCell(e+t+s,this.loadCell(e+s,r));for(s=0;sthis.length){var n=new Uint32Array(3*e);this.length&&n.set(3*e=e&&delete this._combined[o]}}else this._data=new Uint32Array(0),this._combined={};this.length=e}},e.prototype.fill=function(e){this._combined={},this._extendedAttrs={};for(var t=0;t=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0},e.prototype.copyCellsFrom=function(e,t,n,i,r){var o=e._data;if(r)for(var a=i-1;a>=0;a--)for(var s=0;s<3;s++)this._data[3*(n+a)+s]=o[3*(t+a)+s];else for(a=0;a=t&&(this._combined[l-t+n]=e._combined[l])}},e.prototype.translateToString=function(e,t,n){void 0===e&&(e=!1),void 0===t&&(t=0),void 0===n&&(n=this.length),e&&(n=Math.min(n,this.getTrimmedLength()));for(var o="";t>22||1}return o},e}();t.BufferLine=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeElementFromParent=void 0,t.removeElementFromParent=function(){for(var e,t=[],n=0;n24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}!function(e){e[e.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",e[e.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"}(o=t.WindowsOptionsReportType||(t.WindowsOptionsReportType={}));var w=function(){function e(e,t,n,i){this._bufferService=e,this._coreService=t,this._logService=n,this._optionsService=i,this._data=new Uint32Array(0)}return e.prototype.hook=function(e){this._data=new Uint32Array(0)},e.prototype.put=function(e,t,n){this._data=u.concat(this._data,e.subarray(t,n))},e.prototype.unhook=function(e){if(e){var t=h.utf32ToString(this._data);switch(this._data=new Uint32Array(0),t){case'"q':return this._coreService.triggerDataEvent(a.C0.ESC+'P1$r0"q'+a.C0.ESC+"\\");case'"p':return this._coreService.triggerDataEvent(a.C0.ESC+'P1$r61;1"p'+a.C0.ESC+"\\");case"r":return this._coreService.triggerDataEvent(a.C0.ESC+"P1$r"+(this._bufferService.buffer.scrollTop+1)+";"+(this._bufferService.buffer.scrollBottom+1)+"r"+a.C0.ESC+"\\");case"m":return this._coreService.triggerDataEvent(a.C0.ESC+"P1$r0m"+a.C0.ESC+"\\");case" q":var n={block:2,underline:4,bar:6}[this._optionsService.options.cursorStyle];return this._coreService.triggerDataEvent(a.C0.ESC+"P1$r"+(n-=this._optionsService.options.cursorBlink?1:0)+" q"+a.C0.ESC+"\\");default:this._logService.debug("Unknown DCS $q %s",t),this._coreService.triggerDataEvent(a.C0.ESC+"P0$r"+a.C0.ESC+"\\")}}else this._data=new Uint32Array(0)},e}(),k=function(e){function t(t,n,i,r,o,l,u,p,g){void 0===g&&(g=new c.EscapeSequenceParser);var b=e.call(this)||this;b._bufferService=t,b._charsetService=n,b._coreService=i,b._dirtyRowService=r,b._logService=o,b._optionsService=l,b._coreMouseService=u,b._unicodeService=p,b._parser=g,b._parseBuffer=new Uint32Array(4096),b._stringDecoder=new h.StringToUtf32,b._utf8Decoder=new h.Utf8ToUtf32,b._workCell=new m.CellData,b._windowTitle="",b._iconName="",b._windowTitleStack=[],b._iconNameStack=[],b._curAttrData=d.DEFAULT_ATTR_DATA.clone(),b._eraseAttrDataInternal=d.DEFAULT_ATTR_DATA.clone(),b._onRequestBell=new f.EventEmitter,b._onRequestRefreshRows=new f.EventEmitter,b._onRequestReset=new f.EventEmitter,b._onRequestScroll=new f.EventEmitter,b._onRequestSyncScrollBar=new f.EventEmitter,b._onRequestWindowsOptionsReport=new f.EventEmitter,b._onA11yChar=new f.EventEmitter,b._onA11yTab=new f.EventEmitter,b._onCursorMove=new f.EventEmitter,b._onLineFeed=new f.EventEmitter,b._onScroll=new f.EventEmitter,b._onTitleChange=new f.EventEmitter,b.register(b._parser),b._parser.setCsiHandlerFallback((function(e,t){b._logService.debug("Unknown CSI code: ",{identifier:b._parser.identToString(e),params:t.toArray()})})),b._parser.setEscHandlerFallback((function(e){b._logService.debug("Unknown ESC code: ",{identifier:b._parser.identToString(e)})})),b._parser.setExecuteHandlerFallback((function(e){b._logService.debug("Unknown EXECUTE code: ",{code:e})})),b._parser.setOscHandlerFallback((function(e,t,n){b._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:n})})),b._parser.setDcsHandlerFallback((function(e,t,n){"HOOK"===t&&(n=n.toArray()),b._logService.debug("Unknown DCS code: ",{identifier:b._parser.identToString(e),action:t,payload:n})})),b._parser.setPrintHandler((function(e,t,n){return b.print(e,t,n)})),b._parser.setCsiHandler({final:"@"},(function(e){return b.insertChars(e)})),b._parser.setCsiHandler({intermediates:" ",final:"@"},(function(e){return b.scrollLeft(e)})),b._parser.setCsiHandler({final:"A"},(function(e){return b.cursorUp(e)})),b._parser.setCsiHandler({intermediates:" ",final:"A"},(function(e){return b.scrollRight(e)})),b._parser.setCsiHandler({final:"B"},(function(e){return b.cursorDown(e)})),b._parser.setCsiHandler({final:"C"},(function(e){return b.cursorForward(e)})),b._parser.setCsiHandler({final:"D"},(function(e){return b.cursorBackward(e)})),b._parser.setCsiHandler({final:"E"},(function(e){return b.cursorNextLine(e)})),b._parser.setCsiHandler({final:"F"},(function(e){return b.cursorPrecedingLine(e)})),b._parser.setCsiHandler({final:"G"},(function(e){return b.cursorCharAbsolute(e)})),b._parser.setCsiHandler({final:"H"},(function(e){return b.cursorPosition(e)})),b._parser.setCsiHandler({final:"I"},(function(e){return b.cursorForwardTab(e)})),b._parser.setCsiHandler({final:"J"},(function(e){return b.eraseInDisplay(e)})),b._parser.setCsiHandler({prefix:"?",final:"J"},(function(e){return b.eraseInDisplay(e)})),b._parser.setCsiHandler({final:"K"},(function(e){return b.eraseInLine(e)})),b._parser.setCsiHandler({prefix:"?",final:"K"},(function(e){return b.eraseInLine(e)})),b._parser.setCsiHandler({final:"L"},(function(e){return b.insertLines(e)})),b._parser.setCsiHandler({final:"M"},(function(e){return b.deleteLines(e)})),b._parser.setCsiHandler({final:"P"},(function(e){return b.deleteChars(e)})),b._parser.setCsiHandler({final:"S"},(function(e){return b.scrollUp(e)})),b._parser.setCsiHandler({final:"T"},(function(e){return b.scrollDown(e)})),b._parser.setCsiHandler({final:"X"},(function(e){return b.eraseChars(e)})),b._parser.setCsiHandler({final:"Z"},(function(e){return b.cursorBackwardTab(e)})),b._parser.setCsiHandler({final:"`"},(function(e){return b.charPosAbsolute(e)})),b._parser.setCsiHandler({final:"a"},(function(e){return b.hPositionRelative(e)})),b._parser.setCsiHandler({final:"b"},(function(e){return b.repeatPrecedingCharacter(e)})),b._parser.setCsiHandler({final:"c"},(function(e){return b.sendDeviceAttributesPrimary(e)})),b._parser.setCsiHandler({prefix:">",final:"c"},(function(e){return b.sendDeviceAttributesSecondary(e)})),b._parser.setCsiHandler({final:"d"},(function(e){return b.linePosAbsolute(e)})),b._parser.setCsiHandler({final:"e"},(function(e){return b.vPositionRelative(e)})),b._parser.setCsiHandler({final:"f"},(function(e){return b.hVPosition(e)})),b._parser.setCsiHandler({final:"g"},(function(e){return b.tabClear(e)})),b._parser.setCsiHandler({final:"h"},(function(e){return b.setMode(e)})),b._parser.setCsiHandler({prefix:"?",final:"h"},(function(e){return b.setModePrivate(e)})),b._parser.setCsiHandler({final:"l"},(function(e){return b.resetMode(e)})),b._parser.setCsiHandler({prefix:"?",final:"l"},(function(e){return b.resetModePrivate(e)})),b._parser.setCsiHandler({final:"m"},(function(e){return b.charAttributes(e)})),b._parser.setCsiHandler({final:"n"},(function(e){return b.deviceStatus(e)})),b._parser.setCsiHandler({prefix:"?",final:"n"},(function(e){return b.deviceStatusPrivate(e)})),b._parser.setCsiHandler({intermediates:"!",final:"p"},(function(e){return b.softReset(e)})),b._parser.setCsiHandler({intermediates:" ",final:"q"},(function(e){return b.setCursorStyle(e)})),b._parser.setCsiHandler({final:"r"},(function(e){return b.setScrollRegion(e)})),b._parser.setCsiHandler({final:"s"},(function(e){return b.saveCursor(e)})),b._parser.setCsiHandler({final:"t"},(function(e){return b.windowOptions(e)})),b._parser.setCsiHandler({final:"u"},(function(e){return b.restoreCursor(e)})),b._parser.setCsiHandler({intermediates:"'",final:"}"},(function(e){return b.insertColumns(e)})),b._parser.setCsiHandler({intermediates:"'",final:"~"},(function(e){return b.deleteColumns(e)})),b._parser.setExecuteHandler(a.C0.BEL,(function(){return b.bell()})),b._parser.setExecuteHandler(a.C0.LF,(function(){return b.lineFeed()})),b._parser.setExecuteHandler(a.C0.VT,(function(){return b.lineFeed()})),b._parser.setExecuteHandler(a.C0.FF,(function(){return b.lineFeed()})),b._parser.setExecuteHandler(a.C0.CR,(function(){return b.carriageReturn()})),b._parser.setExecuteHandler(a.C0.BS,(function(){return b.backspace()})),b._parser.setExecuteHandler(a.C0.HT,(function(){return b.tab()})),b._parser.setExecuteHandler(a.C0.SO,(function(){return b.shiftOut()})),b._parser.setExecuteHandler(a.C0.SI,(function(){return b.shiftIn()})),b._parser.setExecuteHandler(a.C1.IND,(function(){return b.index()})),b._parser.setExecuteHandler(a.C1.NEL,(function(){return b.nextLine()})),b._parser.setExecuteHandler(a.C1.HTS,(function(){return b.tabSet()})),b._parser.setOscHandler(0,new v.OscHandler((function(e){b.setTitle(e),b.setIconName(e)}))),b._parser.setOscHandler(1,new v.OscHandler((function(e){return b.setIconName(e)}))),b._parser.setOscHandler(2,new v.OscHandler((function(e){return b.setTitle(e)}))),b._parser.setEscHandler({final:"7"},(function(){return b.saveCursor()})),b._parser.setEscHandler({final:"8"},(function(){return b.restoreCursor()})),b._parser.setEscHandler({final:"D"},(function(){return b.index()})),b._parser.setEscHandler({final:"E"},(function(){return b.nextLine()})),b._parser.setEscHandler({final:"H"},(function(){return b.tabSet()})),b._parser.setEscHandler({final:"M"},(function(){return b.reverseIndex()})),b._parser.setEscHandler({final:"="},(function(){return b.keypadApplicationMode()})),b._parser.setEscHandler({final:">"},(function(){return b.keypadNumericMode()})),b._parser.setEscHandler({final:"c"},(function(){return b.fullReset()})),b._parser.setEscHandler({final:"n"},(function(){return b.setgLevel(2)})),b._parser.setEscHandler({final:"o"},(function(){return b.setgLevel(3)})),b._parser.setEscHandler({final:"|"},(function(){return b.setgLevel(3)})),b._parser.setEscHandler({final:"}"},(function(){return b.setgLevel(2)})),b._parser.setEscHandler({final:"~"},(function(){return b.setgLevel(1)})),b._parser.setEscHandler({intermediates:"%",final:"@"},(function(){return b.selectDefaultCharset()})),b._parser.setEscHandler({intermediates:"%",final:"G"},(function(){return b.selectDefaultCharset()}));var y=function(e){_._parser.setEscHandler({intermediates:"(",final:e},(function(){return b.selectCharset("("+e)})),_._parser.setEscHandler({intermediates:")",final:e},(function(){return b.selectCharset(")"+e)})),_._parser.setEscHandler({intermediates:"*",final:e},(function(){return b.selectCharset("*"+e)})),_._parser.setEscHandler({intermediates:"+",final:e},(function(){return b.selectCharset("+"+e)})),_._parser.setEscHandler({intermediates:"-",final:e},(function(){return b.selectCharset("-"+e)})),_._parser.setEscHandler({intermediates:".",final:e},(function(){return b.selectCharset("."+e)})),_._parser.setEscHandler({intermediates:"/",final:e},(function(){return b.selectCharset("/"+e)}))},_=this;for(var k in s.CHARSETS)y(k);return b._parser.setEscHandler({intermediates:"#",final:"8"},(function(){return b.screenAlignmentPattern()})),b._parser.setErrorHandler((function(e){return b._logService.error("Parsing error: ",e),e})),b._parser.setDcsHandler({intermediates:"$",final:"q"},new w(b._bufferService,b._coreService,b._logService,b._optionsService)),b}return r(t,e),Object.defineProperty(t.prototype,"onRequestBell",{get:function(){return this._onRequestBell.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestReset",{get:function(){return this._onRequestReset.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestScroll",{get:function(){return this._onRequestScroll.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestSyncScrollBar",{get:function(){return this._onRequestSyncScrollBar.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestWindowsOptionsReport",{get:function(){return this._onRequestWindowsOptionsReport.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yChar",{get:function(){return this._onA11yChar.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yTab",{get:function(){return this._onA11yTab.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTitleChange",{get:function(){return this._onTitleChange.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype.parse=function(e){var t=this._bufferService.buffer,n=t.x,i=t.y;if(this._logService.debug("parsing data",e),this._parseBuffer.length131072)for(var r=0;r0&&2===f.getWidth(o.x-1)&&f.setCellFromCodePoint(o.x-1,0,1,d.fg,d.bg,d.extended);for(var m=t;m=c)if(l){for(;o.x=this._bufferService.rows&&(o.y=this._bufferService.rows-1),o.lines.get(o.ybase+o.y).isWrapped=!0),f=o.lines.get(o.ybase+o.y)}else if(o.x=c-1,2===r)continue;if(u&&(f.insertCells(o.x,r,o.getNullCell(d),d),2===f.getWidth(c-1)&&f.setCellFromCodePoint(c-1,p.NULL_CELL_CODE,p.NULL_CELL_WIDTH,d.fg,d.bg,d.extended)),f.setCellFromCodePoint(o.x++,i,r,d.fg,d.bg,d.extended),r>0)for(;--r;)f.setCellFromCodePoint(o.x++,0,0,d.fg,d.bg,d.extended)}else f.getWidth(o.x-1)?f.addCodepointToCell(o.x-1,i):f.addCodepointToCell(o.x-2,i)}n-t>0&&(f.loadCell(o.x-1,this._workCell),this._parser.precedingCodepoint=2===this._workCell.getWidth()||this._workCell.getCode()>65535?0:this._workCell.isCombined()?this._workCell.getChars().charCodeAt(0):this._workCell.content),o.x0&&0===f.getWidth(o.x)&&!f.hasContent(o.x)&&f.setCellFromCodePoint(o.x,0,1,d.fg,d.bg,d.extended),this._dirtyRowService.markDirty(o.y)},t.prototype.addCsiHandler=function(e,t){var n=this;return this._parser.addCsiHandler(e,"t"!==e.final||e.prefix||e.intermediates?t:function(e){return!_(e.params[0],n._optionsService.options.windowOptions)||t(e)})},t.prototype.addDcsHandler=function(e,t){return this._parser.addDcsHandler(e,new b.DcsHandler(t))},t.prototype.addEscHandler=function(e,t){return this._parser.addEscHandler(e,t)},t.prototype.addOscHandler=function(e,t){return this._parser.addOscHandler(e,new v.OscHandler(t))},t.prototype.bell=function(){this._onRequestBell.fire()},t.prototype.lineFeed=function(){var e=this._bufferService.buffer;this._dirtyRowService.markDirty(e.y),this._optionsService.options.convertEol&&(e.x=0),e.y++,e.y===e.scrollBottom+1?(e.y--,this._onRequestScroll.fire(this._eraseAttrData())):e.y>=this._bufferService.rows&&(e.y=this._bufferService.rows-1),e.x>=this._bufferService.cols&&e.x--,this._dirtyRowService.markDirty(e.y),this._onLineFeed.fire()},t.prototype.carriageReturn=function(){this._bufferService.buffer.x=0},t.prototype.backspace=function(){var e,t=this._bufferService.buffer;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),void(t.x>0&&t.x--);if(this._restrictCursor(this._bufferService.cols),t.x>0)t.x--;else if(0===t.x&&t.y>t.scrollTop&&t.y<=t.scrollBottom&&(null===(e=t.lines.get(t.ybase+t.y))||void 0===e?void 0:e.isWrapped)){t.lines.get(t.ybase+t.y).isWrapped=!1,t.y--,t.x=this._bufferService.cols-1;var n=t.lines.get(t.ybase+t.y);n.hasWidth(t.x)&&!n.hasContent(t.x)&&t.x--}this._restrictCursor()},t.prototype.tab=function(){if(!(this._bufferService.buffer.x>=this._bufferService.cols)){var e=this._bufferService.buffer.x;this._bufferService.buffer.x=this._bufferService.buffer.nextStop(),this._optionsService.options.screenReaderMode&&this._onA11yTab.fire(this._bufferService.buffer.x-e)}},t.prototype.shiftOut=function(){this._charsetService.setgLevel(1)},t.prototype.shiftIn=function(){this._charsetService.setgLevel(0)},t.prototype._restrictCursor=function(e){void 0===e&&(e=this._bufferService.cols-1),this._bufferService.buffer.x=Math.min(e,Math.max(0,this._bufferService.buffer.x)),this._bufferService.buffer.y=this._coreService.decPrivateModes.origin?Math.min(this._bufferService.buffer.scrollBottom,Math.max(this._bufferService.buffer.scrollTop,this._bufferService.buffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._bufferService.buffer.y)),this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype._setCursor=function(e,t){this._dirtyRowService.markDirty(this._bufferService.buffer.y),this._coreService.decPrivateModes.origin?(this._bufferService.buffer.x=e,this._bufferService.buffer.y=this._bufferService.buffer.scrollTop+t):(this._bufferService.buffer.x=e,this._bufferService.buffer.y=t),this._restrictCursor(),this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype._moveCursor=function(e,t){this._restrictCursor(),this._setCursor(this._bufferService.buffer.x+e,this._bufferService.buffer.y+t)},t.prototype.cursorUp=function(e){var t=this._bufferService.buffer.y-this._bufferService.buffer.scrollTop;this._moveCursor(0,t>=0?-Math.min(t,e.params[0]||1):-(e.params[0]||1))},t.prototype.cursorDown=function(e){var t=this._bufferService.buffer.scrollBottom-this._bufferService.buffer.y;this._moveCursor(0,t>=0?Math.min(t,e.params[0]||1):e.params[0]||1)},t.prototype.cursorForward=function(e){this._moveCursor(e.params[0]||1,0)},t.prototype.cursorBackward=function(e){this._moveCursor(-(e.params[0]||1),0)},t.prototype.cursorNextLine=function(e){this.cursorDown(e),this._bufferService.buffer.x=0},t.prototype.cursorPrecedingLine=function(e){this.cursorUp(e),this._bufferService.buffer.x=0},t.prototype.cursorCharAbsolute=function(e){this._setCursor((e.params[0]||1)-1,this._bufferService.buffer.y)},t.prototype.cursorPosition=function(e){this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1)},t.prototype.charPosAbsolute=function(e){this._setCursor((e.params[0]||1)-1,this._bufferService.buffer.y)},t.prototype.hPositionRelative=function(e){this._moveCursor(e.params[0]||1,0)},t.prototype.linePosAbsolute=function(e){this._setCursor(this._bufferService.buffer.x,(e.params[0]||1)-1)},t.prototype.vPositionRelative=function(e){this._moveCursor(0,e.params[0]||1)},t.prototype.hVPosition=function(e){this.cursorPosition(e)},t.prototype.tabClear=function(e){var t=e.params[0];0===t?delete this._bufferService.buffer.tabs[this._bufferService.buffer.x]:3===t&&(this._bufferService.buffer.tabs={})},t.prototype.cursorForwardTab=function(e){if(!(this._bufferService.buffer.x>=this._bufferService.cols))for(var t=e.params[0]||1;t--;)this._bufferService.buffer.x=this._bufferService.buffer.nextStop()},t.prototype.cursorBackwardTab=function(e){if(!(this._bufferService.buffer.x>=this._bufferService.cols))for(var t=e.params[0]||1,n=this._bufferService.buffer;t--;)n.x=n.prevStop()},t.prototype._eraseInBufferLine=function(e,t,n,i){void 0===i&&(i=!1);var r=this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase+e);r.replaceCells(t,n,this._bufferService.buffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i&&(r.isWrapped=!1)},t.prototype._resetBufferLine=function(e){var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase+e);t.fill(this._bufferService.buffer.getNullCell(this._eraseAttrData())),t.isWrapped=!1},t.prototype.eraseInDisplay=function(e){var t;switch(this._restrictCursor(),e.params[0]){case 0:for(this._dirtyRowService.markDirty(t=this._bufferService.buffer.y),this._eraseInBufferLine(t++,this._bufferService.buffer.x,this._bufferService.cols,0===this._bufferService.buffer.x);t=this._bufferService.cols&&(this._bufferService.buffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 2:for(this._dirtyRowService.markDirty((t=this._bufferService.rows)-1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 3:var n=this._bufferService.buffer.lines.length-this._bufferService.rows;n>0&&(this._bufferService.buffer.lines.trimStart(n),this._bufferService.buffer.ybase=Math.max(this._bufferService.buffer.ybase-n,0),this._bufferService.buffer.ydisp=Math.max(this._bufferService.buffer.ydisp-n,0),this._onScroll.fire(0))}},t.prototype.eraseInLine=function(e){switch(this._restrictCursor(),e.params[0]){case 0:this._eraseInBufferLine(this._bufferService.buffer.y,this._bufferService.buffer.x,this._bufferService.cols);break;case 1:this._eraseInBufferLine(this._bufferService.buffer.y,0,this._bufferService.buffer.x+1);break;case 2:this._eraseInBufferLine(this._bufferService.buffer.y,0,this._bufferService.cols)}this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype.insertLines=function(e){this._restrictCursor();var t=e.params[0]||1,n=this._bufferService.buffer;if(!(n.y>n.scrollBottom||n.yn.scrollBottom||n.yt.scrollBottom||t.yt.scrollBottom||t.yt.scrollBottom||t.yt.scrollBottom||t.y0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(a.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(a.C0.ESC+"[?6c"))},t.prototype.sendDeviceAttributesSecondary=function(e){e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(a.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(a.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(a.C0.ESC+"[>83;40003;0c"))},t.prototype._is=function(e){return 0===(this._optionsService.options.termName+"").indexOf(e)},t.prototype.setMode=function(e){for(var t=0;t=2||2===i[1]&&o+r>=5)break;i[1]&&(r=1)}while(++o+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,0===e&&(t.fg&=-268435457),t.updateExtended()},t.prototype.charAttributes=function(e){if(1===e.length&&0===e.params[0])return this._curAttrData.fg=d.DEFAULT_ATTR_DATA.fg,void(this._curAttrData.bg=d.DEFAULT_ATTR_DATA.bg);for(var t,n=e.length,i=this._curAttrData,r=0;r=30&&t<=37?(i.fg&=-50331904,i.fg|=16777216|t-30):t>=40&&t<=47?(i.bg&=-50331904,i.bg|=16777216|t-40):t>=90&&t<=97?(i.fg&=-50331904,i.fg|=16777224|t-90):t>=100&&t<=107?(i.bg&=-50331904,i.bg|=16777224|t-100):0===t?(i.fg=d.DEFAULT_ATTR_DATA.fg,i.bg=d.DEFAULT_ATTR_DATA.bg):1===t?i.fg|=134217728:3===t?i.bg|=67108864:4===t?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):5===t?i.fg|=536870912:7===t?i.fg|=67108864:8===t?i.fg|=1073741824:2===t?i.bg|=134217728:21===t?this._processUnderline(2,i):22===t?(i.fg&=-134217729,i.bg&=-134217729):23===t?i.bg&=-67108865:24===t?i.fg&=-268435457:25===t?i.fg&=-536870913:27===t?i.fg&=-67108865:28===t?i.fg&=-1073741825:39===t?(i.fg&=-67108864,i.fg|=16777215&d.DEFAULT_ATTR_DATA.fg):49===t?(i.bg&=-67108864,i.bg|=16777215&d.DEFAULT_ATTR_DATA.bg):38===t||48===t||58===t?r+=this._extractColor(e,r,i):59===t?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):100===t?(i.fg&=-67108864,i.fg|=16777215&d.DEFAULT_ATTR_DATA.fg,i.bg&=-67108864,i.bg|=16777215&d.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",t)},t.prototype.deviceStatus=function(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(a.C0.ESC+"[0n");break;case 6:this._coreService.triggerDataEvent(a.C0.ESC+"["+(this._bufferService.buffer.y+1)+";"+(this._bufferService.buffer.x+1)+"R")}},t.prototype.deviceStatusPrivate=function(e){switch(e.params[0]){case 6:this._coreService.triggerDataEvent(a.C0.ESC+"[?"+(this._bufferService.buffer.y+1)+";"+(this._bufferService.buffer.x+1)+"R")}},t.prototype.softReset=function(e){this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._bufferService.buffer.scrollTop=0,this._bufferService.buffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=d.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._bufferService.buffer.savedX=0,this._bufferService.buffer.savedY=this._bufferService.buffer.ybase,this._bufferService.buffer.savedCurAttrData.fg=this._curAttrData.fg,this._bufferService.buffer.savedCurAttrData.bg=this._curAttrData.bg,this._bufferService.buffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1},t.prototype.setCursorStyle=function(e){var t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}this._optionsService.options.cursorBlink=t%2==1},t.prototype.setScrollRegion=function(e){var t,n=e.params[0]||1;(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>n&&(this._bufferService.buffer.scrollTop=n-1,this._bufferService.buffer.scrollBottom=t-1,this._setCursor(0,0))},t.prototype.windowOptions=function(e){if(_(e.params[0],this._optionsService.options.windowOptions)){var t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==t&&this._onRequestWindowsOptionsReport.fire(o.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(o.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(a.C0.ESC+"[8;"+this._bufferService.rows+";"+this._bufferService.cols+"t");break;case 22:0!==t&&2!==t||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),0!==t&&1!==t||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:0!==t&&2!==t||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),0!==t&&1!==t||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}}},t.prototype.saveCursor=function(e){this._bufferService.buffer.savedX=this._bufferService.buffer.x,this._bufferService.buffer.savedY=this._bufferService.buffer.ybase+this._bufferService.buffer.y,this._bufferService.buffer.savedCurAttrData.fg=this._curAttrData.fg,this._bufferService.buffer.savedCurAttrData.bg=this._curAttrData.bg,this._bufferService.buffer.savedCharset=this._charsetService.charset},t.prototype.restoreCursor=function(e){this._bufferService.buffer.x=this._bufferService.buffer.savedX||0,this._bufferService.buffer.y=Math.max(this._bufferService.buffer.savedY-this._bufferService.buffer.ybase,0),this._curAttrData.fg=this._bufferService.buffer.savedCurAttrData.fg,this._curAttrData.bg=this._bufferService.buffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._bufferService.buffer.savedCharset&&(this._charsetService.charset=this._bufferService.buffer.savedCharset),this._restrictCursor()},t.prototype.setTitle=function(e){this._windowTitle=e,this._onTitleChange.fire(e)},t.prototype.setIconName=function(e){this._iconName=e},t.prototype.nextLine=function(){this._bufferService.buffer.x=0,this.index()},t.prototype.keypadApplicationMode=function(){this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire()},t.prototype.keypadNumericMode=function(){this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire()},t.prototype.selectDefaultCharset=function(){this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,s.DEFAULT_CHARSET)},t.prototype.selectCharset=function(e){2===e.length?"/"!==e[0]&&this._charsetService.setgCharset(y[e[0]],s.CHARSETS[e[1]]||s.DEFAULT_CHARSET):this.selectDefaultCharset()},t.prototype.index=function(){this._restrictCursor();var e=this._bufferService.buffer;this._bufferService.buffer.y++,e.y===e.scrollBottom+1?(e.y--,this._onRequestScroll.fire(this._eraseAttrData())):e.y>=this._bufferService.rows&&(e.y=this._bufferService.rows-1),this._restrictCursor()},t.prototype.tabSet=function(){this._bufferService.buffer.tabs[this._bufferService.buffer.x]=!0},t.prototype.reverseIndex=function(){this._restrictCursor();var e=this._bufferService.buffer;e.y===e.scrollTop?(e.lines.shiftElements(e.ybase+e.y,e.scrollBottom-e.scrollTop,1),e.lines.set(e.ybase+e.y,e.getBlankLine(this._eraseAttrData())),this._dirtyRowService.markRangeDirty(e.scrollTop,e.scrollBottom)):(e.y--,this._restrictCursor())},t.prototype.fullReset=function(){this._parser.reset(),this._onRequestReset.fire()},t.prototype.reset=function(){this._curAttrData=d.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=d.DEFAULT_ATTR_DATA.clone()},t.prototype._eraseAttrData=function(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal},t.prototype.setgLevel=function(e){this._charsetService.setgLevel(e)},t.prototype.screenAlignmentPattern=function(){var e=new m.CellData;e.content=1<<22|"E".charCodeAt(0),e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg;var t=this._bufferService.buffer;this._setCursor(0,0);for(var n=0;n256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}return e.fromArray=function(t){var n=new e;if(!t.length)return n;for(var i=t[0]instanceof Array?1:0;i>8,i=255&this._subParamsIdx[t];i-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,i))}return e},e.prototype.reset=function(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1},e.prototype.addParam=function(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>2147483647?2147483647:e}},e.prototype.addSubParam=function(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>2147483647?2147483647:e,this._subParamsIdx[this.length-1]++}},e.prototype.hasSubParams=function(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0},e.prototype.getSubParams=function(e){var t=this._subParamsIdx[e]>>8,n=255&this._subParamsIdx[e];return n-t>0?this._subParams.subarray(t,n):null},e.prototype.getSubParamsAll=function(){for(var e={},t=0;t>8,i=255&this._subParamsIdx[t];i-n>0&&(e[t]=this._subParams.slice(n,i))}return e},e.prototype.addDigit=function(e){var t;if(!(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)){var n=this._digitIsSub?this._subParams:this.params,i=n[t-1];n[t-1]=~i?Math.min(10*i+e,2147483647):e}},e}();t.Params=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;var i=n(23),r=n(8),o=function(){function e(){this._state=0,this._id=-1,this._handlers=Object.create(null),this._handlerFb=function(){}}return e.prototype.addHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var n=this._handlers[e];return n.push(t),{dispose:function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}}},e.prototype.setHandler=function(e,t){this._handlers[e]=[t]},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){}},e.prototype.reset=function(){2===this._state&&this.end(!1),this._id=-1,this._state=0},e.prototype._start=function(){var e=this._handlers[this._id];if(e)for(var t=e.length-1;t>=0;t--)e[t].start();else this._handlerFb(this._id,"START")},e.prototype._put=function(e,t,n){var i=this._handlers[this._id];if(i)for(var o=i.length-1;o>=0;o--)i[o].put(e,t,n);else this._handlerFb(this._id,"PUT",r.utf32ToString(e,t,n))},e.prototype._end=function(e){var t=this._handlers[this._id];if(t){for(var n=t.length-1;n>=0&&!1===t[n].end(e);n--);for(n--;n>=0;n--)t[n].end(!1)}else this._handlerFb(this._id,"END",e)},e.prototype.start=function(){this.reset(),this._id=-1,this._state=1},e.prototype.put=function(e,t,n){if(3!==this._state){if(1===this._state)for(;t0&&this._put(e,t,n)}},e.prototype.end=function(e){0!==this._state&&(3!==this._state&&(1===this._state&&this._start(),this._end(e)),this._id=-1,this._state=0)},e}();t.OscParser=o;var a=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.start=function(){this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,n){this._hitLimit||(this._data+=r.utf32ToString(e,t,n),this._data.length>i.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.end=function(e){var t;return this._hitLimit?t=!1:e&&(t=this._handler(this._data)),this._data="",this._hitLimit=!1,t},e}();t.OscHandler=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;var i=n(8),r=n(21),o=n(23),a=[],s=function(){function e(){this._handlers=Object.create(null),this._active=a,this._ident=0,this._handlerFb=function(){}}return e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){}},e.prototype.addHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var n=this._handlers[e];return n.push(t),{dispose:function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}}},e.prototype.setHandler=function(e,t){this._handlers[e]=[t]},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.reset=function(){this._active.length&&this.unhook(!1),this._active=a,this._ident=0},e.prototype.hook=function(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||a,this._active.length)for(var n=this._active.length-1;n>=0;n--)this._active[n].hook(t);else this._handlerFb(this._ident,"HOOK",t)},e.prototype.put=function(e,t,n){if(this._active.length)for(var r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n);else this._handlerFb(this._ident,"PUT",i.utf32ToString(e,t,n))},e.prototype.unhook=function(e){if(this._active.length){for(var t=this._active.length-1;t>=0&&!1===this._active[t].unhook(e);t--);for(t--;t>=0;t--)this._active[t].unhook(!1)}else this._handlerFb(this._ident,"UNHOOK",e);this._active=a,this._ident=0},e}();t.DcsParser=s;var c=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.hook=function(e){this._params=e.clone(),this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,n){this._hitLimit||(this._data+=i.utf32ToString(e,t,n),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.unhook=function(e){var t;return this._hitLimit?t=!1:e&&(t=this._handler(this._data,this._params||new r.Params)),this._params=void 0,this._data="",this._hitLimit=!1,t},e}();t.DcsHandler=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeTerminalFromCache=t.acquireCharAtlas=void 0;var i=n(26),r=n(43),o=[];t.acquireCharAtlas=function(e,t,n,a,s){for(var c=i.generateConfig(a,s,e,n),l=0;l=0){if(i.configEquals(h.config,c))return h.atlas;1===h.ownedBy.length?(h.atlas.dispose(),o.splice(l,1)):h.ownedBy.splice(u,1);break}}for(l=0;l1)for(var h=this._getJoinedRanges(i,s,o,t,r),d=0;d1)for(h=this._getJoinedRanges(i,s,o,t,r),d=0;d=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new i.CellData)},e.prototype.translateToString=function(e,t,n){return this._line.translateToString(e,t,n)},e}(),d=function(){function e(e){this._core=e}return e.prototype.registerCsiHandler=function(e,t){return this._core.addCsiHandler(e,(function(e){return t(e.toArray())}))},e.prototype.addCsiHandler=function(e,t){return this.registerCsiHandler(e,t)},e.prototype.registerDcsHandler=function(e,t){return this._core.addDcsHandler(e,(function(e,n){return t(e,n.toArray())}))},e.prototype.addDcsHandler=function(e,t){return this.registerDcsHandler(e,t)},e.prototype.registerEscHandler=function(e,t){return this._core.addEscHandler(e,t)},e.prototype.addEscHandler=function(e,t){return this.registerEscHandler(e,t)},e.prototype.registerOscHandler=function(e,t){return this._core.addOscHandler(e,t)},e.prototype.addOscHandler=function(e,t){return this.registerOscHandler(e,t)},e}(),f=function(){function e(e){this._core=e}return e.prototype.register=function(e){this._core.unicodeService.register(e)},Object.defineProperty(e.prototype,"versions",{get:function(){return this._core.unicodeService.versions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeVersion",{get:function(){return this._core.unicodeService.activeVersion},set:function(e){this._core.unicodeService.activeVersion=e},enumerable:!1,configurable:!0}),e}()},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;var o=n(36),a=n(37),s=n(38),c=n(12),l=n(19),u=n(40),h=n(50),d=n(51),f=n(11),p=n(7),m=n(18),g=n(54),v=n(55),b=n(56),y=n(57),_=n(59),w=n(0),k=n(16),C=n(27),S=n(60),x=n(5),O=n(61),M=n(62),T=n(63),E=n(64),P=n(65),j="undefined"!=typeof window?window.document:null,A=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,t)||this;return n.browser=f,n._keyDownHandled=!1,n._onCursorMove=new w.EventEmitter,n._onKey=new w.EventEmitter,n._onRender=new w.EventEmitter,n._onSelectionChange=new w.EventEmitter,n._onTitleChange=new w.EventEmitter,n._onFocus=new w.EventEmitter,n._onBlur=new w.EventEmitter,n._onA11yCharEmitter=new w.EventEmitter,n._onA11yTabEmitter=new w.EventEmitter,n._setup(),n.linkifier=n._instantiationService.createInstance(h.Linkifier),n.linkifier2=n.register(n._instantiationService.createInstance(T.Linkifier2)),n.register(n._inputHandler.onRequestBell((function(){return n.bell()}))),n.register(n._inputHandler.onRequestRefreshRows((function(e,t){return n.refresh(e,t)}))),n.register(n._inputHandler.onRequestReset((function(){return n.reset()}))),n.register(n._inputHandler.onRequestScroll((function(e,t){return n.scroll(e,t||void 0)}))),n.register(n._inputHandler.onRequestWindowsOptionsReport((function(e){return n._reportWindowsOptions(e)}))),n.register(w.forwardEvent(n._inputHandler.onCursorMove,n._onCursorMove)),n.register(w.forwardEvent(n._inputHandler.onTitleChange,n._onTitleChange)),n.register(w.forwardEvent(n._inputHandler.onA11yChar,n._onA11yCharEmitter)),n.register(w.forwardEvent(n._inputHandler.onA11yTab,n._onA11yTabEmitter)),n.register(n._bufferService.onResize((function(e){return n._afterResize(e.cols,e.rows)}))),n}return r(t,e),Object.defineProperty(t.prototype,"options",{get:function(){return this.optionsService.options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onKey",{get:function(){return this._onKey.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRender",{get:function(){return this._onRender.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onSelectionChange",{get:function(){return this._onSelectionChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTitleChange",{get:function(){return this._onTitleChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onFocus",{get:function(){return this._onFocus.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBlur",{get:function(){return this._onBlur.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yChar",{get:function(){return this._onA11yCharEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onA11yTab",{get:function(){return this._onA11yTabEmitter.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t,n,i;this._isDisposed||(e.prototype.dispose.call(this),null===(t=this._renderService)||void 0===t||t.dispose(),this._customKeyEventHandler=void 0,this.write=function(){},null===(i=null===(n=this.element)||void 0===n?void 0:n.parentNode)||void 0===i||i.removeChild(this.element))},t.prototype._setup=function(){e.prototype._setup.call(this),this._customKeyEventHandler=void 0},Object.defineProperty(t.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!1,configurable:!0}),t.prototype.focus=function(){this.textarea&&this.textarea.focus({preventScroll:!0})},t.prototype._updateOptions=function(t){var n,i,r,o;switch(e.prototype._updateOptions.call(this,t),t){case"fontFamily":case"fontSize":null===(n=this._renderService)||void 0===n||n.clear(),null===(i=this._charSizeService)||void 0===i||i.measure();break;case"cursorBlink":case"cursorStyle":this.refresh(this.buffer.y,this.buffer.y);break;case"drawBoldTextInBrightColors":case"letterSpacing":case"lineHeight":case"fontWeight":case"fontWeightBold":case"minimumContrastRatio":this._renderService&&(this._renderService.clear(),this._renderService.onResize(this.cols,this.rows),this.refresh(0,this.rows-1));break;case"rendererType":this._renderService&&(this._renderService.setRenderer(this._createRenderer()),this._renderService.onResize(this.cols,this.rows));break;case"scrollback":null===(r=this.viewport)||void 0===r||r.syncScrollArea();break;case"screenReaderMode":this.optionsService.options.screenReaderMode?!this._accessibilityManager&&this._renderService&&(this._accessibilityManager=new b.AccessibilityManager(this,this._renderService)):(null===(o=this._accessibilityManager)||void 0===o||o.dispose(),this._accessibilityManager=void 0);break;case"tabStopWidth":this.buffers.setupTabStops();break;case"theme":this._setTheme(this.optionsService.options.theme)}},t.prototype._onTextAreaFocus=function(e){this._coreService.decPrivateModes.sendFocus&&this._coreService.triggerDataEvent(c.C0.ESC+"[I"),this.updateCursorStyle(e),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()},t.prototype.blur=function(){var e;return null===(e=this.textarea)||void 0===e?void 0:e.blur()},t.prototype._onTextAreaBlur=function(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this._coreService.decPrivateModes.sendFocus&&this._coreService.triggerDataEvent(c.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()},t.prototype._syncTextArea=function(){if(this.textarea&&this.buffer.isCursorInViewport&&!this._compositionHelper.isComposing){var e=Math.ceil(this._charSizeService.height*this.optionsService.options.lineHeight),t=this._bufferService.buffer.y*e;this.textarea.style.left=this._bufferService.buffer.x*this._charSizeService.width+"px",this.textarea.style.top=t+"px",this.textarea.style.width=this._charSizeService.width+"px",this.textarea.style.height=e+"px",this.textarea.style.lineHeight=e+"px",this.textarea.style.zIndex="-5"}},t.prototype._initGlobal=function(){var e=this;this._bindKeys(),this.register(p.addDisposableDomListener(this.element,"copy",(function(t){e.hasSelection()&&s.copyHandler(t,e._selectionService)})));var t=function(t){return s.handlePasteEvent(t,e.textarea,e._coreService)};this.register(p.addDisposableDomListener(this.textarea,"paste",t)),this.register(p.addDisposableDomListener(this.element,"paste",t)),this.register(f.isFirefox?p.addDisposableDomListener(this.element,"mousedown",(function(t){2===t.button&&s.rightClickHandler(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)})):p.addDisposableDomListener(this.element,"contextmenu",(function(t){s.rightClickHandler(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)}))),f.isLinux&&this.register(p.addDisposableDomListener(this.element,"auxclick",(function(t){1===t.button&&s.moveTextAreaUnderMouseCursor(t,e.textarea,e.screenElement)})))},t.prototype._bindKeys=function(){var e=this;this.register(p.addDisposableDomListener(this.textarea,"keyup",(function(t){return e._keyUp(t)}),!0)),this.register(p.addDisposableDomListener(this.textarea,"keydown",(function(t){return e._keyDown(t)}),!0)),this.register(p.addDisposableDomListener(this.textarea,"keypress",(function(t){return e._keyPress(t)}),!0)),this.register(p.addDisposableDomListener(this.textarea,"compositionstart",(function(){return e._compositionHelper.compositionstart()}))),this.register(p.addDisposableDomListener(this.textarea,"compositionupdate",(function(t){return e._compositionHelper.compositionupdate(t)}))),this.register(p.addDisposableDomListener(this.textarea,"compositionend",(function(){return e._compositionHelper.compositionend()}))),this.register(this.onRender((function(){return e._compositionHelper.updateCompositionElements()}))),this.register(this.onRender((function(t){return e._queueLinkification(t.start,t.end)})))},t.prototype.open=function(e){var t=this;if(!e)throw new Error("Terminal requires a parent element.");j.body.contains(e)||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=e.ownerDocument,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"),e.appendChild(this.element);var n=j.createDocumentFragment();this._viewportElement=j.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),n.appendChild(this._viewportElement),this._viewportScrollArea=j.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=j.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=j.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),n.appendChild(this.screenElement),this.textarea=j.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",m.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(p.addDisposableDomListener(this.textarea,"focus",(function(e){return t._onTextAreaFocus(e)}))),this.register(p.addDisposableDomListener(this.textarea,"blur",(function(){return t._onTextAreaBlur()}))),this._helperContainer.appendChild(this.textarea);var i=this._instantiationService.createInstance(E.CoreBrowserService,this.textarea);this._instantiationService.setService(x.ICoreBrowserService,i),this._charSizeService=this._instantiationService.createInstance(O.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._compositionView=j.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(o.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(n),this._theme=this.options.theme||this._theme,this._colorManager=new C.ColorManager(j,this.options.allowTransparency),this.register(this.optionsService.onOptionChange((function(e){return t._colorManager.onOptionsChange(e)}))),this._colorManager.setTheme(this._theme);var r=this._createRenderer();this._renderService=this.register(this._instantiationService.createInstance(S.RenderService,r,this.rows,this.screenElement)),this._instantiationService.setService(x.IRenderService,this._renderService),this.register(this._renderService.onRenderedBufferChange((function(e){return t._onRender.fire(e)}))),this.onResize((function(e){return t._renderService.resize(e.cols,e.rows)})),this._soundService=this._instantiationService.createInstance(g.SoundService),this._instantiationService.setService(x.ISoundService,this._soundService),this._mouseService=this._instantiationService.createInstance(M.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(a.Viewport,(function(e,n){return t.scrollLines(e,n)}),this._viewportElement,this._viewportScrollArea),this.viewport.onThemeChange(this._colorManager.colors),this.register(this._inputHandler.onRequestSyncScrollBar((function(){return t.viewport.syncScrollArea()}))),this.register(this.viewport),this.register(this.onCursorMove((function(){t._renderService.onCursorMove(),t._syncTextArea()}))),this.register(this.onResize((function(){return t._renderService.onResize(t.cols,t.rows)}))),this.register(this.onBlur((function(){return t._renderService.onBlur()}))),this.register(this.onFocus((function(){return t._renderService.onFocus()}))),this.register(this._renderService.onDimensionsChange((function(){return t.viewport.syncScrollArea()}))),this._selectionService=this.register(this._instantiationService.createInstance(d.SelectionService,this.element,this.screenElement)),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((function(e){return t.scrollLines(e.amount,e.suppressScrollEvent)}))),this.register(this._selectionService.onSelectionChange((function(){return t._onSelectionChange.fire()}))),this.register(this._selectionService.onRequestRedraw((function(e){return t._renderService.onSelectionChanged(e.start,e.end,e.columnSelectMode)}))),this.register(this._selectionService.onLinuxMouseSelection((function(e){t.textarea.value=e,t.textarea.focus(),t.textarea.select()}))),this.register(this.onScroll((function(){t.viewport.syncScrollArea(),t._selectionService.refresh()}))),this.register(p.addDisposableDomListener(this._viewportElement,"scroll",(function(){return t._selectionService.refresh()}))),this._mouseZoneManager=this._instantiationService.createInstance(v.MouseZoneManager,this.element,this.screenElement),this.register(this._mouseZoneManager),this.register(this.onScroll((function(){return t._mouseZoneManager.clearAll()}))),this.linkifier.attachToDom(this.element,this._mouseZoneManager),this.linkifier2.attachToDom(this.element,this._mouseService,this._renderService),this.register(p.addDisposableDomListener(this.element,"mousedown",(function(e){return t._selectionService.onMouseDown(e)}))),this._coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager=new b.AccessibilityManager(this,this._renderService)),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()},t.prototype._createRenderer=function(){switch(this.options.rendererType){case"canvas":return this._instantiationService.createInstance(u.Renderer,this._colorManager.colors,this.screenElement,this.linkifier,this.linkifier2);case"dom":return this._instantiationService.createInstance(y.DomRenderer,this._colorManager.colors,this.element,this.screenElement,this._viewportElement,this.linkifier,this.linkifier2);default:throw new Error('Unrecognized rendererType "'+this.options.rendererType+'"')}},t.prototype._setTheme=function(e){var t,n,i;this._theme=e,null===(t=this._colorManager)||void 0===t||t.setTheme(e),null===(n=this._renderService)||void 0===n||n.setColors(this._colorManager.colors),null===(i=this.viewport)||void 0===i||i.onThemeChange(this._colorManager.colors)},t.prototype.bindMouse=function(){var e=this,t=this,n=this.element;function i(e){var n,i,r=t._mouseService.getRawByteCoords(e,t.screenElement,t.cols,t.rows);if(!r)return!1;switch(e.overrideType||e.type){case"mousemove":i=32,void 0===e.buttons?(n=3,void 0!==e.button&&(n=e.button<3?e.button:3)):n=1&e.buttons?0:4&e.buttons?1:2&e.buttons?2:3;break;case"mouseup":i=0,n=e.button<3?e.button:3;break;case"mousedown":i=1,n=e.button<3?e.button:3;break;case"wheel":0!==e.deltaY&&(i=e.deltaY<0?0:1),n=4;break;default:return!1}return!(void 0===i||void 0===n||n>4)&&t._coreMouseService.triggerMouseEvent({col:r.x-33,row:r.y-33,button:n,action:i,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})}var r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o=function(t){return i(t),t.buttons||(e._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&e._document.removeEventListener("mousemove",r.mousedrag)),e.cancel(t)},a=function(t){return i(t),t.preventDefault(),e.cancel(t)},s=function(e){e.buttons&&i(e)},l=function(e){e.buttons||i(e)};this.register(this._coreMouseService.onProtocolChange((function(t){t?("debug"===e.optionsService.options.logLevel&&e._logService.debug("Binding to mouse events:",e._coreMouseService.explainEvents(t)),e.element.classList.add("enable-mouse-events"),e._selectionService.disable()):(e._logService.debug("Unbinding from mouse events."),e.element.classList.remove("enable-mouse-events"),e._selectionService.enable()),8&t?r.mousemove||(n.addEventListener("mousemove",l),r.mousemove=l):(n.removeEventListener("mousemove",r.mousemove),r.mousemove=null),16&t?r.wheel||(n.addEventListener("wheel",a,{passive:!1}),r.wheel=a):(n.removeEventListener("wheel",r.wheel),r.wheel=null),2&t?r.mouseup||(r.mouseup=o):(e._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),4&t?r.mousedrag||(r.mousedrag=s):(e._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)}))),this._coreMouseService.activeProtocol=this._coreMouseService.activeProtocol,this.register(p.addDisposableDomListener(n,"mousedown",(function(t){if(t.preventDefault(),e.focus(),e._coreMouseService.areMouseEventsActive&&!e._selectionService.shouldForceSelection(t))return i(t),r.mouseup&&e._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&e._document.addEventListener("mousemove",r.mousedrag),e.cancel(t)}))),this.register(p.addDisposableDomListener(n,"wheel",(function(t){if(r.wheel);else if(!e.buffer.hasScrollback){var n=e.viewport.getLinesScrolled(t);if(0===n)return;for(var i=c.C0.ESC+(e._coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B"),o="",a=0;a47)},t.prototype._keyUp=function(e){this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return 16===e.keyCode||17===e.keyCode||18===e.keyCode}(e)||this.focus(),this.updateCursorStyle(e))},t.prototype._keyPress=function(e){var t;if(this._keyDownHandled)return!1;if(this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null==e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this._coreService.triggerDataEvent(t,!0),0))},t.prototype.bell=function(){this._soundBell()&&this._soundService.playBellSound()},t.prototype.resize=function(t,n){t!==this.cols||n!==this.rows?e.prototype.resize.call(this,t,n):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()},t.prototype._afterResize=function(e,t){var n,i;null===(n=this._charSizeService)||void 0===n||n.measure(),null===(i=this.viewport)||void 0===i||i.syncScrollArea(!0)},t.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;e=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompositionHelper=void 0;var o=n(5),a=n(1),s=function(){function e(e,t,n,i,r,o){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=i,this._charSizeService=r,this._coreService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0}}return Object.defineProperty(e.prototype,"isComposing",{get:function(){return this._isComposing},enumerable:!1,configurable:!0}),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,e){var n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((function(){var e;t._isSendingComposition&&(t._isSendingComposition=!1,e=t._isComposing?t._textarea.value.substring(n.start,n.end):t._textarea.value.substring(n.start),t._coreService.triggerDataEvent(e,!0))}),0)}else{this._isSendingComposition=!1;var i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}},e.prototype._handleAnyTextareaChanges=function(){var e=this,t=this._textarea.value;setTimeout((function(){if(!e._isComposing){var n=e._textarea.value.replace(t,"");n.length>0&&e._coreService.triggerDataEvent(n,!0)}}),0)},e.prototype.updateCompositionElements=function(e){var t=this;if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){var n=Math.ceil(this._charSizeService.height*this._optionsService.options.lineHeight),i=this._bufferService.buffer.y*n,r=this._bufferService.buffer.x*this._charSizeService.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.options.fontFamily,this._compositionView.style.fontSize=this._optionsService.options.fontSize+"px";var o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=o.width+"px",this._textarea.style.height=o.height+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout((function(){return t.updateCompositionElements(!0)}),0)}},i([r(2,a.IBufferService),r(3,a.IOptionsService),r(4,o.ICharSizeService),r(5,a.ICoreService)],e)}();t.CompositionHelper=s},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Viewport=void 0;var s=n(2),c=n(7),l=n(5),u=n(1),h=function(e){function t(t,n,i,r,o,a,s){var l=e.call(this)||this;return l._scrollLines=t,l._viewportElement=n,l._scrollArea=i,l._bufferService=r,l._optionsService=o,l._charSizeService=a,l._renderService=s,l.scrollBarWidth=0,l._currentRowHeight=0,l._lastRecordedBufferLength=0,l._lastRecordedViewportHeight=0,l._lastRecordedBufferHeight=0,l._lastTouchY=0,l._lastScrollTop=0,l._wheelPartialScroll=0,l._refreshAnimationFrame=null,l._ignoreNextScrollEvent=!1,l.scrollBarWidth=l._viewportElement.offsetWidth-l._scrollArea.offsetWidth||15,l.register(c.addDisposableDomListener(l._viewportElement,"scroll",l._onScroll.bind(l))),setTimeout((function(){return l.syncScrollArea()}),0),l}return r(t,e),t.prototype.onThemeChange=function(e){this._viewportElement.style.backgroundColor=e.background.css},t.prototype._refresh=function(e){var t=this;if(e)return this._innerRefresh(),void(null!==this._refreshAnimationFrame&&cancelAnimationFrame(this._refreshAnimationFrame));null===this._refreshAnimationFrame&&(this._refreshAnimationFrame=requestAnimationFrame((function(){return t._innerRefresh()})))},t.prototype._innerRefresh=function(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.scaledCellHeight/window.devicePixelRatio,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;var e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.canvasHeight);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}var t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==t&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=t),this._refreshAnimationFrame=null},t.prototype.syncScrollArea=function(e){if(void 0===e&&(e=!1),this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);this._lastRecordedViewportHeight===this._renderService.dimensions.canvasHeight&&this._lastScrollTop===this._bufferService.buffer.ydisp*this._currentRowHeight&&this._lastScrollTop===this._viewportElement.scrollTop&&this._renderService.dimensions.scaledCellHeight/window.devicePixelRatio===this._currentRowHeight||this._refresh(e)},t.prototype._onScroll=function(e){if(this._lastScrollTop=this._viewportElement.scrollTop,this._viewportElement.offsetParent)if(this._ignoreNextScrollEvent)this._ignoreNextScrollEvent=!1;else{var t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._scrollLines(t,!0)}},t.prototype._bubbleScroll=function(e,t){return!(t<0&&0!==this._viewportElement.scrollTop||t>0&&this._viewportElement.scrollTop+this._lastRecordedViewportHeight0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t},t.prototype._applyScrollModifier=function(e,t){var n=this._optionsService.options.fastScrollModifier;return"alt"===n&&t.altKey||"ctrl"===n&&t.ctrlKey||"shift"===n&&t.shiftKey?e*this._optionsService.options.fastScrollSensitivity*this._optionsService.options.scrollSensitivity:e*this._optionsService.options.scrollSensitivity},t.prototype.onTouchStart=function(e){this._lastTouchY=e.touches[0].pageY},t.prototype.onTouchMove=function(e){var t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))},o([a(3,u.IBufferService),a(4,u.IOptionsService),a(5,l.ICharSizeService),a(6,l.IRenderService)],t)}(s.Disposable);t.Viewport=h},function(e,t,n){"use strict";function i(e){return e.replace(/\r?\n/g,"\r")}function r(e,t){return t?"\x1b[200~"+e+"\x1b[201~":e}function o(e,t,n){e=r(e=i(e),n.decPrivateModes.bracketedPasteMode),n.triggerDataEvent(e,!0),t.value=""}function a(e,t,n){var i=n.getBoundingClientRect(),r=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=r+"px",t.style.top=o+"px",t.style.zIndex="1000",t.focus()}Object.defineProperty(t,"__esModule",{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=i,t.bracketTextForPaste=r,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,n){e.stopPropagation(),e.clipboardData&&o(e.clipboardData.getData("text/plain"),t,n)},t.paste=o,t.moveTextAreaUnderMouseCursor=a,t.rightClickHandler=function(e,t,n,i,r){a(e,t,n),r&&!i.isClickInSelection(e)&&i.selectWordAtCursor(e),t.value=i.selectionText,t.select()}},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;var o=n(2),a=n(15),s=n(21),c=n(22),l=n(24),u=function(){function e(e){this.table=new Uint8Array(e)}return e.prototype.setDefault=function(e,t){a.fill(this.table,e<<4|t)},e.prototype.add=function(e,t,n,i){this.table[t<<8|e]=n<<4|i},e.prototype.addMany=function(e,t,n,i){for(var r=0;r1)throw new Error("only one byte as prefix supported");if((n=e.prefix.charCodeAt(0))&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(var i=0;ir||r>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=r}}if(1!==e.final.length)throw new Error("final must be a single byte");var o=e.final.charCodeAt(0);if(t[0]>o||o>t[1])throw new Error("final must be in range "+t[0]+" .. "+t[1]);return(n<<=8)|o},n.prototype.identToString=function(e){for(var t=[];e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")},n.prototype.dispose=function(){this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null),this._oscParser.dispose(),this._dcsParser.dispose()},n.prototype.setPrintHandler=function(e){this._printHandler=e},n.prototype.clearPrintHandler=function(){this._printHandler=this._printHandlerFb},n.prototype.addEscHandler=function(e,t){var n=this._identifier(e,[48,126]);void 0===this._escHandlers[n]&&(this._escHandlers[n]=[]);var i=this._escHandlers[n];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},n.prototype.setEscHandler=function(e,t){this._escHandlers[this._identifier(e,[48,126])]=[t]},n.prototype.clearEscHandler=function(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]},n.prototype.setEscHandlerFallback=function(e){this._escHandlerFb=e},n.prototype.setExecuteHandler=function(e,t){this._executeHandlers[e.charCodeAt(0)]=t},n.prototype.clearExecuteHandler=function(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]},n.prototype.setExecuteHandlerFallback=function(e){this._executeHandlerFb=e},n.prototype.addCsiHandler=function(e,t){var n=this._identifier(e);void 0===this._csiHandlers[n]&&(this._csiHandlers[n]=[]);var i=this._csiHandlers[n];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},n.prototype.setCsiHandler=function(e,t){this._csiHandlers[this._identifier(e)]=[t]},n.prototype.clearCsiHandler=function(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]},n.prototype.setCsiHandlerFallback=function(e){this._csiHandlerFb=e},n.prototype.addDcsHandler=function(e,t){return this._dcsParser.addHandler(this._identifier(e),t)},n.prototype.setDcsHandler=function(e,t){this._dcsParser.setHandler(this._identifier(e),t)},n.prototype.clearDcsHandler=function(e){this._dcsParser.clearHandler(this._identifier(e))},n.prototype.setDcsHandlerFallback=function(e){this._dcsParser.setHandlerFallback(e)},n.prototype.addOscHandler=function(e,t){return this._oscParser.addHandler(e,t)},n.prototype.setOscHandler=function(e,t){this._oscParser.setHandler(e,t)},n.prototype.clearOscHandler=function(e){this._oscParser.clearHandler(e)},n.prototype.setOscHandlerFallback=function(e){this._oscParser.setHandlerFallback(e)},n.prototype.setErrorHandler=function(e){this._errorHandler=e},n.prototype.clearErrorHandler=function(){this._errorHandler=this._errorHandlerFb},n.prototype.reset=function(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0},n.prototype.parse=function(e,t){for(var n=0,i=0,r=this.currentState,o=this._oscParser,a=this._dcsParser,s=this._collect,c=this._params,l=this._transitions.table,u=0;u>4){case 2:for(var h=u+1;;++h){if(h>=t||(n=e[h])<32||n>126&&n<160){this._printHandler(e,u,h),u=h-1;break}if(++h>=t||(n=e[h])<32||n>126&&n<160){this._printHandler(e,u,h),u=h-1;break}if(++h>=t||(n=e[h])<32||n>126&&n<160){this._printHandler(e,u,h),u=h-1;break}if(++h>=t||(n=e[h])<32||n>126&&n<160){this._printHandler(e,u,h),u=h-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:u,code:n,currentState:r,collect:s,params:c,abort:!1}).abort)return;break;case 7:for(var d=this._csiHandlers[s<<8|n],f=d?d.length-1:-1;f>=0&&!1===d[f](c);f--);f<0&&this._csiHandlerFb(s<<8|n,c),this.precedingCodepoint=0;break;case 8:do{switch(n){case 59:c.addParam(0);break;case 58:c.addSubParam(-1);break;default:c.addDigit(n-48)}}while(++u47&&n<60);u--;break;case 9:s<<=8,s|=n;break;case 10:for(var p=this._escHandlers[s<<8|n],m=p?p.length-1:-1;m>=0&&!1===p[m]();m--);m<0&&this._escHandlerFb(s<<8|n),this.precedingCodepoint=0;break;case 11:c.reset(),c.addParam(0),s=0;break;case 12:a.hook(s<<8|n,c);break;case 13:for(var g=u+1;;++g)if(g>=t||24===(n=e[g])||26===n||27===n||n>127&&n<160){a.put(e,u,g),u=g-1;break}break;case 14:a.unhook(24!==n&&26!==n),27===n&&(i|=1),c.reset(),c.addParam(0),s=0,this.precedingCodepoint=0;break;case 4:o.start();break;case 5:for(var v=u+1;;v++)if(v>=t||(n=e[v])<32||n>127&&n<=159){o.put(e,u,v),u=v-1;break}break;case 6:o.end(24!==n&&26!==n),27===n&&(i|=1),c.reset(),c.addParam(0),s=0,this.precedingCodepoint=0}r=15&i}this._collect=s,this.currentState=r},n}(o.Disposable);t.EscapeSequenceParser=h},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer=void 0;var s=n(41),c=n(47),l=n(48),u=n(49),h=n(29),d=n(2),f=n(5),p=n(1),m=n(25),g=n(0),v=1,b=function(e){function t(t,n,i,r,o,a,d,f,p){var m=e.call(this)||this;m._colors=t,m._screenElement=n,m._bufferService=o,m._charSizeService=a,m._optionsService=d,m._id=v++,m._onRequestRedraw=new g.EventEmitter;var b=m._optionsService.options.allowTransparency;return m._characterJoinerRegistry=new h.CharacterJoinerRegistry(m._bufferService),m._renderLayers=[new s.TextRenderLayer(m._screenElement,0,m._colors,m._characterJoinerRegistry,b,m._id,m._bufferService,d),new c.SelectionRenderLayer(m._screenElement,1,m._colors,m._id,m._bufferService,d),new u.LinkRenderLayer(m._screenElement,2,m._colors,m._id,i,r,m._bufferService,d),new l.CursorRenderLayer(m._screenElement,3,m._colors,m._id,m._onRequestRedraw,m._bufferService,d,f,p)],m.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},m._devicePixelRatio=window.devicePixelRatio,m._updateDimensions(),m.onOptionsChanged(),m}return r(t,e),Object.defineProperty(t.prototype,"onRequestRedraw",{get:function(){return this._onRequestRedraw.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){for(var t=0,n=this._renderLayers;t0&&u===s[0][0]){d=!0;var p=s.shift();h=new l.JoinedCellData(this._workCell,a.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1}!d&&this._isOverlapping(h)&&fthis._characterWidth;return this._ctx.restore(),this._characterOverlapCache[t]=n,n},t}(a.BaseRenderLayer);t.TextRenderLayer=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GridCache=void 0;var i=function(){function e(){this.cache=[]}return e.prototype.resize=function(e,t){for(var n=0;n>>24,r=t.rgba>>>16&255,o=t.rgba>>>8&255,a=0;a=this.capacity)this._unlinkNode(n=this._head),delete this._map[n.key],n.key=e,n.value=t,this._map[e]=n;else{var i=this._nodePool;i.length>0?((n=i.pop()).key=e,n.value=t):n={prev:null,next:null,key:e,value:t},this._map[e]=n,this.size++}this._appendNode(n)},e}();t.LRUMap=i},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionRenderLayer=void 0;var o=function(e){function t(t,n,i,r,o,a){var s=e.call(this,t,"selection",n,!0,i,r,o,a)||this;return s._clearState(),s}return r(t,e),t.prototype._clearState=function(){this._state={start:void 0,end:void 0,columnSelectMode:void 0,ydisp:void 0}},t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._clearState()},t.prototype.reset=function(){this._state.start&&this._state.end&&(this._clearState(),this._clearAll())},t.prototype.onSelectionChanged=function(e,t,n){if(this._didStateChange(e,t,n,this._bufferService.buffer.ydisp))if(this._clearAll(),e&&t){var i=e[1]-this._bufferService.buffer.ydisp,r=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),a=Math.min(r,this._bufferService.rows-1);if(o>=this._bufferService.rows||a<0)this._state.ydisp=this._bufferService.buffer.ydisp;else{if(this._ctx.fillStyle=this._colors.selectionTransparent.css,n){var s=e[0];this._fillCells(s,o,t[0]-s,a-o+1)}else{this._fillCells(s=i===o?e[0]:0,o,(o===r?t[0]:this._bufferService.cols)-s,1);var c=Math.max(a-o-1,0);this._fillCells(0,o+1,this._bufferService.cols,c),o!==a&&this._fillCells(0,a,r===a?t[0]:this._bufferService.cols,1)}this._state.start=[e[0],e[1]],this._state.end=[t[0],t[1]],this._state.columnSelectMode=n,this._state.ydisp=this._bufferService.buffer.ydisp}}else this._clearState()},t.prototype._didStateChange=function(e,t,n,i){return!this._areCoordinatesEqual(e,this._state.start)||!this._areCoordinatesEqual(t,this._state.end)||n!==this._state.columnSelectMode||i!==this._state.ydisp},t.prototype._areCoordinatesEqual=function(e,t){return!(!e||!t)&&e[0]===t[0]&&e[1]===t[1]},t}(n(13).BaseRenderLayer);t.SelectionRenderLayer=o},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.CursorRenderLayer=void 0;var o=n(13),a=n(4),s=function(e){function t(t,n,i,r,o,s,c,l,u){var h=e.call(this,t,"cursor",n,!0,i,r,s,c)||this;return h._onRequestRedraw=o,h._coreService=l,h._coreBrowserService=u,h._cell=new a.CellData,h._state={x:0,y:0,isFocused:!1,style:"",width:0},h._cursorRenderers={bar:h._renderBarCursor.bind(h),block:h._renderBlockCursor.bind(h),underline:h._renderUnderlineCursor.bind(h)},h}return r(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._state={x:0,y:0,isFocused:!1,style:"",width:0}},t.prototype.reset=function(){this._clearCursor(),this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=void 0,this.onOptionsChanged())},t.prototype.onBlur=function(){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause(),this._onRequestRedraw.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onFocus=function(){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume():this._onRequestRedraw.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onOptionsChanged=function(){var e,t=this;this._optionsService.options.cursorBlink?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new c(this._coreBrowserService.isFocused,(function(){t._render(!0)}))):(null===(e=this._cursorBlinkStateManager)||void 0===e||e.dispose(),this._cursorBlinkStateManager=void 0),this._onRequestRedraw.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onCursorMove=function(){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation()},t.prototype.onGridChanged=function(e,t){!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isPaused?this._render(!1):this._cursorBlinkStateManager.restartBlinkAnimation()},t.prototype._render=function(e){if(this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden){var t=this._bufferService.buffer.ybase+this._bufferService.buffer.y,n=t-this._bufferService.buffer.ydisp;if(n<0||n>=this._bufferService.rows)this._clearCursor();else{var i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1);if(this._bufferService.buffer.lines.get(t).loadCell(i,this._cell),void 0!==this._cell.content){if(!this._coreBrowserService.isFocused){this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css;var r=this._optionsService.options.cursorStyle;return r&&"block"!==r?this._cursorRenderers[r](i,n,this._cell):this._renderBlurCursor(i,n,this._cell),this._ctx.restore(),this._state.x=i,this._state.y=n,this._state.isFocused=!1,this._state.style=r,void(this._state.width=this._cell.getWidth())}if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===i&&this._state.y===n&&this._state.isFocused===this._coreBrowserService.isFocused&&this._state.style===this._optionsService.options.cursorStyle&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[this._optionsService.options.cursorStyle||"block"](i,n,this._cell),this._ctx.restore(),this._state.x=i,this._state.y=n,this._state.isFocused=!1,this._state.style=this._optionsService.options.cursorStyle,this._state.width=this._cell.getWidth()}else this._clearCursor()}}}else this._clearCursor()},t.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})},t.prototype._renderBarCursor=function(e,t,n){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,t,this._optionsService.options.cursorWidth),this._ctx.restore()},t.prototype._renderBlockCursor=function(e,t,n){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,t,n.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(n,e,t),this._ctx.restore()},t.prototype._renderUnderlineCursor=function(e,t,n){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,t),this._ctx.restore()},t.prototype._renderBlurCursor=function(e,t,n){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,t,n.getWidth(),1),this._ctx.restore()},t}(o.BaseRenderLayer);t.CursorRenderLayer=s;var c=function(){function e(e,t){this._renderCallback=t,this.isCursorVisible=!0,e&&this._restartInterval()}return Object.defineProperty(e.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!1,configurable:!0}),e.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)},e.prototype.restartBlinkAnimation=function(){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}))))},e.prototype._restartInterval=function(e){var t=this;void 0===e&&(e=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=window.setTimeout((function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);if(t._animationTimeRestarted=void 0,e>0)return void t._restartInterval(e)}t.isCursorVisible=!1,t._animationFrame=window.requestAnimationFrame((function(){t._renderCallback(),t._animationFrame=void 0})),t._blinkInterval=window.setInterval((function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);return t._animationTimeRestarted=void 0,void t._restartInterval(e)}t.isCursorVisible=!t.isCursorVisible,t._animationFrame=window.requestAnimationFrame((function(){t._renderCallback(),t._animationFrame=void 0}))}),600)}),e)},e.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)},e.prototype.resume=function(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()},e}()},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.LinkRenderLayer=void 0;var o=n(13),a=n(9),s=n(26),c=function(e){function t(t,n,i,r,o,a,s,c){var l=e.call(this,t,"link",n,!0,i,r,s,c)||this;return o.onShowLinkUnderline((function(e){return l._onShowLinkUnderline(e)})),o.onHideLinkUnderline((function(e){return l._onHideLinkUnderline(e)})),a.onShowLinkUnderline((function(e){return l._onShowLinkUnderline(e)})),a.onHideLinkUnderline((function(e){return l._onHideLinkUnderline(e)})),l}return r(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._state=void 0},t.prototype.reset=function(){this._clearCurrentLink()},t.prototype._clearCurrentLink=function(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);var e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}},t.prototype._onShowLinkUnderline=function(e){if(this._ctx.fillStyle=e.fg===a.INVERTED_DEFAULT_COLOR?this._colors.background.css:e.fg&&s.is256Color(e.fg)?this._colors.ansi[e.fg].css:this._colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(var t=e.y1+1;t=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseZone=t.Linkifier=void 0;var o=n(0),a=n(1),s=function(){function e(e,t,n){this._bufferService=e,this._logService=t,this._unicodeService=n,this._linkMatchers=[],this._nextLinkMatcherId=0,this._onShowLinkUnderline=new o.EventEmitter,this._onHideLinkUnderline=new o.EventEmitter,this._onLinkTooltip=new o.EventEmitter,this._rowsToLinkify={start:void 0,end:void 0}}return Object.defineProperty(e.prototype,"onShowLinkUnderline",{get:function(){return this._onShowLinkUnderline.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onHideLinkUnderline",{get:function(){return this._onHideLinkUnderline.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLinkTooltip",{get:function(){return this._onLinkTooltip.event},enumerable:!1,configurable:!0}),e.prototype.attachToDom=function(e,t){this._element=e,this._mouseZoneManager=t},e.prototype.linkifyRows=function(t,n){var i=this;this._mouseZoneManager&&(void 0===this._rowsToLinkify.start||void 0===this._rowsToLinkify.end?(this._rowsToLinkify.start=t,this._rowsToLinkify.end=n):(this._rowsToLinkify.start=Math.min(this._rowsToLinkify.start,t),this._rowsToLinkify.end=Math.max(this._rowsToLinkify.end,n)),this._mouseZoneManager.clearAll(t,n),this._rowsTimeoutId&&clearTimeout(this._rowsTimeoutId),this._rowsTimeoutId=setTimeout((function(){return i._linkifyRows()}),e._timeBeforeLatency))},e.prototype._linkifyRows=function(){this._rowsTimeoutId=void 0;var e=this._bufferService.buffer;if(void 0!==this._rowsToLinkify.start&&void 0!==this._rowsToLinkify.end){var t=e.ydisp+this._rowsToLinkify.start;if(!(t>=e.lines.length)){for(var n=e.ydisp+Math.min(this._rowsToLinkify.end,this._bufferService.rows)+1,i=Math.ceil(2e3/this._bufferService.cols),r=this._bufferService.buffer.iterator(!1,t,n,i,i);r.hasNext();)for(var o=r.next(),a=0;a=0;t--)if(e.priority<=this._linkMatchers[t].priority)return void this._linkMatchers.splice(t+1,0,e);this._linkMatchers.splice(0,0,e)}else this._linkMatchers.push(e)},e.prototype.deregisterLinkMatcher=function(e){for(var t=0;t>9&511:void 0;n.validationCallback?n.validationCallback(s,(function(e){r._rowsTimeoutId||e&&r._addLink(l[1],l[0]-r._bufferService.buffer.ydisp,s,n,d)})):c._addLink(l[1],l[0]-c._bufferService.buffer.ydisp,s,n,d)},c=this;null!==(i=o.exec(t))&&"break"!==s(););},e.prototype._addLink=function(e,t,n,i,r){var o=this;if(this._mouseZoneManager&&this._element){var a=this._unicodeService.getStringCellWidth(n),s=e%this._bufferService.cols,l=t+Math.floor(e/this._bufferService.cols),u=(s+a)%this._bufferService.cols,h=l+Math.floor((s+a)/this._bufferService.cols);0===u&&(u=this._bufferService.cols,h--),this._mouseZoneManager.add(new c(s+1,l+1,u+1,h+1,(function(e){if(i.handler)return i.handler(e,n);var t=window.open();t?(t.opener=null,t.location.href=n):console.warn("Opening link blocked as opener could not be cleared")}),(function(){o._onShowLinkUnderline.fire(o._createLinkHoverEvent(s,l,u,h,r)),o._element.classList.add("xterm-cursor-pointer")}),(function(e){o._onLinkTooltip.fire(o._createLinkHoverEvent(s,l,u,h,r)),i.hoverTooltipCallback&&i.hoverTooltipCallback(e,n,{start:{x:s,y:l},end:{x:u,y:h}})}),(function(){o._onHideLinkUnderline.fire(o._createLinkHoverEvent(s,l,u,h,r)),o._element.classList.remove("xterm-cursor-pointer"),i.hoverLeaveCallback&&i.hoverLeaveCallback()}),(function(e){return!i.willLinkActivate||i.willLinkActivate(e,n)})))}},e.prototype._createLinkHoverEvent=function(e,t,n,i,r){return{x1:e,y1:t,x2:n,y2:i,cols:this._bufferService.cols,fg:r}},e._timeBeforeLatency=200,e=i([r(0,a.IBufferService),r(1,a.ILogService),r(2,a.IUnicodeService)],e)}();t.Linkifier=s;var c=function(e,t,n,i,r,o,a,s,c){this.x1=e,this.y1=t,this.x2=n,this.y2=i,this.clickCallback=r,this.hoverCallback=o,this.tooltipCallback=a,this.leaveCallback=s,this.willLinkActivate=c};t.MouseZone=c},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionService=void 0;var s=n(11),c=n(52),l=n(4),u=n(0),h=n(5),d=n(1),f=n(30),p=n(53),m=n(2),g=String.fromCharCode(160),v=new RegExp(g,"g"),b=function(e){function t(t,n,i,r,o,a,s){var h=e.call(this)||this;return h._element=t,h._screenElement=n,h._bufferService=i,h._coreService=r,h._mouseService=o,h._optionsService=a,h._renderService=s,h._dragScrollAmount=0,h._enabled=!0,h._workCell=new l.CellData,h._mouseDownTimeStamp=0,h._onLinuxMouseSelection=h.register(new u.EventEmitter),h._onRedrawRequest=h.register(new u.EventEmitter),h._onSelectionChange=h.register(new u.EventEmitter),h._onRequestScrollLines=h.register(new u.EventEmitter),h._mouseMoveListener=function(e){return h._onMouseMove(e)},h._mouseUpListener=function(e){return h._onMouseUp(e)},h._coreService.onUserInput((function(){h.hasSelection&&h.clearSelection()})),h._trimListener=h._bufferService.buffer.lines.onTrim((function(e){return h._onTrim(e)})),h.register(h._bufferService.buffers.onBufferActivate((function(e){return h._onBufferActivate(e)}))),h.enable(),h._model=new c.SelectionModel(h._bufferService),h._activeSelectionMode=0,h}return r(t,e),Object.defineProperty(t.prototype,"onLinuxMouseSelection",{get:function(){return this._onLinuxMouseSelection.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestRedraw",{get:function(){return this._onRedrawRequest.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onSelectionChange",{get:function(){return this._onSelectionChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRequestScrollLines",{get:function(){return this._onRequestScrollLines.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._removeMouseDownListeners()},t.prototype.reset=function(){this.clearSelection()},t.prototype.disable=function(){this.clearSelection(),this._enabled=!1},t.prototype.enable=function(){this._enabled=!0},Object.defineProperty(t.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!1,configurable:!0}),Object.defineProperty(t.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectionText",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";var n=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";for(var r=e[1];r<=t[1];r++){var o=n.translateBufferLineToString(r,!0,e[0],t[0]);i.push(o)}}else{for(i.push(n.translateBufferLineToString(e[1],!0,e[0],e[1]===t[1]?t[0]:void 0)),r=e[1]+1;r<=t[1]-1;r++){var a=n.lines.get(r);o=n.translateBufferLineToString(r,!0),a&&a.isWrapped?i[i.length-1]+=o:i.push(o)}e[1]!==t[1]&&(a=n.lines.get(t[1]),o=n.translateBufferLineToString(t[1],!0,0,t[0]),a&&a.isWrapped?i[i.length-1]+=o:i.push(o))}return i.map((function(e){return e.replace(v," ")})).join(s.isWindows?"\r\n":"\n")},enumerable:!1,configurable:!0}),t.prototype.clearSelection=function(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()},t.prototype.refresh=function(e){var t=this;this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame((function(){return t._refresh()}))),s.isLinux&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)},t.prototype._refresh=function(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})},t.prototype.isClickInSelection=function(e){var t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!(n&&i&&t)&&this._areCoordsInSelection(t,n,i)},t.prototype._areCoordsInSelection=function(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]},t.prototype.selectWordAtCursor=function(e){var t=this._getMouseBufferCoords(e);t&&(this._selectWordAt(t,!1),this._model.selectionEnd=void 0,this.refresh(!0))},t.prototype.selectAll=function(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()},t.prototype.selectLines=function(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()},t.prototype._onTrim=function(e){this._model.onTrim(e)&&this.refresh()},t.prototype._getMouseBufferCoords=function(e){var t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t},t.prototype._getMouseEventScrollAmount=function(e){var t=f.getCoordsRelativeToElement(e,this._screenElement)[1],n=this._renderService.dimensions.canvasHeight;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-50),50),(t/=50)/Math.abs(t)+Math.round(14*t))},t.prototype.shouldForceSelection=function(e){return s.isMac?e.altKey&&this._optionsService.options.macOptionClickForcesSelection:e.shiftKey},t.prototype.onMouseDown=function(e){if(this._mouseDownTimeStamp=e.timeStamp,(2!==e.button||!this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._onIncrementalClick(e):1===e.detail?this._onSingleClick(e):2===e.detail?this._onDoubleClick(e):3===e.detail&&this._onTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}},t.prototype._addMouseDownListeners=function(){var e=this;this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=window.setInterval((function(){return e._dragScroll()}),50)},t.prototype._removeMouseDownListeners=function(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0},t.prototype._onIncrementalClick=function(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))},t.prototype._onSingleClick=function(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),this._model.selectionStart){this._model.selectionEnd=void 0;var t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&0===t.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}},t.prototype._onDoubleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=1,this._selectWordAt(t,!0))},t.prototype._onTripleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))},t.prototype.shouldColumnSelect=function(e){return e.altKey&&!(s.isMac&&this._optionsService.options.macOptionClickForcesSelection)},t.prototype._onMouseMove=function(e){if(e.stopImmediatePropagation(),this._model.selectionStart){var t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),this._model.selectionEnd){2===this._activeSelectionMode?this._model.selectionEnd[0]=this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));var n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}},t.prototype._onMouseUp=function(e){var t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500&&e.altKey){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){var n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&void 0!==n[0]&&void 0!==n[1]){var i=p.moveToCellSequence(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this.hasSelection&&this._onSelectionChange.fire()},t.prototype._onBufferActivate=function(e){var t=this;this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim((function(e){return t._onTrim(e)}))},t.prototype._convertViewportColToCharacterIndex=function(e,t){for(var n=t[0],i=0;t[0]>=i;i++){var r=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?n--:r>1&&t[0]!==i&&(n+=r-1)}return n},t.prototype.setSelection=function(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh()},t.prototype._getWordAt=function(e,t,n,i){if(void 0===n&&(n=!0),void 0===i&&(i=!0),!(e[0]>=this._bufferService.cols)){var r=this._bufferService.buffer,o=r.lines.get(e[1]);if(o){var a=r.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(o,e),c=s,l=e[0]-s,u=0,h=0,d=0,f=0;if(" "===a.charAt(s)){for(;s>0&&" "===a.charAt(s-1);)s--;for(;c1&&(f+=g-1,c+=g-1);p>0&&s>0&&!this._isCharWordSeparator(o.loadCell(p-1,this._workCell));){o.loadCell(p-1,this._workCell);var v=this._workCell.getChars().length;0===this._workCell.getWidth()?(u++,p--):v>1&&(d+=v-1,s-=v-1),s--,p--}for(;m1&&(f+=b-1,c+=b-1),c++,m++}}c++;var y=s+l-u+d,_=Math.min(this._bufferService.cols,c-s+u+h-d-f);if(t||""!==a.slice(s,c).trim()){if(n&&0===y&&32!==o.getCodePoint(0)){var w=r.lines.get(e[1]-1);if(w&&o.isWrapped&&32!==w.getCodePoint(this._bufferService.cols-1)){var k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){var C=this._bufferService.cols-k.start;y-=C,_+=C}}}if(i&&y+_===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){var S=r.lines.get(e[1]+1);if(S&&S.isWrapped&&32!==S.getCodePoint(0)){var x=this._getWordAt([0,e[1]+1],!1,!1,!0);x&&(_+=x.length)}}return{start:y,length:_}}}}},t.prototype._selectWordAt=function(e,t){var n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}},t.prototype._selectToWordAt=function(e){var t=this._getWordAt(e,!0);if(t){for(var n=e[1];t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}},t.prototype._isCharWordSeparator=function(e){return 0!==e.getWidth()&&this._optionsService.options.wordSeparator.indexOf(e.getChars())>=0},t.prototype._selectLineAt=function(e){var t=this._bufferService.buffer.getWrappedRangeForLine(e);this._model.selectionStart=[0,t.first],this._model.selectionEnd=[this._bufferService.cols,t.last],this._model.selectionStartLength=0},o([a(2,d.IBufferService),a(3,d.ICoreService),a(4,h.IMouseService),a(5,d.IOptionsService),a(6,h.IRenderService)],t)}(m.Disposable);t.SelectionService=b},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionModel=void 0;var i=function(){function e(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}return e.prototype.clearSelection=function(){this.selectionStart=void 0,this.selectionEnd=void 0,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"finalSelectionEnd",{get:function(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){var e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}return this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]?[Math.max(this.selectionStart[0]+this.selectionStartLength,this.selectionEnd[0]),this.selectionEnd[1]]:this.selectionEnd}},enumerable:!1,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}();t.SelectionModel=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.moveToCellSequence=void 0;var i=n(12);function r(e,t,n,i){var r=e-o(n,e),s=t-o(n,t);return l(Math.abs(r-s)-function(e,t,n){for(var i=0,r=e-o(n,e),s=t-o(n,t),c=0;c=0&&tt?"A":"B"}function s(e,t,n,i,r,o){for(var a=e,s=t,c="";a!==n||s!==i;)a+=r?1:-1,r&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(s,!1,e,a),a=0,e=0,s++):!r&&a<0&&(c+=o.buffer.translateBufferLineToString(s,!1,0,e+1),e=a=o.cols-1,s--);return c+o.buffer.translateBufferLineToString(s,!1,e,a)}function c(e,t){return i.C0.ESC+(t?"O":"[")+e}function l(e,t){e=Math.floor(e);for(var n="",i=0;i0?i-o(a,i):t;var d=i,f=function(e,t,n,i,a,s){var c;return c=r(n,i,a,s).length>0?i-o(a,i):t,e=n&&ce?"D":"C",l(Math.abs(u-e),c(a,i));a=h>t?"D":"C";var d=Math.abs(h-t);return l(function(e,t){return t.cols-e}(h>t?e:u,n)+(d-1)*n.cols+1+((h>t?u:e)-1),c(a,i))}},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SoundService=void 0;var o=n(1),a=function(){function e(e){this._optionsService=e}return Object.defineProperty(e,"audioContext",{get:function(){if(!e._audioContext){var t=window.AudioContext||window.webkitAudioContext;if(!t)return console.warn("Web Audio API is not supported by this browser. Consider upgrading to the latest version"),null;e._audioContext=new t}return e._audioContext},enumerable:!1,configurable:!0}),e.prototype.playBellSound=function(){var t=e.audioContext;if(t){var n=t.createBufferSource();t.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.options.bellSound)),(function(e){n.buffer=e,n.connect(t.destination),n.start(0)}))}},e.prototype._base64ToArrayBuffer=function(e){for(var t=window.atob(e),n=t.length,i=new Uint8Array(n),r=0;r=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseZoneManager=void 0;var s=n(2),c=n(7),l=n(5),u=n(1),h=function(e){function t(t,n,i,r,o,a){var s=e.call(this)||this;return s._element=t,s._screenElement=n,s._bufferService=i,s._mouseService=r,s._selectionService=o,s._optionsService=a,s._zones=[],s._areZonesActive=!1,s._lastHoverCoords=[void 0,void 0],s._initialSelectionLength=0,s.register(c.addDisposableDomListener(s._element,"mousedown",(function(e){return s._onMouseDown(e)}))),s._mouseMoveListener=function(e){return s._onMouseMove(e)},s._mouseLeaveListener=function(e){return s._onMouseLeave(e)},s._clickListener=function(e){return s._onClick(e)},s}return r(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._deactivate()},t.prototype.add=function(e){this._zones.push(e),1===this._zones.length&&this._activate()},t.prototype.clearAll=function(e,t){if(0!==this._zones.length){e&&t||(e=0,t=this._bufferService.rows-1);for(var n=0;ne&&i.y1<=t+1||i.y2>e&&i.y2<=t+1||i.y1t+1)&&(this._currentZone&&this._currentZone===i&&(this._currentZone.leaveCallback(),this._currentZone=void 0),this._zones.splice(n--,1))}0===this._zones.length&&this._deactivate()}},t.prototype._activate=function(){this._areZonesActive||(this._areZonesActive=!0,this._element.addEventListener("mousemove",this._mouseMoveListener),this._element.addEventListener("mouseleave",this._mouseLeaveListener),this._element.addEventListener("click",this._clickListener))},t.prototype._deactivate=function(){this._areZonesActive&&(this._areZonesActive=!1,this._element.removeEventListener("mousemove",this._mouseMoveListener),this._element.removeEventListener("mouseleave",this._mouseLeaveListener),this._element.removeEventListener("click",this._clickListener))},t.prototype._onMouseMove=function(e){this._lastHoverCoords[0]===e.pageX&&this._lastHoverCoords[1]===e.pageY||(this._onHover(e),this._lastHoverCoords=[e.pageX,e.pageY])},t.prototype._onHover=function(e){var t=this,n=this._findZoneEventAt(e);n!==this._currentZone&&(this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout)),n&&(this._currentZone=n,n.hoverCallback&&n.hoverCallback(e),this._tooltipTimeout=window.setTimeout((function(){return t._onTooltip(e)}),this._optionsService.options.linkTooltipHoverDuration)))},t.prototype._onTooltip=function(e){this._tooltipTimeout=void 0;var t=this._findZoneEventAt(e);t&&t.tooltipCallback&&t.tooltipCallback(e)},t.prototype._onMouseDown=function(e){if(this._initialSelectionLength=this._getSelectionLength(),this._areZonesActive){var t=this._findZoneEventAt(e);(null==t?void 0:t.willLinkActivate(e))&&(e.preventDefault(),e.stopImmediatePropagation())}},t.prototype._onMouseLeave=function(e){this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout))},t.prototype._onClick=function(e){var t=this._findZoneEventAt(e),n=this._getSelectionLength();t&&n===this._initialSelectionLength&&(t.clickCallback(e),e.preventDefault(),e.stopImmediatePropagation())},t.prototype._getSelectionLength=function(){var e=this._selectionService.selectionText;return e?e.length:0},t.prototype._findZoneEventAt=function(e){var t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows);if(t)for(var n=t[0],i=t[1],r=0;r=o.x1&&n=o.x1||i===o.y2&&no.y1&&ie;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()},t.prototype._createAccessibilityTreeNode=function(){var e=document.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e},t.prototype._onTab=function(e){for(var t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=o.tooMuchOutput)),a.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((function(){t._accessibilityTreeRoot.appendChild(t._liveRegion)}),0))},t.prototype._clearLiveRegion=function(){this._liveRegion.textContent="",this._liveRegionLineCount=0,a.isMac&&h.removeElementFromParent(this._liveRegion)},t.prototype._onKey=function(e){this._clearLiveRegion(),this._charsToConsume.push(e)},t.prototype._refreshRows=function(e,t){this._renderRowsDebouncer.refresh(e,t,this._terminal.rows)},t.prototype._renderRows=function(e,t){for(var n=this._terminal.buffer,i=n.lines.length.toString(),r=e;r<=t;r++){var o=n.translateBufferLineToString(n.ydisp+r,!0),a=(n.ydisp+r+1).toString(),s=this._rowElements[r];s&&(0===o.length?s.innerHTML=" ":s.textContent=o,s.setAttribute("aria-posinset",a),s.setAttribute("aria-setsize",i))}this._announceCharacters()},t.prototype._refreshRowsDimensions=function(){if(this._renderService.dimensions.actualCellHeight){this._rowElements.length!==this._terminal.rows&&this._onResize(this._terminal.rows);for(var e=0;e=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRenderer=void 0;var s=n(58),c=n(9),l=n(2),u=n(5),h=n(1),d=n(0),f=n(10),p=n(17),m=1,g=function(e){function t(t,n,i,r,o,a,c,l,u){var h=e.call(this)||this;return h._colors=t,h._element=n,h._screenElement=i,h._viewportElement=r,h._linkifier=o,h._linkifier2=a,h._charSizeService=c,h._optionsService=l,h._bufferService=u,h._terminalClass=m++,h._rowElements=[],h._rowContainer=document.createElement("div"),h._rowContainer.classList.add("xterm-rows"),h._rowContainer.style.lineHeight="normal",h._rowContainer.setAttribute("aria-hidden","true"),h._refreshRowElements(h._bufferService.cols,h._bufferService.rows),h._selectionContainer=document.createElement("div"),h._selectionContainer.classList.add("xterm-selection"),h._selectionContainer.setAttribute("aria-hidden","true"),h.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},h._updateDimensions(),h._injectCss(),h._rowFactory=new s.DomRendererRowFactory(document,h._optionsService,h._colors),h._element.classList.add("xterm-dom-renderer-owner-"+h._terminalClass),h._screenElement.appendChild(h._rowContainer),h._screenElement.appendChild(h._selectionContainer),h._linkifier.onShowLinkUnderline((function(e){return h._onLinkHover(e)})),h._linkifier.onHideLinkUnderline((function(e){return h._onLinkLeave(e)})),h._linkifier2.onShowLinkUnderline((function(e){return h._onLinkHover(e)})),h._linkifier2.onHideLinkUnderline((function(e){return h._onLinkLeave(e)})),h}return r(t,e),Object.defineProperty(t.prototype,"onRequestRedraw",{get:function(){return(new d.EventEmitter).event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._element.classList.remove("xterm-dom-renderer-owner-"+this._terminalClass),p.removeElementFromParent(this._rowContainer,this._selectionContainer,this._themeStyleElement,this._dimensionsStyleElement),e.prototype.dispose.call(this)},t.prototype._updateDimensions=function(){this.dimensions.scaledCharWidth=this._charSizeService.width*window.devicePixelRatio,this.dimensions.scaledCharHeight=Math.ceil(this._charSizeService.height*window.devicePixelRatio),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._optionsService.options.letterSpacing),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.options.lineHeight),this.dimensions.scaledCharLeft=0,this.dimensions.scaledCharTop=0,this.dimensions.scaledCanvasWidth=this.dimensions.scaledCellWidth*this._bufferService.cols,this.dimensions.scaledCanvasHeight=this.dimensions.scaledCellHeight*this._bufferService.rows,this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._bufferService.cols,this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._bufferService.rows;for(var e=0,t=this._rowElements;et;)this._rowContainer.removeChild(this._rowElements.pop())},t.prototype.onResize=function(e,t){this._refreshRowElements(e,t),this._updateDimensions()},t.prototype.onCharSizeChanged=function(){this._updateDimensions()},t.prototype.onBlur=function(){this._rowContainer.classList.remove("xterm-focus")},t.prototype.onFocus=function(){this._rowContainer.classList.add("xterm-focus")},t.prototype.onSelectionChanged=function(e,t,n){for(;this._selectionContainer.children.length;)this._selectionContainer.removeChild(this._selectionContainer.children[0]);if(e&&t){var i=e[1]-this._bufferService.buffer.ydisp,r=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),a=Math.min(r,this._bufferService.rows-1);if(!(o>=this._bufferService.rows||a<0)){var s=document.createDocumentFragment();n?s.appendChild(this._createSelectionElement(o,e[0],t[0],a-o+1)):(s.appendChild(this._createSelectionElement(o,i===o?e[0]:0,o===r?t[0]:this._bufferService.cols)),s.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a&&s.appendChild(this._createSelectionElement(a,0,r===a?t[0]:this._bufferService.cols))),this._selectionContainer.appendChild(s)}}},t.prototype._createSelectionElement=function(e,t,n,i){void 0===i&&(i=1);var r=document.createElement("div");return r.style.height=i*this.dimensions.actualCellHeight+"px",r.style.top=e*this.dimensions.actualCellHeight+"px",r.style.left=t*this.dimensions.actualCellWidth+"px",r.style.width=this.dimensions.actualCellWidth*(n-t)+"px",r},t.prototype.onCursorMove=function(){},t.prototype.onOptionsChanged=function(){this._updateDimensions(),this._injectCss()},t.prototype.clear=function(){for(var e=0,t=this._rowElements;e=r&&(e=0,n++)}},o([a(6,u.ICharSizeService),a(7,h.IOptionsService),a(8,h.IBufferService)],t)}(l.Disposable);t.DomRenderer=g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DomRendererRowFactory=t.CURSOR_STYLE_UNDERLINE_CLASS=t.CURSOR_STYLE_BAR_CLASS=t.CURSOR_STYLE_BLOCK_CLASS=t.CURSOR_BLINK_CLASS=t.CURSOR_CLASS=t.UNDERLINE_CLASS=t.ITALIC_CLASS=t.DIM_CLASS=t.BOLD_CLASS=void 0;var i=n(9),r=n(3),o=n(4),a=n(10);t.BOLD_CLASS="xterm-bold",t.DIM_CLASS="xterm-dim",t.ITALIC_CLASS="xterm-italic",t.UNDERLINE_CLASS="xterm-underline",t.CURSOR_CLASS="xterm-cursor",t.CURSOR_BLINK_CLASS="xterm-cursor-blink",t.CURSOR_STYLE_BLOCK_CLASS="xterm-cursor-block",t.CURSOR_STYLE_BAR_CLASS="xterm-cursor-bar",t.CURSOR_STYLE_UNDERLINE_CLASS="xterm-cursor-underline";var s=function(){function e(e,t,n){this._document=e,this._optionsService=t,this._colors=n,this._workCell=new o.CellData}return e.prototype.setColors=function(e){this._colors=e},e.prototype.createRow=function(e,n,o,s,l,u,h){for(var d=this._document.createDocumentFragment(),f=0,p=Math.min(e.length,h)-1;p>=0;p--)if(e.loadCell(p,this._workCell).getCode()!==r.NULL_CELL_CODE||n&&p===s){f=p+1;break}for(p=0;p1&&(g.style.width=u*m+"px"),n&&p===s)switch(g.classList.add(t.CURSOR_CLASS),l&&g.classList.add(t.CURSOR_BLINK_CLASS),o){case"bar":g.classList.add(t.CURSOR_STYLE_BAR_CLASS);break;case"underline":g.classList.add(t.CURSOR_STYLE_UNDERLINE_CLASS);break;default:g.classList.add(t.CURSOR_STYLE_BLOCK_CLASS)}this._workCell.isBold()&&g.classList.add(t.BOLD_CLASS),this._workCell.isItalic()&&g.classList.add(t.ITALIC_CLASS),this._workCell.isDim()&&g.classList.add(t.DIM_CLASS),this._workCell.isUnderline()&&g.classList.add(t.UNDERLINE_CLASS),g.textContent=this._workCell.isInvisible()?r.WHITESPACE_CELL_CHAR:this._workCell.getChars()||r.WHITESPACE_CELL_CHAR;var v=this._workCell.getFgColor(),b=this._workCell.getFgColorMode(),y=this._workCell.getBgColor(),_=this._workCell.getBgColorMode(),w=!!this._workCell.isInverse();if(w){var k=v;v=y,y=k;var C=b;b=_,_=C}switch(b){case 16777216:case 33554432:this._workCell.isBold()&&v<8&&this._optionsService.options.drawBoldTextInBrightColors&&(v+=8),this._applyMinimumContrast(g,this._colors.background,this._colors.ansi[v])||g.classList.add("xterm-fg-"+v);break;case 50331648:var S=a.rgba.toColor(v>>16&255,v>>8&255,255&v);this._applyMinimumContrast(g,this._colors.background,S)||this._addStyle(g,"color:#"+c(v.toString(16),"0",6));break;case 0:default:this._applyMinimumContrast(g,this._colors.background,this._colors.foreground)||w&&g.classList.add("xterm-fg-"+i.INVERTED_DEFAULT_COLOR)}switch(_){case 16777216:case 33554432:g.classList.add("xterm-bg-"+y);break;case 50331648:this._addStyle(g,"background-color:#"+c(y.toString(16),"0",6));break;case 0:default:w&&g.classList.add("xterm-bg-"+i.INVERTED_DEFAULT_COLOR)}d.appendChild(g)}}return d},e.prototype._applyMinimumContrast=function(e,t,n){if(1===this._optionsService.options.minimumContrastRatio)return!1;var i=this._colors.contrastCache.getColor(this._workCell.bg,this._workCell.fg);return void 0===i&&(i=a.color.ensureContrastRatio(t,n,this._optionsService.options.minimumContrastRatio),this._colors.contrastCache.setColor(this._workCell.bg,this._workCell.fg,null!=i?i:null)),!!i&&(this._addStyle(e,"color:"+i.css),!0)},e.prototype._addStyle=function(e,t){e.setAttribute("style",""+(e.getAttribute("style")||"")+t+";")},e}();function c(e,t,n){for(;e.length"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};t.evaluateKeyboardEvent=function(e,t,n,o){var a={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?a.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A":"UIKeyInputLeftArrow"===e.key?a.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D":"UIKeyInputRightArrow"===e.key?a.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(a.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B");break;case 8:if(e.shiftKey){a.key=i.C0.BS;break}if(e.altKey){a.key=i.C0.ESC+i.C0.DEL;break}a.key=i.C0.DEL;break;case 9:if(e.shiftKey){a.key=i.C0.ESC+"[Z";break}a.key=i.C0.HT,a.cancel=!0;break;case 13:a.key=e.altKey?i.C0.ESC+i.C0.CR:i.C0.CR,a.cancel=!0;break;case 27:a.key=i.C0.ESC,e.altKey&&(a.key=i.C0.ESC+i.C0.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;s?(a.key=i.C0.ESC+"[1;"+(s+1)+"D",a.key===i.C0.ESC+"[1;3D"&&(a.key=i.C0.ESC+(n?"b":"[1;5D"))):a.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D";break;case 39:if(e.metaKey)break;s?(a.key=i.C0.ESC+"[1;"+(s+1)+"C",a.key===i.C0.ESC+"[1;3C"&&(a.key=i.C0.ESC+(n?"f":"[1;5C"))):a.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C";break;case 38:if(e.metaKey)break;s?(a.key=i.C0.ESC+"[1;"+(s+1)+"A",n||a.key!==i.C0.ESC+"[1;3A"||(a.key=i.C0.ESC+"[1;5A")):a.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A";break;case 40:if(e.metaKey)break;s?(a.key=i.C0.ESC+"[1;"+(s+1)+"B",n||a.key!==i.C0.ESC+"[1;3B"||(a.key=i.C0.ESC+"[1;5B")):a.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(a.key=i.C0.ESC+"[2~");break;case 46:a.key=s?i.C0.ESC+"[3;"+(s+1)+"~":i.C0.ESC+"[3~";break;case 36:a.key=s?i.C0.ESC+"[1;"+(s+1)+"H":t?i.C0.ESC+"OH":i.C0.ESC+"[H";break;case 35:a.key=s?i.C0.ESC+"[1;"+(s+1)+"F":t?i.C0.ESC+"OF":i.C0.ESC+"[F";break;case 33:e.shiftKey?a.type=2:a.key=i.C0.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:a.key=i.C0.ESC+"[6~";break;case 112:a.key=s?i.C0.ESC+"[1;"+(s+1)+"P":i.C0.ESC+"OP";break;case 113:a.key=s?i.C0.ESC+"[1;"+(s+1)+"Q":i.C0.ESC+"OQ";break;case 114:a.key=s?i.C0.ESC+"[1;"+(s+1)+"R":i.C0.ESC+"OR";break;case 115:a.key=s?i.C0.ESC+"[1;"+(s+1)+"S":i.C0.ESC+"OS";break;case 116:a.key=s?i.C0.ESC+"[15;"+(s+1)+"~":i.C0.ESC+"[15~";break;case 117:a.key=s?i.C0.ESC+"[17;"+(s+1)+"~":i.C0.ESC+"[17~";break;case 118:a.key=s?i.C0.ESC+"[18;"+(s+1)+"~":i.C0.ESC+"[18~";break;case 119:a.key=s?i.C0.ESC+"[19;"+(s+1)+"~":i.C0.ESC+"[19~";break;case 120:a.key=s?i.C0.ESC+"[20;"+(s+1)+"~":i.C0.ESC+"[20~";break;case 121:a.key=s?i.C0.ESC+"[21;"+(s+1)+"~":i.C0.ESC+"[21~";break;case 122:a.key=s?i.C0.ESC+"[23;"+(s+1)+"~":i.C0.ESC+"[23~";break;case 123:a.key=s?i.C0.ESC+"[24;"+(s+1)+"~":i.C0.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(n&&!o||!e.altKey||e.metaKey)n&&!e.altKey&&!e.ctrlKey&&e.metaKey?65===e.keyCode&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?a.key=e.key:e.key&&e.ctrlKey&&"_"===e.key&&(a.key=i.C0.US);else{var c=r[e.keyCode],l=c&&c[e.shiftKey?1:0];l?a.key=i.C0.ESC+l:e.keyCode>=65&&e.keyCode<=90&&(a.key=i.C0.ESC+String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32))}else e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?a.key=i.C0.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?a.key=i.C0.DEL:219===e.keyCode?a.key=i.C0.ESC:220===e.keyCode?a.key=i.C0.FS:221===e.keyCode&&(a.key=i.C0.GS)}return a}},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.RenderService=void 0;var s=n(31),c=n(0),l=n(2),u=n(32),h=n(7),d=n(1),f=n(5),p=function(e){function t(t,n,i,r,o,a){var l=e.call(this)||this;if(l._renderer=t,l._rowCount=n,l._isPaused=!1,l._needsFullRefresh=!1,l._isNextRenderRedrawOnly=!0,l._needsSelectionRefresh=!1,l._canvasWidth=0,l._canvasHeight=0,l._selectionState={start:void 0,end:void 0,columnSelectMode:!1},l._onDimensionsChange=new c.EventEmitter,l._onRender=new c.EventEmitter,l._onRefreshRequest=new c.EventEmitter,l.register({dispose:function(){return l._renderer.dispose()}}),l._renderDebouncer=new s.RenderDebouncer((function(e,t){return l._renderRows(e,t)})),l.register(l._renderDebouncer),l._screenDprMonitor=new u.ScreenDprMonitor,l._screenDprMonitor.setListener((function(){return l.onDevicePixelRatioChange()})),l.register(l._screenDprMonitor),l.register(a.onResize((function(e){return l._fullRefresh()}))),l.register(r.onOptionChange((function(){return l._renderer.onOptionsChanged()}))),l.register(o.onCharSizeChange((function(){return l.onCharSizeChanged()}))),l._renderer.onRequestRedraw((function(e){return l.refreshRows(e.start,e.end,!0)})),l.register(h.addDisposableDomListener(window,"resize",(function(){return l.onDevicePixelRatioChange()}))),"IntersectionObserver"in window){var d=new IntersectionObserver((function(e){return l._onIntersectionChange(e[e.length-1])}),{threshold:0});d.observe(i),l.register({dispose:function(){return d.disconnect()}})}return l}return r(t,e),Object.defineProperty(t.prototype,"onDimensionsChange",{get:function(){return this._onDimensionsChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRenderedBufferChange",{get:function(){return this._onRender.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRefreshRequest",{get:function(){return this._onRefreshRequest.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dimensions",{get:function(){return this._renderer.dimensions},enumerable:!1,configurable:!0}),t.prototype._onIntersectionChange=function(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,!this._isPaused&&this._needsFullRefresh&&(this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)},t.prototype.refreshRows=function(e,t,n){void 0===n&&(n=!1),this._isPaused?this._needsFullRefresh=!0:(n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount))},t.prototype._renderRows=function(e,t){this._renderer.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.onSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0},t.prototype.resize=function(e,t){this._rowCount=t,this._fireOnCanvasResize()},t.prototype.changeOptions=function(){this._renderer.onOptionsChanged(),this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize()},t.prototype._fireOnCanvasResize=function(){this._renderer.dimensions.canvasWidth===this._canvasWidth&&this._renderer.dimensions.canvasHeight===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.dimensions)},t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype.setRenderer=function(e){var t=this;this._renderer.dispose(),this._renderer=e,this._renderer.onRequestRedraw((function(e){return t.refreshRows(e.start,e.end,!0)})),this._needsSelectionRefresh=!0,this._fullRefresh()},t.prototype._fullRefresh=function(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)},t.prototype.setColors=function(e){this._renderer.setColors(e),this._fullRefresh()},t.prototype.onDevicePixelRatioChange=function(){this._renderer.onDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1)},t.prototype.onResize=function(e,t){this._renderer.onResize(e,t),this._fullRefresh()},t.prototype.onCharSizeChanged=function(){this._renderer.onCharSizeChanged()},t.prototype.onBlur=function(){this._renderer.onBlur()},t.prototype.onFocus=function(){this._renderer.onFocus()},t.prototype.onSelectionChanged=function(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.onSelectionChanged(e,t,n)},t.prototype.onCursorMove=function(){this._renderer.onCursorMove()},t.prototype.clear=function(){this._renderer.clear()},t.prototype.registerCharacterJoiner=function(e){return this._renderer.registerCharacterJoiner(e)},t.prototype.deregisterCharacterJoiner=function(e){return this._renderer.deregisterCharacterJoiner(e)},o([a(3,d.IOptionsService),a(4,f.ICharSizeService),a(5,d.IBufferService)],t)}(l.Disposable);t.RenderService=p},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharSizeService=void 0;var o=n(1),a=n(0),s=function(){function e(e,t,n){this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=new a.EventEmitter,this._measureStrategy=new c(e,t,this._optionsService)}return Object.defineProperty(e.prototype,"hasValidSize",{get:function(){return this.width>0&&this.height>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCharSizeChange",{get:function(){return this._onCharSizeChange.event},enumerable:!1,configurable:!0}),e.prototype.measure=function(){var e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())},i([r(2,o.IOptionsService)],e)}();t.CharSizeService=s;var c=function(){function e(e,t,n){this._document=e,this._parentElement=t,this._optionsService=n,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W",this._measureElement.setAttribute("aria-hidden","true"),this._parentElement.appendChild(this._measureElement)}return e.prototype.measure=function(){this._measureElement.style.fontFamily=this._optionsService.options.fontFamily,this._measureElement.style.fontSize=this._optionsService.options.fontSize+"px";var e=this._measureElement.getBoundingClientRect();return 0!==e.width&&0!==e.height&&(this._result.width=e.width,this._result.height=Math.ceil(e.height)),this._result},e}()},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseService=void 0;var o=n(5),a=n(30),s=function(){function e(e,t){this._renderService=e,this._charSizeService=t}return e.prototype.getCoords=function(e,t,n,i,r){return a.getCoords(e,t,n,i,this._charSizeService.hasValidSize,this._renderService.dimensions.actualCellWidth,this._renderService.dimensions.actualCellHeight,r)},e.prototype.getRawByteCoords=function(e,t,n,i){var r=this.getCoords(e,t,n,i);return a.getRawByteCoords(r)},i([r(0,o.IRenderService),r(1,o.ICharSizeService)],e)}();t.MouseService=s},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Linkifier2=void 0;var s=n(1),c=n(0),l=n(2),u=n(7),h=function(e){function t(t){var n=e.call(this)||this;return n._bufferService=t,n._linkProviders=[],n._linkCacheDisposables=[],n._isMouseOut=!0,n._activeLine=-1,n._onShowLinkUnderline=n.register(new c.EventEmitter),n._onHideLinkUnderline=n.register(new c.EventEmitter),n.register(l.getDisposeArrayDisposable(n._linkCacheDisposables)),n}return r(t,e),Object.defineProperty(t.prototype,"onShowLinkUnderline",{get:function(){return this._onShowLinkUnderline.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onHideLinkUnderline",{get:function(){return this._onHideLinkUnderline.event},enumerable:!1,configurable:!0}),t.prototype.registerLinkProvider=function(e){var t=this;return this._linkProviders.push(e),{dispose:function(){var n=t._linkProviders.indexOf(e);-1!==n&&t._linkProviders.splice(n,1)}}},t.prototype.attachToDom=function(e,t,n){var i=this;this._element=e,this._mouseService=t,this._renderService=n,this.register(u.addDisposableDomListener(this._element,"mouseleave",(function(){i._isMouseOut=!0,i._clearCurrentLink()}))),this.register(u.addDisposableDomListener(this._element,"mousemove",this._onMouseMove.bind(this))),this.register(u.addDisposableDomListener(this._element,"click",this._onClick.bind(this)))},t.prototype._onMouseMove=function(e){if(this._lastMouseEvent=e,this._element&&this._mouseService){var t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(t){this._isMouseOut=!1;for(var n=e.composedPath(),i=0;ie?this._bufferService.cols:a.link.range.end.x,c=a.link.range.start.y=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,l.disposeArray(this._linkCacheDisposables))},t.prototype._handleNewLink=function(e){var t=this;if(this._element&&this._lastMouseEvent&&this._mouseService){var n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._linkAtPosition(e.link,n)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:function(){var e,n;return null===(n=null===(e=t._currentLink)||void 0===e?void 0:e.state)||void 0===n?void 0:n.decorations.pointerCursor},set:function(e){var n,i;(null===(n=t._currentLink)||void 0===n?void 0:n.state)&&t._currentLink.state.decorations.pointerCursor!==e&&(t._currentLink.state.decorations.pointerCursor=e,t._currentLink.state.isHovered&&(null===(i=t._element)||void 0===i||i.classList.toggle("xterm-cursor-pointer",e)))}},underline:{get:function(){var e,n;return null===(n=null===(e=t._currentLink)||void 0===e?void 0:e.state)||void 0===n?void 0:n.decorations.underline},set:function(n){var i,r,o;(null===(i=t._currentLink)||void 0===i?void 0:i.state)&&(null===(o=null===(r=t._currentLink)||void 0===r?void 0:r.state)||void 0===o?void 0:o.decorations.underline)!==n&&(t._currentLink.state.decorations.underline=n,t._currentLink.state.isHovered&&t._fireUnderlineEvent(e.link,n))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedBufferChange((function(e){t._clearCurrentLink(0===e.start?0:e.start+1+t._bufferService.buffer.ydisp,e.end+1+t._bufferService.buffer.ydisp)}))))}},t.prototype._linkHover=function(e,t,n){var i;(null===(i=this._currentLink)||void 0===i?void 0:i.state)&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)},t.prototype._fireUnderlineEvent=function(e,t){var n=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-i-1,n.end.x,n.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)},t.prototype._linkLeave=function(e,t,n){var i;(null===(i=this._currentLink)||void 0===i?void 0:i.state)&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)},t.prototype._linkAtPosition=function(e,t){var n=e.range.start.yt.y;return(e.range.start.y===e.range.end.y&&e.range.start.x<=t.x&&e.range.end.x>=t.x||n&&e.range.end.x>=t.x||i&&e.range.start.x<=t.x||n&&i)&&e.range.start.y<=t.y&&e.range.end.y>=t.y},t.prototype._positionFromMouseEvent=function(e,t,n){var i=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}},t.prototype._createLinkUnderlineEvent=function(e,t,n,i,r){return{x1:e,y1:t,x2:n,y2:i,cols:this._bufferService.cols,fg:r}},o([a(0,s.IBufferService)],t)}(l.Disposable);t.Linkifier2=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CoreBrowserService=void 0;var i=function(){function e(e){this._textarea=e}return Object.defineProperty(e.prototype,"isFocused",{get:function(){return document.activeElement===this._textarea&&document.hasFocus()},enumerable:!1,configurable:!0}),e}();t.CoreBrowserService=i},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;var o=n(2),a=n(1),s=n(66),c=n(67),l=n(68),u=n(74),h=n(75),d=n(0),f=n(76),p=n(77),m=n(78),g=n(80),v=n(81),b=n(19),y=n(82),_=function(e){function t(t){var n=e.call(this)||this;return n._onBinary=new d.EventEmitter,n._onData=new d.EventEmitter,n._onLineFeed=new d.EventEmitter,n._onResize=new d.EventEmitter,n._onScroll=new d.EventEmitter,n._instantiationService=new s.InstantiationService,n.optionsService=new u.OptionsService(t),n._instantiationService.setService(a.IOptionsService,n.optionsService),n._bufferService=n.register(n._instantiationService.createInstance(l.BufferService)),n._instantiationService.setService(a.IBufferService,n._bufferService),n._logService=n._instantiationService.createInstance(c.LogService),n._instantiationService.setService(a.ILogService,n._logService),n._coreService=n.register(n._instantiationService.createInstance(h.CoreService,(function(){return n.scrollToBottom()}))),n._instantiationService.setService(a.ICoreService,n._coreService),n._coreMouseService=n._instantiationService.createInstance(f.CoreMouseService),n._instantiationService.setService(a.ICoreMouseService,n._coreMouseService),n._dirtyRowService=n._instantiationService.createInstance(p.DirtyRowService),n._instantiationService.setService(a.IDirtyRowService,n._dirtyRowService),n.unicodeService=n._instantiationService.createInstance(m.UnicodeService),n._instantiationService.setService(a.IUnicodeService,n.unicodeService),n._charsetService=n._instantiationService.createInstance(g.CharsetService),n._instantiationService.setService(a.ICharsetService,n._charsetService),n._inputHandler=new b.InputHandler(n._bufferService,n._charsetService,n._coreService,n._dirtyRowService,n._logService,n.optionsService,n._coreMouseService,n.unicodeService),n.register(d.forwardEvent(n._inputHandler.onLineFeed,n._onLineFeed)),n.register(n._inputHandler),n.register(d.forwardEvent(n._bufferService.onResize,n._onResize)),n.register(d.forwardEvent(n._coreService.onData,n._onData)),n.register(d.forwardEvent(n._coreService.onBinary,n._onBinary)),n.register(n.optionsService.onOptionChange((function(e){return n._updateOptions(e)}))),n._writeBuffer=new y.WriteBuffer((function(e){return n._inputHandler.parse(e)})),n}return r(t,e),Object.defineProperty(t.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onData",{get:function(){return this._onData.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cols",{get:function(){return this._bufferService.cols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._bufferService.rows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buffers",{get:function(){return this._bufferService.buffers},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){var t;this._isDisposed||(e.prototype.dispose.call(this),null===(t=this._windowsMode)||void 0===t||t.dispose(),this._windowsMode=void 0)},t.prototype.write=function(e,t){this._writeBuffer.write(e,t)},t.prototype.writeSync=function(e){this._writeBuffer.writeSync(e)},t.prototype.resize=function(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,l.MINIMUM_COLS),t=Math.max(t,l.MINIMUM_ROWS),this._bufferService.resize(e,t))},t.prototype.scroll=function(e,t){void 0===t&&(t=!1);var n,i=this._bufferService.buffer;(n=this._cachedBlankLine)&&n.length===this.cols&&n.getFg(0)===e.fg&&n.getBg(0)===e.bg||(n=i.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;var r=i.ybase+i.scrollTop,o=i.ybase+i.scrollBottom;if(0===i.scrollTop){var a=i.lines.isFull;o===i.lines.length-1?a?i.lines.recycle().copyFrom(n):i.lines.push(n.clone()):i.lines.splice(o+1,0,n.clone()),a?this._bufferService.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this._bufferService.isUserScrolling||i.ydisp++)}else i.lines.shiftElements(r+1,o-r+1-1,-1),i.lines.set(o,n.clone());this._bufferService.isUserScrolling||(i.ydisp=i.ybase),this._dirtyRowService.markRangeDirty(i.scrollTop,i.scrollBottom),this._onScroll.fire(i.ydisp)},t.prototype.scrollLines=function(e,t){var n=this._bufferService.buffer;if(e<0){if(0===n.ydisp)return;this._bufferService.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this._bufferService.isUserScrolling=!1);var i=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),i!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))},t.prototype.scrollPages=function(e){this.scrollLines(e*(this.rows-1))},t.prototype.scrollToTop=function(){this.scrollLines(-this._bufferService.buffer.ydisp)},t.prototype.scrollToBottom=function(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)},t.prototype.scrollToLine=function(e){var t=e-this._bufferService.buffer.ydisp;0!==t&&this.scrollLines(t)},t.prototype.addEscHandler=function(e,t){return this._inputHandler.addEscHandler(e,t)},t.prototype.addDcsHandler=function(e,t){return this._inputHandler.addDcsHandler(e,t)},t.prototype.addCsiHandler=function(e,t){return this._inputHandler.addCsiHandler(e,t)},t.prototype.addOscHandler=function(e,t){return this._inputHandler.addOscHandler(e,t)},t.prototype._setup=function(){this.optionsService.options.windowsMode&&this._enableWindowsMode()},t.prototype.reset=function(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this._coreService.reset(),this._coreMouseService.reset()},t.prototype._updateOptions=function(e){var t;switch(e){case"scrollback":this.buffers.resize(this.cols,this.rows);break;case"windowsMode":this.optionsService.options.windowsMode?this._enableWindowsMode():(null===(t=this._windowsMode)||void 0===t||t.dispose(),this._windowsMode=void 0)}},t.prototype._enableWindowsMode=function(){var e=this;if(!this._windowsMode){var t=[];t.push(this.onLineFeed(v.updateWindowsModeWrappedState.bind(null,this._bufferService))),t.push(this.addCsiHandler({final:"H"},(function(){return v.updateWindowsModeWrappedState(e._bufferService),!1}))),this._windowsMode={dispose:function(){for(var e=0,n=t;e0?r[0].index:t.length;if(t.length!==h)throw new Error("[createInstance] First service dependency of "+e.name+" at position "+(h+1)+" conflicts with "+t.length+" static arguments");return new(e.bind.apply(e,i([void 0],i(t,a))))},e}();t.InstantiationService=s},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;var s=n(1),c=n(69),l=n(0),u=n(2);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;var h=function(e){function n(n){var i=e.call(this)||this;return i._optionsService=n,i.isUserScrolling=!1,i._onResize=new l.EventEmitter,i.cols=Math.max(n.options.cols,t.MINIMUM_COLS),i.rows=Math.max(n.options.rows,t.MINIMUM_ROWS),i.buffers=new c.BufferSet(n,i),i}return r(n,e),Object.defineProperty(n.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!1,configurable:!0}),n.prototype.dispose=function(){e.prototype.dispose.call(this),this.buffers.dispose()},n.prototype.resize=function(e,t){this.cols=e,this.rows=t,this.buffers.resize(e,t),this.buffers.setupTabStops(this.cols),this._onResize.fire({cols:e,rows:t})},n.prototype.reset=function(){this.buffers.dispose(),this.buffers=new c.BufferSet(this._optionsService,this),this.isUserScrolling=!1},o([a(0,s.IOptionsService)],n)}(u.Disposable);t.BufferService=h},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;var o=n(70),a=n(0),s=function(e){function t(t,n){var i=e.call(this)||this;return i._onBufferActivate=i.register(new a.EventEmitter),i._normal=new o.Buffer(!0,t,n),i._normal.fillViewportRows(),i._alt=new o.Buffer(!1,t,n),i._activeBuffer=i._normal,i.setupTabStops(),i}return r(t,e),Object.defineProperty(t.prototype,"onBufferActivate",{get:function(){return this._onBufferActivate.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alt",{get:function(){return this._alt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},enumerable:!1,configurable:!0}),t.prototype.activateNormalBuffer=function(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))},t.prototype.activateAltBuffer=function(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))},t.prototype.resize=function(e,t){this._normal.resize(e,t),this._alt.resize(e,t)},t.prototype.setupTabStops=function(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)},t}(n(2).Disposable);t.BufferSet=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BufferStringIterator=t.Buffer=t.MAX_BUFFER_SIZE=void 0;var i=n(71),r=n(16),o=n(4),a=n(3),s=n(72),c=n(73),l=n(20),u=n(6);t.MAX_BUFFER_SIZE=4294967295;var h=function(){function e(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.savedY=0,this.savedX=0,this.savedCurAttrData=r.DEFAULT_ATTR_DATA.clone(),this.savedCharset=l.DEFAULT_CHARSET,this.markers=[],this._nullCell=o.CellData.fromCharData([0,a.NULL_CELL_CHAR,a.NULL_CELL_WIDTH,a.NULL_CELL_CODE]),this._whitespaceCell=o.CellData.fromCharData([0,a.WHITESPACE_CELL_CHAR,a.WHITESPACE_CELL_WIDTH,a.WHITESPACE_CELL_CODE]),this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}return e.prototype.getNullCell=function(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new u.ExtendedAttrs),this._nullCell},e.prototype.getWhitespaceCell=function(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new u.ExtendedAttrs),this._whitespaceCell},e.prototype.getBlankLine=function(e,t){return new r.BufferLine(this._bufferService.cols,this.getNullCell(e),t)},Object.defineProperty(e.prototype,"hasScrollback",{get:function(){return this._hasScrollback&&this.lines.maxLength>this._rows},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCursorInViewport",{get:function(){var e=this.ybase+this.y-this.ydisp;return e>=0&&et.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:n},e.prototype.fillViewportRows=function(e){if(0===this.lines.length){void 0===e&&(e=r.DEFAULT_ATTR_DATA);for(var t=this._rows;t--;)this.lines.push(this.getBlankLine(e))}},e.prototype.clear=function(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()},e.prototype.resize=function(e,t){var n=this.getNullCell(r.DEFAULT_ATTR_DATA),i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new r.BufferLine(e,n)));else for(s=this._rows;s>t;s--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(o=0;othis._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))},e.prototype._reflowLarger=function(e,t){var n=s.reflowLargerGetLinesToRemove(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(r.DEFAULT_ATTR_DATA));if(n.length>0){var i=s.reflowLargerCreateNewLayout(this.lines,n);s.reflowLargerApplyNewLayout(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}},e.prototype._reflowLargerAdjustViewport=function(e,t,n){for(var i=this.getNullCell(r.DEFAULT_ATTR_DATA),o=n;o-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length=0;a--){var c=this.lines.get(a);if(!(!c||!c.isWrapped&&c.getTrimmedLength()<=e)){for(var l=[c];c.isWrapped&&a>0;)c=this.lines.get(--a),l.unshift(c);var u=this.ybase+this.y;if(!(u>=a&&u0&&(i.push({start:a+l.length+o,newLines:m}),o+=m.length),l.push.apply(l,m);var b=f.length-1,y=f[b];0===y&&(y=f[--b]);for(var _=l.length-p-1,w=d;_>=0;){var k=Math.min(w,y);if(l[b].copyCellsFrom(l[_],w-k,y-k,k,!0),0==(y-=k)&&(y=f[--b]),0==(w-=k)){_--;var C=Math.max(_,0);w=s.getWrappedLineTrimmedLength(l,C,this._cols)}}for(g=0;g0;)0===this.ybase?this.y0){var x=[],O=[];for(g=0;g=0;g--)if(P&&P.start>T+j){for(var A=P.newLines.length-1;A>=0;A--)this.lines.set(g--,P.newLines[A]);g++,x.push({index:T+1,amount:P.newLines.length}),j+=P.newLines.length,P=i[++E]}else this.lines.set(g,O[T--]);var I=0;for(g=x.length-1;g>=0;g--)x[g].index+=I,this.lines.onInsertEmitter.fire(x[g]),I+=x[g].amount;var D=Math.max(0,M+o-this.lines.maxLength);D>0&&this.lines.onTrimEmitter.fire(D)}},e.prototype.stringIndexToBufferIndex=function(e,t,n){for(void 0===n&&(n=!1);t;){var i=this.lines.get(e);if(!i)return[-1,-1];for(var r=n?i.getTrimmedLength():i.length,o=0;o0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.nextStop=function(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e},e.prototype.addMarker=function(e){var t=this,n=new c.Marker(e);return this.markers.push(n),n.register(this.lines.onTrim((function(e){n.line-=e,n.line<0&&n.dispose()}))),n.register(this.lines.onInsert((function(e){n.line>=e.index&&(n.line+=e.amount)}))),n.register(this.lines.onDelete((function(e){n.line>=e.index&&n.linee.index&&(n.line-=e.amount)}))),n.register(n.onDispose((function(){return t._removeMarker(n)}))),n},e.prototype._removeMarker=function(e){this.markers.splice(this.markers.indexOf(e),1)},e.prototype.iterator=function(e,t,n,i,r){return new d(this,e,t,n,i,r)},e}();t.Buffer=h;var d=function(){function e(e,t,n,i,r,o){void 0===n&&(n=0),void 0===i&&(i=e.lines.length),void 0===r&&(r=0),void 0===o&&(o=0),this._buffer=e,this._trimRight=t,this._startIndex=n,this._endIndex=i,this._startOverscan=r,this._endOverscan=o,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="",n=e.first;n<=e.last;++n)t+=this._buffer.translateBufferLineToString(n,this._trimRight);return this._current=e.last+1,{range:e,content:t}},e}();t.BufferStringIterator=d},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;var i=n(0),r=function(){function e(e){this._maxLength=e,this.onDeleteEmitter=new i.EventEmitter,this.onInsertEmitter=new i.EventEmitter,this.onTrimEmitter=new i.EventEmitter,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}return Object.defineProperty(e.prototype,"onDelete",{get:function(){return this.onDeleteEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onInsert",{get:function(){return this.onInsertEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTrim",{get:function(){return this.onTrimEmitter.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxLength",{get:function(){return this._maxLength},set:function(e){if(this._maxLength!==e){for(var t=new Array(e),n=0;nthis._length)for(var t=this._length;t=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(r=0;rthis._maxLength){var o=this._length+n.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=n.length},e.prototype.trimStart=function(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)},e.prototype.shiftElements=function(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(var i=t-1;i>=0;i--)this.set(e+i+n,this.get(e+i));var r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(i=0;i=s&&r0&&(b>h||0===u[b].getTrimmedLength());b--)v++;v>0&&(a.push(s+u.length-v),a.push(v)),s+=u.length-1}}}return a},t.reflowLargerCreateNewLayout=function(e,t){for(var n=[],i=0,r=t[i],o=0,a=0;al&&(a-=l,s++);var u=2===e[s].getWidth(a-1);u&&a--;var h=u?n-1:n;r.push(h),c+=h}return r},t.getWrappedLineTrimmedLength=i},function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;var o=n(0),a=function(e){function t(n){var i=e.call(this)||this;return i.line=n,i._id=t._nextId++,i.isDisposed=!1,i._onDispose=new o.EventEmitter,i}return r(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{get:function(){return this._onDispose.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire())},t._nextId=1,t}(n(2).Disposable);t.Marker=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=t.DEFAULT_BELL_SOUND=void 0;var i=n(0),r=n(11),o=n(33);t.DEFAULT_BELL_SOUND="data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",t.DEFAULT_OPTIONS=Object.freeze({cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,bellSound:t.DEFAULT_BELL_SOUND,bellStyle:"none",drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",lineHeight:1,linkTooltipHoverDuration:500,letterSpacing:0,logLevel:"info",scrollback:1e3,scrollSensitivity:1,screenReaderMode:!1,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!0,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:r.isMac,rendererType:"canvas",windowOptions:{},windowsMode:!1,wordSeparator:" ()[]{}',\"`",convertEol:!1,termName:"xterm",cancelEvents:!1});var a=["normal","bold","100","200","300","400","500","600","700","800","900"],s=["cols","rows"],c=function(){function e(e){this._onOptionChange=new i.EventEmitter,this.options=o.clone(t.DEFAULT_OPTIONS);for(var n=0,r=Object.keys(e);n=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},a=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;var s=n(1),c=n(0),l=n(33),u=n(2),h=Object.freeze({insertMode:!1}),d=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),f=function(e){function t(t,n,i,r){var o=e.call(this)||this;return o._bufferService=n,o._logService=i,o._optionsService=r,o.isCursorInitialized=!1,o.isCursorHidden=!1,o._onData=o.register(new c.EventEmitter),o._onUserInput=o.register(new c.EventEmitter),o._onBinary=o.register(new c.EventEmitter),o._scrollToBottom=t,o.register({dispose:function(){return o._scrollToBottom=void 0}}),o.modes=l.clone(h),o.decPrivateModes=l.clone(d),o}return r(t,e),Object.defineProperty(t.prototype,"onData",{get:function(){return this._onData.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onUserInput",{get:function(){return this._onUserInput.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this.modes=l.clone(h),this.decPrivateModes=l.clone(d)},t.prototype.triggerDataEvent=function(e,t){if(void 0===t&&(t=!1),!this._optionsService.options.disableStdin){var n=this._bufferService.buffer;n.ybase!==n.ydisp&&this._scrollToBottom(),t&&this._onUserInput.fire(),this._logService.debug('sending data "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onData.fire(e)}},t.prototype.triggerBinaryEvent=function(e){this._optionsService.options.disableStdin||(this._logService.debug('sending binary "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onBinary.fire(e))},o([a(1,s.IBufferService),a(2,s.ILogService),a(3,s.IOptionsService)],t)}(u.Disposable);t.CoreService=f},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;var o=n(1),a=n(0),s={NONE:{events:0,restrict:function(){return!1}},X10:{events:1,restrict:function(e){return 4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)}},VT200:{events:19,restrict:function(e){return 32!==e.action}},DRAG:{events:23,restrict:function(e){return 32!==e.action||3!==e.button}},ANY:{events:31,restrict:function(e){return!0}}};function c(e,t){var n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(n|=64,n|=e.action):(n|=3&e.button,4&e.button&&(n|=64),8&e.button&&(n|=128),32===e.action?n|=32:0!==e.action||t||(n|=3)),n}var l=String.fromCharCode,u={DEFAULT:function(e){var t=[c(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":"\x1b[M"+l(t[0])+l(t[1])+l(t[2])},SGR:function(e){var t=0===e.action&&4!==e.button?"m":"M";return"\x1b[<"+c(e,!0)+";"+e.col+";"+e.row+t}},h=function(){function e(e,t){this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._onProtocolChange=new a.EventEmitter,this._lastEvent=null;for(var n=0,i=Object.keys(s);n=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows)return!1;if(4===e.button&&32===e.action)return!1;if(3===e.button&&32!==e.action)return!1;if(4!==e.button&&(2===e.action||3===e.action))return!1;if(e.col++,e.row++,32===e.action&&this._lastEvent&&this._compareEvents(this._lastEvent,e))return!1;if(!this._protocols[this._activeProtocol].restrict(e))return!1;var t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0},e.prototype.explainEvents=function(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}},e.prototype._compareEvents=function(e,t){return e.col===t.col&&e.row===t.row&&e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift},i([r(0,o.IBufferService),r(1,o.ICoreService)],e)}();t.CoreMouseService=h},function(e,t,n){"use strict";var i=this&&this.__decorate||function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a},r=this&&this.__param||function(e,t){return function(n,i){t(n,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirtyRowService=void 0;var o=n(1),a=function(){function e(e){this._bufferService=e,this.clearRange()}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!1,configurable:!0}),e.prototype.clearRange=function(){this._start=this._bufferService.buffer.y,this._end=this._bufferService.buffer.y},e.prototype.markDirty=function(e){ethis._end&&(this._end=e)},e.prototype.markRangeDirty=function(e,t){if(e>t){var n=e;e=t,t=n}ethis._end&&(this._end=t)},e.prototype.markAllDirty=function(){this.markRangeDirty(0,this._bufferService.rows-1)},i([r(0,o.IBufferService)],e)}();t.DirtyRowService=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;var i=n(0),r=n(79),o=function(){function e(){this._providers=Object.create(null),this._active="",this._onChange=new i.EventEmitter;var e=new r.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}return Object.defineProperty(e.prototype,"onChange",{get:function(){return this._onChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"versions",{get:function(){return Object.keys(this._providers)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeVersion",{get:function(){return this._active},set:function(e){if(!this._providers[e])throw new Error('unknown Unicode version "'+e+'"');this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)},enumerable:!1,configurable:!0}),e.prototype.register=function(e){this._providers[e.version]=e},e.prototype.wcwidth=function(e){return this._activeProvider.wcwidth(e)},e.prototype.getStringCellWidth=function(e){for(var t=0,n=e.length,i=0;i=n)return t+this.wcwidth(r);var o=e.charCodeAt(i);56320<=o&&o<=57343?r=1024*(r-55296)+o-56320+65536:t+=this.wcwidth(o)}t+=this.wcwidth(r)}return t},e}();t.UnicodeService=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;var i,r=n(15),o=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],s=function(){function e(){if(this.version="6",!i){i=new Uint8Array(65536),r.fill(i,1),i[0]=0,r.fill(i,0,1,32),r.fill(i,0,127,160),r.fill(i,2,4352,4448),i[9001]=2,i[9002]=2,r.fill(i,2,11904,42192),i[12351]=1,r.fill(i,2,44032,55204),r.fill(i,2,63744,64256),r.fill(i,2,65040,65050),r.fill(i,2,65072,65136),r.fill(i,2,65280,65377),r.fill(i,2,65504,65511);for(var e=0;et[r][1])return!1;for(;r>=i;)if(e>t[n=i+r>>1][1])i=n+1;else{if(!(e=131072&&e<=196605||e>=196608&&e<=262141?2:1},e}();t.UnicodeV6=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0;var i=function(){function e(){this.glevel=0,this._charsets=[]}return e.prototype.reset=function(){this.charset=void 0,this._charsets=[],this.glevel=0},e.prototype.setgLevel=function(e){this.glevel=e,this.charset=this._charsets[e]},e.prototype.setgCharset=function(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)},e}();t.CharsetService=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=void 0;var i=n(3);t.updateWindowsModeWrappedState=function(e){var t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1),n=null==t?void 0:t.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&n&&(r.isWrapped=n[i.CHAR_DATA_CODE_INDEX]!==i.NULL_CELL_CODE&&n[i.CHAR_DATA_CODE_INDEX]!==i.WHITESPACE_CELL_CODE)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;var i=function(){function e(e){this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0}return e.prototype.writeSync=function(e){if(this._writeBuffer.length){for(var t=this._bufferOffset;t5e7)throw new Error("write data discarded, use flow control to avoid losing data");this._writeBuffer.length||(this._bufferOffset=0,setTimeout((function(){return n._innerWrite()}))),this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)},e.prototype._innerWrite=function(){for(var e=this,t=Date.now();this._writeBuffer.length>this._bufferOffset;){var n=this._writeBuffer[this._bufferOffset],i=this._callbacks[this._bufferOffset];if(this._bufferOffset++,this._action(n),this._pendingData-=n.length,i&&i(),Date.now()-t>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((function(){return e._innerWrite()}),0)):(this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0)},e}();t.WriteBuffer=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0;var i=function(){function e(){this._addons=[]}return e.prototype.dispose=function(){for(var e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()},e.prototype.loadAddon=function(e,t){var n=this,i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=function(){return n._wrappedAddonDispose(i)},t.activate(e)},e.prototype._wrappedAddonDispose=function(e){if(!e.isDisposed){for(var t=-1,n=0;n100&&(u=a-60+3,a=58);for(var h=s;h<=c;h++)h>=0&&h0&&i[h].length>u?"\u2026":"")+i[h].substr(u,98)+(i[h].length>u+100-1?"\u2026":""));return[n(s,o),new Array(a+l+2).join("-")+"^",n(o,c)].filter(Boolean).join("\n")}e.exports=function(e,t,n,r,a){var s=i("SyntaxError",e);return s.source=t,s.offset=n,s.line=r,s.column=a,s.sourceFragment=function(e){return o(s,isNaN(e)?0:e)},Object.defineProperty(s,"formattedMessage",{get:function(){return"Parse error: "+s.message+"\n"+o(s,2)}}),s.parseError={offset:n,line:r,column:a},s}},"1gRP":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("kU1M");t.materialize=function(){return i.materialize()(this)}},"1uah":function(e,t,n){"use strict";n.d(t,"b",(function(){return d})),n.d(t,"a",(function(){return f}));var i=n("Ji7U"),r=n("LK+K"),o=n("1OyB"),a=n("vuIU"),s=n("yCtX"),c=n("DH7j"),l=n("7o/Q"),u=n("Lhse"),h=n("zx2A");function d(){for(var e=arguments.length,t=new Array(e),n=0;n2&&void 0!==arguments[2]||Object.create(null),Object(o.a)(this,n),(r=t.call(this,e)).resultSelector=i,r.iterators=[],r.active=0,r.resultSelector="function"==typeof i?i:void 0,r}return Object(a.a)(n,[{key:"_next",value:function(e){var t=this.iterators;Object(c.a)(e)?t.push(new g(e)):t.push("function"==typeof e[u.a]?new m(e[u.a]()):new v(this.destination,this,e))}},{key:"_complete",value:function(){var e=this.iterators,t=e.length;if(this.unsubscribe(),0!==t){this.active=t;for(var n=0;nthis.index}},{key:"hasCompleted",value:function(){return this.array.length===this.index}}]),e}(),v=function(e){Object(i.a)(n,e);var t=Object(r.a)(n);function n(e,i,r){var a;return Object(o.a)(this,n),(a=t.call(this,e)).parent=i,a.observable=r,a.stillUnsubscribed=!0,a.buffer=[],a.isComplete=!1,a}return Object(a.a)(n,[{key:u.a,value:function(){return this}},{key:"next",value:function(){var e=this.buffer;return 0===e.length&&this.isComplete?{value:null,done:!0}:{value:e.shift(),done:!1}}},{key:"hasValue",value:function(){return this.buffer.length>0}},{key:"hasCompleted",value:function(){return 0===this.buffer.length&&this.isComplete}},{key:"notifyComplete",value:function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()}},{key:"notifyNext",value:function(e){this.buffer.push(e),this.parent.checkIterators()}},{key:"subscribe",value:function(){return Object(h.c)(this.observable,new h.a(this))}}]),n}(h.b)},"2+DN":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("uMcE");i.Observable.prototype.shareReplay=r.shareReplay},"25BE":function(e,t,n){"use strict";function i(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}n.d(t,"a",(function(){return i}))},"2Gxe":function(e,t,n){var i=n("vd7W").TYPE,r=i.Ident,o=i.String,a=i.Colon,s=i.LeftSquareBracket,c=i.RightSquareBracket;function l(){this.scanner.eof&&this.error("Unexpected end of input");var e=this.scanner.tokenStart,t=!1,n=!0;return this.scanner.isDelim(42)?(t=!0,n=!1,this.scanner.next()):this.scanner.isDelim(124)||this.eat(r),this.scanner.isDelim(124)?61!==this.scanner.source.charCodeAt(this.scanner.tokenStart+1)?(this.scanner.next(),this.eat(r)):t&&this.error("Identifier is expected",this.scanner.tokenEnd):t&&this.error("Vertical line is expected"),n&&this.scanner.tokenType===a&&(this.scanner.next(),this.eat(r)),{type:"Identifier",loc:this.getLocation(e,this.scanner.tokenStart),name:this.scanner.substrToCursor(e)}}function u(){var e=this.scanner.tokenStart,t=this.scanner.source.charCodeAt(e);return 61!==t&&126!==t&&94!==t&&36!==t&&42!==t&&124!==t&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.scanner.next(),61!==t&&(this.scanner.isDelim(61)||this.error("Equal sign is expected"),this.scanner.next()),this.scanner.substrToCursor(e)}e.exports={name:"AttributeSelector",structure:{name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]},parse:function(){var e,t=this.scanner.tokenStart,n=null,i=null,a=null;return this.eat(s),this.scanner.skipSC(),e=l.call(this),this.scanner.skipSC(),this.scanner.tokenType!==c&&(this.scanner.tokenType!==r&&(n=u.call(this),this.scanner.skipSC(),i=this.scanner.tokenType===o?this.String():this.Identifier(),this.scanner.skipSC()),this.scanner.tokenType===r&&(a=this.scanner.getTokenValue(),this.scanner.next(),this.scanner.skipSC())),this.eat(c),{type:"AttributeSelector",loc:this.getLocation(t,this.scanner.tokenStart),name:e,matcher:n,value:i,flags:a}},generate:function(e){var t=" ";this.chunk("["),this.node(e.name),null!==e.matcher&&(this.chunk(e.matcher),null!==e.value&&(this.node(e.value),"String"===e.value.type&&(t=""))),null!==e.flags&&(this.chunk(t),this.chunk(e.flags)),this.chunk("]")}}},"2IC2":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("j5kd");i.Observable.prototype.windowTime=r.windowTime},"2QA8":function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}()},"2TAq":function(e,t,n){var i=n("vd7W").isHexDigit,r=n("vd7W").cmpChar,o=n("vd7W").TYPE,a=o.Ident,s=o.Delim,c=o.Number,l=o.Dimension;function u(e,t){return null!==e&&e.type===s&&e.value.charCodeAt(0)===t}function h(e,t){return e.value.charCodeAt(0)===t}function d(e,t,n){for(var r=t,o=0;r0?6:0;if(!i(a))return 0;if(++o>6)return 0}return o}function f(e,t,n){if(!e)return 0;for(;u(n(t),63);){if(++e>6)return 0;t++}return t}e.exports=function(e,t){var n=0;if(null===e||e.type!==a||!r(e.value,0,117))return 0;if(null===(e=t(++n)))return 0;if(u(e,43))return null===(e=t(++n))?0:e.type===a?f(d(e,0,!0),++n,t):u(e,63)?f(1,++n,t):0;if(e.type===c){if(!h(e,43))return 0;var i=d(e,1,!0);return 0===i?0:null===(e=t(++n))?n:e.type===l||e.type===c?h(e,45)&&d(e,1,!1)?n+1:0:f(i,n,t)}return e.type===l&&h(e,43)?f(d(e,1,!0),++n,t):0}},"2Vo4":function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var i=n("1OyB"),r=n("vuIU"),o=n("ReuC"),a=n("foSv"),s=n("Ji7U"),c=n("LK+K"),l=n("XNiG"),u=n("9ppp"),h=function(e){Object(s.a)(n,e);var t=Object(c.a)(n);function n(e){var r;return Object(i.a)(this,n),(r=t.call(this))._value=e,r}return Object(r.a)(n,[{key:"_subscribe",value:function(e){var t=Object(o.a)(Object(a.a)(n.prototype),"_subscribe",this).call(this,e);return t&&!t.closed&&e.next(this._value),t}},{key:"getValue",value:function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new u.a;return this._value}},{key:"next",value:function(e){Object(o.a)(Object(a.a)(n.prototype),"next",this).call(this,this._value=e)}},{key:"value",get:function(){return this.getValue()}}]),n}(l.b)},"2WcH":function(e,t,n){"use strict";function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}n.d(t,"a",(function(){return i}))},"2fFW":function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=!1,r={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){if(e){var t=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+t.stack)}else i&&console.log("RxJS: Back to a better error behavior. Thank you. <3");i=e},get useDeprecatedSynchronousErrorHandling(){return i}}},"2pxp":function(e,t){e.exports={parse:function(){return this.createSingleNodeList(this.SelectorList())}}},"338f":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("kU1M");t.concatMap=function(e){return i.concatMap(e)(this)}},"33Dm":function(e,t,n){var i=n("vd7W").TYPE,r=i.WhiteSpace,o=i.Comment,a=i.Ident,s=i.LeftParenthesis;e.exports={name:"MediaQuery",structure:{children:[["Identifier","MediaFeature","WhiteSpace"]]},parse:function(){this.scanner.skipSC();var e=this.createList(),t=null,n=null;e:for(;!this.scanner.eof;){switch(this.scanner.tokenType){case o:this.scanner.next();continue;case r:n=this.WhiteSpace();continue;case a:t=this.Identifier();break;case s:t=this.MediaFeature();break;default:break e}null!==n&&(e.push(n),n=null),e.push(t)}return null===t&&this.error("Identifier or parenthesis is expected"),{type:"MediaQuery",loc:this.getLocationFromList(e),children:e}},generate:function(e){this.children(e)}}},"37L2":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("338f");i.Observable.prototype.concatMap=r.concatMap},"3E0/":function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var i=n("Ji7U"),r=n("LK+K"),o=n("1OyB"),a=n("vuIU"),s=n("D0XW"),c=n("mlxB"),l=n("7o/Q"),u=n("WMd4");function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.a,n=Object(c.a)(e),i=n?+e-t.now():Math.abs(e);return function(e){return e.lift(new d(i,t))}}var d=function(){function e(t,n){Object(o.a)(this,e),this.delay=t,this.scheduler=n}return Object(a.a)(e,[{key:"call",value:function(e,t){return t.subscribe(new f(e,this.delay,this.scheduler))}}]),e}(),f=function(e){Object(i.a)(n,e);var t=Object(r.a)(n);function n(e,i,r){var a;return Object(o.a)(this,n),(a=t.call(this,e)).delay=i,a.scheduler=r,a.queue=[],a.active=!1,a.errored=!1,a}return Object(a.a)(n,[{key:"_schedule",value:function(e){this.active=!0,this.destination.add(e.schedule(n.dispatch,this.delay,{source:this,destination:this.destination,scheduler:e}))}},{key:"scheduleNotification",value:function(e){if(!0!==this.errored){var t=this.scheduler,n=new p(t.now()+this.delay,e);this.queue.push(n),!1===this.active&&this._schedule(t)}}},{key:"_next",value:function(e){this.scheduleNotification(u.a.createNext(e))}},{key:"_error",value:function(e){this.errored=!0,this.queue=[],this.destination.error(e),this.unsubscribe()}},{key:"_complete",value:function(){this.scheduleNotification(u.a.createComplete()),this.unsubscribe()}}],[{key:"dispatch",value:function(e){for(var t=e.source,n=t.queue,i=e.scheduler,r=e.destination;n.length>0&&n[0].time-i.now()<=0;)n.shift().notification.observe(r);if(n.length>0){var o=Math.max(0,n[0].time-i.now());this.schedule(e,o)}else this.unsubscribe(),t.active=!1}}]),n}(l.a),p=function e(t,n){Object(o.a)(this,e),this.time=t,this.notification=n}},"3EiV":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp"),r=n("dL1u");i.Observable.prototype.buffer=r.buffer},"3N8a":function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n("1OyB"),r=n("vuIU"),o=n("Ji7U"),a=n("LK+K"),s=function(e){Object(o.a)(n,e);var t=Object(a.a)(n);function n(e,r){var o;return Object(i.a)(this,n),(o=t.call(this,e,r)).scheduler=e,o.work=r,o.pending=!1,o}return Object(r.a)(n,[{key:"schedule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=this.id||this.requestAsyncId(i,this.id,t),this}},{key:"requestAsyncId",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return setInterval(e.flush.bind(e,this),n)}},{key:"recycleAsyncId",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(null!==n&&this.delay===n&&!1===this.pending)return t;clearInterval(t)}},{key:"execute",value:function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))}},{key:"_execute",value:function(e,t){var n=!1,i=void 0;try{this.work(e)}catch(r){n=!0,i=!!r&&r||new Error(r)}if(n)return this.unsubscribe(),i}},{key:"_unsubscribe",value:function(){var e=this.id,t=this.scheduler,n=t.actions,i=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==i&&n.splice(i,1),null!=e&&(this.id=this.recycleAsyncId(t,e,null)),this.delay=null}}]),n}(function(e){Object(o.a)(n,e);var t=Object(a.a)(n);function n(e,r){return Object(i.a)(this,n),t.call(this)}return Object(r.a)(n,[{key:"schedule",value:function(e){return this}}]),n}(n("quSY").a))},"3Qpg":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("qCKp");i.Observable.fromPromise=i.from},"3UWI":function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n("D0XW"),r=n("tnsW"),o=n("PqYM");function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.a;return Object(r.a)((function(){return Object(o.a)(e,t)}))}},"3XNy":function(e,t){function n(e){return e>=48&&e<=57}function i(e){return e>=65&&e<=90}function r(e){return e>=97&&e<=122}function o(e){return i(e)||r(e)}function a(e){return e>=128}function s(e){return o(e)||a(e)||95===e}function c(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function l(e){return 10===e||13===e||12===e}function u(e){return l(e)||32===e||9===e}function h(e,t){return 92===e&&!l(t)&&0!==t}var d=new Array(128);p.Eof=128,p.WhiteSpace=130,p.Digit=131,p.NameStart=132,p.NonPrintable=133;for(var f=0;f=65&&e<=70||e>=97&&e<=102},isUppercaseLetter:i,isLowercaseLetter:r,isLetter:o,isNonAscii:a,isNameStart:s,isName:function(e){return s(e)||n(e)||45===e},isNonPrintable:c,isNewline:l,isWhiteSpace:u,isValidEscape:h,isIdentifierStart:function(e,t,n){return 45===e?s(t)||45===t||h(t,n):!!s(e)||92===e&&h(e,t)},isNumberStart:function(e,t,i){return 43===e||45===e?n(t)?2:46===t&&n(i)?3:0:46===e?n(t)?2:0:n(e)?1:0},isBOM:function(e){return 65279===e||65534===e?1:0},charCodeCategory:p}},"3uOa":function(e,t,n){"use strict";n.r(t);var i=n("lcII");n.d(t,"webSocket",(function(){return i.a}));var r=n("wxn8");n.d(t,"WebSocketSubject",(function(){return r.a}))},"4AtU":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("kU1M");t.expand=function(e,t,n){return void 0===t&&(t=Number.POSITIVE_INFINITY),void 0===n&&(n=void 0),i.expand(e,t=(t||0)<1?Number.POSITIVE_INFINITY:t,n)(this)}},"4HHr":function(e,t){var n=Object.prototype.hasOwnProperty,i=function(){};function r(e){return"function"==typeof e?e:i}function o(e,t){return function(n,i,r){n.type===t&&e.call(this,n,i,r)}}function a(e,t){var i=t.structure,r=[];for(var o in i)if(!1!==n.call(i,o)){var a=i[o],s={name:o,type:!1,nullable:!1};Array.isArray(i[o])||(a=[i[o]]);for(var c=0;c>>((3&t)<<3)&255;return r}}},"4hIw":function(e,t,n){"use strict";n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return l}));var i=n("1OyB"),r=n("D0XW"),o=n("Kqap"),a=n("NXyV"),s=n("lJxs");function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.a;return function(t){return Object(a.a)((function(){return t.pipe(Object(o.a)((function(t,n){var i=t.current;return{value:n,current:e.now(),last:i}}),{current:e.now(),value:void 0,last:void 0}),Object(s.a)((function(e){return new l(e.value,e.current-e.last)})))}))}}var l=function e(t,n){Object(i.a)(this,e),this.value=t,this.interval=n}},"4njK":function(e,t,n){var i=n("vd7W").TYPE,r=i.WhiteSpace,o=i.Semicolon,a=i.LeftCurlyBracket,s=i.Delim;function c(){return this.scanner.tokenIndex>0&&this.scanner.lookupType(-1)===r?this.scanner.tokenIndex>1?this.scanner.getTokenStart(this.scanner.tokenIndex-1):this.scanner.firstCharOffset:this.scanner.tokenStart}function l(){return 0}e.exports={name:"Raw",structure:{value:String},parse:function(e,t,n){var i,r=this.scanner.getTokenStart(e);return this.scanner.skip(this.scanner.getRawLength(e,t||l)),i=n&&this.scanner.tokenStart>r?c.call(this):this.scanner.tokenStart,{type:"Raw",loc:this.getLocation(r,i),value:this.scanner.source.substring(r,i)}},generate:function(e){this.chunk(e.value)},mode:{default:l,leftCurlyBracket:function(e){return e===a?1:0},leftCurlyBracketOrSemicolon:function(e){return e===a||e===o?1:0},exclamationMarkOrSemicolon:function(e,t,n){return e===s&&33===t.charCodeAt(n)||e===o?1:0},semicolonIncluded:function(e){return e===o?2:0}}}},"4vYp":function(e){e.exports=JSON.parse('{"generic":true,"types":{"absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large","alpha-value":"|","angle-percentage":"|","angular-color-hint":"","angular-color-stop":"&&?","angular-color-stop-list":"[ [, ]?]# , ","animateable-feature":"scroll-position|contents|","attachment":"scroll|fixed|local","attr()":"attr( ? [, ]? )","attr-matcher":"[\'~\'|\'|\'|\'^\'|\'$\'|\'*\']? \'=\'","attr-modifier":"i|s","attribute-selector":"\'[\' \']\'|\'[\' [|] ? \']\'","auto-repeat":"repeat( [auto-fill|auto-fit] , [? ]+ ? )","auto-track-list":"[? [|]]* ? [? [|]]* ?","baseline-position":"[first|last]? baseline","basic-shape":"|||","bg-image":"none|","bg-layer":"|| [/ ]?||||||||","bg-position":"[[left|center|right|top|bottom|]|[left|center|right|] [top|center|bottom|]|[center|[left|right] ?]&&[center|[top|bottom] ?]]","bg-size":"[|auto]{1,2}|cover|contain","blur()":"blur( )","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity","box":"border-box|padding-box|content-box","brightness()":"brightness( )","calc()":"calc( )","calc-sum":" [[\'+\'|\'-\'] ]*","calc-product":" [\'*\' |\'/\' ]*","calc-value":"|||( )","cf-final-image":"|","cf-mixing-image":"?&&","circle()":"circle( []? [at ]? )","clamp()":"clamp( #{3} )","class-selector":"\'.\' ","clip-source":"","color":"||||||currentcolor|","color-stop":"|","color-stop-angle":"{1,2}","color-stop-length":"{1,2}","color-stop-list":"[ [, ]?]# , ","combinator":"\'>\'|\'+\'|\'~\'|[\'||\']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat":"searchfield|textarea|push-button|button-bevel|slider-horizontal|checkbox|radio|square-button|menulist|menulist-button|listbox|meter|progress-bar","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[? * [ *]*]!","compound-selector-list":"#","complex-selector":" [? ]*","complex-selector-list":"#","conic-gradient()":"conic-gradient( [from ]? [at ]? , )","contextual-alt-values":"[contextual|no-contextual]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[|contents||||counter( , <\'list-style-type\'>? )]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"","contrast()":"contrast( [] )","counter()":"counter( , [|none]? )","counter-style":"|symbols( )","counter-style-name":"","counters()":"counters( , , [|none]? )","cross-fade()":"cross-fade( , ? )","cubic-bezier-timing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( , , , )","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( {2,3} ? )","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( )","ellipse()":"ellipse( [{2}]? [at ]? )","ending-shape":"circle|ellipse","env()":"env( , ? )","explicit-track-list":"[? ]+ ?","family-name":"|+","feature-tag-value":" [|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":" \'{\' \'}\'","feature-value-block-list":"+","feature-value-declaration":" : + ;","feature-value-declaration-list":"","feature-value-name":"","fill-rule":"nonzero|evenodd","filter-function":"|||||||||","filter-function-list":"[|]+","final-bg-layer":"<\'background-color\'>|||| [/ ]?||||||||","fit-content()":"fit-content( [|] )","fixed-breadth":"","fixed-repeat":"repeat( [] , [? ]+ ? )","fixed-size":"|minmax( , )|minmax( , )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|","font-variant-css21":"[normal|small-caps]","font-weight-absolute":"normal|bold|","frequency-percentage":"|","general-enclosed":"[ )]|( )","generic-family":"serif|sans-serif|cursive|fantasy|monospace|-apple-system","generic-name":"serif|sans-serif|cursive|fantasy|monospace","geometry-box":"|fill-box|stroke-box|view-box","gradient":"|||||<-legacy-gradient>","grayscale()":"grayscale( )","grid-line":"auto||[&&?]|[span&&[||]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( [/ ]? )|hsl( , , , ? )","hsla()":"hsla( [/ ]? )|hsla( , , , ? )","hue":"|","hue-rotate()":"hue-rotate( )","image":"|||||","image()":"image( ? [? , ?]! )","image-set()":"image-set( # )","image-set-option":"[|] ","image-src":"|","image-tags":"ltr|rtl","inflexible-breadth":"||min-content|max-content|auto","inset()":"inset( {1,4} [round <\'border-radius\'>]? )","invert()":"invert( )","keyframes-name":"|","keyframe-block":"# { }","keyframe-block-list":"+","keyframe-selector":"from|to|","leader()":"leader( )","leader-type":"dotted|solid|space|","length-percentage":"|","line-names":"\'[\' * \']\'","line-name-list":"[|]+","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"|thin|medium|thick","linear-color-hint":"","linear-color-stop":" ?","linear-gradient()":"linear-gradient( [|to ]? , )","mask-layer":"|| [/ ]?||||||[|no-clip]||||","mask-position":"[|left|center|right] [|top|center|bottom]?","mask-reference":"none||","mask-source":"","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( #{6} )","matrix3d()":"matrix3d( #{16} )","max()":"max( # )","media-and":" [and ]+","media-condition":"|||","media-condition-without-or":"||","media-feature":"( [||] )","media-in-parens":"( )||","media-not":"not ","media-or":" [or ]+","media-query":"|[not|only]? [and ]?","media-query-list":"#","media-type":"","mf-boolean":"","mf-name":"","mf-plain":" : ","mf-range":" [\'<\'|\'>\']? \'=\'? | [\'<\'|\'>\']? \'=\'? | \'<\' \'=\'? \'<\' \'=\'? | \'>\' \'=\'? \'>\' \'=\'? ","mf-value":"|||","min()":"min( # )","minmax()":"minmax( [|||min-content|max-content|auto] , [|||min-content|max-content|auto] )","named-color":"transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|<-non-standard-color>","namespace-prefix":"","ns-prefix":"[|\'*\']? \'|\'","number-percentage":"|","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]","nth":"|even|odd","opacity()":"opacity( [] )","overflow-position":"unsafe|safe","outline-radius":"|","page-body":"? [; ]?| ","page-margin-box":" \'{\' \'}\'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector-list":"[#]?","page-selector":"+| *","perspective()":"perspective( )","polygon()":"polygon( ? , [ ]# )","position":"[[left|center|right]||[top|center|bottom]|[left|center|right|] [top|center|bottom|]?|[[left|right] ]&&[[top|bottom] ]]","pseudo-class-selector":"\':\' |\':\' \')\'","pseudo-element-selector":"\':\' ","pseudo-page":": [left|right|first|blank]","quote":"open-quote|close-quote|no-open-quote|no-close-quote","radial-gradient()":"radial-gradient( [||]? [at ]? , )","relative-selector":"? ","relative-selector-list":"#","relative-size":"larger|smaller","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-linear-gradient()":"repeating-linear-gradient( [|to ]? , )","repeating-radial-gradient()":"repeating-radial-gradient( [||]? [at ]? , )","rgb()":"rgb( {3} [/ ]? )|rgb( {3} [/ ]? )|rgb( #{3} , ? )|rgb( #{3} , ? )","rgba()":"rgba( {3} [/ ]? )|rgba( {3} [/ ]? )|rgba( #{3} , ? )|rgba( #{3} , ? )","rotate()":"rotate( [|] )","rotate3d()":"rotate3d( , , , [|] )","rotateX()":"rotateX( [|] )","rotateY()":"rotateY( [|] )","rotateZ()":"rotateZ( [|] )","saturate()":"saturate( )","scale()":"scale( , ? )","scale3d()":"scale3d( , , )","scaleX()":"scaleX( )","scaleY()":"scaleY( )","scaleZ()":"scaleZ( )","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","shape-radius":"|closest-side|farthest-side","skew()":"skew( [|] , [|]? )","skewX()":"skewX( [|] )","skewY()":"skewY( [|] )","sepia()":"sepia( )","shadow":"inset?&&{2,4}&&?","shadow-t":"[{2,3}&&?]","shape":"rect( , , , )|rect( )","shape-box":"|margin-box","side-or-corner":"[left|right]||[top|bottom]","single-animation":"