UNPKG

@sberdevices/assistant-client

Version:

Модуль взаимодействия с виртуальным ассистентом

15 lines (13 loc) 78.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assistant={})}(this,(function(exports){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function __rest(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function __spreadArrays(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}var getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),rnds8=new Uint8Array(16);function rng(){if(!getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}for(var byteToHex=[],i=0;i<256;++i)byteToHex[i]=(i+256).toString(16).substr(1);function bytesToUuid(e,t){var n=t||0,r=byteToHex;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}function v4(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||rng)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;++o)t[r+o]=i[o];return t||bytesToUuid(i)}var createNanoEvents=function(){var e={},t=function(t,n){return(e[t]=e[t]||[]).push(n),function(){e[t]=e[t].filter((function(e){return e!==n}))}};return{events:e,emit:function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];for(var i=0,o=e[t]||[];i<o.length;i++){var s=o[i];s.apply(void 0,n)}},on:t,once:function(e,n){var r=t(e,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.apply(void 0,e),r()}));return r},clear:function(){e={}}}},createNanoObservable=function(e){var t=createNanoEvents(),n=t.on,r=t.emit;return e({next:function(e){r("next",e)}}),{subscribe:function(e){var t=e.next;return{unsubscribe:n("next",t)}}}},findCommandIndex=function(e,t){var n,r,i=-1;return"character"===t.type?i=e.findIndex((function(e){return"character"===e.type&&e.character.id===t.character.id})):"insets"===t.type?i=e.findIndex((function(e){return"insets"===e.type})):"app_context"===t.type?i=e.findIndex((function(e){return"app_context"===e.type})):t.sdk_meta&&(null===(n=t.sdk_meta)||void 0===n?void 0:n.mid)&&"-1"!==(null===(r=t.sdk_meta)||void 0===r?void 0:r.mid)&&(i=e.findIndex((function(e){var n,r;return(null===(n=e.sdk_meta)||void 0===n?void 0:n.mid)===(null===(r=t.sdk_meta)||void 0===r?void 0:r.mid)}))),i},appInitialData=(isPulled=!1,pulled=[],committed=[],diff=[],{pull:function(){return isPulled=!0,pulled=__spreadArrays(window.appInitialData||[]),__spreadArrays(pulled)},commit:function(){committed=__spreadArrays(window.appInitialData||[]),diff=!0===isPulled?(window.appInitialData||[]).filter((function(e){return!(findCommandIndex(pulled,e)>=0)})):__spreadArrays(window.appInitialData||[])},diff:function(){return __spreadArrays(diff)},isCommitted:function(e){var t=findCommandIndex(committed,e),n=t>=0;return n&&committed.splice(t,1),n},find:function(e){var t=e.type,n=e.command,r=__spreadArrays(window.appInitialData||[]).find((function(e){return!(n||!t||t!==e.type)||(n&&"smart_app_data"in e?n===e.smart_app_data.command||n===e.smart_app_data.type:void 0)}));return r&&"smart_app_data"in r?r.smart_app_data:r}}),isPulled,pulled,committed,diff,commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return commonjsRequire(e,null==t?n.path:t)}},n.exports),n.exports}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var aspromise=asPromise;function asPromise(e,t){for(var n=new Array(arguments.length-1),r=0,i=2,o=!0;i<arguments.length;)n[r++]=arguments[i++];return new Promise((function(i,s){n[r]=function(e){if(o)if(o=!1,e)s(e);else{for(var t=new Array(arguments.length-1),n=0;n<t.length;)t[n++]=arguments[n];i.apply(null,t)}};try{e.apply(t||null,n)}catch(e){o&&(o=!1,s(e))}}))}var base64_1=createCommonjsModule((function(e,t){var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),i=new Array(123),o=0;o<64;)i[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(e,t,n){for(var i,o=null,s=[],a=0,l=0;t<n;){var c=e[t++];switch(l){case 0:s[a++]=r[c>>2],i=(3&c)<<4,l=1;break;case 1:s[a++]=r[i|c>>4],i=(15&c)<<2,l=2;break;case 2:s[a++]=r[i|c>>6],s[a++]=r[63&c],l=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return l&&(s[a++]=r[i],s[a++]=61,1===l&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";n.decode=function(e,t,n){for(var r,o=n,a=0,l=0;l<e.length;){var c=e.charCodeAt(l++);if(61===c&&a>1)break;if(void 0===(c=i[c]))throw Error(s);switch(a){case 0:r=c,a=1;break;case 1:t[n++]=r<<2|(48&c)>>4,r=c,a=2;break;case 2:t[n++]=(15&r)<<4|(60&c)>>2,r=c,a=3;break;case 3:t[n++]=(3&r)<<6|c,a=0}}if(1===a)throw Error(s);return n-o},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}})),eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},EventEmitter.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r<n.length;)n[r].fn===t?n.splice(r,1):++r;return this},EventEmitter.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,n)}return this};var float_1=factory(factory);function factory(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function o(e,r,i){t[0]=e,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function a(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?i:o,e.writeFloatBE=r?o:i,e.readFloatLE=r?s:a,e.readFloatBE=r?a:s}():function(){function t(e,t,n,r){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,n,r)}}function n(e,t,n){var r=e(t,n),i=2*(r>>31)+1,o=r>>>23&255,s=8388607&r;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=t.bind(null,writeUintLE),e.writeFloatBE=t.bind(null,writeUintBE),e.readFloatLE=n.bind(null,readUintLE),e.readFloatBE=n.bind(null,readUintBE)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function o(e,r,i){t[0]=e,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function a(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?i:o,e.writeDoubleBE=r?o:i,e.readDoubleLE=r?s:a,e.readDoubleBE=r?a:s}():function(){function t(e,t,n,r,i,o){var s=r<0?1:0;if(s&&(r=-r),0===r)e(0,i,o+t),e(1/r>0?0:2147483648,i,o+n);else if(isNaN(r))e(0,i,o+t),e(2146959360,i,o+n);else if(r>17976931348623157e292)e(0,i,o+t),e((s<<31|2146435072)>>>0,i,o+n);else{var a;if(r<22250738585072014e-324)e((a=r/5e-324)>>>0,i,o+t),e((s<<31|a/4294967296)>>>0,i,o+n);else{var l=Math.floor(Math.log(r)/Math.LN2);1024===l&&(l=1023),e(4503599627370496*(a=r*Math.pow(2,-l))>>>0,i,o+t),e((s<<31|l+1023<<20|1048576*a&1048575)>>>0,i,o+n)}}}function n(e,t,n,r,i){var o=e(r,i+t),s=e(r,i+n),a=2*(s>>31)+1,l=s>>>20&2047,c=4294967296*(1048575&s)+o;return 2047===l?c?NaN:a*(1/0):0===l?5e-324*a*c:a*Math.pow(2,l-1075)*(c+4503599627370496)}e.writeDoubleLE=t.bind(null,writeUintLE,0,4),e.writeDoubleBE=t.bind(null,writeUintBE,4,0),e.readDoubleLE=n.bind(null,readUintLE,0,4),e.readDoubleBE=n.bind(null,readUintBE,4,0)}(),e}function writeUintLE(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function writeUintBE(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function readUintLE(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function readUintBE(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var inquire_1=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}var utf8_1=createCommonjsModule((function(e,t){var n=t;n.length=function(e){for(var t=0,n=0,r=0;r<e.length;++r)(n=e.charCodeAt(r))<128?t+=1:n<2048?t+=2:55296==(64512&n)&&56320==(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t},n.read=function(e,t,n){if(n-t<1)return"";for(var r,i=null,o=[],s=0;t<n;)(r=e[t++])<128?o[s++]=r:r>191&&r<224?o[s++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(r>>10),o[s++]=56320+(1023&r)):o[s++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},n.write=function(e,t,n){for(var r,i,o=n,s=0;s<e.length;++s)(r=e.charCodeAt(s))<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=e.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&i),++s,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-o}})),pool_1=pool;function pool(e,t,n){var r=n||8192,i=r>>>1,o=null,s=r;return function(n){if(n<1||n>i)return e(n);s+n>r&&(o=e(r),s=0);var a=t.call(o,s,s+=n);return 7&s&&(s=1+(7|s)),a}}var longbits=LongBits;function LongBits(e,t){this.lo=e>>>0,this.hi=t>>>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(e){if(0===e)return zero;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new LongBits(n,r)},LongBits.from=function(e){if("number"==typeof e)return LongBits.fromNumber(e);if(minimal.isString(e)){if(!minimal.Long)return LongBits.fromNumber(parseInt(e,10));e=minimal.Long.fromString(e)}return e.low||e.high?new LongBits(e.low>>>0,e.high>>>0):zero},LongBits.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},LongBits.prototype.toLong=function(e){return minimal.Long?new minimal.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var charCodeAt=String.prototype.charCodeAt;LongBits.fromHash=function(e){return e===zeroHash?zero:new LongBits((charCodeAt.call(e,0)|charCodeAt.call(e,1)<<8|charCodeAt.call(e,2)<<16|charCodeAt.call(e,3)<<24)>>>0,(charCodeAt.call(e,4)|charCodeAt.call(e,5)<<8|charCodeAt.call(e,6)<<16|charCodeAt.call(e,7)<<24)>>>0)},LongBits.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},LongBits.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},LongBits.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},LongBits.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10};var minimal=createCommonjsModule((function(e,t){var n=t;function r(e,t,n){for(var r=Object.keys(t),i=0;i<r.length;++i)void 0!==e[r[i]]&&n||(e[r[i]]=t[r[i]]);return e}function i(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&r(this,n)}return(t.prototype=Object.create(Error.prototype)).constructor=t,Object.defineProperty(t.prototype,"name",{get:function(){return e}}),t.prototype.toString=function(){return this.name+": "+this.message},t}n.asPromise=aspromise,n.base64=base64_1,n.EventEmitter=eventemitter,n.float=float_1,n.inquire=inquire_1,n.utf8=utf8_1,n.pool=pool_1,n.LongBits=longbits,n.isNode=Boolean(void 0!==commonjsGlobal&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),n.global=n.isNode&&commonjsGlobal||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||commonjsGlobal,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},n.isString=function(e){return"string"==typeof e||e instanceof String},n.isObject=function(e){return e&&"object"==typeof e},n.isset=n.isSet=function(e,t){var n=e[t];return!(null==n||!e.hasOwnProperty(t))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"==typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=r,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=i,n.ProtocolError=i("ProtocolError"),n.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},n.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var e=n.Buffer;e?(n._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,n){return new e(t,n)},n._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):n._Buffer_from=n._Buffer_allocUnsafe=null}})),writer=Writer,BufferWriter,LongBits$1=minimal.LongBits,base64=minimal.base64,utf8=minimal.utf8;function Op(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function noop(){}function State(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function Writer(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create=function(){return minimal.Buffer?function(){return(Writer.create=function(){return new BufferWriter})()}:function(){return new Writer}};function writeByte(e,t,n){t[n]=255&e}function writeVarint32(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e}function VarintOp(e,t){this.len=e,this.next=void 0,this.val=t}function writeVarint64(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function writeFixed32(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}Writer.create=create(),Writer.alloc=function(e){return new minimal.Array(e)},minimal.Array!==Array&&(Writer.alloc=minimal.pool(Writer.alloc,minimal.Array.prototype.subarray)),Writer.prototype._push=function(e,t,n){return this.tail=this.tail.next=new Op(e,t,n),this.len+=t,this},VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new VarintOp((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},Writer.prototype.int32=function(e){return e<0?this._push(writeVarint64,10,LongBits$1.fromNumber(e)):this.uint32(e)},Writer.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},Writer.prototype.uint64=function(e){var t=LongBits$1.from(e);return this._push(writeVarint64,t.length(),t)},Writer.prototype.int64=Writer.prototype.uint64,Writer.prototype.sint64=function(e){var t=LongBits$1.from(e).zzEncode();return this._push(writeVarint64,t.length(),t)},Writer.prototype.bool=function(e){return this._push(writeByte,1,e?1:0)},Writer.prototype.fixed32=function(e){return this._push(writeFixed32,4,e>>>0)},Writer.prototype.sfixed32=Writer.prototype.fixed32,Writer.prototype.fixed64=function(e){var t=LongBits$1.from(e);return this._push(writeFixed32,4,t.lo)._push(writeFixed32,4,t.hi)},Writer.prototype.sfixed64=Writer.prototype.fixed64,Writer.prototype.float=function(e){return this._push(minimal.float.writeFloatLE,4,e)},Writer.prototype.double=function(e){return this._push(minimal.float.writeDoubleLE,8,e)};var writeBytes=minimal.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r<e.length;++r)t[n+r]=e[r]};Writer.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(writeByte,1,0);if(minimal.isString(e)){var n=Writer.alloc(t=base64.length(e));base64.decode(e,n,0),e=n}return this.uint32(t)._push(writeBytes,t,e)},Writer.prototype.string=function(e){var t=utf8.length(e);return t?this.uint32(t)._push(utf8.write,t,e):this._push(writeByte,1,0)},Writer.prototype.fork=function(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this},Writer.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},Writer.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},Writer._configure=function(e){BufferWriter=e,Writer.create=create(),BufferWriter._configure()};var writer_buffer=BufferWriter$1;function BufferWriter$1(){writer.call(this)}function writeStringBuffer(e,t,n){e.length<40?minimal.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}(BufferWriter$1.prototype=Object.create(writer.prototype)).constructor=BufferWriter$1,BufferWriter$1._configure=function(){BufferWriter$1.alloc=minimal._Buffer_allocUnsafe,BufferWriter$1.writeBytesBuffer=minimal.Buffer&&minimal.Buffer.prototype instanceof Uint8Array&&"set"===minimal.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r<e.length;)t[n++]=e[r++]}},BufferWriter$1.prototype.bytes=function(e){minimal.isString(e)&&(e=minimal._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(BufferWriter$1.writeBytesBuffer,t,e),this},BufferWriter$1.prototype.string=function(e){var t=minimal.Buffer.byteLength(e);return this.uint32(t),t&&this._push(writeStringBuffer,t,e),this},BufferWriter$1._configure();var reader=Reader,BufferReader,LongBits$2=minimal.LongBits,utf8$1=minimal.utf8;function indexOutOfRange(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Reader(e){this.buf=e,this.pos=0,this.len=e.length}var create_array="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new Reader(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new Reader(e);throw Error("illegal buffer")},create$1=function(){return minimal.Buffer?function(e){return(Reader.create=function(e){return minimal.Buffer.isBuffer(e)?new BufferReader(e):create_array(e)})(e)}:create_array},value;function readLongVarint(){var e=new LongBits$2(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw indexOutOfRange(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function readFixed32_end(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits$2(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader.create=create$1(),Reader.prototype._slice=minimal.Array.prototype.subarray||minimal.Array.prototype.slice,Reader.prototype.uint32=(value=4294967295,function(){if(value=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return value;if(value=(value|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return value;if(value=(value|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return value;if(value=(value|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return value;if(value=(value|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return value;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return value}),Reader.prototype.int32=function(){return 0|this.uint32()},Reader.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},Reader.prototype.bool=function(){return 0!==this.uint32()},Reader.prototype.fixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.sfixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return 0|readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.float=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var e=minimal.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},Reader.prototype.double=function(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var e=minimal.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},Reader.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw indexOutOfRange(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},Reader.prototype.string=function(){var e=this.bytes();return utf8$1.read(e,0,e.length)},Reader.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw indexOutOfRange(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw indexOutOfRange(this)}while(128&this.buf[this.pos++]);return this},Reader.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},Reader._configure=function(e){BufferReader=e,Reader.create=create$1(),BufferReader._configure();var t=minimal.Long?"toLong":"toNumber";minimal.merge(Reader.prototype,{int64:function(){return readLongVarint.call(this)[t](!1)},uint64:function(){return readLongVarint.call(this)[t](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[t](!1)},fixed64:function(){return readFixed64.call(this)[t](!0)},sfixed64:function(){return readFixed64.call(this)[t](!1)}})};var reader_buffer=BufferReader$1;function BufferReader$1(e){reader.call(this,e)}(BufferReader$1.prototype=Object.create(reader.prototype)).constructor=BufferReader$1,BufferReader$1._configure=function(){minimal.Buffer&&(BufferReader$1.prototype._slice=minimal.Buffer.prototype.slice)},BufferReader$1.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},BufferReader$1._configure();var service=Service;function Service(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");minimal.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(Service.prototype=Object.create(minimal.EventEmitter.prototype)).constructor=Service,Service.prototype.rpcCall=function e(t,n,r,i,o){if(!i)throw TypeError("request must be specified");var s=this;if(!o)return minimal.asPromise(e,s,t,n,r,i);if(s.rpcImpl)try{return s.rpcImpl(t,n[s.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,n){if(e)return s.emit("error",e,t),o(e);if(null!==n){if(!(n instanceof r))try{n=r[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return s.emit("error",e,t),o(e)}return s.emit("data",n,t),o(null,n)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){o(e)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},Service.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this};var rpc_1=createCommonjsModule((function(e,t){t.Service=service})),roots={},indexMinimal=createCommonjsModule((function(e,t){var n=t;function r(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=writer,n.BufferWriter=writer_buffer,n.Reader=reader,n.BufferReader=reader_buffer,n.util=minimal,n.rpc=rpc_1,n.roots=roots,n.configure=r,r()})),minimal$1=indexMinimal,proto=createCommonjsModule((function(e){var t,n,r,i,o;"function"==typeof commonjsRequire&&e&&e.exports&&(e.exports=(n=(t=minimal$1).Reader,r=t.Writer,i=t.util,(o=t.roots.default||(t.roots.default={})).Message=function(){function e(e){if(this.devContext=[],this.meta={},e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}var s;return e.prototype.userId="",e.prototype.messageId=i.Long?i.Long.fromBits(0,0,!1):0,e.prototype.last=0,e.prototype.token="",e.prototype.userChannel="",e.prototype.vpsToken="",e.prototype.devContext=i.emptyArray,e.prototype.messageName="",e.prototype.version=0,e.prototype.voice=null,e.prototype.text=null,e.prototype.systemMessage=null,e.prototype.legacyDevice=null,e.prototype.settings=null,e.prototype.status=null,e.prototype.device=null,e.prototype.bytes=null,e.prototype.initialSettings=null,e.prototype.cancel=null,e.prototype.timestamp=i.Long?i.Long.fromBits(0,0,!1):0,e.prototype.meta=i.emptyObject,Object.defineProperty(e.prototype,"content",{get:i.oneOfGetter(s=["voice","text","systemMessage","legacyDevice","settings","status","device","bytes","initialSettings","cancel"]),set:i.oneOfSetter(s)}),e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=r.create()),null!=e.userId&&Object.hasOwnProperty.call(e,"userId")&&t.uint32(10).string(e.userId),null!=e.messageId&&Object.hasOwnProperty.call(e,"messageId")&&t.uint32(16).int64(e.messageId),null!=e.last&&Object.hasOwnProperty.call(e,"last")&&t.uint32(24).int32(e.last),null!=e.token&&Object.hasOwnProperty.call(e,"token")&&t.uint32(34).string(e.token),null!=e.voice&&Object.hasOwnProperty.call(e,"voice")&&o.Voice.encode(e.voice,t.uint32(42).fork()).ldelim(),null!=e.text&&Object.hasOwnProperty.call(e,"text")&&o.Text.encode(e.text,t.uint32(50).fork()).ldelim(),null!=e.systemMessage&&Object.hasOwnProperty.call(e,"systemMessage")&&o.SystemMessage.encode(e.systemMessage,t.uint32(58).fork()).ldelim(),null!=e.legacyDevice&&Object.hasOwnProperty.call(e,"legacyDevice")&&o.LegacyDevice.encode(e.legacyDevice,t.uint32(66).fork()).ldelim(),null!=e.settings&&Object.hasOwnProperty.call(e,"settings")&&o.Settings.encode(e.settings,t.uint32(74).fork()).ldelim(),null!=e.status&&Object.hasOwnProperty.call(e,"status")&&o.Status.encode(e.status,t.uint32(82).fork()).ldelim(),null!=e.userChannel&&Object.hasOwnProperty.call(e,"userChannel")&&t.uint32(90).string(e.userChannel),null!=e.vpsToken&&Object.hasOwnProperty.call(e,"vpsToken")&&t.uint32(98).string(e.vpsToken),null!=e.devContext&&e.devContext.length)for(var n=0;n<e.devContext.length;++n)o.DevContext.encode(e.devContext[n],t.uint32(106).fork()).ldelim();if(null!=e.messageName&&Object.hasOwnProperty.call(e,"messageName")&&t.uint32(114).string(e.messageName),null!=e.version&&Object.hasOwnProperty.call(e,"version")&&t.uint32(120).int32(e.version),null!=e.device&&Object.hasOwnProperty.call(e,"device")&&o.Device.encode(e.device,t.uint32(130).fork()).ldelim(),null!=e.bytes&&Object.hasOwnProperty.call(e,"bytes")&&o.Bytes.encode(e.bytes,t.uint32(138).fork()).ldelim(),null!=e.initialSettings&&Object.hasOwnProperty.call(e,"initialSettings")&&o.InitialSettings.encode(e.initialSettings,t.uint32(146).fork()).ldelim(),null!=e.timestamp&&Object.hasOwnProperty.call(e,"timestamp")&&t.uint32(152).int64(e.timestamp),null!=e.meta&&Object.hasOwnProperty.call(e,"meta")){var i=Object.keys(e.meta);for(n=0;n<i.length;++n)t.uint32(162).fork().uint32(10).string(i[n]).uint32(18).string(e.meta[i[n]]).ldelim()}return null!=e.cancel&&Object.hasOwnProperty.call(e,"cancel")&&o.Cancel.encode(e.cancel,t.uint32(170).fork()).ldelim(),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof n||(e=n.create(e));for(var r,s,a=void 0===t?e.len:e.pos+t,l=new o.Message;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:l.userId=e.string();break;case 2:l.messageId=e.int64();break;case 3:l.last=e.int32();break;case 4:l.token=e.string();break;case 11:l.userChannel=e.string();break;case 12:l.vpsToken=e.string();break;case 13:l.devContext&&l.devContext.length||(l.devContext=[]),l.devContext.push(o.DevContext.decode(e,e.uint32()));break;case 14:l.messageName=e.string();break;case 15:l.version=e.int32();break;case 5:l.voice=o.Voice.decode(e,e.uint32());break;case 6:l.text=o.Text.decode(e,e.uint32());break;case 7:l.systemMessage=o.SystemMessage.decode(e,e.uint32());break;case 8:l.legacyDevice=o.LegacyDevice.decode(e,e.uint32());break;case 9:l.settings=o.Settings.decode(e,e.uint32());break;case 10:l.status=o.Status.decode(e,e.uint32());break;case 16:l.device=o.Device.decode(e,e.uint32());break;case 17:l.bytes=o.Bytes.decode(e,e.uint32());break;case 18:l.initialSettings=o.InitialSettings.decode(e,e.uint32());break;case 21:l.cancel=o.Cancel.decode(e,e.uint32());break;case 19:l.timestamp=e.int64();break;case 20:l.meta===i.emptyObject&&(l.meta={});var u=e.uint32()+e.pos;for(r="",s="";e.pos<u;){var p=e.uint32();switch(p>>>3){case 1:r=e.string();break;case 2:s=e.string();break;default:e.skipType(7&p)}}l.meta[r]=s;break;default:e.skipType(7&c)}}return l},e.decodeDelimited=function(e){return e instanceof n||(e=new n(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.userId&&e.hasOwnProperty("userId")&&!i.isString(e.userId))return"userId: string expected";if(null!=e.messageId&&e.hasOwnProperty("messageId")&&!(i.isInteger(e.messageId)||e.messageId&&i.isInteger(e.messageId.low)&&i.isInteger(e.messageId.high)))return"messageId: integer|Long expected";if(null!=e.last&&e.hasOwnProperty("last")&&!i.isInteger(e.last))return"last: integer expected";if(null!=e.token&&e.hasOwnProperty("token")&&!i.isString(e.token))return"token: string expected";if(null!=e.userChannel&&e.hasOwnProperty("userChannel")&&!i.isString(e.userChannel))return"userChannel: string expected";if(null!=e.vpsToken&&e.hasOwnProperty("vpsToken")&&!i.isString(e.vpsToken))return"vpsToken: string expected";if(null!=e.devContext&&e.hasOwnProperty("devContext")){if(!Array.isArray(e.devContext))return"devContext: array expected";for(var n=0;n<e.devContext.length;++n)if(r=o.DevContext.verify(e.devContext[n]))return"devContext."+r}if(null!=e.messageName&&e.hasOwnProperty("messageName")&&!i.isString(e.messageName))return"messageName: string expected";if(null!=e.version&&e.hasOwnProperty("version")&&!i.isInteger(e.version))return"version: integer expected";if(null!=e.voice&&e.hasOwnProperty("voice")&&(t.content=1,r=o.Voice.verify(e.voice)))return"voice."+r;if(null!=e.text&&e.hasOwnProperty("text")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.Text.verify(e.text))return"text."+r}if(null!=e.systemMessage&&e.hasOwnProperty("systemMessage")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.SystemMessage.verify(e.systemMessage))return"systemMessage."+r}if(null!=e.legacyDevice&&e.hasOwnProperty("legacyDevice")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.LegacyDevice.verify(e.legacyDevice))return"legacyDevice."+r}if(null!=e.settings&&e.hasOwnProperty("settings")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.Settings.verify(e.settings))return"settings."+r}if(null!=e.status&&e.hasOwnProperty("status")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.Status.verify(e.status))return"status."+r}if(null!=e.device&&e.hasOwnProperty("device")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.Device.verify(e.device))return"device."+r}if(null!=e.bytes&&e.hasOwnProperty("bytes")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.Bytes.verify(e.bytes))return"bytes."+r}if(null!=e.initialSettings&&e.hasOwnProperty("initialSettings")){if(1===t.content)return"content: multiple values";if(t.content=1,r=o.InitialSettings.verify(e.initialSettings))return"initialSettings."+r}if(null!=e.cancel&&e.hasOwnProperty("cancel")){if(1===t.content)return"content: multiple values";var r;if(t.content=1,r=o.Cancel.verify(e.cancel))return"cancel."+r}if(null!=e.timestamp&&e.hasOwnProperty("timestamp")&&!(i.isInteger(e.timestamp)||e.timestamp&&i.isInteger(e.timestamp.low)&&i.isInteger(e.timestamp.high)))return"timestamp: integer|Long expected";if(null!=e.meta&&e.hasOwnProperty("meta")){if(!i.isObject(e.meta))return"meta: object expected";var s=Object.keys(e.meta);for(n=0;n<s.length;++n)if(!i.isString(e.meta[s[n]]))return"meta: string{k:string} expected"}return null},e.fromObject=function(e){if(e instanceof o.Message)return e;var t=new o.Message;if(null!=e.userId&&(t.userId=String(e.userId)),null!=e.messageId&&(i.Long?(t.messageId=i.Long.fromValue(e.messageId)).unsigned=!1:"string"==typeof e.messageId?t.messageId=parseInt(e.messageId,10):"number"==typeof e.messageId?t.messageId=e.messageId:"object"==typeof e.messageId&&(t.messageId=new i.LongBits(e.messageId.low>>>0,e.messageId.high>>>0).toNumber())),null!=e.last&&(t.last=0|e.last),null!=e.token&&(t.token=String(e.token)),null!=e.userChannel&&(t.userChannel=String(e.userChannel)),null!=e.vpsToken&&(t.vpsToken=String(e.vpsToken)),e.devContext){if(!Array.isArray(e.devContext))throw TypeError(".Message.devContext: array expected");t.devContext=[];for(var n=0;n<e.devContext.length;++n){if("object"!=typeof e.devContext[n])throw TypeError(".Message.devContext: object expected");t.devContext[n]=o.DevContext.fromObject(e.devContext[n])}}if(null!=e.messageName&&(t.messageName=String(e.messageName)),null!=e.version&&(t.version=0|e.version),null!=e.voice){if("object"!=typeof e.voice)throw TypeError(".Message.voice: object expected");t.voice=o.Voice.fromObject(e.voice)}if(null!=e.text){if("object"!=typeof e.text)throw TypeError(".Message.text: object expected");t.text=o.Text.fromObject(e.text)}if(null!=e.systemMessage){if("object"!=typeof e.systemMessage)throw TypeError(".Message.systemMessage: object expected");t.systemMessage=o.SystemMessage.fromObject(e.systemMessage)}if(null!=e.legacyDevice){if("object"!=typeof e.legacyDevice)throw TypeError(".Message.legacyDevice: object expected");t.legacyDevice=o.LegacyDevice.fromObject(e.legacyDevice)}if(null!=e.settings){if("object"!=typeof e.settings)throw TypeError(".Message.settings: object expected");t.settings=o.Settings.fromObject(e.settings)}if(null!=e.status){if("object"!=typeof e.status)throw TypeError(".Message.status: object expected");t.status=o.Status.fromObject(e.status)}if(null!=e.device){if("object"!=typeof e.device)throw TypeError(".Message.device: object expected");t.device=o.Device.fromObject(e.device)}if(null!=e.bytes){if("object"!=typeof e.bytes)throw TypeError(".Message.bytes: object expected");t.bytes=o.Bytes.fromObject(e.bytes)}if(null!=e.initialSettings){if("object"!=typeof e.initialSettings)throw TypeError(".Message.initialSettings: object expected");t.initialSettings=o.InitialSettings.fromObject(e.initialSettings)}if(null!=e.cancel){if("object"!=typeof e.cancel)throw TypeError(".Message.cancel: object expected");t.cancel=o.Cancel.fromObject(e.cancel)}if(null!=e.timestamp&&(i.Long?(t.timestamp=i.Long.fromValue(e.timestamp)).unsigned=!1:"string"==typeof e.timestamp?t.timestamp=parseInt(e.timestamp,10):"number"==typeof e.timestamp?t.timestamp=e.timestamp:"object"==typeof e.timestamp&&(t.timestamp=new i.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber())),e.meta){if("object"!=typeof e.meta)throw TypeError(".Message.meta: object expected");t.meta={};var r=Object.keys(e.meta);for(n=0;n<r.length;++n)t.meta[r[n]]=String(e.meta[r[n]])}return t},e.toObject=function(e,t){t||(t={});var n,r={};if((t.arrays||t.defaults)&&(r.devContext=[]),(t.objects||t.defaults)&&(r.meta={}),t.defaults){if(r.userId="",i.Long){var s=new i.Long(0,0,!1);r.messageId=t.longs===String?s.toString():t.longs===Number?s.toNumber():s}else r.messageId=t.longs===String?"0":0;r.last=0,r.token="",r.userChannel="",r.vpsToken="",r.messageName="",r.version=0,i.Long?(s=new i.Long(0,0,!1),r.timestamp=t.longs===String?s.toString():t.longs===Number?s.toNumber():s):r.timestamp=t.longs===String?"0":0}if(null!=e.userId&&e.hasOwnProperty("userId")&&(r.userId=e.userId),null!=e.messageId&&e.hasOwnProperty("messageId")&&("number"==typeof e.messageId?r.messageId=t.longs===String?String(e.messageId):e.messageId:r.messageId=t.longs===String?i.Long.prototype.toString.call(e.messageId):t.longs===Number?new i.LongBits(e.messageId.low>>>0,e.messageId.high>>>0).toNumber():e.messageId),null!=e.last&&e.hasOwnProperty("last")&&(r.last=e.last),null!=e.token&&e.hasOwnProperty("token")&&(r.token=e.token),null!=e.voice&&e.hasOwnProperty("voice")&&(r.voice=o.Voice.toObject(e.voice,t),t.oneofs&&(r.content="voice")),null!=e.text&&e.hasOwnProperty("text")&&(r.text=o.Text.toObject(e.text,t),t.oneofs&&(r.content="text")),null!=e.systemMessage&&e.hasOwnProperty("systemMessage")&&(r.systemMessage=o.SystemMessage.toObject(e.systemMessage,t),t.oneofs&&(r.content="systemMessage")),null!=e.legacyDevice&&e.hasOwnProperty("legacyDevice")&&(r.legacyDevice=o.LegacyDevice.toObject(e.legacyDevice,t),t.oneofs&&(r.content="legacyDevice")),null!=e.settings&&e.hasOwnProperty("settings")&&(r.settings=o.Settings.toObject(e.settings,t),t.oneofs&&(r.content="settings")),null!=e.status&&e.hasOwnProperty("status")&&(r.status=o.Status.toObject(e.status,t),t.oneofs&&(r.content="status")),null!=e.userChannel&&e.hasOwnProperty("userChannel")&&(r.userChannel=e.userChannel),null!=e.vpsToken&&e.hasOwnProperty("vpsToken")&&(r.vpsToken=e.vpsToken),e.devContext&&e.devContext.length){r.devContext=[];for(var a=0;a<e.devContext.length;++a)r.devContext[a]=o.DevContext.toObject(e.devContext[a],t)}if(null!=e.messageName&&e.hasOwnProperty("messageName")&&(r.messageName=e.messageName),null!=e.version&&e.hasOwnProperty("version")&&(r.version=e.version),null!=e.device&&e.hasOwnProperty("device")&&(r.device=o.Device.toObject(e.device,t),t.oneofs&&(r.content="device")),null!=e.bytes&&e.hasOwnProperty("bytes")&&(r.bytes=o.Bytes.toObject(e.bytes,t),t.oneofs&&(r.content="bytes")),null!=e.initialSettings&&e.hasOwnProperty("initialSettings")&&(r.initialSettings=o.InitialSettings.toObject(e.initialSettings,t),t.oneofs&&(r.content="initialSettings")),null!=e.timestamp&&e.hasOwnProperty("timestamp")&&("number"==typeof e.timestamp?r.timestamp=t.longs===String?String(e.timestamp):e.timestamp:r.timestamp=t.longs===String?i.Long.prototype.toString.call(e.timestamp):t.longs===Number?new i.LongBits(e.timestamp.low>>>0,e.timestamp.high>>>0).toNumber():e.timestamp),e.meta&&(n=Object.keys(e.meta)).length)for(r.meta={},a=0;a<n.length;++a)r.meta[n[a]]=e.meta[n[a]];return null!=e.cancel&&e.hasOwnProperty("cancel")&&(r.cancel=o.Cancel.toObject(e.cancel,t),t.oneofs&&(r.content="cancel")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e}(),o.InitialSettings=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.userId="",e.prototype.userChannel="",e.prototype.device=null,e.prototype.settings=null,e.prototype.locale="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=r.create()),null!=e.userId&&Object.hasOwnProperty.call(e,"userId")&&t.uint32(10).string(e.userId),null!=e.userChannel&&Object.hasOwnProperty.call(e,"userChannel")&&t.uint32(18).string(e.userChannel),null!=e.device&&Object.hasOwnProperty.call(e,"device")&&o.Device.encode(e.device,t.uint32(26).fork()).ldelim(),null!=e.settings&&Object.hasOwnProperty.call(e,"settings")&&o.Settings.encode(e.settings,t.uint32(34).fork()).ldelim(),null!=e.locale&&Object.hasOwnProperty.call(e,"locale")&&t.uint32(42).string(e.locale),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof n||(e=n.create(e));for(var r=void 0===t?e.len:e.pos+t,i=new o.InitialSettings;e.pos<r;){var s=e.uint32();switch(s>>>3){case 1:i.userId=e.string();break;case 2:i.userChannel=e.string();break;case 3:i.device=o.Device.decode(e,e.uint32());break;case 4:i.settings=o.Settings.decode(e,e.uint32());break;case 5:i.locale=e.string();break;default:e.skipType(7&s)}}return i},e.decodeDelimited=function(e){return e instanceof n||(e=new n(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.userId&&e.hasOwnProperty("userId")&&!i.isString(e.userId)?"userId: string expected":null!=e.userChannel&&e.hasOwnProperty("userChannel")&&!i.isString(e.userChannel)?"userChannel: string expected":null!=e.device&&e.hasOwnProperty("device")&&(t=o.Device.verify(e.device))?"device."+t:null!=e.settings&&e.hasOwnProperty("settings")&&(t=o.Settings.verify(e.settings))?"settings."+t:null!=e.locale&&e.hasOwnProperty("locale")&&!i.isString(e.locale)?"locale: string expected":null;var t},e.fromObject=function(e){if(e instanceof o.InitialSettings)return e;var t=new o.InitialSettings;if(null!=e.userId&&(t.userId=String(e.userId)),null!=e.userChannel&&(t.userChannel=String(e.userChannel)),null!=e.device){if("object"!=typeof e.device)throw TypeError(".InitialSettings.device: object expected");t.device=o.Device.fromObject(e.device)}if(null!=e.settings){if("object"!=typeof e.settings)throw TypeError(".InitialSettings.settings: object expected");t.settings=o.Settings.fromObject(e.settings)}return null!=e.locale&&(t.locale=String(e.locale)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.userId="",n.userChannel="",n.device=null,n.settings=null,n.locale=""),null!=e.userId&&e.hasOwnProperty("userId")&&(n.userId=e.userId),null!=e.userChannel&&e.hasOwnProperty("userChannel")&&(n.userChannel=e.userChannel),null!=e.device&&e.hasOwnProperty("device")&&(n.device=o.Device.toObject(e.device,t)),null!=e.settings&&e.hasOwnProperty("settings")&&(n.settings=o.Settings.toObject(e.settings,t)),null!=e.locale&&e.hasOwnProperty("locale")&&(n.locale=e.locale),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,t.util.toJSONOptions)},e}(),o.Device=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.platformType="",e.prototype.platformVersion="",e.prototype.surface="",e.prototype.surfaceVersion="",e.prototype.features="",e.prototype.capabilities="",e.prototype.deviceId="",e.prototype.deviceManufacturer="",e.prototype.deviceModel="",e.prototype.additionalInfo="",e.prototype.tenant="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=r.create()),null!=e.platformType&&Object.hasOwnProperty.call(e,"platformType")&&t.uint32(10).string(e.platformType),null!=e.platformVersion&&Object.hasOwnProperty.call(e,"platformVersion")&&t.uint32(18).string(e.platformVersion),null!=e.surface&&Object.hasOwnProperty.call(e,"surface")&&t.uint32(26).string(e.surface),null!=e.surfaceVersion&&Object.hasOwnProperty.call(e,"surfaceVersion")&&t.uint32(34).string(e.surfaceVersion),null!=e.features&&Object.hasOwnProperty.call(e,"features")&&t.uint32(42).string(e.features),null!=e.capabilities&&Object.hasOwnProperty.call(e,"capabilities")&&t.uint32(50).string(e.capabilities),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(58).string(e.deviceId),null!=e.deviceManufacturer&&Object.hasOwnProperty.call(e,"deviceManufacturer")&&t.uint32(66).string(e.deviceManufacturer),null!=e.deviceModel&&Object.hasOwnProperty.call(e,"deviceModel")&&t.uint32(74).string(e.deviceModel),null!=e.additionalInfo&&Object.hasOwnProperty.call(e,"additionalInfo")&&t.uint32(82).string(e.additionalInfo),null!=e.tenant&&Object.hasOwnProperty.call(e,"tenant")&&t.uint32(90).string(e.tenant),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof n||(e=n.create(e));for(var r=void 0===t?e.len:e.pos+t,i=new o.Device;e.pos<r;){var s=e.uint32();switch(s>>>3){case 1:i.platformType=e.string();break;case 2:i.platformVersion=e.string();break;case 3:i.surface=e.string();break;case 4:i.surfaceVersion=e.string();break;case 5:i.features=e.string();break;case 6:i.capabilities=e.string();break;case 7:i.deviceId=e.string();break;case 8:i.deviceManufacturer=e.string();break;case 9:i.deviceModel=e.string();break;case 10:i.additionalInfo=e.string();break;case 11:i.tenant=e.string();break;default:e.skipType(7&s)}}return i},e.decodeDelimited=function(e){return e instanceof n||(e=new n(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.platformType&&e.hasOwnProperty("platformType")&&!i.isString(e.platformType)?"platformType: string expected":null!=e.platformVersion&&e.hasOwnProperty("platformVersion")&&!i.isString(e.platformVersion)?"platformVersion: string expected":null!=e.surface&&e.hasOwnProperty("surface")&&!i.isString(e.surface)?"surface: string expected":null!=e.surfaceVersion&&e.hasOwnProperty("surfaceVersion")&&!i.isString(e.surfaceVersion)?"surfaceVersion: string expected":null!=e.features&&e.hasOwnProperty("features")&&!i.isString(e.features)?"features: string expected":null!=e.capabilities&&e.hasOwnProperty("capabilities")&&!i.isString(e.capabilities)?"capabilities: string expected":null!=e.deviceId&&e.hasOwnProperty("deviceId")&&!i.isString(e.deviceId)?"deviceId: string expected":null!=e.deviceManufacturer&&e.hasOwnProperty("deviceManufacturer")&&!i.isString(e.deviceManufacturer)?"deviceManufacturer: string expected":null!=e.deviceModel&&e.hasOwnProperty("deviceModel")&&!i.isString(e.deviceModel)?"deviceModel: string expected":null!=e.a