(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{11:function(t,e,a){t.exports=a(21)},17:function(t,e,a){},20:function(t,e,a){},21:function(t,e,a){"use strict";a.r(e);var n=a(0),o=a.n(n),s=a(4),c=a.n(s),l=(a(17),a(1)),i=a(2),r=a.n(i),u=a(5),h=a(6),m=a(7),d=a(9),_=a(8),v=a(10),f=(a(20),new URLSearchParams(document.location.search)),p=f.get("host"),g=parseInt(f.get("port")),w=function(t){function e(){var t,a;Object(h.a)(this,e);for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(a=Object(d.a)(this,(t=Object(_.a)(e)).call.apply(t,[this].concat(o)))).interval=null,a.el=null,a.state={__groups:new Set,__selection:null,__autoScroll:!0,__connected:!1},a}return Object(v.a)(e,t),Object(m.a)(e,[{key:"componentWillUnmount",value:function(){this.interval&&(clearInterval(this.interval),this.interval=null)}},{key:"componentDidMount",value:function(){var t=Object(u.a)(r.a.mark(function t(){var e,a,n=this;return r.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=null,this.interval=setInterval(function(){e&&3!=e.readyState||a(),1!=e.readyState||n.state.__connected||n.setState({__connected:!0})},500),a=function(){(e=new WebSocket("ws://".concat(p,":").concat(g))).onmessage=function(t){var e=JSON.parse(t.data);n.addMessage(e)},e.onclose=function(){n.setState({__connected:!1})}};case 3:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"addMessage",value:function(t){if(this.state.__selection||this.setState({__selection:t.alias}),!this.state.__groups.has(t.alias)){var e=new Set(this.state.__groups);e.add(t.alias),this.setState({__groups:e})}if(this.state[t.alias]){var a=this.state[t.alias].concat(t);a.length>5e3&&a.shift(),this.setState(Object(l.a)({},t.alias,a))}else this.setState(Object(l.a)({},t.alias,[t]))}},{key:"componentDidUpdate",value:function(){this.state.__autoScroll&&this.scrollToBottom()}},{key:"scrollToBottom",value:function(){var t=this.el.scrollHeight-this.el.clientHeight;this.el.scrollTop=t>0?t:0}},{key:"render",value:function(){var t=this;return console.log(this.state.__autoScroll),o.a.createElement("div",{className:"App"},o.a.createElement("header",null,o.a.createElement("h1",{className:this.state.__connected?"":"offline"},"Hoist ",o.a.createElement("span",null,this.state.__selection)),o.a.createElement("span",null,"Connected to wss://",p,":",g)),o.a.createElement("div",{className:"grid"},o.a.createElement("div",{id:"controls"},o.a.createElement("div",{className:"item"},o.a.createElement("label",{htmlFor:"auto-scroll"},o.a.createElement("input",{id:"auto-scroll",type:"checkbox",value:this.state.__autoScroll,onChange:function(e){t.setState({__autoScroll:e.target.checked})}})," Auto-scroll"))),o.a.createElement("nav",null,Array.from(this.state.__groups).sort().map(function(e){return o.a.createElement("div",null,o.a.createElement("a",{key:e,href:"#",onClick:function(){return t.setState({__selection:e})}},e))})),o.a.createElement("main",{ref:function(e){t.el=e}},(this.state[this.state.__selection]||[]).map(function(t){return o.a.createElement("div",{key:t.id,className:"std ".concat(t.std)},t.message)}))))}}]),e}(n.Component);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));c.a.render(o.a.createElement(w,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(t){t.unregister()})}},[[11,1,2]]]);
//# sourceMappingURL=main.2b2d99ed.chunk.js.map