@seasongold4/webssh2-frontend-fixed
Version:
WebSSH2 前端终端库 - 修复版本,完全兼容原项目后端,解决终端显示乱码问题
1 lines • 370 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WebSSHClient",[],t):"object"==typeof exports?exports.WebSSHClient=t():e.WebSSHClient=t()}("undefined"!=typeof self?self:this,(()=>(()=>{var e={7:function(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.Socket=t.Manager=t.protocol=void 0,t.io=c,t.connect=c,t.default=c;const r=i(894),n=i(776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return n.Manager}});const o=i(214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,s(i(833)).default)("socket.io-client"),h={};function c(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const i=(0,r.url)(e,t.path||"/socket.io"),s=i.source,o=i.id,c=i.path,l=h[o]&&c in h[o].nsps;let d;return t.forceNew||t["force new connection"]||!1===t.multiplex||l?(a("ignoring socket cache for %s",s),d=new n.Manager(s,t)):(h[o]||(a("new io instance for %s",s),h[o]=new n.Manager(s,t)),d=h[o]),i.query&&!t.query&&(t.query=i.queryKey),d.socket(i.path,t)}Object.assign(c,{Manager:n.Manager,Socket:o.Socket,io:c,connect:c});var l=i(627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return l.protocol}});var d=i(956);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return d.Fetch}}),Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.NodeXHR}}),Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return d.XHR}}),Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return d.NodeWebSocket}}),Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return d.WebSocket}}),Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return d.WebTransport}}),e.exports=c},15:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=function(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let o=i.exec(e||""),a={},h=14;for(;h--;)a[s[h]]=o[h]||"";return-1!=r&&-1!=n&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const i=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||i.splice(0,1),"/"==t.slice(-1)&&i.splice(i.length-1,1),i}(0,a.path),a.queryKey=function(e,t){const i={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,s){t&&(i[t]=s)})),i}(0,a.query),a};const i=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,s=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]},46:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const i=Object.create(null);t.PACKET_TYPES=i,i.open="0",i.close="1",i.ping="2",i.pong="3",i.message="4",i.upgrade="5",i.noop="6";const s=Object.create(null);t.PACKET_TYPES_REVERSE=s,Object.keys(i).forEach((e=>{s[i[e]]=e})),t.ERROR_PACKET={type:"error",data:"parser error"}},71:function(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XHR=t.Request=t.BaseXHR=void 0;const r=i(528),n=i(454),o=i(374),a=i(624),h=i(110),c=(0,s(i(833)).default)("engine.io-client:polling");function l(){}class d extends r.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let i=location.port;i||(i=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,t){const i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){c("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}t.BaseXHR=d;class u extends n.Emitter{constructor(e,t,i){super(),this.createRequest=e,(0,o.installTimerFunctions)(this,i),this._opts=i,this._method=i.method||"GET",this._uri=t,this._data=void 0!==i.data?i.data:null,this._create()}_create(){var e;const t=(0,o.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(t);try{c("xhr open %s: %s",this._method,this._uri),i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&i.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{i.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var e;3===i.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(i.getResponseHeader("set-cookie"))),4===i.readyState&&(200===i.status||1223===i.status?this._onLoad():this.setTimeoutFn((()=>{this._onError("number"==typeof i.status?i.status:0)}),0))},c("xhr data %s",this._data),i.send(this._data)}catch(e){return void this.setTimeoutFn((()=>{this._onError(e)}),0)}"undefined"!=typeof document&&(this._index=u.requestsCount++,u.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=l,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete u.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(t.Request=u,u.requestsCount=0,u.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",_);else if("function"==typeof addEventListener){const e="onpagehide"in a.globalThisShim?"pagehide":"unload";addEventListener(e,_,!1)}function _(){for(let e in u.requests)u.requests.hasOwnProperty(e)&&u.requests[e].abort()}const f=function(){const e=p({xdomain:!1});return e&&null!==e.responseType}();function p(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||h.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}t.XHR=class extends d{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=f&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new u(p,this.uri(),e)}}},110:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let i=!1;try{i="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=i},133:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasBinary=t.isBinary=void 0;const i="function"==typeof ArrayBuffer,s=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),n="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);function o(e){return i&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||r&&e instanceof Blob||n&&e instanceof File}t.isBinary=o,t.hasBinary=function e(t,i){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let i=0,s=t.length;i<s;i++)if(e(t[i]))return!0;return!1}if(o(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&e(t[i]))return!0;return!1}},156:function(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.WebSSHTerminal=t.WebSSHClient=void 0;var r=i(297);Object.defineProperty(t,"WebSSHClient",{enumerable:!0,get:function(){return r.WebSSHClient}});var n=i(386);Object.defineProperty(t,"WebSSHTerminal",{enumerable:!0,get:function(){return n.WebSSHTerminal}});var o=i(297);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return s(o).default}})},195:e=>{var t;self,t=()=>(()=>{"use strict";var e,t={};return e=t,Object.defineProperty(e,"__esModule",{value:!0}),e.FitAddon=void 0,e.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const i=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),h=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-i;return{cols:Math.max(2,Math.floor(h/t.css.cell.width)),rows:Math.max(1,Math.floor(a/t.css.cell.height))}}},t})(),e.exports=t()},209:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetch=void 0;const s=i(528);class r extends s.Polling{doPoll(){this._fetch().then((e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then((e=>this.onData(e)))})).catch((e=>{this.onError("fetch read error",e)}))}doWrite(e,t){this._fetch(e).then((e=>{if(!e.ok)return this.onError("fetch write error",e.status,e);t()})).catch((e=>{this.onError("fetch write error",e)}))}_fetch(e){var t;const i=void 0!==e,s=new Headers(this.opts.extraHeaders);return i&&s.set("content-type","text/plain;charset=UTF-8"),null===(t=this.socket._cookieJar)||void 0===t||t.appendCookies(s),fetch(this.uri(),{method:i?"POST":"GET",body:i?e:null,headers:s,credentials:this.opts.withCredentials?"include":"omit"}).then((e=>{var t;return null===(t=this.socket._cookieJar)||void 0===t||t.parseCookies(e.headers.getSetCookie()),e}))}}t.Fetch=r},214:function(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const r=i(627),n=i(942),o=i(454),a=(0,s(i(833)).default)("socket.io-client:socket"),h=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends o.Emitter{constructor(e,t,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,n.on)(e,"open",this.onopen.bind(this)),(0,n.on)(e,"packet",this.onpacket.bind(this)),(0,n.on)(e,"error",this.onerror.bind(this)),(0,n.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var i,s,n;if(h.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:r.PacketType.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const i=t.pop();this._registerAckCallback(e,i),o.id=e}const c=null===(s=null===(i=this.io.engine)||void 0===i?void 0:i.transport)||void 0===s?void 0:s.writable,l=this.connected&&!(null===(n=this.io.engine)||void 0===n?void 0:n._hasPingExpired());return this.flags.volatile&&!c?a("discard packet as the transport is not currently writable"):l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o),this.flags={},this}_registerAckCallback(e,t){var i;const s=null!==(i=this.flags.timeout)&&void 0!==i?i:this._opts.ackTimeout;if(void 0===s)return void(this.acks[e]=t);const r=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))}),s),n=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};n.withError=!0,this.acks[e]=n}emitWithAck(e,...t){return new Promise(((i,s)=>{const r=(e,t)=>e?s(e):i(t);r.withError=!0,t.push(r),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...s)=>{if(i===this._queue[0])return null!==e?i.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",i.id,i.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",i.id),this._queue.shift(),t&&t(null,...s)),i.pending=!1,this._drainQueue()})),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:r.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((e=>{if(!this.sendBuffer.some((t=>String(t.id)===e))){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}}))}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case r.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case r.PacketType.EVENT:case r.PacketType.BINARY_EVENT:this.onevent(e);break;case r.PacketType.ACK:case r.PacketType.BINARY_ACK:this.onack(e);break;case r.PacketType.DISCONNECT:this.ondisconnect();break;case r.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const i of t)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let i=!1;return function(...s){i||(i=!0,a("sending ack %j",s),t.packet({type:r.PacketType.ACK,id:e,data:s}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:r.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const i of t)i.apply(this,e.data)}}}t.Socket=c},223:function(e,t,i){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=t.SocketWithUpgrade=t.SocketWithoutUpgrade=void 0;const r=i(419),n=i(374),o=i(661),a=i(15),h=i(454),c=i(376),l=i(624),d=(0,s(i(833)).default)("engine.io-client:socket"),u="function"==typeof addEventListener&&"function"==typeof removeEventListener,_=[];u&&addEventListener("offline",(()=>{d("closing %d connection(s) because the network was lost",_.length),_.forEach((e=>e()))}),!1);class f extends h.Emitter{constructor(e,t){if(super(),this.binaryType=l.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const i=(0,a.parse)(e);t.hostname=i.host,t.secure="https"===i.protocol||"wss"===i.protocol,t.port=i.port,i.query&&(t.query=i.query)}else t.host&&(t.hostname=(0,a.parse)(t.host).host);(0,n.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach((e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e})),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,o.decode)(this.opts.query)),u&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(d("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},_.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,l.createCookieJar)()),this._open()}createTransport(e){d('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=c.protocol,t.transport=e,this.id&&(t.sid=this.id);const i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return d("options: %j",i),new this._transportsByName[e](i)}_open(){if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);const e=this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){d("setting transport %s",e.name),this.transport&&(d("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",(e=>this._onClose("transport close",e)))}onOpen(){d("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(d('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else d('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn((()=>{this._onClose("ping timeout")}),e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();d("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const i=this.writeBuffer[t].data;if(i&&(e+=(0,n.byteLength)(i)),t>0&&e>this._maxPayload)return d("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return d("payload size is %d (max: %d)",e,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(d("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,l.nextTick)((()=>{this._onClose("ping timeout")}),this.setTimeoutFn)),e}write(e,t,i){return this._sendPacket("message",e,t,i),this}send(e,t,i){return this._sendPacket("message",e,t,i),this}_sendPacket(e,t,i,s){if("function"==typeof t&&(s=t,t=void 0),"function"==typeof i&&(s=i,i=null),"closing"===this.readyState||"closed"===this.readyState)return;(i=i||{}).compress=!1!==i.compress;const r={type:e,data:t,options:i};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),s&&this.once("flush",s),this.flush()}close(){const e=()=>{this._onClose("forced close"),d("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?i():e()})):this.upgrading?i():e()),this}_onError(e){if(d("socket error %j",e),f.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return d("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(d('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),u&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=_.indexOf(this._offlineEventListener);-1!==e&&(d("removing listener for the 'offline' event"),_.splice(e,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}t.SocketWithoutUpgrade=f,f.protocol=c.protocol;class p extends f{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade){d("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){d('probing transport "%s"',e);let t=this.createTransport(e),i=!1;f.priorWebsocketSuccess=!1;const s=()=>{i||(d('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(s=>{if(!i)if("pong"===s.type&&"probe"===s.data){if(d('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,d('pausing current transport "%s"',this.transport.name),this.transport.pause((()=>{i||"closed"!==this.readyState&&(d("changing transport and sending upgrade packet"),c(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{d('probe transport "%s" failed',e);const i=new Error("probe error");i.transport=t.name,this.emitReserved("upgradeError",i)}})))};function r(){i||(i=!0,c(),t.close(),t=null)}const n=i=>{const s=new Error("probe error: "+i);s.transport=t.name,r(),d('probe transport "%s" failed because of error: %s',e,i),this.emitReserved("upgradeError",s)};function o(){n("transport closed")}function a(){n("socket closed")}function h(e){t&&e.name!==t.name&&(d('"%s" works - aborting "%s"',e.name,t.name),r())}const c=()=>{t.removeListener("open",s),t.removeListener("error",n),t.removeListener("close",o),this.off("close",a),this.off("upgrading",h)};t.once("open",s),t.once("error",n),t.once("close",o),this.once("close",a),this.once("upgrading",h),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{i||t.open()}),200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let i=0;i<e.length;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}}t.SocketWithUpgrade=p,t.Socket=class extends p{constructor(e,t={}){const i="object"==typeof e?e:t;(!i.transports||i.transports&&"string"==typeof i.transports[0])&&(i.transports=(i.transports||["polling","websocket","webtransport"]).map((e=>r.transports[e])).filter((e=>!!e))),super(e,i)}}},297:function(e,t,i){"use strict";var s=this&&this.__assign||function(){return s=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.WebSSHClient=void 0;var r=i(7),n=i(975),o=i(195),a=function(){function e(e,t){if(this.socket=null,this.sessionLogEnable=!1,this.loggedData=!1,this.allowreplay=!1,this.allowreauth=!1,this.sessionLog="",this.sessionFooter="",this.logDate=null,this.currentDate=null,this.myFile="",this.errorExists=!1,this.hasCountdownStarted=!1,"string"==typeof e){var i=document.getElementById(e);if(!i)throw new Error("Container element with id '".concat(e,"' not found"));this.container=i}else this.container=e;this.config=s({socketPath:"/ssh/socket.io"},t),this.setupUI(),this.initTerminal()}return e.prototype.setupUI=function(){this.container.innerHTML='\n <div class="box">\n <div id="header"></div>\n <div id="terminal-container" class="terminal"></div>\n <div id="bottomdiv">\n <div class="dropup" id="menu">\n <i class="fas fa-bars fa-fw"></i> Menu\n <div id="dropupContent" class="dropup-content">\n <a id="logBtn"><i class="fas fa-clipboard fa-fw"></i> Start Log</a>\n <a id="downloadLogBtn"><i class="fas fa-download fa-fw"></i> Download Log</a>\n <a id="reauthBtn" style="display: none;"><i class="fas fa-key fa-fw"></i> Switch User</a>\n <a id="credentialsBtn" style="display: none;"><i class="fas fa-key fa-fw"></i> Credentials</a>\n </div>\n </div>\n <div id="footer"></div>\n <div id="status"></div>\n <div id="countdown"></div>\n </div>\n </div>\n ',this.addOriginalStyles(),this.getDOMElements()},e.prototype.getDOMElements=function(){this.logBtn=this.container.querySelector("#logBtn"),this.credentialsBtn=this.container.querySelector("#credentialsBtn"),this.reauthBtn=this.container.querySelector("#reauthBtn"),this.downloadLogBtn=this.container.querySelector("#downloadLogBtn"),this.status=this.container.querySelector("#status"),this.header=this.container.querySelector("#header"),this.footer=this.container.querySelector("#footer"),this.countdown=this.container.querySelector("#countdown"),this.terminalContainer=this.container.querySelector("#terminal-container")},e.prototype.addOriginalStyles=function(){var e=document.createElement("style");e.textContent="\n .webssh-original {\n font-family: helvetica, sans-serif, arial;\n font-size: 1em;\n background-color: rgb(0, 0, 0);\n color: rgb(240, 240, 240);\n height: 100%;\n margin: 0;\n width: 100%;\n position: relative;\n }\n \n .webssh-original #header {\n color: rgb(240, 240, 240);\n background-color: rgb(0, 128, 0);\n width: 100%;\n border-color: white;\n border-style: none none solid none;\n border-width: 1px;\n text-align: center;\n flex: 0 1 auto;\n z-index: 99;\n height: 19px;\n display: none;\n }\n \n .webssh-original .box {\n display: block;\n height: 100%;\n }\n \n .webssh-original #terminal-container {\n display: block;\n width: calc(100% - 1px);\n margin: 0 auto;\n padding: 2px;\n height: calc(100% - 19px);\n }\n \n .webssh-original #terminal-container .terminal {\n background-color: #000000;\n color: #fafafa;\n padding: 2px;\n height: calc(100% - 19px);\n }\n \n .webssh-original #terminal-container .terminal:focus .terminal-cursor {\n background-color: #fafafa;\n }\n \n .webssh-original #bottomdiv {\n position: fixed;\n left: 0;\n bottom: 0;\n width: 100%;\n background-color: rgb(50, 50, 50);\n border-color: white;\n border-style: solid none none none;\n border-width: 1px;\n z-index: 99;\n height: 19px;\n }\n \n .webssh-original #footer {\n display: inline-block;\n color: rgb(240, 240, 240);\n background-color: rgb(50, 50, 50);\n padding-left: 5px;\n padding-right: 5px;\n border-color: white;\n border-style: none none none solid;\n border-width: 1px;\n text-align: left;\n }\n \n .webssh-original #status {\n display: inline-block;\n color: rgb(240, 240, 240);\n background-color: rgb(50, 50, 50);\n padding-left: 10px;\n padding-right: 10px;\n border-color: white;\n border-style: none solid none solid;\n border-width: 1px;\n text-align: left;\n z-index: 100;\n }\n \n .webssh-original #countdown {\n display: none;\n color: rgb(240, 240, 240);\n background-color: rgb(50, 50, 50);\n padding-left: 10px;\n padding-right: 10px;\n border-color: white;\n border-style: none solid none solid;\n border-width: 1px;\n text-align: left;\n z-index: 100;\n }\n \n .webssh-original #countdown.active {\n display: inline-block;\n animation: countdown infinite alternate 200ms;\n }\n \n @keyframes countdown {\n from { background-color: rgb(255, 255, 0); }\n to { background-color: inherit; }\n }\n \n .webssh-original #menu {\n display: inline-block;\n font-size: 16px;\n color: rgb(255, 255, 255);\n padding-left: 10px;\n z-index: 100;\n }\n \n .webssh-original #menu:hover .dropup-content {\n display: block;\n }\n \n .webssh-original #logBtn, \n .webssh-original #credentialsBtn, \n .webssh-original #reauthBtn {\n color: #000;\n }\n \n .webssh-original .dropup {\n position: relative;\n display: inline-block;\n cursor: pointer;\n }\n \n .webssh-original .dropup-content {\n display: none;\n position: absolute;\n background-color: #f1f1f1;\n font-size: 16px;\n min-width: 160px;\n bottom: 18px;\n z-index: 101;\n }\n \n .webssh-original .dropup-content a {\n color: #777;\n padding: 12px 16px;\n text-decoration: none;\n display: block;\n }\n \n .webssh-original .dropup-content a:hover {\n background-color: #ccc;\n }\n \n .webssh-original .dropup:hover .dropup-content {\n display: block;\n }\n \n .webssh-original .dropup:click .dropup-content {\n display: block;\n }\n \n .webssh-original .dropup:hover .dropbtn {\n background-color: #3e8e41;\n }\n ",this.container.classList.add("webssh-original"),document.head.querySelector("#webssh-original-styles")||(e.id="webssh-original-styles",document.head.appendChild(e))},e.prototype.initTerminal=function(){var e=this;this.terminal=new n.Terminal,this.fitAddon=new o.FitAddon,this.terminal.loadAddon(this.fitAddon),this.terminal.open(this.terminalContainer),this.terminal.focus(),this.fitAddon.fit(),this.terminal.onData((function(t){e.socket&&e.socket.emit("data",t)})),window.addEventListener("resize",(function(){return e.resizeScreen()}),!1),this.terminal.onTitleChange((function(e){document.title=e}))},e.prototype.connect=function(){var e=this.config.socketUrl;this.socket=(0,r.io)(e,{path:this.config.socketPath,transports:["websocket"]}),this.setupOriginalSocketEvents()},e.prototype.setupOriginalSocketEvents=function(){var e=this;this.socket&&(this.socket.on("connect",(function(){var t,i;e.socket.emit("geometry",e.terminal.cols,e.terminal.rows),null===(i=(t=e.config).onConnected)||void 0===i||i.call(t)})),this.socket.on("data",(function(t){var i,s;e.terminal.write(t),e.sessionLogEnable&&(e.sessionLog+=t),null===(s=(i=e.config).onData)||void 0===s||s.call(i,t)})),this.socket.on("setTerminalOpts",(function(t){e.terminal.options.cursorBlink=t.cursorBlink,e.terminal.options.scrollback=t.scrollback,e.terminal.options.tabStopWidth=t.tabStopWidth})),this.socket.on("title",(function(e){document.title=e})),this.socket.on("menu",(function(){e.drawMenu()})),this.socket.on("status",(function(t){e.status.innerHTML=t})),this.socket.on("ssherror",(function(t){var i,s;e.status.innerHTML=t,e.status.style.backgroundColor="red",e.errorExists=!0,null===(s=(i=e.config).onError)||void 0===s||s.call(i,t)})),this.socket.on("header",(function(t){t&&(e.header.innerHTML=t,e.header.style.display="block",e.terminalContainer.style.height="calc(100% - 38px)",e.resizeScreen())})),this.socket.on("footer",(function(t){e.sessionFooter=t,e.footer.innerHTML=t})),this.socket.on("headerBackground",(function(t){e.header.style.backgroundColor=t})),this.socket.on("statusBackground",(function(t){e.status.style.backgroundColor=t})),this.socket.on("allowreplay",(function(t){!0===t?(e.allowreplay=!0,e.drawMenu()):e.allowreplay=!1})),this.socket.on("allowreauth",(function(t){!0===t?(e.allowreauth=!0,e.drawMenu()):e.allowreauth=!1})),this.socket.on("reauth",(function(){e.allowreauth&&e.reauthSession()})),this.socket.on("disconnect",(function(t){var i,s;e.errorExists||(e.status.style.backgroundColor="red",e.status.innerHTML="WEBSOCKET SERVER DISCONNECTED: ".concat(t)),e.socket.io.opts.reconnection=!1,e.countdown.classList.remove("active"),null===(s=(i=e.config).onDisconnected)||void 0===s||s.call(i)})),this.socket.on("error",(function(t){var i,s;e.errorExists||(e.status.style.backgroundColor="red",e.status.innerHTML="ERROR: ".concat(t)),null===(s=(i=e.config).onError)||void 0===s||s.call(i,t)})),this.socket.on("shutdownCountdownUpdate",(function(t){e.hasCountdownStarted||(e.countdown.classList.add("active"),e.hasCountdownStarted=!0),e.countdown.innerText="Shutting down in ".concat(t,"s")})))},e.prototype.drawMenu=function(){this.logBtn.addEventListener("click",this.toggleLog.bind(this)),this.allowreauth&&(this.reauthBtn.addEventListener("click",this.reauthSession.bind(this)),this.reauthBtn.style.display="block"),this.allowreplay&&(this.credentialsBtn.addEventListener("click",this.replayCredentials.bind(this)),this.credentialsBtn.style.display="block"),this.loggedData&&(this.downloadLogBtn.addEventListener("click",this.downloadLog.bind(this)),this.downloadLogBtn.style.display="block")},e.prototype.resizeScreen=function(){this.fitAddon.fit(),this.socket&&this.socket.emit("resize",{cols:this.terminal.cols,rows:this.terminal.rows})},e.prototype.toggleLog=function(){if(!0===this.sessionLogEnable)return this.sessionLogEnable=!1,this.loggedData=!0,this.logBtn.innerHTML='<i class="fas fa-clipboard fa-fw"></i> Start Log',this.currentDate=new Date,this.sessionLog="".concat(this.sessionLog,"\r\n\r\nLog End for ").concat(this.sessionFooter,": ").concat(this.currentDate.getFullYear(),"/").concat(this.currentDate.getMonth()+1,"/").concat(this.currentDate.getDate()," @ ").concat(this.currentDate.getHours(),":").concat(this.currentDate.getMinutes(),":").concat(this.currentDate.getSeconds(),"\r\n"),this.logDate=this.currentDate,void this.terminal.focus();this.sessionLogEnable=!0,this.loggedData=!0,this.logBtn.innerHTML='<i class="fas fa-cog fa-spin fa-fw"></i> Stop Log',this.downloadLogBtn.style.color="#000",this.downloadLogBtn.addEventListener("click",this.downloadLog.bind(this)),this.currentDate=new Date,this.sessionLog="Log Start for ".concat(this.sessionFooter,": ").concat(this.currentDate.getFullYear(),"/").concat(this.currentDate.getMonth()+1,"/").concat(this.currentDate.getDate()," @ ").concat(this.currentDate.getHours(),":").concat(this.currentDate.getMinutes(),":").concat(this.currentDate.getSeconds(),"\r\n\r\n"),this.logDate=this.currentDate,this.terminal.focus()},e.prototype.downloadLog=function(){if(!0===this.loggedData&&this.logDate){this.myFile="WebSSH2-".concat(this.logDate.getFullYear()).concat(this.logDate.getMonth()+1).concat(this.logDate.getDate(),"_").concat(this.logDate.getHours()).concat(this.logDate.getMinutes()).concat(this.logDate.getSeconds(),".log");var e=new Blob([this.sessionLog.replace(/[\u001b\u009b][[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><;]/g,"")],{type:"text/plain"});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveBlob(e,this.myFile);else{var t=window.document.createElement("a");t.href=window.URL.createObjectURL(e),t.download=this.myFile,document.body.appendChild(t),t.click(),document.body.removeChild(t)}}this.terminal.focus()},e.prototype.replayCredentials=function(){this.socket&&this.socket.emit("control","replayCredentials"),this.terminal.focus()},e.prototype.reauthSession=function(){window.location.href="/ssh/reauth"},e.prototype.disconnect=function(){this.socket&&(this.socket.disconnect(),this.socket=null)},e.prototype.destroy=function(){this.disconnect(),this.terminal&&this.terminal.dispose()},e}();t.WebSSHClient=a,t.default=a},374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pick=function(e,...t){return t.reduce(((t,i)=>(e.hasOwnProperty(i)&&(t[i]=e[i]),t)),{})},t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=r.bind(s.globalThisShim),e.clearTimeoutFn=n.bind(s.globalThisShim)):(e.setTimeoutFn=s.globalThisShim.setTimeout.bind(s.globalThisShim),e.clearTimeoutFn=s.globalThisShim.clearTimeout.bind(s.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,i=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?i+=1:t<2048?i+=2:t<55296||t>=57344?i+=3:(s++,i+=4);return i}(e):Math.ceil((e.byteLength||e.size)*o)},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const s=i(624),r=s.globalThisShim.setTimeout,n=s.globalThisShim.clearTimeout,o=1.33},376:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=void 0,t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,s.encodePacketToBinary)(e,(i=>{const s=i.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,s)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(s))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(i)}))}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const i=[];let s=0,o=-1,l=!1;return new TransformStream({transform(d,u){for(i.push(d);;){if(0===s){if(h(i)<1)break;const e=c(i,1);l=!(128&~e[0]),o=127&e[0],s=o<126?3:126===o?1:2}else if(1===s){if(h(i)<2)break;const e=c(i,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),s=3}else if(2===s){if(h(i)<8)break;const e=c(i,8),t=new DataView(e.buffer,e.byteOffset,e.length),r=t.getUint32(0);if(r>Math.pow(2,21)-1){u.enqueue(n.ERROR_PACKET);break}o=r*Math.pow(2,32)+t.getUint32(4),s=3}else{if(h(i)<o)break;const e=c(i,o);u.enqueue((0,r.decodePacket)(l?e:a.decode(e),t)),s=0}if(0===o||o>e){u.enqueue(n.ERROR_PACKET);break}}}})};const s=i(686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return s.encodePacket}});const r=i(662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return r.decodePacket}});const n=i(46),o=String.fromCharCode(30);let a;function h(e){return e.reduce(((e,t)=>e+t.length),0)}function c(e,t){if(e[0].length===t)return e.shift();const i=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)i[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),i}t.encodePayload=(e,t)=>{const i=e.length,r=new Array(i);let n=0;e.forEach(((e,a)=>{(0,s.encodePacket)(e,!1,(e=>{r[a]=e,++n===i&&t(r.join(o))}))}))},t.decodePayload=(e,t)=>{const i=e.split(o),s=[];for(let e=0;e<i.length;e++){const n=(0,r.decodePacket)(i[e],t);if(s.push(n),"error"===n.type)break}return s},t.protocol=4},386:function(e,t,i){"use strict";var s=this&&this.__assign||function(){return s=Object.assign||function(e){for(var t,i=1,s=arguments.length;i<s;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.WebSSHTerminal=void 0,t.createWebSSHTerminal=function(e,t){return new h(e,t)};var r=i(975),n=i(195),o=i(727),a=i(7),h=function(){function e(e,t){if(this.socket=null,this.isConnected=!1,"string"==typeof e){var i=document.getElementById(e);if(!i)throw new Error("Container element with id '".concat(e,"' not found"));this.container=i}else this.container=e;this.config=s({socketPath:"/socket.io",terminal:s({theme:{background:"#000000",foreground:"#ffffff",cursor:"#ffffff"},fontSize:14,fontFamily:'Monaco, Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',cursorBlink:!0,scrollback:1e3},t.terminal),ui:s({headerText:"SSH Terminal",headerBackground:"#2c3e50",showReconnectButton:!0},t.ui)},t),this.initTerminal(),this.setupUI()}return e.prototype.initTerminal=function(){var e,t,i,s,a,h,c,l=this;this.terminal=new r.Terminal({theme:null===(e=this.config.terminal)||void 0===e?void 0:e.theme,fontSize:null===(t=this.config.terminal)||void 0===t?void 0:t.fontSize,fontFamily:null===(i=this.config.terminal)||void 0===i?void 0:i.fontFamily,cursorBlink:null===(s=this.config.terminal)||void 0===s?void 0:s.cursorBlink,scrollback:null===(a=this.config.terminal)||void 0===a?void 0:a.scrollback,cols:null===(h=this.config.terminal)||void 0===h?void 0:h.cols,rows:null===(c=this.config.terminal)||void 0===c?void 0:c.rows}),this.fitAddon=new n.FitAddon,this.terminal.loadAddon(this.fitAddon),this.terminal.loadAddon(new o.WebLinksAddon),this.terminal.open(this.container.querySelector(".terminal-content")),this.fitAddon.fit(),this.terminal.onData((function(e){l.socket&&l.isConnected&&l.socket.emit("terminal-input",e)})),this.terminal.onResize((function(e){l.socket&&l.isConnected&&l.socket.emit("terminal-resize",{cols:e.cols,rows:e.rows})})),window.addEventListener("resize",(function(){l.fitAddon.fit()}))},e.prototype.setupUI=function(){var e,t,i,s=this;this.container.innerHTML='\n <div class="webssh-terminal">\n <div class="terminal-header" style="background-color: '.concat(null===(e=this.config.ui)||void 0===e?void 0:e.headerBackground,'">\n <span class="header-text">').concat(null===(t=this.config.ui)||void 0===t?void 0:t.headerText,'</span>\n <div class="header-controls">\n <span class="connection-status">连接中...</span>\n ').concat((null===(i=this.config.ui)||void 0===i?void 0:i.showReconnectButton)?'<button class="reconnect-btn" style="display: none;">重新连接</button>':"",'\n </div>\n </div>\n <div class="terminal-content"></div>\n </div>\n '),this.addStyles();var r=this.container.querySelector(".reconnect-btn");r&&r.addEventListener("click",(function(){s.connect()}))},e.prototype.addStyles=function(){var e=document.createElement("style");e.textContent="\n .webssh-terminal {\n display: flex;\n flex-direction: column;\n height: 100%;\n border: 1px solid #ddd;\n border-radius: 4px;\n overflow: hidden;\n }\n .terminal-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 16px;\n color: white;\n font-size: 14px;\n font-weight: 500;\n }\n .header-controls {\n display: flex;\n align-items: center;\n gap: 10px;\n }\n .connection-status {\n font-size: 12px;\n opacity: 0.8;\n }\n .reconnect-btn {\n background: rgba(255,255,255,0.2);\n border: 1px solid rgba(255,255,255,0.3);\n color: white;\n padding: 4px 8px;\n border-radius: 3px;\n cursor: pointer;\n font-size: 12px;\n }\n .reconnect-btn:hover {\n background: rgba(255,255,255,0.3);\n }\n .terminal-content {\n flex: 1;\n padding: 8px;\n background: #000;\n }\n .status-connected { color: #2ecc71; }\n .status-disconnected { color: #e74c3c; }\n .status-connecting { color: #f39c12; }\n ",document.head.appendChild(e)},e.prototype.connect=function(){var e=this.config.socketUrl||window.location.origin;this.socket=(0,a.io)(e,{path:this.config.socketPath,transports:["websocket"]}),this.setupSocketEvents(),this.updateConnectionStatus("connecting"),this.socket.emit("ssh-connect",{host:this.config.host,port:this.config.port||22,username:this.config.username,password:this.config.password,privateKey:this.config.privateKey,terminalSize:{cols:this.terminal.cols,rows:this.t