katoikia-app/web-ui/web-react/node_modules/primereact/terminal/terminal.esm.min.js

2 lines
5.6 KiB
JavaScript
Raw Normal View History

2022-07-06 04:15:11 +00:00
import e,{Component as t}from"react";import{TerminalService as n}from"primereact/terminalservice";import{classNames as r}from"primereact/utils";function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e){if(Array.isArray(e))return o(e)}function a(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function s(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e){return i(e)||a(e)||c(e)||s()}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){return f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},f(e,t)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t)}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function h(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var g,w,k,x=function(o){y(g,t);var i,a,c,s,f,d=(i=g,a=b(),function(){var e,t=v(i);if(a){var n=v(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return h(this,e)});function g(e){var t;return u(this,g),(t=d.call(this,e)).state={commandText:"",commands:[],index:0},t.onClick=t.onClick.bind(m(t)),t.onInputChange=t.onInputChange.bind(m(t)),t.onInputKeyDown=t.onInputKeyDown.bind(m(t)),t.response=t.response.bind(m(t)),t.clear=t.clear.bind(m(t)),t}return c=g,(s=[{key:"onClick",value:function(){this.input.focus()}},{key:"onInputChange",value:function(e){this.setState({commandText:e.target.value})}},{key:"onInputKeyDown",value:function(e){var t=this.state.commands;switch(e.which||e.keyCode){case 38:if(t&&t.length){var r=this.state.index-1<0?t.length-1:this.state.index-1;this.setState({index:r,commandText:t[r].text})}break;case 13:if(this.state.commandText){var o=l(t),i=this.state.commandText;o.push({text:i}),this.setState((function(e){return{index:e.index+1,commandText:"",commands:o}}),(function(){n.emit("command",i)}))}}}},{key:"response",value:function(e){var t=this.state.commands;if(t&&t.length>0){var n=l(t);n[n.length-1].response=e,this.setState({commands:n})}}},{key:"clear",value:function(){this.setState({commands:[],index:0})}},{key:"componentDidMount",value:function(){n.on("response",this.response),n.on("clear",this.clear)}},{key:"componentDidUpdate",value:function(){this.container.scrollTop=this.container.scrollHeight}},{key:"componentWillUnmount",value:function(){n.off("response",this.response),n.off("clear",this.clear)}},{key:"renderWelcomeMessage",value:function(){return this.p