phirepass-widgets 0.0.72 → 0.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +20 -19
  3. package/dist/cjs/phirepass-terminal.cjs.entry.js +6 -5
  4. package/dist/cjs/phirepass-widgets.cjs.js +1 -1
  5. package/dist/cjs/{protocol-IOKYxtd-.js → protocol-Cldo-J8L.js} +23 -17
  6. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +38 -18
  7. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +24 -4
  8. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  9. package/dist/components/p-DuwTRFG1.js +1 -0
  10. package/dist/components/phirepass-sftp-client.js +1 -1
  11. package/dist/components/phirepass-terminal.js +2 -2
  12. package/dist/esm/loader.js +1 -1
  13. package/dist/esm/phirepass-sftp-client.entry.js +20 -19
  14. package/dist/esm/phirepass-terminal.entry.js +6 -5
  15. package/dist/esm/phirepass-widgets.js +1 -1
  16. package/dist/esm/{protocol-CB680LkG.js → protocol-DuwTRFG1.js} +22 -16
  17. package/dist/phirepass-widgets/{p-82d89f76.entry.js → p-6da808f9.entry.js} +2 -2
  18. package/dist/phirepass-widgets/p-804b8045.entry.js +1 -0
  19. package/dist/phirepass-widgets/p-DuwTRFG1.js +1 -0
  20. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  21. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  22. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +1 -0
  23. package/dist/types/components/phirepass-terminal/phirepass-terminal.d.ts +1 -0
  24. package/dist/types/components.d.ts +8 -2
  25. package/package.json +2 -2
  26. package/dist/components/p-CB680LkG.js +0 -1
  27. package/dist/phirepass-widgets/p-845f353c.entry.js +0 -1
  28. package/dist/phirepass-widgets/p-CB680LkG.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-DovZQ7sb.js';
2
- import { _ as __wbg_init, E as ErrorType, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-CB680LkG.js';
2
+ import { _ as __wbg_init, E as ErrorType, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-DuwTRFG1.js';
3
3
 
4
4
  const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
5
5
 
@@ -51,6 +51,7 @@ const PhirepassSftpClient = class {
51
51
  allowInsecure = false;
52
52
  heartbeatInterval = 30_000;
53
53
  nodeId;
54
+ serviceId;
54
55
  token;
55
56
  onNodeIdChange(newValue, _oldValue) {
56
57
  // Handle the change in node_id here
@@ -348,7 +349,7 @@ const PhirepassSftpClient = class {
348
349
  this.clear_creds_buffer();
349
350
  this.version = auth.version;
350
351
  this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
351
- this.channel.open_sftp_tunnel(this.nodeId);
352
+ this.channel.open_sftp_tunnel(this.nodeId, this.serviceId);
352
353
  this.status = 'Connected';
353
354
  }
354
355
  handle_tunnel_opened(web) {
@@ -923,18 +924,18 @@ const PhirepassSftpClient = class {
923
924
  return `${typeChar}${chars.join('')}`;
924
925
  }
925
926
  render() {
926
- return (h(Host, { key: '733fe85191c976aa3f1a1888aaf6b8ac66b78bce', class: {
927
+ return (h(Host, { key: '693cdfaab69be7ba55dd7333ac5f8ed5ccb0dbce', class: {
927
928
  'default': !this.max,
928
929
  'max': this.max,
929
- } }, h("section", { key: 'd2282996dfa3970f6e60713417872958b0273257', class: "listing" }, !this.hideHeader &&
930
- h("header", { key: 'c270d12cf1da32374f0bdcb650f3ad4f6e6701c1' }, h("section", { key: '670335955f4f453d687c5315fe4e9b4b64c69ff7', class: "title" }, h("img", { key: '9c4be4e7366ff1e3cd11d633b31beb625671be2b', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), h("div", { key: 'bcb3764dc20d9d6b01fca4b3d9a7d4371a621403', class: "text" }, h("div", { key: 'bf036e8de51caf4fb468051edd0625e30ade4f62', class: "name" }, this.name), h("div", { key: '9f042ed7412611dde5cacf7e66a7373049175da3', class: "description" }, this.description))), h("section", { key: '46028c58138f41f8cfb0f355fd403cfbeada8559', class: "actions" }, h("div", { key: '2613d4578a05d5b4ba5a27a6d7f0bb199692305c', class: "action", onClick: () => this.toggle_max() }, h("img", { key: 'afbd51291e77e0a34bc429eacc3f92aafa72e65e', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), h("main", { key: '200d355da53b9a777d870d472c279dc93cfae8ee' }, this.show_navigation && h("nav", { key: 'a2a6d1f87818c9abfb8be2fbe7198ef3986efab5', class: "navigation" }, h("div", { key: 'b6d8104e7063e4011efd6510fc6f3fa33ad0c28d', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index, breadcrumbs) => (h("span", { key: index, class: "breadcrumb-container" }, h("span", { key: index, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index < breadcrumbs.length - 1 && h("img", { class: "arrow", src: phirepassSftpClientChevronSvg }))))), h("section", { key: '86b69b8d759e1fc8a52c7f3f1cd90c318d1d413d', class: "actions", "aria-label": "SFTP actions" }, h("button", { key: 'c69af8d208771d2788d055fa92fb396f567972e1', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, h("img", { key: 'e7c0eaf4d8983369a68506084e77f20cc29184c8', src: phirepassSftpClientGoUpSvg, alt: "Go up" })), h("button", { key: '0e8b47e93b2825bc0e60b0c75d961609c2b98158', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, h("img", { key: '1a8d0178825ac27fb85584a36bd2d660fe09c135', src: phirepassSftpClientRefreshSvg, alt: "Refresh" })), h("button", { key: 'fddbb65e05c0a9d800dc901bea49c9352099085d', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, h("img", { key: 'cbb5517d854064846a05ee56ef959ed79308b9ad', src: phirepassSftpClientUploadSvg, alt: "Upload" })), h("button", { key: '15f521ad9359057a75fc13ab0336fd9803b9c432', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), h("input", { key: '48f7a635ea1e93a60e5b64042e730b3af5816ce9', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && h("div", { key: '7a977051ab3ccd46524a53c590e52c33904375e4', class: "content" }, h("table", { key: '0ac3ae940c7ae094ca99a1c07b37980a9d5a06c4' }, h("thead", { key: 'f8141383e987cd435a4f89b9d85b5d373559ec1c' }, h("tr", { key: '88479b89f19e1364afaf284b7947c754457c2aa5' }, h("th", { key: '1ad5c30387a14041ff7f45e1caaffe39c4972b3f' }, "Name"), h("th", { key: 'b80c51a07e6e144b8d21698b1a4e6116eb36cb3a' }, "Size"), h("th", { key: '9265bd2250aeb15ff19224f3247b0ec4c8678d7c' }, "Permissions"), h("th", { key: '6c9488fced66224aee51e9193b7beb4d0ea05a04' }, "Owner"), h("th", { key: 'b741ca68c2ec44243160d5e9f64271c488381713' }, "Modified"), h("th", { key: 'a6717e7f50003dc7cb14c2c46b5141afaca3eef1', class: "action-col", "aria-label": "Actions" }))), h("tbody", { key: '2406bf5112dff02abcb4952a19718398b43e6635' }, this.listing.map((item, index) => (h("tr", { key: index, class: {
930
+ } }, h("section", { key: '504d57b244dd055f23b81807ef6a397032dcf088', class: "listing" }, !this.hideHeader &&
931
+ h("header", { key: 'cef1e0a272851379e6d9ca07092b8078c94e2509' }, h("section", { key: '49fe94d69837676a46e3c92f54496c2ffa1e3ecd', class: "title" }, h("img", { key: 'cec6b64508c31904b34496cc34b26f81ae3e290e', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), h("div", { key: '3331b32275581f9bcf79b4b346e9820018868cbf', class: "text" }, h("div", { key: '289f2fef2e14c0a1954a99f6bbd920edbf66bf42', class: "name" }, this.name), h("div", { key: '8c88da9841dc39373f94cb313c7897cbc5a828a3', class: "description" }, this.description))), h("section", { key: 'f6f7ae566a225586c4a79ba31eecf998a1df010b', class: "actions" }, h("div", { key: 'd1a5e9c21e61320035eafe255213e883140815c4', class: "action", onClick: () => this.toggle_max() }, h("img", { key: '10f834c7a7846964bc84c2fd6eef39b09fa33e8f', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), h("main", { key: 'e17ee5827dc56cea9139697ce9024011a638e5ff' }, this.show_navigation && h("nav", { key: '277080aa09d738f21605d95d1bf70adc9156dfbb', class: "navigation" }, h("div", { key: '526b99f6b6c1161e41ee6dfcd13b48f8e52f85eb', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index, breadcrumbs) => (h("span", { key: index, class: "breadcrumb-container" }, h("span", { key: index, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index < breadcrumbs.length - 1 && h("img", { class: "arrow", src: phirepassSftpClientChevronSvg }))))), h("section", { key: '61a48831425637dc03662f6a8748619745a13b7b', class: "actions", "aria-label": "SFTP actions" }, h("button", { key: '53f150ed1579a653a6f843106ba14534156d46d2', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, h("img", { key: 'dd9853885e3a18882ded99fb28e0e270a9e8bb2b', src: phirepassSftpClientGoUpSvg, alt: "Go up" })), h("button", { key: '5a2a2f865b5169d2187cf5c8d5aa876163d708d3', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, h("img", { key: '62752fa2e46faf222fedd7f5f8a6e7d81242a089', src: phirepassSftpClientRefreshSvg, alt: "Refresh" })), h("button", { key: '09fe21b04d27e7e1abd87b14789e6bd8faa68a98', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, h("img", { key: '0b4ab6f686c7261844221835836e2dbee86866bf', src: phirepassSftpClientUploadSvg, alt: "Upload" })), h("button", { key: 'eab9cf7df64384db2cfb383ba2bc87ff84e9ef63', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), h("input", { key: '05609273cfc54c019f801768e560365845c38671', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && h("div", { key: 'ed910c6b7c2d5ac17e13fef9fd4597b1406b7d85', class: "content" }, h("table", { key: 'c28ed3308bf01665e313e1f8b8fb482f2dc0303a' }, h("thead", { key: '187c2e34ed9cbe57ea13083645472f0dc6f2e957' }, h("tr", { key: 'd43d3d698ba06cc24bc9fba9946a0bcf382327a1' }, h("th", { key: '8128742b1975b1c655e5665256cceb8f63441450' }, "Name"), h("th", { key: '35f91f13e38b62dfa97c742f4f23d14495f71462' }, "Size"), h("th", { key: '89f10d37b9558aadfc1e10e6729ef0bc63f30216' }, "Permissions"), h("th", { key: '51905e8a7d3391119290b59fb0f36420b23b5331' }, "Owner"), h("th", { key: 'a2133c42789fb79ec0bfd91c1ffe4f869a8b0acf' }, "Modified"), h("th", { key: 'a3b72803212e5ba60249777cdad37341c101a4b5', class: "action-col", "aria-label": "Actions" }))), h("tbody", { key: 'e5ee4a1cd8943a4966d33a43ee04df5f355f21e0' }, this.listing.map((item, index) => (h("tr", { key: index, class: {
931
932
  'selected': this.is_selected(item),
932
933
  }, onClick: () => this.list_directory(item) }, h("td", null, item.kind === 'Folder' ? h("img", { class: "kind", src: phirepassSftpClientFolderSvg, alt: "Folder" }) : h("img", { class: "kind", src: phirepassSftpClientFileSvg, alt: "File" }), h("span", { class: `name ${item.kind.toLowerCase()}` }, item.name)), h("td", null, this.format_size(item.attributes.size)), h("td", null, this.format_permissions(item.attributes.permissions, item.kind)), h("td", null, item.attributes.user ?? '-'), h("td", null, new Date(item.attributes.modified * 1000).toLocaleString()), h("td", { class: "action-col" }, item.kind === 'File' &&
933
- h("div", { class: "file-actions" }, h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": "Download" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), h("polyline", { points: "7 10 12 15 17 10" }), h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": "Delete" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("polyline", { points: "3 6 5 6 21 6" }), h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), h("line", { x1: "14", x2: "14", y1: "11", y2: "17" }))))))))))), this.show_loader && h("div", { key: 'aa63f480151a0143183f8769413bbf1d8bad517a', class: "loader" }, "Loading..."), this.show_error && h("div", { key: '3ca7fe377368a520de804391d8939627e956e3d0', class: "error" }, this.error_message)), h("footer", { key: '71a1233b255561b5e0cf4408c268ab399982cb7f' }, h("section", { key: '5533f9b423be66da41ff7128b903e09bcd447c4c', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
934
- h("section", { key: '6dc948c828b479b6d706dbcca3b3075e58757cef', class: {
934
+ h("div", { class: "file-actions" }, h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": "Download" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), h("polyline", { points: "7 10 12 15 17 10" }), h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": "Delete" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, h("polyline", { points: "3 6 5 6 21 6" }), h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), h("line", { x1: "14", x2: "14", y1: "11", y2: "17" }))))))))))), this.show_loader && h("div", { key: '30777c73738f9c6a5199033428d9033d0cd05b99', class: "loader" }, "Loading..."), this.show_error && h("div", { key: '0a5bc583f268e00c1bf17661ea1f49bccaba6ab9', class: "error" }, this.error_message)), h("footer", { key: '94aff725f14e25d8c34719cbf2decdd5e17b8e22' }, h("section", { key: '6342e9ce4b7fe08e12d62406f203127a0c872055', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
935
+ h("section", { key: '039eeae64731e54a5bf0982777815c8ad0df6b49', class: {
935
936
  'creds': true,
936
937
  'blurred': this.show_login_screen,
937
- } }, h("form", { key: 'a7f60c3dcc672cc18f1ec67a45495eb756ae9c92', class: "auth", onSubmit: (event) => {
938
+ } }, h("form", { key: 'b1881dd755b66c392155bb8f670a924f711bd717', class: "auth", onSubmit: (event) => {
938
939
  const formData = new FormData(event.target);
939
940
  let username = undefined;
940
941
  if (this.show_login_screen_username) {
@@ -944,35 +945,35 @@ const PhirepassSftpClient = class {
944
945
  if (this.show_login_screen_password) {
945
946
  password = formData.get('password');
946
947
  }
947
- this.channel.open_sftp_tunnel(this.nodeId, username, password);
948
+ this.channel.open_sftp_tunnel(this.nodeId, this.serverId, username, password);
948
949
  this.show_login_screen_username = false;
949
950
  this.show_login_screen_password = false;
950
951
  this.show_login_screen = false;
951
952
  this.show_loader = true;
952
953
  event.stopPropagation();
953
954
  event.preventDefault();
954
- } }, h("div", { key: 'b0f3c4b74c59590624d4944b8d6ccd5a45b6065c', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
955
- h("div", { key: '2d6d9424cd170e087cc6f17d55c8cf1461a06988' }, h("label", { key: 'e420f513abc053a99c0e61c27716ff39f0527827', htmlFor: "username" }, "Username"), h("input", { key: 'c50aff8ff53e8ed3b3dbb5d0cc85055b247864cf', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
956
- h("div", { key: '8f49b0425783375996484b536c58f07414215b44' }, h("label", { key: 'ed739b253b2bfa7dc6bab37dbf184b0c9eacf657', htmlFor: "password" }, "Password"), h("input", { key: 'd1be51c537fb0461678ede0e940fd312d96c1517', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), h("div", { key: '66da4c8d32459483a1b0329473287e89a82c5e4c' }, h("button", { key: 'cf5a2534f2a6abc344e999520bb4328c4dadd090', type: "submit" }, "Connect")))), this.show_upload_modal &&
957
- h("section", { key: 'b678714eff09b18b7932e936ae4dee366aa98b4e', class: {
955
+ } }, h("div", { key: '250b78b4d4f20f0491034d6c261ee55581d93483', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
956
+ h("div", { key: '68130dd636c5ae29d4bb344b45ba6b6747b2fdaf' }, h("label", { key: '0d3bc72b4ce0581a910f3b702e299e257498d088', htmlFor: "username" }, "Username"), h("input", { key: 'fef6876079e4097339549547138bcafc93901a3a', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
957
+ h("div", { key: 'ae8d6f4f1d3bee55038dcc6b60899d4ab0ebd5ce' }, h("label", { key: '54dc4ff7a8faf76644d9885ea77d75357ac92ff8', htmlFor: "password" }, "Password"), h("input", { key: '8a4b35f9daa410d96c424ffae53ba92a793081cb', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), h("div", { key: '0c41f3a81ffbd29bba566f6c7ee35234de77e051' }, h("button", { key: '5bf5676382c66f032d72e77bc889596c0f851dbe', type: "submit" }, "Connect")))), this.show_upload_modal &&
958
+ h("section", { key: 'f37ec9066ef29eba7b79f3db98ee080c48c9ec4e', class: {
958
959
  'upload-modal': true,
959
960
  'visible': this.show_upload_modal,
960
- } }, h("div", { key: 'c4fa4e401c192e705207df634d2f93943ce77af5', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, h("div", { key: '18ff3a246aa39f28474ced7cce76ace778922a2f', class: "title" }, "Uploading File"), h("div", { key: 'b08fa6b79f6080e9d60f361021b8bac6a5ed7424', class: "file-name", title: this.upload_file_name }, this.upload_file_name), h("div", { key: '9efc45e387d8156a18afb90d5531df4ebfa64328', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, h("div", { key: 'c988402fedde675d04bc7b2054da4e319c2af082', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), h("div", { key: '1d0d8f845d3bfa817aec865598cffa59f55505f4', class: "progress-meta" }, h("div", { key: '5b983ed819d48105c3fb0a71b2d2d62f7f46003c', class: "progress-speed" }, this.upload_speed), h("div", { key: '859bb76ff953d69ddaa710574bb1c72b92968f5a', class: "progress-value" }, this.format_percent(this.upload_progress))), h("button", { key: '41d970d2112e63f931c5a5513bb580559f9e619b', type: "button", class: {
961
+ } }, h("div", { key: '77b7a1debd316d191ea9bc7e7fa0e914943e7951', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, h("div", { key: '614f3abe44943fb8d7d7e1976f82fa3161b66112', class: "title" }, "Uploading File"), h("div", { key: 'f2d3b094309ce4cfb4fafb0a289be1f8f116a246', class: "file-name", title: this.upload_file_name }, this.upload_file_name), h("div", { key: '7f6e1892490759e62c3dd5acf46dd53017619a6a', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, h("div", { key: '605c95beaf914644b5500bcc61b5b44aa71f4af9', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), h("div", { key: '2389e2b5d9f719e39d24b40e8083d662864a87db', class: "progress-meta" }, h("div", { key: '2464c8db01adee774d35a65bbdb22d175476e19e', class: "progress-speed" }, this.upload_speed), h("div", { key: 'c47334ec3967a4269cbdea7c7e4e55726461e797', class: "progress-value" }, this.format_percent(this.upload_progress))), h("button", { key: '25d0755fef743af337f7178da1bdd92628f908e2', type: "button", class: {
961
962
  'cancel': true,
962
963
  'finished': this.upload_finished,
963
964
  }, onClick: () => this.cancel_upload() }, this.upload_finished ? 'Close' : 'Cancel'))), this.show_download_modal &&
964
- h("section", { key: 'd9bfadbc2d3a164bc05811a7f2e9024a914ecbc8', class: {
965
+ h("section", { key: '0e9db491e0475a85eb811ee83ee5f1102b6e6091', class: {
965
966
  'download-modal': true,
966
967
  'visible': this.show_download_modal,
967
- } }, h("div", { key: '1f874ba0e526b99d2b41beaf8023cbada567ecc8', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, h("div", { key: 'ac2b5f65423e7e2b20ffecf864477e849b737259', class: "title" }, "Downloading File"), h("div", { key: '639d6fe5a64db1aa53b077eb318fa21d72a551ed', class: "file-name", title: this.download_file_name }, this.download_file_name), h("div", { key: 'e90546d4dceab157f4599b2ffd31f1eb4eb9d18c', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, h("div", { key: 'eeb597904e31a6aa9717cc4e6fc534ae68924dee', class: "progress-fill", style: { width: `${this.download_progress}%` } })), h("div", { key: '1bbf952144d17c374de6948ad94bc4deed7ae8a0', class: "progress-meta" }, h("div", { key: '049f748019b11cea95f236202cd48c758e99411a', class: "progress-speed" }, this.download_speed), h("div", { key: '01b8d063a3fdfe8cc9df21e75833df3a6c2eda49', class: "progress-value" }, this.format_percent(this.download_progress))), h("button", { key: 'a87560c1555bf8a6dea73a424792b3af25e06a68', type: "button", class: {
968
+ } }, h("div", { key: 'c177ed66cd9fea215cc3551455243c7cb8ddfe2a', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, h("div", { key: '1d4ea586f1598ce83db53c8eab628db8092ceb2c', class: "title" }, "Downloading File"), h("div", { key: '64bfbe33ddb139ffb7f6035dc4bdd3fb666e054e', class: "file-name", title: this.download_file_name }, this.download_file_name), h("div", { key: '568ca83a87c7f098453fa9d810d894cf32eac728', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, h("div", { key: '3a608f280ee43ffb7933f2755021ae655bd2029e', class: "progress-fill", style: { width: `${this.download_progress}%` } })), h("div", { key: '4c703f990756d4b3b8c4750d711ff4b9817fe2f1', class: "progress-meta" }, h("div", { key: 'd5fe7bc49d1f8f7fcb14c4462244c41140092b87', class: "progress-speed" }, this.download_speed), h("div", { key: 'd99c13a9638b7018fead0c6e2ea8df3c1ed7fca0', class: "progress-value" }, this.format_percent(this.download_progress))), h("button", { key: '32aa10e73df04f3b6b3f2263608c55e069bc29eb', type: "button", class: {
968
969
  'cancel': true,
969
970
  'finished': this.download_finished,
970
971
  }, onClick: () => this.cancel_download() }, this.download_finished ? 'Close' : 'Cancel'))), this.show_delete_modal &&
971
- h("section", { key: '7e547c5f320acc9920020a4bcafc21ca57d6ad66', class: {
972
+ h("section", { key: '0f142b91f29d4b2474ae0a9d479cec3457414f43', class: {
972
973
  'delete-modal': true,
973
974
  'visible': this.show_delete_modal,
974
- } }, h("div", { key: 'b79c2be285b8e2af00189cd69143950f133f5722', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation" }, h("div", { key: 'b25d1669edded42eae34ac15887428d85a3e8577', class: "title" }, "Delete File"), h("div", { key: 'da2a16b8f85ae7dc7d09aa2ffe4562124642233f', class: "message" }, this.delete_loading ? 'Deleting file...' : 'Are you sure you want to delete this file?'), h("div", { key: '702dfa13f1e9b828c2d956cab0c1fcc557c80bb1', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_loading &&
975
- h("div", { key: '1e2b57c73dad6f463c3377c16ae407cc553232e3', class: "delete-loader", "aria-hidden": "true" }, h("span", { key: '40338e85202b89cb8b2fea8adddf10323fa91a25', class: "spinner" })), h("div", { key: 'e0b264439056ab3e7f49f5dd221b5f58ea720d2e', class: "modal-actions" }, h("button", { key: 'ee6932fa56c02bca43c6ce914cec55ca9dbfd48a', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), h("button", { key: '2c26e30cc0942f532996a3b485ad77fb11c2d214', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete'))))));
975
+ } }, h("div", { key: '2fa13dec3240b69016e33c2f751af97c5903f693', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation" }, h("div", { key: '22742d0f1384acba3f08132d7efad4a78a2357ae', class: "title" }, "Delete File"), h("div", { key: '7eaf020753953b82d843d5b4dd8414131906151b', class: "message" }, this.delete_loading ? 'Deleting file...' : 'Are you sure you want to delete this file?'), h("div", { key: 'f4fc23b43a78541d7ab84659d287f5d33dc4be1d', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_loading &&
976
+ h("div", { key: 'ad9fd03a6b983eb87ec37a63bf35d440ce7f908c', class: "delete-loader", "aria-hidden": "true" }, h("span", { key: 'e22bfb5dd729a865454cafb23f4d6eee9a2e3838', class: "spinner" })), h("div", { key: '730b9aa6e1bd773e8e8e9be5ee75c63ba5f69ad3', class: "modal-actions" }, h("button", { key: 'dd7b1ae63736e3c36b9b4894b969433a390e9ee4', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), h("button", { key: '113304b503ba82498a26c34b68ec9f217e6372a2', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete'))))));
976
977
  }
977
978
  static get watchers() { return {
978
979
  "nodeId": [{
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, g as getElement, h as h$1, H as Host } from './index-DovZQ7sb.js';
2
- import { I as InputMode, _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType, E as ErrorType } from './protocol-CB680LkG.js';
2
+ import { I as InputMode, _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType, E as ErrorType } from './protocol-DuwTRFG1.js';
3
3
 
4
4
  /**
5
5
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
@@ -296,6 +296,7 @@ const PhirepassTerminal = class {
296
296
  allowInsecure = false;
297
297
  heartbeatInterval = 30_000;
298
298
  nodeId;
299
+ serviceId;
299
300
  token;
300
301
  onNodeIdChange(newValue, _oldValue) {
301
302
  // Handle the change in node_id here
@@ -552,7 +553,7 @@ const PhirepassTerminal = class {
552
553
  handle_auth_success(_auth_) {
553
554
  this.clear_creds_buffer();
554
555
  this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
555
- this.channel.open_ssh_tunnel(this.nodeId);
556
+ this.channel.open_ssh_tunnel(this.nodeId, this.serviceId);
556
557
  }
557
558
  handle_tunnel_opened(web) {
558
559
  this.session_id = web.sid;
@@ -647,7 +648,7 @@ const PhirepassTerminal = class {
647
648
  return;
648
649
  }
649
650
  this.inputMode = InputMode.Default;
650
- this.channel.open_ssh_tunnel(this.nodeId, username);
651
+ this.channel.open_ssh_tunnel(this.nodeId, this.serviceId, username);
651
652
  }
652
653
  handle_password_input(data) {
653
654
  if (data === "\r" || data === "\n") {
@@ -686,13 +687,13 @@ const PhirepassTerminal = class {
686
687
  this.inputMode = InputMode.Default;
687
688
  // Assuming there's a method to submit password to the channel
688
689
  // You may need to adjust this based on your actual API
689
- this.channel.open_ssh_tunnel(this.nodeId, this.usernameBuffer.trim(), password);
690
+ this.channel.open_ssh_tunnel(this.nodeId, this.serviceId, this.usernameBuffer.trim(), password);
690
691
  // Clear sensitive data
691
692
  this.passwordBuffer = "";
692
693
  this.usernameBuffer = "";
693
694
  }
694
695
  render() {
695
- return (h$1(Host, { key: '641344887f33ba9c4c8aa98186b84a92ebb020e7' }, h$1("div", { key: '558aebfd21575d5dbdaacf03335485941373679a', id: "ccc", ref: el => (this.containerEl = el) })));
696
+ return (h$1(Host, { key: '8bc2181d5ca26f6e6552591b7d399f81bece3efa' }, h$1("div", { key: '4c7085ba44cebb23f7712fbfe4ea52a9e8bde6d7', id: "ccc", ref: el => (this.containerEl = el) })));
696
697
  }
697
698
  static get watchers() { return {
698
699
  "nodeId": [{
@@ -17,5 +17,5 @@ var patchBrowser = () => {
17
17
 
18
18
  patchBrowser().then(async (options) => {
19
19
  await globalScripts();
20
- return bootstrapLazy([["phirepass-sftp-client",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_error":[32],"error_message":[32],"show_login_screen_password":[32],"show_navigation":[32],"breadcrumbs":[32],"current_dir":[32],"listing":[32],"show_content":[32],"show_loader":[32],"version":[32],"status":[32],"selected_item":[32],"show_upload_modal":[32],"upload_progress":[32],"upload_file_name":[32],"upload_speed":[32],"upload_finished":[32],"show_download_modal":[32],"download_progress":[32],"download_file_name":[32],"download_speed":[32],"download_finished":[32],"show_delete_modal":[32],"delete_file_name":[32],"delete_loading":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["phirepass-terminal",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
20
+ return bootstrapLazy([["phirepass-sftp-client",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_error":[32],"error_message":[32],"show_login_screen_password":[32],"show_navigation":[32],"breadcrumbs":[32],"current_dir":[32],"listing":[32],"show_content":[32],"show_loader":[32],"version":[32],"status":[32],"selected_item":[32],"show_upload_modal":[32],"upload_progress":[32],"upload_file_name":[32],"upload_speed":[32],"upload_finished":[32],"show_download_modal":[32],"download_progress":[32],"download_file_name":[32],"download_speed":[32],"download_finished":[32],"show_delete_modal":[32],"delete_file_name":[32],"delete_loading":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["phirepass-terminal",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serviceId":[1,"service-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
21
21
  });
@@ -144,33 +144,39 @@ class Channel {
144
144
  }
145
145
  /**
146
146
  * @param {string} node_id
147
+ * @param {string} service_id
147
148
  * @param {string | null} [username]
148
149
  * @param {string | null} [password]
149
150
  * @param {number | null} [msg_id]
150
151
  */
151
- open_sftp_tunnel(node_id, username, password, msg_id) {
152
+ open_sftp_tunnel(node_id, service_id, username, password, msg_id) {
152
153
  const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
153
154
  const len0 = WASM_VECTOR_LEN;
154
- var ptr1 = isLikeNone(username) ? 0 : passStringToWasm0(username, wasm.__wbindgen_export, wasm.__wbindgen_export2);
155
- var len1 = WASM_VECTOR_LEN;
156
- var ptr2 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
155
+ const ptr1 = passStringToWasm0(service_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
156
+ const len1 = WASM_VECTOR_LEN;
157
+ var ptr2 = isLikeNone(username) ? 0 : passStringToWasm0(username, wasm.__wbindgen_export, wasm.__wbindgen_export2);
157
158
  var len2 = WASM_VECTOR_LEN;
158
- wasm.channel_open_sftp_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
159
+ var ptr3 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
160
+ var len3 = WASM_VECTOR_LEN;
161
+ wasm.channel_open_sftp_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
159
162
  }
160
163
  /**
161
164
  * @param {string} node_id
165
+ * @param {string} service_id
162
166
  * @param {string | null} [username]
163
167
  * @param {string | null} [password]
164
168
  * @param {number | null} [msg_id]
165
169
  */
166
- open_ssh_tunnel(node_id, username, password, msg_id) {
170
+ open_ssh_tunnel(node_id, service_id, username, password, msg_id) {
167
171
  const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
168
172
  const len0 = WASM_VECTOR_LEN;
169
- var ptr1 = isLikeNone(username) ? 0 : passStringToWasm0(username, wasm.__wbindgen_export, wasm.__wbindgen_export2);
170
- var len1 = WASM_VECTOR_LEN;
171
- var ptr2 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
173
+ const ptr1 = passStringToWasm0(service_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
174
+ const len1 = WASM_VECTOR_LEN;
175
+ var ptr2 = isLikeNone(username) ? 0 : passStringToWasm0(username, wasm.__wbindgen_export, wasm.__wbindgen_export2);
172
176
  var len2 = WASM_VECTOR_LEN;
173
- wasm.channel_open_ssh_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
177
+ var ptr3 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
178
+ var len3 = WASM_VECTOR_LEN;
179
+ wasm.channel_open_ssh_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, isLikeNone(msg_id) ? Number.MAX_SAFE_INTEGER : (msg_id) >>> 0);
174
180
  }
175
181
  /**
176
182
  * @param {string} node_id
@@ -424,7 +430,7 @@ function __wbg_get_imports() {
424
430
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
425
431
  return addHeapObject(ret);
426
432
  }, arguments); },
427
- __wbg_info_2f2b0f083e705d41: function(arg0, arg1) {
433
+ __wbg_info_a035e9398ce057dc: function(arg0, arg1) {
428
434
  console.info(getStringFromWasm0(arg0, arg1));
429
435
  },
430
436
  __wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da: function(arg0) {
@@ -496,7 +502,7 @@ function __wbg_get_imports() {
496
502
  __wbg_set_onopen_ca8d311fe5282041: function(arg0, arg1) {
497
503
  getObject(arg0).onopen = getObject(arg1);
498
504
  },
499
- __wbg_warn_7b140f9c52075c0d: function(arg0, arg1) {
505
+ __wbg_warn_1087e5a6742be100: function(arg0, arg1) {
500
506
  console.warn(getStringFromWasm0(arg0, arg1));
501
507
  },
502
508
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
@@ -515,8 +521,8 @@ function __wbg_get_imports() {
515
521
  return addHeapObject(ret);
516
522
  },
517
523
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
518
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 5, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
519
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_46);
524
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 3, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
525
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_44);
520
526
  return addHeapObject(ret);
521
527
  },
522
528
  __wbindgen_cast_0000000000000005: function(arg0) {
@@ -553,8 +559,8 @@ function __wbg_get_imports() {
553
559
  };
554
560
  }
555
561
 
556
- function __wasm_bindgen_func_elem_46(arg0, arg1) {
557
- wasm.__wasm_bindgen_func_elem_46(arg0, arg1);
562
+ function __wasm_bindgen_func_elem_44(arg0, arg1) {
563
+ wasm.__wasm_bindgen_func_elem_44(arg0, arg1);
558
564
  }
559
565
 
560
566
  function __wasm_bindgen_func_elem_42(arg0, arg1, arg2) {
@@ -1,4 +1,4 @@
1
- import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_ as n,C as o,a as l,P as a,E as u}from"./p-CB680LkG.js";
1
+ import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_ as n,C as o,a as l,P as a,E as u}from"./p-DuwTRFG1.js";
2
2
  /**
3
3
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
4
4
  * @license MIT
@@ -46,4 +46,4 @@ import{r as t,c as i,g as s,h as e,H as h}from"./p-DovZQ7sb.js";import{I as r,_
46
46
  * Fabrice Bellard's javascript vt100 for jslinux:
47
47
  * http://bellard.org/jslinux/
48
48
  * Copyright (c) 2011 Fabrice Bellard
49
- */function eu(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Ha||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=Number.POSITIVE_INFINITY){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Ta||={});var hu=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(Ta.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};hu.DISABLE_DISPOSED_WARNING=!1;var ru=hu,nu=class{constructor(){this._store=new ru}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};nu.None=Object.freeze({dispose(){}});var ou=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},lu=class t extends nu{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new ou),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:eu((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,l=Math.ceil(o.width/r),a=i%l*r,u=Math.floor(i/l)*n,c=s*r,A=e*n,f=h*r+a>o.width?o.width-a:h*r,d=u+n>o.height?o.height-u:n;this._ctx.drawImage(o,Math.floor(a),Math.floor(u),Math.ceil(f),Math.ceil(d),Math.floor(c),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,l=Math.floor(s/n)*h,a=e+o>r.width?r.width-o:e,u=l+h>r.height?r.height-l:h,c=t.createCanvas(this.document,a,u),A=c.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(l),Math.floor(a),Math.floor(u),0,0,Math.floor(a),Math.floor(u)),c):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,su.toRGBA8888)(0,0,0),l=(0,su.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=l}h.putImageData(r,0,0);let a=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,a,i);let u=this._placeholder.getContext("2d",{alpha:!1});if(u){for(let t=0;t<a;t+=s)u.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},au={width:7,height:14},uu=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},cu=new uu,Au=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=au);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=au);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,l=r.x,a=r.y,u=l,c=0;this._opts.sixelScrolling||(r.x=0,r.y=0,u=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(u+e>=n);++e)this._writeToCell(i,u+e,h,t*s+e),c++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=u}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=u:(r.x=l,r.y=a);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:c,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||cu,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,l=s,a=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||cu)&&e.imageId===r&&e.tileId===o+a;)a++;s--,n?n.actual&&this._renderer.draw(n,o,l,t,a):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(l,t,a),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||cu,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let l=Math.min(t.cols,n-i.tileId%n+e),a=i.tileId;for(let t=e+1;t<l;++t)this._writeToCell(s,t,h,++a),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||cu;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=lu.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||cu;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new uu(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new uu(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},fu=Ya(Va());function du(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function gu(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw new Error("illegal char");i=10*i+t[s]-48}return i}function wu(t){let i=du(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return i}var pu={inline:gu,size:gu,name:function(t){if(typeof Buffer<"u")return Buffer.from(du(t),"base64").toString();let i=atob(du(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:wu,height:wu,preserveAspectRatio:gu},Cu=[70,105,108,101],mu=1024,Iu=class{constructor(){this.state=0,this._buffer=new Uint32Array(mu),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<Cu.length;++t)if(r[t]!==Cu[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=mu)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=mu)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=du(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=pu[this._key]?pu[this._key](i):i}catch{return!1}return!0}return!1}},vu={mime:"unsupported",width:0,height:0},Bu={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},Mu=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new Iu,this._header=Bu,this._dec=new fu.default(4194304),this._metrics=vu}reset(){}start(){this._aborted=!1,this._header=Bu,this._metrics=vu,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},Bu,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return vu;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?vu:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=lu.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||au.width,e=this._renderer.dimensions?.css.cell.height||au.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},yu=Ya(Za()),Qu=Ya(iu()),Eu=yu.PALETTE_ANSI_256;Eu.set(yu.PALETTE_VT340_COLOR);var bu=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Qu.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:Eu,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Eu,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=ku(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,yu.toRGBA8888)(...i)}else s=ku(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=ku(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,yu.toRGBA8888)(...i)}else s=ku(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn(`SIXEL: error while decoding image - ${t}`),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=lu.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function ku(t){return yu.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var xu={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},Du=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},xu,t),this._defaultOpts=Object.assign({},xu,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new lu(t),this._storage=new Au(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new bu(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new Mu(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=au;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};const Lu=class{constructor(s){t(this,s),this.connectionStateChanged=i(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=r.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return s(this)}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await n(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeDebounceHandle&&(clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=void 0),this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}is_terminal_open(){return Boolean(this.connected&&this.containerEl&&this.terminal.element)}fit_terminal_safely(){if(this.fitAddon&&this.is_terminal_open())try{this.fitAddon.fit()}catch(t){console.warn("Skipping terminal fit before renderer is ready:",t)}}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new Mr(this.terminalOptions),this.fitAddon=new yr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new Dr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new Ln,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new Ga,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new Du(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Qa,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new o(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId):new o(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([l.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([l.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([l.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case a.Error:this.handle_error(i);break;case a.AuthSuccess:this.handle_auth_success(i);break;case a.TunnelOpened:this.handle_tunnel_opened(i);break;case a.TunnelClosed:this.handle_tunnel_closed(i);break;case a.TunnelData:this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fit_terminal_safely();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0||s<=0||e<=0)console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`);else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case u.Generic:case u.Authentication:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus(),this.usernameBuffer="",this.passwordBuffer="";break;case u.RequiresUsernamePassword:case u.RequiresUsername:this.terminal.reset(),this.inputMode=r.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case u.RequiresPassword:this.terminal.reset(),this.inputMode=r.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=r.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=r.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fit_terminal_safely(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=r.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.connected=!0,this.fit_terminal_safely(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fit_terminal_safely(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case r.Username:this.handle_username_input(t);break;case r.Password:this.handle_password_input(t);break;case r.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=r.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=r.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return e(h,{key:"641344887f33ba9c4c8aa98186b84a92ebb020e7"},e("div",{key:"558aebfd21575d5dbdaacf03335485941373679a",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};Lu.style=".xterm{cursor:text;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;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}";export{Lu as phirepass_terminal}
49
+ */function eu(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Ha||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=Number.POSITIVE_INFINITY){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Ta||={});var hu=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(Ta.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};hu.DISABLE_DISPOSED_WARNING=!1;var ru=hu,nu=class{constructor(){this._store=new ru}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};nu.None=Object.freeze({dispose(){}});var ou=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},lu=class t extends nu{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new ou),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:eu((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,l=Math.ceil(o.width/r),a=i%l*r,u=Math.floor(i/l)*n,c=s*r,A=e*n,f=h*r+a>o.width?o.width-a:h*r,d=u+n>o.height?o.height-u:n;this._ctx.drawImage(o,Math.floor(a),Math.floor(u),Math.ceil(f),Math.ceil(d),Math.floor(c),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,l=Math.floor(s/n)*h,a=e+o>r.width?r.width-o:e,u=l+h>r.height?r.height-l:h,c=t.createCanvas(this.document,a,u),A=c.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(l),Math.floor(a),Math.floor(u),0,0,Math.floor(a),Math.floor(u)),c):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,su.toRGBA8888)(0,0,0),l=(0,su.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=l}h.putImageData(r,0,0);let a=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,a,i);let u=this._placeholder.getContext("2d",{alpha:!1});if(u){for(let t=0;t<a;t+=s)u.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},au={width:7,height:14},uu=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},cu=new uu,Au=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=au);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=au);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,l=r.x,a=r.y,u=l,c=0;this._opts.sixelScrolling||(r.x=0,r.y=0,u=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(u+e>=n);++e)this._writeToCell(i,u+e,h,t*s+e),c++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=u}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=u:(r.x=l,r.y=a);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:c,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||cu,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,l=s,a=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||cu)&&e.imageId===r&&e.tileId===o+a;)a++;s--,n?n.actual&&this._renderer.draw(n,o,l,t,a):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(l,t,a),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||cu,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let l=Math.min(t.cols,n-i.tileId%n+e),a=i.tileId;for(let t=e+1;t<l;++t)this._writeToCell(s,t,h,++a),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||cu;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=lu.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||cu;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new uu(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new uu(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},fu=Ya(Va());function du(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function gu(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw new Error("illegal char");i=10*i+t[s]-48}return i}function wu(t){let i=du(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return i}var pu={inline:gu,size:gu,name:function(t){if(typeof Buffer<"u")return Buffer.from(du(t),"base64").toString();let i=atob(du(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:wu,height:wu,preserveAspectRatio:gu},Cu=[70,105,108,101],mu=1024,Iu=class{constructor(){this.state=0,this._buffer=new Uint32Array(mu),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<Cu.length;++t)if(r[t]!==Cu[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=mu)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=mu)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=du(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=pu[this._key]?pu[this._key](i):i}catch{return!1}return!0}return!1}},vu={mime:"unsupported",width:0,height:0},Bu={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},Mu=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new Iu,this._header=Bu,this._dec=new fu.default(4194304),this._metrics=vu}reset(){}start(){this._aborted=!1,this._header=Bu,this._metrics=vu,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},Bu,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return vu;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?vu:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=lu.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||au.width,e=this._renderer.dimensions?.css.cell.height||au.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},yu=Ya(Za()),Qu=Ya(iu()),Eu=yu.PALETTE_ANSI_256;Eu.set(yu.PALETTE_VT340_COLOR);var bu=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Qu.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:Eu,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Eu,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=ku(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,yu.toRGBA8888)(...i)}else s=ku(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=ku(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,yu.toRGBA8888)(...i)}else s=ku(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn(`SIXEL: error while decoding image - ${t}`),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=lu.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function ku(t){return yu.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var xu={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},Du=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},xu,t),this._defaultOpts=Object.assign({},xu,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new lu(t),this._storage=new Au(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new bu(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new Mu(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=au;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};const Lu=class{constructor(s){t(this,s),this.connectionStateChanged=i(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=r.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return s(this)}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;serviceId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await n(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeDebounceHandle&&(clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=void 0),this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}is_terminal_open(){return Boolean(this.connected&&this.containerEl&&this.terminal.element)}fit_terminal_safely(){if(this.fitAddon&&this.is_terminal_open())try{this.fitAddon.fit()}catch(t){console.warn("Skipping terminal fit before renderer is ready:",t)}}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new Mr(this.terminalOptions),this.fitAddon=new yr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new Dr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new Ln,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new Ga,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new Du(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Qa,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new o(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId):new o(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([l.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([l.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([l.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case a.Error:this.handle_error(i);break;case a.AuthSuccess:this.handle_auth_success(i);break;case a.TunnelOpened:this.handle_tunnel_opened(i);break;case a.TunnelClosed:this.handle_tunnel_closed(i);break;case a.TunnelData:this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fit_terminal_safely();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0||s<=0||e<=0)console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`);else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case u.Generic:case u.Authentication:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus(),this.usernameBuffer="",this.passwordBuffer="";break;case u.RequiresUsernamePassword:case u.RequiresUsername:this.terminal.reset(),this.inputMode=r.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case u.RequiresPassword:this.terminal.reset(),this.inputMode=r.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=r.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=r.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId,this.serviceId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fit_terminal_safely(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=r.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.connected=!0,this.fit_terminal_safely(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fit_terminal_safely(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case r.Username:this.handle_username_input(t);break;case r.Password:this.handle_password_input(t);break;case r.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=r.Default,this.channel.open_ssh_tunnel(this.nodeId,this.serviceId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=r.Default,this.channel.open_ssh_tunnel(this.nodeId,this.serviceId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return e(h,{key:"8bc2181d5ca26f6e6552591b7d399f81bece3efa"},e("div",{key:"4c7085ba44cebb23f7712fbfe4ea52a9e8bde6d7",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};Lu.style=".xterm{cursor:text;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;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}";export{Lu as phirepass_terminal}