text: (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){const logger=require("./logging")(module);function Chunk(offset,length,index=0,timeout=128*1e3){this._offset=offset;this._length=length;this._index=index;this._timeout=timeout;this._data=new Array;this._recv_size=0;if(typeof this._offset!="number"){throw new Error("wrong offset")}if(typeof this._length!="number"){throw new Error("wrong length")}if(typeof this._index!="number"){throw new Error("wrong index")}if(typeof this._timeout!="number"){throw new Error("wrong timeout")}this._init()}Chunk.prototype=Object.create(null);Chunk.prototype.cb_chunk_finished=null;Chunk.State={WAITING:1,INPROGRESS:2,FINISHED:3};Chunk.prototype._init=function(){this._ts=Date.now();this._state=Chunk.State.WAITING;this._node_id=null;this._data=new Array;this._recv_size=0;this._temporary_data={}};Chunk.prototype.getIndex=function(){return this._index};Chunk.prototype.getOffset=function(){return this._offset};Chunk.prototype.getLength=function(){return this._length};Chunk.prototype.getTimeout=function(){return this._timeout};Chunk.prototype.getTime=function(){var t=Date.now()-this._ts;return t};Chunk.prototype.getState=function(){return this._state};Chunk.prototype.getRecvSize=function(){return this._recv_size};Chunk.prototype.setStateInProgress=function(){this._state=Chunk.State.INPROGRESS};Chunk.prototype.getNodeId=function(){return this._node_id};Chunk.prototype.setNodeId=function(node_id){this._node_id=node_id};Chunk.prototype.toString=function(){var s="chunk offset: "+this._offset;s+=", chunk length: "+this._length;s+=", chunk index: "+this._index;return s};Chunk.prototype.allocate=function(including_active){including_active=including_active||false;if(this._state==Chunk.State.WAITING){this._state=Chunk.State.INPROGRESS;this._ts=Date.now();return true}else if(this._state==Chunk.State.INPROGRESS){if(this.getTime()<this._timeout){if(including_active==false)return false}this._ts=Date.now();return true}else if(this._state==Chunk.State.FINISHED){return false}else{return false}};Chunk.prototype.push_block=function(channel_id,offset,length,data){if(this._state==Chunk.State.FINISHED){logger.warn("Data received for finished chunk, channel_id:",channel_id,", offset:",offset,", length:",length);if(typeof this.cb_chunk_finished=="function")this.cb_chunk_finished(channel_id,this._index,false);return}this._ts=Date.now();if(offset<this._offset||offset>=this._offset+this._length){logger.warn("block has skipped, wrong offset: ",offset);return}if(+offset+ +length>this._offset+this._length){logger.warn("block has skipped, wrong offset or length: ",offset,length);logger.warn("for chunk:",this.toString());return}if(length!=data.byteLength){logger.warn("block has skipped, length is not equal length of data");return}var effective_received_size=0;this._temporary_data[offset]=data;while(true){var expected_offset=this._offset+this._recv_size;data=this._temporary_data[expected_offset];if(data===undefined){break}this._data.push(data);delete this._temporary_data[expected_offset];this._recv_size+=data.byteLength;effective_received_size+=data.byteLength;if(this._recv_size>=this._length){this._state=Chunk.State.FINISHED;if(typeof this.cb_chunk_finished=="function"){this.cb_chunk_finished(channel_id,this._index)}}}return effective_received_size};Chunk.prototype.reset=function(){this._ts=0};module.exports=Chunk},{"./logging":5}],2:[function(require,module,exports){var assign=require("object.assign/polyfill")();if(window.Object.assign===undefined)window.Object.assign=assign;var Transport=require("../transport");var Download_Task=require("../download_task");var get_appropriate_writer=require("../file_writer").get_appropriate_writer;var Blob_Writer=require("../file_writer").Blob_Writer;var Storage_Writer=require("../file_writer").Storage_Writer;var MediaSource_Writer=require("../mediasource_writer").MediaSource_Writer;window.Transport=Transport;window.Download_Task=Download_Task;window.get_appropriate_writer=get_appropriate_writer;window.Blob_Writer=Blob_Writer;window.Storage_Writer=Storage_Writer;window.MediaSource_Writer=MediaSource_Writer},{"../download_task":3,"../file_writer":4,"../mediasource_writer":6,"../transport":71,"object.assign/polyfill":32}],3:[function(require,module,exports){"use strict";const Write_Buffer=require("./write_buffer");const Chunk=require("./chunk");const Proto=require("./proto");const logger=require("./logging")(module);function Download_Task(transport,file_writer,file_id,file_name,file_size,opts,callbacks){this._transport=transport;this._file_writer=file_writer;this._file_id=file_id;this._file_name=file_name;this._file_size=file_size;this._chunk_size=opts.chunk_size||2097152;this._first_chunk_size=opts.first_chunk_size||this._chunk_size;this._chunk_multiplier=opts.chunk_multiplier||1;this._task_timeout=opts.task_timeout||64*1e3;this._chunk_timeout=opts.chunk_timeout||16*1e3;this._timer_interval=opts.timer_interval||1e3;this._max_chunks_in_buffer=opts.max_chunks_in_buffer||0;this._range=opts.range||{start:0,end:file_size-1};this._keep_signal_connections=opts.keep_signal_connections||false;this._wait_online_nodes=opts.wait_online_nodes||false;this._channel_opening_timeout=opts.channel_opening_timeout||0;this._availability_info_timeout=opts.availability_info_timeout||8e3;this._info_request_retry_count=opts.info_request_retry_count||1;this._data_receiving_check_interval=opts.data_receiving_check_interval||3e3;this._max_repeat_data_requests=opts.max_repeat_data_requests||3;this._write_buffer_timeout=opts.write_buffer_timeout;this._cb_task_success=callbacks.cb_task_success;this._cb_task_failure=callbacks.cb_task_failure;this._cb_task_progress=callbacks.cb_task_progress;this._cb_task_state=callbacks.cb_task_state;this._cb_warning=callbacks.cb_warning;this._cb_online_nodes=callbacks.cb_online_nodes;this._file_chunks=[];this._state=Download_Task.State.WAITING;this._ts=Date.now();this._recv_size=0;this._eff_recv_size=0;this._start_ts=Date.now();this._pause_duration=0;this._pause_ts=0;this._write_buffer=null;this._channel_opening_count=0;this._channel_opening_ts=0;this._request_allowed_flags={};this._channel_failed_count=0;this._availability_info={};this._availability_info_ts=0;this._availability_info_timeout_stopped=false;this._requested_chunks={};this._data_ts={};this._proto=new Proto({on_info_response:this._on_info_response.bind(this),on_info_failure:this._on_info_failure.bind(this),on_data_response:this._on_data_response.bind(this),on_data_failure:this._on_data_failure.bind(this)});if(this._transport){this._transport.cb_channel_onopen=this._channel_onopen.bind(this);this._transport.cb_channel_onclose=this._channel_onclose.bind(this);this._transport.cb_channel_onmessage=this._channel_onmessage.bind(this);this._transport.cb_online_nodes=this._online_nodes.bind(this);this._transport.cb_node_connected=this._node_connected.bind(this);this._transport.cb_node_disconnected=this._node_disconnected.bind(this)}this._make_file_chunks(this._range)}Download_Task.prototype=Object.create(null);Download_Task.State={WAITING:1,INPROGRESS:2,FINISHED:3,PAUSED:4};Download_Task.ErrorCode={TASK_CANCELED:1,TASK_TIMEOUT:2,INVALID_FILE_SIZE:3,FILE_NOT_AVAILABLE:4,NO_SIGNALING_CONNECTION:5,NO_AVAILABLE_NODES:6,WRITE_BUFFER_ERROR:7,FILE_WRITER_ERROR:8,CHANNEL_OPENING_TIMEOUT:9,AVAILABILITY_INFO_TIMEOUT:10};Download_Task.prototype._cb_task_success=null;Download_Task.prototype._cb_task_failure=null;Download_Task.prototype._cb_task_progress=null;Download_Task.prototype._cb_task_state=null;Download_Task.prototype._cb_warning=null;Download_Task.prototype._check_parameters=function(){if(typeof this._file_id!="string"){this._task_failed("wrong file_id");return false}if(typeof this._file_name!="string"){this._task_failed("wrong file_name");return false}if(this._first_chunk_size>this._chunk_size){this._task_failed("wrong first_chunk_size");return false}var error=new Download_Task.Error("Invalid file size",Download_Task.ErrorCode.INVALID_FILE_SIZE,"INVALID_FILE_SIZE");if(typeof this._file_size!="number"){this._task_failed(error);return false}if(this._file_size<=0){this._task_failed(error);return false}return true};Download_Task.prototype._make_file_chunks=function(range){var total_size=range.end-range.start+1;var rest_size=total_size;var start=range.start;var chunk_size=this._chunk_size;var first_chunk_size=this._first_chunk_size;var second_chunk_size=this._chunk_size;if(first_chunk_size<this._chunk_size){if(first_chunk_size+range.start%this._chunk_size>=this._chunk_size){first_chunk_size=this._chunk_size-range.start%this._chunk_size}else{second_chunk_size=this._chunk_size-first_chunk_size-range.start%this._chunk_size}}while(rest_size>0){var index=this._file_chunks.length;if(index==0)chunk_size=first_chunk_size;else if(index==1)chunk_size=second_chunk_size;else chunk_size=this._chunk_size;var offset=start+total_size-rest_size;var length=rest_size>chunk_size?chunk_size:rest_size;var chunk=new Chunk(offset,length,index,this._chunk_timeout);chunk.cb_chunk_finished=this._chunk_finished.bind(this);this._file_chunks.push(chunk);rest_size-=length}};Download_Task.prototype.getFileChunks=function(){return this._file_chunks};Download_Task.prototype.getNextChunk=function(including_active){including_active=including_active||false;for(var i=0;i<this._file_chunks.length;i++){if(this._file_chunks[i].allocate(including_active)){return this._file_chunks[i]}else{continue}}return false};Download_Task.prototype.getTaskTimeout=function(){return this._task_timeout};Download_Task.prototype.start=function(){if(!(this._state==Download_Task.State.WAITING||this._state==Download_Task.State.FINISHED)){logger.info("Download task already started");return}logger.info("Download task has started, timestamp: ",this._ts);logger.info("Download task timeout: ",this.getTaskTimeout());this._task_state(Download_Task.State.INPROGRESS);if(this._check_parameters()!=true){this._task_failed("invalid parameters");return}if(this._transport.get_signal_connections_num()==0){var error=new Download_Task.Error("No connections to signaling-server at the moment",Download_Task.ErrorCode.NO_SIGNALING_CONNECTION,"NO_SIGNALING_CONNECTION");this._task_failed(error);return}if(this._check_available_nodes()!=true)return;this._ts=Date.now();this._start_ts=Date.now();this._recv_size=0;this._channel_opening_count=0;this._channel_opening_ts=0;this._request_allowed_flags={};this._channel_failed_count=0;this._availability_info={};this._availability_info_ts=0;this._availability_info_timeout_stopped=false;this._requested_chunks={};this._data_ts={};if(this._transport.get_online_nodes().length>0)this._channel_opening_ts=Date.now();else this._channel_opening_ts=0;this._file_chunks=[];this._make_file_chunks(this._range);this._write_buffer=null;this._write_buffer=new Write_Buffer(this._file_writer,{num_of_chunks:this._file_chunks.length,file_size:this._file_size,max_chunks_in_buffer:this._max_chunks_in_buffer,timeout:this._write_buffer_timeout},{cb_oninit:this._write_buffer_oninit.bind(this),cb_onwrite:this._write_buffer_onwrite.bind(this),cb_onerror:this._write_buffer_onerror.bind(this)});var timer_id=setTimeout(this._check_task_timeout.bind(this),this._timer_interval);this._write_buffer.init()};Download_Task.prototype._write_buffer_oninit=function(){logger.info("file_writer is ready (init success) ...");if(this._state==Download_Task.State.INPROGRESS){this._channel_opening_ts=Date.now();if(typeof this._transport.open_channels=="function")this._transport.open_channels(1)}};Download_Task.prototype._write_buffer_onwrite=function(size){logger.info("flushed:",size);var total_size=this._range.end-this._range.start+1;logger.debug("total_size: %d",total_size);if(size>=total_size){this._task_finished()}};Download_Task.prototype._write_buffer_onerror=function(error){var err_code=Download_Task.ErrorCode.WRITE_BUFFER_ERROR;if(error.name=="FILE_WRITER_ERROR")err_code=Download_Task.ErrorCode.FILE_WRITER_ERROR;var err_message="Unknown error on write buffer";if(error.message!==undefined)err_message=error.message;var e=new Download_Task.Error(err_message,err_code,error.name);this._task_failed(e)};Download_Task.prototype._check_task_timeout=function(){if(this._state==Download_Task.State.FINISHED){logger.info("Task already finished");return}if(this._state==Download_Task.State.PAUSED){this._ts=Date.now();if(this._channel_opening_ts>0)this._channel_opening_ts=Date.now();var ts=Date.now();this._pause_duration+=ts-this._pause_ts;this._pause_ts=ts}if(this._channel_opening_timeout&&this._channel_opening_ts){if(Date.now()-this._channel_opening_ts>this._channel_opening_timeout){if(this._channel_opening_count>0){this._channel_opening_timeout=0}else{var error=new Download_Task.Error("Timeout",Download_Task.ErrorCode.CHANNEL_OPENING_TIMEOUT,"CHANNEL_OPENING_TIMEOUT");this._task_failed(error);return}}}if(this._availability_info_timeout>0&&this._availability_info_ts>0&&this._availability_info_timeout_stopped==false&&this._state==Download_Task.State.INPROGRESS&&Date.now()-this._availability_info_ts>this._availability_info_timeout){var availability_info_count=0;for(var node_id in this._availability_info){if(this._availability_info[node_id]){availability_info_count++;break}}if(availability_info_count>0){this._availability_info_timeout_stopped=true}else{var error=new Download_Task.Error("Availability info timeout",Download_Task.ErrorCode.AVAILABILITY_INFO_TIMEOUT,"AVAILABILITY_INFO_TIMEOUT");this._task_failed(error);return}if(this._check_file_availability()!=true){var error=new Download_Task.Error("File not available",Download_Task.ErrorCode.FILE_NOT_AVAILABLE,"FILE_NOT_AVAILABLE");this._task_failed(error);return}}if(Date.now()-this._ts>this._task_timeout&&this._file_writer.is_ready()==true){var error=new Download_Task.Error("Timeout",Download_Task.ErrorCode.TASK_TIMEOUT,"TASK_TIMEOUT");this._task_failed(error);return}this._task_progress();var timer_id=setTimeout(this._check_task_timeout.bind(this),this._timer_interval)};Download_Task.prototype._task_failed=function(cause){if(this._state==Download_Task.State.FINISHED){logger.info("task already finished");return}logger.warn("Download task failed, cause: ",cause);this._task_state(Download_Task.State.FINISHED);this._transport.close_channels();if(!this._keep_signal_connections)this._transport.close_signal_connections();var e=cause;if(e.message===undefined){e=new Error(cause)}if(typeof this._cb_task_failure=="function"){setTimeout(this._cb_task_failure,0,e)}else{throw e}};Download_Task.prototype.cancel=function(){if(this._state==Download_Task.State.INPROGRESS||this._state==Download_Task.State.PAUSED){var e=new Download_Task.Error("Task canceled",Download_Task.ErrorCode.TASK_CANCELED,"TASK_CANCELED");this._task_failed(e);return}logger.info("Task is not in progress or paused")};Download_Task.prototype._send_data_request=function(channel_id,flag_including_active_chunk){flag_including_active_chunk=flag_including_active_chunk||false;if(this._state==Download_Task.State.FINISHED){return}if(this._transport.channel_exists(channel_id)!=true)return;if(this._state==Download_Task.State.PAUSED){logger.debug("task is paused, request is not send");var timer_id=setTimeout(this._send_data_request.bind(this),this._timer_interval,channel_id);return}var bundle=[];for(var i=0;i<this._chunk_multiplier;i++){var next_chunk=this.getNextChunk(flag_including_active_chunk);flag_including_active_chunk=false;if(next_chunk){if(bundle.length>0)if(bundle[bundle.length-1].getIndex()+1!=next_chunk.getIndex())break;if(!this._write_buffer.is_ready()){var idx_in_buffer=this._write_buffer.get_last_index_in_buffer();if(next_chunk.getIndex()>=idx_in_buffer){logger.debug("write buffer is not ready to receive new chunks");next_chunk.reset();this._ts=Date.now();flag_including_active_chunk=true;break}}bundle.push(next_chunk);if(next_chunk.getIndex()==0||next_chunk.getIndex()==1)break}else{flag_including_active_chunk=true;break}}if(bundle.length>0)logger.debug("Bundle to check:",bundle);var checked_bundle=[];var sequence_started=false;var sequence_finished=false;for(var i=0;i<bundle.length;i++){if(sequence_finished==false){var is_available=this._check_chunk_availability(channel_id,bundle[i].getOffset(),bundle[i].getLength());if(is_available==true){if(checked_bundle.length==0)sequence_started=true;checked_bundle.push(bundle[i]);if(bundle[i].getRecvSize()>0){sequence_finished==true;continue}}else{if(sequence_started==true)sequence_finished=true}}if(sequence_started==false||sequence_finished==true)bundle[i].reset()}if(checked_bundle.length>0)logger.debug("Bundle to request:",checked_bundle);if(checked_bundle.length==0){var timer_id=setTimeout(this._send_data_request.bind(this),this._timer_interval,channel_id,flag_including_active_chunk);return}var next_offset=checked_bundle[0].getOffset();var next_length=checked_bundle[0].getLength();var requested_chunks=new Set;requested_chunks.add(checked_bundle[0].getIndex());for(var i=1;i<checked_bundle.length;i++){next_length+=checked_bundle[i].getLength();requested_chunks.add(checked_bundle[i].getIndex())}var node_id=this._transport.get_node_id_by_channel_id(channel_id);this._requested_chunks[node_id]=requested_chunks;var chunk_recv_size=checked_bundle[0].getRecvSize();if(chunk_recv_size>0)logger.debug("For the chunk already received:",chunk_recv_size);next_offset=next_offset+chunk_recv_size;next_length=next_length-chunk_recv_size;logger.info("send data request:",channel_id,this._file_id,next_offset,next_length);var message=this._proto.data_request(this._file_id,next_offset,next_length);this._transport.send_request(channel_id,message);var original_offset=next_offset;var repeat_request_counter=0;setTimeout(this._data_receiving_check.bind(this),this._data_receiving_check_interval,node_id,original_offset,next_offset,next_length,repeat_request_counter);return};Download_Task.prototype._data_receiving_check=function(node_id,original_offset,requested_offset,requested_length,repeat_request_counter){logger.debug("data receiving checking ..",node_id,original_offset,requested_offset,requested_length,repeat_request_counter);if(this._state==Download_Task.State.FINISHED){logger.debug("task already is finished");return}if(this._state==Download_Task.State.PAUSED){logger.debug("task is paused");return}var current_offset=0;var current_length=0;var max_offset=requested_offset+requested_length;var chunk_idx=this._get_chunk_idx(requested_offset);while(true){if(chunk_idx>=this._file_chunks.length)return;var chunk=this._file_chunks[chunk_idx];if(chunk.getOffset()>=max_offset)return;if(chunk.getState()==Chunk.State.FINISHED){chunk_idx++;continue}if(this._data_ts[node_id]&&Date.now()-this._data_ts[node_id]<this._data_receiving_check_interval){logger.debug("data timestamp is fine");break}current_offset=chunk.getOffset()+chunk.getRecvSize();current_length=max_offset-current_offset;if(current_offset>requested_offset){logger.debug("data receiving is fine");break}else{logger.debug("need repeat request");var channel_ids=this._transport.get_channel_ids_by_node_id(node_id);logger.debug("channel_ids for node:",node_id,channel_ids);if(channel_ids.lenght==0){logger.warn("channels not found for node:",node_id);return}var idx=Math.floor(Math.random()*channel_ids.length);var channel_id=channel_ids[idx];var data_abort_message=this._proto.data_abort(this._file_id,original_offset);logger.info("send data abort:",channel_id,this._file_id,original_offset);this._transport.send_request(channel_id,data_abort_message);logger.info("send repeated data request:",channel_id,this._file_id,current_offset,current_length);var message=this._proto.data_request(this._file_id,current_offset,current_length);this._transport.send_request(channel_id,message);original_offset=current_offset;repeat_request_counter++;break}}if(repeat_request_counter>this._max_repeat_data_requests)return;setTimeout(this._data_receiving_check.bind(this),this._data_receiving_check_interval,node_id,original_offset,current_offset,current_length,repeat_request_counter)};Download_Task.prototype._channel_onopen=function(channel_id,node_id){this._channel_opening_count++;if(this._recv_size==0){this._start_ts=Date.now()}if(this._request_allowed_flags[node_id]===undefined)this._request_allowed_flags[node_id]=true;if(this._request_allowed_flags[node_id]==true){this._request_allowed_flags[node_id]=false;delete this._availability_info[node_id];this._send_info_request(channel_id)}};Download_Task.prototype._channel_onclose=function(channel_id,node_id){logger.info("download task says: channel closed: ",channel_id);this._channel_opening_count--;this._request_allowed_flags[node_id]=true;if(this._state==Download_Task.State.FINISHED)return;var online_nodes=this._transport.get_online_nodes();if(online_nodes.indexOf(node_id)==-1)return;this._transport.open_channels(1,[node_id])};Download_Task.prototype._channel_onmessage=function(channel_id,message){if(this._state==Download_Task.State.FINISHED)return;try{this._proto.decode(message,channel_id)}catch(e){logger.warn("cannot decode message from channel: ",channel_id)}};Download_Task.prototype._online_nodes=function(node_ids){if(this._state==Download_Task.State.INPROGRESS)if(node_ids.length>0&&this._channel_opening_ts==0)this._channel_opening_ts=Date.now();else this._channel_opening_ts=0;for(var node_id in this._request_allowed_flags){if(node_ids.indexOf(node_id)==-1&&this._request_allowed_flags[node_id]==false)this._request_allowed_flags[node_id]=true}if(typeof this._cb_online_nodes=="function")this._cb_online_nodes(node_ids)};Download_Task.prototype._send_info_request=function(channel_id,retry_num_){var retry_num=retry_num_||0;var node_id=this._transport.get_node_id_by_channel_id(channel_id);var ai=this._availability_info[node_id];if(!(ai===undefined||ai===null))return;logger.info("send info request:",channel_id,this._file_id);var message=this._proto.info_request(this._file_id);this._transport.send_request(channel_id,message);if(this._availability_info_ts==0)this._availability_info_ts=Date.now();retry_num++;if(retry_num>this._info_request_retry_count)return;var timeout=parseInt(this._availability_info_timeout/(1+this._info_request_retry_count));setTimeout(this._send_info_request.bind(this),timeout,channel_id,retry_num)};Download_Task.prototype._on_info_response=function(message,channel_id){logger.debug("'availability info response' received."," channel_id: ",channel_id," message: ",message);if(message.obj_id!=this._file_id){logger.error("wrong file_id:",file_id,", skip info response");return}var node_id=this._transport.get_node_id_by_channel_id(channel_id);var flag_first_info=false;if(!node_id)return;if(this._availability_info[node_id]===null||this._availability_info[node_id]===undefined)flag_first_info=true;this._availability_info[node_id]=message.info;if(flag_first_info==true){if(this._early_availability_check()==false)return;if(this._state==Download_Task.State.INPROGRESS||Download_Task.State.PAUSED)this._transport.open_channels(this._transport.get_num_of_channels()-1,[node_id]);this._send_data_request(channel_id)}};Download_Task.prototype._on_info_failure=function(message,channel_id){logger.debug("'availability info failure' received."," channel_id: ",channel_id," message: ",message);if(message.obj_id!=this._file_id){logger.error("wrong file_id:",file_id,", skip info response");return}var node_id=this._transport.get_node_id_by_channel_id(channel_id);if(this._availability_info[node_id]===null){this._availability_info[node_id]=[];if(this._early_availability_check()==false)return}else{this._availability_info[node_id]=null;setTimeout(this._send_info_request.bind(this),2*this._timer_interval,channel_id,this._info_request_retry_count)}};Download_Task.prototype._on_data_response=function(message,channel_id){var file_id=message.obj_id;var offset=+message.info[0].offset;var length=+message.info[0].length;var data=message.data;if(file_id!=this._file_id){logger.error("wrong file_id:",file_id,", skip block");return}if(offset<0||offset>this._file_size){logger.error("wrong offset:",offset,", skip block");return}this._block_received(channel_id,offset,length,data)};Download_Task.prototype._on_data_failure=function(message,channel_id){logger.warn(">> on_proto_failure");var obj_id=message.obj_id;var offset=null;var length=null;if(message.info.length>0){var offset=message.info[0].offset;var length=message.info[0].length}var error=message.error;this._failure_received(channel_id,obj_id,offset,length,error)};Download_Task.prototype._block_received=function(channel_id,offset,length,data){var node_id=this._transport.get_node_id_by_channel_id(channel_id);this._data_ts[node_id]=Date.now();this._ts=Date.now();var start_pos=0;while(start_pos<length){var idx=this._get_chunk_idx(offset+start_pos);var chunk=this._file_chunks[idx];var end_pos=start_pos+chunk.getLength();if(offset>chunk.getOffset())end_pos=end_pos-(offset-chunk.getOffset());var data_to_push=data.slice(start_pos,end_pos);this._recv_size+=data_to_push.byteLength;var z=chunk.push_block(channel_id,offset+start_pos,data_to_push.byteLength,data_to_push);if(z!==undefined&&z>0)this._eff_recv_size+=z;this._task_progress();start_pos+=data_to_push.byteLength}};Download_Task.prototype._failure_received=function(channel_id,obj_id,offset,length,error){logger.warn("channel_id:",channel_id,"obj_id:",obj_id,", offset:",offset,", length:",length,", error:",error);this._warning(error+" ("+channel_id+")");this._channel_failed_count++;if(offset>=0){var idx=this._get_chunk_idx(offset);var chunk=this._file_chunks[idx];logger.debug("reset chunk: ",chunk);chunk.reset()}if(this._wait_online_nodes==true)return;if(this._channel_failed_count<this._transport.get_online_nodes().length)return;var error=new Download_Task.Error("File not available",Download_Task.ErrorCode.FILE_NOT_AVAILABLE,"FILE_NOT_AVAILABLE");this._task_failed(error)};Download_Task.prototype._chunk_finished=function(channel_id,chunk_index,without_warning_){var without_warning=without_warning_===undefined?true:without_warning_;if(without_warning==true){this._write_buffer.push_chunk(chunk_index,this._file_chunks[chunk_index]._data);delete this._file_chunks[chunk_index]._data;this._task_progress()}var node_id=this._transport.get_node_id_by_channel_id(channel_id);var requested_chunks=this._requested_chunks[node_id];if(requested_chunks)requested_chunks.delete(chunk_index);if(this._chunk_multiplier>1&&requested_chunks&&requested_chunks.size>0)return;this._send_data_request(channel_id)};Download_Task.prototype._task_finished=function(){this._task_state(Download_Task.State.FINISHED);this._transport.close_channels();this._transport.send_notifications();if(!this._keep_signal_connections)this._transport.close_signal_connections();if(typeof this._cb_task_success=="function"){var url=this._write_buffer.get_url();setTimeout(this._cb_task_success,200,url)}};Download_Task.prototype._task_progress=function(){if(typeof this._cb_task_progress=="function"){var a={total_duration:Date.now()-this._start_ts,duration:Date.now()-this._start_ts-this._pause_duration,received_size:this._recv_size,effective_received_size:this._eff_recv_size,task_size:this._file_size};setTimeout(this._cb_task_progress,0,a)}};Download_Task.prototype._task_state=function(state){this._state=state;if(typeof this._cb_task_state=="function")this._cb_task_state(this._state)};Download_Task.prototype._warning=function(warning){if(typeof this._cb_warning=="function")this._cb_warning(warning)};Download_Task.prototype.pause=function(){if(this._state==Download_Task.State.INPROGRESS){logger.debug(">> pause download task ..");this._pause_ts=Date.now();this._task_state(Download_Task.State.PAUSED)}};Download_Task.prototype.resume=function(){if(this._state==Download_Task.State.PAUSED){logger.debug(">> resume download task ..");this._pause_duration+=Date.now()-this._pause_ts;if(this._check_available_nodes()==true)if(this._early_availability_check()==true)this._task_state(Download_Task.State.INPROGRESS)}};Download_Task.prototype.set_max_chunks_in_buffer=function(n){this._max_chunks_in_buffer=n||0};Download_Task.prototype.set_file_writer=function(file_writer){this._file_writer=null;this._file_writer=file_writer};Download_Task.prototype.get_state=function(){return this._state};Download_Task.prototype._get_chunk_idx=function(offset){var start=this._range.start;var first_chunk_size=this._file_chunks[0].getLength();var second_chunk_size=this._file_chunks.length>1?this._file_chunks[1].getLength():0;if(offset-start<first_chunk_size)return 0;if(offset-start<first_chunk_size+second_chunk_size)return 1;var rel_offset=offset-start-first_chunk_size-second_chunk_size;return(rel_offset-rel_offset%this._chunk_size)/this._chunk_size+2};Download_Task.prototype._check_chunk_availability=function(channel_id,offset,length,node_id_){var node_id=node_id_||this._transport.get_node_id_by_channel_id(channel_id);var ai=this._availability_info[node_id];if(!ai)return false;for(var i=0;i<ai.length;i++){if(offset>=ai[i].offset&&offset+length<=ai[i].offset+ai[i].length)return true}return false};Download_Task.prototype._check_file_availability=function(){var q=false;for(var node_id in this._availability_info){var ai=this._availability_info[node_id];if(ai&&ai.length==1&&ai[0].offset==0&&ai[0].length==this._file_size)return true;q=q||!!ai}if(q!=true)return false;var i=0;for(i;i<this._file_chunks.length;i++){var chunk=this._file_chunks[i];if(chunk.getState()==Chunk.State.FINISHED)continue;var t=false;for(var node_id in this._availability_info){t=t||this._check_chunk_availability(null,chunk.getOffset(),chunk.getLength(),node_id);if(t==true)break}if(t!=true)break}if(i==this._file_chunks.length)return true;return false};Download_Task.prototype._early_availability_check=function(){if(this._state!=Download_Task.State.INPROGRESS)return true;if(this._wait_online_nodes==true)return true;logger.debug("call _early_availability_check ..");var online_nodes_count=this._transport.get_online_nodes().length;var availability_info_count=Object.keys(this._availability_info).length;if(online_nodes_count>availability_info_count)return true;this._availability_info_timeout_stopped=true;if(this._check_file_availability()!=true){var error=new Download_Task.Error("File not available",Download_Task.ErrorCode.FILE_NOT_AVAILABLE,"FILE_NOT_AVAILABLE");this._task_failed(error);return false}return true};Download_Task.prototype._node_connected=function(node_id){logger.info("node has been connected:",node_id);if(this._state==Download_Task.State.INPROGRESS||this._state==Download_Task.State.PAUSED)if(typeof this._transport.open_channels=="function")this._transport.open_channels(1,[node_id])};Download_Task.prototype._node_disconnected=function(node_id){logger.info("node has been disconnected:",node_id);delete this._availability_info[node_id];delete this._request_allowed_flags[node_id];delete this._requested_chunks[node_id];this._transport.close_channels([node_id]);if(this._state==Download_Task.State.INPROGRESS){setTimeout(this._check_available_nodes.bind(this),this._availability_info_timeout);setTimeout(this._early_availability_check.bind(this),this._availability_info_timeout*2)}};Download_Task.prototype._check_available_nodes=function(){if(this._transport.get_online_nodes().length==0&&this._wait_online_nodes==false){var error=new Download_Task.Error("Online nodes are not available at the moment",Download_Task.ErrorCode.NO_AVAILABLE_NODES,"NO_AVAILABLE_NODES");this._task_failed(error);return false}return true};Download_Task.Error=function(message,code,name){this.name=name||"DOWNLOAD_TASK_ERROR";this.message=message||"Download Task Error"
  ;this.stack=(new Error).stack;this.code=code||null};Download_Task.Error.prototype=Object.create(Error.prototype);module.exports=Download_Task},{"./chunk":1,"./logging":5,"./proto":67,"./write_buffer":72}],4:[function(require,module,exports){var is_node=require("detect-node");var logger=require("./logging")(module);function File_Writer(opts,callbacks){this._file_size=opts.file_size;this._mime_type=opts.mime_type||"application/octet-stream";this._size=0;this._ready=true}File_Writer.prototype=Object.create(null);File_Writer.prototype._cb_oninit=null;File_Writer.prototype._cb_onwrite=null;File_Writer.prototype._cb_onerror=null;File_Writer.prototype.init=function(){};File_Writer.prototype.write=function(chunk){};File_Writer.prototype.is_ready=function(){return this._ready};File_Writer.prototype.get_size=function(){return this._size};File_Writer.prototype.get_url=function(){};File_Writer.prototype.set_callbacks=function(callbacks){if(callbacks!==undefined){this._cb_oninit=callbacks.cb_oninit;this._cb_onwrite=callbacks.cb_onwrite;this._cb_onerror=callbacks.cb_onerror}};function Blob_Writer(opts,callbacks){this._mime_type=opts.mime_type||"application/octet-stream";this._size=0;this._ready=true;this._blob=new window.Blob([]);if(callbacks!==undefined){this._cb_oninit=callbacks.cb_oninit;this._cb_onwrite=callbacks.cb_onwrite;this._cb_onerror=callbacks.cb_onerror}}Blob_Writer.prototype=Object.create(File_Writer.prototype);Blob_Writer.prototype.constructor=File_Writer;Blob_Writer.prototype.init=function(){this._size=0;this._ready=true;this._blob=new window.Blob([],{type:this._mime_type});logger.info("MIMETYPE:",this._mime_type);if(typeof this._cb_oninit=="function"){setTimeout(this._cb_oninit,100)}};Blob_Writer.prototype.write=function(chunk){this._blob=new window.Blob([this._blob,new window.Blob(chunk)],{type:this._mime_type});this._size=this._blob.size;if(typeof this._cb_onwrite=="function")this._cb_onwrite(this._size)};Blob_Writer.prototype.get_url=function(){return URL.createObjectURL(this._blob)};function Storage_Writer(opts,callbacks){this._file_size=opts.file_size;this._size=0;this._ready=false;this._file_entry=null;this._writer=null;if(callbacks!==undefined){this._cb_oninit=callbacks.cb_oninit;this._cb_onwrite=callbacks.cb_onwrite;this._cb_onerror=callbacks.cb_onerror}}Storage_Writer.prototype=Object.create(File_Writer.prototype);Storage_Writer.prototype.constructor=File_Writer;Storage_Writer.prototype.write=function(chunk){if(typeof this._writer=="object"){this._ready=false;this._writer.write(new window.Blob(chunk))}else{console.error("this._writer is not instance of FileWriter")}};Storage_Writer.prototype.get_url=function(){if(typeof this._file_entry=="object"){return this._file_entry.toURL()}};Storage_Writer.prototype.init=function(){this._size=0;this._ready=false;this._file_entry=null;this._writer=null;var requested_size=this._file_size+1024*1024*2;console.log("Requested size:",requested_size);var _on_init=this._on_init.bind(this);var _on_error=this._on_error.bind(this);navigator.webkitPersistentStorage.requestQuota(requested_size,function(granted_size){console.log("Granted size: ",granted_size);if(granted_size<requested_size){var err_msg="Requested quota of file system not granted";console.error(err_msg);var e=new File_Writer_Error(err_msg,new Error(err_msg));if(typeof this._cb_onerror=="function"){this._cb_onerror(e)}else{throw e}}else{window.webkitRequestFileSystem(PERSISTENT,granted_size,_on_init,_on_error)}}.bind(this),this._on_error.bind(this))};Storage_Writer.prototype._on_init=function(fs){console.log("Opened file system: "+fs.name);this._quota_info();fs.root.getFile("tmp.bin",{create:true},function(file_entry){this._file_entry=file_entry;file_entry.createWriter(function(writer){writer.onwriteend=this._on_write.bind(this);writer.onerror=this._on_error.bind(this);console.log("truncate file ...");writer.truncate(0);this._writer=writer}.bind(this),this._on_error.bind(this))}.bind(this),this._on_error.bind(this))};Storage_Writer.prototype._quota_info=function(){navigator.webkitPersistentStorage.queryUsageAndQuota(function(used_size,granted_size){console.log("granted: ",granted_size,", used: ",used_size)},this._on_error.bind(this))};Storage_Writer.prototype._on_error=function(error){var err_msg="While working with file system error occured";console.error(err_msg,":",error);var e=new File_Writer_Error(err_msg,error);if(typeof this._cb_onerror=="function"){this._cb_onerror(e)}else{throw e}};Storage_Writer.prototype._on_write=function(){this._size=this._writer.length;this._ready=true;if(this._writer.position==0&&this._writer.length==0){this._quota_info();if(typeof this._cb_oninit=="function")this._cb_oninit()}else{if(typeof this._cb_onwrite=="function")this._cb_onwrite(this._size)}};function File_Writer_Error(message,cause){this.name="FILE_WRITER_ERROR";this.message=message;this.cause=cause}function get_appropriate_writer(file_size){if(is_node){console.log("Node.js has been detected");return null}else{window.requestFileSystem=window.requestFileSystem||window.webkitRequestFileSystem;console.log("window.requestFileSystem: ",window.requestFileSystem);if(window.requestFileSystem===undefined){if(file_size>2048*1024*1024){var e="The file for downloading has size > 2GB.";e+=" Your browser doesn't support file storage feature. ";e+=" Your can try to use another browser (e.g. Chrome/Chromium).";if(confirm(e+" Do you want to try to download the file anyway?")){}else{return}}console.log("will be make blob_writer");return Blob_Writer}else{if(file_size<=500*1024*1024){console.log("make blob_writer (file_size <= 500MB)");return Blob_Writer}else{console.log("make storage_writer (file_size > 500MB)");return Storage_Writer}}}}module.exports.File_Writer=File_Writer;module.exports.File_Writer_Error=File_Writer_Error;module.exports.Blob_Writer=Blob_Writer;module.exports.Storage_Writer=Storage_Writer;module.exports.get_appropriate_writer=get_appropriate_writer},{"./logging":5,"detect-node":20}],5:[function(require,module,exports){"use strict";function getLogger(module){return console}module.exports=getLogger},{}],6:[function(require,module,exports){"use strict;";var File_Writer=require("./file_writer").File_Writer;var File_Writer_Error=require("./file_writer").File_Writer_Error;var logger=require("./logging")(module);function MediaSource_Writer(opts,callbacks){logger.debug(opts);if(window.MediaSource===undefined){throw"Your browser does not support MediaSource"}if(typeof opts!=="object"){throw"Invalid options for MediaSource_Writer"}this._media_type=opts.media_type;this._media_element=opts.media_element;this._media_source=new window.MediaSource;this._source_buffer=null;this._url="";this._size=0;this._ready=true;if(callbacks!==undefined){this._cb_oninit=callbacks.cb_oninit;this._cb_onwrite=callbacks.cb_onwrite;this._cb_onerror=callbacks.cb_onerror}}MediaSource_Writer.prototype=Object.create(File_Writer.prototype);MediaSource_Writer.prototype.constructor=File_Writer;MediaSource_Writer.prototype.init=function(){this._size=0;this._ready=true;if(!this._media_source){var err_msg="Invalid media source object";var e=new File_Writer_Error(err_msg,new Error(err_msg));this._cb_onerror(e);return}logger.info("Media type requested:",this._media_type);logger.info("Media type is supported:",window.MediaSource.isTypeSupported(this._media_type));if(!window.MediaSource.isTypeSupported(this._media_type)){var err_msg="Unsupported media type '"+this._media_type+"'";var e=new File_Writer_Error(err_msg,new Error(err_msg));this._cb_onerror(e);return}this._media_source.addEventListener("sourceopen",this._on_sourceopen.bind(this));this._url=URL.createObjectURL(this._media_source);this._media_element.src=this._url};MediaSource_Writer.prototype._on_sourceopen=function(){logger.debug(">> MediaSource_Writer._on_sourceopen ..");logger.info(this._media_element);this._source_buffer=this._media_source.addSourceBuffer(this._media_type);this._source_buffer.addEventListener("updateend",this._on_updateend.bind(this));if(typeof this._cb_oninit=="function")this._cb_oninit()};MediaSource_Writer.prototype._on_updateend=function(){logger.debug(">> MediaSource_Writer._on_updateend ..");if(this._media_element.hidden==true)this._media_element.hidden=false;this._on_write()};MediaSource_Writer.prototype._on_write=function(){this._ready=true;if(typeof this._cb_onwrite=="function")this._cb_onwrite(this._size)};MediaSource_Writer.prototype.write=function(chunk){logger.debug(">> MediaSource_Writer.write ..");var blob=new window.Blob(chunk);logger.debug(blob);this._size=this._size+blob.size;this._ready=false;var source_buffer=this._source_buffer;var reader=new window.FileReader;reader.onloadend=function(e){source_buffer.appendBuffer(e.target.result)};reader.readAsArrayBuffer(blob)};MediaSource_Writer.prototype.get_url=function(){return""};module.exports.MediaSource_Writer=MediaSource_Writer},{"./file_writer":4,"./logging":5}],7:[function(require,module,exports){var EventEmitter=require("events").EventEmitter;var getBrowserRTC=require("get-browser-rtc");module.exports=function(opts){var wrtc=new EventEmitter;return Object.assign(wrtc,getBrowserRTC(),{close:function(){},electronDaemon:wrtc})}},{events:21,"get-browser-rtc":25}],8:[function(require,module,exports){"use strict";module.exports=asPromise;function asPromise(fn,ctx){var params=new Array(arguments.length-1),offset=0,index=2,pending=true;while(index<arguments.length)params[offset++]=arguments[index++];return new Promise(function executor(resolve,reject){params[offset]=function callback(err){if(pending){pending=false;if(err)reject(err);else{var params=new Array(arguments.length-1),offset=0;while(offset<params.length)params[offset++]=arguments[offset];resolve.apply(null,params)}}};try{fn.apply(ctx||null,params)}catch(err){if(pending){pending=false;reject(err)}}})}},{}],9:[function(require,module,exports){"use strict";var base64=exports;base64.length=function length(string){var p=string.length;if(!p)return 0;var n=0;while(--p%4>1&&string.charAt(p)==="=")++n;return Math.ceil(string.length*3)/4-n};var b64=new Array(64);var s64=new Array(123);for(var i=0;i<64;)s64[b64[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;base64.encode=function encode(buffer,start,end){var parts=null,chunk=[];var i=0,j=0,t;while(start<end){var b=buffer[start++];switch(j){case 0:chunk[i++]=b64[b>>2];t=(b&3)<<4;j=1;break;case 1:chunk[i++]=b64[t|b>>4];t=(b&15)<<2;j=2;break;case 2:chunk[i++]=b64[t|b>>6];chunk[i++]=b64[b&63];j=0;break}if(i>8191){(parts||(parts=[])).push(String.fromCharCode.apply(String,chunk));i=0}}if(j){chunk[i++]=b64[t];chunk[i++]=61;if(j===1)chunk[i++]=61}if(parts){if(i)parts.push(String.fromCharCode.apply(String,chunk.slice(0,i)));return parts.join("")}return String.fromCharCode.apply(String,chunk.slice(0,i))};var invalidEncoding="invalid encoding";base64.decode=function decode(string,buffer,offset){var start=offset;var j=0,t;for(var i=0;i<string.length;){var c=string.charCodeAt(i++);if(c===61&&j>1)break;if((c=s64[c])===undefined)throw Error(invalidEncoding);switch(j){case 0:t=c;j=1;break;case 1:buffer[offset++]=t<<2|(c&48)>>4;t=c;j=2;break;case 2:buffer[offset++]=(t&15)<<4|(c&60)>>2;t=c;j=3;break;case 3:buffer[offset++]=(t&3)<<6|c;j=0;break}}if(j===1)throw Error(invalidEncoding);return offset-start};base64.test=function test(string){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(string)}},{}],10:[function(require,module,exports){"use strict";module.exports=codegen;function codegen(functionParams,functionName){if(typeof functionParams==="string"){functionName=functionParams;functionParams=undefined}var body=[];function Codegen(formatStringOrScope){if(typeof formatStringOrScope!=="string"){var source=toString();if(codegen.verbose)console.log("codegen: "+source);source="return "+source;if(formatStringOrScope){var scopeKeys=Object.keys(formatStringOrScope),scopeParams=new Array(scopeKeys.length+1),scopeValues=new Array(scopeKeys.length),scopeOffset=0;while(scopeOffset<scopeKeys.length){scopeParams[scopeOffset]=scopeKeys[scopeOffset];scopeValues[scopeOffset]=formatStringOrScope[scopeKeys[scopeOffset++]]}scopeParams[scopeOffset]=source;return Function.apply(null,scopeParams).apply(null,scopeValues)}return Function(source)()}var formatParams=new Array(arguments.length-1),formatOffset=0;while(formatOffset<formatParams.length)formatParams[formatOffset]=arguments[++formatOffset];formatOffset=0;formatStringOrScope=formatStringOrScope.replace(/%([%dfijs])/g,function replace($0,$1){var value=formatParams[formatOffset++];switch($1){case"d":case"f":return String(Number(value));case"i":return String(Math.floor(value));case"j":return JSON.stringify(value);case"s":return String(value)}return"%"});if(formatOffset!==formatParams.length)throw Error("parameter count mismatch");body.push(formatStringOrScope);return Codegen}function toString(functionNameOverride){return"function "+(functionNameOverride||functionName||"")+"("+(functionParams&&functionParams.join(",")||"")+"){\n  "+body.join("\n  ")+"\n}"}Codegen.toString=toString;return Codegen}codegen.verbose=false},{}],11:[function(require,module,exports){"use strict";module.exports=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function on(evt,fn,ctx){(this._listeners[evt]||(this._listeners[evt]=[])).push({fn:fn,ctx:ctx||this});return this};EventEmitter.prototype.off=function off(evt,fn){if(evt===undefined)this._listeners={};else{if(fn===undefined)this._listeners[evt]=[];else{var listeners=this._listeners[evt];for(var i=0;i<listeners.length;)if(listeners[i].fn===fn)listeners.splice(i,1);else++i}}return this};EventEmitter.prototype.emit=function emit(evt){var listeners=this._listeners[evt];if(listeners){var args=[],i=1;for(;i<arguments.length;)args.push(arguments[i++]);for(i=0;i<listeners.length;)listeners[i].fn.apply(listeners[i++].ctx,args)}return this}},{}],12:[function(require,module,exports){"use strict";module.exports=fetch;var asPromise=require("@protobufjs/aspromise"),inquire=require("@protobufjs/inquire");var fs=inquire("fs");function fetch(filename,options,callback){if(typeof options==="function"){callback=options;options={}}else if(!options)options={};if(!callback)return asPromise(fetch,this,filename,options);if(!options.xhr&&fs&&fs.readFile)return fs.readFile(filename,function fetchReadFileCallback(err,contents){return err&&typeof XMLHttpRequest!=="undefined"?fetch.xhr(filename,options,callback):err?callback(err):callback(null,options.binary?contents:contents.toString("utf8"))});return fetch.xhr(filename,options,callback)}fetch.xhr=function fetch_xhr(filename,options,callback){var xhr=new XMLHttpRequest;xhr.onreadystatechange=function fetchOnReadyStateChange(){if(xhr.readyState!==4)return undefined;if(xhr.status!==0&&xhr.status!==200)return callback(Error("status "+xhr.status));if(options.binary){var buffer=xhr.response;if(!buffer){buffer=[];for(var i=0;i<xhr.responseText.length;++i)buffer.push(xhr.responseText.charCodeAt(i)&255)}return callback(null,typeof Uint8Array!=="undefined"?new Uint8Array(buffer):buffer)}return callback(null,xhr.responseText)};if(options.binary){if("overrideMimeType"in xhr)xhr.overrideMimeType("text/plain; charset=x-user-defined");xhr.responseType="arraybuffer"}xhr.open("GET",filename);xhr.send()}},{"@protobufjs/aspromise":8,"@protobufjs/inquire":14}],13:[function(require,module,exports){"use strict";module.exports=factory(factory);function factory(exports){if(typeof Float32Array!=="undefined")(function(){var f32=new Float32Array([-0]),f8b=new Uint8Array(f32.buffer),le=f8b[3]===128;function writeFloat_f32_cpy(val,buf,pos){f32[0]=val;buf[pos]=f8b[0];buf[pos+1]=f8b[1];buf[pos+2]=f8b[2];buf[pos+3]=f8b[3]}function writeFloat_f32_rev(val,buf,pos){f32[0]=val;buf[pos]=f8b[3];buf[pos+1]=f8b[2];buf[pos+2]=f8b[1];buf[pos+3]=f8b[0]}exports.writeFloatLE=le?writeFloat_f32_cpy:writeFloat_f32_rev;exports.writeFloatBE=le?writeFloat_f32_rev:writeFloat_f32_cpy;function readFloat_f32_cpy(buf,pos){f8b[0]=buf[pos];f8b[1]=buf[pos+1];f8b[2]=buf[pos+2];f8b[3]=buf[pos+3];return f32[0]}function readFloat_f32_rev(buf,pos){f8b[3]=buf[pos];f8b[2]=buf[pos+1];f8b[1]=buf[pos+2];f8b[0]=buf[pos+3];return f32[0]}exports.readFloatLE=le?readFloat_f32_cpy:readFloat_f32_rev;exports.readFloatBE=le?readFloat_f32_rev:readFloat_f32_cpy})();else(function(){function writeFloat_ieee754(writeUint,val,buf,pos){var sign=val<0?1:0;if(sign)val=-val;if(val===0)writeUint(1/val>0?0:2147483648,buf,pos);else if(isNaN(val))writeUint(2143289344,buf,pos);else if(val>3.4028234663852886e38)writeUint((sign<<31|2139095040)>>>0,buf,pos);else if(val<1.1754943508222875e-38)writeUint((sign<<31|Math.round(val/1.401298464324817e-45))>>>0,buf,pos);else{var exponent=Math.floor(Math.log(val)/Math.LN2),mantissa=Math.round(val*Math.pow(2,-exponent)*8388608)&8388607;writeUint((sign<<31|exponent+127<<23|mantissa)>>>0,buf,pos)}}exports.writeFloatLE=writeFloat_ieee754.bind(null,writeUintLE);exports.writeFloatBE=writeFloat_ieee754.bind(null,writeUintBE);function readFloat_ieee754(readUint,buf,pos){var uint=readUint(buf,pos),sign=(uint>>31)*2+1,exponent=uint>>>23&255,mantissa=uint&8388607;return exponent===255?mantissa?NaN:sign*Infinity:exponent===0?sign*1.401298464324817e-45*mantissa:sign*Math.pow(2,exponent-150)*(mantissa+8388608)}exports.readFloatLE=readFloat_ieee754.bind(null,readUintLE);exports.readFloatBE=readFloat_ieee754.bind(null,readUintBE)})();if(typeof Float64Array!=="undefined")(function(){var f64=new Float64Array([-0]),f8b=new Uint8Array(f64.buffer),le=f8b[7]===128;function writeDouble_f64_cpy(val,buf,pos){f64[0]=val;buf[pos]=f8b[0];buf[pos+1]=f8b[1];buf[pos+2]=f8b[2];buf[pos+3]=f8b[3];buf[pos+4]=f8b[4];buf[pos+5]=f8b[5];buf[pos+6]=f8b[6];buf[pos+7]=f8b[7]}function writeDouble_f64_rev(val,buf,pos){f64[0]=val;buf[pos]=f8b[7];buf[pos+1]=f8b[6];buf[pos+2]=f8b[5];buf[pos+3]=f8b[4];buf[pos+4]=f8b[3];buf[pos+5]=f8b[2];buf[pos+6]=f8b[1];buf[pos+7]=f8b[0]}exports.writeDoubleLE=le?writeDouble_f64_cpy:writeDouble_f64_rev;exports.writeDoubleBE=le?writeDouble_f64_rev:writeDouble_f64_cpy;function readDouble_f64_cpy(buf,pos){f8b[0]=buf[pos];f8b[1]=buf[pos+1];f8b[2]=buf[pos+2];f8b[3]=buf[pos+3];f8b[4]=buf[pos+4];f8b[5]=buf[pos+5];f8b[6]=buf[pos+6];f8b[7]=buf[pos+7];return f64[0]}function readDouble_f64_rev(buf,pos){f8b[7]=buf[pos];f8b[6]=buf[pos+1];f8b[5]=buf[pos+2];f8b[4]=buf[pos+3];f8b[3]=buf[pos+4];f8b[2]=buf[pos+5];f8b[1]=buf[pos+6];f8b[0]=buf[pos+7];return f64[0]}exports.readDoubleLE=le?readDouble_f64_cpy:readDouble_f64_rev;exports.readDoubleBE=le?readDouble_f64_rev:readDouble_f64_cpy})();else(function(){function writeDouble_ieee754(writeUint,off0,off1,val,buf,pos){var sign=val<0?1:0;if(sign)val=-val;if(val===0){writeUint(0,buf,pos+off0);writeUint(1/val>0?0:2147483648,buf,pos+off1)}else if(isNaN(val)){writeUint(0,buf,pos+off0);writeUint(2146959360,buf,pos+off1)}else if(val>1.7976931348623157e308){writeUint(0,buf,pos+off0);writeUint((sign<<31|2146435072)>>>0,buf,pos+off1)}else{var mantissa;if(val<2.2250738585072014e-308){mantissa=val/5e-324;writeUint(mantissa>>>0,buf,pos+off0);writeUint((sign<<31|mantissa/4294967296)>>>0,buf,pos+off1)}else{var exponent=Math.floor(Math.log(val)/Math.LN2);if(exponent===1024)exponent=1023;mantissa=val*Math.pow(2,-exponent);writeUint(mantissa*4503599627370496>>>0,buf,pos+off0);writeUint((sign<<31|exponent+1023<<20|mantissa*1048576&1048575)>>>0,buf,pos+off1)}}}exports.writeDoubleLE=writeDouble_ieee754.bind(null,writeUintLE,0,4);exports.writeDoubleBE=writeDouble_ieee754.bind(null,writeUintBE,4,0);function readDouble_ieee754(readUint,off0,off1,buf,pos){var lo=readUint(buf,pos+off0),hi=readUint(buf,pos+off1);var sign=(hi>>31)*2+1,exponent=hi>>>20&2047,mantissa=4294967296*(hi&1048575)+lo;return exponent===2047?mantissa?NaN:sign*Infinity:exponent===0?sign*5e-324*mantissa:sign*Math.pow(2,exponent-1075)*(mantissa+4503599627370496)}exports.readDoubleLE=readDouble_ieee754.bind(null,readUintLE,0,4);exports.readDoubleBE=readDouble_ieee754.bind(null,readUintBE,4,0)})();return exports}function writeUintLE(val,buf,pos){buf[pos]=val&255;buf[pos+1]=val>>>8&255;buf[pos+2]=val>>>16&255;buf[pos+3]=val>>>24}function writeUintBE(val,buf,pos){buf[pos]=val>>>24;buf[pos+1]=val>>>16&255;buf[pos+2]=val>>>8&255;buf[pos+3]=val&255}function readUintLE(buf,pos){return(buf[pos]|buf[pos+1]<<8|buf[pos+2]<<16|buf[pos+3]<<24)>>>0}function readUintBE(buf,pos){return(buf[pos]<<24|buf[pos+1]<<16|buf[pos+2]<<8|buf[pos+3])>>>0}},{}],14:[function(require,module,exports){"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}},{}],15:[function(require,module,exports){"use strict";var path=exports;var isAbsolute=path.isAbsolute=function isAbsolute(path){return/^(?:\/|\w+:)/.test(path)};var normalize=path.normalize=function normalize(path){path=path.replace(/\\/g,"/").replace(/\/{2,}/g,"/");var parts=path.split("/"),absolute=isAbsolute(path),prefix="";if(absolute)prefix=parts.shift()+"/";for(var i=0;i<parts.length;){if(parts[i]===".."){if(i>0&&parts[i-1]!=="..")parts.splice(--i,2);else if(absolute)parts.splice(i,1);else++i}else if(parts[i]===".")parts.splice(i,1);else++i}return prefix+parts.join("/")};path.resolve=function resolve(originPath,includePath,alreadyNormalized){if(!alreadyNormalized)includePath=normalize(includePath);if(isAbsolute(includePath))return includePath;if(!alreadyNormalized)originPath=normalize(originPath);return(originPath=originPath.replace(/(?:\/|^)[^\/]+$/,"")).length?normalize(originPath+"/"+includePath):includePath}},{}],16:[function(require,module,exports){"use strict";module.exports=pool;function pool(alloc,slice,size){var SIZE=size||8192;var MAX=SIZE>>>1;var slab=null;var offset=SIZE;return function pool_alloc(size){if(size<1||size>MAX)return alloc(size);if(offset+size>SIZE){slab=alloc(SIZE);offset=0}var buf=slice.call(slab,offset,offset+=size);if(offset&7)offset=(offset|7)+1;return buf}}},{}],17:[function(require,module,exports){"use strict";var utf8=exports;utf8.length=function utf8_length(string){var len=0,c=0;for(var i=0;i<string.length;++i){c=string.charCodeAt(i);if(c<128)len+=1;else if(c<2048)len+=2;else if((c&64512)===55296&&(string.charCodeAt(i+1)&64512)===56320){++i;len+=4}else len+=3}return len};utf8.read=function utf8_read(buffer,start,end){var len=end-start;if(len<1)return"";var parts=null,chunk=[],i=0,t;while(start<end){t=buffer[start++];if(t<128)chunk[i++]=t;else if(t>191&&t<224)chunk[i++]=(t&31)<<6|buffer[start++]&63;else if(t>239&&t<365){t=((t&7)<<18|(buffer[start++]&63)<<12|(buffer[start++]&63)<<6|buffer[start++]&63)-65536;chunk[i++]=55296+(t>>10);chunk[i++]=56320+(t&1023)}else chunk[i++]=(t&15)<<12|(buffer[start++]&63)<<6|buffer[start++]&63;if(i>8191){(parts||(parts=[])).push(String.fromCharCode.apply(String,chunk));i=0}}if(parts){if(i)parts.push(String.fromCharCode.apply(String,chunk.slice(0,i)));return parts.join("")}return String.fromCharCode.apply(String,chunk.slice(0,i))};utf8.write=function utf8_write(string,buffer,offset){var start=offset,c1,c2;for(var i=0;i<string.length;++i){c1=string.charCodeAt(i);if(c1<128){buffer[offset++]=c1}else if(c1<2048){buffer[offset++]=c1>>6|192;buffer[offset++]=c1&63|128}else if((c1&64512)===55296&&((c2=string.charCodeAt(i+1))&64512)===56320){c1=65536+((c1&1023)<<10)+(c2&1023);++i;buffer[offset++]=c1>>18|240;buffer[offset++]=c1>>12&63|128;buffer[offset++]=c1>>6&63|128;buffer[offset++]=c1&63|128}else{buffer[offset++]=c1>>12|224;buffer[offset++]=c1>>6&63|128;buffer[offset++]=c1&63|128}}return offset-start}},{}],18:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63;function getLens(b64){var len=b64.length;if(len%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i<len;i+=4){tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)];arr[curByte++]=tmp>>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;i<end;i+=3){tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(uint8[i+2]&255);output.push(tripletToBase64(tmp))}return output.join("")}function fromByteArray(uint8){var tmp;var len=uint8.length;var extraBytes=len%3;var parts=[];var maxChunkLength=16383;for(var i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],19:[function(require,module,exports){(function(Buffer){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var customInspectSymbol=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null;exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);var proto={foo:function(){return 42}};Object.setPrototypeOf(proto,Uint8Array.prototype);Object.setPrototypeOf(arr,proto);return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);Object.setPrototypeOf(buf,Buffer.prototype);return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype);Object.setPrototypeOf(Buffer,Uint8Array);function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i<length;i+=1){buf[i]=array[i]&255}return buf}function fromArrayBuffer(array,byteOffset,length){if(byteOffset<0||array.byteLength<byteOffset){throw new RangeError('"offset" is outside of buffer bounds')}if(array.byteLength<byteOffset+(length||0)){throw new RangeError('"length" is outside of buffer bounds')}var buf;if(byteOffset===undefined&&length===undefined){buf=new Uint8Array(array)}else if(length===undefined){buf=new Uint8Array(array,byteOffset)}else{buf=new Uint8Array(array,byteOffset,length)}Object.setPrototypeOf(buf,Buffer.prototype);return buf}function fromObject(obj){if(Buffer.isBuffer(obj)){var len=checked(obj.length)|0;var buf=createBuffer(len);if(buf.length===0){return buf}obj.copy(buf,0,0,len);return buf}if(obj.length!==undefined){if(typeof obj.length!=="number"||numberIsNaN(obj.length)){return createBuffer(0)}return fromArrayLike(obj)}if(obj.type==="Buffer"&&Array.isArray(obj.data)){return fromArrayLike(obj.data)}}function checked(length){if(length>=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength)
  ;if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len;++i){if(a[i]!==b[i]){x=a[i];y=b[i];break}}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function isEncoding(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function concat(list,length){if(!Array.isArray(list)){throw new TypeError('"list" argument must be an Array of Buffers')}if(list.length===0){return Buffer.alloc(0)}var i;if(length===undefined){length=0;for(i=0;i<list.length;++i){length+=list[i].length}}var buffer=Buffer.allocUnsafe(length);var pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(isInstance(buf,Uint8Array)){buf=Buffer.from(buf)}if(!Buffer.isBuffer(buf)){throw new TypeError('"list" argument must be an Array of Buffers')}buf.copy(buffer,pos);pos+=buf.length}return buffer};function byteLength(string,encoding){if(Buffer.isBuffer(string)){return string.length}if(ArrayBuffer.isView(string)||isInstance(string,ArrayBuffer)){return string.byteLength}if(typeof string!=="string"){throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. '+"Received type "+typeof string)}var len=string.length;var mustMatch=arguments.length>2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i<len;i+=2){swap(this,i,i+1)}return this};Buffer.prototype.swap32=function swap32(){var len=this.length;if(len%4!==0){throw new RangeError("Buffer size must be a multiple of 32-bits")}for(var i=0;i<len;i+=4){swap(this,i,i+3);swap(this,i+1,i+2)}return this};Buffer.prototype.swap64=function swap64(){var len=this.length;if(len%8!==0){throw new RangeError("Buffer size must be a multiple of 64-bits")}for(var i=0;i<len;i+=8){swap(this,i,i+7);swap(this,i+1,i+6);swap(this,i+2,i+5);swap(this,i+3,i+4)}return this};Buffer.prototype.toString=function toString(){var length=this.length;if(length===0)return"";if(arguments.length===0)return utf8Slice(this,0,length);return slowToString.apply(this,arguments)};Buffer.prototype.toLocaleString=Buffer.prototype.toString;Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return true;return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function inspect(){var str="";var max=exports.INSPECT_MAX_BYTES;str=this.toString("hex",0,max).replace(/(.{2})/g,"$1 ").trim();if(this.length>max)str+=" ... ";return"<Buffer "+str+">"};if(customInspectSymbol){Buffer.prototype[customInspectSymbol]=Buffer.prototype.inspect}Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i<len;++i){if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i];y=targetCopy[i];break}}if(x<y)return-1;if(y<x)return 1;return 0};function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(buffer.length===0)return-1;if(typeof byteOffset==="string"){encoding=byteOffset;byteOffset=0}else if(byteOffset>2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++){if(read(arr,i)===read(val,foundIndex===-1?0:i-foundIndex)){if(foundIndex===-1)foundIndex=i;if(i-foundIndex+1===valLength)return foundIndex*indexSize}else{if(foundIndex!==-1)i-=i-foundIndex;foundIndex=-1}}}else{if(byteOffset+valLength>arrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;j<valLength;j++){if(read(arr,i+j)!==read(val,j)){found=false;break}}if(found)return i}}return-1}Buffer.prototype.includes=function includes(val,byteOffset,encoding){return this.indexOf(val,byteOffset,encoding)!==-1};Buffer.prototype.indexOf=function indexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,true)};Buffer.prototype.lastIndexOf=function lastIndexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,false)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i<length;++i){var parsed=parseInt(string.substr(i*2,2),16);if(numberIsNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(asciiToBytes(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length)}Buffer.prototype.write=function write(string,offset,length,encoding){if(offset===undefined){encoding="utf8";length=this.length;offset=0}else if(length===undefined&&typeof offset==="string"){encoding=offset;length=this.length;offset=0}else if(isFinite(offset)){offset=offset>>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i<end){var firstByte=buf[i];var codePoint=null;var bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(i<len){res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH))}return res}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i){ret+=String.fromCharCode(buf[i]&127)}return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;++i){out+=hexSliceLookupTable[buf[i]]}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function slice(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf=this.subarray(start,end);Object.setPrototypeOf(newBuf,Buffer.prototype);return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}return val};Buffer.prototype.readUIntBE=function readUIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUIntBE=function writeUIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){if(value<0&&sub===0&&this[offset+i-1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||this.length===0)return 0;if(targetStart<0){throw new RangeError("targetStart out of bounds")}if(start<0||start>=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart<end-start){end=target.length-targetStart+start}var len=end-start;if(this===target&&typeof Uint8Array.prototype.copyWithin==="function"){this.copyWithin(targetStart,start,end)}else if(this===target&&start<targetStart&&targetStart<end){for(var i=len-1;i>=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}else if(typeof val==="boolean"){val=Number(val)}if(start<0||this.length<start||this.length<end){throw new RangeError("Out of range index")}if(end<=start){return this}start=start>>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i<end;++i){this[i]=val}}else{var bytes=Buffer.isBuffer(val)?val:Buffer.from(val,encoding);var len=bytes.length;if(len===0){throw new TypeError('The value "'+val+'" is invalid for argument "value"')}for(i=0;i<end-start;++i){this[i+start]=bytes[i%len]}}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(str){str=str.split("=")[0];str=str.trim().replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function utf8ToBytes(string,units){units=units||Infinity;var codePoint;var length=string.length;var leadSurrogate=null;var bytes=[];for(var i=0;i<length;++i){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;++i){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;++i){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length;++i){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}var hexSliceLookupTable=function(){var alphabet="0123456789abcdef";var table=new Array(256);for(var i=0;i<16;++i){var i16=i*16;for(var j=0;j<16;++j){table[i16+j]=alphabet[i]+alphabet[j]}}return table}()}).call(this,require("buffer").Buffer)},{"base64-js":18,buffer:19,ieee754:27}],20:[function(require,module,exports){module.exports=false},{}],21:[function(require,module,exports){var objectCreate=Object.create||objectCreatePolyfill;var objectKeys=Object.keys||objectKeysPolyfill;var bind=Function.prototype.bind||functionBindPolyfill;function EventEmitter(){if(!this._events||!Object.prototype.hasOwnProperty.call(this,"_events")){this._events=objectCreate(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;var hasDefineProperty;try{var o={};if(Object.defineProperty)Object.defineProperty(o,"x",{value:0});hasDefineProperty=o.x===0}catch(err){hasDefineProperty=false}if(hasDefineProperty){Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||arg!==arg)throw new TypeError('"defaultMaxListeners" must be a positive number');defaultMaxListeners=arg}})}else{EventEmitter.defaultMaxListeners=defaultMaxListeners}EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||isNaN(n))throw new TypeError('"n" argument must be a positive number');this._maxListeners=n;return this};function $getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return $getMaxListeners(this)};function emitNone(handler,isFn,self){if(isFn)handler.call(self);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self)}}function emitOne(handler,isFn,self,arg1){if(isFn)handler.call(self,arg1);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self,arg1)}}function emitTwo(handler,isFn,self,arg1,arg2){if(isFn)handler.call(self,arg1,arg2);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self,arg1,arg2)}}function emitThree(handler,isFn,self,arg1,arg2,arg3){if(isFn)handler.call(self,arg1,arg2,arg3);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self,arg1,arg2,arg3)}}function emitMany(handler,isFn,self,args){if(isFn)handler.apply(self,args);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].apply(self,args)}}EventEmitter.prototype.emit=function emit(type){var er,handler,len,args,i,events;var doError=type==="error";events=this._events;if(events)doError=doError&&events.error==null;else if(!doError)return false;if(doError){if(arguments.length>1)er=arguments[1];if(er instanceof Error){throw er}else{var err=new Error('Unhandled "error" event. ('+er+")");err.context=er;throw err}return false}handler=events[type];if(!handler)return false;var isFn=typeof handler==="function";len=arguments.length;switch(len){case 1:emitNone(handler,isFn,this);break;case 2:emitOne(handler,isFn,this,arguments[1]);break;case 3:emitTwo(handler,isFn,this,arguments[1],arguments[2]);break;case 4:emitThree(handler,isFn,this,arguments[1],arguments[2],arguments[3]);break;default:args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];emitMany(handler,isFn,this,args)}return true};function _addListener(target,type,listener,prepend){var m;var events;var existing;if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');events=target._events;if(!events){events=target._events=objectCreate(null);target._eventsCount=0}else{if(events.newListener){target.emit("newListener",type,listener.listener?listener.listener:listener);events=target._events}existing=events[type]}if(!existing){existing=events[type]=listener;++target._eventsCount}else{if(typeof existing==="function"){existing=events[type]=prepend?[listener,existing]:[existing,listener]}else{if(prepend){existing.unshift(listener)}else{existing.push(listener)}}if(!existing.warned){m=$getMaxListeners(target);if(m&&m>0&&existing.length>m){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+' "'+String(type)+'" listeners '+"added. Use emitter.setMaxListeners() to "+"increase limit.");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;if(typeof console==="object"&&console.warn){console.warn("%s: %s",w.name,w.message)}}}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){
  return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;switch(arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:var args=new Array(arguments.length);for(var i=0;i<args.length;++i)args[i]=arguments[i];this.listener.apply(this.target,args)}}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=bind.call(onceWrapper,state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');events=this._events;if(!events)return this;list=events[type];if(!list)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=objectCreate(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else spliceOne(list,position);if(list.length===1)events[type]=list[0];if(events.removeListener)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(!events)return this;if(!events.removeListener){if(arguments.length===0){this._events=objectCreate(null);this._eventsCount=0}else if(events[type]){if(--this._eventsCount===0)this._events=objectCreate(null);else delete events[type]}return this}if(arguments.length===0){var keys=objectKeys(events);var key;for(i=0;i<keys.length;++i){key=keys[i];if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events=objectCreate(null);this._eventsCount=0;return this}listeners=events[type];if(typeof listeners==="function"){this.removeListener(type,listeners)}else if(listeners){for(i=listeners.length-1;i>=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(!events)return[];var evlistener=events[type];if(!evlistener)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function spliceOne(list,index){for(var i=index,k=i+1,n=list.length;k<n;i+=1,k+=1)list[i]=list[k];list.pop()}function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i<n;++i)copy[i]=arr[i];return copy}function unwrapListeners(arr){var ret=new Array(arr.length);for(var i=0;i<ret.length;++i){ret[i]=arr[i].listener||arr[i]}return ret}function objectCreatePolyfill(proto){var F=function(){};F.prototype=proto;return new F}function objectKeysPolyfill(obj){var keys=[];for(var k in obj)if(Object.prototype.hasOwnProperty.call(obj,k)){keys.push(k)}return k}function functionBindPolyfill(context){var fn=this;return function(){return fn.apply(context,arguments)}}},{}],22:[function(require,module,exports){(function(global){(function(l){function m(b){b=void 0===b?"utf-8":b;if("utf-8"!==b)throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+b+"') is invalid.")}function k(b,a){b=void 0===b?"utf-8":b;a=void 0===a?{fatal:!1}:a;if("utf-8"!==b)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+b+"') is invalid.");if(a.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(l.TextEncoder&&l.TextDecoder)return!1;Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(b,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");a=0;for(var h=b.length,f=0,c=Math.max(32,h+(h>>1)+7),e=new Uint8Array(c>>3<<3);a<h;){var d=b.charCodeAt(a++);if(55296<=d&&56319>=d){if(a<h){var g=b.charCodeAt(a);56320===(g&64512)&&(++a,d=((d&1023)<<10)+(g&1023)+65536)}if(55296<=d&&56319>=d)continue}f+4>e.length&&(c+=8,c*=1+a/b.length*2,c=c>>3<<3,g=new Uint8Array(c),g.set(e),e=g);if(0===(d&4294967168))e[f++]=d;else{if(0===(d&4294965248))e[f++]=d>>6&31|192;else if(0===(d&4294901760))e[f++]=d>>12&15|224,e[f++]=d>>6&63|128;else if(0===(d&4292870144))e[f++]=d>>18&7|240,e[f++]=d>>12&63|128,e[f++]=d>>6&63|128;else continue;e[f++]=d&63|128}}return e.slice(0,f)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});k.prototype.decode=function(b,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to decode: the 'stream' option is unsupported.");b=new Uint8Array(b);a=0;for(var h=b.length,f=[];a<h;){var c=b[a++];if(0===c)break;if(0===(c&128))f.push(c);else if(192===(c&224)){var e=b[a++]&63;f.push((c&31)<<6|e)}else if(224===(c&240)){e=b[a++]&63;var d=b[a++]&63;f.push((c&31)<<12|e<<6|d)}else if(240===(c&248)){e=b[a++]&63;d=b[a++]&63;var g=b[a++]&63;c=(c&7)<<18|e<<12|d<<6|g;65535<c&&(c-=65536,f.push(c>>>10&1023|55296),c=56320|c&1023);f.push(c)}}return String.fromCharCode.apply(null,f)};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],23:[function(require,module,exports){"use strict";var ERROR_MESSAGE="Function.prototype.bind called on incompatible ";var slice=Array.prototype.slice;var toStr=Object.prototype.toString;var funcType="[object Function]";module.exports=function bind(that){var target=this;if(typeof target!=="function"||toStr.call(target)!==funcType){throw new TypeError(ERROR_MESSAGE+target)}var args=slice.call(arguments,1);var bound;var binder=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));if(Object(result)===result){return result}return this}else{return target.apply(that,args.concat(slice.call(arguments)))}};var boundLength=Math.max(0,target.length-args.length);var boundArgs=[];for(var i=0;i<boundLength;i++){boundArgs.push("$"+i)}bound=Function("binder","return function ("+boundArgs.join(",")+"){ return binder.apply(this,arguments); }")(binder);if(target.prototype){var Empty=function Empty(){};Empty.prototype=target.prototype;bound.prototype=new Empty;Empty.prototype=null}return bound}},{}],24:[function(require,module,exports){"use strict";var implementation=require("./implementation");module.exports=Function.prototype.bind||implementation},{"./implementation":23}],25:[function(require,module,exports){module.exports=function getBrowserRTC(){if(typeof window==="undefined")return null;var wrtc={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};if(!wrtc.RTCPeerConnection)return null;return wrtc}},{}],26:[function(require,module,exports){"use strict";module.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var obj={};var sym=Symbol("test");var symObj=Object(sym);if(typeof sym==="string"){return false}if(Object.prototype.toString.call(sym)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(symObj)!=="[object Symbol]"){return false}var symVal=42;obj[sym]=symVal;for(sym in obj){return false}if(typeof Object.keys==="function"&&Object.keys(obj).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(obj).length!==0){return false}var syms=Object.getOwnPropertySymbols(obj);if(syms.length!==1||syms[0]!==sym){return false}if(!Object.prototype.propertyIsEnumerable.call(obj,sym)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var descriptor=Object.getOwnPropertyDescriptor(obj,sym);if(descriptor.value!==symVal||descriptor.enumerable!==true){return false}}return true}},{}],27:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<<eLen)-1;var eBias=eMax>>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<<eLen)-1;var eBias=eMax>>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],28:[function(require,module,exports){"use strict";var keys=require("object-keys");var bind=require("function-bind");var canBeObject=function(obj){return typeof obj!=="undefined"&&obj!==null};var hasSymbols=require("has-symbols/shams")();var toObject=Object;var push=bind.call(Function.call,Array.prototype.push);var propIsEnumerable=bind.call(Function.call,Object.prototype.propertyIsEnumerable);var originalGetSymbols=hasSymbols?Object.getOwnPropertySymbols:null;module.exports=function assign(target,source1){if(!canBeObject(target)){throw new TypeError("target must be an object")}var objTarget=toObject(target);var s,source,i,props,syms,value,key;for(s=1;s<arguments.length;++s){source=toObject(arguments[s]);props=keys(source);var getSymbols=hasSymbols&&(Object.getOwnPropertySymbols||originalGetSymbols);if(getSymbols){syms=getSymbols(source);for(i=0;i<syms.length;++i){key=syms[i];if(propIsEnumerable(source,key)){push(props,key)}}}for(i=0;i<props.length;++i){key=props[i];value=source[key];if(propIsEnumerable(source,key)){objTarget[key]=value}}}return objTarget}},{"function-bind":24,"has-symbols/shams":26,"object-keys":30}],29:[function(require,module,exports){"use strict";var keysShim;if(!Object.keys){var has=Object.prototype.hasOwnProperty;var toStr=Object.prototype.toString;var isArgs=require("./isArguments");var isEnumerable=Object.prototype.propertyIsEnumerable;var hasDontEnumBug=!isEnumerable.call({toString:null},"toString");var hasProtoEnumBug=isEnumerable.call(function(){},"prototype");var dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var equalsConstructorPrototype=function(o){var ctor=o.constructor;return ctor&&ctor.prototype===o};var excludedKeys={$applicationCache:true,$console:true,$external:true,$frame:true,$frameElement:true,$frames:true,$innerHeight:true,$innerWidth:true,$onmozfullscreenchange:true,$onmozfullscreenerror:true,$outerHeight:true,$outerWidth:true,$pageXOffset:true,$pageYOffset:true,$parent:true,$scrollLeft:true,$scrollTop:true,$scrollX:true,$scrollY:true,$self:true,$webkitIndexedDB:true,$webkitStorageInfo:true,$window:true};var hasAutomationEqualityBug=function(){if(typeof window==="undefined"){return false}for(var k in window){try{if(!excludedKeys["$"+k]&&has.call(window,k)&&window[k]!==null&&typeof window[k]==="object"){try{equalsConstructorPrototype(window[k])}catch(e){return true}}}catch(e){return true}}return false}();var equalsConstructorPrototypeIfNotBuggy=function(o){if(typeof window==="undefined"||!hasAutomationEqualityBug){return equalsConstructorPrototype(o)}try{return equalsConstructorPrototype(o)}catch(e){return false}};keysShim=function keys(object){var isObject=object!==null&&typeof object==="object";var isFunction=toStr.call(object)==="[object Function]";var isArguments=isArgs(object);var isString=isObject&&toStr.call(object)==="[object String]";var theKeys=[];if(!isObject&&!isFunction&&!isArguments){throw new TypeError("Object.keys called on a non-object")}var skipProto=hasProtoEnumBug&&isFunction;if(isString&&object.length>0&&!has.call(object,0)){for(var i=0;i<object.length;++i){theKeys.push(String(i))}}if(isArguments&&object.length>0){for(var j=0;j<object.length;++j){theKeys.push(String(j))}}else{for(var name in object){if(!(skipProto&&name==="prototype")&&has.call(object,name)){theKeys.push(String(name))}}}if(hasDontEnumBug){var skipConstructor=equalsConstructorPrototypeIfNotBuggy(object);for(var k=0;k<dontEnums.length;++k){if(!(skipConstructor&&dontEnums[k]==="constructor")&&has.call(object,dontEnums[k])){theKeys.push(dontEnums[k])}}}return theKeys}}module.exports=keysShim},{"./isArguments":31}],30:[function(require,module,exports){"use strict";var slice=Array.prototype.slice;var isArgs=require("./isArguments");var origKeys=Object.keys;var keysShim=origKeys?function keys(o){return origKeys(o)}:require("./implementation");var originalKeys=Object.keys;keysShim.shim=function shimObjectKeys(){if(Object.keys){var keysWorksWithArguments=function(){var args=Object.keys(arguments);return args&&args.length===arguments.length}(1,2);if(!keysWorksWithArguments){Object.keys=function keys(object){if(isArgs(object)){return originalKeys(slice.call(object))}return originalKeys(object)}}}else{Object.keys=keysShim}return Object.keys||keysShim};module.exports=keysShim},{"./implementation":29,"./isArguments":31}],31:[function(require,module,exports){"use strict";var toStr=Object.prototype.toString;module.exports=function isArguments(value){var str=toStr.call(value);var isArgs=str==="[object Arguments]";if(!isArgs){isArgs=str!=="[object Array]"&&value!==null&&typeof value==="object"&&typeof value.length==="number"&&value.length>=0&&toStr.call(value.callee)==="[object Function]"}return isArgs}},{}],32:[function(require,module,exports){"use strict";var implementation=require("./implementation");var lacksProperEnumerationOrder=function(){if(!Object.assign){return false}var str="abcdefghijklmnopqrst";var letters=str.split("");var map={};for(var i=0;i<letters.length;++i){map[letters[i]]=letters[i]}var obj=Object.assign({},map);var actual="";for(var k in obj){actual+=k}return str!==actual};var assignHasPendingExceptions=function(){if(!Object.assign||!Object.preventExtensions){return false}var thrower=Object.preventExtensions({1:2});try{Object.assign(thrower,"xy")}catch(e){return thrower[1]==="y"}return false};module.exports=function getPolyfill(){if(!Object.assign){return implementation}if(lacksProperEnumerationOrder()){return implementation}if(assignHasPendingExceptions()){return implementation}return Object.assign}},{"./implementation":28}],33:[function(require,module,exports){"use strict";module.exports=require("./src/index-light")},{"./src/index-light":39}],34:[function(require,module,exports){"use strict";var converter=exports;var Enum=require("./enum"),util=require("./util");function genValuePartial_fromObject(gen,field,fieldIndex,prop){if(field.resolvedType){if(field.resolvedType instanceof Enum){gen("switch(d%s){",prop);for(var values=field.resolvedType.values,keys=Object.keys(values),i=0;i<keys.length;++i){if(field.repeated&&values[keys[i]]===field.typeDefault)gen("default:");gen("case%j:",keys[i])("case %i:",values[keys[i]])("m%s=%j",prop,values[keys[i]])("break")}gen("}")}else gen('if(typeof d%s!=="object")',prop)("throw TypeError(%j)",field.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",prop,fieldIndex,prop)}else{var isUnsigned=false;switch(field.type){case"double":case"float":gen("m%s=Number(d%s)",prop,prop);break;case"uint32":case"fixed32":gen("m%s=d%s>>>0",prop,prop);break;case"int32":case"sint32":case"sfixed32":gen("m%s=d%s|0",prop,prop);break;case"uint64":isUnsigned=true;case"int64":case"sint64":case"fixed64":case"sfixed64":gen("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",prop,prop,isUnsigned)('else if(typeof d%s==="string")',prop)("m%s=parseInt(d%s,10)",prop,prop)('else if(typeof d%s==="number")',prop)("m%s=d%s",prop,prop)('else if(typeof d%s==="object")',prop)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",prop,prop,prop,isUnsigned?"true":"");break;case"bytes":gen('if(typeof d%s==="string")',prop)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",prop,prop,prop)("else if(d%s.length)",prop)("m%s=d%s",prop,prop);break;case"string":gen("m%s=String(d%s)",prop,prop);break;case"bool":gen("m%s=Boolean(d%s)",prop,prop);break}}return gen}converter.fromObject=function fromObject(mtype){var fields=mtype.fieldsArray;var gen=util.codegen(["d"],mtype.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!fields.length)return gen("return new this.ctor");gen("var m=new this.ctor");for(var i=0;i<fields.length;++i){var field=fields[i].resolve(),prop=util.safeProp(field.name);if(field.map){gen("if(d%s){",prop)('if(typeof d%s!=="object")',prop)("throw TypeError(%j)",field.fullName+": object expected")("m%s={}",prop)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",prop);genValuePartial_fromObject(gen,field,i,prop+"[ks[i]]")("}")("}")}else if(field.repeated){gen("if(d%s){",prop)("if(!Array.isArray(d%s))",prop)("throw TypeError(%j)",field.fullName+": array expected")("m%s=[]",prop)("for(var i=0;i<d%s.length;++i){",prop);genValuePartial_fromObject(gen,field,i,prop+"[i]")("}")("}")}else{if(!(field.resolvedType instanceof Enum))gen("if(d%s!=null){",prop);genValuePartial_fromObject(gen,field,i,prop);if(!(field.resolvedType instanceof Enum))gen("}")}}return gen("return m")};function genValuePartial_toObject(gen,field,fieldIndex,prop){if(field.resolvedType){if(field.resolvedType instanceof Enum)gen("d%s=o.enums===String?types[%i].values[m%s]:m%s",prop,fieldIndex,prop,prop);else gen("d%s=types[%i].toObject(m%s,o)",prop,fieldIndex,prop)}else{var isUnsigned=false;switch(field.type){case"double":case"float":gen("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",prop,prop,prop,prop);break;case"uint64":isUnsigned=true;case"int64":case"sint64":case"fixed64":case"sfixed64":gen('if(typeof m%s==="number")',prop)("d%s=o.longs===String?String(m%s):m%s",prop,prop,prop)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",prop,prop,prop,prop,isUnsigned?"true":"",prop);break;case"bytes":gen("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",prop,prop,prop,prop,prop);break;default:gen("d%s=m%s",prop,prop);break}}return gen}converter.toObject=function toObject(mtype){var fields=mtype.fieldsArray.slice().sort(util.compareFieldsById);if(!fields.length)return util.codegen()("return {}");var gen=util.codegen(["m","o"],mtype.name+"$toObject")("if(!o)")("o={}")("var d={}");var repeatedFields=[],mapFields=[],normalFields=[],i=0;for(;i<fields.length;++i)if(!fields[i].partOf)(fields[i].resolve().repeated?repeatedFields:fields[i].map?mapFields:normalFields).push(fields[i]);if(repeatedFields.length){gen("if(o.arrays||o.defaults){");for(i=0;i<repeatedFields.length;++i)gen("d%s=[]",util.safeProp(repeatedFields[i].name));gen("}")}if(mapFields.length){gen("if(o.objects||o.defaults){");for(i=0;i<mapFields.length;++i)gen("d%s={}",util.safeProp(mapFields[i].name));gen("}")}if(normalFields.length){gen("if(o.defaults){");for(i=0;i<normalFields.length;++i){var field=normalFields[i],prop=util.safeProp(field.name);if(field.resolvedType instanceof Enum)gen("d%s=o.enums===String?%j:%j",prop,field.resolvedType.valuesById[field.typeDefault],field.typeDefault);else if(field.long)gen("if(util.Long){")("var n=new util.Long(%i,%i,%j)",field.typeDefault.low,field.typeDefault.high,field.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",prop)("}else")("d%s=o.longs===String?%j:%i",prop,field.typeDefault.toString(),field.typeDefault.toNumber());else if(field.bytes){var arrayDefault="["+Array.prototype.slice.call(field.typeDefault).join(",")+"]";gen("if(o.bytes===String)d%s=%j",prop,String.fromCharCode.apply(String,field.typeDefault))("else{")("d%s=%s",prop,arrayDefault)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",prop,prop)("}")}else gen("d%s=%j",prop,field.typeDefault)}gen("}")}var hasKs2=false;for(i=0;i<fields.length;++i){var field=fields[i],index=mtype._fieldsArray.indexOf(field),prop=util.safeProp(field.name);if(field.map){if(!hasKs2){hasKs2=true;gen("var ks2")}gen("if(m%s&&(ks2=Object.keys(m%s)).length){",prop,prop)("d%s={}",prop)("for(var j=0;j<ks2.length;++j){");genValuePartial_toObject(gen,field,index,prop+"[ks2[j]]")("}")}else if(field.repeated){gen("if(m%s&&m%s.length){",prop,prop)("d%s=[]",prop)("for(var j=0;j<m%s.length;++j){",prop);genValuePartial_toObject(gen,field,index,prop+"[j]")("}")}else{gen("if(m%s!=null&&m.hasOwnProperty(%j)){",prop,field.name);genValuePartial_toObject(gen,field,index,prop);if(field.partOf)gen("if(o.oneofs)")("d%s=%j",util.safeProp(field.partOf.name),field.name)}gen("}")}return gen("return d")}},{"./enum":37,"./util":56}],35:[function(require,module,exports){"use strict";module.exports=decoder;var Enum=require("./enum"),types=require("./types"),util=require("./util");function missing(field){return"missing required '"+field.name+"'"}function decoder(mtype){var gen=util.codegen(["r","l"],mtype.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(mtype.fieldsArray.filter(function(field){return field.map}).length?",k":""))("while(r.pos<c){")("var t=r.uint32()");if(mtype.group)gen("if((t&7)===4)")("break");gen("switch(t>>>3){");var i=0;for(;i<mtype.fieldsArray.length;++i){var field=mtype._fieldsArray[i].resolve(),type=field.resolvedType instanceof Enum?"int32":field.type,ref="m"+util.safeProp(field.name);gen("case %i:",field.id);if(field.map){gen("r.skip().pos++")("if(%s===util.emptyObject)",ref)("%s={}",ref)("k=r.%s()",field.keyType)("r.pos++");if(types.long[field.keyType]!==undefined){if(types.basic[type]===undefined)gen('%s[typeof k==="object"?util.longToHash(k):k]=types[%i].decode(r,r.uint32())',ref,i);else gen('%s[typeof k==="object"?util.longToHash(k):k]=r.%s()',ref,type)}else{if(types.basic[type]===undefined)gen("%s[k]=types[%i].decode(r,r.uint32())",ref,i);else gen("%s[k]=r.%s()",ref,type)}}else if(field.repeated){gen("if(!(%s&&%s.length))",ref,ref)("%s=[]",ref);if(types.packed[type]!==undefined)gen("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",ref,type)("}else");if(types.basic[type]===undefined)gen(field.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",ref,i);else gen("%s.push(r.%s())",ref,type)}else if(types.basic[type]===undefined)gen(field.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",ref,i);else gen("%s=r.%s()",ref,type);gen("break")}gen("default:")("r.skipType(t&7)")("break")("}")("}");for(i=0;i<mtype._fieldsArray.length;++i){var rfield=mtype._fieldsArray[i];if(rfield.required)gen("if(!m.hasOwnProperty(%j))",rfield.name)("throw util.ProtocolError(%j,{instance:m})",missing(rfield))}return gen("return m")}},{"./enum":37,"./types":55,"./util":56}],36:[function(require,module,exports){"use strict";module.exports=encoder;var Enum=require("./enum"),types=require("./types"),util=require("./util");function genTypePartial(gen,field,fieldIndex,ref){return field.resolvedType.group?gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",fieldIndex,ref,(field.id<<3|3)>>>0,(field.id<<3|4)>>>0):gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",fieldIndex,ref,(field.id<<3|2)>>>0)}function encoder(mtype){var gen=util.codegen(["m","w"],mtype.name+"$encode")("if(!w)")("w=Writer.create()");var i,ref;var fields=mtype.fieldsArray.slice().sort(util.compareFieldsById);for(var i=0;i<fields.length;++i){var field=fields[i].resolve(),index=mtype._fieldsArray.indexOf(field),type=field.resolvedType instanceof Enum?"int32":field.type,wireType=types.basic[type];ref="m"+util.safeProp(field.name);if(field.map){gen("if(%s!=null&&m.hasOwnProperty(%j)){",ref,field.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",ref)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(field.id<<3|2)>>>0,8|types.mapKey[field.keyType],field.keyType);if(wireType===undefined)gen("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",index,ref);else gen(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|wireType,type,ref);gen("}")("}")}else if(field.repeated){gen("if(%s!=null&&%s.length){",ref,ref);if(field.packed&&types.packed[type]!==undefined){gen("w.uint32(%i).fork()",(field.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",ref)("w.%s(%s[i])",type,ref)("w.ldelim()")}else{gen("for(var i=0;i<%s.length;++i)",ref);if(wireType===undefined)genTypePartial(gen,field,index,ref+"[i]");else gen("w.uint32(%i).%s(%s[i])",(field.id<<3|wireType)>>>0,type,ref)}gen("}")}else{if(field.optional)gen("if(%s!=null&&m.hasOwnProperty(%j))",ref,field.name);if(wireType===undefined)genTypePartial(gen,field,index,ref);else gen("w.uint32(%i).%s(%s)",(field.id<<3|wireType)>>>0,type,ref)}}return gen("return w")}},{"./enum":37,"./types":55,"./util":56}],37:[function(require,module,exports){"use strict";module.exports=Enum;var ReflectionObject=require("./object");((Enum.prototype=Object.create(ReflectionObject.prototype)).constructor=Enum).className="Enum";var Namespace=require("./namespace"),util=require("./util");function Enum(name,values,options,comment,comments){ReflectionObject.call(this,name,options);if(values&&typeof values!=="object")throw TypeError("values must be an object");this.valuesById={};this.values=Object.create(this.valuesById);this.comment=comment;this.comments=comments||{};this.reserved=undefined;if(values)for(var keys=Object.keys(values),i=0;i<keys.length;++i)if(typeof values[keys[i]]==="number")this.valuesById[this.values[keys[i]]=values[keys[i]]]=keys[i]}Enum.fromJSON=function fromJSON(name,json){var enm=new Enum(name,json.values,json.options,json.comment,json.comments);enm.reserved=json.reserved;return enm};Enum.prototype.toJSON=function toJSON(toJSONOptions){var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false;return util.toObject(["options",this.options,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:undefined,"comment",keepComments?this.comment:undefined,"comments",keepComments?this.comments:undefined])};Enum.prototype.add=function add(name,id,comment){if(!util.isString(name))throw TypeError("name must be a string");if(!util.isInteger(id))throw TypeError("id must be an integer");if(this.values[name]!==undefined)throw Error("duplicate name '"+name+"' in "+this);if(this.isReservedId(id))throw Error("id "+id+" is reserved in "+this);if(this.isReservedName(name))throw Error("name '"+name+"' is reserved in "+this);if(this.valuesById[id]!==undefined){if(!(this.options&&this.options.allow_alias))throw Error("duplicate id "+id+" in "+this);this.values[name]=id}else this.valuesById[this.values[name]=id]=name;this.comments[name]=comment||null;return this};Enum.prototype.remove=function remove(name){if(!util.isString(name))throw TypeError("name must be a string");var val=this.values[name];if(val==null)throw Error("name '"+name+"' does not exist in "+this);delete this.valuesById[val];delete this.values[name];delete this.comments[name];return this};Enum.prototype.isReservedId=function isReservedId(id){return Namespace.isReservedId(this.reserved,id)};Enum.prototype.isReservedName=function isReservedName(name){return Namespace.isReservedName(this.reserved,name)}},{"./namespace":44,"./object":45,"./util":56}],38:[function(require,module,exports){"use strict";module.exports=Field;var ReflectionObject=require("./object");((Field.prototype=Object.create(ReflectionObject.prototype)).constructor=Field).className="Field";var Enum=require("./enum"),types=require("./types"),util=require("./util");var Type;var ruleRe=/^required|optional|repeated$/;Field.fromJSON=function fromJSON(name,json){return new Field(name,json.id,json.type,json.rule,json.extend,json.options,json.comment)};function Field(name,id,type,rule,extend,options,comment){if(util.isObject(rule)){comment=extend;options=rule;rule=extend=undefined}else if(util.isObject(extend)){comment=options;options=extend;extend=undefined}ReflectionObject.call(this,name,options);if(!util.isInteger(id)||id<0)throw TypeError("id must be a non-negative integer");if(!util.isString(type))throw TypeError("type must be a string");if(rule!==undefined&&!ruleRe.test(rule=rule.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(extend!==undefined&&!util.isString(extend))throw TypeError("extend must be a string");this.rule=rule&&rule!=="optional"?rule:undefined;this.type=type;this.id=id;this.extend=extend||undefined;this.required=rule==="required";this.optional=!this.required;this.repeated=rule==="repeated";this.map=false;this.message=null;this.partOf=null;this.typeDefault=null;this.defaultValue=null;this.long=util.Long?types.long[type]!==undefined:false;this.bytes=type==="bytes";this.resolvedType=null;this.extensionField=null;this.declaringField=null;this._packed=null;this.comment=comment}Object.defineProperty(Field.prototype,"packed",{get:function(){if(this._packed===null)this._packed=this.getOption("packed")!==false;return this._packed}});Field.prototype.setOption=function setOption(name,value,ifNotSet){if(name==="packed")this._packed=null;return ReflectionObject.prototype.setOption.call(this,name,value,ifNotSet)};Field.prototype.toJSON=function toJSON(toJSONOptions){var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false
  ;return util.toObject(["rule",this.rule!=="optional"&&this.rule||undefined,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",keepComments?this.comment:undefined])};Field.prototype.resolve=function resolve(){if(this.resolved)return this;if((this.typeDefault=types.defaults[this.type])===undefined){this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type);if(this.resolvedType instanceof Type)this.typeDefault=null;else this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]}if(this.options&&this.options["default"]!=null){this.typeDefault=this.options["default"];if(this.resolvedType instanceof Enum&&typeof this.typeDefault==="string")this.typeDefault=this.resolvedType.values[this.typeDefault]}if(this.options){if(this.options.packed===true||this.options.packed!==undefined&&this.resolvedType&&!(this.resolvedType instanceof Enum))delete this.options.packed;if(!Object.keys(this.options).length)this.options=undefined}if(this.long){this.typeDefault=util.Long.fromNumber(this.typeDefault,this.type.charAt(0)==="u");if(Object.freeze)Object.freeze(this.typeDefault)}else if(this.bytes&&typeof this.typeDefault==="string"){var buf;if(util.base64.test(this.typeDefault))util.base64.decode(this.typeDefault,buf=util.newBuffer(util.base64.length(this.typeDefault)),0);else util.utf8.write(this.typeDefault,buf=util.newBuffer(util.utf8.length(this.typeDefault)),0);this.typeDefault=buf}if(this.map)this.defaultValue=util.emptyObject;else if(this.repeated)this.defaultValue=util.emptyArray;else this.defaultValue=this.typeDefault;if(this.parent instanceof Type)this.parent.ctor.prototype[this.name]=this.defaultValue;return ReflectionObject.prototype.resolve.call(this)};Field.d=function decorateField(fieldId,fieldType,fieldRule,defaultValue){if(typeof fieldType==="function")fieldType=util.decorateType(fieldType).name;else if(fieldType&&typeof fieldType==="object")fieldType=util.decorateEnum(fieldType).name;return function fieldDecorator(prototype,fieldName){util.decorateType(prototype.constructor).add(new Field(fieldName,fieldId,fieldType,fieldRule,{default:defaultValue}))}};Field._configure=function configure(Type_){Type=Type_}},{"./enum":37,"./object":45,"./types":55,"./util":56}],39:[function(require,module,exports){"use strict";var protobuf=module.exports=require("./index-minimal");protobuf.build="light";function load(filename,root,callback){if(typeof root==="function"){callback=root;root=new protobuf.Root}else if(!root)root=new protobuf.Root;return root.load(filename,callback)}protobuf.load=load;function loadSync(filename,root){if(!root)root=new protobuf.Root;return root.loadSync(filename)}protobuf.loadSync=loadSync;protobuf.encoder=require("./encoder");protobuf.decoder=require("./decoder");protobuf.verifier=require("./verifier");protobuf.converter=require("./converter");protobuf.ReflectionObject=require("./object");protobuf.Namespace=require("./namespace");protobuf.Root=require("./root");protobuf.Enum=require("./enum");protobuf.Type=require("./type");protobuf.Field=require("./field");protobuf.OneOf=require("./oneof");protobuf.MapField=require("./mapfield");protobuf.Service=require("./service");protobuf.Method=require("./method");protobuf.Message=require("./message");protobuf.wrappers=require("./wrappers");protobuf.types=require("./types");protobuf.util=require("./util");protobuf.ReflectionObject._configure(protobuf.Root);protobuf.Namespace._configure(protobuf.Type,protobuf.Service,protobuf.Enum);protobuf.Root._configure(protobuf.Type);protobuf.Field._configure(protobuf.Type)},{"./converter":34,"./decoder":35,"./encoder":36,"./enum":37,"./field":38,"./index-minimal":40,"./mapfield":41,"./message":42,"./method":43,"./namespace":44,"./object":45,"./oneof":46,"./root":49,"./service":53,"./type":54,"./types":55,"./util":56,"./verifier":59,"./wrappers":60}],40:[function(require,module,exports){"use strict";var protobuf=exports;protobuf.build="minimal";protobuf.Writer=require("./writer");protobuf.BufferWriter=require("./writer_buffer");protobuf.Reader=require("./reader");protobuf.BufferReader=require("./reader_buffer");protobuf.util=require("./util/minimal");protobuf.rpc=require("./rpc");protobuf.roots=require("./roots");protobuf.configure=configure;function configure(){protobuf.Reader._configure(protobuf.BufferReader);protobuf.util._configure()}protobuf.Writer._configure(protobuf.BufferWriter);configure()},{"./reader":47,"./reader_buffer":48,"./roots":50,"./rpc":51,"./util/minimal":58,"./writer":61,"./writer_buffer":62}],41:[function(require,module,exports){"use strict";module.exports=MapField;var Field=require("./field");((MapField.prototype=Object.create(Field.prototype)).constructor=MapField).className="MapField";var types=require("./types"),util=require("./util");function MapField(name,id,keyType,type,options,comment){Field.call(this,name,id,type,undefined,undefined,options,comment);if(!util.isString(keyType))throw TypeError("keyType must be a string");this.keyType=keyType;this.resolvedKeyType=null;this.map=true}MapField.fromJSON=function fromJSON(name,json){return new MapField(name,json.id,json.keyType,json.type,json.options,json.comment)};MapField.prototype.toJSON=function toJSON(toJSONOptions){var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false;return util.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",keepComments?this.comment:undefined])};MapField.prototype.resolve=function resolve(){if(this.resolved)return this;if(types.mapKey[this.keyType]===undefined)throw Error("invalid key type: "+this.keyType);return Field.prototype.resolve.call(this)};MapField.d=function decorateMapField(fieldId,fieldKeyType,fieldValueType){if(typeof fieldValueType==="function")fieldValueType=util.decorateType(fieldValueType).name;else if(fieldValueType&&typeof fieldValueType==="object")fieldValueType=util.decorateEnum(fieldValueType).name;return function mapFieldDecorator(prototype,fieldName){util.decorateType(prototype.constructor).add(new MapField(fieldName,fieldId,fieldKeyType,fieldValueType))}}},{"./field":38,"./types":55,"./util":56}],42:[function(require,module,exports){"use strict";module.exports=Message;var util=require("./util/minimal");function Message(properties){if(properties)for(var keys=Object.keys(properties),i=0;i<keys.length;++i)this[keys[i]]=properties[keys[i]]}Message.create=function create(properties){return this.$type.create(properties)};Message.encode=function encode(message,writer){return this.$type.encode(message,writer)};Message.encodeDelimited=function encodeDelimited(message,writer){return this.$type.encodeDelimited(message,writer)};Message.decode=function decode(reader){return this.$type.decode(reader)};Message.decodeDelimited=function decodeDelimited(reader){return this.$type.decodeDelimited(reader)};Message.verify=function verify(message){return this.$type.verify(message)};Message.fromObject=function fromObject(object){return this.$type.fromObject(object)};Message.toObject=function toObject(message,options){return this.$type.toObject(message,options)};Message.prototype.toJSON=function toJSON(){return this.$type.toObject(this,util.toJSONOptions)}},{"./util/minimal":58}],43:[function(require,module,exports){"use strict";module.exports=Method;var ReflectionObject=require("./object");((Method.prototype=Object.create(ReflectionObject.prototype)).constructor=Method).className="Method";var util=require("./util");function Method(name,type,requestType,responseType,requestStream,responseStream,options,comment){if(util.isObject(requestStream)){options=requestStream;requestStream=responseStream=undefined}else if(util.isObject(responseStream)){options=responseStream;responseStream=undefined}if(!(type===undefined||util.isString(type)))throw TypeError("type must be a string");if(!util.isString(requestType))throw TypeError("requestType must be a string");if(!util.isString(responseType))throw TypeError("responseType must be a string");ReflectionObject.call(this,name,options);this.type=type||"rpc";this.requestType=requestType;this.requestStream=requestStream?true:undefined;this.responseType=responseType;this.responseStream=responseStream?true:undefined;this.resolvedRequestType=null;this.resolvedResponseType=null;this.comment=comment}Method.fromJSON=function fromJSON(name,json){return new Method(name,json.type,json.requestType,json.responseType,json.requestStream,json.responseStream,json.options,json.comment)};Method.prototype.toJSON=function toJSON(toJSONOptions){var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false;return util.toObject(["type",this.type!=="rpc"&&this.type||undefined,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",keepComments?this.comment:undefined])};Method.prototype.resolve=function resolve(){if(this.resolved)return this;this.resolvedRequestType=this.parent.lookupType(this.requestType);this.resolvedResponseType=this.parent.lookupType(this.responseType);return ReflectionObject.prototype.resolve.call(this)}},{"./object":45,"./util":56}],44:[function(require,module,exports){"use strict";module.exports=Namespace;var ReflectionObject=require("./object");((Namespace.prototype=Object.create(ReflectionObject.prototype)).constructor=Namespace).className="Namespace";var Field=require("./field"),util=require("./util");var Type,Service,Enum;Namespace.fromJSON=function fromJSON(name,json){return new Namespace(name,json.options).addJSON(json.nested)};function arrayToJSON(array,toJSONOptions){if(!(array&&array.length))return undefined;var obj={};for(var i=0;i<array.length;++i)obj[array[i].name]=array[i].toJSON(toJSONOptions);return obj}Namespace.arrayToJSON=arrayToJSON;Namespace.isReservedId=function isReservedId(reserved,id){if(reserved)for(var i=0;i<reserved.length;++i)if(typeof reserved[i]!=="string"&&reserved[i][0]<=id&&reserved[i][1]>=id)return true;return false};Namespace.isReservedName=function isReservedName(reserved,name){if(reserved)for(var i=0;i<reserved.length;++i)if(reserved[i]===name)return true;return false};function Namespace(name,options){ReflectionObject.call(this,name,options);this.nested=undefined;this._nestedArray=null}function clearCache(namespace){namespace._nestedArray=null;return namespace}Object.defineProperty(Namespace.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=util.toArray(this.nested))}});Namespace.prototype.toJSON=function toJSON(toJSONOptions){return util.toObject(["options",this.options,"nested",arrayToJSON(this.nestedArray,toJSONOptions)])};Namespace.prototype.addJSON=function addJSON(nestedJson){var ns=this;if(nestedJson){for(var names=Object.keys(nestedJson),i=0,nested;i<names.length;++i){nested=nestedJson[names[i]];ns.add((nested.fields!==undefined?Type.fromJSON:nested.values!==undefined?Enum.fromJSON:nested.methods!==undefined?Service.fromJSON:nested.id!==undefined?Field.fromJSON:Namespace.fromJSON)(names[i],nested))}}return this};Namespace.prototype.get=function get(name){return this.nested&&this.nested[name]||null};Namespace.prototype.getEnum=function getEnum(name){if(this.nested&&this.nested[name]instanceof Enum)return this.nested[name].values;throw Error("no such enum: "+name)};Namespace.prototype.add=function add(object){if(!(object instanceof Field&&object.extend!==undefined||object instanceof Type||object instanceof Enum||object instanceof Service||object instanceof Namespace))throw TypeError("object must be a valid nested object");if(!this.nested)this.nested={};else{var prev=this.get(object.name);if(prev){if(prev instanceof Namespace&&object instanceof Namespace&&!(prev instanceof Type||prev instanceof Service)){var nested=prev.nestedArray;for(var i=0;i<nested.length;++i)object.add(nested[i]);this.remove(prev);if(!this.nested)this.nested={};object.setOptions(prev.options,true)}else throw Error("duplicate name '"+object.name+"' in "+this)}}this.nested[object.name]=object;object.onAdd(this);return clearCache(this)};Namespace.prototype.remove=function remove(object){if(!(object instanceof ReflectionObject))throw TypeError("object must be a ReflectionObject");if(object.parent!==this)throw Error(object+" is not a member of "+this);delete this.nested[object.name];if(!Object.keys(this.nested).length)this.nested=undefined;object.onRemove(this);return clearCache(this)};Namespace.prototype.define=function define(path,json){if(util.isString(path))path=path.split(".");else if(!Array.isArray(path))throw TypeError("illegal path");if(path&&path.length&&path[0]==="")throw Error("path must be relative");var ptr=this;while(path.length>0){var part=path.shift();if(ptr.nested&&ptr.nested[part]){ptr=ptr.nested[part];if(!(ptr instanceof Namespace))throw Error("path conflicts with non-namespace objects")}else ptr.add(ptr=new Namespace(part))}if(json)ptr.addJSON(json);return ptr};Namespace.prototype.resolveAll=function resolveAll(){var nested=this.nestedArray,i=0;while(i<nested.length)if(nested[i]instanceof Namespace)nested[i++].resolveAll();else nested[i++].resolve();return this.resolve()};Namespace.prototype.lookup=function lookup(path,filterTypes,parentAlreadyChecked){if(typeof filterTypes==="boolean"){parentAlreadyChecked=filterTypes;filterTypes=undefined}else if(filterTypes&&!Array.isArray(filterTypes))filterTypes=[filterTypes];if(util.isString(path)&&path.length){if(path===".")return this.root;path=path.split(".")}else if(!path.length)return this;if(path[0]==="")return this.root.lookup(path.slice(1),filterTypes);var found=this.get(path[0]);if(found){if(path.length===1){if(!filterTypes||filterTypes.indexOf(found.constructor)>-1)return found}else if(found instanceof Namespace&&(found=found.lookup(path.slice(1),filterTypes,true)))return found}else for(var i=0;i<this.nestedArray.length;++i)if(this._nestedArray[i]instanceof Namespace&&(found=this._nestedArray[i].lookup(path,filterTypes,true)))return found;if(this.parent===null||parentAlreadyChecked)return null;return this.parent.lookup(path,filterTypes)};Namespace.prototype.lookupType=function lookupType(path){var found=this.lookup(path,[Type]);if(!found)throw Error("no such type: "+path);return found};Namespace.prototype.lookupEnum=function lookupEnum(path){var found=this.lookup(path,[Enum]);if(!found)throw Error("no such Enum '"+path+"' in "+this);return found};Namespace.prototype.lookupTypeOrEnum=function lookupTypeOrEnum(path){var found=this.lookup(path,[Type,Enum]);if(!found)throw Error("no such Type or Enum '"+path+"' in "+this);return found};Namespace.prototype.lookupService=function lookupService(path){var found=this.lookup(path,[Service]);if(!found)throw Error("no such Service '"+path+"' in "+this);return found};Namespace._configure=function(Type_,Service_,Enum_){Type=Type_;Service=Service_;Enum=Enum_}},{"./field":38,"./object":45,"./util":56}],45:[function(require,module,exports){"use strict";module.exports=ReflectionObject;ReflectionObject.className="ReflectionObject";var util=require("./util");var Root;function ReflectionObject(name,options){if(!util.isString(name))throw TypeError("name must be a string");if(options&&!util.isObject(options))throw TypeError("options must be an object");this.options=options;this.name=name;this.parent=null;this.resolved=false;this.comment=null;this.filename=null}Object.defineProperties(ReflectionObject.prototype,{root:{get:function(){var ptr=this;while(ptr.parent!==null)ptr=ptr.parent;return ptr}},fullName:{get:function(){var path=[this.name],ptr=this.parent;while(ptr){path.unshift(ptr.name);ptr=ptr.parent}return path.join(".")}}});ReflectionObject.prototype.toJSON=function toJSON(){throw Error()};ReflectionObject.prototype.onAdd=function onAdd(parent){if(this.parent&&this.parent!==parent)this.parent.remove(this);this.parent=parent;this.resolved=false;var root=parent.root;if(root instanceof Root)root._handleAdd(this)};ReflectionObject.prototype.onRemove=function onRemove(parent){var root=parent.root;if(root instanceof Root)root._handleRemove(this);this.parent=null;this.resolved=false};ReflectionObject.prototype.resolve=function resolve(){if(this.resolved)return this;if(this.root instanceof Root)this.resolved=true;return this};ReflectionObject.prototype.getOption=function getOption(name){if(this.options)return this.options[name];return undefined};ReflectionObject.prototype.setOption=function setOption(name,value,ifNotSet){if(!ifNotSet||!this.options||this.options[name]===undefined)(this.options||(this.options={}))[name]=value;return this};ReflectionObject.prototype.setOptions=function setOptions(options,ifNotSet){if(options)for(var keys=Object.keys(options),i=0;i<keys.length;++i)this.setOption(keys[i],options[keys[i]],ifNotSet);return this};ReflectionObject.prototype.toString=function toString(){var className=this.constructor.className,fullName=this.fullName;if(fullName.length)return className+" "+fullName;return className};ReflectionObject._configure=function(Root_){Root=Root_}},{"./util":56}],46:[function(require,module,exports){"use strict";module.exports=OneOf;var ReflectionObject=require("./object");((OneOf.prototype=Object.create(ReflectionObject.prototype)).constructor=OneOf).className="OneOf";var Field=require("./field"),util=require("./util");function OneOf(name,fieldNames,options,comment){if(!Array.isArray(fieldNames)){options=fieldNames;fieldNames=undefined}ReflectionObject.call(this,name,options);if(!(fieldNames===undefined||Array.isArray(fieldNames)))throw TypeError("fieldNames must be an Array");this.oneof=fieldNames||[];this.fieldsArray=[];this.comment=comment}OneOf.fromJSON=function fromJSON(name,json){return new OneOf(name,json.oneof,json.options,json.comment)};OneOf.prototype.toJSON=function toJSON(toJSONOptions){var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false;return util.toObject(["options",this.options,"oneof",this.oneof,"comment",keepComments?this.comment:undefined])};function addFieldsToParent(oneof){if(oneof.parent)for(var i=0;i<oneof.fieldsArray.length;++i)if(!oneof.fieldsArray[i].parent)oneof.parent.add(oneof.fieldsArray[i])}OneOf.prototype.add=function add(field){if(!(field instanceof Field))throw TypeError("field must be a Field");if(field.parent&&field.parent!==this.parent)field.parent.remove(field);this.oneof.push(field.name);this.fieldsArray.push(field);field.partOf=this;addFieldsToParent(this);return this};OneOf.prototype.remove=function remove(field){if(!(field instanceof Field))throw TypeError("field must be a Field");var index=this.fieldsArray.indexOf(field);if(index<0)throw Error(field+" is not a member of "+this);this.fieldsArray.splice(index,1);index=this.oneof.indexOf(field.name);if(index>-1)this.oneof.splice(index,1);field.partOf=null;return this};OneOf.prototype.onAdd=function onAdd(parent){ReflectionObject.prototype.onAdd.call(this,parent);var self=this;for(var i=0;i<this.oneof.length;++i){var field=parent.get(this.oneof[i]);if(field&&!field.partOf){field.partOf=self;self.fieldsArray.push(field)}}addFieldsToParent(this)};OneOf.prototype.onRemove=function onRemove(parent){for(var i=0,field;i<this.fieldsArray.length;++i)if((field=this.fieldsArray[i]).parent)field.parent.remove(field);ReflectionObject.prototype.onRemove.call(this,parent)};OneOf.d=function decorateOneOf(){var fieldNames=new Array(arguments.length),index=0;while(index<arguments.length)fieldNames[index]=arguments[index++];return function oneOfDecorator(prototype,oneofName){util.decorateType(prototype.constructor).add(new OneOf(oneofName,fieldNames));Object.defineProperty(prototype,oneofName,{get:util.oneOfGetter(fieldNames),set:util.oneOfSetter(fieldNames)})}}},{"./field":38,"./object":45,"./util":56}],47:[function(require,module,exports){"use strict";module.exports=Reader;var util=require("./util/minimal");var BufferReader;var LongBits=util.LongBits,utf8=util.utf8;function indexOutOfRange(reader,writeLength){return RangeError("index out of range: "+reader.pos+" + "+(writeLength||1)+" > "+reader.len)}function Reader(buffer){this.buf=buffer;this.pos=0;this.len=buffer.length}var create_array=typeof Uint8Array!=="undefined"?function create_typed_array(buffer){if(buffer instanceof Uint8Array||Array.isArray(buffer))return new Reader(buffer);throw Error("illegal buffer")}:function create_array(buffer){if(Array.isArray(buffer))return new Reader(buffer);throw Error("illegal buffer")};Reader.create=util.Buffer?function create_buffer_setup(buffer){return(Reader.create=function create_buffer(buffer){return util.Buffer.isBuffer(buffer)?new BufferReader(buffer):create_array(buffer)})(buffer)}:create_array;Reader.prototype._slice=util.Array.prototype.subarray||util.Array.prototype.slice;Reader.prototype.uint32=function read_uint32_setup(){var value=4294967295;return function read_uint32(){value=(this.buf[this.pos]&127)>>>0;if(this.buf[this.pos++]<128)return value;value=(value|(this.buf[this.pos]&127)<<7)>>>0;if(this.buf[this.pos++]<128)return value;value=(value|(this.buf[this.pos]&127)<<14)>>>0;if(this.buf[this.pos++]<128)return value;value=(value|(this.buf[this.pos]&127)<<21)>>>0;if(this.buf[this.pos++]<128)return value;value=(value|(this.buf[this.pos]&15)<<28)>>>0;if(this.buf[this.pos++]<128)return value;if((this.pos+=5)>this.len){this.pos=this.len;throw indexOutOfRange(this,10)}return value}}();Reader.prototype.int32=function read_int32(){return this.uint32()|0};Reader.prototype.sint32=function read_sint32(){var value=this.uint32();return value>>>1^-(value&1)|0};function readLongVarint(){var bits=new LongBits(0,0);var i=0;if(this.len-this.pos>4){for(;i<4;++i){bits.lo=(bits.lo|(this.buf[this.pos]&127)<<i*7)>>>0;if(this.buf[this.pos++]<128)return bits}bits.lo=(bits.lo|(this.buf[this.pos]&127)<<28)>>>0;bits.hi=(bits.hi|(this.buf[this.pos]&127)>>4)>>>0;if(this.buf[this.pos++]<128)return bits;i=0}else{for(;i<3;++i){if(this.pos>=this.len)throw indexOutOfRange(this);bits.lo=(bits.lo|(this.buf[this.pos]&127)<<i*7)>>>0;if(this.buf[this.pos++]<128)return bits}bits.lo=(bits.lo|(this.buf[this.pos++]&127)<<i*7)>>>0;return bits}if(this.len-this.pos>4){for(;i<5;++i){bits.hi=(bits.hi|(this.buf[this.pos]&127)<<i*7+3)>>>0;if(this.buf[this.pos++]<128)return bits}}else{for(;i<5;++i){if(this.pos>=this.len)throw indexOutOfRange(this);bits.hi=(bits.hi|(this.buf[this.pos]&127)<<i*7+3)>>>0;if(this.buf[this.pos++]<128)return bits}}throw Error("invalid varint encoding")}Reader.prototype.bool=function read_bool(){return this.uint32()!==0};function readFixed32_end(buf,end){return(buf[end-4]|buf[end-3]<<8|buf[end-2]<<16|buf[end-1]<<24)>>>0}Reader.prototype.fixed32=function read_fixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)};Reader.prototype.sfixed32=function read_sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader.prototype.float=function read_float(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var value=util.float.readFloatLE(this.buf,this.pos);this.pos+=4;return value};Reader.prototype.double=function read_double(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var value=util.float.readDoubleLE(this.buf,this.pos);this.pos+=8;return value};Reader.prototype.bytes=function read_bytes(){var length=this.uint32(),start=this.pos,end=this.pos+length;if(end>this.len)throw indexOutOfRange(this,length);this.pos+=length;if(Array.isArray(this.buf))return this.buf.slice(start,end);return start===end?new this.buf.constructor(0):this._slice.call(this.buf,start,end)};Reader.prototype.string=function read_string(){var bytes=this.bytes();return utf8.read(bytes,0,bytes.length)};Reader.prototype.skip=function skip(length){if(typeof length==="number"){if(this.pos+length>this.len)throw indexOutOfRange(this,length);this.pos+=length}else{do{if(this.pos>=this.len)throw indexOutOfRange(this)}while(this.buf[this.pos++]&128)}return this};Reader.prototype.skipType=function(wireType){switch(wireType){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:while((wireType=this.uint32()&7)!==4){this.skipType(wireType)}break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+wireType+" at offset "+this.pos)}return this};Reader._configure=function(BufferReader_){BufferReader=BufferReader_;var fn=util.Long?"toLong":"toNumber";util.merge(Reader.prototype,{int64:function read_int64(){return readLongVarint.call(this)[fn](false)},uint64:function read_uint64(){return readLongVarint.call(this)[fn](true)},sint64:function read_sint64(){return readLongVarint.call(this).zzDecode()[fn](false)},fixed64:function read_fixed64(){return readFixed64.call(this)[fn](true)},sfixed64:function read_sfixed64(){return readFixed64.call(this)[fn](false)}})}},{"./util/minimal":58}],48:[function(require,module,exports){"use strict";module.exports=BufferReader;var Reader=require("./reader");(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util=require("./util/minimal");function BufferReader(buffer){Reader.call(this,buffer)}if(util.Buffer)BufferReader.prototype._slice=util.Buffer.prototype.slice;BufferReader.prototype.string=function read_string_buffer(){var len=this.uint32();return this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+len,this.len))}},{"./reader":47,"./util/minimal":58}],49:[function(require,module,exports){"use strict";module.exports=Root;var Namespace=require("./namespace");((Root.prototype=Object.create(Namespace.prototype)).constructor=Root).className="Root";var Field=require("./field"),Enum=require("./enum"),OneOf=require("./oneof"),util=require("./util");var Type,parse,common;function Root(options){Namespace.call(this,"",options);this.deferred=[];this.files=[]}Root.fromJSON=function fromJSON(json,root){if(!root)root=new Root;if(json.options)root.setOptions(json.options);return root.addJSON(json.nested)};Root.prototype.resolvePath=util.path.resolve;function SYNC(){}Root.prototype.load=function load(filename,options,callback){if(typeof options==="function"){callback=options;options=undefined}var self=this;if(!callback)return util.asPromise(load,self,filename,options);var sync=callback===SYNC;function finish(err,root){if(!callback)return;var cb=callback;callback=null;if(sync)throw err;cb(err,root)}function process(filename,source){try{if(util.isString(source)&&source.charAt(0)==="{")source=JSON.parse(source);if(!util.isString(source))self.setOptions(source.options).addJSON(source.nested);else{parse.filename=filename;var parsed=parse(source,self,options),resolved,i=0;if(parsed.imports)for(;i<parsed.imports.length;++i)if(resolved=self.resolvePath(filename,parsed.imports[i]))fetch(resolved);if(parsed.weakImports)for(i=0;i<parsed.weakImports.length;++i)if(resolved=self.resolvePath(filename,parsed.weakImports[i]))fetch(resolved,true)}}catch(err){finish(err)}if(!sync&&!queued)finish(null,self)}function fetch(filename,weak){var idx=filename.lastIndexOf("google/protobuf/");if(idx>-1){var altname=filename.substring(idx);if(altname in common)filename=altname}if(self.files.indexOf(filename)>-1)return;self.files.push(filename);if(filename in common){if(sync)process(filename,common[filename]);else{++queued;setTimeout(function(){--queued;process(filename,common[filename])})}return}if(sync){var source;try{source=util.fs.readFileSync(filename).toString("utf8")}catch(err){if(!weak)finish(err);return}process(filename,source)}else{++queued;util.fetch(filename,function(err,source){--queued;if(!callback)return;if(err){if(!weak)finish(err);else if(!queued)finish(null,self);return}process(filename,source)})}}var queued=0;if(util.isString(filename))filename=[filename];for(var i=0,resolved;i<filename.length;++i)if(resolved=self.resolvePath("",filename[i]))fetch(resolved);if(sync)return self;if(!queued)finish(null,self);return undefined};Root.prototype.loadSync=function loadSync(filename,options){if(!util.isNode)throw Error("not supported");return this.load(filename,options,SYNC)};Root.prototype.resolveAll=function resolveAll(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(field){return"'extend "+field.extend+"' in "+field.parent.fullName}).join(", "));return Namespace.prototype.resolveAll.call(this)};var exposeRe=/^[A-Z]/;function tryHandleExtension(root,field){var extendedType=field.parent.lookup(field.extend);if(extendedType){var sisterField=new Field(field.fullName,field.id,field.type,field.rule,undefined,field.options);sisterField.declaringField=field;field.extensionField=sisterField;extendedType.add(sisterField);return true}return false}Root.prototype._handleAdd=function _handleAdd(object){if(object instanceof Field){if(object.extend!==undefined&&!object.extensionField)if(!tryHandleExtension(this,object))this.deferred.push(object)}else if(object instanceof Enum){if(exposeRe.test(object.name))object.parent[object.name]=object.values}else if(!(object instanceof OneOf)){if(object instanceof Type)for(var i=0;i<this.deferred.length;)if(tryHandleExtension(this,this.deferred[i]))this.deferred.splice(i,1);else++i;for(var j=0;j<object.nestedArray.length;++j)this._handleAdd(object._nestedArray[j]);if(exposeRe.test(object.name))object.parent[object.name]=object}};Root.prototype._handleRemove=function _handleRemove(object){if(object instanceof Field){if(object.extend!==undefined){if(object.extensionField){object.extensionField.parent.remove(object.extensionField);object.extensionField=null}else{var index=this.deferred.indexOf(object);if(index>-1)this.deferred.splice(index,1)}}}else if(object instanceof Enum){if(exposeRe.test(object.name))delete object.parent[object.name]}else if(object instanceof Namespace){for(var i=0;i<object.nestedArray.length;++i)this._handleRemove(object._nestedArray[i]);if(exposeRe.test(object.name))delete object.parent[object.name]}};Root._configure=function(Type_,parse_,common_){Type=Type_;parse=parse_;common=common_}},{"./enum":37,"./field":38,"./namespace":44,"./oneof":46,"./util":56}],50:[function(require,module,exports){"use strict";module.exports={}},{}],51:[function(require,module,exports){"use strict";var rpc=exports;rpc.Service=require("./rpc/service")},{"./rpc/service":52}],52:[function(require,module,exports){"use strict";module.exports=Service;var util=require("../util/minimal");(Service.prototype=Object.create(util.EventEmitter.prototype)).constructor=Service;function Service(rpcImpl,requestDelimited,responseDelimited){if(typeof rpcImpl!=="function")throw TypeError("rpcImpl must be a function");util.EventEmitter.call(this);this.rpcImpl=rpcImpl;this.requestDelimited=Boolean(requestDelimited);this.responseDelimited=Boolean(responseDelimited)}Service.prototype.rpcCall=function rpcCall(method,requestCtor,responseCtor,request,callback){if(!request)throw TypeError("request must be specified");var self=this;if(!callback)return util.asPromise(rpcCall,self,method,requestCtor,responseCtor,request);if(!self.rpcImpl){setTimeout(function(){callback(Error("already ended"))},0);return undefined}try{return self.rpcImpl(method,requestCtor[self.requestDelimited?"encodeDelimited":"encode"](request).finish(),function rpcCallback(err,response){if(err){self.emit("error",err,method);return callback(err)}if(response===null){self.end(true);return undefined}if(!(response instanceof responseCtor)){try{response=responseCtor[self.responseDelimited?"decodeDelimited":"decode"](response)}catch(err){self.emit("error",err,method);return callback(err)}}self.emit("data",response,method);return callback(null,response)})}catch(err){self.emit("error",err,method);setTimeout(function(){callback(err)},0);return undefined}};Service.prototype.end=function end(endedByRPC){if(this.rpcImpl){if(!endedByRPC)this.rpcImpl(null,null,null);this.rpcImpl=null;this.emit("end").off()
  }return this}},{"../util/minimal":58}],53:[function(require,module,exports){"use strict";module.exports=Service;var Namespace=require("./namespace");((Service.prototype=Object.create(Namespace.prototype)).constructor=Service).className="Service";var Method=require("./method"),util=require("./util"),rpc=require("./rpc");function Service(name,options){Namespace.call(this,name,options);this.methods={};this._methodsArray=null}Service.fromJSON=function fromJSON(name,json){var service=new Service(name,json.options);if(json.methods)for(var names=Object.keys(json.methods),i=0;i<names.length;++i)service.add(Method.fromJSON(names[i],json.methods[names[i]]));if(json.nested)service.addJSON(json.nested);service.comment=json.comment;return service};Service.prototype.toJSON=function toJSON(toJSONOptions){var inherited=Namespace.prototype.toJSON.call(this,toJSONOptions);var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false;return util.toObject(["options",inherited&&inherited.options||undefined,"methods",Namespace.arrayToJSON(this.methodsArray,toJSONOptions)||{},"nested",inherited&&inherited.nested||undefined,"comment",keepComments?this.comment:undefined])};Object.defineProperty(Service.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=util.toArray(this.methods))}});function clearCache(service){service._methodsArray=null;return service}Service.prototype.get=function get(name){return this.methods[name]||Namespace.prototype.get.call(this,name)};Service.prototype.resolveAll=function resolveAll(){var methods=this.methodsArray;for(var i=0;i<methods.length;++i)methods[i].resolve();return Namespace.prototype.resolve.call(this)};Service.prototype.add=function add(object){if(this.get(object.name))throw Error("duplicate name '"+object.name+"' in "+this);if(object instanceof Method){this.methods[object.name]=object;object.parent=this;return clearCache(this)}return Namespace.prototype.add.call(this,object)};Service.prototype.remove=function remove(object){if(object instanceof Method){if(this.methods[object.name]!==object)throw Error(object+" is not a member of "+this);delete this.methods[object.name];object.parent=null;return clearCache(this)}return Namespace.prototype.remove.call(this,object)};Service.prototype.create=function create(rpcImpl,requestDelimited,responseDelimited){var rpcService=new rpc.Service(rpcImpl,requestDelimited,responseDelimited);for(var i=0,method;i<this.methodsArray.length;++i){var methodName=util.lcFirst((method=this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g,"");rpcService[methodName]=util.codegen(["r","c"],util.isReserved(methodName)?methodName+"_":methodName)("return this.rpcCall(m,q,s,r,c)")({m:method,q:method.resolvedRequestType.ctor,s:method.resolvedResponseType.ctor})}return rpcService}},{"./method":43,"./namespace":44,"./rpc":51,"./util":56}],54:[function(require,module,exports){"use strict";module.exports=Type;var Namespace=require("./namespace");((Type.prototype=Object.create(Namespace.prototype)).constructor=Type).className="Type";var Enum=require("./enum"),OneOf=require("./oneof"),Field=require("./field"),MapField=require("./mapfield"),Service=require("./service"),Message=require("./message"),Reader=require("./reader"),Writer=require("./writer"),util=require("./util"),encoder=require("./encoder"),decoder=require("./decoder"),verifier=require("./verifier"),converter=require("./converter"),wrappers=require("./wrappers");function Type(name,options){Namespace.call(this,name,options);this.fields={};this.oneofs=undefined;this.extensions=undefined;this.reserved=undefined;this.group=undefined;this._fieldsById=null;this._fieldsArray=null;this._oneofsArray=null;this._ctor=null}Object.defineProperties(Type.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var names=Object.keys(this.fields),i=0;i<names.length;++i){var field=this.fields[names[i]],id=field.id;if(this._fieldsById[id])throw Error("duplicate id "+id+" in "+this);this._fieldsById[id]=field}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=util.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=util.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=Type.generateConstructor(this)())},set:function(ctor){var prototype=ctor.prototype;if(!(prototype instanceof Message)){(ctor.prototype=new Message).constructor=ctor;util.merge(ctor.prototype,prototype)}ctor.$type=ctor.prototype.$type=this;util.merge(ctor,Message,true);this._ctor=ctor;var i=0;for(;i<this.fieldsArray.length;++i)this._fieldsArray[i].resolve();var ctorProperties={};for(i=0;i<this.oneofsArray.length;++i)ctorProperties[this._oneofsArray[i].resolve().name]={get:util.oneOfGetter(this._oneofsArray[i].oneof),set:util.oneOfSetter(this._oneofsArray[i].oneof)};if(i)Object.defineProperties(ctor.prototype,ctorProperties)}}});Type.generateConstructor=function generateConstructor(mtype){var gen=util.codegen(["p"],mtype.name);for(var i=0,field;i<mtype.fieldsArray.length;++i)if((field=mtype._fieldsArray[i]).map)gen("this%s={}",util.safeProp(field.name));else if(field.repeated)gen("this%s=[]",util.safeProp(field.name));return gen("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")};function clearCache(type){type._fieldsById=type._fieldsArray=type._oneofsArray=null;delete type.encode;delete type.decode;delete type.verify;return type}Type.fromJSON=function fromJSON(name,json){var type=new Type(name,json.options);type.extensions=json.extensions;type.reserved=json.reserved;var names=Object.keys(json.fields),i=0;for(;i<names.length;++i)type.add((typeof json.fields[names[i]].keyType!=="undefined"?MapField.fromJSON:Field.fromJSON)(names[i],json.fields[names[i]]));if(json.oneofs)for(names=Object.keys(json.oneofs),i=0;i<names.length;++i)type.add(OneOf.fromJSON(names[i],json.oneofs[names[i]]));if(json.nested)for(names=Object.keys(json.nested),i=0;i<names.length;++i){var nested=json.nested[names[i]];type.add((nested.id!==undefined?Field.fromJSON:nested.fields!==undefined?Type.fromJSON:nested.values!==undefined?Enum.fromJSON:nested.methods!==undefined?Service.fromJSON:Namespace.fromJSON)(names[i],nested))}if(json.extensions&&json.extensions.length)type.extensions=json.extensions;if(json.reserved&&json.reserved.length)type.reserved=json.reserved;if(json.group)type.group=true;if(json.comment)type.comment=json.comment;return type};Type.prototype.toJSON=function toJSON(toJSONOptions){var inherited=Namespace.prototype.toJSON.call(this,toJSONOptions);var keepComments=toJSONOptions?Boolean(toJSONOptions.keepComments):false;return util.toObject(["options",inherited&&inherited.options||undefined,"oneofs",Namespace.arrayToJSON(this.oneofsArray,toJSONOptions),"fields",Namespace.arrayToJSON(this.fieldsArray.filter(function(obj){return!obj.declaringField}),toJSONOptions)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:undefined,"reserved",this.reserved&&this.reserved.length?this.reserved:undefined,"group",this.group||undefined,"nested",inherited&&inherited.nested||undefined,"comment",keepComments?this.comment:undefined])};Type.prototype.resolveAll=function resolveAll(){var fields=this.fieldsArray,i=0;while(i<fields.length)fields[i++].resolve();var oneofs=this.oneofsArray;i=0;while(i<oneofs.length)oneofs[i++].resolve();return Namespace.prototype.resolveAll.call(this)};Type.prototype.get=function get(name){return this.fields[name]||this.oneofs&&this.oneofs[name]||this.nested&&this.nested[name]||null};Type.prototype.add=function add(object){if(this.get(object.name))throw Error("duplicate name '"+object.name+"' in "+this);if(object instanceof Field&&object.extend===undefined){if(this._fieldsById?this._fieldsById[object.id]:this.fieldsById[object.id])throw Error("duplicate id "+object.id+" in "+this);if(this.isReservedId(object.id))throw Error("id "+object.id+" is reserved in "+this);if(this.isReservedName(object.name))throw Error("name '"+object.name+"' is reserved in "+this);if(object.parent)object.parent.remove(object);this.fields[object.name]=object;object.message=this;object.onAdd(this);return clearCache(this)}if(object instanceof OneOf){if(!this.oneofs)this.oneofs={};this.oneofs[object.name]=object;object.onAdd(this);return clearCache(this)}return Namespace.prototype.add.call(this,object)};Type.prototype.remove=function remove(object){if(object instanceof Field&&object.extend===undefined){if(!this.fields||this.fields[object.name]!==object)throw Error(object+" is not a member of "+this);delete this.fields[object.name];object.parent=null;object.onRemove(this);return clearCache(this)}if(object instanceof OneOf){if(!this.oneofs||this.oneofs[object.name]!==object)throw Error(object+" is not a member of "+this);delete this.oneofs[object.name];object.parent=null;object.onRemove(this);return clearCache(this)}return Namespace.prototype.remove.call(this,object)};Type.prototype.isReservedId=function isReservedId(id){return Namespace.isReservedId(this.reserved,id)};Type.prototype.isReservedName=function isReservedName(name){return Namespace.isReservedName(this.reserved,name)};Type.prototype.create=function create(properties){return new this.ctor(properties)};Type.prototype.setup=function setup(){var fullName=this.fullName,types=[];for(var i=0;i<this.fieldsArray.length;++i)types.push(this._fieldsArray[i].resolve().resolvedType);this.encode=encoder(this)({Writer:Writer,types:types,util:util});this.decode=decoder(this)({Reader:Reader,types:types,util:util});this.verify=verifier(this)({types:types,util:util});this.fromObject=converter.fromObject(this)({types:types,util:util});this.toObject=converter.toObject(this)({types:types,util:util});var wrapper=wrappers[fullName];if(wrapper){var originalThis=Object.create(this);originalThis.fromObject=this.fromObject;this.fromObject=wrapper.fromObject.bind(originalThis);originalThis.toObject=this.toObject;this.toObject=wrapper.toObject.bind(originalThis)}return this};Type.prototype.encode=function encode_setup(message,writer){return this.setup().encode(message,writer)};Type.prototype.encodeDelimited=function encodeDelimited(message,writer){return this.encode(message,writer&&writer.len?writer.fork():writer).ldelim()};Type.prototype.decode=function decode_setup(reader,length){return this.setup().decode(reader,length)};Type.prototype.decodeDelimited=function decodeDelimited(reader){if(!(reader instanceof Reader))reader=Reader.create(reader);return this.decode(reader,reader.uint32())};Type.prototype.verify=function verify_setup(message){return this.setup().verify(message)};Type.prototype.fromObject=function fromObject(object){return this.setup().fromObject(object)};Type.prototype.toObject=function toObject(message,options){return this.setup().toObject(message,options)};Type.d=function decorateType(typeName){return function typeDecorator(target){util.decorateType(target,typeName)}}},{"./converter":34,"./decoder":35,"./encoder":36,"./enum":37,"./field":38,"./mapfield":41,"./message":42,"./namespace":44,"./oneof":46,"./reader":47,"./service":53,"./util":56,"./verifier":59,"./wrappers":60,"./writer":61}],55:[function(require,module,exports){"use strict";var types=exports;var util=require("./util");var s=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function bake(values,offset){var i=0,o={};offset|=0;while(i<values.length)o[s[i+offset]]=values[i++];return o}types.basic=bake([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]);types.defaults=bake([0,0,0,0,0,0,0,0,0,0,0,0,false,"",util.emptyArray,null]);types.long=bake([0,0,0,1,1],7);types.mapKey=bake([0,0,0,5,5,0,0,0,1,1,0,2],2);types.packed=bake([1,5,0,0,0,5,5,0,0,0,1,1,0])},{"./util":56}],56:[function(require,module,exports){"use strict";var util=module.exports=require("./util/minimal");var roots=require("./roots");var Type,Enum;util.codegen=require("@protobufjs/codegen");util.fetch=require("@protobufjs/fetch");util.path=require("@protobufjs/path");util.fs=util.inquire("fs");util.toArray=function toArray(object){if(object){var keys=Object.keys(object),array=new Array(keys.length),index=0;while(index<keys.length)array[index]=object[keys[index++]];return array}return[]};util.toObject=function toObject(array){var object={},index=0;while(index<array.length){var key=array[index++],val=array[index++];if(val!==undefined)object[key]=val}return object};var safePropBackslashRe=/\\/g,safePropQuoteRe=/"/g;util.isReserved=function isReserved(name){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(name)};util.safeProp=function safeProp(prop){if(!/^[$\w_]+$/.test(prop)||util.isReserved(prop))return'["'+prop.replace(safePropBackslashRe,"\\\\").replace(safePropQuoteRe,'\\"')+'"]';return"."+prop};util.ucFirst=function ucFirst(str){return str.charAt(0).toUpperCase()+str.substring(1)};var camelCaseRe=/_([a-z])/g;util.camelCase=function camelCase(str){return str.substring(0,1)+str.substring(1).replace(camelCaseRe,function($0,$1){return $1.toUpperCase()})};util.compareFieldsById=function compareFieldsById(a,b){return a.id-b.id};util.decorateType=function decorateType(ctor,typeName){if(ctor.$type){if(typeName&&ctor.$type.name!==typeName){util.decorateRoot.remove(ctor.$type);ctor.$type.name=typeName;util.decorateRoot.add(ctor.$type)}return ctor.$type}if(!Type)Type=require("./type");var type=new Type(typeName||ctor.name);util.decorateRoot.add(type);type.ctor=ctor;Object.defineProperty(ctor,"$type",{value:type,enumerable:false});Object.defineProperty(ctor.prototype,"$type",{value:type,enumerable:false});return type};var decorateEnumIndex=0;util.decorateEnum=function decorateEnum(object){if(object.$type)return object.$type;if(!Enum)Enum=require("./enum");var enm=new Enum("Enum"+decorateEnumIndex++,object);util.decorateRoot.add(enm);Object.defineProperty(object,"$type",{value:enm,enumerable:false});return enm};Object.defineProperty(util,"decorateRoot",{get:function(){return roots["decorated"]||(roots["decorated"]=new(require("./root")))}})},{"./enum":37,"./root":49,"./roots":50,"./type":54,"./util/minimal":58,"@protobufjs/codegen":10,"@protobufjs/fetch":12,"@protobufjs/path":15}],57:[function(require,module,exports){"use strict";module.exports=LongBits;var util=require("../util/minimal");function LongBits(lo,hi){this.lo=lo>>>0;this.hi=hi>>>0}var zero=LongBits.zero=new LongBits(0,0);zero.toNumber=function(){return 0};zero.zzEncode=zero.zzDecode=function(){return this};zero.length=function(){return 1};var zeroHash=LongBits.zeroHash="\0\0\0\0\0\0\0\0";LongBits.fromNumber=function fromNumber(value){if(value===0)return zero;var sign=value<0;if(sign)value=-value;var lo=value>>>0,hi=(value-lo)/4294967296>>>0;if(sign){hi=~hi>>>0;lo=~lo>>>0;if(++lo>4294967295){lo=0;if(++hi>4294967295)hi=0}}return new LongBits(lo,hi)};LongBits.from=function from(value){if(typeof value==="number")return LongBits.fromNumber(value);if(util.isString(value)){if(util.Long)value=util.Long.fromString(value);else return LongBits.fromNumber(parseInt(value,10))}return value.low||value.high?new LongBits(value.low>>>0,value.high>>>0):zero};LongBits.prototype.toNumber=function toNumber(unsigned){if(!unsigned&&this.hi>>>31){var lo=~this.lo+1>>>0,hi=~this.hi>>>0;if(!lo)hi=hi+1>>>0;return-(lo+hi*4294967296)}return this.lo+this.hi*4294967296};LongBits.prototype.toLong=function toLong(unsigned){return util.Long?new util.Long(this.lo|0,this.hi|0,Boolean(unsigned)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(unsigned)}};var charCodeAt=String.prototype.charCodeAt;LongBits.fromHash=function fromHash(hash){if(hash===zeroHash)return zero;return new LongBits((charCodeAt.call(hash,0)|charCodeAt.call(hash,1)<<8|charCodeAt.call(hash,2)<<16|charCodeAt.call(hash,3)<<24)>>>0,(charCodeAt.call(hash,4)|charCodeAt.call(hash,5)<<8|charCodeAt.call(hash,6)<<16|charCodeAt.call(hash,7)<<24)>>>0)};LongBits.prototype.toHash=function toHash(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};LongBits.prototype.zzEncode=function zzEncode(){var mask=this.hi>>31;this.hi=((this.hi<<1|this.lo>>>31)^mask)>>>0;this.lo=(this.lo<<1^mask)>>>0;return this};LongBits.prototype.zzDecode=function zzDecode(){var mask=-(this.lo&1);this.lo=((this.lo>>>1|this.hi<<31)^mask)>>>0;this.hi=(this.hi>>>1^mask)>>>0;return this};LongBits.prototype.length=function length(){var part0=this.lo,part1=(this.lo>>>28|this.hi<<4)>>>0,part2=this.hi>>>24;return part2===0?part1===0?part0<16384?part0<128?1:2:part0<2097152?3:4:part1<16384?part1<128?5:6:part1<2097152?7:8:part2<128?9:10}},{"../util/minimal":58}],58:[function(require,module,exports){(function(global){"use strict";var util=exports;util.asPromise=require("@protobufjs/aspromise");util.base64=require("@protobufjs/base64");util.EventEmitter=require("@protobufjs/eventemitter");util.float=require("@protobufjs/float");util.inquire=require("@protobufjs/inquire");util.utf8=require("@protobufjs/utf8");util.pool=require("@protobufjs/pool");util.LongBits=require("./longbits");util.global=typeof window!=="undefined"&&window||typeof global!=="undefined"&&global||typeof self!=="undefined"&&self||this;util.emptyArray=Object.freeze?Object.freeze([]):[];util.emptyObject=Object.freeze?Object.freeze({}):{};util.isNode=Boolean(util.global.process&&util.global.process.versions&&util.global.process.versions.node);util.isInteger=Number.isInteger||function isInteger(value){return typeof value==="number"&&isFinite(value)&&Math.floor(value)===value};util.isString=function isString(value){return typeof value==="string"||value instanceof String};util.isObject=function isObject(value){return value&&typeof value==="object"};util.isset=util.isSet=function isSet(obj,prop){var value=obj[prop];if(value!=null&&obj.hasOwnProperty(prop))return typeof value!=="object"||(Array.isArray(value)?value.length:Object.keys(value).length)>0;return false};util.Buffer=function(){try{var Buffer=util.inquire("buffer").Buffer;return Buffer.prototype.utf8Write?Buffer:null}catch(e){return null}}();util._Buffer_from=null;util._Buffer_allocUnsafe=null;util.newBuffer=function newBuffer(sizeOrArray){return typeof sizeOrArray==="number"?util.Buffer?util._Buffer_allocUnsafe(sizeOrArray):new util.Array(sizeOrArray):util.Buffer?util._Buffer_from(sizeOrArray):typeof Uint8Array==="undefined"?sizeOrArray:new Uint8Array(sizeOrArray)};util.Array=typeof Uint8Array!=="undefined"?Uint8Array:Array;util.Long=util.global.dcodeIO&&util.global.dcodeIO.Long||util.global.Long||util.inquire("long");util.key2Re=/^true|false|0|1$/;util.key32Re=/^-?(?:0|[1-9][0-9]*)$/;util.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;util.longToHash=function longToHash(value){return value?util.LongBits.from(value).toHash():util.LongBits.zeroHash};util.longFromHash=function longFromHash(hash,unsigned){var bits=util.LongBits.fromHash(hash);if(util.Long)return util.Long.fromBits(bits.lo,bits.hi,unsigned);return bits.toNumber(Boolean(unsigned))};function merge(dst,src,ifNotSet){for(var keys=Object.keys(src),i=0;i<keys.length;++i)if(dst[keys[i]]===undefined||!ifNotSet)dst[keys[i]]=src[keys[i]];return dst}util.merge=merge;util.lcFirst=function lcFirst(str){return str.charAt(0).toLowerCase()+str.substring(1)};function newError(name){function CustomError(message,properties){if(!(this instanceof CustomError))return new CustomError(message,properties);Object.defineProperty(this,"message",{get:function(){return message}});if(Error.captureStackTrace)Error.captureStackTrace(this,CustomError);else Object.defineProperty(this,"stack",{value:(new Error).stack||""});if(properties)merge(this,properties)}(CustomError.prototype=Object.create(Error.prototype)).constructor=CustomError;Object.defineProperty(CustomError.prototype,"name",{get:function(){return name}});CustomError.prototype.toString=function toString(){return this.name+": "+this.message};return CustomError}util.newError=newError;util.ProtocolError=newError("ProtocolError");util.oneOfGetter=function getOneOf(fieldNames){var fieldMap={};for(var i=0;i<fieldNames.length;++i)fieldMap[fieldNames[i]]=1;return function(){for(var keys=Object.keys(this),i=keys.length-1;i>-1;--i)if(fieldMap[keys[i]]===1&&this[keys[i]]!==undefined&&this[keys[i]]!==null)return keys[i]}};util.oneOfSetter=function setOneOf(fieldNames){return function(name){for(var i=0;i<fieldNames.length;++i)if(fieldNames[i]!==name)delete this[fieldNames[i]]}};util.toJSONOptions={longs:String,enums:String,bytes:String,json:true};util._configure=function(){var Buffer=util.Buffer;if(!Buffer){util._Buffer_from=util._Buffer_allocUnsafe=null;return}util._Buffer_from=Buffer.from!==Uint8Array.from&&Buffer.from||function Buffer_from(value,encoding){return new Buffer(value,encoding)};util._Buffer_allocUnsafe=Buffer.allocUnsafe||function Buffer_allocUnsafe(size){return new Buffer(size)}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./longbits":57,"@protobufjs/aspromise":8,"@protobufjs/base64":9,"@protobufjs/eventemitter":11,"@protobufjs/float":13,"@protobufjs/inquire":14,"@protobufjs/pool":16,"@protobufjs/utf8":17}],59:[function(require,module,exports){"use strict";module.exports=verifier;var Enum=require("./enum"),util=require("./util");function invalid(field,expected){return field.name+": "+expected+(field.repeated&&expected!=="array"?"[]":field.map&&expected!=="object"?"{k:"+field.keyType+"}":"")+" expected"}function genVerifyValue(gen,field,fieldIndex,ref){if(field.resolvedType){if(field.resolvedType instanceof Enum){gen("switch(%s){",ref)("default:")("return%j",invalid(field,"enum value"));for(var keys=Object.keys(field.resolvedType.values),j=0;j<keys.length;++j)gen("case %i:",field.resolvedType.values[keys[j]]);gen("break")("}")}else{gen("{")("var e=types[%i].verify(%s);",fieldIndex,ref)("if(e)")("return%j+e",field.name+".")("}")}}else{switch(field.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":gen("if(!util.isInteger(%s))",ref)("return%j",invalid(field,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":gen("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",ref,ref,ref,ref)("return%j",invalid(field,"integer|Long"));break;case"float":case"double":gen('if(typeof %s!=="number")',ref)("return%j",invalid(field,"number"));break;case"bool":gen('if(typeof %s!=="boolean")',ref)("return%j",invalid(field,"boolean"));break;case"string":gen("if(!util.isString(%s))",ref)("return%j",invalid(field,"string"));break;case"bytes":gen('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',ref,ref,ref)("return%j",invalid(field,"buffer"));break}}return gen}function genVerifyKey(gen,field,ref){switch(field.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":gen("if(!util.key32Re.test(%s))",ref)("return%j",invalid(field,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":gen("if(!util.key64Re.test(%s))",ref)("return%j",invalid(field,"integer|Long key"));break;case"bool":gen("if(!util.key2Re.test(%s))",ref)("return%j",invalid(field,"boolean key"));break}return gen}function verifier(mtype){var gen=util.codegen(["m"],mtype.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected");var oneofs=mtype.oneofsArray,seenFirstField={};if(oneofs.length)gen("var p={}");for(var i=0;i<mtype.fieldsArray.length;++i){var field=mtype._fieldsArray[i].resolve(),ref="m"+util.safeProp(field.name);if(field.optional)gen("if(%s!=null&&m.hasOwnProperty(%j)){",ref,field.name);if(field.map){gen("if(!util.isObject(%s))",ref)("return%j",invalid(field,"object"))("var k=Object.keys(%s)",ref)("for(var i=0;i<k.length;++i){");genVerifyKey(gen,field,"k[i]");genVerifyValue(gen,field,i,ref+"[k[i]]")("}")}else if(field.repeated){gen("if(!Array.isArray(%s))",ref)("return%j",invalid(field,"array"))("for(var i=0;i<%s.length;++i){",ref);genVerifyValue(gen,field,i,ref+"[i]")("}")}else{if(field.partOf){var oneofProp=util.safeProp(field.partOf.name);if(seenFirstField[field.partOf.name]===1)gen("if(p%s===1)",oneofProp)("return%j",field.partOf.name+": multiple values");seenFirstField[field.partOf.name]=1;gen("p%s=1",oneofProp)}genVerifyValue(gen,field,i,ref)}if(field.optional)gen("}")}return gen("return null")}},{"./enum":37,"./util":56}],60:[function(require,module,exports){"use strict";var wrappers=exports;var Message=require("./message");wrappers[".google.protobuf.Any"]={fromObject:function(object){if(object&&object["@type"]){var type=this.lookup(object["@type"]);if(type){var type_url=object["@type"].charAt(0)==="."?object["@type"].substr(1):object["@type"];return this.create({type_url:"/"+type_url,value:type.encode(type.fromObject(object)).finish()})}}return this.fromObject(object)},toObject:function(message,options){if(options&&options.json&&message.type_url&&message.value){var name=message.type_url.substring(message.type_url.lastIndexOf("/")+1);var type=this.lookup(name);if(type)message=type.decode(message.value)}if(!(message instanceof this.ctor)&&message instanceof Message){var object=message.$type.toObject(message,options);object["@type"]=message.$type.fullName;return object}return this.toObject(message,options)}}},{"./message":42}],61:[function(require,module,exports){"use strict";module.exports=Writer;var util=require("./util/minimal");var BufferWriter;var LongBits=util.LongBits,base64=util.base64,utf8=util.utf8;function Op(fn,len,val){this.fn=fn;this.len=len;this.next=undefined;this.val=val}function noop(){}function State(writer){this.head=writer.head;this.tail=writer.tail;this.len=writer.len;this.next=writer.states}function Writer(){this.len=0;this.head=new Op(noop,0,0);this.tail=this.head;this.states=null}Writer.create=util.Buffer?function create_buffer_setup(){return(Writer.create=function create_buffer(){return new BufferWriter})()}:function create_array(){return new Writer};Writer.alloc=function alloc(size){return new util.Array(size)};if(util.Array!==Array)Writer.alloc=util.pool(Writer.alloc,util.Array.prototype.subarray);Writer.prototype._push=function push(fn,len,val){this.tail=this.tail.next=new Op(fn,len,val);this.len+=len;return this};function writeByte(val,buf,pos){buf[pos]=val&255}function writeVarint32(val,buf,pos){while(val>127){buf[pos++]=val&127|128;val>>>=7}buf[pos]=val}function VarintOp(len,val){this.len=len;this.next=undefined;this.val=val}VarintOp.prototype=Object.create(Op.prototype);VarintOp.prototype.fn=writeVarint32;Writer.prototype.uint32=function write_uint32(value){this.len+=(this.tail=this.tail.next=new VarintOp((value=value>>>0)<128?1:value<16384?2:value<2097152?3:value<268435456?4:5,value)).len;return this};Writer.prototype.int32=function write_int32(value){return value<0?this._push(writeVarint64,10,LongBits.fromNumber(value)):this.uint32(value)};Writer.prototype.sint32=function write_sint32(value){return this.uint32((value<<1^value>>31)>>>0)};function writeVarint64(val,buf,pos){while(val.hi){buf[pos++]=val.lo&127|128;val.lo=(val.lo>>>7|val.hi<<25)>>>0;val.hi>>>=7}while(val.lo>127){buf[pos++]=val.lo&127|128;val.lo=val.lo>>>7}buf[pos++]=val.lo}Writer.prototype.uint64=function write_uint64(value){var bits=LongBits.from(value);return this._push(writeVarint64,bits.length(),bits)};Writer.prototype.int64=Writer.prototype.uint64;Writer.prototype.sint64=function write_sint64(value){var bits=LongBits.from(value).zzEncode();return this._push(writeVarint64,bits.length(),bits)};Writer.prototype.bool=function write_bool(value){return this._push(writeByte,1,value?1:0)};function writeFixed32(val,buf,pos){buf[pos]=val&255;buf[pos+1]=val>>>8&255;buf[pos+2]=val>>>16&255;buf[pos+3]=val>>>24}Writer.prototype.fixed32=function write_fixed32(value){return this._push(writeFixed32,4,value>>>0)};Writer.prototype.sfixed32=Writer.prototype.fixed32;Writer.prototype.fixed64=function write_fixed64(value){var bits=LongBits.from(value);return this._push(writeFixed32,4,bits.lo)._push(writeFixed32,4,bits.hi)};Writer.prototype.sfixed64=Writer.prototype.fixed64;Writer.prototype.float=function write_float(value){return this._push(util.float.writeFloatLE,4,value)};Writer.prototype.double=function write_double(value){return this._push(util.float.writeDoubleLE,8,value)};var writeBytes=util.Array.prototype.set?function writeBytes_set(val,buf,pos){buf.set(val,pos)}:function writeBytes_for(val,buf,pos){for(var i=0;i<val.length;++i)buf[pos+i]=val[i]};Writer.prototype.bytes=function write_bytes(value){var len=value.length>>>0;if(!len)return this._push(writeByte,1,0);if(util.isString(value)){var buf=Writer.alloc(len=base64.length(value));base64.decode(value,buf,0);value=buf}return this.uint32(len)._push(writeBytes,len,value)};Writer.prototype.string=function write_string(value){var len=utf8.length(value);return len?this.uint32(len)._push(utf8.write,len,value):this._push(writeByte,1,0)};Writer.prototype.fork=function fork(){this.states=new State(this);this.head=this.tail=new Op(noop,0,0);this.len=0;return this};Writer.prototype.reset=function reset(){if(this.states){this.head=this.states.head;this.tail=this.states.tail;this.len=this.states.len;this.states=this.states.next}else{this.head=this.tail=new Op(noop,0,0);this.len=0}return this};Writer.prototype.ldelim=function ldelim(){var head=this.head,tail=this.tail,len=this.len;this.reset().uint32(len);if(len){this.tail.next=head.next;this.tail=tail;this.len+=len}return this};Writer.prototype.finish=function finish(){var head=this.head.next,buf=this.constructor.alloc(this.len),pos=0;while(head){head.fn(head.val,buf,pos);pos+=head.len;head=head.next}return buf};Writer._configure=function(BufferWriter_){BufferWriter=BufferWriter_}},{"./util/minimal":58}],62:[function(require,module,exports){"use strict";module.exports=BufferWriter;var Writer=require("./writer");(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util=require("./util/minimal");var Buffer=util.Buffer;function BufferWriter(){Writer.call(this)}BufferWriter.alloc=function alloc_buffer(size){return(BufferWriter.alloc=util._Buffer_allocUnsafe)(size)};var writeBytesBuffer=Buffer&&Buffer.prototype instanceof Uint8Array&&Buffer.prototype.set.name==="set"?function writeBytesBuffer_set(val,buf,pos){buf.set(val,pos)}:function writeBytesBuffer_copy(val,buf,pos){if(val.copy)val.copy(buf,pos,0,val.length);else for(var i=0;i<val.length;)buf[pos++]=val[i++]};BufferWriter.prototype.bytes=function write_bytes_buffer(value){if(util.isString(value))value=util._Buffer_from(value,"base64");var len=value.length>>>0;this.uint32(len);if(len)this._push(writeBytesBuffer,len,value);return this};function writeStringBuffer(val,buf,pos){if(val.length<40)util.utf8.write(val,buf,pos);else buf.utf8Write(val,pos)}BufferWriter.prototype.string=function write_string_buffer(value){var len=Buffer.byteLength(value);this.uint32(len);if(len)this._push(writeStringBuffer,len,value);return this}},{"./util/minimal":58,"./writer":61}],63:[function(require,module,exports){var _global=function(){return this}();var NativeWebSocket=_global.WebSocket||_global.MozWebSocket;var websocket_version=require("./version");function W3CWebSocket(uri,protocols){var native_instance;if(protocols){native_instance=new NativeWebSocket(uri,protocols)}else{native_instance=new NativeWebSocket(uri)}return native_instance}if(NativeWebSocket){["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(prop){Object.defineProperty(W3CWebSocket,prop,{get:function(){return NativeWebSocket[prop]}})})}module.exports={w3cwebsocket:NativeWebSocket?W3CWebSocket:null,version:websocket_version}},{"./version":64}],
  64:[function(require,module,exports){module.exports=require("../package.json").version},{"../package.json":65}],65:[function(require,module,exports){module.exports={_args:[["websocket@1.0.28","/home/sdb1/node/workspace/modules-js/label/webrtc-opensuse-64bit"]],_from:"websocket@1.0.28",_id:"websocket@1.0.28",_inBundle:false,_integrity:"sha512-00y/20/80P7H4bCYkzuuvvfDvh+dgtXi5kzDf3UcZwN6boTYaKvsrtZ5lIYm1Gsg48siMErd9M4zjSYfYFHTrA==",_location:"/websocket",_phantomChildren:{},_requested:{type:"version",registry:true,raw:"websocket@1.0.28",name:"websocket",escapedName:"websocket",rawSpec:"1.0.28",saveSpec:null,fetchSpec:"1.0.28"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/websocket/-/websocket-1.0.28.tgz",_spec:"1.0.28",_where:"/home/sdb1/node/workspace/modules-js/label/webrtc-opensuse-64bit",author:{name:"Brian McKelvey",email:"theturtle32@gmail.com",url:"https://github.com/theturtle32"},browser:"lib/browser.js",bugs:{url:"https://github.com/theturtle32/WebSocket-Node/issues"},config:{verbose:false},contributors:[{name:"Iñaki Baz Castillo",email:"ibc@aliax.net",url:"http://dev.sipdoc.net"}],dependencies:{debug:"^2.2.0",nan:"^2.11.0","typedarray-to-buffer":"^3.1.5",yaeti:"^0.0.6"},description:"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",devDependencies:{"buffer-equal":"^1.0.0",faucet:"^0.0.1",gulp:"git+https://github.com/gulpjs/gulp.git#4.0","gulp-jshint":"^2.0.4",jshint:"^2.0.0","jshint-stylish":"^2.2.1",tape:"^4.9.1"},directories:{lib:"./lib"},engines:{node:">=0.10.0"},homepage:"https://github.com/theturtle32/WebSocket-Node",keywords:["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],license:"Apache-2.0",main:"index",name:"websocket",repository:{type:"git",url:"git+https://github.com/theturtle32/WebSocket-Node.git"},scripts:{gulp:"gulp",install:"(node-gyp rebuild 2> builderror.log) || (exit 0)",test:"faucet test/unit"},version:"1.0.28"}},{}],66:[function(require,module,exports){module.exports={nested:{proto:{nested:{Info:{fields:{offset:{type:"uint64",id:1},length:{type:"uint64",id:2}}},Message:{fields:{magic_cookie:{rule:"required",type:"fixed32",id:1},mtype:{type:"MType",id:2},obj_id:{type:"string",id:3},obj_type:{type:"ObjectType",id:4},info:{rule:"repeated",type:"Info",id:5},data:{type:"bytes",id:6},error:{type:"bytes",id:7}},nested:{MType:{values:{AVAILABILITY_INFO_REQUEST:5,AVAILABILITY_INFO_RESPONSE:6,AVAILABILITY_INFO_ABORT:7,AVAILABILITY_INFO_FAILURE:8,DATA_REQUEST:9,DATA_RESPONSE:10,DATA_ABORT:11,DATA_FAILURE:12}},ObjectType:{values:{FILE:1,PATCH:2}}}}}}}}},{}],67:[function(require,module,exports){(function(Buffer){"use strict";var protobuf=require("protobufjs/light");var jsonDescriptor=require("./desc.json");require("fast-text-encoding");var is_node=require("detect-node");var root=protobuf.Root.fromJSON(jsonDescriptor);var magic_cookie=2052258419;var Proto=function(callbacks){var Message=root.lookupType("proto.Message");this._message=Message;this.MType=this._message.MType;this.ObjectType=this._message.ObjectType;if(callbacks!==undefined){this._cb_info_request=callbacks.on_info_request;this._cb_info_response=callbacks.on_info_response;this._cb_info_abort=callbacks.on_info_abort;this._cb_info_failure=callbacks.on_info_failure;this._cb_data_request=callbacks.on_data_request;this._cb_data_response=callbacks.on_data_response;this._cb_data_abort=callbacks.on_data_abort;this._cb_data_failure=callbacks.on_data_failure}};Proto.prototype=Object.create(null);Proto.prototype._cb_info_request=null;Proto.prototype._cb_info_response=null;Proto.prototype._cb_info_abort=null;Proto.prototype._cb_info_failure=null;Proto.prototype._cb_data_request=null;Proto.prototype._cb_data_response=null;Proto.prototype._cb_data_abort=null;Proto.prototype._cb_data_failure=null;Proto.prototype.info_request=function(obj_id){var fields={obj_id:obj_id,mtype:this.MType.AVAILABILITY_INFO_REQUEST,obj_type:this.ObjectType.FILE,magic_cookie:magic_cookie};var err=this._message.verify(fields);if(err)throw Error(err);var message=this._message.create(fields);var buffer=this._message.encode(message).finish();if(!is_node)buffer=buffer.slice(0,buffer.byteLength);return buffer};Proto.prototype.info_response=function(obj_id,info){var fields={obj_id:obj_id,mtype:this.MType.AVAILABILITY_INFO_RESPONSE,obj_type:this.ObjectType.FILE,magic_cookie:magic_cookie,info:[]};var err=this._message.verify(fields);if(err)throw Error(err);var message=this._message.create(fields);for(var i=0;i<info.length;i++)message.info.push(info[i]);var buffer=this._message.encode(message).finish();if(!is_node)buffer=buffer.slice(0,buffer.byteLength);return buffer};Proto.prototype.info_abort=function(obj_id){var fields={obj_id:obj_id,mtype:this.MType.AVAILABILITY_INFO_ABORT,obj_type:this.ObjectType.FILE,magic_cookie:magic_cookie};var err=this._message.verify(fields);if(err)throw Error(err);var message=this._message.create(fields);var buffer=this._message.encode(message).finish();if(!is_node)buffer=buffer.slice(0,buffer.byteLength);return buffer};Proto.prototype.info_failure=function(obj_id){var fields={obj_id:obj_id,mtype:this.MType.AVAILABILITY_INFO_FAILURE,obj_type:this.ObjectType.FILE,magic_cookie:magic_cookie};var err=this._message.verify(fields);if(err)throw Error(err);var message=this._message.create(fields);var buffer=this._message.encode(message).finish();if(!is_node)buffer=buffer.slice(0,buffer.byteLength);return buffer};Proto.prototype.data_request=function(obj_id,offset,length){var fields={obj_id:obj_id,mtype:this.MType.DATA_REQUEST,obj_type:this.ObjectType.FILE,magic_cookie:magic_cookie,info:[{offset:offset,length:length}]};var err=this._message.verify(fields);if(err)throw Error(err);var message=this._message.create(fields);var buffer=this._message.encode(message).finish();if(!is_node)buffer=buffer.slice(0,buffer.byteLength);return buffer};Proto.prototype.data_abort=function(obj_id,offset){var fields={obj_id:obj_id,mtype:this.MType.DATA_ABORT,obj_type:this.ObjectType.FILE,magic_cookie:magic_cookie,info:[{offset:offset}]};var err=this._message.verify(fields);if(err)throw Error(err);var message=this._message.create(fields);var buffer=this._message.encode(message).finish();if(!is_node)buffer=buffer.slice(0,buffer.byteLength);return buffer};Proto.prototype.decode=function(buffer,remote_peer_id){var message=this._message.decode(new Buffer(buffer));switch(message.mtype){case this.MType.AVAILABILITY_INFO_REQUEST:if(typeof this._cb_info_request=="function")this._cb_info_request(message,remote_peer_id);break;case this.MType.AVAILABILITY_INFO_RESPONSE:if(typeof this._cb_info_response=="function")this._cb_info_response(message,remote_peer_id);break;case this.MType.AVAILABILITY_INFO_ABORT:if(typeof this._cb_info_abort=="function")this._cb_info_abort(message,remote_peer_id);break;case this.MType.AVAILABILITY_INFO_FAILURE:if(message.error&&message.error.length>0){message.error=message.error.buffer.slice(message.error.offset);message.error=new TextDecoder("utf-8").decode(message.error)}if(typeof this._cb_info_failure=="function")this._cb_info_failure(message,remote_peer_id);break;case this.MType.DATA_REQUEST:if(typeof this._cb_data_request=="function")this._cb_data_request(message,remote_peer_id);break;case this.MType.DATA_RESPONSE:if(typeof this._cb_data_response=="function")this._cb_data_response(message,remote_peer_id);break;case this.MType.DATA_ABORT:if(typeof this._cb_data_abort=="function")this._cb_data_abort(message,remote_peer_id);break;case this.MType.DATA_FAILURE:if(message.error&&message.error.length>0)message.error=new TextDecoder("utf-8").decode(message.error);else message.error="No error message";if(typeof this._cb_data_failure=="function")this._cb_data_failure(message,remote_peer_id);break;default:console.warn("Unknown message type: ",message.mtype);break}return message};module.exports=Proto}).call(this,require("buffer").Buffer)},{"./desc.json":66,buffer:19,"detect-node":20,"fast-text-encoding":22,"protobufjs/light":33}],68:[function(require,module,exports){"use strict";const logger=require("./logging")(module);const Signal_Protocol=require("./signal_protocol");const Signal_Connection=require("./signal_connection");const wrtc=require("@elavoie/electron-webrtc")();const is_node=require("detect-node");if(is_node){var RTCPeerConnection=wrtc.RTCPeerConnection;var RTCSessionDescription=wrtc.RTCSessionDescription;var RTCIceCandidate=wrtc.RTCIceCandidate}else{var RTCPeerConnection=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection;var RTCSessionDescription=window.RTCSessionDescription||window.mozRTCSessionDescription;var RTCIceCandidate=window.RTCIceCandidate||window.mozRTCIceCandidate}function RTCDC(ice_servers,remote_peer_id,signal_connection,opts,callbacks){opts=opts||{};callbacks=callbacks||{};this.remote_peer_id=remote_peer_id;this.signal_connection=signal_connection;this.signal_protocol=new Signal_Protocol;this.conn_uuid=this.signal_protocol.generate_uuid();this._deffered_ice_candidates=new Array;this._is_local_description_done=false;this._is_remote_description_done=false;this.pc=new RTCPeerConnection(ice_servers,null);this.pc.onicecandidate=this._on_icecandidate.bind(this);var dc_opts={ordered:false};this.dc=this.pc.createDataChannel("data_channel",dc_opts);this.dc.binaryType="arraybuffer";this.dc.onopen=this._channel_onopen.bind(this);this.dc.onclose=this._channel_onclose.bind(this);this.dc.onmessage=this._channel_onmessage.bind(this);this.dc.onerror=this._channel_onerror.bind(this);this._cb_channel_open=callbacks.cb_channel_open;this._cb_channel_close=callbacks.cb_channel_close;this._cb_channel_message=callbacks.cb_channel_message;this._is_initiator=opts.is_initiator||true;this._start()}RTCDC.prototype=Object.create(null);RTCDC.prototype.cb_channel_open=null;RTCDC.prototype.cb_channel_close=null;RTCDC.prototype.cb_channel_message=null;RTCDC.prototype._can_use_promises=function(){if(is_node)return false;return typeof this.pc.createOffer().then=="function"};RTCDC.prototype._start=function(){if(this._is_initiator==true)this._create_offer()};RTCDC.prototype._create_offer=function(){if(this._can_use_promises())this.pc.createOffer().then(function(offer){logger.debug("offer has been created successfully");logger.debug(offer);return this.pc.setLocalDescription(offer)}.bind(this)).then(this._set_local_description_success.bind(this),this._set_local_description_failure.bind(this)).catch(this._create_offer_failure.bind(this));else this.pc.createOffer(this._create_offer_success.bind(this),this._create_offer_failure.bind(this))};RTCDC.prototype._create_offer_success=function(offer){logger.debug("offer has been created successfully");logger.debug(offer);if(this._can_use_promises())this.pc.setLocalDescription(offer).then(this._set_local_description_success.bind(this)).catch(this._set_local_description_failure.bind(this));else this.pc.setLocalDescription(offer,this._set_local_description_success.bind(this),this._set_local_description_failure.bind(this))};RTCDC.prototype._create_offer_failure=function(error){logger.error("While creating offer error occured");logger.error(error)};RTCDC.prototype._set_local_description_success=function(){logger.debug("local description successfully set");this._is_local_description_done=true;this._send_offer(this.pc.localDescription)};RTCDC.prototype._set_local_description_failure=function(error){logger.error("While setting local description error occured");logger.error(error)};RTCDC.prototype._send_offer=function(offer){var offer_msg=this.signal_protocol.make_offer_message(this.remote_peer_id,this.conn_uuid,JSON.stringify(offer));logger.debug(offer_msg);if(this.signal_connection instanceof Signal_Connection)this.signal_connection.send(offer_msg);else logger.error("signal_connection is not defined")};RTCDC.prototype.recv_answer=function(answer){logger.debug("answer has been received");logger.debug(answer);var remote_desc=new RTCSessionDescription(answer);if(this._can_use_promises())this.pc.setRemoteDescription(remote_desc).then(this._set_remote_description_success.bind(this)).catch(this._set_remote_description_failure.bind(this));else this.pc.setRemoteDescription(remote_desc,this._set_remote_description_success.bind(this),this._set_remote_description_failure.bind(this))};RTCDC.prototype._set_remote_description_success=function(){logger.debug("remote description successfully set");this._is_remote_description_done=true};RTCDC.prototype._set_remote_description_failure=function(error){logger.error("While setting remote description error occured");logger.error(error)};RTCDC.prototype.add_candidate=function(cand){logger.debug("add remote candidate: "+cand.candidate);var remote_cand=new RTCIceCandidate(cand);this._deffered_ice_candidates.push(remote_cand);if(this._is_local_description_done&&this._is_remote_description_done){for(var i=0;i<this._deffered_ice_candidates.length;i++){this.pc.addIceCandidate(this._deffered_ice_candidates[i])}this._deffered_ice_candidates=new Array}};RTCDC.prototype._on_icecandidate=function(event){if(!event.candidate)return;logger.debug("local candidate: "+event.candidate.candidate);var cand=event.candidate;var cand_msg=this.signal_protocol.make_candidate_message(this.remote_peer_id,this.conn_uuid,JSON.stringify(cand));logger.debug(cand_msg);this.signal_connection.send(cand_msg)};RTCDC.prototype._channel_onopen=function(){if(!(this.dc&&this.dc.readyState))return;logger.debug("channel has been open, readyState is:",this.dc.readyState);if(typeof this._cb_channel_open=="function")this._cb_channel_open(this.remote_peer_id,this.conn_uuid,this.signal_connection.getConnectionId())};RTCDC.prototype._channel_onclose=function(){logger.debug("channel has been closed");if(typeof this._cb_channel_close=="function")this._cb_channel_close(this.remote_peer_id,this.conn_uuid,this.signal_connection.getConnectionId())};RTCDC.prototype._channel_onmessage=function(event){if(typeof this._cb_channel_message=="function")this._cb_channel_message(this.remote_peer_id,this.conn_uuid,this.signal_connection.getConnectionId(),event.data)};RTCDC.prototype._channel_onerror=function(error){logger.error("In data channel error occured");logger.error(error)};RTCDC.prototype.close_channel=function(){this.dc.close();this.pc.close();delete this.dc;delete this.pc};function getStats(pc,selector){if(navigator.mozGetUserMedia){return pc.getStats(selector)}else{var p=pc.getStats();if(typeof p.then=="function")return pc.getStats(selector)}return new Promise(function(resolve,reject){pc.getStats(function(response){var standardReport={};response.result().forEach(function(report){var standardStats={id:report.id,type:report.type};report.names().forEach(function(name){standardStats[name]=report.stat(name)});standardReport[standardStats.id]=standardStats});resolve(standardReport)},selector,reject)})}function get_stat(pc){var stat_promise;stat_promise=getStats(pc);var mystat=function(stats){var stat={};if(navigator.mozGetUserMedia){stats.forEach(function(obj){if(obj["type"]=="candidatepair"&&obj["nominated"]==true&&obj["selected"]==true&&obj["state"]=="succeeded"){if(obj["localCandidateId"]){stat["local_cand"]=stats.get(obj["localCandidateId"])}if(obj["remoteCandidateId"]){stat["remote_cand"]=stats.get(obj["remoteCandidateId"])}}})}else{var pair_id="";for(var key in stats){var obj=stats[key];if(obj["selectedCandidatePairId"]){pair_id=obj["selectedCandidatePairId"];break}}if(pair_id){console.log("selected pair: ",pair_id);for(var key in stats){if(key==pair_id){var tt=stats[pair_id];if(tt["localCandidateId"]){stat["local_cand"]=stats[tt["localCandidateId"]]}if(tt["remoteCandidateId"]){stat["remote_cand"]=stats[tt["remoteCandidateId"]]}}}}}return stat};return stat_promise.then(mystat)}module.exports.RTCDC=RTCDC;module.exports.get_stat=get_stat},{"./logging":5,"./signal_connection":69,"./signal_protocol":70,"@elavoie/electron-webrtc":7,"detect-node":20}],69:[function(require,module,exports){"use strict";const WebSocket=require("websocket").w3cwebsocket;function Signal_Connection(connection_string,connection_id,connection_timeout){this._connection_timeout=connection_timeout||5e3;this._timer=setTimeout(this._on_timer.bind(this),this._connection_timeout);this._ws=new WebSocket(connection_string);this._connection_string=connection_string;this._connection_id=connection_id;this._ws.onopen=this._onopen.bind(this);this._ws.onclose=this._onclose.bind(this);this._ws.onmessage=this._onmessage.bind(this);this._ws.onerror=this._onerror.bind(this)}Signal_Connection.State={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3};Signal_Connection.prototype._onopen=function(){clearTimeout(this._timer);if(this.hasOwnProperty("onopen")){if(typeof this.onopen=="function")this.onopen(this._connection_id)}};Signal_Connection.prototype._onclose=function(close){clearTimeout(this._timer);if(this.hasOwnProperty("onclose")){if(typeof this.onclose=="function")this.onclose(close,this._connection_id)}};Signal_Connection.prototype._onerror=function(error){clearTimeout(this._timer);if(this.hasOwnProperty("onerror")){if(typeof this.onerror=="function")this.onerror(error,this._connection_id,this._connection_string)}};Signal_Connection.prototype._onmessage=function(message){if(this.hasOwnProperty("onmessage")){if(typeof this.onopen=="function")this.onmessage(message,this._connection_id)}};Signal_Connection.prototype.close=function(){this._ws.close();this._ws=null};Signal_Connection.prototype.getState=function(){return this._ws?this._ws.readyState:null};Signal_Connection.prototype.getConnectionId=function(){return this._connection_id};Signal_Connection.prototype.getConnectionString=function(){return this._connection_string};Signal_Connection.prototype.send=function(message){if(this.getState()==Signal_Connection.State.OPEN)this._ws.send(message)};Signal_Connection.prototype._on_timer=function(){if(this.getState()!=Signal_Connection.State.OPEN){this.close();this._onerror(new Error("Timeout"))}};module.exports=Signal_Connection},{websocket:63}],70:[function(require,module,exports){"use strict";const logger=require("./logging")(module);function Signal_Protocol(){this._uuid=this.generate_uuid()}Signal_Protocol.prototype=Object.create(null);Signal_Protocol.prototype.cb_offer_received=null;Signal_Protocol.prototype.cb_answer_received=null;Signal_Protocol.prototype.cb_candidate_received=null;Signal_Protocol.prototype.cb_node_list=null;Signal_Protocol.prototype.cb_node_connected=null;Signal_Protocol.prototype.cb_node_disconnected=null;Signal_Protocol.prototype.cb_share_info=null;Signal_Protocol.prototype.decode_message=function(message,connection_id){var t_message=message.data;try{var message=JSON.parse(t_message)}catch(err){logger.error("To handle message error caused:");logger.error(err.name,err.message)}if("operation"in message){logger.debug("Message received: ",message);switch(message["operation"]){case"peer_list":var peers=message["data"];if(typeof this.cb_node_list=="function"){this.cb_node_list(peers)}break;case"peer_connect":var node_info=message["data"];if(typeof this.cb_node_connected=="function"){this.cb_node_connected(node_info)}break;case"peer_disconnect":var node_id=message["node_id"];if(typeof this.cb_node_disconnected=="function"){this.cb_node_disconnected(node_id)}break;case"sdp":if(!("data"in message)){logger.error("'data' not found in message");break}if(!("message"in message.data)){logger.error("'message' not found in message.data");break}var data=message["data"]["message"];if(!("conn_uuid"in message.data)){logger.error("'conn_uuid' not found in message.data");break}var conn_uuid=message["data"]["conn_uuid"];if(typeof data!="object"){try{data=JSON.parse(data)}catch(err){logger.error("Error while JSON.parse(data): ",err);break}}if(!("node_id"in message)){logger.error("node_id not found in message");break}var node_id=message["node_id"];if("type"in data){var msg_type=data.type;if(msg_type=="offer"){if(typeof cb_offer_received=="function"){this.cb_offer_received(node_id,conn_uuid,connection_id,data)}}else if(msg_type=="answer"){if(typeof this.cb_answer_received=="function"){this.cb_answer_received(node_id,conn_uuid,connection_id,data)}}else{}}else if("candidate"in data){if(typeof this.cb_candidate_received=="function"){this.cb_candidate_received(node_id,conn_uuid,connection_id,data)}}else{logger.warn("Received unknown data: ",data)}break;case"share_info":if(!("data"in message)){logger.error("'data' not found in message");break}var share_info=message["data"];if(!("name"in share_info)){logger.error("'name' not found in 'share_info'");break}var file_name=share_info.name;if(!("file_size"in share_info)){logger.error("'file_size' not found in 'share_info'");break}var file_size=+share_info.file_size;if(!("share_hash"in share_info)){logger.error("'share_hash' not found in 'share_info'");break}var share_hash=share_info.share_hash;if(!("event_uuid"in share_info)){logger.error("'event_uuid' not found in 'share_info'");break}var event_uuid=share_info.event_uuid;if(typeof this.cb_share_info=="function"){this.cb_share_info(file_name,file_size,share_hash,event_uuid)}break;default:logger.warn("Received message with unknown operation: ",message);break}}else{logger.warn("Received message without operation property: ",message)}};Signal_Protocol.prototype.make_sdp_message=function(node_id,conn_uuid,data){var msg={operation:"sdp",node_id:node_id,data:{conn_uuid:conn_uuid,message:data}};return JSON.stringify(msg)};Signal_Protocol.prototype.make_candidate_message=function(node_id,conn_uuid,data){return this.make_sdp_message(node_id,conn_uuid,data)};Signal_Protocol.prototype.make_offer_message=function(node_id,conn_uuid,data){return this.make_sdp_message(node_id,conn_uuid,data)};Signal_Protocol.prototype.make_answer_message=function(node_id,conn_uuid,data){return this.make_sdp_message(node_id,conn_uuid,data)};Signal_Protocol.prototype.make_notification=function(notification_type,data){var notification={operation:notification_type,data:data};return JSON.stringify(notification)};Signal_Protocol.prototype.generate_uuid=function(){var d=(new Date).getTime();var uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";uuid=uuid.replace(/[xy]/g,function(c){var r=(d+Math.random()*16)%16|0;d=Math.floor(d/16);return(c=="x"?r:r&3|8).toString(16)});return uuid};module.exports=Signal_Protocol},{"./logging":5}],71:[function(require,module,exports){"use strict";const Signal_Protocol=require("./signal_protocol");const Signal_Connection=require("./signal_connection");const RTCDC=require("./rtcdc").RTCDC;const get_stat=require("./rtcdc").get_stat;const logger=require("./logging")(module);const is_node=require("detect-node");function Transport(ice_servers,num_of_channels,callbacks){this._ice_servers=ice_servers;this._num_of_channels=num_of_channels;this._signal_protocol=new Signal_Protocol;this._signal_connections=new Array;this._node_ids=[];this._channels={};this._state_info={num_of_signal_connections:0,channels:{}};this._notifications=[];this._no_connections_flag=true;this._retry_ss_connection_plan=[1e3,1e3];this.set_callbacks(callbacks);this._init()}Transport.prototype.cb_online_nodes=null;Transport.prototype.cb_state_changed=null;Transport.prototype.cb_error=null;Transport.prototype.cb_channel_onopen=null;Transport.prototype.cb_channel_onmessage=null;Transport.prototype.cb_channel_onclose=null;Transport.prototype.cb_share_info=null;Transport.prototype.set_callbacks=function(callbacks){if(typeof callbacks!="object")return;if(typeof callbacks.cb_online_nodes=="function")this.cb_online_nodes=callbacks.cb_online_nodes;if(typeof callbacks.cb_state_changed=="function")this.cb_state_changed=callbacks.cb_state_changed;if(typeof callbacks.cb_error=="function")this.cb_error=callbacks.cb_error;if(typeof callbacks.cb_channel_onopen=="function")this.cb_channel_onopen=callbacks.cb_channel_onopen;if(typeof callbacks.cb_channel_onmessage=="function")this.cb_channel_onmessage=callbacks.cb_channel_onmessage;if(typeof callbacks.cb_channel_onclose=="function")this.cb_channel_onclose=callbacks.cb_channel_onclose;if(typeof callbacks.cb_share_info=="function")this.cb_share_info=callbacks.cb_share_info};Transport.prototype._init=function(){this._signal_protocol.cb_node_list=this._node_list.bind(this);this._signal_protocol.cb_node_connected=this._node_connected.bind(this);this._signal_protocol.cb_node_disconnected=this._node_disconnected.bind(this);this._signal_protocol.cb_answer_received=this._answer_received.bind(this);this._signal_protocol.cb_candidate_received=this._candidate_received.bind(this);this._signal_protocol.cb_share_info=this._share_info.bind(this)};Transport.prototype._node_list=function(node_list){logger.info("node list received: ",node_list);var node_ids=this._node_ids;node_list.forEach(function(node_info){node_ids=this._add_node(node_info)}.bind(this));if(typeof this.cb_online_nodes=="function")this.cb_online_nodes(this.get_online_nodes())};Transport.prototype._node_connected=function(node_info){if(this._check_node(node_info)!=true)return;logger.debug("node connected: ",node_info);var new_connection_flag=true;if(this._node_ids.indexOf(node_info.id)>=0)new_connection_flag=false;var node_ids=this._add_node(node_info);if(typeof this.cb_node_connected=="function")this.cb_node_connected(node_info.id);if(typeof this.cb_online_nodes=="function")this.cb_online_nodes(this.get_online_nodes())};Transport.prototype._node_disconnected=function(node_id){if(this._node_ids.indexOf(node_id)==-1)return;logger.debug("node disconnected: ",node_id);var node_ids=this._del_node(node_id);if(typeof this.cb_node_disconnected=="function")this.cb_node_disconnected(node_id);if(typeof this.cb_online_nodes=="function")this.cb_online_nodes(this.get_online_nodes())};Transport.prototype._share_info=function(file_name,file_size,share_hash,event_uuid){logger.info("share_info received:",file_name,file_size,share_hash,event_uuid);this.add_notification("share_downloaded",{share_hash:share_hash});if(typeof this.cb_share_info=="function")this.cb_share_info(file_name,file_size,share_hash,event_uuid)};Transport.prototype.open_signal_connection=function(connection_string,conn_id){var connection_id=conn_id||this._signal_connections.length;var signal_connection=new Signal_Connection(connection_string,connection_id);this._signal_connections[connection_id]=signal_connection;signal_connection.onopen=this._signal_connection_onopen.bind(this);signal_connection.onclose=this._signal_connection_onclose.bind(this);signal_connection.onerror=this._signal_connection_onerror.bind(this);signal_connection.onmessage=this._signal_connection_onmessage.bind(this)};Transport.prototype._signal_connection_onopen=function(connection_id){logger.info("open signal connection: ",connection_id,", state: ",this._signal_connections[connection_id].getState());this._state_info["num_of_signal_connections"]=this._get_num_opened_signal_connections();this._no_connections_flag=false;this._state_changed()};Transport.prototype.close_signal_connections=function(){logger.debug("close signal connections ..");for(var i=0;i<this._signal_connections.length;i++){this._signal_connections[i].close()}};Transport.prototype._signal_connection_onclose=function(close,connection_id){logger.debug("close signal connection with index=%d, reason is '%s'",connection_id,close.reason);this._state_info["num_of_signal_connections"]=this._get_num_opened_signal_connections();this._signal_connections.splice(connection_id,1);this._state_changed()};Transport.prototype._signal_connection_onerror=function(error,connection_id,connection_string){logger.warn("error signal connection: ",connection_id,error);if(this._no_connections_flag!=true)return;var retry_timeout=this._retry_ss_connection_plan.pop();if(retry_timeout){logger.debug("retry connection to signalling server");setTimeout(this.open_signal_connection.bind(this),retry_timeout,connection_string);return}var err_message="While connecting to signaling server an error occured.";if(typeof this.cb_error=="function")this.cb_error(new Error(err_message))};Transport.prototype._get_num_opened_signal_connections=function(){var count=0;for(var i=0;i<this._signal_connections.length;i++){if(this._signal_connections[i].getState()==Signal_Connection.State.OPEN){count++}}return count};Transport.prototype._signal_connection_onmessage=function(message,connection_id){this._signal_protocol.decode_message(message,connection_id)};Transport.prototype._add_node=function(node_info){if(this._check_node(node_info)){if(this._node_ids.indexOf(node_info.id)==-1){this._node_ids.push(node_info.id)}}return this._node_ids};Transport.prototype._del_node=function(node_id){var index=this._node_ids.indexOf(node_id);if(index>=0){this._node_ids.splice(index,1)}return this._node_ids};Transport.prototype._check_node=function(node_info){if(node_info.type=="node")return true;return false};Transport.prototype.get_online_nodes=function(){var a=[];this._node_ids.forEach(function(node_id){a.push(node_id)});return a};Transport.prototype.get_state_info=function(){return this._state_info};Transport.prototype.get_signal_connections_num=function(){var n=0;for(var i=0;i<this._signal_connections.length;i++){var signal_connection=this._signal_connections[i];if(signal_connection.getState()==Signal_Connection.State.OPEN){n++}}return n};Transport.prototype.open_channels=function(num_of_channels_,node_ids_){var num_of_channels=num_of_channels_||this._num_of_channels;var node_ids=node_ids_||this._node_ids;for(var i=0;i<this._signal_connections.length;i++){var signal_connection=this._signal_connections[i];if(signal_connection.getState()==Signal_Connection.State.OPEN){node_ids.forEach(function(node_id){for(var j=0;j<num_of_channels;j++){this._open_channel(node_id,signal_connection)}}.bind(this))}}};Transport.prototype.close_channels=function(node_ids_){var node_ids=node_ids_||[];for(var channel_id in this._channels){var rtcdc=this._channels[channel_id];if(!rtcdc)continue;if(node_ids.length>0)if(node_ids.indexOf(rtcdc.remote_peer_id)==-1)continue;logger.debug("close channel:",channel_id);rtcdc.close_channel();delete this._channels[channel_id]}};Transport.prototype._make_channel_id=function(node_id,conn_uuid,connection_id){return node_id+"-"+connection_id+"--"+conn_uuid};Transport.prototype._open_channel=function(node_id,signal_connection){logger.info(">> try to open channel with node: ",node_id);var opts={};var callbacks={cb_channel_open:this._channel_onopen.bind(this),cb_channel_close:this._channel_onclose.bind(this),cb_channel_message:this._channel_onmessage.bind(this)};var rtcdc=new RTCDC(this._ice_servers,node_id,signal_connection,opts,callbacks);var channel_id=this._make_channel_id(node_id,rtcdc.conn_uuid,signal_connection.getConnectionId());logger.info(">> channel uuid: ",channel_id);this._channels[channel_id]=rtcdc;return channel_id};Transport.prototype._channel_onopen=function(node_id,conn_uuid,connection_id){var channel_id=this._make_channel_id(node_id,conn_uuid,connection_id);logger.info("channel has been opened: ",channel_id);var rtcdc=this._channels[channel_id];if(rtcdc){if(!is_node)this._get_channel_stat(channel_id,rtcdc);if(typeof this.cb_channel_onopen=="function")this.cb_channel_onopen(channel_id,node_id)}else{logger.error("channel not found: ",channel_id)}};Transport.prototype._channel_onclose=function(node_id,conn_uuid,connection_id){var channel_id=this._make_channel_id(node_id,conn_uuid,connection_id);logger.info("channel closed: ",channel_id);if(typeof this.cb_channel_onclose=="function")this.cb_channel_onclose(channel_id,node_id);var rtcdc=this._channels[channel_id];if(rtcdc){rtcdc.close_channel();rtcdc=null}delete this._channels[channel_id]};Transport.prototype._channel_onmessage=function(node_id,conn_uuid,connection_id,message){var channel_id=this._make_channel_id(node_id,conn_uuid,connection_id);if(typeof this.cb_channel_onmessage=="function")this.cb_channel_onmessage(channel_id,message)};Transport.prototype._answer_received=function(node_id,conn_uuid,connection_id,answer){
  var channel_id=this._make_channel_id(node_id,conn_uuid,connection_id);var rtcdc=this._channels[channel_id];if(rtcdc){rtcdc.recv_answer(answer)}else{logger.debug("channel not found: ",channel_id)}};Transport.prototype._candidate_received=function(node_id,conn_uuid,connection_id,candidate){var channel_id=this._make_channel_id(node_id,conn_uuid,connection_id);var rtcdc=this._channels[channel_id];if(rtcdc){rtcdc.add_candidate(candidate)}else{logger.debug("channel not found: ",channel_id)}};Transport.prototype._get_channel_stat=function(channel_id,rtcdc){var conn_types={};var stat_promise=get_stat(rtcdc.pc);stat_promise.then(function(stat){try{logger.debug("stat: ",stat);var local_cand=stat["local_cand"];var remote_cand=stat["remote_cand"];if(local_cand&&remote_cand){var s="State: channel_id: "+channel_id;s+=", local candidate type: "+local_cand["candidateType"];s+=", addr: "+local_cand["ipAddress"]+":"+local_cand["portNumber"];s+=", remote candidate type: "+remote_cand["candidateType"];s+=", addr: "+remote_cand["ipAddress"]+":"+remote_cand["portNumber"];logger.info("connection state: ",s);var local_cand_type=local_cand["candidateType"];var remote_cand_type=remote_cand["candidateType"];if(local_cand_type.search(/relay/i)>=0||remote_cand_type.search(/relay/i)>=0){conn_types[channel_id]="TURN"}else{conn_types[channel_id]="P2P"}s="State: ";for(var node_id in conn_types){s+="node_id: "+node_id;s+=", connection type: "+conn_types[node_id]+"; "}logger.info("State: ",s);this._state_info["channels"][channel_id]=conn_types[channel_id];this._state_changed()}}catch(err){logger.error(err)}}.bind(this))};Transport.prototype._state_changed=function(){if(typeof this.cb_state_changed=="function"){this.cb_state_changed(this._state_info)}};Transport.prototype.send_request=function(channel_id,message){var rtcdc=this._channels[channel_id];if(rtcdc){rtcdc.dc.send(message)}else{logger.error("channel not found: ",channel_id)}};Transport.prototype.add_notification=function(notification_type,data){var notification=this._signal_protocol.make_notification(notification_type,data);this._notifications.push(notification)};Transport.prototype.send_notifications=function(){if(this._signal_connections.length>0){var signal_connection=this._signal_connections[0];if(signal_connection.getState()==Signal_Connection.State.OPEN)for(var i=0;i<this._notifications.length;i++)signal_connection.send(this._notifications[i])}this._notifications=[]};Transport.prototype.get_node_id_by_channel_id=function(channel_id){var rtcdc=this._channels[channel_id];if(rtcdc)return rtcdc.remote_peer_id};Transport.prototype.get_num_of_channels=function(){return this._num_of_channels};Transport.prototype.channel_exists=function(channel_id){return channel_id in this._channels==true?true:false};Transport.prototype.get_channel_ids_by_node_id=function(node_id){var channel_ids=[];for(var channel_id in this._channels){var rtcdc=this._channels[channel_id];if(!rtcdc)continue;if(node_id==rtcdc.remote_peer_id)channel_ids.push(channel_id)}return channel_ids};module.exports=Transport},{"./logging":5,"./rtcdc":68,"./signal_connection":69,"./signal_protocol":70,"detect-node":20}],72:[function(require,module,exports){const logger=require("./logging")(module);function Write_Buffer(file_writer,opts,callbacks){this._num_of_chunks=opts.num_of_chunks;this._file_size=opts.file_size;this._timeout=opts.timeout||20*1e3;this._timer_interval=opts.timer_interval||1e3;this._max_chunks_in_buffer=opts.max_chunks_in_buffer||0;this._cb_oninit=callbacks.cb_oninit;this._cb_onwrite=callbacks.cb_onwrite;this._cb_onerror=callbacks.cb_onerror;this._file_writer=file_writer;if(typeof this._num_of_chunks!="number")throw new Error("wrong type of parameter num_of_chunks, number required");if(this._num_of_chunks<=0)throw new Error("wrong value of parameter num_of_chunks, greater than zero required");if(typeof this._file_size!="number")throw new Error("wrong type of parameter file_size, number required");if(this._file_size<=0)throw new Error("wrong value of parameter file_size, greater than zero required");this._buffer=Object.create(null);this._next_index=0;this._ts=Date.now();this._waiting=false;this._timer_id=null;this._chunks_in_buffer=0}Write_Buffer.prototype=Object.create(null);Write_Buffer.prototype.init=function(){this._file_writer.set_callbacks({cb_oninit:this._on_init_file_writer.bind(this),cb_onwrite:this._on_write_file_writer.bind(this),cb_onerror:this._on_error_file_writer.bind(this)});this._file_writer.init()};Write_Buffer.prototype._on_init_file_writer=function(){if(typeof this._cb_oninit=="function")this._cb_oninit()};Write_Buffer.prototype._on_write_file_writer=function(size){if(this._timer_id){clearTimeout(this._timer_id);this._timer_id=null;this._waiting=false;this._buffer_flush();return}if(typeof this._cb_onwrite=="function")this._cb_onwrite(size)};Write_Buffer.prototype._on_error_file_writer=function(error){if(typeof this._cb_onerror=="function")this._cb_onerror(error);else throw error};Write_Buffer.prototype.push_chunk=function(index,chunk){if(typeof index!="number")throw new Error("wrong type of parameter index");if(index>this._num_of_chunks-1||index<0)throw new Error("wrong chunk index");if(typeof chunk!="object")throw new Error("wrong type of parameter chunk");this._buffer[index]=chunk;this._chunks_in_buffer+=1;this._buffer_flush()};Write_Buffer.prototype._buffer_flush=function(){if(this._waiting){if(Date.now()-this._ts>this._timeout){clearTimeout(this._timer_id);var err_msg="While flushing buffer of FileWriter Timeout exceeded";var e=new Write_Buffer_Error(err_msg,new Error("Timeout exceeded"));if(typeof this._cb_onerror=="function"){this._cb_onerror(e);return}else{throw e}}}while(true){var _next_index=this._get_next_index();if(_next_index==-1)break;if(this._file_writer.is_ready()){this._waiting=false;this._file_writer.write(this._buffer[_next_index]);this._next_index+=1;this._chunks_in_buffer-=1;delete this._buffer[_next_index]}else{if(this._waiting==false){this._ts=Date.now();this._waiting=true}this._timer_id=setTimeout(this._buffer_flush.bind(this),this._timer_interval,_next_index,this._buffer[_next_index]);break}}};Write_Buffer.prototype._get_next_index=function(){if(this._next_index in this._buffer){return this._next_index}return-1};Write_Buffer.prototype.get_url=function(){return this._file_writer.get_url()};Write_Buffer.prototype.get_size=function(){return this._file_writer.get_size()};Write_Buffer.prototype.is_ready=function(){if(this._max_chunks_in_buffer>0){logger.debug("chunks in buffer: %d, max: ",this._chunks_in_buffer,this._max_chunks_in_buffer);return this._chunks_in_buffer<this._max_chunks_in_buffer?true:false}return true};Write_Buffer.prototype.get_last_index_in_buffer=function(){return Math.max.apply(null,Object.keys(this._buffer))};function Write_Buffer_Error(message,cause){this.name="WRITE_BUFFER_ERROR";this.message=message;this.cause=cause}module.exports=Write_Buffer},{"./logging":5}]},{},[2]);
  