106 lines
168 KiB
JavaScript
Executable File
106 lines
168 KiB
JavaScript
Executable File
/**
|
||
* CyberChef - The Cyber Swiss Army Knife
|
||
*
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*
|
||
* Copyright 2016 Crown Copyright
|
||
*
|
||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
* you may not use this file except in compliance with the License.
|
||
* You may obtain a copy of the License at
|
||
*
|
||
* http://www.apache.org/licenses/LICENSE-2.0
|
||
*
|
||
* Unless required by applicable law or agreed to in writing, software
|
||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
* See the License for the specific language governing permissions and
|
||
* limitations under the License.
|
||
*/!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1512)}({0:function(e,t,r){"use strict";var n=r(15),i=r.n(n),o=r(10),u=r(7),s=r(19),a=r(18);function f(e,t,r,n,i,o,u){try{var s=e[o](u),a=s.value}catch(e){return void r(e)}s.done?t(a):Promise.resolve(a).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function u(e){f(o,n,i,u,s,"next",e)}function s(e){f(o,n,i,u,s,"throw",e)}u(void 0)})}}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}
|
||
/**
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*/
|
||
var h=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n;return t=e,r=null,n=[{key:"chr",value:function(e){if(e>65535){e-=65536;var t=String.fromCharCode(e>>>10&1023|55296);return e=56320|1023&e,t+String.fromCharCode(e)}return String.fromCharCode(e)}},{key:"ord",value:function(e){if(2===e.length){var t=e.charCodeAt(0),r=e.charCodeAt(1);if(t>=55296&&t<56320&&r>=56320&&r<57344)return 1024*(t-55296)+r-56320+65536}return e.charCodeAt(0)}},{key:"padBytesRight",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=new Array(t);return n.fill(r),Array.prototype.map.call(e,function(e,t){n[t]=e}),n}},{key:"truncate",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";return e.length>t&&(e=e.slice(0,t-r.length)+r),e}},{key:"hex",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return(t="string"==typeof t?e.ord(t):t).toString(16).padStart(r,"0")}},{key:"bin",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return(t="string"==typeof t?e.ord(t):t).toString(2).padStart(r,"0")}},{key:"printable",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"==typeof window&&window.app&&!window.app.options.treatAsUtf8&&(t=e.byteArrayToChars(e.strToByteArray(t)));return t=t.replace(/[\0-\x08\x0B-\x0C\x0E-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BFB-\u0C00\u0C04\u0C0D\u0C11\u0C29\u0C34\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5A-\u0C5F\u0C64\u0C65\u0C70-\u0C77\u0C80\u0C81\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0D01\u0D04\u0D0D\u0D11\u0D3B\u0D3C\u0D45\u0D49\u0D4F-\u0D56\u0D58-\u0D5F\u0D64\u0D65\u0D76-\u0D78\u0D80\u0D81\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DF1\u0DF5-\u0E00\u0E3B-\u0E3E\u0E5C-\u0E80\u0E83\u0E85\u0E86\u0E89\u0E8B\u0E8C\u0E8E-\u0E93\u0E98\u0EA0\u0EA4\u0EA6\u0EA8\u0EA9\u0EAC\u0EBA\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F48\u0F6D-\u0F70\u0F98\u0FBD\u0FCD\u0FDB-\u0FFF\u10C6\u10C8-\u10CC\u10CE\u10CF\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u137D-\u137F\u139A-\u139F\u13F5-\u13FF\u169D-\u169F\u16F1-\u16FF\u170D\u1715-\u171F\u1737-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17DE\u17DF\u17EA-\u17EF\u17FA-\u17FF\u180F\u181A-\u181F\u1878-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191D-\u191F\u192C-\u192F\u193C-\u193F\u1941-\u1943\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19DD\u1A1C\u1A1D\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1A9F\u1AAE-\u1AFF\u1B4C-\u1B4F\u1B7D-\u1B7F\u1BF4-\u1BFB\u1C38-\u1C3A\u1C4A-\u1C4C\u1C80-\u1CBF\u1CC8-\u1CCF\u1CF7-\u1CFF\u1DE7-\u1DFB\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FC5\u1FD4\u1FD5\u1FDC\u1FF0\u1FF1\u1FF5\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u206F\u2072\u2073\u208F\u209D-\u209F\u20BB-\u20CF\u20F1-\u20FF\u218A-\u218F\u23F4-\u23FF\u2427-\u243F\u244B-\u245F\u2700\u2B4D-\u2B4F\u2B5A-\u2BFF\u2C2F\u2C5F\u2CF4-\u2CF8\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D71-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E3C-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u2FFC-\u2FFF\u3040\u3097\u3098\u3100-\u3104\u312E-\u3130\u318F\u31BB-\u31BF\u31E4-\u31EF\u321F\u32FF\u4DB6-\u4DBF\u9FCD-\u9FFF\uA48D-\uA48F\uA4C7-\uA4CF\uA62C-\uA63F\uA698-\uA69E\uA6F8-\uA6FF\uA78F\uA794-\uA79F\uA7AB-\uA7F7\uA82C-\uA82F\uA83A-\uA83F\uA878-\uA87F\uA8C5-\uA8CD\uA8DA-\uA8DF\uA8FC-\uA8FF\uA954-\uA95E\uA97D-\uA97F\uA9CE\uA9DA-\uA9DD\uA9E0-\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A\uAA5B\uAA7C-\uAA7F\uAAC3-\uAADA\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F-\uABBF\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBC2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFE\uFDFF\uFE1A-\uFE1F\uFE27-\uFE2F\uFE53\uFE67\uFE6C-\uFE6F\uFE75\uFEFD-\uFF00\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]/g,"."),r||(t=t.replace(/[\x09-\x10\x0D\u2028\u2029]/g,".")),t}},{key:"parseEscapedChars",value:function(e){return e.replace(/(\\)?\\([bfnrtv0'"]|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]{1,6}\})/g,function(e,t,r){if("\\"===t)return"\\"+r;switch(r[0]){case"0":return"\0";case"b":return"\b";case"t":return"\t";case"n":return"\n";case"v":return"\v";case"f":return"\f";case"r":return"\r";case'"':return'"';case"'":return"'";case"x":return String.fromCharCode(parseInt(r.substr(1),16));case"u":return"{"===r[1]?String.fromCodePoint(parseInt(r.slice(2,-1),16)):String.fromCharCode(parseInt(r.substr(1),16))}})}},{key:"escapeRegex",value:function(e){return e.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}},{key:"expandAlphRange",value:function(t){for(var r=[],n=0;n<t.length;n++)if(n<t.length-2&&"-"===t[n+1]&&"\\"!==t[n]){for(var i=e.ord(t[n]),o=e.ord(t[n+2]),u=i;u<=o;u++)r.push(e.chr(u));n+=2}else n<t.length-2&&"\\"===t[n]&&"-"===t[n+1]?(r.push("-"),n++):r.push(t[n]);return r}},{key:"convertToByteArray",value:function(t,r){switch(r.toLowerCase()){case"binary":return Object(a.a)(t);case"hex":return Object(u.c)(t);case"decimal":return Object(s.a)(t);case"base64":return Object(o.b)(t,null,"byteArray");case"utf8":return e.strToUtf8ByteArray(t);case"latin1":default:return e.strToByteArray(t)}}},{key:"convertToByteString",value:function(t,r){switch(r.toLowerCase()){case"binary":return e.byteArrayToChars(Object(a.a)(t));case"hex":return e.byteArrayToChars(Object(u.c)(t));case"decimal":return e.byteArrayToChars(Object(s.a)(t));case"base64":return e.byteArrayToChars(Object(o.b)(t,null,"byteArray"));case"utf8":return i.a.encode(t);case"latin1":default:return t}}},{key:"strToByteArray",value:function(t){for(var r,n=new Array(t.length),i=t.length;i--;)if(r=t.charCodeAt(i),n[i]=r,r>255)return e.strToUtf8ByteArray(t);return n}},{key:"strToUtf8ByteArray",value:function(t){var r=i.a.encode(t);return t.length!==r.length&&("function"==typeof importScripts?self.setOption("attemptHighlight",!1):"object"==typeof window&&(window.app.options.attemptHighlight=!1)),e.strToByteArray(r)}},{key:"strToCharcode",value:function(t){for(var r=[],n=0;n<t.length;n++){var i=t.charCodeAt(n);if(n<t.length-1&&i>=55296&&i<56320){var o=t[n+1].charCodeAt(0);o>=56320&&o<57344&&(i=e.ord(t[n]+t[++n]))}r.push(i)}return r}},{key:"byteArrayToUtf8",value:function(t){var r=e.byteArrayToChars(t);try{var n=i.a.decode(r);return r.length!==n.length&&("function"==typeof importScripts?self.setOption("attemptHighlight",!1):"object"==typeof window&&(window.app.options.attemptHighlight=!1)),n}catch(e){return r}}},{key:"byteArrayToChars",value:function(e){if(!e)return"";for(var t="",r=0;r<e.length;)t+=String.fromCharCode(e[r++]);return t}},{key:"arrayBufferToStr",value:function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Array.prototype.slice.call(new Uint8Array(t));return r?e.byteArrayToUtf8(n):e.byteArrayToChars(n)}},{key:"parseCSV",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[","],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:["\n","\r"],o=!1,u=!1,s="",a=[],f=[];e.length&&"\ufeff"===e[0]&&(e=e.substr(1));for(var l=0;l<e.length;l++)t=e[l],r=e[l+1]||"",o?(s+=t,o=!1):'"'!==t||u?'"'===t&&u?'"'===r?o=!0:u=!1:!u&&n.indexOf(t)>=0?(a.push(s),s=""):!u&&i.indexOf(t)>=0?(a.push(s),s="",f.push(a),a=[],i.indexOf(r)>=0&&r!==t&&l++):s+=t:u=!0;return a.length&&(a.push(s),f.push(a)),f}},{key:"stripHtmlTags",value:function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&(e=e.replace(/<(script|style)[^>]*>.*<\/(script|style)>/gim,"")),e.replace(/<[^>]+>/g,"")}},{key:"escapeHtml",value:function(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`"};return e.replace(/[&<>"'\/`]/g,function(e){return t[e]})}},{key:"unescapeHtml",value:function(e){var t={"&":"&","<":"<",">":">",""":'"',"'":"'","/":"/","`":"`"};return e.replace(/&#?x?[a-z0-9]{2,4};/gi,function(e){return t[e]||e})}},{key:"encodeURIFragment",value:function(e){var t={"%2D":"-","%2E":".","%5F":"_","%7E":"~","%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2C":",","%3B":";","%3A":":","%40":"@","%2F":"/","%3F":"?"};return(e=encodeURIComponent(e)).replace(/%[0-9A-F]{2}/g,function(e){return t[e]||e})}},{key:"generatePrettyRecipe",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="",n="",i="",o="",u="";return e.forEach(function(e){n=e.op.replace(/ /g,"_"),i=JSON.stringify(e.args).slice(1,-1).replace(/'/g,"\\'").replace(/"((?:[^"\\]|\\.)*)"/g,"'$1'").replace(/\\"/g,'"'),o=e.disabled?"/disabled":"",u=e.breakpoint?"/breakpoint":"",r+="".concat(n,"(").concat(i).concat(o).concat(u,")"),t&&(r+="\n")}),r}},{key:"parseRecipeConfig",value:function(e){if(0===(e=e.trim()).length)return[];if("["===e[0])return JSON.parse(e);var t,r;e=e.replace(/\n/g,"");for(var n=/([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)\/'])*)(\/[^)]+)?\)/g,i=[];t=n.exec(e);){r="["+(r=t[2].replace(/"/g,'\\"').replace(/(^|,|{|:)'/g,'$1"').replace(/([^\\]|[^\\]\\\\)'(,|:|}|$)/g,'$1"$2').replace(/\\'/g,"'"))+"]";var o={op:t[1].replace(/_/g," "),args:JSON.parse(r)};t[3]&&t[3].indexOf("disabled")>0&&(o.disabled=!0),t[3]&&t[3].indexOf("breakpoint")>0&&(o.breakpoint=!0),i.push(o)}return i}},{key:"displayFilesAsHTML",value:function(){var t=l(regeneratorRuntime.mark(function t(r){var n,i,u,s,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=function(t){return"<div class='card' style='white-space: normal;'>\n <div class='card-header'>\n <h6 class=\"mb-0\">\n ".concat(e.escapeHtml(t.name),"\n </h6>\n </div>\n </div>")},i=function(t,r){if(r.startsWith("image")){var n="data:";return n+=r+";","<img style='max-width: 100%;' src='"+(n+="base64,"+Object(o.c)(t))+"'>"}return"<pre>".concat(e.escapeHtml(e.arrayBufferToStr(t.buffer)),"</pre>")},u=function(){var t=l(regeneratorRuntime.mark(function t(r,n){var o,u,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.readFile(r);case 2:return o=t.sent,u=new Blob([o],{type:"octet/stream"}),s="<div class='card' style='white-space: normal;'>\n <div class='card-header' id='heading".concat(n,"'>\n <h6 class='mb-0'>\n <a class='collapsed'\n data-toggle='collapse'\n href='#collapse").concat(n,"'\n aria-expanded='false'\n aria-controls='collapse").concat(n,"'\n title=\"Show/hide contents of '").concat(e.escapeHtml(r.name),"'\">\n ").concat(e.escapeHtml(r.name),"</a>\n <span class='float-right' style=\"margin-top: -3px\">\n ").concat(r.size.toLocaleString(),' bytes\n <a title="Download ').concat(e.escapeHtml(r.name),"\"\n href='").concat(URL.createObjectURL(u),"'\n download='").concat(e.escapeHtml(r.name),'\'>\n <i class="material-icons" style="vertical-align: bottom">save</i>\n </a>\n </span>\n </h6>\n </div>\n <div id=\'collapse').concat(n,"' class='collapse' aria-labelledby='heading").concat(n,"' data-parent=\"#files\">\n <div class='card-body'>\n ").concat(i(o,r.type),"\n </div>\n </div>\n </div>"),t.abrupt("return",s);case 6:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}(),s="<div style='padding: 5px; white-space: normal;'>\n ".concat(r.length,' file(s) found\n </div><div id="files" style="padding: 20px">'),a=0;case 5:if(!(a<r.length)){t.next=17;break}if(!r[a].name.endsWith("/")){t.next=10;break}s+=n(r[a]),t.next=14;break;case 10:return t.t0=s,t.next=13,u(r[a],a);case 13:s=t.t0+=t.sent;case 14:a++,t.next=5;break;case 17:return t.abrupt("return",s+="</div>");case 18:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"parseURIParams",value:function(e){if(""===e)return{};"?"!==e[0]&&"#"!==e[0]||(e=e.substr(1));for(var t=e.split("&"),r={},n=0;n<t.length;n++){var i=t[n].split("=");2!==i.length?r[t[n]]=!0:r[i[0]]=decodeURIComponent(i[1].replace(/\+/g," "))}return r}},{key:"readFile",value:function(e){return new Promise(function(t,r){var n=new FileReader,i=new Uint8Array(e.size),o=0,u=function(){if(o>=e.size)t(i);else{var r=e.slice(o,o+10485760);n.readAsArrayBuffer(r)}};n.onload=function(e){i.set(new Uint8Array(n.result),o),o+=10485760,u()},n.onerror=function(e){r(n.error.message)},u()})}},{key:"mod",value:function(e,t){return(e%t+t)%t}},{key:"gcd",value:function(t,r){return r?e.gcd(r,t%r):t}},{key:"modInv",value:function(e,t){e%=t;for(var r=1;r<t;r++)if(e*r%26==1)return r}},{key:"charRep",value:function(e){return{Space:" ",Comma:",","Semi-colon":";",Colon:":","Line feed":"\n",CRLF:"\r\n","Forward slash":"/",Backslash:"\\","0x":"0x","\\x":"\\x","Nothing (separate chars)":"",None:""}[e]}},{key:"regexRep",value:function(e){return{Space:/\s+/g,Comma:/,/g,"Semi-colon":/;/g,Colon:/:/g,"Line feed":/\n/g,CRLF:/\r\n/g,"Forward slash":/\//g,Backslash:/\\/g,"0x":/0x/g,"\\x":/\\x/g,None:/\s+/g}[e]}}],r&&c(t.prototype,r),n&&c(t,n),e}();t.a=h,Array.prototype.unique=function(){for(var e={},t=[],r=0,n=this.length;r<n;r++)e.hasOwnProperty(this[r])||(t.push(this[r]),e[this[r]]=1);return t},Array.prototype.max=function(){return Math.max.apply(null,this)},Array.prototype.min=function(){return Math.min.apply(null,this)},Array.prototype.sum=function(){return this.reduce(function(e,t){return e+t},0)},Array.prototype.equals=function(e){if(!e)return!1;var t=this.length;if(t!==e.length)return!1;for(;t--;)if(this[t]!==e[t])return!1;return!0},String.prototype.count=function(e){return this.split(e).length-1},String.prototype.padStart||(String.prototype.padStart=function(e,t){return e>>=0,t=String(void 0!==t?t:" "),this.length>e?String(this):((e-=this.length)>t.length&&(t+=t.repeat(e/t.length)),t.slice(0,e)+String(this))}),String.prototype.padEnd||(String.prototype.padEnd=function(e,t){return e>>=0,t=String(void 0!==t?t:" "),this.length>e?String(this):((e-=this.length)>t.length&&(t+=t.repeat(e/t.length)),String(this)+t.slice(0,e))})},1:function(e,t,r){"use strict";var n=r(9),i=r(0),o=r(7);function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}
|
||
/**
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*/
|
||
var s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="",this.type="",this._value=null,this.disabled=!1,this.hint="",this.rows=0,this.toggleValues=[],this.target=null,this.defaultIndex=0,t&&this._parseConfig(t)}var t,r,n;return t=e,n=[{key:"prepare",value:function(e,t){var r;switch(t){case"binaryString":case"binaryShortString":case"editableOption":case"editableOptionShort":return i.a.parseEscapedChars(e);case"byteArray":return"string"==typeof e?(e=e.replace(/\s+/g,""),Object(o.c)(e)):e;case"number":if(r=parseFloat(e),isNaN(r))throw"Invalid ingredient value. Not a number: "+i.a.truncate(e.toString(),10);return r;default:return e}}}],(r=[{key:"_parseConfig",value:function(e){this.name=e.name,this.type=e.type,this.defaultValue=e.value,this.disabled=!!e.disabled,this.hint=e.hint||!1,this.rows=e.rows||!1,this.toggleValues=e.toggleValues,this.target=void 0!==e.target?e.target:null,this.defaultIndex=void 0!==e.defaultIndex?e.defaultIndex:0}},{key:"config",get:function(){return this._value}},{key:"value",set:function(t){this._value=e.prepare(t,this.type)},get:function(){return this._value}}])&&u(t.prototype,r),n&&u(t,n),e}();function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}
|
||
/**
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*/
|
||
var f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._inputType=-1,this._outputType=-1,this._presentType=-1,this._breakpoint=!1,this._disabled=!1,this._flowControl=!1,this._manualBake=!1,this._ingList=[],this.name="",this.module="",this.description="",this.infoURL=null}var t,r,i;return t=e,(r=[{key:"run",value:function(e,t){return e}},{key:"highlight",value:function(e,t){return!1}},{key:"highlightReverse",value:function(e,t){return!1}},{key:"present",value:function(e,t){return e}},{key:"addIngredient",value:function(e){this._ingList.push(e)}},{key:"inputType",set:function(e){this._inputType=n.a.typeEnum(e)},get:function(){return n.a.enumLookup(this._inputType)}},{key:"outputType",set:function(e){this._outputType=n.a.typeEnum(e),this._presentType<0&&(this._presentType=this._outputType)},get:function(){return n.a.enumLookup(this._outputType)}},{key:"presentType",set:function(e){this._presentType=n.a.typeEnum(e)},get:function(){return n.a.enumLookup(this._presentType)}},{key:"args",set:function(e){var t=this;e.forEach(function(e){var r=new s(e);t.addIngredient(r)})},get:function(){return this._ingList.map(function(e){var t={name:e.name,type:e.type,value:e.defaultValue};return e.toggleValues&&(t.toggleValues=e.toggleValues),e.hint&&(t.hint=e.hint),e.rows&&(t.rows=e.rows),e.disabled&&(t.disabled=e.disabled),e.target&&(t.target=e.target),e.defaultIndex&&(t.defaultIndex=e.defaultIndex),t})}},{key:"config",get:function(){return{op:this.name,args:this._ingList.map(function(e){return e.config})}}},{key:"ingValues",set:function(e){var t=this;e.forEach(function(e,r){t._ingList[r].value=e})},get:function(){return this._ingList.map(function(e){return e.value})}},{key:"breakpoint",set:function(e){this._breakpoint=!!e},get:function(){return this._breakpoint}},{key:"disabled",set:function(e){this._disabled=!!e},get:function(){return this._disabled}},{key:"flowControl",get:function(){return this._flowControl},set:function(e){this._flowControl=!!e}},{key:"manualBake",get:function(){return this._manualBake},set:function(e){this._manualBake=!!e}}])&&a(t.prototype,r),i&&a(t,i),e}();t.a=f},10:function(e,t,r){"use strict";r.d(t,"c",function(){return i}),r.d(t,"b",function(){return o}),r.d(t,"a",function(){return u});var n=r(0);
|
||
/**
|
||
* Base64 functions.
|
||
*
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*/function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"A-Za-z0-9+/=";if(!e)return"";"string"==typeof e&&(e=n.a.strToByteArray(e)),t=n.a.expandAlphRange(t).join("");for(var r,i,o,u,s,a,f,l="",c=0;c<e.length;)u=(r=e[c++])>>2,s=(3&r)<<4|(i=e[c++])>>4,a=(15&i)<<2|(o=e[c++])>>6,f=63&o,isNaN(i)?a=f=64:isNaN(o)&&(f=64),l+=t.charAt(u)+t.charAt(s)+t.charAt(a)+t.charAt(f);return l}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"A-Za-z0-9+/=",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"string",i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!e)return"string"===r?"":[];t=t||"A-Za-z0-9+/=",t=n.a.expandAlphRange(t).join("");var o,u,s,a,f,l,c=[],h=0;if(i){var p=new RegExp("[^"+t.replace(/[[\]\\\-^$]/g,"\\$&")+"]","g");e=e.replace(p,"")}for(;h<e.length;)o=t.indexOf(e.charAt(h++))<<2|(a=-1===(a=t.indexOf(e.charAt(h++)||"="))?64:a)>>4,u=(15&a)<<4|(f=-1===(f=t.indexOf(e.charAt(h++)||"="))?64:f)>>2,s=(3&f)<<6|(l=-1===(l=t.indexOf(e.charAt(h++)||"="))?64:l),c.push(o),64!==f&&c.push(u),64!==l&&c.push(s);return"string"===r?n.a.byteArrayToUtf8(c):c}var u=[{name:"Standard (RFC 4648): A-Za-z0-9+/=",value:"A-Za-z0-9+/="},{name:"URL safe (RFC 4648 §5): A-Za-z0-9-_",value:"A-Za-z0-9-_"},{name:"Filename safe: A-Za-z0-9+-=",value:"A-Za-z0-9+\\-="},{name:"itoa64: ./0-9A-Za-z=",value:"./0-9A-Za-z="},{name:"XML: A-Za-z0-9_.",value:"A-Za-z0-9_."},{name:"y64: A-Za-z0-9._-",value:"A-Za-z0-9._-"},{name:"z64: 0-9a-zA-Z+/=",value:"0-9a-zA-Z+/="},{name:"Radix-64 (RFC 4880): 0-9A-Za-z+/=",value:"0-9A-Za-z+/="},{name:"Uuencoding: [space]-_",value:" -_"},{name:"Xxencoding: +-0-9A-Za-z",value:"+\\-0-9A-Za-z"},{name:"BinHex: !-,-0-689@A-NP-VX-Z[`a-fh-mp-r",value:"!-,-0-689@A-NP-VX-Z[`a-fh-mp-r"},{name:"ROT13: N-ZA-Mn-za-m0-9+/=",value:"N-ZA-Mn-za-m0-9+/="},{name:"UNIX crypt: ./0-9A-Za-z",value:"./0-9A-Za-z"}]},1070:function(e,t){e.exports=n;var r=null;try{r=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function n(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function i(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=i;var o={},u={};function s(e,t){var r,n,i;return t?(i=0<=(e>>>=0)&&e<256)&&(n=u[e])?n:(r=f(e,(0|e)<0?-1:0,!0),i&&(u[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(n=o[e])?n:(r=f(e,e<0?-1:0,!1),i&&(o[e]=r),r)}function a(e,t){if(isNaN(e))return t?_:b;if(t){if(e<0)return _;if(e>=g)return E}else{if(e<=-y)return N;if(e+1>=y)return B}return e<0?a(-e,t).neg():f(e%p|0,e/p|0,t)}function f(e,t,r){return new n(e,t,r)}n.fromInt=s,n.fromNumber=a,n.fromBits=f;var l=Math.pow;function c(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return b;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return c(e.substring(1),t,r).neg();for(var i=a(l(r,8)),o=b,u=0;u<e.length;u+=8){var s=Math.min(8,e.length-u),f=parseInt(e.substring(u,u+s),r);if(s<8){var h=a(l(r,s));o=o.mul(h).add(a(f))}else o=(o=o.mul(i)).add(a(f))}return o.unsigned=t,o}function h(e,t){return"number"==typeof e?a(e,t):"string"==typeof e?c(e,t):f(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}n.fromString=c,n.fromValue=h;var p=4294967296,g=p*p,y=g/2,d=s(1<<24),b=s(0);n.ZERO=b;var _=s(0,!0);n.UZERO=_;var v=s(1);n.ONE=v;var A=s(1,!0);n.UONE=A;var m=s(-1);n.NEG_ONE=m;var B=f(-1,2147483647,!1);n.MAX_VALUE=B;var E=f(-1,-1,!0);n.MAX_UNSIGNED_VALUE=E;var N=f(0,-2147483648,!1);n.MIN_VALUE=N;var S=n.prototype;S.toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*p+(this.low>>>0):this.high*p+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(N)){var t=a(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(l(e,6),this.unsigned),o=this,u="";;){var s=o.div(i),f=(o.sub(s.mul(i)).toInt()>>>0).toString(e);if((o=s).isZero())return f+u;for(;f.length<6;)f="0"+f;u=""+f+u}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(N)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},S.isZero=function(){return 0===this.high&&0===this.low},S.eqz=S.isZero,S.isNegative=function(){return!this.unsigned&&this.high<0},S.isPositive=function(){return this.unsigned||this.high>=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(e){return i(e)||(e=h(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},S.eq=S.equals,S.notEquals=function(e){return!this.eq(e)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(e){return this.comp(e)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(e){return this.comp(e)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(e){return this.comp(e)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(e){return this.comp(e)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(e){if(i(e)||(e=h(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(N)?N:this.not().add(v)},S.neg=S.negate,S.add=function(e){i(e)||(e=h(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,u=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,p=0,g=0;return p+=(g+=o+(65535&e.low))>>>16,c+=(p+=n+a)>>>16,l+=(c+=r+s)>>>16,l+=t+u,f((p&=65535)<<16|(g&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},S.subtract=function(e){return i(e)||(e=h(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return b;if(i(e)||(e=h(e)),r)return f(r.mul(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned);if(e.isZero())return b;if(this.eq(N))return e.isOdd()?N:b;if(e.eq(N))return this.isOdd()?N:b;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(d)&&e.lt(d))return a(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,o=this.low>>>16,u=65535&this.low,s=e.high>>>16,l=65535&e.high,c=e.low>>>16,p=65535&e.low,g=0,y=0,_=0,v=0;return _+=(v+=u*p)>>>16,y+=(_+=o*p)>>>16,_&=65535,y+=(_+=u*c)>>>16,g+=(y+=n*p)>>>16,y&=65535,g+=(y+=o*c)>>>16,y&=65535,g+=(y+=u*l)>>>16,g+=t*p+n*c+o*l+u*s,f((_&=65535)<<16|(v&=65535),(g&=65535)<<16|(y&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(i(e)||(e=h(e)),e.isZero())throw Error("division by zero");var t,n,o;if(r)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?f((this.unsigned?r.div_u:r.div_s)(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?_:b;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return _;if(e.gt(this.shru(1)))return A;o=_}else{if(this.eq(N))return e.eq(v)||e.eq(m)?N:e.eq(N)?v:(t=this.shr(1).div(e).shl(1)).eq(b)?e.isNegative()?v:m:(n=this.sub(e.mul(t)),o=t.add(n.div(e)));if(e.eq(N))return this.unsigned?_:b;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=b}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var u=Math.ceil(Math.log(t)/Math.LN2),s=u<=48?1:l(2,u-48),c=a(t),p=c.mul(e);p.isNegative()||p.gt(n);)p=(c=a(t-=s,this.unsigned)).mul(e);c.isZero()&&(c=v),o=o.add(c),n=n.sub(p)}return o},S.div=S.divide,S.modulo=function(e){return i(e)||(e=h(e)),r?f((this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,e.low,e.high),r.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return f(~this.low,~this.high,this.unsigned)},S.and=function(e){return i(e)||(e=h(e)),f(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return i(e)||(e=h(e)),f(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return i(e)||(e=h(e)),f(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?f(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):f(0,this.low<<e-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?f(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):f(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(i(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?f(this.low>>>e|t<<32-e,t>>>e,this.unsigned):f(32===e?t:t>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},12:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}
|
||
/**
|
||
* Custom error type for handling Dish type errors.
|
||
* i.e. where the Dish cannot be successfully translated between types
|
||
*
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2018
|
||
* @license Apache-2.0
|
||
*/var a=function(e){function t(){var e,r,o,s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var a=arguments.length,f=new Array(a),l=0;l<a;l++)f[l]=arguments[l];return o=this,(r=!(s=(e=i(t)).call.apply(e,[this].concat(f)))||"object"!==n(s)&&"function"!=typeof s?u(o):s).type="DishError",Error.captureStackTrace&&Error.captureStackTrace(u(u(r)),t),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(t,s(Error)),t}();t.a=a},14:function(e,t,r){var n,i;!function(o,u){"use strict";void 0===(i="function"==typeof(n=function(){var e=function(){},t="undefined",r=["trace","debug","info","warn","error"];function n(e,t){var r=e[t];if("function"==typeof r.bind)return r.bind(e);try{return Function.prototype.bind.call(r,e)}catch(t){return function(){return Function.prototype.apply.apply(r,[e,arguments])}}}function i(t,n){for(var i=0;i<r.length;i++){var o=r[i];this[o]=i<t?e:this.methodFactory(o,t,n)}this.log=this.debug}function o(r,o,u){return function(r){"debug"===r&&(r="log");return typeof console!==t&&(void 0!==console[r]?n(console,r):void 0!==console.log?n(console,"log"):e)}(r)||function(e,r,n){return function(){typeof console!==t&&(i.call(this,r,n),this[e].apply(this,arguments))}}.apply(this,arguments)}function u(e,n,u){var s,a=this,f="loglevel";function l(){var e;if(typeof window!==t){try{e=window.localStorage[f]}catch(e){}if(typeof e===t)try{var r=window.document.cookie,n=r.indexOf(encodeURIComponent(f)+"=");-1!==n&&(e=/^([^;]+)/.exec(r.slice(n))[1])}catch(e){}return void 0===a.levels[e]&&(e=void 0),e}}e&&(f+=":"+e),a.name=e,a.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},a.methodFactory=u||o,a.getLevel=function(){return s},a.setLevel=function(n,o){if("string"==typeof n&&void 0!==a.levels[n.toUpperCase()]&&(n=a.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=a.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(s=n,!1!==o&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window===t)return;try{return void(window.localStorage[f]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"="+n+";"}catch(e){}}(n),i.call(a,n,e),typeof console===t&&n<a.levels.SILENT)return"No console available for logging"},a.setDefaultLevel=function(e){l()||a.setLevel(e,!1)},a.enableAll=function(e){a.setLevel(a.levels.TRACE,e)},a.disableAll=function(e){a.setLevel(a.levels.SILENT,e)};var c=l();null==c&&(c=null==n?"WARN":n),a.setLevel(c,!1)}var s=new u,a={};s.getLogger=function(e){if("string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=a[e];return t||(t=a[e]=new u(e,s.getLevel(),s.methodFactory)),t};var f=typeof window!==t?window.log:void 0;return s.noConflict=function(){return typeof window!==t&&window.log===s&&(window.log=f),s},s.getLoggers=function(){return a},s})?n.call(t,r,t,e):n)||(e.exports=i)}()},15:function(e,t,r){!function(e){var t,r,n,i=String.fromCharCode;function o(e){for(var t,r,n=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(r=e.charCodeAt(i++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),i--):n.push(t);return n}function u(e){if(e>=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function s(e,t){return i(e>>t&63|128)}function a(e){if(0==(4294967168&e))return i(e);var t="";return 0==(4294965248&e)?t=i(e>>6&31|192):0==(4294901760&e)?(u(e),t=i(e>>12&15|224),t+=s(e,6)):0==(4292870144&e)&&(t=i(e>>18&7|240),t+=s(e,12),t+=s(e,6)),t+=i(63&e|128)}function f(){if(n>=r)throw Error("Invalid byte index");var e=255&t[n];if(n++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function l(){var e,i;if(n>r)throw Error("Invalid byte index");if(n==r)return!1;if(e=255&t[n],n++,0==(128&e))return e;if(192==(224&e)){if((i=(31&e)<<6|f())>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&e)){if((i=(15&e)<<12|f()<<6|f())>=2048)return u(i),i;throw Error("Invalid continuation byte")}if(240==(248&e)&&(i=(7&e)<<18|f()<<12|f()<<6|f())>=65536&&i<=1114111)return i;throw Error("Invalid UTF-8 detected")}e.version="3.0.0",e.encode=function(e){for(var t=o(e),r=t.length,n=-1,i="";++n<r;)i+=a(t[n]);return i},e.decode=function(e){t=o(e),r=t.length,n=0;for(var u,s=[];!1!==(u=l());)s.push(u);return function(e){for(var t,r=e.length,n=-1,o="";++n<r;)(t=e[n])>65535&&(o+=i((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=i(t);return o}(s)}}(t)},1512:function(e,t,r){"use strict";r.r(t);var n=r(775),i=r(1),o=r(518),u=r.n(o),s=r(3);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}
|
||
/**
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2018
|
||
* @license Apache-2.0
|
||
*/var p=function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=l(this,c(t).call(this))).name="BSON serialise",e.module="BSON",e.description="BSON is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database. It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB. The name 'BSON' is based on the term JSON and stands for 'Binary JSON'.<br><br>Input data should be valid JSON.",e.infoURL="https://wikipedia.org/wiki/BSON",e.inputType="string",e.outputType="ArrayBuffer",e.args=[],e}var r,n,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(t,i["a"]),r=t,(n=[{key:"run",value:function(e,t){if(!e)return new ArrayBuffer;try{var r=JSON.parse(e);return u.a.serialize(r).buffer}catch(e){throw new s.a(e.toString())}}}])&&f(r.prototype,n),o&&f(r,o),t}(),g="undefined"==typeof self?{}:self.OpModules||{};g.BSON={"BSON deserialise":n.a,"BSON serialise":p};t.default=g},17:function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},18:function(e,t,r){"use strict";r.d(t,"b",function(){return i}),r.d(t,"a",function(){return o});var n=r(0);
|
||
/**
|
||
* Binary functions.
|
||
*
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2018
|
||
* @license Apache-2.0
|
||
*/function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Space",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8;if(!e)return"";t=n.a.charRep(t);for(var i="",o=0;o<e.length;o++)i+=e[o].toString(2).padStart(r,"0")+t;return t.length?i.slice(0,-t.length):i}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Space",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,i=n.a.regexRep(t);e=e.replace(i,"");for(var o=[],u=0;u<e.length;u+=r)o.push(parseInt(e.substr(u,r),2));return o}},19:function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(0);
|
||
/**
|
||
* Decimal functions.
|
||
*
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2018
|
||
* @license Apache-2.0
|
||
*/function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Auto";t=n.a.charRep(t);var r=[],i=e.split(t);""===i[i.length-1]&&(i=i.slice(0,i.length-1));for(var o=0;o<i.length;o++)r[o]=parseInt(i[o],10);return r}},3:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}
|
||
/**
|
||
* Custom error type for handling operation input errors.
|
||
* i.e. where the operation can handle the error and print a message to the screen.
|
||
*
|
||
* @author d98762625 [d98762625@gmail.com]
|
||
* @copyright Crown Copyright 2018
|
||
* @license Apache-2.0
|
||
*/var a=function(e){function t(){var e,r,o,s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var a=arguments.length,f=new Array(a),l=0;l<a;l++)f[l]=arguments[l];return o=this,(r=!(s=(e=i(t)).call.apply(e,[this].concat(f)))||"object"!==n(s)&&"function"!=typeof s?u(o):s).type="OperationError",Error.captureStackTrace&&Error.captureStackTrace(u(u(r)),t),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(t,s(Error)),t}();t.a=a},4:function(e,t,r){var n;!function(i){"use strict";var o,u=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,a=Math.floor,f="[BigNumber Error] ",l=f+"Number primitive has more than 15 significant digits: ",c=1e14,h=14,p=9007199254740991,g=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],y=1e7,d=1e9;function b(e){var t=0|e;return e>0||e===t?t:t-1}function _(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=h-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function v(e,t){var r,n,i=e.c,o=t.c,u=e.s,s=t.s,a=e.e,f=t.e;if(!u||!s)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-s:u;if(u!=s)return u;if(r=u<0,n=a==f,!i||!o)return n?0:!i^r?1:-1;if(!n)return a>f^r?1:-1;for(s=(a=i.length)<(f=o.length)?a:f,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^r?1:-1;return a==f?0:a>f^r?1:-1}function A(e,t,r,n){if(e<t||e>r||e!==(e<0?s(e):a(e)))throw Error(f+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function m(e){var t=e.c.length-1;return b(e.e/h)==t&&e.c[t]%2!=0}function B(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function E(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}(o=function e(t){var r,n,i,o,N,S,w,O,T,D=$.prototype={constructor:$,toString:null,valueOf:null},I=new $(1),F=20,R=4,x=-7,C=21,U=-1e7,M=1e7,k=!1,P=1,L=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},z="0123456789abcdefghijklmnopqrstuvwxyz";function $(e,t){var r,o,s,f,c,g,y,d,b=this;if(!(b instanceof $))return new $(e,t);if(null==t){if(e instanceof $)return b.s=e.s,b.e=e.e,void(b.c=(e=e.c)?e.slice():e);if((g="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,c=e;c>=10;c/=10,f++);return b.e=f,void(b.c=[e])}d=String(e)}else{if(d=String(e),!u.test(d))return i(b,d,g);b.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(f=d.indexOf("."))>-1&&(d=d.replace(".","")),(c=d.search(/e/i))>0?(f<0&&(f=c),f+=+d.slice(c+1),d=d.substring(0,c)):f<0&&(f=d.length)}else{if(A(t,2,z.length,"Base"),d=String(e),10==t)return G(b=new $(e instanceof $?e:d),F+b.e+1,R);if(g="number"==typeof e){if(0*e!=0)return i(b,d,g,t);if(b.s=1/e<0?(d=d.slice(1),-1):1,$.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(l+e);g=!1}else b.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(r=z.slice(0,t),f=c=0,y=d.length;c<y;c++)if(r.indexOf(o=d.charAt(c))<0){if("."==o){if(c>f){f=y;continue}}else if(!s&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){s=!0,c=-1,f=0;continue}return i(b,String(e),g,t)}(f=(d=n(d,t,10,b.s)).indexOf("."))>-1?d=d.replace(".",""):f=d.length}for(c=0;48===d.charCodeAt(c);c++);for(y=d.length;48===d.charCodeAt(--y););if(d=d.slice(c,++y)){if(y-=c,g&&$.DEBUG&&y>15&&(e>p||e!==a(e)))throw Error(l+b.s*e);if((f=f-c-1)>M)b.c=b.e=null;else if(f<U)b.c=[b.e=0];else{if(b.e=f,b.c=[],c=(f+1)%h,f<0&&(c+=h),c<y){for(c&&b.c.push(+d.slice(0,c)),y-=h;c<y;)b.c.push(+d.slice(c,c+=h));d=d.slice(c),c=h-d.length}else c-=y;for(;c--;d+="0");b.c.push(+d)}}else b.c=[b.e=0]}function Y(e,t,r,n){var i,o,u,s,a;if(null==r?r=R:A(r,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==t)a=_(e.c),a=1==n||2==n&&(u<=x||u>=C)?B(a,u):E(a,u,"0");else if(o=(e=G(new $(e),t,r)).e,s=(a=_(e.c)).length,1==n||2==n&&(t<=o||o<=x)){for(;s<t;a+="0",s++);a=B(a,o)}else if(t-=u,a=E(a,o,"0"),o+1>s){if(--t>0)for(a+=".";t--;a+="0");}else if((t+=o-s)>0)for(o+1==s&&(a+=".");t--;a+="0");return e.s<0&&i?"-"+a:a}function J(e,t){for(var r,n=1,i=new $(e[0]);n<e.length;n++){if(!(r=new $(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function X(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+r*h-1)>M?e.c=e.e=null:r<U?e.c=[e.e=0]:(e.e=r,e.c=t),e}function G(e,t,r,n){var i,o,u,f,l,p,y,d=e.c,b=g;if(d){e:{for(i=1,f=d[0];f>=10;f/=10,i++);if((o=t-i)<0)o+=h,u=t,y=(l=d[p=0])/b[i-u-1]%10|0;else if((p=s((o+1)/h))>=d.length){if(!n)break e;for(;d.length<=p;d.push(0));l=y=0,i=1,u=(o%=h)-h+1}else{for(l=f=d[p],i=1;f>=10;f/=10,i++);y=(u=(o%=h)-h+i)<0?0:l/b[i-u-1]%10|0}if(n=n||t<0||null!=d[p+1]||(u<0?l:l%b[i-u-1]),n=r<4?(y||n)&&(0==r||r==(e.s<0?3:2)):y>5||5==y&&(4==r||n||6==r&&(o>0?u>0?l/b[i-u]:0:d[p-1])%10&1||r==(e.s<0?8:7)),t<1||!d[0])return d.length=0,n?(t-=e.e+1,d[0]=b[(h-t%h)%h],e.e=-t||0):d[0]=e.e=0,e;if(0==o?(d.length=p,f=1,p--):(d.length=p+1,f=b[h-o],d[p]=u>0?a(l/b[i-u]%b[u])*f:0),n)for(;;){if(0==p){for(o=1,u=d[0];u>=10;u/=10,o++);for(u=d[0]+=f,f=1;u>=10;u/=10,f++);o!=f&&(e.e++,d[0]==c&&(d[0]=1));break}if(d[p]+=f,d[p]!=c)break;d[p--]=0,f=1}for(o=d.length;0===d[--o];d.pop());}e.e>M?e.c=e.e=null:e.e<U&&(e.c=[e.e=0])}return e}function H(e){var t,r=e.e;return null===r?e.toString():(t=_(e.c),t=r<=x||r>=C?B(t,r):E(t,r,"0"),e.s<0?"-"+t:t)}return $.clone=e,$.ROUND_UP=0,$.ROUND_DOWN=1,$.ROUND_CEIL=2,$.ROUND_FLOOR=3,$.ROUND_HALF_UP=4,$.ROUND_HALF_DOWN=5,$.ROUND_HALF_EVEN=6,$.ROUND_HALF_CEIL=7,$.ROUND_HALF_FLOOR=8,$.EUCLID=9,$.config=$.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(f+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(A(r=e[t],0,d,t),F=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(A(r=e[t],0,8,t),R=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(A(r[0],-d,0,t),A(r[1],0,d,t),x=r[0],C=r[1]):(A(r,-d,d,t),x=-(C=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)A(r[0],-d,-1,t),A(r[1],1,d,t),U=r[0],M=r[1];else{if(A(r,-d,d,t),!r)throw Error(f+t+" cannot be zero: "+r);U=-(M=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(f+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw k=!r,Error(f+"crypto unavailable");k=r}else k=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(A(r=e[t],0,9,t),P=r),e.hasOwnProperty(t="POW_PRECISION")&&(A(r=e[t],0,d,t),L=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(f+t+" not an object: "+r);j=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(f+t+" invalid: "+r);z=r}}return{DECIMAL_PLACES:F,ROUNDING_MODE:R,EXPONENTIAL_AT:[x,C],RANGE:[U,M],CRYPTO:k,MODULO_MODE:P,POW_PRECISION:L,FORMAT:j,ALPHABET:z}},$.isBigNumber=function(e){return e instanceof $||e&&!0===e._isBigNumber||!1},$.maximum=$.max=function(){return J(arguments,D.lt)},$.minimum=$.min=function(){return J(arguments,D.gt)},$.random=(o=9007199254740992*Math.random()&2097151?function(){return a(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,u,l=0,c=[],p=new $(I);if(null==e?e=F:A(e,0,d),i=s(e/h),k)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));l<i;)(u=131072*t[l]+(t[l+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[l]=r[0],t[l+1]=r[1]):(c.push(u%1e14),l+=2);l=i/2}else{if(!crypto.randomBytes)throw k=!1,Error(f+"crypto unavailable");for(t=crypto.randomBytes(i*=7);l<i;)(u=281474976710656*(31&t[l])+1099511627776*t[l+1]+4294967296*t[l+2]+16777216*t[l+3]+(t[l+4]<<16)+(t[l+5]<<8)+t[l+6])>=9e15?crypto.randomBytes(7).copy(t,l):(c.push(u%1e14),l+=7);l=i/7}if(!k)for(;l<i;)(u=o())<9e15&&(c[l++]=u%1e14);for(i=c[--l],e%=h,i&&e&&(u=g[h-e],c[l]=a(i/u)*u);0===c[l];c.pop(),l--);if(l<0)c=[n=0];else{for(n=-1;0===c[0];c.splice(0,1),n-=h);for(l=1,u=c[0];u>=10;u/=10,l++);l<h&&(n-=h-l)}return p.e=n,p.c=c,p}),$.sum=function(){for(var e=1,t=arguments,r=new $(t[0]);e<t.length;)r=r.plus(t[e++]);return r},n=function(){function e(e,t,r,n){for(var i,o,u=[0],s=0,a=e.length;s<a;){for(o=u.length;o--;u[o]*=t);for(u[0]+=n.indexOf(e.charAt(s++)),i=0;i<u.length;i++)u[i]>r-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/r|0,u[i]%=r)}return u.reverse()}return function(t,n,i,o,u){var s,a,f,l,c,h,p,g,y=t.indexOf("."),d=F,b=R;for(y>=0&&(l=L,L=0,t=t.replace(".",""),h=(g=new $(n)).pow(t.length-y),L=l,g.c=e(E(_(h.c),h.e,"0"),10,i,"0123456789"),g.e=g.c.length),f=l=(p=e(t,n,i,u?(s=z,"0123456789"):(s="0123456789",z))).length;0==p[--l];p.pop());if(!p[0])return s.charAt(0);if(y<0?--f:(h.c=p,h.e=f,h.s=o,p=(h=r(h,g,d,b,i)).c,c=h.r,f=h.e),y=p[a=f+d+1],l=i/2,c=c||a<0||null!=p[a+1],c=b<4?(null!=y||c)&&(0==b||b==(h.s<0?3:2)):y>l||y==l&&(4==b||c||6==b&&1&p[a-1]||b==(h.s<0?8:7)),a<1||!p[0])t=c?E(s.charAt(1),-d,s.charAt(0)):s.charAt(0);else{if(p.length=a,c)for(--i;++p[--a]>i;)p[a]=0,a||(++f,p=[1].concat(p));for(l=p.length;!p[--l];);for(y=0,t="";y<=l;t+=s.charAt(p[y++]));t=E(t,f,s.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,o,u,s=0,a=e.length,f=t%y,l=t/y|0;for(e=e.slice();a--;)s=((i=f*(o=e[a]%y)+(n=l*o+(u=e[a]/y|0)*f)%y*y+s)/r|0)+(n/y|0)+l*u,e[a]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,o,u,s){var f,l,p,g,y,d,_,v,A,m,B,E,N,S,w,O,T,D=n.s==i.s?1:-1,I=n.c,F=i.c;if(!(I&&I[0]&&F&&F[0]))return new $(n.s&&i.s&&(I?!F||I[0]!=F[0]:F)?I&&0==I[0]||!F?0*D:D/0:NaN);for(A=(v=new $(D)).c=[],D=o+(l=n.e-i.e)+1,s||(s=c,l=b(n.e/h)-b(i.e/h),D=D/h|0),p=0;F[p]==(I[p]||0);p++);if(F[p]>(I[p]||0)&&l--,D<0)A.push(1),g=!0;else{for(S=I.length,O=F.length,p=0,D+=2,(y=a(s/(F[0]+1)))>1&&(F=e(F,y,s),I=e(I,y,s),O=F.length,S=I.length),N=O,B=(m=I.slice(0,O)).length;B<O;m[B++]=0);T=F.slice(),T=[0].concat(T),w=F[0],F[1]>=s/2&&w++;do{if(y=0,(f=t(F,m,O,B))<0){if(E=m[0],O!=B&&(E=E*s+(m[1]||0)),(y=a(E/w))>1)for(y>=s&&(y=s-1),_=(d=e(F,y,s)).length,B=m.length;1==t(d,m,_,B);)y--,r(d,O<_?T:F,_,s),_=d.length,f=1;else 0==y&&(f=y=1),_=(d=F.slice()).length;if(_<B&&(d=[0].concat(d)),r(m,d,B,s),B=m.length,-1==f)for(;t(F,m,O,B)<1;)y++,r(m,O<B?T:F,B,s),B=m.length}else 0===f&&(y++,m=[0]);A[p++]=y,m[0]?m[B++]=I[N]||0:(m=[I[N]],B=1)}while((N++<S||null!=m[0])&&D--);g=null!=m[0],A[0]||A.splice(0,1)}if(s==c){for(p=1,D=A[0];D>=10;D/=10,p++);G(v,o+(v.e=p+l*h-1)+1,u,g)}else v.e=l,v.r=+g;return v}}(),N=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,w=/^\.([^.]+)$/,O=/^-?(Infinity|NaN)$/,T=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(T,"");if(O.test(o))e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null;else{if(!r&&(o=o.replace(N,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(S,"$1").replace(w,"0.$1")),t!=o))return new $(o,i);if($.DEBUG)throw Error(f+"Not a"+(n?" base "+n:"")+" number: "+t);e.c=e.e=e.s=null}},D.absoluteValue=D.abs=function(){var e=new $(this);return e.s<0&&(e.s=1),e},D.comparedTo=function(e,t){return v(this,new $(e,t))},D.decimalPlaces=D.dp=function(e,t){var r,n,i,o=this;if(null!=e)return A(e,0,d),null==t?t=R:A(t,0,8),G(new $(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-b(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},D.dividedBy=D.div=function(e,t){return r(this,new $(e,t),F,R)},D.dividedToIntegerBy=D.idiv=function(e,t){return r(this,new $(e,t),0,1)},D.exponentiatedBy=D.pow=function(e,t){var r,n,i,o,u,l,c,p,g=this;if((e=new $(e)).c&&!e.isInteger())throw Error(f+"Exponent not an integer: "+H(e));if(null!=t&&(t=new $(t)),u=e.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!e.c||!e.c[0])return p=new $(Math.pow(+H(g),u?2-m(e):+H(e))),t?p.mod(t):p;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new $(NaN);(n=!l&&g.isInteger()&&t.isInteger())&&(g=g.mod(t))}else{if(e.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||u&&g.c[1]>=24e7:g.c[0]<8e13||u&&g.c[0]<=9999975e7)))return o=g.s<0&&m(e)?-0:0,g.e>-1&&(o=1/o),new $(l?1/o:o);L&&(o=s(L/h+2))}for(u?(r=new $(.5),l&&(e.s=1),c=m(e)):c=(i=Math.abs(+H(e)))%2,p=new $(I);;){if(c){if(!(p=p.times(g)).c)break;o?p.c.length>o&&(p.c.length=o):n&&(p=p.mod(t))}if(i){if(0===(i=a(i/2)))break;c=i%2}else if(G(e=e.times(r),e.e+1,1),e.e>14)c=m(e);else{if(0==(i=+H(e)))break;c=i%2}g=g.times(g),o?g.c&&g.c.length>o&&(g.c.length=o):n&&(g=g.mod(t))}return n?p:(l&&(p=I.div(p)),t?p.mod(t):o?G(p,L,R,void 0):p)},D.integerValue=function(e){var t=new $(this);return null==e?e=R:A(e,0,8),G(t,t.e+1,e)},D.isEqualTo=D.eq=function(e,t){return 0===v(this,new $(e,t))},D.isFinite=function(){return!!this.c},D.isGreaterThan=D.gt=function(e,t){return v(this,new $(e,t))>0},D.isGreaterThanOrEqualTo=D.gte=function(e,t){return 1===(t=v(this,new $(e,t)))||0===t},D.isInteger=function(){return!!this.c&&b(this.e/h)>this.c.length-2},D.isLessThan=D.lt=function(e,t){return v(this,new $(e,t))<0},D.isLessThanOrEqualTo=D.lte=function(e,t){return-1===(t=v(this,new $(e,t)))||0===t},D.isNaN=function(){return!this.s},D.isNegative=function(){return this.s<0},D.isPositive=function(){return this.s>0},D.isZero=function(){return!!this.c&&0==this.c[0]},D.minus=function(e,t){var r,n,i,o,u=this,s=u.s;if(t=(e=new $(e,t)).s,!s||!t)return new $(NaN);if(s!=t)return e.s=-t,u.plus(e);var a=u.e/h,f=e.e/h,l=u.c,p=e.c;if(!a||!f){if(!l||!p)return l?(e.s=-t,e):new $(p?u:NaN);if(!l[0]||!p[0])return p[0]?(e.s=-t,e):new $(l[0]?u:3==R?-0:0)}if(a=b(a),f=b(f),l=l.slice(),s=a-f){for((o=s<0)?(s=-s,i=l):(f=a,i=p),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=l.length)<(t=p.length))?s:t,s=t=0;t<n;t++)if(l[t]!=p[t]){o=l[t]<p[t];break}if(o&&(i=l,l=p,p=i,e.s=-e.s),(t=(n=p.length)-(r=l.length))>0)for(;t--;l[r++]=0);for(t=c-1;n>s;){if(l[--n]<p[n]){for(r=n;r&&!l[--r];l[r]=t);--l[r],l[n]+=c}l[n]-=p[n]}for(;0==l[0];l.splice(0,1),--f);return l[0]?X(e,l,f):(e.s=3==R?-1:1,e.c=[e.e=0],e)},D.modulo=D.mod=function(e,t){var n,i,o=this;return e=new $(e,t),!o.c||!e.s||e.c&&!e.c[0]?new $(NaN):!e.c||o.c&&!o.c[0]?new $(o):(9==P?(i=e.s,e.s=1,n=r(o,e,0,3),e.s=i,n.s*=i):n=r(o,e,0,P),(e=o.minus(n.times(e))).c[0]||1!=P||(e.s=o.s),e)},D.multipliedBy=D.times=function(e,t){var r,n,i,o,u,s,a,f,l,p,g,d,_,v,A,m=this,B=m.c,E=(e=new $(e,t)).c;if(!(B&&E&&B[0]&&E[0]))return!m.s||!e.s||B&&!B[0]&&!E||E&&!E[0]&&!B?e.c=e.e=e.s=null:(e.s*=m.s,B&&E?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=b(m.e/h)+b(e.e/h),e.s*=m.s,(a=B.length)<(p=E.length)&&(_=B,B=E,E=_,i=a,a=p,p=i),i=a+p,_=[];i--;_.push(0));for(v=c,A=y,i=p;--i>=0;){for(r=0,g=E[i]%A,d=E[i]/A|0,o=i+(u=a);o>i;)r=((f=g*(f=B[--u]%A)+(s=d*f+(l=B[u]/A|0)*g)%A*A+_[o]+r)/v|0)+(s/A|0)+d*l,_[o--]=f%v;_[o]=r}return r?++n:_.splice(0,1),X(e,_,n)},D.negated=function(){var e=new $(this);return e.s=-e.s||null,e},D.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new $(e,t)).s,!i||!t)return new $(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/h,u=e.e/h,s=n.c,a=e.c;if(!o||!u){if(!s||!a)return new $(i/0);if(!s[0]||!a[0])return a[0]?e:new $(s[0]?n:0*i)}if(o=b(o),u=b(u),s=s.slice(),i=o-u){for(i>0?(u=o,r=a):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(t=a.length)<0&&(r=a,a=s,s=r,t=i),i=0;t;)i=(s[--t]=s[t]+a[t]+i)/c|0,s[t]=c===s[t]?0:s[t]%c;return i&&(s=[i].concat(s),++u),X(e,s,u)},D.precision=D.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return A(e,1,d),null==t?t=R:A(t,0,8),G(new $(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*h+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},D.shiftedBy=function(e){return A(e,-p,p),this.times("1e"+e)},D.squareRoot=D.sqrt=function(){var e,t,n,i,o,u=this,s=u.c,a=u.s,f=u.e,l=F+4,c=new $("0.5");if(1!==a||!s||!s[0])return new $(!a||a<0&&(!s||s[0])?NaN:s?u:1/0);if(0==(a=Math.sqrt(+H(u)))||a==1/0?(((t=_(s)).length+f)%2==0&&(t+="0"),a=Math.sqrt(+t),f=b((f+1)/2)-(f<0||f%2),n=new $(t=a==1/0?"1e"+f:(t=a.toExponential()).slice(0,t.indexOf("e")+1)+f)):n=new $(a+""),n.c[0])for((a=(f=n.e)+l)<3&&(a=0);;)if(o=n,n=c.times(o.plus(r(u,o,l,1))),_(o.c).slice(0,a)===(t=_(n.c)).slice(0,a)){if(n.e<f&&--a,"9999"!=(t=t.slice(a-3,a+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(G(n,n.e+F+2,1),e=!n.times(n).eq(u));break}if(!i&&(G(o,o.e+F+2,0),o.times(o).eq(u))){n=o;break}l+=4,a+=4,i=1}return G(n,n.e+F+1,R,e)},D.toExponential=function(e,t){return null!=e&&(A(e,0,d),e++),Y(this,e,t,1)},D.toFixed=function(e,t){return null!=e&&(A(e,0,d),e=e+this.e+1),Y(this,e,t)},D.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=j;else if("object"!=typeof r)throw Error(f+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var o,u=n.split("."),s=+r.groupSize,a=+r.secondaryGroupSize,l=r.groupSeparator||"",c=u[0],h=u[1],p=i.s<0,g=p?c.slice(1):c,y=g.length;if(a&&(o=s,s=a,a=o,y-=o),s>0&&y>0){for(o=y%s||s,c=g.substr(0,o);o<y;o+=s)c+=l+g.substr(o,s);a>0&&(c+=l+g.slice(o)),p&&(c="-"+c)}n=h?c+(r.decimalSeparator||"")+((a=+r.fractionGroupSize)?h.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):h):c}return(r.prefix||"")+n+(r.suffix||"")},D.toFraction=function(e){var t,n,i,o,u,s,a,l,c,p,y,d,b=this,v=b.c;if(null!=e&&(!(a=new $(e)).isInteger()&&(a.c||1!==a.s)||a.lt(I)))throw Error(f+"Argument "+(a.isInteger()?"out of range: ":"not an integer: ")+H(a));if(!v)return new $(b);for(t=new $(I),c=n=new $(I),i=l=new $(I),d=_(v),u=t.e=d.length-b.e-1,t.c[0]=g[(s=u%h)<0?h+s:s],e=!e||a.comparedTo(t)>0?u>0?t:c:a,s=M,M=1/0,a=new $(d),l.c[0]=0;p=r(a,t,0,1),1!=(o=n.plus(p.times(i))).comparedTo(e);)n=i,i=o,c=l.plus(p.times(o=c)),l=o,t=a.minus(p.times(o=t)),a=o;return o=r(e.minus(n),i,0,1),l=l.plus(o.times(c)),n=n.plus(o.times(i)),l.s=c.s=b.s,y=r(c,i,u*=2,R).minus(b).abs().comparedTo(r(l,n,u,R).minus(b).abs())<1?[c,i]:[l,n],M=s,y},D.toNumber=function(){return+H(this)},D.toPrecision=function(e,t){return null!=e&&A(e,1,d),Y(this,e,t,2)},D.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=x||o>=C?B(_(r.c),o):E(_(r.c),o,"0"):10===e?t=E(_((r=G(new $(r),F+o+1,R)).c),r.e,"0"):(A(e,2,z.length,"Base"),t=n(E(_(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},D.valueOf=D.toJSON=function(){return H(this)},D._isBigNumber=!0,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(D[Symbol.toStringTag]="BigNumber",D[Symbol.for("nodejs.util.inspect.custom")]=D.valueOf),null!=t&&$.set(t),$}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},5:function(e,t,r){"use strict";(function(e){
|
||
/*!
|
||
* The buffer module from node.js, for the browser.
|
||
*
|
||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
||
* @license MIT
|
||
*/
|
||
var n=r(58),i=r(59),o=r(60);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(u()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=a.prototype:(null===e&&(e=new a(t)),e.length=t),e}function a(e,t,r){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return c(this,e)}return f(this,e,t,r)}function f(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);a.TYPED_ARRAY_SUPPORT?(e=t).__proto__=a.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!a.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|g(t,r),i=(e=s(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(a.isBuffer(t)){var r=0|p(t.length);return 0===(e=s(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?s(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function c(e,t){if(l(t),e=s(e,t<0?0:0|p(t)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|p(t.length);e=s(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function p(e){if(e>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|e}function g(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function d(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,u=1,s=e.length,a=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;u=2,s/=2,a/=2,r/=2}function f(e,t){return 1===u?e[t]:e.readUInt16BE(t*u)}if(i){var l=-1;for(o=r;o<s;o++)if(f(e,o)===f(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===a)return l*u}else-1!==l&&(o-=o-l),l=-1}else for(r+a>s&&(r=s-a),o=r;o>=0;o--){for(var c=!0,h=0;h<a;h++)if(f(e,o+h)!==f(t,h)){c=!1;break}if(c)return o}return-1}function _(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var s=parseInt(t.substr(2*u,2),16);if(isNaN(s))return u;e[r+u]=s}return u}function v(e,t,r,n){return $(j(t,e.length-r),e,r,n)}function A(e,t,r,n){return $(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function m(e,t,r,n){return A(e,t,r,n)}function B(e,t,r,n){return $(z(t),e,r,n)}function E(e,t,r,n){return $(function(e,t){for(var r,n,i,o=[],u=0;u<e.length&&!((t-=2)<0);++u)r=e.charCodeAt(u),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function N(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,u,s,a,f=e[i],l=null,c=f>239?4:f>223?3:f>191?2:1;if(i+c<=r)switch(c){case 1:f<128&&(l=f);break;case 2:128==(192&(o=e[i+1]))&&(a=(31&f)<<6|63&o)>127&&(l=a);break;case 3:o=e[i+1],u=e[i+2],128==(192&o)&&128==(192&u)&&(a=(15&f)<<12|(63&o)<<6|63&u)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:o=e[i+1],u=e[i+2],s=e[i+3],128==(192&o)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&o)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(l=a)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=c}return function(e){var t=e.length;if(t<=w)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=w));return r}(n)}t.Buffer=a,t.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},t.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=u(),a.poolSize=8192,a._augment=function(e){return e.__proto__=a.prototype,e},a.from=function(e,t,r){return f(null,e,t,r)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(e,t,r){return function(e,t,r,n){return l(t),t<=0?s(e,t):void 0!==r?"string"==typeof n?s(e,t).fill(r,n):s(e,t).fill(r):s(e,t)}(null,e,t,r)},a.allocUnsafe=function(e){return c(null,e)},a.allocUnsafeSlow=function(e){return c(null,e)},a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(e){switch(String(e).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!0;default:return!1}},a.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=a.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var u=e[r];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(n,i),i+=u.length}return n},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},a.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?S(this,0,e):function(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return D(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return N(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},a.prototype.compare=function(e,t,r,n,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(r>>>=0)-(t>>>=0),s=Math.min(o,u),f=this.slice(n,i),l=e.slice(t,r),c=0;c<s;++c)if(f[c]!==l[c]){o=f[c],u=l[c];break}return o<u?-1:u<o?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return d(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return d(this,e,t,r,!1)},a.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return A(this,e,t,r);case"latin1":case"binary":return m(this,e,t,r);case"base64":return B(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function O(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function D(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=L(e[o]);return i}function I(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function F(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function x(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function C(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function U(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,o){return o||U(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function k(e,t,r,n,o){return o||U(e,0,r,8),i.write(e,t,r,n,52,8),r+8}a.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),a.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=a.prototype;else{var i=t-e;r=new a(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},a.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||F(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},a.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||F(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||F(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||F(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),i.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||R(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},a.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||R(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):C(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);R(this,e,t,r,i-1,-i)}var o=0,u=1,s=0;for(this[t]=255&e;++o<r&&(u*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/u>>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);R(this,e,t,r,i-1,-i)}var o=r-1,u=1,s=0;for(this[t+o]=255&e;--o>=0&&(u*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/u>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):C(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return k(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return k(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var u=a.isBuffer(e)?e:j(new a(e,n).toString()),s=u.length;for(o=0;o<r-t;++o)this[o+t]=u[o%s]}return this};var P=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],u=0;u<n;++u){if((r=e.charCodeAt(u))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(P,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function $(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(17))},518:function(module,exports,__webpack_require__){(function(global,Buffer){var factory;factory=function(exports,long,buffer){"use strict";long=long&&long.hasOwnProperty("default")?long.default:long,buffer=buffer&&buffer.hasOwnProperty("default")?buffer.default:buffer;var commonjsGlobal="undefined"!=typeof window?window:void 0!==global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}function getCjsExportFromNamespace(e){return e&&e.default||e}var map=createCommonjsModule(function(e){if(void 0!==commonjsGlobal.Map)e.exports=commonjsGlobal.Map,e.exports.Map=commonjsGlobal.Map;else{var t=function(e){this._keys=[],this._values={};for(var t=0;t<e.length;t++)if(null!=e[t]){var r=e[t],n=r[0],i=r[1];this._keys.push(n),this._values[n]={v:i,i:this._keys.length-1}}};t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(e){var t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)},t.prototype.entries=function(){var e=this,t=0;return{next:function(){var r=e._keys[t++];return{value:void 0!==r?[r,e._values[r].v]:void 0,done:void 0===r}}}},t.prototype.forEach=function(e,t){t=t||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];e.call(t,this._values[n].v,n,t)}},t.prototype.get=function(e){return this._values[e]?this._values[e].v:void 0},t.prototype.has=function(e){return null!=this._values[e]},t.prototype.keys=function(){var e=this,t=0;return{next:function(){var r=e._keys[t++];return{value:void 0!==r?r:void 0,done:void 0===r}}}},t.prototype.set=function(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)},t.prototype.values=function(){var e=this,t=0;return{next:function(){var r=e._keys[t++];return{value:void 0!==r?e._values[r].v:void 0,done:void 0===r}}}},Object.defineProperty(t.prototype,"size",{enumerable:!0,get:function(){return this._keys.length}}),e.exports=t}}),map_1=map.Map;long.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},long.fromExtendedJSON=function(e,t){var r=long.fromString(e.$numberLong);return t&&t.relaxed?r.toNumber():r},Object.defineProperty(long.prototype,"_bsontype",{value:"Long"});var long_1=long;function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_assertThisInitialized(e):t}var Double=function(){function e(t){_classCallCheck(this,e),this.value=t}return _createClass(e,[{key:"valueOf",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(e){return e&&e.relaxed&&isFinite(this.value)?this.value:{$numberDouble:this.value.toString()}}}],[{key:"fromExtendedJSON",value:function(t,r){return r&&r.relaxed?parseFloat(t.$numberDouble):new e(parseFloat(t.$numberDouble))}}]),e}();Object.defineProperty(Double.prototype,"_bsontype",{value:"Double"});var double_1=Double,Timestamp=function(e){function t(e,r){var n;return _classCallCheck(this,t),n=_possibleConstructorReturn(this,e instanceof long_1?_getPrototypeOf(t).call(this,e.low,e.high):_getPrototypeOf(t).call(this,e,r)),_possibleConstructorReturn(n)}return _inherits(t,long_1),_createClass(t,[{key:"toJSON",value:function(){return{$timestamp:this.toString()}}},{key:"toExtendedJSON",value:function(){return{$timestamp:{t:this.high,i:this.low}}}}],[{key:"fromInt",value:function(e){return new t(long_1.fromInt(e))}},{key:"fromNumber",value:function(e){return new t(long_1.fromNumber(e))}},{key:"fromBits",value:function(e,r){return new t(e,r)}},{key:"fromString",value:function(e,r){return new t(long_1.fromString(e,r))}},{key:"fromExtendedJSON",value:function(e){return new t(e.$timestamp.i,e.$timestamp.t)}}]),t}();Object.defineProperty(Timestamp.prototype,"_bsontype",{value:"Timestamp"});var timestamp=Timestamp,empty={},empty$1=Object.freeze({default:empty}),require$$0=getCjsExportFromNamespace(empty$1);function normalizedFunctionString(e){return e.toString().replace("function(","function (")}function insecureRandomBytes(e){for(var t=new Uint8Array(e),r=0;r<e;++r)t[r]=Math.floor(256*Math.random());return t}var randomBytes=insecureRandomBytes;if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)randomBytes=function(e){return window.crypto.getRandomValues(new Uint8Array(e))};else{try{randomBytes=require$$0.randomBytes}catch(e){}null==randomBytes&&(randomBytes=insecureRandomBytes)}var utils={normalizedFunctionString:normalizedFunctionString,randomBytes:randomBytes};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}var cachedSetTimeout=defaultSetTimout,cachedClearTimeout=defaultClearTimeout;function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}"function"==typeof global.setTimeout&&(cachedSetTimeout=setTimeout),"function"==typeof global.clearTimeout&&(cachedClearTimeout=clearTimeout);var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function nextTick(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)}function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};var title="browser",platform="browser",browser=!0,env={},argv=[],version="",versions={},release={},config={};function noop(){}var on=noop,addListener=noop,once=noop,off=noop,removeListener=noop,removeAllListeners=noop,emit=noop;function binding(e){throw new Error("process.binding is not supported")}function cwd(){return"/"}function chdir(e){throw new Error("process.chdir is not supported")}function umask(){return 0}var performance=global.performance||{},performanceNow=performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()};function hrtime(e){var t=.001*performanceNow.call(performance),r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r-=e[0],(n-=e[1])<0&&(r--,n+=1e9)),[r,n]}var startTime=new Date;function uptime(){return(new Date-startTime)/1e3}var process={nextTick:nextTick,title:title,browser:browser,env:env,argv:argv,version:version,versions:versions,on:on,addListener:addListener,once:once,off:off,removeListener:removeListener,removeAllListeners:removeAllListeners,emit:emit,binding:binding,cwd:cwd,chdir:chdir,umask:umask,hrtime:hrtime,platform:platform,release:release,config:config,uptime:uptime},inherits;inherits="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e};var inherits$1=inherits,formatRegExp=/%[sdj%]/g;function format(e){if(!isString(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(inspect(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,i=n.length,o=String(e).replace(formatRegExp,function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),u=n[r];r<i;u=n[++r])isNull(u)||!isObject(u)?o+=" "+u:o+=" "+inspect(u);return o}function deprecate(e,t){if(isUndefined(global.process))return function(){return deprecate(e,t).apply(this,arguments)};var r=!1;return function(){return r||(console.error(t),r=!0),e.apply(this,arguments)}}var debugs={},debugEnviron;function debuglog(e){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){debugs[e]=function(){var t=format.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else debugs[e]=function(){};return debugs[e]}function inspect(e,t){var r={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),isBoolean(t)?r.showHidden=t:t&&_extend(r,t),isUndefined(r.showHidden)&&(r.showHidden=!1),isUndefined(r.depth)&&(r.depth=2),isUndefined(r.colors)&&(r.colors=!1),isUndefined(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=stylizeWithColor),formatValue(r,e,r.depth)}function stylizeWithColor(e,t){var r=inspect.styles[t];return r?"["+inspect.colors[r][0]+"m"+e+"["+inspect.colors[r][1]+"m":e}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function formatValue(e,t,r){if(e.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return isString(n)||(n=formatValue(e,n,r)),n}var i=formatPrimitive(e,t);if(i)return i;var o=Object.keys(t),u=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),isError(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(t);if(0===o.length){if(isFunction(t)){var s=t.name?": "+t.name:"";return e.stylize("[Function"+s+"]","special")}if(isRegExp(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(isDate(t))return e.stylize(Date.prototype.toString.call(t),"date");if(isError(t))return formatError(t)}var a,f="",l=!1,c=["{","}"];(isArray(t)&&(l=!0,c=["[","]"]),isFunction(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return isRegExp(t)&&(f=" "+RegExp.prototype.toString.call(t)),isDate(t)&&(f=" "+Date.prototype.toUTCString.call(t)),isError(t)&&(f=" "+formatError(t)),0!==o.length||l&&0!=t.length?r<0?isRegExp(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),a=l?formatArray(e,t,r,u,o):o.map(function(n){return formatProperty(e,t,r,u,n,l)}),e.seen.pop(),reduceToSingleString(a,f,c)):c[0]+f+c[1]}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return isNumber(t)?e.stylize(""+t,"number"):isBoolean(t)?e.stylize(""+t,"boolean"):isNull(t)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,r,n,i){for(var o=[],u=0,s=t.length;u<s;++u)hasOwnProperty(t,String(u))?o.push(formatProperty(e,t,r,n,String(u),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(formatProperty(e,t,r,n,i,!0))}),o}function formatProperty(e,t,r,n,i,o){var u,s,a;if((a=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(s=e.stylize("[Setter]","special")),hasOwnProperty(n,i)||(u="["+i+"]"),s||(e.seen.indexOf(a.value)<0?(s=isNull(r)?formatValue(e,a.value,null):formatValue(e,a.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n")):s=e.stylize("[Circular]","special")),isUndefined(u)){if(o&&i.match(/^\d+$/))return s;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=e.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=e.stylize(u,"string"))}return u+": "+s}function reduceToSingleString(e,t,r){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"===_typeof(e)}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"===_typeof(e)&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===_typeof(e)||void 0===e}function isBuffer(e){return Buffer.isBuffer(e)}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp$1(){var e=new Date,t=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],t].join(" ")}function log(){console.log("%s - %s",timestamp$1(),format.apply(null,arguments))}function _extend(e,t){if(!t||!isObject(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var util={inherits:inherits$1,_extend:_extend,log:log,isBuffer:isBuffer,isPrimitive:isPrimitive,isFunction:isFunction,isError:isError,isDate:isDate,isObject:isObject,isRegExp:isRegExp,isUndefined:isUndefined,isSymbol:isSymbol,isString:isString,isNumber:isNumber,isNullOrUndefined:isNullOrUndefined,isNull:isNull,isBoolean:isBoolean,isArray:isArray,inspect:inspect,deprecate:deprecate,format:format,debuglog:debuglog},util$1=Object.freeze({format:format,deprecate:deprecate,debuglog:debuglog,inspect:inspect,isArray:isArray,isBoolean:isBoolean,isNull:isNull,isNullOrUndefined:isNullOrUndefined,isNumber:isNumber,isString:isString,isSymbol:isSymbol,isUndefined:isUndefined,isRegExp:isRegExp,isObject:isObject,isDate:isDate,isError:isError,isFunction:isFunction,isPrimitive:isPrimitive,isBuffer:isBuffer,log:log,inherits:inherits$1,_extend:_extend,default:util}),require$$2=getCjsExportFromNamespace(util$1),Buffer$1=buffer.Buffer,randomBytes$1=utils.randomBytes,deprecate$1=require$$2.deprecate,PROCESS_UNIQUE=randomBytes$1(5),checkForHexRegExp=new RegExp("^[0-9a-fA-F]{24}$"),hasBufferType=!1;try{Buffer$1&&Buffer$1.from&&(hasBufferType=!0)}catch(e){hasBufferType=!1}for(var hexTable=[],_i=0;_i<256;_i++)hexTable[_i]=(_i<=15?"0":"")+_i.toString(16);for(var decodeLookup=[],i=0;i<10;)decodeLookup[48+i]=i++;for(;i<16;)decodeLookup[55+i]=decodeLookup[87+i]=i++;var _Buffer=Buffer$1;function convertToHex(e){return e.toString("hex")}function makeObjectIdError(e,t){var r=e[t];return new TypeError('ObjectId string "'.concat(e,'" contains invalid character "').concat(r,'" with character code (').concat(e.charCodeAt(t),"). All character codes for a non-hex string must be less than 256."))}var ObjectId=function(){function e(t){if(_classCallCheck(this,e),t instanceof e)return t;if(null==t||"number"==typeof t)return this.id=e.generate(t),void(e.cacheHexString&&(this.__id=this.toString("hex")));var r=e.isValid(t);if(!r&&null!=t)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(r&&"string"==typeof t&&24===t.length&&hasBufferType)return new e(Buffer$1.from(t,"hex"));if(r&&"string"==typeof t&&24===t.length)return e.createFromHexString(t);if(null==t||12!==t.length){if(null!=t&&t.toHexString)return t;throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters")}this.id=t,e.cacheHexString&&(this.__id=this.toString("hex"))}return _createClass(e,[{key:"toHexString",value:function(){if(e.cacheHexString&&this.__id)return this.__id;var t="";if(!this.id||!this.id.length)throw new TypeError("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(this.id instanceof _Buffer)return t=convertToHex(this.id),e.cacheHexString&&(this.__id=t),t;for(var r=0;r<this.id.length;r++){var n=hexTable[this.id.charCodeAt(r)];if("string"!=typeof n)throw makeObjectIdError(this.id,r);t+=n}return e.cacheHexString&&(this.__id=t),t}},{key:"toString",value:function(e){return this.id&&this.id.copy?this.id.toString("string"==typeof e?e:"hex"):this.toHexString()}},{key:"toJSON",value:function(){return this.toHexString()}},{key:"equals",value:function(t){return t instanceof e?this.toString()===t.toString():"string"==typeof t&&e.isValid(t)&&12===t.length&&this.id instanceof _Buffer?t===this.id.toString("binary"):"string"==typeof t&&e.isValid(t)&&24===t.length?t.toLowerCase()===this.toHexString():"string"==typeof t&&e.isValid(t)&&12===t.length?t===this.id:!(null==t||!(t instanceof e||t.toHexString))&&t.toHexString()===this.toHexString()}},{key:"getTimestamp",value:function(){var e=new Date,t=this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24;return e.setTime(1e3*Math.floor(t)),e}},{key:"toExtendedJSON",value:function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}}],[{key:"getInc",value:function(){return e.index=(e.index+1)%16777215}},{key:"generate",value:function(t){"number"!=typeof t&&(t=~~(Date.now()/1e3));var r=e.getInc(),n=Buffer$1.alloc(12);return n[3]=255&t,n[2]=t>>8&255,n[1]=t>>16&255,n[0]=t>>24&255,n[4]=PROCESS_UNIQUE[0],n[5]=PROCESS_UNIQUE[1],n[6]=PROCESS_UNIQUE[2],n[7]=PROCESS_UNIQUE[3],n[8]=PROCESS_UNIQUE[4],n[11]=255&r,n[10]=r>>8&255,n[9]=r>>16&255,n}},{key:"createPk",value:function(){return new e}},{key:"createFromTime",value:function(t){var r=Buffer$1.from([0,0,0,0,0,0,0,0,0,0,0,0]);return r[3]=255&t,r[2]=t>>8&255,r[1]=t>>16&255,r[0]=t>>24&255,new e(r)}},{key:"createFromHexString",value:function(t){if(void 0===t||null!=t&&24!==t.length)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(hasBufferType)return new e(Buffer$1.from(t,"hex"));for(var r=new _Buffer(12),n=0,i=0;i<24;)r[n++]=decodeLookup[t.charCodeAt(i++)]<<4|decodeLookup[t.charCodeAt(i++)];return new e(r)}},{key:"isValid",value:function(t){return null!=t&&("number"==typeof t||("string"==typeof t?12===t.length||24===t.length&&checkForHexRegExp.test(t):t instanceof e||(t instanceof _Buffer&&12===t.length||!!t.toHexString&&(12===t.id.length||24===t.id.length&&checkForHexRegExp.test(t.id)))))}},{key:"fromExtendedJSON",value:function(t){return new e(t.$oid)}}]),e}();ObjectId.get_inc=deprecate$1(function(){return ObjectId.getInc()},"Please use the static `ObjectId.getInc()` instead"),ObjectId.prototype.get_inc=deprecate$1(function(){return ObjectId.getInc()},"Please use the static `ObjectId.getInc()` instead"),ObjectId.prototype.getInc=deprecate$1(function(){return ObjectId.getInc()},"Please use the static `ObjectId.getInc()` instead"),ObjectId.prototype.generate=deprecate$1(function(e){return ObjectId.generate(e)},"Please use the static `ObjectId.generate(time)` instead"),Object.defineProperty(ObjectId.prototype,"generationTime",{enumerable:!0,get:function(){return this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24},set:function(e){this.id[3]=255&e,this.id[2]=e>>8&255,this.id[1]=e>>16&255,this.id[0]=e>>24&255}}),ObjectId.prototype.inspect=ObjectId.prototype.toString,ObjectId.index=~~(16777215*Math.random()),Object.defineProperty(ObjectId.prototype,"_bsontype",{value:"ObjectId"});var objectid=ObjectId;function alphabetize(e){return e.split("").sort().join("")}var BSONRegExp=function(){function e(t,r){_classCallCheck(this,e),this.pattern=t||"",this.options=r?alphabetize(r):"";for(var n=0;n<this.options.length;n++)if("i"!==this.options[n]&&"m"!==this.options[n]&&"x"!==this.options[n]&&"l"!==this.options[n]&&"s"!==this.options[n]&&"u"!==this.options[n])throw new Error("The regular expression option [".concat(this.options[n],"] is not supported"))}return _createClass(e,[{key:"toExtendedJSON",value:function(){return{$regularExpression:{pattern:this.pattern,options:this.options}}}}],[{key:"fromExtendedJSON",value:function(t){return new e(t.$regularExpression.pattern,t.$regularExpression.options.split("").sort().join(""))}}]),e}();Object.defineProperty(BSONRegExp.prototype,"_bsontype",{value:"BSONRegExp"});var regexp=BSONRegExp,BSONSymbol=function(){function e(t){_classCallCheck(this,e),this.value=t}return _createClass(e,[{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}},{key:"inspect",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(){return{$symbol:this.value}}}],[{key:"fromExtendedJSON",value:function(t){return new e(t.$symbol)}}]),e}();Object.defineProperty(BSONSymbol.prototype,"_bsontype",{value:"Symbol"});var symbol=BSONSymbol,Int32=function(){function e(t){_classCallCheck(this,e),this.value=t}return _createClass(e,[{key:"valueOf",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(e){return e&&e.relaxed?this.value:{$numberInt:this.value.toString()}}}],[{key:"fromExtendedJSON",value:function(t,r){return r&&r.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)}}]),e}();Object.defineProperty(Int32.prototype,"_bsontype",{value:"Int32"});var int_32=Int32,Code=function(){function e(t,r){_classCallCheck(this,e),this.code=t,this.scope=r}return _createClass(e,[{key:"toJSON",value:function(){return{scope:this.scope,code:this.code}}},{key:"toExtendedJSON",value:function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}}],[{key:"fromExtendedJSON",value:function(t){return new e(t.$code,t.$scope)}}]),e}();Object.defineProperty(Code.prototype,"_bsontype",{value:"Code"});var code=Code,PARSE_STRING_REGEXP=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,PARSE_INF_REGEXP=/^(\+|-)?(Infinity|inf)$/i,PARSE_NAN_REGEXP=/^(\+|-)?NaN$/i,EXPONENT_MAX=6111,EXPONENT_MIN=-6176,EXPONENT_BIAS=6176,MAX_DIGITS=34,NAN_BUFFER=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),INF_NEGATIVE_BUFFER=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),INF_POSITIVE_BUFFER=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),EXPONENT_REGEX=/^([-+])?(\d+)?$/;function isDigit(e){return!isNaN(parseInt(e,10))}function divideu128(e){var t=long_1.fromNumber(1e9),r=long_1.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:r};for(var n=0;n<=3;n++)r=(r=r.shiftLeft(32)).add(new long_1(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function multiply64x2(e,t){if(!e&&!t)return{high:long_1.fromNumber(0),low:long_1.fromNumber(0)};var r=e.shiftRightUnsigned(32),n=new long_1(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new long_1(t.getLowBits(),0),u=r.multiply(i),s=r.multiply(o),a=n.multiply(i),f=n.multiply(o);return u=u.add(s.shiftRightUnsigned(32)),s=new long_1(s.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:u=u.add(s.shiftRightUnsigned(32)),low:f=s.shiftLeft(32).add(new long_1(f.getLowBits(),0))}}function lessThan(e,t){var r=e.high>>>0,n=t.high>>>0;return r<n||r===n&&e.low>>>0<t.low>>>0}function invalidErr(e,t){throw new TypeError('"'.concat(e,'" is not a valid Decimal128 string - ').concat(t))}function Decimal128(e){this.bytes=e}Decimal128.fromString=function(e){var t,r=!1,n=!1,i=!1,o=0,u=0,s=0,a=0,f=0,l=[0],c=0,h=0,p=0,g=0,y=0,d=0,b=[0,0],_=[0,0],v=0;if(e.length>=7e3)throw new TypeError(e+" not a valid Decimal128 string");var A=e.match(PARSE_STRING_REGEXP),m=e.match(PARSE_INF_REGEXP),B=e.match(PARSE_NAN_REGEXP);if(!A&&!m&&!B||0===e.length)throw new TypeError(e+" not a valid Decimal128 string");if(A){var E=A[2],N=A[4],S=A[5],w=A[6];N&&void 0===w&&invalidErr(e,"missing exponent power"),N&&void 0===E&&invalidErr(e,"missing exponent base"),void 0===N&&(S||w)&&invalidErr(e,"missing e before exponent")}if("+"!==e[v]&&"-"!==e[v]||(r="-"===e[v++]),!isDigit(e[v])&&"."!==e[v]){if("i"===e[v]||"I"===e[v])return new Decimal128(Buffer.from(r?INF_NEGATIVE_BUFFER:INF_POSITIVE_BUFFER));if("N"===e[v])return new Decimal128(Buffer.from(NAN_BUFFER))}for(;isDigit(e[v])||"."===e[v];)"."!==e[v]?(c<34&&("0"!==e[v]||i)&&(i||(f=u),i=!0,l[h++]=parseInt(e[v],10),c+=1),i&&(s+=1),n&&(a+=1),u+=1,v+=1):(n&&invalidErr(e,"contains multiple periods"),n=!0,v+=1);if(n&&!u)throw new TypeError(e+" not a valid Decimal128 string");if("e"===e[v]||"E"===e[v]){var O=e.substr(++v).match(EXPONENT_REGEX);if(!O||!O[2])return new Decimal128(Buffer.from(NAN_BUFFER));y=parseInt(O[0],10),v+=O[0].length}if(e[v])return new Decimal128(Buffer.from(NAN_BUFFER));if(p=0,c){if(g=c-1,1!==(o=s))for(;"0"===e[f+o-1];)o-=1}else p=0,g=0,l[0]=0,s=1,c=1,o=0;for(y<=a&&a-y>16384?y=EXPONENT_MIN:y-=a;y>EXPONENT_MAX;){if((g+=1)-p>MAX_DIGITS){if(l.join("").match(/^0+$/)){y=EXPONENT_MAX;break}invalidErr(e,"overflow")}y-=1}for(;y<EXPONENT_MIN||c<s;){if(0===g&&o<c){y=EXPONENT_MIN,o=0;break}if(c<s?s-=1:g-=1,y<EXPONENT_MAX)y+=1;else{if(l.join("").match(/^0+$/)){y=EXPONENT_MAX;break}invalidErr(e,"overflow")}}if(g-p+1<o){var T=u;n&&(f+=1,T+=1),r&&(f+=1,T+=1);var D=parseInt(e[f+g+1],10),I=0;if(D>=5&&(I=1,5===D))for(I=l[g]%2==1,d=f+g+2;d<T;d++)if(parseInt(e[d],10)){I=1;break}if(I)for(var F=g;F>=0;F--)if(++l[F]>9&&(l[F]=0,0===F)){if(!(y<EXPONENT_MAX))return new Decimal128(Buffer.from(r?INF_NEGATIVE_BUFFER:INF_POSITIVE_BUFFER));y+=1,l[F]=1}}if(b=long_1.fromNumber(0),_=long_1.fromNumber(0),0===o)b=long_1.fromNumber(0),_=long_1.fromNumber(0);else if(g-p<17){var R=p;for(_=long_1.fromNumber(l[R++]),b=new long_1(0,0);R<=g;R++)_=(_=_.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(l[R]))}else{var x=p;for(b=long_1.fromNumber(l[x++]);x<=g-17;x++)b=(b=b.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(l[x]));for(_=long_1.fromNumber(l[x++]);x<=g;x++)_=(_=_.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(l[x]))}var C=multiply64x2(b,long_1.fromString("100000000000000000"));C.low=C.low.add(_),lessThan(C.low,_)&&(C.high=C.high.add(long_1.fromNumber(1))),t=y+EXPONENT_BIAS;var U={low:long_1.fromNumber(0),high:long_1.fromNumber(0)};C.high.shiftRightUnsigned(49).and(long_1.fromNumber(1)).equals(long_1.fromNumber(1))?(U.high=U.high.or(long_1.fromNumber(3).shiftLeft(61)),U.high=U.high.or(long_1.fromNumber(t).and(long_1.fromNumber(16383).shiftLeft(47))),U.high=U.high.or(C.high.and(long_1.fromNumber(0x7fffffffffff)))):(U.high=U.high.or(long_1.fromNumber(16383&t).shiftLeft(49)),U.high=U.high.or(C.high.and(long_1.fromNumber(562949953421311)))),U.low=C.low,r&&(U.high=U.high.or(long_1.fromString("9223372036854775808")));var M=Buffer.alloc(16);return v=0,M[v++]=255&U.low.low,M[v++]=U.low.low>>8&255,M[v++]=U.low.low>>16&255,M[v++]=U.low.low>>24&255,M[v++]=255&U.low.high,M[v++]=U.low.high>>8&255,M[v++]=U.low.high>>16&255,M[v++]=U.low.high>>24&255,M[v++]=255&U.high.low,M[v++]=U.high.low>>8&255,M[v++]=U.high.low>>16&255,M[v++]=U.high.low>>24&255,M[v++]=255&U.high.high,M[v++]=U.high.high>>8&255,M[v++]=U.high.high>>16&255,M[v++]=U.high.high>>24&255,new Decimal128(M)};var COMBINATION_MASK=31,EXPONENT_MASK=16383,COMBINATION_INFINITY=30,COMBINATION_NAN=31;Decimal128.prototype.toString=function(){for(var e,t,r,n,i,o,u=0,s=new Array(36),a=0;a<s.length;a++)s[a]=0;var f,l,c,h,p,g=0,y=!1,d={parts:new Array(4)},b=[];g=0;var _=this.bytes;if(n=_[g++]|_[g++]<<8|_[g++]<<16|_[g++]<<24,r=_[g++]|_[g++]<<8|_[g++]<<16|_[g++]<<24,t=_[g++]|_[g++]<<8|_[g++]<<16|_[g++]<<24,e=_[g++]|_[g++]<<8|_[g++]<<16|_[g++]<<24,g=0,{low:new long_1(n,r),high:new long_1(t,e)}.high.lessThan(long_1.ZERO)&&b.push("-"),(i=e>>26&COMBINATION_MASK)>>3==3){if(i===COMBINATION_INFINITY)return b.join("")+"Infinity";if(i===COMBINATION_NAN)return"NaN";o=e>>15&EXPONENT_MASK,c=8+(e>>14&1)}else c=e>>14&7,o=e>>17&EXPONENT_MASK;if(f=o-EXPONENT_BIAS,d.parts[0]=(16383&e)+((15&c)<<14),d.parts[1]=t,d.parts[2]=r,d.parts[3]=n,0===d.parts[0]&&0===d.parts[1]&&0===d.parts[2]&&0===d.parts[3])y=!0;else for(p=3;p>=0;p--){var v=0,A=divideu128(d);if(d=A.quotient,v=A.rem.low)for(h=8;h>=0;h--)s[9*p+h]=v%10,v=Math.floor(v/10)}if(y)u=1,s[g]=0;else for(u=36;!s[g];)u-=1,g+=1;if((l=u-1+f)>=34||l<=-7||f>0){if(u>34)return b.push(0),f>0?b.push("E+"+f):f<0&&b.push("E"+f),b.join("");b.push(s[g++]),(u-=1)&&b.push(".");for(var m=0;m<u;m++)b.push(s[g++]);b.push("E"),l>0?b.push("+"+l):b.push(l)}else if(f>=0)for(var B=0;B<u;B++)b.push(s[g++]);else{var E=u+f;if(E>0)for(var N=0;N<E;N++)b.push(s[g++]);else b.push("0");for(b.push(".");E++<0;)b.push("0");for(var S=0;S<u-Math.max(E-1,0);S++)b.push(s[g++])}return b.join("")},Decimal128.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},Decimal128.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},Decimal128.fromExtendedJSON=function(e){return Decimal128.fromString(e.$numberDecimal)},Object.defineProperty(Decimal128.prototype,"_bsontype",{value:"Decimal128"});var decimal128=Decimal128,MinKey=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"toExtendedJSON",value:function(){return{$minKey:1}}}],[{key:"fromExtendedJSON",value:function(){return new e}}]),e}();Object.defineProperty(MinKey.prototype,"_bsontype",{value:"MinKey"});var min_key=MinKey,MaxKey=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"toExtendedJSON",value:function(){return{$maxKey:1}}}],[{key:"fromExtendedJSON",value:function(){return new e}}]),e}();Object.defineProperty(MaxKey.prototype,"_bsontype",{value:"MaxKey"});var max_key=MaxKey,DBRef=function(){function e(t,r,n,i){_classCallCheck(this,e);var o=t.split(".");2===o.length&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=r,this.db=n,this.fields=i||{}}return _createClass(e,[{key:"toJSON",value:function(){var e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}},{key:"toExtendedJSON",value:function(){var e={$ref:this.collection,$id:this.oid};return this.db&&(e.$db=this.db),e=Object.assign(e,this.fields)}}],[{key:"fromExtendedJSON",value:function(t){var r=Object.assign({},t);return["$ref","$id","$db"].forEach(function(e){return delete r[e]}),new e(t.$ref,t.$id,t.$db,r)}}]),e}();Object.defineProperty(DBRef.prototype,"_bsontype",{value:"DBRef"});var db_ref=DBRef,Binary=function(){function e(t,r){if(_classCallCheck(this,e),!(null==t||"string"==typeof t||Buffer.isBuffer(t)||t instanceof Uint8Array||Array.isArray(t)))throw new TypeError("only String, Buffer, Uint8Array or Array accepted");if(this.sub_type=null==r?BSON_BINARY_SUBTYPE_DEFAULT:r,this.position=0,null==t||t instanceof Number)void 0!==Buffer?this.buffer=Buffer.alloc(e.BUFFER_SIZE):"undefined"!=typeof Uint8Array?this.buffer=new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE)):this.buffer=new Array(e.BUFFER_SIZE);else{if("string"==typeof t)if(void 0!==Buffer)this.buffer=Buffer.from(t);else{if("undefined"==typeof Uint8Array&&!Array.isArray(t))throw new TypeError("only String, Buffer, Uint8Array or Array accepted");this.buffer=writeStringToArray(t)}else this.buffer=t;this.position=t.length}}return _createClass(e,[{key:"put",value:function(t){if(null!=t.length&&"number"!=typeof t&&1!==t.length)throw new TypeError("only accepts single character String, Uint8Array or Array");if("number"!=typeof t&&t<0||t>255)throw new TypeError("only accepts number in a valid unsigned byte range 0-255");var r=null;if(r="string"==typeof t?t.charCodeAt(0):null!=t.length?t[0]:t,this.buffer.length>this.position)this.buffer[this.position++]=r;else if(void 0!==Buffer&&Buffer.isBuffer(this.buffer)){var n=Buffer.alloc(e.BUFFER_SIZE+this.buffer.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n,this.buffer[this.position++]=r}else{var i=null;i=isUint8Array(this.buffer)?new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE+this.buffer.length)):new Array(e.BUFFER_SIZE+this.buffer.length);for(var o=0;o<this.buffer.length;o++)i[o]=this.buffer[o];this.buffer=i,this.buffer[this.position++]=r}}},{key:"write",value:function(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){var r=null;if(void 0!==Buffer&&Buffer.isBuffer(this.buffer))r=Buffer.alloc(this.buffer.length+e.length),this.buffer.copy(r,0,0,this.buffer.length);else if(isUint8Array(this.buffer)){r=new Uint8Array(new ArrayBuffer(this.buffer.length+e.length));for(var n=0;n<this.position;n++)r[n]=this.buffer[n]}this.buffer=r}if(void 0!==Buffer&&Buffer.isBuffer(e)&&Buffer.isBuffer(this.buffer))e.copy(this.buffer,t,0,e.length),this.position=t+e.length>this.position?t+e.length:this.position;else if(void 0!==Buffer&&"string"==typeof e&&Buffer.isBuffer(this.buffer))this.buffer.write(e,t,"binary"),this.position=t+e.length>this.position?t+e.length:this.position;else if(isUint8Array(e)||Array.isArray(e)&&"string"!=typeof e){for(var i=0;i<e.length;i++)this.buffer[t++]=e[i];this.position=t>this.position?t:this.position}else if("string"==typeof e){for(var o=0;o<e.length;o++)this.buffer[t++]=e.charCodeAt(o);this.position=t>this.position?t:this.position}}},{key:"read",value:function(e,t){if(t=t&&t>0?t:this.position,this.buffer.slice)return this.buffer.slice(e,e+t);for(var r="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(t)):new Array(t),n=0;n<t;n++)r[n]=this.buffer[e++];return r}},{key:"value",value:function(e){if((e=null!=e&&e)&&void 0!==Buffer&&Buffer.isBuffer(this.buffer)&&this.buffer.length===this.position)return this.buffer;if(void 0!==Buffer&&Buffer.isBuffer(this.buffer))return e?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position);if(e){if(null!=this.buffer.slice)return this.buffer.slice(0,this.position);for(var t=isUint8Array(this.buffer)?new Uint8Array(new ArrayBuffer(this.position)):new Array(this.position),r=0;r<this.position;r++)t[r]=this.buffer[r];return t}return convertArraytoUtf8BinaryString(this.buffer,0,this.position)}},{key:"length",value:function(){return this.position}},{key:"toJSON",value:function(){return null!=this.buffer?this.buffer.toString("base64"):""}},{key:"toString",value:function(e){return null!=this.buffer?this.buffer.slice(0,this.position).toString(e):""}},{key:"toExtendedJSON",value:function(){var e=Buffer.isBuffer(this.buffer)?this.buffer.toString("base64"):Buffer.from(this.buffer).toString("base64"),t=Number(this.sub_type).toString(16);return{$binary:{base64:e,subType:1===t.length?"0"+t:t}}}}],[{key:"fromExtendedJSON",value:function(t){var r=t.$binary.subType?parseInt(t.$binary.subType,16):0;return new e(new Buffer(t.$binary.base64,"base64"),r)}}]),e}(),BSON_BINARY_SUBTYPE_DEFAULT=0;function isUint8Array(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function writeStringToArray(e){for(var t="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(e.length)):new Array(e.length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function convertArraytoUtf8BinaryString(e,t,r){for(var n="",i=t;i<r;i++)n+=String.fromCharCode(e[i]);return n}Binary.BUFFER_SIZE=256,Binary.SUBTYPE_DEFAULT=0,Binary.SUBTYPE_FUNCTION=1,Binary.SUBTYPE_BYTE_ARRAY=2,Binary.SUBTYPE_UUID_OLD=3,Binary.SUBTYPE_UUID=4,Binary.SUBTYPE_MD5=5,Binary.SUBTYPE_USER_DEFINED=128,Object.defineProperty(Binary.prototype,"_bsontype",{value:"Binary"});var binary=Binary,constants={BSON_INT32_MAX:2147483647,BSON_INT32_MIN:-2147483648,BSON_INT64_MAX:Math.pow(2,63)-1,BSON_INT64_MIN:-Math.pow(2,63),JS_INT_MAX:9007199254740992,JS_INT_MIN:-9007199254740992,BSON_DATA_NUMBER:1,BSON_DATA_STRING:2,BSON_DATA_OBJECT:3,BSON_DATA_ARRAY:4,BSON_DATA_BINARY:5,BSON_DATA_UNDEFINED:6,BSON_DATA_OID:7,BSON_DATA_BOOLEAN:8,BSON_DATA_DATE:9,BSON_DATA_NULL:10,BSON_DATA_REGEXP:11,BSON_DATA_DBPOINTER:12,BSON_DATA_CODE:13,BSON_DATA_SYMBOL:14,BSON_DATA_CODE_W_SCOPE:15,BSON_DATA_INT:16,BSON_DATA_TIMESTAMP:17,BSON_DATA_LONG:18,BSON_DATA_DECIMAL128:19,BSON_DATA_MIN_KEY:255,BSON_DATA_MAX_KEY:127,BSON_BINARY_SUBTYPE_DEFAULT:0,BSON_BINARY_SUBTYPE_FUNCTION:1,BSON_BINARY_SUBTYPE_BYTE_ARRAY:2,BSON_BINARY_SUBTYPE_UUID:3,BSON_BINARY_SUBTYPE_MD5:4,BSON_BINARY_SUBTYPE_USER_DEFINED:128},keysToCodecs={$oid:objectid,$binary:binary,$symbol:symbol,$numberInt:int_32,$numberDecimal:decimal128,$numberDouble:double_1,$numberLong:long_1,$minKey:min_key,$maxKey:max_key,$regularExpression:regexp,$timestamp:timestamp};function deserializeValue(e,t,r,n){if("number"==typeof r){if(n.relaxed)return r;if(Math.floor(r)===r){if(r>=BSON_INT32_MIN&&r<=BSON_INT32_MAX)return new int_32(r);if(r>=BSON_INT64_MIN&&r<=BSON_INT64_MAX)return new long_1.fromNumber(r)}return new double_1(r)}if(null==r||"object"!==_typeof(r))return r;if(r.$undefined)return null;for(var i=Object.keys(r).filter(function(e){return e.startsWith("$")&&null!=r[e]}),o=0;o<i.length;o++){var u=keysToCodecs[i[o]];if(u)return u.fromExtendedJSON(r,n)}if(null!=r.$date){var s=r.$date,a=new Date;return"string"==typeof s?a.setTime(Date.parse(s)):s instanceof long_1?a.setTime(s.toNumber()):"number"==typeof s&&n.relaxed&&a.setTime(s),a}if(null!=r.$code){var f=Object.assign({},r);return r.$scope&&(f.$scope=deserializeValue(e,null,r.$scope)),code.fromExtendedJSON(r)}if(null!=r.$ref||null!=r.$dbPointer){var l=r.$ref?r:r.$dbPointer;if(l instanceof db_ref)return l;var c=Object.keys(l).filter(function(e){return e.startsWith("$")}),h=!0;if(c.forEach(function(e){-1===["$ref","$id","$db"].indexOf(e)&&(h=!1)}),h)return db_ref.fromExtendedJSON(l)}return r}function parse(e,t){var r=this;return"boolean"==typeof(t=Object.assign({},{relaxed:!0},t)).relaxed&&(t.strict=!t.relaxed),"boolean"==typeof t.strict&&(t.relaxed=!t.strict),JSON.parse(e,function(e,n){return deserializeValue(r,e,n,t)})}var BSON_INT32_MAX=2147483647,BSON_INT32_MIN=-2147483648,BSON_INT64_MAX=0x8000000000000000,BSON_INT64_MIN=-0x8000000000000000;function stringify(e,t,r,n){null!=r&&"object"===_typeof(r)&&(n=r,r=0),null!=t&&"object"===_typeof(t)&&(n=t,t=null,r=0),n=Object.assign({},{relaxed:!0},n);var i=Array.isArray(e)?serializeArray(e,n):serializeDocument(e,n);return JSON.stringify(i,t,r)}function serialize(e,t){return t=t||{},JSON.parse(stringify(e,t))}function deserialize(e,t){return t=t||{},parse(JSON.stringify(e),t)}function serializeArray(e,t){return e.map(function(e){return serializeValue(e,t)})}function getISOString(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function serializeValue(e,t){if(Array.isArray(e))return serializeArray(e,t);if(void 0===e)return null;if(e instanceof Date){var r=e.getTime(),n=r>-1&&r<2534023188e5;return t.relaxed&&n?{$date:getISOString(e)}:{$date:{$numberLong:e.getTime().toString()}}}if("number"==typeof e&&!t.relaxed){if(Math.floor(e)===e){var i=e>=BSON_INT64_MIN&&e<=BSON_INT64_MAX;if(e>=BSON_INT32_MIN&&e<=BSON_INT32_MAX)return{$numberInt:e.toString()};if(i)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}return null!=e&&"object"===_typeof(e)?serializeDocument(e,t):e}function serializeDocument(e,t){if(null==e||"object"!==_typeof(e))throw new Error("not an object instance");if(e._bsontype&&"function"==typeof e.toExtendedJSON)return"Code"===e._bsontype&&e.scope?e.scope=serializeDocument(e.scope,t):"DBRef"===e._bsontype&&e.oid&&(e.oid=serializeDocument(e.oid,t)),e.toExtendedJSON(t);var r={};for(var n in e){var i=e[n];if(Array.isArray(i)?r[n]=serializeArray(i,t):null!=i&&"function"==typeof i.toExtendedJSON?("Code"===i._bsontype&&i.scope?i.scope=serializeDocument(i.scope,t):"DBRef"===i._bsontype&&i.oid&&(i.oid=serializeDocument(i.oid,t)),r[n]=i.toExtendedJSON(t)):i instanceof Date?r[n]=serializeValue(i,t):null!=i&&"object"===_typeof(i)&&(r[n]=serializeDocument(i,t)),r[n]=serializeValue(i,t),i instanceof RegExp){var o=i.flags;void 0===o&&(o=i.toString().match(/[gimuy]*$/)[0]);var u=new regexp(i.source,o);r[n]=u.toExtendedJSON()}}return r}var extended_json={parse:parse,deserialize:deserialize,serialize:serialize,stringify:stringify},FIRST_BIT=128,FIRST_TWO_BITS=192,FIRST_THREE_BITS=224,FIRST_FOUR_BITS=240,FIRST_FIVE_BITS=248,TWO_BIT_CHAR=192,THREE_BIT_CHAR=224,FOUR_BIT_CHAR=240,CONTINUING_CHAR=128;function validateUtf8(e,t,r){for(var n=0,i=t;i<r;i+=1){var o=e[i];if(n){if((o&FIRST_TWO_BITS)!==CONTINUING_CHAR)return!1;n-=1}else if(o&FIRST_BIT)if((o&FIRST_THREE_BITS)===TWO_BIT_CHAR)n=1;else if((o&FIRST_FOUR_BITS)===THREE_BIT_CHAR)n=2;else{if((o&FIRST_FIVE_BITS)!==FOUR_BIT_CHAR)return!1;n=3}}return!n}var validateUtf8_1=validateUtf8,validate_utf8={validateUtf8:validateUtf8_1},Buffer$2=buffer.Buffer,validateUtf8$1=validate_utf8.validateUtf8,JS_INT_MAX_LONG=long_1.fromNumber(constants.JS_INT_MAX),JS_INT_MIN_LONG=long_1.fromNumber(constants.JS_INT_MIN),functionCache={};function deserialize$1(e,t,r){var n=(t=null==t?{}:t)&&t.index?t.index:0,i=e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24;if(i<5)throw new Error("bson size must be >= 5, is ".concat(i));if(t.allowObjectSmallerThanBufferSize&&e.length<i)throw new Error("buffer length ".concat(e.length," must be >= bson size ").concat(i));if(!t.allowObjectSmallerThanBufferSize&&e.length!==i)throw new Error("buffer length ".concat(e.length," must === bson size ").concat(i));if(i+n>e.length)throw new Error("(bson size ".concat(i," + options.index ").concat(n," must be <= buffer length ").concat(Buffer$2.byteLength(e),")"));if(0!==e[n+i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return deserializeObject(e,n,t,r)}function deserializeObject(e,t,r,n){var i=null!=r.evalFunctions&&r.evalFunctions,o=null!=r.cacheFunctions&&r.cacheFunctions,u=null!=r.cacheFunctionsCrc32&&r.cacheFunctionsCrc32;if(!u)var s=null;var a=null==r.fieldsAsRaw?null:r.fieldsAsRaw,f=null!=r.raw&&r.raw,l="boolean"==typeof r.bsonRegExp&&r.bsonRegExp,c=null!=r.promoteBuffers&&r.promoteBuffers,h=null==r.promoteLongs||r.promoteLongs,p=null==r.promoteValues||r.promoteValues,g=t;if(e.length<5)throw new Error("corrupt bson message < 5 bytes long");var y=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(y<5||y>e.length)throw new Error("corrupt bson message");for(var d=n?[]:{},b=0;;){var _=e[t++];if(0===_)break;for(var v=t;0!==e[v]&&v<e.length;)v++;if(v>=Buffer$2.byteLength(e))throw new Error("Bad BSON Document: illegal CString");var A=n?b++:e.toString("utf8",t,v);if(t=v+1,_===constants.BSON_DATA_STRING){var m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||0!==e[t+m-1])throw new Error("bad string length in bson");if(!validateUtf8$1(e,t,t+m-1))throw new Error("Invalid UTF-8 string in BSON document");var B=e.toString("utf8",t,t+m-1);d[A]=B,t+=m}else if(_===constants.BSON_DATA_OID){var E=Buffer$2.alloc(12);e.copy(E,0,t,t+12),d[A]=new objectid(E),t+=12}else if(_===constants.BSON_DATA_INT&&!1===p)d[A]=new int_32(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(_===constants.BSON_DATA_INT)d[A]=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(_===constants.BSON_DATA_NUMBER&&!1===p)d[A]=new double_1(e.readDoubleLE(t)),t+=8;else if(_===constants.BSON_DATA_NUMBER)d[A]=e.readDoubleLE(t),t+=8;else if(_===constants.BSON_DATA_DATE){var N=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,S=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;d[A]=new Date(new long_1(N,S).toNumber())}else if(_===constants.BSON_DATA_BOOLEAN){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");d[A]=1===e[t++]}else if(_===constants.BSON_DATA_OBJECT){var w=t,O=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(O<=0||O>e.length-t)throw new Error("bad embedded document length in bson");d[A]=f?e.slice(t,t+O):deserializeObject(e,w,r,!1),t+=O}else if(_===constants.BSON_DATA_ARRAY){var T=t,D=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,I=r,F=t+D;if(a&&a[A]){for(var R in I={},r)I[R]=r[R];I.raw=!0}if(d[A]=deserializeObject(e,T,I,!0),0!==e[(t+=D)-1])throw new Error("invalid array terminator byte");if(t!==F)throw new Error("corrupted array bson")}else if(_===constants.BSON_DATA_UNDEFINED)d[A]=void 0;else if(_===constants.BSON_DATA_NULL)d[A]=null;else if(_===constants.BSON_DATA_LONG){var x=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,C=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,U=new long_1(x,C);d[A]=h&&!0===p&&U.lessThanOrEqual(JS_INT_MAX_LONG)&&U.greaterThanOrEqual(JS_INT_MIN_LONG)?U.toNumber():U}else if(_===constants.BSON_DATA_DECIMAL128){var M=Buffer$2.alloc(16);e.copy(M,0,t,t+16),t+=16;var k=new decimal128(M);d[A]=k.toObject?k.toObject():k}else if(_===constants.BSON_DATA_BINARY){var P=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,L=P,j=e[t++];if(P<0)throw new Error("Negative binary type element size found");if(P>Buffer$2.byteLength(e))throw new Error("Binary type size larger than document size");if(null!=e.slice){if(j===binary.SUBTYPE_BYTE_ARRAY){if((P=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(P>L-4)throw new Error("Binary type with subtype 0x02 contains to long binary size");if(P<L-4)throw new Error("Binary type with subtype 0x02 contains to short binary size")}d[A]=c&&p?e.slice(t,t+P):new binary(e.slice(t,t+P),j)}else{var z="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(P)):new Array(P);if(j===binary.SUBTYPE_BYTE_ARRAY){if((P=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(P>L-4)throw new Error("Binary type with subtype 0x02 contains to long binary size");if(P<L-4)throw new Error("Binary type with subtype 0x02 contains to short binary size")}for(v=0;v<P;v++)z[v]=e[t+v];d[A]=c&&p?z:new binary(z,j)}t+=P}else if(_===constants.BSON_DATA_REGEXP&&!1===l){for(v=t;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");var $=e.toString("utf8",t,v);for(v=t=v+1;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");var Y=e.toString("utf8",t,v);t=v+1;var J=new Array(Y.length);for(v=0;v<Y.length;v++)switch(Y[v]){case"m":J[v]="m";break;case"s":J[v]="g";break;case"i":J[v]="i"}d[A]=new RegExp($,J.join(""))}else if(_===constants.BSON_DATA_REGEXP&&!0===l){for(v=t;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");var X=e.toString("utf8",t,v);for(v=t=v+1;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");var G=e.toString("utf8",t,v);t=v+1,d[A]=new regexp(X,G)}else if(_===constants.BSON_DATA_SYMBOL){var H=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(H<=0||H>e.length-t||0!==e[t+H-1])throw new Error("bad string length in bson");d[A]=e.toString("utf8",t,t+H-1),t+=H}else if(_===constants.BSON_DATA_TIMESTAMP){var q=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,V=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;d[A]=new timestamp(q,V)}else if(_===constants.BSON_DATA_MIN_KEY)d[A]=new min_key;else if(_===constants.BSON_DATA_MAX_KEY)d[A]=new max_key;else if(_===constants.BSON_DATA_CODE){var Z=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(Z<=0||Z>e.length-t||0!==e[t+Z-1])throw new Error("bad string length in bson");var K=e.toString("utf8",t,t+Z-1);if(i)if(o){var W=u?s(K):K;d[A]=isolateEvalWithHash(functionCache,W,K,d)}else d[A]=isolateEval(K);else d[A]=new code(K);t+=Z}else if(_===constants.BSON_DATA_CODE_W_SCOPE){var Q=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(Q<13)throw new Error("code_w_scope total size shorter minimum expected length");var ee=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(ee<=0||ee>e.length-t||0!==e[t+ee-1])throw new Error("bad string length in bson");var te=e.toString("utf8",t,t+ee-1),re=t+=ee,ne=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,ie=deserializeObject(e,re,r,!1);if(t+=ne,Q<8+ne+ee)throw new Error("code_w_scope total size is to short, truncating scope");if(Q>8+ne+ee)throw new Error("code_w_scope total size is to long, clips outer document");if(i){if(o){var oe=u?s(te):te;d[A]=isolateEvalWithHash(functionCache,oe,te,d)}else d[A]=isolateEval(te);d[A].scope=ie}else d[A]=new code(te,ie)}else{if(_!==constants.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+_.toString(16)+' for fieldname "'+A+'", are you using the latest BSON parser?');var ue=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(ue<=0||ue>e.length-t||0!==e[t+ue-1])throw new Error("bad string length in bson");if(!validateUtf8$1(e,t,t+ue-1))throw new Error("Invalid UTF-8 string in BSON document");var se=e.toString("utf8",t,t+ue-1);t+=ue;var ae=Buffer$2.alloc(12);e.copy(ae,0,t,t+12);var fe=new objectid(ae);t+=12,d[A]=new db_ref(se,fe)}}if(y!==t-g){if(n)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}var le=Object.keys(d).filter(function(e){return e.startsWith("$")}),ce=!0;if(le.forEach(function(e){-1===["$ref","$id","$db"].indexOf(e)&&(ce=!1)}),!ce)return d;if(null!=d.$id&&null!=d.$ref){var he=Object.assign({},d);return delete he.$ref,delete he.$id,delete he.$db,new db_ref(d.$ref,d.$id,d.$db||null,he)}return d}function isolateEvalWithHash(functionCache,hash,functionString,object){var value=null;return null==functionCache[hash]&&(eval("value = "+functionString),functionCache[hash]=value),functionCache[hash].bind(object)}function isolateEval(functionString){var value=null;return eval("value = "+functionString),value}var deserializer=deserialize$1;function readIEEE754(e,t,r,n,i){var o,u,s="big"===r,a=8*i-n-1,f=(1<<a)-1,l=f>>1,c=-7,h=s?0:i-1,p=s?1:-1,g=e[t+h];for(h+=p,o=g&(1<<-c)-1,g>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=p,c-=8);for(u=o&(1<<-c)-1,o>>=-c,c+=n;c>0;u=256*u+e[t+h],h+=p,c-=8);if(0===o)o=1-l;else{if(o===f)return u?NaN:1/0*(g?-1:1);u+=Math.pow(2,n),o-=l}return(g?-1:1)*u*Math.pow(2,o-n)}function writeIEEE754(e,t,r,n,i,o){var u,s,a,f="big"===n,l=8*o-i-1,c=(1<<l)-1,h=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,g=f?o-1:0,y=f?-1:1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,u=c):(u=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-u))<1&&(u--,a*=2),(t+=u+h>=1?p/a:p*Math.pow(2,1-h))*a>=2&&(u++,a/=2),u+h>=c?(s=0,u=c):u+h>=1?(s=(t*a-1)*Math.pow(2,i),u+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),u=0)),isNaN(t)&&(s=0);i>=8;)e[r+g]=255&s,g+=y,s/=256,i-=8;for(u=u<<i|s,isNaN(t)&&(u+=8),l+=i;l>0;)e[r+g]=255&u,g+=y,u/=256,l-=8;e[r+g-y]|=128*d}var float_parser={readIEEE754:readIEEE754,writeIEEE754:writeIEEE754},Buffer$3=buffer.Buffer,writeIEEE754$1=float_parser.writeIEEE754,normalizedFunctionString$1=utils.normalizedFunctionString,regexp$1=/\x00/,ignoreKeys=new Set(["$db","$ref","$id","$clusterTime"]),isDate$1=function(e){return"object"===_typeof(e)&&"[object Date]"===Object.prototype.toString.call(e)},isRegExp$1=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)};function serializeString(e,t,r,n,i){e[n++]=constants.BSON_DATA_STRING;var o=i?e.write(t,n,"ascii"):e.write(t,n,"utf8");e[(n=n+o+1)-1]=0;var u=e.write(r,n+4,"utf8");return e[n+3]=u+1>>24&255,e[n+2]=u+1>>16&255,e[n+1]=u+1>>8&255,e[n]=u+1&255,n=n+4+u,e[n++]=0,n}function serializeNumber(e,t,r,n,i){if(Math.floor(r)===r&&r>=constants.JS_INT_MIN&&r<=constants.JS_INT_MAX)if(r>=constants.BSON_INT32_MIN&&r<=constants.BSON_INT32_MAX)e[n++]=constants.BSON_DATA_INT,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=r>>16&255,e[n++]=r>>24&255;else if(r>=constants.JS_INT_MIN&&r<=constants.JS_INT_MAX){e[n++]=constants.BSON_DATA_NUMBER,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,writeIEEE754$1(e,r,n,"little",52,8),n+=8}else{e[n++]=constants.BSON_DATA_LONG,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var o=long_1.fromNumber(r),u=o.getLowBits(),s=o.getHighBits();e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255,e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255}else e[n++]=constants.BSON_DATA_NUMBER,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,writeIEEE754$1(e,r,n,"little",52,8),n+=8;return n}function serializeNull(e,t,r,n,i){return e[n++]=constants.BSON_DATA_NULL,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,n}function serializeBoolean(e,t,r,n,i){return e[n++]=constants.BSON_DATA_BOOLEAN,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,e[n++]=r?1:0,n}function serializeDate(e,t,r,n,i){e[n++]=constants.BSON_DATA_DATE,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var o=long_1.fromNumber(r.getTime()),u=o.getLowBits(),s=o.getHighBits();return e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255,e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,n}function serializeRegExp(e,t,r,n,i){if(e[n++]=constants.BSON_DATA_REGEXP,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,r.source&&null!=r.source.match(regexp$1))throw Error("value "+r.source+" must not contain null bytes");return n+=e.write(r.source,n,"utf8"),e[n++]=0,r.ignoreCase&&(e[n++]=105),r.global&&(e[n++]=115),r.multiline&&(e[n++]=109),e[n++]=0,n}function serializeBSONRegExp(e,t,r,n,i){if(e[n++]=constants.BSON_DATA_REGEXP,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,null!=r.pattern.match(regexp$1))throw Error("pattern "+r.pattern+" must not contain null bytes");return n+=e.write(r.pattern,n,"utf8"),e[n++]=0,n+=e.write(r.options.split("").sort().join(""),n,"utf8"),e[n++]=0,n}function serializeMinMax(e,t,r,n,i){return e[n++]=null===r?constants.BSON_DATA_NULL:r instanceof min_key?constants.BSON_DATA_MIN_KEY:constants.BSON_DATA_MAX_KEY,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,n}function serializeObjectId(e,t,r,n,i){if(e[n++]=constants.BSON_DATA_OID,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,"string"==typeof r.id)e.write(r.id,n,"binary");else{if(!r.id||!r.id.copy)throw new TypeError("object ["+JSON.stringify(r)+"] is not a valid ObjectId");r.id.copy(e,n,0,12)}return n+12}function serializeBuffer(e,t,r,n,i){e[n++]=constants.BSON_DATA_BINARY,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var o=r.length;return e[n++]=255&o,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=constants.BSON_BINARY_SUBTYPE_DEFAULT,r.copy(e,n,0,o),n+=o}function serializeObject(e,t,r,n,i,o,u,s,a,f){for(var l=0;l<f.length;l++)if(f[l]===r)throw new Error("cyclic dependency detected");f.push(r),e[n++]=Array.isArray(r)?constants.BSON_DATA_ARRAY:constants.BSON_DATA_OBJECT,n+=a?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var c=serializeInto(e,r,i,n,o+1,u,s,f);return f.pop(),c}function serializeDecimal128(e,t,r,n,i){return e[n++]=constants.BSON_DATA_DECIMAL128,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,r.bytes.copy(e,n,0,16),n+16}function serializeLong(e,t,r,n,i){e[n++]="Long"===r._bsontype?constants.BSON_DATA_LONG:constants.BSON_DATA_TIMESTAMP,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var o=r.getLowBits(),u=r.getHighBits();return e[n++]=255&o,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255,n}function serializeInt32(e,t,r,n,i){return e[n++]=constants.BSON_DATA_INT,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=r>>16&255,e[n++]=r>>24&255,n}function serializeDouble(e,t,r,n,i){return e[n++]=constants.BSON_DATA_NUMBER,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0,writeIEEE754$1(e,r.value,n,"little",52,8),n+=8}function serializeFunction(e,t,r,n,i,o,u){e[n++]=constants.BSON_DATA_CODE,n+=u?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var s=normalizedFunctionString$1(r),a=e.write(s,n+4,"utf8")+1;return e[n]=255&a,e[n+1]=a>>8&255,e[n+2]=a>>16&255,e[n+3]=a>>24&255,n=n+4+a-1,e[n++]=0,n}function serializeCode(e,t,r,n,i,o,u,s,a){if(r.scope&&"object"===_typeof(r.scope)){e[n++]=constants.BSON_DATA_CODE_W_SCOPE,n+=a?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var f=n,l="string"==typeof r.code?r.code:r.code.toString();n+=4;var c=e.write(l,n+4,"utf8")+1;e[n]=255&c,e[n+1]=c>>8&255,e[n+2]=c>>16&255,e[n+3]=c>>24&255,e[n+4+c-1]=0,n=n+c+4;var h=serializeInto(e,r.scope,i,n,o+1,u,s);n=h-1;var p=h-f;e[f++]=255&p,e[f++]=p>>8&255,e[f++]=p>>16&255,e[f++]=p>>24&255,e[n++]=0}else{e[n++]=constants.BSON_DATA_CODE,n+=a?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var g=r.code.toString(),y=e.write(g,n+4,"utf8")+1;e[n]=255&y,e[n+1]=y>>8&255,e[n+2]=y>>16&255,e[n+3]=y>>24&255,n=n+4+y-1,e[n++]=0}return n}function serializeBinary(e,t,r,n,i){e[n++]=constants.BSON_DATA_BINARY,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var o=r.value(!0),u=r.position;return r.sub_type===binary.SUBTYPE_BYTE_ARRAY&&(u+=4),e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255,e[n++]=r.sub_type,r.sub_type===binary.SUBTYPE_BYTE_ARRAY&&(u-=4,e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255),o.copy(e,n,0,r.position),n+=r.position}function serializeSymbol(e,t,r,n,i){e[n++]=constants.BSON_DATA_SYMBOL,n+=i?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var o=e.write(r.value,n+4,"utf8")+1;return e[n]=255&o,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0,n}function serializeDBRef(e,t,r,n,i,o,u){e[n++]=constants.BSON_DATA_OBJECT,n+=u?e.write(t,n,"ascii"):e.write(t,n,"utf8"),e[n++]=0;var s,a=n,f={$ref:r.collection,$id:r.oid};null!=r.db&&(f.$db=r.db);var l=(s=serializeInto(e,f=Object.assign(f,r.fields),!1,n,i+1,o))-a;return e[a++]=255&l,e[a++]=l>>8&255,e[a++]=l>>16&255,e[a++]=l>>24&255,s}function serializeInto(e,t,r,n,i,o,u,s){n=n||0,(s=s||[]).push(t);var a=n+4;if(Array.isArray(t))for(var f=0;f<t.length;f++){var l=""+f,c=t[f];if(c&&c.toBSON){if("function"!=typeof c.toBSON)throw new TypeError("toBSON is not a function");c=c.toBSON()}var h=_typeof(c);"string"===h?a=serializeString(e,l,c,a,!0):"number"===h?a=serializeNumber(e,l,c,a,!0):"boolean"===h?a=serializeBoolean(e,l,c,a,!0):c instanceof Date||isDate$1(c)?a=serializeDate(e,l,c,a,!0):void 0===c?a=serializeNull(e,l,c,a,!0):null===c?a=serializeNull(e,l,c,a,!0):"ObjectId"===c._bsontype||"ObjectID"===c._bsontype?a=serializeObjectId(e,l,c,a,!0):Buffer$3.isBuffer(c)?a=serializeBuffer(e,l,c,a,!0):c instanceof RegExp||isRegExp$1(c)?a=serializeRegExp(e,l,c,a,!0):"object"===h&&null==c._bsontype?a=serializeObject(e,l,c,a,r,i,o,u,!0,s):"object"===h&&"Decimal128"===c._bsontype?a=serializeDecimal128(e,l,c,a,!0):"Long"===c._bsontype||"Timestamp"===c._bsontype?a=serializeLong(e,l,c,a,!0):"Double"===c._bsontype?a=serializeDouble(e,l,c,a,!0):"function"==typeof c&&o?a=serializeFunction(e,l,c,a,r,i,o,!0):"Code"===c._bsontype?a=serializeCode(e,l,c,a,r,i,o,u,!0):"Binary"===c._bsontype?a=serializeBinary(e,l,c,a,!0):"Symbol"===c._bsontype?a=serializeSymbol(e,l,c,a,!0):"DBRef"===c._bsontype?a=serializeDBRef(e,l,c,a,i,o,!0):"BSONRegExp"===c._bsontype?a=serializeBSONRegExp(e,l,c,a,!0):"Int32"===c._bsontype?a=serializeInt32(e,l,c,a,!0):"MinKey"!==c._bsontype&&"MaxKey"!==c._bsontype||(a=serializeMinMax(e,l,c,a,!0))}else if(t instanceof map)for(var p=t.entries(),g=!1;!g;){var y=p.next();if(!(g=y.done)){var d=y.value[0],b=y.value[1],_=_typeof(b);if("string"==typeof d&&!ignoreKeys.has(d)){if(null!=d.match(regexp$1))throw Error("key "+d+" must not contain null bytes");if(r){if("$"===d[0])throw Error("key "+d+" must not start with '$'");if(~d.indexOf("."))throw Error("key "+d+" must not contain '.'")}}"string"===_?a=serializeString(e,d,b,a):"number"===_?a=serializeNumber(e,d,b,a):"boolean"===_?a=serializeBoolean(e,d,b,a):b instanceof Date||isDate$1(b)?a=serializeDate(e,d,b,a):null===b||void 0===b&&!1===u?a=serializeNull(e,d,b,a):"ObjectId"===b._bsontype||"ObjectID"===b._bsontype?a=serializeObjectId(e,d,b,a):Buffer$3.isBuffer(b)?a=serializeBuffer(e,d,b,a):b instanceof RegExp||isRegExp$1(b)?a=serializeRegExp(e,d,b,a):"object"===_&&null==b._bsontype?a=serializeObject(e,d,b,a,r,i,o,u,!1,s):"object"===_&&"Decimal128"===b._bsontype?a=serializeDecimal128(e,d,b,a):"Long"===b._bsontype||"Timestamp"===b._bsontype?a=serializeLong(e,d,b,a):"Double"===b._bsontype?a=serializeDouble(e,d,b,a):"Code"===b._bsontype?a=serializeCode(e,d,b,a,r,i,o,u):"function"==typeof b&&o?a=serializeFunction(e,d,b,a,r,i,o):"Binary"===b._bsontype?a=serializeBinary(e,d,b,a):"Symbol"===b._bsontype?a=serializeSymbol(e,d,b,a):"DBRef"===b._bsontype?a=serializeDBRef(e,d,b,a,i,o):"BSONRegExp"===b._bsontype?a=serializeBSONRegExp(e,d,b,a):"Int32"===b._bsontype?a=serializeInt32(e,d,b,a):"MinKey"!==b._bsontype&&"MaxKey"!==b._bsontype||(a=serializeMinMax(e,d,b,a))}}else{if(t.toBSON){if("function"!=typeof t.toBSON)throw new TypeError("toBSON is not a function");if(null!=(t=t.toBSON())&&"object"!==_typeof(t))throw new TypeError("toBSON function did not return an object")}for(var v in t){var A=t[v];if(A&&A.toBSON){if("function"!=typeof A.toBSON)throw new TypeError("toBSON is not a function");A=A.toBSON()}var m=_typeof(A);if("string"==typeof v&&!ignoreKeys.has(v)){if(null!=v.match(regexp$1))throw Error("key "+v+" must not contain null bytes");if(r){if("$"===v[0])throw Error("key "+v+" must not start with '$'");if(~v.indexOf("."))throw Error("key "+v+" must not contain '.'")}}"string"===m?a=serializeString(e,v,A,a):"number"===m?a=serializeNumber(e,v,A,a):"boolean"===m?a=serializeBoolean(e,v,A,a):A instanceof Date||isDate$1(A)?a=serializeDate(e,v,A,a):void 0===A?!1===u&&(a=serializeNull(e,v,A,a)):null===A?a=serializeNull(e,v,A,a):"ObjectId"===A._bsontype||"ObjectID"===A._bsontype?a=serializeObjectId(e,v,A,a):Buffer$3.isBuffer(A)?a=serializeBuffer(e,v,A,a):A instanceof RegExp||isRegExp$1(A)?a=serializeRegExp(e,v,A,a):"object"===m&&null==A._bsontype?a=serializeObject(e,v,A,a,r,i,o,u,!1,s):"object"===m&&"Decimal128"===A._bsontype?a=serializeDecimal128(e,v,A,a):"Long"===A._bsontype||"Timestamp"===A._bsontype?a=serializeLong(e,v,A,a):"Double"===A._bsontype?a=serializeDouble(e,v,A,a):"Code"===A._bsontype?a=serializeCode(e,v,A,a,r,i,o,u):"function"==typeof A&&o?a=serializeFunction(e,v,A,a,r,i,o):"Binary"===A._bsontype?a=serializeBinary(e,v,A,a):"Symbol"===A._bsontype?a=serializeSymbol(e,v,A,a):"DBRef"===A._bsontype?a=serializeDBRef(e,v,A,a,i,o):"BSONRegExp"===A._bsontype?a=serializeBSONRegExp(e,v,A,a):"Int32"===A._bsontype?a=serializeInt32(e,v,A,a):"MinKey"!==A._bsontype&&"MaxKey"!==A._bsontype||(a=serializeMinMax(e,v,A,a))}}s.pop(),e[a++]=0;var B=a-n;return e[n++]=255&B,e[n++]=B>>8&255,e[n++]=B>>16&255,e[n++]=B>>24&255,a}var serializer=serializeInto,Buffer$4=buffer.Buffer,normalizedFunctionString$2=utils.normalizedFunctionString;function isDate$2(e){return"object"===_typeof(e)&&"[object Date]"===Object.prototype.toString.call(e)}function calculateObjectSize(e,t,r){var n=5;if(Array.isArray(e))for(var i=0;i<e.length;i++)n+=calculateElement(i.toString(),e[i],t,!0,r);else for(var o in e.toBSON&&(e=e.toBSON()),e)n+=calculateElement(o,e[o],t,!1,r);return n}function calculateElement(e,t,r,n,i){switch(t&&t.toBSON&&(t=t.toBSON()),_typeof(t)){case"string":return 1+Buffer$4.byteLength(e,"utf8")+1+4+Buffer$4.byteLength(t,"utf8")+1;case"number":return Math.floor(t)===t&&t>=constants.JS_INT_MIN&&t<=constants.JS_INT_MAX&&t>=constants.BSON_INT32_MIN&&t<=constants.BSON_INT32_MAX?(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+5:(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+9;case"undefined":return n||!i?(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||t instanceof min_key||t instanceof max_key||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1;if(t instanceof objectid||"ObjectId"===t._bsontype)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||isDate$2(t))return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+9;if(void 0!==Buffer$4&&Buffer$4.isBuffer(t))return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+6+t.length;if(t instanceof long_1||t instanceof double_1||t instanceof timestamp||"Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+9;if(t instanceof decimal128||"Decimal128"===t._bsontype)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+17;if(t instanceof code||"Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+4+4+Buffer$4.byteLength(t.code.toString(),"utf8")+1+calculateObjectSize(t.scope,r,i):(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+4+Buffer$4.byteLength(t.code.toString(),"utf8")+1;if(t instanceof binary||"Binary"===t._bsontype)return t.sub_type===binary.SUBTYPE_BYTE_ARRAY?(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if(t instanceof symbol||"Symbol"===t._bsontype)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+Buffer$4.byteLength(t.value,"utf8")+4+1+1;if(t instanceof db_ref||"DBRef"===t._bsontype){var o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(o.$db=t.db),(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+calculateObjectSize(o,r,i)}return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)?(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+Buffer$4.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:t instanceof regexp||"BSONRegExp"===t._bsontype?(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+Buffer$4.byteLength(t.pattern,"utf8")+1+Buffer$4.byteLength(t.options,"utf8")+1:(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+calculateObjectSize(t,r,i)+1;case"function":if(t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)||"[object RegExp]"===String.call(t))return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+Buffer$4.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(r&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+4+4+Buffer$4.byteLength(normalizedFunctionString$2(t),"utf8")+1+calculateObjectSize(t.scope,r,i);if(r)return(null!=e?Buffer$4.byteLength(e,"utf8")+1:0)+1+4+Buffer$4.byteLength(normalizedFunctionString$2(t),"utf8")+1}return 0}var calculate_size=calculateObjectSize,Buffer$5=buffer.Buffer,ensure_buffer=function(e){if(e instanceof Buffer$5)return e;if(e instanceof Uint8Array)return Buffer$5.from(e.buffer);throw new TypeError("Must use either Buffer or Uint8Array")},Buffer$6=buffer.Buffer,MAXSIZE=17825792,buffer$1=Buffer$6.alloc(MAXSIZE);function setInternalBufferSize(e){buffer$1.length<e&&(buffer$1=Buffer$6.alloc(e))}function serialize$1(e,t){var r="boolean"==typeof(t=t||{}).checkKeys&&t.checkKeys,n="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,i="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,o="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:MAXSIZE;buffer$1.length<o&&(buffer$1=Buffer$6.alloc(o));var u=serializer(buffer$1,e,r,0,0,n,i,[]),s=Buffer$6.alloc(u);return buffer$1.copy(s,0,0,s.length),s}function serializeWithBufferAndIndex(e,t,r){var n="boolean"==typeof(r=r||{}).checkKeys&&r.checkKeys,i="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,o="boolean"!=typeof r.ignoreUndefined||r.ignoreUndefined,u="number"==typeof r.index?r.index:0,s=serializer(buffer$1,e,n,0,0,i,o);return buffer$1.copy(t,u,0,s),u+s-1}function deserialize$2(e,t){return e=ensure_buffer(e),deserializer(e,t)}function calculateObjectSize$1(e,t){var r="boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,n="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined;return calculate_size(e,r,n)}function deserializeStream(e,t,r,n,i,o){o=Object.assign({allowObjectSmallerThanBufferSize:!0},o),e=ensure_buffer(e);for(var u=t,s=0;s<r;s++){var a=e[u]|e[u+1]<<8|e[u+2]<<16|e[u+3]<<24;o.index=u,n[i+s]=deserializer(e,o),u+=a}return u}var bson={BSON_INT32_MAX:constants.BSON_INT32_MAX,BSON_INT32_MIN:constants.BSON_INT32_MIN,BSON_INT64_MAX:constants.BSON_INT64_MAX,BSON_INT64_MIN:constants.BSON_INT64_MIN,JS_INT_MAX:constants.JS_INT_MAX,JS_INT_MIN:constants.JS_INT_MIN,BSON_DATA_NUMBER:constants.BSON_DATA_NUMBER,BSON_DATA_STRING:constants.BSON_DATA_STRING,BSON_DATA_OBJECT:constants.BSON_DATA_OBJECT,BSON_DATA_ARRAY:constants.BSON_DATA_ARRAY,BSON_DATA_BINARY:constants.BSON_DATA_BINARY,BSON_DATA_UNDEFINED:constants.BSON_DATA_UNDEFINED,BSON_DATA_OID:constants.BSON_DATA_OID,BSON_DATA_BOOLEAN:constants.BSON_DATA_BOOLEAN,BSON_DATA_DATE:constants.BSON_DATA_DATE,BSON_DATA_NULL:constants.BSON_DATA_NULL,BSON_DATA_REGEXP:constants.BSON_DATA_REGEXP,BSON_DATA_DBPOINTER:constants.BSON_DATA_DBPOINTER,BSON_DATA_CODE:constants.BSON_DATA_CODE,BSON_DATA_SYMBOL:constants.BSON_DATA_SYMBOL,BSON_DATA_CODE_W_SCOPE:constants.BSON_DATA_CODE_W_SCOPE,BSON_DATA_INT:constants.BSON_DATA_INT,BSON_DATA_TIMESTAMP:constants.BSON_DATA_TIMESTAMP,BSON_DATA_LONG:constants.BSON_DATA_LONG,BSON_DATA_DECIMAL128:constants.BSON_DATA_DECIMAL128,BSON_DATA_MIN_KEY:constants.BSON_DATA_MIN_KEY,BSON_DATA_MAX_KEY:constants.BSON_DATA_MAX_KEY,BSON_BINARY_SUBTYPE_DEFAULT:constants.BSON_BINARY_SUBTYPE_DEFAULT,BSON_BINARY_SUBTYPE_FUNCTION:constants.BSON_BINARY_SUBTYPE_FUNCTION,BSON_BINARY_SUBTYPE_BYTE_ARRAY:constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY,BSON_BINARY_SUBTYPE_UUID:constants.BSON_BINARY_SUBTYPE_UUID,BSON_BINARY_SUBTYPE_MD5:constants.BSON_BINARY_SUBTYPE_MD5,BSON_BINARY_SUBTYPE_USER_DEFINED:constants.BSON_BINARY_SUBTYPE_USER_DEFINED,Code:code,Map:map,BSONSymbol:symbol,DBRef:db_ref,Binary:binary,ObjectId:objectid,Long:long_1,Timestamp:timestamp,Double:double_1,Int32:int_32,MinKey:min_key,MaxKey:max_key,BSONRegExp:regexp,Decimal128:decimal128,serialize:serialize$1,serializeWithBufferAndIndex:serializeWithBufferAndIndex,deserialize:deserialize$2,calculateObjectSize:calculateObjectSize$1,deserializeStream:deserializeStream,setInternalBufferSize:setInternalBufferSize,ObjectID:objectid,EJSON:extended_json},bson_1=bson.BSON_INT32_MAX,bson_2=bson.BSON_INT32_MIN,bson_3=bson.BSON_INT64_MAX,bson_4=bson.BSON_INT64_MIN,bson_5=bson.JS_INT_MAX,bson_6=bson.JS_INT_MIN,bson_7=bson.BSON_DATA_NUMBER,bson_8=bson.BSON_DATA_STRING,bson_9=bson.BSON_DATA_OBJECT,bson_10=bson.BSON_DATA_ARRAY,bson_11=bson.BSON_DATA_BINARY,bson_12=bson.BSON_DATA_UNDEFINED,bson_13=bson.BSON_DATA_OID,bson_14=bson.BSON_DATA_BOOLEAN,bson_15=bson.BSON_DATA_DATE,bson_16=bson.BSON_DATA_NULL,bson_17=bson.BSON_DATA_REGEXP,bson_18=bson.BSON_DATA_DBPOINTER,bson_19=bson.BSON_DATA_CODE,bson_20=bson.BSON_DATA_SYMBOL,bson_21=bson.BSON_DATA_CODE_W_SCOPE,bson_22=bson.BSON_DATA_INT,bson_23=bson.BSON_DATA_TIMESTAMP,bson_24=bson.BSON_DATA_LONG,bson_25=bson.BSON_DATA_DECIMAL128,bson_26=bson.BSON_DATA_MIN_KEY,bson_27=bson.BSON_DATA_MAX_KEY,bson_28=bson.BSON_BINARY_SUBTYPE_DEFAULT,bson_29=bson.BSON_BINARY_SUBTYPE_FUNCTION,bson_30=bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY,bson_31=bson.BSON_BINARY_SUBTYPE_UUID,bson_32=bson.BSON_BINARY_SUBTYPE_MD5,bson_33=bson.BSON_BINARY_SUBTYPE_USER_DEFINED,bson_34=bson.Code,bson_35=bson.BSONSymbol,bson_36=bson.DBRef,bson_37=bson.Binary,bson_38=bson.ObjectId,bson_39=bson.Long,bson_40=bson.Timestamp,bson_41=bson.Double,bson_42=bson.Int32,bson_43=bson.MinKey,bson_44=bson.MaxKey,bson_45=bson.BSONRegExp,bson_46=bson.Decimal128,bson_47=bson.serialize,bson_48=bson.serializeWithBufferAndIndex,bson_49=bson.deserialize,bson_50=bson.calculateObjectSize,bson_51=bson.deserializeStream,bson_52=bson.setInternalBufferSize,bson_53=bson.ObjectID,bson_54=bson.EJSON;exports.default=bson,exports.BSON_INT32_MAX=bson_1,exports.BSON_INT32_MIN=bson_2,exports.BSON_INT64_MAX=bson_3,exports.BSON_INT64_MIN=bson_4,exports.JS_INT_MAX=bson_5,exports.JS_INT_MIN=bson_6,exports.BSON_DATA_NUMBER=bson_7,exports.BSON_DATA_STRING=bson_8,exports.BSON_DATA_OBJECT=bson_9,exports.BSON_DATA_ARRAY=bson_10,exports.BSON_DATA_BINARY=bson_11,exports.BSON_DATA_UNDEFINED=bson_12,exports.BSON_DATA_OID=bson_13,exports.BSON_DATA_BOOLEAN=bson_14,exports.BSON_DATA_DATE=bson_15,exports.BSON_DATA_NULL=bson_16,exports.BSON_DATA_REGEXP=bson_17,exports.BSON_DATA_DBPOINTER=bson_18,exports.BSON_DATA_CODE=bson_19,exports.BSON_DATA_SYMBOL=bson_20,exports.BSON_DATA_CODE_W_SCOPE=bson_21,exports.BSON_DATA_INT=bson_22,exports.BSON_DATA_TIMESTAMP=bson_23,exports.BSON_DATA_LONG=bson_24,exports.BSON_DATA_DECIMAL128=bson_25,exports.BSON_DATA_MIN_KEY=bson_26,exports.BSON_DATA_MAX_KEY=bson_27,exports.BSON_BINARY_SUBTYPE_DEFAULT=bson_28,exports.BSON_BINARY_SUBTYPE_FUNCTION=bson_29,exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY=bson_30,exports.BSON_BINARY_SUBTYPE_UUID=bson_31,exports.BSON_BINARY_SUBTYPE_MD5=bson_32,exports.BSON_BINARY_SUBTYPE_USER_DEFINED=bson_33,exports.Code=bson_34,exports.BSONSymbol=bson_35,exports.DBRef=bson_36,exports.Binary=bson_37,exports.ObjectId=bson_38,exports.Long=bson_39,exports.Timestamp=bson_40,exports.Double=bson_41,exports.Int32=bson_42,exports.MinKey=bson_43,exports.MaxKey=bson_44,exports.BSONRegExp=bson_45,exports.Decimal128=bson_46,exports.serialize=bson_47,exports.serializeWithBufferAndIndex=bson_48,exports.deserialize=bson_49,exports.calculateObjectSize=bson_50,exports.deserializeStream=bson_51,exports.setInternalBufferSize=bson_52,exports.ObjectID=bson_53,exports.EJSON=bson_54,Object.defineProperty(exports,"__esModule",{value:!0})},factory(exports,__webpack_require__(1070),__webpack_require__(5))}).call(this,__webpack_require__(17),__webpack_require__(5).Buffer)},58:function(e,t,r){"use strict";t.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=f(e),n=r[0],u=r[1],s=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,u)),a=0,l=u>0?n-4:n,c=0;c<l;c+=4)t=i[e.charCodeAt(c)]<<18|i[e.charCodeAt(c+1)]<<12|i[e.charCodeAt(c+2)]<<6|i[e.charCodeAt(c+3)],s[a++]=t>>16&255,s[a++]=t>>8&255,s[a++]=255&t;2===u&&(t=i[e.charCodeAt(c)]<<2|i[e.charCodeAt(c+1)]>>4,s[a++]=255&t);1===u&&(t=i[e.charCodeAt(c)]<<10|i[e.charCodeAt(c+1)]<<4|i[e.charCodeAt(c+2)]>>2,s[a++]=t>>8&255,s[a++]=255&t);return s},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],u=0,s=r-i;u<s;u+=16383)o.push(l(e,u,u+16383>s?s:u+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s<a;++s)n[s]=u[s],i[u.charCodeAt(s)]=s;function f(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var i,o,u=[],s=t;s<r;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),u.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return u.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},59:function(e,t){t.read=function(e,t,r,n,i){var o,u,s=8*i-n-1,a=(1<<s)-1,f=a>>1,l=-7,c=r?i-1:0,h=r?-1:1,p=e[t+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+e[t+c],c+=h,l-=8);for(u=o&(1<<-l)-1,o>>=-l,l+=n;l>0;u=256*u+e[t+c],c+=h,l-=8);if(0===o)o=1-f;else{if(o===a)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,n),o-=f}return(p?-1:1)*u*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var u,s,a,f=8*o-i-1,l=(1<<f)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,g=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,u=l):(u=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-u))<1&&(u--,a*=2),(t+=u+c>=1?h/a:h*Math.pow(2,1-c))*a>=2&&(u++,a/=2),u+c>=l?(s=0,u=l):u+c>=1?(s=(t*a-1)*Math.pow(2,i),u+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,i),u=0));i>=8;e[r+p]=255&s,p+=g,s/=256,i-=8);for(u=u<<i|s,f+=i;f>0;e[r+p]=255&u,p+=g,u/=256,f-=8);e[r+p-g]|=128*y}},60:function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},7:function(e,t,r){"use strict";r.d(t,"d",function(){return i}),r.d(t,"e",function(){return o}),r.d(t,"c",function(){return u}),r.d(t,"b",function(){return s}),r.d(t,"a",function(){return a});var n=r(0);
|
||
/**
|
||
* Hexadecimal functions.
|
||
*
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*/function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" ",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if(!e)return"";for(var n="",i=0;i<e.length;i++)n+=e[i].toString(16).padStart(r,"0")+t;return"0x"===t&&(n="0x"+n),"\\x"===t&&(n="\\x"+n),t.length?n.slice(0,-t.length):n}function o(e){if(!e)return"";for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Auto",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if("None"!==t){var i="Auto"===t?/[^a-f\d]/gi:n.a.regexRep(t);e=e.replace(i,"")}for(var o=[],u=0;u<e.length;u+=r)o.push(parseInt(e.substr(u,r),16));return o}var s=["Space","Comma","Semi-colon","Colon","Line feed","CRLF","0x","\\x","None"],a=["Auto"].concat(s)},775:function(e,t,r){"use strict";(function(e){var n=r(1),i=r(518),o=r.n(i),u=r(3);function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}
|
||
/**
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @copyright Crown Copyright 2018
|
||
* @license Apache-2.0
|
||
*/var h=function(t){function r(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(e=f(this,l(r).call(this))).name="BSON deserialise",e.module="BSON",e.description="BSON is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database. It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB. The name 'BSON' is based on the term JSON and stands for 'Binary JSON'.<br><br>Input data should be in a raw bytes format.",e.infoURL="https://wikipedia.org/wiki/BSON",e.inputType="ArrayBuffer",e.outputType="string",e.args=[],e}var i,s,h;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(r,n["a"]),i=r,(s=[{key:"run",value:function(t,r){if(!t.byteLength)return"";try{var n=o.a.deserialize(new e(t));return JSON.stringify(n,null,2)}catch(e){throw new u.a(e.toString())}}}])&&a(i.prototype,s),h&&a(i,h),r}();t.a=h}).call(this,r(5).Buffer)},9:function(e,t,r){"use strict";var n=r(0),i=r(12),o=r(4),u=r.n(o),s=r(14),a=r.n(s);function f(e,t,r,n,i,o,u){try{var s=e[o](u),a=s.value}catch(e){return void r(e)}s.done?t(a):Promise.resolve(a).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function u(e){f(o,n,i,u,s,"next",e)}function s(e){f(o,n,i,u,s,"throw",e)}u(void 0)})}}function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}
|
||
/**
|
||
* @author n1474335 [n1474335@gmail.com]
|
||
* @author Matt C [matt@artemisbot.uk]
|
||
* @copyright Crown Copyright 2016
|
||
* @license Apache-2.0
|
||
*/
|
||
var h=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.value=[],this.type=e.BYTE_ARRAY,t&&t.hasOwnProperty("value")&&t.hasOwnProperty("type")&&this.set(t.value,t.type)}var t,r,o;return t=e,r=[{key:"set",value:function(t,r){if("string"==typeof r&&(r=e.typeEnum(r)),a.a.debug("Dish type: "+e.enumLookup(r)),this.value=t,this.type=r,!this.valid()){var o=n.a.truncate(JSON.stringify(this.value),13);throw new i.a("Data is not a valid ".concat(e.enumLookup(r),": ").concat(o))}}},{key:"get",value:function(){var t=l(regeneratorRuntime.mark(function t(r){var n,i=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=i.length>1&&void 0!==i[1]&&i[1],"string"==typeof r&&(r=e.typeEnum(r)),this.type===r){t.next=5;break}return t.next=5,this._translate(r,n);case 5:return t.abrupt("return",this.value);case 6:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"_translate",value:function(){var t=l(regeneratorRuntime.mark(function t(r){var o,s,f=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:o=f.length>1&&void 0!==f[1]&&f[1],a.a.debug("Translating Dish from ".concat(e.enumLookup(this.type)," to ").concat(e.enumLookup(r))),s=o?n.a.byteArrayToChars:n.a.byteArrayToUtf8,t.prev=3,t.t0=this.type,t.next=t.t0===e.STRING?7:t.t0===e.NUMBER?9:t.t0===e.HTML?11:t.t0===e.ARRAY_BUFFER?13:t.t0===e.BIG_NUMBER?15:t.t0===e.JSON?17:t.t0===e.FILE?19:t.t0===e.LIST_FILE?24:30;break;case 7:return this.value=this.value?n.a.strToByteArray(this.value):[],t.abrupt("break",31);case 9:return this.value="number"==typeof this.value?n.a.strToByteArray(this.value.toString()):[],t.abrupt("break",31);case 11:return this.value=this.value?n.a.strToByteArray(n.a.unescapeHtml(n.a.stripHtmlTags(this.value,!0))):[],t.abrupt("break",31);case 13:return this.value=Array.prototype.slice.call(new Uint8Array(this.value)),t.abrupt("break",31);case 15:return this.value=u.a.isBigNumber(this.value)?n.a.strToByteArray(this.value.toFixed()):[],t.abrupt("break",31);case 17:return this.value=this.value?n.a.strToByteArray(JSON.stringify(this.value,null,4)):[],t.abrupt("break",31);case 19:return t.next=21,n.a.readFile(this.value);case 21:return this.value=t.sent,this.value=Array.prototype.slice.call(this.value),t.abrupt("break",31);case 24:return t.next=26,Promise.all(this.value.map(function(){var e=l(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.a.readFile(t));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()));case 26:return this.value=t.sent,this.value=this.value.map(function(e){return Array.prototype.slice.call(e)}),this.value=[].concat.apply([],this.value),t.abrupt("break",31);case 30:return t.abrupt("break",31);case 31:t.next=36;break;case 33:throw t.prev=33,t.t1=t.catch(3),new i.a("Error translating from ".concat(e.enumLookup(this.type)," to byteArray: ").concat(t.t1));case 36:this.type=e.BYTE_ARRAY,t.prev=37,t.t2=r,t.next=t.t2===e.STRING?41:t.t2===e.HTML?41:t.t2===e.NUMBER?44:t.t2===e.ARRAY_BUFFER?47:t.t2===e.BIG_NUMBER?50:t.t2===e.JSON?53:t.t2===e.FILE?56:t.t2===e.LIST_FILE?58:61;break;case 41:return this.value=this.value?s(this.value):"",this.type=e.STRING,t.abrupt("break",62);case 44:return this.value=this.value?parseFloat(s(this.value)):0,this.type=e.NUMBER,t.abrupt("break",62);case 47:return this.value=new Uint8Array(this.value).buffer,this.type=e.ARRAY_BUFFER,t.abrupt("break",62);case 50:try{this.value=new u.a(s(this.value))}catch(e){this.value=new u.a(NaN)}return this.type=e.BIG_NUMBER,t.abrupt("break",62);case 53:return this.value=JSON.parse(s(this.value)),this.type=e.JSON,t.abrupt("break",62);case 56:return this.value=new File(this.value,"unknown"),t.abrupt("break",62);case 58:return this.value=[new File(this.value,"unknown")],this.type=e.LIST_FILE,t.abrupt("break",62);case 61:return t.abrupt("break",62);case 62:t.next=67;break;case 64:throw t.prev=64,t.t3=t.catch(37),new i.a("Error translating from byteArray to ".concat(e.enumLookup(r),": ").concat(t.t3));case 67:case"end":return t.stop()}},t,this,[[3,33],[37,64]])}));return function(e){return t.apply(this,arguments)}}()},{key:"valid",value:function(){switch(this.type){case e.BYTE_ARRAY:if(!(this.value instanceof Array))return!1;for(var t=0;t<this.value.length;t++)if("number"!=typeof this.value[t]||this.value[t]<0||this.value[t]>255)return!1;return!0;case e.STRING:case e.HTML:return"string"==typeof this.value;case e.NUMBER:return"number"==typeof this.value;case e.ARRAY_BUFFER:return this.value instanceof ArrayBuffer;case e.BIG_NUMBER:return u.a.isBigNumber(this.value);case e.JSON:return!0;case e.FILE:return this.value instanceof File;case e.LIST_FILE:return this.value instanceof Array&&this.value.reduce(function(e,t){return e&&t instanceof File},!0);default:return!1}}},{key:"clone",value:function(){var t=new e;switch(this.type){case e.STRING:case e.HTML:case e.NUMBER:case e.BIG_NUMBER:t.set(this.value,this.type);break;case e.BYTE_ARRAY:case e.JSON:t.set(JSON.parse(JSON.stringify(this.value)),this.type);break;case e.ARRAY_BUFFER:t.set(this.value.slice(0),this.type);break;case e.FILE:t.set(new File([this.value],this.value.name,{type:this.value.type,lastModified:this.value.lastModified}),this.type);break;case e.LIST_FILE:t.set(this.value.map(function(e){return new File([e],e.name,{type:e.type,lastModified:e.lastModified})}),this.type);break;default:throw new i.a("Cannot clone Dish, unknown type")}return t}},{key:"size",get:function(){switch(this.type){case e.BYTE_ARRAY:case e.STRING:case e.HTML:return this.value.length;case e.NUMBER:case e.BIG_NUMBER:return this.value.toString().length;case e.ARRAY_BUFFER:return this.value.byteLength;case e.JSON:return JSON.stringify(this.value).length;case e.FILE:return this.value.size;case e.LIST_FILE:return this.value.reduce(function(e,t){return e+t.size},0);default:return-1}}}],o=[{key:"typeEnum",value:function(t){switch(t.toLowerCase()){case"bytearray":case"byte array":return e.BYTE_ARRAY;case"string":return e.STRING;case"number":return e.NUMBER;case"html":return e.HTML;case"arraybuffer":case"array buffer":return e.ARRAY_BUFFER;case"bignumber":case"big number":return e.BIG_NUMBER;case"json":return e.JSON;case"file":return e.FILE;case"list<file>":return e.LIST_FILE;default:throw new i.a("Invalid data type string. No matching enum.")}}},{key:"enumLookup",value:function(t){switch(t){case e.BYTE_ARRAY:return"byteArray";case e.STRING:return"string";case e.NUMBER:return"number";case e.HTML:return"html";case e.ARRAY_BUFFER:return"ArrayBuffer";case e.BIG_NUMBER:return"BigNumber";case e.JSON:return"JSON";case e.FILE:return"File";case e.LIST_FILE:return"List<File>";default:throw new i.a("Invalid data type enum. No matching type.")}}}],r&&c(t.prototype,r),o&&c(t,o),e}();h.BYTE_ARRAY=0,h.STRING=1,h.NUMBER=2,h.HTML=3,h.ARRAY_BUFFER=4,h.BIG_NUMBER=5,h.JSON=6,h.FILE=7,h.LIST_FILE=8,t.a=h}}); |