!function n(e,t,r){function o(i,s){if(!t[i]){if(!e[i]){var u="function"==typeof require&&require;if(!s&&u)return u(i,!0);if(c)return c(i,!0);throw new Error("Cannot find module '"+i+"'")}var h=t[i]={exports:{}};e[i][0].call(h.exports,function(n){var t=e[i][1][n];return o(t?t:n)},h,h.exports,n,e,t,r)}return t[i].exports}for(var c="function"==typeof require&&require,i=0;i=t?0>=e:e>=0;n=0>=t?++e:--e)r.push(this.sync_process_order.unshift(arguments[n]));return r},n}(),e.exports=t},{}],2:[function(n){var e,t,r=function(n,e){return function(){return n.apply(e,arguments)}},o={}.hasOwnProperty,c=function(n,e){function t(){this.constructor=n}for(var r in e)o.call(e,r)&&(n[r]=e[r]);return t.prototype=e.prototype,n.prototype=new t,n.__super__=e.prototype,n};e=n("../connector"),window.PeerJsConnector=t=function(n){function e(n,t){var o;this.id=n,this._addConnection=r(this._addConnection,this),e.__super__.constructor.call(this),o=this,this.sync_process_order.push(function(){var n,e,t;return t=function(){var t,r;t=o.connections,r=[];for(e in t)n=t[e],r.push(e);return r}()}),this.sync_process_order.push(function(n){var e,t,r;for(t=0,r=n.length;r>t;t++)e=n[t],o.join(e);return!0}),this.conn=new Peer(this.id,t),this.conn.on("error",function(n){throw new Error("Peerjs connector: "+n)}),this.conn.on("disconnected",function(){throw new Error("Peerjs connector disconnected from signalling server. Cannot accept new connections. Not fatal, but not so good either..")}),this.conn.on("disconnect",function(){return o.conn.reconnect()}),this.conn.on("connection",this._addConnection)}return c(e,n),e.prototype.join=function(n){var e;return null==this.unsynced_connections[n]&&null==this.connections[n]&&n!==this.id?(e=this.conn.connect(n,{reliable:!0}),this.unsynced_connections[n]=e,this._addConnection(e),!0):!1},e.prototype._send=function(n,e){var t,r,o,c,i;if(n.constructor!==[].constructor)return this.connections[n].send(e);for(r=[],c=0,i=n.length;i>c;c++){o=n[c];try{this.connection[o].send(e)}catch(s){t=s,r.push(t+"")}}if(r.length>0)throw new Error(r)},e.prototype._addConnection=function(n){return n.on("open",function(e){return function(){var t,r;return r=e,n.send(r.sync_process_order[0]()),t=1,n.on("data",function(e){var o,c,i,s,u,h,p,f,d,a;if(console.log("receive data: "+JSON.stringify(e)),tu;u++)c=d[u],a.push(c(n.peer,e));return a}if(t++,delete r.unsynced_connections[n.peer],r.connections[n.peer]=n,n.on("close",function(){return delete r.connections[n.peer]}),(i=function(n){var e;for(e in n)return!1;return!0})(r.unsynced_connections)){for(r.is_synced=!0,f=r.compute_when_synced,s=0,h=f.length;h>s;s++)o=f[s],o[0].apply(r,o.slice(1));return r.compute_when_synced=[]}})}}(this))},e}(e)},{"../connector":1}]},{},[2]);