(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{27:function(e,t,n){e.exports=n.p+"static/media/logo.74cdedb8.png"},32:function(e,t,n){e.exports=n(74)},38:function(e,t,n){},39:function(e,t,n){},74:function(e,t,n){"use strict";n.r(t);var a=n(0),l=n.n(a),r=n(23),o=n.n(r),s=(n(38),n(24)),i=n(25),c=n(30),m=n(26),d=n(31),u=(n(39),n(27)),p=n.n(u),w=n(28),E=n(29),h=n.n(E);function b(e){return l.a.createElement("div",{style:{overflow:"hidden",whiteSpace:"nowrap"}},l.a.createElement("div",{style:{display:"inline-block",marginRight:"5px"},className:"led led-".concat(e.color)}),l.a.createElement("span",null,e.text))}var f=function(e){function t(e){var n;return Object(s.a)(this,t),(n=Object(c.a)(this,Object(m.a)(t).call(this,e))).state={rows:n.props.rows||20,cols:n.props.cols||60,status:"connection-pending",num_clients:n.props.num_clients},n.term=new w.Terminal({cursorBlink:!0,macOptionIsMeta:!0,scrollback:1e3}),n.terminalEl=l.a.createRef(),n.term.resize(n.state.cols,n.state.rows),n}return Object(d.a)(t,e),Object(i.a)(t,[{key:"render",value:function(){return l.a.createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 4fr"}},l.a.createElement("div",{id:"stats"},l.a.createElement("a",{href:"https://github.com/cs01/termpair"},l.a.createElement("img",{src:p.a,width:"200px",alt:"logo"})),l.a.createElement("table",null,l.a.createElement("tbody",null,l.a.createElement("tr",null,l.a.createElement("td",null,"Status"),l.a.createElement("td",null,"connected"===this.state.status?l.a.createElement(b,{color:"green",text:this.state.status}):l.a.createElement(b,{color:"red",text:this.state.status}))),l.a.createElement("tr",null,l.a.createElement("td",null,"Control"),l.a.createElement("td",null,this.props.allow_browser_control?l.a.createElement(b,{color:"green",text:"enabled"}):l.a.createElement(b,{color:"orange",text:"disabled"}))),l.a.createElement("tr",null,l.a.createElement("td",null,"Connected Clients"),l.a.createElement("td",null,this.state.num_clients)),l.a.createElement("tr",null,l.a.createElement("td",null,"Broadcast start time"),l.a.createElement("td",null,h()(this.props.broadcast_start_time_iso).format("dddd, MMMM Do YYYY, h:mm:ss a"))),l.a.createElement("tr",null,l.a.createElement("td",null,"Rows"),l.a.createElement("td",null,this.state.rows)),l.a.createElement("tr",null,l.a.createElement("td",null,"Columns"),l.a.createElement("td",null,this.state.cols)))),l.a.createElement("div",{style:{position:"absolute",bottom:0,textAlign:"center"}},l.a.createElement("p",null,"Built by Chad Smith ",l.a.createElement("br",null)," ",l.a.createElement("a",{href:"https://github.com/cs01"},"GitHub")," |"," ",l.a.createElement("a",{href:"https://twitter.com/grassfedcode"},"Twitter")),l.a.createElement("p",null,"Powered by"," ",l.a.createElement("a",{href:"https://github.com/bocadilloproject/bocadillo"},"Bocadillo")))),l.a.createElement("div",{id:"content"},l.a.createElement("div",{id:"terminal",className:this.state.status,ref:this.terminalEl})))}},{key:"componentDidMount",value:function(){var e=this,t=this.term;if(t.open(document.getElementById("terminal")),t.writeln("Welcome to TermPair!"),t.writeln("https://github.com/cs01/termpair"),!this.props.terminal_id)return t.writeln(""),t.writeln("A valid terminal id was not provided."),t.writeln("To view or broadcast a terminal, see instructions at"),t.writeln("https://github.com/cs01/termpair"),void this.setState({status:"disconnected"});t.writeln("Connecting to terminal...");var n="https:"===window.location.protocol?"wss":"ws",a=new WebSocket("".concat(n,"://").concat(window.location.hostname,":").concat(window.location.port,"/connect_browser_to_terminal?id=").concat(this.props.terminal_id));t.on("key",function(e,t){a.send(e)}),a.addEventListener("open",function(n){e.setState({status:"connected"}),t.writeln("Connection established")}),a.addEventListener("close",function(n){e.setState({status:"disconnected"}),t.writeln("Connection ended"),e.setState({num_clients:0})}),a.addEventListener("message",function(n){var a=JSON.parse(n.data);"new_output"===a.event?t.write(atob(a.payload)):"resize"===a.event?(clearTimeout(e.resizeTimeout),e.resizeTimeout=setTimeout(function(){e.term.resize(a.payload.cols,a.payload.rows),e.setState({rows:a.payload.rows,cols:a.payload.cols})},500)):"num_clients"===a.event?e.setState({num_clients:a.payload}):console.error("unknown event type",a)})}}]),t}(a.Component);o.a.render(l.a.createElement(f,window.initial_data),document.getElementById("root"))}},[[32,1,2]]]);
//# sourceMappingURL=main.418b1700.chunk.js.map