diff --git a/connectcore-demo-example/index.html b/connectcore-demo-example/index.html new file mode 100644 index 0000000..ac89ffe --- /dev/null +++ b/connectcore-demo-example/index.html @@ -0,0 +1,1075 @@ + + + + +Digi Demo - Dashboard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ Loading... +
+
+ + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
No
+
Yes
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+ + + + + + + + + +
+ Time between samples: + + - +
+ Samples to buffer: + + - +
+
+
+
+
+
+
+
+
+
+ + Device information +
+
+ +
+
+
+
+ +
+

Welcome to the device dashboard.

+ From this page you can explore and interact with the different device components. Hover and click the green-highlighted panels to discover the board interfaces and specific enabled functionality. +
Got it!
+
+
+
+ Open console + +
+
+
+
+
+ + Remote console +
+
+
+
+ + +
+
+
+ CPU stats + +
+
+ +
+ + CPU stats +
+
+
+
+ + + + + + + + + + + + + + + + + +
+ Usage: + + - % +
+ Uptime: + + - +
+ Frequency: + + - MHz +
+ Temperature: + + - ºC +
+
+
+
+ + + + + + + + + + +
+
+ + Core 1 +
+
- %
- MHz
+
+
+ + + + + + + + + + +
+
+ + Core 2 +
+
- %
- MHz
+
+
+ + + + + + + + + + +
+
+ + Core 3 +
+
- %
- MHz
+
+
+ + + + + + + + + + +
+
+ + Core 4 +
+
- %
- MHz
+
+
+
+
+
+ RAM memory + +
+
+ +
+ + RAM memory stats +
+
+
+ + + + + + + + + + + + + +
+ Total memory: + + - MB +
+ Used memory: + + - MB +
+ Free memory: + + - MB +
+
+
+
+
+
+
+ + Device file system +
+
+
+
+
+
+
+ + Create new directory +
+
+
Enter the new directory name
+ +
+
Create directory
+
+
+
+
+
Current dir:
+
+
+
+
+
+
+
+
+
+
+
+
Name
+
Size
+
Last modified
+
+
+ +
+
+
+ WiFi/BT stats + +
+
+ +
+ + Wi-Fi/BT stats +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Status: + + - +
+ MAC address: + + - +
+ IP address: + + - +
+ Sent data: + + - +
+ Received data: + + - +
+
+
+ + Bluetooth +
+
+ + + + + + + + + + + + + + + + + +
+ Status: + + - +
+ MAC address: + + - +
+ Sent data: + + - +
+ Received data: + + - +
+
+
+
+ Ethernet stats + +
+
+ +
+ + Ethernet stats +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Status: + + - +
+ MAC address: + + - +
+ IP address: + + - +
+ Sent data: + + - +
+ Received data: + + - +
+
+
+
+ Video info + +
+
+ +
+ + Video info +
+
+
+ + + + + +
+ Resolution: + + - +
+
+ Brightness: + 0% + + 100% +
+
+
+
+ Audio control + +
+
+ +
+ + Audio control +
+
+
+
+ Volume: + 0% + + 100% +
+
+
+
+
+ Toggle LED + + +
+
+ Flash memory + +
+
+ +
+ + Flash memory stats +
+
+
+ + + + + +
+ Total flash memory: + + - GB +
+
Explore file system...
+
+
+
+
+
+
+
+
+
+
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/connectcore-demo-example/management.html b/connectcore-demo-example/management.html new file mode 100644 index 0000000..ae73785 --- /dev/null +++ b/connectcore-demo-example/management.html @@ -0,0 +1,534 @@ + + + + +Digi Demo - Management + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ Loading... +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+
No
+
Yes
+
+
+
+
+
+
System monitor
+
Configure the system monitor service parameters.
+
+ Time between samples: + + +
+
+
+ Samples to buffer: + + +
+
+
Save
+
+
+
+
+
Reboot device
+
Click REBOOT to restart your device.
+
REBOOT
+
+
+
+
+
Firmware update
+ + + + + + + + + + + + + +
+ Current DEY version: + + - +
+ Current kernel version: + + - +
+ Current U-Boot version: + + - +
+
+
+ + Upload file +
+
+ + Download from storage +
+
+
+
+
Upload and install a firmware file from your computer.
+
+
Choose file...
+
No file chosen
+
+
+
+
Download and install firmware from Digi Remote Manager storage.
+
+
+
Name
+
Path
+
Size
+
Last modified
+
+
+
Refresh
+
+
+
+
Firmware update in progress...
+
+
40%
+
+ Waiting for firmware update... +
+
+
Update Firmware
+
Cancel update
+
+
+
+
+
+
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/connectcore-demo-example/static/css/general.css b/connectcore-demo-example/static/css/general.css new file mode 100644 index 0000000..81487de --- /dev/null +++ b/connectcore-demo-example/static/css/general.css @@ -0,0 +1,2129 @@ +/* GENERAL */ +:root { + --digi-green: #84C361; + --digi-green-transparent: rgba(132, 195, 97, 0.5); + --digi-green-dark: #6E9C54; + --digi-gray: #717174; + --digi-light-gray: #E8E8E8; + --digi-gray-transparent: rgba(113, 113, 116, 0.3); + --white-transparent: rgba(255, 255, 255, 0.5); + --nav-img-size: 34px; + + --font-family-open-sans: "Open Sans", Arial, "sans serif"; +} + +@font-face { + font-family: 'Open Sans'; + src: local('Open Sans'), + url('../fonts/OpenSans-Regular.ttf') format('truetype'); +} + +html, body { + overflow: hidden; +} + +body { + font-family: var(--font-family-open-sans); +} + +.disabled-div { + pointer-events: none; + opacity: 0.4; +} + +.btn-primary { + background-color: var(--digi-green); + border: none; + color: white; + padding: 12px 80px; + text-align: center; + text-decoration: none; + display: inline-block; + text-transform: uppercase; + font-size: 14px; + -webkit-box-shadow: 0 10px 30px 0 rgba(132, 195, 97, 0.4); + box-shadow: 0 10px 30px 0 rgba(132, 195, 97, 0.4); + -webkit-border-radius: 5px 5px 5px 5px; + border-radius: 5px 5px 5px 5px; + -webkit-transition: all 0.3s ease-in-out; + -moz-transition: all 0.3s ease-in-out; + -ms-transition: all 0.3s ease-in-out; + -o-transition: all 0.3s ease-in-out; + transition: all 0.3s ease-in-out; + visibility: inherit; +} + +.btn-primary:hover, .btn-primary:active { + background-color: var(--digi-green) !important; + box-shadow: 0 0 0 .2rem var(--digi-green-transparent) !important; + color: white !important; +} + +.btn-primary:focus { + box-shadow: 0 0 0 .2rem var(--digi-green-transparent) !important; +} + +.btn-primary:disabled { + background-color: var(--digi-light-gray) !important; +} + +.element-grayed { + opacity: 20%; + background-color: white; + pointer-events: none; +} + +/* NAVIGATION BAR */ +.banner-icon, .devices-list-icon { + height: var(--nav-img-size); +} + +.devices-list-icon:hover { + opacity: 0.8; + color: var(--digi-green); +} + +#banner-text { + font-size: 20px; + line-height: 14px; + height: 14px; + margin: 0px; + color: var(--digi-gray); +} + +.navbar-brand { + padding-top: 2px; + padding-bottom: 2px; +} + +#topBar { + z-index: 1000; +} + +.dropdown-toggle, .widget-button { + background-color: transparent; + border: 0px solid transparent; + padding: 0px; +} + +.dropdown-toggle:focus, .widget-button:focus { + outline: 0; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.dropdown-toggle::after { + vertical-align: 0px; +} + +.dropdown-menu { + right: 0; + left: auto; + margin: 12px 0px; + border: 0px solid transparent; + border-radius: 0px; + padding: 2px 0px; +} + +.digi-gray .dropdown-toggle::after { + color: var(--digi-gray) +} + +.digi-green .dropdown-toggle::after { + color: var(--digi-green) +} + +.dropdown-item { + color: var(--digi-gray); +} + +.dropdown-item:hover { + background-color: var(--digi-gray-transparent); + color: var(--digi-gray); +} + +@media (min-width: 992px) { + .navbar-expand-lg > .nav-container { + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; + } +} +.navbar > .nav-container { + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + -ms-flex-align: center; + align-items: center; + -ms-flex-pack: justify; + justify-content: space-between; + width: 100%; + padding-right: 30px; + padding-left: 30px; + margin-right: auto; + margin-left: auto; +} + +.nav-right-container { + display: flex; +} + +.simulation-controls-container { + padding: 10px; + min-width: 300px; +} + +.widget-button { + margin-left: 5px; + margin-right: 5px; +} + +.vertical-separator { + border-left: 2px solid var(--digi-gray); + height: var(--nav-img-size); + margin-left: 20px; + margin-right: 20px; +} + +#device-name { + height: var(--nav-img-size); + font-size: 20px; + color: var(--digi-gray); + font-weight: bold; + padding-top: 4px; + margin: 0px 10px; +} + +.device-title-img { + padding-top: 6px; + width: 24px; +} +/* END NAVIGATION BAR */ + +/* SIDEBAR */ +#body-row { + margin-left:0; + margin-right:0; + height: calc( 100vh - var(--nav-img-size) - 20px ); /* height of the top toolbar or banner plus 20 px of padding */ + display: flex; +} + +#sidebar-container { + height: 100%; + background-color: var(--digi-gray); + padding: 0px; + box-shadow: 4px 0 0.25rem rgba(0,0,0,.075); + z-index: 999; +} + +/* Sidebar sizes when expanded and collapsed */ +.sidebar-expanded { + width: 230px; +} + +.sidebar-collapsed { + width: 60px; +} + +.sidebar-expanded, .sidebar-collapsed { + transition: width 0.2s; + -moz-transition: width 0.2s; /* Firefox 4 */ + -webkit-transition: width 0.2s; /* Safari and Chrome */ + -o-transition: width 0.2s; /* Opera */ +} + +#sidebar-contents { + height: 100%; + display: flex; + flex-direction: column; + white-space: nowrap; +} + +/* Menu item */ +#sidebar-container .list-group a { + height: 50px; + color: white; + background-color: var(--digi-gray); +} + +.list-group-item:first-child { + border-top-left-radius: 0px; + border-top-right-radius: 0px; +} + +.list-group-item:last-child { + border-bottom-right-radius: 0px; + border-bottom-left-radius: 0px; +} + +.list-group-item { + border: 0px solid transparent; + padding: 10px 17px; +} + +#sidebar-container #sections .selected { + background-color: white; + color: var(--digi-gray); +} + +#sidebar-container #sections a:hover, +#sidebar-container #collapsator > a:hover, +#sidebar-container #sections .selected:hover { + background-color: var(--digi-green); + color: white; +} + +/* Submenu item */ +#sidebar-container .list-group .sidebar-submenu a { + height: 45px; + padding-left: 30px; +} + +.sidebar-submenu { + font-size: 0.9rem; +} + +/* Separators */ +.sidebar-separator-title { + background-color: var(--digi-gray); + height: 35px; +} + +.sidebar-separator { + background-color: var(--digi-gray); + height: 25px; +} + +.logo-separator { + background-color: var(--digi-gray); + height: 60px; +} + +/* Submenu icon */ +#sidebar-container .list-group .list-group-item .submenu-icon::after { + font-family: FontAwesome; + display: inline; + text-align: right; + padding-left: 10px; +} + +/* Closed submenu icon */ +#sidebar-container .list-group .list-group-item[aria-expanded="false"] .submenu-icon::after { + content: " \f0d7"; +} + +/* Opened submenu icon */ +#sidebar-container .list-group .list-group-item[aria-expanded="true"] .submenu-icon::after { + content: " \f0da"; +} + +.digi-menu-icon { + min-width: 25px; + max-width: 25px; +} + +#collapsator { + height: 100%; +} + +#sidebar-container #collapsator > a { + margin-top: auto; + background-color: #4C4C4D; +} + +.icon-widget { + color: var(--digi-gray); +} + +.icon-widget:hover { + opacity: 0.8; +} + +.selected-icon-widget { + color: var(--digi-green); +} + +/* CONTENT */ + +/* LOADING */ +#loading { + width: 100%; + height: 100%; + position: relative; + z-index: 997; + text-align: center; +} + +#loading-image { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.loading-wrapper { + position: relative; + height: 100%; + z-index: 1; +} + +/* END LOADING */ + +/* POPUP */ +.popup { + z-index: 999; + position: absolute; + transform: translate(-50%, -50%); + background-color: white; + padding: 20px 10px; + border-radius: 15px; + top: 50%; + left: 50%; + text-align: center; + max-width: 800px; +} + +.popup i { + font-size: 1.3vw; +} + +.popup .popup-item { + width: 70%; +} + +.popup .popup-title, .popup .popup-text { + color: var(--digi-gray); +} + +.popup .popup-title { + font-size: 18px; + font-weight: bold; + margin-bottom: 15px; +} + +.popup-error-reconnect { + top: 35%; + z-index: 999; + padding: 20px 30px; +} +/* END POPUP */ + +/* CENTRAL CONTAINER */ +.container-fluid { + padding: 15px 60px; + overflow: auto; + font-size: 15px; +} + +.card { + padding: 10px; + margin: 8px 6px; + border: 0px solid transparent; + border-radius: 0px; + + transition: height 0.2s; + -moz-transition: height 0.2s; /* Firefox 4 */ + -webkit-transition: height 0.2s; /* Safari and Chrome */ + -o-transition: height 0.2s; /* Opera */ +} + +.card-body { + padding: 10px; +} + +.card-img-digi { + width: 100%; + border-radius: 0px; +} + +.column { + padding: 0px 10px; +} + +.column .card { + padding: 15px 0px 0px 0px; + margin: 8px 6px; + border: 0px solid transparent; + border-radius: 0px; + + transition: height 0.2s; + -moz-transition: height 0.2s; /* Firefox 4 */ + -webkit-transition: height 0.2s; /* Safari and Chrome */ + -o-transition: height 0.2s; /* Opera */ +} + +.column .card-body { + padding: 0px; +} + +.column .card .row { + margin-right: 0px; + margin-left: 0px; +} + +.column .card-title { + padding: 0px 15px 15px 15px; + border-bottom: 1px solid var(--digi-gray-transparent); + margin-bottom: 0px; +} + +.col, +.col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, +.col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, +.col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, +.col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, +.col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto { + padding-right: 0px; + padding-left: 0px; +} + +.card-title { + font-weight: bold; +} + +/* DEVICES */ +.devices-list-card { + flex: 1; + max-width: 650px; + margin: 0 auto !important; + border-radius: 10px 10px 10px 10px !important; + box-shadow: 0 30px 60px 0 rgb(0 0 0 / 30%); + align-items: center; + padding-bottom: 10px !important; +} + +.devices-list-container { + position: relative; + /* 35px of the header (19px of the h6 plus 15px of padding bottom plus 1px of border) */ + height: calc(100% - 35px); + width: 650px; +} + +.devices-list-title { + color: white; + width: 185px; + text-align: center; + font-size: 20px; + width: 100%; + padding: 5px 0px; + border-bottom: 1px solid white; +} + +.devices-list-entry { + max-width: inherit; + cursor: pointer; + padding: 10px 10px; + border-radius: 10px 10px 10px 10px; + margin: 5px; + white-space: normal; + background: var(--digi-light-gray); +} + +.devices-list-entry-selected { + background: var(--digi-green); +} + +.device-list-entry-status { + text-align: left; + width: 48px; + height: 48px; + margin-right: 5px; +} + +.device-list-entry-name { + text-align: left; + margin-right: 5px; + margin-left: 10px; + font-size: 16px; + font-weight: bold; +} + +.device-list-entry-id { + text-align: left; + margin-right: 5px; + margin-left: 10px; + font-size: 14px; +} + +.devices-list-entry:hover { + background-color: var(--digi-green); +} + +.devices-list { + overflow-y: auto; + width: 100%; + /* This height is to set the "Continue" button at the bottom and the header at the top. + The height of the div is 100% of its parent minus 60px of the "Continue" button plus 60px + of the "Add device" section. */ + height: calc(100% - 60px - 60px); + max-height: 740px; + padding: 10px; +} + +.add-device-dialog { + position: absolute; + width: 100%; + height: 100%; + z-index: 999; + top: 0px; + visibility: hidden; +} + +.add-device-background { + background-color: #FFFFFF; + position: absolute; + width: 100%; + height: 100%; + opacity: 0.7; +} + +.add-device-container { + background-color: white; + position: absolute; + left: 15%; + top: 25%; + width: 70%; + min-height: 200px; + -webkit-box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); +} + +.add-device-label { + position: relative; + padding-bottom: 10px; + padding-top: 10px; + padding-right: 10px; + left: 7.5%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.add-device-input { + position: relative; + left: 7.5%; + font-size: 16px !important; + -webkit-transition: none !important; + -moz-transition: none !important; + -ms-transition: none !important; + -o-transition: none !important; + transition: none !important; +} + +.add-device-input-error { + background-color: #f3b1b1 !important; +} + +.add-device-error { + color: red; + font-size: 12px; + font-style: italic; + margin-top: -20px; + margin-bottom: 5px; + padding-left: 10px; + padding-right: 10px; + position: relative; +} + +.add-device-button { + position: relative; + left: 30%; + width: 40% !important; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + margin-bottom: 10px; +} + +.add-device-button-disabled { + cursor: default; + color: white; + background-color: #c3c3c3 !important; + pointer-events: none; +} + +.register-device-container { + position: relative; + width: 100%; + height: 60px; + margin-top: 15px; +} + +.register-device-description { + position: relative; + float: left; + width: 60%; + padding-left: 15px; +} + +.register-device-button { + float: left; + height: 35px; + width: 30%; + margin-top: 7px; + margin-left: 5%; + border: none; + color: white; + background-color: var(--digi-gray); + font-weight: bold; + display: flex; + justify-content: center; + align-items: center; + bottom: 0px; +} + +.register-device-button:hover { + cursor: pointer; + background-color: var(--digi-green); +} + +.register-device-button:active { + border: none; + cursor: pointer; + background-color: var(--digi-green); +} + +.devices-buttons-container { + width: 100%; + text-align: center; + margin-top: 10px; + height: 60px; +} +/* END DEVICES */ + +/* DASHBOARD */ +.dashboard-top-panel { + min-height: 20%; +} + +.device-board { + overflow-y: auto; + overflow-x: hidden; + display: flex; + flex-direction: column; + background-color: transparent; +} + +.device-board-container { + background-color: white; +} + +.device-board-image { + object-fit: contain; +} + +.device-error, .device-board { + position: absolute; + width: 100%; + height: 100%; +} + +.device-error { + padding-top: 300px; + text-align: center; + font-weight: bold; + color: #BD362F; + font-size: 18px; + background-color: rgba(255, 255, 255, 0.85); + display: none; +} + +.main-row { + display: flex; + flex-flow: column; + height: 89vh; + min-height: 600px; +} + +.main-row .dashboard-device-card, +.main-row { + flex: 1; +} + +.dashboard-device-card { + padding: 0px !important; + background-color: transparent; +} + +.dashboard-device { + position: relative; + height: 100%; + overflow: auto; + min-width: 630px; +} + +.device-info { + flex: 1; + margin-top: 20px; +} + +.device-card { + background-color: white; + position: absolute; + z-index: 90; + top: 0px; + left: 0px; + bottom: 0px; + right: 0px; + visibility: collapse; +} + +.device-card-header { + background-color: var(--digi-gray); + color: white; + padding: 5px 10px; + align-items: center; + font-size: 16px; + font-weight: bold; +} + +.device-card-header-button { + margin-top: 4px; + float: right; + cursor: pointer; +} + +.device-card-header-button:hover { + color: var(--digi-green); +} + +.device-card-content { + background-color: white; + color: var(--digi-gray); + padding: 8px; +} + +.device-card-content .table { + width: 100%; + table-layout: fixed; + padding: 5px 0px; +} + +.device-card-content-text { + font-weight: bold; +} + +.device-card-content-value { + margin-left: 10px; + font-weight: 100; +} + +.device-card-button { + height: 35px; + width: 100%; + color: white; + background-color: var(--digi-gray); + font-weight: bold; + display: flex; + justify-content: center; + align-items: center; + bottom: 0px; +} + +.device-card-button p { + margin: 0; +} + +.device-card-button:hover { + background-color: var(--digi-green); + cursor: pointer; +} + +.device-card-button:active { + color: var(--digi-gray); + background-color: white; +} + +.value-updated { + color: var(--digi-green); + font-weight: 1000; + visibility: inherit; +} + +.value-animation { + transition: all 1.5s; + visibility: inherit; +} + +.panel-arrow { + z-index: -99; + content: ""; + width: 0; + height: 0; + transform: rotate(-45deg); + position: absolute; + border: 20px solid #fff; +} + +.panel-area { + z-index: 2; + width: 0px; + height: 0px; + top: 0px; + left: 0px; + position: absolute; + background-color: #84c361b3; + border: 2px solid #004e03; + color: #004e03; +} + +.panel-area:hover { + background-color: #f5e04eb3; + cursor: pointer; + border: 2px solid white; +} + +.panel-area-selected { + background-color: #aeaeffb3; + border: 2px solid #4f0097; +} + +.panel-area-icon { + position: absolute; + display: inline-block; + font-size: 2vw; + color: inherit; + width: 100%; + height: 100%; + text-align: center; + vertical-align: bottom; + opacity: 0.8; + line-height: inherit !important; + visibility: hidden; +} + +.panel-area-icon:hover { + color: white; +} + +.panel-area-icon-selected { + background-color: #aeaeffb3; + color: #4f0097; +} + +.box { + height: 35px; + width: 60px; +} + +.small-title { + font-size: 16px; + font-weight: bold; + display: block; + clear: both; + margin-bottom: 8px; +} + +.status { + padding: 0px 15px; +} + +.digi-icon-color { + color: var(--digi-gray); + display: inline-block; + margin-bottom: 10px; + vertical-align: middle; +} + +/* TOOLTIP */ +/* Tooltip container */ +.panel-tooltip { + display: inline-block; +} + +.panel-tooltip:hover { + z-index: 100; +} + +/* Tooltip text */ +.panel-tooltip-text { + visibility: hidden; + width: 120px; + background-color: #555; + color: #fff; + text-align: center; + padding: 5px 0; + border-radius: 6px; + + /* Position the tooltip text */ + position: absolute; + z-index: 999; + bottom: 110%; + left: 50%; + margin-left: -60px; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; +} + +/* Tooltip arrow */ +.panel-tooltip-text::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; +} + +/* Show the tooltip text when you mouse over the tooltip container */ +.panel-tooltip:hover .panel-tooltip-text { + visibility: visible; + opacity: 1; +} +/* END TOOLTIP */ + +/* CPU STATUS */ +.cpu-panel { + width: 280px; +} + +.cpu-info { + +} + +.core-info-icon { + padding-right: 1.2vw; + text-align: right; +} + +.cores { + background-color: #EEEEEE; + visibility: collapse; +} + +.core { + padding-left: 5px; + font-size: 16px; + color: var(--digi-gray); +} + +#core-2, #core-4 { + background-color: white; +} + +.core-table { + width: 100%; + table-layout: fixed; + padding: 5px 0px; +} + +.core-name-container { + padding-top: 10px; +} +/* END CPU STATUS */ + +/* MEMORY */ +.memory-panel { + width: 250px; +} +/* END MEMORY */ + +/* FLASH MEMORY */ +.flash-memory-panel { + width: 280px; +} +/* END FLASH MEMORY */ + +/* WIFI */ +.wifi-panel { + width: 280px; +} +/* END WIFI */ + +/* ETHERNET */ +.ethernet-panel { + width: 280px; +} +/* END ETHERNET */ + +/* VIDEO */ +.video-panel { + width: 400px; +} + +.slider-selection { + background: #56b1f5; +} + +.slider-disabled .slider-selection { + background: #BABABA; +} +/* END VIDEO */ + +/* AUDIO */ +.audio-panel { + width: 350px; +} + +#audio_panel .slider-horizontal { + width: 180px; +} +/* END AUDIO */ + +/* CONSOLE */ +.console-panel { + position: absolute; + z-index: 999; + width: 100%; + height: 100%; + top: 0px; + left: 0px; + visibility: collapse; + display: flex; + align-items: center; + justify-content: center; +} + +.console-background { + background-color: #FFFFFF; + position: absolute; + width: 100%; + height: 100%; + opacity: 0.7; + visibility: inherit; +} + +.console-container { + position: absolute; + width: 90%; + max-height: 80%; + top: 10%; + margin: 0 auto; + -webkit-box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); +} + +.console-hover-background { + background-color: #FFFFFF; + position: absolute; + top: 34px; + width: 100%; + height: 100%; + opacity: 0.7; + z-index: 998; +} + +.console-error-text { + color: var(--digi-gray); + font-size: 16px; +} + +.console-error-buttons-container { + width: 100%; + text-align: center; + margin-top: 10px; + display: flex; + visible: inherit; +} +/* END CONSOLE */ + +/* LED */ +.led-panel { + position: absolute; + z-index: 2; + top: 0px; + left: 0px; + bottom: 0px; + right: 0px; + width: 4%; + visibility: collapse; +} + +.led-panel:hover { + cursor: pointer; +} + +.led-image { + position: relative; + max-width:100%; + max-height:100%; +} + +.led-panel-area-off { + z-index: 2; + width: 0px; + height: 0px; + top: 0px; + left: 0px; + position: absolute; + background-color: #d5d5d5b3; + border: 2px solid #3c3c3c; +} + +.led-panel-area-on { + background-color: white; + border: 3px solid rgb(255, 235, 0); + box-shadow: rgb(255 235 0) 0px 0px 30px 15px; +} + +/* LED END */ + +/* FILE SYSTEM */ +.filesystem-explore-button { + width: 80%; + margin-top: 10px; + margin-left: 10%; + margin-bottom: 5px; +} + +.filesystem-panel { + position: absolute; + z-index: 999; + width: 100%; + height: 100%; + top: 0px; + left: 0px; + visibility: collapse; + display: flex; + align-items: center; + justify-content: center; +} + +.filesystem-background { + background-color: #FFFFFF; + position: absolute; + width: 100%; + height: 100%; + opacity: 0.7; + visibility: inherit; +} + +.filesystem-container { + position: absolute; + width: 90%; + height: 70%; + top: 10%; + margin: 0 auto; + background: white; + -webkit-box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); +} + +.filesystem-hover-background { + background-color: #FFFFFF; + position: absolute; + top: 34px; + width: 100%; + height: 100%; + opacity: 0.7; + z-index: 998; +} + +.filesystem-dir-name-panel { + position: absolute; + width: 100%; + height: 100%; + z-index: 999; + top: 0px; + visibility: hidden; +} + +.filesystem-dir-name-background { + background-color: #FFFFFF; + position: absolute; + width: 100%; + height: 100%; + opacity: 0.7; +} + +.filesystem-dir-name-container { + background-color: white; + position: absolute; + left: 30%; + top: 25%; + width: 40%; + height: 200px; + -webkit-box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); +} + +.filesystem-dir-name-label { + position: relative; + padding-bottom: 10px; + padding-top: 10px; + padding-right: 10px; + left: 7.5%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.filesystem-dir-name-input { + position: relative; + left: 7.5%; + -webkit-transition: none !important; + -moz-transition: none !important; + -ms-transition: none !important; + -o-transition: none !important; + transition: none !important; +} + +.filesystem-dir-name-input-error { + background-color: #f3b1b1 !important; +} + +.filesystem-dir-name-error { + color: red; + font-size: 12px; + font-style: italic; + margin-top: -20px; + margin-bottom: 5px; + left: 7.5%; + position: relative; +} + +.filesystem-dir-name-button { + position: relative; + left: 30%; + width: 40%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.filesystem-dir-name-button-disabled { + cursor: default; + color: white; + background-color: #c3c3c3; + pointer-events: none; +} + +.filesystem-toolbar { + position: relative; + background-color: #FFFFFF; + width: 100%; + background-color: var(--digi-light-gray); + color: black; + height: 40px; +} + +.filesystem-toolbar-buttons-container { + position: relative; + float: right; + padding-right: 5px; + width: 170px; +} + +.filesystem-button { + padding: 5px; + cursor: pointer; + color: var(--digi-gray); + margin-bottom: 0; +} + +.filesystem-button-disabled { + cursor: default; + color: #c3c3c3; + pointer-events: none; +} + +.filesystem-button:hover { + color: var(--digi-green); +} + +.filesystem-current-directory-container { + position: relative; + height: 100%; + max-width: 80%; + float: left; + padding-left: 5px; + padding-right: 5px; + color: var(--digi-gray); + width: calc(100% - 170px); +} + +.filesystem-current-directory-label { + position: relative; + float: left; + font-weight: 800; + white-space: nowrap; + padding-top: 10px; +} + +.filesystem-current-directory { + position: relative; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + padding-left: 10px; + padding-top: 10px; +} + +.filesystem-items-container { + position: relative; + background-color: #FFFFFF; + width: 100%; + overflow-x: hidden; + overflow-y: auto; +} + +.filesystem-items-header { + width: 100%; + height: 30px; + background-color: var(--digi-gray); + display: flex; + align-items: center; + color: white; + font-size: 16px; + font-weight: 800; +} + +.filesystem-entry { + width: 100%; + height: 30px; + background-color: #FFFFFF; + cursor: pointer; + display: flex; + align-items: center; + color: var(--digi-gray); +} + +.filesystem-entry:hover { + color: white; + background-color: var(--digi-green); +} + +.filesystem-entry-selected { + color: white; + background-color: #aeaeff; +} + +.filesystem-entry-icon { + position: relative; + width: 4%; + min-width: 32px; + float: left; + padding-left: 5px; +} + +.filesystem-entry-name { + position: relative; + width: 48%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.filesystem-entry-size { + position: relative; + width: 23%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.filesystem-entry-last-modified { + position: relative; + width: 25%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +/* END FILE SYSTEM */ + +/* DATA USAGE */ +.data-usage-panel { + background-color: white; + position: absolute; + z-index: 90; + top: 54px; + right: 120px; + position: absolute; + width: 320px; + height: 370px; + -webkit-box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + color: var(--digi-gray); +} + +.data-usage-panel-wrapper { + z-index: 90; + position: relative; + width: 100%; + height: 100%; +} + +.data-usage-loading { + z-index: 91; + position: absolute; + width: 100%; + height: 100%; +} + +.data-usage-loading-background { + z-index: 91; + position: absolute; + width: 100%; + height: 100%; + background-color: white; + pointer-events: none; + opacity: 90%; +} + +.data-usage-loading-icon { + z-index: 92; + position: relative; + width: 40%; + left: 30%; + top: 20%; +} + +.data-usage-loading-text { + z-index: 92; + position: relative; + text-align: center; + margin-top: 70px; +} + +.data-usage-content { + position: absolute; + width: 100%; + height: 100%; + padding: 10px; +} + +.data-usage-header { + position: relative; + width: 100%; + height: 30px; +} + +.data-usage-section { + position: relative; + width: 100%; +} + +.data-usage-title { + position: relative; + float: left; + font-size: 18px; + font-weight: 800; +} + +.data-usage-total-value { + font-size: 22px; + text-align: center; + margin-top: 10px; +} + +.data-usage-graphic-container { + width: 100%; + height: 30px; +} + +.data-usage-graphic { + position: relative; + float: left; + width: 0px; + height: 100%; + transition: width 1.5s; + outline: none; + border: none; + padding: 0px; +} + +.data-usage-graphic:hover, .data-usage-graphic:active { + cursor: pointer; + color: var(--digi-green); + outline: none; +} + +.data-usage-graphic:focus { + border: none !important; + background-color: white !important; + outline: none; +} + +.data-usage-graphic-web { + background-color: #257da2; +} + +.data-usage-graphic-web:hover, .data-usage-graphic-web:active, .data-usage-graphic-web:focus { + background-color: #257da2 !important; + border: 2px solid #1a5e7a !important; +} + +.data-usage-graphic-devices { + background-color: #5fad56; +} + +.data-usage-graphic-devices:hover, .data-usage-graphic-devices:active, .data-usage-graphic-devices:focus { + background-color: #5fad56 !important; + border: 2px solid #3b6c36 !important; +} + +.data-usage-values-container { + position: relative; + width: 100%; + padding: 8px; +} + +.data-usage-legend { + width: 30px; + height: 10px; +} + +.data-usage-legend-text { + font-size: 12px; + padding-left: 5px; +} + +.data-usage-value-label { + font-size: 14px; + width: 170px; +} + +.data-usage-value-label-bold { + font-size: 14px; + width: 170px; + font-weight: 800; +} + +.data-usage-value { + font-size: 14px; + padding-left: 10px; +} + +.data-usage-value-bold { + font-size: 14px; + font-weight: 800; + padding-left: 10px; +} + +/* END DATA USAGE */ + +/* HELP */ +.help-panel-area { + position: absolute; + background-color: #fff; + border: 5px solid #717174; + height: 50px; + width: 50px; + right: 15px; + top: 50px; + color: #717174; + border-radius: 50%; + -moz-border-radius: 50%; + -webkit-border-radius: 50%; +} + +.help-panel-area:hover { + color: white; + border-color: var(--digi-green); + background-color: var(--digi-green); + cursor: pointer; +} + +.help-panel { + background-color: #f5ed95; + position: absolute; + z-index: 90; + top: 125px; + right: 10px; + position: absolute; + visibility: hidden; + width: 400px; + min-height: 100px; + border-radius: 25px 11px 25px 25px; + -moz-border-radius: 25px 11px 25px 25px; + -webkit-border-radius: 25px 11px 25px 25px; +} + +.help-arrow { + z-index: -99; + content: ""; + width: 0; + height: 0; + transform: rotate(-45deg); + position: absolute; + border: 20px solid #f5ed95; + right: 10px; + top: -15px; +} + +.help-panel-content { + padding: 17px; +} + +.help-panel-button { + position: relative; + width: 50%; + margin: 0 auto; + margin-top: 15px; + margin-bottom: 5px; + height: 35px; + color: white; + background-color: #efa614; + font-weight: bold; + display: flex; + justify-content: center; + align-items: center; +} + +.help-panel-button:hover { + color: white; + background-color: var(--digi-green); + cursor: pointer; +} +/* END HELP */ + +/* CONFIRM DIALOG */ +.confirm-dialog { + background-color: white; + position: absolute; + z-index: 999; + left: 30%; + top: 25%; + width: 40%; + height: 200px; + -webkit-box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); + box-shadow: 0 10px 30px 0 rgb(0 0 0 / 40%); +} + +.confirm-dialog-message { + position: relative; + padding: 10px; + height: 55%; +} + +.confirm-dialog-buttons-container { + position: relative; + width: 100%; + display: flex; + justify-content: center; + align-items: center; +} + +.confirm-dialog-button { + position: relative; + float: left; + width: 30%; + margin-left: 10px; + margin-right: 10px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} +/* END CONFIRM DIALOG */ + +/* DEVICE TOOLBAR */ +.device-toolbar { + min-height: 42px; + background-color: var(--digi-gray); +} + +.platform-name { + float: left; + color: white; + padding-top: 7px; + padding-left: 10px; + font-size: 20px; + font-weight: bold; +} + +.samples-info-container { + position: relative; + float: right; + color: white; + padding-left: 10px; + padding-right: 10px; + font-size: 13px; + text-align: right; + margin-top: 2px; + overflow: hidden; +} + +.samples-info-container td { + padding: 0; + margin: 0; +} + +.samples-info-overlay { + position: absolute; + height: 100%; + width: 100%; + right: 0; + top: 0; +} + +.samples-info-container:hover { + cursor: pointer; + color: var(--digi-green); +} + +.device-button { + float: right; + padding: 5px; + margin-left: 5px; + margin-right: 5px; + cursor: pointer; +} +/* END DEVICE TOOLBAR */ + +/* HISTORY */ +.chart-container { + color: #666666; + padding: 20px 0px 20px 0px; +} + +.chart-wrapper { + position: relative; +} + +.big-chart { + width: 100%; + min-height: 300px; + padding: 20px; +} + +.chart-loading { + position: absolute; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(255, 255, 255, 0.85); +} + +.loading-chart-image, .no-data-label { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); +} +/* END HISTORY */ + +/* MANAGEMENT */ +.system-monitor-param-container { + margin-top: 10px; + width: 100%; + padding-left: 10px; +} + +.system-monitor-param-label { + display: inline-block; + position: relative; + width: 170px; +} + +.system-monitor-input { + position: relative; + -webkit-transition: none !important; + -moz-transition: none !important; + -ms-transition: none !important; + -o-transition: none !important; + transition: none !important; + width: 80px !important; + padding: 0px !important; + margin: 0px !important; +} + +.system-monitor-input-error { + background-color: #f3b1b1 !important; +} + +.system-monitor-error { + color: red; + font-size: 12px; + font-style: italic; + position: relative; + padding-left: 10px; +} + +.system-monitor-help { + font-size: 16px; + padding-left: 5px; + color: var(--digi-gray); + border: none; + background-color: white; + outline: none; +} + +.system-monitor-help:hover, .system-monitor-help:active { + cursor: pointer; + color: var(--digi-green); + outline: none; +} + +.system-monitor-help:focus { + border: none !important; + background-color: white !important; + outline: none; +} + +.system-monitor-save { + padding: 5px; + cursor: pointer; + margin-bottom: 0; + margin-top: 15px; + width: 100px; +} + +.system-monitor-save-disabled { + cursor: default; + color: white; + background-color: #c3c3c3; + pointer-events: none; +} + +.firmware-file-input { + position: relative; + margin-top: 15px; +} + +.reboot-button { + padding: 5px; + cursor: pointer; + margin-bottom: 0; + width: 150px; + margin-top: 15px; +} + +.firmware-file-container { + position: relative; + margin-top: 15px; + width: 100%; + display: flex; +} + +.browse-firmware-button { + position: relative; + float: left; + width: 180px; +} + +.firmware-file-label { + position: relative; + float: left; + margin-left: 10px; + margin-top: 5px; +} + +.update-firmware-button { + padding: 5px; + cursor: pointer; + margin-bottom: 0; + width: 250px; + margin-top: 25px; + float: left; + background-color: #00b7ff; +} + +.cancel-firmware-update-button { + padding: 5px; + cursor: pointer; + margin-bottom: 0; + width: 250px; + margin-top: 25px; + margin-left: 15px; + float: left; + background-color: #a72a2a; +} + +.management-button-disabled { + cursor: default; + color: #c3c3c3; + background-color: #e3e3e3; + pointer-events: none; +} + +.update-firmware-progress { + position: relative; + margin-top: 15px; + width: 100%; + display: none; +} + +.update-firmware-progress-title { + position: relative; + margin-top: 15px; + margin-bottom: 10px; + width: 100%; + font-weight: bold; + font-size: 16px; +} + +.update-firmware-progress-status { + position: relative; + margin-top: 15px; + width: 100%; + font-style: italic; + font-size: 14px; +} + +.update-firmware-progress-bar { + height: 20px; + font-size: 12px; + font-weight: bold; + background-color: #e3e3e3; +} + +.update-firmware-progress-bar-hover { + animation: progress-bar-stripes 2s linear infinite; +} + +.update-firmware-progress-bar-info { + background-color: #5bc0de; +} + +.update-firmware-progress-bar-error { + background-color: #d45854; +} + +.update-firmware-progress-bar-success { + background-color: #5cb85c; +} + +.firmware-tabs { + position: relative; + margin-top: 15px; + width: 100%; + height: 50px; + display: block; +} + +.firmware-tab-header { + display: block; + position: relative; + float: left; + border: none; + border-bottom: 1px solid #f2f2f2; + padding: 10px; + cursor: pointer; + color: #00b7ff; +} + +.firmware-tab-header:hover { + color: var(--digi-green); +} + +.firmware-tab-header-active { + border: 1px solid #f2f2f2; + border-bottom: none; + color: var(--digi-gray); + cursor: default; + pointer-events: none; +} + +.firmware-tab-container { + position: relative; + width: 100%; +} + +.firmware-tab { + position: relative; + width: 100%; + padding-left: 15px; + padding-right: 15px; +} + +.firmware-tab-upload { + display: block; +} + +.firmware-tab-fileset { + display: none; +} + +.fileset-items-header { + width: 100%; + height: 30px; + background-color: var(--digi-gray); + display: flex; + align-items: center; + color: white; + font-size: 16px; + font-weight: 800; + margin-top: 15px; +} + +.fileset-items-container { + position: relative; + background-color: #FFFFFF; + width: 100%; + overflow-x: hidden; + overflow-y: auto; + min-height: 50px; + max-height: 250px; + border: solid 1px var(--digi-gray); +} + +.fileset-entry { + width: 100%; + height: 30px; + background-color: #FFFFFF; + cursor: pointer; + display: flex; + align-items: center; + color: var(--digi-gray); +} + +.fileset-entry:hover { + color: white; + background-color: var(--digi-green); +} + +.fileset-entry-selected { + color: white; + background-color: #aeaeff; +} + +.fileset-entry-icon { + position: relative; + width: 4%; + min-width: 32px; + float: left; + padding-left: 5px; +} + +.fileset-entry-name { + position: relative; + width: 25%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.fileset-entry-path { + position: relative; + width: 41%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.fileset-entry-size { + position: relative; + width: 10%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.fileset-entry-last-modified { + position: relative; + width: 20%; + float: left; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.refresh-fileset-button { + padding: 5px; + cursor: pointer; + margin-bottom: 0; + width: 150px; + margin-top: 5px; +} +/* END MANAGEMENT */ diff --git a/connectcore-demo-example/static/css/toastr.css b/connectcore-demo-example/static/css/toastr.css new file mode 100644 index 0000000..65c9fea --- /dev/null +++ b/connectcore-demo-example/static/css/toastr.css @@ -0,0 +1,228 @@ +.toast-title { + font-weight: bold; +} +.toast-message { + -ms-word-wrap: break-word; + word-wrap: break-word; +} +.toast-message a, +.toast-message label { + color: #FFFFFF; +} +.toast-message a:hover { + color: #CCCCCC; + text-decoration: none; +} +.toast-close-button { + position: relative; + right: -0.3em; + top: -0.3em; + float: right; + font-size: 20px; + font-weight: bold; + color: #FFFFFF; + -webkit-text-shadow: 0 1px 0 #ffffff; + text-shadow: 0 1px 0 #ffffff; + opacity: 0.8; + -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); + filter: alpha(opacity=80); + line-height: 1; +} +.toast-close-button:hover, +.toast-close-button:focus { + color: #000000; + text-decoration: none; + cursor: pointer; + opacity: 0.4; + -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40); + filter: alpha(opacity=40); +} +.rtl .toast-close-button { + left: -0.3em; + float: left; + right: 0.3em; +} +/*Additional properties for button version + iOS requires the button element instead of an anchor tag. + If you want the anchor version, it requires `href="#"`.*/ +button.toast-close-button { + padding: 0; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; +} +.toast-top-center { + top: 0; + right: 0; + width: 100%; +} +.toast-bottom-center { + bottom: 0; + right: 0; + width: 100%; +} +.toast-top-full-width { + top: 0; + right: 0; + width: 100%; +} +.toast-bottom-full-width { + bottom: 0; + right: 0; + width: 100%; +} +.toast-top-left { + top: 12px; + left: 12px; +} +.toast-top-right { + top: 12px; + right: 12px; +} +.toast-bottom-right { + right: 12px; + bottom: 12px; +} +.toast-bottom-left { + bottom: 12px; + left: 12px; +} +#toast-container { + position: fixed; + z-index: 999999; + pointer-events: none; + /*overrides*/ +} +#toast-container * { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} +#toast-container > div { + position: relative; + pointer-events: auto; + overflow: hidden; + margin: 0 0 6px; + padding: 15px 15px 15px 50px; + width: 300px; + -moz-border-radius: 3px 3px 3px 3px; + -webkit-border-radius: 3px 3px 3px 3px; + border-radius: 3px 3px 3px 3px; + background-position: 15px center; + background-repeat: no-repeat; + -moz-box-shadow: 0 0 12px #999999; + -webkit-box-shadow: 0 0 12px #999999; + box-shadow: 0 0 12px #999999; + color: #FFFFFF; + opacity: 0.8; + -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); + filter: alpha(opacity=80); +} +#toast-container > div.rtl { + direction: rtl; + padding: 15px 50px 15px 15px; + background-position: right 15px center; +} +#toast-container > div:hover { + -moz-box-shadow: 0 0 12px #000000; + -webkit-box-shadow: 0 0 12px #000000; + box-shadow: 0 0 12px #000000; + opacity: 1; + -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); + filter: alpha(opacity=100); + cursor: pointer; +} +#toast-container > .toast-info { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVEhLtZa9SgNBEMc9sUxxRcoUKSzSWIhXpFMhhYWFhaBg4yPYiWCXZxBLERsLRS3EQkEfwCKdjWJAwSKCgoKCcudv4O5YLrt7EzgXhiU3/4+b2ckmwVjJSpKkQ6wAi4gwhT+z3wRBcEz0yjSseUTrcRyfsHsXmD0AmbHOC9Ii8VImnuXBPglHpQ5wwSVM7sNnTG7Za4JwDdCjxyAiH3nyA2mtaTJufiDZ5dCaqlItILh1NHatfN5skvjx9Z38m69CgzuXmZgVrPIGE763Jx9qKsRozWYw6xOHdER+nn2KkO+Bb+UV5CBN6WC6QtBgbRVozrahAbmm6HtUsgtPC19tFdxXZYBOfkbmFJ1VaHA1VAHjd0pp70oTZzvR+EVrx2Ygfdsq6eu55BHYR8hlcki+n+kERUFG8BrA0BwjeAv2M8WLQBtcy+SD6fNsmnB3AlBLrgTtVW1c2QN4bVWLATaIS60J2Du5y1TiJgjSBvFVZgTmwCU+dAZFoPxGEEs8nyHC9Bwe2GvEJv2WXZb0vjdyFT4Cxk3e/kIqlOGoVLwwPevpYHT+00T+hWwXDf4AJAOUqWcDhbwAAAAASUVORK5CYII=") !important; +} +#toast-container > .toast-error { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHOSURBVEhLrZa/SgNBEMZzh0WKCClSCKaIYOED+AAKeQQLG8HWztLCImBrYadgIdY+gIKNYkBFSwu7CAoqCgkkoGBI/E28PdbLZmeDLgzZzcx83/zZ2SSXC1j9fr+I1Hq93g2yxH4iwM1vkoBWAdxCmpzTxfkN2RcyZNaHFIkSo10+8kgxkXIURV5HGxTmFuc75B2RfQkpxHG8aAgaAFa0tAHqYFfQ7Iwe2yhODk8+J4C7yAoRTWI3w/4klGRgR4lO7Rpn9+gvMyWp+uxFh8+H+ARlgN1nJuJuQAYvNkEnwGFck18Er4q3egEc/oO+mhLdKgRyhdNFiacC0rlOCbhNVz4H9FnAYgDBvU3QIioZlJFLJtsoHYRDfiZoUyIxqCtRpVlANq0EU4dApjrtgezPFad5S19Wgjkc0hNVnuF4HjVA6C7QrSIbylB+oZe3aHgBsqlNqKYH48jXyJKMuAbiyVJ8KzaB3eRc0pg9VwQ4niFryI68qiOi3AbjwdsfnAtk0bCjTLJKr6mrD9g8iq/S/B81hguOMlQTnVyG40wAcjnmgsCNESDrjme7wfftP4P7SP4N3CJZdvzoNyGq2c/HWOXJGsvVg+RA/k2MC/wN6I2YA2Pt8GkAAAAASUVORK5CYII=") !important; +} +#toast-container > .toast-success { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADsSURBVEhLY2AYBfQMgf///3P8+/evAIgvA/FsIF+BavYDDWMBGroaSMMBiE8VC7AZDrIFaMFnii3AZTjUgsUUWUDA8OdAH6iQbQEhw4HyGsPEcKBXBIC4ARhex4G4BsjmweU1soIFaGg/WtoFZRIZdEvIMhxkCCjXIVsATV6gFGACs4Rsw0EGgIIH3QJYJgHSARQZDrWAB+jawzgs+Q2UO49D7jnRSRGoEFRILcdmEMWGI0cm0JJ2QpYA1RDvcmzJEWhABhD/pqrL0S0CWuABKgnRki9lLseS7g2AlqwHWQSKH4oKLrILpRGhEQCw2LiRUIa4lwAAAABJRU5ErkJggg==") !important; +} +#toast-container > .toast-warning { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGYSURBVEhL5ZSvTsNQFMbXZGICMYGYmJhAQIJAICYQPAACiSDB8AiICQQJT4CqQEwgJvYASAQCiZiYmJhAIBATCARJy+9rTsldd8sKu1M0+dLb057v6/lbq/2rK0mS/TRNj9cWNAKPYIJII7gIxCcQ51cvqID+GIEX8ASG4B1bK5gIZFeQfoJdEXOfgX4QAQg7kH2A65yQ87lyxb27sggkAzAuFhbbg1K2kgCkB1bVwyIR9m2L7PRPIhDUIXgGtyKw575yz3lTNs6X4JXnjV+LKM/m3MydnTbtOKIjtz6VhCBq4vSm3ncdrD2lk0VgUXSVKjVDJXJzijW1RQdsU7F77He8u68koNZTz8Oz5yGa6J3H3lZ0xYgXBK2QymlWWA+RWnYhskLBv2vmE+hBMCtbA7KX5drWyRT/2JsqZ2IvfB9Y4bWDNMFbJRFmC9E74SoS0CqulwjkC0+5bpcV1CZ8NMej4pjy0U+doDQsGyo1hzVJttIjhQ7GnBtRFN1UarUlH8F3xict+HY07rEzoUGPlWcjRFRr4/gChZgc3ZL2d8oAAAAASUVORK5CYII=") !important; +} +#toast-container.toast-top-center > div, +#toast-container.toast-bottom-center > div { + width: 300px; + margin-left: auto; + margin-right: auto; +} +#toast-container.toast-top-full-width > div, +#toast-container.toast-bottom-full-width > div { + width: 96%; + margin-left: auto; + margin-right: auto; +} +.toast { + background-color: #030303; +} +.toast-success { + background-color: #51A351; +} +.toast-error { + background-color: #BD362F; +} +.toast-info { + background-color: #2F96B4; +} +.toast-warning { + background-color: #F89406; +} +.toast-progress { + position: absolute; + left: 0; + bottom: 0; + height: 4px; + background-color: #000000; + opacity: 0.4; + -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40); + filter: alpha(opacity=40); +} +/*Responsive Design*/ +@media all and (max-width: 240px) { + #toast-container > div { + padding: 8px 8px 8px 50px; + width: 11em; + } + #toast-container > div.rtl { + padding: 8px 50px 8px 8px; + } + #toast-container .toast-close-button { + right: -0.2em; + top: -0.2em; + } + #toast-container .rtl .toast-close-button { + left: -0.2em; + right: 0.2em; + } +} +@media all and (min-width: 241px) and (max-width: 480px) { + #toast-container > div { + padding: 8px 8px 8px 50px; + width: 18em; + } + #toast-container > div.rtl { + padding: 8px 50px 8px 8px; + } + #toast-container .toast-close-button { + right: -0.2em; + top: -0.2em; + } + #toast-container .rtl .toast-close-button { + left: -0.2em; + right: 0.2em; + } +} +@media all and (min-width: 481px) and (max-width: 768px) { + #toast-container > div { + padding: 15px 15px 15px 50px; + width: 25em; + } + #toast-container > div.rtl { + padding: 15px 50px 15px 15px; + } +} \ No newline at end of file diff --git a/connectcore-demo-example/static/css/xterm.css b/connectcore-demo-example/static/css/xterm.css new file mode 100644 index 0000000..923c27b --- /dev/null +++ b/connectcore-demo-example/static/css/xterm.css @@ -0,0 +1,187 @@ +/** + * Copyright (c) 2014 The xterm.js authors. All rights reserved. + * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) + * https://github.com/chjj/term.js + * @license MIT + * + * 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. + * + * Originally forked from (with the author's permission): + * Fabrice Bellard's javascript vt100 for jslinux: + * http://bellard.org/jslinux/ + * Copyright (c) 2011 Fabrice Bellard + * The original design remains. The terminal itself + * has been extended to include xterm CSI codes, among + * other features. + */ + +/** + * Default styles for xterm.js + */ + +.xterm { + position: relative; + user-select: none; + -ms-user-select: none; + -webkit-user-select: none; +} + +.xterm.focus, +.xterm:focus { + outline: none; +} + +.xterm .xterm-helpers { + position: absolute; + top: 0; + /** + * The z-index of the helpers must be higher than the canvases in order for + * IMEs to appear on top. + */ + z-index: 5; +} + +.xterm .xterm-helper-textarea { + padding: 0; + border: 0; + margin: 0; + /* Move textarea out of the screen to the far left, so that the cursor is not visible */ + position: absolute; + opacity: 0; + left: -9999em; + top: 0; + width: 0; + height: 0; + z-index: -5; + /** Prevent wrapping so the IME appears against the textarea at the correct position */ + white-space: nowrap; + overflow: hidden; + resize: none; +} + +.xterm .composition-view { + /* TODO: Composition position got messed up somewhere */ + background: #000; + color: #FFF; + display: none; + position: absolute; + white-space: nowrap; + z-index: 1; +} + +.xterm .composition-view.active { + display: block; +} + +.xterm .xterm-viewport { + /* On OS X this is required in order for the scroll bar to appear fully opaque */ + background-color: #000; + overflow-y: scroll; + cursor: default; + position: absolute; + right: 0; + left: 0; + top: 0; + bottom: 0; +} + +.xterm .xterm-screen { + position: relative; +} + +.xterm .xterm-screen canvas { + position: absolute; + left: 0; + top: 0; +} + +.xterm .xterm-scroll-area { + visibility: hidden; +} + +.xterm-char-measure-element { + display: inline-block; + visibility: hidden; + position: absolute; + top: 0; + left: -9999em; + line-height: normal; +} + +.xterm { + cursor: text; +} + +.xterm.enable-mouse-events { + /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */ + cursor: default; +} + +.xterm.xterm-cursor-pointer, +.xterm .xterm-cursor-pointer { + cursor: pointer; +} + +.xterm.column-select.focus { + /* Column selection mode */ + cursor: crosshair; +} + +.xterm .xterm-accessibility, +.xterm .xterm-message { + position: absolute; + left: 0; + top: 0; + bottom: 0; + right: 0; + z-index: 10; + color: transparent; +} + +.xterm .live-region { + position: absolute; + left: -9999px; + width: 1px; + height: 1px; + overflow: hidden; +} + +.xterm-dim { + opacity: 0.5; +} + +.xterm-underline { + text-decoration: underline; +} + +.xterm-strikethrough { + text-decoration: line-through; +} + +.xterm-screen .xterm-decoration-container .xterm-decoration { + z-index: 6; + position: absolute; +} + +.xterm-decoration-overview-ruler { + z-index: 7; + position: absolute; + top: 0; + right: 0; +} \ No newline at end of file diff --git a/connectcore-demo-example/static/fonts/OpenSans-Bold.ttf b/connectcore-demo-example/static/fonts/OpenSans-Bold.ttf new file mode 100644 index 0000000..fd79d43 Binary files /dev/null and b/connectcore-demo-example/static/fonts/OpenSans-Bold.ttf differ diff --git a/connectcore-demo-example/static/fonts/OpenSans-BoldItalic.ttf b/connectcore-demo-example/static/fonts/OpenSans-BoldItalic.ttf new file mode 100644 index 0000000..9bc8009 Binary files /dev/null and b/connectcore-demo-example/static/fonts/OpenSans-BoldItalic.ttf differ diff --git a/connectcore-demo-example/static/fonts/OpenSans-Italic.ttf b/connectcore-demo-example/static/fonts/OpenSans-Italic.ttf new file mode 100644 index 0000000..c90da48 Binary files /dev/null and b/connectcore-demo-example/static/fonts/OpenSans-Italic.ttf differ diff --git a/connectcore-demo-example/static/fonts/OpenSans-Regular.ttf b/connectcore-demo-example/static/fonts/OpenSans-Regular.ttf new file mode 100644 index 0000000..db43334 Binary files /dev/null and b/connectcore-demo-example/static/fonts/OpenSans-Regular.ttf differ diff --git a/connectcore-demo-example/static/images/Digi_logo_banner.png b/connectcore-demo-example/static/images/Digi_logo_banner.png new file mode 100644 index 0000000..7ae76e0 Binary files /dev/null and b/connectcore-demo-example/static/images/Digi_logo_banner.png differ diff --git a/connectcore-demo-example/static/images/Digi_logo_banner_gray.png b/connectcore-demo-example/static/images/Digi_logo_banner_gray.png new file mode 100644 index 0000000..1e5289f Binary files /dev/null and b/connectcore-demo-example/static/images/Digi_logo_banner_gray.png differ diff --git a/connectcore-demo-example/static/images/board.png b/connectcore-demo-example/static/images/board.png new file mode 100755 index 0000000..02e31f5 Binary files /dev/null and b/connectcore-demo-example/static/images/board.png differ diff --git a/connectcore-demo-example/static/images/ccimx8m-mini_board.png b/connectcore-demo-example/static/images/ccimx8m-mini_board.png new file mode 100644 index 0000000..49c5daf Binary files /dev/null and b/connectcore-demo-example/static/images/ccimx8m-mini_board.png differ diff --git a/connectcore-demo-example/static/images/ccimx8m-nano_board.png b/connectcore-demo-example/static/images/ccimx8m-nano_board.png new file mode 100644 index 0000000..49c5daf Binary files /dev/null and b/connectcore-demo-example/static/images/ccimx8m-nano_board.png differ diff --git a/connectcore-demo-example/static/images/ccimx8x-sbc-pro_board.png b/connectcore-demo-example/static/images/ccimx8x-sbc-pro_board.png new file mode 100644 index 0000000..38413d0 Binary files /dev/null and b/connectcore-demo-example/static/images/ccimx8x-sbc-pro_board.png differ diff --git a/connectcore-demo-example/static/images/combo_arrow_gray.png b/connectcore-demo-example/static/images/combo_arrow_gray.png new file mode 100644 index 0000000..0ec3be2 Binary files /dev/null and b/connectcore-demo-example/static/images/combo_arrow_gray.png differ diff --git a/connectcore-demo-example/static/images/combo_arrow_green.png b/connectcore-demo-example/static/images/combo_arrow_green.png new file mode 100644 index 0000000..e11e9bd Binary files /dev/null and b/connectcore-demo-example/static/images/combo_arrow_green.png differ diff --git a/connectcore-demo-example/static/images/data_usage.png b/connectcore-demo-example/static/images/data_usage.png new file mode 100755 index 0000000..ae292f4 Binary files /dev/null and b/connectcore-demo-example/static/images/data_usage.png differ diff --git a/connectcore-demo-example/static/images/data_usage_green.png b/connectcore-demo-example/static/images/data_usage_green.png new file mode 100755 index 0000000..46dd6f2 Binary files /dev/null and b/connectcore-demo-example/static/images/data_usage_green.png differ diff --git a/connectcore-demo-example/static/images/devices_list_gray.png b/connectcore-demo-example/static/images/devices_list_gray.png new file mode 100755 index 0000000..14c24a0 Binary files /dev/null and b/connectcore-demo-example/static/images/devices_list_gray.png differ diff --git a/connectcore-demo-example/static/images/devices_list_green.png b/connectcore-demo-example/static/images/devices_list_green.png new file mode 100755 index 0000000..4a47fa2 Binary files /dev/null and b/connectcore-demo-example/static/images/devices_list_green.png differ diff --git a/connectcore-demo-example/static/images/hide_info.png b/connectcore-demo-example/static/images/hide_info.png new file mode 100644 index 0000000..010cf1e Binary files /dev/null and b/connectcore-demo-example/static/images/hide_info.png differ diff --git a/connectcore-demo-example/static/images/hide_info_green.png b/connectcore-demo-example/static/images/hide_info_green.png new file mode 100644 index 0000000..021cb08 Binary files /dev/null and b/connectcore-demo-example/static/images/hide_info_green.png differ diff --git a/connectcore-demo-example/static/images/led_bubble.png b/connectcore-demo-example/static/images/led_bubble.png new file mode 100755 index 0000000..79fc3c3 Binary files /dev/null and b/connectcore-demo-example/static/images/led_bubble.png differ diff --git a/connectcore-demo-example/static/images/led_bubble_hover.png b/connectcore-demo-example/static/images/led_bubble_hover.png new file mode 100755 index 0000000..c1ec9ba Binary files /dev/null and b/connectcore-demo-example/static/images/led_bubble_hover.png differ diff --git a/connectcore-demo-example/static/images/loading.gif b/connectcore-demo-example/static/images/loading.gif new file mode 100644 index 0000000..a9d6788 Binary files /dev/null and b/connectcore-demo-example/static/images/loading.gif differ diff --git a/connectcore-demo-example/static/images/profile_gray.png b/connectcore-demo-example/static/images/profile_gray.png new file mode 100644 index 0000000..a4f2653 Binary files /dev/null and b/connectcore-demo-example/static/images/profile_gray.png differ diff --git a/connectcore-demo-example/static/images/profile_green.png b/connectcore-demo-example/static/images/profile_green.png new file mode 100644 index 0000000..7a6654f Binary files /dev/null and b/connectcore-demo-example/static/images/profile_green.png differ diff --git a/connectcore-demo-example/static/images/remove.png b/connectcore-demo-example/static/images/remove.png new file mode 100644 index 0000000..b9fdca6 Binary files /dev/null and b/connectcore-demo-example/static/images/remove.png differ diff --git a/connectcore-demo-example/static/images/show_info.png b/connectcore-demo-example/static/images/show_info.png new file mode 100644 index 0000000..46ec014 Binary files /dev/null and b/connectcore-demo-example/static/images/show_info.png differ diff --git a/connectcore-demo-example/static/images/show_info_green.png b/connectcore-demo-example/static/images/show_info_green.png new file mode 100644 index 0000000..c99aeaf Binary files /dev/null and b/connectcore-demo-example/static/images/show_info_green.png differ diff --git a/connectcore-demo-example/static/images/status_offline.png b/connectcore-demo-example/static/images/status_offline.png new file mode 100755 index 0000000..111fd28 Binary files /dev/null and b/connectcore-demo-example/static/images/status_offline.png differ diff --git a/connectcore-demo-example/static/images/status_online.png b/connectcore-demo-example/static/images/status_online.png new file mode 100755 index 0000000..b5d391c Binary files /dev/null and b/connectcore-demo-example/static/images/status_online.png differ diff --git a/connectcore-demo-example/static/images/warning.png b/connectcore-demo-example/static/images/warning.png new file mode 100644 index 0000000..d9e063b Binary files /dev/null and b/connectcore-demo-example/static/images/warning.png differ diff --git a/connectcore-demo-example/static/js/ccimx8m-nano.js b/connectcore-demo-example/static/js/ccimx8m-nano.js new file mode 100644 index 0000000..c2a6c40 --- /dev/null +++ b/connectcore-demo-example/static/js/ccimx8m-nano.js @@ -0,0 +1,146 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +class CCIMX8MNANO extends ConnectCoreDevice { + + // Public constants. + static DEVICE_TYPE = "ccimx8mn-dvk"; + static PLATFORM_NAME = "ConnectCore 8M-Nano DVK"; + + // Variables. + BOARD_IMAGE = "ccimx8m-nano_board.png"; + BOARD_IMAGE_SCALE = 85; + + CPU_COMPONENT_VISIBLE = true; + CPU_COMPONENT_HAS_PANEL = true; + CPU_COMPONENT_HAS_ARROW = true; + CPU_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CPU_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + CPU_COMPONENT_PANEL_HORIZONTAL_PERCENT = 28.5; + CPU_COMPONENT_PANEL_VERTICAL_PERCENT = 57; + CPU_COMPONENT_ARROW_PERCENT = 33.5; + CPU_COMPONENT_AREA_TOP_PERCENT = 45.7; + CPU_COMPONENT_AREA_LEFT_PERCENT = 32.4; + CPU_COMPONENT_AREA_WIDTH_PERCENT = 5.7; + CPU_COMPONENT_AREA_HEIGHT_PERCENT = 9; + + MEMORY_COMPONENT_VISIBLE = true; + MEMORY_COMPONENT_HAS_PANEL = true; + MEMORY_COMPONENT_HAS_ARROW = true; + MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_BOTTOM; + MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 22; + MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 65; + MEMORY_COMPONENT_ARROW_PERCENT = 33.7; + MEMORY_COMPONENT_AREA_TOP_PERCENT = 37; + MEMORY_COMPONENT_AREA_LEFT_PERCENT = 32.4; + MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 6; + MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 7; + + WIFI_BT_COMPONENT_VISIBLE = true; + WIFI_BT_COMPONENT_HAS_PANEL = true; + WIFI_BT_COMPONENT_HAS_ARROW = true; + WIFI_BT_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + WIFI_BT_COMPONENT_PANEL_ORIENTATION = VALUE_RIGHT; + WIFI_BT_COMPONENT_PANEL_HORIZONTAL_PERCENT = 73; + WIFI_BT_COMPONENT_PANEL_VERTICAL_PERCENT = 38; + WIFI_BT_COMPONENT_ARROW_PERCENT = 46; + WIFI_BT_COMPONENT_AREA_TOP_PERCENT = 46.5; + WIFI_BT_COMPONENT_AREA_LEFT_PERCENT = 28.3; + WIFI_BT_COMPONENT_AREA_WIDTH_PERCENT = 4; + WIFI_BT_COMPONENT_AREA_HEIGHT_PERCENT = 6; + + ETHERNET_COMPONENT_VISIBLE = true; + ETHERNET_COMPONENT_HAS_PANEL = true; + ETHERNET_COMPONENT_HAS_ARROW = true; + ETHERNET_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + ETHERNET_COMPONENT_PANEL_ORIENTATION = VALUE_LEFT; + ETHERNET_COMPONENT_PANEL_HORIZONTAL_PERCENT = 21; + ETHERNET_COMPONENT_PANEL_VERTICAL_PERCENT = 70; + ETHERNET_COMPONENT_ARROW_PERCENT = 78; + ETHERNET_COMPONENT_AREA_TOP_PERCENT = 77; + ETHERNET_COMPONENT_AREA_LEFT_PERCENT = 11; + ETHERNET_COMPONENT_AREA_WIDTH_PERCENT = 8.5; + ETHERNET_COMPONENT_AREA_HEIGHT_PERCENT = 16; + + CONSOLE_COMPONENT_VISIBLE = true; + CONSOLE_COMPONENT_HAS_PANEL = false; + CONSOLE_COMPONENT_HAS_ARROW = false; + CONSOLE_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CONSOLE_COMPONENT_AREA_TOP_PERCENT = 6.5; + CONSOLE_COMPONENT_AREA_LEFT_PERCENT = 26.5; + CONSOLE_COMPONENT_AREA_WIDTH_PERCENT = 3.4; + CONSOLE_COMPONENT_AREA_HEIGHT_PERCENT = 4.5; + + VIDEO_COMPONENT_VISIBLE = true; + VIDEO_COMPONENT_HAS_PANEL = true; + VIDEO_COMPONENT_HAS_ARROW = true; + VIDEO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + VIDEO_COMPONENT_PANEL_ORIENTATION = VALUE_BOTTOM; + VIDEO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 47.5; + VIDEO_COMPONENT_PANEL_VERTICAL_PERCENT = 18; + VIDEO_COMPONENT_ARROW_PERCENT = 58.5; + VIDEO_COMPONENT_AREA_TOP_PERCENT = 84; + VIDEO_COMPONENT_AREA_LEFT_PERCENT = 57; + VIDEO_COMPONENT_AREA_WIDTH_PERCENT = 6; + VIDEO_COMPONENT_AREA_HEIGHT_PERCENT = 8; + + AUDIO_COMPONENT_VISIBLE = false; + AUDIO_COMPONENT_HAS_PANEL = true; + AUDIO_COMPONENT_HAS_ARROW = true; + AUDIO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + AUDIO_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + AUDIO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 1; + AUDIO_COMPONENT_PANEL_VERTICAL_PERCENT = 19; + AUDIO_COMPONENT_ARROW_PERCENT = 16; + AUDIO_COMPONENT_AREA_TOP_PERCENT = 7; + AUDIO_COMPONENT_AREA_LEFT_PERCENT = 14.5; + AUDIO_COMPONENT_AREA_WIDTH_PERCENT = 5.4; + AUDIO_COMPONENT_AREA_HEIGHT_PERCENT = 11; + + LED_COMPONENT_VISIBLE = true; + LED_COMPONENT_HAS_PANEL = true; + LED_COMPONENT_HAS_ARROW = false; + LED_COMPONENT_PANEL_ALWAYS_VISIBLE = true; + LED_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + LED_COMPONENT_PANEL_HORIZONTAL_PERCENT = 61; + LED_COMPONENT_PANEL_VERTICAL_PERCENT = 14; + LED_COMPONENT_AREA_TOP_PERCENT = 8.5; + LED_COMPONENT_AREA_LEFT_PERCENT = 62.6; + LED_COMPONENT_AREA_WIDTH_PERCENT = 1.5; + LED_COMPONENT_AREA_HEIGHT_PERCENT = 4; + + FLASH_MEMORY_COMPONENT_VISIBLE = true; + FLASH_MEMORY_COMPONENT_HAS_PANEL = true; + FLASH_MEMORY_COMPONENT_HAS_ARROW = true; + FLASH_MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + FLASH_MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_LEFT; + FLASH_MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 45; + FLASH_MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 36; + FLASH_MEMORY_COMPONENT_ARROW_PERCENT = 38; + FLASH_MEMORY_COMPONENT_AREA_TOP_PERCENT = 36.3; + FLASH_MEMORY_COMPONENT_AREA_LEFT_PERCENT = 38.8; + FLASH_MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 5.4; + FLASH_MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 8; + + + // Capabilities + SUPPORTS_VIDEO_BRIGHTNESS = false; + + // Constructor. + constructor(deviceID, deviceData) { + super(CCIMX8MNANO.DEVICE_TYPE, CCIMX8MNANO.PLATFORM_NAME, deviceID, deviceData); + } +} \ No newline at end of file diff --git a/connectcore-demo-example/static/js/ccimx8mm-dvk.js b/connectcore-demo-example/static/js/ccimx8mm-dvk.js new file mode 100644 index 0000000..2201ff9 --- /dev/null +++ b/connectcore-demo-example/static/js/ccimx8mm-dvk.js @@ -0,0 +1,146 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +class CCIMX8MMINI extends ConnectCoreDevice { + + // Public constants. + static DEVICE_TYPE = "ccimx8mm-dvk"; + static PLATFORM_NAME = "ConnectCore 8M-Mini DVK"; + + // Variables. + BOARD_IMAGE = "ccimx8m-mini_board.png"; + BOARD_IMAGE_SCALE = 85; + + CPU_COMPONENT_VISIBLE = true; + CPU_COMPONENT_HAS_PANEL = true; + CPU_COMPONENT_HAS_ARROW = true; + CPU_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CPU_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + CPU_COMPONENT_PANEL_HORIZONTAL_PERCENT = 28.5; + CPU_COMPONENT_PANEL_VERTICAL_PERCENT = 57; + CPU_COMPONENT_ARROW_PERCENT = 33.5; + CPU_COMPONENT_AREA_TOP_PERCENT = 45.7; + CPU_COMPONENT_AREA_LEFT_PERCENT = 32.4; + CPU_COMPONENT_AREA_WIDTH_PERCENT = 5.7; + CPU_COMPONENT_AREA_HEIGHT_PERCENT = 9; + + MEMORY_COMPONENT_VISIBLE = true; + MEMORY_COMPONENT_HAS_PANEL = true; + MEMORY_COMPONENT_HAS_ARROW = true; + MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_BOTTOM; + MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 22; + MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 65; + MEMORY_COMPONENT_ARROW_PERCENT = 33.7; + MEMORY_COMPONENT_AREA_TOP_PERCENT = 37; + MEMORY_COMPONENT_AREA_LEFT_PERCENT = 32.4; + MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 6; + MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 7; + + WIFI_BT_COMPONENT_VISIBLE = true; + WIFI_BT_COMPONENT_HAS_PANEL = true; + WIFI_BT_COMPONENT_HAS_ARROW = true; + WIFI_BT_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + WIFI_BT_COMPONENT_PANEL_ORIENTATION = VALUE_RIGHT; + WIFI_BT_COMPONENT_PANEL_HORIZONTAL_PERCENT = 73; + WIFI_BT_COMPONENT_PANEL_VERTICAL_PERCENT = 38; + WIFI_BT_COMPONENT_ARROW_PERCENT = 46; + WIFI_BT_COMPONENT_AREA_TOP_PERCENT = 46.5; + WIFI_BT_COMPONENT_AREA_LEFT_PERCENT = 28.3; + WIFI_BT_COMPONENT_AREA_WIDTH_PERCENT = 4; + WIFI_BT_COMPONENT_AREA_HEIGHT_PERCENT = 6; + + ETHERNET_COMPONENT_VISIBLE = true; + ETHERNET_COMPONENT_HAS_PANEL = true; + ETHERNET_COMPONENT_HAS_ARROW = true; + ETHERNET_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + ETHERNET_COMPONENT_PANEL_ORIENTATION = VALUE_LEFT; + ETHERNET_COMPONENT_PANEL_HORIZONTAL_PERCENT = 21; + ETHERNET_COMPONENT_PANEL_VERTICAL_PERCENT = 70; + ETHERNET_COMPONENT_ARROW_PERCENT = 78; + ETHERNET_COMPONENT_AREA_TOP_PERCENT = 77; + ETHERNET_COMPONENT_AREA_LEFT_PERCENT = 11; + ETHERNET_COMPONENT_AREA_WIDTH_PERCENT = 8.5; + ETHERNET_COMPONENT_AREA_HEIGHT_PERCENT = 16; + + CONSOLE_COMPONENT_VISIBLE = true; + CONSOLE_COMPONENT_HAS_PANEL = false; + CONSOLE_COMPONENT_HAS_ARROW = false; + CONSOLE_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CONSOLE_COMPONENT_AREA_TOP_PERCENT = 6.5; + CONSOLE_COMPONENT_AREA_LEFT_PERCENT = 26.5; + CONSOLE_COMPONENT_AREA_WIDTH_PERCENT = 3.4; + CONSOLE_COMPONENT_AREA_HEIGHT_PERCENT = 4.5; + + VIDEO_COMPONENT_VISIBLE = true; + VIDEO_COMPONENT_HAS_PANEL = true; + VIDEO_COMPONENT_HAS_ARROW = true; + VIDEO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + VIDEO_COMPONENT_PANEL_ORIENTATION = VALUE_BOTTOM; + VIDEO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 47.5; + VIDEO_COMPONENT_PANEL_VERTICAL_PERCENT = 18; + VIDEO_COMPONENT_ARROW_PERCENT = 58.5; + VIDEO_COMPONENT_AREA_TOP_PERCENT = 84; + VIDEO_COMPONENT_AREA_LEFT_PERCENT = 57; + VIDEO_COMPONENT_AREA_WIDTH_PERCENT = 6; + VIDEO_COMPONENT_AREA_HEIGHT_PERCENT = 8; + + AUDIO_COMPONENT_VISIBLE = false; + AUDIO_COMPONENT_HAS_PANEL = true; + AUDIO_COMPONENT_HAS_ARROW = true; + AUDIO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + AUDIO_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + AUDIO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 1; + AUDIO_COMPONENT_PANEL_VERTICAL_PERCENT = 19; + AUDIO_COMPONENT_ARROW_PERCENT = 16; + AUDIO_COMPONENT_AREA_TOP_PERCENT = 7; + AUDIO_COMPONENT_AREA_LEFT_PERCENT = 14.5; + AUDIO_COMPONENT_AREA_WIDTH_PERCENT = 5.4; + AUDIO_COMPONENT_AREA_HEIGHT_PERCENT = 11; + + LED_COMPONENT_VISIBLE = true; + LED_COMPONENT_HAS_PANEL = true; + LED_COMPONENT_HAS_ARROW = false; + LED_COMPONENT_PANEL_ALWAYS_VISIBLE = true; + LED_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + LED_COMPONENT_PANEL_HORIZONTAL_PERCENT = 61; + LED_COMPONENT_PANEL_VERTICAL_PERCENT = 14; + LED_COMPONENT_AREA_TOP_PERCENT = 8.5; + LED_COMPONENT_AREA_LEFT_PERCENT = 62.6; + LED_COMPONENT_AREA_WIDTH_PERCENT = 1.5; + LED_COMPONENT_AREA_HEIGHT_PERCENT = 4; + + FLASH_MEMORY_COMPONENT_VISIBLE = true; + FLASH_MEMORY_COMPONENT_HAS_PANEL = true; + FLASH_MEMORY_COMPONENT_HAS_ARROW = true; + FLASH_MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + FLASH_MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_LEFT; + FLASH_MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 45; + FLASH_MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 36; + FLASH_MEMORY_COMPONENT_ARROW_PERCENT = 38; + FLASH_MEMORY_COMPONENT_AREA_TOP_PERCENT = 36.3; + FLASH_MEMORY_COMPONENT_AREA_LEFT_PERCENT = 38.8; + FLASH_MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 5.4; + FLASH_MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 8; + + + // Capabilities + SUPPORTS_VIDEO_BRIGHTNESS = false; + + // Constructor. + constructor(deviceID, deviceData) { + super(CCIMX8MMINI.DEVICE_TYPE, CCIMX8MMINI.PLATFORM_NAME, deviceID, deviceData); + } +} \ No newline at end of file diff --git a/connectcore-demo-example/static/js/ccimx8x-sbc-pro.js b/connectcore-demo-example/static/js/ccimx8x-sbc-pro.js new file mode 100644 index 0000000..df5513f --- /dev/null +++ b/connectcore-demo-example/static/js/ccimx8x-sbc-pro.js @@ -0,0 +1,146 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +class CCIMX8X extends ConnectCoreDevice { + + // Public constants. + static DEVICE_TYPE = "ccimx8x-sbc-pro"; + static PLATFORM_NAME = "ConnectCore 8X SBC Pro"; + + // Variables. + BOARD_IMAGE = "ccimx8x-sbc-pro_board.png"; + BOARD_IMAGE_SCALE = 60; + + CPU_COMPONENT_VISIBLE = true; + CPU_COMPONENT_HAS_PANEL = true; + CPU_COMPONENT_HAS_ARROW = true; + CPU_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CPU_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + CPU_COMPONENT_PANEL_HORIZONTAL_PERCENT = 49; + CPU_COMPONENT_PANEL_VERTICAL_PERCENT = 65; + CPU_COMPONENT_ARROW_PERCENT = 62; + CPU_COMPONENT_AREA_TOP_PERCENT = 40; + CPU_COMPONENT_AREA_LEFT_PERCENT = 54; + CPU_COMPONENT_AREA_WIDTH_PERCENT = 19.5; + CPU_COMPONENT_AREA_HEIGHT_PERCENT = 24; + + MEMORY_COMPONENT_VISIBLE = true; + MEMORY_COMPONENT_HAS_PANEL = true; + MEMORY_COMPONENT_HAS_ARROW = true; + MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_RIGHT; + MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 43; + MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 22.5; + MEMORY_COMPONENT_ARROW_PERCENT = 29; + MEMORY_COMPONENT_AREA_TOP_PERCENT = 22.25; + MEMORY_COMPONENT_AREA_LEFT_PERCENT = 57.75; + MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 9.5; + MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 16.5; + + WIFI_BT_COMPONENT_VISIBLE = true; + WIFI_BT_COMPONENT_HAS_PANEL = true; + WIFI_BT_COMPONENT_HAS_ARROW = true; + WIFI_BT_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + WIFI_BT_COMPONENT_PANEL_ORIENTATION = VALUE_LEFT; + WIFI_BT_COMPONENT_PANEL_HORIZONTAL_PERCENT = 83; + WIFI_BT_COMPONENT_PANEL_VERTICAL_PERCENT = 35; + WIFI_BT_COMPONENT_ARROW_PERCENT = 41; + WIFI_BT_COMPONENT_AREA_TOP_PERCENT = 38; + WIFI_BT_COMPONENT_AREA_LEFT_PERCENT = 73.5; + WIFI_BT_COMPONENT_AREA_WIDTH_PERCENT = 8.5; + WIFI_BT_COMPONENT_AREA_HEIGHT_PERCENT = 10; + + ETHERNET_COMPONENT_VISIBLE = true; + ETHERNET_COMPONENT_HAS_PANEL = true; + ETHERNET_COMPONENT_HAS_ARROW = true; + ETHERNET_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + ETHERNET_COMPONENT_PANEL_ORIENTATION = VALUE_BOTTOM; + ETHERNET_COMPONENT_PANEL_HORIZONTAL_PERCENT = -7; + ETHERNET_COMPONENT_PANEL_VERTICAL_PERCENT = 34; + ETHERNET_COMPONENT_ARROW_PERCENT = 18; + ETHERNET_COMPONENT_AREA_TOP_PERCENT = 68; + ETHERNET_COMPONENT_AREA_LEFT_PERCENT = 12; + ETHERNET_COMPONENT_AREA_WIDTH_PERCENT = 17; + ETHERNET_COMPONENT_AREA_HEIGHT_PERCENT = 27; + + CONSOLE_COMPONENT_VISIBLE = true; + CONSOLE_COMPONENT_HAS_PANEL = false; + CONSOLE_COMPONENT_HAS_ARROW = false; + CONSOLE_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CONSOLE_COMPONENT_AREA_TOP_PERCENT = 22.5; + CONSOLE_COMPONENT_AREA_LEFT_PERCENT = 86; + CONSOLE_COMPONENT_AREA_WIDTH_PERCENT = 7; + CONSOLE_COMPONENT_AREA_HEIGHT_PERCENT = 4.5; + + VIDEO_COMPONENT_VISIBLE = true; + VIDEO_COMPONENT_HAS_PANEL = true; + VIDEO_COMPONENT_HAS_ARROW = true; + VIDEO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + VIDEO_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + VIDEO_COMPONENT_PANEL_HORIZONTAL_PERCENT = -15; + VIDEO_COMPONENT_PANEL_VERTICAL_PERCENT = 18; + VIDEO_COMPONENT_ARROW_PERCENT = 20.75; + VIDEO_COMPONENT_AREA_TOP_PERCENT = 8.5; + VIDEO_COMPONENT_AREA_LEFT_PERCENT = 8.75; + VIDEO_COMPONENT_AREA_WIDTH_PERCENT = 27.5; + VIDEO_COMPONENT_AREA_HEIGHT_PERCENT = 7.5; + + AUDIO_COMPONENT_VISIBLE = false; + AUDIO_COMPONENT_HAS_PANEL = true; + AUDIO_COMPONENT_HAS_ARROW = true; + AUDIO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + AUDIO_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + AUDIO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 1; + AUDIO_COMPONENT_PANEL_VERTICAL_PERCENT = 19; + AUDIO_COMPONENT_ARROW_PERCENT = 16; + AUDIO_COMPONENT_AREA_TOP_PERCENT = 7; + AUDIO_COMPONENT_AREA_LEFT_PERCENT = 14.5; + AUDIO_COMPONENT_AREA_WIDTH_PERCENT = 5.4; + AUDIO_COMPONENT_AREA_HEIGHT_PERCENT = 11; + + LED_COMPONENT_VISIBLE = true; + LED_COMPONENT_HAS_PANEL = true; + LED_COMPONENT_HAS_ARROW = false; + LED_COMPONENT_PANEL_ALWAYS_VISIBLE = true; + LED_COMPONENT_PANEL_ORIENTATION = VALUE_LEFT; + LED_COMPONENT_PANEL_HORIZONTAL_PERCENT = 30; + LED_COMPONENT_PANEL_VERTICAL_PERCENT = 52; + LED_COMPONENT_AREA_TOP_PERCENT = 53.5; + LED_COMPONENT_AREA_LEFT_PERCENT = 27; + LED_COMPONENT_AREA_WIDTH_PERCENT = 2.5; + LED_COMPONENT_AREA_HEIGHT_PERCENT = 5; + + FLASH_MEMORY_COMPONENT_VISIBLE = true; + FLASH_MEMORY_COMPONENT_HAS_PANEL = true; + FLASH_MEMORY_COMPONENT_HAS_ARROW = true; + FLASH_MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + FLASH_MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_BOTTOM; + FLASH_MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 57.5; + FLASH_MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 79.5; + FLASH_MEMORY_COMPONENT_ARROW_PERCENT = 71.5; + FLASH_MEMORY_COMPONENT_AREA_TOP_PERCENT = 22.25; + FLASH_MEMORY_COMPONENT_AREA_LEFT_PERCENT = 68; + FLASH_MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 10.8; + FLASH_MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 15; + + + // Capabilities + SUPPORTS_VIDEO_BRIGHTNESS = false; + + // Constructor. + constructor(deviceID, deviceData) { + super(CCIMX8X.DEVICE_TYPE, CCIMX8X.PLATFORM_NAME, deviceID, deviceData); + } +} diff --git a/connectcore-demo-example/static/js/common.js b/connectcore-demo-example/static/js/common.js new file mode 100644 index 0000000..36fbe81 --- /dev/null +++ b/connectcore-demo-example/static/js/common.js @@ -0,0 +1,455 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_AREA = "area"; +const ID_AREA_HEIGHT = "area-height"; +const ID_AREA_LEFT_MARGIN = "area-left-margin"; +const ID_AREA_TOP_MARGIN = "area-top-margin"; +const ID_AREA_WIDTH = "area-width"; +const ID_ARROW = "arrow"; +const ID_ARROW_MARGIN = "arrow-margin"; +const ID_AUDIO = "audio"; +const ID_BLUETOOTH_MAC = "bluetooth_mac"; +const ID_BOARD_ID = "board_id"; +const ID_BOARD_VARIANT = "board_variant"; +const ID_BT_READ_DATA = "bluetooth_received_data"; +const ID_BT_SENT_DATA = "bluetooth_sent_data"; +const ID_BT_STATE = "bluetooth_state"; +const ID_CONSOLE = "console"; +const ID_CONFIRM_DIALOG = "confirm_dialog"; +const ID_CONFIRM_DIALOG_MESSAGE = "confirm_dialog_message"; +const ID_CONFIRM_DIALOG_NO_BUTTON = "confirm_dialog_no_button"; +const ID_CONFIRM_DIALOG_TITLE = "confirm_dialog_title"; +const ID_CONFIRM_DIALOG_YES_BUTTON = "confirm_dialog_yes_button"; +const ID_CPU = "cpu"; +const ID_CPU_FREQUENCY = "cpu_frequency"; +const ID_CPU_LOAD = "cpu_load"; +const ID_CPU_TEMPERATURE = "cpu_temperature"; +const ID_CPU_UPTIME = "cpu_uptime"; +const ID_CURRENT_DIR = "current_dir"; +const ID_DATA = "data"; +const ID_DATA_USAGE_DEVICES = "data_usage_devices"; +const ID_DATA_USAGE_MONITORS = "data_usage_monitors"; +const ID_DATA_USAGE_TOTAL = "data_usage_total"; +const ID_DATA_USAGE_WEB = "data_usage_web"; +const ID_DATA_USAGE_WEB_SERVICES = "data_usage_web_services"; +const ID_DEVICE_ID = "device_id"; +const ID_DEVICE_NAME = "device_name"; +const ID_DEVICE_TYPE = "device_type"; +const ID_DEVICES = "devices"; +const ID_DEY_VERSION = "dey_version"; +const ID_ERROR = "error"; +const ID_ERROR_GUIDE = "error_guide"; +const ID_ERROR_MESSAGE = "error_msg"; +const ID_ERROR_TITLE = "error_title"; +const ID_ETHERNET = "ethernet"; +const ID_ETHERNET_IP = "ethernet_ip"; +const ID_ETHERNET_MAC = "ethernet_mac"; +const ID_ETHERNET_READ_DATA = "ethernet_received_data"; +const ID_ETHERNET_SENT_DATA = "ethernet_sent_data"; +const ID_ETHERNET_STATE = "ethernet_state"; +const ID_FILES = "files"; +const ID_FLASH_MEMORY = "flash_memory"; +const ID_FLASH_SIZE = "flash_size"; +const ID_HAS_ARROW = "has-arrow"; +const ID_HAS_PANEL = "has-panel"; +const ID_ICON = "icon"; +const ID_ID = "id"; +const ID_INFO_POPUP = "info_popup"; +const ID_INFO_POPUP_MESSAGE = "info_popup_message"; +const ID_INFO_POPUP_TITLE = "info_popup_title"; +const ID_KERNEL_VERSION = "kernel_version"; +const ID_LAST_MODIFIED = "last_modified"; +const ID_LED = "led"; +const ID_LOADING_POPUP = "loading_popup"; +const ID_LOADING_POPUP_MESSAGE = "loading_popup_message"; +const ID_LOADING_WRAPPER = "loading_wrapper"; +const ID_MCA_FW_VERSION = "mca_fw_version"; +const ID_MCA_HW_VERSION = "mca_hw_version"; +const ID_MEMORY = "memory"; +const ID_MEMORY_FREE = "memory_free"; +const ID_MEMORY_TOTAL = "memory_total"; +const ID_MEMORY_USED = "memory_used"; +const ID_MESSAGE = "message"; +const ID_MODULE_VARIANT = "module_variant"; +const ID_NAME = "name"; +const ID_NUM_SAMPLES_UPLOAD = "num_samples_upload"; +const ID_ONLINE = "online"; +const ID_PANEL = "panel"; +const ID_PANEL_ALWAYS_VISIBLE = "panel-always-visible"; +const ID_PANEL_HORIZONTAL_MARGIN = "panel-horizontal-margin"; +const ID_PANEL_ORIENTATION = "panel-orientation"; +const ID_PANEL_VERTICAL_MARGIN = "panel-vertical-margin"; +const ID_PATH = "path"; +const ID_PROGRESS = "progress"; +const ID_SAMPLE_RATE = "sample_rate"; +const ID_SERIAL_NUMBER = "serial_number"; +const ID_SESSION_ID = "session_id"; +const ID_SIZE = "size"; +const ID_STATUS = "status"; +const ID_STREAM = "stream"; +const ID_TIMESTAMP = "timestamp"; +const ID_TYPE = "type"; +const ID_UBOOT_VERSION = "uboot_version"; +const ID_USAGE = "usage"; +const ID_VALUE = "value"; +const ID_VIDEO = "video"; +const ID_VIDEO_RESOLUTION = "video_resolution"; +const ID_VISIBLE = "visible"; +const ID_WIFI_BT = "wifi-bt"; +const ID_WIFI_IP = "wifi_ip"; +const ID_WIFI_MAC = "wifi_mac"; +const ID_WIFI_READ_DATA = "wifi_received_data"; +const ID_WIFI_SENT_DATA = "wifi_sent_data"; +const ID_WIFI_STATE = "wifi_state"; + +const VALUE_ACTIVE = "active"; +const VALUE_ABORT = "abort"; +const VALUE_BOTTOM = "bottom"; +const VALUE_CANCELED = "canceled"; +const VALUE_FAILED = "failed"; +const VALUE_LEFT = "left"; +const VALUE_OFF = "Off"; +const VALUE_OFFLINE = "Offline"; +const VALUE_ON = "On"; +const VALUE_ONLINE = "Online"; +const VALUE_RIGHT = "right"; +const VALUE_SUCCESSFUL = "successful"; +const VALUE_TOP = "top"; +const VALUE_UNKNOWN = "unknown"; + +const CLASS_D_NONE = "d-none"; +const CLASS_DISABLED_DIV = "disabled-div"; +const CLASS_ELEMENT_GRAYED = "element-grayed"; +const CLASS_SELECTED = "selected"; + +const ERROR_ABORTED = "Operation aborted"; +const ERROR_URL_NOT_FOUND = "Requested URL not found"; +const ERROR_SERVER_ERROR = "Internal server error"; +const ERROR_TITLE = "Error"; +const ERROR_UNKNOWN_ERROR = "Unknown error"; + +const IMAGE_OFFLINE = "status_offline.png"; +const IMAGE_ONLINE = "status_online.png"; + +const PATH_IMAGES = "../static/images/"; + +String.prototype.format = function() { + var formatted = this; + for (var arg in arguments) + formatted = formatted.replace("{" + arg + "}", arguments[arg]); + return formatted; +}; + +// Shows/hides a front popup over the given background element. +function showPopup(backElementID, frontElementID, visible) { + // Initialize variables. + var backElement = document.getElementById(backElementID); + var frontElement = document.getElementById(frontElementID); + // Sanity checks. + if (backElement == null || frontElement == null) + return; + // Show/Hide the popup. + if (visible) { + if (!backElement.classList.contains(CLASS_ELEMENT_GRAYED)) + backElement.classList.add(CLASS_ELEMENT_GRAYED); + if (frontElement.classList.contains(CLASS_D_NONE)) + frontElement.classList.remove(CLASS_D_NONE); + } else { + if (backElement.classList.contains(CLASS_ELEMENT_GRAYED)) + backElement.classList.remove(CLASS_ELEMENT_GRAYED); + if (!frontElement.classList.contains(CLASS_D_NONE)) + frontElement.classList.add(CLASS_D_NONE); + } +} + +// Redirects to the login page. +function redirectToLogin() { + var url = "/access/login?dest=" + window.location.pathname.replaceAll("/", ""); + var params = new URLSearchParams(window.location.search); + for (let param of params) + url += "&" + param[0] + "=" + param[1]; + window.location.href = url; +} + +// Processes the error response of the AJAX request. +function processAjaxErrorResponse(response) { + // Check common error codes. + if (response.status == 401) + redirectToLogin(); + var errorMessage = ""; + if (response.statusText == VALUE_ABORT) + errorMessage = ERROR_ABORTED; + else if (response.status == 400) { + errorMessage = response.responseJSON[ID_ERROR]; + // Show the error message (if any). + if (errorMessage == null) + errorMessage = ERROR_UNKNOWN_ERROR; + } else if (response.status == 404) + errorMessage = ERROR_URL_NOT_FOUND; + else if (response.status == 500) + errorMessage = ERROR_SERVER_ERROR; + else + errorMessage = ERROR_UNKNOWN_ERROR; + // Show toast with the error message. + toastr.error(errorMessage); + // Return the error message. + return errorMessage; +} + +// Check if there is any error in the response. +function checkErrorResponse(response, showErrorDialog) { + if (response[ID_ERROR_MESSAGE] != null || response[ID_ERROR] != null) { + // Process error. + var errorTitle = ERROR_TITLE; + var errorMessage = getErrorFromResponse(response); + if (response[ID_ERROR_TITLE] != null) + errorTitle = response[ID_ERROR_TITLE]; + // Show toast error. + if (errorMessage != null && errorMessage != "") + toastr.error(errorMessage); + // Hide the loading panel. + showLoadingPopup(false); + // Show error dialog. + if (showErrorDialog) + showInfoPopup(true, errorTitle, errorMessage); + // There was an error, return true. + return true; + } + // No error found. + return false; +} + +// Returns the error message from the response. +function getErrorFromResponse(response) { + var error = ""; + if (response[ID_ERROR_MESSAGE] != null || response[ID_ERROR] != null) { + if (response[ID_ERROR_MESSAGE] != null) { + error = response[ID_ERROR_MESSAGE]; + if (response[ID_ERROR_GUIDE] != null) + error += response[ID_ERROR_GUIDE]; + } else + error = response[ID_ERROR]; + } + return error; +} + +// Shows/hides the loading popup panel. +function showLoadingPopup(visible, message=null) { + // Set loading message only if it is not null and the popup will be visible. + if (visible && message != null) + document.getElementById(ID_LOADING_POPUP_MESSAGE).innerHTML = message; + // Show/Hide the popup. + showPopup(ID_LOADING_WRAPPER, ID_LOADING_POPUP, visible); +} + +// Shows/hides the info popup panel. +function showInfoPopup(visible, tittle=null, message=null) { + // Set title and message. + if (visible && tittle != null && message != null) { + // Initialize vars. + var infoPopupTittleElement = document.getElementById(ID_INFO_POPUP_TITLE); + var infoPopupMessageElement = document.getElementById(ID_INFO_POPUP_MESSAGE); + // Set the info title. + if (infoPopupTittleElement != null) + infoPopupTittleElement.innerHTML = tittle; + // Set the info message. + if (infoPopupMessageElement != null) + infoPopupMessageElement.innerHTML = message; + } + // Show/Hide the popup. + showPopup(ID_LOADING_WRAPPER, ID_INFO_POPUP, visible); +} + +// Shows the confirm dialog. +function showConfirmDialog(title, message, yesCallback, noCallback) { + // Initialize variables. + var confirmDialogTitleElement = document.getElementById(ID_CONFIRM_DIALOG_TITLE); + var confirmDialogMessageElement = document.getElementById(ID_CONFIRM_DIALOG_MESSAGE); + var confirmDialogYesButtonElement = document.getElementById(ID_CONFIRM_DIALOG_YES_BUTTON); + var confirmDialogNoButtonElement = document.getElementById(ID_CONFIRM_DIALOG_NO_BUTTON); + // Check if the elements are valid. + if (confirmDialogTitleElement != null && confirmDialogMessageElement != null && + confirmDialogYesButtonElement != null && confirmDialogNoButtonElement != null) { + // Set the dialog title. + confirmDialogTitleElement.innerHTML = title; + // Set the dialog message. + confirmDialogMessageElement.innerHTML = message; + // Show the dialog. + showPopup(ID_LOADING_WRAPPER, ID_CONFIRM_DIALOG, true); + // Set the yes button callback. + confirmDialogYesButtonElement.onclick = function() { + // Hide the dialog. + showPopup(ID_LOADING_WRAPPER, ID_CONFIRM_DIALOG, false); + // Call the callback. + if (yesCallback != null) + yesCallback(); + }; + // Set the no button callback. + confirmDialogNoButtonElement.onclick = function() { + // Hide the dialog. + showPopup(ID_LOADING_WRAPPER, ID_CONFIRM_DIALOG, false); + // Call the callback. + if (noCallback != null) + noCallback(); + }; + } +} + +// Transforms the given ISO8601 date to human readable date. +function transformDate(iso8601Date) { + // Initialize variables. + var date = new Date(iso8601Date); + var humanReadableDate = ""; + // Check if the date is valid. + if (date != null) { + // Transform the date to human readable date. + humanReadableDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + + date.getHours().toString().padStart(2, '0') + ":" + date.getMinutes().toString().padStart(2, '0'); + } + // Return the human readable date. + return humanReadableDate; +} + +// Transforms the given kilo-bytes to mega-bytes +function kiloBytesToMegaBytes(kiloBytes) { + return (kiloBytes / 1024).toFixed(2); +} + +// Format bytes as human-readable text. +function sizeToHumanRead(bytes, si=true, dp=2) { + // Initialize variables. + var threshold = si ? 1000 : 1024; + var units = si + ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; + var unit = -1; + // Check if minimum threshold is reached. + if (Math.abs(bytes) < threshold) + return bytes + ' Bytes'; + + const r = 10**dp; + do { + bytes /= threshold; + ++unit; + } while (Math.round(Math.abs(bytes) * r) / r >= threshold && unit < units.length - 1); + + return bytes.toFixed(dp) + ' ' + units[unit]; +} + +// Rounds the given number to two decimals. +function roundToTwoDecimals(number) { + return Math.round(number * 100) / 100; +} + +// Returns human readable time from the given seconds. +function secondsToTime(numSeconds) { + // Initialize variables. + var days = 0; + var hours = 0; + var minutes = 0; + var seconds = 0; + // Calculate the time values. + if (numSeconds < 60) + seconds = numSeconds; + else if (numSeconds < (60 * 60)) { + minutes = Math.floor(numSeconds / 60); + seconds = numSeconds % 60; + } else if (numSeconds < (60 * 60 * 24)) { + hours = Math.floor(numSeconds / (60 * 60)); + minutes = Math.floor((numSeconds % (60 * 60)) / 60); + seconds = numSeconds % 60; + } else { + days = Math.floor(numSeconds / (60 * 60 * 24)); + hours = Math.floor((numSeconds % (60 * 60 * 24)) / (60 * 60)); + minutes = Math.floor((numSeconds % (60 * 60)) / 60); + seconds = numSeconds % 60; + } + // Build time string. + var time = ""; + var numFields = 0; + if (days > 0) { + time += days + " day"; + if (days > 1) + time += "s"; + time += " "; + numFields += 1; + } + if (hours > 0) { + time += hours + " hour"; + if (hours > 1) + time += "s"; + time += " "; + numFields += 1; + } + if (minutes > 0 && numFields < 2) { + time += minutes + " minute"; + if (minutes > 1) + time += "s"; + time += " "; + numFields += 1; + } + if ((seconds > 0 && numFields < 2) || time == "") { + time += seconds + " second"; + if (seconds > 1) + time += "s"; + } + // Return the time string. + return time; +} + +// Returns on/off status from the given integer. +function onOffStatus(status) { + return status == 1 ? VALUE_ON : VALUE_OFF; +} + +// Updates the given field ID with the given value. +function updateFieldValue(fieldID, value) { + var fieldElement = document.getElementById(fieldID); + if (fieldElement != null && fieldElement != "undefined") + fieldElement.innerText = value; +} + +// Rounds the given amount of kilo-bytes to giga bytes. +function roundToGigaBytes(kiloBytes) { + return (kiloBytes / (1024 * 1024)).toFixed(2); +} + +// Returns whether the dashboard page is showing or not. +function isDashboardShowing() { + return window.location.pathname.indexOf("dashboard") > -1; +} + +// Returns whether the management page is showing or not. +function isManagementShowing() { + return window.location.pathname.indexOf("management") > -1; +} + +// Returns whether the history page is showing or not. +function isHistoryShowing() { + return window.location.pathname.indexOf("history") > -1; +} + +// Returns the device ID. +function getDeviceID() { + return new URLSearchParams(window.location.search).get(ID_DEVICE_ID); +} + +// Returns the device name. +function getDeviceName() { + return new URLSearchParams(window.location.search).get(ID_DEVICE_NAME); +} diff --git a/connectcore-demo-example/static/js/console.js b/connectcore-demo-example/static/js/console.js new file mode 100644 index 0000000..9647943 --- /dev/null +++ b/connectcore-demo-example/static/js/console.js @@ -0,0 +1,392 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const CONSOLE_CURSOR_BLINK = true; +const CONSOLE_NUM_ROWS = 30; +const CONSOLE_SCROLLBACK = 1000; +const CONSOLE_TAB_STOP_WIDTH = 8; +const CONSOLE_MAX_SEND_COMMANDS = 5; +const CONSOLE_SEND_COMMANDS_DELAY = 150; + +const ID_CONSOLE_CLOSE_BUTTON = "console_close_button"; +const ID_CONSOLE_CONTAINER = "console_container"; +const ID_CONSOLE_ERROR_RECONNECT = "console_error_reconnect"; +const ID_CONSOLE_ERROR_TEXT = "console_error_text"; +const ID_CONSOLE_HEADER = "console_header"; +const ID_CONSOLE_HOVER_BACKGROUND = "console_hover_background"; +const ID_CONSOLE_LOADING = "console_loading"; +const ID_CONSOLE_PANEL = "console_panel"; +const ID_CONSOLE_RECONNECT_BUTTON = "console_reconnect_button"; +const ID_CONSOLE_VIEWPORT = "xterm-viewport"; + +const CLI_MESSAGE_TYPE_DATA = "data"; +const CLI_MESSAGE_TYPE_ERROR = "error"; +const CLI_MESSAGE_TYPE_START = "start"; +const CLI_MESSAGE_TYPE_TERMINATE = "terminate"; + +const ERROR_SESSION_CLOSED_REMOTELY = "Session closed from the remote end"; +const ERROR_SESSION_CLOSING = "Previous console session is closing, please wait a moment..."; + +// Variables. +var term; +var cliSessionID; +var cliSocket; +var cliSessionTerminating = false; +var fitAddon; +var commandsToSend = []; +var cliTerminateFlagTimer = null; +var consoleResizeObserver = null; + +// Opens the console. +function openConsole() { + // Check if console is showing. + if (isConsoleShowing()) + return; + // Check if previous session is terminating. + if (cliSessionTerminating) { + toastr.info(ERROR_SESSION_CLOSING); + return; + } + // Initialize variables. + var consoleDiv = document.getElementById(ID_CONSOLE); + // Remove any residual terminals. + while (consoleDiv.firstChild) + consoleDiv.removeChild(consoleDiv.lastChild); + // Create the terminal instance. + term = new Terminal({ + cursorBlink: CONSOLE_CURSOR_BLINK, + scrollback: CONSOLE_SCROLLBACK, + tabStopWidth: CONSOLE_TAB_STOP_WIDTH, + rows: CONSOLE_NUM_ROWS + }); + // Configure terminal input data event. + term.onData( (data) => { + sendCLIData(data); + }); + // Load Fit addon. + fitAddon = new FitAddon.FitAddon(); + term.loadAddon(fitAddon); + // Attach the terminal to the div. + term.open(consoleDiv); + // Setup resize observer. + if (consoleResizeObserver == null || consoleResizeObserver == "undefined") { + consoleResizeObserver = new ResizeObserver((entries) => { + adjustConsoleSize(); + }) + consoleResizeObserver.observe(document.getElementById(ID_CONSOLE_CONTAINER)); + } + // Show the console. + var consolePanel = document.getElementById(ID_CONSOLE_PANEL); + consolePanel.style.visibility = "visible"; + consolePanel.style.display = "flex"; + // Adjust console size after some time to give time to the terminal to load. + window.setTimeout(function () { + adjustConsoleSize(); + }, 100); + adjustConsoleSize(); + // Initialize the CLI session. + initCLISession(); +} + +// Adjusts the console size. +function adjustConsoleSize() { + // Sanity checks. + if (!isConsoleShowing()) + return; + // Initialize variables. + var consoleContainer = document.getElementById(ID_CONSOLE_CONTAINER); + var consoleViewPort = document.getElementsByClassName(ID_CONSOLE_VIEWPORT)[0]; + var consoleHeader = document.getElementById(ID_CONSOLE_HEADER); + var consoleHoverBackground = document.getElementById(ID_CONSOLE_HOVER_BACKGROUND); + // Adjust terminal size. + if (fitAddon != null && fitAddon != "undefined") + fitAddon.fit(); + // Obtain dimensions. + var consoleHeight = consoleViewPort.clientHeight; + var headerHeight = consoleHeader.clientHeight; + // Set size values. + consoleContainer.style.height = (consoleHeight + headerHeight).toString() + "px"; + consoleHoverBackground.style.height = (consoleContainer.clientHeight - headerHeight).toString() + "px"; + consoleViewPort.style.width = "initial"; +} + +// Returns whether the console window is open or not. +function isConsoleShowing() { + // Sanity checks. + if (!isDashboardShowing()) + return false; + // Initialize variables. + var consolePanel = document.getElementById(ID_CONSOLE_PANEL); + // Return whether the console is showing or not. + return consolePanel.style.visibility == "visible"; +} + +// Shows/hides the console loading panel. +function showConsoleLoading(visible) { + // Initialize variables. + var consoleHoverBackground = document.getElementById(ID_CONSOLE_HOVER_BACKGROUND); + var consoleLoading = document.getElementById(ID_CONSOLE_LOADING); + // Show/hide the loading panel. + if (visible && isConsoleShowing()) { + consoleHoverBackground.style.visibility = "visible"; + consoleLoading.style.visibility = "visible"; + } else { + consoleHoverBackground.style.visibility = "hidden"; + consoleLoading.style.visibility = "hidden"; + } +} + +// Shows/hides the console error with reconnect panel. +function showConsoleErrorReconnect(visible, error) { + // Initialize variables. + var consoleHoverBackground = document.getElementById(ID_CONSOLE_HOVER_BACKGROUND); + var consoleErrorReconnect = document.getElementById(ID_CONSOLE_ERROR_RECONNECT); + var consoleErrorText = document.getElementById(ID_CONSOLE_ERROR_TEXT); + var reconnectButton = document.getElementById(ID_CONSOLE_RECONNECT_BUTTON); + var closeButton = document.getElementById(ID_CONSOLE_CLOSE_BUTTON); + // Show/hide the error panel. + if (visible && isConsoleShowing()) { + consoleHoverBackground.style.visibility = "visible"; + consoleErrorReconnect.style.visibility = "visible"; + reconnectButton.style.visibility = "visible"; + closeButton.style.visibility = "visible"; + if (error == null) + error = ERROR_UNKNOWN_ERROR; + consoleErrorText.innerText = error; + } else { + consoleHoverBackground.style.visibility = "hidden"; + consoleErrorReconnect.style.visibility = "hidden"; + reconnectButton.style.visibility = "hidden"; + closeButton.style.visibility = "hidden"; + } +} + +// Initializes a CLI session. +function initCLISession() { + // Hide error with reconnect panel. + showConsoleErrorReconnect(false); + // Clear the terminal. + term.clear(); + // Show loading panel. + showConsoleLoading(true); + $.post( + "../ajax/cli_init_session", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only if the console is showing. + if (!isConsoleShowing()) + return; + // Process answer. + processInitCLISessionResponse(data); + } + ).fail(function(response) { + // Process only if the console is showing. + if (!isConsoleShowing()) + return; + // Process error. + var error = processAjaxErrorResponse(response); + // Hide the loading status. + showConsoleLoading(false); + // Show error with reconnect panel. + showConsoleErrorReconnect(true, error); + }); +} + +// Processes the init CLI session response. +function processInitCLISessionResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Hide the loading status. + showConsoleLoading(false); + // Show error with reconnect panel. + showConsoleErrorReconnect(true, error); + } else { + // Store session ID. + cliSessionID = response[ID_SESSION_ID]; + // Register the TCP monitor. + subscribeCLISession(cliSessionID); + } +} + +// Sends the given CLI data. +function sendCLIData(data) { + // Check if CLI session exists. + if (cliSessionID == null) + return; + // Add the command to the buffer. + commandsToSend.push(data); + // If the send timer is scheduled and there is enough data to send, + // return to let the timer to complete. + if (sendTimerScheduled && commandsToSend.length > CONSOLE_MAX_SEND_COMMANDS) + return; + if (sendTimer != null && sendTimer != "undefined") { + clearTimeout(sendTimer); + sendTimer = null; + } + // Schedule the timer. + sendTimer = setTimeout(function() { + // Clear timer flag. + sendTimerScheduled = false; + // Build data. + var dataToSend = btoa(commandsToSend.join("")); + commandsToSend = []; + $.post( + "../ajax/cli_data", + JSON.stringify({ + "device_id": getDeviceID(), + "session_id": cliSessionID, + "data": dataToSend + }), + function(data) { + // Process only if the console is showing. + if (!isConsoleShowing()) + return; + // Process answer. + processCLISendDataResponse(data); + } + ).fail(function(response) { + // Process only if the console is showing. + if (!isConsoleShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); + }, CONSOLE_SEND_COMMANDS_DELAY); + // Set timer flag. + sendTimerScheduled = true; +} + +// Processes the send CLI data response. +function processCLISendDataResponse(response) { + // Check if there was any error in the request. + checkErrorResponse(response, false); +} + +// Closes the console. +function closeConsole() { + // Check if console is showing. + if (!isConsoleShowing()) + return; + // Hide the loading panel. + showConsoleLoading(false); + // Hide the error reconnect panel. + showConsoleErrorReconnect(false); + // Terminate the CLI session. + terminateCLIsession(); + // Hide the console. + var consolePanel = document.getElementById(ID_CONSOLE_PANEL); + consolePanel.style.visibility = "collapse"; + consolePanel.style.display = "none"; +} + +// Terminates the CLI session. +function terminateCLIsession() { + // Check if CLI session exists. + if (cliSessionID == null) + return; + // Flag session terminating. + cliSessionTerminating = true; + cliTerminateFlagTimer = window.setTimeout(function () { + cliSessionTerminating = false; + }, 30000); // In the case the terminate request hangs, set a timeout to manually remove the flag. + // Send request to terminate CLI session. + $.post( + "../ajax/cli_terminate_session", + JSON.stringify({ + "device_id": getDeviceID(), + "session_id": cliSessionID + }), + function(data) { + // Process only if the console is showing. + if (!isConsoleShowing()) + return; + // Process answer. + processTerminateCLISessionResponse(data); + } + ).fail(function(response) { + // Un-flag session terminating. + cliSessionTerminating = false; + window.clearTimeout(cliTerminateFlagTimer); + // Process only if the console is showing. + if (!isConsoleShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); + // Clear CLI session ID. + cliSessionID = null; +} + +// Processes the terminate CLI session response. +function processTerminateCLISessionResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Un-flag session terminating. + cliSessionTerminating = false; + window.clearTimeout(cliTerminateFlagTimer); + } +} + +// Subscribes to any CLI session change. +function subscribeCLISession(sessionID) { + // Create the web socket. + var socketPrefix = window.location.protocol == "https:" ? "wss" : "ws"; + cliSocket = new WebSocket(socketPrefix + "://" + window.location.host + "/ws/cli/" + device.getDeviceID() + "/" + sessionID); + // Define the callback to be notified when data is received in the web socket. + cliSocket.onmessage = function(e) { + if (isDashboardShowing() && term != null && term != "undefined") { + var event = JSON.parse(e.data); + var type = event[ID_TYPE]; + switch (type) { + case CLI_MESSAGE_TYPE_DATA: + var data = event[ID_DATA]; + var decodedData = atob(data); + if (isConsoleShowing()) + term.write(decodedData); + break; + case CLI_MESSAGE_TYPE_TERMINATE: + case CLI_MESSAGE_TYPE_ERROR: + cliSessionID = null; + if (cliSocket != null && cliSocket != "undefined") + cliSocket.close(); + // Hide the loading status. + showConsoleLoading(false); + // Check specific type. + var error = null; + if (type == CLI_MESSAGE_TYPE_TERMINATE && isConsoleShowing()) + error = ERROR_SESSION_CLOSED_REMOTELY; + else if (type == CLI_MESSAGE_TYPE_ERROR) + error = event[ID_ERROR]; + if (isConsoleShowing()) + showConsoleErrorReconnect(true, error); + if (error != null && (type == CLI_MESSAGE_TYPE_ERROR || + (type == CLI_MESSAGE_TYPE_TERMINATE && isConsoleShowing()))) + toastr.error(error); + // Un-flag session terminating. + cliSessionTerminating = false; + window.clearTimeout(cliTerminateFlagTimer); + break; + case CLI_MESSAGE_TYPE_START: + // Hide the loading status. + showConsoleLoading(false); + break; + } + } + }; +} diff --git a/connectcore-demo-example/static/js/dashboard.js b/connectcore-demo-example/static/js/dashboard.js new file mode 100644 index 0000000..e6c97dc --- /dev/null +++ b/connectcore-demo-example/static/js/dashboard.js @@ -0,0 +1,1045 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_AUDIO_PANEL = "audio_panel"; +const ID_AUDIO_PANEL_AREA = "audio_panel_area"; +const ID_AUDIO_PANEL_ARROW = "audio_panel_arrow"; +const ID_AUDIO_PANEL_ICON = "audio_panel_icon"; +const ID_AUDIO_SLIDER_CONTAINER = "audio_volume"; +const ID_BOARD_IMAGE = "board_image"; +const ID_BOARD_IMAGE_CONTAINER = "board_image_container"; +const ID_CONSOLE_PANEL_AREA = "console_panel_area"; +const ID_CONSOLE_PANEL_ICON = "console_panel_icon"; +const ID_CPU_PANEL = "cpu_panel"; +const ID_CPU_PANEL_AREA = "cpu_panel_area"; +const ID_CPU_PANEL_ARROW = "cpu_panel_arrow"; +const ID_CPU_PANEL_ICON = "cpu_panel_icon"; +const ID_DEVICE_BOARD = "device_board"; +const ID_DEVICE_INFO_TOGGLE_BUTTON = "device_info_toggle_button"; +const ID_DEVICE_INFO_PANEL_HEADER = "device_info_panel_header"; +const ID_DEVICE_INFO_PANEL_CONTAINER = "device_info_panel_container"; +const ID_DEVICE_TOOLBAR = "device_toolbar"; +const ID_ETHERNET_PANEL = "ethernet_panel"; +const ID_ETHERNET_PANEL_AREA = "ethernet_panel_area"; +const ID_ETHERNET_PANEL_ARROW = "ethernet_panel_arrow"; +const ID_ETHERNET_PANEL_ICON = "ethernet_panel_icon"; +const ID_FLASH_MEMORY_PANEL = "flash_memory_panel"; +const ID_FLASH_MEMORY_PANEL_AREA = "flash_memory_panel_area"; +const ID_FLASH_MEMORY_PANEL_ARROW = "flash_memory_panel_arrow"; +const ID_FLASH_MEMORY_PANEL_ICON = "flash_memory_panel_icon"; +const ID_HELP_PANEL = "help_panel"; +const ID_HELP_POPUP_SHOWN = "help_popup_shown"; +const ID_LED_PANEL = "led_panel"; +const ID_LED_PANEL_AREA = "led_panel_area"; +const ID_LED_PANEL_ARROW = "led_panel_arrow"; +const ID_MEMORY_PANEL = "memory_panel"; +const ID_MEMORY_PANEL_AREA = "memory_panel_area"; +const ID_MEMORY_PANEL_ARROW = "memory_panel_arrow"; +const ID_MEMORY_PANEL_ICON = "memory_panel_icon"; +const ID_PLATFORM_NAME = "platform_name"; +const ID_VIDEO_BRIGHTNESS_CONTAINER = "video_brightness_container"; +const ID_VIDEO_PANEL = "video_panel"; +const ID_VIDEO_PANEL_AREA = "video_panel_area"; +const ID_VIDEO_PANEL_ARROW = "video_panel_arrow"; +const ID_VIDEO_PANEL_ICON = "video_panel_icon"; +const ID_VIDEO_SLIDER_CONTAINER = "video_brightness"; +const ID_WIFI_BT_PANEL = "wifi_bt_panel"; +const ID_WIFI_BT_PANEL_AREA = "wifi_bt_panel_area"; +const ID_WIFI_BT_PANEL_ARROW = "wifi_bt_panel_arrow"; +const ID_WIFI_BT_PANEL_ICON = "wifi_bt_panel_icon"; + +const IFACE_BT = "hci0/"; +const IFACE_ETHERNET = "eth0/"; +const IFACE_WIFI = "wlan0/"; + +const USER_LED = "user_led"; + +const PREFIX_STREAM = "system_monitor/"; + +const STREAM_CPU_LOAD = PREFIX_STREAM + "cpu_load"; +const STREAM_CPU_FREQUENCY = PREFIX_STREAM + "frequency"; +const STREAM_CPU_TEMPERATURE = PREFIX_STREAM + "cpu_temperature"; +const STREAM_CPU_UPTIME = PREFIX_STREAM + "uptime"; +const STREAM_ETHERNET_READ_BYTES = PREFIX_STREAM + IFACE_ETHERNET + "rx_bytes"; +const STREAM_ETHERNET_SENT_BYTES = PREFIX_STREAM + IFACE_ETHERNET + "tx_bytes"; +const STREAM_ETHERNET_STATE = PREFIX_STREAM + IFACE_ETHERNET + "state"; +const STREAM_MEMORY_FREE = PREFIX_STREAM + "free_memory"; +const STREAM_MEMORY_USED = PREFIX_STREAM + "used_memory"; +const STREAM_WIFI_READ_BYTES = PREFIX_STREAM + IFACE_WIFI + "rx_bytes"; +const STREAM_WIFI_SENT_BYTES = PREFIX_STREAM + IFACE_WIFI + "tx_bytes"; +const STREAM_WIFI_STATE = PREFIX_STREAM + IFACE_WIFI + "state"; +const STREAM_BT_READ_BYTES = PREFIX_STREAM + IFACE_BT + "rx_bytes"; +const STREAM_BT_SENT_BYTES = PREFIX_STREAM + IFACE_BT + "tx_bytes"; +const STREAM_BT_STATE = PREFIX_STREAM + IFACE_BT + "state"; + +const PANEL_ARROW_WIDTH_100 = 20; +const PANEL_BOARD_WIDTH_100 = 1200; + +const CLASS_ARROW_DOWN = "fa-caret-down"; +const CLASS_ARROW_UP = "fa-caret-up"; +const CLASS_LED_PANEL_AREA_ON = "led-panel-area-on"; +const CLASS_PANEL_AREA_SELECTED = "panel-area-selected"; +const CLASS_PANEL_AREA_ICON_SELECTED = "panel-area-icon-selected"; +const CLASS_PANEL_TOOLTIP = "panel-tooltip"; +const CLASS_VALUE_ANIMATION = "value-animation"; +const CLASS_VALUE_UPDATED = "value-updated"; + +const MESSAGE_CHANGING_VIDEO_BRIGHTNESS = "Changing video brightness..."; +const MESSAGE_CHANGING_AUDIO_VOLUME = "Changing audio volume..."; +const MESSAGE_READING_DEVICE_INFO = "Reading device info..."; +const MESSAGE_READING_DEVICE_STATUS = "Reading device status..."; +const MESSAGE_TOGGLING_LED_VALUE = "Toggling LED value..."; + +const ERROR_LED_UNKNOWN = "LED status has not been read yet, please wait."; +const ERROR_NOT_SUPPORTED_DEVICE_MESSAGE = "The selected device type is not supported: {0}"; +const ERROR_NOT_SUPPORTED_DEVICE_TITLE = "Unsupported device"; + +// Variables. +var deviceInitialized = false; +var device = null; +var components = {}; +var sendTimerScheduled = false; +var sendTimer = null; +var ledStatus = VALUE_UNKNOWN; +var dataPointsSocket = null; +var volume = 50; +var brightness = 50; +var componentsInitialized = false; +var initializingDevice = false; +var videoSlider = null; +var audioSlider = null; +var redrawTimer = null; + +// Initializes the sliders. +function initSliders() { + // Audio slider. + audioSlider = new Slider("#" + ID_AUDIO_SLIDER_CONTAINER, { + min: 0, + max: 100, + value: 50, + orientation: "horizontal", + tooltip: "hide", + handle: "round", + formatter: function(value) { + return value + "%"; + } + }); + audioSlider.on("slideStop", function(sliderValue) { + volumeChanged(sliderValue); + }); + // Video slider. + videoSlider = new Slider("#" + ID_VIDEO_SLIDER_CONTAINER, { + min: 0, + max: 100, + value: 50, + orientation: "horizontal", + tooltip: "hide", + handle: "round", + formatter: function(value) { + return value + "%"; + } + }); + videoSlider.on("slideStop", function(sliderValue) { + brightnessChanged(sliderValue); + }); +} + +// Initializes the device. +function initDevice() { + // Sanity checks. + if (initializingDevice) + return; + // Flag initializing. + initializingDevice = true; + // Check device state. + if (deviceInitialized && device.getDeviceID() == getDeviceID()) { + // Draw the device. + drawDevice(); + // Read device status. + readDeviceStatus(); + // Position components after some time to give time to the image to load. + window.setTimeout(function () { + positionComponents(); + setInfoPanelsVisible(false); + }, 500); + } else { + // Flag the device as not initialized. + deviceInitialized = false; + // Read all device info. + readDeviceInfo(); + } +} + +// Gets the information of the device. +function readDeviceInfo() { + // Execute only in the dashboard page. + if (!isDashboardShowing()) + return; + // Hide the info popup. + showInfoPopup(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_READING_DEVICE_INFO); + // Send request to retrieve device information. + $.post( + "../ajax/get_device_info", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the dashboard page. + if (!isDashboardShowing()) { + initializingDevice = false; + return; + } + // Process device information answer. + processDeviceInfoResponse(data); + } + ).fail(function(response) { + // Stop device initialization. + initializingDevice = false; + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the device info request. +function processDeviceInfoResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, true)) { + // Do not continue with device status. + initializingDevice = false; + return; + } + // Create the device. + if (!createDevice(response)) { + // Device initialization failed, do not continue. + initializingDevice = false; + return; + } + // Position components after some time to give time to the image to load. + window.setTimeout(function () { + positionComponents(); + setInfoPanelsVisible(false); + }, 500); + // Read device status. + readDeviceStatus(); +} + +// Reads the device status. +function readDeviceStatus() { + // Execute only in the dashboard page. + if (!isDashboardShowing()) + return; + // Hide the info popup. + showInfoPopup(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_READING_DEVICE_STATUS); + // Send request to retrieve device status. + $.post( + "../ajax/get_device_status", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the dashboard page. + if (!isDashboardShowing()) { + initializingDevice = false; + return; + } + // Process device status answer. + processDeviceStatusResponse(data); + } + ).fail(function(response) { + // Flag that the initializing variable. + initializingDevice = false; + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the device status request. +function processDeviceStatusResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, true)) { + // Do not continue. + initializingDevice = false; + return; + } + // Update the device status values. + updateDataPointsValues(response); + // Set LED value to a known status. + ledStatus = VALUE_UNKNOWN; + setLEDValue(USER_LED, false); + // Show the help popup if needed. + var helpShown = sessionStorage.getItem(ID_HELP_POPUP_SHOWN); + if (helpShown == null || helpShown == "false") { + setHelpPopupVisible(true); + sessionStorage.setItem(ID_HELP_POPUP_SHOWN, "true"); + } +} + +// Creates the device. +function createDevice(deviceData) { + // Create the correct device instance. + device = null; + switch (deviceData[ID_DEVICE_TYPE]) { + case CCIMX8MMINI.DEVICE_TYPE: + device = new CCIMX8MMINI(getDeviceID(), deviceData); + break; + case CCIMX8MNANO.DEVICE_TYPE: + device = new CCIMX8MNANO(getDeviceID(), deviceData); + break; + case CCIMX8X.DEVICE_TYPE: + device = new CCIMX8X(getDeviceID(), deviceData); + break; + } + if (device != null) { + // Draw the device. + drawDevice(); + // Automatically receive updates. + subscribeDataPoints(); + // Set device as initialized. + deviceInitialized = true; + // Device created successfully. + return true; + } else { + // Not recognized device, display error. + toastr.error(ERROR_NOT_SUPPORTED_DEVICE_TITLE); + // Hide the loading panel of the device. + showLoadingPopup(false); + // Show info dialog. + showInfoPopup(true, ERROR_NOT_SUPPORTED_DEVICE_TITLE, ERROR_NOT_SUPPORTED_DEVICE_MESSAGE.format(deviceData[ID_DEVICE_TYPE])); + // Device creation failed. + return false; + } +} + +// Draws the device. +function drawDevice() { + // Initialize variables. + var boardImage = document.getElementById(ID_BOARD_IMAGE); + // Draw the device board image. + $(boardImage).attr("src", "../static/images/" + device.getBoardImage()); + boardImage.style.width = device.getBoardImageScale() + "%"; + boardImage.style.maxWidth = device.getBoardImageScale() + "%"; + boardImage.style.height = "auto"; + // Set the device name. + updateFieldValue(ID_PLATFORM_NAME, device.getPlatformName()); + // Set the sample rate. + updateFieldValue(ID_SAMPLE_RATE, device.getSampleRate()); + // Set the number of samples to upload. + updateFieldValue(ID_NUM_SAMPLES_UPLOAD, device.getNumSamplesUpload()); + // Initialize the device component panels. + initializeComponents(); + // Position device components. + positionComponents(); + // Update the device information values. + updateInfoValues(); +} + +// Initializes the device components. +function initializeComponents() { + // CPU component. + var cpuPanel = document.getElementById(ID_CPU_PANEL); + var cpuPanelArrow = document.getElementById(ID_CPU_PANEL_ARROW); + var cpuPanelArea = document.getElementById(ID_CPU_PANEL_AREA); + var cpuPanelIcon = document.getElementById(ID_CPU_PANEL_ICON); + var cpuInfo = {"panel": cpuPanel, "arrow": cpuPanelArrow, "area": cpuPanelArea, "icon": cpuPanelIcon, "data": device.getCPUComponentData()}; + components[ID_CPU] = cpuInfo; + // Memory component. + var memoryPanel = document.getElementById(ID_MEMORY_PANEL); + var memoryPanelArrow = document.getElementById(ID_MEMORY_PANEL_ARROW); + var memoryPanelArea = document.getElementById(ID_MEMORY_PANEL_AREA); + var memoryPanelIcon = document.getElementById(ID_MEMORY_PANEL_ICON); + var memoryInfo = {"panel": memoryPanel, "arrow": memoryPanelArrow, "area": memoryPanelArea, "icon": memoryPanelIcon, "data": device.getMemoryComponentData()}; + components[ID_MEMORY] = memoryInfo; + // WiFi/BT component. + var wifiBtPanel = document.getElementById(ID_WIFI_BT_PANEL); + var wifiBtPanelArrow = document.getElementById(ID_WIFI_BT_PANEL_ARROW); + var wifiBtPanelArea = document.getElementById(ID_WIFI_BT_PANEL_AREA); + var wifiBtPanelIcon = document.getElementById(ID_WIFI_BT_PANEL_ICON); + var wifiBtInfo = {"panel": wifiBtPanel, "arrow": wifiBtPanelArrow, "area": wifiBtPanelArea, "icon": wifiBtPanelIcon, "data": device.getWifiBtComponentData()}; + components[ID_WIFI_BT] = wifiBtInfo; + // Ethernet component. + var ethernetPanel = document.getElementById(ID_ETHERNET_PANEL); + var ethernetPanelArrow = document.getElementById(ID_ETHERNET_PANEL_ARROW); + var ethernetPanelArea = document.getElementById(ID_ETHERNET_PANEL_AREA); + var ethernetPanelIcon = document.getElementById(ID_ETHERNET_PANEL_ICON); + var ethernetInfo = {"panel": ethernetPanel, "arrow": ethernetPanelArrow, "area": ethernetPanelArea, "icon": ethernetPanelIcon, "data": device.getEthernetComponentData()}; + components[ID_ETHERNET] = ethernetInfo; + // Console component. + var consolePanelArea = document.getElementById(ID_CONSOLE_PANEL_AREA); + var consolePanelIcon = document.getElementById(ID_CONSOLE_PANEL_ICON); + var consoleInfo = {"area": consolePanelArea, "icon": consolePanelIcon, "data": device.getConsoleComponentData()}; + components[ID_CONSOLE] = consoleInfo; + // Video component. + var videoPanel = document.getElementById(ID_VIDEO_PANEL); + var videoPanelArrow = document.getElementById(ID_VIDEO_PANEL_ARROW); + var videoPanelArea = document.getElementById(ID_VIDEO_PANEL_AREA); + var videoPanelIcon = document.getElementById(ID_VIDEO_PANEL_ICON); + var videoInfo = {"panel": videoPanel, "arrow": videoPanelArrow, "area": videoPanelArea, "icon": videoPanelIcon, "data": device.getVideoComponentData()}; + components[ID_VIDEO] = videoInfo; + if (!device.supportsVideoBrightness()) { + var videoBrightnessContainer = document.getElementById(ID_VIDEO_BRIGHTNESS_CONTAINER); + if (videoBrightnessContainer != null && videoBrightnessContainer != "undefined") + videoBrightnessContainer.style.display = "none"; + } + // Audio component. + var audioPanel = document.getElementById(ID_AUDIO_PANEL); + var audioPanelArrow = document.getElementById(ID_AUDIO_PANEL_ARROW); + var audioPanelArea = document.getElementById(ID_AUDIO_PANEL_AREA); + var audioPanelIcon = document.getElementById(ID_AUDIO_PANEL_ICON); + var audioInfo = {"panel": audioPanel, "arrow": audioPanelArrow, "area": audioPanelArea, "icon": audioPanelIcon, "data": device.getAudioComponentData()}; + components[ID_AUDIO] = audioInfo; + // LED component. + var ledPanel = document.getElementById(ID_LED_PANEL); + var ledPanelArrow = document.getElementById(ID_LED_PANEL_ARROW); + var ledPanelArea = document.getElementById(ID_LED_PANEL_AREA); + var ledInfo = {"panel": ledPanel, "arrow": ledPanelArrow, "area": ledPanelArea, "data": device.getLEDComponentData()}; + components[ID_LED] = ledInfo; + // Flash memory component. + var flashPanel = document.getElementById(ID_FLASH_MEMORY_PANEL); + var flashPanelArrow = document.getElementById(ID_FLASH_MEMORY_PANEL_ARROW); + var flashPanelArea = document.getElementById(ID_FLASH_MEMORY_PANEL_AREA); + var flashPanelIcon = document.getElementById(ID_FLASH_MEMORY_PANEL_ICON); + var flashInfo = {"panel": flashPanel, "arrow": flashPanelArrow, "area": flashPanelArea, "icon": flashPanelIcon, "data": device.getFlashMemoryComponentData()}; + components[ID_FLASH_MEMORY] = flashInfo; +} + +// Positions the different components. +function positionComponents() { + // Get Board Image dimensions. + var boardImage = document.getElementById(ID_BOARD_IMAGE); + var boardWidth = boardImage.clientWidth; + var boardHeight = boardImage.clientHeight; + if (boardWidth == 0 || dashboardHeight == 0) + return; + // Get Header height. + var headerHeight = 0; + var header = document.getElementById(ID_DEVICE_TOOLBAR); + if (header != "undefined") + headerHeight = header.clientHeight; + // Get Dashboard size. + var dashboardHeight = 0; + var dashboardWidth = 0; + var dashboard = document.getElementById(ID_DEVICE_BOARD); + if (dashboard != "undefined") { + dashboardWidth = dashboard.clientWidth; + dashboardHeight = dashboard.clientHeight; + } + // Position panels. + for (var component in components) + positionComponent(components[component], boardWidth, boardHeight, headerHeight, dashboardHeight, dashboardWidth); +} + +// Positions an specific component. +function positionComponent(component, boardWidth, boardHeight, headerHeight, dashboardHeight, dashboardWidth) { + // Sanity check. + if (component == "undefined" || component[ID_DATA] == null || component[ID_DATA] == "undefined") + return; + // Initialize variables + var panelElement = component[ID_PANEL]; + var panelArrow = component[ID_ARROW]; + var panelArea = component[ID_AREA]; + var panelIcon = component[ID_ICON]; + var componentData = component[ID_DATA]; + var isVisible = componentData[ID_VISIBLE]; + var hasPanel = componentData[ID_HAS_PANEL] && panelElement != null && panelElement != "undefined"; + var hasArrow = componentData[ID_HAS_ARROW] && panelArrow != null && panelArrow != "undefined"; + var hasIcon = panelIcon != null && panelIcon != "undefined"; + var horizontalMargin = (dashboardWidth - boardWidth) / 2; + // Check panel visibility. + if (!isVisible) { + if (panelArea != null) + panelArea.style.visibility = "hidden"; + if (panelElement != null) + panelElement.style.visibility = "hidden"; + return; + } + // Calculate new icon size. + if (hasIcon) { + var iconSize = Math.min(panelArea.clientWidth * 0.7, panelArea.clientHeight * 0.7); // 30% is margin. + panelIcon.style.fontSize = iconSize.toString() + "px"; + } + // Position the panel area. + panelArea.style.left = (horizontalMargin + (boardWidth * componentData[ID_AREA_LEFT_MARGIN]) / 100).toString() + "px"; + panelArea.style.top = (((boardHeight * componentData[ID_AREA_TOP_MARGIN]) / 100) + headerHeight).toString() + "px"; + panelArea.style.width = ((boardWidth * componentData[ID_AREA_WIDTH]) / 100).toString() + "px"; + panelArea.style.height = ((boardHeight * componentData[ID_AREA_HEIGHT]) / 100).toString() + "px"; + // If there is no information panel, return. + if (!hasPanel) + return; + // Calculate the panel location. + var horizontalPixels = horizontalMargin + (boardWidth * componentData[ID_PANEL_HORIZONTAL_MARGIN]) / 100; + var verticalPixels = (boardHeight * componentData[ID_PANEL_VERTICAL_MARGIN]) / 100; + // Calculate the new size of the arrow. + var arrowSize = boardWidth * PANEL_ARROW_WIDTH_100 / PANEL_BOARD_WIDTH_100; + panelArrow.style.border = arrowSize.toString() + "px solid #fff"; + var arrowHeight = Math.sin(45) * arrowSize; + // Calculate new arrow location. + var arrowMargin = 0; + if (hasArrow) { + switch(componentData[ID_PANEL_ORIENTATION]) { + case VALUE_LEFT: + case VALUE_RIGHT: + arrowMargin = ((boardHeight * componentData[ID_ARROW_MARGIN]) / 100) - verticalPixels; + break; + case VALUE_TOP: + case VALUE_BOTTOM: + arrowMargin = horizontalMargin + ((boardWidth * componentData[ID_ARROW_MARGIN]) / 100) - horizontalPixels; + break; + } + } + // Position panel and arrow depending on the orientation. + switch(componentData[ID_PANEL_ORIENTATION]) { + case VALUE_LEFT: + panelElement.style.left = (horizontalPixels).toString() + "px"; + panelElement.style.top = (headerHeight + verticalPixels).toString() + "px"; + panelElement.style.right = "initial"; + panelElement.style.bottom = "initial"; + if (hasArrow) { + panelArrow.style.left = (-1 * arrowHeight).toString() + "px"; + panelArrow.style.top = arrowMargin.toString() + "px"; + } + break; + case VALUE_RIGHT: + panelElement.style.right = (horizontalPixels).toString() + "px"; + panelElement.style.top = (headerHeight + verticalPixels).toString() + "px"; + panelElement.style.left = "initial"; + panelElement.style.bottom = "initial"; + if (hasArrow) { + panelArrow.style.right = (-1 * arrowHeight).toString() + "px"; + panelArrow.style.top = arrowMargin.toString() + "px"; + } + break; + case VALUE_TOP: + panelElement.style.left = horizontalPixels.toString() + "px"; + panelElement.style.top = (headerHeight + verticalPixels).toString() + "px"; + panelElement.style.right = "initial"; + panelElement.style.bottom = "initial"; + if (hasArrow) { + panelArrow.style.left = arrowMargin.toString() + "px"; + panelArrow.style.top = (-1 * arrowHeight).toString() + "px"; + } + break; + case VALUE_BOTTOM: + panelElement.style.left = horizontalPixels.toString() + "px"; + panelElement.style.bottom = (verticalPixels + dashboardHeight - boardHeight - headerHeight).toString() + "px"; + panelElement.style.right = "initial"; + panelElement.style.top = "initial"; + if (hasArrow) { + panelArrow.style.left = arrowMargin.toString() + "px"; + panelArrow.style.bottom = (-1 * arrowHeight).toString() + "px"; + } + break; + } +} + +// Updates the device information values. +function updateInfoValues() { + // Set Device ID. + updateFieldValue(ID_DEVICE_ID, device.getDeviceID()); + // Set serial number. + updateFieldValue(ID_SERIAL_NUMBER, device.getSerialNumber()); + // Set DEY version. + updateFieldValue(ID_DEY_VERSION, device.getDEYVersion()); + // Set Kernel version. + updateFieldValue(ID_KERNEL_VERSION, device.getKernelVersion()); + // Set U-Boot version. + updateFieldValue(ID_UBOOT_VERSION, device.getUbootVersion()); + // Set module variant. + updateFieldValue(ID_MODULE_VARIANT, device.getModuleVariant()); + // Set board variant. + updateFieldValue(ID_BOARD_VARIANT, device.getBoardVariant()); + // Set board ID. + updateFieldValue(ID_BOARD_ID, device.getBoardID()); + // Set MCA FW version. + updateFieldValue(ID_MCA_FW_VERSION, device.getMCAFWVersion()); + // Set MCA HW version. + updateFieldValue(ID_MCA_HW_VERSION, device.getMCAHWVersion()); + // Set Ethernet MAC address. + updateFieldValue(ID_ETHERNET_MAC, device.getEthernetMAC()); + // Set Ethernet IP address. + updateFieldValue(ID_ETHERNET_IP, device.getEthernetIP()); + // Set Wi-Fi MAC address. + updateFieldValue(ID_WIFI_MAC, device.getWifiMAC()); + // Set Wi-Fi IP address. + updateFieldValue(ID_WIFI_IP, device.getWifiIP()); + // Set Bluetooth MAC address. + updateFieldValue(ID_BLUETOOTH_MAC, device.getBluetoothMAC()); + // Set total memory. + updateFieldValue(ID_MEMORY_TOTAL, kiloBytesToMegaBytes(device.getMemoryTotal())); + // Set flash size. + updateFieldValue(ID_FLASH_SIZE, roundToGigaBytes(device.getFlashSize())); + // Set video resolution. + updateFieldValue(ID_VIDEO_RESOLUTION, device.getVideoResolution()); +} + +// Updates the device data points values. +function updateDataPointsValues(response) { + // Iterate the streams in the response. + for (var key in response) + updateDataPointValue(key, response[key]); +} + +// Updates the given data stream value. +function updateDataPointValue(streamID, value) { + if (!streamID.startsWith(PREFIX_STREAM)) + streamID = PREFIX_STREAM + streamID; + switch (streamID) { + case STREAM_CPU_LOAD: + updateValueWithEffect(ID_CPU_LOAD, roundToTwoDecimals(value)); + break; + case STREAM_CPU_TEMPERATURE: + updateValueWithEffect(ID_CPU_TEMPERATURE, roundToTwoDecimals(value)); + break; + case STREAM_CPU_FREQUENCY: + updateValueWithEffect(ID_CPU_FREQUENCY, (value / 1000)); + break; + case STREAM_CPU_UPTIME: + updateValueWithEffect(ID_CPU_UPTIME, secondsToTime(value)); + break; + case STREAM_MEMORY_FREE: + updateValueWithEffect(ID_MEMORY_FREE, kiloBytesToMegaBytes(value)); + break; + case STREAM_MEMORY_USED: + updateValueWithEffect(ID_MEMORY_USED, kiloBytesToMegaBytes(value)); + break; + case STREAM_ETHERNET_STATE: + updateValueWithEffect(ID_ETHERNET_STATE, onOffStatus(value)); + break; + case STREAM_ETHERNET_READ_BYTES: + updateValueWithEffect(ID_ETHERNET_READ_DATA, sizeToHumanRead(value)); + break; + case STREAM_ETHERNET_SENT_BYTES: + updateValueWithEffect(ID_ETHERNET_SENT_DATA, sizeToHumanRead(value)); + break; + case STREAM_WIFI_STATE: + updateValueWithEffect(ID_WIFI_STATE, onOffStatus(value)); + break; + case STREAM_WIFI_READ_BYTES: + updateValueWithEffect(ID_WIFI_READ_DATA, sizeToHumanRead(value)); + break; + case STREAM_WIFI_SENT_BYTES: + updateValueWithEffect(ID_WIFI_SENT_DATA, sizeToHumanRead(value)); + break; + case STREAM_BT_STATE: + updateValueWithEffect(ID_BT_STATE, onOffStatus(value)); + break; + case STREAM_BT_READ_BYTES: + updateValueWithEffect(ID_BT_READ_DATA, sizeToHumanRead(value)); + break; + case STREAM_BT_SENT_BYTES: + updateValueWithEffect(ID_BT_SENT_DATA, sizeToHumanRead(value)); + break; + } +} + +// Updates the value of the given element ID. +function updateValueWithEffect(elementID, value) { + // Initialize variables. + var htmlElement = document.getElementById(elementID); + // Sanity checks. + if (htmlElement == null || htmlElement == "undefined" || value == null) + return; + // Apply value and classes. + htmlElement.classList.add(CLASS_VALUE_UPDATED); + htmlElement.innerText = value; + htmlElement.classList.add(CLASS_VALUE_ANIMATION); + setTimeout(function() { + htmlElement.classList.remove(CLASS_VALUE_UPDATED); + setTimeout(function() { + htmlElement.classList.remove(CLASS_VALUE_ANIMATION); + }, 3000); + }, 2000); +} + +// Toggles the visibility of the given component information panel. +function toggleInfoPanelVisibility(componentName) { + // Sanity checks. + var component = components[componentName]; + if (component == null || component == "undefined" || component[ID_PANEL] == null || component[ID_PANEL] == "undefined") + return; + // Apply visibility.. + if (component[ID_PANEL].style.visibility == "visible") + setInfoPanelVisible(componentName, false); + else + setInfoPanelVisible(componentName, true); +} + +// Changes the visibility of the components information panels. +function setInfoPanelsVisible(visible) { + // Sanity checks. + if (!isDashboardShowing()) + return; + // Iterate all panels. + for (var component in components) + setInfoPanelVisible(component, visible); +} + +// Changes the visibility of the given component information panel. +function setInfoPanelVisible(componentName, visible) { + // Sanity checks. + var component = components[componentName]; + if (component == null || component == "undefined") + return; + var hasArrow = component[ID_DATA][ID_HAS_ARROW] && component[ID_ARROW] != null && component[ID_ARROW] != "undefined"; + var hasIcon = component[ID_ICON] != null && component[ID_ICON] != "undefined"; + // Icon is always visible. + if (hasIcon) + component[ID_ICON].style.visibility = "visible"; + // Apply visibility. + if (component[ID_DATA][ID_PANEL_ALWAYS_VISIBLE] == true) { + if (hasArrow && visible) + component[ID_ARROW].style.visibility = "visible"; + else + component[ID_ARROW].style.visibility = "hidden"; + component[ID_PANEL].style.visibility = "visible"; + component[ID_AREA].classList.remove(CLASS_PANEL_AREA_SELECTED); + component[ID_AREA].classList.add(CLASS_PANEL_TOOLTIP); + } else if (component[ID_DATA][ID_VISIBLE] == true && visible) { + if (component[ID_PANEL] != null && component[ID_PANEL] != "undefined") { + if (hasArrow) + component[ID_ARROW].style.visibility = "visible"; + else + component[ID_ARROW].style.visibility = "hidden"; + component[ID_PANEL].style.visibility = "visible"; + component[ID_AREA].classList.add(CLASS_PANEL_AREA_SELECTED); + component[ID_AREA].classList.remove(CLASS_PANEL_TOOLTIP); + if (hasIcon) + component[ID_ICON].classList.add(CLASS_PANEL_AREA_ICON_SELECTED); + } + } else { + if (component[ID_PANEL] != null && component[ID_PANEL] != "undefined") { + component[ID_ARROW].style.visibility = "hidden"; + component[ID_PANEL].style.visibility = "hidden"; + component[ID_AREA].classList.remove(CLASS_PANEL_AREA_SELECTED); + component[ID_AREA].classList.add(CLASS_PANEL_TOOLTIP); + } + if (component[ID_DATA][ID_VISIBLE] == false && hasIcon) + component[ID_ICON].style.visibility = "hidden"; + else if (hasIcon) + component[ID_ICON].classList.remove(CLASS_PANEL_AREA_ICON_SELECTED); + } +} + +// Toggles the visibility of the device info panel. +function toggleDeviceInfoVisibility() { + // Initialize variables. + var deviceInfoPanel = document.getElementById(ID_DEVICE_INFO_PANEL_CONTAINER); + var deviceInfoButton = document.getElementById(ID_DEVICE_INFO_TOGGLE_BUTTON); + // Sanity checks. + if (deviceInfoPanel == null || deviceInfoButton == null) + return; + // Check visibility. + if (deviceInfoButton.classList.contains(CLASS_ARROW_UP)) { + $("#" + ID_DEVICE_INFO_PANEL_CONTAINER).slideUp("fast", function() { + deviceInfoButton.classList.remove(CLASS_ARROW_UP); + deviceInfoButton.classList.add(CLASS_ARROW_DOWN); + adjustImageSize(); + }); + } else { + $("#" + ID_DEVICE_INFO_PANEL_CONTAINER).slideDown("fast", function() { + deviceInfoButton.classList.remove(CLASS_ARROW_DOWN); + deviceInfoButton.classList.add(CLASS_ARROW_UP); + adjustImageSize(); + }); + } +} + +// Toggles the visibility of the help popup. +function toggleHelpPopup() { + // Initialize variables. + var helpPopup = document.getElementById(ID_HELP_PANEL); + // Sanity checks. + if (helpPopup == null) + return; + // Check visibility. + if (helpPopup.style.visibility == "visible") { + setHelpPopupVisible(false); + sessionStorage.setItem(ID_HELP_POPUP_SHOWN, "true"); + } else + setHelpPopupVisible(true); +} + +// Changes the visibility of the help popup. +function setHelpPopupVisible(visible) { + // Initialize variables. + var helpPanel = document.getElementById(ID_HELP_PANEL); + // Sanity checks. + if (helpPanel == null) + return; + // Apply visibility. + if (visible) + helpPanel.style.visibility = "visible"; + else + helpPanel.style.visibility = "hidden"; +} + +// Adjust the image board size. +function adjustImageSize() { + // Sanity checks. + if (!isDashboardShowing() || device == null || device == "undefined") + return; + // Initialize variables. + var deviceBoardElement = document.getElementById(ID_DEVICE_BOARD); + var boardImageElement = document.getElementById(ID_BOARD_IMAGE); + var deviceInfoHeaderElement = document.getElementById(ID_DEVICE_INFO_PANEL_HEADER); + var deviceInfoContainerElement = document.getElementById(ID_DEVICE_INFO_PANEL_CONTAINER); + var deviceToolbarElement = document.getElementById(ID_DEVICE_TOOLBAR); + var dashboardHeight = deviceBoardElement.getBoundingClientRect().height; + var toolbarHeight = deviceToolbarElement.getBoundingClientRect().height; + var deviceInfoContainerHeight = deviceInfoContainerElement.getBoundingClientRect().height; + var deviceInfoHeaderHeight = deviceInfoHeaderElement.getBoundingClientRect().height; + var infoHeight = deviceInfoContainerHeight + deviceInfoHeaderHeight; + var availableImageHeight = dashboardHeight - infoHeight - toolbarHeight - 20; // .device-info -> margin-top + // Adjust size. + do { + var newWidthPercent = availableImageHeight * parseInt(boardImageElement.style.width.replace("%", "")) / boardImageElement.getBoundingClientRect().height; + if (newWidthPercent > device.getBoardImageScale()) + newWidthPercent = device.getBoardImageScale(); + boardImageElement.style.width = newWidthPercent + "%"; + positionComponents(); + } while (boardImageElement.getBoundingClientRect().height > (dashboardHeight - toolbarHeight - infoHeight)) + // Force a redraw, icons do not display correctly at first. + if (redrawTimer != null) + clearTimeout(redrawTimer); + redrawTimer = setTimeout(positionComponents, 200); +} + +// Processes a video brightness changed event. +function brightnessChanged(newValue) { + // Show the loading panel of the device. + showLoadingPopup(true, MESSAGE_CHANGING_VIDEO_BRIGHTNESS); + // Disable the slider. + videoSlider.disable(); + // Send request to change the video brightness value. + $.post( + "../ajax/set_video_brightness", + JSON.stringify({ + "device_id": getDeviceID(), + "value": newValue + }), + function(data) { + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process answer. + processSetVideoBrightnessResponse(data); + } + ).fail(function(response) { + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading panel of the device. + showLoadingPopup(false); + // Restore the slider value. + videoSlider.setValue(brightness); + // Enable the slider. + videoSlider.enable(); + }); +} + +// Processes the "set video brightness" request answer. +function processSetVideoBrightnessResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Restore the slider value. + videoSlider.setValue(brightness); + } else { + // Save new brightness value. + brightness = videoSlider.getValue(); + } + // Hide the loading panel of the device. + showLoadingPopup(false); + // Enable the slider. + videoSlider.enable(); +} + +// Processes an audio volume changed event. +function volumeChanged(newValue) { + // Show the loading panel of the device. + showLoadingPopup(true, MESSAGE_CHANGING_AUDIO_VOLUME); + // Disable the slider. + audioSlider.disable(); + // Send request to change the audio volume value. + $.post( + "../ajax/set_audio_volume", + JSON.stringify({ + "device_id": getDeviceID(), + "value": newValue + }), + function(data) { + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process answer. + processSetAudioVolumeResponse(data); + } + ).fail(function(response) { + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading panel of the device. + showLoadingPopup(false); + // Restore the slider value. + audioSlider.setValue(volume); + // Enable the slider. + audioSlider.enable(); + }); +} + +// Processes the "set audio volume" request answer. +function processSetAudioVolumeResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Restore the slider value. + audioSlider.setValue(volume); + } else { + // Save new volume value. + volume = audioSlider.getValue(); + } + // Hide the loading panel of the device. + showLoadingPopup(false); + // Enable the slider. + audioSlider.enable(); +} + +// Toggles the user LED. +function toggleUserLED() { + toggleLED(USER_LED); +} + +// Toggles the status of the given LED. +function toggleLED(ledName) { + // Sanity checks. + if (ledStatus == VALUE_UNKNOWN) { + toastr.info(ERROR_LED_UNKNOWN); + return; + } + // Execute action. + setLEDValue(ledName, !ledStatus); +} + +// Sets the value of the given LED. +function setLEDValue(ledName, ledValue) { + // Show the loading panel of the device. + showLoadingPopup(true, MESSAGE_TOGGLING_LED_VALUE); + // Send request to change the LED status. + $.post( + "../ajax/set_led_value", + JSON.stringify({ + "device_id": getDeviceID(), + "led_name": ledName, + "value": ledValue + }), + function(data) { + // Finish initialization. + initializingDevice = false; + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process answer. + processSetLEDResponse(data); + } + ).fail(function(response) { + // Finish initialization. + initializingDevice = false; + // Process only in the dashboard page. + if (!isDashboardShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading panel of the device. + showLoadingPopup(false); + // Hide the info panel of the device. + showInfoPopup(false); + }); +} + +// Processes the set LED request answer. +function processSetLEDResponse(response) { + // Position components after some time to give time to the image to load. + window.setTimeout(function () { + positionComponents(); + setInfoPanelsVisible(false); + }, 500); + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Update the LED status. + updateLEDStatus(); + } + // Hide the loading panel of the device. + showLoadingPopup(false); + // Hide the info panel of the device. + showInfoPopup(false); +} + +// Updates the LED status. +function updateLEDStatus() { + // Initialize variables. + var ledPanelArea = document.getElementById(ID_LED_PANEL_AREA); + // Update LED value. + if (ledStatus == VALUE_UNKNOWN) + ledStatus = false; + else + ledStatus = !ledStatus; + if (ledPanelArea == null || ledPanelArea == undefined) + return; + // Change LED panel area class. + if (ledStatus) + ledPanelArea.classList.add(CLASS_LED_PANEL_AREA_ON); + else + ledPanelArea.classList.remove(CLASS_LED_PANEL_AREA_ON); +} + +// Handles what happens when the change sample rate button is pressed. +function changeSampleRate() { + // Navigate to management page. + window.open("../management/?device_id=" + getDeviceID() + "&device_name=" + getDeviceName(), "_self"); +} + +// Subscribes to any datapoint change. +function subscribeDataPoints() { + // Sanity checks. + if (dataPointsSocket != null) + return; + // Create the web socket. + var socketPrefix = window.location.protocol == "https:" ? "wss" : "ws"; + dataPointsSocket = new WebSocket(socketPrefix + "://" + window.location.host + "/ws/datapoints/" + device.getDeviceID()); + // Define the callback to be notified when data is received in the web socket. + dataPointsSocket.onmessage = function(e) { + if (isDashboardShowing()) { + // Initialize variables. + var event = JSON.parse(e.data); + var stream = event[ID_STREAM]; + var value = event[ID_VALUE]; + // Update the datapoint value. + updateDataPointValue(stream, value); + } + }; +} diff --git a/connectcore-demo-example/static/js/data-usage.js b/connectcore-demo-example/static/js/data-usage.js new file mode 100644 index 0000000..79ebea6 --- /dev/null +++ b/connectcore-demo-example/static/js/data-usage.js @@ -0,0 +1,202 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_DATA_USAGE_BUTTON = "data_usage_button"; +const ID_DATA_USAGE_CURRENT_DEVICE = "data_usage_current_device"; +const ID_DATA_USAGE_GRAPHIC_WEB = "data_usage_graphic_web"; +const ID_DATA_USAGE_GRAPHIC_DEVICES = "data_usage_graphic_devices"; +const ID_DATA_USAGE_ICON = "data_usage_icon"; +const ID_DATA_USAGE_LOADING = "data_usage_loading"; +const ID_DATA_USAGE_PANEL = "data_usage_panel"; + +// Returns whether the data usage panel is open or not. +function isDataUsageShowing() { + // Initialize variables. + var dataUsagePanel = document.getElementById(ID_DATA_USAGE_PANEL); + // Return visibility. + return dataUsagePanel.style.display != "none"; +} + +// Toggles the data usage panel visibility. +function toggleDataUsagePanel() { + // Initialize variables. + var dataUsageIcon = document.getElementById(ID_DATA_USAGE_ICON); + var dataUsageButton = document.getElementById(ID_DATA_USAGE_BUTTON); + // Avoid double clicks. + dataUsageButton.style.pointerEvents = "none"; + // Check data usage panel visibility. + if (isDataUsageShowing()) { + $("#" + ID_DATA_USAGE_PANEL).slideUp("fast", function() { + dataUsageIcon.src = "../static/images/data_usage.png"; + // Enable hover effect. + $("#" + ID_DATA_USAGE_BUTTON).on({ + "mouseover" : function() { + dataUsageIcon.src = "../static/images/data_usage_green.png"; + }, + "mouseout" : function() { + dataUsageIcon.src = "../static/images/data_usage.png"; + } + }); + // React to mouse events again. + dataUsageButton.style.pointerEvents = "auto"; + // Reset fields. + clearDataUsageFields(); + }); + } else { + $("#" + ID_DATA_USAGE_PANEL).slideDown("fast", function() { + dataUsageIcon.src = "../static/images/data_usage_green.png"; + // Disable hover effect. + $("#" + ID_DATA_USAGE_BUTTON).on({ + "mouseover" : function() { + dataUsageIcon.src = "../static/images/data_usage_green.png"; + }, + "mouseout" : function() { + dataUsageIcon.src = "../static/images/data_usage_green.png"; + } + }); + // React to mouse events again. + dataUsageButton.style.pointerEvents = "auto"; + // Read data usage. + readDataUsage(); + }); + } +} + +// Reads the DRM account data usage. +function readDataUsage() { + // Sanity checks. + if (!isDataUsageShowing()) + return; + // Show the data usage loading panel. + showDataUsageLoading(true); + // Send request to change the LED status. + $.post( + "../ajax/get_data_usage", + function(data) { + // Process only if the panel is showing. + if (!isDataUsageShowing()) + return; + // Process answer. + processReadDataUsageResponse(data); + } + ).fail(function(response) { + // Process only if the panel is showing. + if (!isDataUsageShowing()) + return; + // Process error. + error = processAjaxErrorResponse(response); + // Hide the data usage loading panel. + showDataUsageLoading(true); + }); +} + +// Processes the read data usage response. +function processReadDataUsageResponse(response) { + // Hide the data usage loading panel. + showDataUsageLoading(false); + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Update the data usage values. + updateDataUsageValues(response); + } +} + +// Updates the data usage values. +function updateDataUsageValues(response) { + // Sanity checks. + if (!isDataUsageShowing()) + return; + // Initialize variables. + var dataUsageTotal = response[ID_DATA_USAGE_TOTAL]; + var dataUsageWeb = response[ID_DATA_USAGE_WEB]; + var dataUsageDevices = response[ID_DATA_USAGE_DEVICES]; + var dataUsageDevicesPercent = 0; + var dataUsageWebPercent = 0; + var dataUsageCurrentDevice = 0; + var graphicDevicesElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_DEVICES); + var graphicWebElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_WEB); + // Calculate percent for data devices. + if (dataUsageTotal > 0) { + dataUsageDevicesPercent = Math.round(dataUsageDevices * 100 / dataUsageTotal); + dataUsageWebPercent = Math.round(dataUsageWeb * 100 / dataUsageTotal); + } + // Calculate values for totals. + dataUsageDevices = sizeToHumanRead(dataUsageDevices * 1000 * 1000); // This usage is given in MB. + dataUsageWeb = sizeToHumanRead(dataUsageWeb * 1000 * 1000); // This usage is given in MB. + // Retrieve the data usage for the current device. + for (var device in response[ID_DEVICES]) { + if (response[ID_DEVICES][device][ID_DEVICE_ID].toLowerCase() == getDeviceID().toLowerCase()) { + dataUsageCurrentDevice = response[ID_DEVICES][device][ID_USAGE]; + break; + } + } + // Set percentage size of graphics. + graphicDevicesElement.style.width = dataUsageDevicesPercent + "%"; + graphicWebElement.style.width = dataUsageWebPercent + "%"; + // Set graphics tooltips. + graphicDevicesElement.setAttribute("data-original-title", "Total data usage by devices: " + dataUsageDevices + " (" + dataUsageDevicesPercent + "%)"); + graphicWebElement.setAttribute("data-original-title", "Total data usage by web APIs: " + dataUsageWeb + " (" + dataUsageWebPercent + "%)"); + // Update the data usage values. + updateFieldValue(ID_DATA_USAGE_TOTAL, sizeToHumanRead(dataUsageTotal * 1000 * 1000)); // This usage is given in MB. + updateFieldValue(ID_DATA_USAGE_DEVICES, dataUsageDevices); + updateFieldValue(ID_DATA_USAGE_CURRENT_DEVICE, sizeToHumanRead(dataUsageCurrentDevice * 1000)); // This usage is given in KB. + updateFieldValue(ID_DATA_USAGE_WEB, dataUsageWeb); + updateFieldValue(ID_DATA_USAGE_WEB_SERVICES, sizeToHumanRead(response[ID_DATA_USAGE_WEB_SERVICES] * 1000)); // This usage is given in KB. + updateFieldValue(ID_DATA_USAGE_MONITORS, sizeToHumanRead(response[ID_DATA_USAGE_MONITORS] * 1000)); // This usage is given in KB. +} + +// Shows/hides the data usage loading panel. +function showDataUsageLoading(visible) { + // Sanity checks. + if (!isDataUsageShowing()) + return; + // Initialize variables. + var dataUsageLoading = document.getElementById(ID_DATA_USAGE_LOADING); + // Show the data usage loading panel. + if (visible) + dataUsageLoading.style.display = "block"; + else + dataUsageLoading.style.display = "none"; +} + +// Clears all data usage fields. +function clearDataUsageFields() { + // Initialize variables. + var graphicDevicesElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_DEVICES); + var graphicWebElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_WEB); + // Clear all data usage fields. + updateFieldValue(ID_DATA_USAGE_TOTAL, ""); + updateFieldValue(ID_DATA_USAGE_DEVICES, ""); + updateFieldValue(ID_DATA_USAGE_CURRENT_DEVICE, ""); + updateFieldValue(ID_DATA_USAGE_WEB, ""); + updateFieldValue(ID_DATA_USAGE_WEB_SERVICES, ""); + updateFieldValue(ID_DATA_USAGE_MONITORS, ""); + // Reset graphic sizes. + graphicDevicesElement.style.width = "0%"; + graphicWebElement.style.width = "0%"; +} + +// Refreshes the usage data. +function refreshUsageData() { + // Sanity checks. + if (!isDataUsageShowing()) + return; + // Clear all data usage fields. + clearDataUsageFields(); + // Read data usage. + readDataUsage(); +} diff --git a/connectcore-demo-example/static/js/devices.js b/connectcore-demo-example/static/js/devices.js new file mode 100644 index 0000000..5765d84 --- /dev/null +++ b/connectcore-demo-example/static/js/devices.js @@ -0,0 +1,805 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED = "add-device-button-disabled"; +const CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR = "add-device-input-error"; +const CLASS_DEVICE_SELECTED = "devices-list-entry-selected"; + +const ERROR_DEVICE_ID_EMPTY = "A Device ID or MAC Address must be provided."; +const ERROR_DEVICE_ID_INVALID = "A device id format is 00000000-00000000-00000000-00000000, while a mac address format is 00:00:00:00:00:00 (optional colon separators)"; +const ERROR_INVALID_PROVISION_VALUE = "Provided provision value was not valid."; + +const ID_ADD_DEVICE_DIALOG = "add_device_dialog"; +const ID_ADD_DEVICE_DIALOG_BUTTON = "add_device_button"; +const ID_ADD_DEVICE_DIALOG_ERROR = "add_device_error"; +const ID_ADD_DEVICE_DIALOG_INPUT = "add_device_input"; +const ID_CONTINUE_BUTTON = "continue-button"; +const ID_DEVICES_LIST = "devices-list"; +const ID_REFRESH_BUTTON = "refresh-button"; + +const MESSAGE_LOADING_DEVICES = "Loading devices..." +const MESSAGE_REGISTERING_DEVICE = "Registering device..." + +const PROVISION_TYPE_ID = "id"; +const PROVISION_TYPE_MAC = "mac"; +const PROVISION_TYPE_IMEI = "imei"; + +const REGEX_DEVICE_ID = "^(?:[a-fA-F0-9]{8}-){3}[a-fA-F0-9]{8}$"; +const REGEX_DEVICE_MAC = "^(?:[a-fA-F0-9]{2}:?){5}[a-fA-F0-9]{2}$"; +const REGEX_DEVICE_IMEI = "^[0-9]{15}$"; + +const TEMPLATE_COMPONENT_DATA = "" + + "{" + + " \"" + ID_VISIBLE + "\" : {0}," + + " \"" + ID_HAS_PANEL + "\" : {1}," + + " \"" + ID_HAS_ARROW + "\" : {2}," + + " \"" + ID_PANEL_ALWAYS_VISIBLE + "\" : {3}," + + " \"" + ID_PANEL_ORIENTATION + "\" : \"{4}\"," + + " \"" + ID_PANEL_HORIZONTAL_MARGIN + "\" : {5}," + + " \"" + ID_PANEL_VERTICAL_MARGIN + "\" : {6}," + + " \"" + ID_ARROW_MARGIN + "\" : {7}," + + " \"" + ID_AREA_TOP_MARGIN + "\" : {8}," + + " \"" + ID_AREA_LEFT_MARGIN + "\" : {9}," + + " \"" + ID_AREA_WIDTH + "\" : {10}," + + " \"" + ID_AREA_HEIGHT + "\" : {11}" + + "}" +const TEMPLATE_DEVICE_LIST_ENTRY = "" + + "
" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
@@TYPE@@
@@ID@@
" + + "
"; + +// Variables. +var devices = []; + +// Lists DRM devices. +function listDevices() { + // Disable the refresh button. + document.getElementById(ID_REFRESH_BUTTON).disabled = true; + // Disable the continue button. + document.getElementById(ID_CONTINUE_BUTTON).disabled = true; + // Clear the devices list + clearDevices(); + // Hide info dialog. + showInfoPopup(false); + // Show loading dialog. + showLoadingPopup(true, MESSAGE_LOADING_DEVICES); + // Send the request. + $.post( + "../ajax/get_devices", + function(data) { + // Hide the loading panel. + showLoadingPopup(false); + // Process answer. + processListDevicesAnswer(data); + // Enable the refresh button. + document.getElementById(ID_REFRESH_BUTTON).disabled = false; + // Update continue button. + updateContinueButton(); + } + ).fail(function(response) { + // Hide the loading panel. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + // Enable the refresh button. + document.getElementById(ID_REFRESH_BUTTON).disabled = false; + }); +} + +// Processes the answer of the list devices request. +function processListDevicesAnswer(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Do not continue. + return; + } + // Get the devices from the JSON response. + let readDevices = response[ID_DEVICES]; + // Check if the list of devices contains any device. + if (readDevices == null || readDevices.length == 0) + return; + // Process devices. + for (let device of readDevices) { + // Add a new device entry to the list of devices. + devices.push(device); + let deviceDivContent = TEMPLATE_DEVICE_LIST_ENTRY; + deviceDivContent = deviceDivContent.replace(/@@ID@@/g, device[ID_ID]); + deviceDivContent = deviceDivContent.replace(/@@TYPE@@/g, device[ID_TYPE]); + if (device[ID_ONLINE] == true) + deviceDivContent = deviceDivContent.replace(/@@STATUS_IMAGE@@/g, IMAGE_ONLINE); + else + deviceDivContent = deviceDivContent.replace(/@@STATUS_IMAGE@@/g, IMAGE_OFFLINE); + let deviceDiv = document.createElement("div"); + deviceDiv.innerHTML = deviceDivContent; + $("#" + ID_DEVICES_LIST).append(deviceDiv); + } +} + +// Clears the list of devices. +function clearDevices() { + unselectDevices(); + devices = []; + $("#" + ID_DEVICES_LIST).html(""); +} + +// Selects the given device +function selectDevice(deviceID) { + // Unselect all devices. + unselectDevices(); + // Set selected style to the selected device div. + if (document.getElementById(deviceID) != null) + document.getElementById(deviceID).classList.add(CLASS_DEVICE_SELECTED); + // Save selected device. + for (i = 0; i < devices.length; i++) { + device = devices[i]; + if (device[ID_ID] == deviceID) + selectedDevice = device; + } + // Configure continue button. + updateContinueButton(); +} + +// Unselects all the devices. +function unselectDevices() { + // Clear selected style from all device divs. + for (i = 0; i < devices.length; i++) { + device = devices[i]; + if (document.getElementById(device[ID_ID]) != null) + document.getElementById(device[ID_ID]).classList.remove(CLASS_DEVICE_SELECTED); + } + // Remove selected device. + selectedDevice = null; + // Configure continue button. + updateContinueButton(); +} + +// Updates the continue button state. +function updateContinueButton() { + // Initialize variables. + var continueButton = document.getElementById(ID_CONTINUE_BUTTON); + // Check if there is any selected device. + if (selectedDevice != null) { + continueButton.disabled = false; + continueButton.onclick = function() {openSelectedDevice();}; + } else { + continueButton.disabled = true; + continueButton.onclick = function() { }; + } +} + +// Opens the selected device +function openSelectedDevice() { + // Avoid double click. + document.getElementById(ID_CONTINUE_BUTTON).disabled = true; + // Show loading dialog. + showLoadingPopup(true); + // Navigate to device dashboard page. + window.open("../dashboard/?device_id=" + selectedDevice[ID_ID] + "&device_name=" + selectedDevice[ID_TYPE], "_self"); +} + +// Opens the "Add device" dialog. +function openAddDeviceDialog() { + // Initialize variables. + var addDeviceInputElement = document.getElementById(ID_ADD_DEVICE_DIALOG_INPUT); + var addDeviceButtonElement = document.getElementById(ID_ADD_DEVICE_DIALOG_BUTTON); + var addDeviceErrorElement = document.getElementById(ID_ADD_DEVICE_DIALOG_ERROR); + // Reset dialog state. + addDeviceInputElement.value = ""; + addDeviceErrorElement.innerHTML = " "; + addDeviceErrorElement.style.visibility = "hidden"; + if (!addDeviceButtonElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED)) + addDeviceButtonElement.classList.add(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED); + if (addDeviceInputElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR)) + addDeviceInputElement.classList.remove(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR); + // Show panel. + showAddDeviceDialog(true); +} + +// Closes the "Add device" dialog. +function closeAddDeviceDialog() { + showAddDeviceDialog(false); +} + +// Shows/hides the "Add device" dialog. +function showAddDeviceDialog(visible) { + // Initialize variables. + var addDeviceDialogElement = document.getElementById(ID_ADD_DEVICE_DIALOG); + var addDeviceErrorElement = document.getElementById(ID_ADD_DEVICE_DIALOG_ERROR); + // Apply visible state. + if (visible) + addDeviceDialogElement.style.visibility = "visible"; + else { + addDeviceDialogElement.style.visibility = "hidden"; + addDeviceErrorElement.style.visibility = "hidden"; + } +} + +// Validates the device ID. +function validateDeviceID(deviceID) { + // Initialize variables. + var addDeviceInputElement = document.getElementById(ID_ADD_DEVICE_DIALOG_INPUT); + var addDeviceButtonElement = document.getElementById(ID_ADD_DEVICE_DIALOG_BUTTON); + var addDeviceErrorElement = document.getElementById(ID_ADD_DEVICE_DIALOG_ERROR); + var isValid = true; + var error = ERROR_DEVICE_ID_INVALID; + // Check if the device ID is valid. + if (deviceID == null || deviceID == "") { + isValid = false; + error = ERROR_DEVICE_ID_EMPTY; + } else + isValid = deviceID.match(REGEX_DEVICE_ID) || deviceID.match(REGEX_DEVICE_MAC) || deviceID.match(REGEX_DEVICE_IMEI); + // Update controls. + if (isValid) { + if (addDeviceButtonElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED)) + addDeviceButtonElement.classList.remove(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED); + if (addDeviceInputElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR)) + addDeviceInputElement.classList.remove(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR); + addDeviceErrorElement.innerHTML = " "; + addDeviceErrorElement.style.visibility = "hidden"; + } else { + if (!addDeviceButtonElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED)) + addDeviceButtonElement.classList.add(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED); + if (!addDeviceInputElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR)) + addDeviceInputElement.classList.add(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR); + addDeviceErrorElement.innerHTML = error; + addDeviceErrorElement.style.visibility = "visible"; + } +} + +// Handles what happens when the "Register device" button is pressed. +function onRegisterDevice() { + // Initialize variables. + var addDeviceInputElement = document.getElementById(ID_ADD_DEVICE_DIALOG_INPUT); + var provisionValue = addDeviceInputElement.value; + var provisionType = ""; + // Determine provision type. + if (provisionValue.match(REGEX_DEVICE_ID)) + provisionType = PROVISION_TYPE_ID; + else if (provisionValue.match(REGEX_DEVICE_MAC)) + provisionType = PROVISION_TYPE_MAC; + else if (provisionValue.match(REGEX_DEVICE_IMEI)) + provisionType = PROVISION_TYPE_IMEI; + else { + toastr.error(ERROR_INVALID_PROVISION_VALUE); + return; + } + // Register the device. + registerDevice(provisionValue, provisionType); +} + +// Registers the given device ID. +function registerDevice(provisionValue, provisionType) { + // Disable the refresh button. + document.getElementById(ID_REFRESH_BUTTON).disabled = true; + // Disable the continue button. + document.getElementById(ID_CONTINUE_BUTTON).disabled = true; + // Close the add device dialog. + closeAddDeviceDialog(); + // Hide info dialog. + showInfoPopup(false); + // Show loading dialog. + showLoadingPopup(true, MESSAGE_REGISTERING_DEVICE); + // Send the request. + $.post( + "../ajax/register_device", + JSON.stringify({ + "provision_value": provisionValue, + "provision_type": provisionType + }), + function(data) { + // Hide the loading panel. + showLoadingPopup(false); + // Process answer. + processRegisterDeviceAnswer(data); + } + ).fail(function(response) { + // Hide the loading panel. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + // Enable the refresh button. + document.getElementById(ID_REFRESH_BUTTON).disabled = false; + // Refresh the continue button. + updateContinueButton(); + }); +} + +// Processes the answer of the register device request. +function processRegisterDeviceAnswer(answer) { + // Check if there was any error in the request. + if (checkErrorResponse(answer, false)) { + // Enable the refresh button. + document.getElementById(ID_REFRESH_BUTTON).disabled = false; + // Refresh the continue button. + updateContinueButton(); + } else { + // Update the device list. + listDevices(); + } +} + +// Class that represents a ConnectCore device. +class ConnectCoreDevice { + + // Variables + // Board image. + BOARD_IMAGE; + BOARD_IMAGE_SCALE; + + // CPU panel. + CPU_COMPONENT_VISIBLE = false; + CPU_COMPONENT_HAS_PANEL = false; + CPU_COMPONENT_HAS_ARROW = false; + CPU_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CPU_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + CPU_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + CPU_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + CPU_COMPONENT_ARROW_PERCENT = 0; + CPU_COMPONENT_AREA_TOP_PERCENT = 0; + CPU_COMPONENT_AREA_LEFT_PERCENT = 0; + CPU_COMPONENT_AREA_WIDTH_PERCENT = 0; + CPU_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Memory panel. + MEMORY_COMPONENT_VISIBLE = false; + MEMORY_COMPONENT_HAS_PANEL = false; + MEMORY_COMPONENT_HAS_ARROW = false; + MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + MEMORY_COMPONENT_ARROW_PERCENT = 0; + MEMORY_COMPONENT_AREA_TOP_PERCENT = 0; + MEMORY_COMPONENT_AREA_LEFT_PERCENT = 0; + MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 0; + MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // WiFi/BT panel. + WIFI_BT_COMPONENT_VISIBLE = false; + WIFI_BT_COMPONENT_HAS_PANEL = false; + WIFI_BT_COMPONENT_HAS_ARROW = false; + WIFI_BT_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + WIFI_BT_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + WIFI_BT_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + WIFI_BT_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + WIFI_BT_COMPONENT_ARROW_PERCENT = 0; + WIFI_BT_COMPONENT_AREA_TOP_PERCENT = 0; + WIFI_BT_COMPONENT_AREA_LEFT_PERCENT = 0; + WIFI_BT_COMPONENT_AREA_WIDTH_PERCENT = 0; + WIFI_BT_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Ethernet panel. + ETHERNET_COMPONENT_VISIBLE = false; + ETHERNET_COMPONENT_HAS_PANEL = false; + ETHERNET_COMPONENT_HAS_ARROW = false; + ETHERNET_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + ETHERNET_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + ETHERNET_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + ETHERNET_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + ETHERNET_COMPONENT_ARROW_PERCENT = 0; + ETHERNET_COMPONENT_AREA_TOP_PERCENT = 0; + ETHERNET_COMPONENT_AREA_LEFT_PERCENT = 0; + ETHERNET_COMPONENT_AREA_WIDTH_PERCENT = 0; + ETHERNET_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Console. + CONSOLE_COMPONENT_VISIBLE = false; + CONSOLE_COMPONENT_HAS_PANEL = false; + CONSOLE_COMPONENT_HAS_ARROW = false; + CONSOLE_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + CONSOLE_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + CONSOLE_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + CONSOLE_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + CONSOLE_COMPONENT_ARROW_PERCENT = 0; + CONSOLE_COMPONENT_AREA_TOP_PERCENT = 0; + CONSOLE_COMPONENT_AREA_LEFT_PERCENT = 0; + CONSOLE_COMPONENT_AREA_WIDTH_PERCENT = 0; + CONSOLE_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Video panel. + VIDEO_COMPONENT_VISIBLE = false; + VIDEO_COMPONENT_HAS_PANEL = false; + VIDEO_COMPONENT_HAS_ARROW = false; + VIDEO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + VIDEO_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + VIDEO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + VIDEO_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + VIDEO_COMPONENT_ARROW_PERCENT = 0; + VIDEO_COMPONENT_AREA_TOP_PERCENT = 0; + VIDEO_COMPONENT_AREA_LEFT_PERCENT = 0; + VIDEO_COMPONENT_AREA_WIDTH_PERCENT = 0; + VIDEO_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Audio panel. + AUDIO_COMPONENT_VISIBLE = false; + AUDIO_COMPONENT_HAS_PANEL = false; + AUDIO_COMPONENT_HAS_ARROW = false; + AUDIO_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + AUDIO_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + AUDIO_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + AUDIO_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + AUDIO_COMPONENT_ARROW_PERCENT = 0; + AUDIO_COMPONENT_AREA_TOP_PERCENT = 0; + AUDIO_COMPONENT_AREA_LEFT_PERCENT = 0; + AUDIO_COMPONENT_AREA_WIDTH_PERCENT = 0; + AUDIO_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // LED panel. + LED_COMPONENT_VISIBLE = false; + LED_COMPONENT_HAS_PANEL = false; + LED_COMPONENT_HAS_ARROW = false; + LED_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + LED_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + LED_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + LED_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + LED_COMPONENT_ARROW_PERCENT = 0; + LED_COMPONENT_AREA_TOP_PERCENT = 0; + LED_COMPONENT_AREA_LEFT_PERCENT = 0; + LED_COMPONENT_AREA_WIDTH_PERCENT = 0; + LED_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Flash memory panel. + FLASH_MEMORY_COMPONENT_VISIBLE = false; + FLASH_MEMORY_COMPONENT_HAS_PANEL = false; + FLASH_MEMORY_COMPONENT_HAS_ARROW = false; + FLASH_MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE = false; + FLASH_MEMORY_COMPONENT_PANEL_ORIENTATION = VALUE_TOP; + FLASH_MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT = 0; + FLASH_MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT = 0; + FLASH_MEMORY_COMPONENT_ARROW_PERCENT = 0; + FLASH_MEMORY_COMPONENT_AREA_TOP_PERCENT = 0; + FLASH_MEMORY_COMPONENT_AREA_LEFT_PERCENT = 0; + FLASH_MEMORY_COMPONENT_AREA_WIDTH_PERCENT = 0; + FLASH_MEMORY_COMPONENT_AREA_HEIGHT_PERCENT = 0; + + // Capabilities + SUPPORTS_VIDEO_BRIGHTNESS; + + // Device information. + #deviceType; + #platformName; + #deviceID; + #serialNumber; + #ubootVersion; + #kernelVersion; + #deyVersion; + #moduleVariant; + #boardVariant; + #boardID; + #mcaHWVersion; + #mcaFWVersion; + #ethernetMAC; + #ethernetIP; + #wifiMAC; + #wifiIP; + #bluetoothMAC; + #memoryTotal; + #flashSize; + #videoResolution; + #sampleRate; + #numSamplesUpload; + + // Class constructor. + constructor(deviceType, platformName, deviceID, deviceData) { + this.#deviceType = deviceType; + this.#platformName = platformName; + this.#deviceID = deviceID; + this.#initDevice(deviceData); + } + + // Initializes the device with the provided data. + #initDevice(deviceData) { + this.#ubootVersion = deviceData[ID_UBOOT_VERSION]; + this.#serialNumber = deviceData[ID_SERIAL_NUMBER]; + this.#kernelVersion = deviceData[ID_KERNEL_VERSION]; + this.#deyVersion = deviceData[ID_DEY_VERSION]; + this.#moduleVariant = deviceData[ID_MODULE_VARIANT]; + this.#boardVariant = deviceData[ID_BOARD_VARIANT]; + this.#boardID = deviceData[ID_BOARD_ID]; + this.#mcaHWVersion = deviceData[ID_MCA_HW_VERSION]; + this.#mcaFWVersion = deviceData[ID_MCA_FW_VERSION]; + this.#ethernetMAC = deviceData[ID_ETHERNET_MAC]; + this.#ethernetIP = deviceData[ID_ETHERNET_IP]; + this.#wifiMAC = deviceData[ID_WIFI_MAC]; + this.#wifiIP = deviceData[ID_WIFI_IP]; + this.#bluetoothMAC = deviceData[ID_BLUETOOTH_MAC]; + this.#memoryTotal = deviceData[ID_MEMORY_TOTAL]; + this.#flashSize = deviceData[ID_FLASH_SIZE]; + this.#videoResolution = deviceData[ID_VIDEO_RESOLUTION]; + this.#sampleRate = deviceData[ID_SAMPLE_RATE]; + this.#numSamplesUpload = deviceData[ID_NUM_SAMPLES_UPLOAD]; + } + + // Returns the device type. + getDeviceType() { + return this.#deviceType; + } + + // Returns the platform name. + getPlatformName() { + return this.#platformName; + } + + // Returns the device serial number. + getSerialNumber() { + return this.#serialNumber; + } + + // Returns the device ID. + getDeviceID() { + return this.#deviceID; + } + + // Returns the board image file name. + getBoardImage() { + return this.BOARD_IMAGE; + } + + // Returns the board image scale. + getBoardImageScale() { + return this.BOARD_IMAGE_SCALE; + } + + // Returns the device U-Boot version. + getUbootVersion() { + return this.#ubootVersion; + } + + // Returns the device Kernel version. + getKernelVersion() { + return this.#kernelVersion; + } + + // Returns the device DEY version. + getDEYVersion() { + return this.#deyVersion; + } + + // Returns the device module variant. + getModuleVariant() { + return this.#moduleVariant; + } + + // Returns the device board variant. + getBoardVariant() { + return this.#boardVariant; + } + + // Returns the device board ID. + getBoardID() { + return this.#boardID; + } + + // Returns the device MCA hardware version. + getMCAHWVersion() { + return this.#mcaHWVersion; + } + + // Returns the device MCA firmware version. + getMCAFWVersion() { + return this.#mcaFWVersion; + } + + // Returns the device Ethernet MAC address. + getEthernetMAC() { + return this.#ethernetMAC; + } + + // Returns the device Ethernet IP address. + getEthernetIP() { + return this.#ethernetIP; + } + + // Returns the device WiFi MAC address. + getWifiMAC() { + return this.#wifiMAC; + } + + // Returns the device WiFi IP address. + getWifiIP() { + return this.#wifiIP; + } + + // Returns the device Bluetooth MAC address. + getBluetoothMAC() { + return this.#bluetoothMAC; + } + + // Returns the device total memory. + getMemoryTotal() { + return this.#memoryTotal; + } + + // Returns the device flash size. + getFlashSize() { + return this.#flashSize; + } + + // Returns the video resolution. + getVideoResolution() { + return this.#videoResolution; + } + + // Returns the sample rate. + getSampleRate() { + return this.#sampleRate; + } + + // Returns the number of samples to upload each batch. + getNumSamplesUpload() { + return this.#numSamplesUpload; + } + + // Returns the CPU panel data. + getCPUComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.CPU_COMPONENT_VISIBLE, + this.CPU_COMPONENT_HAS_PANEL, + this.CPU_COMPONENT_HAS_ARROW, + this.CPU_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.CPU_COMPONENT_PANEL_ORIENTATION, + this.CPU_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.CPU_COMPONENT_PANEL_VERTICAL_PERCENT, + this.CPU_COMPONENT_ARROW_PERCENT, + this.CPU_COMPONENT_AREA_TOP_PERCENT, + this.CPU_COMPONENT_AREA_LEFT_PERCENT, + this.CPU_COMPONENT_AREA_WIDTH_PERCENT, + this.CPU_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the Memory panel data. + getMemoryComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.MEMORY_COMPONENT_VISIBLE, + this.MEMORY_COMPONENT_HAS_PANEL, + this.MEMORY_COMPONENT_HAS_ARROW, + this.MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.MEMORY_COMPONENT_PANEL_ORIENTATION, + this.MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT, + this.MEMORY_COMPONENT_ARROW_PERCENT, + this.MEMORY_COMPONENT_AREA_TOP_PERCENT, + this.MEMORY_COMPONENT_AREA_LEFT_PERCENT, + this.MEMORY_COMPONENT_AREA_WIDTH_PERCENT, + this.MEMORY_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the WiFi panel data. + getWifiBtComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.WIFI_BT_COMPONENT_VISIBLE, + this.WIFI_BT_COMPONENT_HAS_PANEL, + this.WIFI_BT_COMPONENT_HAS_ARROW, + this.WIFI_BT_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.WIFI_BT_COMPONENT_PANEL_ORIENTATION, + this.WIFI_BT_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.WIFI_BT_COMPONENT_PANEL_VERTICAL_PERCENT, + this.WIFI_BT_COMPONENT_ARROW_PERCENT, + this.WIFI_BT_COMPONENT_AREA_TOP_PERCENT, + this.WIFI_BT_COMPONENT_AREA_LEFT_PERCENT, + this.WIFI_BT_COMPONENT_AREA_WIDTH_PERCENT, + this.WIFI_BT_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the Ethernet panel data. + getEthernetComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.ETHERNET_COMPONENT_VISIBLE, + this.ETHERNET_COMPONENT_HAS_PANEL, + this.ETHERNET_COMPONENT_HAS_ARROW, + this.ETHERNET_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.ETHERNET_COMPONENT_PANEL_ORIENTATION, + this.ETHERNET_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.ETHERNET_COMPONENT_PANEL_VERTICAL_PERCENT, + this.ETHERNET_COMPONENT_ARROW_PERCENT, + this.ETHERNET_COMPONENT_AREA_TOP_PERCENT, + this.ETHERNET_COMPONENT_AREA_LEFT_PERCENT, + this.ETHERNET_COMPONENT_AREA_WIDTH_PERCENT, + this.ETHERNET_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the Console panel data. + getConsoleComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.CONSOLE_COMPONENT_VISIBLE, + this.CONSOLE_COMPONENT_HAS_PANEL, + this.CONSOLE_COMPONENT_HAS_ARROW, + this.CONSOLE_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.CONSOLE_COMPONENT_PANEL_ORIENTATION, + this.CONSOLE_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.CONSOLE_COMPONENT_PANEL_VERTICAL_PERCENT, + this.CONSOLE_COMPONENT_ARROW_PERCENT, + this.CONSOLE_COMPONENT_AREA_TOP_PERCENT, + this.CONSOLE_COMPONENT_AREA_LEFT_PERCENT, + this.CONSOLE_COMPONENT_AREA_WIDTH_PERCENT, + this.CONSOLE_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the Video panel data. + getVideoComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.VIDEO_COMPONENT_VISIBLE, + this.VIDEO_COMPONENT_HAS_PANEL, + this.VIDEO_COMPONENT_HAS_ARROW, + this.VIDEO_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.VIDEO_COMPONENT_PANEL_ORIENTATION, + this.VIDEO_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.VIDEO_COMPONENT_PANEL_VERTICAL_PERCENT, + this.VIDEO_COMPONENT_ARROW_PERCENT, + this.VIDEO_COMPONENT_AREA_TOP_PERCENT, + this.VIDEO_COMPONENT_AREA_LEFT_PERCENT, + this.VIDEO_COMPONENT_AREA_WIDTH_PERCENT, + this.VIDEO_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the Audio panel data. + getAudioComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.AUDIO_COMPONENT_VISIBLE, + this.AUDIO_COMPONENT_HAS_PANEL, + this.AUDIO_COMPONENT_HAS_ARROW, + this.AUDIO_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.AUDIO_COMPONENT_PANEL_ORIENTATION, + this.AUDIO_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.AUDIO_COMPONENT_PANEL_VERTICAL_PERCENT, + this.AUDIO_COMPONENT_ARROW_PERCENT, + this.AUDIO_COMPONENT_AREA_TOP_PERCENT, + this.AUDIO_COMPONENT_AREA_LEFT_PERCENT, + this.AUDIO_COMPONENT_AREA_WIDTH_PERCENT, + this.AUDIO_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the LED panel data. + getLEDComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.LED_COMPONENT_VISIBLE, + this.LED_COMPONENT_HAS_PANEL, + this.LED_COMPONENT_HAS_ARROW, + this.LED_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.LED_COMPONENT_PANEL_ORIENTATION, + this.LED_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.LED_COMPONENT_PANEL_VERTICAL_PERCENT, + this.LED_COMPONENT_ARROW_PERCENT, + this.LED_COMPONENT_AREA_TOP_PERCENT, + this.LED_COMPONENT_AREA_LEFT_PERCENT, + this.LED_COMPONENT_AREA_WIDTH_PERCENT, + this.LED_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns the flash memory panel data. + getFlashMemoryComponentData() { + return JSON.parse(TEMPLATE_COMPONENT_DATA.format(this.FLASH_MEMORY_COMPONENT_VISIBLE, + this.FLASH_MEMORY_COMPONENT_HAS_PANEL, + this.FLASH_MEMORY_COMPONENT_HAS_ARROW, + this.FLASH_MEMORY_COMPONENT_PANEL_ALWAYS_VISIBLE, + this.FLASH_MEMORY_COMPONENT_PANEL_ORIENTATION, + this.FLASH_MEMORY_COMPONENT_PANEL_HORIZONTAL_PERCENT, + this.FLASH_MEMORY_COMPONENT_PANEL_VERTICAL_PERCENT, + this.FLASH_MEMORY_COMPONENT_ARROW_PERCENT, + this.FLASH_MEMORY_COMPONENT_AREA_TOP_PERCENT, + this.FLASH_MEMORY_COMPONENT_AREA_LEFT_PERCENT, + this.FLASH_MEMORY_COMPONENT_AREA_WIDTH_PERCENT, + this.FLASH_MEMORY_COMPONENT_AREA_HEIGHT_PERCENT)); + } + + // Returns whether the device supports video brightness or not. + supportsVideoBrightness() { + return this.SUPPORTS_VIDEO_BRIGHTNESS; + } +} \ No newline at end of file diff --git a/connectcore-demo-example/static/js/file-system.js b/connectcore-demo-example/static/js/file-system.js new file mode 100644 index 0000000..10952fa --- /dev/null +++ b/connectcore-demo-example/static/js/file-system.js @@ -0,0 +1,653 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_CURRENT_DIRECTORY = "current_directory"; +const ID_FILE_SYSTEM_CONTAINER = "filesystem_container"; +const ID_FILE_SYSTEM_DIR_NAME = "filesystem_directory_name"; +const ID_FILE_SYSTEM_DIR_NAME_BUTTON = "filesystem_directory_name_button"; +const ID_FILE_SYSTEM_DIR_NAME_ERROR = "filesystem_directory_name_error"; +const ID_FILE_SYSTEM_DIR_NAME_PANEL = "filesystem_dir_name_panel"; +const ID_FILE_SYSTEM_DOWNLOAD_FILE_BUTTON = "filesystem_download_file_button"; +const ID_FILE_SYSTEM_HEADER = "filesystem_header"; +const ID_FILE_SYSTEM_HOVER_BACKGROUND = "filesystem_hover_background"; +const ID_FILE_SYSTEM_ITEMS_CONTAINER = "filesystem_items_container"; +const ID_FILE_SYSTEM_ITEMS_HEADER = "filesystem_items_header"; +const ID_FILE_SYSTEM_LOADING = "filesystem_loading"; +const ID_FILE_SYSTEM_PANEL = "filesystem_panel"; +const ID_FILE_SYSTEM_REMOVE_FILE_BUTTON = "filesystem_remove_file_button"; +const ID_FILE_SYSTEM_TOOLBAR = "filesystem_toolbar"; +const ID_FILE_TO_UPLOAD = "file_to_upload"; + +const CLASS_FA_FILE = "fa-file"; +const CLASS_FILE_SYSTEM_BUTTON_DISABLED = "filesystem-button-disabled"; +const CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED = "filesystem-dir-name-button-disabled"; +const CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR = "filesystem-dir-name-input-error"; +const CLASS_FILE_SYSTEM_ENTRY_SELECTED = "filesystem-entry-selected"; + +const FS_TYPE_FILE = "file"; +const FS_TYPE_DIRECTORY = "dir"; + +const TITLE_CONFIRM_REMOVE = "Confirm Remove"; + +const MESSAGE_CONFIRM_REMOVE = "Are you sure you want to remove the selected file?"; + +const PREFIX_FS = "fs_"; + +const REGEX_DIRECTORY_NAME = '^[^\\s^\x00-\x1f\\?*:"";<>|\\/.][^\x00-\x1f\\?*:"";<>|\\/]*[^\\s^\x00-\x1f\\?*:"";<>|\\/.]+$'; + +const TEMPLATE_DIRECTORY = "" + + "
" + + "
" + + "
{3}
" + + "
" + + "
{4}
" + + "
"; +const TEMPLATE_FILE = "" + + "
" + + "
" + + "
{4}
" + + "
{5}
" + + "
{6}
" + + "
"; + +const ERROR_DIR_NAME_EMPTY = "Directory name cannot be empty."; +const ERROR_DIR_NAME_INVALID = "The entered name is not valid."; + +const ROOT_DIRECTORY = "/"; + +// Variables. +var currentDirectory = null; +var selectedFileSystemEntry = null; +var filesystemResizeObserver = null; + +// Opens the file system panel. +function openFileSystem() { + // Check if the file system is showing. + if (isFileSystemShowing()) + return; + // Reset current directory. + currentDirectory = null; + $("#" + ID_CURRENT_DIRECTORY).text(""); + // Unselect all entries. + unselectFileSystemEntries(); + // Clear all the file system entries. + clearFileSystemEntries(); + // Setup resize observer. + if (filesystemResizeObserver == null || filesystemResizeObserver == "undefined") { + filesystemResizeObserver = new ResizeObserver((entries) => { + resizeFileSystemElements(); + }) + filesystemResizeObserver.observe(document.getElementById(ID_FILE_SYSTEM_CONTAINER)); + } + // Resize filesystem elements. + resizeFileSystemElements(); + // Show the file system. + var fileSystemContainer = document.getElementById(ID_FILE_SYSTEM_PANEL); + fileSystemContainer.style.visibility = "visible"; + // List root directory. + listDirectory(ROOT_DIRECTORY); +} + +// Returns whether the file system window is open or not. +function isFileSystemShowing() { + // Sanity checks. + if (!isDashboardShowing()) + return false; + // Initialize variables. + var fileSystemContainer = document.getElementById(ID_FILE_SYSTEM_PANEL); + // Return visibility. + return fileSystemContainer.style.visibility == "visible"; +} + +// Closes the file system panel. +function closeFileSystem() { + // Check if the file system is showing. + if (!isFileSystemShowing()) + return; + // Hide the loading panel. + showFileSystemLoading(false); + // Hide the file system panel. + var fileSystemContainer = document.getElementById(ID_FILE_SYSTEM_PANEL); + fileSystemContainer.style.visibility = "collapse"; +} + +// Resizes the file system elements. +function resizeFileSystemElements() { + // If file system is not showing just return. + if (!isFileSystemShowing()) + return; + // Initialize variables. + var filesystemContainer = document.getElementById(ID_FILE_SYSTEM_CONTAINER); + var filesystemHeader = document.getElementById(ID_FILE_SYSTEM_HEADER); + var filesystemToolbar = document.getElementById(ID_FILE_SYSTEM_TOOLBAR); + var filesystemHoverBackground = document.getElementById(ID_FILE_SYSTEM_HOVER_BACKGROUND); + var filesystemItemsHeader = document.getElementById(ID_FILE_SYSTEM_ITEMS_HEADER); + var filesystemItemsContainer = document.getElementById(ID_FILE_SYSTEM_ITEMS_CONTAINER); + var containerHeight = filesystemContainer.clientHeight; + var headerHeight = filesystemHeader.clientHeight; + var toolbarHeight = filesystemToolbar.clientHeight; + var itemsHeaderHeight = filesystemItemsHeader.clientHeight; + // Set correct heights. + filesystemHoverBackground.style.height = (containerHeight - headerHeight).toString() + "px"; + filesystemItemsContainer.style.height = (containerHeight - headerHeight - toolbarHeight - itemsHeaderHeight).toString() + "px"; +} + +// Shows/hides the file system loading panel. +function showFileSystemLoading(visible) { + // Initialize variables. + var fileSystemHoverBackground = document.getElementById(ID_FILE_SYSTEM_HOVER_BACKGROUND); + var fileSystemLoading = document.getElementById(ID_FILE_SYSTEM_LOADING); + // Apply visibility. + if (visible && isFileSystemShowing()) { + fileSystemHoverBackground.style.visibility = "visible"; + fileSystemLoading.style.visibility = "visible"; + } else { + fileSystemHoverBackground.style.visibility = "hidden"; + fileSystemLoading.style.visibility = "hidden"; + } +} + +// Clears all the file system entries. +function clearFileSystemEntries() { + // Initialize variables. + var fileSystemEntriesDiv = document.getElementById(ID_FILE_SYSTEM_ITEMS_CONTAINER); + // Clear all file system HTML entries. + while (fileSystemEntriesDiv.firstChild) + fileSystemEntriesDiv.removeChild(fileSystemEntriesDiv.lastChild); +} + +// Enables/disabled the file system buttons. +function enableFileSystemButtons(enable) { + // Initialize variables. + var downloadButton = document.getElementById(ID_FILE_SYSTEM_DOWNLOAD_FILE_BUTTON); + var removeButton = document.getElementById(ID_FILE_SYSTEM_REMOVE_FILE_BUTTON); + // Apply enable state. + if (!enable) { + downloadButton.disabled = true; + removeButton.disabled = true; + downloadButton.classList.add(CLASS_FILE_SYSTEM_BUTTON_DISABLED) + removeButton.classList.add(CLASS_FILE_SYSTEM_BUTTON_DISABLED) + } else { + downloadButton.disabled = false; + removeButton.disabled = false; + downloadButton.classList.remove(CLASS_FILE_SYSTEM_BUTTON_DISABLED) + removeButton.classList.remove(CLASS_FILE_SYSTEM_BUTTON_DISABLED) + } +} + +// Selects the given file system entry. +function selectFileSystemEntry(entryID) { + // Unselect all entries. + unselectFileSystemEntries(); + // Set selected style to the selected device div. + var entryElement = document.getElementById(entryID) + if (entryElement != null) + entryElement.classList.add(CLASS_FILE_SYSTEM_ENTRY_SELECTED); + // Save selected entry. + selectedFileSystemEntry = entryID; + // Enable buttons. + enableFileSystemButtons(true); +} + +// Unselects all the file system entries. +function unselectFileSystemEntries() { + // Initialize variables. + var fileSystemEntriesDiv = document.getElementById(ID_FILE_SYSTEM_ITEMS_CONTAINER); + var children = fileSystemEntriesDiv.children; + // Remove selected class from all entries. + for (var i = 0; i < children.length; i++) { + var entry = children[i].children[0]; + entry.classList.remove(CLASS_FILE_SYSTEM_ENTRY_SELECTED); + } + // Reset selected entry. + selectedFileSystemEntry = null; + // Disable buttons. + enableFileSystemButtons(false); +} + +// Lists the contents of the given directory. +function listDirectory(directory) { + // Build path. + var path = currentDirectory; + if (path == null || currentDirectory == directory) + path = directory; + else { + if (directory.endsWith("..")) { + // Check if last slash must be removed. + if (path.endsWith("/") && path.length > ROOT_DIRECTORY.length) + path = path.substring(0, path.lastIndexOf("/")); + // Move one directory up. + path = path.substring(0, path.lastIndexOf("/")); + if (path == "") + path = ROOT_DIRECTORY; + } else { + if (!path.endsWith("/")) + path = path + "/" + path = path + directory; + } + } + // Show loading panel. + showFileSystemLoading(true); + // Send request. + $.post( + "../ajax/fs_list_directory", + JSON.stringify({ + "device_id": getDeviceID(), + "directory": path + }), + function(data) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process answer. + processListDirectoryResponse(data); + } + ).fail(function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading status. + showFileSystemLoading(false); + }); +} + +// Processes the list directory response. +function processListDirectoryResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Hide the loading status. + showFileSystemLoading(false); + // Do not continue. + return; + } + // Unselect all entries. + unselectFileSystemEntries(); + // Clear all file system entries. + clearFileSystemEntries(); + // Set current directory. + currentDirectory = response[ID_CURRENT_DIR]; + if (!currentDirectory.endsWith("/")) + currentDirectory = currentDirectory + "/"; + $("#" + ID_CURRENT_DIRECTORY).text(currentDirectory); + // Iterate over all the file system received entries. + if (response[ID_FILES] != null && response[ID_FILES] != "undefined") { + var fileSystemEntriesDiv = document.getElementById(ID_FILE_SYSTEM_ITEMS_CONTAINER); + // Process response entries and create HTML elements. + for (var entry of response[ID_FILES]) { + var name = entry[ID_NAME].substring(currentDirectory.length); + var lastModified = entry[ID_LAST_MODIFIED]; + if (lastModified == null || lastModified == "undefined" || lastModified == 0 || name == "..") { + lastModified = ""; + } else { + var date = new Date(0); // The 0 there is the key, which sets the date to the epoch + date.setUTCSeconds(lastModified); + lastModified = date.toLocaleString("en-US", { hour12:false }); + } + var entryDiv = document.createElement("div"); + if (entry[ID_TYPE] == FS_TYPE_FILE) + entryDiv.innerHTML = TEMPLATE_FILE.format(name, name, name, name, name, + sizeToHumanRead(entry[ID_SIZE]), lastModified); + else if (entry[ID_TYPE] == FS_TYPE_DIRECTORY) + entryDiv.innerHTML = TEMPLATE_DIRECTORY.format(name, name, name, name, lastModified); + if (entryDiv.innerHTML != null && entryDiv.innerHTML != "") + fileSystemEntriesDiv.appendChild(entryDiv); + } + } + // Hide the loading status. + showFileSystemLoading(false); +} + +// Downloads the selected file. +function downloadSelectedFile() { + // Build file path. + var filePath = selectedFileSystemEntry.substring(PREFIX_FS.length); + // Execute the download action. + downloadFile(filePath); +} + +// Attempts to download the given file name. +function downloadFile(fileName) { + // Build file path. + var path = currentDirectory + fileName; + // Show loading panel. + showFileSystemLoading(true); + // Prepare data. + var data = JSON.stringify({ + "device_id": getDeviceID(), + "path": path + }); + // Send request + $.ajax({ + type: 'POST', + url: "../ajax/fs_download_file", + data: data, + cache: false, + async: true, + xhr: function() { + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function () { + if (xhr.readyState == 2) { + if (xhr.status == 200) + xhr.responseType = "blob"; + else + xhr.responseType = "text"; + } + }; + return xhr; + }, + success: function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process answer. + processDownloadFileResponse(response); + }, + error: function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading status. + showFileSystemLoading(false); + } + }); +} + +// Processes the download file response. +function processDownloadFileResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Hide the loading status. + showFileSystemLoading(false); + // Do not continue. + return; + } + // Obtain file name. + var fileName = selectedFileSystemEntry.substring(PREFIX_FS.length) + // Convert the Byte Data to BLOB object. + var blob = new Blob([response], { type: "application/octetstream" }); + // Check the Browser type and download the File. + var isIE = false || !!document.documentMode; + if (isIE) { + window.navigator.msSaveBlob(blob, fileName); + } else { + var url = window.URL || window.webkitURL; + link = url.createObjectURL(blob); + var a = $(""); + a.attr("download", fileName); + a.attr("href", link); + $("body").append(a); + a[0].click(); + $("body").remove(a); + } + // Hide the loading status. + showFileSystemLoading(false); +} + +// Asks user to confirm file removal. +function askRemoveFile() { + showConfirmDialog(TITLE_CONFIRM_REMOVE, MESSAGE_CONFIRM_REMOVE, + function() { + // Remove the file. + removeSelectedFile(); + }, + function() { + // Do nothing. + } + ); +} + +// Removes the selected file. +function removeSelectedFile() { + // Sanity checks. + if (selectedFileSystemEntry == null) + return; + // Initialize variables. + var isFile = false; + var entryElement = document.getElementById(selectedFileSystemEntry); + var iconElement = entryElement.children[0]; + // Check if it is a file. + if (iconElement.classList.contains(CLASS_FA_FILE)) + isFile = true; + // Execute action. + removeFile(selectedFileSystemEntry.substring(PREFIX_FS.length), isFile); +} + +// Attempts to remove the given file name. +function removeFile(fileName, isFile) { + // Build file path. + var path = currentDirectory + fileName; + // Show loading panel. + showFileSystemLoading(true); + // Send request. + $.post( + "../ajax/fs_remove_file", + JSON.stringify({ + "device_id": getDeviceID(), + "path": path, + "is_file": isFile + }), + function(data) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process answer. + processRemoveFileResponse(data); + } + ).fail(function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading status. + showFileSystemLoading(false); + }); +} + +// Processes the remove file response. +function processRemoveFileResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Hide the loading status. + showFileSystemLoading(false); + } else { + // List directory contents again. + listDirectory(currentDirectory); + } +} + +// Opens the file browser. +function openFileBrowser() { + document.getElementById(ID_FILE_TO_UPLOAD).click(); +} + +// Attempts to upload the given file. +function uploadFile(file) { + // Build file path. + var path = currentDirectory + file.name; + // Show loading panel. + showFileSystemLoading(true); + // Prepare data. + var formData = new FormData(); + formData.append("device_id", getDeviceID()); + formData.append("path", path); + formData.append("file", file); + // Send request. + $.ajax({ + type: 'POST', + url: "../ajax/fs_upload_file", + data: formData, + cache: false, + async: true, + processData: false, + contentType: false, + enctype: 'multipart/form-data', + success: function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process answer. + processUploadFileResponse(response); + }, + error: function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading status. + showFileSystemLoading(false); + } + }); +} + +// Processes the upload file response. +function processUploadFileResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Hide the loading status. + showFileSystemLoading(false); + } else { + // List directory contents again. + listDirectory(currentDirectory); + } +} + +// Opens the directory name panel. +function openDirectoryNamePanel() { + // Initialize variables. + var fileSystemDirName = document.getElementById(ID_FILE_SYSTEM_DIR_NAME); + var fileSystemDirNameButton = document.getElementById(ID_FILE_SYSTEM_DIR_NAME_BUTTON); + var fileSystemDirNameError = document.getElementById(ID_FILE_SYSTEM_DIR_NAME_ERROR); + // Reset panel state. + fileSystemDirName.value = ""; + fileSystemDirNameError.innerHTML = " "; + fileSystemDirNameError.style.visibility = "hidden"; + if (!fileSystemDirNameButton.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED)) + fileSystemDirNameButton.classList.add(CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED); + if (fileSystemDirName.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR)) + fileSystemDirName.classList.remove(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR); + // Show panel. + showDirectoryNamePanel(true); +} + +// Closes the directory name panel. +function closeDirectoryNamePanel() { + showDirectoryNamePanel(false); +} + +// Opens the directory name panel. +function showDirectoryNamePanel(visible) { + // Initialize variables. + var fileSystemDirNamePanel = document.getElementById(ID_FILE_SYSTEM_DIR_NAME_PANEL); + var fileSystemDirNameError = document.getElementById(ID_FILE_SYSTEM_DIR_NAME_ERROR); + // Apply visible state. + if (visible && isFileSystemShowing()) + fileSystemDirNamePanel.style.visibility = "visible"; + else { + fileSystemDirNamePanel.style.visibility = "hidden"; + fileSystemDirNameError.style.visibility = "hidden"; + } +} + +// Handles what happens when the "Create directory" button is pressed. +function onCreateDirectory() { + var fileSystemDirName = document.getElementById(ID_FILE_SYSTEM_DIR_NAME); + var dirName = fileSystemDirName.value; + createDirectory(dirName); +} + +// Validates the directory name. +function validateDirectoryName(dirName) { + // Initialize variables. + var fileSystemDirName = document.getElementById(ID_FILE_SYSTEM_DIR_NAME); + var fileSystemDirNameButton = document.getElementById(ID_FILE_SYSTEM_DIR_NAME_BUTTON); + var fileSystemDirNameError = document.getElementById(ID_FILE_SYSTEM_DIR_NAME_ERROR); + var isValid = true; + var error = ERROR_DIR_NAME_INVALID; + // Check if the directory name is valid. + if (dirName == null || dirName == "") { + isValid = false; + error = ERROR_DIR_NAME_EMPTY; + } else + isValid = dirName.match(REGEX_DIRECTORY_NAME); + // Update controls. + if (isValid) { + if (fileSystemDirNameButton.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED)) + fileSystemDirNameButton.classList.remove(CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED); + if (fileSystemDirName.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR)) + fileSystemDirName.classList.remove(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR); + fileSystemDirNameError.innerHTML = " "; + fileSystemDirNameError.style.visibility = "hidden"; + } else { + if (!fileSystemDirNameButton.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED)) + fileSystemDirNameButton.classList.add(CLASS_FILE_SYSTEM_DIR_NAME_BUTTON_DISABLED); + if (!fileSystemDirName.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR)) + fileSystemDirName.classList.add(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR); + fileSystemDirNameError.innerHTML = error; + fileSystemDirNameError.style.visibility = "visible"; + } +} + +// Attempts to create the given directory. +function createDirectory(directoryName) { + // Build file path. + var path = currentDirectory + directoryName; + // Close the directory name panel. + closeDirectoryNamePanel(); + // Show loading panel. + showFileSystemLoading(true); + // Send request. + $.post( + "../ajax/fs_create_dir", + JSON.stringify({ + "device_id": getDeviceID(), + "path": path + }), + function(data) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process answer. + processCreateDirectoryResponse(data); + } + ).fail(function(response) { + // Process only if the file system window is showing. + if (!isFileSystemShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + // Hide the loading status. + showFileSystemLoading(false); + }); +} + +// Processes the create directory response. +function processCreateDirectoryResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Hide the loading status. + showFileSystemLoading(false); + } else { + // List directory contents again. + listDirectory(currentDirectory); + } +} \ No newline at end of file diff --git a/connectcore-demo-example/static/js/history.js b/connectcore-demo-example/static/js/history.js new file mode 100644 index 0000000..78cfc03 --- /dev/null +++ b/connectcore-demo-example/static/js/history.js @@ -0,0 +1,228 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_CPU_CHART = "cpu-chart"; +const ID_CPU_CHART_LOADING = "cpu-chart-loading"; +const ID_MEMORY_CHART = "memory-chart"; +const ID_MEMORY_CHART_LOADING = "memory-chart-loading"; +const ID_TEMPERATURE_CHART = "temperature-chart"; +const ID_TEMPERATURE_CHART_LOADING = "temperature-chart-loading"; + +const COLOR_CPU_CHART = "#3399FF"; +const COLOR_MEMORY_CHART = "#FFD500"; +const COLOR_TEMPERATURE_CHART = "#4F4F4F"; + +const TITLE_CPU_CHART = "CPU Usage"; +const TITLE_MEMORY_CHART = "Memory Usage"; +const TITLE_TEMPERATURE_CHART = "Temperature"; + +const UNITS_CPU_CHART = "%"; +const UNITS_MEMORY_CHART = "MB"; +const UNITS_TEMPERATURE_CHART = "°C"; + +// Variables. +var temperatureData = null; +var cpuData = null; +var memoryData = null; +var temperatureInterval = null; +var cpuInterval = null; +var memoryInterval = null; + +// Initializes the charts. +function initCharts() { + // Reset the variables. + temperatureData = null; + cpuData = null; + memoryData = null; + temperatureInterval = null; + cpuInterval = null; + memoryInterval = null; + // Draw all the charts. + drawAllCharts(true, true); +} + +// Draws all the charts. +function drawAllCharts(refresh=false, showProgress=true) { + // Sanity checks. + if (!isHistoryShowing()) + return; + // Draw the charts. + drawTemperatureChart(refresh, showProgress); + drawCPUChart(refresh, showProgress); + drawMemoryChart(refresh, showProgress); +} + +// Draws the temperature chart. +function drawTemperatureChart(refresh=false, showProgress=false) { + if (refresh) { + if (showProgress) + $("#" + ID_TEMPERATURE_CHART_LOADING).show(); + $.post( + "/ajax/history_temperature", + JSON.stringify({ + "device_id": getDeviceID(), + "interval": temperatureInterval + }), + function(response) { + // Process only if histograms page is showing. + if (!isHistoryShowing()) + return; + // Check for errors. + if (!checkErrorResponse(response, false)) { + temperatureData = response.data; + drawTemperatureChart(); + $("#" + ID_TEMPERATURE_CHART_LOADING).hide(); + } + } + ).fail(function(response) { + // Process only if histograms page is showing. + if (!isHistoryShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); + } else { + drawChart(ID_TEMPERATURE_CHART, temperatureData, TITLE_TEMPERATURE_CHART, UNITS_TEMPERATURE_CHART, COLOR_TEMPERATURE_CHART); + } +} + +// Draws the CPU chart. +function drawCPUChart(refresh=false, showProgress=false) { + if (refresh) { + if (showProgress) + $("#" + ID_CPU_CHART_LOADING).show(); + $.post( + "/ajax/history_cpu", + JSON.stringify({ + "device_id": getDeviceID(), + "interval": cpuInterval + }), + function(response) { + // Process only if histograms page is showing. + if (!isHistoryShowing()) + return; + // Check for errors. + if (!checkErrorResponse(response, false)) { + cpuData = response.data; + drawCPUChart(); + $("#" + ID_CPU_CHART_LOADING).hide(); + } + } + ).fail(function(response) { + // Process only if histograms page is showing. + if (!isHistoryShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); + } else { + drawChart(ID_CPU_CHART, cpuData, TITLE_CPU_CHART, UNITS_CPU_CHART, COLOR_CPU_CHART); + } +} + +// Draws the memory chart. +function drawMemoryChart(refresh=false, showProgress=false) { + if (refresh) { + if (showProgress) + $("#" + ID_MEMORY_CHART_LOADING).show(); + $.post( + "/ajax/history_memory", + JSON.stringify({ + "device_id": getDeviceID(), + "interval": memoryInterval + }), + function(response) { + // Process only if histograms page is showing. + if (!isHistoryShowing()) + return; + // Check for errors. + if (!checkErrorResponse(response, false)) { + memoryData = response.data; + drawMemoryChart(); + $("#" + ID_MEMORY_CHART_LOADING).hide(); + } + } + ).fail(function(response) { + // Process only if histograms page is showing. + if (!isHistoryShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); + } else { + drawChart(ID_MEMORY_CHART, memoryData, TITLE_MEMORY_CHART, UNITS_MEMORY_CHART, COLOR_MEMORY_CHART); + } +} + +// Draws the chart with the given data. +function drawChart(id, data, title, units, color=null) { + // Sanity checks. + if (!isHistoryShowing()) + return; + // Create the chart table. + var dataTable = new google.visualization.DataTable(); + dataTable.addColumn("date", ""); + dataTable.addColumn("number", ""); + // Check if any data was given. + if (data.length == 0) { + $("#" + id).empty(); + $("#" + id).append("Not enough data"); + return; + } + // Add the data rows. + dataTable.addRows(data.length); + // Fill each row with the given data. + $.each(data, function(k, v) { + dataTable.setCell(k, 0, new Date(v[ID_TIMESTAMP])); + dataTable.setCell(k, 1, v[ID_DATA]); + }); + // Build chart options. + var options = { + backgroundColor: "transparent", + series: { + 0: { + axis: "Data", + color: color, + visibleInLegend: false + } + }, + axes: { + y: { + Data: { + label: units + } + } + }, + legend: { + position: "none" + }, + vAxis: { + viewWindow: { + min: 0 + } + } + }; + // Create the chart. + var chart = new google.charts.Line(document.getElementById(id)); + // Draw the chart. + chart.draw(dataTable, google.charts.Line.convertOptions(options)); +} + +// Returns the device ID. +function getDeviceID() { + return new URLSearchParams(window.location.search).get(ID_DEVICE_ID); +} \ No newline at end of file diff --git a/connectcore-demo-example/static/js/jquery.matchHeight-min.js b/connectcore-demo-example/static/js/jquery.matchHeight-min.js new file mode 100644 index 0000000..50936e8 --- /dev/null +++ b/connectcore-demo-example/static/js/jquery.matchHeight-min.js @@ -0,0 +1,12 @@ +/* +* jquery-match-height 0.7.2 by @liabru +* http://brm.io/jquery-match-height/ +* License MIT +*/ +!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=-1,o=-1,n=function(t){return parseFloat(t)||0},a=function(e){var o=1,a=t(e),i=null,r=[];return a.each(function(){var e=t(this),a=e.offset().top-n(e.css("margin-top")),s=r.length>0?r[r.length-1]:null;null===s?r.push(e):Math.floor(Math.abs(i-a))<=o?r[r.length-1]=s.add(e):r.push(e),i=a}),r},i=function(e){var o={ +byRow:!0,property:"height",target:null,remove:!1};return"object"==typeof e?t.extend(o,e):("boolean"==typeof e?o.byRow=e:"remove"===e&&(o.remove=!0),o)},r=t.fn.matchHeight=function(e){var o=i(e);if(o.remove){var n=this;return this.css(o.property,""),t.each(r._groups,function(t,e){e.elements=e.elements.not(n)}),this}return this.length<=1&&!o.target?this:(r._groups.push({elements:this,options:o}),r._apply(this,o),this)};r.version="0.7.2",r._groups=[],r._throttle=80,r._maintainScroll=!1,r._beforeUpdate=null, +r._afterUpdate=null,r._rows=a,r._parse=n,r._parseOptions=i,r._apply=function(e,o){var s=i(o),h=t(e),l=[h],c=t(window).scrollTop(),p=t("html").outerHeight(!0),u=h.parents().filter(":hidden");return u.each(function(){var e=t(this);e.data("style-cache",e.attr("style"))}),u.css("display","block"),s.byRow&&!s.target&&(h.each(function(){var e=t(this),o=e.css("display");"inline-block"!==o&&"flex"!==o&&"inline-flex"!==o&&(o="block"),e.data("style-cache",e.attr("style")),e.css({display:o,"padding-top":"0", +"padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px",overflow:"hidden"})}),l=a(h),h.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||"")})),t.each(l,function(e,o){var a=t(o),i=0;if(s.target)i=s.target.outerHeight(!1);else{if(s.byRow&&a.length<=1)return void a.css(s.property,"");a.each(function(){var e=t(this),o=e.attr("style"),n=e.css("display");"inline-block"!==n&&"flex"!==n&&"inline-flex"!==n&&(n="block");var a={ +display:n};a[s.property]="",e.css(a),e.outerHeight(!1)>i&&(i=e.outerHeight(!1)),o?e.attr("style",o):e.css("display","")})}a.each(function(){var e=t(this),o=0;s.target&&e.is(s.target)||("border-box"!==e.css("box-sizing")&&(o+=n(e.css("border-top-width"))+n(e.css("border-bottom-width")),o+=n(e.css("padding-top"))+n(e.css("padding-bottom"))),e.css(s.property,i-o+"px"))})}),u.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||null)}),r._maintainScroll&&t(window).scrollTop(c/p*t("html").outerHeight(!0)), +this},r._applyDataApi=function(){var e={};t("[data-match-height], [data-mh]").each(function(){var o=t(this),n=o.attr("data-mh")||o.attr("data-match-height");n in e?e[n]=e[n].add(o):e[n]=o}),t.each(e,function(){this.matchHeight(!0)})};var s=function(e){r._beforeUpdate&&r._beforeUpdate(e,r._groups),t.each(r._groups,function(){r._apply(this.elements,this.options)}),r._afterUpdate&&r._afterUpdate(e,r._groups)};r._update=function(n,a){if(a&&"resize"===a.type){var i=t(window).width();if(i===e)return;e=i; +}n?o===-1&&(o=setTimeout(function(){s(a),o=-1},r._throttle)):s(a)},t(r._applyDataApi);var h=t.fn.on?"on":"bind";t(window)[h]("load",function(t){r._update(!1,t)}),t(window)[h]("resize orientationchange",function(t){r._update(!0,t)})}); \ No newline at end of file diff --git a/connectcore-demo-example/static/js/jquery.pjax.js b/connectcore-demo-example/static/js/jquery.pjax.js new file mode 100644 index 0000000..d57269d --- /dev/null +++ b/connectcore-demo-example/static/js/jquery.pjax.js @@ -0,0 +1,903 @@ +/*! + * Copyright 2012, Chris Wanstrath + * Released under the MIT License + * https://github.com/defunkt/jquery-pjax + */ + +(function($){ + +// When called on a container with a selector, fetches the href with +// ajax into the container or with the data-pjax attribute on the link +// itself. +// +// Tries to make sure the back button and ctrl+click work the way +// you'd expect. +// +// Exported as $.fn.pjax +// +// Accepts a jQuery ajax options object that may include these +// pjax specific options: +// +// +// container - String selector for the element where to place the response body. +// push - Whether to pushState the URL. Defaults to true (of course). +// replace - Want to use replaceState instead? That's cool. +// +// For convenience the second parameter can be either the container or +// the options object. +// +// Returns the jQuery object +function fnPjax(selector, container, options) { + options = optionsFor(container, options) + return this.on('click.pjax', selector, function(event) { + var opts = options + if (!opts.container) { + opts = $.extend({}, options) + opts.container = $(this).attr('data-pjax') + } + handleClick(event, opts) + }) +} + +// Public: pjax on click handler +// +// Exported as $.pjax.click. +// +// event - "click" jQuery.Event +// options - pjax options +// +// Examples +// +// $(document).on('click', 'a', $.pjax.click) +// // is the same as +// $(document).pjax('a') +// +// Returns nothing. +function handleClick(event, container, options) { + options = optionsFor(container, options) + + var link = event.currentTarget + var $link = $(link) + + if (link.tagName.toUpperCase() !== 'A') + throw "$.fn.pjax or $.pjax.click requires an anchor element" + + // Middle click, cmd click, and ctrl click should open + // links in a new tab as normal. + if ( event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey ) + return + + // Ignore cross origin links + if ( location.protocol !== link.protocol || location.hostname !== link.hostname ) + return + + // Ignore case when a hash is being tacked on the current URL + if ( link.href.indexOf('#') > -1 && stripHash(link) == stripHash(location) ) + return + + // Ignore event with default prevented + if (event.isDefaultPrevented()) + return + + var defaults = { + url: link.href, + container: $link.attr('data-pjax'), + target: link + } + + var opts = $.extend({}, defaults, options) + var clickEvent = $.Event('pjax:click') + $link.trigger(clickEvent, [opts]) + + if (!clickEvent.isDefaultPrevented()) { + pjax(opts) + event.preventDefault() + $link.trigger('pjax:clicked', [opts]) + } +} + +// Public: pjax on form submit handler +// +// Exported as $.pjax.submit +// +// event - "click" jQuery.Event +// options - pjax options +// +// Examples +// +// $(document).on('submit', 'form', function(event) { +// $.pjax.submit(event, '[data-pjax-container]') +// }) +// +// Returns nothing. +function handleSubmit(event, container, options) { + options = optionsFor(container, options) + + var form = event.currentTarget + var $form = $(form) + + if (form.tagName.toUpperCase() !== 'FORM') + throw "$.pjax.submit requires a form element" + + var defaults = { + type: ($form.attr('method') || 'GET').toUpperCase(), + url: $form.attr('action'), + container: $form.attr('data-pjax'), + target: form + } + + if (defaults.type !== 'GET' && window.FormData !== undefined) { + defaults.data = new FormData(form) + defaults.processData = false + defaults.contentType = false + } else { + // Can't handle file uploads, exit + if ($form.find(':file').length) { + return + } + + // Fallback to manually serializing the fields + defaults.data = $form.serializeArray() + } + + pjax($.extend({}, defaults, options)) + + event.preventDefault() +} + +// Loads a URL with ajax, puts the response body inside a container, +// then pushState()'s the loaded URL. +// +// Works just like $.ajax in that it accepts a jQuery ajax +// settings object (with keys like url, type, data, etc). +// +// Accepts these extra keys: +// +// container - String selector for where to stick the response body. +// push - Whether to pushState the URL. Defaults to true (of course). +// replace - Want to use replaceState instead? That's cool. +// +// Use it just like $.ajax: +// +// var xhr = $.pjax({ url: this.href, container: '#main' }) +// console.log( xhr.readyState ) +// +// Returns whatever $.ajax returns. +function pjax(options) { + options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options) + + if ($.isFunction(options.url)) { + options.url = options.url() + } + + var hash = parseURL(options.url).hash + + var containerType = $.type(options.container) + if (containerType !== 'string') { + throw "expected string value for 'container' option; got " + containerType + } + var context = options.context = $(options.container) + if (!context.length) { + throw "the container selector '" + options.container + "' did not match anything" + } + + // We want the browser to maintain two separate internal caches: one + // for pjax'd partial page loads and one for normal page loads. + // Without adding this secret parameter, some browsers will often + // confuse the two. + if (!options.data) options.data = {} + if ($.isArray(options.data)) { + options.data.push({name: '_pjax', value: options.container}) + } else { + options.data._pjax = options.container + } + + function fire(type, args, props) { + if (!props) props = {} + props.relatedTarget = options.target + var event = $.Event(type, props) + context.trigger(event, args) + return !event.isDefaultPrevented() + } + + var timeoutTimer + + options.beforeSend = function(xhr, settings) { + // No timeout for non-GET requests + // Its not safe to request the resource again with a fallback method. + if (settings.type !== 'GET') { + settings.timeout = 0 + } + + xhr.setRequestHeader('X-PJAX', 'true') + xhr.setRequestHeader('X-PJAX-Container', options.container) + + if (!fire('pjax:beforeSend', [xhr, settings])) + return false + + if (settings.timeout > 0) { + timeoutTimer = setTimeout(function() { + if (fire('pjax:timeout', [xhr, options])) + xhr.abort('timeout') + }, settings.timeout) + + // Clear timeout setting so jquerys internal timeout isn't invoked + settings.timeout = 0 + } + + var url = parseURL(settings.url) + if (hash) url.hash = hash + options.requestUrl = stripInternalParams(url) + } + + options.complete = function(xhr, textStatus) { + if (timeoutTimer) + clearTimeout(timeoutTimer) + + fire('pjax:complete', [xhr, textStatus, options]) + + fire('pjax:end', [xhr, options]) + } + + options.error = function(xhr, textStatus, errorThrown) { + var container = extractContainer("", xhr, options) + + var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options]) + if (options.type == 'GET' && textStatus !== 'abort' && allowed) { + locationReplace(container.url) + } + } + + options.success = function(data, status, xhr) { + var previousState = pjax.state + + // If $.pjax.defaults.version is a function, invoke it first. + // Otherwise it can be a static string. + var currentVersion = typeof $.pjax.defaults.version === 'function' ? + $.pjax.defaults.version() : + $.pjax.defaults.version + + var latestVersion = xhr.getResponseHeader('X-PJAX-Version') + + var container = extractContainer(data, xhr, options) + + var url = parseURL(container.url) + if (hash) { + url.hash = hash + container.url = url.href + } + + // If there is a layout version mismatch, hard load the new url + if (currentVersion && latestVersion && currentVersion !== latestVersion) { + locationReplace(container.url) + return + } + + // If the new response is missing a body, hard load the page + if (!container.contents) { + locationReplace(container.url) + return + } + + pjax.state = { + id: options.id || uniqueId(), + url: container.url, + title: container.title, + container: options.container, + fragment: options.fragment, + timeout: options.timeout + } + + if (options.push || options.replace) { + window.history.replaceState(pjax.state, container.title, container.url) + } + + // Only blur the focus if the focused element is within the container. + var blurFocus = $.contains(context, document.activeElement) + + // Clear out any focused controls before inserting new page contents. + if (blurFocus) { + try { + document.activeElement.blur() + } catch (e) { /* ignore */ } + } + + if (container.title) document.title = container.title + + fire('pjax:beforeReplace', [container.contents, options], { + state: pjax.state, + previousState: previousState + }) + context.html(container.contents) + + // FF bug: Won't autofocus fields that are inserted via JS. + // This behavior is incorrect. So if theres no current focus, autofocus + // the last field. + // + // http://www.w3.org/html/wg/drafts/html/master/forms.html + var autofocusEl = context.find('input[autofocus], textarea[autofocus]').last()[0] + if (autofocusEl && document.activeElement !== autofocusEl) { + autofocusEl.focus() + } + + executeScriptTags(container.scripts) + + var scrollTo = options.scrollTo + + // Ensure browser scrolls to the element referenced by the URL anchor + if (hash) { + var name = decodeURIComponent(hash.slice(1)) + var target = document.getElementById(name) || document.getElementsByName(name)[0] + if (target) scrollTo = $(target).offset().top + } + + if (typeof scrollTo == 'number') $(window).scrollTop(scrollTo) + + fire('pjax:success', [data, status, xhr, options]) + } + + + // Initialize pjax.state for the initial page load. Assume we're + // using the container and options of the link we're loading for the + // back button to the initial page. This ensures good back button + // behavior. + if (!pjax.state) { + pjax.state = { + id: uniqueId(), + url: window.location.href, + title: document.title, + container: options.container, + fragment: options.fragment, + timeout: options.timeout + } + window.history.replaceState(pjax.state, document.title) + } + + // Cancel the current request if we're already pjaxing + abortXHR(pjax.xhr) + + pjax.options = options + var xhr = pjax.xhr = $.ajax(options) + + if (xhr.readyState > 0) { + if (options.push && !options.replace) { + // Cache current container element before replacing it + cachePush(pjax.state.id, [options.container, cloneContents(context)]) + + window.history.pushState(null, "", options.requestUrl) + } + + fire('pjax:start', [xhr, options]) + fire('pjax:send', [xhr, options]) + } + + return pjax.xhr +} + +// Public: Reload current page with pjax. +// +// Returns whatever $.pjax returns. +function pjaxReload(container, options) { + var defaults = { + url: window.location.href, + push: false, + replace: true, + scrollTo: false + } + + return pjax($.extend(defaults, optionsFor(container, options))) +} + +// Internal: Hard replace current state with url. +// +// Work for around WebKit +// https://bugs.webkit.org/show_bug.cgi?id=93506 +// +// Returns nothing. +function locationReplace(url) { + window.history.replaceState(null, "", pjax.state.url) + window.location.replace(url) +} + + +var initialPop = true +var initialURL = window.location.href +var initialState = window.history.state + +// Initialize $.pjax.state if possible +// Happens when reloading a page and coming forward from a different +// session history. +if (initialState && initialState.container) { + pjax.state = initialState +} + +// Non-webkit browsers don't fire an initial popstate event +if ('state' in window.history) { + initialPop = false +} + +// popstate handler takes care of the back and forward buttons +// +// You probably shouldn't use pjax on pages with other pushState +// stuff yet. +function onPjaxPopstate(event) { + + // Hitting back or forward should override any pending PJAX request. + if (!initialPop) { + abortXHR(pjax.xhr) + } + + var previousState = pjax.state + var state = event.state + var direction + + if (state && state.container) { + // When coming forward from a separate history session, will get an + // initial pop with a state we are already at. Skip reloading the current + // page. + if (initialPop && initialURL == state.url) return + + if (previousState) { + // If popping back to the same state, just skip. + // Could be clicking back from hashchange rather than a pushState. + if (previousState.id === state.id) return + + // Since state IDs always increase, we can deduce the navigation direction + direction = previousState.id < state.id ? 'forward' : 'back' + } + + var cache = cacheMapping[state.id] || [] + var containerSelector = cache[0] || state.container + var container = $(containerSelector), contents = cache[1] + + if (container.length) { + if (previousState) { + // Cache current container before replacement and inform the + // cache which direction the history shifted. + cachePop(direction, previousState.id, [containerSelector, cloneContents(container)]) + } + + var popstateEvent = $.Event('pjax:popstate', { + state: state, + direction: direction + }) + container.trigger(popstateEvent) + + var options = { + id: state.id, + url: state.url, + container: containerSelector, + push: false, + fragment: state.fragment, + timeout: state.timeout, + scrollTo: false + } + + if (contents) { + container.trigger('pjax:start', [null, options]) + + pjax.state = state + if (state.title) document.title = state.title + var beforeReplaceEvent = $.Event('pjax:beforeReplace', { + state: state, + previousState: previousState + }) + container.trigger(beforeReplaceEvent, [contents, options]) + container.html(contents) + + container.trigger('pjax:end', [null, options]) + } else { + pjax(options) + } + + // Force reflow/relayout before the browser tries to restore the + // scroll position. + container[0].offsetHeight // eslint-disable-line no-unused-expressions + } else { + locationReplace(location.href) + } + } + initialPop = false +} + +// Fallback version of main pjax function for browsers that don't +// support pushState. +// +// Returns nothing since it retriggers a hard form submission. +function fallbackPjax(options) { + var url = $.isFunction(options.url) ? options.url() : options.url, + method = options.type ? options.type.toUpperCase() : 'GET' + + var form = $('
', { + method: method === 'GET' ? 'GET' : 'POST', + action: url, + style: 'display:none' + }) + + if (method !== 'GET' && method !== 'POST') { + form.append($('', { + type: 'hidden', + name: '_method', + value: method.toLowerCase() + })) + } + + var data = options.data + if (typeof data === 'string') { + $.each(data.split('&'), function(index, value) { + var pair = value.split('=') + form.append($('', {type: 'hidden', name: pair[0], value: pair[1]})) + }) + } else if ($.isArray(data)) { + $.each(data, function(index, value) { + form.append($('', {type: 'hidden', name: value.name, value: value.value})) + }) + } else if (typeof data === 'object') { + var key + for (key in data) + form.append($('', {type: 'hidden', name: key, value: data[key]})) + } + + $(document.body).append(form) + form.submit() +} + +// Internal: Abort an XmlHttpRequest if it hasn't been completed, +// also removing its event handlers. +function abortXHR(xhr) { + if ( xhr && xhr.readyState < 4) { + xhr.onreadystatechange = $.noop + xhr.abort() + } +} + +// Internal: Generate unique id for state object. +// +// Use a timestamp instead of a counter since ids should still be +// unique across page loads. +// +// Returns Number. +function uniqueId() { + return (new Date).getTime() +} + +function cloneContents(container) { + var cloned = container.clone() + // Unmark script tags as already being eval'd so they can get executed again + // when restored from cache. HAXX: Uses jQuery internal method. + cloned.find('script').each(function(){ + if (!this.src) $._data(this, 'globalEval', false) + }) + return cloned.contents() +} + +// Internal: Strip internal query params from parsed URL. +// +// Returns sanitized url.href String. +function stripInternalParams(url) { + url.search = url.search.replace(/([?&])(_pjax|_)=[^&]*/g, '').replace(/^&/, '') + return url.href.replace(/\?($|#)/, '$1') +} + +// Internal: Parse URL components and returns a Locationish object. +// +// url - String URL +// +// Returns HTMLAnchorElement that acts like Location. +function parseURL(url) { + var a = document.createElement('a') + a.href = url + return a +} + +// Internal: Return the `href` component of given URL object with the hash +// portion removed. +// +// location - Location or HTMLAnchorElement +// +// Returns String +function stripHash(location) { + return location.href.replace(/#.*/, '') +} + +// Internal: Build options Object for arguments. +// +// For convenience the first parameter can be either the container or +// the options object. +// +// Examples +// +// optionsFor('#container') +// // => {container: '#container'} +// +// optionsFor('#container', {push: true}) +// // => {container: '#container', push: true} +// +// optionsFor({container: '#container', push: true}) +// // => {container: '#container', push: true} +// +// Returns options Object. +function optionsFor(container, options) { + if (container && options) { + options = $.extend({}, options) + options.container = container + return options + } else if ($.isPlainObject(container)) { + return container + } else { + return {container: container} + } +} + +// Internal: Filter and find all elements matching the selector. +// +// Where $.fn.find only matches descendants, findAll will test all the +// top level elements in the jQuery object as well. +// +// elems - jQuery object of Elements +// selector - String selector to match +// +// Returns a jQuery object. +function findAll(elems, selector) { + return elems.filter(selector).add(elems.find(selector)) +} + +function parseHTML(html) { + return $.parseHTML(html, document, true) +} + +// Internal: Extracts container and metadata from response. +// +// 1. Extracts X-PJAX-URL header if set +// 2. Extracts inline tags +// 3. Builds response Element and extracts fragment if set +// +// data - String response data +// xhr - XHR response +// options - pjax options Object +// +// Returns an Object with url, title, and contents keys. +function extractContainer(data, xhr, options) { + var obj = {}, fullDocument = /<html/i.test(data) + + // Prefer X-PJAX-URL header if it was set, otherwise fallback to + // using the original requested url. + var serverUrl = xhr.getResponseHeader('X-PJAX-URL') + obj.url = serverUrl ? stripInternalParams(parseURL(serverUrl)) : options.requestUrl + + var $head, $body + // Attempt to parse response html into elements + if (fullDocument) { + $body = $(parseHTML(data.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0])) + var head = data.match(/<head[^>]*>([\s\S.]*)<\/head>/i) + $head = head != null ? $(parseHTML(head[0])) : $body + } else { + $head = $body = $(parseHTML(data)) + } + + // If response data is empty, return fast + if ($body.length === 0) + return obj + + // If there's a <title> tag in the header, use it as + // the page's title. + obj.title = findAll($head, 'title').last().text() + + if (options.fragment) { + var $fragment = $body + // If they specified a fragment, look for it in the response + // and pull it out. + if (options.fragment !== 'body') { + $fragment = findAll($fragment, options.fragment).first() + } + + if ($fragment.length) { + obj.contents = options.fragment === 'body' ? $fragment : $fragment.contents() + + // If there's no title, look for data-title and title attributes + // on the fragment + if (!obj.title) + obj.title = $fragment.attr('title') || $fragment.data('title') + } + + } else if (!fullDocument) { + obj.contents = $body + } + + // Clean up any <title> tags + if (obj.contents) { + // Remove any parent title elements + obj.contents = obj.contents.not(function() { return $(this).is('title') }) + + // Then scrub any titles from their descendants + obj.contents.find('title').remove() + + // Gather all script[src] elements + obj.scripts = findAll(obj.contents, 'script[src]').remove() + obj.contents = obj.contents.not(obj.scripts) + } + + // Trim any whitespace off the title + if (obj.title) obj.title = $.trim(obj.title) + + return obj +} + +// Load an execute scripts using standard script request. +// +// Avoids jQuery's traditional $.getScript which does a XHR request and +// globalEval. +// +// scripts - jQuery object of script Elements +// +// Returns nothing. +function executeScriptTags(scripts) { + if (!scripts) return + + var existingScripts = $('script[src]') + + scripts.each(function() { + var src = this.src + var matchedScripts = existingScripts.filter(function() { + return this.src === src + }) + if (matchedScripts.length) return + + var script = document.createElement('script') + var type = $(this).attr('type') + if (type) script.type = type + script.src = $(this).attr('src') + document.head.appendChild(script) + }) +} + +// Internal: History DOM caching class. +var cacheMapping = {} +var cacheForwardStack = [] +var cacheBackStack = [] + +// Push previous state id and container contents into the history +// cache. Should be called in conjunction with `pushState` to save the +// previous container contents. +// +// id - State ID Number +// value - DOM Element to cache +// +// Returns nothing. +function cachePush(id, value) { + cacheMapping[id] = value + cacheBackStack.push(id) + + // Remove all entries in forward history stack after pushing a new page. + trimCacheStack(cacheForwardStack, 0) + + // Trim back history stack to max cache length. + trimCacheStack(cacheBackStack, pjax.defaults.maxCacheLength) +} + +// Shifts cache from directional history cache. Should be +// called on `popstate` with the previous state id and container +// contents. +// +// direction - "forward" or "back" String +// id - State ID Number +// value - DOM Element to cache +// +// Returns nothing. +function cachePop(direction, id, value) { + var pushStack, popStack + cacheMapping[id] = value + + if (direction === 'forward') { + pushStack = cacheBackStack + popStack = cacheForwardStack + } else { + pushStack = cacheForwardStack + popStack = cacheBackStack + } + + pushStack.push(id) + id = popStack.pop() + if (id) delete cacheMapping[id] + + // Trim whichever stack we just pushed to to max cache length. + trimCacheStack(pushStack, pjax.defaults.maxCacheLength) +} + +// Trim a cache stack (either cacheBackStack or cacheForwardStack) to be no +// longer than the specified length, deleting cached DOM elements as necessary. +// +// stack - Array of state IDs +// length - Maximum length to trim to +// +// Returns nothing. +function trimCacheStack(stack, length) { + while (stack.length > length) + delete cacheMapping[stack.shift()] +} + +// Public: Find version identifier for the initial page load. +// +// Returns String version or undefined. +function findVersion() { + return $('meta').filter(function() { + var name = $(this).attr('http-equiv') + return name && name.toUpperCase() === 'X-PJAX-VERSION' + }).attr('content') +} + +// Install pjax functions on $.pjax to enable pushState behavior. +// +// Does nothing if already enabled. +// +// Examples +// +// $.pjax.enable() +// +// Returns nothing. +function enable() { + $.fn.pjax = fnPjax + $.pjax = pjax + $.pjax.enable = $.noop + $.pjax.disable = disable + $.pjax.click = handleClick + $.pjax.submit = handleSubmit + $.pjax.reload = pjaxReload + $.pjax.defaults = { + timeout: 650, + push: true, + replace: false, + type: 'GET', + dataType: 'html', + scrollTo: 0, + maxCacheLength: 20, + version: findVersion + } + $(window).on('popstate.pjax', onPjaxPopstate) +} + +// Disable pushState behavior. +// +// This is the case when a browser doesn't support pushState. It is +// sometimes useful to disable pushState for debugging on a modern +// browser. +// +// Examples +// +// $.pjax.disable() +// +// Returns nothing. +function disable() { + $.fn.pjax = function() { return this } + $.pjax = fallbackPjax + $.pjax.enable = enable + $.pjax.disable = $.noop + $.pjax.click = $.noop + $.pjax.submit = $.noop + $.pjax.reload = function() { window.location.reload() } + + $(window).off('popstate.pjax', onPjaxPopstate) +} + + +// Add the state property to jQuery's event object so we can use it in +// $(window).bind('popstate') +if ($.event.props && $.inArray('state', $.event.props) < 0) { + $.event.props.push('state') +} else if (!('state' in $.Event.prototype)) { + $.event.addProp('state') +} + +// Is pjax supported by this browser? +$.support.pjax = + window.history && window.history.pushState && window.history.replaceState && + // pushState isn't reliable on iOS until 5. + !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/) + +if ($.support.pjax) { + enable() +} else { + disable() +} + +})(jQuery) diff --git a/connectcore-demo-example/static/js/management.js b/connectcore-demo-example/static/js/management.js new file mode 100644 index 0000000..2be0cd9 --- /dev/null +++ b/connectcore-demo-example/static/js/management.js @@ -0,0 +1,1221 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_REBOOT_BUTTON = "reboot_button"; +const ID_CANCEL_FIRMWARE_UPDATE_BUTTON = "cancel_update_firmware_button"; +const ID_FILESET_ITEMS_CONTAINER = "fileset_items_container"; +const ID_FIRMWARE_TAB_FILESET = "firmware_tab_fileset"; +const ID_FIRMWARE_TAB_FILESET_HEADER = "firmware_tab_fileset_header"; +const ID_FIRMWARE_TAB_UPLOAD = "firmware_tab_upload"; +const ID_FIRMWARE_TAB_UPLOAD_HEADER = "firmware_tab_upload_header"; +const ID_NUM_SAMPLES_UPLOAD_ERROR = "samples_buffer_error"; +const ID_SAMPLE_RATE_ERROR = "sample_rate_error"; +const ID_SAVE_BUTTON = "save_button"; +const ID_SELECT_FIRMWARE_BUTTON = "select_firmware_button"; +const ID_UPDATE_FIRMWARE_BUTTON = "update_firmware_button"; +const ID_UPDATE_FIRMWARE_FILE = "firmware_file"; +const ID_UPDATE_FIRMWARE_FILE_LABEL = "firmware_file_label"; +const ID_UPDATE_FIRMWARE_PROGRESS = "update_firmware_progress"; +const ID_UPDATE_FIRMWARE_PROGRESS_BAR = "update_firmware_progress_bar"; +const ID_UPDATE_FIRMWARE_PROGRESS_MESSAGE = "update_firmware_progress_message"; +const ID_UPDATE_FIRMWARE_PROGRESS_TITLE = "update_firmware_progress_title"; +const ID_UPDATE_RUNNING = "update_running"; + +const CLASS_FIRMWARE_TAB = "firmware-tab"; +const CLASS_FIRMWARE_TAB_HEADER = "firmware-tab-header"; +const CLASS_FIRMWARE_TAB_HEADER_ACTIVE = "firmware-tab-header-active"; +const CLASS_FILESET_ENTRY_NAME = "fileset-entry-name"; +const CLASS_FILESET_ENTRY_PATH = "fileset-entry-path"; +const CLASS_FILESET_ENTRY_SELECTED = "fileset-entry-selected"; +const CLASS_MANAGEMENT_BUTTON_DISABLED = "management-button-disabled"; +const CLASS_PROGRESS_BAR_ERROR = "update-firmware-progress-bar-error"; +const CLASS_PROGRESS_BAR_INFO = "update-firmware-progress-bar-info"; +const CLASS_PROGRESS_BAR_SUCCESS = "update-firmware-progress-bar-success"; +const CLASS_SAVE_BUTTON_DISABLED = "system-monitor-save-disabled"; +const CLASS_SYSTEM_MONITOR_INPUT_ERROR = "system-monitor-input-error"; + +const ERROR_FIELD_EMPTY = "Field cannot be empty"; +const ERROR_FIELD_NUMBER = "Value must be a positive number"; +const ERROR_FIELD_POSITIVE = "Value must be greater than 0"; + +const TITLE_CONFIRM_CANCEL_UPDATE = "Cancel firmware update"; +const TITLE_CONFIRM_FIRMWARE_UPDATE = "Confirm firmware update"; +const TITLE_CONFIRM_REBOOT = "Confirm reboot"; +const TITLE_DEVICE_REBOOTING = "Device Rebooting"; +const TITLE_FIRMWARE_UPDATE_ERROR = "Firmware update failed!"; +const TITLE_FIRMWARE_UPDATE_IN_PROGRESS = "Firmware update in progress..."; +const TITLE_FIRMWARE_UPDATE_SUCCESS = "Firmware update succeeded!"; + +const MESSAGE_CANCELING_FIRMWARE_UPDATE = "Canceling firmware update..."; +const MESSAGE_CHECKING_FIRMWARE_UPDATE_STATUS = "Checking firmware update..."; +const MESSAGE_CONFIRM_CANCEL_UPDATE = "This action will cancel the ongoing firmware update process. Do you want to continue?"; +const MESSAGE_CONFIRM_FIRMWARE_UPDATE = "This action will update the device firmware. Do you want to continue?"; +const MESSAGE_CONFIRM_REBOOT = "This action will reboot the device and connection will be lost. Do you want to continue?"; +const MESSAGE_DEVICE_REBOOTING = "The device is rebooting. Please wait..."; +const MESSAGE_LOADING_INFORMATION = "Loading device information..."; +const MESSAGE_LOADING_FILES = "Loading files..."; +const MESSAGE_NO_FILE_SELECTED = "No file selected"; +const MESSAGE_SAVING_SYSTEM_MONITOR = "Saving system monitor settings..."; +const MESSAGE_SENDING_FIRMWARE_UPDATE_REQUEST = "Sending firmware update request..."; +const MESSAGE_SENDING_REBOOT = "Sending reboot request..."; +const MESSAGE_SENDING_UPLOAD_REQUEST = "Sending firmware upload request..."; +const MESSAGE_SYSTEM_MONITOR_SAVED = "System monitor settings saved successfully"; +const MESSAGE_UPLOAD_COMPLETE = "Firmware file upload complete"; +const MESSAGE_UPDATING_FIRMWARE = "Updating firmware..."; +const MESSAGE_UPLOADING_FIRMWARE = "Uploading firmware file..."; + +const REGEX_INTEGER = '^[0-9]+$'; + +const UPDATE_ERROR = "error"; +const UPDATE_INFO = "info"; +const UPDATE_SUCCESS = "success"; + +const DEMO_FILE_SET = "ConnectCoreDemo"; + +const TEMPLATE_FILESET_FILE = "" + + "<div id='file_{0}' class='fileset-entry' title='{1}' onclick='selectFilesetEntry(\"file_{2}\")'>" + + " <div class='fas fa-file fa-lg fileset-entry-icon'></div>" + + " <div class='fileset-entry-name'>{3}</div>" + + " <div class='fileset-entry-path'>{4}</div>" + + " <div class='fileset-entry-size'>{5}</div>" + + " <div class='fileset-entry-last-modified'>{6}</div>" + + "</div>"; + +const FIRMWARE_UPDATE_CHECK_INTERVAL = 10000; + +// Variables. +var readingManagementInfo = false; +var managementInfoRead = false; +var deviceRebooting = false; +var updatingFirmware = false; +var firmwareUpdateTimer = null; +var uploadProgressSocket = null; +var uploadFirmwareAjaxRequest = null; +var filesLoaded = false; +var selectedFilesetEntry = null; + +// Initializes the management page. +function initializeManagementPage() { + // Sanity checks. + if (!isManagementShowing() || managementInfoRead) + return; + // Read management information. + readDeviceInfoManagement(); +} + +// Gets the information of the device. +function readDeviceInfoManagement() { + // Execute only in the management page. + if (!isManagementShowing() || readingManagementInfo) + return; + // Unset device rebooting variable. + deviceRebooting = false; + // Flag reading variable. + readingManagementInfo = true; + // Hide the info popup. + showInfoPopup(false); + // Hide the firmware progress. + showFirmwareUpdateProgress(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_LOADING_INFORMATION); + // Send request to retrieve device information. + $.post( + "../ajax/get_device_info", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + if (!isManagementShowing()) + return; + // Process device information answer. + processDeviceInfoManagementResponse(data); + } + ).fail(function(response) { + // Flag reading variable. + readingManagementInfo = false; + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the device info request. +function processDeviceInfoManagementResponse(response) { + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Fill device info. + fillDeviceInfo(response); + // Read system monitor information. + readSystemMonitorInfo(); + } else { + readingManagementInfo = false; + // Hide the loading panel. + showLoadingPopup(false); + } +} + +// Gets the information of the system monitor. +function readSystemMonitorInfo() { + // Execute only in the management page. + if (!isManagementShowing()) + return; + // Hide the info popup. + showInfoPopup(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_LOADING_INFORMATION); + // Send request to retrieve device information. + $.post( + "../ajax/get_sample_rate", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + readingManagementInfo = false; + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process device information answer. + processSystemMonitorInfoResponse(data); + } + ).fail(function(response) { + // Flag reading variable. + readingManagementInfo = false; + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the system monitor info request. +function processSystemMonitorInfoResponse(response) { + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Fill system monitor info. + fillSystemMonitorInfo(response); + // Flag device info read. + managementInfoRead = true; + // Check if there is a firmware update running. + checkFirmwareUpdateRunning(); + } +} + +// Fills device information. +function fillDeviceInfo(deviceData) { + // Set DEY version. + updateFieldValue(ID_DEY_VERSION, deviceData[ID_DEY_VERSION]); + // Set Kernel version. + updateFieldValue(ID_KERNEL_VERSION, deviceData[ID_KERNEL_VERSION]); + // Set U-Boot version. + updateFieldValue(ID_UBOOT_VERSION, deviceData[ID_UBOOT_VERSION]); +} + +// Fills system monitor information. +function fillSystemMonitorInfo(response) { + // Initialize variables. + var sampleRateInput = document.getElementById(ID_SAMPLE_RATE); + var samplesBufferInput = document.getElementById(ID_NUM_SAMPLES_UPLOAD); + // Set the sample rate. + if (sampleRateInput != null && sampleRateInput != "undefined") + sampleRateInput.value = response[ID_SAMPLE_RATE]; + // Set the number of samples to upload. + if (samplesBufferInput != null && samplesBufferInput != "undefined") + samplesBufferInput.value = response[ID_NUM_SAMPLES_UPLOAD]; + // Validate system monitor. + validateSystemMonitor(); +} + +// Validates the system monitor values. +function validateSystemMonitor() { + // Initialize vars. + var saveButton = document.getElementById(ID_SAVE_BUTTON); + var sampleRateValid = validateSystemMonitorField(ID_SAMPLE_RATE, ID_SAMPLE_RATE_ERROR); + var samplesBufferValid = validateSystemMonitorField(ID_NUM_SAMPLES_UPLOAD, ID_NUM_SAMPLES_UPLOAD_ERROR); + // Check errors. + if (!sampleRateValid || !samplesBufferValid) { + if (!saveButton.classList.contains(CLASS_SAVE_BUTTON_DISABLED)) + saveButton.classList.add(CLASS_SAVE_BUTTON_DISABLED); + } else { + if (saveButton.classList.contains(CLASS_SAVE_BUTTON_DISABLED)) + saveButton.classList.remove(CLASS_SAVE_BUTTON_DISABLED); + } +} + +// Validates the given system monitor field. +function validateSystemMonitorField(fieldID, errorID) { + // Initialize vars. + var field = document.getElementById(fieldID); + var fieldError = document.getElementById(errorID); + var isValid = true; + var error = ""; + // Sanity checks. + if (field == null || fieldError == null) + return false; + // Check if value is valid. + var value = field.value; + if (value.length == 0) { + isValid = false; + error = ERROR_FIELD_EMPTY; + } else if (!value.match(REGEX_INTEGER)) { + isValid = false; + error = ERROR_FIELD_NUMBER; + } else if (parseInt(value) <= 0) { + isValid = false; + error = ERROR_FIELD_POSITIVE; + } + // Update controls. + if (isValid) { + if (field.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR)) + field.classList.remove(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR); + fieldError.innerHTML = " "; + fieldError.style.display = "none"; + } else { + if (!field.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR)) + field.classList.add(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR); + fieldError.innerHTML = error; + fieldError.style.display = "block"; + } + return isValid; +} + +// Saves the system monitor settings. +function saveSystemMonitor() { + // Initialize vars. + var sampleRateInput = document.getElementById(ID_SAMPLE_RATE); + var samplesBufferInput = document.getElementById(ID_NUM_SAMPLES_UPLOAD); + // Sanity checks. + if (sampleRateInput == null || samplesBufferInput == null) + return; + // Execute only in the management page. + if (!isManagementShowing()) + return; + // Hide the info popup. + showInfoPopup(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_SAVING_SYSTEM_MONITOR); + // Send request to set system monitor settings. + $.post( + "../ajax/set_sample_rate", + JSON.stringify({ + "device_id": getDeviceID(), + "sample_rate": sampleRateInput.value, + "num_samples_upload": samplesBufferInput.value + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process device information answer. + processSaveSystemMonitorResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the save system monitor request response. +function processSaveSystemMonitorResponse(response) { + if (!checkErrorResponse(response, false)) + toastr.success(MESSAGE_SYSTEM_MONITOR_SAVED); +} + +// Asks the user to confirm the reboot action. +function askReboot() { + showConfirmDialog(TITLE_CONFIRM_REBOOT, MESSAGE_CONFIRM_REBOOT, + function() { + // Execute the reboot. + rebootDevice(); + }, + function() { + // Do nothing. + } + ); +} + +// Reboots the device. +function rebootDevice() { + // Hide the info popup. + showInfoPopup(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_SENDING_REBOOT); + // Send request to reboot the device. + $.post( + "../ajax/reboot_device", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process reboot device answer. + processRebootDeviceResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading panel. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the reboot device request. +function processRebootDeviceResponse(response) { + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Show info dialog. + showInfoPopup(true, TITLE_DEVICE_REBOOTING, MESSAGE_DEVICE_REBOOTING); + deviceRebooting = true; + managementInfoRead = false; + // TODO: This should not be necessary when implementing device connection monitor. + prevDeviceConnectionStatus = false; + } +} + +// Opens the firmware file browser. +function openFirmwareBrowser() { + document.getElementById(ID_UPDATE_FIRMWARE_FILE).click(); +} + +// Reads the device status. +function firmwareFileChanged() { + // Execute only in the management page. + if (!isManagementShowing()) + return; + // Initialize variables. + var firmwareFileElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE); + var firmwareFileLabelElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE_LABEL); + // Hide progress bar. + showFirmwareUpdateProgress(false); + if (firmwareFileElement.files.length == 0) { + // No file selected. + firmwareFileLabelElement.innerHTML = MESSAGE_NO_FILE_SELECTED; + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, false); + return; + } + var firmwareFile = firmwareFileElement.files[0]; + // Update firmware file name. + firmwareFileLabelElement.innerHTML = firmwareFile.name; + // Enable button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, true); +} + +// Asks the user to confirm the firmware update action. +function askUpdateFirmware() { + showConfirmDialog(TITLE_CONFIRM_FIRMWARE_UPDATE, MESSAGE_CONFIRM_FIRMWARE_UPDATE, + function() { + // Sanity checks. + var activeTab = getActiveFirmwareUpdateTab(); + if (activeTab == null) + return; + // Flag updating variable. + updatingFirmware = true; + // Hide the info popup. + showInfoPopup(false); + // Hide the loading popup. + showLoadingPopup(false); + // Disable firmware update button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, false); + // Show progress bar. + showFirmwareUpdateProgress(true); + // Disable management page controls. + enableManagementPageControls(false); + // Enable cancel button. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, true); + // Check active tab. + if (activeTab == ID_FIRMWARE_TAB_UPLOAD) { + // Upload firmware. + uploadFirmwareFile(); + } else if (activeTab == ID_FIRMWARE_TAB_FILESET) { + // Build file path. + var filesetEntryElement = document.getElementById(selectedFilesetEntry); + var fileName = filesetEntryElement.getElementsByClassName(CLASS_FILESET_ENTRY_NAME)[0].innerHTML; + var filePath = filesetEntryElement.getElementsByClassName(CLASS_FILESET_ENTRY_PATH)[0].innerHTML; + // Update firmware. + updateFirmware(DEMO_FILE_SET + "/" + filePath + "/" + fileName); + } + }, + function() { + // Do nothing. + } + ); +} + +// Attempts to upload the given firmware file. +function uploadFirmwareFile() { + // Initialize variables. + var firmwareFileElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE); + var firmwareFile = firmwareFileElement.files[0]; + // Update upload status. + setFirmwareUpdateProgressInfo(0, MESSAGE_UPLOADING_FIRMWARE); + // Prepare data. + var formData = new FormData(); + formData.append("file_set", DEMO_FILE_SET); + formData.append("path", getDeviceID()); + formData.append("file_name", firmwareFile.name); + formData.append("file", firmwareFile); + // Register websocket to receive upload progress. + subscribeUploadFileProgress(firmwareFile.name); + // Send request + uploadFirmwareAjaxRequest = $.ajax({ + type: 'POST', + url: "../ajax/upload_firmware", + data: formData, + cache: false, + async: true, + processData: false, + contentType: false, + enctype: 'multipart/form-data', + success: function(response) { + // Reset request variable. + uploadFirmwareAjaxRequest = null; + // Close progress socket. + if (uploadProgressSocket != null && uploadProgressSocket != "undefined") + uploadProgressSocket.close(); + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process answer. + processUploadFirmwareFileResponse(response); + }, + error: function(response) { + // Reset request variable. + uploadFirmwareAjaxRequest = null; + // Close progress socket. + if (uploadProgressSocket != null && uploadProgressSocket != "undefined") + uploadProgressSocket.close(); + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process error. + error = processAjaxErrorResponse(response); + // Update upload status. + setFirmwareUpdateProgressError(error); + // Flag updating variable. + updatingFirmware = false; + // Enable the management page controls. + enableManagementPageControls(true); + } + }); +} + +// Processes the upload firmware file response. +function processUploadFirmwareFileResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + error = getErrorFromResponse(response); + // Update upload status. + setFirmwareUpdateProgressError(error); + // Flag updating variable. + updatingFirmware = false; + // Enable the management page controls. + enableManagementPageControls(true); + } else { + // Update upload status. + setFirmwareUpdateProgressInfo(100, MESSAGE_UPLOAD_COMPLETE); + // Build file path. + var firmwareFileElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE); + var firmwareFile = firmwareFileElement.files[0]; + // Send the update request. + updateFirmware(DEMO_FILE_SET + "/" + getDeviceID() + "/" + firmwareFile.name); + } +} + +// Subscribes to firmware update progress. +function subscribeUploadFileProgress(fileName) { + // Create the web socket. + var socketPrefix = window.location.protocol == "https:" ? "wss" : "ws"; + uploadProgressSocket = new WebSocket(socketPrefix + "://" + window.location.host + "/ws/file_upload_progress/" + fileName); + // Define the callback to be notified when firmware update progress is received. + uploadProgressSocket.onmessage = function(e) { + // Process only in the management page. + if (!isManagementShowing()) { + // Close the socket. + uploadProgressSocket.close(); + return; + } + // Update progress. + var data = JSON.parse(e.data); + setFirmwareUpdateProgressInfo(data[ID_PROGRESS], MESSAGE_UPLOADING_FIRMWARE); + } +} + +// Updates the firmware of the device. +function updateFirmware(filePath) { + // Update status. + setFirmwareUpdateProgressInfo(0, MESSAGE_SENDING_UPLOAD_REQUEST); + // Disable the cancel button. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, false); + // Send request to update the firmware. + $.post( + "../ajax/update_firmware", + JSON.stringify({ + "device_id": getDeviceID(), + "file": filePath + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process update firmware answer. + processUpdateFirmwareResponse(data); + } + ).fail(function(response) { + // Flag updating variable. + updatingFirmware = false; + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process error. + error = processAjaxErrorResponse(response); + // Update upload status. + setFirmwareUpdateProgressError(error); + // Enable the management page controls. + enableManagementPageControls(true); + }); +} + +// Processes the response of the update firmware request. +function processUpdateFirmwareResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + error = getErrorFromResponse(response); + // Update upload status. + setFirmwareUpdateProgressError(error); + // Flag updating variable. + updatingFirmware = false; + // Enable the page controls. + enableManagementPageControls(true); + } else { + // Enable the cancel button. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, true); + // Update progress status. + setFirmwareUpdateProgressInfo(100, MESSAGE_SENDING_FIRMWARE_UPDATE_REQUEST); + // Start timer to check firmware update status periodically. + startFirmwareUpdateTimer(); + // Check first firmware update status in 2 seconds. + window.setTimeout(function () { + checkFirmwareUpdateStatus(); + }, 2000); + } +} + +// Starts a timer to check the firmware update status. +function startFirmwareUpdateTimer() { + // Sanity checks + if (!isManagementShowing() || firmwareUpdateTimer != null) + return; + // Start timer to check firmware update status. + firmwareUpdateTimer = setInterval(checkFirmwareUpdateStatus, FIRMWARE_UPDATE_CHECK_INTERVAL); +} + +// Stops the timer to check the firmware update status. +function stopFirmwareUpdateTimer() { + // Stop timer. + if (firmwareUpdateTimer != null && firmwareUpdateTimer != "undefined") { + clearInterval(firmwareUpdateTimer); + firmwareUpdateTimer = null; + } +} + +// Checks the firmware update status. +function checkFirmwareUpdateStatus() { + // Sanity checks + if (!isManagementShowing()) { + // Stop timer. + stopFirmwareUpdateTimer(); + return; + } + // Send request to check firmware update status. + $.post( + "../ajax/check_firmware_update_status", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process check firmware update status answer. + processCheckFirmwareUpdateStatusResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the check firmware update status request. +function processCheckFirmwareUpdateStatusResponse(response) { + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Check if the firmware update is running. + if (response[ID_STATUS] == VALUE_ACTIVE) { + // Check the firmware update progress. + checkFirmwareUpdateProgress(); + } else if (response[ID_STATUS] == VALUE_FAILED || response[ID_STATUS] == VALUE_SUCCESSFUL || response[ID_STATUS] == VALUE_CANCELED) { + // Stop timer. + stopFirmwareUpdateTimer(); + // Flag the update variable. + updatingFirmware = false; + // Enable page controls. + enableManagementPageControls(true); + // Update the firmware update progress. + if (response[ID_STATUS] == VALUE_FAILED || response[ID_STATUS] == VALUE_CANCELED) + setFirmwareUpdateProgressError(ERROR_TITLE + ": " + response[ID_MESSAGE]); + else { + // Reset read info variable so info is read again after device reboots. + managementInfoRead = false; + // Set update as successful. + setFirmwareUpdateProgressSuccess(response[ID_MESSAGE]); + } + } + } +} + +// Checks if there is a firmware update running. +function checkFirmwareUpdateRunning() { + // Sanity checks + if (!isManagementShowing()) + return; + // Hide the info popup. + showInfoPopup(false); + // Show the loading popup. + showLoadingPopup(true, MESSAGE_CHECKING_FIRMWARE_UPDATE_STATUS); + // Send request to check firmware update running. + $.post( + "../ajax/check_firmware_update_running", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading popup. + showLoadingPopup(false); + // Process check firmware update status answer. + processCheckFirmwareUpdateRunningResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide the loading popup. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the check firmware update running request. +function processCheckFirmwareUpdateRunningResponse(response) { + // Check if the firmware update is running. + if (response[ID_UPDATE_RUNNING] == true) { + // Flag the update variable. + updatingFirmware = true; + // Disable page controls. + enableManagementPageControls(false); + // Enable cancel button. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, true); + // Show firmware update progress. + showFirmwareUpdateProgress(true); + // Update the firmware update progress. + setFirmwareUpdateProgressInfo(0, ""); + // Check the firmware update progress. + checkFirmwareUpdateProgress(); + // Subscribe timer. + startFirmwareUpdateTimer(); + } +} + +// Checks the firmware update progress. +function checkFirmwareUpdateProgress() { + // Sanity checks + if (!isManagementShowing()) + return; + // Hide the info popup. + showInfoPopup(false); + // Hide the loading popup. + showLoadingPopup(false); + // Send request to check firmware update progress. + $.post( + "../ajax/check_firmware_update_progress", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process check firmware update progress answer. + processCheckFirmwareUpdateProgressResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the firmware update progress. +function processCheckFirmwareUpdateProgressResponse(response) { + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Update the firmware update progress. + setFirmwareUpdateProgressInfo(response[ID_PROGRESS], response[ID_MESSAGE]); + } +} + +// Asks user to cancel the firmware update process +function askCancelFirmwareUpdate() { + showConfirmDialog(TITLE_CONFIRM_CANCEL_UPDATE, MESSAGE_CONFIRM_CANCEL_UPDATE, + function() { + cancelFirmwareUpdate(); + }, + function() { + // Do nothing. + } + ); +} + +// Cancels an ongoing firmware update. +function cancelFirmwareUpdate() { + // Sanity checks + if (!isManagementShowing() || !updatingFirmware) + return; + // Check the type of the firmware update. + if (uploadFirmwareAjaxRequest != null) + cancelFirmwareUploadProcess(); + else + cancelFirmwareUpdateProcess(); +} + +// Cancels the firmware upload process. +function cancelFirmwareUploadProcess() { + // Sanity checks + if (!isManagementShowing()) + return; + // Send request to cancel firmware upload. + uploadProgressSocket.send("cancel"); + // Abort AJAX request. + uploadFirmwareAjaxRequest.abort(); + uploadFirmwareAjaxRequest = null; + // Flag the update variable. + updatingFirmware = false; + // Enable page controls. + enableManagementPageControls(true); + // Hide he firmware update progress. + showFirmwareUpdateProgress(false); +} + +// Cancels the remote firmware update process. +function cancelFirmwareUpdateProcess() { + // Sanity checks + if (!isManagementShowing()) + return; + // Disable cancel button. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, false); + // Show loading popup. + showLoadingPopup(true, MESSAGE_CANCELING_FIRMWARE_UPDATE); + // Send request to cancel firmware update. + $.post( + "../ajax/cancel_firmware_update", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide loading popup. + showLoadingPopup(false); + // Process cancel firmware update answer. + processCancelFirmwareUpdateResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide loading popup. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + // Enable cancel button again. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, true); + }); +} + +// Processes the response of the cancel firmware update request. +function processCancelFirmwareUpdateResponse(response) { + // Check if there was any error in the request. + if (checkErrorResponse(response, false)) { + // Enable cancel button again. + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, true); + } else { + // Flag the update variable. + updatingFirmware = false; + // Enable page controls. + enableManagementPageControls(true); + // Hide firmware update progress. + showFirmwareUpdateProgress(false); + // Stop the firmware update timer. + stopFirmwareUpdateTimer(); + } +} + +// Clears the fileset file list. +function clearFilesetList() { + // Initialize variables. + var filesetEntriesContainerElement = document.getElementById(ID_FILESET_ITEMS_CONTAINER); + // Clear the fileset file list. + if (filesetEntriesContainerElement != null && filesetEntriesContainerElement != "undefined") { + while (filesetEntriesContainerElement.firstChild) + filesetEntriesContainerElement.removeChild(filesetEntriesContainerElement.lastChild); + } +} + +// Refresh the fileset list of files. +function refreshFilesetFiles() { + // Sanity checks + if (!isManagementShowing()) + return; + // Flag files loaded. + filesLoaded = false; + // Reset fileset files. + listFilesetFiles(DEMO_FILE_SET); +} + +// Lists all the files of a fileset. +function listFilesetFiles(fileSet) { + // Sanity checks + if (!isManagementShowing() || filesLoaded) + return; + // Unselect all fileset entries. + unselectFilesetEntries(); + // Clear the fileset list. + clearFilesetList(); + // Show loading popup. + showLoadingPopup(true, MESSAGE_LOADING_FILES); + // Send request to list files. + $.post( + "../ajax/list_fileset_files", + JSON.stringify({ + "file_set": fileSet + }), + function(data) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide loading popup. + showLoadingPopup(false); + // Process answer. + processListFilesetFilesResponse(data); + } + ).fail(function(response) { + // Process only in the management page. + if (!isManagementShowing()) + return; + // Hide loading popup. + showLoadingPopup(false); + // Process error. + processAjaxErrorResponse(response); + }); +} + +// Processes the response of the list fileset files request. +function processListFilesetFilesResponse(response) { + // Check if there was any error in the request. + if (!checkErrorResponse(response, false)) { + // Parse the files contained in the fileset. + var files = response[ID_FILES]; + // Add the files to the list. + if (files != null && files != "undefined") { + var filesetEntriesContainerElement = document.getElementById(ID_FILESET_ITEMS_CONTAINER); + for (var entry of response[ID_FILES]) { + var name = entry[ID_NAME]; + var entryDiv = document.createElement("div"); + entryDiv.innerHTML = TEMPLATE_FILESET_FILE.format(name, name, name, name, entry[ID_PATH], + sizeToHumanRead(entry[ID_SIZE]), transformDate(entry[ID_LAST_MODIFIED])); + filesetEntriesContainerElement.appendChild(entryDiv); + } + } + // Flag fileset list variable. + filesLoaded = true; + } +} + +// Selects a file from the fileset list +function selectFilesetEntry(entryID) { + // Unselect all entries. + unselectFilesetEntries(); + // Set selected style to the selected div. + var entryElement = document.getElementById(entryID) + if (entryElement != null) { + entryElement.classList.add(CLASS_FILESET_ENTRY_SELECTED); + selectedFilesetEntry = entryID; + // Enable update firmware button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, true); + // Hide firmware update progress. + showFirmwareUpdateProgress(false); + } +} + +// Unselects all the fileset entries. +function unselectFilesetEntries() { + // Initialize variables. + var fileSystemEntriesDiv = document.getElementById(ID_FILESET_ITEMS_CONTAINER); + var children = fileSystemEntriesDiv.children; + // Remove selected class from all entries. + for (var i = 0; i < children.length; i++) { + var entry = children[i].children[0]; + entry.classList.remove(CLASS_FILESET_ENTRY_SELECTED); + } + selectedFilesetEntry = null; + // Disable firmware update button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, false); +} + +// Enables/disables the management page controls. +function enableManagementPageControls(enable) { + // Reboot button. + enableManagementButton(ID_REBOOT_BUTTON, enable); + // Update firmware button. + var activeTab = getActiveFirmwareUpdateTab(); + if (activeTab == ID_FIRMWARE_TAB_UPLOAD) { + var firmwareFileElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE); + if (firmwareFileElement.files.length == 0) + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, false); + else + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, enable); + } else if (activeTab == ID_FIRMWARE_TAB_FILESET) { + if (!filesLoaded || selectedFilesetEntry == null) + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, false); + else + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, enable); + } + // Cancel update button. + if (isFirmwareUpdateRunning() && enable) + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, enable); + else + enableManagementButton(ID_CANCEL_FIRMWARE_UPDATE_BUTTON, false); + // Tabs. + var tabUploadElement = document.getElementById(ID_FIRMWARE_TAB_UPLOAD); + var tabUploadHeaderElement = document.getElementById(ID_FIRMWARE_TAB_UPLOAD_HEADER); + var tabFilesetElement = document.getElementById(ID_FIRMWARE_TAB_FILESET); + var tabFilesetHeaderElement = document.getElementById(ID_FIRMWARE_TAB_FILESET_HEADER); + if (enable) { + tabUploadElement.classList.remove((CLASS_DISABLED_DIV)); + tabUploadHeaderElement.classList.remove((CLASS_DISABLED_DIV)); + tabFilesetElement.classList.remove((CLASS_DISABLED_DIV)); + tabFilesetHeaderElement.classList.remove((CLASS_DISABLED_DIV)); + } else { + tabUploadElement.classList.add((CLASS_DISABLED_DIV)); + tabUploadHeaderElement.classList.add((CLASS_DISABLED_DIV)); + tabFilesetElement.classList.add((CLASS_DISABLED_DIV)); + tabFilesetHeaderElement.classList.add((CLASS_DISABLED_DIV)); + } +} + +// Enables/disables the given button ID +function enableManagementButton(buttonID, enable) { + // Initialize variables. + var buttonElement = document.getElementById(buttonID); + if (buttonElement != null) { + if (enable) { + if (buttonElement.classList.contains(CLASS_MANAGEMENT_BUTTON_DISABLED)) + buttonElement.classList.remove(CLASS_MANAGEMENT_BUTTON_DISABLED); + } else + buttonElement.classList.add(CLASS_MANAGEMENT_BUTTON_DISABLED); + } +} + +// Returns the active firmware update tab. +function getActiveFirmwareUpdateTab() { + // Initialize variables. + var tabUploadHeaderElement = document.getElementById(ID_FIRMWARE_TAB_UPLOAD_HEADER); + var tabFilesetHeaderElement = document.getElementById(ID_FIRMWARE_TAB_FILESET_HEADER); + // Check the active tab. + if (tabUploadHeaderElement.classList.contains(CLASS_FIRMWARE_TAB_HEADER_ACTIVE)) + return ID_FIRMWARE_TAB_UPLOAD; + else if (tabFilesetHeaderElement.classList.contains(CLASS_FIRMWARE_TAB_HEADER_ACTIVE)) + return ID_FIRMWARE_TAB_FILESET; + else + return null; +} + +// Returns whether the device is rebooting or not. +function isDeviceRebooting() { + return deviceRebooting; +} + +// Returns whether firmware update is running or not. +function isFirmwareUpdateRunning() { + return updatingFirmware; +} + +// Shows the given firmware tab +function showFirmwareTab(tabID) { + // Initialize variables. + var tabElement = document.getElementById(tabID); + var tabHeaderElement = document.getElementById(tabID + "_header"); + if (tabElement != null && tabHeaderElement != null) { + // Deselect all tab headers. + var tabHeaders = document.getElementsByClassName(CLASS_FIRMWARE_TAB_HEADER); + for (var i = 0; i < tabHeaders.length; i++) { + var tabHeader = tabHeaders[i]; + if (tabHeader.classList.contains(CLASS_FIRMWARE_TAB_HEADER_ACTIVE)) + tabHeader.classList.remove(CLASS_FIRMWARE_TAB_HEADER_ACTIVE); + } + // Hide all the tabs. + var tabs = document.getElementsByClassName(CLASS_FIRMWARE_TAB); + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + tab.style.display = "none"; + } + // Show the selected tab. + tabHeaderElement.classList.add(CLASS_FIRMWARE_TAB_HEADER_ACTIVE); + tabElement.style.display = "block"; + // Disable firmware update button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, false); + // Hide firmware update progress. + showFirmwareUpdateProgress(false); + // Perform additional actions on each tab. + switch(tabID) { + case ID_FIRMWARE_TAB_FILESET: + if (filesLoaded && selectedFilesetEntry != null) { + // Enable firmware update button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, true); + } else if (!filesLoaded) { + // Refresh fileset entries. + listFilesetFiles(DEMO_FILE_SET); + } + break; + case ID_FIRMWARE_TAB_UPLOAD: + // Check if there is a file in the file input. + var firmwareFileElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE); + if (firmwareFileElement.files.length > 0) { + // Enable firmware update button. + enableManagementButton(ID_UPDATE_FIRMWARE_BUTTON, true); + } + break; + } + } +} + +// Shows/hides the firmware update progress section. +function showFirmwareUpdateProgress(visible) { + // Initialize variables. + var firmwareUpdateProgressElement = document.getElementById(ID_UPDATE_FIRMWARE_PROGRESS); + if (firmwareUpdateProgressElement != null) { + if (visible) + firmwareUpdateProgressElement.style.display = "block"; + else + firmwareUpdateProgressElement.style.display = "none"; + } +} + +// Sets the firmware update progress. +function setFirmwareUpdateProgressInfo(progress, message=null) { + updateFirmwareUpdateProgress(UPDATE_INFO, progress, TITLE_FIRMWARE_UPDATE_IN_PROGRESS, message); +} + +// Sets the firmware update progress error. +function setFirmwareUpdateProgressError(message=null) { + updateFirmwareUpdateProgress(UPDATE_ERROR, 100, TITLE_FIRMWARE_UPDATE_ERROR, message); +} + +// Sets the firmware update progress success. +function setFirmwareUpdateProgressSuccess(message=null) { + updateFirmwareUpdateProgress(UPDATE_SUCCESS, 100, TITLE_FIRMWARE_UPDATE_SUCCESS, message); +} + +// Updates the firmware update progress. +function updateFirmwareUpdateProgress(status, progress, title=null, message=null) { + // Initialize variables. + var firmwareUpdateProgressElement = document.getElementById(ID_UPDATE_FIRMWARE_PROGRESS); + if (firmwareUpdateProgressElement != null) { + // Update the progress bar. + var progressBarElement = document.getElementById(ID_UPDATE_FIRMWARE_PROGRESS_BAR); + if (progressBarElement != null) { + // Update the progress bar status type. + if (progressBarElement.classList.contains(CLASS_PROGRESS_BAR_INFO)) + progressBarElement.classList.remove(CLASS_PROGRESS_BAR_INFO); + if (progressBarElement.classList.contains(CLASS_PROGRESS_BAR_ERROR)) + progressBarElement.classList.remove(CLASS_PROGRESS_BAR_ERROR); + if (progressBarElement.classList.contains(CLASS_PROGRESS_BAR_SUCCESS)) + progressBarElement.classList.remove(CLASS_PROGRESS_BAR_SUCCESS); + switch (status) { + case UPDATE_INFO: + progressBarElement.classList.add(CLASS_PROGRESS_BAR_INFO); + break; + case UPDATE_ERROR: + progressBarElement.classList.add(CLASS_PROGRESS_BAR_ERROR); + break; + case UPDATE_SUCCESS: + progressBarElement.classList.add(CLASS_PROGRESS_BAR_SUCCESS); + break; + } + // Update the progress bar percent. + progressBarElement.style.width = progress + "%"; + progressBarElement.innerHTML = progress + "%"; + } + // Update the progress title. + var progressTitleElement = document.getElementById(ID_UPDATE_FIRMWARE_PROGRESS_TITLE); + if (progressTitleElement != null) { + if (title != null) + progressTitleElement.innerHTML = title; + else + progressTitleElement.innerHTML = ""; + } + // Update the progress message. + var progressMessageElement = document.getElementById(ID_UPDATE_FIRMWARE_PROGRESS_MESSAGE); + if (progressMessageElement != null) { + if (message != null) + progressMessageElement.innerHTML = message; + else + progressMessageElement.innerHTML = ""; + } + } +} diff --git a/connectcore-demo-example/static/js/sidebar.js b/connectcore-demo-example/static/js/sidebar.js new file mode 100644 index 0000000..9bd3be8 --- /dev/null +++ b/connectcore-demo-example/static/js/sidebar.js @@ -0,0 +1,199 @@ +/* + * Copyright 2022, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// Constants. +const ID_DEVICE_CONNECTION_STATUS = "device-connection-status"; + +const ERROR_DEVICE_NOT_CONNECTED_TITLE = "Device offline"; +const ERROR_DEVICE_NOT_CONNECTED_MESSAGE = "The selected device is offline"; + +// Variables. +var deviceConnectionStatus; +var prevDeviceConnectionStatus; + +// Hide submenus +$("#body-row .collapse").collapse("hide"); + +// Collapse/Expand icon. +$("#collapse-icon").addClass("fa-angle-double-left"); + +// Select click. +$("#sections > a").click(function() { + selectSection($(this)); +}); + +// Collapse click. +$("[data-toggle=sidebar-collapse]").click(function() { + sidebarCollapse(); +}); + +$(".element-grayed").click(function(){return false;}); + +// Selects the given item in the sidebar. +function selectSection(selectedItem) { + // Remove decorations of previously selected element. + $("#sections .selected").removeClass(CLASS_SELECTED); + + // Decorate the selected element. + selectedItem.toggleClass(CLASS_SELECTED); +} + +// Collapses the sidebar to the left. +function sidebarCollapse() { + $(".menu-collapsed").toggleClass("d-none"); + $(".sidebar-submenu").toggleClass("d-none"); + $(".submenu-icon").toggleClass("d-none"); + + // Add/Remove right margin. + $(".digi-menu-icon").toggleClass("mr-3 mr-0"); + + $("#sidebar-container").toggleClass("sidebar-expanded sidebar-collapsed"); + + // Treating d-flex/d-none on separators with title. + var separatorTitle = $(".sidebar-separator-title"); + if (separatorTitle.hasClass("d-flex")) + separatorTitle.removeClass("d-flex"); + else + separatorTitle.addClass("d-flex"); + + // Collapse/Expand icon. + $("#collapse-icon").toggleClass("fa-angle-double-left fa-angle-double-right"); + + // Make the cards the same height. Wait some time so size is + // calculated after the content of the cards expands or collapses. + window.setTimeout(function () { + $(".adjust-card-height .card").matchHeight(); + }, 100); + + if (isDashboardShowing()) { + let refreshPanelsInterval = window.setInterval(adjustImageSize, 10); + window.setTimeout(function () { + window.clearInterval(refreshPanelsInterval); + }, 300); + } +} + +// Sets the selected section. +function setSelectedSection(element=null) { + // First, unselect all the sections. + $("#sections li").each(function(i, n) { + n.children[0].classList.remove(CLASS_SELECTED); + }); + // Select the corresponding section. + if (element != null) { + element.classList.add(CLASS_SELECTED); + } else { + $("#sections li").each(function(i, n) { + if (window.location.pathname == n.children[0].pathname) { + n.children[0].classList.add(CLASS_SELECTED); + return false; + } + }); + } +} + +// Verifies the given device parameters. +function verifyParameters() { + let url = new URL(window.location.href); + let device_id = url.searchParams.get("device_id"); + let device_name = url.searchParams.get("device_name"); + $.post( + "../ajax/check_device_connection_status", + JSON.stringify({ + "device_id": device_id, + "device_name": device_name + }), + function(data) { + if (data["redirect"]) + window.location.replace(data["redirect"]); + } + ).fail(function(response) { + processAjaxErrorResponse(response); + }); +} + +// Requests an update on the connection status of the device. +function checkDeviceConnectionStatus() { + $.post( + "../ajax/check_device_connection_status", + JSON.stringify({ + "device_id": getDeviceID() + }), + function(data) { + processDeviceConnectionStatusAnswer(data); + } + ); +} + +// Processes the device connection status answer. +function processDeviceConnectionStatusAnswer(response) { + // Sanity checks. + if (response[ID_STATUS] == null || response[ID_STATUS] == "undefined") { + // Do not continue. + return; + } + // Save the new connection status. + deviceConnectionStatus = response[ID_STATUS]; + // Get icon and title based on connection status. + var statusImage = ""; + var statusTitle = ""; + if (deviceConnectionStatus == true) { + statusImage = IMAGE_ONLINE; + statusTitle = VALUE_ONLINE; + } else { + statusImage = IMAGE_OFFLINE; + statusTitle = VALUE_OFFLINE; + } + // Update the connection status icon and title. + var deviceStatusElement = document.getElementById(ID_DEVICE_CONNECTION_STATUS); + if (deviceStatusElement != null) { + deviceStatusElement.src = PATH_IMAGES + statusImage; + deviceStatusElement.title = statusTitle; + } + // Check if connection changed to update the displayed section. + if (prevDeviceConnectionStatus != deviceConnectionStatus) { + if (isDashboardShowing()) { + if (deviceConnectionStatus) + initDevice(); + else + displayDeviceDisconnectedError(); + } else if (isManagementShowing()) { + if (deviceConnectionStatus) + initializeManagementPage(); + else if (!isDeviceRebooting()) + displayDeviceDisconnectedError(); + } else if (isHistoryShowing()) { + if (deviceConnectionStatus) + initCharts(); + else + displayDeviceDisconnectedError(); + } + } + // Store connection status. + prevDeviceConnectionStatus = deviceConnectionStatus; + // Schedule a new connection status update in 30 seconds. + setTimeout(checkDeviceConnectionStatus, 30000); +} + +// Displays the device disconnected error. +function displayDeviceDisconnectedError() { + // Device disconnected, display error. + toastr.error(ERROR_DEVICE_NOT_CONNECTED_TITLE); + // Hide the loading panel of the device. + showLoadingPopup(false); + // Show info dialog. + showInfoPopup(true, ERROR_DEVICE_NOT_CONNECTED_TITLE, ERROR_DEVICE_NOT_CONNECTED_MESSAGE); +} \ No newline at end of file diff --git a/connectcore-demo-example/static/js/simple-timer.js b/connectcore-demo-example/static/js/simple-timer.js new file mode 100644 index 0000000..90f0127 --- /dev/null +++ b/connectcore-demo-example/static/js/simple-timer.js @@ -0,0 +1,32 @@ +/* + * Copyright 2020, Digi International Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +const SEPARATOR = "@@@" + +var currentTime; +var timer; + +function updateTime() { + currentTime += 1; + postMessage(new Date(1000 * currentTime).toISOString().substr(11, 8)); +} + +onmessage = function (event) { + var parts = event.data.split(SEPARATOR); + currentTime = parseInt(parts[0]); + var factor = parseInt(parts[1]); + setInterval(updateTime, 1000 / factor); +}; \ No newline at end of file diff --git a/connectcore-demo-example/static/js/toastr.min.js b/connectcore-demo-example/static/js/toastr.min.js new file mode 100644 index 0000000..b38c5d3 --- /dev/null +++ b/connectcore-demo-example/static/js/toastr.min.js @@ -0,0 +1 @@ +!function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return g({type:O.error,iconClass:m().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=m()),v=e("#"+t.containerId),v.length?v:(n&&(v=d(t)),v)}function o(e,t,n){return g({type:O.info,iconClass:m().iconClasses.info,message:e,optionsOverride:n,title:t})}function s(e){C=e}function i(e,t,n){return g({type:O.success,iconClass:m().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return g({type:O.warning,iconClass:m().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e,t){var o=m();v||n(o),u(e,o,t)||l(o)}function c(t){var o=m();return v||n(o),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function l(t){for(var n=v.children(),o=n.length-1;o>=0;o--)u(e(n[o]),t)}function u(t,n,o){var s=!(!o||!o.force)&&o.force;return!(!t||!s&&0!==e(":focus",t).length)&&(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0)}function d(t){return v=e("<div/>").attr("id",t.containerId).addClass(t.positionClass),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">×</button>',closeClass:"toast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"toast-progress",rtl:!1}}function f(e){C&&C(e)}function g(t){function o(e){return null==e&&(e=""),e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function s(){c(),u(),d(),p(),g(),C(),l(),i()}function i(){var e="";switch(t.iconClass){case"toast-success":case"toast-info":e="polite";break;default:e="assertive"}I.attr("aria-live",e)}function a(){E.closeOnHover&&I.hover(H,D),!E.onclick&&E.tapToDismiss&&I.click(b),E.closeButton&&j&&j.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),E.onCloseClick&&E.onCloseClick(e),b(!0)}),E.onclick&&I.click(function(e){E.onclick(e),b()})}function r(){I.hide(),I[E.showMethod]({duration:E.showDuration,easing:E.showEasing,complete:E.onShown}),E.timeOut>0&&(k=setTimeout(b,E.timeOut),F.maxHideTime=parseFloat(E.timeOut),F.hideEta=(new Date).getTime()+F.maxHideTime,E.progressBar&&(F.intervalId=setInterval(x,10)))}function c(){t.iconClass&&I.addClass(E.toastClass).addClass(y)}function l(){E.newestOnTop?v.prepend(I):v.append(I)}function u(){if(t.title){var e=t.title;E.escapeHtml&&(e=o(t.title)),M.append(e).addClass(E.titleClass),I.append(M)}}function d(){if(t.message){var e=t.message;E.escapeHtml&&(e=o(t.message)),B.append(e).addClass(E.messageClass),I.append(B)}}function p(){E.closeButton&&(j.addClass(E.closeClass).attr("role","button"),I.prepend(j))}function g(){E.progressBar&&(q.addClass(E.progressClass),I.prepend(q))}function C(){E.rtl&&I.addClass("rtl")}function O(e,t){if(e.preventDuplicates){if(t.message===w)return!0;w=t.message}return!1}function b(t){var n=t&&E.closeMethod!==!1?E.closeMethod:E.hideMethod,o=t&&E.closeDuration!==!1?E.closeDuration:E.hideDuration,s=t&&E.closeEasing!==!1?E.closeEasing:E.hideEasing;if(!e(":focus",I).length||t)return clearTimeout(F.intervalId),I[n]({duration:o,easing:s,complete:function(){h(I),clearTimeout(k),E.onHidden&&"hidden"!==P.state&&E.onHidden(),P.state="hidden",P.endTime=new Date,f(P)}})}function D(){(E.timeOut>0||E.extendedTimeOut>0)&&(k=setTimeout(b,E.extendedTimeOut),F.maxHideTime=parseFloat(E.extendedTimeOut),F.hideEta=(new Date).getTime()+F.maxHideTime)}function H(){clearTimeout(k),F.hideEta=0,I.stop(!0,!0)[E.showMethod]({duration:E.showDuration,easing:E.showEasing})}function x(){var e=(F.hideEta-(new Date).getTime())/F.maxHideTime*100;q.width(e+"%")}var E=m(),y=t.iconClass||E.iconClass;if("undefined"!=typeof t.optionsOverride&&(E=e.extend(E,t.optionsOverride),y=t.optionsOverride.iconClass||y),!O(E,t)){T++,v=n(E,!0);var k=null,I=e("<div/>"),M=e("<div/>"),B=e("<div/>"),q=e("<div/>"),j=e(E.closeHtml),F={intervalId:null,hideEta:null,maxHideTime:null},P={toastId:T,state:"visible",startTime:new Date,options:E,map:t};return s(),r(),a(),f(P),E.debug&&console&&console.log(P),I}}function m(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),w=void 0))}var v,C,w,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:c,error:t,getContainer:n,info:o,options:{},subscribe:s,success:i,version:"2.1.4",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)}); \ No newline at end of file diff --git a/connectcore-demo-example/static/js/xterm-addon-fit.js b/connectcore-demo-example/static/js/xterm-addon-fit.js new file mode 100644 index 0000000..1b17589 --- /dev/null +++ b/connectcore-demo-example/static/js/xterm-addon-fit.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(function(){return(()=>{"use strict";var e={775:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0;var r=function(){function e(){}return e.prototype.activate=function(e){this._terminal=e},e.prototype.dispose=function(){},e.prototype.fit=function(){var e=this.proposeDimensions();if(e&&this._terminal){var t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}},e.prototype.proposeDimensions=function(){if(this._terminal&&this._terminal.element&&this._terminal.element.parentElement){var e=this._terminal._core;if(0!==e._renderService.dimensions.actualCellWidth&&0!==e._renderService.dimensions.actualCellHeight){var t=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(t.getPropertyValue("height")),i=Math.max(0,parseInt(t.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o=r-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=i-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-e.viewport.scrollBarWidth;return{cols:Math.max(2,Math.floor(a/e._renderService.dimensions.actualCellWidth)),rows:Math.max(1,Math.floor(o/e._renderService.dimensions.actualCellHeight))}}}},e}();t.FitAddon=r}},t={};return function r(i){if(t[i])return t[i].exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(775)})()})); \ No newline at end of file diff --git a/connectcore-demo-example/static/js/xterm.js b/connectcore-demo-example/static/js/xterm.js new file mode 100644 index 0000000..f4759fa --- /dev/null +++ b/connectcore-demo-example/static/js/xterm.js @@ -0,0 +1,7 @@ +/** + * Skipped minification because the original files appears to be already minified. + * Original file: /npm/xterm@4.18.0/lib/xterm.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(self,(function(){return(()=>{"use strict";var e={4567:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;var o=r(9042),s=r(6114),a=r(9924),c=r(3656),l=r(844),h=r(5596),u=r(9631),f=function(e){function t(t,r){var i=e.call(this)||this;i._terminal=t,i._renderService=r,i._liveRegionLineCount=0,i._charsToConsume=[],i._charsToAnnounce="",i._accessibilityTreeRoot=document.createElement("div"),i._accessibilityTreeRoot.classList.add("xterm-accessibility"),i._accessibilityTreeRoot.tabIndex=0,i._rowContainer=document.createElement("div"),i._rowContainer.setAttribute("role","list"),i._rowContainer.classList.add("xterm-accessibility-tree"),i._rowElements=[];for(var n=0;n<i._terminal.rows;n++)i._rowElements[n]=i._createAccessibilityTreeNode(),i._rowContainer.appendChild(i._rowElements[n]);if(i._topBoundaryFocusListener=function(e){return i._onBoundaryFocus(e,0)},i._bottomBoundaryFocusListener=function(e){return i._onBoundaryFocus(e,1)},i._rowElements[0].addEventListener("focus",i._topBoundaryFocusListener),i._rowElements[i._rowElements.length-1].addEventListener("focus",i._bottomBoundaryFocusListener),i._refreshRowsDimensions(),i._accessibilityTreeRoot.appendChild(i._rowContainer),i._renderRowsDebouncer=new a.TimeBasedDebouncer(i._renderRows.bind(i)),i._refreshRows(),i._liveRegion=document.createElement("div"),i._liveRegion.classList.add("live-region"),i._liveRegion.setAttribute("aria-live","assertive"),i._accessibilityTreeRoot.appendChild(i._liveRegion),!i._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");return i._terminal.element.insertAdjacentElement("afterbegin",i._accessibilityTreeRoot),i.register(i._renderRowsDebouncer),i.register(i._terminal.onResize((function(e){return i._onResize(e.rows)}))),i.register(i._terminal.onRender((function(e){return i._refreshRows(e.start,e.end)}))),i.register(i._terminal.onScroll((function(){return i._refreshRows()}))),i.register(i._terminal.onA11yChar((function(e){return i._onChar(e)}))),i.register(i._terminal.onLineFeed((function(){return i._onChar("\n")}))),i.register(i._terminal.onA11yTab((function(e){return i._onTab(e)}))),i.register(i._terminal.onKey((function(e){return i._onKey(e.key)}))),i.register(i._terminal.onBlur((function(){return i._clearLiveRegion()}))),i.register(i._renderService.onDimensionsChange((function(){return i._refreshRowsDimensions()}))),i._screenDprMonitor=new h.ScreenDprMonitor,i.register(i._screenDprMonitor),i._screenDprMonitor.setListener((function(){return i._refreshRowsDimensions()})),i.register((0,c.addDisposableDomListener)(window,"resize",(function(){return i._refreshRowsDimensions()}))),i}return n(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),(0,u.removeElementFromParent)(this._accessibilityTreeRoot),this._rowElements.length=0},t.prototype._onBoundaryFocus=function(e,t){var r=e.target,i=this._rowElements[0===t?1:this._rowElements.length-2];if(r.getAttribute("aria-posinset")!==(0===t?"1":""+this._terminal.buffer.lines.length)&&e.relatedTarget===i){var n,o;if(0===t?(n=r,o=this._rowElements.pop(),this._rowContainer.removeChild(o)):(n=this._rowElements.shift(),o=r,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),o.removeEventListener("focus",this._bottomBoundaryFocusListener),0===t){var s=this._createAccessibilityTreeNode();this._rowElements.unshift(s),this._rowContainer.insertAdjacentElement("afterbegin",s)}else s=this._createAccessibilityTreeNode(),this._rowElements.push(s),this._rowContainer.appendChild(s);this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===t?-1:1),this._rowElements[0===t?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}},t.prototype._onResize=function(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(var t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)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;t<e;t++)this._onChar(" ")},t.prototype._onChar=function(e){var t=this;this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=o.tooMuchOutput)),s.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,s.isMac&&(0,u.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 r=this._terminal.buffer,i=r.lines.length.toString(),n=e;n<=t;n++){var o=r.translateBufferLineToString(r.ydisp+n,!0),s=(r.ydisp+n+1).toString(),a=this._rowElements[n];a&&(0===o.length?a.innerText=" ":a.textContent=o,a.setAttribute("aria-posinset",s),a.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<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}},t.prototype._refreshRowDimensions=function(e){e.style.height=this._renderService.dimensions.actualCellHeight+"px"},t.prototype._announceCharacters=function(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")},t}(l.Disposable);t.AccessibilityManager=f},3614:(e,t)=>{function r(e){return e.replace(/\r?\n/g,"\r")}function i(e,t){return t?"[200~"+e+"[201~":e}function n(e,t,n){e=i(e=r(e),n.decPrivateModes.bracketedPasteMode),n.triggerDataEvent(e,!0),t.value=""}function o(e,t,r){var i=r.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=n+"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=r,t.bracketTextForPaste=i,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,r){e.stopPropagation(),e.clipboardData&&n(e.clipboardData.getData("text/plain"),t,r)},t.paste=n,t.moveTextAreaUnderMouseCursor=o,t.rightClickHandler=function(e,t,r,i,n){o(e,t,r),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}},4774:(e,t)=>{var r,i,n,o;function s(e){var t=e.toString(16);return t.length<2?"0"+t:t}function a(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}Object.defineProperty(t,"__esModule",{value:!0}),t.contrastRatio=t.toPaddedHex=t.rgba=t.rgb=t.css=t.color=t.channels=void 0,function(e){e.toCss=function(e,t,r,i){return void 0!==i?"#"+s(e)+s(t)+s(r)+s(i):"#"+s(e)+s(t)+s(r)},e.toRgba=function(e,t,r,i){return void 0===i&&(i=255),(e<<24|t<<16|r<<8|i)>>>0}}(r=t.channels||(t.channels={})),(i=t.color||(t.color={})).blend=function(e,t){var i=(255&t.rgba)/255;if(1===i)return{css:t.css,rgba:t.rgba};var n=t.rgba>>24&255,o=t.rgba>>16&255,s=t.rgba>>8&255,a=e.rgba>>24&255,c=e.rgba>>16&255,l=e.rgba>>8&255,h=a+Math.round((n-a)*i),u=c+Math.round((o-c)*i),f=l+Math.round((s-l)*i);return{css:r.toCss(h,u,f),rgba:r.toRgba(h,u,f)}},i.isOpaque=function(e){return 255==(255&e.rgba)},i.ensureContrastRatio=function(e,t,r){var i=o.ensureContrastRatio(e.rgba,t.rgba,r);if(i)return o.toColor(i>>24&255,i>>16&255,i>>8&255)},i.opaque=function(e){var t=(255|e.rgba)>>>0,i=o.toChannels(t),n=i[0],s=i[1],a=i[2];return{css:r.toCss(n,s,a),rgba:t}},i.opacity=function(e,t){var i=Math.round(255*t),n=o.toChannels(e.rgba),s=n[0],a=n[1],c=n[2];return{css:r.toCss(s,a,c,i),rgba:r.toRgba(s,a,c,i)}},i.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(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,r){var i=e/255,n=t/255,o=r/255;return.2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.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}(n=t.rgb||(t.rgb={})),function(e){function t(e,t,r){for(var i=e>>24&255,o=e>>16&255,s=e>>8&255,c=t>>24&255,l=t>>16&255,h=t>>8&255,u=a(n.relativeLuminance2(c,h,l),n.relativeLuminance2(i,o,s));u<r&&(c>0||l>0||h>0);)c-=Math.max(0,Math.ceil(.1*c)),l-=Math.max(0,Math.ceil(.1*l)),h-=Math.max(0,Math.ceil(.1*h)),u=a(n.relativeLuminance2(c,h,l),n.relativeLuminance2(i,o,s));return(c<<24|l<<16|h<<8|255)>>>0}function i(e,t,r){for(var i=e>>24&255,o=e>>16&255,s=e>>8&255,c=t>>24&255,l=t>>16&255,h=t>>8&255,u=a(n.relativeLuminance2(c,h,l),n.relativeLuminance2(i,o,s));u<r&&(c<255||l<255||h<255);)c=Math.min(255,c+Math.ceil(.1*(255-c))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=Math.min(255,h+Math.ceil(.1*(255-h))),u=a(n.relativeLuminance2(c,h,l),n.relativeLuminance2(i,o,s));return(c<<24|l<<16|h<<8|255)>>>0}e.ensureContrastRatio=function(e,r,o){var s=n.relativeLuminance(e>>8),c=n.relativeLuminance(r>>8);if(a(s,c)<o)return c<s?t(e,r,o):i(e,r,o)},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},e.toColor=function(e,t,i){return{css:r.toCss(e,t,i),rgba:r.toRgba(e,t,i)}}}(o=t.rgba||(t.rgba={})),t.toPaddedHex=s,t.contrastRatio=a},7239:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;var r=function(){function e(){this._color={},this._rgba={}}return e.prototype.clear=function(){this._color={},this._rgba={}},e.prototype.setCss=function(e,t,r){this._rgba[e]||(this._rgba[e]={}),this._rgba[e][t]=r},e.prototype.getCss=function(e,t){return this._rgba[e]?this._rgba[e][t]:void 0},e.prototype.setColor=function(e,t,r){this._color[e]||(this._color[e]={}),this._color[e][t]=r},e.prototype.getColor=function(e,t){return this._color[e]?this._color[e][t]:void 0},e}();t.ColorContrastCache=r},5680:function(e,t,r){var i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.ColorManager=t.DEFAULT_ANSI_COLORS=void 0;var n=r(4774),o=r(7239),s=n.css.toColor("#ffffff"),a=n.css.toColor("#000000"),c=n.css.toColor("#ffffff"),l=n.css.toColor("#000000"),h={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};t.DEFAULT_ANSI_COLORS=Object.freeze(function(){for(var e=[n.css.toColor("#2e3436"),n.css.toColor("#cc0000"),n.css.toColor("#4e9a06"),n.css.toColor("#c4a000"),n.css.toColor("#3465a4"),n.css.toColor("#75507b"),n.css.toColor("#06989a"),n.css.toColor("#d3d7cf"),n.css.toColor("#555753"),n.css.toColor("#ef2929"),n.css.toColor("#8ae234"),n.css.toColor("#fce94f"),n.css.toColor("#729fcf"),n.css.toColor("#ad7fa8"),n.css.toColor("#34e2e2"),n.css.toColor("#eeeeec")],t=[0,95,135,175,215,255],r=0;r<216;r++){var i=t[r/36%6|0],o=t[r/6%6|0],s=t[r%6];e.push({css:n.channels.toCss(i,o,s),rgba:n.channels.toRgba(i,o,s)})}for(r=0;r<24;r++){var a=8+10*r;e.push({css:n.channels.toCss(a,a,a),rgba:n.channels.toRgba(a,a,a)})}return e}());var u=function(){function e(e,r){this.allowTransparency=r;var i=e.createElement("canvas");i.width=1,i.height=1;var u=i.getContext("2d");if(!u)throw new Error("Could not get rendering context");this._ctx=u,this._ctx.globalCompositeOperation="copy",this._litmusColor=this._ctx.createLinearGradient(0,0,1,1),this._contrastCache=new o.ColorContrastCache,this.colors={foreground:s,background:a,cursor:c,cursorAccent:l,selectionTransparent:h,selectionOpaque:n.color.blend(a,h),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache},this._updateRestoreColors()}return e.prototype.onOptionsChange=function(e){"minimumContrastRatio"===e&&this._contrastCache.clear()},e.prototype.setTheme=function(e){void 0===e&&(e={}),this.colors.foreground=this._parseColor(e.foreground,s),this.colors.background=this._parseColor(e.background,a),this.colors.cursor=this._parseColor(e.cursor,c,!0),this.colors.cursorAccent=this._parseColor(e.cursorAccent,l,!0),this.colors.selectionTransparent=this._parseColor(e.selection,h,!0),this.colors.selectionOpaque=n.color.blend(this.colors.background,this.colors.selectionTransparent),n.color.isOpaque(this.colors.selectionTransparent)&&(this.colors.selectionTransparent=n.color.opacity(this.colors.selectionTransparent,.3)),this.colors.ansi[0]=this._parseColor(e.black,t.DEFAULT_ANSI_COLORS[0]),this.colors.ansi[1]=this._parseColor(e.red,t.DEFAULT_ANSI_COLORS[1]),this.colors.ansi[2]=this._parseColor(e.green,t.DEFAULT_ANSI_COLORS[2]),this.colors.ansi[3]=this._parseColor(e.yellow,t.DEFAULT_ANSI_COLORS[3]),this.colors.ansi[4]=this._parseColor(e.blue,t.DEFAULT_ANSI_COLORS[4]),this.colors.ansi[5]=this._parseColor(e.magenta,t.DEFAULT_ANSI_COLORS[5]),this.colors.ansi[6]=this._parseColor(e.cyan,t.DEFAULT_ANSI_COLORS[6]),this.colors.ansi[7]=this._parseColor(e.white,t.DEFAULT_ANSI_COLORS[7]),this.colors.ansi[8]=this._parseColor(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),this.colors.ansi[9]=this._parseColor(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),this.colors.ansi[10]=this._parseColor(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),this.colors.ansi[11]=this._parseColor(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),this.colors.ansi[12]=this._parseColor(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),this.colors.ansi[13]=this._parseColor(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),this.colors.ansi[14]=this._parseColor(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),this.colors.ansi[15]=this._parseColor(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),this._contrastCache.clear(),this._updateRestoreColors()},e.prototype.restoreColor=function(e){if(void 0!==e)switch(e){case 256:this.colors.foreground=this._restoreColors.foreground;break;case 257:this.colors.background=this._restoreColors.background;break;case 258:this.colors.cursor=this._restoreColors.cursor;break;default:this.colors.ansi[e]=this._restoreColors.ansi[e]}else for(var t=0;t<this._restoreColors.ansi.length;++t)this.colors.ansi[t]=this._restoreColors.ansi[t]},e.prototype._updateRestoreColors=function(){this._restoreColors={foreground:this.colors.foreground,background:this.colors.background,cursor:this.colors.cursor,ansi:i([],this.colors.ansi,!0)}},e.prototype._parseColor=function(e,t,r){if(void 0===r&&(r=this.allowTransparency),void 0===e)return t;if(this._ctx.fillStyle=this._litmusColor,this._ctx.fillStyle=e,"string"!=typeof this._ctx.fillStyle)return console.warn("Color: "+e+" is invalid using fallback "+t.css),t;this._ctx.fillRect(0,0,1,1);var i=this._ctx.getImageData(0,0,1,1).data;if(255!==i[3]){if(!r)return console.warn("Color: "+e+" is using transparency, but allowTransparency is false. Using fallback "+t.css+"."),t;var o=this._ctx.fillStyle.substring(5,this._ctx.fillStyle.length-1).split(",").map((function(e){return Number(e)})),s=o[0],a=o[1],c=o[2],l=o[3],h=Math.round(255*l);return{rgba:n.channels.toRgba(s,a,c,h),css:e}}return{css:this._ctx.fillStyle,rgba:n.channels.toRgba(i[0],i[1],i[2],i[3])}},e}();t.ColorManager=u},9631:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeElementFromParent=void 0,t.removeElementFromParent=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var i=0,n=t;i<n.length;i++){var o=n[i];null===(e=null==o?void 0:o.parentElement)||void 0===e||e.removeChild(o)}}},3656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,r,i){e.addEventListener(t,r,i);var n=!1;return{dispose:function(){n||(n=!0,e.removeEventListener(t,r,i))}}}},3551:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseZone=t.Linkifier=void 0;var o=r(8460),s=r(2585),a=function(){function e(e,t,r){this._bufferService=e,this._logService=t,this._unicodeService=r,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,r){var i=this;this._mouseZoneManager&&(void 0===this._rowsToLinkify.start||void 0===this._rowsToLinkify.end?(this._rowsToLinkify.start=t,this._rowsToLinkify.end=r):(this._rowsToLinkify.start=Math.min(this._rowsToLinkify.start,t),this._rowsToLinkify.end=Math.max(this._rowsToLinkify.end,r)),this._mouseZoneManager.clearAll(t,r),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 r=e.ydisp+Math.min(this._rowsToLinkify.end,this._bufferService.rows)+1,i=Math.ceil(2e3/this._bufferService.cols),n=this._bufferService.buffer.iterator(!1,t,r,i,i);n.hasNext();)for(var o=n.next(),s=0;s<this._linkMatchers.length;s++)this._doLinkifyRow(o.range.first,o.content,this._linkMatchers[s]);this._rowsToLinkify.start=void 0,this._rowsToLinkify.end=void 0}}else this._logService.debug("_rowToLinkify was unset before _linkifyRows was called")},e.prototype.registerLinkMatcher=function(e,t,r){if(void 0===r&&(r={}),!t)throw new Error("handler must be defined");var i={id:this._nextLinkMatcherId++,regex:e,handler:t,matchIndex:r.matchIndex,validationCallback:r.validationCallback,hoverTooltipCallback:r.tooltipCallback,hoverLeaveCallback:r.leaveCallback,willLinkActivate:r.willLinkActivate,priority:r.priority||0};return this._addLinkMatcherToList(i),i.id},e.prototype._addLinkMatcherToList=function(e){if(0!==this._linkMatchers.length){for(var t=this._linkMatchers.length-1;t>=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<this._linkMatchers.length;t++)if(this._linkMatchers[t].id===e)return this._linkMatchers.splice(t,1),!0;return!1},e.prototype._doLinkifyRow=function(e,t,r){for(var i,n=this,o=new RegExp(r.regex.source,(r.regex.flags||"")+"g"),s=-1,a=function(){var a=i["number"!=typeof r.matchIndex?0:r.matchIndex];if(!a)return c._logService.debug("match found without corresponding matchIndex",i,r),"break";if(s=t.indexOf(a,s+1),o.lastIndex=s+a.length,s<0)return"break";var l=c._bufferService.buffer.stringIndexToBufferIndex(e,s);if(l[0]<0)return"break";var h=c._bufferService.buffer.lines.get(l[0]);if(!h)return"break";var u=h.getFg(l[1]),f=u?u>>9&511:void 0;r.validationCallback?r.validationCallback(a,(function(e){n._rowsTimeoutId||e&&n._addLink(l[1],l[0]-n._bufferService.buffer.ydisp,a,r,f)})):c._addLink(l[1],l[0]-c._bufferService.buffer.ydisp,a,r,f)},c=this;null!==(i=o.exec(t))&&"break"!==a(););},e.prototype._addLink=function(e,t,r,i,n){var o=this;if(this._mouseZoneManager&&this._element){var s=this._unicodeService.getStringCellWidth(r),a=e%this._bufferService.cols,l=t+Math.floor(e/this._bufferService.cols),h=(a+s)%this._bufferService.cols,u=l+Math.floor((a+s)/this._bufferService.cols);0===h&&(h=this._bufferService.cols,u--),this._mouseZoneManager.add(new c(a+1,l+1,h+1,u+1,(function(e){if(i.handler)return i.handler(e,r);var t=window.open();t?(t.opener=null,t.location.href=r):console.warn("Opening link blocked as opener could not be cleared")}),(function(){o._onShowLinkUnderline.fire(o._createLinkHoverEvent(a,l,h,u,n)),o._element.classList.add("xterm-cursor-pointer")}),(function(e){o._onLinkTooltip.fire(o._createLinkHoverEvent(a,l,h,u,n)),i.hoverTooltipCallback&&i.hoverTooltipCallback(e,r,{start:{x:a,y:l},end:{x:h,y:u}})}),(function(){o._onHideLinkUnderline.fire(o._createLinkHoverEvent(a,l,h,u,n)),o._element.classList.remove("xterm-cursor-pointer"),i.hoverLeaveCallback&&i.hoverLeaveCallback()}),(function(e){return!i.willLinkActivate||i.willLinkActivate(e,r)})))}},e.prototype._createLinkHoverEvent=function(e,t,r,i,n){return{x1:e,y1:t,x2:r,y2:i,cols:this._bufferService.cols,fg:n}},e._timeBeforeLatency=200,e=i([n(0,s.IBufferService),n(1,s.ILogService),n(2,s.IUnicodeService)],e)}();t.Linkifier=a;var c=function(e,t,r,i,n,o,s,a,c){this.x1=e,this.y1=t,this.x2=r,this.y2=i,this.clickCallback=n,this.hoverCallback=o,this.tooltipCallback=s,this.leaveCallback=a,this.willLinkActivate=c};t.MouseZone=c},6465:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Linkifier2=void 0;var a=r(2585),c=r(8460),l=r(844),h=r(3656),u=function(e){function t(t){var r=e.call(this)||this;return r._bufferService=t,r._linkProviders=[],r._linkCacheDisposables=[],r._isMouseOut=!0,r._activeLine=-1,r._onShowLinkUnderline=r.register(new c.EventEmitter),r._onHideLinkUnderline=r.register(new c.EventEmitter),r.register((0,l.getDisposeArrayDisposable)(r._linkCacheDisposables)),r}return n(t,e),Object.defineProperty(t.prototype,"currentLink",{get:function(){return this._currentLink},enumerable:!1,configurable:!0}),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 r=t._linkProviders.indexOf(e);-1!==r&&t._linkProviders.splice(r,1)}}},t.prototype.attachToDom=function(e,t,r){var i=this;this._element=e,this._mouseService=t,this._renderService=r,this.register((0,h.addDisposableDomListener)(this._element,"mouseleave",(function(){i._isMouseOut=!0,i._clearCurrentLink()}))),this.register((0,h.addDisposableDomListener)(this._element,"mousemove",this._onMouseMove.bind(this))),this.register((0,h.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 r=e.composedPath(),i=0;i<r.length;i++){var n=r[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._onHover(t),this._lastBufferCell=t)}}},t.prototype._onHover=function(e){if(this._activeLine!==e.y)return this._clearCurrentLink(),void this._askForLink(e,!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))},t.prototype._askForLink=function(e,t){var r,i=this;this._activeProviderReplies&&t||(null===(r=this._activeProviderReplies)||void 0===r||r.forEach((function(e){null==e||e.forEach((function(e){e.link.dispose&&e.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=e.y);var n=!1;this._linkProviders.forEach((function(r,o){var s;t?(null===(s=i._activeProviderReplies)||void 0===s?void 0:s.get(o))&&(n=i._checkLinkProviderResult(o,e,n)):r.provideLinks(e.y,(function(t){var r,s;if(!i._isMouseOut){var a=null==t?void 0:t.map((function(e){return{link:e}}));null===(r=i._activeProviderReplies)||void 0===r||r.set(o,a),n=i._checkLinkProviderResult(o,e,n),(null===(s=i._activeProviderReplies)||void 0===s?void 0:s.size)===i._linkProviders.length&&i._removeIntersectingLinks(e.y,i._activeProviderReplies)}}))}))},t.prototype._removeIntersectingLinks=function(e,t){for(var r=new Set,i=0;i<t.size;i++){var n=t.get(i);if(n)for(var o=0;o<n.length;o++)for(var s=n[o],a=s.link.range.start.y<e?0:s.link.range.start.x,c=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x,l=a;l<=c;l++){if(r.has(l)){n.splice(o--,1);break}r.add(l)}}},t.prototype._checkLinkProviderResult=function(e,t,r){var i,n=this;if(!this._activeProviderReplies)return r;for(var o=this._activeProviderReplies.get(e),s=!1,a=0;a<e;a++)this._activeProviderReplies.has(a)&&!this._activeProviderReplies.get(a)||(s=!0);if(!s&&o){var c=o.find((function(e){return n._linkAtPosition(e.link,t)}));c&&(r=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviders.length&&!r)for(a=0;a<this._activeProviderReplies.size;a++){var l=null===(i=this._activeProviderReplies.get(a))||void 0===i?void 0:i.find((function(e){return n._linkAtPosition(e.link,t)}));if(l){r=!0,this._handleNewLink(l);break}}return r},t.prototype._onClick=function(e){if(this._element&&this._mouseService&&this._currentLink){var t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}},t.prototype._clearCurrentLink=function(e,t){this._element&&this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.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,(0,l.disposeArray)(this._linkCacheDisposables))},t.prototype._handleNewLink=function(e){var t=this;if(this._element&&this._lastMouseEvent&&this._mouseService){var r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._linkAtPosition(e.link,r)&&(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,r;return null===(r=null===(e=t._currentLink)||void 0===e?void 0:e.state)||void 0===r?void 0:r.decorations.pointerCursor},set:function(e){var r,i;(null===(r=t._currentLink)||void 0===r?void 0:r.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,r;return null===(r=null===(e=t._currentLink)||void 0===e?void 0:e.state)||void 0===r?void 0:r.decorations.underline},set:function(r){var i,n,o;(null===(i=t._currentLink)||void 0===i?void 0:i.state)&&(null===(o=null===(n=t._currentLink)||void 0===n?void 0:n.state)||void 0===o?void 0:o.decorations.underline)!==r&&(t._currentLink.state.decorations.underline=r,t._currentLink.state.isHovered&&t._fireUnderlineEvent(e.link,r))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedBufferChange((function(e){var r=0===e.start?0:e.start+1+t._bufferService.buffer.ydisp;t._clearCurrentLink(r,e.end+1+t._bufferService.buffer.ydisp)}))))}},t.prototype._linkHover=function(e,t,r){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(r,t.text)},t.prototype._fireUnderlineEvent=function(e,t){var r=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-i-1,r.end.x,r.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)},t.prototype._linkLeave=function(e,t,r){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(r,t.text)},t.prototype._linkAtPosition=function(e,t){var r=e.range.start.y===e.range.end.y,i=e.range.start.y<t.y,n=e.range.end.y>t.y;return(r&&e.range.start.x<=t.x&&e.range.end.x>=t.x||i&&e.range.end.x>=t.x||n&&e.range.start.x<=t.x||i&&n)&&e.range.start.y<=t.y&&e.range.end.y>=t.y},t.prototype._positionFromMouseEvent=function(e,t,r){var i=r.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,r,i,n){return{x1:e,y1:t,x2:r,y2:i,cols:this._bufferService.cols,fg:n}},o([s(0,a.IBufferService)],t)}(l.Disposable);t.Linkifier2=u},9042:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel="Terminal input",t.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},6954:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseZoneManager=void 0;var a=r(844),c=r(3656),l=r(4725),h=r(2585),u=function(e){function t(t,r,i,n,o,s){var a=e.call(this)||this;return a._element=t,a._screenElement=r,a._bufferService=i,a._mouseService=n,a._selectionService=o,a._optionsService=s,a._zones=[],a._areZonesActive=!1,a._lastHoverCoords=[void 0,void 0],a._initialSelectionLength=0,a.register((0,c.addDisposableDomListener)(a._element,"mousedown",(function(e){return a._onMouseDown(e)}))),a._mouseMoveListener=function(e){return a._onMouseMove(e)},a._mouseLeaveListener=function(e){return a._onMouseLeave(e)},a._clickListener=function(e){return a._onClick(e)},a}return n(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 r=0;r<this._zones.length;r++){var i=this._zones[r];(i.y1>e&&i.y1<=t+1||i.y2>e&&i.y2<=t+1||i.y1<e&&i.y2>t+1)&&(this._currentZone&&this._currentZone===i&&(this._currentZone.leaveCallback(),this._currentZone=void 0),this._zones.splice(r--,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,r=this._findZoneEventAt(e);r!==this._currentZone&&(this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout)),r&&(this._currentZone=r,r.hoverCallback&&r.hoverCallback(e),this._tooltipTimeout=window.setTimeout((function(){return t._onTooltip(e)}),this._optionsService.rawOptions.linkTooltipHoverDuration)))},t.prototype._onTooltip=function(e){this._tooltipTimeout=void 0;var t=this._findZoneEventAt(e);null==t||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),r=this._getSelectionLength();t&&r===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 r=t[0],i=t[1],n=0;n<this._zones.length;n++){var o=this._zones[n];if(o.y1===o.y2){if(i===o.y1&&r>=o.x1&&r<o.x2)return o}else if(i===o.y1&&r>=o.x1||i===o.y2&&r<o.x2||i>o.y1&&i<o.y2)return o}},o([s(2,h.IBufferService),s(3,l.IMouseService),s(4,l.ISelectionService),s(5,h.IOptionsService)],t)}(a.Disposable);t.MouseZoneManager=u},6193:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RenderDebouncer=void 0;var r=function(){function e(e){this._renderCallback=e}return e.prototype.dispose=function(){this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.refresh=function(e,t,r){var i=this;this._rowCount=r,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,this._animationFrame||(this._animationFrame=window.requestAnimationFrame((function(){return i._innerRefresh()})))},e.prototype._innerRefresh=function(){if(void 0!==this._rowStart&&void 0!==this._rowEnd&&void 0!==this._rowCount){var e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._animationFrame=void 0,this._renderCallback(e,t)}},e}();t.RenderDebouncer=r},5596:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.ScreenDprMonitor=void 0;var o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._currentDevicePixelRatio=window.devicePixelRatio,t}return n(t,e),t.prototype.setListener=function(e){var t=this;this._listener&&this.clearListener(),this._listener=e,this._outerListener=function(){t._listener&&(t._listener(window.devicePixelRatio,t._currentDevicePixelRatio),t._updateDpr())},this._updateDpr()},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.clearListener()},t.prototype._updateDpr=function(){var e;this._outerListener&&(null===(e=this._resolutionMediaMatchList)||void 0===e||e.removeListener(this._outerListener),this._currentDevicePixelRatio=window.devicePixelRatio,this._resolutionMediaMatchList=window.matchMedia("screen and (resolution: "+window.devicePixelRatio+"dppx)"),this._resolutionMediaMatchList.addListener(this._outerListener))},t.prototype.clearListener=function(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)},t}(r(844).Disposable);t.ScreenDprMonitor=o},3236:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;var o=r(2950),s=r(1680),a=r(3614),c=r(2584),l=r(5435),h=r(3525),u=r(3551),f=r(9312),_=r(6114),d=r(3656),p=r(9042),v=r(357),g=r(6954),y=r(4567),m=r(1296),S=r(7399),C=r(8460),b=r(8437),w=r(5680),L=r(3230),E=r(4725),x=r(428),k=r(8934),M=r(6465),A=r(5114),R=r(8969),O=r(4774),T=r(4269),D=r(5941),B=r(7641),P="undefined"!=typeof window?window.document:null,I=function(e){function t(t){void 0===t&&(t={});var r=e.call(this,t)||this;return r.browser=_,r._keyDownHandled=!1,r._keyPressHandled=!1,r._unprocessedDeadKey=!1,r._onCursorMove=new C.EventEmitter,r._onKey=new C.EventEmitter,r._onRender=new C.EventEmitter,r._onSelectionChange=new C.EventEmitter,r._onTitleChange=new C.EventEmitter,r._onBell=new C.EventEmitter,r._onFocus=new C.EventEmitter,r._onBlur=new C.EventEmitter,r._onA11yCharEmitter=new C.EventEmitter,r._onA11yTabEmitter=new C.EventEmitter,r._setup(),r.linkifier=r._instantiationService.createInstance(u.Linkifier),r.linkifier2=r.register(r._instantiationService.createInstance(M.Linkifier2)),r.decorationService=r.register(r._instantiationService.createInstance(B.DecorationService)),r.register(r._inputHandler.onRequestBell((function(){return r.bell()}))),r.register(r._inputHandler.onRequestRefreshRows((function(e,t){return r.refresh(e,t)}))),r.register(r._inputHandler.onRequestSendFocus((function(){return r._reportFocus()}))),r.register(r._inputHandler.onRequestReset((function(){return r.reset()}))),r.register(r._inputHandler.onRequestWindowsOptionsReport((function(e){return r._reportWindowsOptions(e)}))),r.register(r._inputHandler.onColor((function(e){return r._handleColorEvent(e)}))),r.register((0,C.forwardEvent)(r._inputHandler.onCursorMove,r._onCursorMove)),r.register((0,C.forwardEvent)(r._inputHandler.onTitleChange,r._onTitleChange)),r.register((0,C.forwardEvent)(r._inputHandler.onA11yChar,r._onA11yCharEmitter)),r.register((0,C.forwardEvent)(r._inputHandler.onA11yTab,r._onA11yTabEmitter)),r.register(r._bufferService.onResize((function(e){return r._afterResize(e.cols,e.rows)}))),r}return n(t,e),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,"onBell",{get:function(){return this._onBell.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._handleColorEvent=function(e){var t,r;if(this._colorManager){for(var i=0,n=e;i<n.length;i++){var o=n[i],s=void 0,a="";switch(o.index){case 256:s="foreground",a="10";break;case 257:s="background",a="11";break;case 258:s="cursor",a="12";break;default:s="ansi",a="4;"+o.index}if(s)switch(o.type){case 0:var l=O.color.toColorRGB("ansi"===s?this._colorManager.colors.ansi[o.index]:this._colorManager.colors[s]);this.coreService.triggerDataEvent(c.C0.ESC+"]"+a+";"+(0,D.toRgbString)(l)+c.C0.BEL);break;case 1:"ansi"===s?this._colorManager.colors.ansi[o.index]=O.rgba.toColor.apply(O.rgba,o.color):this._colorManager.colors[s]=O.rgba.toColor.apply(O.rgba,o.color);break;case 2:this._colorManager.restoreColor(o.index)}}null===(t=this._renderService)||void 0===t||t.setColors(this._colorManager.colors),null===(r=this.viewport)||void 0===r||r.onThemeChange(this._colorManager.colors)}},t.prototype.dispose=function(){var t,r,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===(r=this.element)||void 0===r?void 0:r.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 r,i,n,o;switch(e.prototype._updateOptions.call(this,t),t){case"fontFamily":case"fontSize":null===(r=this._renderService)||void 0===r||r.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"customGlyphs":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===(n=this.viewport)||void 0===n||n.syncScrollArea();break;case"screenReaderMode":this.optionsService.rawOptions.screenReaderMode?!this._accessibilityManager&&this._renderService&&(this._accessibilityManager=new y.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.rawOptions.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&&this._renderService){var e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(t){var r=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.actualCellHeight,n=t.getWidth(r),o=this._renderService.dimensions.actualCellWidth*n,s=this.buffer.y*this._renderService.dimensions.actualCellHeight,a=r*this._renderService.dimensions.actualCellWidth;this.textarea.style.left=a+"px",this.textarea.style.top=s+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}}},t.prototype._initGlobal=function(){var e=this;this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(function(t){e.hasSelection()&&(0,a.copyHandler)(t,e._selectionService)})));var t=function(t){return(0,a.handlePasteEvent)(t,e.textarea,e.coreService)};this.register((0,d.addDisposableDomListener)(this.textarea,"paste",t)),this.register((0,d.addDisposableDomListener)(this.element,"paste",t)),_.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(function(t){2===t.button&&(0,a.rightClickHandler)(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(function(t){(0,a.rightClickHandler)(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)}))),_.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(function(t){1===t.button&&(0,a.moveTextAreaUnderMouseCursor)(t,e.textarea,e.screenElement)})))},t.prototype._bindKeys=function(){var e=this;this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(function(t){return e._keyUp(t)}),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(function(t){return e._keyDown(t)}),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(function(t){return e._keyPress(t)}),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(function(){return e._compositionHelper.compositionstart()}))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(function(t){return e._compositionHelper.compositionupdate(t)}))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(function(){return e._compositionHelper.compositionend()}))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(function(t){return e._inputEvent(t)}),!0)),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.");e.isConnected||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 r=P.createDocumentFragment();this._viewportElement=P.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this._viewportScrollArea=P.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=P.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=P.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement),this.textarea=P.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.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((0,d.addDisposableDomListener)(this.textarea,"focus",(function(e){return t._onTextAreaFocus(e)}))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(function(){return t._onTextAreaBlur()}))),this._helperContainer.appendChild(this.textarea);var i=this._instantiationService.createInstance(A.CoreBrowserService,this.textarea);this._instantiationService.setService(E.ICoreBrowserService,i),this._charSizeService=this._instantiationService.createInstance(x.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._theme=this.options.theme||this._theme,this._colorManager=new w.ColorManager(P,this.options.allowTransparency),this.register(this.optionsService.onOptionChange((function(e){return t._colorManager.onOptionsChange(e)}))),this._colorManager.setTheme(this._theme),this._characterJoinerService=this._instantiationService.createInstance(T.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService);var n=this._createRenderer();this._renderService=this.register(this._instantiationService.createInstance(L.RenderService,n,this.rows,this.screenElement)),this._instantiationService.setService(E.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._compositionView=P.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(r),this._soundService=this._instantiationService.createInstance(v.SoundService),this._instantiationService.setService(E.ISoundService,this._soundService),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(s.Viewport,(function(e){return t.scrollLines(e,!0,1)}),this._viewportElement,this._viewportScrollArea,this.element),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(f.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.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.event((function(e){t.viewport.syncScrollArea(),t._selectionService.refresh()}))),this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",(function(){return t._selectionService.refresh()}))),this._mouseZoneManager=this._instantiationService.createInstance(g.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.screenElement,this._mouseService,this._renderService),this.decorationService.attachToDom(this.screenElement,this._renderService,this._bufferService),this.register((0,d.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 y.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(h.Renderer,this._colorManager.colors,this.screenElement,this.linkifier,this.linkifier2);case"dom":return this._instantiationService.createInstance(m.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,r,i;this._theme=e,null===(t=this._colorManager)||void 0===t||t.setTheme(e),null===(r=this._renderService)||void 0===r||r.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,r=this.element;function i(e){var r,i,n=t._mouseService.getRawByteCoords(e,t.screenElement,t.cols,t.rows);if(!n)return!1;switch(e.overrideType||e.type){case"mousemove":i=32,void 0===e.buttons?(r=3,void 0!==e.button&&(r=e.button<3?e.button:3)):r=1&e.buttons?0:4&e.buttons?1:2&e.buttons?2:3;break;case"mouseup":i=0,r=e.button<3?e.button:3;break;case"mousedown":i=1,r=e.button<3?e.button:3;break;case"wheel":0!==e.deltaY&&(i=e.deltaY<0?0:1),r=4;break;default:return!1}return!(void 0===i||void 0===r||r>4)&&t.coreMouseService.triggerMouseEvent({col:n.x-33,row:n.y-33,button:r,action:i,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})}var n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o=function(t){return i(t),t.buttons||(e._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&e._document.removeEventListener("mousemove",n.mousedrag)),e.cancel(t)},s=function(t){return i(t),e.cancel(t,!0)},a=function(e){e.buttons&&i(e)},l=function(e){e.buttons||i(e)};this.register(this.coreMouseService.onProtocolChange((function(t){t?("debug"===e.optionsService.rawOptions.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?n.mousemove||(r.addEventListener("mousemove",l),n.mousemove=l):(r.removeEventListener("mousemove",n.mousemove),n.mousemove=null),16&t?n.wheel||(r.addEventListener("wheel",s,{passive:!1}),n.wheel=s):(r.removeEventListener("wheel",n.wheel),n.wheel=null),2&t?n.mouseup||(n.mouseup=o):(e._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),4&t?n.mousedrag||(n.mousedrag=a):(e._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(r,"mousedown",(function(t){if(t.preventDefault(),e.focus(),e.coreMouseService.areMouseEventsActive&&!e._selectionService.shouldForceSelection(t))return i(t),n.mouseup&&e._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&e._document.addEventListener("mousemove",n.mousedrag),e.cancel(t)}))),this.register((0,d.addDisposableDomListener)(r,"wheel",(function(t){if(!n.wheel){if(!e.buffer.hasScrollback){var r=e.viewport.getLinesScrolled(t);if(0===r)return;for(var i=c.C0.ESC+(e.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B"),o="",s=0;s<Math.abs(r);s++)o+=i;return e.coreService.triggerDataEvent(o,!0),e.cancel(t,!0)}return e.viewport.onWheel(t)?e.cancel(t):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(r,"touchstart",(function(t){if(!e.coreMouseService.areMouseEventsActive)return e.viewport.onTouchStart(t),e.cancel(t)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(r,"touchmove",(function(t){if(!e.coreMouseService.areMouseEventsActive)return e.viewport.onTouchMove(t)?void 0:e.cancel(t)}),{passive:!1}))},t.prototype.refresh=function(e,t){var r;null===(r=this._renderService)||void 0===r||r.refreshRows(e,t)},t.prototype._queueLinkification=function(e,t){var r;null===(r=this.linkifier)||void 0===r||r.linkifyRows(e,t)},t.prototype.updateCursorStyle=function(e){var t;(null===(t=this._selectionService)||void 0===t?void 0:t.shouldColumnSelect(e))?this.element.classList.add("column-select"):this.element.classList.remove("column-select")},t.prototype._showCursor=function(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))},t.prototype.scrollLines=function(t,r,i){void 0===i&&(i=0),e.prototype.scrollLines.call(this,t,r,i),this.refresh(0,this.rows-1)},t.prototype.paste=function(e){(0,a.paste)(e,this.textarea,this.coreService)},t.prototype.attachCustomKeyEventHandler=function(e){this._customKeyEventHandler=e},t.prototype.registerLinkMatcher=function(e,t,r){var i=this.linkifier.registerLinkMatcher(e,t,r);return this.refresh(0,this.rows-1),i},t.prototype.deregisterLinkMatcher=function(e){this.linkifier.deregisterLinkMatcher(e)&&this.refresh(0,this.rows-1)},t.prototype.registerLinkProvider=function(e){return this.linkifier2.registerLinkProvider(e)},t.prototype.registerCharacterJoiner=function(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");var t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t},t.prototype.deregisterCharacterJoiner=function(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)},Object.defineProperty(t.prototype,"markers",{get:function(){return this.buffer.markers},enumerable:!1,configurable:!0}),t.prototype.addMarker=function(e){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)},t.prototype.registerDecoration=function(e){return this.decorationService.registerDecoration(e)},t.prototype.hasSelection=function(){return!!this._selectionService&&this._selectionService.hasSelection},t.prototype.select=function(e,t,r){this._selectionService.setSelection(e,t,r)},t.prototype.getSelection=function(){return this._selectionService?this._selectionService.selectionText:""},t.prototype.getSelectionPosition=function(){if(this._selectionService&&this._selectionService.hasSelection)return{startColumn:this._selectionService.selectionStart[0],startRow:this._selectionService.selectionStart[1],endColumn:this._selectionService.selectionEnd[0],endRow:this._selectionService.selectionEnd[1]}},t.prototype.clearSelection=function(){var e;null===(e=this._selectionService)||void 0===e||e.clearSelection()},t.prototype.selectAll=function(){var e;null===(e=this._selectionService)||void 0===e||e.selectAll()},t.prototype.selectLines=function(e,t){var r;null===(r=this._selectionService)||void 0===r||r.selectLines(e,t)},t.prototype._keyDown=function(e){if(this._keyDownHandled=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(!this._compositionHelper.keydown(e))return this.buffer.ybase!==this.buffer.ydisp&&this._bufferService.scrollToBottom(),!1;"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);var t=(0,S.evaluateKeyboardEvent)(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===t.type||2===t.type){var r=this.rows-1;return this.scrollLines(2===t.type?-r:r),this.cancel(e,!0)}return 1===t.type&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(t.cancel&&this.cancel(e,!0),!t.key||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(t.key!==c.C0.ETX&&t.key!==c.C0.CR||(this.textarea.value=""),this._onKey.fire({key:t.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t.key,!0),this.optionsService.rawOptions.screenReaderMode?void(this._keyDownHandled=!0):this.cancel(e,!0))))},t.prototype._isThirdLevelShift=function(e,t){var r=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return"keypress"===t.type?r:r&&(!t.keyCode||t.keyCode>47)},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),this._keyPressHandled=!1)},t.prototype._keyPress=function(e){var t;if(this._keyPressHandled=!1,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||void 0===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),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))},t.prototype._inputEvent=function(e){if(e.data&&"insertText"===e.inputType&&!e.composed&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;var t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1},t.prototype.bell=function(){var e;this._soundBell()&&(null===(e=this._soundService)||void 0===e||e.playBellSound()),this._onBell.fire()},t.prototype.resize=function(t,r){t!==this.cols||r!==this.rows?e.prototype.resize.call(this,t,r):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()},t.prototype._afterResize=function(e,t){var r,i;null===(r=this._charSizeService)||void 0===r||r.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.clearMarkers(),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<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(b.DEFAULT_ATTR_DATA));this.refresh(0,this.rows-1),this._onScroll.fire({position:this.buffer.ydisp,source:0})}},t.prototype.reset=function(){var t,r;this.options.rows=this.rows,this.options.cols=this.cols;var i=this._customKeyEventHandler;this._setup(),e.prototype.reset.call(this),null===(t=this._selectionService)||void 0===t||t.reset(),this._customKeyEventHandler=i,this.refresh(0,this.rows-1),null===(r=this.viewport)||void 0===r||r.syncScrollArea()},t.prototype.clearTextureAtlas=function(){var e;null===(e=this._renderService)||void 0===e||e.clearTextureAtlas()},t.prototype._reportFocus=function(){var e;(null===(e=this.element)||void 0===e?void 0:e.classList.contains("focus"))?this.coreService.triggerDataEvent(c.C0.ESC+"[I"):this.coreService.triggerDataEvent(c.C0.ESC+"[O")},t.prototype._reportWindowsOptions=function(e){if(this._renderService)switch(e){case l.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:var t=this._renderService.dimensions.scaledCanvasWidth.toFixed(0),r=this._renderService.dimensions.scaledCanvasHeight.toFixed(0);this.coreService.triggerDataEvent(c.C0.ESC+"[4;"+r+";"+t+"t");break;case l.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:var i=this._renderService.dimensions.scaledCellWidth.toFixed(0),n=this._renderService.dimensions.scaledCellHeight.toFixed(0);this.coreService.triggerDataEvent(c.C0.ESC+"[6;"+n+";"+i+"t")}},t.prototype.cancel=function(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1},t.prototype._visualBell=function(){return!1},t.prototype._soundBell=function(){return"sound"===this.options.bellStyle},t}(R.CoreTerminal);t.Terminal=I},9924:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeBasedDebouncer=void 0;var r=function(){function e(e,t){void 0===t&&(t=1e3),this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}return e.prototype.dispose=function(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)},e.prototype.refresh=function(e,t,r){var i=this;this._rowCount=r,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t;var n=Date.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){var o=n-this._lastRefreshMs,s=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((function(){i._lastRefreshMs=Date.now(),i._innerRefresh(),i._additionalRefreshRequested=!1,i._refreshTimeoutID=void 0}),s)}},e.prototype._innerRefresh=function(){if(void 0!==this._rowStart&&void 0!==this._rowEnd&&void 0!==this._rowCount){var e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},e}();t.TimeBasedDebouncer=r},1680:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Viewport=void 0;var a=r(844),c=r(3656),l=r(4725),h=r(2585),u=function(e){function t(t,r,i,n,o,s,a,l){var h=e.call(this)||this;return h._scrollLines=t,h._viewportElement=r,h._scrollArea=i,h._element=n,h._bufferService=o,h._optionsService=s,h._charSizeService=a,h._renderService=l,h.scrollBarWidth=0,h._currentRowHeight=0,h._currentScaledCellHeight=0,h._lastRecordedBufferLength=0,h._lastRecordedViewportHeight=0,h._lastRecordedBufferHeight=0,h._lastTouchY=0,h._lastScrollTop=0,h._lastHadScrollBar=!1,h._wheelPartialScroll=0,h._refreshAnimationFrame=null,h._ignoreNextScrollEvent=!1,h.scrollBarWidth=h._viewportElement.offsetWidth-h._scrollArea.offsetWidth||15,h._lastHadScrollBar=!0,h.register((0,c.addDisposableDomListener)(h._viewportElement,"scroll",h._onScroll.bind(h))),h._activeBuffer=h._bufferService.buffer,h.register(h._bufferService.buffers.onBufferActivate((function(e){return h._activeBuffer=e.activeBuffer}))),h._renderDimensions=h._renderService.dimensions,h.register(h._renderService.onDimensionsChange((function(e){return h._renderDimensions=e}))),setTimeout((function(){return h.syncScrollArea()}),0),h}return n(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._currentScaledCellHeight=this._renderService.dimensions.scaledCellHeight,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),0===this._optionsService.rawOptions.scrollback?this.scrollBarWidth=0:this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this._lastHadScrollBar=this.scrollBarWidth>0;var r=window.getComputedStyle(this._element),i=parseInt(r.paddingLeft)+parseInt(r.paddingRight);this._viewportElement.style.width=(this._renderService.dimensions.actualCellWidth*this._bufferService.cols+this.scrollBarWidth+(this._lastHadScrollBar?i:0)).toString()+"px",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._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.scaledCellHeight===this._currentScaledCellHeight?this._lastHadScrollBar!==this._optionsService.rawOptions.scrollback>0&&this._refresh(e):this._refresh(e)},t.prototype._onScroll=function(e){if(this._lastScrollTop=this._viewportElement.scrollTop,this._viewportElement.offsetParent){if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._scrollLines(0);var t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._scrollLines(t)}},t.prototype._bubbleScroll=function(e,t){var r=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&0!==this._viewportElement.scrollTop||t>0&&r<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)},t.prototype.onWheel=function(e){var t=this._getPixelsScrolled(e);return 0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))},t.prototype._getPixelsScrolled=function(e){if(0===e.deltaY||e.shiftKey)return 0;var t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t},t.prototype.getLinesScrolled=function(e){if(0===e.deltaY||e.shiftKey)return 0;var t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t},t.prototype._applyScrollModifier=function(e,t){var r=this._optionsService.rawOptions.fastScrollModifier;return"alt"===r&&t.altKey||"ctrl"===r&&t.ctrlKey||"shift"===r&&t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.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([s(4,h.IBufferService),s(5,h.IOptionsService),s(6,l.ICharSizeService),s(7,l.IRenderService)],t)}(a.Disposable);t.Viewport=u},2950:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompositionHelper=void 0;var o=r(4725),s=r(2585),a=function(){function e(e,t,r,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}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._dataAlreadySent="",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 r={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((function(){if(t._isSendingComposition){t._isSendingComposition=!1;var e;r.start+=t._dataAlreadySent.length,(e=t._isComposing?t._textarea.value.substring(r.start,r.end):t._textarea.value.substring(r.start)).length>0&&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 r=e._textarea.value.replace(t,"");r.length>0&&(e._dataAlreadySent=r,e._coreService.triggerDataEvent(r,!0))}}),0)},e.prototype.updateCompositionElements=function(e){var t=this;if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){var r=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.actualCellHeight,n=this._bufferService.buffer.y*this._renderService.dimensions.actualCellHeight,o=r*this._renderService.dimensions.actualCellWidth;this._compositionView.style.left=o+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";var s=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(s.width,1)+"px",this._textarea.style.height=Math.max(s.height,1)+"px",this._textarea.style.lineHeight=s.height+"px"}e||setTimeout((function(){return t.updateCompositionElements(!0)}),0)}},i([n(2,s.IBufferService),n(3,s.IOptionsService),n(4,s.ICoreService),n(5,o.IRenderService)],e)}();t.CompositionHelper=a},9806:(e,t)=>{function r(e,t){var r=t.getBoundingClientRect();return[e.clientX-r.left,e.clientY-r.top]}Object.defineProperty(t,"__esModule",{value:!0}),t.getRawByteCoords=t.getCoords=t.getCoordsRelativeToElement=void 0,t.getCoordsRelativeToElement=r,t.getCoords=function(e,t,i,n,o,s,a,c){if(o){var l=r(e,t);if(l)return l[0]=Math.ceil((l[0]+(c?s/2:0))/s),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),n),l}},t.getRawByteCoords=function(e){if(e)return{x:e[0]+32,y:e[1]+32}}},9504:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.moveToCellSequence=void 0;var i=r(2584);function n(e,t,r,i){var n=e-o(r,e),a=t-o(r,t),h=Math.abs(n-a)-function(e,t,r){for(var i=0,n=e-o(r,e),a=t-o(r,t),c=0;c<Math.abs(n-a);c++){var l="A"===s(e,t)?-1:1,h=r.buffer.lines.get(n+l*c);(null==h?void 0:h.isWrapped)&&i++}return i}(e,t,r);return l(h,c(s(e,t),i))}function o(e,t){for(var r=0,i=e.buffer.lines.get(t),n=null==i?void 0:i.isWrapped;n&&t>=0&&t<e.rows;)r++,n=null==(i=e.buffer.lines.get(--t))?void 0:i.isWrapped;return r}function s(e,t){return e>t?"A":"B"}function a(e,t,r,i,n,o){for(var s=e,a=t,c="";s!==r||a!==i;)s+=n?1:-1,n&&s>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,s),s=0,e=0,a++):!n&&s<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),e=s=o.cols-1,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,s)}function c(e,t){var r=t?"O":"[";return i.C0.ESC+r+e}function l(e,t){e=Math.floor(e);for(var r="",i=0;i<e;i++)r+=t;return r}t.moveToCellSequence=function(e,t,r,i){var s,h=r.buffer.x,u=r.buffer.y;if(!r.buffer.hasScrollback)return function(e,t,r,i,s,h){return 0===n(t,i,s,h).length?"":l(a(e,t,e,t-o(s,t),!1,s).length,c("D",h))}(h,u,0,t,r,i)+n(u,t,r,i)+function(e,t,r,i,s,h){var u;u=n(t,i,s,h).length>0?i-o(s,i):t;var f=i,_=function(e,t,r,i,s,a){var c;return c=n(r,i,s,a).length>0?i-o(s,i):t,e<r&&c<=i||e>=r&&c<i?"C":"D"}(e,t,r,i,s,h);return l(a(e,u,r,f,"C"===_,s).length,c(_,h))}(h,u,e,t,r,i);if(u===t)return s=h>e?"D":"C",l(Math.abs(h-e),c(s,i));s=u>t?"D":"C";var f=Math.abs(u-t);return l(function(e,t){return t.cols-e}(u>t?e:h,r)+(f-1)*r.cols+1+((u>t?h:e)-1),c(s,i))}},4389:function(e,t,r){var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;var n=r(3236),o=r(9042),s=r(7975),a=r(7090),c=r(5741),l=r(8285),h=["cols","rows"],u=function(){function e(e){var t=this;this._core=new n.Terminal(e),this._addonManager=new c.AddonManager,this._publicOptions=i({},this._core.options);var r=function(e){return t._core.options[e]},o=function(e,r){t._checkReadonlyOptions(e),t._core.options[e]=r};for(var s in this._core.options){var a={get:r.bind(this,s),set:o.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}return e.prototype._checkReadonlyOptions=function(e){if(h.includes(e))throw new Error('Option "'+e+'" can only be set in the constructor')},e.prototype._checkProposedApi=function(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")},Object.defineProperty(e.prototype,"onBell",{get:function(){return this._core.onBell},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBinary",{get:function(){return this._core.onBinary},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCursorMove",{get:function(){return this._core.onCursorMove},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onData",{get:function(){return this._core.onData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onKey",{get:function(){return this._core.onKey},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLineFeed",{get:function(){return this._core.onLineFeed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRender",{get:function(){return this._core.onRender},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onResize",{get:function(){return this._core.onResize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScroll",{get:function(){return this._core.onScroll},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSelectionChange",{get:function(){return this._core.onSelectionChange},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTitleChange",{get:function(){return this._core.onTitleChange},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this._core.element},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parser",{get:function(){return this._checkProposedApi(),this._parser||(this._parser=new s.ParserApi(this._core)),this._parser},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unicode",{get:function(){return this._checkProposedApi(),new a.UnicodeApi(this._core)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textarea",{get:function(){return this._core.textarea},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._core.rows},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cols",{get:function(){return this._core.cols},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._checkProposedApi(),this._buffer||(this._buffer=new l.BufferNamespaceApi(this._core)),this._buffer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"markers",{get:function(){return this._checkProposedApi(),this._core.markers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"modes",{get:function(){var e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,wraparoundMode:e.wraparound}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._publicOptions},set:function(e){for(var t in e)this._publicOptions[t]=e[t]},enumerable:!1,configurable:!0}),e.prototype.blur=function(){this._core.blur()},e.prototype.focus=function(){this._core.focus()},e.prototype.resize=function(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)},e.prototype.open=function(e){this._core.open(e)},e.prototype.attachCustomKeyEventHandler=function(e){this._core.attachCustomKeyEventHandler(e)},e.prototype.registerLinkMatcher=function(e,t,r){return this._checkProposedApi(),this._core.registerLinkMatcher(e,t,r)},e.prototype.deregisterLinkMatcher=function(e){this._checkProposedApi(),this._core.deregisterLinkMatcher(e)},e.prototype.registerLinkProvider=function(e){return this._checkProposedApi(),this._core.registerLinkProvider(e)},e.prototype.registerCharacterJoiner=function(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)},e.prototype.deregisterCharacterJoiner=function(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)},e.prototype.registerMarker=function(e){return void 0===e&&(e=0),this._checkProposedApi(),this._verifyIntegers(e),this._core.addMarker(e)},e.prototype.registerDecoration=function(e){var t,r,i;return this._checkProposedApi(),this._verifyPositiveIntegers(null!==(t=e.x)&&void 0!==t?t:0,null!==(r=e.width)&&void 0!==r?r:0,null!==(i=e.height)&&void 0!==i?i:0),this._core.registerDecoration(e)},e.prototype.addMarker=function(e){return this.registerMarker(e)},e.prototype.hasSelection=function(){return this._core.hasSelection()},e.prototype.select=function(e,t,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)},e.prototype.getSelection=function(){return this._core.getSelection()},e.prototype.getSelectionPosition=function(){return this._core.getSelectionPosition()},e.prototype.clearSelection=function(){this._core.clearSelection()},e.prototype.selectAll=function(){this._core.selectAll()},e.prototype.selectLines=function(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)},e.prototype.dispose=function(){this._addonManager.dispose(),this._core.dispose()},e.prototype.scrollLines=function(e){this._verifyIntegers(e),this._core.scrollLines(e)},e.prototype.scrollPages=function(e){this._verifyIntegers(e),this._core.scrollPages(e)},e.prototype.scrollToTop=function(){this._core.scrollToTop()},e.prototype.scrollToBottom=function(){this._core.scrollToBottom()},e.prototype.scrollToLine=function(e){this._verifyIntegers(e),this._core.scrollToLine(e)},e.prototype.clear=function(){this._core.clear()},e.prototype.write=function(e,t){this._core.write(e,t)},e.prototype.writeUtf8=function(e,t){this._core.write(e,t)},e.prototype.writeln=function(e,t){this._core.write(e),this._core.write("\r\n",t)},e.prototype.paste=function(e){this._core.paste(e)},e.prototype.getOption=function(e){return this._core.optionsService.getOption(e)},e.prototype.setOption=function(e,t){this._checkReadonlyOptions(e),this._core.optionsService.setOption(e,t)},e.prototype.refresh=function(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)},e.prototype.reset=function(){this._core.reset()},e.prototype.clearTextureAtlas=function(){this._core.clearTextureAtlas()},e.prototype.loadAddon=function(e){return this._addonManager.loadAddon(this,e)},Object.defineProperty(e,"strings",{get:function(){return o},enumerable:!1,configurable:!0}),e.prototype._verifyIntegers=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=0,i=e;r<i.length;r++){var n=i[r];if(n===1/0||isNaN(n)||n%1!=0)throw new Error("This API only accepts integers")}},e.prototype._verifyPositiveIntegers=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=0,i=e;r<i.length;r++){var n=i[r];if(n&&(n===1/0||isNaN(n)||n%1!=0||n<0))throw new Error("This API only accepts positive integers")}},e}();t.Terminal=u},1546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseRenderLayer=void 0;var i=r(643),n=r(8803),o=r(1420),s=r(3734),a=r(1752),c=r(4774),l=r(9631),h=r(8978),u=function(){function e(e,t,r,i,n,o,s,a){this._container=e,this._alpha=i,this._colors=n,this._rendererId=o,this._bufferService=s,this._optionsService=a,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=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return e.prototype.dispose=function(){var e;(0,l.removeElementFromParent)(this._canvas),null===(e=this._charAtlas)||void 0===e||e.dispose()},e.prototype._initCanvas=function(){this._ctx=(0,a.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,r){void 0===r&&(r=!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=(0,o.acquireCharAtlas)(this._optionsService.rawOptions,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.clearTextureAtlas=function(){var e;null===(e=this._charAtlas)||void 0===e||e.clear()},e.prototype._fillCells=function(e,t,r,i){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight)},e.prototype._fillMiddleLineAtCells=function(e,t,r){void 0===r&&(r=1);var i=Math.ceil(.5*this._scaledCellHeight);this._ctx.fillRect(e*this._scaledCellWidth,(t+1)*this._scaledCellHeight-i-window.devicePixelRatio,r*this._scaledCellWidth,window.devicePixelRatio)},e.prototype._fillBottomLineAtCells=function(e,t,r){void 0===r&&(r=1),this._ctx.fillRect(e*this._scaledCellWidth,(t+1)*this._scaledCellHeight-window.devicePixelRatio-1,r*this._scaledCellWidth,window.devicePixelRatio)},e.prototype._fillLeftLineAtCell=function(e,t,r){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,window.devicePixelRatio*r,this._scaledCellHeight)},e.prototype._strokeRectAtCell=function(e,t,r,i){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(e*this._scaledCellWidth+window.devicePixelRatio/2,t*this._scaledCellHeight+window.devicePixelRatio/2,r*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,r,i){this._alpha?this._ctx.clearRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight))},e.prototype._fillCharTrueColor=function(e,t,r){this._ctx.font=this._getFont(!1,!1),this._ctx.textBaseline=n.TEXT_BASELINE,this._clipRow(r);var i=!1;!1!==this._optionsService.rawOptions.customGlyphs&&(i=(0,h.tryDrawCustomChar)(this._ctx,e.getChars(),t*this._scaledCellWidth,r*this._scaledCellHeight,this._scaledCellWidth,this._scaledCellHeight)),i||this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight)},e.prototype._drawChars=function(e,t,r){var o,s,a,c=this._getContrastColor(e);c||e.isFgRGB()||e.isBgRGB()?this._drawUncachedChars(e,t,r,c):(e.isInverse()?(s=e.isBgDefault()?n.INVERTED_DEFAULT_COLOR:e.getBgColor(),a=e.isFgDefault()?n.INVERTED_DEFAULT_COLOR:e.getFgColor()):(a=e.isBgDefault()?i.DEFAULT_COLOR:e.getBgColor(),s=e.isFgDefault()?i.DEFAULT_COLOR:e.getFgColor()),s+=this._optionsService.rawOptions.drawBoldTextInBrightColors&&e.isBold()&&s<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=s,this._currentGlyphIdentifier.bold=!!e.isBold(),this._currentGlyphIdentifier.dim=!!e.isDim(),this._currentGlyphIdentifier.italic=!!e.isItalic(),(null===(o=this._charAtlas)||void 0===o?void 0:o.draw(this._ctx,this._currentGlyphIdentifier,t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop))||this._drawUncachedChars(e,t,r))},e.prototype._drawUncachedChars=function(e,t,r,i){if(this._ctx.save(),this._ctx.font=this._getFont(!!e.isBold(),!!e.isItalic()),this._ctx.textBaseline=n.TEXT_BASELINE,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("+s.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var o=e.getBgColor();this._optionsService.rawOptions.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("+s.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var a=e.getFgColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&e.isBold()&&a<8&&(a+=8),this._ctx.fillStyle=this._colors.ansi[a].css}this._clipRow(r),e.isDim()&&(this._ctx.globalAlpha=n.DIM_OPACITY);var l=!1;!1!==this._optionsService.rawOptions.customGlyphs&&(l=(0,h.tryDrawCustomChar)(this._ctx,e.getChars(),t*this._scaledCellWidth,r*this._scaledCellHeight,this._scaledCellWidth,this._scaledCellHeight)),l||this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight),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.rawOptions.fontWeightBold:this._optionsService.rawOptions.fontWeight)+" "+this._optionsService.rawOptions.fontSize*window.devicePixelRatio+"px "+this._optionsService.rawOptions.fontFamily},e.prototype._getContrastColor=function(e){if(1!==this._optionsService.rawOptions.minimumContrastRatio){var t=this._colors.contrastCache.getColor(e.bg,e.fg);if(void 0!==t)return t||void 0;var r=e.getFgColor(),i=e.getFgColorMode(),n=e.getBgColor(),o=e.getBgColorMode(),s=!!e.isInverse(),a=!!e.isInverse();if(s){var l=r;r=n,n=l;var h=i;i=o,o=h}var u=this._resolveBackgroundRgba(o,n,s),f=this._resolveForegroundRgba(i,r,s,a),_=c.rgba.ensureContrastRatio(u,f,this._optionsService.rawOptions.minimumContrastRatio);if(_){var d={css:c.channels.toCss(_>>24&255,_>>16&255,_>>8&255),rgba:_};return this._colors.contrastCache.setColor(e.bg,e.fg,d),d}this._colors.contrastCache.setColor(e.bg,e.fg,null)}},e.prototype._resolveBackgroundRgba=function(e,t,r){switch(e){case 16777216:case 33554432:return this._colors.ansi[t].rgba;case 50331648:return t<<8;default:return r?this._colors.foreground.rgba:this._colors.background.rgba}},e.prototype._resolveForegroundRgba=function(e,t,r,i){switch(e){case 16777216:case 33554432:return this._optionsService.rawOptions.drawBoldTextInBrightColors&&i&&t<8&&(t+=8),this._colors.ansi[t].rgba;case 50331648:return t<<8;default:return r?this._colors.background.rgba:this._colors.foreground.rgba}},e}();t.BaseRenderLayer=u},2512:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CursorRenderLayer=void 0;var a=r(1546),c=r(511),l=r(2585),h=r(4725),u=600,f=function(e){function t(t,r,i,n,o,s,a,l,h){var u=e.call(this,t,"cursor",r,!0,i,n,s,a)||this;return u._onRequestRedraw=o,u._coreService=l,u._coreBrowserService=h,u._cell=new c.CellData,u._state={x:0,y:0,isFocused:!1,style:"",width:0},u._cursorRenderers={bar:u._renderBarCursor.bind(u),block:u._renderBlockCursor.bind(u),underline:u._renderUnderlineCursor.bind(u)},u}return n(t,e),t.prototype.dispose=function(){this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=void 0),e.prototype.dispose.call(this)},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(){var e;this._clearCursor(),null===(e=this._cursorBlinkStateManager)||void 0===e||e.restartBlinkAnimation(),this.onOptionsChanged()},t.prototype.onBlur=function(){var e;null===(e=this._cursorBlinkStateManager)||void 0===e||e.pause(),this._onRequestRedraw.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onFocus=function(){var e;null===(e=this._cursorBlinkStateManager)||void 0===e||e.resume(),this._onRequestRedraw.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onOptionsChanged=function(){var e,t=this;this._optionsService.rawOptions.cursorBlink?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new _(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(){var e;null===(e=this._cursorBlinkStateManager)||void 0===e||e.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,r=t-this._bufferService.buffer.ydisp;if(r<0||r>=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 n=this._optionsService.rawOptions.cursorStyle;return n&&"block"!==n?this._cursorRenderers[n](i,r,this._cell):this._renderBlurCursor(i,r,this._cell),this._ctx.restore(),this._state.x=i,this._state.y=r,this._state.isFocused=!1,this._state.style=n,void(this._state.width=this._cell.getWidth())}if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===i&&this._state.y===r&&this._state.isFocused===this._coreBrowserService.isFocused&&this._state.style===this._optionsService.rawOptions.cursorStyle&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[this._optionsService.rawOptions.cursorStyle||"block"](i,r,this._cell),this._ctx.restore(),this._state.x=i,this._state.y=r,this._state.isFocused=!1,this._state.style=this._optionsService.rawOptions.cursorStyle,this._state.width=this._cell.getWidth()}else this._clearCursor()}}}else this._clearCursor()},t.prototype._clearCursor=function(){this._state&&(window.devicePixelRatio<1?this._clearAll():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,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,t,this._optionsService.rawOptions.cursorWidth),this._ctx.restore()},t.prototype._renderBlockCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,t,r.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(r,e,t),this._ctx.restore()},t.prototype._renderUnderlineCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,t),this._ctx.restore()},t.prototype._renderBlurCursor=function(e,t,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,t,r.getWidth(),1),this._ctx.restore()},o([s(5,l.IBufferService),s(6,l.IOptionsService),s(7,l.ICoreService),s(8,h.ICoreBrowserService)],t)}(a.BaseRenderLayer);t.CursorRenderLayer=f;var _=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=u),this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=window.setTimeout((function(){if(t._animationTimeRestarted){var e=u-(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=u-(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}))}),u)}),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}()},8978:(e,t,r)=>{var i,n,o,s,a,c,l,h,u,f,_,d,p,v,g,y,m,S,C,b,w,L,E,x,k,M,A,R,O,T,D,B,P,I,H,F,j,W,U,q,N,z,K,G,V,X,Y,Z,J,$,Q,ee,te,re,ie,ne,oe,se,ae,ce,le,he,ue,fe,_e,de,pe,ve,ge,ye,me,Se,Ce,be,we,Le,Ee,xe,ke,Me,Ae,Re,Oe,Te,De,Be,Pe,Ie,He,Fe,je,We,Ue,qe,Ne,ze,Ke,Ge,Ve,Xe,Ye,Ze,Je,$e,Qe,et,tt,rt,it,nt,ot,st,at,ct,lt,ht,ut,ft,_t,dt,pt,vt,gt,yt,mt,St,Ct,bt;Object.defineProperty(t,"__esModule",{value:!0}),t.tryDrawCustomChar=t.boxDrawingDefinitions=t.blockElementDefinitions=void 0;var wt=r(1752);t.blockElementDefinitions={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:9,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:0,y:0,w:4,h:8}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]};var Lt={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]};t.boxDrawingDefinitions={"─":(i={},i[1]="M0,.5 L1,.5",i),"━":(n={},n[3]="M0,.5 L1,.5",n),"│":(o={},o[1]="M.5,0 L.5,1",o),"┃":(s={},s[3]="M.5,0 L.5,1",s),"┌":(a={},a[1]="M0.5,1 L.5,.5 L1,.5",a),"┏":(c={},c[3]="M0.5,1 L.5,.5 L1,.5",c),"┐":(l={},l[1]="M0,.5 L.5,.5 L.5,1",l),"┓":(h={},h[3]="M0,.5 L.5,.5 L.5,1",h),"└":(u={},u[1]="M.5,0 L.5,.5 L1,.5",u),"┗":(f={},f[3]="M.5,0 L.5,.5 L1,.5",f),"┘":(_={},_[1]="M.5,0 L.5,.5 L0,.5",_),"┛":(d={},d[3]="M.5,0 L.5,.5 L0,.5",d),"├":(p={},p[1]="M.5,0 L.5,1 M.5,.5 L1,.5",p),"┣":(v={},v[3]="M.5,0 L.5,1 M.5,.5 L1,.5",v),"┤":(g={},g[1]="M.5,0 L.5,1 M.5,.5 L0,.5",g),"┫":(y={},y[3]="M.5,0 L.5,1 M.5,.5 L0,.5",y),"┬":(m={},m[1]="M0,.5 L1,.5 M.5,.5 L.5,1",m),"┳":(S={},S[3]="M0,.5 L1,.5 M.5,.5 L.5,1",S),"┴":(C={},C[1]="M0,.5 L1,.5 M.5,.5 L.5,0",C),"┻":(b={},b[3]="M0,.5 L1,.5 M.5,.5 L.5,0",b),"┼":(w={},w[1]="M0,.5 L1,.5 M.5,0 L.5,1",w),"╋":(L={},L[3]="M0,.5 L1,.5 M.5,0 L.5,1",L),"╴":(E={},E[1]="M.5,.5 L0,.5",E),"╸":(x={},x[3]="M.5,.5 L0,.5",x),"╵":(k={},k[1]="M.5,.5 L.5,0",k),"╹":(M={},M[3]="M.5,.5 L.5,0",M),"╶":(A={},A[1]="M.5,.5 L1,.5",A),"╺":(R={},R[3]="M.5,.5 L1,.5",R),"╷":(O={},O[1]="M.5,.5 L.5,1",O),"╻":(T={},T[3]="M.5,.5 L.5,1",T),"═":(D={},D[1]=function(e,t){return"M0,"+(.5-t)+" L1,"+(.5-t)+" M0,"+(.5+t)+" L1,"+(.5+t)},D),"║":(B={},B[1]=function(e,t){return"M"+(.5-e)+",0 L"+(.5-e)+",1 M"+(.5+e)+",0 L"+(.5+e)+",1"},B),"╒":(P={},P[1]=function(e,t){return"M.5,1 L.5,"+(.5-t)+" L1,"+(.5-t)+" M.5,"+(.5+t)+" L1,"+(.5+t)},P),"╓":(I={},I[1]=function(e,t){return"M"+(.5-e)+",1 L"+(.5-e)+",.5 L1,.5 M"+(.5+e)+",.5 L"+(.5+e)+",1"},I),"╔":(H={},H[1]=function(e,t){return"M1,"+(.5-t)+" L"+(.5-e)+","+(.5-t)+" L"+(.5-e)+",1 M1,"+(.5+t)+" L"+(.5+e)+","+(.5+t)+" L"+(.5+e)+",1"},H),"╕":(F={},F[1]=function(e,t){return"M0,"+(.5-t)+" L.5,"+(.5-t)+" L.5,1 M0,"+(.5+t)+" L.5,"+(.5+t)},F),"╖":(j={},j[1]=function(e,t){return"M"+(.5+e)+",1 L"+(.5+e)+",.5 L0,.5 M"+(.5-e)+",.5 L"+(.5-e)+",1"},j),"╗":(W={},W[1]=function(e,t){return"M0,"+(.5+t)+" L"+(.5-e)+","+(.5+t)+" L"+(.5-e)+",1 M0,"+(.5-t)+" L"+(.5+e)+","+(.5-t)+" L"+(.5+e)+",1"},W),"╘":(U={},U[1]=function(e,t){return"M.5,0 L.5,"+(.5+t)+" L1,"+(.5+t)+" M.5,"+(.5-t)+" L1,"+(.5-t)},U),"╙":(q={},q[1]=function(e,t){return"M1,.5 L"+(.5-e)+",.5 L"+(.5-e)+",0 M"+(.5+e)+",.5 L"+(.5+e)+",0"},q),"╚":(N={},N[1]=function(e,t){return"M1,"+(.5-t)+" L"+(.5+e)+","+(.5-t)+" L"+(.5+e)+",0 M1,"+(.5+t)+" L"+(.5-e)+","+(.5+t)+" L"+(.5-e)+",0"},N),"╛":(z={},z[1]=function(e,t){return"M0,"+(.5+t)+" L.5,"+(.5+t)+" L.5,0 M0,"+(.5-t)+" L.5,"+(.5-t)},z),"╜":(K={},K[1]=function(e,t){return"M0,.5 L"+(.5+e)+",.5 L"+(.5+e)+",0 M"+(.5-e)+",.5 L"+(.5-e)+",0"},K),"╝":(G={},G[1]=function(e,t){return"M0,"+(.5-t)+" L"+(.5-e)+","+(.5-t)+" L"+(.5-e)+",0 M0,"+(.5+t)+" L"+(.5+e)+","+(.5+t)+" L"+(.5+e)+",0"},G),"╞":(V={},V[1]=function(e,t){return"M.5,0 L.5,1 M.5,"+(.5-t)+" L1,"+(.5-t)+" M.5,"+(.5+t)+" L1,"+(.5+t)},V),"╟":(X={},X[1]=function(e,t){return"M"+(.5-e)+",0 L"+(.5-e)+",1 M"+(.5+e)+",0 L"+(.5+e)+",1 M"+(.5+e)+",.5 L1,.5"},X),"╠":(Y={},Y[1]=function(e,t){return"M"+(.5-e)+",0 L"+(.5-e)+",1 M1,"+(.5+t)+" L"+(.5+e)+","+(.5+t)+" L"+(.5+e)+",1 M1,"+(.5-t)+" L"+(.5+e)+","+(.5-t)+" L"+(.5+e)+",0"},Y),"╡":(Z={},Z[1]=function(e,t){return"M.5,0 L.5,1 M0,"+(.5-t)+" L.5,"+(.5-t)+" M0,"+(.5+t)+" L.5,"+(.5+t)},Z),"╢":(J={},J[1]=function(e,t){return"M0,.5 L"+(.5-e)+",.5 M"+(.5-e)+",0 L"+(.5-e)+",1 M"+(.5+e)+",0 L"+(.5+e)+",1"},J),"╣":($={},$[1]=function(e,t){return"M"+(.5+e)+",0 L"+(.5+e)+",1 M0,"+(.5+t)+" L"+(.5-e)+","+(.5+t)+" L"+(.5-e)+",1 M0,"+(.5-t)+" L"+(.5-e)+","+(.5-t)+" L"+(.5-e)+",0"},$),"╤":(Q={},Q[1]=function(e,t){return"M0,"+(.5-t)+" L1,"+(.5-t)+" M0,"+(.5+t)+" L1,"+(.5+t)+" M.5,"+(.5+t)+" L.5,1"},Q),"╥":(ee={},ee[1]=function(e,t){return"M0,.5 L1,.5 M"+(.5-e)+",.5 L"+(.5-e)+",1 M"+(.5+e)+",.5 L"+(.5+e)+",1"},ee),"╦":(te={},te[1]=function(e,t){return"M0,"+(.5-t)+" L1,"+(.5-t)+" M0,"+(.5+t)+" L"+(.5-e)+","+(.5+t)+" L"+(.5-e)+",1 M1,"+(.5+t)+" L"+(.5+e)+","+(.5+t)+" L"+(.5+e)+",1"},te),"╧":(re={},re[1]=function(e,t){return"M.5,0 L.5,"+(.5-t)+" M0,"+(.5-t)+" L1,"+(.5-t)+" M0,"+(.5+t)+" L1,"+(.5+t)},re),"╨":(ie={},ie[1]=function(e,t){return"M0,.5 L1,.5 M"+(.5-e)+",.5 L"+(.5-e)+",0 M"+(.5+e)+",.5 L"+(.5+e)+",0"},ie),"╩":(ne={},ne[1]=function(e,t){return"M0,"+(.5+t)+" L1,"+(.5+t)+" M0,"+(.5-t)+" L"+(.5-e)+","+(.5-t)+" L"+(.5-e)+",0 M1,"+(.5-t)+" L"+(.5+e)+","+(.5-t)+" L"+(.5+e)+",0"},ne),"╪":(oe={},oe[1]=function(e,t){return"M.5,0 L.5,1 M0,"+(.5-t)+" L1,"+(.5-t)+" M0,"+(.5+t)+" L1,"+(.5+t)},oe),"╫":(se={},se[1]=function(e,t){return"M0,.5 L1,.5 M"+(.5-e)+",0 L"+(.5-e)+",1 M"+(.5+e)+",0 L"+(.5+e)+",1"},se),"╬":(ae={},ae[1]=function(e,t){return"M0,"+(.5+t)+" L"+(.5-e)+","+(.5+t)+" L"+(.5-e)+",1 M1,"+(.5+t)+" L"+(.5+e)+","+(.5+t)+" L"+(.5+e)+",1 M0,"+(.5-t)+" L"+(.5-e)+","+(.5-t)+" L"+(.5-e)+",0 M1,"+(.5-t)+" L"+(.5+e)+","+(.5-t)+" L"+(.5+e)+",0"},ae),"╱":(ce={},ce[1]="M1,0 L0,1",ce),"╲":(le={},le[1]="M0,0 L1,1",le),"╳":(he={},he[1]="M1,0 L0,1 M0,0 L1,1",he),"╼":(ue={},ue[1]="M.5,.5 L0,.5",ue[3]="M.5,.5 L1,.5",ue),"╽":(fe={},fe[1]="M.5,.5 L.5,0",fe[3]="M.5,.5 L.5,1",fe),"╾":(_e={},_e[1]="M.5,.5 L1,.5",_e[3]="M.5,.5 L0,.5",_e),"╿":(de={},de[1]="M.5,.5 L.5,1",de[3]="M.5,.5 L.5,0",de),"┍":(pe={},pe[1]="M.5,.5 L.5,1",pe[3]="M.5,.5 L1,.5",pe),"┎":(ve={},ve[1]="M.5,.5 L1,.5",ve[3]="M.5,.5 L.5,1",ve),"┑":(ge={},ge[1]="M.5,.5 L.5,1",ge[3]="M.5,.5 L0,.5",ge),"┒":(ye={},ye[1]="M.5,.5 L0,.5",ye[3]="M.5,.5 L.5,1",ye),"┕":(me={},me[1]="M.5,.5 L.5,0",me[3]="M.5,.5 L1,.5",me),"┖":(Se={},Se[1]="M.5,.5 L1,.5",Se[3]="M.5,.5 L.5,0",Se),"┙":(Ce={},Ce[1]="M.5,.5 L.5,0",Ce[3]="M.5,.5 L0,.5",Ce),"┚":(be={},be[1]="M.5,.5 L0,.5",be[3]="M.5,.5 L.5,0",be),"┝":(we={},we[1]="M.5,0 L.5,1",we[3]="M.5,.5 L1,.5",we),"┞":(Le={},Le[1]="M0.5,1 L.5,.5 L1,.5",Le[3]="M.5,.5 L.5,0",Le),"┟":(Ee={},Ee[1]="M.5,0 L.5,.5 L1,.5",Ee[3]="M.5,.5 L.5,1",Ee),"┠":(xe={},xe[1]="M.5,.5 L1,.5",xe[3]="M.5,0 L.5,1",xe),"┡":(ke={},ke[1]="M.5,.5 L.5,1",ke[3]="M.5,0 L.5,.5 L1,.5",ke),"┢":(Me={},Me[1]="M.5,.5 L.5,0",Me[3]="M0.5,1 L.5,.5 L1,.5",Me),"┥":(Ae={},Ae[1]="M.5,0 L.5,1",Ae[3]="M.5,.5 L0,.5",Ae),"┦":(Re={},Re[1]="M0,.5 L.5,.5 L.5,1",Re[3]="M.5,.5 L.5,0",Re),"┧":(Oe={},Oe[1]="M.5,0 L.5,.5 L0,.5",Oe[3]="M.5,.5 L.5,1",Oe),"┨":(Te={},Te[1]="M.5,.5 L0,.5",Te[3]="M.5,0 L.5,1",Te),"┩":(De={},De[1]="M.5,.5 L.5,1",De[3]="M.5,0 L.5,.5 L0,.5",De),"┪":(Be={},Be[1]="M.5,.5 L.5,0",Be[3]="M0,.5 L.5,.5 L.5,1",Be),"┭":(Pe={},Pe[1]="M0.5,1 L.5,.5 L1,.5",Pe[3]="M.5,.5 L0,.5",Pe),"┮":(Ie={},Ie[1]="M0,.5 L.5,.5 L.5,1",Ie[3]="M.5,.5 L1,.5",Ie),"┯":(He={},He[1]="M.5,.5 L.5,1",He[3]="M0,.5 L1,.5",He),"┰":(Fe={},Fe[1]="M0,.5 L1,.5",Fe[3]="M.5,.5 L.5,1",Fe),"┱":(je={},je[1]="M.5,.5 L1,.5",je[3]="M0,.5 L.5,.5 L.5,1",je),"┲":(We={},We[1]="M.5,.5 L0,.5",We[3]="M0.5,1 L.5,.5 L1,.5",We),"┵":(Ue={},Ue[1]="M.5,0 L.5,.5 L1,.5",Ue[3]="M.5,.5 L0,.5",Ue),"┶":(qe={},qe[1]="M.5,0 L.5,.5 L0,.5",qe[3]="M.5,.5 L1,.5",qe),"┷":(Ne={},Ne[1]="M.5,.5 L.5,0",Ne[3]="M0,.5 L1,.5",Ne),"┸":(ze={},ze[1]="M0,.5 L1,.5",ze[3]="M.5,.5 L.5,0",ze),"┹":(Ke={},Ke[1]="M.5,.5 L1,.5",Ke[3]="M.5,0 L.5,.5 L0,.5",Ke),"┺":(Ge={},Ge[1]="M.5,.5 L0,.5",Ge[3]="M.5,0 L.5,.5 L1,.5",Ge),"┽":(Ve={},Ve[1]="M.5,0 L.5,1 M.5,.5 L1,.5",Ve[3]="M.5,.5 L0,.5",Ve),"┾":(Xe={},Xe[1]="M.5,0 L.5,1 M.5,.5 L0,.5",Xe[3]="M.5,.5 L1,.5",Xe),"┿":(Ye={},Ye[1]="M.5,0 L.5,1",Ye[3]="M0,.5 L1,.5",Ye),"╀":(Ze={},Ze[1]="M0,.5 L1,.5 M.5,.5 L.5,1",Ze[3]="M.5,.5 L.5,0",Ze),"╁":(Je={},Je[1]="M.5,.5 L.5,0 M0,.5 L1,.5",Je[3]="M.5,.5 L.5,1",Je),"╂":($e={},$e[1]="M0,.5 L1,.5",$e[3]="M.5,0 L.5,1",$e),"╃":(Qe={},Qe[1]="M0.5,1 L.5,.5 L1,.5",Qe[3]="M.5,0 L.5,.5 L0,.5",Qe),"╄":(et={},et[1]="M0,.5 L.5,.5 L.5,1",et[3]="M.5,0 L.5,.5 L1,.5",et),"╅":(tt={},tt[1]="M.5,0 L.5,.5 L1,.5",tt[3]="M0,.5 L.5,.5 L.5,1",tt),"╆":(rt={},rt[1]="M.5,0 L.5,.5 L0,.5",rt[3]="M0.5,1 L.5,.5 L1,.5",rt),"╇":(it={},it[1]="M.5,.5 L.5,1",it[3]="M.5,.5 L.5,0 M0,.5 L1,.5",it),"╈":(nt={},nt[1]="M.5,.5 L.5,0",nt[3]="M0,.5 L1,.5 M.5,.5 L.5,1",nt),"╉":(ot={},ot[1]="M.5,.5 L1,.5",ot[3]="M.5,0 L.5,1 M.5,.5 L0,.5",ot),"╊":(st={},st[1]="M.5,.5 L0,.5",st[3]="M.5,0 L.5,1 M.5,.5 L1,.5",st),"╌":(at={},at[1]="M.1,.5 L.4,.5 M.6,.5 L.9,.5",at),"╍":(ct={},ct[3]="M.1,.5 L.4,.5 M.6,.5 L.9,.5",ct),"┄":(lt={},lt[1]="M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",lt),"┅":(ht={},ht[3]="M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",ht),"┈":(ut={},ut[1]="M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",ut),"┉":(ft={},ft[3]="M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",ft),"╎":(_t={},_t[1]="M.5,.1 L.5,.4 M.5,.6 L.5,.9",_t),"╏":(dt={},dt[3]="M.5,.1 L.5,.4 M.5,.6 L.5,.9",dt),"┆":(pt={},pt[1]="M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",pt),"┇":(vt={},vt[3]="M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",vt),"┊":(gt={},gt[1]="M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",gt),"┋":(yt={},yt[3]="M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",yt),"╭":(mt={},mt[1]="C.5,1,.5,.5,1,.5",mt),"╮":(St={},St[1]="C.5,1,.5,.5,0,.5",St),"╯":(Ct={},Ct[1]="C.5,0,.5,.5,0,.5",Ct),"╰":(bt={},bt[1]="C.5,0,.5,.5,1,.5",bt)},t.tryDrawCustomChar=function(e,r,i,n,o,s){var a=t.blockElementDefinitions[r];if(a)return function(e,t,r,i,n,o){for(var s=0;s<t.length;s++){var a=t[s],c=n/8,l=o/8;e.fillRect(r+a.x*c,i+a.y*l,a.w*c,a.h*l)}}(e,a,i,n,o,s),!0;var c=Lt[r];if(c)return function(e,t,r,i,n,o){var s,a=Et.get(t);a||(a=new Map,Et.set(t,a));var c=e.fillStyle;if("string"!=typeof c)throw new Error('Unexpected fillStyle type "'+c+'"');var l=a.get(c);if(!l){var h=t[0].length,u=t.length,f=document.createElement("canvas");f.width=h,f.height=u;var _=(0,wt.throwIfFalsy)(f.getContext("2d")),d=new ImageData(h,u),p=void 0,v=void 0,g=void 0,y=void 0;if(c.startsWith("#"))p=parseInt(c.substr(1,2),16),v=parseInt(c.substr(3,2),16),g=parseInt(c.substr(5,2),16),y=c.length>7&&parseInt(c.substr(7,2),16)||1;else{if(!c.startsWith("rgba"))throw new Error('Unexpected fillStyle color format "'+c+'" when drawing pattern glyph');p=(s=c.substring(5,c.length-1).split(",").map((function(e){return parseFloat(e)})))[0],v=s[1],g=s[2],y=s[3]}for(var m=0;m<u;m++)for(var S=0;S<h;S++)d.data[4*(m*h+S)]=p,d.data[4*(m*h+S)+1]=v,d.data[4*(m*h+S)+2]=g,d.data[4*(m*h+S)+3]=t[m][S]*(255*y);_.putImageData(d,0,0),l=(0,wt.throwIfFalsy)(e.createPattern(f,null)),a.set(c,l)}e.fillStyle=l,e.fillRect(r,i,n,o)}(e,c,i,n,o,s),!0;var l=t.boxDrawingDefinitions[r];return!!l&&(function(e,t,r,i,n,o){e.strokeStyle=e.fillStyle;for(var s=0,a=Object.entries(t);s<a.length;s++){var c=a[s],l=c[0],h=c[1];e.beginPath(),e.lineWidth=window.devicePixelRatio*Number.parseInt(l);for(var u=0,f=("function"==typeof h?h(.15,.15/o*n):h).split(" ");u<f.length;u++){var _=f[u],d=_[0],p=kt[d];if(p){var v=_.substring(1).split(",");v[0]&&v[1]&&p(e,Mt(v,n,o,r,i))}else console.error('Could not find drawing instructions for "'+d+'"')}e.stroke(),e.closePath()}}(e,l,i,n,o,s),!0)};var Et=new Map;function xt(e,t,r){return void 0===r&&(r=0),Math.max(Math.min(e,t),r)}var kt={C:function(e,t){return e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])},L:function(e,t){return e.lineTo(t[0],t[1])},M:function(e,t){return e.moveTo(t[0],t[1])}};function Mt(e,t,r,i,n){var o=e.map((function(e){return parseFloat(e)||parseInt(e)}));if(o.length<2)throw new Error("Too few arguments for instruction");for(var s=0;s<o.length;s+=2)o[s]*=t,0!==o[s]&&(o[s]=xt(Math.round(o[s]+.5)-.5,t,0)),o[s]+=i;for(var a=1;a<o.length;a+=2)o[a]*=r,0!==o[a]&&(o[a]=xt(Math.round(o[a]+.5)-.5,r,0)),o[a]+=n;return o}},3700:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GridCache=void 0;var r=function(){function e(){this.cache=[]}return e.prototype.resize=function(e,t){for(var r=0;r<e;r++){this.cache.length<=r&&this.cache.push([]);for(var i=this.cache[r].length;i<t;i++)this.cache[r].push(void 0);this.cache[r].length=t}this.cache.length=e},e.prototype.clear=function(){for(var e=0;e<this.cache.length;e++)for(var t=0;t<this.cache[e].length;t++)this.cache[e][t]=void 0},e}();t.GridCache=r},5098:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.LinkRenderLayer=void 0;var a=r(1546),c=r(8803),l=r(2040),h=r(2585),u=function(e){function t(t,r,i,n,o,s,a,c){var l=e.call(this,t,"link",r,!0,i,n,a,c)||this;return o.onShowLinkUnderline((function(e){return l._onShowLinkUnderline(e)})),o.onHideLinkUnderline((function(e){return l._onHideLinkUnderline(e)})),s.onShowLinkUnderline((function(e){return l._onShowLinkUnderline(e)})),s.onHideLinkUnderline((function(e){return l._onHideLinkUnderline(e)})),l}return n(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(e.fg===c.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._colors.background.css:e.fg&&(0,l.is256Color)(e.fg)?this._ctx.fillStyle=this._colors.ansi[e.fg].css:this._ctx.fillStyle=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<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e},t.prototype._onHideLinkUnderline=function(e){this._clearCurrentLink()},o([s(6,h.IBufferService),s(7,h.IOptionsService)],t)}(a.BaseRenderLayer);t.LinkRenderLayer=u},3525:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer=void 0;var a=r(9596),c=r(4149),l=r(2512),h=r(5098),u=r(844),f=r(4725),_=r(2585),d=r(1420),p=r(8460),v=1,g=function(e){function t(t,r,i,n,o,s,u,f){var _=e.call(this)||this;_._colors=t,_._screenElement=r,_._bufferService=s,_._charSizeService=u,_._optionsService=f,_._id=v++,_._onRequestRedraw=new p.EventEmitter;var d=_._optionsService.rawOptions.allowTransparency;return _._renderLayers=[o.createInstance(a.TextRenderLayer,_._screenElement,0,_._colors,d,_._id),o.createInstance(c.SelectionRenderLayer,_._screenElement,1,_._colors,_._id),o.createInstance(h.LinkRenderLayer,_._screenElement,2,_._colors,_._id,i,n),o.createInstance(l.CursorRenderLayer,_._screenElement,3,_._colors,_._id,_._onRequestRedraw)],_.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},_._devicePixelRatio=window.devicePixelRatio,_._updateDimensions(),_.onOptionsChanged(),_}return n(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,r=this._renderLayers;t<r.length;t++)r[t].dispose();e.prototype.dispose.call(this),(0,d.removeTerminalFromCache)(this._id)},t.prototype.onDevicePixelRatioChange=function(){this._devicePixelRatio!==window.devicePixelRatio&&(this._devicePixelRatio=window.devicePixelRatio,this.onResize(this._bufferService.cols,this._bufferService.rows))},t.prototype.setColors=function(e){this._colors=e;for(var t=0,r=this._renderLayers;t<r.length;t++){var i=r[t];i.setColors(this._colors),i.reset()}},t.prototype.onResize=function(e,t){this._updateDimensions();for(var r=0,i=this._renderLayers;r<i.length;r++)i[r].resize(this.dimensions);this._screenElement.style.width=this.dimensions.canvasWidth+"px",this._screenElement.style.height=this.dimensions.canvasHeight+"px"},t.prototype.onCharSizeChanged=function(){this.onResize(this._bufferService.cols,this._bufferService.rows)},t.prototype.onBlur=function(){this._runOperation((function(e){return e.onBlur()}))},t.prototype.onFocus=function(){this._runOperation((function(e){return e.onFocus()}))},t.prototype.onSelectionChanged=function(e,t,r){void 0===r&&(r=!1),this._runOperation((function(i){return i.onSelectionChanged(e,t,r)}))},t.prototype.onCursorMove=function(){this._runOperation((function(e){return e.onCursorMove()}))},t.prototype.onOptionsChanged=function(){this._runOperation((function(e){return e.onOptionsChanged()}))},t.prototype.clear=function(){this._runOperation((function(e){return e.reset()}))},t.prototype._runOperation=function(e){for(var t=0,r=this._renderLayers;t<r.length;t++)e(r[t])},t.prototype.renderRows=function(e,t){for(var r=0,i=this._renderLayers;r<i.length;r++)i[r].onGridChanged(e,t)},t.prototype.clearTextureAtlas=function(){for(var e=0,t=this._renderLayers;e<t.length;e++)t[e].clearTextureAtlas()},t.prototype._updateDimensions=function(){this._charSizeService.hasValidSize&&(this.dimensions.scaledCharWidth=Math.floor(this._charSizeService.width*window.devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._charSizeService.height*window.devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.rawOptions.lineHeight),this.dimensions.scaledCharTop=1===this._optionsService.rawOptions.lineHeight?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.scaledCharLeft=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.scaledCanvasHeight=this._bufferService.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._bufferService.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._bufferService.rows,this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._bufferService.cols)},o([s(4,_.IInstantiationService),s(5,_.IBufferService),s(6,f.ICharSizeService),s(7,_.IOptionsService)],t)}(u.Disposable);t.Renderer=g},1752:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw new Error("value must not be falsy");return e}},4149:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionRenderLayer=void 0;var a=r(1546),c=r(2585),l=function(e){function t(t,r,i,n,o,s){var a=e.call(this,t,"selection",r,!0,i,n,o,s)||this;return a._clearState(),a}return n(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,r){if(this._didStateChange(e,t,r,this._bufferService.buffer.ydisp))if(this._clearAll(),e&&t){var i=e[1]-this._bufferService.buffer.ydisp,n=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),s=Math.min(n,this._bufferService.rows-1);if(o>=this._bufferService.rows||s<0)this._state.ydisp=this._bufferService.buffer.ydisp;else{if(this._ctx.fillStyle=this._colors.selectionTransparent.css,r){var a=e[0],c=t[0]-a,l=s-o+1;this._fillCells(a,o,c,l)}else{a=i===o?e[0]:0;var h=o===n?t[0]:this._bufferService.cols;this._fillCells(a,o,h-a,1);var u=Math.max(s-o-1,0);if(this._fillCells(0,o+1,this._bufferService.cols,u),o!==s){var f=n===s?t[0]:this._bufferService.cols;this._fillCells(0,s,f,1)}}this._state.start=[e[0],e[1]],this._state.end=[t[0],t[1]],this._state.columnSelectMode=r,this._state.ydisp=this._bufferService.buffer.ydisp}}else this._clearState()},t.prototype._didStateChange=function(e,t,r,i){return!this._areCoordinatesEqual(e,this._state.start)||!this._areCoordinatesEqual(t,this._state.end)||r!==this._state.columnSelectMode||i!==this._state.ydisp},t.prototype._areCoordinatesEqual=function(e,t){return!(!e||!t)&&e[0]===t[0]&&e[1]===t[1]},o([s(4,c.IBufferService),s(5,c.IOptionsService)],t)}(a.BaseRenderLayer);t.SelectionRenderLayer=l},9596:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.TextRenderLayer=void 0;var a=r(3700),c=r(1546),l=r(3734),h=r(643),u=r(511),f=r(2585),_=r(4725),d=r(4269),p=function(e){function t(t,r,i,n,o,s,c,l){var h=e.call(this,t,"text",r,n,i,o,s,c)||this;return h._characterJoinerService=l,h._characterWidth=0,h._characterFont="",h._characterOverlapCache={},h._workCell=new u.CellData,h._state=new a.GridCache,h}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t);var r=this._getFont(!1,!1);this._characterWidth===t.scaledCharWidth&&this._characterFont===r||(this._characterWidth=t.scaledCharWidth,this._characterFont=r,this._characterOverlapCache={}),this._state.clear(),this._state.resize(this._bufferService.cols,this._bufferService.rows)},t.prototype.reset=function(){this._state.clear(),this._clearAll()},t.prototype._forEachCell=function(e,t,r){for(var i=e;i<=t;i++)for(var n=i+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.lines.get(n),s=this._characterJoinerService.getJoinedCharacters(n),a=0;a<this._bufferService.cols;a++){o.loadCell(a,this._workCell);var c=this._workCell,l=!1,u=a;if(0!==c.getWidth()){if(s.length>0&&a===s[0][0]){l=!0;var f=s.shift();c=new d.JoinedCellData(this._workCell,o.translateToString(!0,f[0],f[1]),f[1]-f[0]),u=f[1]-1}!l&&this._isOverlapping(c)&&u<o.length-1&&o.getCodePoint(u+1)===h.NULL_CELL_CODE&&(c.content&=-12582913,c.content|=2<<22),r(c,a,i),a=u}}},t.prototype._drawBackground=function(e,t){var r=this,i=this._ctx,n=this._bufferService.cols,o=0,s=0,a=null;i.save(),this._forEachCell(e,t,(function(e,t,c){var h=null;e.isInverse()?h=e.isFgDefault()?r._colors.foreground.css:e.isFgRGB()?"rgb("+l.AttributeData.toColorRGB(e.getFgColor()).join(",")+")":r._colors.ansi[e.getFgColor()].css:e.isBgRGB()?h="rgb("+l.AttributeData.toColorRGB(e.getBgColor()).join(",")+")":e.isBgPalette()&&(h=r._colors.ansi[e.getBgColor()].css),null===a&&(o=t,s=c),c!==s?(i.fillStyle=a||"",r._fillCells(o,s,n-o,1),o=t,s=c):a!==h&&(i.fillStyle=a||"",r._fillCells(o,s,t-o,1),o=t,s=c),a=h})),null!==a&&(i.fillStyle=a,this._fillCells(o,s,n-o,1)),i.restore()},t.prototype._drawForeground=function(e,t){var r=this;this._forEachCell(e,t,(function(e,t,i){if(!e.isInvisible()&&(r._drawChars(e,t,i),e.isUnderline()||e.isStrikethrough())){if(r._ctx.save(),e.isInverse())if(e.isBgDefault())r._ctx.fillStyle=r._colors.background.css;else if(e.isBgRGB())r._ctx.fillStyle="rgb("+l.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var n=e.getBgColor();r._optionsService.rawOptions.drawBoldTextInBrightColors&&e.isBold()&&n<8&&(n+=8),r._ctx.fillStyle=r._colors.ansi[n].css}else if(e.isFgDefault())r._ctx.fillStyle=r._colors.foreground.css;else if(e.isFgRGB())r._ctx.fillStyle="rgb("+l.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var o=e.getFgColor();r._optionsService.rawOptions.drawBoldTextInBrightColors&&e.isBold()&&o<8&&(o+=8),r._ctx.fillStyle=r._colors.ansi[o].css}e.isStrikethrough()&&r._fillMiddleLineAtCells(t,i,e.getWidth()),e.isUnderline()&&r._fillBottomLineAtCells(t,i,e.getWidth()),r._ctx.restore()}}))},t.prototype.onGridChanged=function(e,t){0!==this._state.cache.length&&(this._charAtlas&&this._charAtlas.beginFrame(),this._clearCells(0,e,this._bufferService.cols,t-e+1),this._drawBackground(e,t),this._drawForeground(e,t))},t.prototype.onOptionsChanged=function(){this._setTransparency(this._optionsService.rawOptions.allowTransparency)},t.prototype._isOverlapping=function(e){if(1!==e.getWidth())return!1;if(e.getCode()<256)return!1;var t=e.getChars();if(this._characterOverlapCache.hasOwnProperty(t))return this._characterOverlapCache[t];this._ctx.save(),this._ctx.font=this._characterFont;var r=Math.floor(this._ctx.measureText(t).width)>this._characterWidth;return this._ctx.restore(),this._characterOverlapCache[t]=r,r},o([s(5,f.IBufferService),s(6,f.IOptionsService),s(7,_.ICharacterJoinerService)],t)}(c.BaseRenderLayer);t.TextRenderLayer=p},9616:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseCharAtlas=void 0;var r=function(){function e(){this._didWarmUp=!1}return e.prototype.dispose=function(){},e.prototype.warmUp=function(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)},e.prototype._doWarmUp=function(){},e.prototype.clear=function(){},e.prototype.beginFrame=function(){},e}();t.BaseCharAtlas=r},1420:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeTerminalFromCache=t.acquireCharAtlas=void 0;var i=r(2040),n=r(1906),o=[];t.acquireCharAtlas=function(e,t,r,s,a){for(var c=(0,i.generateConfig)(s,a,e,r),l=0;l<o.length;l++){var h=(u=o[l]).ownedBy.indexOf(t);if(h>=0){if((0,i.configEquals)(u.config,c))return u.atlas;1===u.ownedBy.length?(u.atlas.dispose(),o.splice(l,1)):u.ownedBy.splice(h,1);break}}for(l=0;l<o.length;l++){var u=o[l];if((0,i.configEquals)(u.config,c))return u.ownedBy.push(t),u.atlas}var f={atlas:new n.DynamicCharAtlas(document,c),config:c,ownedBy:[t]};return o.push(f),f.atlas},t.removeTerminalFromCache=function(e){for(var t=0;t<o.length;t++){var r=o[t].ownedBy.indexOf(e);if(-1!==r){1===o[t].ownedBy.length?(o[t].atlas.dispose(),o.splice(t,1)):o[t].ownedBy.splice(r,1);break}}}},2040:function(e,t,r){var i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.is256Color=t.configEquals=t.generateConfig=void 0;var n=r(643);t.generateConfig=function(e,t,r,n){var o={foreground:n.foreground,background:n.background,cursor:void 0,cursorAccent:void 0,selection:void 0,ansi:i([],n.ansi,!0)};return{devicePixelRatio:window.devicePixelRatio,scaledCharWidth:e,scaledCharHeight:t,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,colors:o}},t.configEquals=function(e,t){for(var r=0;r<e.colors.ansi.length;r++)if(e.colors.ansi[r].rgba!==t.colors.ansi[r].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.scaledCharWidth===t.scaledCharWidth&&e.scaledCharHeight===t.scaledCharHeight&&e.colors.foreground===t.colors.foreground&&e.colors.background===t.colors.background},t.is256Color=function(e){return e<n.DEFAULT_COLOR}},8803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CHAR_ATLAS_CELL_SPACING=t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;var i=r(6114);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=i.isFirefox||i.isLegacyEdge?"bottom":"ideographic",t.CHAR_ATLAS_CELL_SPACING=1},1906:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.NoneCharAtlas=t.DynamicCharAtlas=t.getGlyphCacheKey=void 0;var o=r(8803),s=r(9616),a=r(5680),c=r(7001),l=r(6114),h=r(1752),u=r(4774),f=1024,_=1024,d={css:"rgba(0, 0, 0, 0)",rgba:0};function p(e){return e.code<<21|e.bg<<12|e.fg<<3|(e.bold?0:4)+(e.dim?0:2)+(e.italic?0:1)}t.getGlyphCacheKey=p;var v=function(e){function t(t,r){var i=e.call(this)||this;i._config=r,i._drawToCacheCount=0,i._glyphsWaitingOnBitmap=[],i._bitmapCommitTimeout=null,i._bitmap=null,i._cacheCanvas=t.createElement("canvas"),i._cacheCanvas.width=f,i._cacheCanvas.height=_,i._cacheCtx=(0,h.throwIfFalsy)(i._cacheCanvas.getContext("2d",{alpha:!0}));var n=t.createElement("canvas");n.width=i._config.scaledCharWidth,n.height=i._config.scaledCharHeight,i._tmpCtx=(0,h.throwIfFalsy)(n.getContext("2d",{alpha:i._config.allowTransparency})),i._width=Math.floor(f/i._config.scaledCharWidth),i._height=Math.floor(_/i._config.scaledCharHeight);var o=i._width*i._height;return i._cacheMap=new c.LRUMap(o),i._cacheMap.prealloc(o),i}return n(t,e),t.prototype.dispose=function(){null!==this._bitmapCommitTimeout&&(window.clearTimeout(this._bitmapCommitTimeout),this._bitmapCommitTimeout=null)},t.prototype.beginFrame=function(){this._drawToCacheCount=0},t.prototype.clear=function(){if(this._cacheMap.size>0){var e=this._width*this._height;this._cacheMap=new c.LRUMap(e),this._cacheMap.prealloc(e)}this._cacheCtx.clearRect(0,0,f,_),this._tmpCtx.clearRect(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight)},t.prototype.draw=function(e,t,r,i){if(32===t.code)return!0;if(!this._canCache(t))return!1;var n=p(t),o=this._cacheMap.get(n);if(null!=o)return this._drawFromCache(e,o,r,i),!0;if(this._drawToCacheCount<100){var s;s=this._cacheMap.size<this._cacheMap.capacity?this._cacheMap.size:this._cacheMap.peek().index;var a=this._drawToCache(t,s);return this._cacheMap.set(n,a),this._drawFromCache(e,a,r,i),!0}return!1},t.prototype._canCache=function(e){return e.code<256},t.prototype._toCoordinateX=function(e){return e%this._width*this._config.scaledCharWidth},t.prototype._toCoordinateY=function(e){return Math.floor(e/this._width)*this._config.scaledCharHeight},t.prototype._drawFromCache=function(e,t,r,i){if(!t.isEmpty){var n=this._toCoordinateX(t.index),o=this._toCoordinateY(t.index);e.drawImage(t.inBitmap?this._bitmap:this._cacheCanvas,n,o,this._config.scaledCharWidth,this._config.scaledCharHeight,r,i,this._config.scaledCharWidth,this._config.scaledCharHeight)}},t.prototype._getColorFromAnsiIndex=function(e){return e<this._config.colors.ansi.length?this._config.colors.ansi[e]:a.DEFAULT_ANSI_COLORS[e]},t.prototype._getBackgroundColor=function(e){return this._config.allowTransparency?d:e.bg===o.INVERTED_DEFAULT_COLOR?this._config.colors.foreground:e.bg<256?this._getColorFromAnsiIndex(e.bg):this._config.colors.background},t.prototype._getForegroundColor=function(e){return e.fg===o.INVERTED_DEFAULT_COLOR?u.color.opaque(this._config.colors.background):e.fg<256?this._getColorFromAnsiIndex(e.fg):this._config.colors.foreground},t.prototype._drawToCache=function(e,t){this._drawToCacheCount++,this._tmpCtx.save();var r=this._getBackgroundColor(e);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=r.css,this._tmpCtx.fillRect(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),this._tmpCtx.globalCompositeOperation="source-over";var i=e.bold?this._config.fontWeightBold:this._config.fontWeight,n=e.italic?"italic":"";this._tmpCtx.font=n+" "+i+" "+this._config.fontSize*this._config.devicePixelRatio+"px "+this._config.fontFamily,this._tmpCtx.textBaseline=o.TEXT_BASELINE,this._tmpCtx.fillStyle=this._getForegroundColor(e).css,e.dim&&(this._tmpCtx.globalAlpha=o.DIM_OPACITY),this._tmpCtx.fillText(e.chars,0,this._config.scaledCharHeight);var s=this._tmpCtx.getImageData(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),a=!1;if(this._config.allowTransparency||(a=y(s,r)),a&&"_"===e.chars&&!this._config.allowTransparency)for(var c=1;c<=5&&(this._tmpCtx.fillText(e.chars,0,this._config.scaledCharHeight-c),a=y(s=this._tmpCtx.getImageData(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),r));c++);this._tmpCtx.restore();var l=this._toCoordinateX(t),h=this._toCoordinateY(t);this._cacheCtx.putImageData(s,l,h);var u={index:t,isEmpty:a,inBitmap:!1};return this._addGlyphToBitmap(u),u},t.prototype._addGlyphToBitmap=function(e){var t=this;!("createImageBitmap"in window)||l.isFirefox||l.isSafari||(this._glyphsWaitingOnBitmap.push(e),null===this._bitmapCommitTimeout&&(this._bitmapCommitTimeout=window.setTimeout((function(){return t._generateBitmap()}),100)))},t.prototype._generateBitmap=function(){var e=this,t=this._glyphsWaitingOnBitmap;this._glyphsWaitingOnBitmap=[],window.createImageBitmap(this._cacheCanvas).then((function(r){e._bitmap=r;for(var i=0;i<t.length;i++)t[i].inBitmap=!0})),this._bitmapCommitTimeout=null},t}(s.BaseCharAtlas);t.DynamicCharAtlas=v;var g=function(e){function t(t,r){return e.call(this)||this}return n(t,e),t.prototype.draw=function(e,t,r,i){return!1},t}(s.BaseCharAtlas);function y(e,t){for(var r=!0,i=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,s=0;s<e.data.length;s+=4)e.data[s]===i&&e.data[s+1]===n&&e.data[s+2]===o?e.data[s+3]=0:r=!1;return r}t.NoneCharAtlas=g},7001:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LRUMap=void 0;var r=function(){function e(e){this.capacity=e,this._map={},this._head=null,this._tail=null,this._nodePool=[],this.size=0}return e.prototype._unlinkNode=function(e){var t=e.prev,r=e.next;e===this._head&&(this._head=r),e===this._tail&&(this._tail=t),null!==t&&(t.next=r),null!==r&&(r.prev=t)},e.prototype._appendNode=function(e){var t=this._tail;null!==t&&(t.next=e),e.prev=t,e.next=null,this._tail=e,null===this._head&&(this._head=e)},e.prototype.prealloc=function(e){for(var t=this._nodePool,r=0;r<e;r++)t.push({prev:null,next:null,key:null,value:null})},e.prototype.get=function(e){var t=this._map[e];return void 0!==t?(this._unlinkNode(t),this._appendNode(t),t.value):null},e.prototype.peekValue=function(e){var t=this._map[e];return void 0!==t?t.value:null},e.prototype.peek=function(){var e=this._head;return null===e?null:e.value},e.prototype.set=function(e,t){var r=this._map[e];if(void 0!==r)r=this._map[e],this._unlinkNode(r),r.value=t;else if(this.size>=this.capacity)r=this._head,this._unlinkNode(r),delete this._map[r.key],r.key=e,r.value=t,this._map[e]=r;else{var i=this._nodePool;i.length>0?((r=i.pop()).key=e,r.value=t):r={prev:null,next:null,key:e,value:t},this._map[e]=r,this.size++}this._appendNode(r)},e}();t.LRUMap=r},1296:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRenderer=void 0;var a=r(3787),c=r(8803),l=r(844),h=r(4725),u=r(2585),f=r(8460),_=r(4774),d=r(9631),p="xterm-dom-renderer-owner-",v="xterm-fg-",g="xterm-bg-",y="xterm-focus",m=1,S=function(e){function t(t,r,i,n,o,s,c,l,h,u){var f=e.call(this)||this;return f._colors=t,f._element=r,f._screenElement=i,f._viewportElement=n,f._linkifier=o,f._linkifier2=s,f._charSizeService=l,f._optionsService=h,f._bufferService=u,f._terminalClass=m++,f._rowElements=[],f._rowContainer=document.createElement("div"),f._rowContainer.classList.add("xterm-rows"),f._rowContainer.style.lineHeight="normal",f._rowContainer.setAttribute("aria-hidden","true"),f._refreshRowElements(f._bufferService.cols,f._bufferService.rows),f._selectionContainer=document.createElement("div"),f._selectionContainer.classList.add("xterm-selection"),f._selectionContainer.setAttribute("aria-hidden","true"),f.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},f._updateDimensions(),f._injectCss(),f._rowFactory=c.createInstance(a.DomRendererRowFactory,document,f._colors),f._element.classList.add(p+f._terminalClass),f._screenElement.appendChild(f._rowContainer),f._screenElement.appendChild(f._selectionContainer),f._linkifier.onShowLinkUnderline((function(e){return f._onLinkHover(e)})),f._linkifier.onHideLinkUnderline((function(e){return f._onLinkLeave(e)})),f._linkifier2.onShowLinkUnderline((function(e){return f._onLinkHover(e)})),f._linkifier2.onHideLinkUnderline((function(e){return f._onLinkLeave(e)})),f}return n(t,e),Object.defineProperty(t.prototype,"onRequestRedraw",{get:function(){return(new f.EventEmitter).event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._element.classList.remove(p+this._terminalClass),(0,d.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.rawOptions.letterSpacing),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.rawOptions.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;e<t.length;e++){var r=t[e];r.style.width=this.dimensions.canvasWidth+"px",r.style.height=this.dimensions.actualCellHeight+"px",r.style.lineHeight=this.dimensions.actualCellHeight+"px",r.style.overflow="hidden"}this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));var i=this._terminalSelector+" .xterm-rows span { display: inline-block; height: 100%; vertical-align: top; width: "+this.dimensions.actualCellWidth+"px}";this._dimensionsStyleElement.textContent=i,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=this.dimensions.canvasWidth+"px",this._screenElement.style.height=this.dimensions.canvasHeight+"px"},t.prototype.setColors=function(e){this._colors=e,this._injectCss()},t.prototype._injectCss=function(){var e=this;this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));var t=this._terminalSelector+" .xterm-rows { color: "+this._colors.foreground.css+"; font-family: "+this._optionsService.rawOptions.fontFamily+"; font-size: "+this._optionsService.rawOptions.fontSize+"px;}";t+=this._terminalSelector+" span:not(."+a.BOLD_CLASS+") { font-weight: "+this._optionsService.rawOptions.fontWeight+";}"+this._terminalSelector+" span."+a.BOLD_CLASS+" { font-weight: "+this._optionsService.rawOptions.fontWeightBold+";}"+this._terminalSelector+" span."+a.ITALIC_CLASS+" { font-style: italic;}",t+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { box-shadow: none; }}",t+="@keyframes blink_block_"+this._terminalClass+" { 0% { background-color: "+this._colors.cursor.css+"; color: "+this._colors.cursorAccent.css+"; } 50% { background-color: "+this._colors.cursorAccent.css+"; color: "+this._colors.cursor.css+"; }}",t+=this._terminalSelector+" .xterm-rows:not(.xterm-focus) ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { outline: 1px solid "+this._colors.cursor.css+"; outline-offset: -1px;}"+this._terminalSelector+" .xterm-rows.xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_BLINK_CLASS+":not(."+a.CURSOR_STYLE_BLOCK_CLASS+") { animation: blink_box_shadow_"+this._terminalClass+" 1s step-end infinite;}"+this._terminalSelector+" .xterm-rows.xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_BLINK_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { animation: blink_block_"+this._terminalClass+" 1s step-end infinite;}"+this._terminalSelector+" .xterm-rows.xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { background-color: "+this._colors.cursor.css+"; color: "+this._colors.cursorAccent.css+";}"+this._terminalSelector+" .xterm-rows ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BAR_CLASS+" { box-shadow: "+this._optionsService.rawOptions.cursorWidth+"px 0 0 "+this._colors.cursor.css+" inset;}"+this._terminalSelector+" .xterm-rows ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_UNDERLINE_CLASS+" { box-shadow: 0 -1px 0 "+this._colors.cursor.css+" inset;}",t+=this._terminalSelector+" .xterm-selection { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}"+this._terminalSelector+" .xterm-selection div { position: absolute; background-color: "+this._colors.selectionTransparent.css+";}",this._colors.ansi.forEach((function(r,i){t+=e._terminalSelector+" ."+v+i+" { color: "+r.css+"; }"+e._terminalSelector+" ."+g+i+" { background-color: "+r.css+"; }"})),t+=this._terminalSelector+" ."+v+c.INVERTED_DEFAULT_COLOR+" { color: "+_.color.opaque(this._colors.background).css+"; }"+this._terminalSelector+" ."+g+c.INVERTED_DEFAULT_COLOR+" { background-color: "+this._colors.foreground.css+"; }",this._themeStyleElement.textContent=t},t.prototype.onDevicePixelRatioChange=function(){this._updateDimensions()},t.prototype._refreshRowElements=function(e,t){for(var r=this._rowElements.length;r<=t;r++){var i=document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)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(y)},t.prototype.onFocus=function(){this._rowContainer.classList.add(y)},t.prototype.onSelectionChanged=function(e,t,r){for(;this._selectionContainer.children.length;)this._selectionContainer.removeChild(this._selectionContainer.children[0]);if(e&&t){var i=e[1]-this._bufferService.buffer.ydisp,n=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),s=Math.min(n,this._bufferService.rows-1);if(!(o>=this._bufferService.rows||s<0)){var a=document.createDocumentFragment();if(r)a.appendChild(this._createSelectionElement(o,e[0],t[0],s-o+1));else{var c=i===o?e[0]:0,l=o===n?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));var h=s-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==s){var u=n===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,0,u))}}this._selectionContainer.appendChild(a)}}},t.prototype._createSelectionElement=function(e,t,r,i){void 0===i&&(i=1);var n=document.createElement("div");return n.style.height=i*this.dimensions.actualCellHeight+"px",n.style.top=e*this.dimensions.actualCellHeight+"px",n.style.left=t*this.dimensions.actualCellWidth+"px",n.style.width=this.dimensions.actualCellWidth*(r-t)+"px",n},t.prototype.onCursorMove=function(){},t.prototype.onOptionsChanged=function(){this._updateDimensions(),this._injectCss()},t.prototype.clear=function(){for(var e=0,t=this._rowElements;e<t.length;e++)t[e].innerText=""},t.prototype.renderRows=function(e,t){for(var r=this._bufferService.buffer.ybase+this._bufferService.buffer.y,i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._optionsService.rawOptions.cursorBlink,o=e;o<=t;o++){var s=this._rowElements[o];s.innerText="";var a=o+this._bufferService.buffer.ydisp,c=this._bufferService.buffer.lines.get(a),l=this._optionsService.rawOptions.cursorStyle;s.appendChild(this._rowFactory.createRow(c,a,a===r,l,i,n,this.dimensions.actualCellWidth,this._bufferService.cols))}},Object.defineProperty(t.prototype,"_terminalSelector",{get:function(){return"."+p+this._terminalClass},enumerable:!1,configurable:!0}),t.prototype._onLinkHover=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)},t.prototype._onLinkLeave=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)},t.prototype._setCellUnderline=function(e,t,r,i,n,o){for(;e!==t||r!==i;){var s=this._rowElements[r];if(!s)return;var a=s.children[e];a&&(a.style.textDecoration=o?"underline":"none"),++e>=n&&(e=0,r++)}},o([s(6,u.IInstantiationService),s(7,h.ICharSizeService),s(8,u.IOptionsService),s(9,u.IBufferService)],t)}(l.Disposable);t.DomRenderer=S},3787:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};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.STRIKETHROUGH_CLASS=t.UNDERLINE_CLASS=t.ITALIC_CLASS=t.DIM_CLASS=t.BOLD_CLASS=void 0;var o=r(8803),s=r(643),a=r(511),c=r(2585),l=r(4774),h=r(4725),u=r(4269);t.BOLD_CLASS="xterm-bold",t.DIM_CLASS="xterm-dim",t.ITALIC_CLASS="xterm-italic",t.UNDERLINE_CLASS="xterm-underline",t.STRIKETHROUGH_CLASS="xterm-strikethrough",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 f=function(){function e(e,t,r,i,n){this._document=e,this._colors=t,this._characterJoinerService=r,this._optionsService=i,this._coreService=n,this._workCell=new a.CellData}return e.prototype.setColors=function(e){this._colors=e},e.prototype.createRow=function(e,r,i,n,a,c,h,f){for(var d=this._document.createDocumentFragment(),p=this._characterJoinerService.getJoinedCharacters(r),v=0,g=Math.min(e.length,f)-1;g>=0;g--)if(e.loadCell(g,this._workCell).getCode()!==s.NULL_CELL_CODE||i&&g===a){v=g+1;break}for(g=0;g<v;g++){e.loadCell(g,this._workCell);var y=this._workCell.getWidth();if(0!==y){var m=!1,S=g,C=this._workCell;if(p.length>0&&g===p[0][0]){m=!0;var b=p.shift();C=new u.JoinedCellData(this._workCell,e.translateToString(!0,b[0],b[1]),b[1]-b[0]),S=b[1]-1,y=C.getWidth()}var w=this._document.createElement("span");if(y>1&&(w.style.width=h*y+"px"),m&&(w.style.display="inline",a>=g&&a<=S&&(a=g)),!this._coreService.isCursorHidden&&i&&g===a)switch(w.classList.add(t.CURSOR_CLASS),c&&w.classList.add(t.CURSOR_BLINK_CLASS),n){case"bar":w.classList.add(t.CURSOR_STYLE_BAR_CLASS);break;case"underline":w.classList.add(t.CURSOR_STYLE_UNDERLINE_CLASS);break;default:w.classList.add(t.CURSOR_STYLE_BLOCK_CLASS)}C.isBold()&&w.classList.add(t.BOLD_CLASS),C.isItalic()&&w.classList.add(t.ITALIC_CLASS),C.isDim()&&w.classList.add(t.DIM_CLASS),C.isUnderline()&&w.classList.add(t.UNDERLINE_CLASS),C.isInvisible()?w.textContent=s.WHITESPACE_CELL_CHAR:w.textContent=C.getChars()||s.WHITESPACE_CELL_CHAR,C.isStrikethrough()&&w.classList.add(t.STRIKETHROUGH_CLASS);var L=C.getFgColor(),E=C.getFgColorMode(),x=C.getBgColor(),k=C.getBgColorMode(),M=!!C.isInverse();if(M){var A=L;L=x,x=A;var R=E;E=k,k=R}switch(E){case 16777216:case 33554432:C.isBold()&&L<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(L+=8),this._applyMinimumContrast(w,this._colors.background,this._colors.ansi[L])||w.classList.add("xterm-fg-"+L);break;case 50331648:var O=l.rgba.toColor(L>>16&255,L>>8&255,255&L);this._applyMinimumContrast(w,this._colors.background,O)||this._addStyle(w,"color:#"+_(L.toString(16),"0",6));break;default:this._applyMinimumContrast(w,this._colors.background,this._colors.foreground)||M&&w.classList.add("xterm-fg-"+o.INVERTED_DEFAULT_COLOR)}switch(k){case 16777216:case 33554432:w.classList.add("xterm-bg-"+x);break;case 50331648:this._addStyle(w,"background-color:#"+_(x.toString(16),"0",6));break;default:M&&w.classList.add("xterm-bg-"+o.INVERTED_DEFAULT_COLOR)}d.appendChild(w),g=S}}return d},e.prototype._applyMinimumContrast=function(e,t,r){if(1===this._optionsService.rawOptions.minimumContrastRatio)return!1;var i=this._colors.contrastCache.getColor(this._workCell.bg,this._workCell.fg);return void 0===i&&(i=l.color.ensureContrastRatio(t,r,this._optionsService.rawOptions.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+";")},i([n(2,h.ICharacterJoinerService),n(3,c.IOptionsService),n(4,c.ICoreService)],e)}();function _(e,t,r){for(;e.length<r;)e=t+e;return e}t.DomRendererRowFactory=f},456:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionModel=void 0;var r=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==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[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=r},428:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharSizeService=void 0;var o=r(2585),s=r(8460),a=function(){function e(e,t,r){this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=new s.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([n(2,o.IOptionsService)],e)}();t.CharSizeService=a;var c=function(){function e(e,t,r){this._document=e,this._parentElement=t,this._optionsService=r,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.rawOptions.fontFamily,this._measureElement.style.fontSize=this._optionsService.rawOptions.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}()},4269:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharacterJoinerService=t.JoinedCellData=void 0;var a=r(3734),c=r(643),l=r(511),h=r(2585),u=function(e){function t(t,r,i){var n=e.call(this)||this;return n.content=0,n.combinedData="",n.fg=t.fg,n.bg=t.bg,n.combinedData=r,n._width=i,n}return n(t,e),t.prototype.isCombined=function(){return 2097152},t.prototype.getWidth=function(){return this._width},t.prototype.getChars=function(){return this.combinedData},t.prototype.getCode=function(){return 2097151},t.prototype.setFromCharData=function(e){throw new Error("not implemented")},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(a.AttributeData);t.JoinedCellData=u;var f=function(){function e(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new l.CellData}return e.prototype.register=function(e){var t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id},e.prototype.deregister=function(e){for(var t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1},e.prototype.getJoinedCharacters=function(e){if(0===this._characterJoiners.length)return[];var t=this._bufferService.buffer.lines.get(e);if(!t||0===t.length)return[];for(var r=[],i=t.translateToString(!0),n=0,o=0,s=0,a=t.getFg(0),l=t.getBg(0),h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-n>1)for(var u=this._getJoinedRanges(i,s,o,t,n),f=0;f<u.length;f++)r.push(u[f]);n=h,s=o,a=this._workCell.fg,l=this._workCell.bg}o+=this._workCell.getChars().length||c.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-n>1)for(u=this._getJoinedRanges(i,s,o,t,n),f=0;f<u.length;f++)r.push(u[f]);return r},e.prototype._getJoinedRanges=function(t,r,i,n,o){var s=t.substring(r,i),a=[];try{a=this._characterJoiners[0].handler(s)}catch(e){console.error(e)}for(var c=1;c<this._characterJoiners.length;c++)try{for(var l=this._characterJoiners[c].handler(s),h=0;h<l.length;h++)e._mergeRanges(a,l[h])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,n,o),a},e.prototype._stringRangesToCellRanges=function(e,t,r){var i=0,n=!1,o=0,s=e[i];if(s){for(var a=r;a<this._bufferService.cols;a++){var l=t.getWidth(a),h=t.getString(a).length||c.WHITESPACE_CELL_CHAR.length;if(0!==l){if(!n&&s[0]<=o&&(s[0]=a,n=!0),s[1]<=o){if(s[1]=a,!(s=e[++i]))break;s[0]<=o?(s[0]=a,n=!0):n=!1}o+=h}}s&&(s[1]=this._bufferService.cols)}},e._mergeRanges=function(e,t){for(var r=!1,i=0;i<e.length;i++){var n=e[i];if(r){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),r=!0)}}return r?e[e.length-1][1]=t[1]:e.push(t),e},e=o([s(0,h.IBufferService)],e)}();t.CharacterJoinerService=f},5114:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreBrowserService=void 0;var r=function(){function e(e){this._textarea=e}return Object.defineProperty(e.prototype,"isFocused",{get:function(){return(this._textarea.getRootNode?this._textarea.getRootNode():document).activeElement===this._textarea&&document.hasFocus()},enumerable:!1,configurable:!0}),e}();t.CoreBrowserService=r},7641:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Decoration=t.DecorationService=void 0;var a=r(8460),c=r(844),l=r(2585),h=function(e){function t(t){var r=e.call(this)||this;return r._instantiationService=t,r._decorations=[],r}return n(t,e),t.prototype.attachToDom=function(e,t){var r=this;this._renderService=t,this._screenElement=e,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),e.appendChild(this._container),this.register(this._renderService.onRenderedBufferChange((function(){return r.refresh()}))),this.register(this._renderService.onDimensionsChange((function(){return r.refresh(!0)})))},t.prototype.registerDecoration=function(e){var t=this;if(!e.marker.isDisposed&&this._container){var r=this._instantiationService.createInstance(u,e,this._container);return this._decorations.push(r),r.onDispose((function(){return t._decorations.splice(t._decorations.indexOf(r),1)})),this._queueRefresh(),r}},t.prototype._queueRefresh=function(){var e=this;void 0===this._animationFrame&&(this._animationFrame=window.requestAnimationFrame((function(){e.refresh(),e._animationFrame=void 0})))},t.prototype.refresh=function(e){if(this._renderService)for(var t=0,r=this._decorations;t<r.length;t++)r[t].render(this._renderService,e)},t.prototype.dispose=function(){for(var e=0,t=this._decorations;e<t.length;e++)t[e].dispose();this._screenElement&&this._container&&this._screenElement.contains(this._container)&&this._screenElement.removeChild(this._container)},o([s(0,l.IInstantiationService)],t)}(c.Disposable);t.DecorationService=h;var u=function(e){function t(t,r,i){var n,o=e.call(this)||this;return o._container=r,o._bufferService=i,o.isDisposed=!1,o._onDispose=new a.EventEmitter,o._onRender=new a.EventEmitter,o.x=null!==(n=t.x)&&void 0!==n?n:0,o._marker=t.marker,o._marker.onDispose((function(){return o.dispose()})),o.anchor=t.anchor||"left",o.width=t.width||1,o.height=t.height||1,o}return n(t,e),Object.defineProperty(t.prototype,"element",{get:function(){return this._element},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"marker",{get:function(){return this._marker},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{get:function(){return this._onDispose.event},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRender",{get:function(){return this._onRender.event},enumerable:!1,configurable:!0}),t.prototype.render=function(e,t){this._element&&!t||this._createElement(e,t),this._container&&this._element&&!this._container.contains(this._element)&&this._container.append(this._element),this._refreshStyle(e),this._element&&this._onRender.fire(this._element)},t.prototype._createElement=function(e,t){t&&this._element&&this._container.contains(this._element)&&this._container.removeChild(this._element),this._element=document.createElement("div"),this._element.classList.add("xterm-decoration"),this._element.style.width=this.width*e.dimensions.actualCellWidth+"px",this._element.style.height=this.height*e.dimensions.actualCellHeight+"px",this._element.style.top=(this.marker.line-this._bufferService.buffers.active.ydisp)*e.dimensions.actualCellHeight+"px",this._element.style.lineHeight=e.dimensions.actualCellHeight+"px",this.x&&this.x>this._bufferService.cols&&(this._element.style.display="none"),"right"===this.anchor?this._element.style.right=this.x?this.x*e.dimensions.actualCellWidth+"px":"":this._element.style.left=this.x?this.x*e.dimensions.actualCellWidth+"px":""},t.prototype._refreshStyle=function(e){if(this._element){var t=this.marker.line-this._bufferService.buffers.active.ydisp;t<0||t>this._bufferService.rows?this._element.style.display="none":(this._element.style.top=t*e.dimensions.actualCellHeight+"px",this._element.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block")}},t.prototype.dispose=function(){this.isDisposed||(this._element&&this._container.contains(this._element)&&this._container.removeChild(this._element),this.isDisposed=!0,this._onDispose.fire())},o([s(2,l.IBufferService)],t)}(c.Disposable);t.Decoration=u},8934:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseService=void 0;var o=r(4725),s=r(9806),a=function(){function e(e,t){this._renderService=e,this._charSizeService=t}return e.prototype.getCoords=function(e,t,r,i,n){return(0,s.getCoords)(e,t,r,i,this._charSizeService.hasValidSize,this._renderService.dimensions.actualCellWidth,this._renderService.dimensions.actualCellHeight,n)},e.prototype.getRawByteCoords=function(e,t,r,i){var n=this.getCoords(e,t,r,i);return(0,s.getRawByteCoords)(n)},i([n(0,o.IRenderService),n(1,o.ICharSizeService)],e)}();t.MouseService=a},3230:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.RenderService=void 0;var a=r(6193),c=r(8460),l=r(844),h=r(5596),u=r(3656),f=r(2585),_=r(4725),d=function(e){function t(t,r,i,n,o,s){var l=e.call(this)||this;if(l._renderer=t,l._rowCount=r,l._charSizeService=o,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 a.RenderDebouncer((function(e,t){return l._renderRows(e,t)})),l.register(l._renderDebouncer),l._screenDprMonitor=new h.ScreenDprMonitor,l._screenDprMonitor.setListener((function(){return l.onDevicePixelRatioChange()})),l.register(l._screenDprMonitor),l.register(s.onResize((function(){return l._fullRefresh()}))),l.register(s.buffers.onBufferActivate((function(){var e;return null===(e=l._renderer)||void 0===e?void 0:e.clear()}))),l.register(n.onOptionChange((function(){return l._renderer.onOptionsChanged()}))),l.register(l._charSizeService.onCharSizeChange((function(){return l.onCharSizeChanged()}))),l._renderer.onRequestRedraw((function(e){return l.refreshRows(e.start,e.end,!0)})),l.register((0,u.addDisposableDomListener)(window,"resize",(function(){return l.onDevicePixelRatioChange()}))),"IntersectionObserver"in window){var f=new IntersectionObserver((function(e){return l._onIntersectionChange(e[e.length-1])}),{threshold:0});f.observe(i),l.register({dispose:function(){return f.disconnect()}})}return l}return n(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._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)},t.prototype.refreshRows=function(e,t,r){void 0===r&&(r=!1),this._isPaused?this._needsFullRefresh=!0:(r||(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.clearTextureAtlas=function(){var e,t;null===(t=null===(e=this._renderer)||void 0===e?void 0:e.clearTextureAtlas)||void 0===t||t.call(e),this._fullRefresh()},t.prototype.setColors=function(e){this._renderer.setColors(e),this._fullRefresh()},t.prototype.onDevicePixelRatioChange=function(){this._charSizeService.measure(),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,r){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,this._renderer.onSelectionChanged(e,t,r)},t.prototype.onCursorMove=function(){this._renderer.onCursorMove()},t.prototype.clear=function(){this._renderer.clear()},o([s(3,f.IOptionsService),s(4,_.ICharSizeService),s(5,f.IBufferService)],t)}(l.Disposable);t.RenderService=d},9312:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionService=void 0;var a=r(6114),c=r(456),l=r(511),h=r(8460),u=r(4725),f=r(2585),_=r(9806),d=r(9504),p=r(844),v=r(4841),g=String.fromCharCode(160),y=new RegExp(g,"g"),m=function(e){function t(t,r,i,n,o,s,a,u){var f=e.call(this)||this;return f._element=t,f._screenElement=r,f._linkifier=i,f._bufferService=n,f._coreService=o,f._mouseService=s,f._optionsService=a,f._renderService=u,f._dragScrollAmount=0,f._enabled=!0,f._workCell=new l.CellData,f._mouseDownTimeStamp=0,f._oldHasSelection=!1,f._oldSelectionStart=void 0,f._oldSelectionEnd=void 0,f._onLinuxMouseSelection=f.register(new h.EventEmitter),f._onRedrawRequest=f.register(new h.EventEmitter),f._onSelectionChange=f.register(new h.EventEmitter),f._onRequestScrollLines=f.register(new h.EventEmitter),f._mouseMoveListener=function(e){return f._onMouseMove(e)},f._mouseUpListener=function(e){return f._onMouseUp(e)},f._coreService.onUserInput((function(){f.hasSelection&&f.clearSelection()})),f._trimListener=f._bufferService.buffer.lines.onTrim((function(e){return f._onTrim(e)})),f.register(f._bufferService.buffers.onBufferActivate((function(e){return f._onBufferActivate(e)}))),f.enable(),f._model=new c.SelectionModel(f._bufferService),f._activeSelectionMode=0,f}return n(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 r=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";for(var n=e[1];n<=t[1];n++){var o=r.translateBufferLineToString(n,!0,e[0],t[0]);i.push(o)}}else{var s=e[1]===t[1]?t[0]:void 0;for(i.push(r.translateBufferLineToString(e[1],!0,e[0],s)),n=e[1]+1;n<=t[1]-1;n++){var c=r.lines.get(n);o=r.translateBufferLineToString(n,!0),(null==c?void 0:c.isWrapped)?i[i.length-1]+=o:i.push(o)}e[1]!==t[1]&&(c=r.lines.get(t[1]),o=r.translateBufferLineToString(t[1],!0,0,t[0]),c&&c.isWrapped?i[i.length-1]+=o:i.push(o))}return i.map((function(e){return e.replace(y," ")})).join(a.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()}))),a.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),r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!(r&&i&&t)&&this._areCoordsInSelection(t,r,i)},t.prototype._areCoordsInSelection=function(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]},t.prototype._selectWordAtCursor=function(e,t){var r,i,n=null===(i=null===(r=this._linkifier.currentLink)||void 0===r?void 0:r.link)||void 0===i?void 0:i.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;var o=this._getMouseBufferCoords(e);return!!o&&(this._selectWordAt(o,t),this._model.selectionEnd=void 0,!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=(0,_.getCoordsRelativeToElement)(e,this._screenElement)[1],r=this._renderService.dimensions.canvasHeight;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-50),50),(t/=50)/Math.abs(t)+Math.round(14*t))},t.prototype.shouldForceSelection=function(e){return a.isMac?e.altKey&&this._optionsService.rawOptions.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){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)},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&&!(a.isMac&&this._optionsService.rawOptions.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[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));var r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){var i=r.lines.get(this._model.selectionEnd[1]);i&&0===i.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}else this.refresh(!0)}},t.prototype._dragScroll=function(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});var e=this._bufferService.buffer;this._dragScrollAmount>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&&this._optionsService.getOption("altClickMovesCursor")){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){var r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){var i=(0,d.moveToCellSequence)(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()},t.prototype._fireEventIfSelectionChanged=function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);r?e&&t&&(this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,r)):this._oldHasSelection&&this._fireOnSelectionChange(e,t,r)},t.prototype._fireOnSelectionChange=function(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,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 r=t[0],i=0;t[0]>=i;i++){var n=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?r--:n>1&&t[0]!==i&&(r+=n-1)}return r},t.prototype.setSelection=function(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh()},t.prototype.rightClickSelect=function(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())},t.prototype._getWordAt=function(e,t,r,i){if(void 0===r&&(r=!0),void 0===i&&(i=!0),!(e[0]>=this._bufferService.cols)){var n=this._bufferService.buffer,o=n.lines.get(e[1]);if(o){var s=n.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e),c=a,l=e[0]-a,h=0,u=0,f=0,_=0;if(" "===s.charAt(a)){for(;a>0&&" "===s.charAt(a-1);)a--;for(;c<s.length&&" "===s.charAt(c+1);)c++}else{var d=e[0],p=e[0];0===o.getWidth(d)&&(h++,d--),2===o.getWidth(p)&&(u++,p++);var v=o.getString(p).length;for(v>1&&(_+=v-1,c+=v-1);d>0&&a>0&&!this._isCharWordSeparator(o.loadCell(d-1,this._workCell));){o.loadCell(d-1,this._workCell);var g=this._workCell.getChars().length;0===this._workCell.getWidth()?(h++,d--):g>1&&(f+=g-1,a-=g-1),a--,d--}for(;p<o.length&&c+1<s.length&&!this._isCharWordSeparator(o.loadCell(p+1,this._workCell));){o.loadCell(p+1,this._workCell);var y=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,p++):y>1&&(_+=y-1,c+=y-1),c++,p++}}c++;var m=a+l-h+f,S=Math.min(this._bufferService.cols,c-a+h+u-f-_);if(t||""!==s.slice(a,c).trim()){if(r&&0===m&&32!==o.getCodePoint(0)){var C=n.lines.get(e[1]-1);if(C&&o.isWrapped&&32!==C.getCodePoint(this._bufferService.cols-1)){var b=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(b){var w=this._bufferService.cols-b.start;m-=w,S+=w}}}if(i&&m+S===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){var L=n.lines.get(e[1]+1);if((null==L?void 0:L.isWrapped)&&32!==L.getCodePoint(0)){var E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(S+=E.length)}}return{start:m,length:S}}}}},t.prototype._selectWordAt=function(e,t){var r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}},t.prototype._selectToWordAt=function(e){var t=this._getWordAt(e,!0);if(t){for(var r=e[1];t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}},t.prototype._isCharWordSeparator=function(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.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([s(3,f.IBufferService),s(4,f.ICoreService),s(5,u.IMouseService),s(6,f.IOptionsService),s(7,u.IRenderService)],t)}(p.Disposable);t.SelectionService=m},4725:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.ICharacterJoinerService=t.ISoundService=t.ISelectionService=t.IRenderService=t.IMouseService=t.ICoreBrowserService=t.ICharSizeService=void 0;var i=r(8343);t.ICharSizeService=(0,i.createDecorator)("CharSizeService"),t.ICoreBrowserService=(0,i.createDecorator)("CoreBrowserService"),t.IMouseService=(0,i.createDecorator)("MouseService"),t.IRenderService=(0,i.createDecorator)("RenderService"),t.ISelectionService=(0,i.createDecorator)("SelectionService"),t.ISoundService=(0,i.createDecorator)("SoundService"),t.ICharacterJoinerService=(0,i.createDecorator)("CharacterJoinerService"),t.IDecorationService=(0,i.createDecorator)("DecorationService")},357:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SoundService=void 0;var o=r(2585),s=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 r=t.createBufferSource();t.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.rawOptions.bellSound)),(function(e){r.buffer=e,r.connect(t.destination),r.start(0)}))}},e.prototype._base64ToArrayBuffer=function(e){for(var t=window.atob(e),r=t.length,i=new Uint8Array(r),n=0;n<r;n++)i[n]=t.charCodeAt(n);return i.buffer},e.prototype._removeMimeType=function(e){return e.split(",")[1]},e=i([n(0,o.IOptionsService)],e)}();t.SoundService=s},6349:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;var i=r(8460),n=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),r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];this._array=t,this._maxLength=e,this._startIndex=0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._length},set:function(e){if(e>this._length)for(var t=this._length;t<e;t++)this._array[t]=void 0;this._length=e},enumerable:!1,configurable:!0}),e.prototype.get=function(e){return this._array[this._getCyclicIndex(e)]},e.prototype.set=function(e,t){this._array[this._getCyclicIndex(e)]=t},e.prototype.push=function(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++},e.prototype.recycle=function(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]},Object.defineProperty(e.prototype,"isFull",{get:function(){return this._length===this._maxLength},enumerable:!1,configurable:!0}),e.prototype.pop=function(){return this._array[this._getCyclicIndex(this._length---1)]},e.prototype.splice=function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t){for(var n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){var o=this._length+r.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=r.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,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(var i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));var n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(i=0;i<t;i++)this.set(e+i+r,this.get(e+i))}},e.prototype._getCyclicIndex=function(e){return(this._startIndex+e)%this._maxLength},e}();t.CircularList=n},1439:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=void 0,t.clone=function e(t,r){if(void 0===r&&(r=5),"object"!=typeof t)return t;var i=Array.isArray(t)?[]:{};for(var n in t)i[n]=r<=1?t[n]:t[n]&&e(t[n],r-1);return i}},8969:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;var o=r(844),s=r(2585),a=r(4348),c=r(7866),l=r(744),h=r(7302),u=r(6975),f=r(8460),_=r(1753),d=r(3730),p=r(1480),v=r(7994),g=r(9282),y=r(5435),m=r(5981),S=!1,C=function(e){function t(t){var r=e.call(this)||this;return r._onBinary=new f.EventEmitter,r._onData=new f.EventEmitter,r._onLineFeed=new f.EventEmitter,r._onResize=new f.EventEmitter,r._onScroll=new f.EventEmitter,r._instantiationService=new a.InstantiationService,r.optionsService=new h.OptionsService(t),r._instantiationService.setService(s.IOptionsService,r.optionsService),r._bufferService=r.register(r._instantiationService.createInstance(l.BufferService)),r._instantiationService.setService(s.IBufferService,r._bufferService),r._logService=r._instantiationService.createInstance(c.LogService),r._instantiationService.setService(s.ILogService,r._logService),r.coreService=r.register(r._instantiationService.createInstance(u.CoreService,(function(){return r.scrollToBottom()}))),r._instantiationService.setService(s.ICoreService,r.coreService),r.coreMouseService=r._instantiationService.createInstance(_.CoreMouseService),r._instantiationService.setService(s.ICoreMouseService,r.coreMouseService),r._dirtyRowService=r._instantiationService.createInstance(d.DirtyRowService),r._instantiationService.setService(s.IDirtyRowService,r._dirtyRowService),r.unicodeService=r._instantiationService.createInstance(p.UnicodeService),r._instantiationService.setService(s.IUnicodeService,r.unicodeService),r._charsetService=r._instantiationService.createInstance(v.CharsetService),r._instantiationService.setService(s.ICharsetService,r._charsetService),r._inputHandler=new y.InputHandler(r._bufferService,r._charsetService,r.coreService,r._dirtyRowService,r._logService,r.optionsService,r.coreMouseService,r.unicodeService),r.register((0,f.forwardEvent)(r._inputHandler.onLineFeed,r._onLineFeed)),r.register(r._inputHandler),r.register((0,f.forwardEvent)(r._bufferService.onResize,r._onResize)),r.register((0,f.forwardEvent)(r.coreService.onData,r._onData)),r.register((0,f.forwardEvent)(r.coreService.onBinary,r._onBinary)),r.register(r.optionsService.onOptionChange((function(e){return r._updateOptions(e)}))),r.register(r._bufferService.onScroll((function(e){r._onScroll.fire({position:r._bufferService.buffer.ydisp,source:0}),r._dirtyRowService.markRangeDirty(r._bufferService.buffer.scrollTop,r._bufferService.buffer.scrollBottom)}))),r.register(r._inputHandler.onScroll((function(e){r._onScroll.fire({position:r._bufferService.buffer.ydisp,source:0}),r._dirtyRowService.markRangeDirty(r._bufferService.buffer.scrollTop,r._bufferService.buffer.scrollBottom)}))),r._writeBuffer=new m.WriteBuffer((function(e,t){return r._inputHandler.parse(e,t)})),r}return n(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(){var e=this;return this._onScrollApi||(this._onScrollApi=new f.EventEmitter,this.register(this._onScroll.event((function(t){var r;null===(r=e._onScrollApi)||void 0===r||r.fire(t.position)})))),this._onScrollApi.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}),Object.defineProperty(t.prototype,"options",{get:function(){return this.optionsService.options},set:function(e){for(var t in e)this.optionsService.options[t]=e[t]},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,t){this._logService.logLevel<=s.LogLevelEnum.WARN&&!S&&(this._logService.warn("writeSync is unreliable and will be removed soon."),S=!0),this._writeBuffer.writeSync(e,t)},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),this._bufferService.scroll(e,t)},t.prototype.scrollLines=function(e,t,r){this._bufferService.scrollLines(e,t,r)},t.prototype.scrollPages=function(e){this._bufferService.scrollPages(e)},t.prototype.scrollToTop=function(){this._bufferService.scrollToTop()},t.prototype.scrollToBottom=function(){this._bufferService.scrollToBottom()},t.prototype.scrollToLine=function(e){this._bufferService.scrollToLine(e)},t.prototype.registerEscHandler=function(e,t){return this._inputHandler.registerEscHandler(e,t)},t.prototype.registerDcsHandler=function(e,t){return this._inputHandler.registerDcsHandler(e,t)},t.prototype.registerCsiHandler=function(e,t){return this._inputHandler.registerCsiHandler(e,t)},t.prototype.registerOscHandler=function(e,t){return this._inputHandler.registerOscHandler(e,t)},t.prototype._setup=function(){this.optionsService.rawOptions.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.rawOptions.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(g.updateWindowsModeWrappedState.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},(function(){return(0,g.updateWindowsModeWrappedState)(e._bufferService),!1}))),this._windowsMode={dispose:function(){for(var e=0,r=t;e<r.length;e++)r[e].dispose()}}}},t}(o.Disposable);t.CoreTerminal=C},8460:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.forwardEvent=t.EventEmitter=void 0;var r=function(){function e(){this._listeners=[],this._disposed=!1}return Object.defineProperty(e.prototype,"event",{get:function(){var e=this;return this._event||(this._event=function(t){return e._listeners.push(t),{dispose:function(){if(!e._disposed)for(var r=0;r<e._listeners.length;r++)if(e._listeners[r]===t)return void e._listeners.splice(r,1)}}}),this._event},enumerable:!1,configurable:!0}),e.prototype.fire=function(e,t){for(var r=[],i=0;i<this._listeners.length;i++)r.push(this._listeners[i]);for(i=0;i<r.length;i++)r[i].call(void 0,e,t)},e.prototype.dispose=function(){this._listeners&&(this._listeners.length=0),this._disposed=!0},e}();t.EventEmitter=r,t.forwardEvent=function(e,t){return e((function(e){return t.fire(e)}))}},5435:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0;var o,s=r(2584),a=r(7116),c=r(2015),l=r(844),h=r(8273),u=r(482),f=r(8437),_=r(8460),d=r(643),p=r(511),v=r(3734),g=r(2585),y=r(6242),m=r(6351),S=r(5941),C={"(":0,")":1,"*":2,"+":3,"-":1,".":2},b=131072;function w(e,t){if(e>24)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 L=function(){function e(e,t,r,i){this._bufferService=e,this._coreService=t,this._logService=r,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,r){this._data=(0,h.concat)(this._data,e.subarray(t,r))},e.prototype.unhook=function(e){if(!e)return this._data=new Uint32Array(0),!0;var t=(0,u.utf32ToString)(this._data);switch(this._data=new Uint32Array(0),t){case'"q':this._coreService.triggerDataEvent(s.C0.ESC+'P1$r0"q'+s.C0.ESC+"\\");break;case'"p':this._coreService.triggerDataEvent(s.C0.ESC+'P1$r61;1"p'+s.C0.ESC+"\\");break;case"r":var r=this._bufferService.buffer.scrollTop+1+";"+(this._bufferService.buffer.scrollBottom+1)+"r";this._coreService.triggerDataEvent(s.C0.ESC+"P1$r"+r+s.C0.ESC+"\\");break;case"m":this._coreService.triggerDataEvent(s.C0.ESC+"P1$r0m"+s.C0.ESC+"\\");break;case" q":var i={block:2,underline:4,bar:6}[this._optionsService.rawOptions.cursorStyle];i-=this._optionsService.rawOptions.cursorBlink?1:0,this._coreService.triggerDataEvent(s.C0.ESC+"P1$r"+i+" q"+s.C0.ESC+"\\");break;default:this._logService.debug("Unknown DCS $q %s",t),this._coreService.triggerDataEvent(s.C0.ESC+"P0$r"+s.C0.ESC+"\\")}return!0},e}(),E=function(e){function t(t,r,i,n,o,l,h,d,v){void 0===v&&(v=new c.EscapeSequenceParser);var g=e.call(this)||this;g._bufferService=t,g._charsetService=r,g._coreService=i,g._dirtyRowService=n,g._logService=o,g._optionsService=l,g._coreMouseService=h,g._unicodeService=d,g._parser=v,g._parseBuffer=new Uint32Array(4096),g._stringDecoder=new u.StringToUtf32,g._utf8Decoder=new u.Utf8ToUtf32,g._workCell=new p.CellData,g._windowTitle="",g._iconName="",g._windowTitleStack=[],g._iconNameStack=[],g._curAttrData=f.DEFAULT_ATTR_DATA.clone(),g._eraseAttrDataInternal=f.DEFAULT_ATTR_DATA.clone(),g._onRequestBell=new _.EventEmitter,g._onRequestRefreshRows=new _.EventEmitter,g._onRequestReset=new _.EventEmitter,g._onRequestSendFocus=new _.EventEmitter,g._onRequestSyncScrollBar=new _.EventEmitter,g._onRequestWindowsOptionsReport=new _.EventEmitter,g._onA11yChar=new _.EventEmitter,g._onA11yTab=new _.EventEmitter,g._onCursorMove=new _.EventEmitter,g._onLineFeed=new _.EventEmitter,g._onScroll=new _.EventEmitter,g._onTitleChange=new _.EventEmitter,g._onColor=new _.EventEmitter,g._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},g._specialColors=[256,257,258],g.register(g._parser),g._activeBuffer=g._bufferService.buffer,g.register(g._bufferService.buffers.onBufferActivate((function(e){return g._activeBuffer=e.activeBuffer}))),g._parser.setCsiHandlerFallback((function(e,t){g._logService.debug("Unknown CSI code: ",{identifier:g._parser.identToString(e),params:t.toArray()})})),g._parser.setEscHandlerFallback((function(e){g._logService.debug("Unknown ESC code: ",{identifier:g._parser.identToString(e)})})),g._parser.setExecuteHandlerFallback((function(e){g._logService.debug("Unknown EXECUTE code: ",{code:e})})),g._parser.setOscHandlerFallback((function(e,t,r){g._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:r})})),g._parser.setDcsHandlerFallback((function(e,t,r){"HOOK"===t&&(r=r.toArray()),g._logService.debug("Unknown DCS code: ",{identifier:g._parser.identToString(e),action:t,payload:r})})),g._parser.setPrintHandler((function(e,t,r){return g.print(e,t,r)})),g._parser.registerCsiHandler({final:"@"},(function(e){return g.insertChars(e)})),g._parser.registerCsiHandler({intermediates:" ",final:"@"},(function(e){return g.scrollLeft(e)})),g._parser.registerCsiHandler({final:"A"},(function(e){return g.cursorUp(e)})),g._parser.registerCsiHandler({intermediates:" ",final:"A"},(function(e){return g.scrollRight(e)})),g._parser.registerCsiHandler({final:"B"},(function(e){return g.cursorDown(e)})),g._parser.registerCsiHandler({final:"C"},(function(e){return g.cursorForward(e)})),g._parser.registerCsiHandler({final:"D"},(function(e){return g.cursorBackward(e)})),g._parser.registerCsiHandler({final:"E"},(function(e){return g.cursorNextLine(e)})),g._parser.registerCsiHandler({final:"F"},(function(e){return g.cursorPrecedingLine(e)})),g._parser.registerCsiHandler({final:"G"},(function(e){return g.cursorCharAbsolute(e)})),g._parser.registerCsiHandler({final:"H"},(function(e){return g.cursorPosition(e)})),g._parser.registerCsiHandler({final:"I"},(function(e){return g.cursorForwardTab(e)})),g._parser.registerCsiHandler({final:"J"},(function(e){return g.eraseInDisplay(e)})),g._parser.registerCsiHandler({prefix:"?",final:"J"},(function(e){return g.eraseInDisplay(e)})),g._parser.registerCsiHandler({final:"K"},(function(e){return g.eraseInLine(e)})),g._parser.registerCsiHandler({prefix:"?",final:"K"},(function(e){return g.eraseInLine(e)})),g._parser.registerCsiHandler({final:"L"},(function(e){return g.insertLines(e)})),g._parser.registerCsiHandler({final:"M"},(function(e){return g.deleteLines(e)})),g._parser.registerCsiHandler({final:"P"},(function(e){return g.deleteChars(e)})),g._parser.registerCsiHandler({final:"S"},(function(e){return g.scrollUp(e)})),g._parser.registerCsiHandler({final:"T"},(function(e){return g.scrollDown(e)})),g._parser.registerCsiHandler({final:"X"},(function(e){return g.eraseChars(e)})),g._parser.registerCsiHandler({final:"Z"},(function(e){return g.cursorBackwardTab(e)})),g._parser.registerCsiHandler({final:"`"},(function(e){return g.charPosAbsolute(e)})),g._parser.registerCsiHandler({final:"a"},(function(e){return g.hPositionRelative(e)})),g._parser.registerCsiHandler({final:"b"},(function(e){return g.repeatPrecedingCharacter(e)})),g._parser.registerCsiHandler({final:"c"},(function(e){return g.sendDeviceAttributesPrimary(e)})),g._parser.registerCsiHandler({prefix:">",final:"c"},(function(e){return g.sendDeviceAttributesSecondary(e)})),g._parser.registerCsiHandler({final:"d"},(function(e){return g.linePosAbsolute(e)})),g._parser.registerCsiHandler({final:"e"},(function(e){return g.vPositionRelative(e)})),g._parser.registerCsiHandler({final:"f"},(function(e){return g.hVPosition(e)})),g._parser.registerCsiHandler({final:"g"},(function(e){return g.tabClear(e)})),g._parser.registerCsiHandler({final:"h"},(function(e){return g.setMode(e)})),g._parser.registerCsiHandler({prefix:"?",final:"h"},(function(e){return g.setModePrivate(e)})),g._parser.registerCsiHandler({final:"l"},(function(e){return g.resetMode(e)})),g._parser.registerCsiHandler({prefix:"?",final:"l"},(function(e){return g.resetModePrivate(e)})),g._parser.registerCsiHandler({final:"m"},(function(e){return g.charAttributes(e)})),g._parser.registerCsiHandler({final:"n"},(function(e){return g.deviceStatus(e)})),g._parser.registerCsiHandler({prefix:"?",final:"n"},(function(e){return g.deviceStatusPrivate(e)})),g._parser.registerCsiHandler({intermediates:"!",final:"p"},(function(e){return g.softReset(e)})),g._parser.registerCsiHandler({intermediates:" ",final:"q"},(function(e){return g.setCursorStyle(e)})),g._parser.registerCsiHandler({final:"r"},(function(e){return g.setScrollRegion(e)})),g._parser.registerCsiHandler({final:"s"},(function(e){return g.saveCursor(e)})),g._parser.registerCsiHandler({final:"t"},(function(e){return g.windowOptions(e)})),g._parser.registerCsiHandler({final:"u"},(function(e){return g.restoreCursor(e)})),g._parser.registerCsiHandler({intermediates:"'",final:"}"},(function(e){return g.insertColumns(e)})),g._parser.registerCsiHandler({intermediates:"'",final:"~"},(function(e){return g.deleteColumns(e)})),g._parser.setExecuteHandler(s.C0.BEL,(function(){return g.bell()})),g._parser.setExecuteHandler(s.C0.LF,(function(){return g.lineFeed()})),g._parser.setExecuteHandler(s.C0.VT,(function(){return g.lineFeed()})),g._parser.setExecuteHandler(s.C0.FF,(function(){return g.lineFeed()})),g._parser.setExecuteHandler(s.C0.CR,(function(){return g.carriageReturn()})),g._parser.setExecuteHandler(s.C0.BS,(function(){return g.backspace()})),g._parser.setExecuteHandler(s.C0.HT,(function(){return g.tab()})),g._parser.setExecuteHandler(s.C0.SO,(function(){return g.shiftOut()})),g._parser.setExecuteHandler(s.C0.SI,(function(){return g.shiftIn()})),g._parser.setExecuteHandler(s.C1.IND,(function(){return g.index()})),g._parser.setExecuteHandler(s.C1.NEL,(function(){return g.nextLine()})),g._parser.setExecuteHandler(s.C1.HTS,(function(){return g.tabSet()})),g._parser.registerOscHandler(0,new y.OscHandler((function(e){return g.setTitle(e),g.setIconName(e),!0}))),g._parser.registerOscHandler(1,new y.OscHandler((function(e){return g.setIconName(e)}))),g._parser.registerOscHandler(2,new y.OscHandler((function(e){return g.setTitle(e)}))),g._parser.registerOscHandler(4,new y.OscHandler((function(e){return g.setOrReportIndexedColor(e)}))),g._parser.registerOscHandler(10,new y.OscHandler((function(e){return g.setOrReportFgColor(e)}))),g._parser.registerOscHandler(11,new y.OscHandler((function(e){return g.setOrReportBgColor(e)}))),g._parser.registerOscHandler(12,new y.OscHandler((function(e){return g.setOrReportCursorColor(e)}))),g._parser.registerOscHandler(104,new y.OscHandler((function(e){return g.restoreIndexedColor(e)}))),g._parser.registerOscHandler(110,new y.OscHandler((function(e){return g.restoreFgColor(e)}))),g._parser.registerOscHandler(111,new y.OscHandler((function(e){return g.restoreBgColor(e)}))),g._parser.registerOscHandler(112,new y.OscHandler((function(e){return g.restoreCursorColor(e)}))),g._parser.registerEscHandler({final:"7"},(function(){return g.saveCursor()})),g._parser.registerEscHandler({final:"8"},(function(){return g.restoreCursor()})),g._parser.registerEscHandler({final:"D"},(function(){return g.index()})),g._parser.registerEscHandler({final:"E"},(function(){return g.nextLine()})),g._parser.registerEscHandler({final:"H"},(function(){return g.tabSet()})),g._parser.registerEscHandler({final:"M"},(function(){return g.reverseIndex()})),g._parser.registerEscHandler({final:"="},(function(){return g.keypadApplicationMode()})),g._parser.registerEscHandler({final:">"},(function(){return g.keypadNumericMode()})),g._parser.registerEscHandler({final:"c"},(function(){return g.fullReset()})),g._parser.registerEscHandler({final:"n"},(function(){return g.setgLevel(2)})),g._parser.registerEscHandler({final:"o"},(function(){return g.setgLevel(3)})),g._parser.registerEscHandler({final:"|"},(function(){return g.setgLevel(3)})),g._parser.registerEscHandler({final:"}"},(function(){return g.setgLevel(2)})),g._parser.registerEscHandler({final:"~"},(function(){return g.setgLevel(1)})),g._parser.registerEscHandler({intermediates:"%",final:"@"},(function(){return g.selectDefaultCharset()})),g._parser.registerEscHandler({intermediates:"%",final:"G"},(function(){return g.selectDefaultCharset()}));var m=function(e){S._parser.registerEscHandler({intermediates:"(",final:e},(function(){return g.selectCharset("("+e)})),S._parser.registerEscHandler({intermediates:")",final:e},(function(){return g.selectCharset(")"+e)})),S._parser.registerEscHandler({intermediates:"*",final:e},(function(){return g.selectCharset("*"+e)})),S._parser.registerEscHandler({intermediates:"+",final:e},(function(){return g.selectCharset("+"+e)})),S._parser.registerEscHandler({intermediates:"-",final:e},(function(){return g.selectCharset("-"+e)})),S._parser.registerEscHandler({intermediates:".",final:e},(function(){return g.selectCharset("."+e)})),S._parser.registerEscHandler({intermediates:"/",final:e},(function(){return g.selectCharset("/"+e)}))},S=this;for(var C in a.CHARSETS)m(C);return g._parser.registerEscHandler({intermediates:"#",final:"8"},(function(){return g.screenAlignmentPattern()})),g._parser.setErrorHandler((function(e){return g._logService.error("Parsing error: ",e),e})),g._parser.registerDcsHandler({intermediates:"$",final:"q"},new L(g._bufferService,g._coreService,g._logService,g._optionsService)),g}return n(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,"onRequestSendFocus",{get:function(){return this._onRequestSendFocus.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}),Object.defineProperty(t.prototype,"onColor",{get:function(){return this._onColor.event},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype._preserveStack=function(e,t,r,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=i},t.prototype._logSlowResolvingAsync=function(e){this._logService.logLevel<=g.LogLevelEnum.WARN&&Promise.race([e,new Promise((function(e,t){return setTimeout((function(){return t("#SLOW_TIMEOUT")}),5e3)}))]).catch((function(e){if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")}))},t.prototype.parse=function(e,t){var r,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,s=this._parseStack.paused;if(s){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>b&&(o=this._parseStack.position+b)}if(this._logService.logLevel<=g.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+("string"==typeof e?' "'+e+'"':' "'+Array.prototype.map.call(e,(function(e){return String.fromCharCode(e)})).join("")+'"'),"string"==typeof e?e.split("").map((function(e){return e.charCodeAt(0)})):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<b&&(this._parseBuffer=new Uint32Array(Math.min(e.length,b))),s||this._dirtyRowService.clearRange(),e.length>b)for(var a=o;a<e.length;a+=b){var c=a+b<e.length?a+b:e.length,l="string"==typeof e?this._stringDecoder.decode(e.substring(a,c),this._parseBuffer):this._utf8Decoder.decode(e.subarray(a,c),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,n,l,a),this._logSlowResolvingAsync(r),r}else if(!s&&(l="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer),r=this._parser.parse(this._parseBuffer,l)))return this._preserveStack(i,n,l,0),this._logSlowResolvingAsync(r),r;this._activeBuffer.x===i&&this._activeBuffer.y===n||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowService.start,this._dirtyRowService.end)},t.prototype.print=function(e,t,r){var i,n,o=this._charsetService.charset,s=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,h=this._curAttrData,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowService.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&2===f.getWidth(this._activeBuffer.x-1)&&f.setCellFromCodePoint(this._activeBuffer.x-1,0,1,h.fg,h.bg,h.extended);for(var _=t;_<r;++_){if(i=e[_],n=this._unicodeService.wcwidth(i),i<127&&o){var p=o[String.fromCharCode(i)];p&&(i=p.charCodeAt(0))}if(s&&this._onA11yChar.fire((0,u.stringFromCodePoint)(i)),n||!this._activeBuffer.x){if(this._activeBuffer.x+n-1>=a)if(c){for(;this._activeBuffer.x<a;)f.setCellFromCodePoint(this._activeBuffer.x++,0,1,h.fg,h.bg,h.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=a-1,2===n)continue;if(l&&(f.insertCells(this._activeBuffer.x,n,this._activeBuffer.getNullCell(h),h),2===f.getWidth(a-1)&&f.setCellFromCodePoint(a-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,h.fg,h.bg,h.extended)),f.setCellFromCodePoint(this._activeBuffer.x++,i,n,h.fg,h.bg,h.extended),n>0)for(;--n;)f.setCellFromCodePoint(this._activeBuffer.x++,0,0,h.fg,h.bg,h.extended)}else f.getWidth(this._activeBuffer.x-1)?f.addCodepointToCell(this._activeBuffer.x-1,i):f.addCodepointToCell(this._activeBuffer.x-2,i)}r-t>0&&(f.loadCell(this._activeBuffer.x-1,this._workCell),2===this._workCell.getWidth()||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<a&&r-t>0&&0===f.getWidth(this._activeBuffer.x)&&!f.hasContent(this._activeBuffer.x)&&f.setCellFromCodePoint(this._activeBuffer.x,0,1,h.fg,h.bg,h.extended),this._dirtyRowService.markDirty(this._activeBuffer.y)},t.prototype.registerCsiHandler=function(e,t){var r=this;return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,(function(e){return!w(e.params[0],r._optionsService.rawOptions.windowOptions)||t(e)}))},t.prototype.registerDcsHandler=function(e,t){return this._parser.registerDcsHandler(e,new m.DcsHandler(t))},t.prototype.registerEscHandler=function(e,t){return this._parser.registerEscHandler(e,t)},t.prototype.registerOscHandler=function(e,t){return this._parser.registerOscHandler(e,new y.OscHandler(t))},t.prototype.bell=function(){return this._onRequestBell.fire(),!0},t.prototype.lineFeed=function(){return this._dirtyRowService.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowService.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0},t.prototype.carriageReturn=function(){return this._activeBuffer.x=0,!0},t.prototype.backspace=function(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(null===(e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))||void 0===e?void 0:e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0},t.prototype.tab=function(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;var e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0},t.prototype.shiftOut=function(){return this._charsetService.setgLevel(1),!0},t.prototype.shiftIn=function(){return this._charsetService.setgLevel(0),!0},t.prototype._restrictCursor=function(e){void 0===e&&(e=this._bufferService.cols-1),this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowService.markDirty(this._activeBuffer.y)},t.prototype._setCursor=function(e,t){this._dirtyRowService.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowService.markDirty(this._activeBuffer.y)},t.prototype._moveCursor=function(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)},t.prototype.cursorUp=function(e){var t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0},t.prototype.cursorDown=function(e){var t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0},t.prototype.cursorForward=function(e){return this._moveCursor(e.params[0]||1,0),!0},t.prototype.cursorBackward=function(e){return this._moveCursor(-(e.params[0]||1),0),!0},t.prototype.cursorNextLine=function(e){return this.cursorDown(e),this._activeBuffer.x=0,!0},t.prototype.cursorPrecedingLine=function(e){return this.cursorUp(e),this._activeBuffer.x=0,!0},t.prototype.cursorCharAbsolute=function(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0},t.prototype.cursorPosition=function(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0},t.prototype.charPosAbsolute=function(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0},t.prototype.hPositionRelative=function(e){return this._moveCursor(e.params[0]||1,0),!0},t.prototype.linePosAbsolute=function(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0},t.prototype.vPositionRelative=function(e){return this._moveCursor(0,e.params[0]||1),!0},t.prototype.hVPosition=function(e){return this.cursorPosition(e),!0},t.prototype.tabClear=function(e){var t=e.params[0];return 0===t?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===t&&(this._activeBuffer.tabs={}),!0},t.prototype.cursorForwardTab=function(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;for(var t=e.params[0]||1;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0},t.prototype.cursorBackwardTab=function(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;for(var t=e.params[0]||1;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0},t.prototype._eraseInBufferLine=function(e,t,r,i){void 0===i&&(i=!1);var n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i&&(n.isWrapped=!1)},t.prototype._resetBufferLine=function(e){var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);t.fill(this._activeBuffer.getNullCell(this._eraseAttrData())),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),t.isWrapped=!1},t.prototype.eraseInDisplay=function(e){var t;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(t=this._activeBuffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x);t<this._bufferService.rows;t++)this._resetBufferLine(t);this._dirtyRowService.markDirty(t);break;case 1:for(t=this._activeBuffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t,0,this._activeBuffer.x+1,!0),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 2:for(t=this._bufferService.rows,this._dirtyRowService.markDirty(t-1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 3:var r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0))}return!0},t.prototype.eraseInLine=function(e){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0)}return this._dirtyRowService.markDirty(this._activeBuffer.y),!0},t.prototype.insertLines=function(e){this._restrictCursor();var t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;for(var r=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowService.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0},t.prototype.deleteLines=function(e){this._restrictCursor();var t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;var r,i=this._activeBuffer.ybase+this._activeBuffer.y;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowService.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0},t.prototype.insertChars=function(e){this._restrictCursor();var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowService.markDirty(this._activeBuffer.y)),!0},t.prototype.deleteChars=function(e){this._restrictCursor();var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowService.markDirty(this._activeBuffer.y)),!0},t.prototype.scrollUp=function(e){for(var t=e.params[0]||1;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0},t.prototype.scrollDown=function(e){for(var t=e.params[0]||1;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(f.DEFAULT_ATTR_DATA));return this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0},t.prototype.scrollLeft=function(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;for(var t=e.params[0]||1,r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){var i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i.isWrapped=!1}return this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0},t.prototype.scrollRight=function(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;for(var t=e.params[0]||1,r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){var i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i.isWrapped=!1}return this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0},t.prototype.insertColumns=function(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;for(var t=e.params[0]||1,r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){var i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i.isWrapped=!1}return this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0},t.prototype.deleteColumns=function(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;for(var t=e.params[0]||1,r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){var i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i.isWrapped=!1}return this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0},t.prototype.eraseChars=function(e){this._restrictCursor();var t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowService.markDirty(this._activeBuffer.y)),!0},t.prototype.repeatPrecedingCharacter=function(e){if(!this._parser.precedingCodepoint)return!0;for(var t=e.params[0]||1,r=new Uint32Array(t),i=0;i<t;++i)r[i]=this._parser.precedingCodepoint;return this.print(r,0,r.length),!0},t.prototype.sendDeviceAttributesPrimary=function(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(s.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(s.C0.ESC+"[?6c")),!0},t.prototype.sendDeviceAttributesSecondary=function(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(s.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(s.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(s.C0.ESC+"[>83;40003;0c")),!0},t.prototype._is=function(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)},t.prototype.setMode=function(e){for(var t=0;t<e.length;t++)4===e.params[t]&&(this._coreService.modes.insertMode=!0);return!0},t.prototype.setModePrivate=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,a.DEFAULT_CHARSET),this._charsetService.setgCharset(1,a.DEFAULT_CHARSET),this._charsetService.setgCharset(2,a.DEFAULT_CHARSET),this._charsetService.setgCharset(3,a.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0},t.prototype.resetMode=function(e){for(var t=0;t<e.length;t++)4===e.params[t]&&(this._coreService.modes.insertMode=!1);return!0},t.prototype.resetModePrivate=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[t]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0},t.prototype._updateAttrColor=function(e,t,r,i,n){return 2===t?(e|=50331648,e&=-16777216,e|=v.AttributeData.fromColorRGB([r,i,n])):5===t&&(e&=-50331904,e|=33554432|255&r),e},t.prototype._extractColor=function(e,t,r){var i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){var s=e.getSubParams(t+o),a=0;do{5===i[1]&&(n=1),i[o+a+1+n]=s[a]}while(++a<s.length&&a+o+1+n<i.length);break}if(5===i[1]&&o+n>=2||2===i[1]&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(a=2;a<i.length;++a)-1===i[a]&&(i[a]=0);switch(i[0]){case 38:r.fg=this._updateAttrColor(r.fg,i[1],i[3],i[4],i[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,i[1],i[3],i[4],i[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,i[1],i[3],i[4],i[5])}return o},t.prototype._processUnderline=function(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(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=f.DEFAULT_ATTR_DATA.fg,this._curAttrData.bg=f.DEFAULT_ATTR_DATA.bg,!0;for(var t,r=e.length,i=this._curAttrData,n=0;n<r;n++)(t=e.params[n])>=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=f.DEFAULT_ATTR_DATA.fg,i.bg=f.DEFAULT_ATTR_DATA.bg):1===t?i.fg|=134217728:3===t?i.bg|=67108864:4===t?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):5===t?i.fg|=536870912:7===t?i.fg|=67108864:8===t?i.fg|=1073741824:9===t?i.fg|=2147483648: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:29===t?i.fg&=2147483647:39===t?(i.fg&=-67108864,i.fg|=16777215&f.DEFAULT_ATTR_DATA.fg):49===t?(i.bg&=-67108864,i.bg|=16777215&f.DEFAULT_ATTR_DATA.bg):38===t||48===t||58===t?n+=this._extractColor(e,n,i):59===t?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):100===t?(i.fg&=-67108864,i.fg|=16777215&f.DEFAULT_ATTR_DATA.fg,i.bg&=-67108864,i.bg|=16777215&f.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",t);return!0},t.prototype.deviceStatus=function(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(s.C0.ESC+"[0n");break;case 6:var t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(s.C0.ESC+"["+t+";"+r+"R")}return!0},t.prototype.deviceStatusPrivate=function(e){if(6===e.params[0]){var t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(s.C0.ESC+"[?"+t+";"+r+"R")}return!0},t.prototype.softReset=function(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=f.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0},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"}var r=t%2==1;return this._optionsService.options.cursorBlink=r,!0},t.prototype.setScrollRegion=function(e){var t,r=e.params[0]||1;return(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=t-1,this._setCursor(0,0)),!0},t.prototype.windowOptions=function(e){if(!w(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;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(s.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())}return!0},t.prototype.saveCursor=function(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0},t.prototype.restoreCursor=function(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0},t.prototype.setTitle=function(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0},t.prototype.setIconName=function(e){return this._iconName=e,!0},t.prototype.setOrReportIndexedColor=function(e){for(var t=[],r=e.split(";");r.length>1;){var i=r.shift(),n=r.shift();if(/^\d+$/.exec(i)){var o=parseInt(i);if(0<=o&&o<256)if("?"===n)t.push({type:0,index:o});else{var s=(0,S.parseColor)(n);s&&t.push({type:1,index:o,color:s})}}}return t.length&&this._onColor.fire(t),!0},t.prototype._setOrReportSpecialColor=function(e,t){for(var r=e.split(";"),i=0;i<r.length&&!(t>=this._specialColors.length);++i,++t)if("?"===r[i])this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{var n=(0,S.parseColor)(r[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0},t.prototype.setOrReportFgColor=function(e){return this._setOrReportSpecialColor(e,0)},t.prototype.setOrReportBgColor=function(e){return this._setOrReportSpecialColor(e,1)},t.prototype.setOrReportCursorColor=function(e){return this._setOrReportSpecialColor(e,2)},t.prototype.restoreIndexedColor=function(e){if(!e)return this._onColor.fire([{type:2}]),!0;for(var t=[],r=e.split(";"),i=0;i<r.length;++i)if(/^\d+$/.exec(r[i])){var n=parseInt(r[i]);0<=n&&n<256&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0},t.prototype.restoreFgColor=function(e){return this._onColor.fire([{type:2,index:256}]),!0},t.prototype.restoreBgColor=function(e){return this._onColor.fire([{type:2,index:257}]),!0},t.prototype.restoreCursorColor=function(e){return this._onColor.fire([{type:2,index:258}]),!0},t.prototype.nextLine=function(){return this._activeBuffer.x=0,this.index(),!0},t.prototype.keypadApplicationMode=function(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0},t.prototype.keypadNumericMode=function(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0},t.prototype.selectDefaultCharset=function(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,a.DEFAULT_CHARSET),!0},t.prototype.selectCharset=function(e){return 2!==e.length?(this.selectDefaultCharset(),!0):("/"===e[0]||this._charsetService.setgCharset(C[e[0]],a.CHARSETS[e[1]]||a.DEFAULT_CHARSET),!0)},t.prototype.index=function(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0},t.prototype.tabSet=function(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0},t.prototype.reverseIndex=function(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){var e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowService.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0},t.prototype.fullReset=function(){return this._parser.reset(),this._onRequestReset.fire(),!0},t.prototype.reset=function(){this._curAttrData=f.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=f.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){return this._charsetService.setgLevel(e),!0},t.prototype.screenAlignmentPattern=function(){var e=new p.CellData;e.content=1<<22|"E".charCodeAt(0),e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(var t=0;t<this._bufferService.rows;++t){var r=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(r);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowService.markAllDirty(),this._setCursor(0,0),!0},t}(l.Disposable);t.InputHandler=E},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDisposeArrayDisposable=t.disposeArray=t.Disposable=void 0;var r=function(){function e(){this._disposables=[],this._isDisposed=!1}return e.prototype.dispose=function(){this._isDisposed=!0;for(var e=0,t=this._disposables;e<t.length;e++)t[e].dispose();this._disposables.length=0},e.prototype.register=function(e){return this._disposables.push(e),e},e.prototype.unregister=function(e){var t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)},e}();function i(e){for(var t=0,r=e;t<r.length;t++)r[t].dispose();e.length=0}t.Disposable=r,t.disposeArray=i,t.getDisposeArrayDisposable=function(e){return{dispose:function(){return i(e)}}}},6114:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.isSafari=t.isLegacyEdge=t.isFirefox=void 0;var r="undefined"==typeof navigator,i=r?"node":navigator.userAgent,n=r?"node":navigator.platform;t.isFirefox=i.includes("Firefox"),t.isLegacyEdge=i.includes("Edge"),t.isSafari=/^((?!chrome|android).)*safari/i.test(i),t.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(n),t.isIpad="iPad"===n,t.isIphone="iPhone"===n,t.isWindows=["Windows","Win16","Win32","WinCE"].includes(n),t.isLinux=n.indexOf("Linux")>=0},8273:(e,t)=>{function r(e,t,r,i){if(void 0===r&&(r=0),void 0===i&&(i=e.length),r>=e.length)return e;r=(e.length+r)%e.length,i=i>=e.length?e.length:(e.length+i)%e.length;for(var n=r;n<i;++n)e[n]=t;return e}Object.defineProperty(t,"__esModule",{value:!0}),t.concat=t.fillFallback=t.fill=void 0,t.fill=function(e,t,i,n){return e.fill?e.fill(t,i,n):r(e,t,i,n)},t.fillFallback=r,t.concat=function(e,t){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r}},9282:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=void 0;var i=r(643);t.updateWindowsModeWrappedState=function(e){var t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1),r=null==t?void 0:t.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&r&&(n.isWrapped=r[i.CHAR_DATA_CODE_INDEX]!==i.NULL_CELL_CODE&&r[i.CHAR_DATA_CODE_INDEX]!==i.WHITESPACE_CELL_CODE)}},3734:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;var r=function(){function e(){this.fg=0,this.bg=0,this.extended=new i}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.isStrikethrough=function(){return 2147483648&this.fg},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=r;var i=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=i},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferStringIterator=t.Buffer=t.MAX_BUFFER_SIZE=void 0;var i=r(6349),n=r(8437),o=r(511),s=r(643),a=r(4634),c=r(4863),l=r(7116),h=r(3734);t.MAX_BUFFER_SIZE=4294967295;var u=function(){function e(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.savedY=0,this.savedX=0,this.savedCurAttrData=n.DEFAULT_ATTR_DATA.clone(),this.savedCharset=l.DEFAULT_CHARSET,this.markers=[],this._nullCell=o.CellData.fromCharData([0,s.NULL_CELL_CHAR,s.NULL_CELL_WIDTH,s.NULL_CELL_CODE]),this._whitespaceCell=o.CellData.fromCharData([0,s.WHITESPACE_CELL_CHAR,s.WHITESPACE_CELL_WIDTH,s.WHITESPACE_CELL_CODE]),this._isClearing=!1,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 h.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 h.ExtendedAttrs),this._whitespaceCell},e.prototype.getBlankLine=function(e,t){return new n.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&&e<this._rows},enumerable:!1,configurable:!0}),e.prototype._getCorrectBufferLength=function(e){if(!this._hasScrollback)return e;var r=e+this._optionsService.rawOptions.scrollback;return r>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:r},e.prototype.fillViewportRows=function(e){if(0===this.lines.length){void 0===e&&(e=n.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 r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(var o=0;o<this.lines.length;o++)this.lines.get(o).resize(e,r);var s=0;if(this._rows<t)for(var a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode?this.lines.push(new n.BufferLine(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new n.BufferLine(e,r)));else for(a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){var c=this.lines.length-i;c>0&&(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),s&&(this.y+=s),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;o<this.lines.length;o++)this.lines.get(o).resize(e,r);this._cols=e,this._rows=t},Object.defineProperty(e.prototype,"_isReflowEnabled",{get:function(){return this._hasScrollback&&!this._optionsService.rawOptions.windowsMode},enumerable:!1,configurable:!0}),e.prototype._reflow=function(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))},e.prototype._reflowLarger=function(e,t){var r=(0,a.reflowLargerGetLinesToRemove)(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(n.DEFAULT_ATTR_DATA));if(r.length>0){var i=(0,a.reflowLargerCreateNewLayout)(this.lines,r);(0,a.reflowLargerApplyNewLayout)(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}},e.prototype._reflowLargerAdjustViewport=function(e,t,r){for(var i=this.getNullCell(n.DEFAULT_ATTR_DATA),o=r;o-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new n.BufferLine(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)},e.prototype._reflowSmaller=function(e,t){for(var r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=[],o=0,s=this.lines.length-1;s>=0;s--){var c=this.lines.get(s);if(!(!c||!c.isWrapped&&c.getTrimmedLength()<=e)){for(var l=[c];c.isWrapped&&s>0;)c=this.lines.get(--s),l.unshift(c);var h=this.ybase+this.y;if(!(h>=s&&h<s+l.length)){var u,f=l[l.length-1].getTrimmedLength(),_=(0,a.reflowSmallerGetNewLineLengths)(l,this._cols,e),d=_.length-l.length;u=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);for(var p=[],v=0;v<d;v++){var g=this.getBlankLine(n.DEFAULT_ATTR_DATA,!0);p.push(g)}p.length>0&&(i.push({start:s+l.length+o,newLines:p}),o+=p.length),l.push.apply(l,p);var y=_.length-1,m=_[y];0===m&&(m=_[--y]);for(var S=l.length-d-1,C=f;S>=0;){var b=Math.min(C,m);if(void 0===l[y])break;if(l[y].copyCellsFrom(l[S],C-b,m-b,b,!0),0==(m-=b)&&(m=_[--y]),0==(C-=b)){S--;var w=Math.max(S,0);C=(0,a.getWrappedLineTrimmedLength)(l,w,this._cols)}}for(v=0;v<l.length;v++)_[v]<e&&l[v].setCell(_[v],r);for(var L=d-u;L-- >0;)0===this.ybase?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}}}if(i.length>0){var E=[],x=[];for(v=0;v<this.lines.length;v++)x.push(this.lines.get(v));var k=this.lines.length,M=k-1,A=0,R=i[A];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);var O=0;for(v=Math.min(this.lines.maxLength-1,k+o-1);v>=0;v--)if(R&&R.start>M+O){for(var T=R.newLines.length-1;T>=0;T--)this.lines.set(v--,R.newLines[T]);v++,E.push({index:M+1,amount:R.newLines.length}),O+=R.newLines.length,R=i[++A]}else this.lines.set(v,x[M--]);var D=0;for(v=E.length-1;v>=0;v--)E[v].index+=D,this.lines.onInsertEmitter.fire(E[v]),D+=E[v].amount;var B=Math.max(0,k+o-this.lines.maxLength);B>0&&this.lines.onTrimEmitter.fire(B)}},e.prototype.stringIndexToBufferIndex=function(e,t,r){for(void 0===r&&(r=!1);t;){var i=this.lines.get(e);if(!i)return[-1,-1];for(var n=r?i.getTrimmedLength():i.length,o=0;o<n;++o)if(i.get(o)[s.CHAR_DATA_WIDTH_INDEX]&&(t-=i.get(o)[s.CHAR_DATA_CHAR_INDEX].length||1),t<0)return[e,o];e++}return[e,0]},e.prototype.translateBufferLineToString=function(e,t,r,i){void 0===r&&(r=0);var n=this.lines.get(e);return n?n.translateToString(t,r,i):""},e.prototype.getWrappedRangeForLine=function(e){for(var t=e,r=e;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}},e.prototype.setupTabStops=function(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0},e.prototype.prevStop=function(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);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;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.clearMarkers=function(e){if(this._isClearing=!0,void 0!==e)for(var t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));else{for(var r=0,i=this.markers;r<i.length;r++)i[r].dispose();this.markers=[]}this._isClearing=!1},e.prototype.addMarker=function(e){var t=this,r=new c.Marker(e);return this.markers.push(r),r.register(this.lines.onTrim((function(e){r.line-=e,r.line<0&&r.dispose()}))),r.register(this.lines.onInsert((function(e){r.line>=e.index&&(r.line+=e.amount)}))),r.register(this.lines.onDelete((function(e){r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)}))),r.register(r.onDispose((function(){return t._removeMarker(r)}))),r},e.prototype._removeMarker=function(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)},e.prototype.iterator=function(e,t,r,i,n){return new f(this,e,t,r,i,n)},e}();t.Buffer=u;var f=function(){function e(e,t,r,i,n,o){void 0===r&&(r=0),void 0===i&&(i=e.lines.length),void 0===n&&(n=0),void 0===o&&(o=0),this._buffer=e,this._trimRight=t,this._startIndex=r,this._endIndex=i,this._startOverscan=n,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._current<this._endIndex},e.prototype.next=function(){var e=this._buffer.getWrappedRangeForLine(this._current);e.first<this._startIndex-this._startOverscan&&(e.first=this._startIndex-this._startOverscan),e.last>this._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="",r=e.first;r<=e.last;++r)t+=this._buffer.translateBufferLineToString(r,this._trimRight);return this._current=e.last+1,{range:e,content:t}},e}();t.BufferStringIterator=f},8437:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;var i=r(482),n=r(643),o=r(511),s=r(3734);t.DEFAULT_ATTR_DATA=Object.freeze(new s.AttributeData);var a=function(){function e(e,t,r){void 0===r&&(r=!1),this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);for(var i=t||o.CellData.fromCharData([0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]),s=0;s<e;++s)this.setCell(s,i);this.length=e}return e.prototype.get=function(e){var t=this._data[3*e+0],r=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:r?(0,i.stringFromCodePoint)(r):"",t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):r]},e.prototype.set=function(e,t){this._data[3*e+1]=t[n.CHAR_DATA_ATTR_INDEX],t[n.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[n.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.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?(0,i.stringFromCodePoint)(2097151&t):""},e.prototype.loadCell=function(e,t){var r=3*e;return t.content=this._data[r+0],t.fg=this._data[r+1],t.bg=this._data[r+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,r,i,n,o){268435456&n&&(this._extendedAttrs[e]=o),this._data[3*e+0]=t|r<<22,this._data[3*e+1]=i,this._data[3*e+2]=n},e.prototype.addCodepointToCell=function(e,t){var r=this._data[3*e+0];2097152&r?this._combined[e]+=(0,i.stringFromCodePoint)(t):(2097151&r?(this._combined[e]=(0,i.stringFromCodePoint)(2097151&r)+(0,i.stringFromCodePoint)(t),r&=-2097152,r|=2097152):r=t|1<<22,this._data[3*e+0]=r)},e.prototype.insertCells=function(e,t,r,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 s.ExtendedAttrs),t<this.length-e){for(var n=new o.CellData,a=this.length-e-t-1;a>=0;--a)this.setCell(e+t+a,this.loadCell(e+a,n));for(a=0;a<t;++a)this.setCell(e+a,r)}else for(a=e;a<this.length;++a)this.setCell(a,r);2===this.getWidth(this.length-1)&&this.setCellFromCodePoint(this.length-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0,(null==i?void 0:i.extended)||new s.ExtendedAttrs)},e.prototype.deleteCells=function(e,t,r,i){if(e%=this.length,t<this.length-e){for(var n=new o.CellData,a=0;a<this.length-e-t;++a)this.setCell(e+a,this.loadCell(e+t+a,n));for(a=this.length-t;a<this.length;++a)this.setCell(a,r)}else for(a=e;a<this.length;++a)this.setCell(a,r);e&&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 s.ExtendedAttrs),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodePoint(e,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0,(null==i?void 0:i.extended)||new s.ExtendedAttrs)},e.prototype.replaceCells=function(e,t,r,i){for(e&&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 s.ExtendedAttrs),t<this.length&&2===this.getWidth(t-1)&&this.setCellFromCodePoint(t,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0,(null==i?void 0:i.extended)||new s.ExtendedAttrs);e<t&&e<this.length;)this.setCell(e++,r)},e.prototype.resize=function(e,t){if(e!==this.length){if(e>this.length){var r=new Uint32Array(3*e);this.length&&(3*e<this._data.length?r.set(this._data.subarray(0,3*e)):r.set(this._data)),this._data=r;for(var i=this.length;i<e;++i)this.setCell(i,t)}else if(e){(r=new Uint32Array(3*e)).set(this._data.subarray(0,3*e)),this._data=r;var n=Object.keys(this._combined);for(i=0;i<n.length;i++){var o=parseInt(n[i],10);o>=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<this.length;++t)this.setCell(t,e)},e.prototype.copyFrom=function(e){for(var t in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[t]=e._combined[t];for(var t in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped},e.prototype.clone=function(){var t=new e(0);for(var r in t._data=new Uint32Array(this._data),t.length=this.length,this._combined)t._combined[r]=this._combined[r];for(var r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t},e.prototype.getTrimmedLength=function(){for(var e=this.length-1;e>=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,r,i,n){var o=e._data;if(n)for(var s=i-1;s>=0;s--)for(var a=0;a<3;a++)this._data[3*(r+s)+a]=o[3*(t+s)+a];else for(s=0;s<i;s++)for(a=0;a<3;a++)this._data[3*(r+s)+a]=o[3*(t+s)+a];var c=Object.keys(e._combined);for(a=0;a<c.length;a++){var l=parseInt(c[a],10);l>=t&&(this._combined[l-t+r]=e._combined[l])}},e.prototype.translateToString=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=0),void 0===r&&(r=this.length),e&&(r=Math.min(r,this.getTrimmedLength()));for(var o="";t<r;){var s=this._data[3*t+0],a=2097151&s;o+=2097152&s?this._combined[t]:a?(0,i.stringFromCodePoint)(a):n.WHITESPACE_CELL_CHAR,t+=s>>22||1}return o},e}();t.BufferLine=a},4841:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRangeLength=void 0,t.getRangeLength=function(e,t){if(e.start.y>e.end.y)throw new Error("Buffer range end ("+e.end.x+", "+e.end.y+") cannot be before start ("+e.start.x+", "+e.start.y+")");return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}},4634:(e,t)=>{function r(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();var i=!e[t].hasContent(r-1)&&1===e[t].getWidth(r-1),n=2===e[t+1].getWidth(0);return i&&n?r-1:r}Object.defineProperty(t,"__esModule",{value:!0}),t.getWrappedLineTrimmedLength=t.reflowSmallerGetNewLineLengths=t.reflowLargerApplyNewLayout=t.reflowLargerCreateNewLayout=t.reflowLargerGetLinesToRemove=void 0,t.reflowLargerGetLinesToRemove=function(e,t,i,n,o){for(var s=[],a=0;a<e.length-1;a++){var c=a,l=e.get(++c);if(l.isWrapped){for(var h=[e.get(a)];c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(n>=a&&n<c)a+=h.length-1;else{for(var u=0,f=r(h,u,t),_=1,d=0;_<h.length;){var p=r(h,_,t),v=p-d,g=i-f,y=Math.min(v,g);h[u].copyCellsFrom(h[_],d,f,y,!1),(f+=y)===i&&(u++,f=0),(d+=y)===p&&(_++,d=0),0===f&&0!==u&&2===h[u-1].getWidth(i-1)&&(h[u].copyCellsFrom(h[u-1],i-1,f++,1,!1),h[u-1].setCell(i-1,o))}h[u].replaceCells(f,i,o);for(var m=0,S=h.length-1;S>0&&(S>u||0===h[S].getTrimmedLength());S--)m++;m>0&&(s.push(a+h.length-m),s.push(m)),a+=h.length-1}}}return s},t.reflowLargerCreateNewLayout=function(e,t){for(var r=[],i=0,n=t[i],o=0,s=0;s<e.length;s++)if(n===s){var a=t[++i];e.onDeleteEmitter.fire({index:s-o,amount:a}),s+=a-1,o+=a,n=t[++i]}else r.push(s);return{layout:r,countRemoved:o}},t.reflowLargerApplyNewLayout=function(e,t){for(var r=[],i=0;i<t.length;i++)r.push(e.get(t[i]));for(i=0;i<r.length;i++)e.set(i,r[i]);e.length=t.length},t.reflowSmallerGetNewLineLengths=function(e,t,i){for(var n=[],o=e.map((function(i,n){return r(e,n,t)})).reduce((function(e,t){return e+t})),s=0,a=0,c=0;c<o;){if(o-c<i){n.push(o-c);break}s+=i;var l=r(e,a,t);s>l&&(s-=l,a++);var h=2===e[a].getWidth(s-1);h&&s--;var u=h?i-1:i;n.push(u),c+=u}return n},t.getWrappedLineTrimmedLength=r},5295:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;var o=r(9092),s=r(8460),a=function(e){function t(t,r){var i=e.call(this)||this;return i._optionsService=t,i._bufferService=r,i._onBufferActivate=i.register(new s.EventEmitter),i.reset(),i}return n(t,e),Object.defineProperty(t.prototype,"onBufferActivate",{get:function(){return this._onBufferActivate.event},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this._normal=new o.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new o.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()},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}(r(844).Disposable);t.BufferSet=a},511:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;var o=r(482),s=r(643),a=r(3734),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.content=0,t.fg=0,t.bg=0,t.extended=new a.ExtendedAttrs,t.combinedData="",t}return n(t,e),t.fromCharData=function(e){var r=new t;return r.setFromCharData(e),r},t.prototype.isCombined=function(){return 2097152&this.content},t.prototype.getWidth=function(){return this.content>>22},t.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,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[s.CHAR_DATA_ATTR_INDEX],this.bg=0;var t=!1;if(e[s.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(2===e[s.CHAR_DATA_CHAR_INDEX].length){var r=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=r&&r<=56319){var i=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(r-55296)+i-56320+65536|e[s.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[s.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[s.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[s.CHAR_DATA_WIDTH_INDEX]<<22)},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(a.AttributeData);t.CellData=c},643:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=256,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},4863:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;var o=r(8460),s=function(e){function t(r){var i=e.call(this)||this;return i.line=r,i._id=t._nextId++,i.isDisposed=!1,i._onDispose=new o.EventEmitter,i}return n(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(),e.prototype.dispose.call(this))},t._nextId=1,t}(r(844).Disposable);t.Marker=s},7116:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},t.CHARSETS.A={"#":"£"},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},t.CHARSETS.C=t.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},t.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},t.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},t.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},t.CHARSETS.E=t.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},t.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},t.CHARSETS.H=t.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(e,t)=>{var r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.C1=t.C0=void 0,(i=t.C0||(t.C0={})).NUL="\0",i.SOH="",i.STX="",i.ETX="",i.EOT="",i.ENQ="",i.ACK="",i.BEL="",i.BS="\b",i.HT="\t",i.LF="\n",i.VT="\v",i.FF="\f",i.CR="\r",i.SO="",i.SI="",i.DLE="",i.DC1="",i.DC2="",i.DC3="",i.DC4="",i.NAK="",i.SYN="",i.ETB="",i.CAN="",i.EM="",i.SUB="",i.ESC="",i.FS="",i.GS="",i.RS="",i.US="",i.SP=" ",i.DEL="",(r=t.C1||(t.C1={})).PAD="€",r.HOP="",r.BPH="‚",r.NBH="ƒ",r.IND="„",r.NEL="…",r.SSA="†",r.ESA="‡",r.HTS="ˆ",r.HTJ="‰",r.VTS="Š",r.PLD="‹",r.PLU="Œ",r.RI="",r.SS2="Ž",r.SS3="",r.DCS="",r.PU1="‘",r.PU2="’",r.STS="“",r.CCH="”",r.MW="•",r.SPA="–",r.EPA="—",r.SOS="˜",r.SGCI="™",r.SCI="š",r.CSI="›",r.ST="œ",r.OSC="",r.PM="ž",r.APC="Ÿ"},7399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateKeyboardEvent=void 0;var i=r(2584),n={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};t.evaluateKeyboardEvent=function(e,t,r,o){var s={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?s.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A":"UIKeyInputLeftArrow"===e.key?s.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D":"UIKeyInputRightArrow"===e.key?s.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(s.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B");break;case 8:if(e.shiftKey){s.key=i.C0.BS;break}if(e.altKey){s.key=i.C0.ESC+i.C0.DEL;break}s.key=i.C0.DEL;break;case 9:if(e.shiftKey){s.key=i.C0.ESC+"[Z";break}s.key=i.C0.HT,s.cancel=!0;break;case 13:s.key=e.altKey?i.C0.ESC+i.C0.CR:i.C0.CR,s.cancel=!0;break;case 27:s.key=i.C0.ESC,e.altKey&&(s.key=i.C0.ESC+i.C0.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"D",s.key===i.C0.ESC+"[1;3D"&&(s.key=i.C0.ESC+(r?"b":"[1;5D"))):s.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D";break;case 39:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"C",s.key===i.C0.ESC+"[1;3C"&&(s.key=i.C0.ESC+(r?"f":"[1;5C"))):s.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C";break;case 38:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"A",r||s.key!==i.C0.ESC+"[1;3A"||(s.key=i.C0.ESC+"[1;5A")):s.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A";break;case 40:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"B",r||s.key!==i.C0.ESC+"[1;3B"||(s.key=i.C0.ESC+"[1;5B")):s.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(s.key=i.C0.ESC+"[2~");break;case 46:s.key=a?i.C0.ESC+"[3;"+(a+1)+"~":i.C0.ESC+"[3~";break;case 36:s.key=a?i.C0.ESC+"[1;"+(a+1)+"H":t?i.C0.ESC+"OH":i.C0.ESC+"[H";break;case 35:s.key=a?i.C0.ESC+"[1;"+(a+1)+"F":t?i.C0.ESC+"OF":i.C0.ESC+"[F";break;case 33:e.shiftKey?s.type=2:s.key=i.C0.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:s.key=i.C0.ESC+"[6~";break;case 112:s.key=a?i.C0.ESC+"[1;"+(a+1)+"P":i.C0.ESC+"OP";break;case 113:s.key=a?i.C0.ESC+"[1;"+(a+1)+"Q":i.C0.ESC+"OQ";break;case 114:s.key=a?i.C0.ESC+"[1;"+(a+1)+"R":i.C0.ESC+"OR";break;case 115:s.key=a?i.C0.ESC+"[1;"+(a+1)+"S":i.C0.ESC+"OS";break;case 116:s.key=a?i.C0.ESC+"[15;"+(a+1)+"~":i.C0.ESC+"[15~";break;case 117:s.key=a?i.C0.ESC+"[17;"+(a+1)+"~":i.C0.ESC+"[17~";break;case 118:s.key=a?i.C0.ESC+"[18;"+(a+1)+"~":i.C0.ESC+"[18~";break;case 119:s.key=a?i.C0.ESC+"[19;"+(a+1)+"~":i.C0.ESC+"[19~";break;case 120:s.key=a?i.C0.ESC+"[20;"+(a+1)+"~":i.C0.ESC+"[20~";break;case 121:s.key=a?i.C0.ESC+"[21;"+(a+1)+"~":i.C0.ESC+"[21~";break;case 122:s.key=a?i.C0.ESC+"[23;"+(a+1)+"~":i.C0.ESC+"[23~";break;case 123:s.key=a?i.C0.ESC+"[24;"+(a+1)+"~":i.C0.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(r&&!o||!e.altKey||e.metaKey)!r||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?s.key=e.key:e.key&&e.ctrlKey&&"_"===e.key&&(s.key=i.C0.US):65===e.keyCode&&(s.type=1);else{var c=n[e.keyCode],l=null==c?void 0:c[e.shiftKey?1:0];if(l)s.key=i.C0.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){var h=e.ctrlKey?e.keyCode-64:e.keyCode+32;s.key=i.C0.ESC+String.fromCharCode(h)}}else e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?s.key=i.C0.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?s.key=i.C0.DEL:219===e.keyCode?s.key=i.C0.ESC:220===e.keyCode?s.key=i.C0.FS:221===e.keyCode&&(s.key=i.C0.GS)}return s}},482:(e,t)=>{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,r){void 0===t&&(t=0),void 0===r&&(r=e.length);for(var i="",n=t;n<r;++n){var o=e[n];o>65535?(o-=65536,i+=String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i};var r=function(){function e(){this._interim=0}return e.prototype.clear=function(){this._interim=0},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i=0,n=0;this._interim&&(56320<=(a=e.charCodeAt(n++))&&a<=57343?t[i++]=1024*(this._interim-55296)+a-56320+65536:(t[i++]=this._interim,t[i++]=a),this._interim=0);for(var o=n;o<r;++o){var s=e.charCodeAt(o);if(55296<=s&&s<=56319){if(++o>=r)return this._interim=s,i;var a;56320<=(a=e.charCodeAt(o))&&a<=57343?t[i++]=1024*(s-55296)+a-56320+65536:(t[i++]=s,t[i++]=a)}else 65279!==s&&(t[i++]=s)}return i},e}();t.StringToUtf32=r;var i=function(){function e(){this.interim=new Uint8Array(3)}return e.prototype.clear=function(){this.interim.fill(0)},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i,n,o,s,a=0,c=0,l=0;if(this.interim[0]){var h=!1,u=this.interim[0];u&=192==(224&u)?31:224==(240&u)?15:7;for(var f=0,_=void 0;(_=63&this.interim[++f])&&f<4;)u<<=6,u|=_;for(var d=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,p=d-f;l<p;){if(l>=r)return 0;if(128!=(192&(_=e[l++]))){l--,h=!0;break}this.interim[f++]=_,u<<=6,u|=63&_}h||(2===d?u<128?l--:t[a++]=u:3===d?u<2048||u>=55296&&u<=57343||65279===u||(t[a++]=u):u<65536||u>1114111||(t[a++]=u)),this.interim.fill(0)}for(var v=r-4,g=l;g<r;){for(;!(!(g<v)||128&(i=e[g])||128&(n=e[g+1])||128&(o=e[g+2])||128&(s=e[g+3]));)t[a++]=i,t[a++]=n,t[a++]=o,t[a++]=s,g+=4;if((i=e[g++])<128)t[a++]=i;else if(192==(224&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if((c=(31&i)<<6|63&n)<128){g--;continue}t[a++]=c}else if(224==(240&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(o=e[g++]))){g--;continue}if((c=(15&i)<<12|(63&n)<<6|63&o)<2048||c>=55296&&c<=57343||65279===c)continue;t[a++]=c}else if(240==(248&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(o=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,this.interim[2]=o,a;if(128!=(192&(s=e[g++]))){g--;continue}if((c=(7&i)<<18|(63&n)<<12|(63&o)<<6|63&s)<65536||c>1114111)continue;t[a++]=c}}return a},e}();t.Utf8ToUtf32=i},225:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;var i,n=r(8273),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]],s=[[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]],a=function(){function e(){if(this.version="6",!i){i=new Uint8Array(65536),(0,n.fill)(i,1),i[0]=0,(0,n.fill)(i,0,1,32),(0,n.fill)(i,0,127,160),(0,n.fill)(i,2,4352,4448),i[9001]=2,i[9002]=2,(0,n.fill)(i,2,11904,42192),i[12351]=1,(0,n.fill)(i,2,44032,55204),(0,n.fill)(i,2,63744,64256),(0,n.fill)(i,2,65040,65050),(0,n.fill)(i,2,65072,65136),(0,n.fill)(i,2,65280,65377),(0,n.fill)(i,2,65504,65511);for(var e=0;e<o.length;++e)(0,n.fill)(i,0,o[e][0],o[e][1]+1)}}return e.prototype.wcwidth=function(e){return e<32?0:e<127?1:e<65536?i[e]:function(e,t){var r,i=0,n=t.length-1;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=i;)if(e>t[r=i+n>>1][1])i=r+1;else{if(!(e<t[r][0]))return!0;n=r-1}return!1}(e,s)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1},e}();t.UnicodeV6=a},5981:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;var r="undefined"==typeof queueMicrotask?function(e){Promise.resolve().then(e)}:queueMicrotask,i=function(){function e(e){this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0}return e.prototype.writeSync=function(e,t){if(void 0!==t&&this._syncCalls>t)this._syncCalls=0;else if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){var r;for(this._isSyncWriting=!0;r=this._writeBuffer.shift();){this._action(r);var i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}},e.prototype.write=function(e,t){var r=this;if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");this._writeBuffer.length||(this._bufferOffset=0,setTimeout((function(){return r._innerWrite()}))),this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)},e.prototype._innerWrite=function(e,t){var i=this;void 0===e&&(e=0),void 0===t&&(t=!0);for(var n=e||Date.now();this._writeBuffer.length>this._bufferOffset;){var o=this._writeBuffer[this._bufferOffset],s=this._action(o,t);if(s)return void s.catch((function(e){return r((function(){throw e})),Promise.resolve(!1)})).then((function(e){return Date.now()-n>=12?setTimeout((function(){return i._innerWrite(0,e)})):i._innerWrite(n,e)}));var a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=o.length,Date.now()-n>=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 i._innerWrite()}))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0)},e}();t.WriteBuffer=i},5941:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toRgbString=t.parseColor=void 0;var r=/^([\da-f]{1})\/([\da-f]{1})\/([\da-f]{1})$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,i=/^[\da-f]+$/;function n(e,t){var r=e.toString(16),i=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}t.parseColor=function(e){if(e){var t=e.toLowerCase();if(0===t.indexOf("rgb:")){t=t.slice(4);var n=r.exec(t);if(n){var o=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/o*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/o*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/o*255)]}}else if(0===t.indexOf("#")&&(t=t.slice(1),i.exec(t)&&[3,6,9,12].includes(t.length))){for(var s=t.length/3,a=[0,0,0],c=0;c<3;++c){var l=parseInt(t.slice(s*c,s*c+s),16);a[c]=1===s?l<<4:2===s?l:3===s?l>>4:l>>8}return a}}},t.toRgbString=function(e,t){void 0===t&&(t=16);var r=e[0],i=e[1],o=e[2];return"rgb:"+n(r,t)+"/"+n(i,t)+"/"+n(o,t)}},5770:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},6351:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;var i=r(482),n=r(8742),o=r(5770),s=[],a=function(){function e(){this._handlers=Object.create(null),this._active=s,this._ident=0,this._handlerFb=function(){},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}return e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){},this._active=s},e.prototype.registerHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.reset=function(){if(this._active.length)for(var e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=s,this._ident=0},e.prototype.hook=function(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||s,this._active.length)for(var r=this._active.length-1;r>=0;r--)this._active[r].hook(t);else this._handlerFb(this._ident,"HOOK",t)},e.prototype.put=function(e,t,r){if(this._active.length)for(var n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r);else this._handlerFb(this._ident,"PUT",(0,i.utf32ToString)(e,t,r))},e.prototype.unhook=function(e,t){if(void 0===t&&(t=!0),this._active.length){var r=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;i>=0&&!0!==(r=this._active[i].unhook(e));i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if((r=this._active[i].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}else this._handlerFb(this._ident,"UNHOOK",e);this._active=s,this._ident=0},e}();t.DcsParser=a;var c=new n.Params;c.addParam(0);var l=function(){function e(e){this._handler=e,this._data="",this._params=c,this._hitLimit=!1}return e.prototype.hook=function(e){this._params=e.length>1||e.params[0]?e.clone():c,this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=(0,i.utf32ToString)(e,t,r),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.unhook=function(e){var t=this,r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data,this._params))instanceof Promise)return r.then((function(e){return t._params=c,t._data="",t._hitLimit=!1,e}));return this._params=c,this._data="",this._hitLimit=!1,r},e}();t.DcsHandler=l},2015:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;var o=r(844),s=r(8273),a=r(8742),c=r(6242),l=r(6351),h=function(){function e(e){this.table=new Uint8Array(e)}return e.prototype.setDefault=function(e,t){(0,s.fill)(this.table,e<<4|t)},e.prototype.add=function(e,t,r,i){this.table[t<<8|e]=r<<4|i},e.prototype.addMany=function(e,t,r,i){for(var n=0;n<e.length;n++)this.table[t<<8|e[n]]=r<<4|i},e}();t.TransitionTable=h;var u=160;t.VT500_TRANSITION_TABLE=function(){var e=new h(4095),t=Array.apply(null,Array(256)).map((function(e,t){return t})),r=function(e,r){return t.slice(e,r)},i=r(32,127),n=r(0,24);n.push(25),n.push.apply(n,r(28,32));var o,s=r(0,14);for(o in e.setDefault(1,0),e.addMany(i,0,2,0),s)e.addMany([24,26,153,154],o,3,0),e.addMany(r(128,144),o,3,0),e.addMany(r(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(u,0,2,0),e.add(u,8,5,8),e.add(u,6,0,6),e.add(u,11,0,11),e.add(u,13,13,13),e}();var f=function(e){function r(r){void 0===r&&(r=t.VT500_TRANSITION_TABLE);var i=e.call(this)||this;return i._transitions=r,i._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},i.initialState=0,i.currentState=i.initialState,i._params=new a.Params,i._params.addParam(0),i._collect=0,i.precedingCodepoint=0,i._printHandlerFb=function(e,t,r){},i._executeHandlerFb=function(e){},i._csiHandlerFb=function(e,t){},i._escHandlerFb=function(e){},i._errorHandlerFb=function(e){return e},i._printHandler=i._printHandlerFb,i._executeHandlers=Object.create(null),i._csiHandlers=Object.create(null),i._escHandlers=Object.create(null),i._oscParser=new c.OscParser,i._dcsParser=new l.DcsParser,i._errorHandler=i._errorHandlerFb,i.registerEscHandler({final:"\\"},(function(){return!0})),i}return n(r,e),r.prototype._identifier=function(e,t){void 0===t&&(t=[64,126]);var r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if((r=e.prefix.charCodeAt(0))&&60>r||r>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;i<e.intermediates.length;++i){var n=e.intermediates.charCodeAt(i);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=n}}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(r<<=8)|o},r.prototype.identToString=function(e){for(var t=[];e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")},r.prototype.dispose=function(){this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null),this._oscParser.dispose(),this._dcsParser.dispose()},r.prototype.setPrintHandler=function(e){this._printHandler=e},r.prototype.clearPrintHandler=function(){this._printHandler=this._printHandlerFb},r.prototype.registerEscHandler=function(e,t){var r=this._identifier(e,[48,126]);void 0===this._escHandlers[r]&&(this._escHandlers[r]=[]);var i=this._escHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.clearEscHandler=function(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]},r.prototype.setEscHandlerFallback=function(e){this._escHandlerFb=e},r.prototype.setExecuteHandler=function(e,t){this._executeHandlers[e.charCodeAt(0)]=t},r.prototype.clearExecuteHandler=function(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]},r.prototype.setExecuteHandlerFallback=function(e){this._executeHandlerFb=e},r.prototype.registerCsiHandler=function(e,t){var r=this._identifier(e);void 0===this._csiHandlers[r]&&(this._csiHandlers[r]=[]);var i=this._csiHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.clearCsiHandler=function(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]},r.prototype.setCsiHandlerFallback=function(e){this._csiHandlerFb=e},r.prototype.registerDcsHandler=function(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)},r.prototype.clearDcsHandler=function(e){this._dcsParser.clearHandler(this._identifier(e))},r.prototype.setDcsHandlerFallback=function(e){this._dcsParser.setHandlerFallback(e)},r.prototype.registerOscHandler=function(e,t){return this._oscParser.registerHandler(e,t)},r.prototype.clearOscHandler=function(e){this._oscParser.clearHandler(e)},r.prototype.setOscHandlerFallback=function(e){this._oscParser.setHandlerFallback(e)},r.prototype.setErrorHandler=function(e){this._errorHandler=e},r.prototype.clearErrorHandler=function(){this._errorHandler=this._errorHandlerFb},r.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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])},r.prototype._preserveStack=function(e,t,r,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=i,this._parseStack.chunkPos=n},r.prototype.parse=function(e,t,r){var i,n=0,o=0,s=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,s=this._parseStack.chunkPos+1;else{if(void 0===r||1===this._parseStack.state)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");var a=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===r&&c>-1)for(;c>=0&&!0!==(i=a[c](this._params));c--)if(i instanceof Promise)return this._parseStack.handlerPos=c,i;this._parseStack.handlers=[];break;case 4:if(!1===r&&c>-1)for(;c>=0&&!0!==(i=a[c]());c--)if(i instanceof Promise)return this._parseStack.handlerPos=c,i;this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],i=this._dcsParser.unhook(24!==n&&26!==n,r))return i;27===n&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],i=this._oscParser.end(24!==n&&26!==n,r))return i;27===n&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,s=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(var l=s;l<t;++l){switch(n=e[l],(o=this._transitions.table[this.currentState<<8|(n<160?n:u)])>>4){case 2:for(var h=l+1;;++h){if(h>=t||(n=e[h])<32||n>126&&n<u){this._printHandler(e,l,h),l=h-1;break}if(++h>=t||(n=e[h])<32||n>126&&n<u){this._printHandler(e,l,h),l=h-1;break}if(++h>=t||(n=e[h])<32||n>126&&n<u){this._printHandler(e,l,h),l=h-1;break}if(++h>=t||(n=e[h])<32||n>126&&n<u){this._printHandler(e,l,h),l=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:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:for(var f=(a=this._csiHandlers[this._collect<<8|n])?a.length-1:-1;f>=0&&!0!==(i=a[f](this._params));f--)if(i instanceof Promise)return this._preserveStack(3,a,f,o,l),i;f<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingCodepoint=0;break;case 8:do{switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}}while(++l<t&&(n=e[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:for(var _=this._escHandlers[this._collect<<8|n],d=_?_.length-1:-1;d>=0&&!0!==(i=_[d]());d--)if(i instanceof Promise)return this._preserveStack(4,_,d,o,l),i;d<0&&this._escHandlerFb(this._collect<<8|n),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(var p=l+1;;++p)if(p>=t||24===(n=e[p])||26===n||27===n||n>127&&n<u){this._dcsParser.put(e,l,p),l=p-1;break}break;case 14:if(i=this._dcsParser.unhook(24!==n&&26!==n))return this._preserveStack(6,[],0,o,l),i;27===n&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(var v=l+1;;v++)if(v>=t||(n=e[v])<32||n>127&&n<u){this._oscParser.put(e,l,v),l=v-1;break}break;case 6:if(i=this._oscParser.end(24!==n&&26!==n))return this._preserveStack(5,[],0,o,l),i;27===n&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&o}},r}(o.Disposable);t.EscapeSequenceParser=f},6242:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;var i=r(5770),n=r(482),o=[],s=function(){function e(){this._state=0,this._active=o,this._id=-1,this._handlers=Object.create(null),this._handlerFb=function(){},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}return e.prototype.registerHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},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(){},this._active=o},e.prototype.reset=function(){if(2===this._state)for(var e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=o,this._id=-1,this._state=0},e.prototype._start=function(){if(this._active=this._handlers[this._id]||o,this._active.length)for(var e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")},e.prototype._put=function(e,t,r){if(this._active.length)for(var i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,r);else this._handlerFb(this._id,"PUT",(0,n.utf32ToString)(e,t,r))},e.prototype.start=function(){this.reset(),this._state=1},e.prototype.put=function(e,t,r){if(3!==this._state){if(1===this._state)for(;t<r;){var i=e[t++];if(59===i){this._state=2,this._start();break}if(i<48||57<i)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+i-48}2===this._state&&r-t>0&&this._put(e,t,r)}},e.prototype.end=function(e,t){if(void 0===t&&(t=!0),0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){var r=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===r){for(;i>=0&&!0!==(r=this._active[i].end(e));i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if((r=this._active[i].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}else this._handlerFb(this._id,"END",e);this._active=o,this._id=-1,this._state=0}},e}();t.OscParser=s;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,r){this._hitLimit||(this._data+=(0,n.utf32ToString)(e,t,r),this._data.length>i.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.end=function(e){var t=this,r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data))instanceof Promise)return r.then((function(e){return t._data="",t._hitLimit=!1,e}));return this._data="",this._hitLimit=!1,r},e}();t.OscHandler=a},8742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;var r=2147483647,i=function(){function e(e,t){if(void 0===e&&(e=32),void 0===t&&(t=32),this.maxLength=e,this.maxSubParamsLength=t,t>256)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 r=new e;if(!t.length)return r;for(var i=Array.isArray(t[0])?1:0;i<t.length;++i){var n=t[i];if(Array.isArray(n))for(var o=0;o<n.length;++o)r.addSubParam(n[o]);else r.addParam(n)}return r},e.prototype.clone=function(){var t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t},e.prototype.toArray=function(){for(var e=[],t=0;t<this.length;++t){e.push(this.params[t]);var r=this._subParamsIdx[t]>>8,i=255&this._subParamsIdx[t];i-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,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>r?r: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>r?r: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,r=255&this._subParamsIdx[e];return r-t>0?this._subParams.subarray(t,r):null},e.prototype.getSubParamsAll=function(){for(var e={},t=0;t<this.length;++t){var r=this._subParamsIdx[t]>>8,i=255&this._subParamsIdx[t];i-r>0&&(e[t]=this._subParams.slice(r,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 i=this._digitIsSub?this._subParams:this.params,n=i[t-1];i[t-1]=~n?Math.min(10*n+e,r):e}},e}();t.Params=i},5741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0;var r=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 r=this,i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=function(){return r._wrappedAddonDispose(i)},t.activate(e)},e.prototype._wrappedAddonDispose=function(e){if(!e.isDisposed){for(var t=-1,r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;break}if(-1===t)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},e}();t.AddonManager=r},8771:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;var i=r(3785),n=r(511),o=function(){function e(e,t){this._buffer=e,this.type=t}return e.prototype.init=function(e){return this._buffer=e,this},Object.defineProperty(e.prototype,"cursorY",{get:function(){return this._buffer.y},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cursorX",{get:function(){return this._buffer.x},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewportY",{get:function(){return this._buffer.ydisp},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseY",{get:function(){return this._buffer.ybase},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._buffer.lines.length},enumerable:!1,configurable:!0}),e.prototype.getLine=function(e){var t=this._buffer.lines.get(e);if(t)return new i.BufferLineApiView(t)},e.prototype.getNullCell=function(){return new n.CellData},e}();t.BufferApiView=o},3785:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;var i=r(511),n=function(){function e(e){this._line=e}return Object.defineProperty(e.prototype,"isWrapped",{get:function(){return this._line.isWrapped},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._line.length},enumerable:!1,configurable:!0}),e.prototype.getCell=function(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new i.CellData)},e.prototype.translateToString=function(e,t,r){return this._line.translateToString(e,t,r)},e}();t.BufferLineApiView=n},8285:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;var i=r(8771),n=r(8460),o=function(){function e(e){var t=this;this._core=e,this._onBufferChange=new n.EventEmitter,this._normal=new i.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new i.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((function(){return t._onBufferChange.fire(t.active)}))}return Object.defineProperty(e.prototype,"onBufferChange",{get:function(){return this._onBufferChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"active",{get:function(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal.init(this._core.buffers.normal)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alternate",{get:function(){return this._alternate.init(this._core.buffers.alt)},enumerable:!1,configurable:!0}),e}();t.BufferNamespaceApi=o},7975:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0;var r=function(){function e(e){this._core=e}return e.prototype.registerCsiHandler=function(e,t){return this._core.registerCsiHandler(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.registerDcsHandler(e,(function(e,r){return t(e,r.toArray())}))},e.prototype.addDcsHandler=function(e,t){return this.registerDcsHandler(e,t)},e.prototype.registerEscHandler=function(e,t){return this._core.registerEscHandler(e,t)},e.prototype.addEscHandler=function(e,t){return this.registerEscHandler(e,t)},e.prototype.registerOscHandler=function(e,t){return this._core.registerOscHandler(e,t)},e.prototype.addOscHandler=function(e,t){return this.registerOscHandler(e,t)},e}();t.ParserApi=r},7090:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0;var r=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}();t.UnicodeApi=r},744:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;var a=r(2585),c=r(5295),l=r(8460),h=r(844);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;var u=function(e){function r(r){var i=e.call(this)||this;return i._optionsService=r,i.isUserScrolling=!1,i._onResize=new l.EventEmitter,i._onScroll=new l.EventEmitter,i.cols=Math.max(r.rawOptions.cols||0,t.MINIMUM_COLS),i.rows=Math.max(r.rawOptions.rows||0,t.MINIMUM_ROWS),i.buffers=new c.BufferSet(r,i),i}return n(r,e),Object.defineProperty(r.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){e.prototype.dispose.call(this),this.buffers.dispose()},r.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})},r.prototype.reset=function(){this.buffers.reset(),this.isUserScrolling=!1},r.prototype.scroll=function(e,t){void 0===t&&(t=!1);var r,i=this.buffer;(r=this._cachedBlankLine)&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=i.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;var n=i.ybase+i.scrollTop,o=i.ybase+i.scrollBottom;if(0===i.scrollTop){var s=i.lines.isFull;o===i.lines.length-1?s?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(o+1,0,r.clone()),s?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{var a=o-n+1;i.lines.shiftElements(n+1,a-1,-1),i.lines.set(o,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)},r.prototype.scrollLines=function(e,t,r){var i=this.buffer;if(e<0){if(0===i.ydisp)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);var n=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),n!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))},r.prototype.scrollPages=function(e){this.scrollLines(e*(this.rows-1))},r.prototype.scrollToTop=function(){this.scrollLines(-this.buffer.ydisp)},r.prototype.scrollToBottom=function(){this.scrollLines(this.buffer.ybase-this.buffer.ydisp)},r.prototype.scrollToLine=function(e){var t=e-this.buffer.ydisp;0!==t&&this.scrollLines(t)},o([s(0,a.IOptionsService)],r)}(h.Disposable);t.BufferService=u},7994:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0;var r=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=r},1753:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;var o=r(2585),s=r(8460),a={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 r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(r|=64,r|=e.action):(r|=3&e.button,4&e.button&&(r|=64),8&e.button&&(r|=128),32===e.action?r|=32:0!==e.action||t||(r|=3)),r}var l=String.fromCharCode,h={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?"":""+l(t[0])+l(t[1])+l(t[2])},SGR:function(e){var t=0===e.action&&4!==e.button?"m":"M";return"[<"+c(e,!0)+";"+e.col+";"+e.row+t}},u=function(){function e(e,t){this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._onProtocolChange=new s.EventEmitter,this._lastEvent=null;for(var r=0,i=Object.keys(a);r<i.length;r++){var n=i[r];this.addProtocol(n,a[n])}for(var o=0,c=Object.keys(h);o<c.length;o++){var l=c[o];this.addEncoding(l,h[l])}this.reset()}return e.prototype.addProtocol=function(e,t){this._protocols[e]=t},e.prototype.addEncoding=function(e,t){this._encodings[e]=t},Object.defineProperty(e.prototype,"activeProtocol",{get:function(){return this._activeProtocol},set:function(e){if(!this._protocols[e])throw new Error('unknown protocol "'+e+'"');this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"areMouseEventsActive",{get:function(){return 0!==this._protocols[this._activeProtocol].events},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activeEncoding",{get:function(){return this._activeEncoding},set:function(e){if(!this._encodings[e])throw new Error('unknown encoding "'+e+'"');this._activeEncoding=e},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null},Object.defineProperty(e.prototype,"onProtocolChange",{get:function(){return this._onProtocolChange.event},enumerable:!1,configurable:!0}),e.prototype.triggerMouseEvent=function(e){if(e.col<0||e.col>=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([n(0,o.IBufferService),n(1,o.ICoreService)],e)}();t.CoreMouseService=u},6975:function(e,t,r){var i,n=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 r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;var a=r(2585),c=r(8460),l=r(1439),h=r(844),u=Object.freeze({insertMode:!1}),f=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0}),_=function(e){function t(t,r,i,n){var o=e.call(this)||this;return o._bufferService=r,o._logService=i,o._optionsService=n,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=(0,l.clone)(u),o.decPrivateModes=(0,l.clone)(f),o}return n(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=(0,l.clone)(u),this.decPrivateModes=(0,l.clone)(f)},t.prototype.triggerDataEvent=function(e,t){if(void 0===t&&(t=!1),!this._optionsService.rawOptions.disableStdin){var r=this._bufferService.buffer;r.ybase!==r.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.rawOptions.disableStdin||(this._logService.debug('sending binary "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onBinary.fire(e))},o([s(1,a.IBufferService),s(2,a.ILogService),s(3,a.IOptionsService)],t)}(h.Disposable);t.CoreService=_},3730:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirtyRowService=void 0;var o=r(2585),s=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){e<this._start?this._start=e:e>this._end&&(this._end=e)},e.prototype.markRangeDirty=function(e,t){if(e>t){var r=e;e=t,t=r}e<this._start&&(this._start=e),t>this._end&&(this._end=t)},e.prototype.markAllDirty=function(){this.markRangeDirty(0,this._bufferService.rows-1)},i([n(0,o.IBufferService)],e)}();t.DirtyRowService=s},4348:function(e,t,r){var i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;var n=r(2585),o=r(8343),s=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._entries=new Map;for(var r=0,i=e;r<i.length;r++){var n=i[r],o=n[0],s=n[1];this.set(o,s)}}return e.prototype.set=function(e,t){var r=this._entries.get(e);return this._entries.set(e,t),r},e.prototype.forEach=function(e){this._entries.forEach((function(t,r){return e(r,t)}))},e.prototype.has=function(e){return this._entries.has(e)},e.prototype.get=function(e){return this._entries.get(e)},e}();t.ServiceCollection=s;var a=function(){function e(){this._services=new s,this._services.set(n.IInstantiationService,this)}return e.prototype.setService=function(e,t){this._services.set(e,t)},e.prototype.getService=function(e){return this._services.get(e)},e.prototype.createInstance=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=(0,o.getServiceDependencies)(e).sort((function(e,t){return e.index-t.index})),s=[],a=0,c=n;a<c.length;a++){var l=c[a],h=this._services.get(l.id);if(!h)throw new Error("[createInstance] "+e.name+" depends on UNKNOWN service "+l.id+".");s.push(h)}var u=n.length>0?n[0].index:t.length;if(t.length!==u)throw new Error("[createInstance] First service dependency of "+e.name+" at position "+(u+1)+" conflicts with "+t.length+" static arguments");return new(e.bind.apply(e,i([void 0],i(i([],t,!0),s,!0),!1)))},e}();t.InstantiationService=a},7866:function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.LogService=void 0;var s=r(2585),a={debug:s.LogLevelEnum.DEBUG,info:s.LogLevelEnum.INFO,warn:s.LogLevelEnum.WARN,error:s.LogLevelEnum.ERROR,off:s.LogLevelEnum.OFF},c=function(){function e(e){var t=this;this._optionsService=e,this.logLevel=s.LogLevelEnum.OFF,this._updateLogLevel(),this._optionsService.onOptionChange((function(e){"logLevel"===e&&t._updateLogLevel()}))}return e.prototype._updateLogLevel=function(){this.logLevel=a[this._optionsService.rawOptions.logLevel]},e.prototype._evalLazyOptionalParams=function(e){for(var t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())},e.prototype._log=function(e,t,r){this._evalLazyOptionalParams(r),e.call.apply(e,o([console,"xterm.js: "+t],r,!1))},e.prototype.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.logLevel<=s.LogLevelEnum.DEBUG&&this._log(console.log,e,t)},e.prototype.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.logLevel<=s.LogLevelEnum.INFO&&this._log(console.info,e,t)},e.prototype.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.logLevel<=s.LogLevelEnum.WARN&&this._log(console.warn,e,t)},e.prototype.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.logLevel<=s.LogLevelEnum.ERROR&&this._log(console.error,e,t)},i([n(0,s.IOptionsService)],e)}();t.LogService=c},7302:function(e,t,r){var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=t.DEFAULT_BELL_SOUND=void 0;var n=r(8460),o=r(6114);t.DEFAULT_BELL_SOUND="data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,customGlyphs:!0,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:o.isMac,rendererType:"canvas",windowOptions:{},windowsMode:!1,wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1};var s=["normal","bold","100","200","300","400","500","600","700","800","900"],a=function(){function e(e){this._onOptionChange=new n.EventEmitter;var r=i({},t.DEFAULT_OPTIONS);for(var o in e)if(o in r)try{var s=e[o];r[o]=this._sanitizeAndValidateOption(o,s)}catch(e){console.error(e)}this.rawOptions=r,this.options=i({},r),this._setupOptions()}return Object.defineProperty(e.prototype,"onOptionChange",{get:function(){return this._onOptionChange.event},enumerable:!1,configurable:!0}),e.prototype._setupOptions=function(){var e=this,r=function(r){if(!(r in t.DEFAULT_OPTIONS))throw new Error('No option with key "'+r+'"');return e.rawOptions[r]},i=function(r,i){if(!(r in t.DEFAULT_OPTIONS))throw new Error('No option with key "'+r+'"');i=e._sanitizeAndValidateOption(r,i),e.rawOptions[r]!==i&&(e.rawOptions[r]=i,e._onOptionChange.fire(r))};for(var n in this.rawOptions){var o={get:r.bind(this,n),set:i.bind(this,n)};Object.defineProperty(this.options,n,o)}},e.prototype.setOption=function(e,t){this.options[e]=t},e.prototype._sanitizeAndValidateOption=function(e,r){switch(e){case"bellStyle":case"cursorStyle":case"rendererType":case"wordSeparator":r||(r=t.DEFAULT_OPTIONS[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof r&&1<=r&&r<=1e3)break;r=s.includes(r)?r:t.DEFAULT_OPTIONS[e];break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw new Error(e+" cannot be less than 1, value: "+r);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,4294967295))<0)throw new Error(e+" cannot be less than 0, value: "+r);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw new Error(e+" cannot be less than or equal to 0, value: "+r);case"rows":case"cols":if(!r&&0!==r)throw new Error(e+" must be numeric, value: "+r)}return r},e.prototype.getOption=function(e){return this.options[e]},e}();t.OptionsService=a},8343:(e,t)=>{function r(e,t,r){t.di$target===t?t.di$dependencies.push({id:e,index:r}):(t.di$dependencies=[{id:e,index:r}],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 i=function(e,t,n){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");r(i,e,n)};return i.toString=function(){return e},t.serviceRegistry.set(e,i),i}},2585:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IUnicodeService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.IDirtyRowService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;var i,n=r(8343);t.IBufferService=(0,n.createDecorator)("BufferService"),t.ICoreMouseService=(0,n.createDecorator)("CoreMouseService"),t.ICoreService=(0,n.createDecorator)("CoreService"),t.ICharsetService=(0,n.createDecorator)("CharsetService"),t.IDirtyRowService=(0,n.createDecorator)("DirtyRowService"),t.IInstantiationService=(0,n.createDecorator)("InstantiationService"),(i=t.LogLevelEnum||(t.LogLevelEnum={}))[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.OFF=4]="OFF",t.ILogService=(0,n.createDecorator)("LogService"),t.IOptionsService=(0,n.createDecorator)("OptionsService"),t.IUnicodeService=(0,n.createDecorator)("UnicodeService")},1480:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;var i=r(8460),n=r(225),o=function(){function e(){this._providers=Object.create(null),this._active="",this._onChange=new i.EventEmitter;var e=new n.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,r=e.length,i=0;i<r;++i){var n=e.charCodeAt(i);if(55296<=n&&n<=56319){if(++i>=r)return t+this.wcwidth(n);var o=e.charCodeAt(i);56320<=o&&o<=57343?n=1024*(n-55296)+o-56320+65536:t+=this.wcwidth(o)}t+=this.wcwidth(n)}return t},e}();t.UnicodeService=o}},t={};return function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,r),o.exports}(4389)})()})); \ No newline at end of file